diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-05-17 16:24:14 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-05-18 14:31:31 +0200 |
commit | f73e75e91c757b20682d1df75de2f79b3972a500 (patch) | |
tree | 8eab7d3155dd9124329207cfac4a6744593f58d7 /writerfilter | |
parent | 4708aede266da92903f48a24badb204c2a9a54b6 (diff) |
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
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 26 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLParserState.cxx | 37 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLParserState.hxx | 9 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 5 |
5 files changed, 77 insertions, 2 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 58d7627d4491..f693319d8776 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -814,6 +814,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 bb0e8895e808..31ca2f73281f 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 8704645b7e85..7e9b474ba80c 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 void OOXMLParserState::dumpXml( const TagLogger::Pointer_t& pLogger ) { diff --git a/writerfilter/source/ooxml/OOXMLParserState.hxx b/writerfilter/source/ooxml/OOXMLParserState.hxx index df26a24ff824..e89b0b22ad0d 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: void dumpXml( const TagLogger::Pointer_t& pLogger ); diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index f95112e03884..c5fea31ea259 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -23651,7 +23651,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> |