1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <swmodeltestbase.hxx>
12 #include <tools/UnitConversion.hxx>
14 #include <com/sun/star/awt/XBitmap.hpp>
15 #include <com/sun/star/drawing/FillStyle.hpp>
16 #include <com/sun/star/drawing/LineStyle.hpp>
17 #include <com/sun/star/awt/Gradient2.hpp>
18 #include <com/sun/star/style/TabStop.hpp>
19 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
20 #include <com/sun/star/text/RelOrientation.hpp>
21 #include <com/sun/star/text/XTextTable.hpp>
22 #include <com/sun/star/text/XTextFramesSupplier.hpp>
23 #include <com/sun/star/style/LineSpacing.hpp>
24 #include <com/sun/star/style/LineSpacingMode.hpp>
25 #include <com/sun/star/table/ShadowFormat.hpp>
26 #include <com/sun/star/text/WritingMode2.hpp>
27 #include <com/sun/star/text/WrapTextMode.hpp>
28 #include <com/sun/star/text/XTextDocument.hpp>
29 #include <com/sun/star/text/XTextTablesSupplier.hpp>
30 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
31 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
32 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
34 #include <oox/drawingml/drawingmltypes.hxx>
35 #include <basegfx/utils/gradienttools.hxx>
36 #include <docmodel/uno/UnoGradientTools.hxx>
38 class Test
: public SwModelTestBase
41 Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
44 CPPUNIT_TEST_FIXTURE(Test
, testPageGraphicBackground
)
46 loadAndReload("page-graphic-background.odt");
47 validate(maTempFile
.GetFileName(), test::OOXML
);
48 CPPUNIT_ASSERT_EQUAL(1, getPages());
49 // No idea how the graphic background should be exported (seems there is no
50 // way to do a non-tiling export to OOXML), but at least the background
51 // color shouldn't be black.
52 uno::Reference
<beans::XPropertySet
> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
53 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty
<sal_Int32
>(xPageStyle
, "BackColor"));
57 CPPUNIT_TEST_FIXTURE(Test
, testCustomProperties
)
59 loadAndSave("custom-properties.docx");
60 // tdf#133377 tdf#103987 FILESAVE XLSX: Make sure the custom/core/application
61 // file properties are stored correctly after roundtrip to .docx
63 // Extended file properties - specific to Office package,
64 // eg. docx - Number of Pages, pptx - Number of Slides
65 xmlDocUniquePtr pXmlDoc
= parseExport("docProps/app.xml");
66 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Paragraphs", "1");
67 //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Lines", "1");
68 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Pages", "1");
69 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Words", "3");
70 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Characters", "22");
71 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:CharactersWithSpaces", "24");
72 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Company", "hhhhkompany");
73 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Manager", "ffffmenadzer;iiiiisecondmanager");
74 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:HyperlinkBase", "gggghiperlink");
75 //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:DocSecurity", "2");
76 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:AppVersion", "15.0000");
78 // Custom file properties - defined by user
79 xmlDocUniquePtr pCustomXml
= parseExport("docProps/custom.xml");
80 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property", 9);
81 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[1]",
82 "name", "testDateProperty");
83 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[1]/vt:filetime",
84 "1982-04-19T10:00:00Z");
85 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[3]",
86 "name", "testNegativeNumberProperty");
87 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[3]/vt:r8",
89 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[4]",
90 "name", "testNumberProperty");
91 //assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[4]/vt:i4",
93 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[5]",
94 "name", "testRealNumberProperty");
95 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[5]/vt:r8",
97 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[6]",
98 "name", "testScientificNumber");
99 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[6]/vt:r8",
101 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[7]",
102 "name", "testTextProperty");
103 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[7]/vt:lpwstr",
104 "testPropertyValue");
105 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[8]",
106 "name", "testYesNoProperty");
107 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[8]/vt:bool",
109 // Hidden Custom File Property. With Final set, MS Office notifies recipients that the document is final, and sets the document to read-only.
110 assertXPath(pCustomXml
, "/custom-properties:Properties/custom-properties:property[9]",
111 "name", "_MarkAsFinal");
112 assertXPathContent(pCustomXml
, "/custom-properties:Properties/custom-properties:property[9]/vt:bool",
115 // Core file properties - common for all packages (eg. creation date, modify date)
116 pXmlDoc
= parseExport("docProps/core.xml");
117 assertXPathContent(pXmlDoc
, "/cp:coreProperties/dc:creator", "Bartosz Kosiorek;secondauthor");
118 assertXPathContent(pXmlDoc
, "/cp:coreProperties/dc:description", "cccckomentarzglowny");
119 assertXPathContent(pXmlDoc
, "/cp:coreProperties/cp:lastPrinted", "2020-10-15T07:42:00Z");
120 assertXPathContent(pXmlDoc
, "/cp:coreProperties/dcterms:created", "2020-10-14T16:23:00Z");
121 assertXPathContent(pXmlDoc
, "/cp:coreProperties/cp:category", "eeeetokategoria");
122 assertXPathContent(pXmlDoc
, "/cp:coreProperties/cp:version", "xxxxversion");
123 assertXPathContent(pXmlDoc
, "/cp:coreProperties/cp:contentStatus", "ddddstatusnieznany");
124 assertXPathContent(pXmlDoc
, "/cp:coreProperties/dc:identifier", "zzzzidentifier");
127 DECLARE_OOXMLEXPORT_TEST(testUTF8CustomProperties
, "tdf127864.docx")
129 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(
130 mxComponent
, uno::UNO_QUERY
);
131 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
132 = xDocumentPropertiesSupplier
->getDocumentProperties();
133 uno::Reference
<beans::XPropertySet
> xPropertySet(
134 xDocumentProperties
->getUserDefinedProperties(), uno::UNO_QUERY
);
135 CPPUNIT_ASSERT_EQUAL(OUString(u
"первый"), getProperty
<OUString
>(xPropertySet
, u
"первый"));
138 DECLARE_OOXMLEXPORT_TEST(testKeywords
, "tdf143175.docx")
140 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(
141 mxComponent
, uno::UNO_QUERY
);
142 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
143 = xDocumentPropertiesSupplier
->getDocumentProperties();
144 uno::Sequence
<OUString
> aKeywords(xDocumentProperties
->getKeywords());
145 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aKeywords
.getLength());
146 CPPUNIT_ASSERT_EQUAL(OUString("One"), aKeywords
[0]);
147 CPPUNIT_ASSERT_EQUAL(OUString("Two"), aKeywords
[1]);
148 CPPUNIT_ASSERT_EQUAL(OUString("Three"), aKeywords
[2]);
151 DECLARE_OOXMLEXPORT_TEST(testZoom
, "zoom.docx")
153 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
154 uno::Reference
<view::XViewSettingsSupplier
> xViewSettingsSupplier(xModel
->getCurrentController(), uno::UNO_QUERY
);
155 uno::Reference
<beans::XPropertySet
> xPropertySet(xViewSettingsSupplier
->getViewSettings());
156 sal_Int16 nValue
= 0;
157 xPropertySet
->getPropertyValue("ZoomValue") >>= nValue
;
158 CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue
);
160 // Validation test: order of elements were wrong.
163 validate(maTempFile
.GetFileName(), test::OOXML
);
164 xmlDocUniquePtr pXmlDoc
= parseExport("word/styles.xml");
165 // Order was: rsid, next.
166 int nNext
= getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "next");
167 int nRsid
= getXPathPosition(pXmlDoc
, "/w:styles/w:style[3]", "rsid");
168 CPPUNIT_ASSERT(nNext
< nRsid
);
170 pXmlDoc
= parseExport("docProps/app.xml");
171 // One paragraph in the document.
172 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Paragraphs", "1");
173 assertXPathContent(pXmlDoc
, "/extended-properties:Properties/extended-properties:Company", "Example Ltd");
176 CPPUNIT_TEST_FIXTURE(Test
, defaultTabStopNotInStyles
)
178 loadAndReload("empty.odt");
179 validate(maTempFile
.GetFileName(), test::OOXML
);
180 CPPUNIT_ASSERT_EQUAL(1, getPages());
181 // The default tab stop was mistakenly exported to a style.
182 // xray ThisComponent.StyleFamilies(1)(0).ParaTabStop
183 uno::Reference
< container::XNameAccess
> paragraphStyles
= getStyles( "ParagraphStyles" );
184 uno::Sequence
< style::TabStop
> stops
= getProperty
< uno::Sequence
< style::TabStop
> >(
185 paragraphStyles
->getByName( "Standard" ), "ParaTabStops" );
186 // There actually be one tab stop, but it will be the default.
187 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32
>(1), stops
.getLength());
188 CPPUNIT_ASSERT_EQUAL( style::TabAlign_DEFAULT
, stops
[ 0 ].Alignment
);
191 DECLARE_OOXMLEXPORT_TEST(testFdo38244
, "fdo38244.docx")
194 * Comments attached to a range was imported without the range, check for the annotation mark start/end positions.
196 * oParas = ThisComponent.Text.createEnumeration
197 * oPara = oParas.nextElement
198 * oRuns = oPara.createEnumeration
199 * oRun = oRuns.nextElement
200 * oRun = oRuns.nextElement 'Annotation
201 * oRun = oRuns.nextElement
202 * oRun = oRuns.nextElement 'AnnotationEnd
203 * xray oRun.TextPortionType
205 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
206 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
207 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
208 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParaEnum
->nextElement(), uno::UNO_QUERY
);
209 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
210 xRunEnum
->nextElement();
211 uno::Reference
<beans::XPropertySet
> xPropertySet(xRunEnum
->nextElement(), uno::UNO_QUERY
);
212 CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty
<OUString
>(xPropertySet
, "TextPortionType"));
213 xRunEnum
->nextElement();
214 xPropertySet
.set(xRunEnum
->nextElement(), uno::UNO_QUERY
);
215 CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty
<OUString
>(xPropertySet
, "TextPortionType"));
218 * Initials were not imported.
220 * oFields = ThisComponent.TextFields.createEnumeration
221 * oField = oFields.nextElement
222 * xray oField.Initials
224 uno::Reference
<text::XTextFieldsSupplier
> xTextFieldsSupplier(mxComponent
, uno::UNO_QUERY
);
225 uno::Reference
<container::XEnumerationAccess
> xFieldsAccess(xTextFieldsSupplier
->getTextFields());
226 uno::Reference
<container::XEnumeration
> xFields(xFieldsAccess
->createEnumeration());
227 xPropertySet
.set(xFields
->nextElement(), uno::UNO_QUERY
);
228 CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty
<OUString
>(xPropertySet
, "Initials"));
231 * There was a fake empty paragraph at the end of the comment text.
233 * oFields = ThisComponent.TextFields.createEnumeration
234 * oField = oFields.nextElement
235 * oParas = oField.TextRange.createEnumeration
236 * oPara = oParas.nextElement
237 * oPara = oParas.nextElement
240 xParaEnumAccess
= getProperty
< uno::Reference
<container::XEnumerationAccess
> >(xPropertySet
, "TextRange");
241 xParaEnum
= xParaEnumAccess
->createEnumeration();
242 xParaEnum
->nextElement();
243 CPPUNIT_ASSERT(!xParaEnum
->hasMoreElements());
246 validate(maTempFile
.GetFileName(), test::OOXML
);
249 CPPUNIT_TEST_FIXTURE(Test
, testCommentsNested
)
251 loadAndReload("comments-nested.odt");
252 validate(maTempFile
.GetFileName(), test::OOXML
);
253 CPPUNIT_ASSERT_EQUAL(1, getPages());
254 uno::Reference
<beans::XPropertySet
> xOuter
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getRun(getParagraph(1), 2), "TextField");
255 CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty
<OUString
>(xOuter
, "Content"));
257 uno::Reference
<beans::XPropertySet
> xInner
= getProperty
< uno::Reference
<beans::XPropertySet
> >(getRun(getParagraph(1), 4), "TextField");
258 CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty
<OUString
>(xInner
, "Content"));
261 CPPUNIT_TEST_FIXTURE(Test
, testMathEscape
)
263 loadAndReload("math-escape.docx");
264 CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
267 CPPUNIT_TEST_FIXTURE(Test
, testFdo51034
)
269 loadAndReload("fdo51034.odt");
270 CPPUNIT_ASSERT_EQUAL(1, getPages());
271 // The problem was that the 'l' param of the HYPERLINK field was parsed with = "#", not += "#".
272 CPPUNIT_ASSERT_EQUAL(OUString("http://Www.google.com/#a"), getProperty
<OUString
>(getRun(getParagraph(1), 1), "HyperLinkURL"));
275 // Remove all spaces, as LO export/import may change that.
276 // Replace symbol - (i.e. U+2212) with ASCII - , LO does this change and it shouldn't matter.
277 static void CHECK_FORMULA(OUString
const & expected
, OUString
const & actual
) {
278 CPPUNIT_ASSERT_EQUAL(
279 expected
.replaceAll( " ", "" ).replaceAll( u
"\u2212", "-" ),
280 actual
.replaceAll( " ", "" ).replaceAll( u
"\u2212", "-" ));
283 DECLARE_OOXMLEXPORT_TEST(testMathAccents
, "math-accents.docx")
286 "acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a}"
287 " widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}",
288 getFormula( getRun( getParagraph( 1 ), 1 )));
291 DECLARE_OOXMLEXPORT_TEST(testMathD
, "math-d.docx")
293 CHECK_FORMULA( "left (x mline y mline z right )", getFormula( getRun( getParagraph( 1 ), 1 )));
294 CHECK_FORMULA( "left (1 right )", getFormula( getRun( getParagraph( 1 ), 2 )));
295 CHECK_FORMULA( "left [2 right ]", getFormula( getRun( getParagraph( 1 ), 3 )));
296 CHECK_FORMULA( "left ldbracket 3 right rdbracket", getFormula( getRun( getParagraph( 1 ), 4 )));
297 CHECK_FORMULA( "left lline 4 right rline", getFormula( getRun( getParagraph( 1 ), 5 )));
298 CHECK_FORMULA( "left ldline 5 right rdline", getFormula( getRun( getParagraph( 1 ), 6 )));
299 CHECK_FORMULA( "left langle 6 right rangle", getFormula( getRun( getParagraph( 1 ), 7 )));
300 CHECK_FORMULA( "left langle a mline b right rangle", getFormula( getRun( getParagraph( 1 ), 8 )));
301 CHECK_FORMULA( "left ({x} over {y} right )", getFormula( getRun( getParagraph( 1 ), 9 )));
304 DECLARE_OOXMLEXPORT_TEST(testMathEscaping
, "math-escaping.docx")
306 CHECK_FORMULA( u
"\u2212 \u221E < x < \u221E", getFormula( getRun( getParagraph( 1 ), 1 )));
309 DECLARE_OOXMLEXPORT_TEST(testMathLim
, "math-lim.docx")
311 CHECK_FORMULA( u
"lim from {x \u2192 1} {x}", getFormula( getRun( getParagraph( 1 ), 1 )));
314 DECLARE_OOXMLEXPORT_TEST(testMathMatrix
, "math-matrix.docx")
316 CHECK_FORMULA( "left [matrix {1 # 2 ## 3 # 4} right ]", getFormula( getRun( getParagraph( 1 ), 1 )));
319 CPPUNIT_TEST_FIXTURE(Test
, testMathMso2k7
)
321 loadAndReload("math-mso2k7.docx");
322 CHECK_FORMULA( u
"A = \u03C0 {r} ^ {2}", getFormula( getRun( getParagraph( 1 ), 1 )));
323 // TODO check the stack/binom difference
324 // CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}",
325 CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}",
326 getFormula( getRun( getParagraph( 2 ), 1 )));
327 CHECK_FORMULA( u
"{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left (n-1 right ) {x} ^ {2}} over {2!} +\u2026",
328 getFormula( getRun( getParagraph( 3 ), 1 )));
329 // TODO check (cos/sin miss {})
330 // CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {{n\xcf\x80x} over {L}} + {b} rsub {n} sin {{n\xcf\x80x} over {L}} right )}",
331 CHECK_FORMULA( u
"f left (x right ) = {a} rsub {0} + sum from {n=1} to {\u221E} {left ({a} rsub {n} cos {n\u03C0x} over {L} + {b} rsub {n} sin {n\u03C0x} over {L} right )}",
332 getFormula( getRun( getParagraph( 4 ), 1 )));
333 CHECK_FORMULA( "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}", getFormula( getRun( getParagraph( 5 ), 1 )));
334 CHECK_FORMULA( u
"x = {- b \u00B1 sqrt {{b} ^ {2} -4 ac}} over {2 a}",
335 getFormula( getRun( getParagraph( 6 ), 1 )));
337 u
"{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} over {3!} +\u2026, -\u221E<x<\u221E",
338 getFormula( getRun( getParagraph( 7 ), 1 )));
340 // "sin {\xce\xb1} \xc2\xb1 sin {\xce\xb2} =2 sin {{1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )}",
341 // TODO check (cos/in miss {})
342 u
"sin \u03B1 \u00B1 sin \u03B2 =2 sin {1} over {2} left (\u03B1\u00B1\u03B2 right ) cos {1} over {2} left (\u03B1\u2213\u03B2 right )",
343 getFormula( getRun( getParagraph( 8 ), 1 )));
345 // "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left (\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}",
346 // TODO check (cos/sin miss {})
347 u
"cos \u03B1 + cos \u03B2 =2 cos {1} over {2} left (\u03B1+\u03B2 right ) cos {1} over {2} left (\u03B1-\u03B2 right )",
348 getFormula( getRun( getParagraph( 9 ), 1 )));
351 DECLARE_OOXMLEXPORT_TEST(testMathNary
, "math-nary.docx")
353 CHECK_FORMULA( "lllint from {1} to {2} {x + 1}", getFormula( getRun( getParagraph( 1 ), 1 )));
354 CHECK_FORMULA( "prod from {a} {b}", getFormula( getRun( getParagraph( 1 ), 2 )));
355 CHECK_FORMULA( "sum to {2} {x}", getFormula( getRun( getParagraph( 1 ), 3 )));
358 DECLARE_OOXMLEXPORT_TEST(testMathOverbraceUnderbrace
, "math-overbrace_underbrace.docx")
360 CHECK_FORMULA( "{abcd} overbrace {4}", getFormula( getRun( getParagraph( 1 ), 1 )));
361 CHECK_FORMULA( "{xyz} underbrace {3}", getFormula( getRun( getParagraph( 2 ), 1 )));
364 DECLARE_OOXMLEXPORT_TEST(testMathOverstrike
, "math-overstrike.docx")
366 CHECK_FORMULA( "overstrike {abc}", getFormula( getRun( getParagraph( 1 ), 1 )));
369 DECLARE_OOXMLEXPORT_TEST(testMathPlaceholders
, "math-placeholders.docx")
371 CHECK_FORMULA( "sum from <?> to <?> <?>", getFormula( getRun( getParagraph( 1 ), 1 )));
374 DECLARE_OOXMLEXPORT_TEST(testMathRad
, "math-rad.docx")
376 CHECK_FORMULA( "sqrt {4}", getFormula( getRun( getParagraph( 1 ), 1 )));
377 CHECK_FORMULA( "nroot {3} {x + 1}", getFormula( getRun( getParagraph( 1 ), 2 )));
380 DECLARE_OOXMLEXPORT_TEST(testMathSubscripts
, "math-subscripts.docx")
382 CHECK_FORMULA( "{x} ^ {y} + {e} ^ {x}", getFormula( getRun( getParagraph( 1 ), 1 )));
383 CHECK_FORMULA( "{x} ^ {b}", getFormula( getRun( getParagraph( 1 ), 2 )));
384 CHECK_FORMULA( "{x} rsub {b}", getFormula( getRun( getParagraph( 1 ), 3 )));
385 CHECK_FORMULA( "{a} rsub {c} rsup {b}", getFormula( getRun( getParagraph( 1 ), 4 )));
386 CHECK_FORMULA( "{x} lsub {2} lsup {1}", getFormula( getRun( getParagraph( 1 ), 5 )));
387 CHECK_FORMULA( "{{x csup {6} csub {3}} lsub {4} lsup {5}} rsub {2} rsup {1}",
388 getFormula( getRun( getParagraph( 1 ), 6 )));
391 DECLARE_OOXMLEXPORT_TEST(testMathVerticalStacks
, "math-vertical_stacks.docx")
393 CHECK_FORMULA( "{a} over {b}", getFormula( getRun( getParagraph( 1 ), 1 )));
394 CHECK_FORMULA( "{a} / {b}", getFormula( getRun( getParagraph( 2 ), 1 )));
396 // CHECK_FORMULA( "binom {a} {b}", getFormula( getRun( getParagraph( 3 ), 1 )));
397 // CHECK_FORMULA( "binom {a} {binom {b} {c}}", getFormula( getRun( getParagraph( 4 ), 1 )));
400 CPPUNIT_TEST_FIXTURE(Test
, testTable
)
402 loadAndReload("table.odt");
403 CPPUNIT_ASSERT_EQUAL(1, getPages());
404 // Make sure we write qFormat for well-known style names.
405 xmlDocUniquePtr pXmlDocCT
= parseExport("word/styles.xml");
406 CPPUNIT_ASSERT(pXmlDocCT
);
407 assertXPath(pXmlDocCT
, "//w:style[@w:styleId='Normal']/w:qFormat", 1);
412 struct SingleLineBorders
{
413 sal_Int16 top
, bottom
, left
, right
;
414 SingleLineBorders(int t
=0, int b
=0, int l
=0, int r
=0)
415 : top(t
), bottom(b
), left(l
), right(r
) {}
416 sal_Int16
getBorder(int i
) const
420 case 1: return bottom
;
422 case 3: return right
;
423 default: assert(false); return 0;
430 DECLARE_OOXMLEXPORT_TEST(testTableBorders
, "table-borders.docx")
432 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
433 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables( ), uno::UNO_QUERY
);
434 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables
->getCount());
435 uno::Reference
<text::XTextTable
> xTextTable (xTables
->getByIndex(0), uno::UNO_QUERY
);
437 std::map
<OUString
, SingleLineBorders
> cellBorders
;
438 cellBorders
[OUString("A1")] = SingleLineBorders(106, 106, 106, 106);
439 cellBorders
[OUString("B1")] = SingleLineBorders(106, 0, 106, 35);
440 cellBorders
[OUString("C1")] = SingleLineBorders(106, 106, 35, 106);
441 cellBorders
[OUString("A2")] = SingleLineBorders(106, 35, 106, 0);
442 cellBorders
[OUString("B2")] = SingleLineBorders(0, 0, 0, 0);
443 cellBorders
[OUString("C2")] = SingleLineBorders(106, 106, 0, 106);
444 cellBorders
[OUString("A3")] = SingleLineBorders(35, 35, 106, 106);
445 cellBorders
[OUString("B3")] = SingleLineBorders(0, 106, 106, 106);
446 cellBorders
[OUString("C3")] = SingleLineBorders(106, 106, 106, 106);
447 cellBorders
[OUString("A4")] = SingleLineBorders(35, 106, 106, 35);
448 cellBorders
[OUString("B4")] = SingleLineBorders(106, 106, 35, 106);
449 cellBorders
[OUString("C4")] = SingleLineBorders(106, 106, 106, 106);
451 const OUString borderNames
[] = {
452 OUString("TopBorder"),
453 OUString("BottomBorder"),
454 OUString("LeftBorder"),
455 OUString("RightBorder"),
458 uno::Sequence
<OUString
> const cells
= xTextTable
->getCellNames();
459 sal_Int32 nLength
= cells
.getLength();
460 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(cellBorders
.size()), nLength
);
462 for (sal_Int32 i
= 0; i
< nLength
; ++i
)
464 uno::Reference
<table::XCell
> xCell
= xTextTable
->getCellByName(cells
[i
]);
465 uno::Reference
< beans::XPropertySet
> xPropSet(xCell
, uno::UNO_QUERY_THROW
);
466 const SingleLineBorders
& borders
= cellBorders
[cells
[i
]];
468 for (sal_Int32 j
= 0; j
< 4; ++j
)
470 uno::Any aBorder
= xPropSet
->getPropertyValue(borderNames
[j
]);
471 table::BorderLine aBorderLine
;
472 if (aBorder
>>= aBorderLine
)
474 std::stringstream message
;
475 message
<< cells
[i
] << "'s " << borderNames
[j
] << " is incorrect";
476 CPPUNIT_ASSERT_EQUAL_MESSAGE(message
.str(),
477 borders
.getBorder(j
), aBorderLine
.OuterLineWidth
);
483 CPPUNIT_TEST_FIXTURE(Test
, testFdo51550
)
485 loadAndReload("fdo51550.odt");
486 CPPUNIT_ASSERT_EQUAL(1, getShapes());
487 CPPUNIT_ASSERT_EQUAL(1, getPages());
488 // The problem was that we lacked the fallback to export the replacement
489 // graphic for OLE objects. But we can actually export the OLE itself now,
490 // so check that instead.
491 uno::Reference
<text::XTextEmbeddedObjectsSupplier
> xTextEmbeddedObjectsSupplier(mxComponent
, uno::UNO_QUERY
);
492 uno::Reference
<container::XIndexAccess
> xEmbeddedObjects(xTextEmbeddedObjectsSupplier
->getEmbeddedObjects(), uno::UNO_QUERY
);
493 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects
->getCount());
495 xmlDocUniquePtr pXmlDocCT
= parseExport("[Content_Types].xml");
498 return; // initial import
500 assertXPath(pXmlDocCT
, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xlsx']", "ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
502 // check the rels too
503 xmlDocUniquePtr pXmlDocRels
= parseExport("word/_rels/document.xml.rels");
504 assertXPath(pXmlDocRels
,
505 "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsx']",
507 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
508 // check the content too
509 xmlDocUniquePtr pXmlDocContent
= parseExport("word/document.xml");
510 assertXPath(pXmlDocContent
,
511 "/w:document/w:body/w:p/w:r/w:object/o:OLEObject",
516 DECLARE_OOXMLEXPORT_TEST(test1Table1Page
, "1-table-1-page.docx")
518 // 2 problem for this document after export:
519 // - invalid sectPr inserted at the beginning of the page
520 // - font of empty cell is not preserved, leading to change in rows height
521 CPPUNIT_ASSERT_EQUAL(1, getPages());
524 CPPUNIT_TEST_FIXTURE(Test
, testTextFrames
)
526 loadAndReload("textframes.odt");
527 CPPUNIT_ASSERT_EQUAL(1, getPages());
528 // The frames were simply missing, so let's check if all 3 frames were imported back.
529 CPPUNIT_ASSERT_EQUAL(3, getShapes());
532 DECLARE_OOXMLEXPORT_TEST(testTextFrameBorders
, "textframe-borders.docx")
534 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
535 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
536 if (xIndexAccess
->getCount())
538 // After import, a TextFrame is created by the VML import.
539 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
540 CPPUNIT_ASSERT_EQUAL(Color(0xD99594), getProperty
<Color
>(xFrame
, "BackColor"));
542 table::BorderLine2 aBorder
= getProperty
<table::BorderLine2
>(xFrame
, "TopBorder");
543 CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), Color(ColorTransparency
, aBorder
.Color
));
544 CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder
.LineWidth
);
546 table::ShadowFormat aShadowFormat
= getProperty
<table::ShadowFormat
>(xFrame
, "ShadowFormat");
547 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT
, aShadowFormat
.Location
);
548 CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat
.ShadowWidth
);
549 CPPUNIT_ASSERT_EQUAL(Color(0x622423), Color(ColorTransparency
, aShadowFormat
.Color
));
553 // After export and import, the result is a shape.
554 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
555 CPPUNIT_ASSERT_EQUAL(Color(0xD99594), getProperty
<Color
>(xShape
, "FillColor"));
557 CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), getProperty
<Color
>(xShape
, "LineColor"));
558 CPPUNIT_ASSERT_EQUAL(sal_Int32(35), getProperty
<sal_Int32
>(xShape
, "LineWidth"));
560 CPPUNIT_ASSERT_EQUAL(sal_Int32(48), getProperty
<sal_Int32
>(xShape
, "ShadowXDistance"));
561 CPPUNIT_ASSERT_EQUAL(sal_Int32(48), getProperty
<sal_Int32
>(xShape
, "ShadowYDistance"));
562 CPPUNIT_ASSERT_EQUAL(Color(0x622423), getProperty
<Color
>(xShape
, "ShadowColor"));
566 DECLARE_OOXMLEXPORT_TEST(testTextframeGradient
, "textframe-gradient.docx")
568 CPPUNIT_ASSERT_EQUAL(2, getShapes());
570 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
571 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xFrame
, "FillStyle"));
572 awt::Gradient2
aGradient(getProperty
<awt::Gradient2
>(xFrame
, "FillGradient"));
574 // MCGR: Use the completely imported transparency gradient to check for correctness
575 basegfx::BColorStops aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
577 CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops
.size());
578 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
579 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(), basegfx::BColor(0.85098039215686272, 0.58431372549019611, 0.58039215686274515));
580 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 0.5));
581 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(0.75294117647058822, 0.31372549019607843, 0.30196078431372547));
582 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[2].getStopOffset(), 1.0));
583 CPPUNIT_ASSERT_EQUAL(aColorStops
[2].getStopColor(), basegfx::BColor(0.85098039215686272, 0.58431372549019611, 0.58039215686274515));
584 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR
, aGradient
.Style
);
586 xFrame
.set(getShape(2), uno::UNO_QUERY
);
587 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, getProperty
<drawing::FillStyle
>(xFrame
, "FillStyle"));
588 aGradient
= getProperty
<awt::Gradient2
>(xFrame
, "FillGradient");
590 // MCGR: Use the completely imported transparency gradient to check for correctness
591 aColorStops
= model::gradient::getColorStopsFromUno(aGradient
.ColorStops
);
593 CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops
.size());
594 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[0].getStopOffset(), 0.0));
595 CPPUNIT_ASSERT_EQUAL(aColorStops
[0].getStopColor(), basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
596 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[1].getStopOffset(), 0.5));
597 CPPUNIT_ASSERT_EQUAL(aColorStops
[1].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
598 CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops
[2].getStopOffset(), 1.0));
599 CPPUNIT_ASSERT_EQUAL(aColorStops
[2].getStopColor(), basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
600 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR
, aGradient
.Style
);
602 // Left / right margin was incorrect: the attribute was missing and we
603 // didn't have the right default (had 0 instead of the below one).
604 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(318), getProperty
<sal_Int32
>(xFrame
, "LeftMargin"), 2);
605 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(318), getProperty
<sal_Int32
>(xFrame
, "RightMargin"), 2);
608 CPPUNIT_TEST_FIXTURE(Test
, testCellBtlr
)
610 loadAndSave("cell-btlr.docx");
612 * The problem was that the exporter didn't mirror the workaround of the
613 * importer, regarding the btLr text direction: the <w:textDirection
614 * w:val="btLr"/> token was completely missing in the output.
617 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
618 assertXPath(pXmlDoc
, "/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:textDirection", "val", "btLr");
621 DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz
, "table-style-rPr-sz.docx")
623 // Verify that font size inside the table is 20pt, despite the sz attribute in the table size.
624 // Also check that other rPr attribute are used: italic, bold, underline
625 // Office has the same behavior
626 uno::Reference
<text::XTextTablesSupplier
> xTextTablesSupplier(mxComponent
, uno::UNO_QUERY
);
627 uno::Reference
<container::XIndexAccess
> xTables(xTextTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
628 uno::Reference
<text::XTextTable
> xTable(xTables
->getByIndex(0), uno::UNO_QUERY
);
629 uno::Reference
<text::XTextRange
> xCell(xTable
->getCellByName("A1"), uno::UNO_QUERY
);
630 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xCell
->getText(), uno::UNO_QUERY
);
631 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
632 // disabled temporarily, next commit enables it again
634 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
635 CPPUNIT_ASSERT_EQUAL(20.f
, getProperty
<float>(getRun(xPara
, 1), "CharHeight"));
637 // CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline"));
638 // CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight"));
639 // CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture"));
642 DECLARE_OOXMLEXPORT_TEST(testMathLiteral
, "math-literal.docx")
644 CHECK_FORMULA( u
"iiint from {V} to <?> {\"div\" \"F\"} dV= llint from {S} to <?> {\"F\" \u2219 \"n \" dS}",
645 getFormula( getRun( getParagraph( 1 ), 1 )));
648 CPPUNIT_TEST_FIXTURE(Test
, testFdo48557
)
650 loadAndReload("fdo48557.odt");
651 CPPUNIT_ASSERT_EQUAL(1, getShapes());
652 CPPUNIT_ASSERT_EQUAL(1, getPages());
653 // Inner margins of the textframe wasn't exported.
654 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
655 CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty
<sal_Int32
>(xFrame
, "TextLeftDistance"));
656 CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty
<sal_Int32
>(xFrame
, "TextRightDistance"));
657 CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty
<sal_Int32
>(xFrame
, "TextUpperDistance"));
658 CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty
<sal_Int32
>(xFrame
, "TextLowerDistance"));
660 //tdf#140967 frame border was too small. Expected 0 (hairline), actual was 2
661 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty
<sal_uInt32
>(xFrame
, "LineWidth"));
664 DECLARE_OOXMLEXPORT_TEST(testI120928
, "i120928.docx")
666 // w:numPicBullet was ignored, leading to missing graphic bullet in numbering.
667 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
668 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
669 uno::Sequence
<beans::PropertyValue
> aProps
;
670 xLevels
->getByIndex(0) >>= aProps
; // 1st level
672 uno::Reference
<awt::XBitmap
> xBitmap
;
673 sal_Int16 nNumberingType
= -1;
675 for (beans::PropertyValue
const & rProp
: std::as_const(aProps
))
677 if (rProp
.Name
== "NumberingType")
678 nNumberingType
= rProp
.Value
.get
<sal_Int16
>();
679 else if (rProp
.Name
== "GraphicBitmap")
680 xBitmap
= rProp
.Value
.get
<uno::Reference
<awt::XBitmap
>>();
682 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP
, nNumberingType
);
683 CPPUNIT_ASSERT(xBitmap
.is());
686 DECLARE_OOXMLEXPORT_TEST(testFdo64826
, "fdo64826.docx")
688 // 'Track-Changes' (Track Revisions) wasn't exported.
689 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(mxComponent
, "RecordChanges"));
690 // 'Show-Changes' should not be exported - default is true.
693 xmlDocUniquePtr pXmlSettings
= parseExport("word/settings.xml");
694 assertXPath(pXmlSettings
, "/w:settings/w:revisionView", 0);
698 DECLARE_OOXMLEXPORT_TEST(testPageBackground
, "page-background.docx")
700 // 'Document Background' wasn't exported.
701 uno::Reference
<beans::XPropertySet
> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
702 CPPUNIT_ASSERT_EQUAL(Color(0x92D050), getProperty
<Color
>(xPageStyle
, "BackColor"));
705 DECLARE_OOXMLEXPORT_TEST(testFdo65265
, "fdo65265.docx")
707 // Redline (tracked changes) of text formatting were not exported
708 uno::Reference
<text::XTextRange
> xParagraph1
= getParagraph(1);
709 uno::Reference
<text::XTextRange
> xParagraph2
= getParagraph(2);
711 CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty
<OUString
>(getRun(xParagraph1
, 3), "RedlineType"));
712 CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty
<OUString
>(getRun(xParagraph2
, 2), "RedlineType"));
715 DECLARE_OOXMLEXPORT_TEST(testFdo65655
, "fdo65655.docx")
717 // The problem was that the DOCX had a non-blank odd footer and a blank even footer
718 // The 'Different Odd & Even Pages' was turned on
719 // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag
720 // So it did not import it and did not export it
721 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY
);
723 xPropertySet
->getPropertyValue("HeaderIsShared") >>= bValue
;
724 CPPUNIT_ASSERT_EQUAL(false, bValue
);
725 xPropertySet
->getPropertyValue("FooterIsShared") >>= bValue
;
726 CPPUNIT_ASSERT_EQUAL(false, bValue
);
729 DECLARE_OOXMLEXPORT_TEST(testFDO63053
, "fdo63053.docx")
731 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(mxComponent
, uno::UNO_QUERY
);
732 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
= xDocumentPropertiesSupplier
->getDocumentProperties();
733 CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties
->getTitle());
734 CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties
->getSubject());
737 DECLARE_OOXMLEXPORT_TEST(testWatermark
, "watermark.docx")
739 uno::Reference
<text::XTextRange
> xShape(getShape(1), uno::UNO_QUERY
);
740 // 1st problem: last character was missing
741 CPPUNIT_ASSERT_EQUAL(OUString("SAMPLE"), xShape
->getString());
743 const uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xShape
, "CustomShapeGeometry");
745 for (beans::PropertyValue
const & prop
: aProps
)
746 if (prop
.Name
== "TextPath")
748 // 2nd problem: v:textpath wasn't imported
749 CPPUNIT_ASSERT_EQUAL(true, bFound
);
751 // 3rd problem: rotation angle was 315, not 45.
752 CPPUNIT_ASSERT_EQUAL(sal_Int32(45 * 100), getProperty
<sal_Int32
>(xShape
, "RotateAngle"));
754 // 4th problem: mso-position-vertical-relative:margin was ignored, VertOrientRelation was text::RelOrientation::FRAME.
755 CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA
, getProperty
<sal_Int16
>(xShape
, "VertOrientRelation"));
757 // These problems were in the exporter
758 // The textpath wasn't semi-transparent.
759 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty
<sal_Int16
>(xShape
, "FillTransparence"));
760 // The textpath had a stroke.
761 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE
, getProperty
<drawing::LineStyle
>(xShape
, "LineStyle"));
764 DECLARE_OOXMLEXPORT_TEST(testWatermarkFont
, "watermark-font.docx")
766 uno::Reference
<text::XTextRange
> xShape(getShape(1), uno::UNO_QUERY
);
767 CPPUNIT_ASSERT_EQUAL(OUString("TestFont"), xShape
->getString());
769 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY
);
774 CPPUNIT_ASSERT(xPropertySet
->getPropertyValue("CharFontName") >>= aFont
);
775 CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Serif"), aFont
);
778 CPPUNIT_ASSERT(xPropertySet
->getPropertyValue("CharHeight") >>= nFontSize
);
779 CPPUNIT_ASSERT_EQUAL(float(72), nFontSize
);
782 DECLARE_OOXMLEXPORT_TEST(testFdo43093
, "fdo43093.docx")
784 // The problem was that the alignment are not exchange when the paragraph are RTL.
785 uno::Reference
<uno::XInterface
> xParaRtlLeft(getParagraph( 1, "RTL Left"));
786 sal_Int32 nRtlLeft
= getProperty
< sal_Int32
>( xParaRtlLeft
, "ParaAdjust" );
787 // test the text Direction value for the paragraph
788 sal_Int16 nRLDir
= getProperty
< sal_Int32
>( xParaRtlLeft
, "WritingMode" );
790 uno::Reference
<uno::XInterface
> xParaRtlRight(getParagraph( 3, "RTL Right"));
791 sal_Int32 nRtlRight
= getProperty
< sal_Int32
>( xParaRtlRight
, "ParaAdjust" );
792 sal_Int16 nRRDir
= getProperty
< sal_Int32
>( xParaRtlRight
, "WritingMode" );
794 uno::Reference
<uno::XInterface
> xParaLtrLeft(getParagraph( 5, "LTR Left"));
795 sal_Int32 nLtrLeft
= getProperty
< sal_Int32
>( xParaLtrLeft
, "ParaAdjust" );
796 sal_Int16 nLLDir
= getProperty
< sal_Int32
>( xParaLtrLeft
, "WritingMode" );
798 uno::Reference
<uno::XInterface
> xParaLtrRight(getParagraph( 7, "LTR Right"));
799 sal_Int32 nLtrRight
= getProperty
< sal_Int32
>( xParaLtrRight
, "ParaAdjust" );
800 sal_Int16 nLRDir
= getProperty
< sal_Int32
>( xParaLtrRight
, "WritingMode" );
802 // this will test the both the text direction and alignment for each paragraph
803 CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT
), nRtlLeft
);
804 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB
, nRLDir
);
806 CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT
), nRtlRight
);
807 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB
, nRRDir
);
809 CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT
), nLtrLeft
);
810 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB
, nLLDir
);
812 CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT
), nLtrRight
);
813 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB
, nLRDir
);
816 DECLARE_OOXMLEXPORT_TEST(testFdo64238_a
, "fdo64238_a.docx")
818 // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled*
819 // then LO would still import the Even footer and concatenate it to the odd footer.
820 // This case specifically is for :
821 // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word
822 // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' footer
823 uno::Reference
<text::XText
> xFooterText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("Standard"), "FooterText");
824 uno::Reference
< text::XTextRange
> xFooterParagraph
= getParagraphOfText( 1, xFooterText
);
825 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xFooterParagraph
, uno::UNO_QUERY
);
826 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
827 sal_Int32 numOfRuns
= 0;
828 while (xRunEnum
->hasMoreElements())
830 xRunEnum
->nextElement();
833 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns
);
836 DECLARE_OOXMLEXPORT_TEST(testFdo64238_b
, "fdo64238_b.docx")
838 // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled*
839 // then LO would still import the Even footer and concatenate it to the odd footer.
840 // This case specifically is for :
841 // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word
842 // In this case the imported footer in LO was supposed to be just the odd footer, but instead was the 'odd' and 'even' footers concatenated
843 uno::Reference
<text::XText
> xFooterText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("Standard"), "FooterText");
844 uno::Reference
< text::XTextRange
> xFooterParagraph
= getParagraphOfText( 1, xFooterText
);
845 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xFooterParagraph
, uno::UNO_QUERY
);
846 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
847 sal_Int32 numOfRuns
= 0;
848 while (xRunEnum
->hasMoreElements())
850 xRunEnum
->nextElement();
853 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns
);
856 DECLARE_OOXMLEXPORT_TEST(testFdo56679
, "fdo56679.docx")
858 // The problem was that the DOCX importer and exporter did not handle the 'color' of an underline
859 // (not the color of the text, the color of the underline itself)
860 uno::Reference
< text::XTextRange
> xParagraph
= getParagraph( 1 );
861 uno::Reference
< text::XTextRange
> xText
= getRun( xParagraph
, 2, "This is a simple sentence.");
863 CPPUNIT_ASSERT_EQUAL(true, getProperty
<bool>(xText
, "CharUnderlineHasColor"));
864 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), getProperty
<Color
>(xText
, "CharUnderlineColor"));
867 DECLARE_OOXMLEXPORT_TEST(testFdo65400
, "fdo65400.docx")
869 // The problem was that if in Word you choose 'Character Shading' - then the text portion
870 // is marked with 'w:shd val=pct15'. LO did not store this value and so when importing and exporting
871 // this value was lost (and so Word did not show 'Character Shading' was on)
872 uno::Reference
< text::XTextRange
> paragraph1
= getParagraph( 1 );
873 uno::Reference
< text::XTextRange
> shaded
= getRun( paragraph1
, 2, "normal" );
874 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty
< sal_Int32
>( shaded
, "CharShadingValue" ));
875 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty
< sal_Int32
>( shaded
, "CharBackColor" ));
878 DECLARE_OOXMLEXPORT_TEST(testFdo66543
, "fdo66543.docx")
880 // The problem was that when importing DOCX with 'line numbers' - the 'start value' was imported
881 // but nothing was done with it.
883 uno::Reference
< text::XTextRange
> paragraph1
= getParagraph( 1 );
884 CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
885 getProperty
<sal_Int32
>(paragraph1
, "ParaLineNumberStartValue"));
888 CPPUNIT_TEST_FIXTURE(Test
, testN822175
)
890 loadAndReload("n822175.odt");
891 CPPUNIT_ASSERT_EQUAL(1, getShapes());
892 CPPUNIT_ASSERT_EQUAL(1, getPages());
893 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
894 // Was text::WrapTextMode_THROUGH, due to missing Surround handling in the exporter.
895 CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL
, getProperty
<text::WrapTextMode
>(xFrame
, "Surround"));
898 DECLARE_OOXMLEXPORT_TEST(testFdo66688
, "fdo66688.docx")
900 // The problem was that TextFrame imported and exported the wrong value for transparency
901 // (was stored as 'FillTransparence' instead of 'BackColorTransparency'
902 uno::Reference
<beans::XPropertySet
> xFrame(getShape(2), uno::UNO_QUERY
);
903 CPPUNIT_ASSERT_EQUAL( sal_Int32( 80 ), getProperty
< sal_Int32
>( xFrame
, "FillTransparence" ) );
906 DECLARE_OOXMLEXPORT_TEST(testFdo66773
, "fdo66773.docx")
908 // The problem was the line spacing was interpreted by Word as 'Multiple 1.08' if no default settings were written.
909 // Now after the 'docDefaults' section is written in <styles.xml> - there is no more problem.
910 // (Word does not try to calculate some arbitrary value for line spacing).
911 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
912 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(), uno::UNO_QUERY
);
913 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
914 CPPUNIT_ASSERT(xParaEnum
->hasMoreElements());
916 style::LineSpacing alineSpacing
= getProperty
<style::LineSpacing
>(xParaEnum
->nextElement(), "ParaLineSpacing");
917 CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP
, alineSpacing
.Mode
);
918 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(100), static_cast<sal_Int32
>(alineSpacing
.Height
));
921 CPPUNIT_TEST_FIXTURE(Test
, testFdo58577
)
923 loadAndReload("fdo58577.odt");
924 CPPUNIT_ASSERT_EQUAL(1, getPages());
925 // The second frame was simply missing, so let's check if both frames were imported back.
926 CPPUNIT_ASSERT_EQUAL(2, getShapes());
929 CPPUNIT_TEST_FIXTURE(Test
, testBnc581614
)
931 loadAndReload("bnc581614.doc");
932 uno::Reference
<beans::XPropertySet
> xFrame(getShape(1), uno::UNO_QUERY
);
933 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, getProperty
<drawing::FillStyle
>(xFrame
, "FillStyle"));
936 DECLARE_OOXMLEXPORT_TEST(testFdo66929
, "fdo66929.docx")
938 // The problem was that the default 'inset' attribute of the 'textbox' node was exported incorrectly.
939 // A node like '<v:textbox inset="0">' was exported back as '<v:textbox inset="0pt,0pt,0pt,0pt">'
940 // This is wrong because the original node denotes a specific 'left' inset, and a default 'top','right','bottom' inset
941 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
942 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
943 if (xIndexAccess
->getCount())
945 // VML import -> TextFrame
946 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
947 CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ) , getProperty
< sal_Int32
>( xFrame
, "LeftBorderDistance" ) );
948 CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty
< sal_Int32
>( xFrame
, "TopBorderDistance" ) );
949 CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty
< sal_Int32
>( xFrame
, "RightBorderDistance" ) );
950 CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty
< sal_Int32
>( xFrame
, "BottomBorderDistance" ) );
954 // drawingML import -> shape with TextBox
955 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
956 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty
<sal_Int32
>(xShape
, "TextLeftDistance"));
957 CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty
<sal_Int32
>(xShape
, "TextUpperDistance"));
958 CPPUNIT_ASSERT_EQUAL(sal_Int32(254), getProperty
<sal_Int32
>(xShape
, "TextRightDistance"));
959 CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty
<sal_Int32
>(xShape
, "TextLowerDistance"));
963 CPPUNIT_TEST_FIXTURE(Test
, testPageBorderSpacingExportCase2
)
965 loadAndSave("page-borders-export-case-2.docx");
966 // The problem was that the exporter didn't mirror the workaround of the
967 // importer, regarding the page border's spacing : the <w:pgBorders w:offsetFrom="page">
968 // and the inner nodes like <w:top w:space="24" ... />
970 // The exporter ALWAYS exported 'w:offsetFrom="text"' even when the spacing values where too large
971 // for Word to handle (larger than 31 points)
973 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
975 // Assert the XPath expression - page borders
976 assertXPath(pXmlDoc
, "/w:document/w:body/w:sectPr/w:pgBorders", "offsetFrom", "page");
978 // Assert the XPath expression - 'left' border
979 assertXPath(pXmlDoc
, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", "24");
981 // Assert the XPath expression - 'right' border
982 assertXPath(pXmlDoc
, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", "24");
985 DECLARE_OOXMLEXPORT_TEST(testFdo66145
, "fdo66145.docx")
987 // The Writer ignored the 'First Is Shared' flag
988 CPPUNIT_ASSERT_EQUAL(OUString("This is the FIRST page header."),
989 parseDump("/root/page[1]/header/txt/text()"));
990 CPPUNIT_ASSERT_EQUAL(
991 OUString("This is the header for the REST OF THE FILE."),
992 parseDump("/root/page[2]/header/txt/text()"));
993 CPPUNIT_ASSERT_EQUAL(
994 OUString("This is the header for the REST OF THE FILE."),
995 parseDump("/root/page[3]/header/txt/text()"));
998 CPPUNIT_TEST_FIXTURE(Test
, testGrabBag
)
1000 loadAndSave("grabbag.docx");
1001 // w:mirrorIndents was lost on roundtrip, now should be handled as a grab bag property
1002 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1003 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:pPr/w:mirrorIndents");
1006 DECLARE_OOXMLEXPORT_TEST(testFdo66781
, "fdo66781.docx")
1008 // The problem was that bullets with level=0 were shown in LO as normal bullets,
1009 // and when saved back to DOCX were saved with level=1 (so hidden bullets became visible)
1010 uno::Reference
<beans::XPropertySet
> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY
);
1011 uno::Reference
<container::XIndexAccess
> xLevels(xPropertySet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1012 uno::Sequence
<beans::PropertyValue
> aProps
;
1013 xLevels
->getByIndex(0) >>= aProps
; // 1st level
1015 for (beans::PropertyValue
const & rProp
: std::as_const(aProps
))
1017 if (rProp
.Name
== "BulletChar")
1019 CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_ASCII_US
), rProp
.Value
.get
<OUString
>());
1024 // Shouldn't reach here
1025 CPPUNIT_FAIL("Did not find bullet with level 0");
1028 CPPUNIT_TEST_FIXTURE(Test
, testFdo60990
)
1030 loadAndReload("fdo60990.odt");
1031 CPPUNIT_ASSERT_EQUAL(1, getShapes());
1032 CPPUNIT_ASSERT_EQUAL(1, getPages());
1033 // The shape had no background, no paragraph adjust and no font color.
1034 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
1035 CPPUNIT_ASSERT_EQUAL(Color(0x00CFE7F5), getProperty
<Color
>(xShape
, "FillColor"));
1036 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
1037 uno::Reference
<text::XTextRange
> xParagraph
= getParagraphOfText(1, xText
);
1038 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(getProperty
<sal_Int16
>(xParagraph
, "ParaAdjust")));
1039 CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), getProperty
<Color
>(getRun(xParagraph
, 1), "CharColor"));
1042 DECLARE_OOXMLEXPORT_TEST(testFdo65718
, "fdo65718.docx")
1044 // The problem was that the exporter always exported values of "0" for an images distance from text.
1045 // the actual attributes where 'distT', 'distB', 'distL', 'distR'
1046 uno::Reference
<beans::XPropertySet
> xPropertySet(getShape(1), uno::UNO_QUERY
);
1048 CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(0), getProperty
<sal_Int32
>(xPropertySet
, "TopMargin") );
1049 CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(0), getProperty
<sal_Int32
>(xPropertySet
, "BottomMargin") );
1051 // 'getProperty' return 318 (instead of 317.5)
1052 // I think this is because it returns an integer, instead of a float.
1053 // The actual exporting to DOCX exports the correct value (114300 = 317.5 * 360)
1054 // The exporting to DOCX uses the 'SvxLRSpacing' that stores the value in TWIPS (180 TWIPS)
1055 // However, the 'LeftMargin' property is an integer property that holds that value in 'MM100' (should hold 317.5, but it is 318)
1056 CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300), getProperty
<sal_Int32
>(xPropertySet
, "LeftMargin") );
1057 CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300), getProperty
<sal_Int32
>(xPropertySet
, "RightMargin") );
1060 DECLARE_OOXMLEXPORT_TEST(testFdo64350
, "fdo64350.docx")
1062 // The problem was that page border shadows were not exported
1063 table::ShadowFormat aShadow
= getProperty
<table::ShadowFormat
>(getStyles("PageStyles")->getByName("Standard"), "ShadowFormat");
1064 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT
, aShadow
.Location
);
1067 DECLARE_OOXMLEXPORT_TEST(testFdo67013
, "fdo67013.docx")
1070 * The problem was that borders inside headers \ footers were not exported
1071 * This was checked in xray using these commands:
1073 * xHeaderText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").HeaderText
1074 * xHeaderEnum = xHeaderText.createEnumeration()
1075 * xHeaderFirstParagraph = xHeaderEnum.nextElement()
1076 * xHeaderBottomBorder = xHeaderFirstParagraph.BottomBorder
1078 * xFooterText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").FooterText
1079 * xFooterEnum = xFooterText.createEnumeration()
1080 * xFooterFirstParagraph = xFooterEnum.nextElement()
1081 * xFooterTopBorder = xFooterFirstParagraph.TopBorder
1083 uno::Reference
<text::XText
> xHeaderText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("Standard"), "HeaderText");
1084 uno::Reference
< text::XTextRange
> xHeaderParagraph
= getParagraphOfText( 1, xHeaderText
);
1085 table::BorderLine2 aHeaderBottomBorder
= getProperty
<table::BorderLine2
>(xHeaderParagraph
, "BottomBorder");
1086 CPPUNIT_ASSERT_EQUAL(Color(0x622423), Color(ColorTransparency
, aHeaderBottomBorder
.Color
));
1087 CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aHeaderBottomBorder
.InnerLineWidth
);
1088 CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder
.LineDistance
);
1089 CPPUNIT_ASSERT_EQUAL(sal_Int16(7), aHeaderBottomBorder
.LineStyle
);
1090 CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aHeaderBottomBorder
.LineWidth
);
1091 CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder
.OuterLineWidth
);
1093 uno::Reference
<text::XText
> xFooterText
= getProperty
< uno::Reference
<text::XText
> >(getStyles("PageStyles")->getByName("Standard"), "FooterText");
1094 uno::Reference
< text::XTextRange
> xFooterParagraph
= getParagraphOfText( 1, xFooterText
);
1095 table::BorderLine2 aFooterTopBorder
= getProperty
<table::BorderLine2
>(xFooterParagraph
, "TopBorder");
1096 CPPUNIT_ASSERT_EQUAL(Color(0x622423), Color(ColorTransparency
, aFooterTopBorder
.Color
));
1097 CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder
.InnerLineWidth
);
1098 CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder
.LineDistance
);
1099 CPPUNIT_ASSERT_EQUAL(sal_Int16(4), aFooterTopBorder
.LineStyle
);
1100 CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aFooterTopBorder
.LineWidth
);
1101 CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aFooterTopBorder
.OuterLineWidth
);
1104 DECLARE_OOXMLEXPORT_TEST(testParaShadow
, "para-shadow.docx")
1106 // The problem was that in w:pBdr, child elements had a w:shadow attribute, but that was ignored.
1107 table::ShadowFormat aShadow
= getProperty
<table::ShadowFormat
>(getParagraph(2), "ParaShadowFormat");
1108 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, Color(ColorTransparency
, aShadow
.Color
));
1109 CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT
, aShadow
.Location
);
1110 // w:sz="48" is in eights of a point, 1 pt is 20 twips.
1111 CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(24/8*20)), aShadow
.ShadowWidth
);
1114 DECLARE_OOXMLEXPORT_TEST(testTableFloating
, "table-floating.docx")
1116 // Both the size and the position of the table was incorrect.
1117 uno::Reference
<text::XTextTablesSupplier
> xTablesSupplier(mxComponent
, uno::UNO_QUERY
);
1118 uno::Reference
<container::XIndexAccess
> xTables(xTablesSupplier
->getTextTables(), uno::UNO_QUERY
);
1119 // Second table was too wide: 16249, i.e. as wide as the first table.
1120 CPPUNIT_ASSERT_EQUAL(sal_Int32(11248), getProperty
<sal_Int32
>(xTables
->getByIndex(1), "Width"));
1122 uno::Reference
<text::XTextFramesSupplier
> xTextFramesSupplier(mxComponent
, uno::UNO_QUERY
);
1123 uno::Reference
<container::XIndexAccess
> xIndexAccess(xTextFramesSupplier
->getTextFrames(), uno::UNO_QUERY
);
1124 if (xIndexAccess
->getCount())
1126 // After import, table is inside a TextFrame.
1127 uno::Reference
<beans::XPropertySet
> xFrame(xIndexAccess
->getByIndex(0), uno::UNO_QUERY
);
1128 // This was 0, should be the opposite of (left margin + half of the border width).
1129 CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty
<sal_Int32
>(xFrame
, "HoriOrientPosition"));
1130 // Was 0 as well, should be the right margin.
1131 CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty
<sal_Int32
>(xFrame
, "RightMargin"));
1135 // After import, table is inside a TextFrame.
1136 uno::Reference
<beans::XPropertySet
> xShape(getShape(1), uno::UNO_QUERY
);
1137 // This was 0, should be the opposite of (left margin + half of the border width).
1138 CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty
<sal_Int32
>(xShape
, "HoriOrientPosition"));
1139 // Was 0 as well, should be the right margin.
1140 CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty
<sal_Int32
>(xShape
, "RightMargin"));
1144 DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_0
, "fdo44689_start_page_0.docx")
1146 // The problem was that the import & export process did not analyze the 'start from page' attribute of a section
1147 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1148 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty
<sal_Int16
>(xPara
, "PageNumberOffset"));
1151 DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_7
, "fdo44689_start_page_7.docx")
1153 // The problem was that the import & export process did not analyze the 'start from page' attribute of a section
1154 uno::Reference
<beans::XPropertySet
> xPara(getParagraph(1), uno::UNO_QUERY
);
1155 CPPUNIT_ASSERT_EQUAL(sal_Int16(7), getProperty
<sal_Int16
>(xPara
, "PageNumberOffset"));
1158 DECLARE_OOXMLEXPORT_TEST(testFdo67737
, "fdo67737.docx")
1160 // The problem was that imported shapes did not import and render the 'flip:x' and 'flip:y' attributes
1161 uno::Reference
<drawing::XShape
> xArrow
= getShape(1);
1162 const uno::Sequence
<beans::PropertyValue
> aProps
= getProperty
< uno::Sequence
<beans::PropertyValue
> >(xArrow
, "CustomShapeGeometry");
1163 for (beans::PropertyValue
const & rProp
: aProps
)
1165 if (rProp
.Name
== "MirroredY")
1167 CPPUNIT_ASSERT_EQUAL( true, rProp
.Value
.get
<bool>() );
1172 // Shouldn't reach here
1173 CPPUNIT_FAIL("Did not find MirroredY=true property");
1176 DECLARE_OOXMLEXPORT_TEST(testTransparentShadow
, "transparent-shadow.docx")
1178 uno::Reference
<drawing::XShape
> xPicture
= getShape(1);
1179 sal_Int16 nShadowTransparence
= getProperty
<sal_Int16
>(xPicture
, "ShadowTransparence");
1180 CPPUNIT_ASSERT_EQUAL(Color(0x808080), getProperty
<Color
>(xPicture
, "ShadowColor"));
1181 CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nShadowTransparence
);
1184 CPPUNIT_TEST_FIXTURE(Test
, NoFillAttrInImagedata
)
1186 loadAndSave("NoFillAttrInImagedata.docx");
1187 //problem was that type and color2 which are v:fill attributes were written in 'v:imagedata'. The
1188 //source file has v:fill and no v:imagedata. Same should be in the file written by LO.
1189 xmlDocUniquePtr pXmlDoc
= parseExport("word/document.xml");
1191 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect/v:imagedata", 0);
1192 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect/v:fill", 1);
1193 assertXPath(pXmlDoc
, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect/v:fill", "type", "tile");
1196 DECLARE_OOXMLEXPORT_TEST(testBnc837302
, "bnc837302.docx")
1198 // The problem was that text with empty author was not inserted as a redline
1199 uno::Reference
<text::XTextRange
> xParagraph
= getParagraph(1);
1201 // previously 'AAA' was not an own run
1202 getRun(xParagraph
, 3, "AAA");
1203 // interestingly the 'Insert' is set on the _previous_ run
1204 CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty
<OUString
>(getRun(xParagraph
, 2), "RedlineType"));
1206 // make sure we don't introduce a redlined delete in the 2nd paragraph
1207 xParagraph
= getParagraph(2);
1208 CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph
, 1), "RedlineType"));
1211 CPPUNIT_PLUGIN_IMPLEMENT();
1213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */