diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-21 09:34:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-22 07:22:13 +0100 |
commit | 8e7226233940a201c76c6a43e0648603d17961f4 (patch) | |
tree | 523aaab816b93c7c276def7d8462500cae0df957 /sc/source/filter | |
parent | eb21db08b3aee4b9113d221ca47af73d2f9b82d7 (diff) |
ColorData->Color in sc
and fix the sal_Int32() conversion operator in Color, which was
always returning 0
Change-Id: I0aefaedc34ee0a8bccd43238ccfe8196d2dd5c5c
Reviewed-on: https://gerrit.libreoffice.org/50051
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/filter')
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/excel/xiescher.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xistyle.cxx | 20 | ||||
-rw-r--r-- | sc/source/filter/excel/xlchart.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/excel/xlstyle.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/ftools/fapihelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/inc/fapihelper.hxx | 11 | ||||
-rw-r--r-- | sc/source/filter/inc/xistyle.hxx | 11 | ||||
-rw-r--r-- | sc/source/filter/inc/xlstyle.hxx | 17 |
9 files changed, 41 insertions, 56 deletions
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 25cda7d56db7..3a95c4b23a40 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -253,7 +253,7 @@ public: /** Returns the RGB color data for a (non-zero-based) Excel palette entry. @return The color from current or default palette or COL_AUTO, if nothing else found. */ - ColorData GetColorData( sal_uInt16 nXclIndex ) const; + Color GetColor( sal_uInt16 nXclIndex ) const; /** Returns true, if all colors of the palette are equal to default palette colors. */ bool IsDefaultPalette() const; @@ -461,7 +461,7 @@ void XclExpPaletteImpl::GetMixedColors( } } -ColorData XclExpPaletteImpl::GetColorData( sal_uInt16 nXclIndex ) const +Color XclExpPaletteImpl::GetColor( sal_uInt16 nXclIndex ) const { if( nXclIndex >= EXC_COLOR_USEROFFSET ) { @@ -469,7 +469,7 @@ ColorData XclExpPaletteImpl::GetColorData( sal_uInt16 nXclIndex ) const if( nIdx < maPalette.size() ) return maPalette[ nIdx ].maColor.GetColor(); } - return mrDefPal.GetDefColorData( nXclIndex ); + return mrDefPal.GetDefColor( nXclIndex ); } bool XclExpPaletteImpl::IsDefaultPalette() const @@ -798,7 +798,7 @@ void XclExpPalette::GetMixedColors( Color XclExpPalette::GetColor( sal_uInt16 nXclIndex ) const { - return Color(mxImpl->GetColorData( nXclIndex )); + return Color(mxImpl->GetColor( nXclIndex )); } void XclExpPalette::Save( XclExpStream& rStrm ) diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 2b75c82a94d4..8a84cfcf4c20 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -3219,7 +3219,7 @@ XclImpSimpleDffConverter::~XclImpSimpleDffConverter() bool XclImpSimpleDffConverter::GetColorFromPalette( sal_uInt16 nIndex, Color& rColor ) const { - ColorData nColor = GetPalette().GetColorData( nIndex ); + Color nColor = GetPalette().GetColor( nIndex ); if( nColor == COL_AUTO ) return false; diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 7cafcf70e7fd..8b54b6241afd 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -72,23 +72,23 @@ using ::std::vector; using namespace ::com::sun::star; typedef ::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE; -typedef ::std::vector< ColorData > ColorDataVec; +typedef ::std::vector< Color > ColorVec; class PaletteIndex : public XIndexAccess_BASE { public: - explicit PaletteIndex( const ColorDataVec& rColorDataTable ) : maColorData( rColorDataTable ) {} + explicit PaletteIndex( const ColorVec& rColorTable ) : maColor( rColorTable ) {} // Methods XIndexAccess virtual ::sal_Int32 SAL_CALL getCount() override { - return maColorData.size(); + return maColor.size(); } virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override { //--Index; // apparently the palette is already 1 based - return uno::makeAny( sal_Int32( maColorData[ Index ] ) ); + return uno::makeAny( sal_Int32( maColor[ Index ] ) ); } // Methods XElementAccess @@ -98,11 +98,11 @@ public: } virtual sal_Bool SAL_CALL hasElements() override { - return (maColorData.size() > 0); + return (maColor.size() > 0); } private: - ColorDataVec maColorData; + ColorVec maColor; }; void @@ -112,10 +112,10 @@ XclImpPalette::ExportPalette() { // copy values in color palette sal_Int16 nColors = maColorTable.size(); - ColorDataVec aColors; + ColorVec aColors; aColors.resize( nColors ); for( sal_uInt16 nIndex = 0; nIndex < nColors; ++nIndex ) - aColors[ nIndex ] = GetColorData( nIndex ); + aColors[ nIndex ] = GetColor( nIndex ); uno::Reference< beans::XPropertySet > xProps( pDocShell->GetModel(), uno::UNO_QUERY ); if ( xProps.is() ) @@ -138,7 +138,7 @@ void XclImpPalette::Initialize() maColorTable.clear(); } -ColorData XclImpPalette::GetColorData( sal_uInt16 nXclIndex ) const +Color XclImpPalette::GetColor( sal_uInt16 nXclIndex ) const { if( nXclIndex >= EXC_COLOR_USEROFFSET ) { @@ -146,7 +146,7 @@ ColorData XclImpPalette::GetColorData( sal_uInt16 nXclIndex ) const if( nIx < maColorTable.size() ) return maColorTable[ nIx ]; } - return GetDefColorData( nXclIndex ); + return GetDefColor( nXclIndex ); } void XclImpPalette::ReadPalette( XclImpStream& rStrm ) diff --git a/sc/source/filter/excel/xlchart.cxx b/sc/source/filter/excel/xlchart.cxx index b4c65de0c546..b583c2df42ff 100644 --- a/sc/source/filter/excel/xlchart.cxx +++ b/sc/source/filter/excel/xlchart.cxx @@ -884,8 +884,8 @@ void XclChPropSetHelper::ReadMarkerProperties( rMarkerFmt.mnMarkerSize = XclTools::GetTwipsFromHmm( nApiSize ); // symbol colors - rMarkerFmt.maLineColor = ScfApiHelper::ConvertFromApiColor( aApiSymbol.BorderColor ); - rMarkerFmt.maFillColor = ScfApiHelper::ConvertFromApiColor( aApiSymbol.FillColor ); + rMarkerFmt.maLineColor = Color( aApiSymbol.BorderColor ); + rMarkerFmt.maFillColor = Color( aApiSymbol.FillColor ); } } @@ -949,7 +949,7 @@ void XclChPropSetHelper::WriteLineProperties( } // line color - sal_Int32 nApiColor = ScfApiHelper::ConvertToApiColor( rLineFmt.maColor ); + sal_Int32 nApiColor = sal_Int32( rLineFmt.maColor ); // try to insert the dash style and receive its name uno::Any aDashNameAny; @@ -1081,9 +1081,9 @@ void XclChPropSetHelper::WriteMarkerProperties( aApiSymbol.Size = awt::Size( nApiSize, nApiSize ); // symbol colors - aApiSymbol.FillColor = ScfApiHelper::ConvertToApiColor( rMarkerFmt.maFillColor ); + aApiSymbol.FillColor = sal_Int32( rMarkerFmt.maFillColor ); aApiSymbol.BorderColor = ::get_flag( rMarkerFmt.mnFlags, EXC_CHMARKERFORMAT_NOLINE ) ? - aApiSymbol.FillColor : ScfApiHelper::ConvertToApiColor( rMarkerFmt.maLineColor ); + aApiSymbol.FillColor : sal_Int32( rMarkerFmt.maLineColor ); // set the property rPropSet.SetProperty( EXC_CHPROP_SYMBOL, aApiSymbol ); diff --git a/sc/source/filter/excel/xlstyle.cxx b/sc/source/filter/excel/xlstyle.cxx index 7c7b54253931..3c32027ce5cc 100644 --- a/sc/source/filter/excel/xlstyle.cxx +++ b/sc/source/filter/excel/xlstyle.cxx @@ -42,13 +42,13 @@ 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080 /** Default color table for BIFF2. */ -static const ColorData spnDefColorTable2[] = +static const Color spnDefColorTable2[] = { /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT }; /** Default color table for BIFF3/BIFF4. */ -static const ColorData spnDefColorTable3[] = +static const Color spnDefColorTable3[] = { /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT, /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT, @@ -56,7 +56,7 @@ static const ColorData spnDefColorTable3[] = }; /** Default color table for BIFF5/BIFF7. */ -static const ColorData spnDefColorTable5[] = +static const Color spnDefColorTable5[] = { /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT, /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT, @@ -69,7 +69,7 @@ static const ColorData spnDefColorTable5[] = }; /** Default color table for BIFF8. */ -static const ColorData spnDefColorTable8[] = +static const Color spnDefColorTable8[] = { /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT, /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT, @@ -134,9 +134,9 @@ XclDefaultPalette::XclDefaultPalette( const XclRoot& rRoot ) : } } -ColorData XclDefaultPalette::GetDefColorData( sal_uInt16 nXclIndex ) const +Color XclDefaultPalette::GetDefColor( sal_uInt16 nXclIndex ) const { - ColorData nColor; + Color nColor; if( nXclIndex < mnTableSize ) nColor = mpnColorTable[ nXclIndex ]; else switch( nXclIndex ) @@ -153,7 +153,7 @@ ColorData XclDefaultPalette::GetDefColorData( sal_uInt16 nXclIndex ) const case EXC_COLOR_NOTETEXT: nColor = mnNoteText; break; case EXC_COLOR_FONTAUTO: nColor = COL_AUTO; break; default: - SAL_WARN("sc", "XclDefaultPalette::GetDefColorData - unknown default color index: " << nXclIndex ); + SAL_WARN("sc", "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex ); nColor = COL_AUTO; } return nColor; diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx index b7fbf428d24a..0d09cfb5c2a5 100644 --- a/sc/source/filter/ftools/fapihelper.cxx +++ b/sc/source/filter/ftools/fapihelper.cxx @@ -201,7 +201,7 @@ bool ScfPropertySet::GetColorProperty( Color& rColor, const OUString& rPropName { sal_Int32 nApiColor = 0; bool bRet = GetProperty( nApiColor, rPropName ); - rColor = ScfApiHelper::ConvertFromApiColor( nApiColor ); + rColor = Color( nApiColor ); return bRet; } @@ -324,7 +324,7 @@ void ScfPropSetHelper::ReadValue( Color& rColor ) { sal_Int32 nApiColor(0); ReadValue( nApiColor ); - rColor = ScfApiHelper::ConvertFromApiColor( nApiColor ); + rColor = Color( nApiColor ); } void ScfPropSetHelper::ReadValue( bool& rbValue ) diff --git a/sc/source/filter/inc/fapihelper.hxx b/sc/source/filter/inc/fapihelper.hxx index 4610650744d5..0648da426305 100644 --- a/sc/source/filter/inc/fapihelper.hxx +++ b/sc/source/filter/inc/fapihelper.hxx @@ -47,13 +47,6 @@ class SfxObjectShell; class ScfApiHelper { public: - /** Converts a tools color to a UNO color value. */ - static sal_Int32 ConvertToApiColor( const Color& rColor ) - { return static_cast< sal_Int32 >( rColor.GetColor() ); } - /** Converts a UNO color value to a tools color. */ - static Color ConvertFromApiColor( sal_Int32 nApiColor ) - { return Color( static_cast< ColorData >( nApiColor ) ); } - /** Converts a non-empty vector into a UNO sequence containing elements of the same type. */ template< typename Type > static css::uno::Sequence< Type > @@ -188,7 +181,7 @@ public: /** Puts the passed color into the property set. */ void SetColorProperty( const OUString& rPropName, const Color& rColor ) - { SetProperty( rPropName, ScfApiHelper::ConvertToApiColor( rColor ) ); } + { SetProperty( rPropName, sal_Int32( rColor ) ); } /** Puts the passed properties into the property set. Tries to use the XMultiPropertySet interface. @param rPropNames The property names. MUST be ordered alphabetically. @@ -247,7 +240,7 @@ public: void WriteValue( const css::uno::Any& rAny ); /** Writes a color value to the value sequence. */ void WriteValue( const Color& rColor ) - { WriteValue( ScfApiHelper::ConvertToApiColor( rColor ) ); } + { WriteValue( sal_Int32( rColor ) ); } /** Writes a C++ boolean value to the value sequence. */ void WriteValue( bool rbValue ); diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx index da818321dabd..68fec485b95d 100644 --- a/sc/source/filter/inc/xistyle.hxx +++ b/sc/source/filter/inc/xistyle.hxx @@ -49,23 +49,18 @@ public: /** Clears all buffered data, used to set up for a new sheet. */ void Initialize(); - /** Returns the RGB color data for a (non-zero-based) Excel palette entry. - @descr First looks for a color read from file, then looks for a default color. - @return The color from current or default palette or COL_AUTO, if nothing else found. */ - ColorData GetColorData( sal_uInt16 nXclIndex ) const; /** Returns the color for a (non-zero-based) Excel palette entry. @descr First looks for a color read from file, then looks for a default color. @return The color from current or default palette or COL_AUTO, if nothing else found. */ - Color GetColor( sal_uInt16 nXclIndex ) const - { return Color( GetColorData( nXclIndex ) ); } + Color GetColor( sal_uInt16 nXclIndex ) const; /** Reads a PALETTE record. */ void ReadPalette( XclImpStream& rStrm ); private: void ExportPalette(); - typedef ::std::vector< ColorData > ColorDataVec; - ColorDataVec maColorTable; /// Colors read from file. + typedef ::std::vector< Color > ColorVec; + ColorVec maColorTable; /// Colors read from file. const XclImpRoot& mrRoot; }; diff --git a/sc/source/filter/inc/xlstyle.hxx b/sc/source/filter/inc/xlstyle.hxx index 1e20c5c396d8..1ff7b9a8c1f7 100644 --- a/sc/source/filter/inc/xlstyle.hxx +++ b/sc/source/filter/inc/xlstyle.hxx @@ -257,22 +257,19 @@ public: /** Returns the color count in the current palette. */ sal_uInt32 GetColorCount() const { return mnTableSize - EXC_COLOR_USEROFFSET; } - /** Returns the default RGB color data for a (non-zero-based) Excel color or COL_AUTO on error. */ - ColorData GetDefColorData( sal_uInt16 nXclIndex ) const; /** Returns the default color for a (non-zero-based) Excel color or COL_AUTO on error. */ - Color GetDefColor( sal_uInt16 nXclIndex ) const - { return Color( GetDefColorData( nXclIndex ) ); } + Color GetDefColor( sal_uInt16 nXclIndex ) const; /** Returns true, if the passed Excel color index is a system color. */ bool IsSystemColor( sal_uInt16 nXclIndex ) const { return nXclIndex >= mnTableSize; } private: - const ColorData* mpnColorTable; /// The table with RGB values. - ColorData mnWindowText; /// System window text color. - ColorData mnWindowBack; /// System window background color. - ColorData mnFaceColor; /// System button background color. - ColorData mnNoteText; /// Note text color. - ColorData mnNoteBack; /// Note background color. + const Color* mpnColorTable; /// The table with RGB values. + Color mnWindowText; /// System window text color. + Color mnWindowBack; /// System window background color. + Color mnFaceColor; /// System button background color. + Color mnNoteText; /// Note text color. + Color mnNoteBack; /// Note background color. sal_uInt32 mnTableSize; /// The color table size. }; |