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

Miklos Vajna vmiklos at collabora.co.uk
Tue Aug 19 09:19:44 PDT 2014


 sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx |binary
 sw/source/filter/ww8/docxattributeoutput.cxx     |   15 ++++++++++++++-
 sw/source/filter/ww8/docxattributeoutput.hxx     |    4 ++++
 sw/source/filter/ww8/docxexport.cxx              |    4 ++++
 writerfilter/CustomTarget_source.mk              |    4 ++--
 writerfilter/source/ooxml/factoryimpl.py         |   23 ++++++++++++++++-------
 6 files changed, 40 insertions(+), 10 deletions(-)

New commits:
commit 788632dcb0450cc9863a5a332b6df50b92f30c4d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 19 18:12:16 2014 +0200

    DOCX export: handle SDT end right before a section break introducing headers
    
    Change-Id: I0fab5ae4335ed6016d31aa243b131899c3154388

diff --git a/sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx b/sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx
new file mode 100644
index 0000000..334b6e5
Binary files /dev/null and b/sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx differ
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b3f2255..9f43f7f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -292,13 +292,14 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
             bEndParaSdt = m_bStartedParaSdt && rMap.find("ParaSdtEndBefore") != rMap.end();
         }
     }
-    if (bEndParaSdt)
+    if (bEndParaSdt || (m_bStartedParaSdt && m_bHadSectPr))
     {
         // This is the common case: "close sdt before the current paragraph" was requrested by the next paragraph.
         EndSdtBlock();
         bEndParaSdt = false;
         m_bStartedParaSdt = false;
     }
+    m_bHadSectPr = false;
 
     // this mark is used to be able to enclose the paragraph inside a sdr tag.
     // We will only know if we have to do that later.
@@ -5390,6 +5391,7 @@ void DocxAttributeOutput::StartSection()
         aSeqOrder[i] = aOrder[i];
 
     m_pSerializer->mark( aSeqOrder );
+    m_bHadSectPr = true;
 }
 
 void DocxAttributeOutput::EndSection()
@@ -8216,6 +8218,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_pRedlineData( NULL ),
       m_nRedlineId( 0 ),
       m_bOpenedSectPr( false ),
+      m_bHadSectPr(false),
       m_bRunTextIsOn( false ),
       m_bWritingHeaderFooter( false ),
       m_bAnchorLinkedToNode(false),
@@ -8368,4 +8371,14 @@ void DocxAttributeOutput::AddToAttrList( ::sax_fastparser::FastAttributeList* &p
     va_end( args );
 }
 
+void DocxAttributeOutput::SetStartedParaSdt(bool bStartedParaSdt)
+{
+    m_bStartedParaSdt = bStartedParaSdt;
+}
+
+bool DocxAttributeOutput::IsStartedParaSdt()
+{
+    return m_bStartedParaSdt;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 343afaf..d0bfe92 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -746,6 +746,8 @@ private:
 
     /// Flag indicating that the section properties are being written
     bool m_bOpenedSectPr;
+    /// Did we have a section break in this paragraph? Set by StartSection(), reset by the next StartParagraph().
+    bool m_bHadSectPr;
 
     /// Flag indicating that the Run Text is being written
     bool m_bRunTextIsOn;
@@ -960,6 +962,8 @@ public:
     void SetAlternateContentChoiceOpen( bool bAltContentChoiceOpen ) { m_bAlternateContentChoiceOpen = bAltContentChoiceOpen; }
     bool IsAlternateContentChoiceOpen( ) { return m_bAlternateContentChoiceOpen; }
     void GetSdtEndBefore(const SdrObject* pSdrObj);
+    void SetStartedParaSdt(bool bStartedParaSdt);
+    bool IsStartedParaSdt();
 };
 
 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 43272db..7f8ef58 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -714,6 +714,9 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char*
     m_pVMLExport->SetFS( pFS );
     m_pSdrExport->setSerializer(pFS);
     SetFS( pFS );
+    bool bStartedParaSdt = m_pAttrOutput->IsStartedParaSdt();
+    m_pAttrOutput->SetStartedParaSdt(false);
+
     m_pAttrOutput->switchHeaderFooter(true, m_nHeadersFootersInSection++);
     // do the work
     WriteHeaderFooterText( rFmt, bHeader );
@@ -728,6 +731,7 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char*
     m_pVMLExport->SetFS( m_pDocumentFS );
     m_pSdrExport->setSerializer(m_pDocumentFS);
     SetFS( m_pDocumentFS );
