diff options
author | Eike Rathke <erack@redhat.com> | 2017-09-18 16:47:59 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-09-18 18:10:41 +0200 |
commit | b149201a076ed2d39fb95dd1c3d1367c9ef6924d (patch) | |
tree | 7a6ccc7f71973efc22a570995b8df315eef558d4 /filter/source/graphic | |
parent | 7654183a53cd221e54a10a1bf5497df0c788860d (diff) |
Export to PNG: use proper dialog and filter options, tdf#108317
... and not the crude JPG ones.
The com.sun.star.svtools.SvFilterOptionsDialog service has all we need,
so teach it to cope with non-Graphics source documents and let
ExportDialog handle that as well, just the actual rendering needs to go
via GraphicExportFilter (and effectively DocumentToGraphicRenderer), so
don't let that overwrite the properties set by the filter dialog.
Switching to the dialog then is just a matter of changing the
UIComponent in filter/source/config/fragments/filters/calc_png_Export
The same mechanism probably could be used by Writer as well by adjusting
filter/source/config/fragments/filters/writer_png_Export.xcu and maybe
filter/source/config/fragments/filters/writer_jpg_Export.xcu
in which case the GraphicExportOptionsDialog likely would be moot
then.
Also, it looks like a
filter/source/config/fragments/filters/calc_jpg_Export.xcu
(which doesn't exist yet) could be possible using the same mechanism.
Change-Id: I1fb9b33a6490dc39d7591b2b5913be182bb820e5
Reviewed-on: https://gerrit.libreoffice.org/42421
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'filter/source/graphic')
-rw-r--r-- | filter/source/graphic/GraphicExportFilter.cxx | 63 | ||||
-rw-r--r-- | filter/source/graphic/GraphicExportFilter.hxx | 5 |
2 files changed, 61 insertions, 7 deletions
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; |