add some color conversion methods to sax::Converter
to make the call-sites less verbose Change-Id: Ifddcbb03a454a241bef93f31a8025801b84a66fc Reviewed-on: https://gerrit.libreoffice.org/50578 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <com/sun/star/uno/Sequence.h>
|
||||
#include <com/sun/star/util/MeasureUnit.hpp>
|
||||
#include <tools/color.hxx>
|
||||
|
||||
|
||||
namespace com { namespace sun { namespace star {
|
||||
@@ -97,10 +98,21 @@ public:
|
||||
/** convert string to rgb color */
|
||||
static bool convertColor( sal_Int32& rColor,
|
||||
const OUString&rValue );
|
||||
static bool convertColor( ::Color& rColor,
|
||||
const OUString&rValue )
|
||||
{
|
||||
sal_Int32 n(rColor);
|
||||
bool b = convertColor( n, rValue );
|
||||
if (b) rColor = n;
|
||||
return b;
|
||||
}
|
||||
|
||||
/** convert color to string */
|
||||
static void convertColor( OUStringBuffer &rBuffer,
|
||||
sal_Int32 nColor );
|
||||
static void convertColor( OUStringBuffer &rBuffer,
|
||||
::Color nColor )
|
||||
{ convertColor( rBuffer, sal_Int32(nColor) ); }
|
||||
|
||||
/** convert string to number with optional min and max values */
|
||||
static bool convertNumber( sal_Int32& rValue,
|
||||
|
||||
@@ -23,6 +23,7 @@ $(eval $(call gb_Library_use_libraries,sax,\
|
||||
cppu \
|
||||
cppuhelper \
|
||||
sal \
|
||||
tl \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_add_defs,sax,\
|
||||
|
||||
@@ -457,15 +457,13 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport,
|
||||
|
||||
if(!sPositiveColor.isEmpty())
|
||||
{
|
||||
sal_Int32 nColor = 0;
|
||||
sax::Converter::convertColor( nColor, sPositiveColor );
|
||||
mpFormatData->maPositiveColor = Color(nColor);
|
||||
sax::Converter::convertColor( mpFormatData->maPositiveColor, sPositiveColor );
|
||||
}
|
||||
|
||||
if(!sNegativeColor.isEmpty())
|
||||
{
|
||||
// we might check here for 0xff0000 and don't write it
|
||||
sal_Int32 nColor = 0;
|
||||
Color nColor;
|
||||
sax::Converter::convertColor( nColor, sNegativeColor );
|
||||
mpFormatData->mpNegativeColor.reset(new Color(nColor));
|
||||
}
|
||||
@@ -482,9 +480,7 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport,
|
||||
|
||||
if(!sAxisColor.isEmpty())
|
||||
{
|
||||
sal_Int32 nColor = 0;
|
||||
sax::Converter::convertColor( nColor, sAxisColor );
|
||||
mpFormatData->maAxisColor = Color(nColor);
|
||||
sax::Converter::convertColor( mpFormatData->maAxisColor, sAxisColor );
|
||||
}
|
||||
|
||||
if(!sShowValue.isEmpty())
|
||||
@@ -889,9 +885,7 @@ ScXMLColorScaleFormatEntryContext::ScXMLColorScaleFormatEntryContext( ScXMLImpor
|
||||
}
|
||||
}
|
||||
|
||||
sal_Int32 nColor;
|
||||
sax::Converter::convertColor(nColor, sColor);
|
||||
aColor = Color(nColor);
|
||||
sax::Converter::convertColor(aColor, sColor);
|
||||
|
||||
if(!sVal.isEmpty())
|
||||
sax::Converter::convertDouble(nVal, sVal);
|
||||
|
||||
@@ -3971,7 +3971,7 @@ void ScXMLExport::WriteScenario()
|
||||
if (!(nFlags & ScScenarioFlags::ShowFrame))
|
||||
AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_BORDER, XML_FALSE);
|
||||
OUStringBuffer aBuffer;
|
||||
::sax::Converter::convertColor(aBuffer, aColor.GetColor());
|
||||
::sax::Converter::convertColor(aBuffer, aColor);
|
||||
AddAttribute(XML_NAMESPACE_TABLE, XML_BORDER_COLOR, aBuffer.makeStringAndClear());
|
||||
if (!(nFlags & ScScenarioFlags::TwoWay))
|
||||
AddAttribute(XML_NAMESPACE_TABLE, XML_COPY_BACK, XML_FALSE);
|
||||
@@ -4426,7 +4426,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
|
||||
|
||||
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*it[0]));
|
||||
OUStringBuffer aBuffer;
|
||||
::sax::Converter::convertColor(aBuffer, it[0]->GetColor().GetColor());
|
||||
::sax::Converter::convertColor(aBuffer, it[0]->GetColor());
|
||||
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLOR, aBuffer.makeStringAndClear());
|
||||
SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE_ENTRY, true, true);
|
||||
}
|
||||
@@ -4450,13 +4450,13 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
|
||||
if(pFormatData->mpNegativeColor)
|
||||
{
|
||||
OUStringBuffer aBuffer;
|
||||
::sax::Converter::convertColor(aBuffer, pFormatData->mpNegativeColor->GetColor());
|
||||
::sax::Converter::convertColor(aBuffer, *pFormatData->mpNegativeColor);
|
||||
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_NEGATIVE_COLOR, aBuffer.makeStringAndClear());
|
||||
}
|
||||
else
|
||||
{
|
||||
OUStringBuffer aBuffer;
|
||||
::sax::Converter::convertColor(aBuffer, sal_Int32(COL_LIGHTRED));
|
||||
::sax::Converter::convertColor(aBuffer, COL_LIGHTRED);
|
||||
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_NEGATIVE_COLOR, aBuffer.makeStringAndClear());
|
||||
}
|
||||
}
|
||||
@@ -4474,11 +4474,11 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
|
||||
}
|
||||
|
||||
OUStringBuffer aBuffer;
|
||||
::sax::Converter::convertColor(aBuffer, pFormatData->maPositiveColor.GetColor());
|
||||
::sax::Converter::convertColor(aBuffer, pFormatData->maPositiveColor);
|
||||
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_POSITIVE_COLOR, aBuffer.makeStringAndClear());
|
||||
|
||||
aBuffer.truncate();
|
||||
::sax::Converter::convertColor(aBuffer, pFormatData->maAxisColor.GetColor());
|
||||
::sax::Converter::convertColor(aBuffer, pFormatData->maAxisColor);
|
||||
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_AXIS_COLOR, aBuffer.makeStringAndClear());
|
||||
SvXMLElementExport aElementDataBar(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, true, true);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ VCL_BUILDER_FACTORY_ARGS(HexColorControl, WB_BORDER)
|
||||
void HexColorControl::SetColor(Color nColor)
|
||||
{
|
||||
OUStringBuffer aBuffer;
|
||||
sax::Converter::convertColor(aBuffer, sal_Int32(nColor));
|
||||
sax::Converter::convertColor(aBuffer, nColor);
|
||||
SetText(aBuffer.makeStringAndClear().copy(1));
|
||||
}
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ bool SvXMLExportItemMapper::QueryXMLValue(
|
||||
nX *= pShadow->GetWidth();
|
||||
nY *= pShadow->GetWidth();
|
||||
|
||||
::sax::Converter::convertColor(aOut, pShadow->GetColor().GetColor());
|
||||
::sax::Converter::convertColor(aOut, pShadow->GetColor());
|
||||
aOut.append( ' ' );
|
||||
rUnitConverter.convertMeasureToXML( aOut, nX );
|
||||
aOut.append( ' ' );
|
||||
@@ -774,7 +774,7 @@ bool SvXMLExportItemMapper::QueryXMLValue(
|
||||
aOut.append( GetXMLToken( eStyle ) );
|
||||
aOut.append( ' ' );
|
||||
::sax::Converter::convertColor(aOut,
|
||||
pLine->GetColor().GetColor());
|
||||
pLine->GetColor());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -349,7 +349,7 @@ void SvXMLNumFmtExport::WriteColorElement_Impl( const Color& rColor )
|
||||
FinishTextElement_Impl();
|
||||
|
||||
OUStringBuffer aColStr( 7 );
|
||||
::sax::Converter::convertColor( aColStr, rColor.GetColor() );
|
||||
::sax::Converter::convertColor( aColStr, rColor );
|
||||
rExport.AddAttribute( XML_NAMESPACE_FO, XML_COLOR,
|
||||
aColStr.makeStringAndClear() );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user