[Libreoffice-commits] core.git: 3 commits - include/oox oox/source sw/qa
Zolnai Tamás
tamas.zolnai at collabora.com
Fri Feb 21 00:43:27 PST 2014
include/oox/drawingml/textfont.hxx | 3
oox/source/drawingml/shape.cxx | 5 +
oox/source/drawingml/textcharacterpropertiescontext.cxx | 12 +++
oox/source/drawingml/textfont.cxx | 8 ++
oox/source/export/drawingml.cxx | 16 +++-
sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx |binary
sw/qa/extras/ooxmlexport/data/nested-text-frames.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 44 +++++++++++--
sw/qa/extras/ooxmlimport/data/dml-groupshape-runfonts.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 10 ++
10 files changed, 88 insertions(+), 10 deletions(-)
New commits:
commit b733190b0eae3177a30e09054a764eed4f616ba2
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Thu Feb 20 11:57:09 2014 +0100
DOCX export tests: increase strength of testing nested text frames
Change-Id: I370f22ee948f5a760ba01c98a8cfb5fac96f98b7
diff --git a/sw/qa/extras/ooxmlexport/data/nested-text-frames.odt b/sw/qa/extras/ooxmlexport/data/nested-text-frames.odt
index 4c38e1f..d2106f9 100644
Binary files a/sw/qa/extras/ooxmlexport/data/nested-text-frames.odt and b/sw/qa/extras/ooxmlexport/data/nested-text-frames.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index bda5ea0..c68d3df 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3280,11 +3280,21 @@ DECLARE_OOXMLEXPORT_TEST(testNestedTextFrames, "nested-text-frames.odt")
// First problem was LO crashed during export (crash test)
// Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word.
- // So test that all three exported text boxes are on the same level
- xmlDocPtr pXmlDoc = parseExport("word/document.xml");
- if (!pXmlDoc)
- return;
- assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/w:t", 3);
+ // Test that all three exported text boxes are anchored to the same paragraph and not each other.
+ uno::Reference<text::XTextContent> xTextContent(getShape(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
+
+ xTextContent.set(getShape(2), uno::UNO_QUERY);
+ xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
+ xText.set(xRange->getText(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
+
+ xTextContent.set(getShape(3), uno::UNO_QUERY);
+ xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
+ xText.set(xRange->getText(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
}
DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.docx")
commit 756d0b1dff3cb5c3cab10c1f14e4dae6ac3ba135
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Thu Feb 20 13:22:33 2014 +0100
drawingML import: run fonts inside group shape
Change-Id: Ib54fe868c11c0c22b85d8821fa7274c80918362c
diff --git a/include/oox/drawingml/textfont.hxx b/include/oox/drawingml/textfont.hxx
index a069057..d3361fc 100644
--- a/include/oox/drawingml/textfont.hxx
+++ b/include/oox/drawingml/textfont.hxx
@@ -39,6 +39,9 @@ public:
/** Sets attributes from the passed attribute list. */
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. */
void assignIfUsed( const TextFont& rTextFont );
diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index 36bd255..8b6156e 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -132,6 +132,18 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
return new HyperLinkContext( *this, rAttribs, mrTextCharacterProperties.maHyperlinkPropertyMap );
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;
case OOX_TOKEN( doc, b ):
mrTextCharacterProperties.moBold = rAttribs.getBool(OOX_TOKEN( doc, val ), true);
diff --git a/oox/source/drawingml/textfont.cxx b/oox/source/drawingml/textfont.cxx
index 553f5ae..239c087 100644
--- a/oox/source/drawingml/textfont.cxx
+++ b/oox/source/drawingml/textfont.cxx
@@ -65,6 +65,14 @@ void TextFont::setAttributes( const AttributeList& rAttribs )
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 )
{
if( !rTextFont.maTypeface.isEmpty() )
diff --git a/sw/qa/extras/ooxmlimport/data/dml-groupshape-runfonts.docx b/sw/qa/extras/ooxmlimport/data/dml-groupshape-runfonts.docx
new file mode 100644
index 0000000..e4c8c6c
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/dml-groupshape-runfonts.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index acfe4ea..5f41a1d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1881,6 +1881,16 @@ DECLARE_OOXMLIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.docx")
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
CPPUNIT_PLUGIN_IMPLEMENT();
commit 191f648ffd97b58f57afca65961e5dbcc2bbe724
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Thu Feb 20 11:48:35 2014 +0100
drawingML export: gradient fill defined by imported theme
Plus avoid writing out empty <a:gradFill></a:gradFill>.
Change-Id: I50fa92b2cc30eedfe28a8c6af697d43d98a3aee8
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b302010..9066d44 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -853,7 +853,10 @@ Reference< XShape > Shape::createAndInsert(
PUT_PROP( aGradientStops, i, OUString::number( i ), aGradientStop );
++aIt;
}
- putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) );
+ // If getFillProperties.moFillType is unused that means gradient is defined by a theme
+ // which is already saved into StyleFillRef property, so no need to save the explicit values too
+ if( getFillProperties().moFillType.has() )
+ putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) );
putPropertyToGrabBag( "OriginalGradFill", Any( aShapeProps[PROP_FillGradient] ) );
}
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8ff54aa..e019ed6 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -339,15 +339,23 @@ void DrawingML::WriteGradientFill( Reference< XPropertySet > rXPropSet )
aGrabBag[i].Value >>= aOriginalGradient;
}
- mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
// check if an ooxml gradient had been imported and if the user has modified it
- if( aGradientStops.hasElements() && EqualGradients( aOriginalGradient, aGradient ) )
+ if( EqualGradients( aOriginalGradient, aGradient ) )
{
- WriteGrabBagGradientFill(aGradientStops, aGradient);
+ // If we have no gradient stops that means original gradient were defined by a theme.
+ if( aGradientStops.hasElements() )
+ {
+ mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
+ WriteGrabBagGradientFill(aGradientStops, aGradient);
+ mpFS->endElementNS( XML_a, XML_gradFill );
+ }
}
else
+ {
+ mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
WriteGradientFill(aGradient);
- mpFS->endElementNS( XML_a, XML_gradFill );
+ mpFS->endElementNS( XML_a, XML_gradFill );
+ }
}
}
diff --git a/sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx b/sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx
new file mode 100644
index 0000000..3311ce8
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index dc434a3..bda5ea0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3318,6 +3318,30 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childpo
CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -2119 : -2121), xChildGroup->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 14028 : 14025), xChildGroup->getPosition().Y);
}
+
+DECLARE_OOXMLEXPORT_TEST(testDMLGradientFillTheme, "dml-gradientfill-theme.docx")
+{
+ // Problem was when a fill gradient was imported from a theme, (fillRef in ooxml)
+ // not just the theme was written out but the explicit values too
+ // Besides the duplication of values it causes problems with writing out
+ // <a:schemeClr val="phClr"> into document.xml, while phClr can be used just for theme definitions.
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ // check no explicit gradFill has been exported
+ assertXPath(pXmlDoc,
+ "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill",
+ 0);
+
+ // check shape style has been exported
+ assertXPath(pXmlDoc,
+ "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef",
+ "idx", "2");
+ assertXPath(pXmlDoc,
+ "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef/a:schemeClr",
+ "val", "accent1");
+}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list