1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: defaultforminspection.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include "defaultforminspection.hxx"
34 #include "pcrcommon.hxx"
35 #ifndef EXTENSIONS_PROPRESID_HRC
36 #include "propresid.hrc"
38 #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
39 #include "formresid.hrc"
41 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
42 #include "modulepcr.hxx"
44 #ifndef _EXTENSIONS_FORMCTRLR_FORMHELPID_HRC_
45 #include "formhelpid.hrc"
47 #include "formmetadata.hxx"
49 /** === begin UNO includes === **/
50 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
51 #include <com/sun/star/lang/IllegalArgumentException.hpp>
52 /** === end UNO includes === **/
53 #include <cppuhelper/implbase1.hxx>
54 #include <osl/diagnose.h>
56 //------------------------------------------------------------------------
57 extern "C" void SAL_CALL
createRegistryInfo_DefaultFormComponentInspectorModel()
59 ::pcr::OAutoRegistration
< ::pcr::DefaultFormComponentInspectorModel
> aAutoRegistration
;
62 //........................................................................
65 //........................................................................
67 /** === begin UNO using === **/
68 using ::com::sun::star::uno::Reference
;
69 using ::com::sun::star::uno::Sequence
;
70 using ::com::sun::star::uno::Any
;
71 using ::com::sun::star::uno::RuntimeException
;
72 using ::com::sun::star::uno::XInterface
;
73 using ::com::sun::star::uno::XComponentContext
;
74 using ::com::sun::star::uno::Exception
;
75 using ::com::sun::star::lang::EventObject
;
76 using ::com::sun::star::inspection::PropertyCategoryDescriptor
;
77 using ::com::sun::star::beans::UnknownPropertyException
;
78 using ::com::sun::star::ucb::AlreadyInitializedException
;
79 using ::com::sun::star::lang::IllegalArgumentException
;
80 /** === end UNO using === **/
82 //====================================================================
83 //= DefaultFormComponentInspectorModel
84 //====================================================================
85 //--------------------------------------------------------------------
86 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference
< XComponentContext
>& _rxContext
, bool _bUseFormFormComponentHandlers
)
87 :ImplInspectorModel( _rxContext
)
88 ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers
)
89 ,m_bConstructed( false )
90 ,m_pInfoService( new OPropertyInfoService
)
94 //------------------------------------------------------------------------
95 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
99 //------------------------------------------------------------------------
100 ::rtl::OUString SAL_CALL
DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException
)
102 return getImplementationName_static();
105 //------------------------------------------------------------------------
106 Sequence
< ::rtl::OUString
> SAL_CALL
DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException
)
108 return getSupportedServiceNames_static();
111 //------------------------------------------------------------------------
112 ::rtl::OUString
DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException
)
114 return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
117 //------------------------------------------------------------------------
118 Sequence
< ::rtl::OUString
> DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException
)
120 Sequence
< ::rtl::OUString
> aSupported(1);
121 aSupported
[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" );
125 //------------------------------------------------------------------------
126 Reference
< XInterface
> SAL_CALL
DefaultFormComponentInspectorModel::Create( const Reference
< XComponentContext
>& _rxContext
)
128 return *new DefaultFormComponentInspectorModel( _rxContext
);
131 //--------------------------------------------------------------------
132 Sequence
< Any
> SAL_CALL
DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException
)
134 ::osl::MutexGuard
aGuard( m_aMutex
);
136 // service names for all our handlers
139 const sal_Char
* serviceName
;
143 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
144 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
146 // generic virtual edit properties
147 { "com.sun.star.form.inspection.EditPropertyHandler", false },
149 // a handler which virtualizes the ButtonType property, to provide additional types like
150 // "move to next record"
151 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
153 // a handler for script events bound to form components or dialog elements
154 { "com.sun.star.form.inspection.EventHandler", false },
156 // a handler which introduces virtual properties for binding controls to spreadsheet cells
157 { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
159 // properties related to binding to an XForms DOM node
160 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
162 // properties related to the XSD data against which a control content is validated
163 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
165 // a handler which cares for XForms submissions
166 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
168 // a handler which cares for geometry properties of form controls
169 { "com.sun.star.form.inspection.FormGeometryHandler", true }
172 sal_Int32 nFactories
= sizeof( aFactories
) / sizeof( aFactories
[ 0 ] );
173 Sequence
< Any
> aReturn( nFactories
);
174 Any
* pReturn
= aReturn
.getArray();
175 for ( sal_Int32 i
= 0; i
< nFactories
; ++i
)
177 if ( aFactories
[i
].isFormOnly
&& !m_bUseFormComponentHandlers
)
179 *pReturn
++ <<= ::rtl::OUString::createFromAscii( aFactories
[i
].serviceName
);
181 aReturn
.realloc( pReturn
- aReturn
.getArray() );
186 //--------------------------------------------------------------------
187 Sequence
< PropertyCategoryDescriptor
> SAL_CALL
DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException
)
189 ::osl::MutexGuard
aGuard( m_aMutex
);
193 const sal_Char
* programmaticName
;
197 { "General", RID_STR_PROPPAGE_DEFAULT
, HID_FM_PROPDLG_TAB_GENERAL
},
198 { "Data", RID_STR_PROPPAGE_DATA
, HID_FM_PROPDLG_TAB_DATA
},
199 { "Events", RID_STR_EVENTS
, HID_FM_PROPDLG_TAB_EVT
}
202 sal_Int32 nCategories
= sizeof( aCategories
) / sizeof( aCategories
[0] );
203 Sequence
< PropertyCategoryDescriptor
> aReturn( nCategories
);
204 PropertyCategoryDescriptor
* pReturn
= aReturn
.getArray();
205 for ( sal_Int32 i
=0; i
<nCategories
; ++i
, ++pReturn
)
207 pReturn
->ProgrammaticName
= ::rtl::OUString::createFromAscii( aCategories
[i
].programmaticName
);
208 pReturn
->UIName
= String( PcrRes( aCategories
[i
].uiNameResId
) );
209 pReturn
->HelpURL
= HelpIdUrl::getHelpURL( aCategories
[i
].helpId
);
215 //--------------------------------------------------------------------
216 ::sal_Int32 SAL_CALL
DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString
& _rPropertyName
) throw (RuntimeException
)
218 sal_Int32
nPropertyId( m_pInfoService
->getPropertyId( _rPropertyName
) );
219 if ( nPropertyId
== -1 )
221 if ( _rPropertyName
.indexOf( ';' ) != -1 )
222 // it's an event. Just give it an arbitrary number - events will be on a separate
223 // page, and by definition, if two properties have the same OrderIndex, then
224 // they will be ordered as they appear in the handler's getSupportedProperties.
228 return m_pInfoService
->getPropertyPos( nPropertyId
);
231 //--------------------------------------------------------------------
232 void SAL_CALL
DefaultFormComponentInspectorModel::initialize( const Sequence
< Any
>& _arguments
) throw (Exception
, RuntimeException
)
234 if ( m_bConstructed
)
235 throw AlreadyInitializedException();
237 StlSyntaxSequence
< Any
> arguments( _arguments
);
238 if ( arguments
.empty() )
239 { // constructor: "createDefault()"
244 sal_Int32
nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
245 if ( arguments
.size() == 2 )
246 { // constructor: "createWithHelpSection( long, long )"
247 if ( !( arguments
[0] >>= nMinHelpTextLines
) || !( arguments
[1] >>= nMaxHelpTextLines
) )
248 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
249 createWithHelpSection( nMinHelpTextLines
, nMaxHelpTextLines
);
253 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
256 //--------------------------------------------------------------------
257 void DefaultFormComponentInspectorModel::createDefault()
259 m_bConstructed
= true;
262 //--------------------------------------------------------------------
263 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines
, sal_Int32 _nMaxHelpTextLines
)
265 if ( ( _nMinHelpTextLines
<= 0 ) || ( _nMaxHelpTextLines
<= 0 ) || ( _nMinHelpTextLines
> _nMaxHelpTextLines
) )
266 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
268 enableHelpSectionProperties( _nMinHelpTextLines
, _nMaxHelpTextLines
);
269 m_bConstructed
= true;
272 //........................................................................
274 //........................................................................