Kaydet (Commit) 5a4d6162 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

convert SymbolBitmapURL to SymbolBitmap used in chart2

Change-Id: Ib35ee5b5890ff5ca30796fc8608f00ff4b6b03e2
Reviewed-on: https://gerrit.libreoffice.org/50788Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst d72145f9
...@@ -590,7 +590,7 @@ beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OU ...@@ -590,7 +590,7 @@ beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OU
beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
try try
{ {
if (rPropertyName == "SymbolBitmapURL") if (rPropertyName == "SymbolBitmap")
{ {
uno::Any aAny = WrappedPropertySet::getPropertyValue("SymbolType"); uno::Any aAny = WrappedPropertySet::getPropertyValue("SymbolType");
sal_Int32 nVal = css::chart::ChartSymbolType::NONE; sal_Int32 nVal = css::chart::ChartSymbolType::NONE;
......
...@@ -61,13 +61,13 @@ public: ...@@ -61,13 +61,13 @@ public:
tSeriesOrDiagramPropertyType ePropertyType); tSeriesOrDiagramPropertyType ePropertyType);
}; };
class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty< OUString > class WrappedSymbolBitmapProperty : public WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>
{ {
public: public:
virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override; virtual uno::Reference<graphic::XGraphic> getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override;
virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewGraphicURL ) 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); tSeriesOrDiagramPropertyType ePropertyType);
}; };
...@@ -99,7 +99,7 @@ enum ...@@ -99,7 +99,7 @@ enum
{ {
//symbol properties //symbol properties
PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP, 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_SIZE,
PROP_CHART_SYMBOL_AND_LINES PROP_CHART_SYMBOL_AND_LINES
}; };
...@@ -154,7 +154,7 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList ...@@ -154,7 +154,7 @@ void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList
, tSeriesOrDiagramPropertyType ePropertyType ) , tSeriesOrDiagramPropertyType ePropertyType )
{ {
rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, 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 WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) );
rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) ); rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) );
} }
...@@ -169,9 +169,9 @@ void WrappedSymbolProperties::addProperties( std::vector< Property > & rOutPrope ...@@ -169,9 +169,9 @@ void WrappedSymbolProperties::addProperties( std::vector< Property > & rOutPrope
beans::PropertyAttribute::BOUND beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ); | beans::PropertyAttribute::MAYBEDEFAULT );
rOutProperties.emplace_back( "SymbolBitmapURL", rOutProperties.emplace_back( "SymbolBitmap",
PROP_CHART_SYMBOL_BITMAP_URL, PROP_CHART_SYMBOL_BITMAP,
cppu::UnoType<OUString>::get(), cppu::UnoType<graphic::XGraphic>::get(),
beans::PropertyAttribute::BOUND beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ); | beans::PropertyAttribute::MAYBEDEFAULT );
...@@ -281,66 +281,42 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc ...@@ -281,66 +281,42 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc
return WrappedProperty::getPropertyState( xInnerPropertyState ); return WrappedProperty::getPropertyState( xInnerPropertyState );
} }
WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
tSeriesOrDiagramPropertyType ePropertyType ) tSeriesOrDiagramPropertyType ePropertyType )
: WrappedSeriesOrDiagramProperty< OUString >( "SymbolBitmapURL" : WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>("SymbolBitmap",
, uno::Any( OUString() ), spChart2ModelContact, ePropertyType ) 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; uno::Reference<graphic::XGraphic> xGraphic;
m_aDefaultValue >>= aRet; m_aDefaultValue >>= xGraphic;
chart2::Symbol aSymbol; chart2::Symbol aSymbol;
if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol)
&& aSymbol.Graphic.is()) && aSymbol.Graphic.is())
{ {
GraphicObject aGrObj( Graphic( aSymbol.Graphic )); xGraphic = aSymbol.Graphic;
aRet = UNO_NAME_GRAPHOBJ_URLPREFIX +
OStringToOUString(aGrObj.GetUniqueID(),
RTL_TEXTENCODING_ASCII_US);
} }
return aRet; return xGraphic;
} }
void WrappedSymbolBitmapURLProperty::setValueToSeries( void WrappedSymbolBitmapProperty::setValueToSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet, const Reference< beans::XPropertySet >& xSeriesPropertySet,
const OUString& aNewGraphicURL ) const uno::Reference<graphic::XGraphic> const & xNewGraphic) const
{ {
if(!xSeriesPropertySet.is()) if (!xSeriesPropertySet.is())
return; return;
chart2::Symbol aSymbol; chart2::Symbol aSymbol;
if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) if (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol)
{ {
bool bMatchesPrefix = aNewGraphicURL.match( UNO_NAME_GRAPHOBJ_URLPREFIX ); if (xNewGraphic.is())
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
{ {
try aSymbol.Graphic.set(xNewGraphic);
{ xSeriesPropertySet->setPropertyValue("Symbol", uno::Any(aSymbol));
// @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 );
}
} }
} }
} }
......
...@@ -121,7 +121,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = ...@@ -121,7 +121,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
// if type=="named-symbol" => name of symbol (square, diamond, ...) // if type=="named-symbol" => name of symbol (square, diamond, ...)
MAP_ENTRY( "SymbolType", CHART, XML_SYMBOL_NAME, XML_SCH_TYPE_NAMED_SYMBOL | MID_FLAG_MULTI_PROPERTY ), MAP_ENTRY( "SymbolType", CHART, XML_SYMBOL_NAME, XML_SCH_TYPE_NAMED_SYMBOL | MID_FLAG_MULTI_PROPERTY ),
// if type=="image" => an xlink:href element with a linked (package) URI // if type=="image" => an xlink:href element with a linked (package) URI
MAP_SPECIAL( "SymbolBitmapURL", CHART, XML_SYMBOL_IMAGE, XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE ), MAP_SPECIAL( "SymbolBitmap", CHART, XML_SYMBOL_IMAGE, XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE ),
MAP_SPECIAL( "SymbolSize", CHART, XML_SYMBOL_WIDTH, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH ), MAP_SPECIAL( "SymbolSize", CHART, XML_SYMBOL_WIDTH, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH ),
MAP_SPECIAL( "SymbolSize", CHART, XML_SYMBOL_HEIGHT, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT ), MAP_SPECIAL( "SymbolSize", CHART, XML_SYMBOL_HEIGHT, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT ),
MAP_ENTRY( "Vertical", CHART, XML_VERTICAL, XML_TYPE_BOOL ), MAP_ENTRY( "Vertical", CHART, XML_VERTICAL, XML_TYPE_BOOL ),
...@@ -251,7 +251,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = ...@@ -251,7 +251,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
MAP_ENTRY( "StackedText", STYLE, XML_DIRECTION, XML_SCH_TYPE_TEXT_ORIENTATION ), MAP_ENTRY( "StackedText", STYLE, XML_DIRECTION, XML_SCH_TYPE_TEXT_ORIENTATION ),
// for compatibility to pre 6.0beta documents // for compatibility to pre 6.0beta documents
// MAP_SPECIAL( "SymbolBitmapURL", CHART, XML_SYMBOL_IMAGE_NAME, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME ), // MAP_SPECIAL( "SymbolBitmap", CHART, XML_SYMBOL_IMAGE_NAME, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME ),
MAP_ENTRY( "ChartUserDefinedAttributes", TEXT, XML_XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM ), MAP_ENTRY( "ChartUserDefinedAttributes", TEXT, XML_XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM ),
......
...@@ -289,15 +289,20 @@ void XMLChartExportPropertyMapper::handleElementItem( ...@@ -289,15 +289,20 @@ void XMLChartExportPropertyMapper::handleElementItem(
{ {
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE: case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
{ {
OUString aURLStr; uno::Reference<graphic::XGraphic> xGraphic;
rProperty.maValue >>= aURLStr; rProperty.maValue >>= xGraphic;
OUString sInternalURL;
// export as XLink reference into the package // export as XLink reference into the package
// if embedding is off // if embedding is off
OUString sTempURL( mrExport.AddEmbeddedGraphicObject( aURLStr )); if (xGraphic.is())
if( !sTempURL.isEmpty() )
{ {
mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sTempURL ); OUString aOutMimeType;
sInternalURL = mrExport.AddEmbeddedXGraphic(xGraphic, aOutMimeType);
}
if (!sInternalURL.isEmpty())
{
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sInternalURL);
} }
{ {
...@@ -310,8 +315,8 @@ void XMLChartExportPropertyMapper::handleElementItem( ...@@ -310,8 +315,8 @@ void XMLChartExportPropertyMapper::handleElementItem(
// export as Base64 embedded graphic // export as Base64 embedded graphic
// if embedding is on // if embedding is on
if( !aURLStr.isEmpty()) if (xGraphic.is())
mrExport.AddEmbeddedGraphicObjectAsBase64( aURLStr ); mrExport.AddEmbeddedXGraphicAsBase64(xGraphic);
} }
} }
break; break;
...@@ -639,7 +644,7 @@ bool XMLChartImportPropertyMapper::handleSpecialItem( ...@@ -639,7 +644,7 @@ bool XMLChartImportPropertyMapper::handleSpecialItem(
// deprecated from 6.0 beta on // deprecated from 6.0 beta on
case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME: case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, false ); rProperty.maValue <<= mrImport.loadGraphicByURL(rValue);
break; break;
case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE: case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include <xmloff/nmspmap.hxx> #include <xmloff/nmspmap.hxx>
#include <xmloff/XMLBase64ImportContext.hxx> #include <xmloff/XMLBase64ImportContext.hxx>
#include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
using namespace css;
using namespace ::com::sun::star;
enum SvXMLTokenMapAttrs enum SvXMLTokenMapAttrs
{ {
...@@ -115,22 +115,22 @@ SvXMLImportContextRef XMLSymbolImageContext::CreateChildContext( ...@@ -115,22 +115,22 @@ SvXMLImportContextRef XMLSymbolImageContext::CreateChildContext(
void XMLSymbolImageContext::EndElement() void XMLSymbolImageContext::EndElement()
{ {
OUString sResolvedURL; uno::Reference<graphic::XGraphic> xGraphic;
if( !msURL.isEmpty() ) if (!msURL.isEmpty())
{ {
sResolvedURL = GetImport().ResolveGraphicObjectURL( msURL, false ); xGraphic = GetImport().loadGraphicByURL(msURL);
} }
else if( mxBase64Stream.is() ) else if (mxBase64Stream.is())
{ {
sResolvedURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ); xGraphic = GetImport().loadGraphicFromBase64(mxBase64Stream);
mxBase64Stream = nullptr; mxBase64Stream = nullptr;
} }
if( !sResolvedURL.isEmpty()) if (xGraphic.is())
{ {
// aProp is a member of XMLElementPropertyContext // aProp is a member of XMLElementPropertyContext
aProp.maValue <<= sResolvedURL; aProp.maValue <<= xGraphic;
SetInsert( true ); SetInsert( true );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment