summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Bende <tushar.bende@synerzip.com>2014-02-03 16:44:08 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-13 17:43:47 +0100
commitd9809c68f62af3b594854b142e1db5171804158d (patch)
treee56c916785bfe4bdeef185a446f545912cc227a2
parentf8ebc65a51a61c1d9b3172467b0770202281db32 (diff)
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
-rw-r--r--editeng/source/items/frmitems.cxx12
-rw-r--r--include/editeng/lrspitem.hxx17
-rw-r--r--sw/qa/extras/ooxmlexport/data/test_indentation.docxbin0 -> 12896 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx12
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx12
5 files changed, 46 insertions, 7 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 6eb012ad26e0..7f2cf425d51a 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 d56b26831bc9..a18b4ea8138f 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 000000000000..b39e06658416
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/test_indentation.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 4c437bac178a..79e0bacc8bb7 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 188429402269..5f6fed317953 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 ) );