summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdpdf.cxx
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-14 16:20:11 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commit7884e7a8543cf9c05dea5fcd8bb73f79952bc52e (patch)
tree427a6028b7ff7ea0f68b5d2d5f9fff8cac5e343c /svx/source/svdraw/svdpdf.cxx
parent7d5f78d2761dbbdfb888d7b4d9504f5e1e1f4601 (diff)
svx: more accurate PDF imported text size
Change-Id: I22880afdd9d36d9096003d86bba15098b465e0b3 (cherry picked from commit d583d4635f165a788c12ef336a25377239049253)
Diffstat (limited to 'svx/source/svdraw/svdpdf.cxx')
-rw-r--r--svx/source/svdraw/svdpdf.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 59dc26c8da34..48bceeacc1e5 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1037,6 +1037,8 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
return;
}
+ const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
+
const int nChars = FPDFTextObj_CountChars(pPageObject);
std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1057,6 +1059,7 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
<< ", " << e << ", " << f << ')');
Point aPos = PointsToLogic(e, f);
SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
+ SAL_WARN("sd.filter", "Got TEXT Bounds: " << aRect);
const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
@@ -1078,10 +1081,10 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
aFnt.SetFontSize(Size(dFontSizeH, dFontSizeV));
mpVD->SetFont(aFnt);
- ImportText(aPos, sText);
+ ImportText(aRect.TopLeft(), aRect.GetSize(), sText);
}
-void ImpSdrPdfImport::ImportText(const Point& rPos, const OUString& rStr)
+void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const OUString& rStr)
{
// calc text box size, add 5% to make it fit safely
@@ -1096,6 +1099,7 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const OUString& rStr)
<< ", Scaled: " << nTextWidth << 'x' << nTextHeight);
Point aPos(FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()));
+ Size bSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
Size aSize(nTextWidth, nTextHeight);
if (eAlg == ALIGN_BASELINE)
@@ -1103,8 +1107,11 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const OUString& rStr)
else if (eAlg == ALIGN_BOTTOM)
aPos.AdjustY(-nTextHeight);
- tools::Rectangle aTextRect(aPos, aSize);
- SAL_WARN("sd.filter", "Text Rect: " << aTextRect);
+ SAL_WARN("sd.filter", "Final POS: " << aPos);
+ SAL_WARN("sd.filter", "Final Text Size: " << aSize);
+ SAL_WARN("sd.filter", "Final Bound Size: " << bSize);
+ tools::Rectangle aTextRect(aPos, bSize);
+ // SAL_WARN("sd.filter", "Text Rect: " << aTextRect);
SdrRectObj* pText = new SdrRectObj(*mpModel, OBJ_TEXT, aTextRect);
pText->SetMergedItem(makeSdrTextUpperDistItem(0));