1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "modulepcr.hxx"
31 #include "pcrcommon.hxx"
32 #include "inspectormodelbase.hxx"
34 /** === begin UNO includes === **/
35 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
36 #include <com/sun/star/lang/IllegalArgumentException.hpp>
37 /** === end UNO includes === **/
39 #include <cppuhelper/implbase3.hxx>
41 #include <comphelper/broadcasthelper.hxx>
42 #include <comphelper/uno3.hxx>
44 //........................................................................
47 //........................................................................
49 /** === begin UNO using === **/
50 using ::com::sun::star::inspection::XObjectInspectorModel
;
51 using ::com::sun::star::lang::XInitialization
;
52 using ::com::sun::star::lang::XServiceInfo
;
53 using ::com::sun::star::uno::Reference
;
54 using ::com::sun::star::uno::XComponentContext
;
55 using ::com::sun::star::uno::RuntimeException
;
56 using ::com::sun::star::uno::Sequence
;
57 using ::com::sun::star::uno::Any
;
58 using ::com::sun::star::inspection::PropertyCategoryDescriptor
;
59 using ::com::sun::star::uno::Exception
;
60 using ::com::sun::star::uno::XInterface
;
61 using ::com::sun::star::lang::IllegalArgumentException
;
62 using ::com::sun::star::ucb::AlreadyInitializedException
;
63 using ::com::sun::star::beans::XPropertySetInfo
;
64 using ::com::sun::star::uno::makeAny
;
65 /** === end UNO using === **/
67 //====================================================================
68 //= ObjectInspectorModel
69 //====================================================================
70 class ObjectInspectorModel
: public ImplInspectorModel
73 Sequence
< Any
> m_aFactories
;
76 ObjectInspectorModel( const Reference
< XComponentContext
>& _rxContext
);
78 // XObjectInspectorModel
79 virtual Sequence
< Any
> SAL_CALL
getHandlerFactories() throw (RuntimeException
);
80 virtual Sequence
< PropertyCategoryDescriptor
> SAL_CALL
describeCategories( ) throw (RuntimeException
);
81 virtual ::sal_Int32 SAL_CALL
getPropertyOrderIndex( const ::rtl::OUString
& PropertyName
) throw (RuntimeException
);
84 virtual void SAL_CALL
initialize( const Sequence
< Any
>& aArguments
) throw (Exception
, RuntimeException
);
87 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw (RuntimeException
);
88 virtual Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw (RuntimeException
);
90 // XServiceInfo - static versions
91 static ::rtl::OUString
getImplementationName_static( ) throw(RuntimeException
);
92 static Sequence
< ::rtl::OUString
> getSupportedServiceNames_static( ) throw(RuntimeException
);
93 static Reference
< XInterface
> SAL_CALL
94 Create(const Reference
< XComponentContext
>&);
98 void createWithHandlerFactories( const Sequence
< Any
>& _rFactories
);
99 void createWithHandlerFactoriesAndHelpSection( const Sequence
< Any
>& _rFactories
, sal_Int32 _nMinHelpTextLines
, sal_Int32 _nMaxHelpTextLines
);
102 /** checks a given condition to be <TRUE/>, and throws an IllegalArgumentException if not
104 void impl_verifyArgument_throw( bool _bCondition
, sal_Int16 _nArgumentPosition
);
107 //====================================================================
108 //= ObjectInspectorModel
109 //====================================================================
110 ObjectInspectorModel::ObjectInspectorModel( const Reference
< XComponentContext
>& _rxContext
)
111 :ImplInspectorModel( _rxContext
)
115 //--------------------------------------------------------------------
116 Sequence
< Any
> SAL_CALL
ObjectInspectorModel::getHandlerFactories() throw (RuntimeException
)
121 //--------------------------------------------------------------------
122 Sequence
< PropertyCategoryDescriptor
> SAL_CALL
ObjectInspectorModel::describeCategories( ) throw (RuntimeException
)
124 // no category info provided by this default implementation
125 return Sequence
< PropertyCategoryDescriptor
>( );
128 //--------------------------------------------------------------------
129 ::sal_Int32 SAL_CALL
ObjectInspectorModel::getPropertyOrderIndex( const ::rtl::OUString
& /*PropertyName*/ ) throw (RuntimeException
)
131 // no ordering provided by this default implementation
135 //--------------------------------------------------------------------
136 void SAL_CALL
ObjectInspectorModel::initialize( const Sequence
< Any
>& _arguments
) throw (Exception
, RuntimeException
)
138 ::osl::MutexGuard
aGuard( m_aMutex
);
139 if ( m_aFactories
.getLength() )
140 throw AlreadyInitializedException();
142 StlSyntaxSequence
< Any
> arguments( _arguments
);
143 if ( arguments
.empty() )
144 { // constructor: "createDefault()"
149 Sequence
< Any
> factories
;
150 impl_verifyArgument_throw( arguments
[0] >>= factories
, 1 );
152 if ( arguments
.size() == 1 )
153 { // constructor: "createWithHandlerFactories( any[] )"
154 createWithHandlerFactories( factories
);
158 sal_Int32
nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
159 if ( arguments
.size() == 3 )
160 { // constructor: "createWithHandlerFactoriesAndHelpSection( any[], long, long )"
161 impl_verifyArgument_throw( arguments
[1] >>= nMinHelpTextLines
, 2 );
162 impl_verifyArgument_throw( arguments
[2] >>= nMaxHelpTextLines
, 3 );
163 createWithHandlerFactoriesAndHelpSection( factories
, nMinHelpTextLines
, nMaxHelpTextLines
);
167 impl_verifyArgument_throw( false, 2 );
170 //--------------------------------------------------------------------
171 ::rtl::OUString SAL_CALL
ObjectInspectorModel::getImplementationName( ) throw (RuntimeException
)
173 return getImplementationName_static();
176 //--------------------------------------------------------------------
177 Sequence
< ::rtl::OUString
> SAL_CALL
ObjectInspectorModel::getSupportedServiceNames( ) throw (RuntimeException
)
179 return getSupportedServiceNames_static();
182 //--------------------------------------------------------------------
183 ::rtl::OUString
ObjectInspectorModel::getImplementationName_static( ) throw(RuntimeException
)
185 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.extensions.ObjectInspectorModel" ) );
188 //--------------------------------------------------------------------
189 Sequence
< ::rtl::OUString
> ObjectInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException
)
191 ::rtl::OUString
sService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspectorModel" ) );
192 return Sequence
< ::rtl::OUString
>( &sService
, 1 );
195 //--------------------------------------------------------------------
196 Reference
< XInterface
> SAL_CALL
ObjectInspectorModel::Create(const Reference
< XComponentContext
>& _rxContext
)
198 return *( new ObjectInspectorModel( _rxContext
) );
201 //--------------------------------------------------------------------
202 void ObjectInspectorModel::createDefault()
204 m_aFactories
.realloc( 1 );
205 m_aFactories
[0] <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
208 //--------------------------------------------------------------------
209 void ObjectInspectorModel::createWithHandlerFactories( const Sequence
< Any
>& _rFactories
)
211 impl_verifyArgument_throw( _rFactories
.getLength() > 0, 1 );
212 m_aFactories
= _rFactories
;
215 //--------------------------------------------------------------------
216 void ObjectInspectorModel::createWithHandlerFactoriesAndHelpSection( const Sequence
< Any
>& _rFactories
, sal_Int32 _nMinHelpTextLines
, sal_Int32 _nMaxHelpTextLines
)
218 impl_verifyArgument_throw( _rFactories
.getLength() > 0, 1 );
219 impl_verifyArgument_throw( _nMinHelpTextLines
>= 1, 2 );
220 impl_verifyArgument_throw( _nMaxHelpTextLines
>= 1, 3 );
221 impl_verifyArgument_throw( _nMinHelpTextLines
<= _nMaxHelpTextLines
, 2 );
223 m_aFactories
= _rFactories
;
224 enableHelpSectionProperties( _nMinHelpTextLines
, _nMaxHelpTextLines
);
227 //--------------------------------------------------------------------
228 void ObjectInspectorModel::impl_verifyArgument_throw( bool _bCondition
, sal_Int16 _nArgumentPosition
)
231 throw IllegalArgumentException( ::rtl::OUString(), *this, _nArgumentPosition
);
234 //........................................................................
236 //........................................................................
238 //------------------------------------------------------------------------
239 extern "C" void SAL_CALL
createRegistryInfo_ObjectInspectorModel()
241 ::pcr::OAutoRegistration
< ::pcr::ObjectInspectorModel
> aObjectInspectorModelRegistration
;