use more Color in xmloff

Change-Id: Iec12d2e9f3e254dc6525dc285259321b13f75c4a
Reviewed-on: https://gerrit.libreoffice.org/50794
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2018-03-06 10:34:00 +02:00
parent d15ff312ad
commit f02b1ba18d
6 changed files with 18 additions and 19 deletions

View File

@@ -20,6 +20,7 @@
#define XMLOFF_COLORPROPERTYSET_HXX #define XMLOFF_COLORPROPERTYSET_HXX
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <tools/color.hxx>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertyState.hpp>
@@ -71,8 +72,8 @@ protected:
private: private:
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo; css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo;
OUString m_aColorPropName; OUString m_aColorPropName;
sal_Int32 m_nColor; Color m_nColor;
sal_Int32 m_nDefaultColor; Color m_nDefaultColor;
}; };
} // namespace chart } // namespace chart

View File

@@ -152,11 +152,11 @@ void XMLGraphicsDefaultStyle::SetDefaults()
if (std::none_of(GetProperties().begin(), GetProperties().end(), if (std::none_of(GetProperties().begin(), GetProperties().end(),
XMLPropertyByIndex(nStrokeIndex))) XMLPropertyByIndex(nStrokeIndex)))
{ {
sal_Int32 const nStroke( Color const nStroke(
bIsAOO4 ? Color(128, 128, 128) : COL_BLACK); bIsAOO4 ? Color(128, 128, 128) : COL_BLACK);
xDefaults->setPropertyValue("LineColor", makeAny(nStroke)); xDefaults->setPropertyValue("LineColor", makeAny(nStroke));
} }
sal_Int32 const nFillColor( bIsAOO4 Color const nFillColor( bIsAOO4
? Color(0xCF, 0xE7, 0xF5) : Color(153, 204, 255)); ? Color(0xCF, 0xE7, 0xF5) : Color(153, 204, 255));
sal_Int32 const nFillIndex( sal_Int32 const nFillIndex(
pImpPrMap->GetEntryIndex(XML_NAMESPACE_DRAW, "fill-color", 0)); pImpPrMap->GetEntryIndex(XML_NAMESPACE_DRAW, "fill-color", 0));
@@ -172,7 +172,7 @@ void XMLGraphicsDefaultStyle::SetDefaults()
if (std::none_of(GetProperties().begin(), GetProperties().end(), if (std::none_of(GetProperties().begin(), GetProperties().end(),
XMLPropertyByIndex(nFill2Index))) XMLPropertyByIndex(nFill2Index)))
{ {
xDefaults->setPropertyValue("FillColor2", makeAny(nFillColor)); xDefaults->setPropertyValue("FillColor2", makeAny(sal_Int32(nFillColor)));
} }
} }
} }

View File

@@ -151,7 +151,7 @@ void XMLTransGradientStyleImport::importXML(
( (100 - aStartTransparency) * 255 ) / 100 ); ( (100 - aStartTransparency) * 255 ) / 100 );
Color aColor( n, n, n ); Color aColor( n, n, n );
aGradient.StartColor = static_cast<sal_Int32>( aColor.GetColor() ); aGradient.StartColor = static_cast<sal_Int32>( aColor );
} }
break; break;
case XML_TOK_GRADIENT_END: case XML_TOK_GRADIENT_END:
@@ -163,7 +163,7 @@ void XMLTransGradientStyleImport::importXML(
( (100 - aEndTransparency) * 255 ) / 100 ); ( (100 - aEndTransparency) * 255 ) / 100 );
Color aColor( n, n, n ); Color aColor( n, n, n );
aGradient.EndColor = static_cast<sal_Int32>( aColor.GetColor() ); aGradient.EndColor = static_cast<sal_Int32>( aColor );
} }
break; break;
case XML_TOK_GRADIENT_ANGLE: case XML_TOK_GRADIENT_ANGLE:
@@ -248,14 +248,14 @@ void XMLTransGradientStyleExport::exportXML(
Color aColor; Color aColor;
// Transparency start // Transparency start
aColor = aGradient.StartColor; aColor = Color(aGradient.StartColor);
sal_Int32 aStartValue = 100 - static_cast<sal_Int32>(((aColor.GetRed() + 1) * 100) / 255); sal_Int32 aStartValue = 100 - static_cast<sal_Int32>(((aColor.GetRed() + 1) * 100) / 255);
::sax::Converter::convertPercent( aOut, aStartValue ); ::sax::Converter::convertPercent( aOut, aStartValue );
aStrValue = aOut.makeStringAndClear(); aStrValue = aOut.makeStringAndClear();
rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_START, aStrValue ); rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_START, aStrValue );
// Transparency end // Transparency end
aColor = aGradient.EndColor; aColor = Color(aGradient.EndColor);
sal_Int32 aEndValue = 100 - static_cast<sal_Int32>(((aColor.GetRed() + 1) * 100) / 255); sal_Int32 aEndValue = 100 - static_cast<sal_Int32>(((aColor.GetRed() + 1) * 100) / 255);
::sax::Converter::convertPercent( aOut, aEndValue ); ::sax::Converter::convertPercent( aOut, aEndValue );
aStrValue = aOut.makeStringAndClear(); aStrValue = aOut.makeStringAndClear();

View File

@@ -63,12 +63,9 @@ bool XMLShadowPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue
} }
else if( !bColorFound && aToken.startsWith("#") ) else if( !bColorFound && aToken.startsWith("#") )
{ {
sal_Int32 nColor(0); bRet = ::sax::Converter::convertColor( aColor, aToken );
bRet = ::sax::Converter::convertColor( nColor, aToken );
if( !bRet ) if( !bRet )
return false; return false;
aColor = nColor;
bColorFound = true; bColorFound = true;
} }
else if( !bOffsetFound ) else if( !bOffsetFound )
@@ -112,7 +109,7 @@ bool XMLShadowPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue
if( bRet && ( bColorFound || bOffsetFound ) ) if( bRet && ( bColorFound || bOffsetFound ) )
{ {
aShadow.IsTransparent = aColor.GetTransparency() > 0; aShadow.IsTransparent = aColor.GetTransparency() > 0;
aShadow.Color = aColor.GetColor(); aShadow.Color = sal_Int32(aColor);
bRet = true; bRet = true;
} }

View File

@@ -190,7 +190,7 @@ public:
class SvXMLNumFmtPropContext : public SvXMLImportContext class SvXMLNumFmtPropContext : public SvXMLImportContext
{ {
SvXMLNumFormatContext& rParent; SvXMLNumFormatContext& rParent;
sal_Int32 m_nColor; Color m_nColor;
bool bColSet; bool bColSet;
public: public:

View File

@@ -37,6 +37,7 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <tools/fontenum.hxx> #include <tools/fontenum.hxx>
#include <tools/color.hxx>
#include <sax/tools/converter.hxx> #include <sax/tools/converter.hxx>
@@ -174,7 +175,7 @@ class SvxXMLListLevelStyleContext_Impl : public SvXMLImportContext
sal_Unicode cBullet; sal_Unicode cBullet;
sal_Int16 nRelSize; sal_Int16 nRelSize;
sal_Int32 m_nColor; Color m_nColor;
sal_Int16 ePosAndSpaceMode; sal_Int16 ePosAndSpaceMode;
sal_Int16 eLabelFollowedBy; sal_Int16 eLabelFollowedBy;
@@ -188,7 +189,7 @@ class SvxXMLListLevelStyleContext_Impl : public SvXMLImportContext
bool bHasColor : 1; bool bHasColor : 1;
void SetRelSize( sal_Int16 nRel ) { nRelSize = nRel; } void SetRelSize( sal_Int16 nRel ) { nRelSize = nRel; }
void SetColor( sal_Int32 nColor ) void SetColor( Color nColor )
{ m_nColor = nColor; bHasColor = true; } { m_nColor = nColor; bHasColor = true; }
void SetSpaceBefore( sal_Int32 nSet ) { nSpaceBefore = nSet; } void SetSpaceBefore( sal_Int32 nSet ) { nSpaceBefore = nSet; }
void SetMinLabelWidth( sal_Int32 nSet ) { nMinLabelWidth = nSet; } void SetMinLabelWidth( sal_Int32 nSet ) { nMinLabelWidth = nSet; }
@@ -738,14 +739,14 @@ SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
sal_Int32 nColor(0); sal_Int32 nColor(0);
if (::sax::Converter::convertColor( nColor, rValue )) if (::sax::Converter::convertColor( nColor, rValue ))
{ {
rListLevel.SetColor( nColor ); rListLevel.SetColor( Color(nColor) );
} }
} }
break; break;
case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR: case XML_TOK_STYLE_ATTRIBUTES_ATTR_WINDOW_FONT_COLOR:
{ {
if( IsXMLToken( rValue, XML_TRUE ) ) if( IsXMLToken( rValue, XML_TRUE ) )
rListLevel.SetColor( sal_Int32(0xffffffff) ); rListLevel.SetColor( Color(0xffffffff) );
} }
break; break;
case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE: case XML_TOK_STYLE_ATTRIBUTES_ATTR_FONT_SIZE: