[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - basic/source chart2/source editeng/source include/vcl sc/source sd/source sfx2/source svtools/source svx/source sw/qa sw/source vcl/inc vcl/qa vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 24 01:26:16 UTC 2020
basic/source/runtime/methods.cxx | 4
chart2/source/controller/main/ChartController_Tools.cxx | 6
editeng/source/items/legacyitem.cxx | 12
include/vcl/graph.hxx | 5
sc/source/ui/view/viewfun3.cxx | 5
sc/source/ui/view/viewfun5.cxx | 4
sd/source/ui/view/sdview3.cxx | 4
sfx2/source/appl/linkmgr2.cxx | 4
svtools/source/misc/embedhlp.cxx | 31 +
svx/source/dialog/compressgraphicdialog.cxx | 72 +--
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 5
sw/qa/extras/uiwriter/uiwriter.cxx | 4
sw/qa/extras/uiwriter/uiwriter3.cxx | 5
sw/source/uibase/dochdl/swdtflvr.cxx | 4
vcl/inc/impgraph.hxx | 5
vcl/inc/pch/precompiled_vcl.hxx | 2
vcl/qa/cppunit/TypeSerializerTest.cxx | 150 --------
vcl/source/filter/graphicfilter.cxx | 9
vcl/source/filter/graphicfilter2.cxx | 2
vcl/source/font/font.cxx | 2
vcl/source/gdi/TypeSerializer.cxx | 2
vcl/source/gdi/gdimtf.cxx | 2
vcl/source/gdi/graph.cxx | 16
vcl/source/gdi/graphictools.cxx | 11
vcl/source/gdi/impgraph.cxx | 289 ----------------
vcl/source/gdi/mapmod.cxx | 2
vcl/source/gdi/metaact.cxx | 2
vcl/source/gdi/svmconverter.cxx | 2
vcl/source/gdi/wall.cxx | 3
vcl/source/graphic/UnoGraphicProvider.cxx | 7
vcl/source/treelist/transfer.cxx | 9
31 files changed, 137 insertions(+), 543 deletions(-)
New commits:
commit 77f279120ecf18b8167c4ea8fa70ce608a974c29
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Dec 24 09:22:35 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Dec 24 09:22:35 2020 +0900
vcl: remove {Read,Write}ImpGraphic and ImplExportNative from Graphic
ReadImpGraphic and WriteImpGraphic have been reimplemented in the
TypeSerializer some time ago, but the code has not yet been moved
to use that class. This commits does that and changes all the code
using those 2 methods and removes them. With this implemented in
the TypeSerializer, it is easier to handle
In addition it also removes ImplExportNative (and the method on
the Graphic interface). This was really used only in one method,
and it could be implemented in the mthod itself.
Change-Id: I0982429d1c1d5ed7ef07627d87ed9a08df43f040
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 84d51c760f1e..d8c0c3f9a583 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -101,6 +101,7 @@ using namespace com::sun::star::uno;
#include <com/sun/star/i18n/XCharacterClassification.hpp>
#include <vcl/unohelp.hxx>
+#include <vcl/TypeSerializer.hxx>
#if HAVE_FEATURE_SCRIPTING
@@ -4332,7 +4333,8 @@ void SbRtl_SavePicture(StarBASIC *, SbxArray & rPar, bool)
{
SvFileStream aOStream( rPar.Get32(2)->GetOUString(), StreamMode::WRITE | StreamMode::TRUNC );
const Graphic& aGraphic = pPicture->GetGraphic();
- WriteGraphic( aOStream, aGraphic );
+ TypeSerializer aSerializer(aOStream);
+ aSerializer.writeGraphic(aGraphic);
}
}
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index ed0776d94c79..705fd6fe0cf6 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -57,6 +57,7 @@
#include <vcl/transfer.hxx>
#include <sot/storage.hxx>
#include <vcl/graph.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <svx/unomodel.hxx>
#include <svx/svdmodel.hxx>
#include <unotools/streamwrap.hxx>
@@ -290,7 +291,10 @@ void ChartController::executeDispatch_Paste()
// graphic exchange format (graphic manager bitmap format?)
tools::SvRef<SotStorageStream> xStm;
if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm ))
- ReadGraphic( *xStm, aGraphic );
+ {
+ TypeSerializer aSerializer(*xStm);
+ aSerializer.readGraphic(aGraphic);
+ }
}
else if( aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE ))
{
diff --git a/editeng/source/items/legacyitem.cxx b/editeng/source/items/legacyitem.cxx
index af41980b2d2c..fd4334aed245 100644
--- a/editeng/source/items/legacyitem.cxx
+++ b/editeng/source/items/legacyitem.cxx
@@ -24,6 +24,7 @@
#include <comphelper/fileformat.h>
#include <vcl/graph.hxx>
#include <vcl/GraphicObject.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <osl/diagnose.h>
#include <tools/urlobj.hxx>
#include <editeng/fontitem.hxx>
@@ -493,7 +494,7 @@ namespace legacy
sal_Int8 nStyle;
rStrm.ReadCharAsBool( bTrans );
- tools::GenericTypeSerializer aSerializer(rStrm);
+ TypeSerializer aSerializer(rStrm);
aSerializer.readColor(aTempColor);
aSerializer.readColor(aTempFillColor);
rStrm.ReadSChar( nStyle );
@@ -555,8 +556,7 @@ namespace legacy
if ( nDoLoad & LOAD_GRAPHIC )
{
Graphic aGraphic;
-
- ReadGraphic( rStrm, aGraphic );
+ aSerializer.readGraphic(aGraphic);
rItem.SetGraphicObject(GraphicObject(aGraphic));
if( SVSTREAM_FILEFORMAT_ERROR == rStrm.GetError() )
@@ -592,7 +592,7 @@ namespace legacy
SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16)
{
rStrm.WriteBool( false );
- tools::GenericTypeSerializer aSerializer(rStrm);
+ TypeSerializer aSerializer(rStrm);
aSerializer.writeColor(rItem.GetColor());
aSerializer.writeColor(rItem.GetColor());
rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
@@ -609,7 +609,9 @@ namespace legacy
rStrm.WriteUInt16( nDoLoad );
if (nullptr != pGraphicObject && rItem.GetGraphicLink().isEmpty())
- WriteGraphic(rStrm, pGraphicObject->GetGraphic());
+ {
+ aSerializer.writeGraphic(pGraphicObject->GetGraphic());
+ }
if ( !rItem.GetGraphicLink().isEmpty() )
{
OSL_FAIL("No BaseURL!");
diff --git a/vcl/inc/TypeSerializer.hxx b/include/vcl/TypeSerializer.hxx
similarity index 100%
rename from vcl/inc/TypeSerializer.hxx
rename to include/vcl/TypeSerializer.hxx
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 983330a89745..86d885a326ac 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -185,11 +185,6 @@ public:
GfxLink GetGfxLink() const;
bool IsGfxLink() const;
- bool ExportNative( SvStream& rOStream ) const;
-
- friend VCL_DLLPUBLIC void WriteGraphic(SvStream& rOStream, const Graphic& rGraphic);
- friend VCL_DLLPUBLIC void ReadGraphic(SvStream& rIStream, Graphic& rGraphic);
-
const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const;
/// Get the page number of the multi-page source this Graphic is rendered from.
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index af9e50ab2373..653b930d464c 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -31,6 +31,7 @@
#include <memory>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <attrib.hxx>
#include <patattr.hxx>
@@ -783,8 +784,8 @@ bool ScViewFunc::PasteOnDrawObjectLinked(
if( pScDrawView && aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm ) )
{
Graphic aGraphic;
-
- ReadGraphic( *xStm, aGraphic );
+ TypeSerializer aSerializer(*xStm);
+ aSerializer.readGraphic(aGraphic);
const OUString aBeginUndo(ScResId(STR_UNDO_DRAGDROP));
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index aad9b69a8719..aaf6c133a7e1 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -40,6 +40,7 @@
#include <svl/stritem.hxx>
#include <vcl/transfer.hxx>
#include <vcl/graph.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <osl/thread.h>
#include <comphelper/automationinvokedzone.hxx>
@@ -501,7 +502,8 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm ) )
{
Graphic aGraphic;
- ReadGraphic( *xStm, aGraphic );
+ TypeSerializer aSerializer(*xStm);
+ aSerializer.readGraphic(aGraphic);
bRet = PasteGraphic( aPos, aGraphic, EMPTY_OUSTRING );
}
}
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index d5c2f494c3e6..db3c6950526a 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -41,6 +41,7 @@
#include <svx/ImageMapInfo.hxx>
#include <unotools/streamwrap.hxx>
#include <vcl/metaact.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <svx/svxids.hrc>
#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/embedhlp.hxx>
@@ -1200,7 +1201,8 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
Point aInsertPos( rPos );
Graphic aGraphic;
- ReadGraphic( *xStm, aGraphic );
+ TypeSerializer aSerializer(*xStm);
+ aSerializer.readGraphic(aGraphic);
if( pOwnData && pOwnData->GetWorkDocument() )
{
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index befb7510f82a..0bdfd7b3788e 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -42,6 +42,7 @@
#include <unotools/charclass.hxx>
#include <unotools/securityoptions.hxx>
#include <vcl/GraphicLoader.hxx>
+#include <vcl/TypeSerializer.hxx>
#include "fileobj.hxx"
#include "impldde.hxx"
@@ -543,7 +544,8 @@ bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
{
case SotClipboardFormatId::SVXB:
{
- ReadGraphic( aMemStm, rGraphic );
+ TypeSerializer aSerializer(aMemStm);
+ aSerializer.readGraphic(rGraphic);
bRet = true;
}
break;
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 27a9703fdc7f..6536747f1b3a 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -22,6 +22,8 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/outdev.hxx>
+#include <vcl/gfxlink.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <bitmaps.hlst>
#include <sal/log.hxx>
@@ -770,15 +772,32 @@ void EmbeddedObjectRef::SetGraphicToContainer( const Graphic& rGraphic,
{
SvMemoryStream aStream;
aStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
- if ( rGraphic.ExportNative( aStream ) )
- {
- aStream.Seek( 0 );
- uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( aStream );
- aContainer.InsertGraphicStream( xStream, aName, aMediaType );
+ auto pGfxLink = rGraphic.GetSharedGfxLink();
+ if (pGfxLink && pGfxLink->IsNative())
+ {
+ if (pGfxLink->ExportNative(aStream))
+ {
+ aStream.Seek(0);
+ uno::Reference <io::XInputStream> xStream = new ::utl::OSeekableInputStreamWrapper(aStream);
+ aContainer.InsertGraphicStream(xStream, aName, aMediaType);
+ }
+ else
+ OSL_FAIL("Export of graphic is failed!");
}
else
- OSL_FAIL( "Export of graphic is failed!" );
+ {
+ TypeSerializer aSerializer(aStream);
+ aSerializer.writeGraphic(rGraphic);
+ if (aStream.GetError() == ERRCODE_NONE)
+ {
+ aStream.Seek(0);
+ uno::Reference <io::XInputStream> xStream = new ::utl::OSeekableInputStreamWrapper(aStream);
+ aContainer.InsertGraphicStream(xStream, aName, aMediaType);
+ }
+ else
+ OSL_FAIL("Export of graphic is failed!");
+ }
}
uno::Reference< io::XInputStream > EmbeddedObjectRef::GetGraphicReplacementStream(
diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx
index 856dd7a08149..1c32e8de0606 100644
--- a/svx/source/dialog/compressgraphicdialog.cxx
+++ b/svx/source/dialog/compressgraphicdialog.cxx
@@ -121,40 +121,41 @@ void CompressGraphicsDialog::Initialize()
void CompressGraphicsDialog::Update()
{
- GfxLinkType aLinkType = m_aGraphic.GetGfxLink().GetType();
- OUString aGraphicTypeString;
- switch(aLinkType)
+ OUString aGraphicTypeString = SvxResId(STR_IMAGE_UNKNOWN);
+
+ auto pGfxLink = m_aGraphic.GetSharedGfxLink();
+ if (pGfxLink)
{
- case GfxLinkType::NativeGif:
- aGraphicTypeString = SvxResId(STR_IMAGE_GIF);
- break;
- case GfxLinkType::NativeJpg:
- aGraphicTypeString = SvxResId(STR_IMAGE_JPEG);
- break;
- case GfxLinkType::NativePng:
- aGraphicTypeString = SvxResId(STR_IMAGE_PNG);
- break;
- case GfxLinkType::NativeTif:
- aGraphicTypeString = SvxResId(STR_IMAGE_TIFF);
- break;
- case GfxLinkType::NativeWmf:
- aGraphicTypeString = SvxResId(STR_IMAGE_WMF);
- break;
- case GfxLinkType::NativeMet:
- aGraphicTypeString = SvxResId(STR_IMAGE_MET);
- break;
- case GfxLinkType::NativePct:
- aGraphicTypeString = SvxResId(STR_IMAGE_PCT);
- break;
- case GfxLinkType::NativeSvg:
- aGraphicTypeString = SvxResId(STR_IMAGE_SVG);
- break;
- case GfxLinkType::NativeBmp:
- aGraphicTypeString = SvxResId(STR_IMAGE_BMP);
- break;
- default:
- aGraphicTypeString = SvxResId(STR_IMAGE_UNKNOWN);
- break;
+ switch (pGfxLink->GetType())
+ {
+ case GfxLinkType::NativeGif:
+ aGraphicTypeString = SvxResId(STR_IMAGE_GIF);
+ break;
+ case GfxLinkType::NativeJpg:
+ aGraphicTypeString = SvxResId(STR_IMAGE_JPEG);
+ break;
+ case GfxLinkType::NativePng:
+ aGraphicTypeString = SvxResId(STR_IMAGE_PNG);
+ break;
+ case GfxLinkType::NativeTif:
+ aGraphicTypeString = SvxResId(STR_IMAGE_TIFF);
+ break;
+ case GfxLinkType::NativeWmf:
+ aGraphicTypeString = SvxResId(STR_IMAGE_WMF);
+ break;
+ case GfxLinkType::NativeMet:
+ aGraphicTypeString = SvxResId(STR_IMAGE_MET);
+ break;
+ case GfxLinkType::NativePct:
+ aGraphicTypeString = SvxResId(STR_IMAGE_PCT);
+ break;
+ case GfxLinkType::NativeSvg:
+ aGraphicTypeString = SvxResId(STR_IMAGE_SVG);
+ break;
+ case GfxLinkType::NativeBmp:
+ aGraphicTypeString = SvxResId(STR_IMAGE_BMP);
+ break;
+ }
}
m_xLabelGraphicType->set_label(aGraphicTypeString);
@@ -189,10 +190,7 @@ void CompressGraphicsDialog::Update()
aViewSizeString = aViewSizeString.replaceAll("$(DPI)", OUString::number(aValX));
m_xFixedText3->set_label(aViewSizeString);
- SvMemoryStream aMemStream;
- aMemStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
- m_aGraphic.ExportNative(aMemStream);
- m_aNativeSize = aMemStream.TellEnd();
+ m_aNativeSize = pGfxLink ? pGfxLink->GetDataSize() : 0;
OUString aNativeSizeString = SvxResId(STR_IMAGE_CAPACITY);
aNativeSizeString = aNativeSizeString.replaceAll("$(CAPACITY)", OUString::number( m_aNativeSize / 1024 ));
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index e39d475d8718..3d185a72afb9 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -64,6 +64,8 @@
#include <comphelper/propertysequence.hxx>
#include <osl/time.h>
#include <comphelper/processfactory.hxx>
+#include <vcl/TypeSerializer.hxx>
+
class Test : public SwModelTestBase
{
@@ -1554,7 +1556,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf100072, "tdf100072.docx")
// Read it back and dump it as an XML file.
Graphic aGraphic;
- ReadGraphic(aStream, aGraphic);
+ TypeSerializer aSerializer(aStream);
+ aSerializer.readGraphic(aGraphic);
const GDIMetaFile& rMetaFile = aGraphic.GetGDIMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, rMetaFile);
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index fec30772d5dd..c651fd8859f3 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -46,6 +46,7 @@
#include <AnnotationWin.hxx>
#include <com/sun/star/text/XDefaultNumberingProvider.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
+#include <vcl/TypeSerializer.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
@@ -2151,7 +2152,8 @@ void SwUiWriterTest::testFdo87448()
// Read it back and dump it as an XML file.
Graphic aGraphic;
- ReadGraphic(aStream, aGraphic);
+ TypeSerializer aSerializer(aStream);
+ aSerializer.readGraphic(aGraphic);
const GDIMetaFile& rMetaFile = aGraphic.GetGDIMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, rMetaFile);
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 3f89bba3d171..3d6f3422db79 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -10,6 +10,7 @@
#include <swmodeltestbase.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <vcl/scheduler.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <IDocumentDrawModelAccess.hxx>
#include <com/sun/star/text/TextContentAnchorType.hpp>
@@ -2084,7 +2085,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133477)
// Read it back and check the color of the first pixel.
Graphic aGraphic;
- ReadGraphic(aStream, aGraphic);
+ TypeSerializer aSerializer(aStream);
+ aSerializer.readGraphic(aGraphic);
+
BitmapEx aBitmap = aGraphic.GetBitmapEx();
CPPUNIT_ASSERT_EQUAL(Color(0, 102, 204), aBitmap.GetPixelColor(0, 0));
}
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 784683be6603..ed5bbfa7ec7c 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -124,6 +124,7 @@
#include <vcl/GraphicNativeTransform.hxx>
#include <vcl/GraphicNativeMetadata.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <comphelper/lok.hxx>
#include <sfx2/classificationhelper.hxx>
#include <sfx2/sfxdlg.hxx>
@@ -2774,7 +2775,8 @@ bool SwTransferable::PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
if(rData.GetSotStorageStream(SotClipboardFormatId::SVXB, xStm))
{
- ReadGraphic( *xStm, aGraphic );
+ TypeSerializer aSerializer(*xStm);
+ aSerializer.readGraphic(aGraphic);
bRet = (GraphicType::NONE != aGraphic.GetType() && GraphicType::Default != aGraphic.GetType());
}
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index f4417a262d1c..1b80f0f452f1 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -197,11 +197,6 @@ private:
BitmapChecksum ImplGetChecksum() const;
- bool ImplExportNative( SvStream& rOStm ) const;
-
- friend void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic);
- friend void ReadImpGraphic(SvStream& rIStm, ImpGraphic& rImpGraphic);
-
const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const;
/// Gets the bitmap replacement for a vector graphic.
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index a816716d3ab6..2410dd92b4b0 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -247,7 +247,6 @@
#if PCH_LEVEL >= 4
#include <PhysicalFontCollection.hxx>
#include <PhysicalFontFace.hxx>
-#include <TypeSerializer.hxx>
#include <bitmapwriteaccess.hxx>
#include <brdwin.hxx>
#include <configsettings.hxx>
@@ -274,6 +273,7 @@
#include <vcl/AccessibleBrowseBoxObjType.hxx>
#include <vcl/BitmapFilter.hxx>
#include <vcl/BitmapTools.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <vcl/QueueInfo.hxx>
#include <vcl/accel.hxx>
#include <vcl/alpha.hxx>
diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx b/vcl/qa/cppunit/TypeSerializerTest.cxx
index fd45662bdf20..265b7f760496 100644
--- a/vcl/qa/cppunit/TypeSerializerTest.cxx
+++ b/vcl/qa/cppunit/TypeSerializerTest.cxx
@@ -25,7 +25,7 @@
#include <tools/vcompat.hxx>
#include <comphelper/fileformat.h>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
#if USE_TLS_NSS
#include <nss.h>
@@ -124,56 +124,6 @@ void TypeSerializerTest::testGraphic_Vector()
aGraphic.makeAvailable();
BitmapChecksum aChecksum = aGraphic.getVectorGraphicData()->GetChecksum();
- // Test WriteGraphic - Native Format 5
- {
- SvMemoryStream aMemoryStream;
- aMemoryStream.SetVersion(SOFFICE_FILEFORMAT_50);
- aMemoryStream.SetCompressMode(SvStreamCompressFlags::NATIVE);
- WriteGraphic(aMemoryStream, aGraphic);
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(290), aMemoryStream.remainingSize());
- std::vector<unsigned char> aHash = calculateHash(aMemoryStream);
- CPPUNIT_ASSERT_EQUAL(std::string("ee55ab6faa73b61b68bc3d5628d95f0d3c528e2a"),
- toHexString(aHash));
-
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- sal_uInt32 nType;
- aMemoryStream.ReadUInt32(nType);
- CPPUNIT_ASSERT_EQUAL(COMPAT_FORMAT('N', 'A', 'T', '5'), nType);
-
- // Read it back
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- Graphic aNewGraphic;
- ReadGraphic(aMemoryStream, aNewGraphic);
- CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
- CPPUNIT_ASSERT_EQUAL(aChecksum, aNewGraphic.getVectorGraphicData()->GetChecksum());
- }
-
- // Test WriteGraphic - Normal
- {
- SvMemoryStream aMemoryStream;
- WriteGraphic(aMemoryStream, aGraphic);
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(233), aMemoryStream.remainingSize());
- std::vector<unsigned char> aHash = calculateHash(aMemoryStream);
- CPPUNIT_ASSERT_EQUAL(std::string("c2bed2099ce617f1cc035701de5186f0d43e3064"),
- toHexString(aHash));
-
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- sal_uInt32 nType;
- aMemoryStream.ReadUInt32(nType);
- CPPUNIT_ASSERT_EQUAL(createMagic('s', 'v', 'g', '0'), nType);
-
- // Read it back
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- Graphic aNewGraphic;
- ReadGraphic(aMemoryStream, aNewGraphic);
- CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
- CPPUNIT_ASSERT_EQUAL(aChecksum, aNewGraphic.getVectorGraphicData()->GetChecksum());
- }
-
// Test TypeSerializer - Native Format 5
{
SvMemoryStream aMemoryStream;
@@ -244,30 +194,6 @@ void TypeSerializerTest::testGraphic_Bitmap_NoGfxLink()
BitmapEx aBitmapEx(aBitmap);
Graphic aGraphic(aBitmapEx);
- // Test WriteGraphic
- {
- SvMemoryStream aMemoryStream;
- WriteGraphic(aMemoryStream, aGraphic);
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(383), aMemoryStream.remainingSize());
- std::vector<unsigned char> aHash = calculateHash(aMemoryStream);
- CPPUNIT_ASSERT_EQUAL(std::string("da831418499146d51bf245fadf60b9111faa76c2"),
- toHexString(aHash));
-
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- sal_uInt16 nType;
- aMemoryStream.ReadUInt16(nType);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0x4D42), nType); // Magic written with WriteDIBBitmapEx
-
- // Read it back
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- Graphic aNewGraphic;
- ReadGraphic(aMemoryStream, aNewGraphic);
- CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
- CPPUNIT_ASSERT_EQUAL(aBitmapEx.GetChecksum(), aNewGraphic.GetBitmapExRef().GetChecksum());
- }
-
// Test TypeSerializer
{
SvMemoryStream aMemoryStream;
@@ -310,56 +236,6 @@ void TypeSerializerTest::testGraphic_Animation()
CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
CPPUNIT_ASSERT_EQUAL(true, aGraphic.IsAnimated());
- // Test WriteGraphic
- {
- SvMemoryStream aMemoryStream;
- WriteGraphic(aMemoryStream, aGraphic);
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(15167), aMemoryStream.remainingSize());
- std::vector<unsigned char> aHash = calculateHash(aMemoryStream);
- CPPUNIT_ASSERT_EQUAL(std::string("69d0f80832a0aebcbda7ad43ecadf85e99fc1057"),
- toHexString(aHash));
-
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- sal_uInt16 nType;
- aMemoryStream.ReadUInt16(nType);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0x4D42), nType);
-
- // Read it back
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- Graphic aNewGraphic;
- ReadGraphic(aMemoryStream, aNewGraphic);
- CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
- CPPUNIT_ASSERT_EQUAL(true, aNewGraphic.IsAnimated());
- }
-
- // Test WriteGraphic - Native Format 5
- {
- SvMemoryStream aMemoryStream;
- aMemoryStream.SetVersion(SOFFICE_FILEFORMAT_50);
- aMemoryStream.SetCompressMode(SvStreamCompressFlags::NATIVE);
- WriteGraphic(aMemoryStream, aGraphic);
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(1582), aMemoryStream.remainingSize());
- std::vector<unsigned char> aHash = calculateHash(aMemoryStream);
- CPPUNIT_ASSERT_EQUAL(std::string("da3b9600340fa80a895f2107357e4ab65a9292eb"),
- toHexString(aHash));
-
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- sal_uInt32 nType;
- aMemoryStream.ReadUInt32(nType);
- CPPUNIT_ASSERT_EQUAL(COMPAT_FORMAT('N', 'A', 'T', '5'), nType);
-
- // Read it back
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- Graphic aNewGraphic;
- ReadGraphic(aMemoryStream, aNewGraphic);
- CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
- CPPUNIT_ASSERT_EQUAL(true, aNewGraphic.IsAnimated());
- }
-
// Test TypeSerializer
{
SvMemoryStream aMemoryStream;
@@ -438,30 +314,6 @@ void TypeSerializerTest::testGraphic_GDIMetaFile()
Graphic aGraphic(aGDIMetaFile);
CPPUNIT_ASSERT_EQUAL(GraphicType::GdiMetafile, aGraphic.GetType());
- // Test WriteGraphic
- {
- SvMemoryStream aMemoryStream;
- WriteGraphic(aMemoryStream, aGraphic);
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- CPPUNIT_ASSERT_EQUAL(sal_uInt64(229), aMemoryStream.remainingSize());
- std::vector<unsigned char> aHash = calculateHash(aMemoryStream);
- CPPUNIT_ASSERT_EQUAL(std::string("144c518e5149d61ab4bc34643df820372405d61d"),
- toHexString(aHash));
-
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- char aIdCharArray[7] = { 0, 0, 0, 0, 0, 0, 0 };
- aMemoryStream.ReadBytes(aIdCharArray, 6);
- OString sID(aIdCharArray);
- CPPUNIT_ASSERT_EQUAL(OString("VCLMTF"), sID);
-
- // Read it back
- aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
- Graphic aNewGraphic;
- ReadGraphic(aMemoryStream, aNewGraphic);
- CPPUNIT_ASSERT_EQUAL(GraphicType::GdiMetafile, aNewGraphic.GetType());
- }
-
// Test TypeSerializer
{
SvMemoryStream aMemoryStream;
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index dd70545d3645..52a0ef35c2fe 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -65,6 +65,7 @@
#include <vector>
#include <memory>
#include <string_view>
+#include <vcl/TypeSerializer.hxx>
#include "FilterConfigCache.hxx"
#include "graphicfilter_internal.hxx"
@@ -1650,7 +1651,9 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
aFilterName.equalsIgnoreAsciiCase( IMP_SVMETAFILE ) )
{
// SV internal filters for import bitmaps and MetaFiles
- ReadGraphic( rIStream, rGraphic );
+ TypeSerializer aSerializer(rIStream);
+ aSerializer.readGraphic(rGraphic);
+
if( rIStream.GetError() )
{
nStatus = ERRCODE_GRFILTER_FORMATERROR;
@@ -1663,7 +1666,9 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
}
else if( aFilterName.equalsIgnoreAsciiCase( IMP_MOV ) )
{
- ReadGraphic( rIStream, rGraphic );
+ TypeSerializer aSerializer(rIStream);
+ aSerializer.readGraphic(rGraphic);
+
if( rIStream.GetError() )
nStatus = ERRCODE_GRFILTER_FORMATERROR;
else
diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx
index 3d71a6b3b96a..a40e54002cff 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -21,7 +21,7 @@
#include <tools/stream.hxx>
#include <tools/fract.hxx>
#include <tools/urlobj.hxx>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <vcl/outdev.hxx>
#include <vcl/graphicfilter.hxx>
#include <unotools/ucbstreamhelper.hxx>
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index e3fced8fc158..fdd9ef68413e 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -33,7 +33,7 @@
#include <string_view>
#include <rtl/instance.hxx>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
using namespace vcl;
diff --git a/vcl/source/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx
index f02edcb38b25..ad5e95683ff8 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <tools/vcompat.hxx>
#include <sal/log.hxx>
#include <comphelper/fileformat.h>
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 02f47b5c6bba..005db22ab37c 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -39,7 +39,7 @@
#include <vcl/mtfxmldump.hxx>
#include <svmconverter.hxx>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <com/sun/star/beans/XFastPropertySet.hpp>
#include <com/sun/star/rendering/MtfRenderer.hpp>
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 61f0dc3de354..bd59be143d5a 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -515,22 +515,6 @@ BitmapChecksum Graphic::GetChecksum() const
return mxImpGraphic->ImplGetChecksum();
}
-bool Graphic::ExportNative( SvStream& rOStream ) const
-{
- return mxImpGraphic->ImplExportNative( rOStream );
-}
-
-void ReadGraphic(SvStream& rIStream, Graphic& rGraphic)
-{
- rGraphic.ImplTestRefCount();
- ReadImpGraphic(rIStream, *rGraphic.mxImpGraphic);
-}
-
-void WriteGraphic( SvStream& rOStream, const Graphic& rGraphic )
-{
- WriteImpGraphic(rOStream, *rGraphic.mxImpGraphic);
-}
-
const std::shared_ptr<VectorGraphicData>& Graphic::getVectorGraphicData() const
{
return mxImpGraphic->getVectorGraphicData();
diff --git a/vcl/source/gdi/graphictools.cxx b/vcl/source/gdi/graphictools.cxx
index 4be1b43fadb7..7ec3d7d36588 100644
--- a/vcl/source/gdi/graphictools.cxx
+++ b/vcl/source/gdi/graphictools.cxx
@@ -19,8 +19,7 @@
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
-#include <tools/GenericTypeSerializer.hxx>
-
+#include <vcl/TypeSerializer.hxx>
#include <vcl/graphictools.hxx>
SvtGraphicFill::Transform::Transform()
@@ -237,7 +236,7 @@ SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rClass.maPath.Write( rOStm );
- tools::GenericTypeSerializer aSerializer(rOStm);
+ TypeSerializer aSerializer(rOStm);
aSerializer.writeColor(rClass.maFillColor);
rOStm.WriteDouble( rClass.mfTransparency );
sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
@@ -257,7 +256,7 @@ SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
aSerializer.writeColor(rClass.maGradient1stColor);
aSerializer.writeColor(rClass.maGradient2ndColor);
rOStm.WriteInt32( rClass.maGradientStepCount );
- WriteGraphic( rOStm, rClass.maFillGraphic );
+ aSerializer.writeGraphic(rClass.maFillGraphic);
return rOStm;
}
@@ -268,7 +267,7 @@ SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
rClass.maPath.Read( rIStm );
- tools::GenericTypeSerializer aSerializer(rIStm);
+ TypeSerializer aSerializer(rIStm);
aSerializer.readColor(rClass.maFillColor);
rIStm.ReadDouble( rClass.mfTransparency );
sal_uInt16 nTmp;
@@ -288,7 +287,7 @@ SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
aSerializer.readColor(rClass.maGradient1stColor);
aSerializer.readColor(rClass.maGradient2ndColor);
rIStm.ReadInt32( rClass.maGradientStepCount );
- ReadGraphic( rIStm, rClass.maFillGraphic );
+ aSerializer.readGraphic(rClass.maFillGraphic);
return rIStm;
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 6a072c18e129..030cf9e024ef 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -44,14 +44,13 @@
#include <map>
#include <memory>
#include <vcl/gdimetafiletools.hxx>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <vcl/pdfread.hxx>
#define GRAPHIC_MTFTOBMP_MAXEXT 2048
#define GRAPHIC_STREAMBUFSIZE 8192UL
#define SWAP_FORMAT_ID COMPAT_FORMAT( 'S', 'W', 'A', 'P' )
-#define NATIVE_FORMAT_50 COMPAT_FORMAT( 'N', 'A', 'T', '5' )
using namespace com::sun::star;
@@ -1667,31 +1666,6 @@ BitmapChecksum ImpGraphic::ImplGetChecksum() const
return mnChecksum;
}
-bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
-{
- ensureAvailable();
-
- if( rOStm.GetError() )
- return false;
-
- bool bResult = false;
-
- if( !isSwappedOut() )
- {
- if( mpGfxLink && mpGfxLink->IsNative() )
- bResult = mpGfxLink->ExportNative( rOStm );
- else
- {
- WriteImpGraphic( rOStm, *this );
- bResult = ( rOStm.GetError() == ERRCODE_NONE );
- }
- }
- else
- rOStm.SetError( SVSTREAM_GENERALERROR );
-
- return bResult;
-}
-
sal_Int32 ImpGraphic::getPageNumber() const
{
if (isSwappedOut())
@@ -1702,265 +1676,4 @@ sal_Int32 ImpGraphic::getPageNumber() const
return -1;
}
-void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
-{
- if (rIStm.GetError())
- return;
-
- const sal_uLong nStmPos1 = rIStm.Tell();
- sal_uInt32 nTmp;
-
- rImpGraphic.ImplClear();
-
- // read Id
- rIStm.ReadUInt32( nTmp );
-
- // if there is no more data, avoid further expensive
- // reading which will create VDevs and other stuff, just to
- // read nothing. CAUTION: Eof is only true AFTER reading another
- // byte, a speciality of SvMemoryStream (!)
- if (!rIStm.good())
- return;
-
- if (NATIVE_FORMAT_50 == nTmp)
- {
- Graphic aGraphic;
- GfxLink aLink;
-
- // read compat info, destructor writes stuff into the header
- {
- VersionCompat aCompat( rIStm, StreamMode::READ );
- }
-
- TypeSerializer aSerializer(rIStm);
- aSerializer.readGfxLink(aLink);
-
- // set dummy link to avoid creation of additional link after filtering;
- // we set a default link to avoid unnecessary swapping of native data
- aGraphic.SetGfxLink(std::make_shared<GfxLink>());
-
- if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
- {
- // set link only, if no other link was set
- const bool bSetLink = !rImpGraphic.mpGfxLink;
-
- // assign graphic
- rImpGraphic = *aGraphic.ImplGetImpGraphic();
-
- if( aLink.IsPrefMapModeValid() )
- rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
-
- if( aLink.IsPrefSizeValid() )
- rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
-
- if( bSetLink )
- rImpGraphic.ImplSetLink(std::make_shared<GfxLink>(aLink));
- }
- else
- {
- rIStm.Seek( nStmPos1 );
- rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
- }
- return;
- }
-
- BitmapEx aBmpEx;
- const SvStreamEndian nOldFormat = rIStm.GetEndian();
-
- rIStm.SeekRel( -4 );
- rIStm.SetEndian( SvStreamEndian::LITTLE );
- ReadDIBBitmapEx(aBmpEx, rIStm);
-
- if( !rIStm.GetError() )
- {
- sal_uInt32 nMagic1(0), nMagic2(0);
- sal_uLong nActPos = rIStm.Tell();
-
- rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
- rIStm.Seek( nActPos );
-
- rImpGraphic = ImpGraphic( aBmpEx );
-
- if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
- {
- rImpGraphic.mpAnimation = std::make_unique<Animation>();
- ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
-
- // #108077# manually set loaded BmpEx to Animation
- // (which skips loading its BmpEx if already done)
- rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
- }
- else
- rIStm.ResetError();
- }
- else
- {
- GDIMetaFile aMtf;
-
- rIStm.Seek( nStmPos1 );
- rIStm.ResetError();
- ReadGDIMetaFile( rIStm, aMtf );
-
- if( !rIStm.GetError() )
- {
- rImpGraphic = aMtf;
- }
- else
- {
- ErrCode nOrigError = rIStm.GetErrorCode();
- // try to stream in Svg defining data (length, byte array and evtl. path)
- // See below (operator<<) for more information
- sal_uInt32 nMagic;
- rIStm.Seek(nStmPos1);
- rIStm.ResetError();
- rIStm.ReadUInt32( nMagic );
-
- if (constSvgMagic == nMagic || constWmfMagic == nMagic || constEmfMagic == nMagic || constPdfMagic == nMagic)
- {
- sal_uInt32 nVectorGraphicDataArrayLength(0);
- rIStm.ReadUInt32(nVectorGraphicDataArrayLength);
-
- if (nVectorGraphicDataArrayLength)
- {
- VectorGraphicDataArray aNewData(nVectorGraphicDataArrayLength);
-
- rIStm.ReadBytes(aNewData.getArray(), nVectorGraphicDataArrayLength);
- OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
-
- if (!rIStm.GetError())
- {
- VectorGraphicDataType aDataType(VectorGraphicDataType::Svg);
-
- if (constWmfMagic == nMagic)
- {
- aDataType = VectorGraphicDataType::Wmf;
- }
- else if (constEmfMagic == nMagic)
- {
- aDataType = VectorGraphicDataType::Emf;
- }
- else if (constPdfMagic == nMagic)
- {
- aDataType = VectorGraphicDataType::Pdf;
- }
-
- auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aNewData, aPath, aDataType);
- rImpGraphic = aVectorGraphicDataPtr;
- }
- }
- }
- else
- {
- rIStm.SetError(nOrigError);
- }
-
- rIStm.Seek(nStmPos1);
- }
- }
-
- rIStm.SetEndian( nOldFormat );
-}
-
-void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
-{
- if (rOStm.GetError())
- return;
-
- rImpGraphic.ensureAvailable();
-
- if (rImpGraphic.isSwappedOut())
- {
- rOStm.SetError( SVSTREAM_GENERALERROR );
- return;
- }
-
- if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
- ( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
- rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative())
- {
- // native format
- rOStm.WriteUInt32( NATIVE_FORMAT_50 );
-
- // write compat info, destructor writes stuff into the header
- {
- VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
- }
- rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() );
- rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() );
- TypeSerializer aSerializer(rOStm);
- aSerializer.writeGfxLink(*rImpGraphic.mpGfxLink);
- }
- else
- {
- // own format
- const SvStreamEndian nOldFormat = rOStm.GetEndian();
- rOStm.SetEndian( SvStreamEndian::LITTLE );
-
- switch( rImpGraphic.ImplGetType() )
- {
- case GraphicType::NONE:
- case GraphicType::Default:
- break;
-
- case GraphicType::Bitmap:
- {
- if(rImpGraphic.getVectorGraphicData())
- {
- // stream out Vector Graphic defining data (length, byte array and evtl. path)
- // this is used e.g. in swapping out graphic data and in transporting it over UNO API
- // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
- // no problem to extend it; only used at runtime
- switch (rImpGraphic.getVectorGraphicData()->getVectorGraphicDataType())
- {
- case VectorGraphicDataType::Wmf:
- {
- rOStm.WriteUInt32(constWmfMagic);
- break;
- }
- case VectorGraphicDataType::Emf:
- {
- rOStm.WriteUInt32(constEmfMagic);
- break;
- }
- case VectorGraphicDataType::Svg:
- {
- rOStm.WriteUInt32(constSvgMagic);
- break;
- }
- case VectorGraphicDataType::Pdf:
- {
- rOStm.WriteUInt32(constPdfMagic);
- break;
- }
- }
-
- rOStm.WriteUInt32( rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength() );
- rOStm.WriteBytes(rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray(),
- rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
- rOStm.WriteUniOrByteString(rImpGraphic.getVectorGraphicData()->getPath(),
- rOStm.GetStreamCharSet());
- }
- else if( rImpGraphic.ImplIsAnimated())
- {
- WriteAnimation( rOStm, *rImpGraphic.mpAnimation );
- }
- else
- {
- WriteDIBBitmapEx(rImpGraphic.maBitmapEx, rOStm);
- }
- }
- break;
-
- default:
- {
- if( rImpGraphic.ImplIsSupportedGraphic() )
- WriteGDIMetaFile( rOStm, rImpGraphic.maMetaFile );
- }
- break;
- }
-
- rOStm.SetEndian( nOldFormat );
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx
index 5103da66153e..41a3beeb0b06 100644
--- a/vcl/source/gdi/mapmod.cxx
+++ b/vcl/source/gdi/mapmod.cxx
@@ -24,7 +24,7 @@
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
#include <rtl/instance.hxx>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
struct MapMode::ImplMapMode
{
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index c966a68309e9..235fd30a356d 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -29,7 +29,7 @@
#include <vcl/metaact.hxx>
#include <vcl/graphictools.hxx>
#include <unotools/fontdefs.hxx>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
namespace
{
diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx
index 6912654a6164..75f9482b1208 100644
--- a/vcl/source/gdi/svmconverter.cxx
+++ b/vcl/source/gdi/svmconverter.cxx
@@ -31,7 +31,7 @@
#include <sal/log.hxx>
#include <osl/diagnose.h>
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
#include <svmconverter.hxx>
#include <memory>
#include <stack>
diff --git a/vcl/source/gdi/wall.cxx b/vcl/source/gdi/wall.cxx
index 6b332e5c74fe..fb6e84896158 100644
--- a/vcl/source/gdi/wall.cxx
+++ b/vcl/source/gdi/wall.cxx
@@ -26,8 +26,7 @@
#include <wall2.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/settings.hxx>
-
-#include <TypeSerializer.hxx>
+#include <vcl/TypeSerializer.hxx>
ImplWallpaper::ImplWallpaper() :
maColor( COL_TRANSPARENT ), meStyle( WallpaperStyle::NONE )
diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx
index d8c6e774d363..636293e9957d 100644
--- a/vcl/source/graphic/UnoGraphicProvider.cxx
+++ b/vcl/source/graphic/UnoGraphicProvider.cxx
@@ -46,6 +46,8 @@
#include <comphelper/sequence.hxx>
#include <memory>
+#include <vcl/TypeSerializer.hxx>
+
using namespace com::sun::star;
namespace {
@@ -812,7 +814,10 @@ void SAL_CALL GraphicProvider::storeGraphic( const uno::Reference< ::graphic::XG
SvMemoryStream aMemStrm;
aMemStrm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
if( 0 == strcmp( pFilterShortName, MIMETYPE_VCLGRAPHIC ) )
- WriteGraphic( aMemStrm, aGraphic );
+ {
+ TypeSerializer aSerializer(aMemStrm);
+ aSerializer.writeGraphic(aGraphic);
+ }
else
{
rFilter.ExportGraphic( aGraphic, aPath, aMemStrm,
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index a14da846739b..438192ae7d83 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -65,6 +65,7 @@
#include <vcl/graphicfilter.hxx>
#include <memory>
#include <utility>
+#include <vcl/TypeSerializer.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -735,7 +736,10 @@ bool TransferableHelper::SetGraphic( const Graphic& rGraphic )
aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
aMemStm.SetCompressMode( SvStreamCompressFlags::NATIVE );
- WriteGraphic( aMemStm, rGraphic );
+
+ TypeSerializer aSerializer(aMemStm);
+ aSerializer.writeGraphic(rGraphic);
+
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
@@ -1797,7 +1801,8 @@ bool TransferableDataHelper::GetGraphic( const css::datatransfer::DataFlavor& rF
if( GetSotStorageStream( rFlavor, xStm ) )
{
- ReadGraphic( *xStm, rGraphic );
+ TypeSerializer aSerializer(*xStm);
+ aSerializer.readGraphic(rGraphic);
bRet = ( xStm->GetError() == ERRCODE_NONE );
}
}
More information about the Libreoffice-commits
mailing list