summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/source/config/fragments/filters/calc_png_Export.xcu2
-rw-r--r--filter/source/graphic/GraphicExportFilter.cxx63
-rw-r--r--filter/source/graphic/GraphicExportFilter.hxx5
-rw-r--r--svtools/source/filter/SvFilterOptionsDialog.cxx22
-rw-r--r--svtools/source/filter/exportdialog.cxx45
-rw-r--r--svtools/source/filter/exportdialog.hxx3
6 files changed, 119 insertions, 21 deletions
diff --git a/filter/source/config/fragments/filters/calc_png_Export.xcu b/filter/source/config/fragments/filters/calc_png_Export.xcu
index c78a3a63bf5a..a67677abed5e 100644
--- a/filter/source/config/fragments/filters/calc_png_Export.xcu
+++ b/filter/source/config/fragments/filters/calc_png_Export.xcu
@@ -7,7 +7,7 @@
-->
<node oor:name="calc_png_Export" oor:op="replace">
<prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER SUPPORTSSELECTION</value></prop>
- <prop oor:name="UIComponent"><value>com.sun.star.comp.GraphicExportDialog</value></prop>
+ <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</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">
diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx
index e4279513416e..bfc9e231ec72 100644
--- a/filter/source/graphic/GraphicExportFilter.cxx
+++ b/filter/source/graphic/GraphicExportFilter.cxx
@@ -73,6 +73,22 @@ void GraphicExportFilter::gatherProperties( const Sequence<PropertyValue>& rProp
{
mFilterDataSequence[i].Value >>= mTargetHeight;
}
+ else if ( mFilterDataSequence[i].Name == "Compression" )
+ {
+ maCompression = mFilterDataSequence[i].Value;
+ }
+ else if ( mFilterDataSequence[i].Name == "Interlaced" )
+ {
+ maInterlaced = mFilterDataSequence[i].Value;
+ }
+ else if ( mFilterDataSequence[i].Name == "Translucent" )
+ {
+ maTranslucent = mFilterDataSequence[i].Value;
+ }
+ else if ( mFilterDataSequence[i].Name == "Quality" )
+ {
+ maQuality = mFilterDataSequence[i].Value;
+ }
}
if ( !aInternalFilterName.isEmpty() )
@@ -111,13 +127,46 @@ sal_Bool SAL_CALL GraphicExportFilter::filter( const Sequence<PropertyValue>& rD
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;
+ Sequence< PropertyValue > aFilterData( mFilterDataSequence );
+ sal_Int32 nAdd = 0;
+ if (!maCompression.hasValue())
+ ++nAdd;
+ if (!maInterlaced.hasValue())
+ ++nAdd;
+ if (!maTranslucent.hasValue())
+ ++nAdd;
+ if (!maQuality.hasValue())
+ ++nAdd;
+ if (nAdd)
+ {
+ sal_Int32 nLen = aFilterData.getLength();
+ aFilterData.realloc( nLen + nAdd);
+ if (!maCompression.hasValue())
+ { // PNG,JPG
+ aFilterData[ nLen ].Name = "Compression";
+ aFilterData[ nLen ].Value <<= (sal_Int32) 9;
+ ++nLen;
+ }
+ if (!maInterlaced.hasValue())
+ { // PNG,JPG
+ aFilterData[ nLen ].Name = "Interlaced";
+ aFilterData[ nLen ].Value <<= (sal_Int32) 0;
+ ++nLen;
+ }
+ if (!maTranslucent.hasValue())
+ { // PNG
+ aFilterData[ nLen ].Name = "Translucent";
+ aFilterData[ nLen ].Value <<= (sal_Int32) 0;
+ ++nLen;
+ }
+ if (!maQuality.hasValue())
+ { // JPG
+ aFilterData[ nLen ].Name = "Quality";
+ aFilterData[ nLen ].Value <<= (sal_Int32) 99;
+ ++nLen;
+ }
+ assert( nLen == aFilterData.getLength());
+ }
sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( mFilterExtension );
diff --git a/filter/source/graphic/GraphicExportFilter.hxx b/filter/source/graphic/GraphicExportFilter.hxx
index 1514bdefa774..6249b4e81582 100644
--- a/filter/source/graphic/GraphicExportFilter.hxx
+++ b/filter/source/graphic/GraphicExportFilter.hxx
@@ -50,6 +50,11 @@ class GraphicExportFilter :
sal_Int32 mTargetHeight;
bool mbSelectionOnly;
+ css::uno::Any maCompression;
+ css::uno::Any maInterlaced;
+ css::uno::Any maTranslucent;
+ css::uno::Any maQuality;
+
public:
explicit GraphicExportFilter( const Reference<XComponentContext>& rxContext );
virtual ~GraphicExportFilter() override;
diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx
index 134a09ee1fdc..e5bd7ab7e392 100644
--- a/svtools/source/filter/SvFilterOptionsDialog.cxx
+++ b/svtools/source/filter/SvFilterOptionsDialog.cxx
@@ -72,7 +72,8 @@ class SvFilterOptionsDialog : public cppu::WeakImplHelper
OUString maDialogTitle;
FieldUnit meFieldUnit;
- bool mbExportSelection;
+ bool mbExportSelection;
+ bool mbGraphicsSource;
public:
@@ -106,7 +107,8 @@ public:
SvFilterOptionsDialog::SvFilterOptionsDialog( const uno::Reference< uno::XComponentContext >& rxContext ) :
mxContext ( rxContext ),
meFieldUnit ( FUNIT_CM ),
- mbExportSelection ( false )
+ mbExportSelection ( false ),
+ mbGraphicsSource ( true )
{
}
@@ -198,8 +200,9 @@ sal_Int16 SvFilterOptionsDialog::execute()
OUString aStr;
maMediaDescriptor[ j ].Value >>= aStr;
aInternalFilterName = aStr;
- aInternalFilterName = aInternalFilterName.replaceAll( "draw_", "" );
- aInternalFilterName = aInternalFilterName.replaceAll( "impress_", "" );
+ aInternalFilterName = aInternalFilterName.replaceFirst( "draw_", "" );
+ aInternalFilterName = aInternalFilterName.replaceFirst( "impress_", "" );
+ aInternalFilterName = aInternalFilterName.replaceFirst( "calc_", "" );
break;
}
else if ( rName == "Graphic" )
@@ -223,7 +226,8 @@ sal_Int16 SvFilterOptionsDialog::execute()
aFltCallDlgPara.aFilterData = maFilterDataSequence;
aFltCallDlgPara.aFilterExt = aGraphicFilter.GetExportFormatShortName( nFormat );
bool bIsPixelFormat( aGraphicFilter.IsExportPixelFormat( nFormat ) );
- if ( ScopedVclPtrInstance<ExportDialog>( aFltCallDlgPara, mxContext, mxSourceDocument, mbExportSelection, bIsPixelFormat, xGraphic )->Execute() == RET_OK )
+ if ( ScopedVclPtrInstance<ExportDialog>( aFltCallDlgPara, mxContext, mxSourceDocument, mbExportSelection,
+ bIsPixelFormat, mbGraphicsSource, xGraphic )->Execute() == RET_OK )
nRet = ui::dialogs::ExecutableDialogResults::OK;
// taking the out parameter from the dialog
@@ -238,6 +242,8 @@ void SvFilterOptionsDialog::setSourceDocument( const uno::Reference< lang::XComp
{
mxSourceDocument = xDoc;
+ mbGraphicsSource = true; // default Draw and Impress like it was before
+
// try to set the corresponding metric unit
OUString aConfigPath;
uno::Reference< lang::XServiceInfo > xServiceInfo
@@ -248,6 +254,12 @@ void SvFilterOptionsDialog::setSourceDocument( const uno::Reference< lang::XComp
aConfigPath = "Office.Impress/Layout/Other/MeasureUnit";
else if ( xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") )
aConfigPath = "Office.Draw/Layout/Other/MeasureUnit";
+ else
+ {
+ mbGraphicsSource = false;
+ if ( xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument") )
+ aConfigPath = "Office.Calc/Layout/Other/MeasureUnit";
+ }
if ( !aConfigPath.isEmpty() )
{
FilterConfigItem aConfigItem( aConfigPath );
diff --git a/svtools/source/filter/exportdialog.cxx b/svtools/source/filter/exportdialog.cxx
index cd2e84e2cd95..db1c77e2b38e 100644
--- a/svtools/source/filter/exportdialog.cxx
+++ b/svtools/source/filter/exportdialog.cxx
@@ -24,6 +24,7 @@
#include <vcl/FilterConfigItem.hxx>
#include <svtools/strings.hrc>
#include <svtools/svtresid.hxx>
+#include <svtools/DocumentToGraphicRenderer.hxx>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
@@ -316,7 +317,7 @@ awt::Size ExportDialog::GetOriginalSize()
aShapesRange = basegfx::B2DRange( 0, 0, nWidth, nHeight );
}
}
- else
+ else if (mxShapes.is() || mxShape.is())
{
uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory = graphic::PrimitiveFactory2D::create( mxContext );
@@ -347,6 +348,13 @@ awt::Size ExportDialog::GetOriginalSize()
}
}
}
+ else if (!mbGraphicsSource)
+ {
+ DocumentToGraphicRenderer aRenderer( mxSourceDocument, mbExportSelection);
+ const sal_Int32 nCurrentPage = aRenderer.getCurrentPageWriter();
+ const Size aSize = aRenderer.getDocumentSizeIn100mm( nCurrentPage);
+ return awt::Size( aSize.Width(), aSize.Height());
+ }
return awt::Size( static_cast<sal_Int32>(aShapesRange.getWidth()), static_cast<sal_Int32>(aShapesRange.getHeight()) );
}
@@ -369,11 +377,13 @@ void ExportDialog::GetGraphicSource()
if ( xSelectionSupplier.is() )
{
uno::Any aAny( xSelectionSupplier->getSelection() );
- if ( ! ( aAny >>= mxShapes ) )
- aAny >>= mxShape;
+ if ( aAny >>= mxShapes )
+ mbGraphicsSource = true;
+ else if ( aAny >>= mxShape )
+ mbGraphicsSource = true;
}
}
- if ( !mxShape.is() && !mxShapes.is() )
+ if ( !mxShape.is() && !mxShapes.is() && mbGraphicsSource )
{
uno::Reference< drawing::XDrawView > xDrawView( xController, uno::UNO_QUERY );
if ( xDrawView.is() )
@@ -385,6 +395,9 @@ void ExportDialog::GetGraphicSource()
}
}
}
+ // For !mbGraphicsSource the mxSourceDocument is used, from
+ // which XRenderable can query XController and
+ // XSelectionSupplier the same.
}
}
}
@@ -417,9 +430,26 @@ void ExportDialog::GetGraphicStream()
mpTempStream = new SvMemoryStream();
maBitmap = Bitmap();
- if ( mxGraphic.is() )
+ uno::Reference< graphic::XGraphic > xGraphic;
+ if (!mbGraphicsSource && !mxGraphic.is())
+ {
+ // Create a Graphic to be used below.
+ DocumentToGraphicRenderer aRenderer( mxSourceDocument, mbExportSelection);
+ const sal_Int32 nCurrentPage = aRenderer.getCurrentPageWriter();
+ const Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels( nCurrentPage);
+
+ const Size aTargetSizePixel( mbIsPixelFormat ?
+ Size( maSize.Width, maSize.Height) :
+ aDocumentSizePixel );
+
+ Graphic aGraphic( aRenderer.renderToGraphic( nCurrentPage,
+ aDocumentSizePixel, aTargetSizePixel, COL_WHITE));
+ xGraphic = aGraphic.GetXGraphic();
+ }
+
+ if ( mxGraphic.is() || xGraphic.is() )
{
- Graphic aGraphic( mxGraphic );
+ Graphic aGraphic( mxGraphic.is() ? mxGraphic : xGraphic );
if ( aGraphic.GetType() == GraphicType::Bitmap )
{
@@ -554,7 +584,7 @@ bool ExportDialog::IsTempExportAvailable() const
ExportDialog::ExportDialog(FltCallDialogParameter& rPara,
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
const css::uno::Reference< css::lang::XComponent >& rxSourceDocument,
- bool bExportSelection, bool bIsPixelFormat,
+ bool bExportSelection, bool bIsPixelFormat, bool bGraphicsSource,
const css::uno::Reference< css::graphic::XGraphic >& rxGraphic)
: ModalDialog(rPara.pWindow, "GraphicExportDialog", "svt/ui/graphicexport.ui")
, mrFltCallPara(rPara)
@@ -580,6 +610,7 @@ ExportDialog::ExportDialog(FltCallDialogParameter& rPara,
, maOriginalSize(awt::Size(0, 0))
, mbIsPixelFormat(bIsPixelFormat)
, mbExportSelection(bExportSelection)
+ , mbGraphicsSource(bGraphicsSource)
{
get(mpMfSizeX, "widthmf-nospin");
get(mpMfSizeY, "heightmf-nospin");
diff --git a/svtools/source/filter/exportdialog.hxx b/svtools/source/filter/exportdialog.hxx
index 538a30d3e4bc..5c50660cb2e5 100644
--- a/svtools/source/filter/exportdialog.hxx
+++ b/svtools/source/filter/exportdialog.hxx
@@ -126,6 +126,7 @@ private:
bool mbIsPixelFormat;
bool mbExportSelection;
+ bool mbGraphicsSource; // whether source document is graphics (Draw, Impress) or not (Calc, Writer)
sal_Int32 mnInitialResolutionUnit;
@@ -173,7 +174,7 @@ public:
ExportDialog( FltCallDialogParameter& rPara,
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
const css::uno::Reference< css::lang::XComponent >& rxSourceDocument,
- bool bExportSelection, bool bIsExportVectorFormat,
+ bool bExportSelection, bool bIsExportVectorFormat, bool bGraphicsSource,
const css::uno::Reference< css::graphic::XGraphic >& rxGraphic = nullptr);
virtual ~ExportDialog() override;
virtual void dispose() override;