[Libreoffice-commits] core.git: include/svtools svtools/source

Eike Rathke erack at redhat.com
Fri Sep 22 19:52:58 UTC 2017


 include/svtools/DocumentToGraphicRenderer.hxx       |   21 +++++++++++++++++
 svtools/source/filter/DocumentToGraphicRenderer.cxx |   24 ++++++++++++++++++++
 2 files changed, 45 insertions(+)

New commits:
commit 3b06d9df29dc2aef568bad5bbe10c57e78bbb81a
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Sep 22 14:02:20 2017 +0200

    Introduce DocumentToGraphicRenderer::isShapeSelected()
    
    Change-Id: I66fc0e39a7a35969b937253c88326516949ea7e7
    Reviewed-on: https://gerrit.libreoffice.org/42653
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/include/svtools/DocumentToGraphicRenderer.hxx b/include/svtools/DocumentToGraphicRenderer.hxx
index 80f37df3c56e..5ed6f2ce4434 100644
--- a/include/svtools/DocumentToGraphicRenderer.hxx
+++ b/include/svtools/DocumentToGraphicRenderer.hxx
@@ -30,6 +30,16 @@
 
 #include <svtools/svtdllapi.h>
 
+namespace com { namespace sun { namespace star {
+    namespace drawing {
+        class XShapes;
+        class XShape;
+    }
+    namespace frame {
+        class XController;
+    }
+}}}
+
 class SVT_DLLPUBLIC DocumentToGraphicRenderer
 {
     const css::uno::Reference<css::lang::XComponent>& mxDocument;
@@ -63,6 +73,17 @@ public:
 
     Graphic renderToGraphic( sal_Int32 nCurrentPage, Size aDocumentSizePixel,
                             Size aTargetSizePixel, Color aPageColor);
+
+    /** Determine whether rxController has a css::view::XSelectionSupplier at
+        which either a css::drawing::XShapes or css::drawing::XShape is
+        selected. XShapes has precedence over XShape.
+
+        Call only if the SelectionOnly property was set.
+     */
+    static bool isShapeSelected(
+            css::uno::Reference< css::drawing::XShapes > & rxShapes,
+            css::uno::Reference< css::drawing::XShape > & rxShape,
+            const css::uno::Reference< css::frame::XController > & rxController );
 };
 
 #endif
diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx
index 180631cf56e4..8bf5120078bc 100644
--- a/svtools/source/filter/DocumentToGraphicRenderer.cxx
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -31,6 +31,8 @@
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 #include <com/sun/star/beans/PropertyValues.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
 
 #include <toolkit/helper/vclunohelper.hxx>
 
@@ -227,4 +229,26 @@ sal_Int32 DocumentToGraphicRenderer::getCurrentPageWriter()
     return xCursor->getPage();
 }
 
+// static
+bool DocumentToGraphicRenderer::isShapeSelected(
+        css::uno::Reference< css::drawing::XShapes > & rxShapes,
+        css::uno::Reference< css::drawing::XShape > & rxShape,
+        const css::uno::Reference< css::frame::XController > & rxController )
+{
+    bool bShape = false;
+    if (rxController.is())
+    {
+        uno::Reference< view::XSelectionSupplier > xSelectionSupplier( rxController, uno::UNO_QUERY);
+        if (xSelectionSupplier.is())
+        {
+            uno::Any aAny( xSelectionSupplier->getSelection());
+            if (aAny >>= rxShapes)
+                bShape = true;
+            else if (aAny >>= rxShape)
+                bShape = true;
+        }
+    }
+    return bShape;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list