[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - oox/source toolkit/inc toolkit/source

Petr Mladek pmladek at kemper.freedesktop.org
Tue Feb 14 11:04:44 PST 2012


 oox/source/ole/axcontrol.cxx                               |    1 
 toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx |    1 
 toolkit/inc/toolkit/controls/dialogcontrol.hxx             |    4 +
 toolkit/inc/toolkit/controls/unocontrols.hxx               |   13 +++
 toolkit/source/controls/controlmodelcontainerbase.cxx      |   25 -------
 toolkit/source/controls/dialogcontrol.cxx                  |   35 ++++++++--
 toolkit/source/controls/unocontrols.cxx                    |   44 ++++++++++++-
 7 files changed, 89 insertions(+), 34 deletions(-)

New commits:
commit 8015cd2cdbdb05b0048753e12b39fa940add2021
Author: Noel Power <noel.power at novell.com>
Date:   Mon Feb 13 14:50:09 2012 +0000

    handle imported picture attribute from MSO Dialog ( fdo#45995 )
    
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index c9bde1f..6013f75 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -2495,6 +2495,7 @@ void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlCon
 {
     rPropMap.setProperty( PROP_Title, maCaption );
     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
+    rConv.convertAxPicture( rPropMap, maPictureData, AX_PICPOS_CENTER  );
     AxContainerModelBase::convertProperties( rPropMap, rConv );
 }
 
commit 4ea4f80121eedc7f87d950ea8e15336fb691e52f
Author: Noel Power <noel.power at novell.com>
Date:   Mon Feb 13 14:19:22 2012 +0000

    fix support for embedded images for basic Dialogs ( fdo#45992 )
    
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx b/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx
index 9e99968..d307c2a 100644
--- a/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx
+++ b/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx
@@ -234,7 +234,6 @@ protected:
     virtual void        ImplSetPosSize( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxCtrl );
     void        ImplUpdateResourceResolver();
     void        ImplStartListingForResourceEvents();
-    ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > Impl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL );
 
     ControlContainerBase();
 
diff --git a/toolkit/inc/toolkit/controls/dialogcontrol.hxx b/toolkit/inc/toolkit/controls/dialogcontrol.hxx
index 961d449..7c9a674 100644
--- a/toolkit/inc/toolkit/controls/dialogcontrol.hxx
+++ b/toolkit/inc/toolkit/controls/dialogcontrol.hxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/awt/XDialog2.hpp>
 #include <com/sun/star/awt/XSimpleTabController.hpp>
 #include <com/sun/star/resource/XStringResourceResolver.hpp>
+#include <com/sun/star/graphic/XGraphicObject.hpp>
 #include "toolkit/helper/servicenames.hxx"
 #include "toolkit/helper/macros.hxx"
 #include <toolkit/controls/unocontrolcontainer.hxx>
@@ -48,8 +49,11 @@
 class UnoControlDialogModel :   public ControlModelContainerBase
 {
 protected:
+    ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > mxGrfObj;
     ::com::sun::star::uno::Any          ImplGetDefaultValue( sal_uInt16 nPropId ) const;
     ::cppu::IPropertyArrayHelper&       SAL_CALL getInfoHelper();
+    // ::cppu::OPropertySetHelper
+	void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
 public:
                         UnoControlDialogModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory );
                         UnoControlDialogModel( const UnoControlDialogModel& rModel );
diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx
index 201858d..2ed2cf7 100644
--- a/toolkit/inc/toolkit/controls/unocontrols.hxx
+++ b/toolkit/inc/toolkit/controls/unocontrols.hxx
@@ -72,6 +72,19 @@
 #define UNO_NAME_GRAPHOBJ_URLPREFIX                             "vnd.sun.star.GraphicObject:"
 #define UNO_NAME_GRAPHOBJ_URLPKGPREFIX                  "vnd.sun.star.Package:"
 
+class ImageHelper
+{
+public:
+    // The routine will always attempt to return a valid XGraphic for the
+    // passed _rURL, additionallly xOutGraphicObject will contain the
+    // associated XGraphicObject ( if url is valid for that ) and is set
+    // appropriately ( e.g. NULL if non GraphicObject scheme ) or a valid
+    // object if the rURL points to a valid object
+    static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > getGraphicAndGraphicObjectFromURL_nothrow( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject >& xOutGraphicObject, const ::rtl::OUString& _rURL );
+    static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL );
+
+};
+
 //  ----------------------------------------------------
 //  class UnoControlEditModel
 //  ----------------------------------------------------
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index a227d61..ae673aa 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -1856,31 +1856,6 @@ void ControlContainerBase::ImplUpdateResourceResolver()
     }
 }
 
