summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/extras/ooxmlimport/ooxmlimport.cxx')
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx518
1 files changed, 315 insertions, 203 deletions
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3d185a72afb9..7c2800b7aa72 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <memory>
-#include <config_features.h>
+#include <config_fonts.h>
#ifdef MACOSX
#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
@@ -38,6 +37,7 @@
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/XDependentTextField.hpp>
#include <com/sun/star/text/XFormField.hpp>
+#include <com/sun/star/text/XParagraphCursor.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
@@ -56,82 +56,42 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <o3tl/cppunittraitshelper.hxx>
-#include <unotools/fltrcfg.hxx>
-#include <comphelper/sequenceashashmap.hxx>
#include <tools/datetimeutils.hxx>
+#include <officecfg/Office/Common.hxx>
#include <oox/drawingml/drawingmltypes.hxx>
#include <unotools/streamwrap.hxx>
#include <comphelper/propertysequence.hxx>
-#include <osl/time.h>
#include <comphelper/processfactory.hxx>
+#include <comphelper/sequenceashashmap.hxx>
#include <vcl/TypeSerializer.hxx>
+#include <comphelper/scopeguard.hxx>
-
+namespace
+{
class Test : public SwModelTestBase
{
public:
Test() : SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text")
{
}
-
- virtual std::unique_ptr<Resetter> preTest(const char* filename) override
- {
- if (OString(filename) == "fdo87488.docx")
- {
- std::unique_ptr<Resetter> pResetter(new Resetter(
- [] () {
- SvtFilterOptions::Get().SetSmartArt2Shape(false);
- }));
- SvtFilterOptions::Get().SetSmartArt2Shape(true);
- return pResetter;
- }
- return nullptr;
- }
};
-class FailTest : public Test
-{
-public:
- // UGLY: hacky manual override of MacrosTest::loadFromDesktop
- void executeImportTest(const char* filename, const char* /*password*/)
- {
- header();
- preTest(filename);
- {
- if (mxComponent.is())
- mxComponent->dispose();
- std::cout << filename << ",";
- mnStartTime = osl_getGlobalTimer();
- {
- OUString aURL(m_directories.getURLFromSrc(mpTestDocumentPath) + OUString::createFromAscii(filename));
- CPPUNIT_ASSERT_MESSAGE("no desktop", mxDesktop.is());
- uno::Sequence<beans::PropertyValue> args( comphelper::InitPropertySequence({
- { "DocumentService", uno::Any(OUString("com.sun.star.text.TextDocument")) }
- }));
-
- uno::Reference<lang::XComponent> xComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0, args);
- OUString sMessage = "loading succeeded: " + aURL;
- CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sMessage, RTL_TEXTENCODING_UTF8).getStr(), !xComponent.is());
- }
- }
- verify();
- finish();
- }
-};
-
-DECLARE_OOXMLIMPORT_TEST(testImageHyperlink, "image-hyperlink.docx")
+CPPUNIT_TEST_FIXTURE(Test, testImageHyperlink)
{
+ createSwDoc("image-hyperlink.docx");
OUString URL = getProperty<OUString>(getShape(1), "HyperLinkURL");
CPPUNIT_ASSERT_EQUAL(OUString("http://www.libreoffice.org/"), URL);
}
-DECLARE_SW_IMPORT_TEST(testMathMalformedXml, "math-malformed_xml.docx", nullptr, FailTest)
+CPPUNIT_TEST_FIXTURE(Test, testMathMalformedXml)
{
+ mxComponent = mxDesktop->loadComponentFromURL(createFileURL(u"math-malformed_xml.docx"), "_default", 0, {});
CPPUNIT_ASSERT(!mxComponent.is());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf103931, "tdf103931.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf103931)
{
+ createSwDoc("tdf103931.docx");
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
// This was 2, the last (empty) section of the document was lost on import.
@@ -139,8 +99,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf103931, "tdf103931.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xTextSections->getCount());
}
-DECLARE_OOXMLIMPORT_TEST(testN751017, "n751017.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN751017)
{
+ createSwDoc("n751017.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters());
// Make sure we have a variable named foo.
@@ -185,8 +146,9 @@ DECLARE_OOXMLIMPORT_TEST(testN751017, "n751017.docx")
CPPUNIT_ASSERT(bFoundGet);
}
-DECLARE_OOXMLIMPORT_TEST(testN757890, "n757890.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN757890)
{
+ createSwDoc("n757890.docx");
// The w:pStyle token affected the text outside the textbox.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
@@ -205,23 +167,29 @@ DECLARE_OOXMLIMPORT_TEST(testN757890, "n757890.docx")
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, nValue);
}
-DECLARE_OOXMLIMPORT_TEST(testN751077, "n751077.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN751077)
{
+ createSwDoc("n751077.docx");
/*
xray ThisComponent.DrawPage(1).getByIndex(0).String
xray ThisComponent.DrawPage(1).getByIndex(0).Anchor.PageStyleName
*/
uno::Reference<drawing::XShapes> xShapes(getShape(2), uno::UNO_QUERY);
+ // The groupshape should be in the foreground, not the background.
+ CPPUNIT_ASSERT(getProperty<bool>(xShapes, "Opaque"));
+
uno::Reference<text::XTextRange> xShape(xShapes->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("TEXT1\n"), xShape->getString());
// we want to test the textbox is on the first page (it was put onto another page without the fix),
// use a small trick and instead of checking the page layout, check the page style
uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString("First Page"), getProperty<OUString>(xTextContent->getAnchor(), "PageStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(xTextContent->getAnchor(), "PageStyleName"));
+ // TODO - This is not a reliable way to determine if something is on first page
}
-DECLARE_OOXMLIMPORT_TEST(testTdf129237, "tdf129237.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf129237)
{
+ createSwDoc("tdf129237.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
@@ -263,8 +231,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf129237, "tdf129237.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Title New"), xEnumerationAccess4->getPresentation(false).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf134572, "tdf134572.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf134572)
{
+ createSwDoc("tdf134572.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
@@ -291,8 +260,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf134572, "tdf134572.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Choose an item."), xEnumerationAccess2->getPresentation(false).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf128076, "tdf128076.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf128076)
{
+ createSwDoc("tdf128076.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
@@ -307,8 +277,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf128076, "tdf128076.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Test"), xEnumerationAccess->getPresentation(false).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testfdo90720, "testfdo90720.docx")
+CPPUNIT_TEST_FIXTURE(Test, testfdo90720)
{
+ createSwDoc("testfdo90720.docx");
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
@@ -319,8 +290,9 @@ DECLARE_OOXMLIMPORT_TEST(testfdo90720, "testfdo90720.docx")
CPPUNIT_ASSERT_EQUAL( sal_Int32(100), fill_transperence );
}
-DECLARE_OOXMLIMPORT_TEST(testN760764, "n760764.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN760764)
{
+ createSwDoc("n760764.docx");
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
@@ -336,8 +308,9 @@ DECLARE_OOXMLIMPORT_TEST(testN760764, "n760764.docx")
CPPUNIT_ASSERT_EQUAL(8.f, fValue);
}
-DECLARE_OOXMLIMPORT_TEST(testN764745, "n764745-alignment.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN764745)
{
+ createSwDoc("n764745-alignment.docx");
/*
shape = ThisComponent.DrawPage.getByIndex(0)
xray shape.AnchorType
@@ -364,14 +337,16 @@ xray ThisComponent.StyleFamilies.PageStyles.Default.Width
CPPUNIT_ASSERT( pos.X > width / 2 );
}
-DECLARE_OOXMLIMPORT_TEST(testTdf115719b, "tdf115719b.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf115719b)
{
+ createSwDoc("tdf115719b.docx");
// This was 0, 4th (last) paragraph had no increased spacing.
CPPUNIT_ASSERT(getProperty<sal_Int32>(getParagraph(4), "ParaTopMargin") > 0);
}
-DECLARE_OOXMLIMPORT_TEST(testN766477, "n766477.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN766477)
{
+ createSwDoc("n766477.docx");
/*
* The problem was that the checkbox was not checked.
*
@@ -393,33 +368,62 @@ DECLARE_OOXMLIMPORT_TEST(testN766477, "n766477.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Checkbox_Checked"), aElementNames[0]);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf130804, "tdf130804.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf130804)
{
- OUString flyHeight = parseDump("/root/page/body/txt[1]/infos/bounds", "height");
- OUString txtHeight = parseDump("/root/page/body/txt[1]/anchored/fly/infos/bounds", "height");
+ createSwDoc("tdf130804.docx");
+ OUString flyHeight = parseDump("/root/page/body/txt[1]/infos/bounds"_ostr, "height"_ostr);
+ OUString txtHeight = parseDump("/root/page/body/txt[1]/anchored/fly/infos/bounds"_ostr, "height"_ostr);
//Without the fix in place, txtHeight would have been flyHeight + 55
CPPUNIT_ASSERT_EQUAL(flyHeight, txtHeight);
// Also check the bookmark portion is ignored in the next paragraph
- OUString aTop = parseDump("/root/page/body/txt[2]/infos/prtBounds", "top");
+ OUString aTop = parseDump("/root/page/body/txt[2]/infos/prtBounds"_ostr, "top"_ostr);
CPPUNIT_ASSERT_EQUAL(OUString("240"), aTop);
}
-DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN758883)
{
+ createSwDoc("n758883.docx");
/*
* The problem was that direct formatting of the paragraph was not applied
* to the numbering. This is easier to test using a layout dump.
*/
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
- assertXPath(pXmlDoc, "/root/page/body/txt/Special[1]", "nHeight", "220");
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwFieldPortion[1]/SwFont"_ostr, "height"_ostr, "220");
+
+ // hidden _Toc and _Ref bookmarks are not visible in Visible bookmarks mode
+ // This was PortionType::Bookmark
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwLinePortion[1]"_ostr, "type"_ostr, "PortionType::Text");
+
+ // insert a not hidden bookmark
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange = xTextDocument->getText();
+ uno::Reference<text::XText> xText = xTextRange->getText();
+ uno::Reference<text::XParagraphCursor> xCursor(xText->createTextCursor(), uno::UNO_QUERY);
+ uno::Reference<lang::XMultiServiceFactory> xFact(mxComponent, uno::UNO_QUERY);
+ // creating bookmark "BookmarkTest"
+ uno::Reference<text::XTextContent> xBookmark(
+ xFact->createInstance("com.sun.star.text.Bookmark"), uno::UNO_QUERY);
+ uno::Reference<container::XNamed> xBookmarkName(xBookmark, uno::UNO_QUERY);
+ xBookmarkName->setName("BookmarkTest");
+ // moving cursor to the end of paragraph
+ xCursor->gotoEndOfParagraph(true);
+ // inserting the bookmark in paragraph
+ xText->insertTextContent(xCursor, xBookmark, true);
+
+ discardDumpedLayout();
+ pXmlDoc = parseLayoutDump();
// check the bookmark portions are of the expected height
- assertXPath(pXmlDoc, "/root/page/body/txt/Special[2]", "nType", "PortionType::Bookmark");
- assertXPath(pXmlDoc, "/root/page/body/txt/Special[2]", "nHeight", "253");
- assertXPath(pXmlDoc, "/root/page/body/txt/Special[3]", "nType", "PortionType::Bookmark");
- assertXPath(pXmlDoc, "/root/page/body/txt/Special[3]", "nHeight", "253");
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]"_ostr, "type"_ostr, "PortionType::Bookmark");
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]"_ostr, "height"_ostr, "253");
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]"_ostr, "type"_ostr, "PortionType::Bookmark");
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]"_ostr, "height"_ostr, "253");
+
+ // tdf#150947 check a11y of the newly inserted bookmark portions
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]"_ostr, "colors"_ostr, "#BookmarkTest Bookmark Start");
+ assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]"_ostr, "colors"_ostr, "#BookmarkTest Bookmark End");
/*
* Next problem was that the page margin contained the width of the page border as well.
@@ -459,8 +463,25 @@ DECLARE_OOXMLIMPORT_TEST(testN758883, "n758883.docx")
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
}
-DECLARE_OOXMLIMPORT_TEST(testBnc773061, "bnc773061.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf74367_MarginsZeroed)
+{
+ createSwDoc("tdf74367_MarginsZeroed.docx");
+ // Do not import page borders with 'None' style, or else it will change the page margins.
+ uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ sal_Int32 nValue = 0;
+ xPropertySet->getPropertyValue("TopMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+ xPropertySet->getPropertyValue("RightMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+ xPropertySet->getPropertyValue("BottomMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+ xPropertySet->getPropertyValue("LeftMargin") >>= nValue;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testBnc773061)
{
+ createSwDoc("bnc773061.docx");
uno::Reference< text::XTextRange > paragraph = getParagraph( 1 );
uno::Reference< text::XTextRange > normal = getRun( paragraph, 1, "Normal " );
uno::Reference< text::XTextRange > raised = getRun( paragraph, 2, "Raised" );
@@ -473,8 +494,9 @@ DECLARE_OOXMLIMPORT_TEST(testBnc773061, "bnc773061.docx")
CPPUNIT_ASSERT_EQUAL( sal_Int32( 100 ), getProperty< sal_Int32 >( lowered, "CharEscapementHeight" ));
}
-DECLARE_OOXMLIMPORT_TEST(testN775899, "n775899.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN775899)
{
+ createSwDoc("n775899.docx");
/*
* The problem was that a floating table wasn't imported as a frame, then it contained fake paragraphs.
*
@@ -497,8 +519,9 @@ DECLARE_OOXMLIMPORT_TEST(testN775899, "n775899.docx")
CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
}
-DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN777345)
{
+ createSwDoc("n777345.docx");
// The problem was that v:imagedata inside v:rect was ignored.
uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(getShape(1), uno::UNO_QUERY);
uno::Reference<graphic::XGraphic> xGraphic = xSupplier->getReplacementGraphic();
@@ -511,8 +534,9 @@ DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx")
CPPUNIT_ASSERT_EQUAL( Color( 153, 0, 0 ), aBitmap.GetPixelColor( 0, 15 ));
}
-DECLARE_OOXMLIMPORT_TEST(testN778140, "n778140.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN778140)
{
+ createSwDoc("n778140.docx");
/*
* The problem was that the paragraph top/bottom margins were incorrect due
* to unhandled w:doNotUseHTMLParagraphAutoSpacing.
@@ -521,8 +545,9 @@ DECLARE_OOXMLIMPORT_TEST(testN778140, "n778140.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
}
-DECLARE_OOXMLIMPORT_TEST(testInk, "ink.docx")
+CPPUNIT_TEST_FIXTURE(Test, testInk)
{
+ createSwDoc("ink.docx");
/*
* The problem was that ~nothing was imported, except an empty CustomShape.
*
@@ -532,8 +557,9 @@ DECLARE_OOXMLIMPORT_TEST(testInk, "ink.docx")
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.OpenBezierShape"));
}
-DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN779627)
{
+ createSwDoc("n779627.docx");
/*
* The problem was that the table left position was based on the tableCellMar left value
* even for nested tables, while it shouldn't.
@@ -549,14 +575,15 @@ DECLARE_OOXMLIMPORT_TEST(testN779627, "n779627.docx")
sal_Int32(9), nLeftMargin);
/*
- * Another problem tested with this document is the unnecessary loading of the shapes
- * anchored to a discarded header or footer
+ * Another problem tested with this document is the loading of the shapes
+ * anchored to a hidden header or footer
*/
- CPPUNIT_ASSERT_EQUAL(0, getShapes());
+ CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
-DECLARE_OOXMLIMPORT_TEST(testN779627b, "n779627b.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN779627b)
{
+ createSwDoc("n779627b.docx");
/*
* Another problem tested with the original n779627.docx document (before removing its unnecessary
* shape loading) is that the roundrect is centered vertically and horizontally.
@@ -576,16 +603,18 @@ DECLARE_OOXMLIMPORT_TEST(testN779627b, "n779627b.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
}
-DECLARE_OOXMLIMPORT_TEST(testN782061, "n782061.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN782061)
{
+ createSwDoc("n782061.docx");
/*
* The problem was that the character escapement in the second run was -58.
*/
CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapement"));
}
-DECLARE_OOXMLIMPORT_TEST(testN773061, "n773061.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN773061)
{
+ createSwDoc("n773061.docx");
// xray ThisComponent.TextFrames(0).LeftBorderDistance
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
@@ -596,8 +625,9 @@ DECLARE_OOXMLIMPORT_TEST(testN773061, "n773061.docx")
CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ) );
}
-DECLARE_OOXMLIMPORT_TEST(testN780645, "n780645.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN780645)
{
+ createSwDoc("n780645.docx");
// The problem was that when the number of cells didn't match the grid, we
// didn't take care of direct cell widths.
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
@@ -607,8 +637,9 @@ DECLARE_OOXMLIMPORT_TEST(testN780645, "n780645.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int16(2135), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position); // was 1999
}
-DECLARE_OOXMLIMPORT_TEST(testWordArtResizing, "WordArt.docx")
+CPPUNIT_TEST_FIXTURE(Test, testWordArtResizing)
{
+ createSwDoc("WordArt.docx");
/* The Word-Arts and watermarks were getting resized automatically, It was as if they were
getting glued to the fallback geometry(the sdrObj) and were getting bound to the font size.
The test-case ensures the original height and width of the word-art is not changed while importing*/
@@ -619,8 +650,9 @@ DECLARE_OOXMLIMPORT_TEST(testWordArtResizing, "WordArt.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(4755), xShape->getSize().Height);
}
-DECLARE_OOXMLIMPORT_TEST(testGroupshapeLine, "groupshape-line.docx")
+CPPUNIT_TEST_FIXTURE(Test, testGroupshapeLine)
{
+ createSwDoc("groupshape-line.docx");
/*
* Another fallout from n#792778, this time first the lines inside a
* groupshape wasn't imported, then the fix broke the size/position of
@@ -648,8 +680,9 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeLine, "groupshape-line.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape->getSize().Height);
}
-DECLARE_OOXMLIMPORT_TEST(testGroupshapeChildRotation, "groupshape-child-rotation.docx")
+CPPUNIT_TEST_FIXTURE(Test, testGroupshapeChildRotation)
{
+ createSwDoc("groupshape-child-rotation.docx");
// The problem was that (due to incorrect handling of rotation inside
// groupshapes), the first child wasn't in the top left corner of an inline
// groupshape.
@@ -673,8 +706,9 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeChildRotation, "groupshape-child-rotation
CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.TextShape"), xShapeDescriptor->getShapeType());
}
-DECLARE_OOXMLIMPORT_TEST(testTableWidth, "table_width.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTableWidth)
{
+ createSwDoc("table_width.docx");
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
// Relative width wasn't recognized during import.
@@ -685,8 +719,9 @@ DECLARE_OOXMLIMPORT_TEST(testTableWidth, "table_width.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xFrames->getByIndex(0), "FrameWidthPercent"));
}
-DECLARE_OOXMLIMPORT_TEST(testN820788, "n820788.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN820788)
{
+ createSwDoc("n820788.docx");
// The problem was that AutoSize was not enabled for the text frame.
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
@@ -695,30 +730,35 @@ DECLARE_OOXMLIMPORT_TEST(testN820788, "n820788.docx")
CPPUNIT_ASSERT_EQUAL(text::SizeType::MIN, getProperty<sal_Int16>(xFrame, "SizeType"));
}
-DECLARE_OOXMLIMPORT_TEST(testN820504, "n820504.docx")
+CPPUNIT_TEST_FIXTURE(Test, testN820504)
{
+ createSwDoc("n820504.docx");
uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xFamiliesAccess = xFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xStylesAccess(xFamiliesAccess->getByName("ParagraphStyles"), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xStyle(xStylesAccess->getByName("Default Paragraph Style"), uno::UNO_QUERY);
// The problem was that the CharColor was set to AUTO (-1) even if we have some default char color set
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4040635), getProperty<sal_Int32>(xStyle, "CharColor"));
+ CPPUNIT_ASSERT_EQUAL(Color(0x3da7bb), getProperty<Color>(xStyle, "CharColor"));
// Also, the groupshape was anchored at-page instead of at-character
// (that's incorrect as Word only supports at-character and as-character).
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
}
-DECLARE_OOXMLIMPORT_TEST(testFdo43641, "fdo43641.docx")
+CPPUNIT_TEST_FIXTURE(Test, testFdo43641)
{
- uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY);
+ createSwDoc("fdo43641.docx");
+ uno::Reference<container::XIndexAccess> xGroupLockedCanvas(getShape(1), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xGroupShape(xGroupLockedCanvas->getByIndex(0), uno::UNO_QUERY);
uno::Reference<drawing::XShape> xLine(xGroupShape->getByIndex(1), uno::UNO_QUERY);
// This was 2200, not 2579 in mm100, i.e. the size of the line shape was incorrect.
- CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(928440), xLine->getSize().Width);
+ // File cx=928694EMU = 2579.7Hmm, round up 2580Hmm. Currently off by 1.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2581), xLine->getSize().Width);
}
-DECLARE_OOXMLIMPORT_TEST(testGroupshapeSdt, "groupshape-sdt.docx")
+CPPUNIT_TEST_FIXTURE(Test, testGroupshapeSdt)
{
+ createSwDoc("groupshape-sdt.docx");
// All problems here are due to the groupshape: we have a drawinglayer rectangle, not a writer textframe.
uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY);
uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY);
@@ -731,7 +771,7 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeSdt, "groupshape-sdt.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(20), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xShape->getText()), 1), "CharKerning"));
}
-static void lcl_countTextFrames(const css::uno::Reference< lang::XComponent >& xComponent,
+void lcl_countTextFrames(const css::uno::Reference< lang::XComponent >& xComponent,
sal_Int32 nExpected )
{
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(xComponent, uno::UNO_QUERY);
@@ -739,14 +779,16 @@ static void lcl_countTextFrames(const css::uno::Reference< lang::XComponent >& x
CPPUNIT_ASSERT_EQUAL( nExpected, xIndexAccess->getCount());
}
-DECLARE_OOXMLIMPORT_TEST(testBnc779620, "bnc779620.docx")
+CPPUNIT_TEST_FIXTURE(Test, testBnc779620)
{
+ createSwDoc("bnc779620.docx");
// The problem was that the floating table was imported as a non-floating one.
lcl_countTextFrames( mxComponent, 1 );
}
-DECLARE_OOXMLIMPORT_TEST(testTdf105127, "tdf105127.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf105127)
{
+ createSwDoc("tdf105127.docx");
auto aPolyPolygon = getProperty<drawing::PolyPolygonBezierCoords>(getShape(1), "PolyPolygonBezier");
// tdf#106792 These values were wrong all the time due to a missing
// conversion in SvxShapePolyPolygon::getPropertyValueImpl. There was no
@@ -756,32 +798,36 @@ DECLARE_OOXMLIMPORT_TEST(testTdf105127, "tdf105127.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5719), aPolyPolygon.Coordinates[0][0].Y); // was: 3257
}
-DECLARE_OOXMLIMPORT_TEST(testTdf105143, "tdf105143.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf105143)
{
- OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
+ createSwDoc("tdf105143.docx");
+ OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds"_ostr, "top"_ostr);
// This was 6272, i.e. the shape was moved up (incorrect position) to be
// inside the page rectangle.
CPPUNIT_ASSERT_EQUAL(OUString("6731"), aTop);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf105975, "105975.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf105975)
{
+ createSwDoc("105975.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters());
// Make sure we have a variable named TEST_VAR.
CPPUNIT_ASSERT(xMasters->hasByName("com.sun.star.text.FieldMaster.SetExpression.TEST_VAR"));
}
-DECLARE_OOXMLIMPORT_TEST(testfdo76583, "fdo76583.docx")
+CPPUNIT_TEST_FIXTURE(Test, testfdo76583)
{
+ createSwDoc("fdo76583.docx");
// The problem was that the floating table was imported as a non-floating one.
// floating tables are imported as text frames, therefore the document should
// exactly 1 text frame.
lcl_countTextFrames( mxComponent, 1 );
}
-DECLARE_OOXMLIMPORT_TEST(testTdf105975formula, "tdf105975.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf105975formula)
{
+ createSwDoc("tdf105975.docx");
// Make sure the field contains a formula with 10 + 15
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
@@ -797,8 +843,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf105975formula, "tdf105975.docx")
CPPUNIT_ASSERT_EQUAL(OUString("25"), xEnumerationAccess->getPresentation(false).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf133647, "tdf133647.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf133647)
{
+ createSwDoc("tdf133647.docx");
/* Tests that argument lists, cell references, and cell ranges are translated correctly
* when importing table formulae from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
@@ -847,8 +894,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf133647, "tdf133647.docx")
CPPUNIT_ASSERT_EQUAL(OUString("3"), xEnumerationAccess9->getPresentation(false).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf123386, "tdf123386.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf123386)
{
+ createSwDoc("tdf123386.docx");
/* Tests that argument lists, cell references, and cell ranges are translated correctly
* when importing table formulae from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
@@ -903,8 +951,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf123386, "tdf123386.docx")
}
-DECLARE_OOXMLIMPORT_TEST(testTdf133647_unicode, "tdf133647_unicode.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf133647_unicode)
{
+ createSwDoc("tdf133647_unicode.docx");
/* Tests that non-ASCII characters in formulas are preserved when importing from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
@@ -920,17 +969,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf133647_unicode, "tdf133647_unicode.docx")
xFields->nextElement();
uno::Reference<text::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString(u"defined(預期結果)"), xEnumerationAccess1->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(u"defined(預期結果)"_ustr, xEnumerationAccess1->getPresentation(true).trim());
uno::Reference<text::XTextField> xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString(u"defined(نتيجةمتوقعة)"), xEnumerationAccess2->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(u"defined(نتيجةمتوقعة)"_ustr, xEnumerationAccess2->getPresentation(true).trim());
uno::Reference<text::XTextField> xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString(u"defined(ExpectedResult)"), xEnumerationAccess3->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(u"defined(ExpectedResult)"_ustr, xEnumerationAccess3->getPresentation(true).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf123389, "tdf123389.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf123389)
{
+ createSwDoc("tdf123389.docx");
/* Tests that argument lists, cell references, and cell ranges are translated correctly
* when importing table formulae from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
@@ -952,8 +1002,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf123389, "tdf123389.docx")
}
-DECLARE_OOXMLIMPORT_TEST(testTdf107784, "tdf107784.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf107784)
{
+ createSwDoc("tdf107784.docx");
// Make sure the field displays the citation's title and not the identifier
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
@@ -969,20 +1020,22 @@ DECLARE_OOXMLIMPORT_TEST(testTdf107784, "tdf107784.docx")
CPPUNIT_ASSERT_EQUAL(OUString("(Smith, 1950)"), xEnumerationAccess->getPresentation(false).trim());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf115883, "tdf115883.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf115883)
{
+ createSwDoc("tdf115883.docx");
// Import failed due to an unhandled exception when getting the Surround
// property of a not yet inserted frame.
}
-DECLARE_OOXMLIMPORT_TEST(testTdf75573, "tdf75573_page1frame.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf75573)
{
+ createSwDoc("tdf75573_page1frame.docx");
// the problem was that the frame was discarded
// when an unrelated, unused, odd-header was flagged as discardable
lcl_countTextFrames( mxComponent, 1 );
// the frame should be on page 1
- CPPUNIT_ASSERT_EQUAL( OUString("lorem ipsum"), parseDump("/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()") );
+ CPPUNIT_ASSERT_EQUAL( OUString("lorem ipsum"), parseDump("/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()"_ostr) );
// the "Proprietary" style should set the vertical and horizontal anchors to the page
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
@@ -1001,8 +1054,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573, "tdf75573_page1frame.docx")
CPPUNIT_ASSERT(!bProt);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf75573_lostTable)
{
+ createSwDoc("tdf75573_lostTable.docx");
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of tables", sal_Int32(1), xTables->getCount() );
@@ -1012,8 +1066,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of pages", 3, getPages() );
}
-DECLARE_OOXMLIMPORT_TEST(testTdf109316_dropCaps, "tdf109316_dropCaps.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf109316_dropCaps)
{
+ createSwDoc("tdf109316_dropCaps.docx");
uno::Reference<beans::XPropertySet> xSet(getParagraph(1), uno::UNO_QUERY);
css::style::DropCapFormat aDropCap = getProperty<css::style::DropCapFormat>(xSet,"DropCapFormat");
CPPUNIT_ASSERT_EQUAL( sal_Int8(2), aDropCap.Lines );
@@ -1033,23 +1088,26 @@ DECLARE_OOXMLIMPORT_TEST(testTdf109316_dropCaps, "tdf109316_dropCaps.docx")
CPPUNIT_ASSERT_EQUAL( sal_Int16(0), aDropCap.Distance );
}
-DECLARE_OOXMLIMPORT_TEST(lineWpsOnly, "line-wps-only.docx")
+CPPUNIT_TEST_FIXTURE(Test, lineWpsOnly)
{
+ createSwDoc("line-wps-only.docx");
uno::Reference<drawing::XShape> xShape = getShape(1);
// Check position, it was -7223 as it was set after the CustomShapeGeometry property.
CPPUNIT_ASSERT_EQUAL(sal_Int32(210), xShape->getPosition().X);
}
-DECLARE_OOXMLIMPORT_TEST(lineRotation, "line-rotation.docx")
+CPPUNIT_TEST_FIXTURE(Test, lineRotation)
{
+ createSwDoc("line-rotation.docx");
uno::Reference<drawing::XShape> xShape = getShape(3);
// This was 5096: the line was shifted towards the bottom, so the end of
// the 3 different lines wasn't at the same point.
CPPUNIT_ASSERT_EQUAL(sal_Int32(4808), xShape->getPosition().Y);
}
-DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx")
+CPPUNIT_TEST_FIXTURE(Test, textboxWpsOnly)
{
+ createSwDoc("textbox-wps-only.docx");
uno::Reference<text::XTextRange> xFrame(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Hello world!"), xFrame->getString());
// Position wasn't horizontally centered.
@@ -1067,33 +1125,36 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx")
if ( nsScreen.frame.size.width * scaleFactor > 4000 )
return;
#endif
- // Vertically oriented to page due to tdf#135198
- CPPUNIT_ASSERT_EQUAL(sal_Int32(5304), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
}
-DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx")
+CPPUNIT_TEST_FIXTURE(Test, testGroupshapeRelsize)
{
+ createSwDoc("groupshape-relsize.docx");
// This was 43760, i.e. the height of the groupshape was larger than the page height, which is obviously incorrect.
CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(9142730), getShape(1)->getSize().Height);
}
-DECLARE_OOXMLIMPORT_TEST(testOleAnchor, "ole-anchor.docx")
+CPPUNIT_TEST_FIXTURE(Test, testOleAnchor)
{
+ createSwDoc("ole-anchor.docx");
// This was AS_CHARACTER, even if the VML style explicitly contains "position:absolute".
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
// This was DYNAMIC, even if the default is THROUGH and there is no w10:wrap element in the bugdoc.
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf48658_transparentOLEheader, "tdf48658_transparentOLEheader.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf48658_transparentOLEheader)
{
+ createSwDoc("tdf48658_transparentOLEheader.docx");
// The problem was that the shape in the header was hidden in the background.
// The round-tripped document was always fine (even before the fix) but the shape numbers change, so import-only test.
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getShape(1), "Opaque"));
}
-DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust.docx")
+CPPUNIT_TEST_FIXTURE(Test, testDMLGroupShapeParaAdjust)
{
+ createSwDoc("dml-groupshape-paraadjust.docx");
// Paragraph adjustment inside a group shape was not imported
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_THROW)->getText();
@@ -1111,28 +1172,32 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), "ParaAdjust"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf99135, "tdf99135.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf99135)
{
+ createSwDoc("tdf99135.docx");
// This was 0, crop was ignored on VML import.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1825), getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop").Bottom);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf85523, "tdf85523.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf85523)
{
+ createSwDoc("tdf85523.docx");
auto xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 7), "TextField");
auto xText = getProperty< uno::Reference<text::XText> >(xTextField, "TextRange");
// This was "commentX": an unexpected extra char was added at the comment end.
getParagraphOfText(1, xText, "comment");
}
-DECLARE_OOXMLIMPORT_TEST(testStrictLockedcanvas, "strict-lockedcanvas.docx")
+CPPUNIT_TEST_FIXTURE(Test, testStrictLockedcanvas)
{
+ createSwDoc("strict-lockedcanvas.docx");
// locked canvas shape was missing.
getShape(1);
}
-DECLARE_OOXMLIMPORT_TEST(testFdo75722vml, "fdo75722-vml.docx")
+CPPUNIT_TEST_FIXTURE(Test, testFdo75722vml)
{
+ createSwDoc("fdo75722-vml.docx");
uno::Reference<drawing::XShape> xShape = getShape(1);
awt::Point aPos = xShape->getPosition();
awt::Size aSize = xShape->getSize();
@@ -1145,8 +1210,9 @@ DECLARE_OOXMLIMPORT_TEST(testFdo75722vml, "fdo75722-vml.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int64(3100), nRot);
}
-DECLARE_OOXMLIMPORT_TEST(testFdo75722dml, "fdo75722-dml.docx")
+CPPUNIT_TEST_FIXTURE(Test, testFdo75722dml)
{
+ createSwDoc("fdo75722-dml.docx");
uno::Reference<drawing::XShape> xShape = getShape(1);
awt::Point aPos = xShape->getPosition();
awt::Size aSize = xShape->getSize();
@@ -1160,28 +1226,31 @@ DECLARE_OOXMLIMPORT_TEST(testFdo75722dml, "fdo75722-dml.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot);
}
-DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat.docx")
+CPPUNIT_TEST_FIXTURE(Test, testUnbalancedColumnsCompat)
{
+ createSwDoc("unbalanced-columns-compat.docx");
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
// This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
}
-DECLARE_OOXMLIMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-columns.docx")
+CPPUNIT_TEST_FIXTURE(Test, testFloatingTableSectionColumns)
{
- OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width");
+ createSwDoc("floating-table-section-columns.docx");
+ OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds"_ostr, "width"_ostr);
// table width was restricted by a column
CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
}
-static OString dateTimeToString( const util::DateTime& dt )
+OString dateTimeToString( const util::DateTime& dt )
{
return DateTimeToOString( DateTime( Date( dt.Day, dt.Month, dt.Year ), tools::Time( dt.Hours, dt.Minutes, dt.Seconds )));
}
-DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
+CPPUNIT_TEST_FIXTURE(Test, testBnc821804)
{
+ createSwDoc("bnc821804.docx");
CPPUNIT_ASSERT_EQUAL( OUString( "TITLE" ), getRun( getParagraph( 1 ), 1 )->getString());
CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(1), 1), "RedlineType"));
// Redline information (SwXRedlinePortion) are separate "runs" apparently.
@@ -1189,7 +1258,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(1), 2), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(1), 2), "IsStart"));
CPPUNIT_ASSERT_EQUAL(OUString("unknown1"),getProperty<OUString>(getRun(getParagraph(1), 2), "RedlineAuthor"));
- CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:46:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 2), "RedlineDateTime")));
+ CPPUNIT_ASSERT_EQUAL("2006-08-29T09:46:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 2), "RedlineDateTime")));
// So only the 3rd run is actual text (and the two runs have been merged into one, not sure why, but that shouldn't be a problem).
CPPUNIT_ASSERT_EQUAL(OUString(" (1st run of an insert) (2nd run of an insert)"), getRun(getParagraph(1),3)->getString());
CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(1), 3), "RedlineType"));
@@ -1197,7 +1266,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 4), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(1), 4), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("unknown1"),getProperty<OUString>(getRun(getParagraph(1), 4), "RedlineAuthor"));
- CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:46:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 4), "RedlineDateTime")));
+ CPPUNIT_ASSERT_EQUAL("2006-08-29T09:46:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 4), "RedlineDateTime")));
CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(1), 4), "IsStart"));
CPPUNIT_ASSERT_EQUAL(OUString("Normal text"), getRun(getParagraph(2),1)->getString());
@@ -1206,7 +1275,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 1), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(3), 1), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("unknown2"),getProperty<OUString>(getRun(getParagraph(3), 1), "RedlineAuthor"));
- CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:47:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(3), 1), "RedlineDateTime")));
+ CPPUNIT_ASSERT_EQUAL("2006-08-29T09:47:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(3), 1), "RedlineDateTime")));
CPPUNIT_ASSERT_EQUAL(OUString("Deleted"), getRun(getParagraph(3),2)->getString());
// This is both inserted and formatted, so there are two SwXRedlinePortion "runs". Given that the redlines overlap and Writer core
@@ -1233,7 +1302,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Format"),getProperty<OUString>(getRun(getParagraph(6), 1), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(6), 1), "IsStart"));
CPPUNIT_ASSERT_EQUAL(OUString("unknown5"),getProperty<OUString>(getRun(getParagraph(6), 1), "RedlineAuthor"));
- CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T10:02:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(6), 1), "RedlineDateTime")));
+ CPPUNIT_ASSERT_EQUAL("2006-08-29T10:02:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(6), 1), "RedlineDateTime")));
CPPUNIT_ASSERT_EQUAL(OUString("Formatted run"), getRun(getParagraph(6),2)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(6), 3), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("Format"),getProperty<OUString>(getRun(getParagraph(6), 3), "RedlineType"));
@@ -1244,7 +1313,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(6), 5), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(6), 5), "IsStart"));
CPPUNIT_ASSERT_EQUAL(OUString("unknown6"),getProperty<OUString>(getRun(getParagraph(6), 5), "RedlineAuthor"));
- CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:48:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(6), 5), "RedlineDateTime")));
+ CPPUNIT_ASSERT_EQUAL("2006-08-29T09:48:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(6), 5), "RedlineDateTime")));
CPPUNIT_ASSERT_EQUAL(OUString("and inserted again"), getRun(getParagraph(6),6)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(6), 7), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(6), 7), "RedlineType"));
@@ -1303,13 +1372,23 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(10), 3), "IsStart"));
}
-DECLARE_OOXMLIMPORT_TEST(testFdo87488, "fdo87488.docx")
+CPPUNIT_TEST_FIXTURE(Test, testFdo87488)
{
// The shape on the right (index 0, CustomShape within a
// GroupShape) is rotated 90 degrees clockwise and contains text
- // rotated 90 degrees anticlockwise. Must be read with SmartArt
- // enabled in preTest above, otherwise it gets converted to a
- // StarView MetaFile.
+ // rotated 90 degrees anticlockwise.
+ bool bOrigSet = officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
+ Resetter resetter(
+ [bOrigSet] () {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(bOrigSet, pBatch);
+ return pBatch->commit();
+ });
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pBatch);
+ pBatch->commit();
+ createSwDoc("fdo87488.docx");
uno::Reference<container::XIndexAccess> group(getShape(1), uno::UNO_QUERY);
{
uno::Reference<text::XTextRange> text(group->getByIndex(1), uno::UNO_QUERY);
@@ -1318,34 +1397,28 @@ DECLARE_OOXMLIMPORT_TEST(testFdo87488, "fdo87488.docx")
{
uno::Reference<beans::XPropertySet> props(group->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(props->getPropertyValue("RotateAngle"),
- uno::makeAny<sal_Int32>(270 * 100));
+ uno::Any(sal_Int32(270 * 100)));
comphelper::SequenceAsHashMap geom(props->getPropertyValue("CustomShapeGeometry"));
- CPPUNIT_ASSERT_EQUAL(sal_Int32(90), geom["TextPreRotateAngle"].get<sal_Int32>());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(90), geom["TextRotateAngle"].get<sal_Int32>());
}
}
-DECLARE_OOXMLIMPORT_TEST(testTdf85232, "tdf85232.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf85232)
{
+ createSwDoc("tdf85232.docx");
uno::Reference<drawing::XShapes> xShapes(getShapeByName(u"Group 219"), uno::UNO_QUERY);
uno::Reference<drawing::XShape> xShape(xShapes->getByIndex(1), uno::UNO_QUERY);
uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor = xShape;
// Make sure we're not testing the ellipse child.
CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.LineShape"), xShapeDescriptor->getShapeType());
- // tdf#106792 checked that during load of tdf85232.docx the method
- // SvxShapePolyPolygon::setPropertyValueImpl is used three times. In
- // that method, a call to ForceMetricToItemPoolMetric was missing so
- // that the import did not convert the input values from 100thmm
- // to twips what is needed due to the object residing in Writer. The
- // UNO API by definition is in 100thmm. Result is that in SwXShape::getPosition
- // the offset (aOffset) now is (0, 0) instead of an existing offset in
- // the load of the document before (what is plausible for a GroupObject).
- // Thus, I will adapt the result value here to the now (hopefully) correct one.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1630), xShape->getPosition().X); // was: 2267
+ // This was 2900: horizontal position of the line was incorrect, the 3 children were not connected visually.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2265), xShape->getPosition().X);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf95755, "tdf95755.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf95755)
{
+ createSwDoc("tdf95755.docx");
/*
* The problem was that the width of a second table with single cell was discarded
* and resulted in too wide table
@@ -1356,11 +1429,12 @@ DECLARE_OOXMLIMPORT_TEST(testTdf95755, "tdf95755.docx")
uno::Any aValue = xTableProperties->getPropertyValue("Width");
sal_Int32 nWidth;
aValue >>= nWidth;
- CPPUNIT_ASSERT_EQUAL(sal_Int32(10659), nWidth);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(10592), nWidth);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf60351, "tdf60351.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf60351)
{
+ createSwDoc("tdf60351.docx");
// Get the first image in the document and check its contour polygon.
// It should contain 6 points. Check their coordinates.
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
@@ -1386,8 +1460,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf60351, "tdf60351.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPolygon[5].Y);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf95970, "tdf95970.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf95970)
{
+ createSwDoc("tdf95970.docx");
// First shape: the rotation should be -12.94 deg, it should be mirrored.
// Proper color order of image on test doc (left->right):
// top row: green->red
@@ -1413,8 +1488,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf95970, "tdf95970.docx")
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column3, 1.0));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf96674, "tdf96674.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf96674)
{
+ createSwDoc("tdf96674.docx");
uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT(xShape.is());
awt::Size aActualSize(xShape->getSize());
@@ -1423,22 +1499,39 @@ DECLARE_OOXMLIMPORT_TEST(testTdf96674, "tdf96674.docx")
CPPUNIT_ASSERT(aActualSize.Height > 0);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf98882, "tdf98882.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf122717)
+{
+ createSwDoc("tdf122717.docx");
+ uno::Reference<drawing::XShape> xShape = getShape(1);
+ CPPUNIT_ASSERT(xShape.is());
+ awt::Size aActualSize(xShape->getSize());
+ // Without the fix in place, this test would have failed with
+ // - Expected: 2
+ // - Actual : 8160
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aActualSize.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8160), aActualSize.Height);
+
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf98882)
{
- sal_Int32 nFlyHeight = parseDump("//fly/infos/bounds", "height").toInt32();
- sal_Int32 nContentHeight = parseDump("//notxt/infos/bounds", "height").toInt32();
+ createSwDoc("tdf98882.docx");
+ sal_Int32 nFlyHeight = parseDump("//anchored/fly/infos/bounds"_ostr, "height"_ostr).toInt32();
+ sal_Int32 nContentHeight = parseDump("//notxt/infos/bounds"_ostr, "height"_ostr).toInt32();
// The content height was 600, not 360, so the frame and the content height did not match.
CPPUNIT_ASSERT_EQUAL(nFlyHeight, nContentHeight);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf100830, "tdf100830.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf100830)
{
+ createSwDoc("tdf100830.docx");
// FillTransparence wasn't imported, this was 0.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(30), getProperty<sal_Int16>(getShape(1), "FillTransparence"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf103664, "tdf103664.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf103664)
{
+ createSwDoc("tdf103664.docx");
// Wingdings symbols were displayed as rectangles
uno::Reference<text::XTextRange> xPara(getParagraph(1));
CPPUNIT_ASSERT_EQUAL(u'\xf020', xPara->getString()[0] );
@@ -1455,27 +1548,30 @@ DECLARE_OOXMLIMPORT_TEST(testTdf103664, "tdf103664.docx")
CPPUNIT_ASSERT_EQUAL(awt::CharSet::SYMBOL, getProperty<sal_Int16>(xRun, "CharFontCharSet"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf82824, "tdf82824.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf82824)
{
+ createSwDoc("tdf82824.docx");
// This was text::TextContentAnchorType_AS_CHARACTER, <wp:anchor> wasn't handled on import for the chart.
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf96218, "tdf96218.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf96218)
{
+ createSwDoc("tdf96218.docx");
// Image had a bad position because layoutInCell attribute was not ignored
CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "IsFollowingTextFlow"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf101626, "tdf101626.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf101626)
{
+ createSwDoc("tdf101626.docx");
// Transform soft-hyphen to hard-hyphen as list bulletChar to avoid missing symbols in export
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(0) >>= aProps; // 1st level
- for (beans::PropertyValue const & rProp : std::as_const(aProps))
+ for (beans::PropertyValue const& rProp : aProps)
{
if (rProp.Name == "BulletChar")
{
@@ -1486,8 +1582,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf101626, "tdf101626.docx")
}
}
-DECLARE_OOXMLIMPORT_TEST( testTdf106606, "tdf106606.docx" )
+CPPUNIT_TEST_FIXTURE(Test, testTdf106606)
{
+ createSwDoc("tdf106606.docx" );
auto FindGraphicBitmapPropertyInNumStyle = [&]( OUString rStyleName )
{
uno::Reference<beans::XPropertySet> xPropertySet( getStyles( "NumberingStyles" )->getByName( rStyleName ), uno::UNO_QUERY );
@@ -1495,7 +1592,7 @@ DECLARE_OOXMLIMPORT_TEST( testTdf106606, "tdf106606.docx" )
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex( 0 ) >>= aProps; // 1st level
- for ( beans::PropertyValue const & rProp : std::as_const(aProps))
+ for (beans::PropertyValue const& rProp : aProps)
{
// If the image was prematurely removed from cache when processed for previous numbering list, then the sequence hasn't the property.
if ( rProp.Name == "GraphicBitmap" )
@@ -1509,16 +1606,18 @@ DECLARE_OOXMLIMPORT_TEST( testTdf106606, "tdf106606.docx" )
CPPUNIT_ASSERT( FindGraphicBitmapPropertyInNumStyle("WWNum2") );
}
-DECLARE_OOXMLIMPORT_TEST(testTdf101627, "tdf101627.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf101627)
{
+ createSwDoc("tdf101627.docx");
// Do not shrink the textbox in the footer
uno::Reference<text::XTextRange> xFrame(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xFrame->getString().startsWith( "1" ) );
CPPUNIT_ASSERT_EQUAL(sal_Int32(466), getProperty<sal_Int32>(xFrame, "Height"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf133448, "tdf133448.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf133448)
{
+ createSwDoc("tdf133448.docx");
auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
Graphic aGraphic(xGraphic);
uno::Reference<beans::XPropertySet> xGraphicDescriptor(xGraphic, uno::UNO_QUERY_THROW);
@@ -1530,8 +1629,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf133448, "tdf133448.docx")
CPPUNIT_ASSERT_GREATER(sal_Int32(0), aSizePixel.Height);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf100072, "tdf100072.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf100072)
{
+ createSwDoc("tdf100072.docx");
uno::Reference<drawing::XShape> xShape = getShape(1);
// Ensure that shape has non-zero height
@@ -1563,24 +1663,26 @@ DECLARE_OOXMLIMPORT_TEST(testTdf100072, "tdf100072.docx")
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, rMetaFile);
// Get first polyline rightside x coordinate
- sal_Int32 nFirstEnd = getXPath(pXmlDoc, "(//polyline)[1]/point[2]", "x").toInt32();
+ sal_Int32 nFirstEnd = getXPath(pXmlDoc, "(//polyline)[1]/point[2]"_ostr, "x"_ostr).toInt32();
// Get last stroke x coordinate
- sal_Int32 nSecondEnd = getXPath(pXmlDoc, "(//polyline)[last()]/point[2]", "x").toInt32();
+ sal_Int32 nSecondEnd = getXPath(pXmlDoc, "(//polyline)[last()]/point[2]"_ostr, "x"_ostr).toInt32();
// Assert that the difference is less than half point.
CPPUNIT_ASSERT_MESSAGE("Shape line width does not match", abs(nFirstEnd - nSecondEnd) < 10);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf76446, "tdf76446.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf76446)
{
+ createSwDoc("tdf76446.docx");
uno::Reference<drawing::XShape> xShape = getShape(1);
sal_Int64 nRot = getProperty<sal_Int64>(xShape, "RotateAngle");
CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf108350, "tdf108350.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf108350)
{
+ createSwDoc("tdf108350.docx");
// For OOXML without explicit font information, font needs to be Calibri 11 pt
uno::Reference<text::XTextRange> xPara(getParagraph(1));
uno::Reference<beans::XPropertySet> xRun(getRun(xPara, 1), uno::UNO_QUERY);
@@ -1588,8 +1690,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108350, "tdf108350.docx")
CPPUNIT_ASSERT_EQUAL(double(11), getProperty<double>(xRun, "CharHeight"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf108408)
{
+ createSwDoc("tdf108408.docx");
// Font size must consider units specifications; previously ignored and only used
// integer part as half-pt size, i.e. 10 pt (20 half-pt) instead of 20 pt
uno::Reference<text::XTextRange> xPara(getParagraph(1));
@@ -1597,8 +1700,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
CPPUNIT_ASSERT_EQUAL(double(20), getProperty<double>(xRun, "CharHeight"));
}
-DECLARE_OOXMLIMPORT_TEST(testTdf108806, "tdf108806.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf108806)
{
+ createSwDoc("tdf108806.docx");
// tdf#108806:The CRLF in the text contents of XML must be converted to single spaces.
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
uno::Reference< text::XTextRange > paragraph = getParagraph(1);
@@ -1607,10 +1711,11 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108806, "tdf108806.docx")
paragraph->getString());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf87533_bidi, "tdf87533_bidi.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf87533_bidi)
{
+ createSwDoc("tdf87533_bidi.docx");
// "w:bidi" (specified inside Default paragraph properties) should not be ignored
- const OUString writingMode = "WritingMode"; //getPropertyName(PROP_WRITING_MODE);
+ static constexpr OUString writingMode = u"WritingMode"_ustr; //getPropertyName(PROP_WRITING_MODE);
// check: "Default Style" master-style has RTL
{
@@ -1639,19 +1744,21 @@ DECLARE_OOXMLIMPORT_TEST(testTdf87533_bidi, "tdf87533_bidi.docx")
}
}
-DECLARE_OOXMLIMPORT_TEST(testVmlAdjustments, "vml-adjustments.docx")
+CPPUNIT_TEST_FIXTURE(Test, testVmlAdjustments)
{
+ createSwDoc("vml-adjustments.docx");
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
comphelper::SequenceAsHashMap aGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues =
aGeometry["AdjustmentValues"].get<uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue>>();
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aAdjustmentValues.getLength());
- drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue = *aAdjustmentValues.begin();
+ drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue = *std::cbegin(aAdjustmentValues);
CPPUNIT_ASSERT_EQUAL(sal_Int32(17639), aAdjustmentValue.Value.get<sal_Int32>());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf108714)
{
+ createSwDoc("tdf108714.docx");
CPPUNIT_ASSERT_EQUAL(6, getParagraphs());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Page break is absent - we lost bug-to-bug compatibility with Word", 4, getPages());
@@ -1709,8 +1816,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
}
-DECLARE_OOXMLIMPORT_TEST(testTdf136952_pgBreak3, "tdf136952_pgBreak3.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf136952_pgBreak3)
{
+ createSwDoc("tdf136952_pgBreak3.docx");
// The original 6 page ODT was designed to visually exaggerate the problems
// of emulating LO's followed-by-page-style into MSWord's sections.
// While much has been improved, there are extra pages present, which still need fixing.
@@ -1719,20 +1827,22 @@ DECLARE_OOXMLIMPORT_TEST(testTdf136952_pgBreak3, "tdf136952_pgBreak3.docx")
//Do not lose the page::breakAfter. This SHOULD be on page 4, but sadly it is not.
//The key part of this test is that the page starts with "Lorem ipsum"
//Prior to this, there was no page break, and so it was in the middle of a page.
- CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/Text[1]", "Portion").startsWith("Lorem ipsum"));
+ CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]"_ostr, "portion"_ostr).startsWith("Lorem ipsum"));
}
-DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.docx")
+CPPUNIT_TEST_FIXTURE(Test, testImageLazyRead)
{
+ createSwDoc("image-lazy-read.docx");
auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
Graphic aGraphic(xGraphic);
// This failed, import loaded the graphic, it wasn't lazy-read.
CPPUNIT_ASSERT(!aGraphic.isAvailable());
}
-DECLARE_OOXMLIMPORT_TEST(testTdf108995, "xml_space.docx")
+CPPUNIT_TEST_FIXTURE(Test, testTdf108995)
{
+ createSwDoc("xml_space.docx");
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
// We need to take xml:space attribute into account
uno::Reference< text::XTextRange > paragraph = getParagraph(1);
@@ -1741,8 +1851,9 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108995, "xml_space.docx")
paragraph->getString());
}
-DECLARE_OOXMLIMPORT_TEST(testGroupShapeTextHighlight, "tdf131841_HighlightColorGroupedShape.docx")
+CPPUNIT_TEST_FIXTURE(Test, testGroupShapeTextHighlight)
{
+ createSwDoc("tdf131841_HighlightColorGroupedShape.docx");
// tdf#131841 Highlight color of text in grouped shapes was not imported.
// These are the possible highlight colors in MSO Word. Check that we import them properly.
@@ -1753,14 +1864,14 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeTextHighlight, "tdf131841_HighlightColorG
0xFF00FFUL, // magenta
0x0000FFUL, // blue
0xFF0000UL, // red
- 0x00008BUL, // dark blue
- 0x008B8BUL, // dark cyan
- 0x006400UL, // dark green
+ 0x000080UL, // dark blue
+ 0x008080UL, // dark cyan
+ 0x008000UL, // dark green
0x800080UL, // dark magenta
- 0x8B0000UL, // dark red
+ 0x800000UL, // dark red
0x808000UL, // dark yellow
- 0xA9A9A9UL, // dark grey
- 0xD3D3D3UL, // light grey
+ 0x808080UL, // dark grey
+ 0xC0C0C0UL, // light grey
0x000000UL // black
};
@@ -1776,12 +1887,13 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeTextHighlight, "tdf131841_HighlightColorG
uno::Reference<text::XTextRange> firstRun = getRun(firstParagraph, 1);
uno::Reference<beans::XPropertySet> props(firstRun, uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT_EQUAL(xColors[idx], props->getPropertyValue("CharBackColor").get<sal_uInt32>());
+ CPPUNIT_ASSERT_EQUAL(xColors[idx], props->getPropertyValue("CharHighlight").get<sal_uInt32>());
}
}
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
+} // end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */