Kaydet (Commit) 959a843f authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst bea342be
......@@ -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());
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment