[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 3 commits - sw/qa sw/source writerfilter/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 19 12:56:14 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf122186_input_list.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx             |   10 +
 sw/qa/extras/uiwriter/uiwriter2.cxx                    |  102 ++++++++++-------
 sw/source/filter/ww8/docxattributeoutput.cxx           |    8 +
 sw/source/uibase/docvw/FloatingTableButton.cxx         |   35 +++++
 writerfilter/source/dmapper/SdtHelper.cxx              |    2 
 6 files changed, 114 insertions(+), 43 deletions(-)

New commits:
commit 235f91dd460e7c8312e23868dfdadbb1bb3bf5aa
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jan 30 16:43:28 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 14:50:50 2019 +0200

    Unfloat: Fix some issues with unfloat operation
    
    - Use the correct method to remove the frame, so DOC
    export will work correctly.
    - Remove pagedesc attribute of the first text node if
    the table is moved before it to avoid to generate a page
    break.
    
    Reviewed-on: https://gerrit.libreoffice.org/67093
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 70c29e50af8e16b864d1e5e5a74c30a1de8250de)
    
    Unfloat: Need to move the page desc into the table node AttrSet
    
    Reviewed-on: https://gerrit.libreoffice.org/67126
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 9d319865f8bf78d25ca2e614d148420054a6461a)
    
    b9868bb31238905dd178fcf54c79f013079a037b
    Reviewed-on: https://gerrit.libreoffice.org/67098
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Miklos Vajna <vmiklos at collabora.com>
    
    Change-Id: I02802c4d25c947ec140b846c594848117815f1ce

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 14d0bd77ac49..a88bc96b5c4d 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -33,6 +33,7 @@
 #include <sortedobjs.hxx>
 #include <anchoredobject.hxx>
 #include <swtypes.hxx>
+#include <vcl/scheduler.hxx>
 
 namespace
 {
@@ -882,49 +883,70 @@ void SwUiWriterTest2::testUnfloatButtonReadOnlyMode()
 
 void SwUiWriterTest2::testUnfloating()
 {
-    // Test what happens when pushing the unfloat button
-    load(FLOATING_TABLE_DATA_DIRECTORY, "unfloatable_floating_table.odt");
-    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
-    CPPUNIT_ASSERT(pTextDoc);
-    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
-    CPPUNIT_ASSERT(pWrtShell);
-
-    SwFlyFrame* pFlyFrame;
+    // Test unfloating with tables imported from different file formats
+    const std::vector<OUString> aTestFiles = {
+        "unfloatable_floating_table.odt",
+        "unfloatable_floating_table.docx",
+        "unfloatable_floating_table.doc",
+    };
 
-    // Before unfloating we have only one page with a fly frame
+    for (const OUString& aTestFile : aTestFiles)
     {
-        CPPUNIT_ASSERT_EQUAL(SwFrameType::Page, pWrtShell->GetLayout()->GetLower()->GetType());
-        CPPUNIT_ASSERT(!pWrtShell->GetLayout()->GetLower()->GetNext());
-        CPPUNIT_ASSERT_EQUAL(SwFrameType::Txt,
-                             pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType());
-        const SwSortedObjs* pAnchored
-            = pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs();
-        CPPUNIT_ASSERT(pAnchored);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pAnchored->size());
-        SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
-        pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
-        CPPUNIT_ASSERT(pFlyFrame);
-    }
+        OString sTestFileName = OUStringToOString(aTestFile, RTL_TEXTENCODING_UTF8);
+        OString sFailureMessage = OString("Failure in the test file: ") + sTestFileName;
 
-    // Select the floating table
-    SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject();
-    CPPUNIT_ASSERT(pObj);
-    pWrtShell->SelectObj(Point(), 0, pObj);
-    CPPUNIT_ASSERT(pFlyFrame->IsShowUnfloatButton(pWrtShell));
-
-    // Push the unfloat button
-    pFlyFrame->ActiveUnfloatButton(pWrtShell);
-
-    // After unfloating we have two pages with one tablre frame on each page
-    CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetNext());
-    CPPUNIT_ASSERT_EQUAL(SwFrameType::Page,
-                         pWrtShell->GetLayout()->GetLower()->GetNext()->GetType());
-    CPPUNIT_ASSERT(!pWrtShell->GetLayout()->GetLower()->GetNext()->GetNext());
-    CPPUNIT_ASSERT_EQUAL(SwFrameType::Tab,
-                         pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType());
-    CPPUNIT_ASSERT_EQUAL(
-        SwFrameType::Tab,
-        pWrtShell->GetLayout()->GetLower()->GetNext()->GetLower()->GetLower()->GetType());
+        // Test what happens when pushing the unfloat button
+        load(FLOATING_TABLE_DATA_DIRECTORY, "unfloatable_floating_table.docx");
+        SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+        CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pTextDoc);
+        SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+        CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pWrtShell);
+
+        SwFlyFrame* pFlyFrame;
+
+        // Before unfloating we have only one page with a fly frame
+        {
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailureMessage.getStr(), SwFrameType::Page,
+                                         pWrtShell->GetLayout()->GetLower()->GetType());
+            CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(),
+                                   !pWrtShell->GetLayout()->GetLower()->GetNext());
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(
+                sFailureMessage.getStr(), SwFrameType::Txt,
+                pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType());
+            const SwSortedObjs* pAnchored
+                = pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs();
+            CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pAnchored);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailureMessage.getStr(), static_cast<size_t>(1),
+                                         pAnchored->size());
+            SwAnchoredObject* pAnchoredObj = (*pAnchored)[0];
+            pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
+            CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pFlyFrame);
+        }
+
+        // Select the floating table
+        SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject();
+        CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pObj);
+        pWrtShell->SelectObj(Point(), 0, pObj);
+        CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(), pFlyFrame->IsShowUnfloatButton(pWrtShell));
+
+        // Push the unfloat button
+        pFlyFrame->ActiveUnfloatButton(pWrtShell);
+        Scheduler::ProcessEventsToIdle();
+
+        // After unfloating we have two pages with one table frame on each page
+        CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(),
+                               pWrtShell->GetLayout()->GetLower()->GetNext());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailureMessage.getStr(), SwFrameType::Page,
+                                     pWrtShell->GetLayout()->GetLower()->GetNext()->GetType());
+        CPPUNIT_ASSERT_MESSAGE(sFailureMessage.getStr(),
+                               !pWrtShell->GetLayout()->GetLower()->GetNext()->GetNext());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE(
+            sFailureMessage.getStr(), SwFrameType::Tab,
+            pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE(
+            sFailureMessage.getStr(), SwFrameType::Tab,
+            pWrtShell->GetLayout()->GetLower()->GetNext()->GetLower()->GetLower()->GetType());
+    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
diff --git a/sw/source/uibase/docvw/FloatingTableButton.cxx b/sw/source/uibase/docvw/FloatingTableButton.cxx
index c2494945ba24..2c52e2641c2d 100644
--- a/sw/source/uibase/docvw/FloatingTableButton.cxx
+++ b/sw/source/uibase/docvw/FloatingTableButton.cxx
@@ -11,17 +11,22 @@
 #include <HeaderFooterWin.hxx>
 
 #include <edtwin.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
 #include <strings.hrc>
+#include <fmtpdsc.hxx>
 #include <vcl/metric.hxx>
 #include <viewopt.hxx>
 #include <frame.hxx>
 #include <flyfrm.hxx>
 #include <tabfrm.hxx>
 #include <txtfrm.hxx>
+#include <pagefrm.hxx>
 #include <ndindex.hxx>
 #include <swtable.hxx>
 #include <IDocumentState.hxx>
 #include <IDocumentUndoRedo.hxx>
+#include <IDocumentLayoutAccess.hxx>
 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <drawinglayer/attribute/fontattribute.hxx>
@@ -104,12 +109,40 @@ void FloatingTableButton::MouseButtonDown(const MouseEvent& /*rMEvt*/)
 
     SwDoc& rDoc = *pTextFrame->GetTextNodeFirst()->GetDoc();
 
+    // When we move the table before the first text node, we need to clear RES_PAGEDESC attribute
+    // of the text node otherwise LO will create a page break after the table
+    if (pTextFrame->GetTextNodeFirst())
+    {
+        const SwPageDesc* pPageDesc
+            = pTextFrame->GetAttrSet()->GetPageDesc().GetPageDesc(); // First text node of the page has this
+        if (pPageDesc)
+        {
+            // First set the existing page desc for the table node
+            SfxItemSet aSet(GetEditWin()->GetView().GetWrtShell().GetAttrPool(),
+                            svl::Items<RES_PAGEDESC, RES_PAGEDESC>{});
+            aSet.Put(SwFormatPageDesc(pPageDesc));
+            SwPaM aPaMTable(*pTableNode);
+            rDoc.getIDocumentContentOperations().InsertItemSet(
+                aPaMTable, aSet, SetAttrMode::DEFAULT);
+
+            // Then remove pagedesc from the attributes of the text node
+            aSet.Put(SwFormatPageDesc(nullptr));
+            SwPaM aPaMTextNode(*pTextFrame->GetTextNodeFirst());
+            rDoc.getIDocumentContentOperations().InsertItemSet(
+                aPaMTextNode, aSet, SetAttrMode::DEFAULT);
+        }
+    }
+
     // Move the table outside of the text frame
     SwNodeRange aRange(*pTableNode, 0, *pTableNode->EndOfSectionNode(), 1);
     rDoc.getIDocumentContentOperations().MoveNodeRange(aRange, aInsertPos, SwMoveFlags::DEFAULT);
 
     // Remove the floating table's frame
-    SwFrame::DestroyFrame(pFlyFrame);
+    SwFlyFrameFormat* pFrameFormat = pFlyFrame->GetFormat();
+    if (pFrameFormat)
+    {
+        rDoc.getIDocumentLayoutAccess().DelLayoutFormat(pFrameFormat);
+    }
 
     rDoc.getIDocumentState().SetModified();
 
commit 1d3a32bd04178338d84c3215023337aa1577d929
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jan 14 15:12:16 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 14:40:22 2019 +0200

    tdf#122186: Fix broken Input list after RT in DOCX format
    
    We should not write out the text of the field, because it
    confuses the import code and it's unneeded anyway.
    
    Reviewed-on: https://gerrit.libreoffice.org/66338
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 35ea8fc24ae749b8a87b7ddb5df22ecc4f58cfd3)
    
    Change-Id: Id114f74c5d135e9fe6cb059e25ebf324464c8362
    Reviewed-on: https://gerrit.libreoffice.org/66378
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf122186_input_list.odt b/sw/qa/extras/ooxmlexport/data/tdf122186_input_list.odt
new file mode 100755
index 000000000000..76a6289f7045
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf122186_input_list.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 018aa8ccfcb8..8a82f0f04d38 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -952,6 +952,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf123054, "tdf123054.docx")
                          getProperty<OUString>(getParagraph(20), "ParaStyleName"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testInputListExport, "tdf122186_input_list.odt")
+{
+    // We need to make sure we don't export the text itself next to the input list field
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r", 5);
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 4d7956f9047b..8fcc14b6d8b9 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2178,7 +2178,7 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
             sExpand = static_cast<SwAuthorityField const*>(rInfos.pField.get())
                         ->ExpandCitation(AUTH_FIELD_TITLE, nullptr);
         }
-        else
+        else if(rInfos.eType != ww::eFORMDROPDOWN)
         {
             sExpand = rInfos.pField->ExpandField(true, nullptr);
         }
commit c4e9b22849c6409ddd1d793662159434c06d86a0
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Jan 14 11:27:11 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 14:34:13 2019 +0200

    tdf#122658: Empty date form field is not exported correctly to DOCX file
    
    We need to export date format and also text content
    in case of empty date field. Otherwise the exported
    date field will be lost during import into LO Writer
    or MSO Word.
    
    Reviewed-on: https://gerrit.libreoffice.org/66194
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 24613d7abf820aff639a276a1819ada8d83e9063)
    
    Change-Id: I5cf65bedba010f64ca8f56262057f3cce32b0943
    Reviewed-on: https://gerrit.libreoffice.org/66289
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 02745ac0654a..4d7956f9047b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5286,7 +5286,13 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
             }
         }
         else
+        {
             aContentText = xPropertySet->getPropertyValue("HelpText").get<OUString>();
+            if(aContentText.isEmpty())
+                aContentText = " "; // Need to write out something to have it imported by MS Word
+            if(sDateFormat.isEmpty())
+                sDateFormat = "dd/MM/yyyy"; // Need to set date format even if there is no date set
+        }
 
         // output component
 
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index cccebf1d260c..2f68af8a491e 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -163,7 +163,7 @@ void SdtHelper::createDateControl(OUString const& rContentText, const beans::Pro
         xPropertySet->setPropertyValue("Date", uno::makeAny(aDate));
     }
     else
-        xPropertySet->setPropertyValue("HelpText", uno::makeAny(rContentText));
+        xPropertySet->setPropertyValue("HelpText", uno::makeAny(rContentText.trim()));
 
     // append date format to grab bag
     comphelper::SequenceAsHashMap aGrabBag;


More information about the Libreoffice-commits mailing list