move WriteGradient and ReadGradient to the TypeSerializer class
Change-Id: I40f72470c2a5a4a9ffff45ccc3295e7a8f1f3584 Reviewed-on: https://gerrit.libreoffice.org/78876 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
parent
bdcf58bdb1
commit
c7ca124efd
@ -103,9 +103,6 @@ public:
|
||||
bool operator==( const Gradient& rGradient ) const;
|
||||
bool operator!=( const Gradient& rGradient ) const
|
||||
{ return !(Gradient::operator==( rGradient )); }
|
||||
|
||||
friend VCL_DLLPUBLIC SvStream& ReadGradient( SvStream& rIStm, Gradient& rGradient );
|
||||
friend VCL_DLLPUBLIC SvStream& WriteGradient( SvStream& rOStm, const Gradient& rGradient );
|
||||
};
|
||||
|
||||
#endif // INCLUDED_VCL_GRADIENT_HXX
|
||||
|
@ -314,6 +314,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
|
||||
vcl/source/gdi/wall \
|
||||
vcl/source/gdi/scrptrun \
|
||||
vcl/source/gdi/CommonSalLayout \
|
||||
vcl/source/gdi/TypeSerializer \
|
||||
vcl/source/graphic/GraphicLoader \
|
||||
vcl/source/graphic/GraphicObject \
|
||||
vcl/source/graphic/GraphicObject2 \
|
||||
|
38
vcl/inc/TypeSerializer.hxx
Normal file
38
vcl/inc/TypeSerializer.hxx
Normal file
@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_VCL_INC_TYPESERIALIZER_HXX
|
||||
#define INCLUDED_VCL_INC_TYPESERIALIZER_HXX
|
||||
|
||||
#include <vcl/dllapi.h>
|
||||
#include <tools/GenericTypeSerializer.hxx>
|
||||
#include <vcl/gradient.hxx>
|
||||
|
||||
class VCL_DLLPUBLIC TypeSerializer : public tools::GenericTypeSerializer
|
||||
{
|
||||
public:
|
||||
TypeSerializer(SvStream& rStream);
|
||||
|
||||
void readGradient(Gradient& rGradient);
|
||||
void writeGradient(Gradient& rGradient);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
80
vcl/source/gdi/TypeSerializer.cxx
Normal file
80
vcl/source/gdi/TypeSerializer.cxx
Normal file
@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <TypeSerializer.hxx>
|
||||
#include <tools/vcompat.hxx>
|
||||
|
||||
TypeSerializer::TypeSerializer(SvStream& rStream)
|
||||
: GenericTypeSerializer(rStream)
|
||||
{
|
||||
}
|
||||
|
||||
void TypeSerializer::readGradient(Gradient& rGradient)
|
||||
{
|
||||
VersionCompat aCompat(mrStream, StreamMode::READ);
|
||||
|
||||
sal_uInt16 nStyle;
|
||||
Color aStartColor;
|
||||
Color aEndColor;
|
||||
sal_uInt16 nAngle;
|
||||
sal_uInt16 nBorder;
|
||||
sal_uInt16 nOffsetX;
|
||||
sal_uInt16 nOffsetY;
|
||||
sal_uInt16 nIntensityStart;
|
||||
sal_uInt16 nIntensityEnd;
|
||||
sal_uInt16 nStepCount;
|
||||
|
||||
mrStream.ReadUInt16(nStyle);
|
||||
readColor(aStartColor);
|
||||
readColor(aEndColor);
|
||||
mrStream.ReadUInt16(nAngle);
|
||||
mrStream.ReadUInt16(nBorder);
|
||||
mrStream.ReadUInt16(nOffsetX);
|
||||
mrStream.ReadUInt16(nOffsetY);
|
||||
mrStream.ReadUInt16(nIntensityStart);
|
||||
mrStream.ReadUInt16(nIntensityEnd);
|
||||
mrStream.ReadUInt16(nStepCount);
|
||||
|
||||
rGradient.SetStyle(static_cast<GradientStyle>(nStyle));
|
||||
rGradient.SetStartColor(aStartColor);
|
||||
rGradient.SetEndColor(aEndColor);
|
||||
rGradient.SetAngle(nAngle);
|
||||
rGradient.SetBorder(nBorder);
|
||||
rGradient.SetOfsX(nOffsetX);
|
||||
rGradient.SetOfsY(nOffsetY);
|
||||
rGradient.SetStartIntensity(nIntensityStart);
|
||||
rGradient.SetEndIntensity(nIntensityEnd);
|
||||
rGradient.SetSteps(nStepCount);
|
||||
}
|
||||
|
||||
void TypeSerializer::writeGradient(Gradient& rGradient)
|
||||
{
|
||||
VersionCompat aCompat(mrStream, StreamMode::WRITE, 1);
|
||||
|
||||
mrStream.WriteUInt16(static_cast<sal_uInt16>(rGradient.GetStyle()));
|
||||
writeColor(rGradient.GetStartColor());
|
||||
writeColor(rGradient.GetEndColor());
|
||||
mrStream.WriteUInt16(rGradient.GetAngle());
|
||||
mrStream.WriteUInt16(rGradient.GetBorder());
|
||||
mrStream.WriteUInt16(rGradient.GetOfsX());
|
||||
mrStream.WriteUInt16(rGradient.GetOfsY());
|
||||
mrStream.WriteUInt16(rGradient.GetStartIntensity());
|
||||
mrStream.WriteUInt16(rGradient.GetEndIntensity());
|
||||
mrStream.WriteUInt16(rGradient.GetSteps());
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
#include <tools/vcompat.hxx>
|
||||
#include <tools/gen.hxx>
|
||||
#include <tools/GenericTypeSerializer.hxx>
|
||||
#include <TypeSerializer.hxx>
|
||||
#include <vcl/gradient.hxx>
|
||||
|
||||
Impl_Gradient::Impl_Gradient() :
|
||||
@ -219,44 +220,4 @@ bool Gradient::operator==( const Gradient& rGradient ) const
|
||||
return mpImplGradient == rGradient.mpImplGradient;
|
||||
}
|
||||
|
||||
SvStream& ReadGradient( SvStream& rIStm, Gradient& rGradient )
|
||||
{
|
||||
VersionCompat aCompat( rIStm, StreamMode::READ );
|
||||
sal_uInt16 nTmp16;
|
||||
|
||||
rIStm.ReadUInt16( nTmp16 ); rGradient.mpImplGradient->meStyle = static_cast<GradientStyle>(nTmp16);
|
||||
|
||||
tools::GenericTypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readColor(rGradient.mpImplGradient->maStartColor);
|
||||
aSerializer.readColor(rGradient.mpImplGradient->maEndColor);
|
||||
rIStm.ReadUInt16( rGradient.mpImplGradient->mnAngle )
|
||||
.ReadUInt16( rGradient.mpImplGradient->mnBorder )
|
||||
.ReadUInt16( rGradient.mpImplGradient->mnOfsX )
|
||||
.ReadUInt16( rGradient.mpImplGradient->mnOfsY )
|
||||
.ReadUInt16( rGradient.mpImplGradient->mnIntensityStart )
|
||||
.ReadUInt16( rGradient.mpImplGradient->mnIntensityEnd )
|
||||
.ReadUInt16( rGradient.mpImplGradient->mnStepCount );
|
||||
|
||||
return rIStm;
|
||||
}
|
||||
|
||||
SvStream& WriteGradient( SvStream& rOStm, const Gradient& rGradient )
|
||||
{
|
||||
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
|
||||
|
||||
rOStm.WriteUInt16( static_cast<sal_uInt16>(rGradient.mpImplGradient->meStyle) );
|
||||
tools::GenericTypeSerializer aSerializer(rOStm);
|
||||
aSerializer.writeColor(rGradient.mpImplGradient->maStartColor);
|
||||
aSerializer.writeColor(rGradient.mpImplGradient->maEndColor);
|
||||
rOStm.WriteUInt16( rGradient.mpImplGradient->mnAngle )
|
||||
.WriteUInt16( rGradient.mpImplGradient->mnBorder )
|
||||
.WriteUInt16( rGradient.mpImplGradient->mnOfsX )
|
||||
.WriteUInt16( rGradient.mpImplGradient->mnOfsY )
|
||||
.WriteUInt16( rGradient.mpImplGradient->mnIntensityStart )
|
||||
.WriteUInt16( rGradient.mpImplGradient->mnIntensityEnd )
|
||||
.WriteUInt16( rGradient.mpImplGradient->mnStepCount );
|
||||
|
||||
return rOStm;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <vcl/metaact.hxx>
|
||||
#include <vcl/graphictools.hxx>
|
||||
#include <unotools/fontdefs.hxx>
|
||||
#include <TypeSerializer.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -1987,14 +1988,16 @@ void MetaGradientAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
|
||||
MetaAction::Write(rOStm, pData);
|
||||
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
|
||||
WriteRectangle( rOStm, maRect );
|
||||
WriteGradient( rOStm, maGradient );
|
||||
TypeSerializer aSerializer(rOStm);
|
||||
aSerializer.writeGradient(maGradient);
|
||||
}
|
||||
|
||||
void MetaGradientAction::Read( SvStream& rIStm, ImplMetaReadData* )
|
||||
{
|
||||
VersionCompat aCompat(rIStm, StreamMode::READ);
|
||||
ReadRectangle( rIStm, maRect );
|
||||
ReadGradient( rIStm, maGradient );
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readGradient(maGradient);
|
||||
}
|
||||
|
||||
MetaGradientExAction::MetaGradientExAction() :
|
||||
@ -2044,14 +2047,16 @@ void MetaGradientExAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
|
||||
maPolyPoly.AdaptiveSubdivide(aNoCurvePolyPolygon);
|
||||
|
||||
WritePolyPolygon( rOStm, aNoCurvePolyPolygon );
|
||||
WriteGradient( rOStm, maGradient );
|
||||
TypeSerializer aSerializer(rOStm);
|
||||
aSerializer.writeGradient(maGradient);
|
||||
}
|
||||
|
||||
void MetaGradientExAction::Read( SvStream& rIStm, ImplMetaReadData* )
|
||||
{
|
||||
VersionCompat aCompat(rIStm, StreamMode::READ);
|
||||
ReadPolyPolygon( rIStm, maPolyPoly );
|
||||
ReadGradient( rIStm, maGradient );
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readGradient(maGradient);
|
||||
}
|
||||
|
||||
MetaHatchAction::MetaHatchAction() :
|
||||
@ -2947,7 +2952,9 @@ void MetaFloatTransparentAction::Write( SvStream& rOStm, ImplMetaWriteData* pDat
|
||||
maMtf.Write( rOStm );
|
||||
WritePair( rOStm, maPoint );
|
||||
WritePair( rOStm, maSize );
|
||||
WriteGradient( rOStm, maGradient );
|
||||
|
||||
TypeSerializer aSerializer(rOStm);
|
||||
aSerializer.writeGradient(maGradient);
|
||||
}
|
||||
|
||||
void MetaFloatTransparentAction::Read(SvStream& rIStm, ImplMetaReadData* pData)
|
||||
@ -2956,7 +2963,8 @@ void MetaFloatTransparentAction::Read(SvStream& rIStm, ImplMetaReadData* pData)
|
||||
ReadGDIMetaFile(rIStm, maMtf, pData);
|
||||
ReadPair( rIStm, maPoint );
|
||||
ReadPair( rIStm, maSize );
|
||||
ReadGradient( rIStm, maGradient );
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readGradient(maGradient);
|
||||
}
|
||||
|
||||
MetaEPSAction::MetaEPSAction() :
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <sal/log.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
|
||||
#include <TypeSerializer.hxx>
|
||||
#include <svmconverter.hxx>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
@ -1080,7 +1081,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
|
||||
ReadGDIMetaFile( rIStm, aMtf );
|
||||
ReadPair( rIStm, aPos );
|
||||
ReadPair( rIStm, aSize );
|
||||
ReadGradient( rIStm, aGradient );
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readGradient(aGradient);
|
||||
rIStm.ReadInt32( nFollowingActionCount );
|
||||
ImplSkipActions( rIStm, nFollowingActionCount );
|
||||
rMtf.AddAction( new MetaFloatTransparentAction( aMtf, aPos, aSize, aGradient ) );
|
||||
@ -1169,7 +1171,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
|
||||
sal_Int32 nFollowingActionCount(0);
|
||||
|
||||
ReadPolyPolygon( rIStm, aPolyPoly );
|
||||
ReadGradient( rIStm, aGradient );
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readGradient(aGradient);
|
||||
rIStm.ReadInt32( nFollowingActionCount );
|
||||
ImplSkipActions( rIStm, nFollowingActionCount );
|
||||
rMtf.AddAction( new MetaGradientExAction( aPolyPoly, aGradient ) );
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <vcl/dibtools.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
|
||||
#include <TypeSerializer.hxx>
|
||||
|
||||
ImplWallpaper::ImplWallpaper() :
|
||||
maColor( COL_TRANSPARENT ), meStyle( WallpaperStyle::NONE )
|
||||
{
|
||||
@ -62,7 +64,7 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
|
||||
rImplWallpaper.mpBitmap.reset();
|
||||
|
||||
// version 1
|
||||
tools::GenericTypeSerializer aSerializer(rIStm);
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readColor(rImplWallpaper.maColor);
|
||||
sal_uInt16 nTmp16(0);
|
||||
rIStm.ReadUInt16(nTmp16);
|
||||
@ -84,7 +86,7 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
|
||||
if( bGrad )
|
||||
{
|
||||
rImplWallpaper.mpGradient = std::make_unique<Gradient>();
|
||||
ReadGradient( rIStm, *rImplWallpaper.mpGradient );
|
||||
aSerializer.readGradient(*rImplWallpaper.mpGradient);
|
||||
}
|
||||
|
||||
if( bBmp )
|
||||
@ -112,7 +114,7 @@ SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpap
|
||||
bool bDummy = false;
|
||||
|
||||
// version 1
|
||||
tools::GenericTypeSerializer aSerializer(rOStm);
|
||||
TypeSerializer aSerializer(rOStm);
|
||||
aSerializer.writeColor(rImplWallpaper.maColor);
|
||||
|
||||
rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplWallpaper.meStyle) );
|
||||
@ -123,8 +125,10 @@ SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpap
|
||||
if( bRect )
|
||||
WriteRectangle( rOStm, *rImplWallpaper.mpRect );
|
||||
|
||||
if( bGrad )
|
||||
WriteGradient( rOStm, *rImplWallpaper.mpGradient );
|
||||
if (bGrad)
|
||||
{
|
||||
aSerializer.writeGradient(*rImplWallpaper.mpGradient);
|
||||
}
|
||||
|
||||
if( bBmp )
|
||||
WriteDIBBitmapEx(*rImplWallpaper.mpBitmap, rOStm);
|
||||
|
Loading…
x
Reference in New Issue
Block a user