diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-07 17:53:29 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-18 15:34:55 +0000 |
commit | 99b3e159726b51537563790e8f73b43a88970e13 (patch) | |
tree | 0c98429e0d5d6cf1deddf595eca03c8c4728acd8 /writerfilter | |
parent | 6b80793b919520e443024da5499e7ab9f6720d6c (diff) |
DOCX import: handle section break right after a ToC field
The symptom was that during the handling of the XE field, we tried to
access the top of the text append stack, but the stack was empty.
The situation is the following:
1) There is a multi-page TOC field.
2) The page break inside the field is described using a section break,
featuring headers, and the header contains a field that we map to a
fieldmark.
3) There is an XE field after all this.
The root cause was that during parsing of the header, some of the state
should be stashed away and restored when we're done. The new
HeaderFooterContext does exactly this, and now the number of push/pop
calls on the text append context match again.
(cherry picked from commit 153af84762f98d6c86c4c060b01402f40b2b0c24)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I10f259fd9edb8bd719ae5bc8a43ed5ef8c708071
Reviewed-on: https://gerrit.libreoffice.org/13524
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 18 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index bc4ff520b782..3779aa3b7f29 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1496,6 +1496,9 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter( void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType) { + m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted)); + m_bTextInserted = false; + const PropertyIds ePropIsOn = bHeader? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; const PropertyIds ePropShared = bHeader? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; const PropertyIds ePropTextLeft = bHeader? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; @@ -1576,6 +1579,12 @@ void DomainMapper_Impl::PopPageHeaderFooter() m_bDiscardHeaderFooter = false; } m_bInHeaderFooterImport = false; + + if (!m_aHeaderFooterStack.empty()) + { + m_bTextInserted = m_aHeaderFooterStack.top().getTextInserted(); + m_aHeaderFooterStack.pop(); + } } @@ -2523,6 +2532,15 @@ bool DomainMapper_Impl::IsOpenField() const return !m_aFieldStack.empty(); } +HeaderFooterContext::HeaderFooterContext(bool bTextInserted) + : m_bTextInserted(bTextInserted) +{ +} + +bool HeaderFooterContext::getTextInserted() +{ + return m_bTextInserted; +} FieldContext::FieldContext(uno::Reference< text::XTextRange > xStart) : m_bFieldCommandCompleted( false ) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index f72c8666bb40..68e1af78b22d 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -113,6 +113,22 @@ enum BreakType PAGE_BREAK, COLUMN_BREAK }; + +/** + * Storage for state that is relevant outside a header/footer, but not inside it. + * + * In case some state of DomainMapper_Impl should be reset before handling the + * header/footer and should be restored once handling of header/footer is done, + * then you can use this class to do so. + */ +class HeaderFooterContext +{ + bool m_bTextInserted; +public: + HeaderFooterContext(bool bTextInserted); + bool getTextInserted(); +}; + /*-------------------------------------------------- field stack element * --------------------------------------------------*/ @@ -200,6 +216,7 @@ typedef boost::shared_ptr<FieldContext> FieldContextPtr; typedef std::stack<ContextType> ContextStack; typedef std::stack<PropertyMapPtr> PropertyStack; typedef std::stack< TextAppendContext > TextAppendStack; +typedef std::stack<HeaderFooterContext> HeaderFooterStack; typedef std::stack<FieldContextPtr> FieldStack; typedef std::stack< AnchoredContext > TextContentStack; @@ -301,6 +318,7 @@ private: TextContentStack m_aAnchoredStack; + HeaderFooterStack m_aHeaderFooterStack; FieldStack m_aFieldStack; bool m_bSetUserFieldContent; bool m_bSetCitation; |