[Libreoffice-commits] core.git: filter/source
Eike Rathke
erack at redhat.com
Fri Sep 22 19:56:40 UTC 2017
filter/source/graphic/GraphicExportFilter.cxx | 52 ++++++++++++++++++++++++++
filter/source/graphic/GraphicExportFilter.hxx | 11 +++++
2 files changed, 63 insertions(+)
New commits:
commit 2d0d777fe8830a39a316b01e08864e4694a51964
Author: Eike Rathke <erack at redhat.com>
Date: Fri Sep 22 16:29:10 2017 +0200
Export to PNG: selected shapes via drawing::GraphicExportFilter, tdf#108317
Change-Id: Id09d9b21b2e6c018dd199a1911a9125c118abec2
Reviewed-on: https://gerrit.libreoffice.org/42658
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx
index ba99893c6e7f..882e53f0cabd 100644
--- a/filter/source/graphic/GraphicExportFilter.cxx
+++ b/filter/source/graphic/GraphicExportFilter.cxx
@@ -19,6 +19,8 @@
#include "GraphicExportFilter.hxx"
+#include <com/sun/star/drawing/GraphicExportFilter.hpp>
+
#include <vcl/graphicfilter.hxx>
#include <svl/outstrm.hxx>
#include <svtools/DocumentToGraphicRenderer.hxx>
@@ -115,6 +117,22 @@ sal_Bool SAL_CALL GraphicExportFilter::filter( const Sequence<PropertyValue>& rD
{
gatherProperties(rDescriptor);
+ if (mbSelectionOnly && mxDocument.is())
+ {
+ uno::Reference< frame::XModel > xModel( mxDocument, uno::UNO_QUERY);
+ if (xModel.is())
+ {
+ uno::Reference< frame::XController > xController( xModel->getCurrentController());
+ if (xController.is())
+ {
+ uno::Reference< drawing::XShapes > xShapes;
+ uno::Reference< drawing::XShape > xShape;
+ if (DocumentToGraphicRenderer::isShapeSelected( xShapes, xShape, xController))
+ return filterExportShape( rDescriptor, xShapes, xShape);
+ }
+ }
+ }
+
return filterRenderDocument();
}
@@ -193,6 +211,40 @@ bool GraphicExportFilter::filterRenderDocument() const
return false;
}
+bool GraphicExportFilter::filterExportShape(
+ const css::uno::Sequence< css::beans::PropertyValue > & rDescriptor,
+ const css::uno::Reference< css::drawing::XShapes > & rxShapes,
+ const css::uno::Reference< css::drawing::XShape > & rxShape ) const
+{
+ uno::Reference< lang::XComponent > xSourceDoc;
+ if (rxShapes.is())
+ xSourceDoc.set( rxShapes, uno::UNO_QUERY_THROW );
+ else if (rxShape.is())
+ xSourceDoc.set( rxShape, uno::UNO_QUERY_THROW );
+ if (!xSourceDoc.is())
+ return false;
+
+ uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter =
+ drawing::GraphicExportFilter::create( mxContext );
+ if (!xGraphicExporter.is())
+ return false;
+
+ // Need to replace the internal filter name with the short name
+ // (extension).
+ uno::Sequence< beans::PropertyValue > aDescriptor( rDescriptor);
+ for (sal_Int32 i = 0; i < aDescriptor.getLength(); ++i)
+ {
+ if (aDescriptor[i].Name == "FilterName")
+ {
+ aDescriptor[i].Value <<= mFilterExtension;
+ break;
+ }
+ }
+
+ xGraphicExporter->setSourceDocument( xSourceDoc );
+ return xGraphicExporter->filter( aDescriptor );
+}
+
void SAL_CALL GraphicExportFilter::cancel( )
{
}
diff --git a/filter/source/graphic/GraphicExportFilter.hxx b/filter/source/graphic/GraphicExportFilter.hxx
index 9d213352c770..697592b82286 100644
--- a/filter/source/graphic/GraphicExportFilter.hxx
+++ b/filter/source/graphic/GraphicExportFilter.hxx
@@ -28,6 +28,13 @@
#include <cppuhelper/implbase.hxx>
#include <comphelper/processfactory.hxx>
+namespace com { namespace sun { namespace star {
+ namespace drawing {
+ class XShapes;
+ class XShape;
+ }
+}}}
+
using namespace css;
using namespace css::uno;
using namespace css::lang;
@@ -57,6 +64,10 @@ class GraphicExportFilter :
css::uno::Any maQuality;
bool filterRenderDocument() const;
+ bool filterExportShape(
+ const css::uno::Sequence< css::beans::PropertyValue > & rDescriptor,
+ const css::uno::Reference< css::drawing::XShapes > & rxShapes,
+ const css::uno::Reference< css::drawing::XShape > & rxShape ) const;
public:
explicit GraphicExportFilter( const Reference<XComponentContext>& rxContext );
More information about the Libreoffice-commits
mailing list