[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/svtools sfx2/source svtools/source

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 17 18:33:41 UTC 2019


 include/svtools/DocumentToGraphicRenderer.hxx       |    3 ++
 sfx2/source/doc/objserv.cxx                         |   16 ++-----------
 svtools/source/filter/DocumentToGraphicRenderer.cxx |   23 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 13 deletions(-)

New commits:
commit 5027eab356740ae4ebb0720f30fe1c0af5e0c1d7
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Tue Jan 8 16:58:40 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Mon Jun 17 20:32:53 2019 +0200

    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 at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/69813
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/74190
    Tested-by: Muhammet Kara <muhammet.kara at collabora.com>

diff --git a/include/svtools/DocumentToGraphicRenderer.hxx b/include/svtools/DocumentToGraphicRenderer.hxx
index 5d153a2f5c71..e547caacf38a 100644
--- a/include/svtools/DocumentToGraphicRenderer.hxx
+++ b/include/svtools/DocumentToGraphicRenderer.hxx
@@ -68,12 +68,15 @@ public:
     ~DocumentToGraphicRenderer();
 
     sal_Int32 getCurrentPage();
+
     /**
      * Get list of chapter names for a page, current page is set by
      * renderToGraphic().
      */
     const std::vector<OUString>& getChapterNames() const;
 
+    sal_Int32 getPageCount();
+
     Size getDocumentSizeInPixels( sal_Int32 nCurrentPage );
 
     Size getDocumentSizeIn100mm(sal_Int32 nCurrentPage, Point* pDocumentPosition = nullptr);
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 42ea933fb156..666d1ec25252 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -545,22 +545,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 771ca36152b0..9d1becf178f8 100644
--- a/svtools/source/filter/DocumentToGraphicRenderer.cxx
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -252,6 +252,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);


More information about the Libreoffice-commits mailing list