[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3-3.2' - sd/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu May 24 16:12:57 UTC 2018


 sd/source/filter/pdf/sdpdffilter.cxx |   37 +++++------------------------------
 1 file changed, 6 insertions(+), 31 deletions(-)

New commits:
commit 570c9afc48526c1a85d17d2d9c7c235cba4104ed
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu May 24 06:59:39 2018 -0400

    sd: make the imported PDF page exactly as original
    
    i.e. no borders or larger page than rendered PDF
    
    Change-Id: I1f356cceeec1d5d9f1728f0e29160fdd9241a221
    Reviewed-on: https://gerrit.libreoffice.org/54764
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 5bca171dc64a..4f7bd4ed0a6c 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -129,37 +129,12 @@ bool SdPdfFilter::Import()
 
         // Create the page and insert the Graphic.
         SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
-        Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
-                                                 MapMode(MapUnit::Map100thMM)));
-
-        Size aPagSize(pPage->GetSize());
-        aPagSize.AdjustWidth(-(pPage->GetLftBorder() + pPage->GetRgtBorder()));
-        aPagSize.AdjustHeight(-(pPage->GetUppBorder() + pPage->GetLwrBorder()));
-
-        // scale to fit page
-        if (((aGrfSize.Height() > aPagSize.Height()) || (aGrfSize.Width() > aPagSize.Width()))
-            && aGrfSize.Height() && aPagSize.Height())
-        {
-            const double fGrfWH = static_cast<double>(aGrfSize.Width()) / aGrfSize.Height();
-            const double fWinWH = static_cast<double>(aPagSize.Width()) / aPagSize.Height();
-
-            // adjust graphic to page size (scales)
-            if (fGrfWH < fWinWH)
-            {
-                aGrfSize.setWidth(static_cast<long>(aPagSize.Height() * fGrfWH));
-                aGrfSize.setHeight(aPagSize.Height());
-            }
-            else if (fGrfWH > 0.F)
-            {
-                aGrfSize.setWidth(aPagSize.Width());
-                aGrfSize.setHeight(static_cast<long>(aPagSize.Width() / fGrfWH));
-            }
-        }
-
-        // Set the output rectangle of the Graphic.
-        Point aPos;
-        aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLftBorder());
-        aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUppBorder());
+        const Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
+                                                       MapMode(MapUnit::Map100thMM)));
+
+        // Make the page size match the rendered image.
+        pPage->SetSize(aGrfSize);
+        Point aPos(0, 0);
 
         pPage->InsertObject(new SdrGrafObj(aGraphic, Rectangle(aPos, aGrfSize)));
     }


More information about the Libreoffice-commits mailing list