ooo-build r13074 - trunk/patches/test/vba



Author: noelpwer
Date: Sat Jul  5 08:01:29 2008
New Revision: 13074
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13074&view=rev

Log:
snap shot of some experimental code 
(just does a read e.g. can handle a package url) 
o only works for dialog controls at the moment
o only works with a document with a hardcoded image in the document ( in
a hardcoded path ;-)
o only works with already applied ObjectModule patch from this dir (
although really its mostly independant )


Added:
   trunk/patches/test/vba/HackyImageControlWithNonLinkedImages.diff

Added: trunk/patches/test/vba/HackyImageControlWithNonLinkedImages.diff
==============================================================================
--- (empty file)
+++ trunk/patches/test/vba/HackyImageControlWithNonLinkedImages.diff	Sat Jul  5 08:01:29 2008
@@ -0,0 +1,674 @@
+diff --git forms/source/component/imgprod.cxx forms/source/component/imgprod.cxx
+index 01fa8ac..8c7e065 100644
+--- forms/source/component/imgprod.cxx
++++ forms/source/component/imgprod.cxx
+@@ -39,12 +39,16 @@
+ #include <unotools/ucbstreamhelper.hxx>
+ #include <svtools/filter.hxx>
+ #include <com/sun/star/io/XInputStream.hpp>
++#include <com/sun/star/embed/XStorage.hpp>
++#include <com/sun/star/embed/ElementModes.hpp>
+ 
+ #ifndef SVTOOLS_SOURCE_MISC_IMAGERESOURCEACCESS_HXX
+ #include "svtools/imageresourceaccess.hxx"
+ #endif
+ #include <comphelper/processfactory.hxx>
+ 
++using namespace com::sun::star;
++
+ // --------------------
+ // - ImgProdLockBytes -
+ // --------------------
+@@ -644,6 +648,48 @@ void ImageProducer::initialize( const ::
+ 			SetImage( aURL );
+ 		}
+ 	}
++	if ( aArguments.getLength() == 2 )
++	{
++		rtl::OUString aURL;
++		uno::Reference< embed::XStorage > xStor;	
++		if ( ( aArguments[ 0 ] >>= aURL ) && ( aArguments[ 1 ] >>= xStor ) )
++		{
++			String aUserData = aURL;
++			if( aUserData.Len() && ( aUserData.GetToken( 0, ':' ) == String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
++			{
++				const String aPicturePath( aUserData.GetToken( 1, ':' ) );
++
++				// graphic from picture stream in picture storage in XML package
++				if( aPicturePath.GetTokenCount( '/' ) == 2 )
++				{
++					const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
++					const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
++		
++					try {
++						if ( xStor->isStorageElement( aPictureStorageName ) )
++						{
++							uno::Reference< embed::XStorage > xPictureStorage =
++							xStor->openStorageElement( aPictureStorageName, embed::ElementModes::READ );
++							if( xPictureStorage.is() &&
++						xPictureStorage->isStreamElement( aPictureStreamName ) )
++							{
++								uno::Reference< io::XStream > xStream =
++								xPictureStorage->openStreamElement( aPictureStreamName, embed::ElementModes::READ );
++								if ( xStream.is() )
++								{
++									uno::Reference< io::XInputStream >  xIs( xStream->getInputStream() );
++									setImage( xIs );
++								}
++							}
++						}
++					}
++					catch( uno::Exception& )
++					{
++					}
++				}
++    			}
++		}
++	}
+ }
+ 
+ namespace frm
+diff --git goodies/source/unographic/descriptor.cxx goodies/source/unographic/descriptor.cxx
+index 37721e1..d902d51 100644
+--- goodies/source/unographic/descriptor.cxx
++++ goodies/source/unographic/descriptor.cxx
+@@ -51,6 +51,7 @@
+ #ifndef _COM_SUN_STAR_GRAPHIC_GRAPHICTYPE_HDL_ 
+ #include <com/sun/star/graphic/GraphicType.hpp>
+ #endif
++#include <com/sun/star/embed/ElementModes.hpp>
+ #include "vcl/graph.hxx"
+ #include "vcl/svapp.hxx"
+ 
+@@ -125,6 +126,50 @@ void GraphicDescriptor::init( const uno:
+ 	}
+ }
+ 
++void GraphicDescriptor::init( const uno::Reference< embed::XStorage >& xStorage, const ::rtl::OUString& rURL ) 
++	throw()
++{
++	String aUserData = rURL;
++	if( aUserData.Len() && ( aUserData.GetToken( 0, ':' ) == String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
++	{
++		const String aPicturePath( aUserData.GetToken( 1, ':' ) );
++
++		// graphic from picture stream in picture storage in XML package
++		if( aPicturePath.GetTokenCount( '/' ) == 2 )
++		{
++			const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
++			const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
++
++			try {
++				if ( xStorage->isStorageElement( aPictureStorageName ) )
++				{
++					uno::Reference< embed::XStorage > xPictureStorage =
++					xStorage->openStorageElement( aPictureStorageName, embed::ElementModes::READ );
++					if( xPictureStorage.is() &&
++						xPictureStorage->isStreamElement( aPictureStreamName ) )
++					{
++						uno::Reference< io::XStream > xStream =
++							xPictureStorage->openStreamElement( aPictureStreamName, embed::ElementModes::READ );
++						if ( xStream.is() )
++						{
++							SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( xStream );
++	
++							if( pIStm )
++							{
++								implCreate( *pIStm, &rURL );
++								delete pIStm;
++							}
++						}
++					}
++				}
++			}
++			catch( uno::Exception& )
++			{
++			}
++		}
++
++	}
++}
+ // ------------------------------------------------------------------------------
+ 
+ bool GraphicDescriptor::isValid() const
+diff --git goodies/source/unographic/descriptor.hxx goodies/source/unographic/descriptor.hxx
+index c683e18..8e7ae70 100644
+--- goodies/source/unographic/descriptor.hxx
++++ goodies/source/unographic/descriptor.hxx
+@@ -33,6 +33,7 @@
+ 
+ #include <comphelper/propertysethelper.hxx>
+ #include <com/sun/star/lang/XServiceInfo.hpp>
++#include <com/sun/star/embed/XStorage.hpp>
+ 
+ #include <comphelper/propertysetinfo.hxx>
+ #include <vcl/graph.hxx>
+@@ -90,6 +91,7 @@ public:
+  	void init( const ::Graphic& rGraphic ) throw();
+ 	void init( const ::rtl::OUString& rURL ) throw();
+ 	void init( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxIStm, const ::rtl::OUString& rURL ) throw();
++	void init( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxIStm, const ::rtl::OUString& rURL ) throw();
+ 	
+ 	bool isValid() const;
+ 
+diff --git goodies/source/unographic/provider.cxx goodies/source/unographic/provider.cxx
+index f51b852..e779449 100644
+--- goodies/source/unographic/provider.cxx
++++ goodies/source/unographic/provider.cxx
+@@ -51,6 +51,8 @@
+ #include <vcl/virdev.hxx>
+ #include <com/sun/star/io/XStream.hpp>
+ #include <com/sun/star/text/GraphicCrop.hpp>
++#include <com/sun/star/embed/XStorage.hpp>
++#include <com/sun/star/embed/ElementModes.hpp>
+ 
+ #include "descriptor.hxx"
+ #include "graphic.hxx"
+@@ -319,6 +321,7 @@ uno::Reference< beans::XPropertySet > SA
+ 
+ 	::rtl::OUString aURL;
+ 	uno::Reference< io::XInputStream > xIStm;
++	uno::Reference< embed::XStorage > xStor;
+ 
+ 	for( sal_Int32 i = 0; ( i < rMediaProperties.getLength() ) && !xRet.is(); ++i )
+ 	{
+@@ -333,6 +336,10 @@ uno::Reference< beans::XPropertySet > SA
+ 		{
+ 			aValue >>= xIStm;
+ 		}
++		else if( COMPARE_EQUAL == aName.compareToAscii( "Storage" ) )
++		{
++			aValue >>= xStor;
++		}
+ 	}
+ 
+ 	if( xIStm.is() )
+@@ -343,26 +350,35 @@ uno::Reference< beans::XPropertySet > SA
+ 	}
+ 	else if( aURL.getLength() )
+ 	{
+-		uno::Reference< ::graphic::XGraphic > xGraphic( implLoadMemory( aURL ) );
+-		
+-		if( !xGraphic.is() )
+-			xGraphic = implLoadResource( aURL );
+-
+-        if ( !xGraphic.is() )
+-            xGraphic = implLoadRepositoryImage( aURL );
+-
+-		if ( !xGraphic.is() )
+-            xGraphic = implLoadStandardImage( aURL );
+-		
+-		if( xGraphic.is() )
++		if ( xStor.is() )
+ 		{
+-			xRet = uno::Reference< beans::XPropertySet >( xGraphic, uno::UNO_QUERY );
++			GraphicDescriptor* pDescriptor = new GraphicDescriptor;
++			pDescriptor->init( xStor, aURL );
++			xRet = pDescriptor;
+ 		}
+ 		else
+ 		{
+-			GraphicDescriptor* pDescriptor = new GraphicDescriptor;
+-			pDescriptor->init( aURL );
+-			xRet = pDescriptor;
++			uno::Reference< ::graphic::XGraphic > xGraphic( implLoadMemory( aURL ) );
++		
++			if( !xGraphic.is() )
++				xGraphic = implLoadResource( aURL );
++
++	        if ( !xGraphic.is() )
++	            xGraphic = implLoadRepositoryImage( aURL );
++	
++			if ( !xGraphic.is() )
++	            xGraphic = implLoadStandardImage( aURL );
++		
++			if( xGraphic.is() )
++			{
++				xRet = uno::Reference< beans::XPropertySet >( xGraphic, uno::UNO_QUERY );
++			}
++			else
++			{
++				GraphicDescriptor* pDescriptor = new GraphicDescriptor;
++				pDescriptor->init( aURL );
++				xRet = pDescriptor;
++			}
+ 		}
+ 	}
+ 
+@@ -379,6 +395,7 @@ uno::Reference< ::graphic::XGraphic > SA
+ 	SvStream* 								pIStm = NULL;
+ 
+ 	uno::Reference< io::XInputStream > xIStm;
++	uno::Reference< embed::XStorage > xStor;
+ 
+ 	for( sal_Int32 i = 0; ( i < rMediaProperties.getLength() ) && !pIStm && !xRet.is(); ++i )
+ 	{
+@@ -395,16 +412,55 @@ uno::Reference< ::graphic::XGraphic > SA
+ 		{
+ 			aValue >>= xIStm;
+ 		}
++		else if( COMPARE_EQUAL == aName.compareToAscii( "Storage" ) )
++		{
++			aValue >>= xStor;
++		}
+ 	}
+ 
+ 	if( xIStm.is() )
+ 	{
+ 		pIStm = ::utl::UcbStreamHelper::CreateStream( xIStm );
+ 	}
++	else if( aPath.Len() && xStor.is() )
++    {
++	String aUserData = aPath;
++	if( aUserData.Len() && ( aUserData.GetToken( 0, ':' ) == String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
++	{
++		const String aPicturePath( aUserData.GetToken( 1, ':' ) );
++
++		// graphic from picture stream in picture storage in XML package
++		if( aPicturePath.GetTokenCount( '/' ) == 2 )
++		{
++			const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
++			const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
++
++			try {
++				if ( xStor->isStorageElement( aPictureStorageName ) )
++				{
++					uno::Reference< embed::XStorage > xPictureStorage =
++					xStor->openStorageElement( aPictureStorageName, embed::ElementModes::READ );
++					if( xPictureStorage.is() &&
++						xPictureStorage->isStreamElement( aPictureStreamName ) )
++					{
++						uno::Reference< io::XStream > xStream =
++							xPictureStorage->openStreamElement( aPictureStreamName, embed::ElementModes::READ );
++						if ( xStream.is() )
++							pIStm = ::utl::UcbStreamHelper::CreateStream( xStream );
++					}
++				}
++			}
++			catch( uno::Exception& )
++			{
++			}
++		}
++    }
++    }
+ 	else if( aPath.Len() )
+ 	{
+-		xRet = implLoadMemory( aPath );
+-		
++		if( !xRet.is() )
++		   xRet = implLoadMemory( aPath );
++	
+ 		if( !xRet.is() )
+ 			xRet = implLoadResource( aPath );
+ 	
+diff --git offapi/com/sun/star/graphic/makefile.mk offapi/com/sun/star/graphic/makefile.mk
+index 600f60d..94abf95 100755
+--- offapi/com/sun/star/graphic/makefile.mk
++++ offapi/com/sun/star/graphic/makefile.mk
+@@ -53,7 +53,8 @@ IDLFILES= \
+ 	XGraphic.idl \
+ 	XGraphicProvider.idl \
+ 	XGraphicRenderer.idl \
+-	XGraphicTransformer.idl
++	XGraphicTransformer.idl \
++	XGraphicLinkProvider.idl \
+ 	
+ # --- Targets ------------------------------------------------------
+ 
+diff --git svx/util/makefile.mk svx/util/makefile.mk
+index 10100ae..df47081 100644
+--- svx/util/makefile.mk
++++ svx/util/makefile.mk
+@@ -176,6 +176,7 @@ SHL2STDLIBS= \
+             $(VOSLIB) \
+             $(SALLIB) \
+             $(JVMFWKLIB) \
++             $(CPPUHELPERLIB) \
+             $(ICUUCLIB)
+ 
+ .IF "$(GUI)"=="WNT"
+diff --git toolkit/inc/toolkit/controls/unocontrols.hxx toolkit/inc/toolkit/controls/unocontrols.hxx
+index 72c7db8..757a6c8 100644
+--- toolkit/inc/toolkit/controls/unocontrols.hxx
++++ toolkit/inc/toolkit/controls/unocontrols.hxx
+@@ -221,7 +221,7 @@ private:
+     bool                                                                                    mbAdjustingGraphic;
+ 
+ protected:
+-    ImageProducerControlModel() : mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { }
++    ImageProducerControlModel();
+     ImageProducerControlModel( const ImageProducerControlModel& _rSource ) : com::sun::star::awt::XImageProducer(), UnoControlModel( _rSource ), mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { }
+ 
+ 	::com::sun::star::uno::Any	SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+diff --git toolkit/inc/toolkit/helper/property.hxx toolkit/inc/toolkit/helper/property.hxx
+index db61c94..73e861e 100644
+--- toolkit/inc/toolkit/helper/property.hxx
++++ toolkit/inc/toolkit/helper/property.hxx
+@@ -190,6 +190,7 @@ namespace rtl {
+ #define BASEPROPERTY_CUSTOMUNITTEXT                 136  // ::rtl::OUString
+ #define BASEPROPERTY_ENABLEVISIBLE                  137  // sal_Bool
+ #define BASEPROPERTY_GROUPNAME                      138  // ::rtl::OUString
++#define BASEPROPERTY_GRAPHICLINKPROVIDER            139  // css::graphic::XGraphicLinkProvider
+ 
+ // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen.
+ #define BASEPROPERTY_FONTDESCRIPTORPART_START			1000
+diff --git toolkit/source/controls/dialogcontrol.cxx toolkit/source/controls/dialogcontrol.cxx
+index 3fd5723..2fe56a4 100644
+--- toolkit/source/controls/dialogcontrol.cxx
++++ toolkit/source/controls/dialogcontrol.cxx
+@@ -2120,10 +2120,15 @@ throw (RuntimeException)
+ 
+ 	if ( url.getLength() > 0 )
+ 	{
+-		INetURLObject urlObj(baseLocation);
+-		urlObj.removeSegment();
+-		baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE );
+-		::osl::FileBase::getAbsoluteFileURL( baseLocation, url, ret );
++		if ( url.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.Package:") ) ) == 0 )
++			ret = url;
++		else
++		{
++			INetURLObject urlObj(baseLocation);
++			urlObj.removeSegment();
++			baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE );
++			::osl::FileBase::getAbsoluteFileURL( baseLocation, url, ret );
++		}
+ 	}
+ 
+ 	return ret;
+diff --git toolkit/source/controls/unocontrolmodel.cxx toolkit/source/controls/unocontrolmodel.cxx
+index 6f3b633..2c107b8 100644
+--- toolkit/source/controls/unocontrolmodel.cxx
++++ toolkit/source/controls/unocontrolmodel.cxx
+@@ -36,7 +36,8 @@
+ #include <com/sun/star/awt/FontWidth.hpp>
+ #include <com/sun/star/awt/FontWeight.hpp>
+ #include <com/sun/star/awt/FontSlant.hpp>
+-#include <com/sun/star/graphic/XGraphicProvider.hpp>
++#include <com/sun/star/graphic/XGraphic.hpp>
++#include <com/sun/star/graphic/XGraphicLinkProvider.hpp>
+ #include <com/sun/star/io/XMarkableStream.hpp>
+ #include <toolkit/controls/unocontrolmodel.hxx>
+ #include <toolkit/helper/macros.hxx>
+@@ -256,6 +257,8 @@ void UnoControlModel::ImplPropertyChange
+         {
+ 			case BASEPROPERTY_GRAPHIC:				aDefault <<= ::com::sun::star::uno::makeAny( 
+ 																	::com::sun::star::uno::Reference< graphic::XGraphic >() ); break;
++			case BASEPROPERTY_GRAPHICLINKPROVIDER:				aDefault <<= ::com::sun::star::uno::makeAny( 
++																	::com::sun::star::uno::Reference< graphic::XGraphicLinkProvider >() ); break;
+             case BASEPROPERTY_VERTICALALIGN:
+             case BASEPROPERTY_BORDERCOLOR:
+             case BASEPROPERTY_SYMBOL_COLOR:
+diff --git toolkit/source/controls/unocontrols.cxx toolkit/source/controls/unocontrols.cxx
+index 821c1b9..4dcfb3d 100644
+--- toolkit/source/controls/unocontrols.cxx
++++ toolkit/source/controls/unocontrols.cxx
+@@ -37,6 +37,7 @@
+ #include <com/sun/star/awt/VisualEffect.hpp>
+ #include <com/sun/star/awt/LineEndFormat.hpp>
+ #include <com/sun/star/graphic/XGraphicProvider.hpp>
++#include <com/sun/star/graphic/XGraphicLinkProvider.hpp>
+ #include <com/sun/star/util/Date.hpp>
+ 
+ 
+@@ -548,6 +549,11 @@ UnoFileControl::UnoFileControl()
+ //	----------------------------------------------------
+ //	class ImageProducerControlModel
+ //	----------------------------------------------------
++ImageProducerControlModel::ImageProducerControlModel()  : mbAdjustingImagePosition( false ), mbAdjustingGraphic( false )
++{
++	ImplRegisterProperty( BASEPROPERTY_GRAPHICLINKPROVIDER );
++}
++
+ uno::Any SAL_CALL ImageProducerControlModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
+ {
+     return UnoControlModel::queryInterface( rType );
+@@ -578,7 +584,7 @@ uno::Any ImageProducerControlModel::Impl
+ }
+ namespace
+ {
+-    uno::Reference< graphic::XGraphic > lcl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL )
++    uno::Reference< graphic::XGraphic > lcl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL, const uno::Reference< embed::XStorage >& rxStorage )
+     {
+         uno::Reference< graphic::XGraphic > xGraphic;
+         if ( !_rURL.getLength() )
+@@ -593,6 +599,13 @@ namespace
+                 uno::Sequence< beans::PropertyValue > aMediaProperties(1);
+                 aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+                 aMediaProperties[0].Value <<= _rURL;
++                if ( rxStorage.is() )
++                { 
++                    sal_Int32 nOldLen = aMediaProperties.getLength();
++                    aMediaProperties.realloc( nOldLen + 1 );
++                    aMediaProperties[ nOldLen ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Storage" ) );
++                    aMediaProperties[ nOldLen ].Value <<= rxStorage;
++                }
+                 xGraphic = xProvider->queryGraphic( aMediaProperties );
+             }
+         }
+@@ -603,6 +616,13 @@ namespace
+ 
+         return xGraphic;
+     }
++
++    uno::Reference< graphic::XGraphic > lcl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL )
++    {
++        uno::Reference< embed::XStorage > xStorage;
++        return lcl_getGraphicFromURL_nothrow( _rURL, xStorage );
++    }
++
+ }
+ 
+ void SAL_CALL ImageProducerControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
+@@ -615,16 +635,38 @@ void SAL_CALL ImageProducerControlModel:
+     {
+         switch ( nHandle )
+         {
++        case BASEPROPERTY_GRAPHICLINKPROVIDER:
++            if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
++            {    
++                uno::Reference< graphic::XGraphicLinkProvider > xProv;
++                OSL_VERIFY( rValue >>= xProv );
++                rtl::OUString sURL;
++                //mbAdjustingGraphic = true;
++                if ( xProv.is() )
++		    sURL = xProv->getSourceURL();
++
++                if ( sURL.getLength() )
++                {
++                    //setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( lcl_getGraphicFromURL_nothrow( sURL, xProv->getStorage() ) ) );
++                }
++                
++            }
++            
+         case BASEPROPERTY_IMAGEURL:
++        {
+             if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
+             {
+                 mbAdjustingGraphic = true;
+                 ::rtl::OUString sImageURL;
+-                OSL_VERIFY( rValue >>= sImageURL );
+-                setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( lcl_getGraphicFromURL_nothrow( sImageURL ) ) );
++                //OSL_VERIFY( rValue >>= sImageURL );
++		uno::Reference< graphic::XGraphicLinkProvider > xProv;
++                if ( ImplHasProperty( BASEPROPERTY_GRAPHICLINKPROVIDER ) )
++                    getPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHICLINKPROVIDER ) ) >>= xProv;
++                setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( lcl_getGraphicFromURL_nothrow( sImageURL , xProv->getStorage()  ) ) );
+                 mbAdjustingGraphic = false;
+             }
+             break;
++        }
+ 
+         case BASEPROPERTY_GRAPHIC:
+             if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
+@@ -676,8 +718,23 @@ void ImageProducerControlModel::removeCo
+ 
+ void ImageProducerControlModel::startProduction(  ) throw (::com::sun::star::uno::RuntimeException)
+ {
+-	uno::Sequence<uno::Any> aArgs(1);
++	uno::Reference< graphic::XGraphicLinkProvider > xProv;
++	if ( ImplHasProperty( BASEPROPERTY_GRAPHICLINKPROVIDER ) )
++			getPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHICLINKPROVIDER ) ) >>= xProv;
++	uno::Sequence<uno::Any> aArgs;
++	if ( xProv.is() )
++		aArgs.realloc( 2 );
++	else
++		aArgs.realloc( 1 );
+ 	aArgs.getArray()[0] = getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) );
++	rtl::OUString sUrl;
++	aArgs[0] >>= sUrl;
++	if ( xProv.is() )
++        {
++
++		aArgs[1] <<= xProv->getStorage();
++        }
++
+ 	uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ 	uno::Reference< awt::XImageProducer > xImageProducer( xMSF->createInstanceWithArguments( ::rtl::OUString::createFromAscii( "com.sun.star.awt.ImageProducer" ), aArgs ), uno::UNO_QUERY );
+ 	if ( xImageProducer.is() )
+diff --git toolkit/source/helper/property.cxx toolkit/source/helper/property.cxx
+index a7fc25b..1186c26 100644
+--- toolkit/source/helper/property.cxx
++++ toolkit/source/helper/property.cxx
+@@ -53,6 +53,7 @@
+ #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+ #include <com/sun/star/beans/PropertyAttribute.hpp>
+ #include <com/sun/star/graphic/XGraphic.hpp>
++#include <com/sun/star/graphic/XGraphicLinkProvider.hpp>
+ #include <com/sun/star/resource/XStringResourceResolver.hpp>
+ #include <comphelper/types.hxx>
+ #include <functional>
+@@ -180,6 +181,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( 
+ 
+             DECL_PROP_2     ( "Graphic",                GRAPHIC,            Reference< ::com::sun::star::graphic::XGraphic >, BOUND, TRANSIENT ),
+             DECL_PROP_2     ( "GroupName",              GROUPNAME,          ::rtl::OUString,    BOUND, MAYBEDEFAULT ),
++            DECL_PROP_2     ( "GraphicLinkProvider",              GRAPHICLINKPROVIDER,          Reference< ::com::sun::star::graphic::XGraphicLinkProvider >,    BOUND, MAYBEDEFAULT ),
+             DECL_PROP_2     ( "HelpText",               HELPTEXT,           ::rtl::OUString,    BOUND, MAYBEDEFAULT ),
+             DECL_PROP_2     ( "HelpURL",                HELPURL,            ::rtl::OUString,    BOUND, MAYBEDEFAULT ),
+             DECL_PROP_2     ( "HideInactiveSelection",  HIDEINACTIVESELECTION, bool,            BOUND, MAYBEDEFAULT ),
+diff --git xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+index d57bb95..9a9eb1e 100644
+--- xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
++++ xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+@@ -40,6 +40,8 @@
+ #include <com/sun/star/beans/NamedValue.hpp>
+ #include <com/sun/star/table/CellAddress.hpp>
+ #include <com/sun/star/table/CellRangeAddress.hpp>
++#include <com/sun/star/graphic/XGraphicLinkProvider.hpp>
++#include <com/sun/star/document/XStorageBasedDocument.hpp>
+ 
+ 
+ using namespace ::com::sun::star;
+@@ -48,6 +50,39 @@ using ::rtl::OUString;
+ 
+ namespace xmlscript
+ {
++
++typedef ::cppu::WeakImplHelper1< graphic::XGraphicLinkProvider >  GRAPHIC_LINKPROVIDER_BASE;
++
++class GraphLinkProviderImpl : public GRAPHIC_LINKPROVIDER_BASE
++{
++    Reference< embed::XStorage > mxStorage;
++    rtl::OUString msURL;
++public:
++    GraphLinkProviderImpl( const Reference< frame::XModel >& rxModel, rtl::OUString& sURL ) : msURL( sURL )
++    {
++        Reference< document::XStorageBasedDocument > xDocStorage( rxModel, UNO_QUERY );
++        if ( xDocStorage.is() )
++        {
++            mxStorage = xDocStorage->getDocumentStorage();
++        }
++    }
++
++    virtual Reference< embed::XStorage > SAL_CALL getStorage() throw (RuntimeException)
++    {
++        return mxStorage;
++    }
++
++    virtual void SAL_CALL setStorage( const Reference< embed::XStorage >& _storage ) throw (RuntimeException)
++    {
++    }
++
++    virtual ::rtl::OUString SAL_CALL getSourceURL() throw (RuntimeException)
++    {
++        return msURL;
++    }
++
++};
++
+ void importBindableAndListRangeBits( DialogImport* _pImport, const rtl::OUString sLinkedCell, const rtl::OUString & sCellRange, ControlImportContext& ctx )
+ {
+     Reference< lang::XMultiServiceFactory > xFac( _pImport->getDocOwner(), UNO_QUERY );;
+@@ -1062,6 +1097,23 @@ void ImageControlElement::endElement()
+ 	ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ 							  OUString( RTL_CONSTASCII_USTRINGPARAM("src") ),
+ 							  _xAttributes );
++
++	rtl::OUString sURL = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "src" ) );
++        // hard code-test
++	if (  sURL.indexOf( OUSTR("vnd.sun.star.Package:") ) == 0  &&  _pImport->getDocOwner().is() )
++	{
++		try
++		{
++			Reference< beans::XPropertySet > xProps( ctx.getControlModel(), UNO_QUERY_THROW );
++			Reference< graphic::XGraphicLinkProvider > xProvider ( new  GraphLinkProviderImpl( _pImport->getDocOwner(), sURL ) );
++			xProps->setPropertyValue( OUSTR("GraphicLinkProvider"), makeAny( xProvider ) );
++		}
++		catch( Exception& e )
++		{
++		}
++    
++        }
++
+     ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+                                OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+                                _xAttributes );
+--- /dev/null	2008-04-22 00:28:44.000000000 +0100
++++ offapi/com/sun/star/graphic/XGraphicLinkProvider.idl	2008-07-04 15:16:15.000000000 +0100
+@@ -0,0 +1,46 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XGraphicProvider.idl,v $
++ * $Revision: 1.5 $
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++
++#ifndef com_sun_star_graphic_XGraphicLinkProvider_idl
++#define com_sun_star_graphic_XGraphicLinkProvider_idl
++
++#include <com/sun/star/uno/XInterface.idl>
++#include <com/sun/star/embed/XStorage.idl>
++
++module com { module sun { module star { module graphic
++{
++interface XGraphicLinkProvider : ::com::sun::star::uno::XInterface
++{
++    [attribute] com::sun::star::embed::XStorage Storage;
++    [readonly, attribute] string SourceURL;
++} ; } ; } ; } ; 
++};
++
++#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]