sw/qa/core/frmedt/frmedt.cxx                       |    2 +-
 sw/qa/core/objectpositioning/objectpositioning.cxx |    4 ++--
 sw/qa/core/unocore/unocore.cxx                     |    4 ++--
 sw/qa/extras/globalfilter/globalfilter.cxx         |    5 +----
 sw/qa/extras/layout/layout2.cxx                    |   11 +++--------
 sw/qa/extras/odfimport/odfimport.cxx               |    9 +++------
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx         |   15 ++++++---------
 7 files changed, 18 insertions(+), 32 deletions(-)

New commits:
commit eb41a16530b6a37e2120a1a14975f024893a2ace
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Nov 10 12:27:46 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Nov 10 16:56:44 2022 +0100

    SwModelTestBase: use exisiting createSwDoc
    
    Change-Id: Ic55c245482d93f5ec26c90ca41fac29332bd807a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142549
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index 86f19a0ae17d..7a0520e4f8e3 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -68,7 +68,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, 
testVertPosFromBottomBoundingBox)
 {
     // Insert a shape and anchor it vertically in a way, so its position is 
from the top of the page
     // bottom margin area.
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
     uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<drawing::XShape> xShape(
         xFactory->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY);
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx 
b/sw/qa/core/objectpositioning/objectpositioning.cxx
index 94cb96e449ca..00c85221d1fd 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -48,7 +48,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, 
testOverlapCrash)
 CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testVertPosFromBottom)
 {
     // Create a document, insert a shape and position it 1cm above the bottom 
of the body area.
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
     uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<drawing::XShape> xShape(
         xFactory->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY);
@@ -79,7 +79,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, 
testVertAlignBottomMargin)
     // Create a document, insert three shapes and align it the 
bottom,center,top of page print area bottom.
     // The size of shapes are 284 ~ 0.5cm
     // The height of page print area bottom is 1134 ~ 2cm
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
     uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, 
uno::UNO_QUERY);
 
     //Create first shape and align bottom of page print area bottom.
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index b989a588b09e..2484dd05efb0 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -75,7 +75,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf119081)
 
 CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, flyAtParaAnchor)
 {
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
     uno::Reference<lang::XMultiServiceFactory> const xMSF(mxComponent, 
uno::UNO_QUERY_THROW);
     uno::Reference<text::XTextDocument> const xTD(mxComponent, 
uno::UNO_QUERY_THROW);
     uno::Reference<text::XTextFrame> const xTextFrame(
@@ -95,7 +95,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, flyAtParaAnchor)
 
 CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testRtlGutter)
 {
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
     uno::Reference<beans::XPropertySet> 
xPageStyle(getStyles("PageStyles")->getByName("Standard"),
                                                    uno::UNO_QUERY);
     // Without the accompanying fix in place, this test would have failed with:
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index c50e31f499b2..5db20aa7d7db 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -1068,10 +1068,7 @@ void Test::testRedlineFlags()
         "Office Open XML Text",
     };
 
-    mxComponent = loadFromDesktop("private:factory/swriter");
-    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument 
*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
-    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    SwDoc* pDoc = createSwDoc();
 
     SwPaM pam(SwPosition(pDoc->GetNodes().GetEndOfContent(), 
SwNodeOffset(-1)));
     pDoc->getIDocumentContentOperations().InsertString(pam, "foo bar baz");
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 116bec33c80e..99ef5cf22470 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -746,12 +746,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTableCellInvalidate)
     // inline the loading because currently properties can't be passed...
     mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument",
                                   
comphelper::containerToSequence(aFilterOptions));
-    uno::Sequence<beans::PropertyValue> 
props(comphelper::InitPropertySequence({
-        { "FilterName", uno::Any(OUString("writer_pdf_Export")) },
-    }));
-    utl::TempFileNamed aTempFile;
-    uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
-    xStorable->storeToURL(aTempFile.GetURL(), props);
+    save("writer_pdf_Export");
 
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
     // somehow these 2 rows overlapped in the PDF unless CalcLayout() runs
@@ -776,8 +771,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTableCellInvalidate)
                 "top", "7200");
     assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[2]/cell[1]/txt[1]/infos/bounds",
                 "height", "231");
-
-    aTempFile.EnableKillingFile();
 }
 
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf145719)
@@ -2246,6 +2239,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121509)
     CPPUNIT_ASSERT(pTriangleShapeFormat->SetFormatAttr(aNewAnch));
 
     // Reload (docx)
+    // FIXME: if we use 'reload' here, it fails with
+    //  Assertion `!m_pFirst && !m_pLast && "There are still indices 
registered"' failed.
     save("Office Open XML Text");
 
     // The second part: check if the reloaded doc has flys inside a fly
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index 8a6a4892f079..a0c82aa775e1 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1192,8 +1192,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf134971)
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf151375)
 {
-    // Create a new document.
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
 
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextDocument->getText();
@@ -1209,8 +1208,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf151375)
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf138879)
 {
-    // Create a new document.
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
 
     uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
     {
@@ -1228,8 +1226,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf138879)
 
 CPPUNIT_TEST_FIXTURE(Test, testPasteFirstParaDirectFormat)
 {
-    // Create a new document.
-    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    createSwDoc();
     {
         // Set some direct formatting on the first paragraph, but leave 
paragraph adjust at its
         // default (left).
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 8772c37d51fa..f3d309802acf 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -249,7 +249,7 @@ CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
 CPPUNIT_TEST_FIXTURE(Test, testContentControlExport)
 {
     // Given a document with a content control around one or more text 
portions:
-    mxComponent = loadFromDesktop("private:factory/swriter");
+    createSwDoc();
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextDocument->getText();
@@ -280,7 +280,7 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlExport)
 CPPUNIT_TEST_FIXTURE(Test, testCheckboxContentControlExport)
 {
     // Given a document with a checkbox content control around a text portion:
-    mxComponent = loadFromDesktop("private:factory/swriter");
+    createSwDoc();
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextDocument->getText();
@@ -315,7 +315,7 @@ CPPUNIT_TEST_FIXTURE(Test, testCheckboxContentControlExport)
 CPPUNIT_TEST_FIXTURE(Test, testDropdownContentControlExport)
 {
     // Given a document with a dropdown content control around a text portion:
-    mxComponent = loadFromDesktop("private:factory/swriter");
+    createSwDoc();
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextDocument->getText();
@@ -367,7 +367,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDropdownContentControlExport)
 CPPUNIT_TEST_FIXTURE(Test, testPictureContentControlExport)
 {
     // Given a document with a picture content control around a text portion:
-    mxComponent = loadFromDesktop("private:factory/swriter");
+    createSwDoc();
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextDocument->getText();
@@ -401,7 +401,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPictureContentControlExport)
 CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport)
 {
     // Given a document with a date content control around a text portion:
-    mxComponent = loadFromDesktop("private:factory/swriter");
+    createSwDoc();
     uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextDocument->getText();
@@ -983,10 +983,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148455_2, 
"tdf148455_2.docx")
 CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW)
 {
     load("tdf147978_enhancedPath_commandABVW.odt");
-    CPPUNIT_ASSERT(mxComponent);
-    save("Office Open XML Text");
-    mxComponent->dispose();
-    mxComponent = loadFromDesktop(maTempFile.GetURL(), 
"com.sun.star.text.TextDocument");
+    reload("Office Open XML Text", nullptr);
     // Make sure the new implemented export for commands A,B,V and W use the 
correct arc between
     // the given two points, here the short one.
     for (sal_Int16 i = 1 ; i <= 4; ++i)

Reply via email to