[Libreoffice-commits] core.git: include/sax sax/Library_sax.mk sc/source svx/source sw/source xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Mar 6 05:51:23 UTC 2018


 include/sax/tools/converter.hxx        |   12 ++++++++++++
 sax/Library_sax.mk                     |    1 +
 sc/source/filter/xml/xmlcondformat.cxx |   14 ++++----------
 sc/source/filter/xml/xmlexprt.cxx      |   12 ++++++------
 svx/source/dialog/hexcolorcontrol.cxx  |    2 +-
 sw/source/filter/xml/xmlexpit.cxx      |    4 ++--
 xmloff/source/style/xmlnumfe.cxx       |    2 +-
 7 files changed, 27 insertions(+), 20 deletions(-)

New commits:
commit ffee771f8dae50aea716ffc0def4ef5fe5c104d2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Mar 1 16:14:23 2018 +0200

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sax/tools/converter.hxx b/include/sax/tools/converter.hxx
index 2dfc33461919..c7fe12f4c100 100644
--- a/include/sax/tools/converter.hxx
+++ b/include/sax/tools/converter.hxx
@@ -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,
diff --git a/sax/Library_sax.mk b/sax/Library_sax.mk
index d4149d382b66..6ef11645f6f3 100644
--- a/sax/Library_sax.mk
+++ b/sax/Library_sax.mk
@@ -23,6 +23,7 @@ $(eval $(call gb_Library_use_libraries,sax,\
 	cppu \
 	cppuhelper \
 	sal \
+	tl \
 ))
 
 $(eval $(call gb_Library_add_defs,sax,\
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index be215df81d72..3db4904f99ca 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -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);
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index d41bc3ba2b5a..baf55bb3213e 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -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);
 
diff --git a/svx/source/dialog/hexcolorcontrol.cxx b/svx/source/dialog/hexcolorcontrol.cxx
index 69032b1551fe..61d38bdeb619 100644
--- a/svx/source/dialog/hexcolorcontrol.cxx
+++ b/svx/source/dialog/hexcolorcontrol.cxx
@@ -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));
 }
 
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index 7d7830b09ccb..c4234435ada5 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -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
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index cc7dc555a106..99366b9800fc 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -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() );
 


More information about the Libreoffice-commits mailing list