1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
29*cdf0e10cSrcweir #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "pcrcomponentcontext.hxx"
32*cdf0e10cSrcweir #include "pcrcommon.hxx"
33*cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_
34*cdf0e10cSrcweir #include "modulepcr.hxx"
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir /** === begin UNO includes === **/
38*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
45*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
46*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/inspection/XPropertyHandler.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
52*cdf0e10cSrcweir /** === end UNO includes === **/
53*cdf0e10cSrcweir #include <osl/interlck.h>
54*cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
55*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
56*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #include <memory>
59*cdf0e10cSrcweir #include <vector>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace com { namespace sun { namespace star {
62*cdf0e10cSrcweir     namespace inspection {
63*cdf0e10cSrcweir         struct LineDescriptor;
64*cdf0e10cSrcweir         class XPropertyControlFactory;
65*cdf0e10cSrcweir     }
66*cdf0e10cSrcweir } } }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir class Window;
69*cdf0e10cSrcweir //........................................................................
70*cdf0e10cSrcweir namespace pcr
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir //........................................................................
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     typedef sal_Int32   PropertyId;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	//====================================================================
77*cdf0e10cSrcweir 	//= PropertyHandler
78*cdf0e10cSrcweir 	//====================================================================
79*cdf0e10cSrcweir     class OPropertyInfoService;
80*cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper1    <   ::com::sun::star::inspection::XPropertyHandler
81*cdf0e10cSrcweir                                                 >   PropertyHandler_Base;
82*cdf0e10cSrcweir     /** the base class for property handlers
83*cdf0e10cSrcweir     */
84*cdf0e10cSrcweir     class PropertyHandler : public PropertyHandler_Base
85*cdf0e10cSrcweir     {
86*cdf0e10cSrcweir     private:
87*cdf0e10cSrcweir         /// cache for getSupportedProperties
88*cdf0e10cSrcweir         mutable StlSyntaxSequence< ::com::sun::star::beans::Property >
89*cdf0e10cSrcweir                                     m_aSupportedProperties;
90*cdf0e10cSrcweir         mutable bool                m_bSupportedPropertiesAreKnown;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir         /// helper which ensures that we can access resources as long as the instance lives
93*cdf0e10cSrcweir         PcrClient       m_aEnsureResAccess;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     private:
96*cdf0e10cSrcweir         /// the property listener which has been registered
97*cdf0e10cSrcweir         PropertyChangeListeners                                                         m_aPropertyListeners;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     protected:
100*cdf0e10cSrcweir 		mutable ::osl::Mutex                                                            m_aMutex;
101*cdf0e10cSrcweir         /// the context in which the instance was created
102*cdf0e10cSrcweir         ComponentContext                                                                m_aContext;
103*cdf0e10cSrcweir         /// the component we're inspecting
104*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xComponent;
105*cdf0e10cSrcweir         /// info about our component's properties
106*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >   m_xComponentPropertyInfo;
107*cdf0e10cSrcweir         /// type converter, needed on various occasions
108*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >    m_xTypeConverter;
109*cdf0e10cSrcweir         /// access to property meta data
110*cdf0e10cSrcweir         ::std::auto_ptr< OPropertyInfoService >                                         m_pInfoService;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     protected:
113*cdf0e10cSrcweir         PropertyHandler(
114*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
115*cdf0e10cSrcweir         );
116*cdf0e10cSrcweir         ~PropertyHandler();
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir         // default implementations for XPropertyHandler
119*cdf0e10cSrcweir         virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
120*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
121*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
122*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
123*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
124*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
125*cdf0e10cSrcweir         virtual ::com::sun::star::beans::PropertyState  SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
126*cdf0e10cSrcweir         virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
127*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
128*cdf0e10cSrcweir         virtual ::com::sun::star::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
129*cdf0e10cSrcweir         virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
130*cdf0e10cSrcweir         virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
131*cdf0e10cSrcweir         virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
132*cdf0e10cSrcweir         virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         // XComponent
135*cdf0e10cSrcweir         DECLARE_XCOMPONENT()
136*cdf0e10cSrcweir         virtual void SAL_CALL disposing();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         // own overridables
139*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
140*cdf0e10cSrcweir                     SAL_CALL doDescribeSupportedProperties() const = 0;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         /// called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
143*cdf0e10cSrcweir         virtual void onNewComponent();
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     protected:
146*cdf0e10cSrcweir         /** fires the change in a property value to our listener (if any)
147*cdf0e10cSrcweir             @see addPropertyChangeListener
148*cdf0e10cSrcweir         */
149*cdf0e10cSrcweir         void    firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId,
150*cdf0e10cSrcweir                     const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Any& _rNewValue ) SAL_THROW(());
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         /** retrieves a window which can be used as parent for dialogs
153*cdf0e10cSrcweir         */
154*cdf0e10cSrcweir         Window* impl_getDefaultDialogParent_nothrow() const;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir         /** retrieves the property id for a given property name
157*cdf0e10cSrcweir             @throw com::sun::star::beans::UnknownPropertyException
158*cdf0e10cSrcweir                 if the property name is not known to our ->m_pInfoService
159*cdf0e10cSrcweir         */
160*cdf0e10cSrcweir         PropertyId impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         //-------------------------------------------------------------------------------
163*cdf0e10cSrcweir         // helper for implementing doDescribeSupportedProperties
164*cdf0e10cSrcweir         /** adds a description for the given string property to the given property vector
165*cdf0e10cSrcweir             Most probably to be called from within getSupportedProperties
166*cdf0e10cSrcweir         */
167*cdf0e10cSrcweir         inline void addStringPropertyDescription(
168*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
169*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
170*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
171*cdf0e10cSrcweir                 ) const;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         /** adds a description for the given int32 property to the given property vector
174*cdf0e10cSrcweir         */
175*cdf0e10cSrcweir         inline void addInt32PropertyDescription(
176*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
177*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
178*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
179*cdf0e10cSrcweir                 ) const;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         /** adds a description for the given int16 property to the given property vector
182*cdf0e10cSrcweir         */
183*cdf0e10cSrcweir         inline void addInt16PropertyDescription(
184*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
185*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
186*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
187*cdf0e10cSrcweir                 ) const;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         /** adds a description for the given double property to the given property vector
190*cdf0e10cSrcweir         */
191*cdf0e10cSrcweir         inline void addDoublePropertyDescription(
192*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
193*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
194*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
195*cdf0e10cSrcweir                 ) const;
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir         /** adds a description for the given date property to the given property vector
198*cdf0e10cSrcweir         */
199*cdf0e10cSrcweir         inline void addDatePropertyDescription(
200*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
201*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
202*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
203*cdf0e10cSrcweir                 ) const;
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir         /** adds a description for the given time property to the given property vector
206*cdf0e10cSrcweir         */
207*cdf0e10cSrcweir         inline void addTimePropertyDescription(
208*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
209*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
210*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
211*cdf0e10cSrcweir                 ) const;
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir         /** adds a description for the given DateTime property to the given property vector
214*cdf0e10cSrcweir         */
215*cdf0e10cSrcweir         inline void addDateTimePropertyDescription(
216*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
217*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
218*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
219*cdf0e10cSrcweir                 ) const;
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir         /// adds a Property, given by name only, to a given vector of Properties
222*cdf0e10cSrcweir         void implAddPropertyDescription(
223*cdf0e10cSrcweir                     ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
224*cdf0e10cSrcweir                     const ::rtl::OUString& _rPropertyName,
225*cdf0e10cSrcweir                     const ::com::sun::star::uno::Type& _rType,
226*cdf0e10cSrcweir                     sal_Int16 _nAttribs = 0
227*cdf0e10cSrcweir                 ) const;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir         //-------------------------------------------------------------------------------
230*cdf0e10cSrcweir         // helper for accessing and maintaining meta data about our supported properties
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir         /** retrieves a property given by handle
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir             @return
235*cdf0e10cSrcweir                 a pointer to the descriptor for the given properties, if it is one of our
236*cdf0e10cSrcweir                 supported properties, <NULL/> else.
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir             @see doDescribeSupportedProperties
239*cdf0e10cSrcweir             @see impl_getPropertyFromId_throw
240*cdf0e10cSrcweir         */
241*cdf0e10cSrcweir         const ::com::sun::star::beans::Property*
242*cdf0e10cSrcweir                     impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const;
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         /** retrieves a property given by handle
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir             @throws UnknownPropertyException
247*cdf0e10cSrcweir                 if the handler does not support a property with the given handle
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir             @seealso doDescribeSupportedProperties
250*cdf0e10cSrcweir             @see impl_getPropertyFromId_nothrow
251*cdf0e10cSrcweir         */
252*cdf0e10cSrcweir         const ::com::sun::star::beans::Property&
253*cdf0e10cSrcweir                     impl_getPropertyFromId_throw( PropertyId _nPropId ) const;
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir         /** determines whether a given property id is part of our supported properties
256*cdf0e10cSrcweir             @see getSupportedProperties
257*cdf0e10cSrcweir             @see doDescribeSupportedProperties
258*cdf0e10cSrcweir         */
259*cdf0e10cSrcweir         inline bool impl_isSupportedProperty_nothrow( PropertyId _nPropId ) const
260*cdf0e10cSrcweir         {
261*cdf0e10cSrcweir             return impl_getPropertyFromId_nothrow( _nPropId ) != NULL;
262*cdf0e10cSrcweir         }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         /** retrieves a property given by name
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir             @throws UnknownPropertyException
267*cdf0e10cSrcweir                 if the handler does not support a property with the given name
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir             @seealso doDescribeSupportedProperties
270*cdf0e10cSrcweir         */
271*cdf0e10cSrcweir         const ::com::sun::star::beans::Property&
272*cdf0e10cSrcweir                     impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         /** get the name of a property given by handle
275*cdf0e10cSrcweir         */
276*cdf0e10cSrcweir         inline ::rtl::OUString
277*cdf0e10cSrcweir                     impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const;
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir         /** returns the value of the ContextDocument property in the ComponentContext which was used to create
280*cdf0e10cSrcweir             this handler.
281*cdf0e10cSrcweir         */
282*cdf0e10cSrcweir         inline ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
283*cdf0e10cSrcweir                     impl_getContextDocument_nothrow() const
284*cdf0e10cSrcweir         {
285*cdf0e10cSrcweir             return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >(
286*cdf0e10cSrcweir                 m_aContext.getContextValueByAsciiName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY );
287*cdf0e10cSrcweir         }
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir         /** marks the context document as modified
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir             @see impl_getContextDocument_nothrow
292*cdf0e10cSrcweir         */
293*cdf0e10cSrcweir         void impl_setContextDocumentModified_nothrow() const;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir         /// determines whether our component has a given property
296*cdf0e10cSrcweir         bool impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const;
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir         /** determines the default measure unit for the document in which our component lives
299*cdf0e10cSrcweir         */
300*cdf0e10cSrcweir         sal_Int16 impl_getDocumentMeasurementUnit_throw() const;
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     private:
303*cdf0e10cSrcweir         PropertyHandler();                                    // never implemented
304*cdf0e10cSrcweir         PropertyHandler( const PropertyHandler& );            // never implemented
305*cdf0e10cSrcweir         PropertyHandler& operator=( const PropertyHandler& ); // never implemented
306*cdf0e10cSrcweir     };
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir     //--------------------------------------------------------------------
309*cdf0e10cSrcweir     inline void PropertyHandler::addStringPropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
310*cdf0e10cSrcweir     {
311*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), _nAttribs );
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     inline void PropertyHandler::addInt32PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
315*cdf0e10cSrcweir     {
316*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >( NULL ) ), _nAttribs );
317*cdf0e10cSrcweir     }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir     inline void PropertyHandler::addInt16PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
320*cdf0e10cSrcweir     {
321*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), _nAttribs );
322*cdf0e10cSrcweir     }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     inline void PropertyHandler::addDoublePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
325*cdf0e10cSrcweir     {
326*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< double* >( NULL ) ), _nAttribs );
327*cdf0e10cSrcweir     }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir     inline void PropertyHandler::addDatePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
330*cdf0e10cSrcweir     {
331*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Date* >( NULL ) ), _nAttribs );
332*cdf0e10cSrcweir     }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir     inline void PropertyHandler::addTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
335*cdf0e10cSrcweir     {
336*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Time* >( NULL ) ), _nAttribs );
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     inline void PropertyHandler::addDateTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
340*cdf0e10cSrcweir     {
341*cdf0e10cSrcweir         implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::DateTime* >( NULL ) ), _nAttribs );
342*cdf0e10cSrcweir     }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     inline ::rtl::OUString PropertyHandler::impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const
345*cdf0e10cSrcweir     {
346*cdf0e10cSrcweir         const ::com::sun::star::beans::Property* pProp = impl_getPropertyFromId_nothrow( _nPropId );
347*cdf0e10cSrcweir         return pProp ? pProp->Name : ::rtl::OUString();
348*cdf0e10cSrcweir     }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     //====================================================================
351*cdf0e10cSrcweir 	//= PropertyHandlerComponent
352*cdf0e10cSrcweir 	//====================================================================
353*cdf0e10cSrcweir     typedef ::cppu::ImplHelper1 <   ::com::sun::star::lang::XServiceInfo
354*cdf0e10cSrcweir                                 >   PropertyHandlerComponent_Base;
355*cdf0e10cSrcweir     /** PropertyHandler implementation which additionally supports XServiceInfo
356*cdf0e10cSrcweir     */
357*cdf0e10cSrcweir     class PropertyHandlerComponent  :public PropertyHandler
358*cdf0e10cSrcweir                                     ,public PropertyHandlerComponent_Base
359*cdf0e10cSrcweir     {
360*cdf0e10cSrcweir     protected:
361*cdf0e10cSrcweir         PropertyHandlerComponent(
362*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
363*cdf0e10cSrcweir         );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         DECLARE_XINTERFACE()
366*cdf0e10cSrcweir         DECLARE_XTYPEPROVIDER()
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir         // XServiceInfo
369*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
370*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
371*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
372*cdf0e10cSrcweir     };
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir     //====================================================================
375*cdf0e10cSrcweir 	//= HandlerComponentBase
376*cdf0e10cSrcweir 	//====================================================================
377*cdf0e10cSrcweir     /** a PropertyHandlerComponent implementation which routes XServiceInfo::getImplementationName and
378*cdf0e10cSrcweir         XServiceInfo::getSupportedServiceNames to static versions of those methods, which are part of
379*cdf0e10cSrcweir         the derived class.
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir         Additionally, a method <member>Create</member> is provided which takes a component context, and returns a new
382*cdf0e10cSrcweir         instance of the derived class. This <member>Create</member> is used to register the implementation
383*cdf0e10cSrcweir         of the derived class at the <type>PcrModule</type>.
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir         Well, every time we're talking about derived class, we in fact mean the template argument of
386*cdf0e10cSrcweir         <type>HandlerComponentBase</type>. But usually this equals your derived class:
387*cdf0e10cSrcweir         <pre>
388*cdf0e10cSrcweir         class MyHandler;
389*cdf0e10cSrcweir         typedef HandlerComponentBase< MyHandler > MyHandler_Base;
390*cdf0e10cSrcweir         class MyHandler : MyHandler_Base
391*cdf0e10cSrcweir         {
392*cdf0e10cSrcweir             ...
393*cdf0e10cSrcweir         public:
394*cdf0e10cSrcweir             static ::rtl::OUString SAL_CALL getImplementationName_static(  ) throw (::com::sun::star::uno::RuntimeException);
395*cdf0e10cSrcweir             static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static(  ) throw (::com::sun::star::uno::RuntimeException);
396*cdf0e10cSrcweir         };
397*cdf0e10cSrcweir         </pre>
398*cdf0e10cSrcweir     */
399*cdf0e10cSrcweir     template < class HANDLER >
400*cdf0e10cSrcweir     class HandlerComponentBase : public PropertyHandlerComponent
401*cdf0e10cSrcweir     {
402*cdf0e10cSrcweir     protected:
403*cdf0e10cSrcweir         HandlerComponentBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
404*cdf0e10cSrcweir             :PropertyHandlerComponent( _rxContext )
405*cdf0e10cSrcweir         {
406*cdf0e10cSrcweir         }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     protected:
409*cdf0e10cSrcweir         // XServiceInfo
410*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
411*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
412*cdf0e10cSrcweir         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir     public:
415*cdf0e10cSrcweir         /** registers the implementation of HANDLER at the <type>PcrModule</type>
416*cdf0e10cSrcweir         */
417*cdf0e10cSrcweir         static void registerImplementation();
418*cdf0e10cSrcweir     };
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 	//--------------------------------------------------------------------
421*cdf0e10cSrcweir     template < class HANDLER >
422*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL HandlerComponentBase< HANDLER >::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)
423*cdf0e10cSrcweir     {
424*cdf0e10cSrcweir         return HANDLER::getImplementationName_static();
425*cdf0e10cSrcweir     }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 	//--------------------------------------------------------------------
428*cdf0e10cSrcweir     template < class HANDLER >
429*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL HandlerComponentBase< HANDLER >::getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException)
430*cdf0e10cSrcweir     {
431*cdf0e10cSrcweir         return HANDLER::getSupportedServiceNames_static();
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 	//--------------------------------------------------------------------
435*cdf0e10cSrcweir     template < class HANDLER >
436*cdf0e10cSrcweir     void HandlerComponentBase< HANDLER >::registerImplementation()
437*cdf0e10cSrcweir     {
438*cdf0e10cSrcweir         PcrModule::getInstance().registerImplementation(
439*cdf0e10cSrcweir             HANDLER::getImplementationName_static(),
440*cdf0e10cSrcweir             HANDLER::getSupportedServiceNames_static(),
441*cdf0e10cSrcweir             HANDLER::Create
442*cdf0e10cSrcweir         );
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	//--------------------------------------------------------------------
446*cdf0e10cSrcweir     template < class HANDLER >
447*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL HandlerComponentBase< HANDLER >::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
448*cdf0e10cSrcweir     {
449*cdf0e10cSrcweir         return *( new HANDLER( _rxContext ) );
450*cdf0e10cSrcweir     }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir //........................................................................
453*cdf0e10cSrcweir } // namespace pcr
454*cdf0e10cSrcweir //........................................................................
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir #endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
457*cdf0e10cSrcweir 
458