+    m_pAttrOutput->SetStartedParaSdt(bStartedParaSdt);
 
     // close the tag
     sal_Int32 nReference;
commit 1c06dc14a1f4cf6bf6121aa9a7b62e8890256161
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 19 14:26:28 2014 +0200

    writerfilter: stop reading namespace-alias elements in factoryimpl
    
    Change-Id: I52c2298c9583617481069040e118520cf8935c6d

diff --git a/writerfilter/CustomTarget_source.mk b/writerfilter/CustomTarget_source.mk
index b3bc00c..2061780 100644
--- a/writerfilter/CustomTarget_source.mk
+++ b/writerfilter/CustomTarget_source.mk
@@ -69,9 +69,9 @@ writerfilter_SRC_ooxml_Preprocess_py=$(writerfilter_SRC)/ooxml/modelpreprocess.p
 writerfilter_SRC_ooxml_QNameToStr_py=$(writerfilter_SRC)/ooxml/qnametostr.py
 writerfilter_SRC_ooxml_ResourceIds_py=$(writerfilter_SRC)/ooxml/resourceids.py
 
-$(writerfilter_GEN_ooxml_Factory_cxx) : $(writerfilter_SRC)/ooxml/factoryimpl.py $(writerfilter_GEN_ooxml_Model_processed)
+$(writerfilter_GEN_ooxml_Factory_cxx) : $(writerfilter_SRC)/ooxml/factoryimpl.py $(writerfilter_DEP_ooxml_Namespaces_txt) $(writerfilter_GEN_ooxml_Model_processed)
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,PY ,1)
-	$(call gb_Helper_abbreviate_dirs, $(writerfilter_PYTHONCOMMAND) $< $(writerfilter_GEN_ooxml_Model_processed)) > $@
+	$(call gb_Helper_abbreviate_dirs, $(writerfilter_PYTHONCOMMAND) $< $(writerfilter_DEP_ooxml_Namespaces_txt) $(writerfilter_GEN_ooxml_Model_processed)) > $@
 
 $(writerfilter_GEN_ooxml_Factory_hxx) : $(writerfilter_SRC)/ooxml/factoryinc.py $(writerfilter_GEN_ooxml_Model_processed)
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,PY ,1)
diff --git a/writerfilter/source/ooxml/factoryimpl.py b/writerfilter/source/ooxml/factoryimpl.py
index a2af9c8e1..475620e 100644
--- a/writerfilter/source/ooxml/factoryimpl.py
+++ b/writerfilter/source/ooxml/factoryimpl.py
@@ -126,7 +126,7 @@ std::string fastTokenToId(sal_uInt32 nToken)
     {""")
 
     aliases = []
-    for alias in sorted([a.getAttribute("alias") for a in model.getElementsByTagName("namespace-alias")]):
+    for alias in sorted(ooxUrlAliases.values()):
         if not alias in aliases:
             aliases.append(alias)
             print("""    case oox::NMSP_%s:
@@ -160,11 +160,8 @@ def getFastParser(model):
     {
         mxFastParser = css::xml::sax::FastParser::create(mxContext);
 """)
-    aliases = {}
-    for alias in model.getElementsByTagName("namespace-alias"):
-        aliases[alias.getAttribute("name")] = alias.getAttribute("alias")
-    for name in sorted(aliases.keys()):
-        print("""        mxFastParser->registerNamespace("%s", oox::NMSP_%s);""" % (name, aliases[name]))
+    for url in sorted(ooxUrlAliases.keys()):
+        print("""        mxFastParser->registerNamespace("%s", oox::NMSP_%s);""" % (url, ooxUrlAliases[url]))
     print("""    }
 
     return mxFastParser;
@@ -200,7 +197,19 @@ using namespace com::sun::star;
     getFastParser(model)
 
 
-modelPath = sys.argv[1]
+def parseNamespaces(fro):
+    sock = open(fro)
+    for i in sock.readlines():
+        line = i.strip()
+        id, alias, url = line.split(' ')
+        ooxUrlAliases[url] = alias
+    sock.close()
+
+
+namespacesPath = sys.argv[1]
+ooxUrlAliases = {}
+parseNamespaces(namespacesPath)
+modelPath = sys.argv[2]
 model = minidom.parse(modelPath)
 createImpl(model)
 


More information about the Libreoffice-commits mailing list