[Libreoffice-commits] core.git: include/xmloff xmloff/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Sat Mar 10 01:12:54 UTC 2018


 include/xmloff/xmlexp.hxx              |    4 ---
 xmloff/source/core/xmlexp.cxx          |   31 ++++----------------------
 xmloff/source/forms/propertyexport.cxx |   39 ++++++++++++++++++++++-----------
 3 files changed, 32 insertions(+), 42 deletions(-)

New commits:
commit 0d1479cbd442c3ec3bdd20333c341ea24dcca21e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sat Mar 10 00:42:20 2018 +0900

    xmloff: modify code relying on Graph.Object URL and cleanup code
    
    Change-Id: Id08ee261ae06673809fcf8581e2490ecd957891f
    Reviewed-on: https://gerrit.libreoffice.org/51011
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index b225a932dd86..cf132192bc39 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -137,7 +137,6 @@ class XMLOFF_DLLPUBLIC SvXMLExport : public cppu::WeakImplHelper<
     rtl::Reference<SvXMLAttributeList>          mxAttrList;        // a common attribute list
 
     OUString     msOrigFileName; // the original URL
-    OUString     msGraphicObjectProtocol;
     OUString     msEmbeddedObjectProtocol;
     OUString     msFilterName;
     OUString     msImgFilterName;
@@ -460,9 +459,6 @@ public:
     /// get the export for image maps
     XMLImageMapExport& GetImageMapExport();
 
-    OUString AddEmbeddedGraphicObject(
-                            const OUString& rGraphicObjectURL );
-
     OUString AddEmbeddedXGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName = OUString());
     bool AddEmbeddedXGraphicAsBase64(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
     bool GetGraphicMimeTypeFromStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType);
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index a3a41b31443e..c0be7c830a09 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -396,7 +396,6 @@ void SvXMLExport::InitCtor_()
             GetXMLToken(XML_NP_CSS3TEXT), GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT );
     }
 
-    msGraphicObjectProtocol = "vnd.sun.star.GraphicObject:";
     msEmbeddedObjectProtocol = "vnd.sun.star.EmbeddedObject:";
 
     if (mxModel.is() && !mxEventListener.is())
@@ -1867,23 +1866,6 @@ sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
                  ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
 }
 
-OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
-{
-    OUString sRet( rGraphicObjectURL );
-    if( rGraphicObjectURL.startsWith( msGraphicObjectProtocol ) &&
-        mxGraphicResolver.is() )
-    {
-        if( !(getExportFlags() & SvXMLExportFlags::EMBEDDED) )
-            sRet = mxGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL );
-        else
-            sRet.clear();
-    }
-    else
-        sRet = GetRelativeReference( sRet );
-
-    return sRet;
-}
-
 OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName)
 {
     OUString sURL;
@@ -1951,12 +1933,10 @@ bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic>
 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
 {
     OUString sRet;
-    if( (rEmbeddedObjectURL.startsWith( msEmbeddedObjectProtocol ) ||
-         rEmbeddedObjectURL.startsWith( msGraphicObjectProtocol ) ) &&
-        mxEmbeddedResolver.is() )
+    if (rEmbeddedObjectURL.startsWith(msEmbeddedObjectProtocol) &&
+        mxEmbeddedResolver.is())
     {
-        sRet =
-            mxEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL );
+        sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL(rEmbeddedObjectURL);
     }
     else
         sRet = GetRelativeReference( rEmbeddedObjectURL );
@@ -1967,9 +1947,8 @@ OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
 bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
 {
     bool bRet = false;
-    if( (rEmbeddedObjectURL.startsWith( msEmbeddedObjectProtocol ) ||
-         rEmbeddedObjectURL.startsWith( msGraphicObjectProtocol ) ) &&
-        mxEmbeddedResolver.is() )
+    if (rEmbeddedObjectURL.startsWith(msEmbeddedObjectProtocol) &&
+        mxEmbeddedResolver.is())
     {
         Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
         if( xNA.is() )
diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx
index 2f611bc61f8b..df34513b94a4 100644
--- a/xmloff/source/forms/propertyexport.cxx
+++ b/xmloff/source/forms/propertyexport.cxx
@@ -33,6 +33,7 @@
 #include <rtl/strbuf.hxx>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/util/Time.hpp>
 #include <com/sun/star/util/DateTime.hpp>
 #include <comphelper/extract.hxx>
@@ -46,6 +47,7 @@
 namespace xmloff
 {
 
+    using namespace css;
     using namespace ::com::sun::star::uno;
     using namespace ::com::sun::star::lang;
     using namespace ::com::sun::star::beans;
@@ -394,20 +396,33 @@ namespace xmloff
     {
         DBG_CHECK_PROPERTY( _sPropertyName, OUString );
 
-        OUString sTargetLocation = comphelper::getString(m_xProps->getPropertyValue(_sPropertyName));
-        if ( !sTargetLocation.isEmpty() )
-                    // If this isn't a GraphicObject then GetRelativeReference
-                    // will be called anyway ( in AddEmbeddedGraphic )
-            sTargetLocation = m_rContext.getGlobalContext().AddEmbeddedGraphicObject(sTargetLocation);
-        AddAttribute(OAttributeMetaData::getCommonControlAttributeNamespace(_nProperty)
-                    ,OAttributeMetaData::getCommonControlAttributeName(_nProperty)
-                    , sTargetLocation);
+        Any aAny = m_xProps->getPropertyValue(_sPropertyName);
 
-        // #i110911# add xlink:type="simple" if required
-        if (_bAddType)
-            AddAttribute(XML_NAMESPACE_XLINK, token::XML_TYPE, token::XML_SIMPLE);
+        OUString sTargetLocation;
+        if (aAny.has<uno::Reference<graphic::XGraphic>>())
+        {
+            auto xGraphic = aAny.get<uno::Reference<graphic::XGraphic>>();
+            OUString sOutMimeType;
+            sTargetLocation = m_rContext.getGlobalContext().AddEmbeddedXGraphic(xGraphic, sOutMimeType);
+        }
+        else if (aAny.has<OUString>())
+        {
+            auto sURL = aAny.get<OUString>();
+            sTargetLocation = m_rContext.getGlobalContext().AddEmbeddedObject(sURL);
+        }
 
-        exportedProperty(_sPropertyName);
+        if (!sTargetLocation.isEmpty())
+        {
+            AddAttribute(OAttributeMetaData::getCommonControlAttributeNamespace(_nProperty)
+                        ,OAttributeMetaData::getCommonControlAttributeName(_nProperty)
+                        , sTargetLocation);
+
+            // #i110911# add xlink:type="simple" if required
+            if (_bAddType)
+                AddAttribute(XML_NAMESPACE_XLINK, token::XML_TYPE, token::XML_SIMPLE);
+
+            exportedProperty(_sPropertyName);
+        }
     }
     void OPropertyExport::flagStyleProperties()
     {


More information about the Libreoffice-commits mailing list