[Libreoffice-commits] .: Branch 'libreoffice-3-5' - writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri May 18 08:32:56 PDT 2012


 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   26 ++++++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    2 
 writerfilter/source/ooxml/OOXMLParserState.cxx        |   37 +++++++++++++++++-
 writerfilter/source/ooxml/OOXMLParserState.hxx        |    9 ++++
 writerfilter/source/ooxml/model.xml                   |    5 +-
 5 files changed, 77 insertions(+), 2 deletions(-)

New commits:
commit d32f3048052af80b21e8968d24eb55c48d298052
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu May 17 16:24:14 2012 +0200

    handle recursive <w:p> because of shapes (bnc#751077)
    
    <w:p><w:pict>...<w:txbxContent><w:p><w:p/> - in this case, the inner
    paragraphs should not interfere with the outer one, but e.g.
    detecting whether it was the last paragraph in section could get
    broken.
    
    Change-Id: I8634ee6a0d6274f5770423ff798adfa260a33326
    (cherry picked from commit f73e75e91c757b20682d1df75de2f79b3972a500)
    
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 4b183b9..9716e6a 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -816,6 +816,32 @@ void OOXMLFastContextHandler::endOfParagraph()
         mpStream->utext((const sal_uInt8*)sCR, 1);
 }
 
+void OOXMLFastContextHandler::startTxbxContent()
+{
+#ifdef DEBUG_CONTEXT_HANDLER
+    debug_logger->element("contexthandler.startTxbxContent");
+#endif
+/*
+    This usually means there are recursive <w:p> elements, and the ones
+    inside and outside of w:txbxContent should not interfere (e.g.
+    the lastParagraphInSection setting). So save the whole state
+    and possibly start new groups for the nested content (not section
+    group though, as that'd cause the txbxContent to be moved onto
+    another page, I'm not sure how that should work exactly).
+*/
+    mpParserState->startTxbxContent();
+    startParagraphGroup();
+}
+
+void OOXMLFastContextHandler::endTxbxContent()
+{
+#ifdef DEBUG_CONTEXT_HANDLER
+    debug_logger->element("contexthandler.endTxbxContent");
+#endif
+    endParagraphGroup();
+    mpParserState->endTxbxContent();
+}
+
 void OOXMLFastContextHandler::text(const ::rtl::OUString & sText)
 {
 #ifdef DEBUG_CONTEXT_HANDLER
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index bb0e889..31ca2f7 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -211,6 +211,8 @@ public:
     void positionOffset(const ::rtl::OUString & sText);
     void alignH(const ::rtl::OUString & sText);
     void alignV(const ::rtl::OUString & sText);
+    void startTxbxContent();
+    void endTxbxContent();
     virtual void propagateCharacterProperties();
     virtual void propagateCharacterPropertiesAsSet(const Id & rId);
     virtual void propagateTableProperties();
diff --git a/writerfilter/source/ooxml/OOXMLParserState.cxx b/writerfilter/source/ooxml/OOXMLParserState.cxx
index 943b643..049a7c2 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.cxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.cxx
@@ -46,7 +46,12 @@ OOXMLParserState::OOXMLParserState() :
     mbForwardEvents(true),
     mnContexts(0),
     mnHandle(0),
-    mpDocument(NULL)
+    mpDocument(NULL),
+    inTxbxContent(false),
+    savedInSectionGroup(false),
+    savedInParagraphGroup(false),
+    savedInCharacterGroup(false),
+    savedLastParagraphInSection(false)
 {
 }
 
@@ -275,6 +280,36 @@ void OOXMLParserState::incContextCount()
     mnContexts++;
 }
 
+void OOXMLParserState::startTxbxContent()
+{
+    if( inTxbxContent )
+        SAL_WARN( "writerfilter", "Nested w:txbxContent" );
+    inTxbxContent = true;
+    // Do not save and reset section group state, it'd cause a new page.
+//    savedInSectionGroup = mbInSectionGroup;
+    savedInParagraphGroup = mbInParagraphGroup;
+    savedInCharacterGroup = mbInCharacterGroup;
+    savedLastParagraphInSection = mbLastParagraphInSection;
+//    mbInSectionGroup = false;
+    mbInParagraphGroup = false;
+    mbInCharacterGroup = false;
+    mbLastParagraphInSection = false;
+}
+
+void OOXMLParserState::endTxbxContent()
+{
+    if( !inTxbxContent )
+    {
+        SAL_WARN( "writerfilter", "Non-matching closing w:txbxContent" );
+        return;
+    }
+//    mbInSectionGroup = savedInSectionGroup;
+    mbInParagraphGroup = savedInParagraphGroup;
+    mbInCharacterGroup = savedInCharacterGroup;
+    mbLastParagraphInSection = savedLastParagraphInSection;
+    inTxbxContent = false;
+}
+
 #if OSL_DEBUG_LEVEL > 1
 unsigned int OOXMLParserState::getContextCount() const
 {
diff --git a/writerfilter/source/ooxml/OOXMLParserState.hxx b/writerfilter/source/ooxml/OOXMLParserState.hxx
index 2684592..e3fc657 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.hxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.hxx
@@ -59,6 +59,12 @@ class OOXMLParserState
     stack<OOXMLPropertySet::Pointer_t> mCellProps;
     stack<OOXMLPropertySet::Pointer_t> mRowProps;
     stack<OOXMLPropertySet::Pointer_t> mTableProps;
+    bool inTxbxContent;
+    // these 4 save when inTxbxContent
+    bool savedInSectionGroup;
+    bool savedInParagraphGroup;
+    bool savedInCharacterGroup;
+    bool savedLastParagraphInSection;
 #if OSL_DEBUG_LEVEL > 1
     XPathLogger m_xPathLogger;
 #endif
@@ -109,6 +115,9 @@ public:
 
     void incContextCount();
 
+    void startTxbxContent();
+    void endTxbxContent();
+
 #if OSL_DEBUG_LEVEL > 1
 public:
     unsigned int getContextCount() const;
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 12d29a5..7f76efa 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -23622,7 +23622,10 @@
     <resource name="CT_GlossaryDocument" resource="Stream" tag="content"/>
     <resource name="document" resource="Stream" tag="content"/>
     <resource name="glossaryDocument" resource="Stream" tag="content"/>
-    <resource name="CT_TxbxContent" resource="Stream" tag="shape"/>
+    <resource name="CT_TxbxContent" resource="Stream" tag="shape">
+      <action name="start" action="startTxbxContent"/>
+      <action name="end" action="endTxbxContent"/>
+    </resource>
     <resource name="CT_OMath" resource="Math" tag="math"/>
     <resource name="CT_OMathPara" resource="Stream" tag="math"/>
   </namespace>


More information about the Libreoffice-commits mailing list