8bc870e
From b5ce50d1d07394f6b59b028373120369c83d5d66 Mon Sep 17 00:00:00 2001
8bc870e
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
8bc870e
Date: Tue, 7 Apr 2015 09:56:43 +0100
8bc870e
Subject: [PATCH] negative after-text indents ignored by msword for apos
8bc870e
8bc870e
Change-Id: I33e178f23bc4b1372c4c329954b301ae68902154
8bc870e
---
8bc870e
 sw/source/filter/ww8/ww8graf.cxx |  3 +++
8bc870e
 sw/source/filter/ww8/ww8par.hxx  |  2 ++
8bc870e
 sw/source/filter/ww8/ww8par6.cxx | 26 ++++++++++++++++++++++++++
8bc870e
 3 files changed, 31 insertions(+)
8bc870e
8bc870e
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
8bc870e
index 456ce25..3a11d1e 100644
8bc870e
--- a/sw/source/filter/ww8/ww8graf.cxx
8bc870e
+++ b/sw/source/filter/ww8/ww8graf.cxx
8bc870e
@@ -2905,7 +2905,10 @@ SwFlyFrmFmt* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject,
8bc870e
             MoveOutsideFly(pRetFrmFmt, aSave.GetStartPos(),!bJoined);
8bc870e
 
8bc870e
             aSave.Restore( this );
8bc870e
+
8bc870e
+            StripNegativeAfterIndent(pRetFrmFmt);
8bc870e
         }
8bc870e
+
8bc870e
     }
8bc870e
     return pRetFrmFmt;
8bc870e
 }
8bc870e
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
8bc870e
index a7fdff5..0a34059 100644
8bc870e
--- a/sw/source/filter/ww8/ww8par.hxx
8bc870e
+++ b/sw/source/filter/ww8/ww8par.hxx
8bc870e
@@ -1488,6 +1488,7 @@ private:
8bc870e
     bool IsDropCap();
8bc870e
     bool IsListOrDropcap() { return (!pAktItemSet  || bDropCap); };
8bc870e
 
8bc870e
+    //Apo == Absolutely Positioned Object, MSWord's old-style frames
8bc870e
     WW8FlyPara *ConstructApo(const ApoTestResults &rApo,
8bc870e
         const WW8_TablePos *pTabPos);
8bc870e
     bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos, SvxULSpaceItem* pULSpaceItem = 0);
8bc870e
@@ -1495,6 +1496,7 @@ private:
8bc870e
     bool TestSameApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
8bc870e
     ApoTestResults TestApo(int nCellLevel, bool bTableRowEnd,
8bc870e
         const WW8_TablePos *pTabPos);
8bc870e
+    void StripNegativeAfterIndent(SwFrmFmt *pFlyFmt) const;
8bc870e
 
8bc870e
     void EndSpecial();
8bc870e
     bool ProcessSpecial(bool &rbReSync, WW8_CP nStartCp);
8bc870e
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
8bc870e
index 418e130..b63e639 100644
8bc870e
--- a/sw/source/filter/ww8/ww8par6.cxx
8bc870e
+++ b/sw/source/filter/ww8/ww8par6.cxx
8bc870e
@@ -2430,6 +2430,32 @@ bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr)
8bc870e
     return bRet;
8bc870e
 }
8bc870e
 
8bc870e
+//In auto-width word frames negative after-indent values are ignored
8bc870e
+void SwWW8ImplReader::StripNegativeAfterIndent(SwFrmFmt *pFlyFmt) const
8bc870e
+{
8bc870e
+    const SwNodeIndex* pSttNd = pFlyFmt->GetCntnt().GetCntntIdx();
8bc870e
+    if (!pSttNd)
8bc870e
+        return;
8bc870e
+
8bc870e
+    SwNodeIndex aIdx(*pSttNd, 1);
8bc870e
+    SwNodeIndex aEnd(*pSttNd->GetNode().EndOfSectionNode());
8bc870e
+    while (aIdx < aEnd)
8bc870e
+    {
8bc870e
+        SwTxtNode *pNd = aIdx.GetNode().GetTxtNode();
8bc870e
+        if (pNd)
8bc870e
+        {
8bc870e
+            const SvxLRSpaceItem& rLR = ItemGet<SvxLRSpaceItem>(*pNd, RES_LR_SPACE);
8bc870e
+            if (rLR.GetRight() < 0)
8bc870e
+            {
8bc870e
+                SvxLRSpaceItem aLR(rLR);
8bc870e
+                aLR.SetRight(0);
8bc870e
+                pNd->SetAttr(aLR);
8bc870e
+            }
8bc870e
+        }
8bc870e
+        ++aIdx;
8bc870e
+    }
8bc870e
+}
8bc870e
+
8bc870e
 void SwWW8ImplReader::StopApo()
8bc870e
 {
8bc870e
     OSL_ENSURE(pWFlyPara, "no pWFlyPara to close");
8bc870e
-- 
8bc870e
1.9.3
8bc870e