summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-01-08 16:58:40 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2019-01-08 21:07:22 +0100
commitaf3e421fdb32f172d40ba4641f24f1356fcb55ce (patch)
tree1be8392c1c5e487953cef0ae7a8f43705be50035
parentwriterfilter: avoid exception - IsProtect not page style property. (diff)
downloadcore-af3e421fdb32f172d40ba4641f24f1356fcb55ce.tar.gz
core-af3e421fdb32f172d40ba4641f24f1356fcb55ce.zip
Add method DocumentToGraphicRenderer::getPageCount()
And use that in sfx2 Redaction code to be independent of the document/module type Change-Id: Ic206f7a10a27d8d44566df34a10d009a34adf0a5 Reviewed-on: https://gerrit.libreoffice.org/65971 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
-rw-r--r--include/svtools/DocumentToGraphicRenderer.hxx1
-rw-r--r--sfx2/source/doc/objserv.cxx16
-rw-r--r--svtools/source/filter/DocumentToGraphicRenderer.cxx23
3 files changed, 27 insertions, 13 deletions
diff --git a/include/svtools/DocumentToGraphicRenderer.hxx b/include/svtools/DocumentToGraphicRenderer.hxx
index 5d153a2f5c71..4ce5cb4d41fa 100644
--- a/include/svtools/DocumentToGraphicRenderer.hxx
+++ b/include/svtools/DocumentToGraphicRenderer.hxx
@@ -68,6 +68,7 @@ public:
~DocumentToGraphicRenderer();
sal_Int32 getCurrentPage();
+ sal_Int32 getPageCount();
/**
* Get list of chapter names for a page, current page is set by
* renderToGraphic().
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index fed50045b256..9fb13a899b1b 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -538,22 +538,12 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
if(!xModel.is())
return;
- uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
- xModel->getCurrentController(), uno::UNO_QUERY);
- if(!xTextViewCursorSupplier.is())
- return;
-
- uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
- uno::UNO_QUERY);
- if(!xCursor.is())
- return;
-
- xCursor->jumpToLastPage();
- sal_Int16 nPages = xCursor->getPage();
-
uno::Reference< lang::XComponent > xSourceDoc( xModel );
+
DocumentToGraphicRenderer aRenderer(xSourceDoc, /*bSelectionOnly=*/false);
+ sal_Int32 nPages = aRenderer.getPageCount();
+
std::vector< GDIMetaFile > aMetaFiles;
for (sal_Int32 nPage = 1; nPage <= nPages; ++nPage)
diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx
index ec4b15966dda..5ea3982d0e00 100644
--- a/svtools/source/filter/DocumentToGraphicRenderer.cxx
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -253,6 +253,29 @@ sal_Int32 DocumentToGraphicRenderer::getCurrentPage()
return 1;
}
+sal_Int32 DocumentToGraphicRenderer::getPageCount()
+{
+ Reference< awt::XDevice > xDevice(mxToolkit->createScreenCompatibleDevice( 32, 32 ) );
+
+ uno::Any selection( getSelection() );
+
+ PropertyValues renderProperties;
+
+ renderProperties.realloc( 4 );
+ renderProperties[0].Name = "IsPrinter";
+ renderProperties[0].Value <<= true;
+ renderProperties[1].Name = "RenderDevice";
+ renderProperties[1].Value <<= xDevice;
+ renderProperties[2].Name = "View";
+ renderProperties[2].Value <<= mxController;
+ renderProperties[3].Name = "RenderToGraphic";
+ renderProperties[3].Value <<= true;
+
+ sal_Int32 nPages = mxRenderable->getRendererCount( selection, renderProperties );
+
+ return nPages;
+}
+
sal_Int32 DocumentToGraphicRenderer::getCurrentPageWriter()
{
Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(mxModel->getCurrentController(), UNO_QUERY);