1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*2a97ec55SAndrew Rist * distributed with this work for additional information
6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at
10*2a97ec55SAndrew Rist *
11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist *
13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the
17*2a97ec55SAndrew Rist * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist * under the License.
19*2a97ec55SAndrew Rist *
20*2a97ec55SAndrew Rist *************************************************************/
21*2a97ec55SAndrew Rist
22*2a97ec55SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "modulepcr.hxx"
27cdf0e10cSrcweir #include "pcrcommon.hxx"
28cdf0e10cSrcweir #include "inspectormodelbase.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir /** === begin UNO includes === **/
31cdf0e10cSrcweir #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
33cdf0e10cSrcweir /** === end UNO includes === **/
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
38cdf0e10cSrcweir #include <comphelper/uno3.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir //........................................................................
41cdf0e10cSrcweir namespace pcr
42cdf0e10cSrcweir {
43cdf0e10cSrcweir //........................................................................
44cdf0e10cSrcweir
45cdf0e10cSrcweir /** === begin UNO using === **/
46cdf0e10cSrcweir using ::com::sun::star::inspection::XObjectInspectorModel;
47cdf0e10cSrcweir using ::com::sun::star::lang::XInitialization;
48cdf0e10cSrcweir using ::com::sun::star::lang::XServiceInfo;
49cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
50cdf0e10cSrcweir using ::com::sun::star::uno::XComponentContext;
51cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException;
52cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
53cdf0e10cSrcweir using ::com::sun::star::uno::Any;
54cdf0e10cSrcweir using ::com::sun::star::inspection::PropertyCategoryDescriptor;
55cdf0e10cSrcweir using ::com::sun::star::uno::Exception;
56cdf0e10cSrcweir using ::com::sun::star::uno::XInterface;
57cdf0e10cSrcweir using ::com::sun::star::lang::IllegalArgumentException;
58cdf0e10cSrcweir using ::com::sun::star::ucb::AlreadyInitializedException;
59cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySetInfo;
60cdf0e10cSrcweir using ::com::sun::star::uno::makeAny;
61cdf0e10cSrcweir /** === end UNO using === **/
62cdf0e10cSrcweir
63cdf0e10cSrcweir //====================================================================
64cdf0e10cSrcweir //= ObjectInspectorModel
65cdf0e10cSrcweir //====================================================================
66cdf0e10cSrcweir class ObjectInspectorModel : public ImplInspectorModel
67cdf0e10cSrcweir {
68cdf0e10cSrcweir private:
69cdf0e10cSrcweir Sequence< Any > m_aFactories;
70cdf0e10cSrcweir
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir ObjectInspectorModel( const Reference< XComponentContext >& _rxContext );
73cdf0e10cSrcweir
74cdf0e10cSrcweir // XObjectInspectorModel
75cdf0e10cSrcweir virtual Sequence< Any > SAL_CALL getHandlerFactories() throw (RuntimeException);
76cdf0e10cSrcweir virtual Sequence< PropertyCategoryDescriptor > SAL_CALL describeCategories( ) throw (RuntimeException);
77cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL getPropertyOrderIndex( const ::rtl::OUString& PropertyName ) throw (RuntimeException);
78cdf0e10cSrcweir
79cdf0e10cSrcweir // XInitialization
80cdf0e10cSrcweir virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
81cdf0e10cSrcweir
82cdf0e10cSrcweir // XServiceInfo
83cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
84cdf0e10cSrcweir virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
85cdf0e10cSrcweir
86cdf0e10cSrcweir // XServiceInfo - static versions
87cdf0e10cSrcweir static ::rtl::OUString getImplementationName_static( ) throw(RuntimeException);
88cdf0e10cSrcweir static Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(RuntimeException);
89cdf0e10cSrcweir static Reference< XInterface > SAL_CALL
90cdf0e10cSrcweir Create(const Reference< XComponentContext >&);
91cdf0e10cSrcweir
92cdf0e10cSrcweir protected:
93cdf0e10cSrcweir void createDefault();
94cdf0e10cSrcweir void createWithHandlerFactories( const Sequence< Any >& _rFactories );
95cdf0e10cSrcweir void createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
96cdf0e10cSrcweir
97cdf0e10cSrcweir private:
98cdf0e10cSrcweir /** checks a given condition to be <TRUE/>, and throws an IllegalArgumentException if not
99cdf0e10cSrcweir */
100cdf0e10cSrcweir void impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition );
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
103cdf0e10cSrcweir //====================================================================
104cdf0e10cSrcweir //= ObjectInspectorModel
105cdf0e10cSrcweir //====================================================================
ObjectInspectorModel(const Reference<XComponentContext> & _rxContext)106cdf0e10cSrcweir ObjectInspectorModel::ObjectInspectorModel( const Reference< XComponentContext >& _rxContext )
107cdf0e10cSrcweir :ImplInspectorModel( _rxContext )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir //--------------------------------------------------------------------
getHandlerFactories()112cdf0e10cSrcweir Sequence< Any > SAL_CALL ObjectInspectorModel::getHandlerFactories() throw (RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir return m_aFactories;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir //--------------------------------------------------------------------
describeCategories()118cdf0e10cSrcweir Sequence< PropertyCategoryDescriptor > SAL_CALL ObjectInspectorModel::describeCategories( ) throw (RuntimeException)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir // no category info provided by this default implementation
121cdf0e10cSrcweir return Sequence< PropertyCategoryDescriptor >( );
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir //--------------------------------------------------------------------
getPropertyOrderIndex(const::rtl::OUString &)125cdf0e10cSrcweir ::sal_Int32 SAL_CALL ObjectInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& /*PropertyName*/ ) throw (RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir // no ordering provided by this default implementation
128cdf0e10cSrcweir return 0;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir //--------------------------------------------------------------------
initialize(const Sequence<Any> & _arguments)132cdf0e10cSrcweir void SAL_CALL ObjectInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
135cdf0e10cSrcweir if ( m_aFactories.getLength() )
136cdf0e10cSrcweir throw AlreadyInitializedException();
137cdf0e10cSrcweir
138cdf0e10cSrcweir StlSyntaxSequence< Any > arguments( _arguments );
139cdf0e10cSrcweir if ( arguments.empty() )
140cdf0e10cSrcweir { // constructor: "createDefault()"
141cdf0e10cSrcweir createDefault();
142cdf0e10cSrcweir return;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir Sequence< Any > factories;
146cdf0e10cSrcweir impl_verifyArgument_throw( arguments[0] >>= factories, 1 );
147cdf0e10cSrcweir
148cdf0e10cSrcweir if ( arguments.size() == 1 )
149cdf0e10cSrcweir { // constructor: "createWithHandlerFactories( any[] )"
150cdf0e10cSrcweir createWithHandlerFactories( factories );
151cdf0e10cSrcweir return;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
155cdf0e10cSrcweir if ( arguments.size() == 3 )
156cdf0e10cSrcweir { // constructor: "createWithHandlerFactoriesAndHelpSection( any[], long, long )"
157cdf0e10cSrcweir impl_verifyArgument_throw( arguments[1] >>= nMinHelpTextLines, 2 );
158cdf0e10cSrcweir impl_verifyArgument_throw( arguments[2] >>= nMaxHelpTextLines, 3 );
159cdf0e10cSrcweir createWithHandlerFactoriesAndHelpSection( factories, nMinHelpTextLines, nMaxHelpTextLines );
160cdf0e10cSrcweir return;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir impl_verifyArgument_throw( false, 2 );
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir //--------------------------------------------------------------------
getImplementationName()167cdf0e10cSrcweir ::rtl::OUString SAL_CALL ObjectInspectorModel::getImplementationName( ) throw (RuntimeException)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir return getImplementationName_static();
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir //--------------------------------------------------------------------
getSupportedServiceNames()173cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ObjectInspectorModel::getSupportedServiceNames( ) throw (RuntimeException)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir return getSupportedServiceNames_static();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir //--------------------------------------------------------------------
getImplementationName_static()179cdf0e10cSrcweir ::rtl::OUString ObjectInspectorModel::getImplementationName_static( ) throw(RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.extensions.ObjectInspectorModel" ) );
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir //--------------------------------------------------------------------
getSupportedServiceNames_static()185cdf0e10cSrcweir Sequence< ::rtl::OUString > ObjectInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
186cdf0e10cSrcweir {
187cdf0e10cSrcweir ::rtl::OUString sService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspectorModel" ) );
188cdf0e10cSrcweir return Sequence< ::rtl::OUString >( &sService, 1 );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir //--------------------------------------------------------------------
Create(const Reference<XComponentContext> & _rxContext)192cdf0e10cSrcweir Reference< XInterface > SAL_CALL ObjectInspectorModel::Create(const Reference< XComponentContext >& _rxContext )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir return *( new ObjectInspectorModel( _rxContext ) );
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir //--------------------------------------------------------------------
createDefault()198cdf0e10cSrcweir void ObjectInspectorModel::createDefault()
199cdf0e10cSrcweir {
200cdf0e10cSrcweir m_aFactories.realloc( 1 );
201cdf0e10cSrcweir m_aFactories[0] <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
204cdf0e10cSrcweir //--------------------------------------------------------------------
createWithHandlerFactories(const Sequence<Any> & _rFactories)205cdf0e10cSrcweir void ObjectInspectorModel::createWithHandlerFactories( const Sequence< Any >& _rFactories )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
208cdf0e10cSrcweir m_aFactories = _rFactories;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir //--------------------------------------------------------------------
createWithHandlerFactoriesAndHelpSection(const Sequence<Any> & _rFactories,sal_Int32 _nMinHelpTextLines,sal_Int32 _nMaxHelpTextLines)212cdf0e10cSrcweir void ObjectInspectorModel::createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
215cdf0e10cSrcweir impl_verifyArgument_throw( _nMinHelpTextLines >= 1, 2 );
216cdf0e10cSrcweir impl_verifyArgument_throw( _nMaxHelpTextLines >= 1, 3 );
217cdf0e10cSrcweir impl_verifyArgument_throw( _nMinHelpTextLines <= _nMaxHelpTextLines, 2 );
218cdf0e10cSrcweir
219cdf0e10cSrcweir m_aFactories = _rFactories;
220cdf0e10cSrcweir enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
223cdf0e10cSrcweir //--------------------------------------------------------------------
impl_verifyArgument_throw(bool _bCondition,sal_Int16 _nArgumentPosition)224cdf0e10cSrcweir void ObjectInspectorModel::impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir if ( !_bCondition )
227cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString(), *this, _nArgumentPosition );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir //........................................................................
231cdf0e10cSrcweir } // namespace pcr
232cdf0e10cSrcweir //........................................................................
233cdf0e10cSrcweir
234cdf0e10cSrcweir //------------------------------------------------------------------------
createRegistryInfo_ObjectInspectorModel()235cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_ObjectInspectorModel()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir ::pcr::OAutoRegistration< ::pcr::ObjectInspectorModel > aObjectInspectorModelRegistration;
238cdf0e10cSrcweir }
239