[Libreoffice-commits] core.git: editeng/source include/editeng sw/qa sw/source
Tushar Bende
tushar.bende at synerzip.com
Thu Feb 13 17:44:16 CET 2014
editeng/source/items/frmitems.cxx | 12 +++++++++---
include/editeng/lrspitem.hxx | 17 +++++++++++++++++
sw/qa/extras/ooxmlexport/data/test_indentation.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 ++++++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 12 ++++++++----
5 files changed, 46 insertions(+), 7 deletions(-)
New commits:
commit d9809c68f62af3b594854b142e1db5171804158d
Author: Tushar Bende <tushar.bende at synerzip.com>
Date: Mon Feb 3 16:44:08 2014 +0530
fdo#74141 :In <w:ind> Right margin gets added even if not present in orig doc.
There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
attributes gets added(w:right=0 & w:left=0),if these attributes are not set in original document.
(In this case LO should not write these attributes in <w:ind>)
eg. if original doc has implicit right and left indentation values set(In style.xml) and there is no
explicit values provided for some para (In document.xml) still it used to write w:right=0 and w:left=0
in <w:ind> tag of document.xml which overrides an entry from style.xml.
XML difference :
- Original file:
<w:ind w:left="567" />
- Roundtrip file Before Fix:
<w:ind w:left="567" w:right="0" w:hanging="0"/>
- Roundtrip file After Fix:
<w:ind w:left="567" w:hanging="0"/>
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7816
Change-Id: Ifa01bae24d48bb38d5e255356247c46a43beefcc
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 6eb012a..7f2cf42 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -420,7 +420,9 @@ SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
nPropFirstLineOfst( 100 ),
nPropLeftMargin( 100 ),
nPropRightMargin( 100 ),
- bAutoFirst ( 0 )
+ bAutoFirst ( 0 ),
+ bExplicitZeroMarginValRight(sal_False),
+ bExplicitZeroMarginValLeft(sal_False)
{
}
@@ -439,7 +441,9 @@ SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft, const long nRight,
nPropFirstLineOfst( 100 ),
nPropLeftMargin( 100 ),
nPropRightMargin( 100 ),
- bAutoFirst ( 0 )
+ bAutoFirst ( 0 ),
+ bExplicitZeroMarginValRight(sal_False),
+ bExplicitZeroMarginValLeft(sal_False)
{
}
@@ -574,7 +578,9 @@ bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
nPropFirstLineOfst == rOther.GetPropTxtFirstLineOfst() &&
nPropLeftMargin == rOther.GetPropLeft() &&
nPropRightMargin == rOther.GetPropRight() &&
- bAutoFirst == rOther.IsAutoFirst() );
+ bAutoFirst == rOther.IsAutoFirst() &&
+ bExplicitZeroMarginValRight == rOther.IsExplicitZeroMarginValRight() &&
+ bExplicitZeroMarginValLeft == rOther.IsExplicitZeroMarginValLeft() );
}
// -----------------------------------------------------------------------
diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx
index d56b268..a18b4ea 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -57,10 +57,13 @@ class EDITENG_DLLPUBLIC SvxLRSpaceItem : public SfxPoolItem
sal_uInt16 nPropFirstLineOfst, nPropLeftMargin, nPropRightMargin;
sal_Bool bAutoFirst : 1; // Automatic calculation of the first line indent
+ sal_Bool bExplicitZeroMarginValRight;
+ sal_Bool bExplicitZeroMarginValLeft;
void AdjustLeft(); // nLeftMargin and nTxtLeft are being adjusted.
public:
+
TYPEINFO();
explicit SvxLRSpaceItem( const sal_uInt16 nId );
@@ -99,6 +102,10 @@ public:
inline sal_Bool IsAutoFirst() const { return bAutoFirst; }
inline void SetAutoFirst( const sal_Bool bNew ) { bAutoFirst = bNew; }
+ inline sal_Bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; }
+ inline sal_Bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; }
+ inline void SetExplicitZeroMarginValRight( const sal_Bool eR ) { bExplicitZeroMarginValRight = eR; }
+ inline void SetExplicitZeroMarginValLeft( const sal_Bool eL ) { bExplicitZeroMarginValLeft = eL; }
// Query/Setting the percentage values
inline void SetPropLeft( const sal_uInt16 nProp = 100 )
{ nPropLeftMargin = nProp; }
@@ -131,6 +138,8 @@ inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
nPropLeftMargin = rCpy.nPropLeftMargin;
nPropRightMargin = rCpy.nPropRightMargin;
bAutoFirst = rCpy.bAutoFirst;
+ bExplicitZeroMarginValRight = rCpy.bExplicitZeroMarginValRight;
+ bExplicitZeroMarginValLeft = rCpy.bExplicitZeroMarginValLeft;
return *this;
}
@@ -142,6 +151,10 @@ inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
}
inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
{
+ if (0 == nR)
+ {
+ SetExplicitZeroMarginValRight(sal_True);
+ }
nRightMargin = (nR * nProp) / 100;
nPropRightMargin = nProp;
}
@@ -155,6 +168,10 @@ inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
{
+ if (0 == nL)
+ {
+ SetExplicitZeroMarginValLeft(sal_True);
+ }
nTxtLeft = (nL * nProp) / 100;
nPropLeftMargin = nProp;
AdjustLeft();
diff --git a/sw/qa/extras/ooxmlexport/data/test_indentation.docx b/sw/qa/extras/ooxmlexport/data/test_indentation.docx
new file mode 100644
index 0000000..b39e0665
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/test_indentation.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 4c437ba..79e0bac 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3114,6 +3114,18 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern, "dml-shape-fillpattern.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aHatch.Distance);
CPPUNIT_ASSERT_EQUAL(drawing::HatchStyle_DOUBLE, aHatch.Style);
}
+
+DECLARE_OOXMLEXPORT_TEST(testIndentation, "test_indentation.docx")
+{
+ // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
+ // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document.
+ // This test is to verify <w:ind> does not contain w:right attribute.
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", "end", "");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1884294..5f6fed3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5424,10 +5424,14 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
else
{
FastAttributeList *pLRSpaceAttrList = m_pSerializer->createAttrList();
-
- pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_left : XML_start ) ), OString::number( rLRSpace.GetTxtLeft() ) );
- pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_right : XML_end ) ), OString::number( rLRSpace.GetRight() ) );
-
+ if((0 != rLRSpace.GetTxtLeft()) || ((0 == rLRSpace.GetTxtLeft()) && (sal_True == rLRSpace.IsExplicitZeroMarginValLeft())))
+ {
+ pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_left : XML_start ) ), OString::number( rLRSpace.GetTxtLeft() ) );
+ }
+ if((0 != rLRSpace.GetRight()) || ((0 == rLRSpace.GetRight()) && (sal_True == rLRSpace.IsExplicitZeroMarginValRight())))
+ {
+ pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_right : XML_end ) ), OString::number( rLRSpace.GetRight() ) );
+ }
sal_Int32 nFirstLineAdjustment = rLRSpace.GetTxtFirstLineOfst();
if (nFirstLineAdjustment > 0)
pLRSpaceAttrList->add( FSNS( XML_w, XML_firstLine ), OString::number( nFirstLineAdjustment ) );
More information about the Libreoffice-commits
mailing list