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 "defaultforminspection.hxx"
31 #include "pcrcommon.hxx"
32 #ifndef EXTENSIONS_PROPRESID_HRC
33 #include "propresid.hrc"
35 #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
36 #include "formresid.hrc"
38 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
39 #include "modulepcr.hxx"
41 #include "propctrlr.hrc"
42 #include "formmetadata.hxx"
44 /** === begin UNO includes === **/
45 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
46 #include <com/sun/star/lang/IllegalArgumentException.hpp>
47 /** === end UNO includes === **/
48 #include <cppuhelper/implbase1.hxx>
49 #include <osl/diagnose.h>
51 //------------------------------------------------------------------------
52 extern "C" void SAL_CALL
createRegistryInfo_DefaultFormComponentInspectorModel()
54 ::pcr::OAutoRegistration
< ::pcr::DefaultFormComponentInspectorModel
> aAutoRegistration
;
57 //........................................................................
60 //........................................................................
62 /** === begin UNO using === **/
63 using ::com::sun::star::uno::Reference
;
64 using ::com::sun::star::uno::Sequence
;
65 using ::com::sun::star::uno::Any
;
66 using ::com::sun::star::uno::RuntimeException
;
67 using ::com::sun::star::uno::XInterface
;
68 using ::com::sun::star::uno::XComponentContext
;
69 using ::com::sun::star::uno::Exception
;
70 using ::com::sun::star::lang::EventObject
;
71 using ::com::sun::star::inspection::PropertyCategoryDescriptor
;
72 using ::com::sun::star::beans::UnknownPropertyException
;
73 using ::com::sun::star::ucb::AlreadyInitializedException
;
74 using ::com::sun::star::lang::IllegalArgumentException
;
75 /** === end UNO using === **/
77 //====================================================================
78 //= DefaultFormComponentInspectorModel
79 //====================================================================
80 //--------------------------------------------------------------------
81 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference
< XComponentContext
>& _rxContext
, bool _bUseFormFormComponentHandlers
)
82 :ImplInspectorModel( _rxContext
)
83 ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers
)
84 ,m_bConstructed( false )
85 ,m_pInfoService( new OPropertyInfoService
)
89 //------------------------------------------------------------------------
90 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
94 //------------------------------------------------------------------------
95 ::rtl::OUString SAL_CALL
DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException
)
97 return getImplementationName_static();
100 //------------------------------------------------------------------------
101 Sequence
< ::rtl::OUString
> SAL_CALL
DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException
)
103 return getSupportedServiceNames_static();
106 //------------------------------------------------------------------------
107 ::rtl::OUString
DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException
)
109 return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
112 //------------------------------------------------------------------------
113 Sequence
< ::rtl::OUString
> DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException
)
115 Sequence
< ::rtl::OUString
> aSupported(1);
116 aSupported
[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" );
120 //------------------------------------------------------------------------
121 Reference
< XInterface
> SAL_CALL
DefaultFormComponentInspectorModel::Create( const Reference
< XComponentContext
>& _rxContext
)
123 return *new DefaultFormComponentInspectorModel( _rxContext
);
126 //--------------------------------------------------------------------
127 Sequence
< Any
> SAL_CALL
DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException
)
129 ::osl::MutexGuard
aGuard( m_aMutex
);
131 // service names for all our handlers
134 const sal_Char
* serviceName
;
138 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
139 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
141 // generic virtual edit properties
142 { "com.sun.star.form.inspection.EditPropertyHandler", false },
144 // a handler which virtualizes the ButtonType property, to provide additional types like
145 // "move to next record"
146 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
148 // a handler for script events bound to form components or dialog elements
149 { "com.sun.star.form.inspection.EventHandler", false },
151 // a handler which introduces virtual properties for binding controls to spreadsheet cells
152 { "com.sun.star.form.inspection.CellBindingPropertyHandler", true },
154 // properties related to binding to an XForms DOM node
155 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
157 // properties related to the XSD data against which a control content is validated
158 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
160 // a handler which cares for XForms submissions
161 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
163 // a handler which cares for geometry properties of form controls
164 { "com.sun.star.form.inspection.FormGeometryHandler", true }
167 sal_Int32 nFactories
= sizeof( aFactories
) / sizeof( aFactories
[ 0 ] );
168 Sequence
< Any
> aReturn( nFactories
);
169 Any
* pReturn
= aReturn
.getArray();
170 for ( sal_Int32 i
= 0; i
< nFactories
; ++i
)
172 if ( aFactories
[i
].isFormOnly
&& !m_bUseFormComponentHandlers
)
174 *pReturn
++ <<= ::rtl::OUString::createFromAscii( aFactories
[i
].serviceName
);
176 aReturn
.realloc( pReturn
- aReturn
.getArray() );
181 //--------------------------------------------------------------------
182 Sequence
< PropertyCategoryDescriptor
> SAL_CALL
DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException
)
184 ::osl::MutexGuard
aGuard( m_aMutex
);
188 const sal_Char
* programmaticName
;
192 { "General", RID_STR_PROPPAGE_DEFAULT
, HID_FM_PROPDLG_TAB_GENERAL
},
193 { "Data", RID_STR_PROPPAGE_DATA
, HID_FM_PROPDLG_TAB_DATA
},
194 { "Events", RID_STR_EVENTS
, HID_FM_PROPDLG_TAB_EVT
}
197 sal_Int32 nCategories
= sizeof( aCategories
) / sizeof( aCategories
[0] );
198 Sequence
< PropertyCategoryDescriptor
> aReturn( nCategories
);
199 PropertyCategoryDescriptor
* pReturn
= aReturn
.getArray();
200 for ( sal_Int32 i
=0; i
<nCategories
; ++i
, ++pReturn
)
202 pReturn
->ProgrammaticName
= ::rtl::OUString::createFromAscii( aCategories
[i
].programmaticName
);
203 pReturn
->UIName
= String( PcrRes( aCategories
[i
].uiNameResId
) );
204 pReturn
->HelpURL
= HelpIdUrl::getHelpURL( aCategories
[i
].helpId
);
210 //--------------------------------------------------------------------
211 ::sal_Int32 SAL_CALL
DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString
& _rPropertyName
) throw (RuntimeException
)
213 sal_Int32
nPropertyId( m_pInfoService
->getPropertyId( _rPropertyName
) );
214 if ( nPropertyId
== -1 )
216 if ( _rPropertyName
.indexOf( ';' ) != -1 )
217 // it's an event. Just give it an arbitrary number - events will be on a separate
218 // page, and by definition, if two properties have the same OrderIndex, then
219 // they will be ordered as they appear in the handler's getSupportedProperties.
223 return m_pInfoService
->getPropertyPos( nPropertyId
);
226 //--------------------------------------------------------------------
227 void SAL_CALL
DefaultFormComponentInspectorModel::initialize( const Sequence
< Any
>& _arguments
) throw (Exception
, RuntimeException
)
229 if ( m_bConstructed
)
230 throw AlreadyInitializedException();
232 StlSyntaxSequence
< Any
> arguments( _arguments
);
233 if ( arguments
.empty() )
234 { // constructor: "createDefault()"
239 sal_Int32
nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
240 if ( arguments
.size() == 2 )
241 { // constructor: "createWithHelpSection( long, long )"
242 if ( !( arguments
[0] >>= nMinHelpTextLines
) || !( arguments
[1] >>= nMaxHelpTextLines
) )
243 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
244 createWithHelpSection( nMinHelpTextLines
, nMaxHelpTextLines
);
248 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
251 //--------------------------------------------------------------------
252 void DefaultFormComponentInspectorModel::createDefault()
254 m_bConstructed
= true;
257 //--------------------------------------------------------------------
258 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines
, sal_Int32 _nMaxHelpTextLines
)
260 if ( ( _nMinHelpTextLines
<= 0 ) || ( _nMaxHelpTextLines
<= 0 ) || ( _nMinHelpTextLines
> _nMaxHelpTextLines
) )
261 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
263 enableHelpSectionProperties( _nMinHelpTextLines
, _nMaxHelpTextLines
);
264 m_bConstructed
= true;
267 //........................................................................
269 //........................................................................