summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxsdrexport.cxx
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-07-05 22:21:23 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-07-14 11:34:43 +0200
commitaf99c01570adc0c9205e1650d10866f80bb8118a (patch)
tree97d146fc8e1904efccd00552d427554bcdd8dd03 /sw/source/filter/ww8/docxsdrexport.cxx
parent3f618170b8474b4a4e97aa7685daf064d0413a57 (diff)
tdf#143219 improve docx import/export of contour wrap
The current solution has some problems: (1) Currently effectExtent is used on import to increase the wrap margins for fat stroke and effects like shadow and glow in case of contour wrap. Problems: Word writes these values, but actually the wrap polygon is authorative and third party applications might not write these values at all. The wrap margins were increased on import, but not decreased on export. The effectExtent values by Word contain in addition the amount for rotation as needed in wrapSquare. That part was not removed. (2) To avoid negative values in dist* values they were compensated with effectExtent. For that, the complete effectExtent was shifted to dist* and effectExtent was set to zero. Problems: Contour wrap does not use effectExtent but a wrap polygon. This is set by Word in a way, that it includes the effect extents. LO uses the original wrap polygon if available. So moving the effectExtent values to dist* gives too large 'distance to text' in case of contour wrap, because effects were considered twice. The solution here replaces the way, how the margins are calculated in case of contour wrap. Now the range used by the wrap polygon is compared with the range used by the shape geometry. The difference is added to 'distance to text'. To be able to remove these values on export, they are put into the InteropGrabBag. LO and Word use different concepts for contour wrap. Any solution gives only an approximation. But adapting 'distance to text' brings rendering in LO nearer to the way Word renders contour wrap. Change-Id: Ic3c1c075fedfa7f79e4fe1f3c095da12cf274e36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118538 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/filter/ww8/docxsdrexport.cxx')
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx36
1 files changed, 33 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 561bc475687b..80554455fa3b 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -221,8 +221,16 @@ bool lcl_makeSingleDistAndEffectExtentNonNegative(sal_Int64& rDist, sal_Int32& r
return false;
}
// rDist + rExt >= 0
- rDist += rExt;
- rExt = 0;
+ if (rDist < 0)
+ {
+ rExt += rDist;
+ rDist = 0;
+ }
+ else // rExt < 0
+ {
+ rDist += rExt;
+ rExt = 0;
+ }
return true;
}
@@ -616,8 +624,30 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
lcl_calculateRawEffectExtent(nLeftExt, nTopExt, nRightExt, nBottomExt, *pObj, true);
// We have calculated the effectExtent from boundRect, therefore half stroke width is
// already contained.
- // ToDo: The other half of the strokeWidth needs to be subtracted from padding.
+ // ToDo: The other half of the stroke width needs to be subtracted from padding.
// Where is that?
+
+ // The import has added a difference to dist* in case of contour wrap for to give a
+ // rendering nearer to Word. In that case, we need to subtract it on export.
+ uno::Any aAny;
+ pObj->GetGrabBagItem(aAny);
+ comphelper::SequenceAsHashMap aGrabBag(aAny);
+ auto it = aGrabBag.find("AnchorDistDiff");
+ if (it != aGrabBag.end())
+ {
+ comphelper::SequenceAsHashMap aAnchorDistDiff(it->second);
+ for (const std::pair<const OUString, uno::Any>& rDiff : aAnchorDistDiff)
+ {
+ if (rDiff.first == "distTDiff" && rDiff.second.has<sal_Int32>())
+ nDistT -= round(rDiff.second.get<sal_Int32>());
+ else if (rDiff.first == "distBDiff" && rDiff.second.has<sal_Int32>())
+ nDistB -= round(rDiff.second.get<sal_Int32>());
+ else if (rDiff.first == "distLDiff" && rDiff.second.has<sal_Int32>())
+ nDistL -= rDiff.second.get<sal_Int32>();
+ else if (rDiff.first == "distRDiff" && rDiff.second.has<sal_Int32>())
+ nDistR -= rDiff.second.get<sal_Int32>();
+ }
+ }
// ToDo: bool bCompansated = ... to be later able to switch from wrapSquare to wrapTight,
// if wrapSquare would require negative effectExtent.
lcl_makeDistAndExtentNonNegative(nDistT, nDistB, nDistL, nDistR, nLeftExt, nTopExt,