Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : *
6 : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : *
8 : * OpenOffice.org - a multi-platform office productivity suite
9 : *
10 : * This file is part of OpenOffice.org.
11 : *
12 : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : * it under the terms of the GNU Lesser General Public License version 3
14 : * only, as published by the Free Software Foundation.
15 : *
16 : * OpenOffice.org is distributed in the hope that it will be useful,
17 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : * GNU Lesser General Public License version 3 for more details
20 : * (a copy is included in the LICENSE file that accompanied this code).
21 : *
22 : * You should have received a copy of the GNU Lesser General Public License
23 : * version 3 along with OpenOffice.org. If not, see
24 : * <http://www.openoffice.org/license.html>
25 : * for a copy of the LGPLv3 License.
26 : *
27 : ************************************************************************/
28 : #ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MODEL_HXX
29 : #define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MODEL_HXX
30 :
31 : #include <com/sun/star/io/XObjectInputStream.hpp>
32 : #include <com/sun/star/io/XPersistObject.hpp>
33 : #include <com/sun/star/io/XObjectOutputStream.hpp>
34 : #include <com/sun/star/lang/XServiceName.hpp>
35 : #include <com/sun/star/lang/XServiceInfo.hpp>
36 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 : #include <com/sun/star/awt/XControlModel.hpp>
39 : #include <com/sun/star/awt/XControl.hpp>
40 :
41 : #include <cppuhelper/propshlp.hxx>
42 : #include <cppuhelper/weakagg.hxx>
43 : #include <rtl/alloc.h>
44 :
45 : #include <list>
46 :
47 : using namespace com::sun::star::uno;
48 :
49 : class BroadcasterHelperHolder
50 : {
51 : protected:
52 : ::cppu::OBroadcastHelper m_aHelper;
53 : public:
54 0 : BroadcasterHelperHolder( osl::Mutex& rMutex ) :
55 0 : m_aHelper( rMutex ) {}
56 0 : ~BroadcasterHelperHolder() {}
57 :
58 : ::cppu::OBroadcastHelper& getHelper() { return m_aHelper; }
59 :
60 : };
61 :
62 : class PluginModel : public BroadcasterHelperHolder,
63 : public cppu::OPropertySetHelper,
64 : public cppu::OPropertyArrayHelper,
65 : public cppu::OWeakAggObject,
66 : public com::sun::star::lang::XComponent,
67 : public com::sun::star::io::XPersistObject,
68 : public com::sun::star::awt::XControlModel
69 : {
70 : private:
71 : OUString m_aCreationURL;
72 : OUString m_aMimeType;
73 :
74 : std::list< Reference< com::sun::star::lang::XEventListener > >
75 : m_aDisposeListeners;
76 : public:
77 : // these are here to force memory de/allocation to sal lib.
78 0 : static void * SAL_CALL operator new( size_t nSize ) throw()
79 0 : { return rtl_allocateMemory( nSize ); }
80 0 : static void SAL_CALL operator delete( void * pMem ) throw()
81 0 : { rtl_freeMemory( pMem ); }
82 :
83 : PluginModel();
84 : PluginModel( const OUString& rURL, const OUString& rMimeType );
85 : virtual ~PluginModel();
86 :
87 :
88 : const OUString& getCreationURL() { return m_aCreationURL; }
89 : void setMimeType( const OUString& rMime ) { m_aMimeType = rMime; }
90 :
91 : // XInterface
92 0 : virtual Any SAL_CALL queryInterface( const Type& rType ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
93 0 : { return OWeakAggObject::queryInterface( rType ); }
94 0 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE
95 0 : { OWeakAggObject::acquire(); }
96 0 : virtual void SAL_CALL release() throw() SAL_OVERRIDE
97 0 : { OWeakAggObject::release(); }
98 :
99 : virtual Any SAL_CALL queryAggregation( const Type& ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
100 :
101 :
102 : // com::sun::star::lang::XTypeProvider
103 :
104 : static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static() throw( );
105 0 : static OUString SAL_CALL getImplementationName_Static() throw( )
106 : {
107 : /** the soplayer uses this name in its source! maybe not after 5.2 */
108 0 : return OUString( "com.sun.star.extensions.PluginModel" );
109 : }
110 :
111 : // OPropertySetHelper
112 : virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
113 : virtual sal_Bool SAL_CALL convertFastPropertyValue( Any & rConvertedValue,
114 : Any & rOldValue,
115 : sal_Int32 nHandle,
116 : const Any& rValue ) throw() SAL_OVERRIDE;
117 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
118 : const Any& rValue )
119 : throw(::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
120 : virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw() SAL_OVERRIDE;
121 : virtual Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(std::exception) SAL_OVERRIDE;
122 :
123 : // com::sun::star::io::XPersistObject
124 : virtual OUString SAL_CALL getServiceName() throw(std::exception) SAL_OVERRIDE;
125 : virtual void SAL_CALL write(const Reference< com::sun::star::io::XObjectOutputStream > & OutStream) throw(std::exception) SAL_OVERRIDE;
126 : virtual void SAL_CALL read(const Reference< com::sun::star::io::XObjectInputStream > & InStream) throw(std::exception) SAL_OVERRIDE;
127 :
128 : // com::sun::star::lang::XComponent
129 : virtual void SAL_CALL addEventListener( const Reference< com::sun::star::lang::XEventListener > & l ) throw(std::exception) SAL_OVERRIDE;
130 : virtual void SAL_CALL removeEventListener( const Reference< com::sun::star::lang::XEventListener > & l ) throw(std::exception) SAL_OVERRIDE;
131 : virtual void SAL_CALL dispose() throw(std::exception) SAL_OVERRIDE;
132 : private:
133 : using cppu::OPropertySetHelper::getFastPropertyValue;
134 : };
135 : Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception );
136 :
137 : #endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MODEL_HXX
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|