summaryrefslogtreecommitdiff
path: root/filter/source/svg/svgwriter.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-27 09:34:30 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-27 10:33:24 +0100
commit8fc1b60f62c213a0476f3acc9f89cd5eccbf335d (patch)
tree6953e5f83c91eb837dbfdd2a557facac257340a6 /filter/source/svg/svgwriter.cxx
parent8f90d3bf33fde7759046a13282381bbd710357f1 (diff)
sw SVG export: try to reuse original bitmap data for JPG and PNG bitmaps
Writer shapes are implemented using SwXShape, Impress shapes use SdrGrafObj. So switch to working with the XShape interface, which is supported by both. Also, don't work with the transformed graphic if it has the same checksum as the original graphic: the transformed graphic is not linked to the original JPG/PNG data. Now selecting an image in Writer Online has the same speedup that Impress Online already had. Change-Id: Iab2791c5f5c7a2754e3de0ebb2d6ea664f6c77e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89540 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'filter/source/svg/svgwriter.cxx')
-rw-r--r--filter/source/svg/svgwriter.cxx52
1 files changed, 25 insertions, 27 deletions
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 9ccd18eaafee..8d491d122d0b 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2688,20 +2688,22 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText,
namespace
{
-SdrGrafObj* GetSdrGrafObjFromXShape(const css::uno::Reference<css::drawing::XShape>* pShape)
+void GetGraphicFromXShape(const css::uno::Reference<css::drawing::XShape>* pShape, Graphic& rGraphic)
{
if (!pShape)
{
- return nullptr;
+ return;
}
- auto pObject = dynamic_cast<SvxGraphicObject*>(pShape->get());
- if (!pObject)
+ uno::Reference<beans::XPropertySet> xPropertySet(*pShape, uno::UNO_QUERY);
+ if (!xPropertySet.is())
{
- return nullptr;
+ return;
}
- return dynamic_cast<SdrGrafObj*>(pObject->GetSdrObject());
+ uno::Reference<graphic::XGraphic> xGraphic;
+ xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
+ rGraphic= Graphic(xGraphic);
}
}
@@ -2724,34 +2726,30 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx,
SvMemoryStream aOStm( 65535, 65535 );
bool bCached = false;
- SdrGrafObj* pGrafObj = nullptr;
+ Graphic aGraphic;
bool bPNG = false;
bool bJPG = false;
if (pShape)
{
- pGrafObj = GetSdrGrafObjFromXShape(pShape);
- if (pGrafObj)
+ GetGraphicFromXShape(pShape, aGraphic);
+ if (aGraphic.GetType() == GraphicType::Bitmap)
{
- const Graphic& rGraphic = pGrafObj->GetGraphic();
- if (rGraphic.GetType() == GraphicType::Bitmap)
+ const BitmapEx& rGraphicBitmap = aGraphic.GetBitmapExRef();
+ if (rGraphicBitmap.GetChecksum() == rBmpEx.GetChecksum())
{
- const BitmapEx& rGraphicBitmap = rGraphic.GetBitmapExRef();
- if (rGraphicBitmap.GetChecksum() == rBmpEx.GetChecksum())
+ GfxLink aGfxLink = aGraphic.GetGfxLink();
+ if (aGfxLink.GetType() == GfxLinkType::NativePng)
{
- GfxLink aGfxLink = rGraphic.GetGfxLink();
- if (aGfxLink.GetType() == GfxLinkType::NativePng)
- {
- bPNG = true;
- }
- else if (aGfxLink.GetType() == GfxLinkType::NativeJpg)
- {
- bJPG = true;
- }
- if (bPNG || bJPG)
- {
- aOStm.WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
- bCached = true;
- }
+ bPNG = true;
+ }
+ else if (aGfxLink.GetType() == GfxLinkType::NativeJpg)
+ {
+ bJPG = true;
+ }
+ if (bPNG || bJPG)
+ {
+ aOStm.WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
+ bCached = true;
}
}
}