summaryrefslogtreecommitdiff
path: root/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx')
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx76
1 files changed, 26 insertions, 50 deletions
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));
}
}
}