summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Repository.mk1
-rw-r--r--filter/Configuration_filter.mk11
-rw-r--r--filter/Library_graphicfilter.mk56
-rw-r--r--filter/Module_filter.mk1
-rw-r--r--filter/source/config/fragments/filters/writer_jpg_Export.xcu30
-rw-r--r--filter/source/config/fragments/filters/writer_png_Export.xcu30
-rw-r--r--filter/source/graphic/GraphicExportDialog.cxx160
-rw-r--r--filter/source/graphic/GraphicExportDialog.hxx80
-rw-r--r--filter/source/graphic/GraphicExportFilter.cxx153
-rw-r--r--filter/source/graphic/GraphicExportFilter.hxx76
-rw-r--r--filter/source/graphic/Services.cxx56
-rw-r--r--filter/source/graphic/graphicfilter.component28
-rw-r--r--postprocess/CustomTarget_registry.mk4
-rw-r--r--postprocess/Rdb_services.mk1
-rw-r--r--scp2/source/graphicfilter/file_graphicfilter.scp4
-rw-r--r--scp2/source/graphicfilter/module_graphicfilter.scp10
-rw-r--r--svtools/Library_svt.mk2
-rw-r--r--svtools/Package_inc.mk2
-rw-r--r--svtools/UI_svt.mk1
-rw-r--r--svtools/inc/svtools/DocumentToGraphicRenderer.hxx62
-rw-r--r--svtools/inc/svtools/GraphicExportOptionsDialog.hxx80
-rw-r--r--svtools/source/filter/DocumentToGraphicRenderer.cxx145
-rw-r--r--svtools/source/filter/GraphicExportOptionsDialog.cxx126
-rw-r--r--svtools/uiconfig/ui/GraphicExportOptionsDialog.ui272
24 files changed, 1386 insertions, 5 deletions
diff --git a/Repository.mk b/Repository.mk
index 1da813e6c4ee..f07b819ce2b6 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -307,6 +307,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
flat \
for \
fwk \
+ graphicfilter \
guesslang \
helplinker \
hwp \
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 483da495946e..7ca392c81749 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -829,6 +829,17 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
impress_html_Export_ui \
)
+# fcfg_writergraphics
+$(call filter_Configuration_add_types,fcfg_langpack,fcfg_writergraphics_types.xcu,filter/source/config/fragments/types,\
+ jpg_JPEG \
+ png_Portable_Network_Graphic \
+)
+
+$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writergraphics_filters.xcu,filter/source/config/fragments/filters,\
+ writer_jpg_Export \
+ writer_png_Export \
+)
+
# fcfg_internalgraphics
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_internalgraphics_types.xcu,filter/source/config/fragments/types,\
bmp_MS_Windows \
diff --git a/filter/Library_graphicfilter.mk b/filter/Library_graphicfilter.mk
new file mode 100644
index 000000000000..223121e48844
--- /dev/null
+++ b/filter/Library_graphicfilter.mk
@@ -0,0 +1,56 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+$(eval $(call gb_Library_Library,graphicfilter))
+
+$(eval $(call gb_Library_set_componentfile,graphicfilter,filter/source/graphic/graphicfilter))
+
+$(eval $(call gb_Library_use_external,graphicfilter,boost_headers))
+
+$(eval $(call gb_Library_use_sdk_api,graphicfilter))
+
+$(eval $(call gb_Library_set_include,graphicfilter,\
+ -I$(SRCDIR)/filter/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_libraries,graphicfilter,\
+ svt \
+ sfx \
+ tk \
+ vcl \
+ utl \
+ tl \
+ svl \
+ i18nisolang1 \
+ comphelper \
+ basegfx \
+ cppuhelper \
+ cppu \
+ sal \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_Library_add_exception_objects,graphicfilter,\
+ filter/source/graphic/GraphicExportFilter \
+ filter/source/graphic/GraphicExportDialog \
+ filter/source/graphic/Services \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index 170e8768558f..b13407c67917 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Module_add_targets,filter,\
Library_pdffilter \
Library_placeware \
Library_svgfilter \
+ Library_graphicfilter \
Library_t602filter \
Library_textfd \
Library_xmlfa \
diff --git a/filter/source/config/fragments/filters/writer_jpg_Export.xcu b/filter/source/config/fragments/filters/writer_jpg_Export.xcu
new file mode 100644
index 000000000000..4382761ddfde
--- /dev/null
+++ b/filter/source/config/fragments/filters/writer_jpg_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+ <node oor:name="writer_jpg_Export" oor:op="replace">
+ <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ <prop oor:name="UIComponent"><value>com.sun.star.comp.GraphicExportDialog</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop>
+ <prop oor:name="UserData"><value></value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="x-default">JPEG - Joint Photographic Experts Group</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>jpg_JPEG</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+ </node>
diff --git a/filter/source/config/fragments/filters/writer_png_Export.xcu b/filter/source/config/fragments/filters/writer_png_Export.xcu
new file mode 100644
index 000000000000..85438356d50b
--- /dev/null
+++ b/filter/source/config/fragments/filters/writer_png_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+ <node oor:name="writer_png_Export" oor:op="replace">
+ <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ <prop oor:name="UIComponent"><value>com.sun.star.comp.GraphicExportDialog</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.GraphicExportFilter</value></prop>
+ <prop oor:name="UserData"><value></value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="x-default">PNG - Portable Network Graphic</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>png_Portable_Network_Graphic</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+ </node>
diff --git a/filter/source/graphic/GraphicExportDialog.cxx b/filter/source/graphic/GraphicExportDialog.cxx
new file mode 100644
index 000000000000..23a5e2057e20
--- /dev/null
+++ b/filter/source/graphic/GraphicExportDialog.cxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "GraphicExportDialog.hxx"
+
+#include <vcl/graphicfilter.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/Any.h>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+
+#include <svtools/GraphicExportOptionsDialog.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::beans;
+using namespace css::lang;
+
+GraphicExportDialog::GraphicExportDialog( const Reference< XComponentContext >& rxContext ) :
+ mxContext ( rxContext ),
+ mbExportSelection ( sal_False )
+{
+}
+
+GraphicExportDialog::~GraphicExportDialog()
+{
+}
+
+// XInitialization
+void SAL_CALL GraphicExportDialog::initialize( const Sequence<Any>& ) throw ( Exception, RuntimeException )
+{}
+
+// XPropertyAccess
+Sequence<PropertyValue> GraphicExportDialog::getPropertyValues() throw ( RuntimeException )
+{
+ sal_Int32 i;
+ sal_Int32 nCount = maMediaDescriptor.getLength();
+
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( maMediaDescriptor[ i ].Name == "FilterData" )
+ {
+ break;
+ }
+ }
+
+ if ( i >= nCount )
+ {
+ nCount++;
+ maMediaDescriptor.realloc( nCount );
+ }
+
+ maMediaDescriptor[ i ].Name = OUString( "FilterData" );
+ maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
+ return maMediaDescriptor;
+}
+
+void GraphicExportDialog::setPropertyValues( const Sequence<PropertyValue>& aProps )
+ throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
+ WrappedTargetException, RuntimeException )
+{
+ maMediaDescriptor = aProps;
+
+ sal_Int32 i, nCount;
+ for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
+ {
+ if ( maMediaDescriptor[ i ].Name == "FilterData" )
+ {
+ maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
+ }
+ else if ( maMediaDescriptor[ i ].Name == "SelectionOnly" )
+ {
+ maMediaDescriptor[ i ].Value >>= mbExportSelection;
+ }
+ }
+}
+
+// XExecutableDialog
+void GraphicExportDialog::setTitle( const OUString& aTitle )
+ throw ( uno::RuntimeException )
+{
+ maDialogTitle = aTitle;
+}
+
+sal_Int16 GraphicExportDialog::execute() throw ( RuntimeException )
+{
+ sal_Int16 nReturn = ui::dialogs::ExecutableDialogResults::CANCEL;
+ GraphicExportOptionsDialog graphicExportOptionsDialog( Application::GetDefDialogParent(), mxSourceDocument );
+ if (graphicExportOptionsDialog.Execute() == RET_OK )
+ {
+ maFilterDataSequence = graphicExportOptionsDialog.getFilterData();
+ nReturn = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ return nReturn;
+}
+
+// XEmporter
+void GraphicExportDialog::setSourceDocument( const Reference<XComponent>& xDocument )
+ throw ( IllegalArgumentException, RuntimeException )
+{
+ mxSourceDocument = xDocument;
+
+ // try to set the corresponding metric unit
+ OUString aConfigPath;
+ Reference< XServiceInfo > xServiceInfo ( xDocument, UNO_QUERY );
+
+ if ( xServiceInfo.is() )
+ {
+ if ( xServiceInfo->supportsService( OUString( "com.sun.star.presentation.PresentationDocument" ) ) )
+ {
+ aConfigPath = OUString( "Office.Impress/Layout/Other/MeasureUnit" );
+ }
+ else if ( xServiceInfo->supportsService( OUString( "com.sun.star.drawing.DrawingDocument" ) ) )
+ {
+ aConfigPath = OUString( "Office.Draw/Layout/Other/MeasureUnit" );
+ }
+ else if ( xServiceInfo->supportsService( OUString( "com.sun.star.text.TextDocument" ) ) )
+ {
+ aConfigPath = OUString( "Office.Writer/Layout/Other/MeasureUnit" );
+ }
+ if ( !aConfigPath.isEmpty() )
+ {
+ FilterConfigItem aConfigItem( aConfigPath );
+ String aPropertyName;
+ SvtSysLocale aSysLocale;
+
+ if ( aSysLocale.GetLocaleDataPtr()->getMeasurementSystemEnum() == MEASURE_METRIC )
+ {
+ aPropertyName = String( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+ else
+ {
+ aPropertyName = String( RTL_CONSTASCII_USTRINGPARAM( "NonMetric" ) );
+ }
+ meFieldUnit = (FieldUnit) aConfigItem.ReadInt32( aPropertyName, FUNIT_CM );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphic/GraphicExportDialog.hxx b/filter/source/graphic/GraphicExportDialog.hxx
new file mode 100644
index 000000000000..7a32708d7089
--- /dev/null
+++ b/filter/source/graphic/GraphicExportDialog.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _GRAPHICEXPORTDIALOG_HXX_
+#define _GRAPHICEXPORTDIALOG_HXX_
+
+#include <tools/fldunit.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::beans;
+using namespace css::lang;
+
+class GraphicExportDialog : public cppu::WeakImplHelper4
+<
+ document::XExporter,
+ ui::dialogs::XExecutableDialog,
+ beans::XPropertyAccess,
+ lang::XInitialization
+>
+{
+ Sequence<PropertyValue> maMediaDescriptor;
+ Sequence<PropertyValue> maFilterDataSequence;
+ Reference<XComponent> mxSourceDocument;
+ Reference<XComponentContext> mxContext;
+
+ OUString maDialogTitle;
+ FieldUnit meFieldUnit;
+ bool mbExportSelection;
+
+public:
+
+ explicit GraphicExportDialog( const Reference<XComponentContext>& rxContext );
+ virtual ~GraphicExportDialog();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence<Any>& aArguments ) throw (Exception, RuntimeException );
+
+ // XPropertyAccess
+ virtual Sequence<PropertyValue> SAL_CALL getPropertyValues() throw ( RuntimeException );
+ virtual void SAL_CALL setPropertyValues( const Sequence<PropertyValue>& aProps )
+ throw ( UnknownPropertyException, PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ RuntimeException );
+
+ // XExecuteDialog
+ virtual sal_Int16 SAL_CALL execute() throw ( RuntimeException );
+ virtual void SAL_CALL setTitle( const OUString& aTitle ) throw ( RuntimeException );
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const Reference<lang::XComponent>& xDocument ) throw ( lang::IllegalArgumentException, RuntimeException );
+};
+
+
+#endif // _GRAPHICEXPORTDIALOGUNO_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx
new file mode 100644
index 000000000000..46a5b7f43ef3
--- /dev/null
+++ b/filter/source/graphic/GraphicExportFilter.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "GraphicExportFilter.hxx"
+
+#include <vcl/graphicfilter.hxx>
+#include <svl/outstrm.hxx>
+#include <svtools/DocumentToGraphicRenderer.hxx>
+
+GraphicExportFilter::GraphicExportFilter( const Reference<XComponentContext>& rxContext ) :
+ mxContext( rxContext )
+{}
+
+GraphicExportFilter::~GraphicExportFilter()
+{}
+
+void GraphicExportFilter::gatherProperties( const Sequence<PropertyValue>& rProperties )
+{
+ OUString aInternalFilterName;
+
+ for ( sal_Int32 i = 0; i < rProperties.getLength(); i++ )
+ {
+ PropertyValue aProperty = rProperties[i];
+
+ if ( aProperty.Name == "FilterName" )
+ {
+ aProperty.Value >>= aInternalFilterName;
+ aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "draw_" ), OUString() );
+ aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "impress_" ), OUString() );
+ aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "calc_" ), OUString() );
+ aInternalFilterName = aInternalFilterName.replaceFirst( OUString( "writer_" ), OUString() );
+ }
+ else if ( aProperty.Name == "FilterData" )
+ {
+ aProperty.Value >>= mFilterDataSequence;
+ }
+ else if ( aProperty.Name == "SelectionOnly" )
+ {
+ aProperty.Value >>= mExportSelection;
+ }
+ else if ( aProperty.Name == "URL" )
+ {
+ if( !( aProperty.Value >>= mTargetUrl ) )
+ {
+ aProperty.Value >>= mTargetUrl.Complete;
+ }
+ }
+ else if ( aProperty.Name == "OutputStream" )
+ {
+ aProperty.Value >>= mxOutputStream;
+ }
+ }
+
+ for ( sal_Int32 i = 0; i < mFilterDataSequence.getLength(); i++ )
+ {
+ if ( mFilterDataSequence[i].Name == "PixelWidth" )
+ {
+ mFilterDataSequence[i].Value >>= mTargetWidth;
+ }
+ else if ( mFilterDataSequence[i].Name == "PixelHeight" )
+ {
+ mFilterDataSequence[i].Value >>= mTargetHeight;
+ }
+ }
+
+ if ( !aInternalFilterName.isEmpty() )
+ {
+ GraphicFilter aGraphicFilter( sal_True );
+
+ sal_uInt16 nFilterCount = aGraphicFilter.GetExportFormatCount();
+ sal_uInt16 nFormat;
+
+ for ( nFormat = 0; nFormat < nFilterCount; nFormat++ )
+ {
+ if ( aGraphicFilter.GetExportInternalFilterName( nFormat ) == aInternalFilterName )
+ break;
+ }
+ if ( nFormat < nFilterCount )
+ {
+ mFilterExtension = aGraphicFilter.GetExportFormatShortName( nFormat );
+ }
+ }
+}
+
+sal_Bool SAL_CALL GraphicExportFilter::filter( const Sequence<PropertyValue>& rDescriptor )
+ throw (RuntimeException)
+{
+ gatherProperties(rDescriptor);
+
+ DocumentToGraphicRenderer aRenderer( mxDocument );
+ sal_Int32 aCurrentPage = aRenderer.getCurrentPageWriter();
+ Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels(aCurrentPage);
+
+ Size aTargetSizePixel(mTargetWidth, mTargetHeight);
+
+ Graphic aGraphic = aRenderer.renderToGraphic( aCurrentPage, aDocumentSizePixel, aTargetSizePixel );
+
+ GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+
+ Sequence< PropertyValue > aFilterData( 3 );
+ aFilterData[ 0 ].Name = "Interlaced";
+ aFilterData[ 0 ].Value <<= (sal_Int32) 0;
+ aFilterData[ 1 ].Name = "Compression";
+ aFilterData[ 1 ].Value <<= (sal_Int32) 9;
+ aFilterData[ 2 ].Name = "Quality";
+ aFilterData[ 2 ].Value <<= (sal_Int32) 99;
+
+ sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( mFilterExtension );
+
+ SvMemoryStream aMemStream;
+ const GraphicConversionParameters aParameters(aTargetSizePixel, true, true);
+
+ sal_uInt16 aResult = rFilter.ExportGraphic( aGraphic.GetBitmapEx(aParameters), String(), aMemStream, nFilterFormat, &aFilterData );
+
+ SvOutputStream aOutputStream( mxOutputStream );
+ aMemStream.Seek(0);
+ aOutputStream << aMemStream;
+
+ return true;
+}
+
+void SAL_CALL GraphicExportFilter::cancel( ) throw (RuntimeException)
+{
+}
+
+void SAL_CALL GraphicExportFilter::setSourceDocument( const Reference<XComponent>& xDocument )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ mxDocument = xDocument;
+}
+
+void SAL_CALL GraphicExportFilter::initialize( const Sequence<Any>& )
+ throw (Exception, RuntimeException)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphic/GraphicExportFilter.hxx b/filter/source/graphic/GraphicExportFilter.hxx
new file mode 100644
index 000000000000..13e9b39b317a
--- /dev/null
+++ b/filter/source/graphic/GraphicExportFilter.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _GRAPHICEXPORTFILTER_HXX_
+#define _GRAPHICEXPORTFILTER_HXX_
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+
+#include <cppuhelper/implbase3.hxx>
+#include <comphelper/processfactory.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::beans;
+using namespace css::document;
+
+class GraphicExportFilter :
+ public cppu::WeakImplHelper3 < XFilter, XExporter, XInitialization >
+{
+ Reference<XComponent> mxDocument;
+ Reference<XComponentContext> mxContext;
+ Reference<task::XStatusIndicator> mxStatusIndicator;
+ Reference<io::XOutputStream> mxOutputStream;
+
+ void gatherProperties( const Sequence<PropertyValue>& rDescriptor );
+
+ bool mExportSelection;
+ OUString mFilterExtension;
+ util::URL mTargetUrl;
+
+ Sequence<PropertyValue> mFilterDataSequence;
+
+ sal_Int32 mTargetWidth;
+ sal_Int32 mTargetHeight;
+
+public:
+ explicit GraphicExportFilter( const Reference<XComponentContext>& rxContext );
+ virtual ~GraphicExportFilter();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const Sequence<PropertyValue>& rDescriptor ) throw(RuntimeException);
+ virtual void SAL_CALL cancel( ) throw (RuntimeException);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDocument ) throw(IllegalArgumentException, RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence<Any>& aArguments ) throw(Exception, RuntimeException);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphic/Services.cxx b/filter/source/graphic/Services.cxx
new file mode 100644
index 000000000000..35cf5d75bb48
--- /dev/null
+++ b/filter/source/graphic/Services.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "GraphicExportDialog.hxx"
+#include "GraphicExportFilter.hxx"
+#include <comphelper/servicedecl.hxx>
+
+#define GRAPHIC_EXPORT_FILTER_SERVICE "com.sun.star.comp.GraphicExportFilter"
+#define GRAPHIC_EXPORT_DIALOG_SERVICE "com.sun.star.comp.GraphicExportDialog"
+
+comphelper::service_decl::class_<GraphicExportFilter> serviceGraphicExportFilter;
+const comphelper::service_decl::ServiceDecl graphicExportFilter(
+ serviceGraphicExportFilter,
+ GRAPHIC_EXPORT_FILTER_SERVICE,
+ "com.sun.star.document.ExportFilter" );
+
+comphelper::service_decl::class_<GraphicExportDialog> serviceGraphicExportDialog;
+const comphelper::service_decl::ServiceDecl graphicExportDialog(
+ serviceGraphicExportDialog,
+ GRAPHIC_EXPORT_DIALOG_SERVICE,
+ "com.sun.star.ui.dialog.FilterOptionsDialog" );
+
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL graphicfilter_component_getFactory(
+ sal_Char const* pImplementationName,
+ ::com::sun::star::lang::XMultiServiceFactory* pServiceManager,
+ ::com::sun::star::registry::XRegistryKey* pRegistryKey )
+{
+ if ( rtl_str_compare (pImplementationName, GRAPHIC_EXPORT_FILTER_SERVICE) == 0 )
+ {
+ return component_getFactoryHelper( pImplementationName, pServiceManager, pRegistryKey, graphicExportFilter );
+ }
+ else if ( rtl_str_compare (pImplementationName, GRAPHIC_EXPORT_DIALOG_SERVICE) == 0 )
+ {
+ return component_getFactoryHelper( pImplementationName, pServiceManager, pRegistryKey, graphicExportDialog );
+ }
+ return NULL;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphic/graphicfilter.component b/filter/source/graphic/graphicfilter.component
new file mode 100644
index 000000000000..3082473284a5
--- /dev/null
+++ b/filter/source/graphic/graphicfilter.component
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" prefix="graphicfilter"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.GraphicExportFilter">
+ <service name="com.sun.star.document.ExportFilter"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.GraphicExportDialog">
+ <service name="com.sun.star.ui.dialog.FilterOptionsDialog"/>
+ </implementation>
+</component>
diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk
index f7f69585f071..71a968998218 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -97,7 +97,9 @@ postprocess_FILES_graphicfilter := \
$(postprocess_MOD)/fcfg_drawgraphics_filters.xcu \
$(postprocess_MOD)/fcfg_drawgraphics_types.xcu \
$(postprocess_MOD)/fcfg_impressgraphics_filters.xcu \
- $(postprocess_MOD)/fcfg_impressgraphics_types.xcu
+ $(postprocess_MOD)/fcfg_impressgraphics_types.xcu \
+ $(postprocess_MOD)/fcfg_writergraphics_filters.xcu \
+ $(postprocess_MOD)/fcfg_writergraphics_types.xcu
postprocess_DEPS_impress := main
postprocess_FILES_impress := \
diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk
index 4b0b8b7c527c..805a1e805f1f 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Rdb_add_components,services,\
fileaccess/source/fileacc \
filter/source/config/cache/filterconfig1 \
filter/source/flash/flash \
+ filter/source/graphic/graphicfilter \
filter/source/msfilter/msfilter \
filter/source/odfflatxml/odfflatxml \
filter/source/pdf/pdffilter \
diff --git a/scp2/source/graphicfilter/file_graphicfilter.scp b/scp2/source/graphicfilter/file_graphicfilter.scp
index 9476149994f2..4fe8a8d8b25e 100644
--- a/scp2/source/graphicfilter/file_graphicfilter.scp
+++ b/scp2/source/graphicfilter/file_graphicfilter.scp
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -38,4 +38,6 @@ STD_LIB_FILE( gid_File_Lib_Flash, flash )
STD_LIB_FILE( gid_File_Lib_Svg, svgfilter )
+STD_LIB_FILE( gid_File_Lib_Graphic, graphicfilter )
+
STD_LIB_FILE( gid_File_Lib_WpftDraw, wpftdraw )
diff --git a/scp2/source/graphicfilter/module_graphicfilter.scp b/scp2/source/graphicfilter/module_graphicfilter.scp
index f428c0cf038e..cd7e4a6809af 100644
--- a/scp2/source/graphicfilter/module_graphicfilter.scp
+++ b/scp2/source/graphicfilter/module_graphicfilter.scp
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -33,6 +33,10 @@ Module gid_Module_Optional_Grfflt
Sortkey = "600";
ParentID = gid_Module_Optional;
Default = YES;
- Files = (gid_File_Lib_Svg, gid_File_Lib_Flash, gid_File_Lib_WpftDraw,
- gid_File_Share_Registry_Graphicfilter_Xcd);
+ Files = (
+ gid_File_Lib_Svg,
+ gid_File_Lib_Flash,
+ gid_File_Lib_WpftDraw,
+ gid_File_Lib_Graphic,
+ gid_File_Share_Registry_Graphicfilter_Xcd);
End
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index bfd409bd3d70..cc6219298151 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -144,6 +144,8 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/edit/svmedit2 \
svtools/source/edit/textwindowpeer \
svtools/source/filter/SvFilterOptionsDialog \
+ svtools/source/filter/GraphicExportOptionsDialog \
+ svtools/source/filter/DocumentToGraphicRenderer \
svtools/source/filter/exportdialog \
svtools/source/graphic/descriptor \
svtools/source/graphic/graphic \
diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk
index fe8ccf679cee..b6eb68417c81 100644
--- a/svtools/Package_inc.mk
+++ b/svtools/Package_inc.mk
@@ -21,6 +21,8 @@ $(eval $(call gb_Package_Package,svtools_inc,$(SRCDIR)/svtools/inc))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/AccessibleBrowseBoxObjType.hxx,svtools/AccessibleBrowseBoxObjType.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/DocumentInfoPreview.hxx,svtools/DocumentInfoPreview.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/QueryFolderName.hxx,svtools/QueryFolderName.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/GraphicExportOptionsDialog.hxx,svtools/GraphicExportOptionsDialog.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/DocumentToGraphicRenderer.hxx,svtools/DocumentToGraphicRenderer.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/acceleratorexecute.hxx,svtools/acceleratorexecute.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/accessibilityoptions.hxx,svtools/accessibilityoptions.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/accessiblefactory.hxx,svtools/accessiblefactory.hxx))
diff --git a/svtools/UI_svt.mk b/svtools/UI_svt.mk
index 44c2acd0e251..54d72a75665c 100644
--- a/svtools/UI_svt.mk
+++ b/svtools/UI_svt.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_UI_add_uifiles,svt,\
svtools/uiconfig/ui/placeedit \
svtools/uiconfig/ui/printersetupdialog \
svtools/uiconfig/ui/restartdialog \
+ svtools/uiconfig/ui/GraphicExportOptionsDialog \
))
# vim: set noet sw=4 ts=4:
diff --git a/svtools/inc/svtools/DocumentToGraphicRenderer.hxx b/svtools/inc/svtools/DocumentToGraphicRenderer.hxx
new file mode 100644
index 000000000000..3033e6473129
--- /dev/null
+++ b/svtools/inc/svtools/DocumentToGraphicRenderer.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef _DOCUMENTTOGRAPHICRENDERER_HXX_
+#define _DOCUMENTTOGRAPHICRENDERER_HXX_
+
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/view/XRenderable.hpp>
+#include <com/sun/star/awt/XToolkit.hpp>
+
+#include <vcl/graph.hxx>
+
+#include "svtools/svtdllapi.h"
+
+using namespace css;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::beans;
+
+class SVT_DLLPUBLIC DocumentToGraphicRenderer
+{
+ const Reference<XComponent>& mxDocument;
+
+ Reference<frame::XModel> mxModel;
+ Reference<frame::XController> mxController;
+ Reference<view::XRenderable> mxRenderable;
+ Reference<awt::XToolkit> mxToolkit;
+
+public:
+ DocumentToGraphicRenderer(const Reference<XComponent>& xDocument);
+ ~DocumentToGraphicRenderer();
+
+ sal_Int32 getCurrentPageWriter( );
+
+ Size getDocumentSizeInPixels( sal_Int32 aCurrentPage );
+
+ Size getDocumentSizeIn100mm( sal_Int32 aCurrentPage );
+
+ Graphic renderToGraphic(sal_Int32 aCurrentPage, Size aDocumentSizePixel, Size aTargetSizePixel);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/inc/svtools/GraphicExportOptionsDialog.hxx b/svtools/inc/svtools/GraphicExportOptionsDialog.hxx
new file mode 100644
index 000000000000..7058641c6a6c
--- /dev/null
+++ b/svtools/inc/svtools/GraphicExportOptionsDialog.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _GRAPHICEXPORTOPTIONSDIALOG_HXX_
+#define _GRAPHICEXPORTOPTIONSDIALOG_HXX_
+
+#include <vcl/fltcall.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/scrbar.hxx>
+
+#include <svtools/DocumentToGraphicRenderer.hxx>
+
+#include "svtools/svtdllapi.h"
+
+using namespace css;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::frame;
+using namespace css::beans;
+
+class SVT_DLLPUBLIC GraphicExportOptionsDialog : public ModalDialog
+{
+private:
+ const Reference<XComponent>& mxSourceDocument;
+
+ NumericField* mpWidth;
+ NumericField* mpHeight;
+ ComboBox* mpResolution;
+
+ Size mSize100mm;
+ double mResolution;
+
+ DocumentToGraphicRenderer mRenderer;
+
+ sal_Int32 mCurrentPage;
+
+ void initialize();
+ void updateWidth();
+ void updateHeight();
+ void updateResolution();
+
+ double getViewWidthInch();
+ double getViewHeightInch();
+
+ DECL_LINK( widthModifiedHandle, void* );
+ DECL_LINK( heightModifiedHandle, void* );
+ DECL_LINK( resolutionModifiedHandle, void* );
+
+public:
+ GraphicExportOptionsDialog( Window* pWindow, const Reference<XComponent>& rxSourceDocument );
+ ~GraphicExportOptionsDialog();
+
+ Sequence<PropertyValue> getFilterData();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx
new file mode 100644
index 000000000000..99b4436ea31a
--- /dev/null
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DocumentToGraphicRenderer.hxx"
+
+#include <vcl/graphicfilter.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/beans/PropertyValues.hpp>
+
+#include <toolkit/helper/vclunohelper.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::beans;
+
+DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent>& rxDocument ) :
+ mxDocument(rxDocument),
+ mxModel( mxDocument, uno::UNO_QUERY ),
+ mxController( mxModel->getCurrentController() ),
+ mxRenderable (mxDocument, uno::UNO_QUERY ),
+ mxToolkit( VCLUnoHelper::CreateToolkit() )
+{
+}
+
+DocumentToGraphicRenderer::~DocumentToGraphicRenderer()
+{
+}
+
+Size DocumentToGraphicRenderer::getDocumentSizeInPixels(sal_Int32 aCurrentPage)
+{
+ Size aSize100mm = getDocumentSizeIn100mm(aCurrentPage);
+ return Size( Application::GetDefaultDevice()->LogicToPixel( aSize100mm, MAP_100TH_MM ) );
+}
+
+Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 aCurrentPage)
+{
+ Reference< awt::XDevice > xDevice(mxToolkit->createScreenCompatibleDevice( 32, 32 ) );
+
+ uno::Any selection;
+ selection <<= mxDocument;
+
+ PropertyValues renderProperties;
+
+ renderProperties.realloc( 3 );
+ renderProperties[0].Name = "IsPrinter";
+ renderProperties[0].Value <<= sal_True;
+ renderProperties[1].Name = "RenderDevice";
+ renderProperties[1].Value <<= xDevice;
+ renderProperties[2].Name = "View";
+ renderProperties[2].Value <<= mxController;
+
+ Sequence< beans::PropertyValue > aResult;
+
+ sal_Int32 nPages = mxRenderable->getRendererCount( selection, renderProperties );
+
+ aResult = mxRenderable->getRenderer(aCurrentPage - 1, selection, renderProperties );
+
+ awt::Size aSize;
+ for( sal_Int32 nProperty = 0, nPropertyCount = aResult.getLength(); nProperty < nPropertyCount; ++nProperty )
+ {
+ if ( aResult[ nProperty ].Name == "PageSize" )
+ {
+ aResult[ nProperty ].Value >>= aSize;
+ }
+ }
+ return Size( aSize.Width, aSize.Height );
+}
+
+Graphic DocumentToGraphicRenderer::renderToGraphic(
+ sal_Int32 aCurrentPage,
+ Size aDocumentSizePixel,
+ Size aTargetSizePixel)
+
+{
+ if (!mxModel.is() || !mxController.is() || !mxRenderable.is())
+ return Graphic();
+
+ Reference< awt::XDevice > xDevice(mxToolkit->createScreenCompatibleDevice( aTargetSizePixel.Width(), aTargetSizePixel.Height() ) );
+ if (!xDevice.is())
+ return Graphic();
+
+ double fScaleX = aTargetSizePixel.Width() / (double) aDocumentSizePixel.Width();
+ double fScaleY = aTargetSizePixel.Height() / (double) aDocumentSizePixel.Height();
+
+ PropertyValues renderProps;
+ renderProps.realloc( 3 );
+ renderProps[0].Name = "IsPrinter";
+ renderProps[0].Value <<= sal_True;
+ renderProps[1].Name = "RenderDevice";
+ renderProps[1].Value <<= xDevice;
+ renderProps[2].Name = "View";
+ renderProps[2].Value <<= mxController;
+
+ GDIMetaFile aMtf;
+
+ OutputDevice* pOutputDev = VCLUnoHelper::GetOutputDevice( xDevice );
+ pOutputDev->SetAntialiasing(pOutputDev->GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
+ MapMode mm = pOutputDev->GetMapMode();
+ mm.SetScaleX( fScaleX );
+ mm.SetScaleY( fScaleY );
+ pOutputDev->SetMapMode( mm );
+
+ aMtf.Record( pOutputDev );
+
+ uno::Any aSelection;
+ aSelection <<= mxDocument;
+ mxRenderable->render(aCurrentPage - 1, aSelection, renderProps );
+
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefSize( aTargetSizePixel );
+
+ return Graphic(aMtf);
+}
+
+sal_Int32 DocumentToGraphicRenderer::getCurrentPageWriter()
+{
+ Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(mxModel->getCurrentController(), UNO_QUERY);
+ Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), UNO_QUERY);
+ return xCursor->getPage();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/filter/GraphicExportOptionsDialog.cxx b/svtools/source/filter/GraphicExportOptionsDialog.cxx
new file mode 100644
index 000000000000..4a7b6147c1c4
--- /dev/null
+++ b/svtools/source/filter/GraphicExportOptionsDialog.cxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "GraphicExportOptionsDialog.hxx"
+
+GraphicExportOptionsDialog::GraphicExportOptionsDialog(Window* pWindow, const Reference<XComponent>& rxSourceDocument) :
+ ModalDialog(pWindow, "GraphicExporter", "svt/ui/GraphicExportOptionsDialog.ui"),
+ mxSourceDocument(rxSourceDocument),
+ mResolution(96.0),
+ mRenderer(rxSourceDocument)
+{
+ get(mpWidth, "spin-width");
+ get(mpHeight, "spin-height");
+ get(mpResolution, "combo-resolution");
+
+ mpWidth->SetModifyHdl( LINK( this, GraphicExportOptionsDialog, widthModifiedHandle ));
+ mpHeight->SetModifyHdl( LINK( this, GraphicExportOptionsDialog, heightModifiedHandle ));
+ mpResolution->SetModifyHdl( LINK( this, GraphicExportOptionsDialog, resolutionModifiedHandle ));
+
+ initialize();
+
+ updateWidth();
+ updateHeight();
+ updateResolution();
+}
+
+GraphicExportOptionsDialog::~GraphicExportOptionsDialog()
+{}
+
+void GraphicExportOptionsDialog::initialize()
+{
+ mCurrentPage = mRenderer.getCurrentPageWriter();
+ mSize100mm = mRenderer.getDocumentSizeIn100mm(mCurrentPage);
+}
+
+IMPL_LINK_NOARG( GraphicExportOptionsDialog, widthModifiedHandle )
+{
+ mResolution = mpWidth->GetValue() / getViewWidthInch();
+
+ updateHeight();
+ updateResolution();
+
+ return 0L;
+}
+
+IMPL_LINK_NOARG( GraphicExportOptionsDialog, heightModifiedHandle )
+{
+ mResolution = mpHeight->GetValue() / getViewHeightInch();
+
+ updateWidth();
+ updateResolution();
+
+ return 0L;
+}
+
+IMPL_LINK_NOARG( GraphicExportOptionsDialog, resolutionModifiedHandle )
+{
+ mResolution = mpResolution->GetText().toInt32();
+
+ updateWidth();
+ updateHeight();
+ Update();
+
+ return 0L;
+}
+
+double GraphicExportOptionsDialog::getViewWidthInch()
+{
+ return (double) MetricField::ConvertValue(mSize100mm.Width(), 2, MAP_100TH_MM, FUNIT_INCH) / 100.0;
+}
+
+double GraphicExportOptionsDialog::getViewHeightInch()
+{
+ return (double) MetricField::ConvertValue(mSize100mm.Height(), 2, MAP_100TH_MM, FUNIT_INCH) / 100.0;
+}
+
+void GraphicExportOptionsDialog::updateWidth()
+{
+ sal_Int32 aWidth = (sal_Int32)( getViewWidthInch() * mResolution );
+ mpWidth->SetText( OUString::number( aWidth ));
+}
+
+void GraphicExportOptionsDialog::updateHeight()
+{
+ sal_Int32 aHeight = (sal_Int32)( getViewHeightInch() * mResolution );
+ mpHeight->SetText( OUString::number( aHeight ));
+}
+
+void GraphicExportOptionsDialog::updateResolution()
+{
+ mpResolution->SetText( OUString::valueOf( (sal_Int32) mResolution ) );
+}
+
+Sequence<PropertyValue> GraphicExportOptionsDialog::getFilterData()
+{
+ sal_Int32 aWidth = (sal_Int32)( getViewWidthInch() * mResolution );
+ sal_Int32 aHeight = (sal_Int32)( getViewHeightInch() * mResolution );
+
+ Sequence<PropertyValue> aFilterData;
+
+ aFilterData.realloc( 2 );
+ aFilterData[ 0 ].Name = "PixelWidth";
+ aFilterData[ 0 ].Value <<= aWidth;
+ aFilterData[ 1 ].Name = "PixelHeight";
+ aFilterData[ 1 ].Value <<= aHeight;
+
+ return aFilterData;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/uiconfig/ui/GraphicExportOptionsDialog.ui b/svtools/uiconfig/ui/GraphicExportOptionsDialog.ui
new file mode 100644
index 000000000000..f98882b1a327
--- /dev/null
+++ b/svtools/uiconfig/ui/GraphicExportOptionsDialog.ui
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkAdjustment" id="adjustment-height">
+ <property name="upper">20000</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment-width">
+ <property name="upper">20000</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkDialog" id="GraphicExporter">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Width:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Height:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="resolutionft">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Resolution:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="spin-width">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustment-width</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="spin-height">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustment-height</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">px</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">px</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">DPI</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="combo-resolution">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="column_span_column">0</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ <property name="id_column">1</property>
+ <items>
+ <item>50</item>
+ <item>75</item>
+ <item>96</item>
+ <item>150</item>
+ <item>200</item>
+ <item>300</item>
+ <item>600</item>
+ </items>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="comboboxtext-entry4">
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Size</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">ok</action-widget>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>