Kaydet (Commit) f73e75e9 authored tarafından Luboš Luňák's avatar Luboš Luňák

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
üst 4708aede
......@@ -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
......
......@@ -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();
......
......@@ -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 )
{
......
......@@ -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 );
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment