sw/source/filter/ww8/docxattributeoutput.cxx | 68 ++++++++++++++++++++++----- sw/source/filter/ww8/docxattributeoutput.hxx | 21 ++++++++ 2 files changed, 77 insertions(+), 12 deletions(-)
New commits: commit 408d060dff4737d5468e7ff04035f1674a923198 Author: Adam Co <rattles2...@gmail.com> Date: Wed Jun 5 18:42:10 2013 +0300 fdo#64350: fix for DOCX export of border space Change-Id: Ibd333aa4f85ed04c531187eb89b879196dca2bd8 Reviewed-on: https://gerrit.libreoffice.org/4167 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a062499..5cbf3c6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1506,7 +1506,46 @@ static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, co pSerializer->singleElementNS( XML_w, elementToken, xAttrs ); } -static void impl_pageBorders( FSHelperPtr pSerializer, const SvxBoxItem& rBox, sal_Int32 tag, bool bUseStartEnd = false, bool bWriteTag = true, const SvxBoxItem* pDefaultBorders = 0) +static OutputBorderOptions lcl_getTableDefaultBorderOptions(bool bEcma) +{ + OutputBorderOptions rOptions; + + rOptions.tag = XML_tblBorders; + rOptions.bUseStartEnd = !bEcma; + rOptions.bWriteTag = true; + rOptions.bWriteInsideHV = true; + rOptions.bWriteDistance = false; + + return rOptions; +} + +static OutputBorderOptions lcl_getTableCellBorderOptions(bool bEcma) +{ + OutputBorderOptions rOptions; + + rOptions.tag = XML_tcBorders; + rOptions.bUseStartEnd = !bEcma; + rOptions.bWriteTag = true; + rOptions.bWriteInsideHV = true; + rOptions.bWriteDistance = false; + + return rOptions; +} + +static OutputBorderOptions lcl_getBoxBorderOptions() +{ + OutputBorderOptions rOptions; + + rOptions.tag = XML_pBdr; + rOptions.bUseStartEnd = false; + rOptions.bWriteTag = false; + rOptions.bWriteInsideHV = false; + rOptions.bWriteDistance = true; + + return rOptions; +} + +static void impl_borders( FSHelperPtr pSerializer, const SvxBoxItem& rBox, const OutputBorderOptions& rOptions) { static const sal_uInt16 aBorders[] = { @@ -1516,9 +1555,9 @@ static void impl_pageBorders( FSHelperPtr pSerializer, const SvxBoxItem& rBox, s const sal_Int32 aXmlElements[] = { XML_top, - bUseStartEnd ? XML_start : XML_left, + rOptions.bUseStartEnd ? XML_start : XML_left, XML_bottom, - bUseStartEnd ? XML_end : XML_right + rOptions.bUseStartEnd ? XML_end : XML_right }; bool tagWritten = false; const sal_uInt16* pBrd = aBorders; @@ -1526,23 +1565,28 @@ static void impl_pageBorders( FSHelperPtr pSerializer, const SvxBoxItem& rBox, s { const SvxBorderLine* pLn = rBox.GetLine( *pBrd ); - if (!tagWritten && bWriteTag) { - pSerializer->startElementNS( XML_w, tag, FSEND ); + if (!tagWritten && rOptions.bWriteTag) { + pSerializer->startElementNS( XML_w, rOptions.tag, FSEND ); tagWritten = true; } - impl_borderLine( pSerializer, aXmlElements[i], pLn, 0 ); + sal_uInt16 nDist = 0; + if (rOptions.bWriteDistance) + { + nDist = rBox.GetDistance( *pBrd ); + } + impl_borderLine( pSerializer, aXmlElements[i], pLn, nDist ); // When exporting default borders, we need to export these 2 attr - if ( pDefaultBorders == 0 ) { + if ( rOptions.bWriteInsideHV) { if ( i == 2 ) impl_borderLine( pSerializer, XML_insideH, pLn, 0 ); else if ( i == 3 ) impl_borderLine( pSerializer, XML_insideV, pLn, 0 ); } } - if (tagWritten && bWriteTag) { - pSerializer->endElementNS( XML_w, tag ); + if (tagWritten && rOptions.bWriteTag) { + pSerializer->endElementNS( XML_w, rOptions.tag ); } } @@ -1643,7 +1687,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point const SvxBoxItem& rDefaultBox = (*tableFirstCells.rbegin())->getTableBox( )->GetFrmFmt( )->GetBox( ); { // The cell borders - impl_pageBorders( m_pSerializer, rBox, XML_tcBorders, !bEcma, true, &rDefaultBox ); + impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma) ); } TableBackgrounds( pTableTextNodeInfoInner ); @@ -1893,7 +1937,7 @@ void DocxAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Point bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT; // the defaults of the table are taken from the top-left cell - impl_pageBorders( m_pSerializer, pFrmFmt->GetBox( ), XML_tblBorders, !bEcma, true ); + impl_borders( m_pSerializer, pFrmFmt->GetBox( ), lcl_getTableDefaultBorderOptions(bEcma) ); } void DocxAttributeOutput::TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) @@ -4739,7 +4783,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) m_pSerializer->startElementNS( XML_w, XML_pBdr, FSEND ); } - impl_pageBorders( m_pSerializer, rBox, XML_pBdr, false, false ); + impl_borders( m_pSerializer, rBox, lcl_getBoxBorderOptions() ); if ( m_bOpenedSectPr ) { diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 32d0a84..3227062 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -61,6 +61,27 @@ enum DocxColBreakStatus COLBRK_WRITE }; +/** + * A structure that holds information about the options selected + * when outputting a border to DOCX. + * + * There are 3 functions that initialize this structure: + * - lcl_getTableDefaultBorderOptions - retrieves the options for when outputting table default borders + * - lcl_getTableCellBorderOptions - retrieves the options for when outputting table cell borders + * - lcl_getBoxBorderOptions - retrieves the options for when outputting box borders + * + */ +struct OutputBorderOptions +{ + sal_Int32 tag; + bool bUseStartEnd; + bool bWriteTag; + bool bWriteInsideHV; + bool bWriteDistance; + + OutputBorderOptions() : tag(0), bUseStartEnd(false), bWriteTag(true), bWriteInsideHV(false), bWriteDistance(false) {} +}; + /// The class that has handlers for various resource types when exporting as DOCX. class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits