summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolkit/inc/toolkit/controls/unocontrols.hxx29
-rw-r--r--toolkit/source/controls/unocontrols.cxx81
2 files changed, 96 insertions, 14 deletions
diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx
index c34184793345..6031bf7c0f3f 100644
--- a/toolkit/inc/toolkit/controls/unocontrols.hxx
+++ b/toolkit/inc/toolkit/controls/unocontrols.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unocontrols.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: mt $ $Date: 2001-04-04 09:26:17 $
+ * last change: $Author: mt $ $Date: 2001-04-04 16:03:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -138,6 +138,8 @@
#include <vcl/imgcons.hxx>
#include <vcl/bitmapex.hxx>
+#include <list>
+
struct UnoControlModelHolder;
class UnoControlModelHolderList;
@@ -435,12 +437,20 @@ public:
// ----------------------------------------------------
// class UnoControlButtonModel
// ----------------------------------------------------
-class UnoControlButtonModel : public UnoControlModel
+class UnoControlButtonModel : public ::com::sun::star::awt::XImageProducer,
+ public UnoControlModel
{
+private:
+// ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer > mxImageProducer;
+
+ std::list< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > > maListeners;
+
protected:
::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const;
::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer > ImplGetImageProducer();
+
public:
UnoControlButtonModel();
UnoControlButtonModel( const UnoControlButtonModel& rModel ) : UnoControlModel( rModel ) {;}
@@ -449,6 +459,18 @@ public:
::rtl::OUString getServiceName() const;
+ ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlModel::queryInterface(rType); }
+ ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException) { OWeakAggObject::acquire(); }
+ void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) { OWeakAggObject::release(); }
+
+ // ::com::sun::star::awt::XImageProducer
+ void SAL_CALL addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL startProduction( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::cppu::OPropertySetHelper
+ // void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
// ::com::sun::star::beans::XMultiPropertySet
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
@@ -481,6 +503,7 @@ public:
UnoButtonControl();
::rtl::OUString GetComponentServiceName();
+ void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal );
::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlBase::queryInterface(rType); }
::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index 1c6640122f5c..ab37dfa18d08 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unocontrols.cxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: mt $ $Date: 2001-04-04 10:32:56 $
+ * last change: $Author: mt $ $Date: 2001-04-04 16:06:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1176,6 +1176,12 @@ UnoControlButtonModel::UnoControlButtonModel()
ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR );
}
+uno::Any UnoControlButtonModel::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XImageProducer*, this ) );
+ return (aRet.hasValue() ? aRet : UnoControlModel::queryAggregation( rType ));
+}
+
::rtl::OUString UnoControlButtonModel::getServiceName() const
{
return ::rtl::OUString::createFromAscii( szServiceName_UnoControlButtonModel );
@@ -1211,7 +1217,39 @@ uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetI
return xInfo;
}
+void UnoControlButtonModel::addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException)
+{
+ maListeners.push_back( xConsumer );
+}
+
+void UnoControlButtonModel::removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException)
+{
+ maListeners.remove( xConsumer );
+}
+void UnoControlButtonModel::startProduction( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Any aArg = getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) );
+ rtl::OUString aURL;
+ aArg >>= aURL;
+ if ( aURL.getLength() )
+ {
+ uno::Sequence<uno::Any> aArgs(1);
+ aArgs.getArray()[0] = aArg;
+ 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() )
+ {
+ std::list< uno::Reference< awt::XImageConsumer > >::iterator aIter( maListeners.begin() );
+ while ( aIter != maListeners.end() )
+ {
+ xImageProducer->addConsumer( *aIter );
+ aIter++;
+ }
+ xImageProducer->startProduction();
+ }
+ }
+}
// ----------------------------------------------------
// class UnoButtonControl
@@ -1265,6 +1303,29 @@ void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToo
xButton->addActionListener( &maActionListeners );
}
+void UnoButtonControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
+{
+ sal_uInt16 nType = GetPropertyId( rPropName );
+ if ( mxPeer.is() && nType == BASEPROPERTY_IMAGEURL )
+ {
+ uno::Reference < awt::XImageProducer > xImgProd( getModel(), uno::UNO_QUERY );
+ uno::Reference < awt::XImageConsumer > xImgCons( mxPeer, uno::UNO_QUERY );
+
+ uno::Reference < awt::XImageConsumer > xTest1( (awt::XImageConsumer*)this, uno::UNO_QUERY );
+ uno::Reference < awt::XImageProducer > xTest2( (awt::XImageConsumer*)this, uno::UNO_QUERY );
+
+ if ( xImgProd.is() && xImgCons.is() )
+ {
+ xImgProd->addConsumer( xImgCons );
+ xImgProd->startProduction();
+ xImgProd->removeConsumer( xImgCons );
+ }
+ }
+ else
+ UnoControl::ImplSetPeerProperty( rPropName, rVal );
+}
+
+
void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
{
maActionListeners.addInterface( l );
@@ -1365,10 +1426,9 @@ void UnoButtonControl::startProduction() throw(uno::RuntimeException)
{
if ( mxImageProducer.is() )
{
- UnoMemoryStream* pStrm = new UnoMemoryStream( 0x3FFF, 0x3FFF );
- (*pStrm) << maBitmap;
-
- uno::Reference < io::XInputStream > xIn = pStrm;
+// UnoMemoryStream* pStrm = new UnoMemoryStream( 0x3FFF, 0x3FFF );
+// (*pStrm) << maBitmap;
+// uno::Reference < io::XInputStream > xIn = pStrm;
// mxImageProducer->setImage( xIn );
mxImageProducer->startProduction();
}
@@ -1553,11 +1613,10 @@ void UnoImageControlControl::startProduction() throw(uno::RuntimeException)
{
if ( mxImageProducer.is() )
{
- UnoMemoryStream* pStrm = new UnoMemoryStream( 0x3FFF, 0x3FFF );
- (*pStrm) << maBitmap;
-
- uno::Reference < io::XInputStream > xIn = pStrm;
-// mxImageProducer->setImage( xIn );
+ // UnoMemoryStream* pStrm = new UnoMemoryStream( 0x3FFF, 0x3FFF );
+ // (*pStrm) << maBitmap;
+ // uno::Reference < io::XInputStream > xIn = pStrm;
+ // mxImageProducer->setImage( xIn );
mxImageProducer->startProduction();
}
}