diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-12 11:40:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-12 16:54:35 +0200 |
commit | 959a843f48be63071c64ba9e20c9389ebc390e81 (patch) | |
tree | e59f4c70e89e1b2da09dbe4687c08123c3c59e86 /sw | |
parent | bea342be301063d761f95177d8b65c88a52d1a1e (diff) |
DOC export: factor out wrap polygon handling to to sw::util
So that it'll be possible to reuse it in the DOCX exporter.
Change-Id: Ib7371c92c4fd93d7c6f3271ca81311bac8f1a1a7
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/writerhelper.cxx | 30 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerhelper.hxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 27 |
3 files changed, 34 insertions, 26 deletions
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 015b076dda71..85891c3d72aa 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -660,6 +660,36 @@ namespace sw } } + Polygon CorrectWordWrapPolygonForExport(const PolyPolygon& rPolyPoly, const SwNoTxtNode* pNd) + { + Polygon aPoly(PolygonFromPolyPolygon(rPolyPoly)); + const Size &rOrigSize = pNd->GetGraphic().GetPrefSize(); + Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width()); + Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height()); + aPoly.Scale(aMapPolyX, aMapPolyY); + + /* + a) stretch right bound by 15twips + b) shrink bottom bound to where it would have been in word + c) Move it to the left by 15twips + + See the import for details + */ + const Size &rSize = pNd->GetTwipSize(); + Fraction aMoveHack(ww::nWrap100Percent, rSize.Width()); + aMoveHack *= Fraction(15, 1); + long nMove(aMoveHack); + + Fraction aHackX(ww::nWrap100Percent + nMove, + ww::nWrap100Percent); + Fraction aHackY(ww::nWrap100Percent - nMove, + ww::nWrap100Percent); + aPoly.Scale(aHackX, aHackY); + + aPoly.Move(-nMove, 0); + return aPoly; + } + Size GetSwappedInSize(const SwNoTxtNode& rNd) { Size aGrTwipSz(rNd.GetTwipSize()); diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx index 8a99413fa89f..592849963c4e 100644 --- a/sw/source/filter/ww8/writerhelper.hxx +++ b/sw/source/filter/ww8/writerhelper.hxx @@ -741,6 +741,9 @@ namespace sw */ Polygon PolygonFromPolyPolygon(const PolyPolygon &rPolyPoly); + /// Undo all scaling / move tricks of the wrap polygon done during import. + Polygon CorrectWordWrapPolygonForExport(const PolyPolygon& rPolyPoly, const SwNoTxtNode* pNd); + /** Make setting a drawing object's layer in a Writer document easy Word has the simple concept of a drawing object either in the diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 0808b153acd2..18f0591de1f8 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2106,32 +2106,7 @@ sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrmFmt& rFmt, MSO_SPT eShapeType const PolyPolygon *pPolyPoly = pNd->HasContour(); if (pPolyPoly && pPolyPoly->Count()) { - Polygon aPoly(PolygonFromPolyPolygon(*pPolyPoly)); - const Size &rOrigSize = pNd->GetGraphic().GetPrefSize(); - Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width()); - Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height()); - aPoly.Scale(aMapPolyX, aMapPolyY); - - /* - a) stretch right bound by 15twips - b) shrink bottom bound to where it would have been in word - c) Move it to the left by 15twips - - See the import for details - */ - const Size &rSize = pNd->GetTwipSize(); - Fraction aMoveHack(ww::nWrap100Percent, rSize.Width()); - aMoveHack *= Fraction(15, 1); - long nMove(aMoveHack); - - Fraction aHackX(ww::nWrap100Percent + nMove, - ww::nWrap100Percent); - Fraction aHackY(ww::nWrap100Percent - nMove, - ww::nWrap100Percent); - aPoly.Scale(aHackX, aHackY); - - aPoly.Move(-nMove, 0); - + Polygon aPoly = CorrectWordWrapPolygonForExport(*pPolyPoly, pNd); SvMemoryStream aPolyDump; aPolyDump.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); |