[PATCH] fdo#64350: fix for DOCX export of border space
Adam CloudOn (via Code Review)
gerrit at gerrit.libreoffice.org
Wed Jun 5 08:43:04 PDT 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/4167
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/67/4167/1
fdo#64350: fix for DOCX export of border space
Change-Id: Ibd333aa4f85ed04c531187eb89b879196dca2bd8
---
M sw/source/filter/ww8/docxattributeoutput.cxx
M sw/source/filter/ww8/docxattributeoutput.hxx
2 files changed, 67 insertions(+), 12 deletions(-)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a062499..7c672cd 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1506,7 +1506,46 @@
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 TableDefaultBorderOptions(bool bEcma)
+{
+ OutputBorderOptions rOptions;
+
+ rOptions.tag = XML_tblBorders;
+ rOptions.bUseStartEnd = !bEcma;
+ rOptions.bWriteTag = true;
+ rOptions.bWriteInsideHV = true;
+ rOptions.bWriteDistance = false;
+
+ return rOptions;
+}
+
+static OutputBorderOptions TableCellBorderOptions(bool bEcma)
+{
+ OutputBorderOptions rOptions;
+
+ rOptions.tag = XML_tcBorders;
+ rOptions.bUseStartEnd = !bEcma;
+ rOptions.bWriteTag = true;
+ rOptions.bWriteInsideHV = true;
+ rOptions.bWriteDistance = false;
+
+ return rOptions;
+}
+
+static OutputBorderOptions BoxBorderOptions()
+{
+ 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 @@
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 @@
{
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 @@
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, TableCellBorderOptions(bEcma) );
}
TableBackgrounds( pTableTextNodeInfoInner );
@@ -1893,7 +1937,7 @@
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( ), TableDefaultBorderOptions(bEcma) );
}
void DocxAttributeOutput::TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
@@ -4739,7 +4783,7 @@
m_pSerializer->startElementNS( XML_w, XML_pBdr, FSEND );
}
- impl_pageBorders( m_pSerializer, rBox, XML_pBdr, false, false );
+ impl_borders( m_pSerializer, rBox, BoxBorderOptions() );
if ( m_bOpenedSectPr )
{
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 32d0a84..01166bc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -61,6 +61,17 @@
COLBRK_WRITE
};
+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
{
--
To view, visit https://gerrit.libreoffice.org/4167
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibd333aa4f85ed04c531187eb89b879196dca2bd8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Adam CloudOn <rattles2013 at gmail.com>
More information about the LibreOffice
mailing list