[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Aug 21 06:29:21 PDT 2014


 sw/qa/extras/ooxmlexport/data/sdt-company-multipara.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx            |    9 ++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx             |   16 ++++++++++++++-
 sw/source/filter/ww8/docxattributeoutput.hxx             |    2 +
 writerfilter/source/ooxml/modelpreprocess.py             |    5 ----
 5 files changed, 26 insertions(+), 6 deletions(-)

New commits:
commit 60974f5643745b7714b5a8629d9c574224b67e8c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Aug 21 15:09:29 2014 +0200

    DOCX export: prevent multiple paragraphs in some SDT containers
    
    E.g. Word doesn't do anything if you hit return in the middle of a
    title; if that's so, then we should handle this situation on export as
    well.
    
    Change-Id: Ib5b52a59250b09c97023b53906b8046f530d0e31

diff --git a/sw/qa/extras/ooxmlexport/data/sdt-company-multipara.docx b/sw/qa/extras/ooxmlexport/data/sdt-company-multipara.docx
new file mode 100644
index 0000000..96d25ff
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/sdt-company-multipara.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index d52423f..9a8951d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -628,6 +628,15 @@ DECLARE_OOXMLEXPORT_TEST(testSdtHeader, "sdt-header.docx")
         assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:date", 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testSdtCompanyMultipara, "sdt-company-multipara.docx")
+{
+    if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+    {
+        // This was 3, but multiple paragraphs inside "Company" SDT is now allowed.
+        assertXPath(pXmlDoc, "//w:sdtContent/w:p", 1);
+    }
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 5e59bcc..f6ec6e3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -223,6 +223,12 @@ void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ )
         m_pSerializer->singleElementNS( XML_w, XML_rtl, FSNS( XML_w, XML_val ), "true", FSEND );
 }
 
+/// Are multiple paragraphs disallowed inside this type of SDT?
+static bool lcl_isOnelinerSdt(const OUString& rName)
+{
+    return rName == "Title" || rName == "Subtitle" || rName == "Company";
+}
+
 void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
 {
     if ( m_nColBreakStatus == COLBRK_POSTPONE )
@@ -292,12 +298,15 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
             bEndParaSdt = m_bStartedParaSdt && rMap.find("ParaSdtEndBefore") != rMap.end();
         }
     }
-    if (bEndParaSdt || (m_bStartedParaSdt && m_bHadSectPr))
+    // TODO also avoid multiline paragarphs in those SDT types for shape text
+    bool bOneliner = m_bStartedParaSdt && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() && lcl_isOnelinerSdt(m_aStartedParagraphSdtPrAlias);
+    if (bEndParaSdt || (m_bStartedParaSdt && m_bHadSectPr) || bOneliner)
     {
         // This is the common case: "close sdt before the current paragraph" was requrested by the next paragraph.
         EndSdtBlock();
         bEndParaSdt = false;
         m_bStartedParaSdt = false;
+        m_aStartedParagraphSdtPrAlias = "";
     }
     m_bHadSectPr = false;
 
@@ -7951,6 +7960,7 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
                 {
                     if (!(aPropertyValue.Value >>= m_aParagraphSdtPrAlias))
                         SAL_WARN("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unexpected sdt alias value");
+                    m_aStartedParagraphSdtPrAlias = m_aParagraphSdtPrAlias;
                 }
                 else if (aPropertyValue.Name == "ooxml:CT_SdtPr_checkbox")
                 {
@@ -8007,6 +8017,10 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
             uno::Sequence<beans::PropertyValue> aAttributes = i->second.get< uno::Sequence<beans::PropertyValue> >();
             m_pTableStyleExport->CnfStyle(aAttributes);
         }
+        else if (i->first == "ParaSdtEndBefore")
+        {
+            // Handled already in StartParagraph().
+        }
         else
             SAL_WARN("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unhandled grab bag property " << i->first );
     }
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index d0bfe92..1277203 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -911,6 +911,8 @@ private:
     ::sax_fastparser::FastAttributeList *m_pRunSdtPrDataBindingAttrs;
     /// Value of the <w:alias> paragraph SDT element.
     OUString m_aParagraphSdtPrAlias;
+    /// Same as m_aParagraphSdtPrAlias, but its content is aviailable till the SDT is closed.
+    OUString m_aStartedParagraphSdtPrAlias;
     OUString m_aRunSdtPrAlias;
     /// Currently paragraph SDT has a <w:id> child element.
     bool m_bParagraphSdtHasId;
commit 42faa9f0514c2f55f19cc04338518fd039e2883a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Aug 21 13:05:04 2014 +0200

    writerfilter: remove unused qname attribute
    
    Change-Id: I412390fba4caa4579dec0dab68f4a1c276284118

diff --git a/writerfilter/source/ooxml/modelpreprocess.py b/writerfilter/source/ooxml/modelpreprocess.py
index 11fa3e8..246fae3 100644
--- a/writerfilter/source/ooxml/modelpreprocess.py
+++ b/writerfilter/source/ooxml/modelpreprocess.py
@@ -134,11 +134,6 @@ def preprocess(model):
                 localname = j.getAttribute("name")
 
             # set the attributes
-            qname = ""
-            if len(ns):
-                qname += ns + ":"
-            j.setAttribute("qname", qname + localname)
-
             j.setAttribute("prefix", prefix)
             j.setAttribute("localname", localname)
 


More information about the Libreoffice-commits mailing list