summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-15 20:32:52 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commitdf0e3ba6d079e3aa9a97581bf6c3699eeaaa29bc (patch)
tree5dd5228f98dca6fcb2a464c30491296d2716adb1
parent9ddfbcb02238cb466ad5e83ccaaa81632124c23c (diff)
sd: support breaking any PDF page
(cherry picked from commit 971ada2fe6cb1ccd91ead7e0f34624ace92f3b7d) Change-Id: Ifa5f58163bef209a988fc0f88e2b609b1973e0d4
-rw-r--r--svx/source/svdraw/svdpdf.cxx13
-rw-r--r--svx/source/svdraw/svdpdf.hxx4
-rw-r--r--vcl/source/gdi/impgraph.cxx4
3 files changed, 11 insertions, 10 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index ebf085edca6e..c5c139c11817 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -209,16 +209,17 @@ ImpSdrPdfImport::~ImpSdrPdfImport()
FPDF_DestroyLibrary();
}
-void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport)
+void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
+ int nPageIndex)
{
const int nPageCount = FPDF_GetPageCount(mpPdfDocument);
- SAL_WARN("sd.filter", "Pages: " << nPageCount);
- for (size_t nPageIndex = 0; nPageIndex <= 0; ++nPageIndex)
+ SAL_WARN("sd.filter", "Importing page " << nPageIndex << " of " << nPageCount);
+ if (nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount)
{
// Render next page.
FPDF_PAGE pPdfPage = FPDF_LoadPage(mpPdfDocument, nPageIndex);
if (pPdfPage == nullptr)
- break;
+ return;
const double dPageWidth = FPDF_GetPageWidth(pPdfPage);
const double dPageHeight = FPDF_GetPageHeight(pPdfPage);
@@ -484,7 +485,7 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
// << "(" << mfScaleY << ")");
}
-size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, size_t nPageNumber,
+size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, int nPageNumber,
SvdProgressInfo* pProgrInfo)
{
if (pProgrInfo)
@@ -495,7 +496,7 @@ size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, size_t nPageNu
sal_uInt32 nActionsToReport(0);
// execute
- DoLoopActions(pProgrInfo, &nActionsToReport);
+ DoLoopActions(pProgrInfo, &nActionsToReport, nPageNumber);
if (pProgrInfo)
{
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 2adda0ee5e2d..efd00f02f0c6 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -114,7 +114,7 @@ class ImpSdrPdfImport final
bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
- void DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport);
+ void DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
// Copy assignment is forbidden and not implemented.
ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
@@ -127,7 +127,7 @@ public:
int GetPageCount() const { return mnPageCount; }
- size_t DoImport(SdrObjList& rDestList, size_t nInsPos, size_t nPageNumber,
+ size_t DoImport(SdrObjList& rDestList, size_t nInsPos, int nPageNumber,
SvdProgressInfo* pProgrInfo = nullptr);
};
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index c38c4269512a..5d022fcf1a65 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -200,7 +200,7 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
, maLastUsed (std::chrono::high_resolution_clock::now())
, mbPrepared (rImpGraphic.mbPrepared)
- , mnPageNumber(-1)
+ , mnPageNumber(rImpGraphic.mnPageNumber)
{
if( rImpGraphic.mpGfxLink )
mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink );
@@ -229,7 +229,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic)
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
, maLastUsed (std::chrono::high_resolution_clock::now())
, mbPrepared (rImpGraphic.mbPrepared)
- , mnPageNumber(-1)
+ , mnPageNumber(rImpGraphic.mnPageNumber)
{
rImpGraphic.ImplClear();
rImpGraphic.mbDummyContext = false;