summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/source/svg/svgwriter.cxx45
-rw-r--r--include/svx/svdograf.hxx9
-rw-r--r--svx/source/svdraw/svdograf.cxx22
3 files changed, 34 insertions, 42 deletions
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index dfb203360b4e..cc3aa84d61e4 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2714,29 +2714,52 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx,
bool bCached = false;
SdrGrafObj* pGrafObj = nullptr;
+ bool bPNG = false;
+ bool bJPG = false;
if (pShape)
{
pGrafObj = GetSdrGrafObjFromXShape(pShape);
- if (pGrafObj && pGrafObj->GetPNGPreviewChecksum() == rBmpEx.GetChecksum())
+ if (pGrafObj)
{
- const std::vector<sal_Int8>& rPreviewData = pGrafObj->GetPNGPreviewData();
- aOStm.WriteBytes(rPreviewData.data(), rPreviewData.size());
- bCached = true;
+ const Graphic& rGraphic = pGrafObj->GetGraphic();
+ if (rGraphic.GetType() == GraphicType::Bitmap)
+ {
+ const BitmapEx& rGraphicBitmap = rGraphic.GetBitmapExRef();
+ if (rGraphicBitmap.GetChecksum() == rBmpEx.GetChecksum())
+ {
+ 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;
+ }
+ }
+ }
}
}
if( bCached || GraphicConverter::Export( aOStm, rBmpEx, ConvertDataFormat::PNG ) == ERRCODE_NONE )
{
- if (!bCached && pGrafObj)
- {
- pGrafObj->SetPNGPreviewChecksum(rBmpEx.GetChecksum());
- pGrafObj->SetPNGPreviewData(aOStm);
- }
-
Point aPt;
Size aSz;
Sequence< sal_Int8 > aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell() );
- OUStringBuffer aBuffer( "data:image/png;base64," );
+ OUStringBuffer aBuffer;
+ if (bJPG)
+ {
+ aBuffer.append("data:image/jpeg;base64,");
+ }
+ else
+ {
+ aBuffer.append("data:image/png;base64,");
+ }
::comphelper::Base64::encode( aBuffer, aSeq );
ImplMap( rPt, aPt );
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 29e3a4364f9e..478eabb18dcf 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -29,7 +29,6 @@
#include <vcl/GraphicObject.hxx>
#include <svx/svxdllapi.h>
#include <o3tl/typed_flags_set.hxx>
-#include <tools/stream.hxx>
#include <memory>
#include <cstddef>
@@ -125,9 +124,6 @@ private:
void onGraphicChanged();
GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const;
- BitmapChecksum mnPNGPreviewChecksum = 0;
- std::vector<sal_Int8> maPNGPreviewData;
-
protected:
// protected destructor
virtual ~SdrGrafObj() override;
@@ -303,11 +299,6 @@ public:
{
return mpQrCode.get();
};
-
- void SetPNGPreviewChecksum(BitmapChecksum nPNGPreviewChecksum);
- BitmapChecksum GetPNGPreviewChecksum() const;
- void SetPNGPreviewData(SvMemoryStream& rPNGPreviewData);
- const std::vector<sal_Int8>& GetPNGPreviewData() const;
};
#endif // INCLUDED_SVX_SVDOGRAF_HXX
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index c1e6fa8b6bb6..7e14a6d3bdd9 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1278,26 +1278,4 @@ void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
}
-void SdrGrafObj::SetPNGPreviewChecksum(BitmapChecksum nPNGPreviewChecksum)
-{
- mnPNGPreviewChecksum = nPNGPreviewChecksum;
-}
-
-BitmapChecksum SdrGrafObj::GetPNGPreviewChecksum() const
-{
- return mnPNGPreviewChecksum;
-}
-
-void SdrGrafObj::SetPNGPreviewData(SvMemoryStream& rPNGPreviewData)
-{
- rPNGPreviewData.Seek(0);
- maPNGPreviewData.resize(rPNGPreviewData.remainingSize());
- rPNGPreviewData.ReadBytes(maPNGPreviewData.data(), maPNGPreviewData.size());
-}
-
-const std::vector<sal_Int8>& SdrGrafObj::GetPNGPreviewData() const
-{
- return maPNGPreviewData;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */