summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-01-31 17:15:21 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2022-02-05 12:15:28 +0100
commitf609a16a52f1ac37f1edd297cf1d9e5f2a294724 (patch)
treea5a8efb46646538283b5ad9c3a7ee178b5c2e170 /filter
parentc59f37b9735a0ca122f29606508c50d25bbaa985 (diff)
lok: render image preview with lower resolution
renderShapeSelection callback is used to render image previews which are later used during eg. rotation. Do not render preview with original size which slows down app a lot. Use 1280x720 max. Change-Id: Ia8365a67d87cea869ef74cb70ce4830439a523b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129376 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129497 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/svg/svgexport.cxx6
-rw-r--r--filter/source/svg/svgfilter.cxx10
-rw-r--r--filter/source/svg/svgfilter.hxx1
-rw-r--r--filter/source/svg/svgwriter.cxx22
-rw-r--r--filter/source/svg/svgwriter.hxx2
5 files changed, 39 insertions, 2 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index ef0c1ea37a80..c21b041b1bbc 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -796,7 +796,9 @@ bool SVGFilter::implExportWriterTextGraphic( const Reference< view::XSelectionSu
const Graphic aOriginalGraphic(xOriginalGraphic);
uno::Reference<graphic::XGraphic> xTransformedGraphic;
- xPropertySet->getPropertyValue("TransformedGraphic") >>= xTransformedGraphic;
+ xPropertySet->getPropertyValue(
+ mbIsPreview ? OUString("GraphicPreview") : OUString("TransformedGraphic"))
+ >>= xTransformedGraphic;
if (!xTransformedGraphic.is())
return false;
@@ -971,6 +973,8 @@ bool SVGFilter::implExportDocument()
mpSVGWriter->SetEmbeddedBitmapRefs( &maBitmapActionMap );
implExportTiledBackground();
}
+ if( mbIsPreview )
+ mpSVGWriter->SetPreviewMode();
// #i124608# export a given object selection, so no MasterPage export at all
if (!mbExportShapeSelection)
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 4c3f033d02eb..c6677bf0c9dc 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -77,6 +77,7 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mnVisiblePage( -1 ),
mpObjects( nullptr ),
mbExportShapeSelection(false),
+ mbIsPreview(false),
mbWriterFilter(false),
mbCalcFilter(false),
mbImpressFilter(false),
@@ -108,6 +109,15 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
for (const PropertyValue& rProp : rDescriptor)
{
+ if (rProp.Name == "IsPreview")
+ {
+ rProp.Value >>= mbIsPreview;
+ break;
+ }
+ }
+
+ for (const PropertyValue& rProp : rDescriptor)
+ {
if (rProp.Name == "FilterName")
{
OUString sFilterName;
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index eb889e81662e..93e14ec41671 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -209,6 +209,7 @@ private:
Sequence< PropertyValue > maFilterData;
Reference< css::drawing::XDrawPage > mxDefaultPage;
std::vector< Reference< css::drawing::XDrawPage > > mSelectedPages;
+ bool mbIsPreview;
bool mbWriterFilter;
bool mbCalcFilter;
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 3d8183ebb2fd..f849315ce823 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2942,7 +2942,27 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx,
}
}
- if( !(bCached || GraphicConverter::Export( aOStm, rBmpEx, ConvertDataFormat::PNG ) == ERRCODE_NONE) )
+ const BitmapEx* pBitmap = &rBmpEx;
+ std::unique_ptr<BitmapEx> pNewBitmap;
+
+ // for preview we generate downscaled images (1280x720 max)
+ if (mbIsPreview)
+ {
+ Size aSize = rBmpEx.GetSizePixel();
+ double fX = static_cast<double>(aSize.getWidth()) / 1280;
+ double fY = static_cast<double>(aSize.getHeight()) / 720;
+ double fFactor = fX > fY ? fX : fY;
+ if (fFactor > 1.0)
+ {
+ aSize.setWidth(aSize.getWidth() / fFactor);
+ aSize.setHeight(aSize.getHeight() / fFactor);
+ pNewBitmap = std::make_unique<BitmapEx>(rBmpEx);
+ pNewBitmap->Scale(aSize);
+ pBitmap = pNewBitmap.get();
+ }
+ }
+
+ if( !(bCached || GraphicConverter::Export( aOStm, *pBitmap, ConvertDataFormat::PNG ) == ERRCODE_NONE) )
return;
Point aPt;
diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx
index fdfcd24d32b2..d48d68bdec72 100644
--- a/filter/source/svg/svgwriter.hxx
+++ b/filter/source/svg/svgwriter.hxx
@@ -318,6 +318,7 @@ private:
bool mbClipAttrChanged;
bool mbIsPlaceholderShape;
const MetaBitmapActionMap* mpEmbeddedBitmapsMap;
+ bool mbIsPreview;
tools::Long ImplMap( sal_Int32 nVal ) const;
@@ -377,6 +378,7 @@ public:
void SetEmbeddedBitmapRefs( const MetaBitmapActionMap* pEmbeddedBitmapsMap );
void StartMask(const Point& rDestPt, const Size& rDestSize, const Gradient& rGradient,
sal_uInt32 nWriteFlags, OUString* pTextStyle = nullptr);
+ void SetPreviewMode(bool bState = true) { mbIsPreview = bState; }
};