-
-uno::Reference< graphic::XGraphic > ControlContainerBase::Impl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL )
-{
-    uno::Reference< graphic::XGraphic > xGraphic;
-    if ( !_rURL.getLength() )
-        return xGraphic;
-
-    try
-    {
-        uno::Reference< graphic::XGraphicProvider > xProvider;
-        if ( maContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
-        {
-            uno::Sequence< beans::PropertyValue > aMediaProperties(1);
-            aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
-            aMediaProperties[0].Value <<= _rURL;
-            xGraphic = xProvider->queryGraphic( aMediaProperties );
-        }
-    }
-    catch (const Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION();
-    }
-
-    return xGraphic;
-}
 ////    ----------------------------------------------------
 ////    Helper Method to convert relative url to physical location
 ////    ----------------------------------------------------
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index 60659f1..e69a359 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -60,6 +60,7 @@
 
 #include <vcl/tabctrl.hxx>
 #include <toolkit/awt/vclxwindows.hxx>
+#include "toolkit/controls/unocontrols.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -242,6 +243,23 @@ Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo(  ) thro
     return xInfo;
 }
 
+void SAL_CALL UnoControlDialogModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
+{
+    ControlModelContainerBase::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+    try
+    {
+        if ( nHandle == BASEPROPERTY_IMAGEURL && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
+        {
+            ::rtl::OUString sImageURL;
+            OSL_VERIFY( rValue >>= sImageURL );
+            setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj, sImageURL ) ) );
+        }
+    }
+    catch( const ::com::sun::star::uno::Exception& )
+    {
+        OSL_ENSURE( sal_False, "UnoControlDialogModel::setFastPropertyValue_NoBroadcast: caught an exception while setting ImageURL properties!" );
+    }
+}
 // ============================================================================
 // = class UnoDialogControl
 // ============================================================================
@@ -339,11 +357,12 @@ void UnoDialogControl::PrepareWindowDescriptor( ::com::sun::star::awt::WindowDes
     if (( ImplGetPropertyValue( PROPERTY_IMAGEURL ) >>= aImageURL ) &&
         ( aImageURL.getLength() > 0 ))
     {
-        ::rtl::OUString absoluteUrl =
-            getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
-                                 ImplGetPropertyValue( PROPERTY_IMAGEURL ));
+        ::rtl::OUString absoluteUrl = aImageURL;
+        if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
+            absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( PROPERTY_DIALOGSOURCEURL ),
+                                 uno::makeAny( aImageURL ) );
 
-        xGraphic = ControlContainerBase::Impl_getGraphicFromURL_nothrow( absoluteUrl );
+        xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl );
         ImplSetPropertyValue( PROPERTY_GRAPHIC, uno::makeAny( xGraphic ), sal_True );
     }
 }
@@ -567,11 +586,13 @@ void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChang
             if (( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) ) >>= aImageURL ) &&
                 ( aImageURL.getLength() > 0 ))
             {
-                ::rtl::OUString absoluteUrl =
-                    getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL )),
+                ::rtl::OUString absoluteUrl = aImageURL;
+                if ( aImageURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) != 0 )
+
+                    absoluteUrl = getPhysicalLocation( ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL )),
                                          uno::makeAny(aImageURL));
 
-                xGraphic = Impl_getGraphicFromURL_nothrow( absoluteUrl );
+                xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl );
             }
             ImplSetPropertyValue(  GetPropertyName( BASEPROPERTY_GRAPHIC), uno::makeAny( xGraphic ), sal_True );
             break;
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index 2fae9e6..1ea4759 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -87,7 +87,49 @@ using namespace ::toolkit;
                             } \
 
 
+uno::Reference< graphic::XGraphic >
+ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& xOutGraphicObj, const ::rtl::OUString& _rURL )
+{
+    if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) )
+    {
+        // graphic manager uniqueid
+        rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
+        // get the DefaultContext
+        ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+        xOutGraphicObj = graphic::GraphicObject::createWithId( aContext.getUNOContext(), sID );
+    }
+    else // linked
+        xOutGraphicObj = NULL; // release the GraphicObject
+
+    return ImageHelper::getGraphicFromURL_nothrow( _rURL );
+}
 
+::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
+ImageHelper::getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL )
+{
+    uno::Reference< graphic::XGraphic > xGraphic;
+    if ( _rURL.isEmpty() )
+        return xGraphic;
+
+    try
+    {
+        uno::Reference< graphic::XGraphicProvider > xProvider;
+        ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+        if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
+        {
+            uno::Sequence< beans::PropertyValue > aMediaProperties(1);
+            aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+            aMediaProperties[0].Value <<= _rURL;
+            xGraphic = xProvider->queryGraphic( aMediaProperties );
+        }
+    }
+    catch (const Exception&)
+    {
+        DBG_UNHANDLED_EXCEPTION();
+    }
+
+    return xGraphic;
+}
 //  ----------------------------------------------------
 //  class UnoControlEditModel
 //  ----------------------------------------------------
@@ -591,7 +633,7 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n
                 mbAdjustingGraphic = true;
                 ::rtl::OUString sImageURL;
                 OSL_VERIFY( rValue >>= sImageURL );
-                setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( getGraphicFromURL_nothrow( sImageURL ) ) );
+                setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL ) ) );
                 mbAdjustingGraphic = false;
             }
             break;


More information about the Libreoffice-commits mailing list