canvas/source/vcl/canvas.cxx | 5 - canvas/source/vcl/canvasbitmap.cxx | 10 +- canvas/source/vcl/canvascustomsprite.cxx | 10 +- canvas/source/vcl/canvasfont.cxx | 10 +- canvas/source/vcl/spritecanvas.cxx | 4 canvas/source/vcl/spritecanvashelper.cxx | 18 +-- canvas/source/vcl/textlayout.cxx | 10 +- canvas/source/vcl/windowoutdevholder.cxx | 3 filter/source/svg/svgreader.cxx | 24 ++++ offapi/UnoApi_offapi.mk | 2 sax/inc/sax/tools/converter.hxx | 7 + sax/source/tools/converter.cxx | 22 ++++ svx/inc/svx/xflgrit.hxx | 5 - svx/source/xoutdev/xattr.cxx | 19 +++ xmloff/Library_xo.mk | 1 xmloff/Package_inc.mk | 1 xmloff/inc/xmloff/xmlstyle.hxx | 5 - xmloff/inc/xmloff/xmltoken.hxx | 7 + xmloff/source/core/xmltoken.cxx | 11 +- xmloff/source/style/FillStyleContext.cxx | 151 ++++++++++++++++++++++++++++++- xmloff/source/style/FillStyleContext.hxx | 67 +++++++++++++ xmloff/source/style/GradientStyle.cxx | 12 +- xmloff/source/style/xmlstyle.cxx | 5 + 23 files changed, 350 insertions(+), 59 deletions(-)
New commits: commit 58ae10ed582d845412210042db97a9c47a66a55b Author: Chr. Rossmanith <[email protected]> Date: Mon Jan 7 19:42:36 2013 +0100 RTL_CONSTASCII_(U)STRINGPARAM removed in canvas (WIP) Change-Id: Id8db06826b77a2b59df51dc0829cd9e7539045fa diff --git a/canvas/source/vcl/canvas.cxx b/canvas/source/vcl/canvas.cxx index 9cfb73a..4b59cef 100644 --- a/canvas/source/vcl/canvas.cxx +++ b/canvas/source/vcl/canvas.cxx @@ -101,8 +101,7 @@ namespace vclcanvas OutputDevice* pOutDev = reinterpret_cast<OutputDevice*>(nPtr); if( !pOutDev ) throw lang::NoSupportException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Passed OutDev invalid!")), + ::rtl::OUString( "Passed OutDev invalid!" ), NULL); OutDevProviderSharedPtr pOutdevProvider( new OutDevHolder(*pOutDev) ); @@ -134,7 +133,7 @@ namespace vclcanvas ::rtl::OUString SAL_CALL Canvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVAS_SERVICE_NAME ) ); + return ::rtl::OUString( CANVAS_SERVICE_NAME ); } bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf, diff --git a/canvas/source/vcl/canvasbitmap.cxx b/canvas/source/vcl/canvasbitmap.cxx index a943ba6..b941eb1 100644 --- a/canvas/source/vcl/canvasbitmap.cxx +++ b/canvas/source/vcl/canvasbitmap.cxx @@ -74,9 +74,9 @@ namespace vclcanvas #define IMPLEMENTATION_NAME "VCLCanvas.CanvasBitmap" #define SERVICE_NAME "com.sun.star.rendering.CanvasBitmap" - ::rtl::OUString SAL_CALL CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException) + OUString SAL_CALL CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + return OUString( IMPLEMENTATION_NAME ); } sal_Bool SAL_CALL CanvasBitmap::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException) @@ -84,10 +84,10 @@ namespace vclcanvas return ServiceName == SERVICE_NAME; } - uno::Sequence< ::rtl::OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException) + uno::Sequence< OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(1); - aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + uno::Sequence< OUString > aRet(1); + aRet[0] = OUString( SERVICE_NAME ); return aRet; } diff --git a/canvas/source/vcl/canvascustomsprite.cxx b/canvas/source/vcl/canvascustomsprite.cxx index f1cb72d..a452212 100644 --- a/canvas/source/vcl/canvascustomsprite.cxx +++ b/canvas/source/vcl/canvascustomsprite.cxx @@ -121,9 +121,9 @@ namespace vclcanvas #define IMPLEMENTATION_NAME "VCLCanvas.CanvasCustomSprite" #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite" - ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException ) + OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException ) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + return OUString( IMPLEMENTATION_NAME ); } sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) @@ -131,10 +131,10 @@ namespace vclcanvas return ServiceName == SERVICE_NAME; } - uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException ) + uno::Sequence< OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException ) { - uno::Sequence< ::rtl::OUString > aRet(1); - aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + uno::Sequence< OUString > aRet(1); + aRet[0] = OUString( SERVICE_NAME ); return aRet; } diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx index 12fe3094..8f422f7 100644 --- a/canvas/source/vcl/canvasfont.cxx +++ b/canvas/source/vcl/canvasfont.cxx @@ -153,9 +153,9 @@ namespace vclcanvas #define IMPLEMENTATION_NAME "VCLCanvas::CanvasFont" #define SERVICE_NAME "com.sun.star.rendering.CanvasFont" - ::rtl::OUString SAL_CALL CanvasFont::getImplementationName() throw( uno::RuntimeException ) + OUString SAL_CALL CanvasFont::getImplementationName() throw( uno::RuntimeException ) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + return OUString( IMPLEMENTATION_NAME ); } sal_Bool SAL_CALL CanvasFont::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) @@ -163,10 +163,10 @@ namespace vclcanvas return ServiceName == SERVICE_NAME; } - uno::Sequence< ::rtl::OUString > SAL_CALL CanvasFont::getSupportedServiceNames() throw( uno::RuntimeException ) + uno::Sequence< OUString > SAL_CALL CanvasFont::getSupportedServiceNames() throw( uno::RuntimeException ) { - uno::Sequence< ::rtl::OUString > aRet(1); - aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + uno::Sequence< OUString > aRet(1); + aRet[0] = OUString( SERVICE_NAME ); return aRet; } diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx index 2a950d6..c18a7f9 100644 --- a/canvas/source/vcl/spritecanvas.cxx +++ b/canvas/source/vcl/spritecanvas.cxx @@ -149,9 +149,9 @@ namespace vclcanvas mbSurfaceDirty); } - ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException) + OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SPRITECANVAS_SERVICE_NAME ) ); + return OUString( SPRITECANVAS_SERVICE_NAME ); } bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf, diff --git a/canvas/source/vcl/spritecanvashelper.cxx b/canvas/source/vcl/spritecanvashelper.cxx index 2f69d9d..dc66395 100644 --- a/canvas/source/vcl/spritecanvashelper.cxx +++ b/canvas/source/vcl/spritecanvashelper.cxx @@ -591,15 +591,15 @@ namespace vclcanvas const double denominator( maLastUpdate.getElapsedTime() ); maLastUpdate.reset(); - ::rtl::OUString text( ::rtl::math::doubleToUString( denominator == 0.0 ? 100.0 : 1.0/denominator, + OUString text( ::rtl::math::doubleToUString( denominator == 0.0 ? 100.0 : 1.0/denominator, rtl_math_StringFormat_F, 2,'.',NULL,' ') ); // pad with leading space while( text.getLength() < 6 ) - text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" ")) + text; + text = " " + text; - text += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" fps")); + text += " fps"; renderInfoText( rOutDev, text, @@ -648,9 +648,9 @@ namespace vclcanvas // pad with leading space while( text.getLength() < 3 ) - text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" ")) + text; + text = " " + text; - text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("Sprites: ")) + text; + text = "Sprites: " + text; renderInfoText( rOutDev, text, @@ -684,17 +684,15 @@ namespace vclcanvas rVDevSize.Width()*rVDevSize.Height() * BYTES_PER_PIXEL + rBackBufferSize.Width()*rBackBufferSize.Height() * BYTES_PER_PIXEL ); - ::rtl::OUString text( ::rtl::math::doubleToUString( nMemUsage / 1048576.0, + OUString text( ::rtl::math::doubleToUString( nMemUsage / 1048576.0, rtl_math_StringFormat_F, 2,'.',NULL,' ') ); // pad with leading space while( text.getLength() < 4 ) - text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" ")) + text; + text = " " + text; - text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("Mem: ")) + - text + - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("MB")); + text = "Mem: " + text + "MB"; renderInfoText( rOutDev, text, diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx index 4122d8a..72ede12 100644 --- a/canvas/source/vcl/textlayout.cxx +++ b/canvas/source/vcl/textlayout.cxx @@ -466,9 +466,9 @@ namespace vclcanvas #define IMPLEMENTATION_NAME "VCLCanvas::TextLayout" #define SERVICE_NAME "com.sun.star.rendering.TextLayout" - ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException ) + OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException ) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + return OUString( IMPLEMENTATION_NAME ); } sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) @@ -476,10 +476,10 @@ namespace vclcanvas return ServiceName == SERVICE_NAME; } - uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException ) + uno::Sequence< OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException ) { - uno::Sequence< ::rtl::OUString > aRet(1); - aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + uno::Sequence< OUString > aRet(1); + aRet[0] = OUString( SERVICE_NAME ); return aRet; } diff --git a/canvas/source/vcl/windowoutdevholder.cxx b/canvas/source/vcl/windowoutdevholder.cxx index e93900e..92f4e0e 100644 --- a/canvas/source/vcl/windowoutdevholder.cxx +++ b/canvas/source/vcl/windowoutdevholder.cxx @@ -34,8 +34,7 @@ namespace vclcanvas Window* pWindow = VCLUnoHelper::GetWindow(xWin); if( !pWindow ) throw lang::NoSupportException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Parent window not VCL window, or canvas out-of-process!")), + "Parent window not VCL window, or canvas out-of-process!", NULL); return *pWindow; } commit 6eb0522395c236ae6930a300992ad092449f9592 Author: Chr. Rossmanith <[email protected]> Date: Tue Jan 1 21:38:06 2013 +0100 dummy commit (WIP) Change-Id: Ibeee6553312323b75b2403ad6832595f228e0e3c diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx index 5e9e994..51a0860 100644 --- a/filter/source/svg/svgreader.cxx +++ b/filter/source/svg/svgreader.cxx @@ -179,7 +179,6 @@ struct AnnotatingVisitor case XML_LINEARGRADIENT: { const sal_Int32 nNumAttrs( xAttributes->getLength() ); - rtl::OUString sAttributeValue; maGradientVector.push_back(Gradient(Gradient::LINEAR)); // do we have a reference to a parent gradient? parse @@ -217,7 +216,6 @@ struct AnnotatingVisitor case XML_RADIALGRADIENT: { const sal_Int32 nNumAttrs( xAttributes->getLength() ); - rtl::OUString sAttributeValue; maGradientVector.push_back(Gradient(Gradient::RADIAL)); // do we have a reference to a parent gradient? parse @@ -255,7 +253,6 @@ struct AnnotatingVisitor case XML_STOP: { const sal_Int32 nNumAttrs( xAttributes->getLength() ); - rtl::OUString sAttributeValue; maGradientStopVector.push_back(GradientStop()); maGradientVector.back().maStops.push_back(maGradientStopVector.size()-1); for( sal_Int32 i=0; i<nNumAttrs; ++i ) @@ -518,7 +515,8 @@ struct AnnotatingVisitor double rRotate, rShearX; if( rState.maFillGradient.maTransform.decompose(rScale, rTranslate, rRotate, rShearX) ) xAttrs->AddAttribute( "draw:angle", - rtl::OUString::valueOf(rRotate*1800.0/M_PI ) ); + rtl::OUString::valueOf(rRotate*1800.0/M_PI + 900) ); + SAL_INFO("svg", "maStops " << rState.maFillGradient.maStops[0] << " " << rState.maFillGradient.maStops[1] ); xAttrs->AddAttribute( "draw:start-color", getOdfColor( maGradientStopVector[ @@ -813,6 +811,11 @@ struct AnnotatingVisitor const sal_Int32 nTokenId, const rtl::OUString& sValue ) { + rtl::OString aValueUtf8( sValue.getStr(), + sValue.getLength(), + RTL_TEXTENCODING_UTF8 ); + + SAL_INFO("svg", "nTokenId " << nTokenId); switch(nTokenId) { case XML_HREF: @@ -836,7 +839,18 @@ struct AnnotatingVisitor case XML_STYLE: parseStyle( sValue ); break; + case XML_STOP_COLOR: + parseColor( aValueUtf8.getStr(), io_rGradientStop.maStopColor ); + break; + case XML_STOP_OPACITY: + io_rGradientStop.maStopColor.a = sValue.toDouble(); + if (io_rGradientStop.maStopColor.a < 0) + io_rGradientStop.maStopColor.a = 0; + else if (io_rGradientStop.maStopColor.a > 1) + io_rGradientStop.maStopColor.a = 1; + break; default: + SAL_INFO("svg", "nTokenId unknown " << getTokenName(nTokenId)); break; } } @@ -1031,9 +1045,11 @@ struct AnnotatingVisitor parseTextAlign(maCurrState,aValueUtf8.getStr()); break; case XML_STOP_COLOR: + SAL_INFO("svg", "XML_STOP_COLOR1"); if( maGradientVector.empty() || maGradientVector.back().maStops.empty() ) break; + SAL_INFO("svg", "XML_STOP_COLOR2"); parseColor( aValueUtf8.getStr(), maGradientStopVector[ maGradientVector.back().maStops.back()].maStopColor ); diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 56e5f48..454b297 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -1642,7 +1642,9 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/awt,\ FontWeight \ FontWidth \ Gradient \ + SvgGradient \ GradientStyle \ + GradientSpread \ ImageAlign \ ImagePosition \ ImageScaleMode \ diff --git a/svx/inc/svx/xflgrit.hxx b/svx/inc/svx/xflgrit.hxx index b4318cf..62c04db 100644 --- a/svx/inc/svx/xflgrit.hxx +++ b/svx/inc/svx/xflgrit.hxx @@ -23,6 +23,7 @@ #include <svx/xit.hxx> #include <svx/xgrad.hxx> #include "svx/svxdllapi.h" +#include <com/sun/star/awt/SvgGradient.hpp> class SdrModel; @@ -31,8 +32,8 @@ class SdrModel; //------------------------ class SVX_DLLPUBLIC XFillGradientItem : public NameOrIndex { - XGradient aGradient; - + XGradient aGradient; + ::com::sun::star::awt::SvgGradient aSvgGradient; public: TYPEINFO(); XFillGradientItem() : NameOrIndex(XATTR_FILLGRADIENT, -1) {} diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index ce3f1de..097a34d 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -3443,6 +3443,7 @@ bool XFillGradientItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uI { if ( aPropSeq[n].Value >>= aGradient2 ) bGradient = true; + } } @@ -3483,11 +3484,19 @@ bool XFillGradientItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uI case MID_FILLGRADIENT: { ::com::sun::star::awt::Gradient aGradient2; - if(!(rVal >>= aGradient2)) - return false; + ::com::sun::star::awt::SvgGradient aSvgGradient2; + bool bIsSvgGradient(false); + + if( !(rVal >>= aGradient2) ) + { + if( !(rVal >>= aSvgGradient2) ) + return false; + bIsSvgGradient=true; + } XGradient aXGradient; + if ( !bIsSvgGradient ) { aXGradient.SetGradientStyle( (XGradientStyle) aGradient2.Style ); aXGradient.SetStartColor( aGradient2.StartColor ); aXGradient.SetEndColor( aGradient2.EndColor ); @@ -3498,7 +3507,11 @@ bool XFillGradientItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uI aXGradient.SetStartIntens( aGradient2.StartIntensity ); aXGradient.SetEndIntens( aGradient2.EndIntensity ); aXGradient.SetSteps( aGradient2.StepCount ); - + } + else { + aXGradient.SetStartColor( aSvgGradient2.StopColor[0] ); + aXGradient.SetEndColor( aSvgGradient2.StopColor[1] ); + } SetGradientValue( aXGradient ); break; } diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk index b816482..4b9e68d 100644 --- a/xmloff/Library_xo.mk +++ b/xmloff/Library_xo.mk @@ -196,6 +196,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\ xmloff/source/style/EnumPropertyHdl \ xmloff/source/style/FillStyleContext \ xmloff/source/style/GradientStyle \ + xmloff/source/style/SvgGradientStyle \ xmloff/source/style/HatchStyle \ xmloff/source/style/ImageStyle \ xmloff/source/style/MarkerStyle \ diff --git a/xmloff/Package_inc.mk b/xmloff/Package_inc.mk index 9b3628b..dd32430 100644 --- a/xmloff/Package_inc.mk +++ b/xmloff/Package_inc.mk @@ -22,6 +22,7 @@ $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/DashStyle.hxx,xmloff/Das $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/DocumentSettingsContext.hxx,xmloff/DocumentSettingsContext.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/EnumPropertyHdl.hxx,xmloff/EnumPropertyHdl.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/GradientStyle.hxx,xmloff/GradientStyle.hxx)) +$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/SvgGradientStyle.hxx,xmloff/SvgGradientStyle.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/HatchStyle.hxx,xmloff/HatchStyle.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/ImageStyle.hxx,xmloff/ImageStyle.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/MarkerStyle.hxx,xmloff/MarkerStyle.hxx)) diff --git a/xmloff/inc/xmloff/xmlstyle.hxx b/xmloff/inc/xmloff/xmlstyle.hxx index 8296b24..74c7b02 100644 --- a/xmloff/inc/xmloff/xmlstyle.hxx +++ b/xmloff/inc/xmloff/xmlstyle.hxx @@ -45,6 +45,7 @@ enum XMLStyleStylesElemTokens XML_TOK_TEXT_LIST_STYLE, XML_TOK_TEXT_OUTLINE, XML_TOK_STYLES_GRADIENTSTYLES, + XML_TOK_STYLES_LINEARGRADIENTSTYLES, XML_TOK_STYLES_HATCHSTYLES, XML_TOK_STYLES_BITMAPSTYLES, XML_TOK_STYLES_TRANSGRADIENTSTYLES, @@ -74,8 +75,8 @@ class XMLOFF_DLLPUBLIC SvXMLStyleContext : public SvXMLImportContext sal_Bool mbValid : 1; // Set this to false in CreateAndInsert // if the style shouldn't be processed - // by Finish() or si somehow invalid. - sal_Bool mbNew : 1; // Set this to false in CreateAnsInsert + // by Finish() or is somehow invalid. + sal_Bool mbNew : 1; // Set this to false in CreateAndInsert // if the style is already existing. sal_Bool mbDefaultStyle : 1; diff --git a/xmloff/source/style/FillStyleContext.cxx b/xmloff/source/style/FillStyleContext.cxx index 563da21..330573c 100644 --- a/xmloff/source/style/FillStyleContext.cxx +++ b/xmloff/source/style/FillStyleContext.cxx @@ -18,9 +18,11 @@ */ #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/awt/SvgGradient.hpp> #include "FillStyleContext.hxx" #include <xmloff/xmlimp.hxx> #include "xmloff/GradientStyle.hxx" +#include "xmloff/SvgGradientStyle.hxx" #include "xmloff/HatchStyle.hxx" #include "xmloff/ImageStyle.hxx" #include "TransGradientStyle.hxx" @@ -30,6 +32,8 @@ #include <xmloff/nmspmap.hxx> #include "xmloff/xmlnmspe.hxx" #include <xmloff/XMLBase64ImportContext.hxx> +#include <sax/tools/converter.hxx> +#include <comphelper/sequence.hxx> using namespace ::com::sun::star; using ::rtl::OUString; @@ -46,7 +50,6 @@ XMLGradientStyleContext::XMLGradientStyleContext( SvXMLImport& rImport, sal_uInt const uno::Reference< xml::sax::XAttributeList >& xAttrList) : SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList) { - // start import XMLGradientStyleImport aGradientStyle( GetImport() ); aGradientStyle.importXML( xAttrList, maAny, maStrName ); @@ -86,6 +89,152 @@ sal_Bool XMLGradientStyleContext::IsTransient() const ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +TYPEINIT1( XMLLinearGradientStyleContext, SvXMLStyleContext ); + +XMLLinearGradientStyleContext::XMLLinearGradientStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList) +: SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList) +{ + // start import + XMLSvgGradientStyleImport aGradientStyle( GetImport() ); + aGradientStyle.importXML( xAttrList, maAny, maStrName ); +} + +XMLLinearGradientStyleContext::~XMLLinearGradientStyleContext() +{ +} + + +SvXMLImportContext* XMLLinearGradientStyleContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +{ + if( (XML_NAMESPACE_SVG == nPrefix) && xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_STOP ) ) + { + return new XMLSvgGradientStopImportContext(GetImport(), + nPrefix, rLocalName, + *this); + } + else + { + return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); + } +} + +void XMLLinearGradientStyleContext::EndElement() +{ + uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() ); + + try + { + if(xGradient.is()) + { + if( xGradient->hasByName( maStrName ) ) + { + xGradient->replaceByName( maStrName, maAny ); + } + else + { + xGradient->insertByName( maStrName, maAny ); + } + } + } + catch( container::ElementExistException& ) + {} +} + +sal_Bool XMLLinearGradientStyleContext::IsTransient() const +{ + return sal_True; +} + +void XMLLinearGradientStyleContext::SetGradientStop( ::com::sun::star::util::Color aColor, double aOffset) +{ + mStopColors.push_back( aColor ); + mStopOffsets.push_back( aOffset ); +} + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +TYPEINIT1( XMLSvgGradientStopImportContext, SvXMLImportContext ); + +XMLSvgGradientStopImportContext::XMLSvgGradientStopImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, + const OUString& rLName, + XMLLinearGradientStyleContext& rGradientStyle) + : SvXMLImportContext(rImport, nPrfx, rLName), + rGradientStyleContext(rGradientStyle) +{ +} + +XMLSvgGradientStopImportContext::~XMLSvgGradientStopImportContext() +{ +} + +void XMLSvgGradientStopImportContext::StartElement( + const uno::Reference<xml::sax::XAttributeList> & xAttrList) +{ + sal_Int16 nLength = xAttrList->getLength(); + ::util::Color aColor; + OUString colorString("black"); + double opacity = 1; + double offset=0; + double nTmp; + + for(sal_Int16 i=0; i<nLength; i++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName ); + + if ( nPrefix == XML_NAMESPACE_SVG ) + { + if ( xmloff::token::IsXMLToken(sLocalName, xmloff::token::XML_OFFSET) ) + { + SAL_INFO("svg", "offset " << sLocalName << " " << xAttrList->getValueByIndex(i)); + OUString value = xAttrList->getValueByIndex( i ); + // using convertDouble instead of convertPercent because the latter expects sal_Int32& as its first arg + if ((value.indexOf( "%" ) != -1) && ::sax::Converter::convertDouble( nTmp, value )) + { + SAL_INFO("svg", "offset converted " << nTmp/100); + offset = nTmp * 0.01; + } + else if ( ::sax::Converter::convertDouble( nTmp, value ) ) { + SAL_INFO("svg", "offset converted " << nTmp); + offset = nTmp; + } + else + { + SAL_WARN("svg", "Could not convert gradient offset " << value); + } + } + else if ( xmloff::token::IsXMLToken(sLocalName, xmloff::token::XML_STOPCOLOR) ) + { + colorString = xAttrList->getValueByIndex(i); + SAL_INFO("svg", "stop color " << sLocalName << " " << xAttrList->getValueByIndex(i)); + } + else if ( xmloff::token::IsXMLToken(sLocalName, xmloff::token::XML_STOPOPACITY) ) + { + SAL_INFO("svg", "stop opacity " << sLocalName << " " << xAttrList->getValueByIndex(i)); + ::sax::Converter::convertDouble( nTmp, xAttrList->getValueByIndex(i) ); + opacity = nTmp; + } + } + } + bool bColorSet; + bColorSet = ::sax::Converter::convertColor( aColor, colorString, opacity ); + rGradientStyleContext.SetGradientStop( aColor, offset ); +} + +void XMLSvgGradientStopImportContext::EndElement() +{ + // uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() ); + + SAL_INFO("svgb", "EndElement"); +} + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + TYPEINIT1( XMLHatchStyleContext, SvXMLStyleContext ); XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx, diff --git a/xmloff/source/style/FillStyleContext.hxx b/xmloff/source/style/FillStyleContext.hxx index b8d1d79..f90c100 100644 --- a/xmloff/source/style/FillStyleContext.hxx +++ b/xmloff/source/style/FillStyleContext.hxx @@ -21,11 +21,12 @@ #define _XMLOFF_FILLSTYLECONTEXTS_HXX_ #include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/util/Color.hpp> #include <xmloff/xmlstyle.hxx> -#include<rtl/ustring.hxx> +#include <rtl/ustring.hxx> ////////////////////////////////////////////////////////////////////////////// -// draw:gardient context +// draw:gradient context class XMLGradientStyleContext: public SvXMLStyleContext { @@ -46,6 +47,68 @@ public: }; ////////////////////////////////////////////////////////////////////////////// +// svg:linearGradient context +class XMLLinearGradientStyleContext: public SvXMLStyleContext +{ +private: + ::com::sun::star::uno::Any maAny; + rtl::OUString maStrName; + ::std::vector< ::com::sun::star::util::Color > mStopColors; + ::std::vector< double > mStopOffsets; + +public: + TYPEINFO(); + + XMLLinearGradientStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, + const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XAttributeList> & xAttrList ); + virtual ~XMLLinearGradientStyleContext(); + + virtual void EndElement(); + + virtual sal_Bool IsTransient() const; + + void SetGradientStop( ::com::sun::star::util::Color aColor, double aOffset); + +protected: + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList ); +}; + +////////////////////////////////////////////////////////////////////////////// +// import svg:stop elements +class XMLSvgGradientStopImportContext : public SvXMLImportContext +{ + XMLLinearGradientStyleContext& rGradientStyleContext; + +private: + ::com::sun::star::uno::Any maAny; + +public: + + TYPEINFO(); + + XMLSvgGradientStopImportContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName, + XMLLinearGradientStyleContext& rGradientStyle); + + ~XMLSvgGradientStopImportContext(); + +protected: + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + virtual void EndElement(); +}; + +////////////////////////////////////////////////////////////////////////////// // draw:hatch context class XMLHatchStyleContext: public SvXMLStyleContext diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx index eb432e7..0be3650 100644 --- a/xmloff/source/style/GradientStyle.cxx +++ b/xmloff/source/style/GradientStyle.cxx @@ -90,6 +90,8 @@ sal_Bool XMLGradientStyleImport::importXML( uno::Any& rValue, OUString& rStrName ) { + SAL_INFO ("svg", "importXML"); + sal_Bool bRet = sal_False; sal_Bool bHasName = sal_False; sal_Bool bHasStyle = sal_False; @@ -107,7 +109,7 @@ sal_Bool XMLGradientStyleImport::importXML( { static SvXMLTokenMapEntry aGradientAttrTokenMap[] = -{ + { { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_GRADIENT_NAME }, { XML_NAMESPACE_DRAW, XML_DISPLAY_NAME, XML_TOK_GRADIENT_DISPLAY_NAME }, { XML_NAMESPACE_DRAW, XML_STYLE, XML_TOK_GRADIENT_STYLE }, @@ -126,13 +128,14 @@ sal_Bool XMLGradientStyleImport::importXML( SvXMLNamespaceMap& rNamespaceMap = rImport.GetNamespaceMap(); sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + SAL_INFO ("svg", "nAttrCount " << nAttrCount); for( sal_Int16 i=0; i < nAttrCount; i++ ) { const OUString& rFullAttrName = xAttrList->getNameByIndex( i ); OUString aStrAttrName; sal_uInt16 nPrefix = rNamespaceMap.GetKeyByAttrName( rFullAttrName, &aStrAttrName ); const OUString& rStrValue = xAttrList->getValueByIndex( i ); - + SAL_INFO ("svg", "FullAttrName: " << rFullAttrName << " rStrValue: " << rStrValue << " aStrAttrName: " << aStrAttrName); sal_Int32 nTmpValue; switch( aTokenMap.Get( nPrefix, aStrAttrName ) ) @@ -199,8 +202,8 @@ sal_Bool XMLGradientStyleImport::importXML( break; default: - DBG_WARNING( "Unknown token at import gradient style" ) - ; + SAL_INFO("svg", "Unknown token at import gradient style"); + DBG_WARNING( "Unknown token at import gradient style" ); } } @@ -242,6 +245,7 @@ sal_Bool XMLGradientStyleExport::exportXML( sal_Bool bRet = sal_False; awt::Gradient aGradient; + if( !rStrName.isEmpty() ) { if( rValue >>= aGradient ) diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index b69f3f6..da698c0 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -490,6 +490,11 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( sal_uInt16 p_nPr pStyle = new XMLGradientStyleContext( GetImport(), p_nPrefix, rLocalName, xAttrList ); break; } + case XML_TOK_STYLES_LINEARGRADIENTSTYLES: + { + pStyle = new XMLLinearGradientStyleContext( GetImport(), p_nPrefix, rLocalName, xAttrList ); + break; + } case XML_TOK_STYLES_HATCHSTYLES: { pStyle = new XMLHatchStyleContext( GetImport(), p_nPrefix, rLocalName, xAttrList ); commit f1043aaed082824ca423eee10be5802873e058f3 Author: Chr. Rossmanith <[email protected]> Date: Fri Nov 30 22:10:37 2012 +0100 added token for handling of svg:linearGradient and svg:radialGradient Change-Id: I38014a8d9e21359cb943f813484478293360a2e6 diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 6559b45..41acb78 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -878,6 +878,8 @@ namespace xmloff { namespace token { XML_FULL, XML_FULL_SCREEN, XML_FUNCTION, + XML_FX, + XML_FY, XML_G, XML_GAMMA, XML_GAP, @@ -897,6 +899,7 @@ namespace xmloff { namespace token { XML_GRADIENTSTYLE_RADIAL, XML_GRADIENTSTYLE_RECTANGULAR, XML_GRADIENTSTYLE_SQUARE, + XML_GRADIENTTRANSFORM, XML_GRAND_TOTAL, XML_GRAPHIC, XML_GRAY, @@ -1666,6 +1669,7 @@ namespace xmloff { namespace token { XML_SPLIT_POSITION, XML_SPLIT_ROW, XML_SPREADSHEET, + XML_SPREADMETHOD, XML_SQL_STATEMENT, XML_STACKED, XML_STAGGER_EVEN, @@ -1701,6 +1705,8 @@ namespace xmloff { namespace token { XML_STOCK_UPDOWN_BARS, XML_STOCK_WITH_VOLUME, XML_STOP, + XML_STOPCOLOR, + XML_STOPOPACITY, XML_STRETCH, XML_STRETCH_FROM_BOTTOM, XML_STRETCH_FROM_LEFT, @@ -1734,6 +1740,7 @@ namespace xmloff { namespace token { XML_SUBTOTAL_RULES, XML_SUFFIX, XML_SUM, + XML_SVGLINEARGRADIENT, XML_SWISS, XML_SYMBOL, XML_SYMBOL_HEIGHT, diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 975349d..d7ebd2f 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -882,6 +882,8 @@ namespace xmloff { namespace token { TOKEN( "full", XML_FULL ), TOKEN( "full-screen", XML_FULL_SCREEN ), TOKEN( "function", XML_FUNCTION ), + TOKEN( "fx", XML_FX ), + TOKEN( "fy", XML_FY ), TOKEN( "g", XML_G ), TOKEN( "gamma", XML_GAMMA ), TOKEN( "gap", XML_GAP ), @@ -901,6 +903,7 @@ namespace xmloff { namespace token { TOKEN( "radial", XML_GRADIENTSTYLE_RADIAL ), TOKEN( "rectangular", XML_GRADIENTSTYLE_RECTANGULAR ), TOKEN( "square", XML_GRADIENTSTYLE_SQUARE ), + TOKEN( "gradientTransform", XML_GRADIENTTRANSFORM ), TOKEN( "grand-total", XML_GRAND_TOTAL ), TOKEN( "graphic", XML_GRAPHIC ), TOKEN( "gray", XML_GRAY ), @@ -1671,6 +1674,7 @@ namespace xmloff { namespace token { TOKEN( "split-position", XML_SPLIT_POSITION ), TOKEN( "split-row", XML_SPLIT_ROW ), TOKEN( "spreadsheet", XML_SPREADSHEET ), + TOKEN( "spreadMethod", XML_SPREADMETHOD ), TOKEN( "sql-statement", XML_SQL_STATEMENT ), TOKEN( "stacked", XML_STACKED ), TOKEN( "stagger-even", XML_STAGGER_EVEN ), @@ -1706,6 +1710,8 @@ namespace xmloff { namespace token { TOKEN( "stock-updown-bars", XML_STOCK_UPDOWN_BARS ), TOKEN( "stock-with-volume", XML_STOCK_WITH_VOLUME ), TOKEN( "stop", XML_STOP ), + TOKEN( "stop-color", XML_STOPCOLOR ), + TOKEN( "stop-opacity", XML_STOPOPACITY ), TOKEN( "stretch", XML_STRETCH ), TOKEN( "stretch-from-bottom", XML_STRETCH_FROM_BOTTOM ), TOKEN( "stretch-from-left", XML_STRETCH_FROM_LEFT ), @@ -1739,6 +1745,7 @@ namespace xmloff { namespace token { TOKEN( "subtotal-rules", XML_SUBTOTAL_RULES ), TOKEN( "suffix", XML_SUFFIX ), TOKEN( "sum", XML_SUM ), + TOKEN( "linearGradient", XML_SVGLINEARGRADIENT ), TOKEN( "swiss", XML_SWISS ), TOKEN( "symbol", XML_SYMBOL ), TOKEN( "symbol-height", XML_SYMBOL_HEIGHT ), @@ -3194,8 +3201,8 @@ namespace xmloff { namespace token { XMLTokenEntry* pToken = &aTokenList[(sal_uInt16)eToken]; if (!pToken->pOUString) - pToken->pOUString = new OUString( pToken->pChar, pToken->nLength, - RTL_TEXTENCODING_ASCII_US ); + pToken->pOUString = new OUString( pToken->pChar, pToken->nLength, + RTL_TEXTENCODING_ASCII_US ); return *pToken->pOUString; } commit b3a1909a792956ce3a6ab52675017304969d7a66 Author: Chr. Rossmanith <[email protected]> Date: Fri Nov 30 22:03:16 2012 +0100 added Converter::convertColor with opacity parameter Change-Id: I0f3759d8f75f2739b2815c37e8c81bc97e097ec8 diff --git a/sax/inc/sax/tools/converter.hxx b/sax/inc/sax/tools/converter.hxx index 601ce6c..8b84feb 100644 --- a/sax/inc/sax/tools/converter.hxx +++ b/sax/inc/sax/tools/converter.hxx @@ -95,10 +95,15 @@ public: static void convertMeasurePx( ::rtl::OUStringBuffer& rBuffer, sal_Int32 nValue ); - /** convert string to color */ + /** convert string to rgb color */ static bool convertColor( sal_Int32& rColor, const ::rtl::OUString&rValue ); + /** convert string to argb color */ + static bool convertColor( sal_Int32& rColor, + const ::rtl::OUString&rValue, + const double alpha); + /** convert color to string */ static void convertColor( ::rtl::OUStringBuffer &rBuffer, sal_Int32 nColor ); diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index 78dd22b..e7fff9a 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -478,7 +478,7 @@ int lcl_gethex( int nChar ) return 0; } -/** convert string to color */ +/** convert string to rgb color */ bool Converter::convertColor( sal_Int32& rColor, const OUString& rValue ) { if( rValue.getLength() != 7 || rValue[0] != '#' ) @@ -495,6 +495,26 @@ bool Converter::convertColor( sal_Int32& rColor, const OUString& rValue ) return true; } +/** convert string to rgba color */ +bool Converter::convertColor( sal_Int32& rColor, const OUString& rValue, const double alpha) +{ + if( rValue.getLength() != 7 || rValue[0] != '#' ) + return false; + + rColor = (int) (alpha * 255); + rColor <<= 8; + + rColor |= lcl_gethex( rValue[1] ) * 16 + lcl_gethex( rValue[2] ); + rColor <<= 8; + + rColor |= ( lcl_gethex( rValue[3] ) * 16 + lcl_gethex( rValue[4] ) ); + rColor <<= 8; + + rColor |= ( lcl_gethex( rValue[5] ) * 16 + lcl_gethex( rValue[6] ) ); + + return true; +} + static sal_Char aHexTab[] = "0123456789abcdef"; /** convert color to string */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
