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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Mon Feb 26 05:04:54 UTC 2018


 include/vcl/graph.hxx                    |    2 +
 svx/source/unodraw/XPropertyTable.cxx    |    9 +++++++
 svx/source/xml/xmlxtimp.cxx              |    6 ----
 vcl/source/gdi/graph.cxx                 |    5 ++++
 xmloff/source/style/FillStyleContext.cxx |   31 -------------------------
 xmloff/source/style/ImageStyle.cxx       |   38 ++-----------------------------
 6 files changed, 19 insertions(+), 72 deletions(-)

New commits:
commit 3400424877032595490f38711b5e8520ed889fee
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Feb 26 11:15:37 2018 +0900

    xmloff: remove unused code when loading/saving the bitmap table
    
    Change-Id: I6bffe243e813079538a4cb57111266b41d7c03f1
    Reviewed-on: https://gerrit.libreoffice.org/50333
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx
index 86e530a3eca6..a2675cafa5f5 100644
--- a/svx/source/unodraw/XPropertyTable.cxx
+++ b/svx/source/unodraw/XPropertyTable.cxx
@@ -625,8 +625,17 @@ std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(const OUString&
         return std::unique_ptr<XPropertyEntry>();
 
     auto xBitmap = rAny.get<uno::Reference<awt::XBitmap>>();
+    if (!xBitmap.is())
+        return nullptr;
+
     uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+    if (!xGraphic.is())
+        return nullptr;
+
     Graphic aGraphic(xGraphic);
+    if (!aGraphic)
+        return nullptr;
+
     GraphicObject aGraphicObject(aGraphic);
     return o3tl::make_unique<XBitmapEntry>(aGraphicObject, rName);
 }
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index 6005a5c0199d..af5215c99582 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -285,12 +285,6 @@ void SvxXMLTableImportContext::importBitmap( const uno::Reference< XAttributeLis
             if (xBitmap.is())
                 rAny <<= xBitmap;
         }
-        else if (aGraphicAny.has<uno::Reference<awt::XBitmap>>())
-        {
-            auto xBitmap = aGraphicAny.get<uno::Reference<awt::XBitmap>>();
-            if (xBitmap.is())
-                rAny <<= xBitmap;
-        }
     }
     catch (const Exception&)
     {
diff --git a/xmloff/source/style/FillStyleContext.cxx b/xmloff/source/style/FillStyleContext.cxx
index 5c89613e826f..7a565fe74ecb 100644
--- a/xmloff/source/style/FillStyleContext.cxx
+++ b/xmloff/source/style/FillStyleContext.cxx
@@ -184,37 +184,6 @@ void XMLBitmapStyleContext::EndElement()
         catch (container::ElementExistException&)
         {}
     }
-    else
-    {
-        OUString sURL;
-        maAny >>= sURL;
-
-        if( sURL.isEmpty() && mxBase64Stream.is() )
-        {
-            sURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
-            mxBase64Stream = nullptr;
-            maAny <<= sURL;
-        }
-
-        uno::Reference< container::XNameContainer > xBitmap( GetImport().GetBitmapHelper() );
-
-        try
-        {
-            if(xBitmap.is())
-            {
-                if( xBitmap->hasByName( maStrName ) )
-                {
-                    xBitmap->replaceByName( maStrName, maAny );
-                }
-                else
-                {
-                    xBitmap->insertByName( maStrName, maAny );
-                }
-            }
-        }
-        catch( container::ElementExistException& )
-        {}
-    }
 }
 
 bool XMLBitmapStyleContext::IsTransient() const
diff --git a/xmloff/source/style/ImageStyle.cxx b/xmloff/source/style/ImageStyle.cxx
index 5842b659dc11..9976327103d8 100644
--- a/xmloff/source/style/ImageStyle.cxx
+++ b/xmloff/source/style/ImageStyle.cxx
@@ -83,38 +83,6 @@ void XMLImageStyle::exportXML(OUString const & rStrName, uno::Any const & rValue
             rExport.AddEmbeddedXGraphicAsBase64(xGraphic);
         }
     }
-    else if (rValue.has<OUString>()) // TODO: Remove when GraphicObject URL aren't used anymore
-    {
-        OUString sImageURL = rValue.get<OUString>();
-
-        // Name
-        bool bEncoded = false;
-        rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
-                              rExport.EncodeStyleName( rStrName,
-                                                       &bEncoded ) );
-        if( bEncoded )
-            rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY_NAME,
-                                  rStrName );
-
-        // uri
-        const OUString aStr( rExport.AddEmbeddedGraphicObject( sImageURL ) );
-        if( !aStr.isEmpty() )
-        {
-            rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStr );
-            rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
-            rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
-            rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
-        }
-
-        // Do Write
-        SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_FILL_IMAGE, true, true );
-
-        if( !sImageURL.isEmpty() )
-        {
-            // optional office:binary-data
-            rExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
-        }
-    }
 }
 
 bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & xAttrList,
@@ -179,7 +147,8 @@ bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & x
         }
     }
 
-    rValue <<= xGraphic;
+    if (xGraphic.is())
+        rValue <<= xGraphic;
 
     if( !aDisplayName.isEmpty() )
     {
@@ -188,8 +157,7 @@ bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & x
         rStrName = aDisplayName;
     }
 
-    bool bRet = bHasName && bHasHRef;
-    return bRet;
+    return bHasName && bHasHRef;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6fa55d39bc43383fcdb3276e9b7f612fa96d1b67
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Feb 26 09:21:12 2018 +0900

    bool cast operator for Graphic object
    
    Change-Id: Iec236538271b33eb9e6dcfd98903657c1198476e
    Reviewed-on: https://gerrit.libreoffice.org/50332
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 2ec7a7e14706..4915fa0e347a 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -129,6 +129,8 @@ public:
     bool            operator!=( const Graphic& rGraphic ) const;
     bool            operator!() const;
 
+    operator bool() const;
+
     void            Clear();
 
     GraphicType     GetType() const;
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index b1e5f40335ea..1b753414b60e 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -288,6 +288,11 @@ bool Graphic::operator!() const
     return (GraphicType::NONE == mxImpGraphic->ImplGetType());
 }
 
+Graphic::operator bool() const
+{
+    return GraphicType::NONE != mxImpGraphic->ImplGetType();
+}
+
 void Graphic::Clear()
 {
     ImplTestRefCount();


More information about the Libreoffice-commits mailing list