Kaydet (Commit) 756d0b1d authored tarafından Zolnai Tamás's avatar Zolnai Tamás

drawingML import: run fonts inside group shape

Change-Id: Ib54fe868c11c0c22b85d8821fa7274c80918362c
üst 191f648f
...@@ -39,6 +39,9 @@ public: ...@@ -39,6 +39,9 @@ public:
/** Sets attributes from the passed attribute list. */ /** Sets attributes from the passed attribute list. */
void setAttributes( const AttributeList& rAttribs ); void setAttributes( const AttributeList& rAttribs );
/** Sets font name and init other attributes. */
void setAttributes( const OUString& rFontName );
/** Overwrites this text font with the passed text font, if it is used. */ /** Overwrites this text font with the passed text font, if it is used. */
void assignIfUsed( const TextFont& rTextFont ); void assignIfUsed( const TextFont& rTextFont );
......
...@@ -132,6 +132,18 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl ...@@ -132,6 +132,18 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
return new HyperLinkContext( *this, rAttribs, mrTextCharacterProperties.maHyperlinkPropertyMap ); return new HyperLinkContext( *this, rAttribs, mrTextCharacterProperties.maHyperlinkPropertyMap );
case OOX_TOKEN( doc, rFonts ): case OOX_TOKEN( doc, rFonts ):
if( rAttribs.hasAttribute(OOX_TOKEN(doc, ascii)) )
{
mrTextCharacterProperties.maLatinFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, ascii), OUString()));
}
if( rAttribs.hasAttribute(OOX_TOKEN(doc, cs)) )
{
mrTextCharacterProperties.maComplexFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, cs), OUString()));
}
if( rAttribs.hasAttribute(OOX_TOKEN(doc, eastAsia)) )
{
mrTextCharacterProperties.maAsianFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, eastAsia), OUString()));
}
break; break;
case OOX_TOKEN( doc, b ): case OOX_TOKEN( doc, b ):
mrTextCharacterProperties.moBold = rAttribs.getBool(OOX_TOKEN( doc, val ), true); mrTextCharacterProperties.moBold = rAttribs.getBool(OOX_TOKEN( doc, val ), true);
......
...@@ -65,6 +65,14 @@ void TextFont::setAttributes( const AttributeList& rAttribs ) ...@@ -65,6 +65,14 @@ void TextFont::setAttributes( const AttributeList& rAttribs )
mnCharset = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT ); mnCharset = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT );
} }
void TextFont::setAttributes( const OUString& sFontName )
{
maTypeface = sFontName;
maPanose = OUString();
mnPitch = 0;
mnCharset = WINDOWS_CHARSET_DEFAULT;
}
void TextFont::assignIfUsed( const TextFont& rTextFont ) void TextFont::assignIfUsed( const TextFont& rTextFont )
{ {
if( !rTextFont.maTypeface.isEmpty() ) if( !rTextFont.maTypeface.isEmpty() )
......
...@@ -1881,6 +1881,16 @@ DECLARE_OOXMLIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.docx") ...@@ -1881,6 +1881,16 @@ DECLARE_OOXMLIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.docx")
CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<sal_Int16>(getRun(xParagraph, 1), "CharUnderline")); CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<sal_Int16>(getRun(xParagraph, 1), "CharUnderline"));
} }
DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeRunFonts, "dml-groupshape-runfonts.docx")
{
// Fonts defined by w:rFonts was not imported and so the font specified by a:fontRef was used.
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName"));
CPPUNIT_ASSERT_EQUAL(OUString("Arial Unicode MS"), getProperty<OUString>(xRun, "CharFontNameComplex"));
CPPUNIT_ASSERT_EQUAL(OUString("MS Mincho"), getProperty<OUString>(xRun, "CharFontNameAsian"));
}
#endif #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment