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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Sun Mar 11 00:51:46 UTC 2018


 svx/source/unodraw/unoshap2.cxx    |   32 +++++++++++++++-----------------
 sw/source/filter/xml/xmltexte.cxx  |    4 ++--
 sw/source/filter/xml/xmltexte.hxx  |    3 ++-
 xmloff/source/draw/shapeexport.cxx |    4 +++-
 4 files changed, 22 insertions(+), 21 deletions(-)

New commits:
commit 91ab5a07708892c3df6940aeb643d50bfd43e285
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sun Mar 11 01:53:13 2018 +0900

    use XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE define
    
    Change-Id: I6d37cc1e745b797a1c727a988177916291b650be
    Reviewed-on: https://gerrit.libreoffice.org/51049
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index 2324d667cb39..27205f248222 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -79,7 +79,6 @@ SwXMLTextParagraphExport::SwXMLTextParagraphExport(
          SvXMLAutoStylePoolP& _rAutoStylePool ) :
     XMLTextParagraphExport( rExp, _rAutoStylePool ),
     sEmbeddedObjectProtocol( "vnd.sun.star.EmbeddedObject:" ),
-    sGraphicObjectProtocol( "vnd.sun.star.GraphicObject:" ),
     aAppletClassId( SO3_APPLET_CLASSID ),
     aPluginClassId( SO3_PLUGIN_CLASSID ),
     aIFrameClassId( SO3_IFRAME_CLASSID )
@@ -562,7 +561,8 @@ void SwXMLTextParagraphExport::_exportTextEmbedded(
     }
     if( SV_EMBEDDED_OUTPLACE==nType || SV_EMBEDDED_OWN==nType )
     {
-        OUString sURL( sGraphicObjectProtocol + rOLEObj.GetCurrentPersistName() );
+        OUString sURL(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
+        sURL += rOLEObj.GetCurrentPersistName();
         if( !(rXMLExport.getExportFlags() & SvXMLExportFlags::EMBEDDED) )
         {
             sURL = GetExport().AddEmbeddedObject( sURL );
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
index 9ff9581d5070..38d0d2bdd02e 100644
--- a/sw/source/filter/xml/xmltexte.hxx
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -23,6 +23,8 @@
 #include <xmloff/txtparae.hxx>
 #include <tools/globname.hxx>
 
+#define XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE "vnd.sun.star.GraphicObject:"
+
 class SwXMLExport;
 class SvXMLAutoStylePoolP;
 class SwNoTextNode;
@@ -33,7 +35,6 @@ namespace com { namespace sun { namespace star { namespace style {
 class SwXMLTextParagraphExport : public XMLTextParagraphExport
 {
     const OUString sEmbeddedObjectProtocol;
-    const OUString sGraphicObjectProtocol;
 
     const SvGlobalName aAppletClassId;
     const SvGlobalName aPluginClassId;
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index e028f56e846e..6a6613e486d4 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -128,6 +128,8 @@ using namespace ::com::sun::star;
 using namespace ::xmloff::EnhancedCustomShapeToken;
 using namespace ::xmloff::token;
 
+#define XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE "vnd.sun.star.GraphicObject:"
+
 namespace {
 
 bool supportsText(XmlShapeType eShapeType)
@@ -2954,7 +2956,7 @@ void XMLShapeExport::ImpExportOLE2Shape(
     }
     if( !bIsEmptyPresObj )
     {
-        OUString sURL(  "vnd.sun.star.GraphicObject:"  );
+        OUString sURL(XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE);
         sURL += sPersistName;
         if( !bExportEmbedded )
         {
commit cfb90793b42ff57281d1cdd8b0c609652664ffe9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sun Mar 11 01:11:22 2018 +0900

    svx: convert XBitmap directly to XGraphic
    
    Change-Id: If2bd8419d9073625f0392f59f671d70193bf990c
    Reviewed-on: https://gerrit.libreoffice.org/51048
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index bf8b7b706c0d..453e6a254cfb 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1308,25 +1308,24 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
                 bOk = true;
             }
         }
-        else if( (rValue.getValueType() == cppu::UnoType<awt::XBitmap>::get()) || (rValue.getValueType() == cppu::UnoType<graphic::XGraphic>::get()))
+        else if (rValue.getValueType() == cppu::UnoType<graphic::XGraphic>::get())
         {
-            Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY );
-            if( xGraphic.is() )
+            auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>();
+            if (xGraphic.is())
             {
                 static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(Graphic(xGraphic));
                 bOk = true;
             }
-            else
+        }
+        else if (rValue.getValueType() == cppu::UnoType<awt::XBitmap>::get())
+        {
+            auto xBitmap = rValue.get<uno::Reference<awt::XBitmap>>();
+            if (xBitmap.is())
             {
-                // pack bitmap in the object
-                Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
-                if( xBmp.is() )
-                {
-                    // apply bitmap
-                    Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp ));
-                    static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
-                    bOk = true;
-                }
+                uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+                Graphic aGraphic(xGraphic);
+                static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
+                bOk = true;
             }
         }
         break;
@@ -1479,12 +1478,11 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
     {
     case OWN_ATTR_VALUE_FILLBITMAP:
     {
-        const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
+        const Graphic& rGraphic = static_cast<SdrGrafObj*>(mpObj.get())->GetGraphic();
 
-        if(rGraphic.GetType() != GraphicType::GdiMetafile)
+        if (rGraphic.GetType() != GraphicType::GdiMetafile)
         {
-            // pack object in a bitmap
-            Reference< css::awt::XBitmap >  xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
+            uno::Reference<awt::XBitmap> xBitmap(rGraphic.GetXGraphic(), uno::UNO_QUERY);
             rValue <<= xBitmap;
         }
         else


More information about the Libreoffice-commits mailing list