sw/source/filter/ww8/docxattributeoutput.cxx | 42 ++++++++++++++------------- sw/source/filter/ww8/docxattributeoutput.hxx | 12 +++---- 2 files changed, 29 insertions(+), 25 deletions(-)
New commits: commit c1f4dc6b10ac512c8bda88c7a91403ea0e5108a4 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 28 08:50:19 2014 +0100 DocxTableExportContext: allow usage outside DocxAttributeOutput In particular, if push/pop is done in DocxAttributeOutput, then this can be used in DocxExport as well in the future. Change-Id: If1302c7ccc3842ffd0b48149a3173ee864176bb5 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index be93040..85b38bb 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -497,9 +497,10 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT otherwise the StartParagraph function will use the previous existing table reference attributes since the variable is being shared. */ - DocxTableExportContext aDMLTableExportContext(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + DocxTableExportContext aDMLTableExportContext; + pushToTableExportContext(aDMLTableExportContext); m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++); - aDMLTableExportContext.restore(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + popFromTableExportContext(aDMLTableExportContext); m_pSerializer->endElementNS(XML_mc, XML_Choice); SetAlternateContentChoiceOpen( false ); @@ -510,9 +511,10 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT //reset the tableReference. m_pSerializer->startElementNS(XML_mc, XML_Fallback, FSEND); - DocxTableExportContext aVMLTableExportContext(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + DocxTableExportContext aVMLTableExportContext; + pushToTableExportContext(aVMLTableExportContext); m_rExport.SdrExporter().writeVMLTextFrame(&aFrame); - aVMLTableExportContext.restore(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + popFromTableExportContext(aVMLTableExportContext); m_rExport.mpTableInfo = pOldTableInfo; m_pSerializer->endElementNS(XML_mc, XML_Fallback); @@ -5093,47 +5095,49 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj) m_pSerializer->endElementNS( XML_w, XML_txbxContent ); } -DocxTableExportContext::DocxTableExportContext(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth) +void DocxAttributeOutput::pushToTableExportContext(DocxTableExportContext& rContext) { - m_pTableInfo = pTableInfo; - pTableInfo = ww8::WW8TableInfo::Pointer_t(new ww8::WW8TableInfo()); + rContext.m_pTableInfo = m_rExport.mpTableInfo; + m_rExport.mpTableInfo = ww8::WW8TableInfo::Pointer_t(new ww8::WW8TableInfo()); - m_bTableCellOpen = bTableCellOpen; - bTableCellOpen = false; + rContext.m_bTableCellOpen = m_tableReference->m_bTableCellOpen; + m_tableReference->m_bTableCellOpen = false; - m_nTableDepth = nTableDepth; - nTableDepth = 0; + rContext.m_nTableDepth = m_tableReference->m_nTableDepth; + m_tableReference->m_nTableDepth = 0; } -void DocxTableExportContext::restore(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth) +void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext& rContext) { - pTableInfo = m_pTableInfo; - bTableCellOpen = m_bTableCellOpen; - nTableDepth = m_nTableDepth; + m_rExport.mpTableInfo = rContext.m_pTableInfo; + m_tableReference->m_bTableCellOpen = rContext.m_bTableCellOpen; + m_tableReference->m_nTableDepth = rContext.m_nTableDepth; } void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape) { - DocxTableExportContext aTableExportContext(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + DocxTableExportContext aTableExportContext; + pushToTableExportContext(aTableExportContext); SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(xShape); const SwPosition* pAnchor = pTextBox->GetAnchor().GetCntntAnchor(); sw::Frame aFrame(*pTextBox, *pAnchor); m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true); - aTableExportContext.restore(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + popFromTableExportContext(aTableExportContext); } void DocxAttributeOutput::WriteVMLTextBox(uno::Reference<drawing::XShape> xShape) { - DocxTableExportContext aTableExportContext(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + DocxTableExportContext aTableExportContext; + pushToTableExportContext(aTableExportContext); SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(xShape); const SwPosition* pAnchor = pTextBox->GetAnchor().GetCntntAnchor(); sw::Frame aFrame(*pTextBox, *pAnchor); m_rExport.SdrExporter().writeVMLTextFrame(&aFrame, /*bTextBoxOnly=*/true); - aTableExportContext.restore(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + popFromTableExportContext(aTableExportContext); } oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML() diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index f373b86..765d64d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -109,16 +109,11 @@ struct PageMargins * All the information that should be stashed away when we're in the middle of * of a table export and still have to do something else, e.g. export a shape. */ -class DocxTableExportContext +struct DocxTableExportContext { ww8::WW8TableInfo::Pointer_t m_pTableInfo; bool m_bTableCellOpen; sal_uInt32 m_nTableDepth; -public: - /// Stores the passed parameters and resets them to their default value. - DocxTableExportContext(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth); - /// Restores the remembered state. - void restore(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth); }; /** @@ -978,6 +973,11 @@ public: void GetSdtEndBefore(const SdrObject* pSdrObj); void SetStartedParaSdt(bool bStartedParaSdt); bool IsStartedParaSdt(); + + /// Stores the table export state to the passed context and resets own state. + void pushToTableExportContext(DocxTableExportContext& rContext); + /// Restores from the remembered state. + void popFromTableExportContext(DocxTableExportContext& rContext); }; #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits