diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-04-27 11:18:42 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-04-27 06:48:18 +0200 |
commit | cae53cf14d59bc2fa6317c9493197804928d6e5e (patch) | |
tree | 4420d17bf2c9f1aa001c98c5c140ebd7ed04c30e /tools/source/generic/color.cxx | |
parent | 55e28737e973b40f72d398c9bb7a4a41307eb562 (diff) |
Decouple reading/writing of Color into GenericTypeSerializer
This adds GenericTypeSerializer, which is now responsible of
serializing the Color into a stream (other types will follow), but
only for the older version of the binary format. The new version
we just write the sal_UInt32 mValue directly.
This is a start of decoupling the serialization of generic types
in tools and vcl module from the actual type, so we can in the
future replace those with basegfx variant.
Change-Id: I92738e7c178cac5cbca882dcbe45c80cc8269466
Reviewed-on: https://gerrit.libreoffice.org/71404
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'tools/source/generic/color.cxx')
-rw-r--r-- | tools/source/generic/color.cxx | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index f79342d37862..a06c6e84a964 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -25,7 +25,6 @@ #include <stdlib.h> #include <tools/color.hxx> -#include <tools/stream.hxx> #include <tools/helpers.hxx> #include <basegfx/color/bcolortools.hxx> @@ -184,18 +183,6 @@ Color Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri ) return Color( cR, cG, cB ); } -SvStream& Color::Read( SvStream& rIStm ) -{ - rIStm.ReadUInt32(mValue); - return rIStm; -} - -SvStream& Color::Write( SvStream& rOStm ) const -{ - rOStm.WriteUInt32(mValue); - return rOStm; -} - OUString Color::AsRGBHexString() const { std::stringstream ss; @@ -203,72 +190,6 @@ OUString Color::AsRGBHexString() const return OUString::createFromAscii(ss.str().c_str()); } -#define COL_NAME_USER (sal_uInt16(0x8000)) - -SvStream& ReadColor( SvStream& rIStream, Color& rColor ) -{ - sal_uInt16 nColorName(0); - - rIStream.ReadUInt16( nColorName ); - - if ( nColorName & COL_NAME_USER ) - { - sal_uInt16 nRed; - sal_uInt16 nGreen; - sal_uInt16 nBlue; - - rIStream.ReadUInt16( nRed ); - rIStream.ReadUInt16( nGreen ); - rIStream.ReadUInt16( nBlue ); - - rColor = Color( nRed>>8, nGreen>>8, nBlue>>8 ); - } - else - { - static const Color aColAry[] = - { - COL_BLACK, // COL_BLACK - COL_BLUE, // COL_BLUE - COL_GREEN, // COL_GREEN - COL_CYAN, // COL_CYAN - COL_RED, // COL_RED - COL_MAGENTA, // COL_MAGENTA - COL_BROWN, // COL_BROWN - COL_GRAY, // COL_GRAY - COL_LIGHTGRAY, // COL_LIGHTGRAY - COL_LIGHTBLUE, // COL_LIGHTBLUE - COL_LIGHTGREEN, // COL_LIGHTGREEN - COL_LIGHTCYAN, // COL_LIGHTCYAN - COL_LIGHTRED, // COL_LIGHTRED - COL_LIGHTMAGENTA, // COL_LIGHTMAGENTA - COL_YELLOW, // COL_YELLOW - COL_WHITE, // COL_WHITE - COL_WHITE, // COL_MENUBAR - COL_BLACK, // COL_MENUBARTEXT - COL_WHITE, // COL_POPUPMENU - COL_BLACK, // COL_POPUPMENUTEXT - COL_BLACK, // COL_WINDOWTEXT - COL_WHITE, // COL_WINDOWWORKSPACE - COL_BLACK, // COL_HIGHLIGHT - COL_WHITE, // COL_HIGHLIGHTTEXT - COL_BLACK, // COL_3DTEXT - COL_LIGHTGRAY, // COL_3DFACE - COL_WHITE, // COL_3DLIGHT - COL_GRAY, // COL_3DSHADOW - COL_LIGHTGRAY, // COL_SCROLLBAR - COL_WHITE, // COL_FIELD - COL_BLACK // COL_FIELDTEXT - }; - - if ( nColorName < SAL_N_ELEMENTS( aColAry ) ) - rColor = aColAry[nColorName]; - else - rColor = COL_BLACK; - } - - return rIStream; -} - void Color::ApplyTintOrShade(sal_Int16 n100thPercent) { if (n100thPercent == 0) @@ -295,21 +216,4 @@ void Color::ApplyTintOrShade(sal_Int16 n100thPercent) B = sal_uInt8(std::lround(aBColor.getBlue() * 255.0)); } -SvStream& WriteColor( SvStream& rOStream, const Color& rColor ) -{ - sal_uInt16 nRed = rColor.GetRed(); - sal_uInt16 nGreen = rColor.GetGreen(); - sal_uInt16 nBlue = rColor.GetBlue(); - nRed = (nRed<<8) + nRed; - nGreen = (nGreen<<8) + nGreen; - nBlue = (nBlue<<8) + nBlue; - - rOStream.WriteUInt16( COL_NAME_USER ); - rOStream.WriteUInt16( nRed ); - rOStream.WriteUInt16( nGreen ); - rOStream.WriteUInt16( nBlue ); - - return rOStream; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |