diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-03-05 17:12:01 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-03-07 02:38:03 +0100 |
commit | 5a4d6162f643050faf00ccf08d58feed00dcd781 (patch) | |
tree | 8fac088a8a5ebdf3f39fd87d727854d1a7662e92 /chart2/source | |
parent | d72145f9307c732ced4a546ac1e5093ec7c1a982 (diff) |
convert SymbolBitmapURL to SymbolBitmap used in chart2
Change-Id: Ib35ee5b5890ff5ca30796fc8608f00ff4b6b03e2
Reviewed-on: https://gerrit.libreoffice.org/50788
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx | 76 |
2 files changed, 27 insertions, 51 deletions
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index 36619d12417c..dec06433ac9a 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -590,7 +590,7 @@ beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OU beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); try { - if (rPropertyName == "SymbolBitmapURL") + if (rPropertyName == "SymbolBitmap") { uno::Any aAny = WrappedPropertySet::getPropertyValue("SymbolType"); sal_Int32 nVal = css::chart::ChartSymbolType::NONE; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 0547222017c8..ec84b1f869ad 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -61,13 +61,13 @@ public: tSeriesOrDiagramPropertyType ePropertyType); }; -class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty< OUString > +class WrappedSymbolBitmapProperty : public WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>> { public: - virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; - virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewGraphicURL ) const override; + virtual uno::Reference<graphic::XGraphic> getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override; + virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, uno::Reference<graphic::XGraphic> const & aNewGraphicURL) const override; - explicit WrappedSymbolBitmapURLProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, + explicit WrappedSymbolBitmapProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType); }; @@ -99,7 +99,7 @@ enum { //symbol properties PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP, - PROP_CHART_SYMBOL_BITMAP_URL, + PROP_CHART_SYMBOL_BITMAP, PROP_CHART_SYMBOL_SIZE, PROP_CHART_SYMBOL_AND_LINES }; @@ -154,7 +154,7 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList , tSeriesOrDiagramPropertyType ePropertyType ) { rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) ); - rList.push_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedSymbolBitmapProperty( spChart2ModelContact, ePropertyType ) ); rList.push_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) ); rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) ); } @@ -169,9 +169,9 @@ void WrappedSymbolProperties::addProperties( std::vector< Property > & rOutPrope beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "SymbolBitmapURL", - PROP_CHART_SYMBOL_BITMAP_URL, - cppu::UnoType<OUString>::get(), + rOutProperties.emplace_back( "SymbolBitmap", + PROP_CHART_SYMBOL_BITMAP, + cppu::UnoType<graphic::XGraphic>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); @@ -281,66 +281,42 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc return WrappedProperty::getPropertyState( xInnerPropertyState ); } -WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( +WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty< OUString >( "SymbolBitmapURL" - , uno::Any( OUString() ), spChart2ModelContact, ePropertyType ) + : WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>("SymbolBitmap", + uno::Any(uno::Reference<graphic::XGraphic>()), spChart2ModelContact, ePropertyType) { } -OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +uno::Reference<graphic::XGraphic> WrappedSymbolBitmapProperty::getValueFromSeries(const Reference< beans::XPropertySet >& xSeriesPropertySet) const { - OUString aRet; - m_aDefaultValue >>= aRet; + uno::Reference<graphic::XGraphic> xGraphic; + m_aDefaultValue >>= xGraphic; + chart2::Symbol aSymbol; - if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) + if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol) && aSymbol.Graphic.is()) { - GraphicObject aGrObj( Graphic( aSymbol.Graphic )); - aRet = UNO_NAME_GRAPHOBJ_URLPREFIX + - OStringToOUString(aGrObj.GetUniqueID(), - RTL_TEXTENCODING_ASCII_US); + xGraphic = aSymbol.Graphic; } - return aRet; + return xGraphic; } -void WrappedSymbolBitmapURLProperty::setValueToSeries( +void WrappedSymbolBitmapProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, - const OUString& aNewGraphicURL ) const + uno::Reference<graphic::XGraphic> const & xNewGraphic) const { - if(!xSeriesPropertySet.is()) + if (!xSeriesPropertySet.is()) return; chart2::Symbol aSymbol; - if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) + if (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol) { - bool bMatchesPrefix = aNewGraphicURL.match( UNO_NAME_GRAPHOBJ_URLPREFIX ); - if( bMatchesPrefix ) - { - GraphicObject aGrObj = GraphicObject( - OUStringToOString(aNewGraphicURL.copy( RTL_CONSTASCII_LENGTH(UNO_NAME_GRAPHOBJ_URLPREFIX) ), RTL_TEXTENCODING_ASCII_US)); - aSymbol.Graphic.set( aGrObj.GetGraphic().GetXGraphic()); - xSeriesPropertySet->setPropertyValue( "Symbol", uno::Any( aSymbol ) ); - } - else + if (xNewGraphic.is()) { - try - { - // @todo: get factory from some context? - Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); - Reference< graphic::XGraphicProvider > xGraphProv( graphic::GraphicProvider::create(xContext) ); - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( "URL", -1, uno::Any( aNewGraphicURL ), - beans::PropertyState_DIRECT_VALUE ); - aSymbol.Graphic.set( xGraphProv->queryGraphic( aArgs )); - OSL_ENSURE( aSymbol.Graphic.is(), "Invalid URL for Symbol Bitmap" ); - xSeriesPropertySet->setPropertyValue( "Symbol", uno::Any( aSymbol ) ); - } - catch( const uno::Exception & ex ) - { - SAL_WARN("chart2", "Exception caught. " << ex ); - } + aSymbol.Graphic.set(xNewGraphic); + xSeriesPropertySet->setPropertyValue("Symbol", uno::Any(aSymbol)); } } } |