chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx  |    2 
 chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx |   76 
+++-------
 xmloff/source/chart/PropertyMap.hxx                                  |    4 
 xmloff/source/chart/PropertyMaps.cxx                                 |   21 +-
 xmloff/source/chart/XMLSymbolImageContext.cxx                        |   18 +-
 5 files changed, 51 insertions(+), 70 deletions(-)

New commits:
commit 5a4d6162f643050faf00ccf08d58feed00dcd781
Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
Date:   Mon Mar 5 17:12:01 2018 +0900

    convert SymbolBitmapURL to SymbolBitmap used in chart2
    
    Change-Id: Ib35ee5b5890ff5ca30796fc8608f00ff4b6b03e2
    Reviewed-on: https://gerrit.libreoffice.org/50788
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

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));
         }
     }
 }
diff --git a/xmloff/source/chart/PropertyMap.hxx 
b/xmloff/source/chart/PropertyMap.hxx
index 93285f84ae77..d81a11993082 100644
--- a/xmloff/source/chart/PropertyMap.hxx
+++ b/xmloff/source/chart/PropertyMap.hxx
@@ -121,7 +121,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
     // 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 ),
     // 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_HEIGHT, XML_TYPE_MEASURE | 
MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT ),
     MAP_ENTRY( "Vertical", CHART, XML_VERTICAL, XML_TYPE_BOOL ),
@@ -251,7 +251,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
     MAP_ENTRY( "StackedText", STYLE, XML_DIRECTION, 
XML_SCH_TYPE_TEXT_ORIENTATION ),
 
     // 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 ),
 
diff --git a/xmloff/source/chart/PropertyMaps.cxx 
b/xmloff/source/chart/PropertyMaps.cxx
index 76f4fda22a2b..7c97657f022f 100644
--- a/xmloff/source/chart/PropertyMaps.cxx
+++ b/xmloff/source/chart/PropertyMaps.cxx
@@ -289,15 +289,20 @@ void XMLChartExportPropertyMapper::handleElementItem(
     {
         case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
             {
-                OUString aURLStr;
-                rProperty.maValue >>= aURLStr;
+                uno::Reference<graphic::XGraphic> xGraphic;
+                rProperty.maValue >>= xGraphic;
 
+                OUString sInternalURL;
                 // export as XLink reference into the package
                 // if embedding is off
-                OUString sTempURL( mrExport.AddEmbeddedGraphicObject( aURLStr 
));
-                if( !sTempURL.isEmpty() )
+                if (xGraphic.is())
                 {
-                    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(
 
                     // export as Base64 embedded graphic
                     // if embedding is on
-                    if( !aURLStr.isEmpty())
-                        mrExport.AddEmbeddedGraphicObjectAsBase64( aURLStr );
+                    if (xGraphic.is())
+                        mrExport.AddEmbeddedXGraphicAsBase64(xGraphic);
                 }
             }
             break;
@@ -639,7 +644,7 @@ bool XMLChartImportPropertyMapper::handleSpecialItem(
 
             // deprecated from 6.0 beta on
             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
-                rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( 
rValue, false );
+                rProperty.maValue <<= mrImport.loadGraphicByURL(rValue);
                 break;
 
             case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE:
diff --git a/xmloff/source/chart/XMLSymbolImageContext.cxx 
b/xmloff/source/chart/XMLSymbolImageContext.cxx
index d90119809028..4e9fae4a9df5 100644
--- a/xmloff/source/chart/XMLSymbolImageContext.cxx
+++ b/xmloff/source/chart/XMLSymbolImageContext.cxx
@@ -25,9 +25,9 @@
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/XMLBase64ImportContext.hxx>
 #include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
 
-
-using namespace ::com::sun::star;
+using namespace css;
 
 enum SvXMLTokenMapAttrs
 {
@@ -115,22 +115,22 @@ SvXMLImportContextRef 
XMLSymbolImageContext::CreateChildContext(
 
 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;
     }
 
-    if( !sResolvedURL.isEmpty())
+    if (xGraphic.is())
     {
         // aProp is a member of XMLElementPropertyContext
-        aProp.maValue <<= sResolvedURL;
+        aProp.maValue <<= xGraphic;
         SetInsert( true );
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to