diff options
-rw-r--r-- | filter/inc/filter/msfilter/util.hxx | 4 | ||||
-rw-r--r-- | filter/source/msfilter/rtfutil.cxx | 1 | ||||
-rw-r--r-- | filter/source/msfilter/util.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 41 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsdrimport.cxx | 24 |
5 files changed, 35 insertions, 54 deletions
diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx index 110429551bba..c3b56883e5ba 100644 --- a/filter/inc/filter/msfilter/util.hxx +++ b/filter/inc/filter/msfilter/util.hxx @@ -31,6 +31,7 @@ #include <rtl/textenc.h> #include <tools/datetime.hxx> +#include <tools/color.hxx> #include <com/sun/star/lang/Locale.hpp> #include "filter/msfilter/msfilterdllapi.h" @@ -88,6 +89,9 @@ enum TextCategory */ MSFILTER_DLLPUBLIC TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47LanguageTag); +/// Converts tools Color to HTML color (without leading hashmark). +MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor ); + } } diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx index 3e2dfb0fbf85..050a2f206ccf 100644 --- a/filter/source/msfilter/rtfutil.cxx +++ b/filter/source/msfilter/rtfutil.cxx @@ -181,7 +181,6 @@ OString OutStringUpr(const sal_Char *pToken, const String &rStr, rtl_TextEncodin aRet.append("}}}"); return aRet.makeStringAndClear(); } - } } diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index ca111203543e..3fec6daafd95 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -306,6 +306,25 @@ TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47Lan return eRet; } +OString ConvertColor( const Color &rColor ) +{ + OString color( "auto" ); + if ( rColor.GetColor() != COL_AUTO ) + { + const char pHexDigits[] = "0123456789ABCDEF"; + char pBuffer[] = "000000"; + + pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ]; + pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ]; + pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ]; + pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ]; + pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ]; + pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ]; + + color = OString( pBuffer ); + } + return color; +} } } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5f5934f156ca..86058dd68883 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -191,7 +191,6 @@ class FieldMarkParamsHelper return bResult; } }; -static OString impl_ConvertColor( const Color &rColor ); void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ ) { if (bIsRTL) @@ -276,7 +275,7 @@ void lcl_TextFrameShadow(FSHelperPtr pSerializer, const SwFrmFmt& rFrmFmt) if (aOffset.isEmpty()) return; - OString aShadowColor = impl_ConvertColor(aShadowItem.GetColor()); + OString aShadowColor = msfilter::util::ConvertColor(aShadowItem.GetColor()); pSerializer->singleElementNS(XML_v, XML_shadow, XML_on, "t", XML_color, "#" + aShadowColor, @@ -1400,26 +1399,6 @@ void DocxAttributeOutput::ParagraphStyle( sal_uInt16 nStyle ) m_pSerializer->singleElementNS( XML_w, XML_pStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND ); } -static OString impl_ConvertColor( const Color &rColor ) -{ - OString color( "auto" ); - if ( rColor.GetColor() != COL_AUTO ) - { - const char pHexDigits[] = "0123456789ABCDEF"; - char pBuffer[] = "000000"; - - pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ]; - pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ]; - pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ]; - pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ]; - pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ]; - pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ]; - - color = OString( pBuffer ); - } - return color; -} - static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, const SvxBorderLine* pBorderLine, sal_uInt16 nDist ) { FastAttributeList* pAttr = pSerializer->createAttrList(); @@ -1512,7 +1491,7 @@ static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, co pAttr->add( FSNS( XML_w, XML_space ), OString::valueOf( sal_Int32( nDist / 20 ) ) ); // Get the color code as an RRGGBB hex value - OString sColor( impl_ConvertColor( pBorderLine->GetColor( ) ) ); + OString sColor( msfilter::util::ConvertColor( pBorderLine->GetColor( ) ) ); pAttr->add( FSNS( XML_w, XML_color ), sColor ); } @@ -1932,7 +1911,7 @@ void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_ else aColor = COL_AUTO; - OString sColor = impl_ConvertColor( aColor ); + OString sColor = msfilter::util::ConvertColor( aColor ); m_pSerializer->singleElementNS( XML_w, XML_shd, FSNS( XML_w, XML_fill ), sColor.getStr( ), FSNS( XML_w, XML_val ), "clear", @@ -2397,7 +2376,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size // Distance is measured diagonally from corner double nShadowDist = sqrt((aShadowItem.GetWidth()*aShadowItem.GetWidth())*2.0); OString aShadowDist( OString::valueOf( TwipsToEMU( nShadowDist ) ) ); - OString aShadowColor = impl_ConvertColor( aShadowItem.GetColor() ); + OString aShadowColor = msfilter::util::ConvertColor( aShadowItem.GetColor() ); sal_uInt32 nShadowDir = 0; switch ( aShadowItem.GetLocation() ) { @@ -3356,7 +3335,7 @@ void DocxAttributeOutput::CharColor( const SvxColorItem& rColor ) const Color aColor( rColor.GetValue() ); OString aColorString; - aColorString = impl_ConvertColor( aColor ); + aColorString = msfilter::util::ConvertColor( aColor ); m_pSerializer->singleElementNS( XML_w, XML_color, FSNS( XML_w, XML_val ), aColorString.getStr(), FSEND ); @@ -3553,7 +3532,7 @@ void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink ) void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush ) { m_pSerializer->singleElementNS( XML_w, XML_shd, - FSNS( XML_w, XML_fill ), impl_ConvertColor( rBrush.GetColor() ).getStr(), + FSNS( XML_w, XML_fill ), msfilter::util::ConvertColor( rBrush.GetColor() ).getStr(), FSNS( XML_w, XML_val ), "clear", FSEND ); } @@ -4623,7 +4602,7 @@ void DocxAttributeOutput::FormatAnchor( const SwFmtAnchor& ) void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) { - OString sColor = impl_ConvertColor( rBrush.GetColor( ) ); + OString sColor = msfilter::util::ConvertColor( rBrush.GetColor( ) ); if (m_bTextFrameSyntax) m_pFlyAttrList->add(XML_fillcolor, "#" + sColor); else if ( !m_rExport.bOutPageDescs ) @@ -4648,9 +4627,9 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad m_pFlyFillAttrList->add(XML_type, "gradient"); const XGradient& rGradient = rFillGradient.GetGradientValue(); - OString sStartColor = impl_ConvertColor(rGradient.GetStartColor()); + OString sStartColor = msfilter::util::ConvertColor(rGradient.GetStartColor()); m_pFlyFillAttrList->add(XML_color2, "#" + sStartColor); - OString sEndColor = impl_ConvertColor(rGradient.GetEndColor()); + OString sEndColor = msfilter::util::ConvertColor(rGradient.GetEndColor()); m_pFlyAttrList->add(XML_fillcolor, "#" + sEndColor); switch (rGradient.GetGradientStyle()) @@ -4679,7 +4658,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) if (pLeft && pRight && pTop && pBottom && *pLeft == *pRight && *pLeft == *pTop && *pLeft == *pBottom) { - OString sColor("#" + impl_ConvertColor(pTop->GetColor())); + OString sColor("#" + msfilter::util::ConvertColor(pTop->GetColor())); m_pFlyAttrList->add(XML_strokecolor, sColor); double const fConverted(editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), pTop->GetWidth())); diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index a85cb500fe4f..b0399f601225 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -121,26 +121,6 @@ void RTFSdrImport::resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet xPropertySet->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE)); } -static OString impl_ConvertColor( const Color &rColor ) -{ - OString color( "auto" ); - if ( rColor.GetColor() != COL_AUTO ) - { - const char pHexDigits[] = "0123456789ABCDEF"; - char pBuffer[] = "000000"; - - pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ]; - pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ]; - pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ]; - pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ]; - pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ]; - pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ]; - - color = OString( pBuffer ); - } - return color; -} - void RTFSdrImport::resolve(RTFShape& rShape) { int nType = -1; @@ -224,13 +204,13 @@ void RTFSdrImport::resolve(RTFShape& rShape) xPropertySet->setPropertyValue("FillColor", aAny); // fillType will decide, possible it'll be the start color of a gradient. - aFillModel.moColor.set(OUString("#") + OStringToOUString(impl_ConvertColor(aAny.get<sal_Int32>()), RTL_TEXTENCODING_UTF8)); + aFillModel.moColor.set(OUString("#") + OStringToOUString(msfilter::util::ConvertColor(aAny.get<sal_Int32>()), RTL_TEXTENCODING_UTF8)); xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(0))); } else if ( i->first == "fillBackColor" ) // fillType will decide, possible it'll be the end color of a gradient. - aFillModel.moColor2.set(OUString("#") + OStringToOUString(impl_ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32())), RTL_TEXTENCODING_UTF8)); + aFillModel.moColor2.set(OUString("#") + OStringToOUString(msfilter::util::ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32())), RTL_TEXTENCODING_UTF8)); else if (i->first == "lineColor") aLineColor <<= msfilter::util::BGRToRGB(i->second.toInt32()); else if ( i->first == "lineBackColor" ) |