1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_extensions.hxx"
31 #include "defaultforminspection.hxx"
32 #include "pcrcommon.hxx"
33 #include "propresid.hrc"
34 #include "formresid.hrc"
35 #include "modulepcr.hxx"
36 #include "propctrlr.hrc"
37 #include "formmetadata.hxx"
39 /** === begin UNO includes === **/
40 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
41 #include <com/sun/star/lang/IllegalArgumentException.hpp>
42 /** === end UNO includes === **/
43 #include <cppuhelper/implbase1.hxx>
44 #include <osl/diagnose.h>
45 #include <sal/macros.h>
47 //------------------------------------------------------------------------
48 extern "C" void SAL_CALL
createRegistryInfo_DefaultFormComponentInspectorModel()
50 ::pcr::OAutoRegistration
< ::pcr::DefaultFormComponentInspectorModel
> aAutoRegistration
;
53 //........................................................................
56 //........................................................................
58 /** === begin UNO using === **/
59 using ::com::sun::star::uno::Reference
;
60 using ::com::sun::star::uno::Sequence
;
61 using ::com::sun::star::uno::Any
;
62 using ::com::sun::star::uno::RuntimeException
;
63 using ::com::sun::star::uno::XInterface
;
64 using ::com::sun::star::uno::XComponentContext
;
65 using ::com::sun::star::uno::Exception
;
66 using ::com::sun::star::lang::EventObject
;
67 using ::com::sun::star::inspection::PropertyCategoryDescriptor
;
68 using ::com::sun::star::beans::UnknownPropertyException
;
69 using ::com::sun::star::ucb::AlreadyInitializedException
;
70 using ::com::sun::star::lang::IllegalArgumentException
;
71 /** === end UNO using === **/
73 //====================================================================
74 //= DefaultFormComponentInspectorModel
75 //====================================================================
76 //--------------------------------------------------------------------
77 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference
< XComponentContext
>& _rxContext
, bool _bUseFormFormComponentHandlers
)
78 :ImplInspectorModel( _rxContext
)
79 ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers
)
80 ,m_bConstructed( false )
81 ,m_pInfoService( new OPropertyInfoService
)
85 //------------------------------------------------------------------------
86 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
90 //------------------------------------------------------------------------
91 ::rtl::OUString SAL_CALL
DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException
)
93 return getImplementationName_static();
96 //------------------------------------------------------------------------
97 Sequence
< ::rtl::OUString
> SAL_CALL
DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException
)
99 return getSupportedServiceNames_static();
102 //------------------------------------------------------------------------
103 ::rtl::OUString
DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException
)
105 return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
108 //------------------------------------------------------------------------
109 Sequence
< ::rtl::OUString
> DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException
)
111 Sequence
< ::rtl::OUString
> aSupported(1);
112 aSupported
[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" );
116 //------------------------------------------------------------------------
117 Reference
< XInterface
> SAL_CALL
DefaultFormComponentInspectorModel::Create( const Reference
< XComponentContext
>& _rxContext
)
119 return *new DefaultFormComponentInspectorModel( _rxContext
);
122 //--------------------------------------------------------------------
123 Sequence
< Any
> SAL_CALL
DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException
)
125 ::osl::MutexGuard
aGuard( m_aMutex
);
127 // service names for all our handlers
130 const sal_Char
* serviceName
;
134 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
135 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
137 // generic virtual edit properties
138 { "com.sun.star.form.inspection.EditPropertyHandler", false },
140 // a handler which virtualizes the ButtonType property, to provide additional types like
141 // "move to next record"
142 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
144 // a handler for script events bound to form components or dialog elements
145 { "com.sun.star.form.inspection.EventHandler", false },
147 // a handler which introduces virtual properties for binding controls to spreadsheet cells
148 { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
150 // properties related to binding to an XForms DOM node
151 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
153 // properties related to the XSD data against which a control content is validated
154 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
156 // a handler which cares for XForms submissions
157 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
159 // a handler which cares for geometry properties of form controls
160 { "com.sun.star.form.inspection.FormGeometryHandler", true }
163 sal_Int32 nFactories
= SAL_N_ELEMENTS( aFactories
);
164 Sequence
< Any
> aReturn( nFactories
);
165 Any
* pReturn
= aReturn
.getArray();
166 for ( sal_Int32 i
= 0; i
< nFactories
; ++i
)
168 if ( aFactories
[i
].isFormOnly
&& !m_bUseFormComponentHandlers
)
170 *pReturn
++ <<= ::rtl::OUString::createFromAscii( aFactories
[i
].serviceName
);
172 aReturn
.realloc( pReturn
- aReturn
.getArray() );
177 //--------------------------------------------------------------------
178 Sequence
< PropertyCategoryDescriptor
> SAL_CALL
DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException
)
180 ::osl::MutexGuard
aGuard( m_aMutex
);
184 const sal_Char
* programmaticName
;
188 { "General", RID_STR_PROPPAGE_DEFAULT
, HID_FM_PROPDLG_TAB_GENERAL
},
189 { "Data", RID_STR_PROPPAGE_DATA
, HID_FM_PROPDLG_TAB_DATA
},
190 { "Events", RID_STR_EVENTS
, HID_FM_PROPDLG_TAB_EVT
}
193 sal_Int32 nCategories
= SAL_N_ELEMENTS( aCategories
);
194 Sequence
< PropertyCategoryDescriptor
> aReturn( nCategories
);
195 PropertyCategoryDescriptor
* pReturn
= aReturn
.getArray();
196 for ( sal_Int32 i
=0; i
<nCategories
; ++i
, ++pReturn
)
198 pReturn
->ProgrammaticName
= ::rtl::OUString::createFromAscii( aCategories
[i
].programmaticName
);
199 pReturn
->UIName
= String( PcrRes( aCategories
[i
].uiNameResId
) );
200 pReturn
->HelpURL
= HelpIdUrl::getHelpURL( aCategories
[i
].helpId
);
206 //--------------------------------------------------------------------
207 ::sal_Int32 SAL_CALL
DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString
& _rPropertyName
) throw (RuntimeException
)
209 sal_Int32
nPropertyId( m_pInfoService
->getPropertyId( _rPropertyName
) );
210 if ( nPropertyId
== -1 )
212 if ( _rPropertyName
.indexOf( ';' ) != -1 )
213 // it's an event. Just give it an arbitrary number - events will be on a separate
214 // page, and by definition, if two properties have the same OrderIndex, then
215 // they will be ordered as they appear in the handler's getSupportedProperties.
219 return m_pInfoService
->getPropertyPos( nPropertyId
);
222 //--------------------------------------------------------------------
223 void SAL_CALL
DefaultFormComponentInspectorModel::initialize( const Sequence
< Any
>& _arguments
) throw (Exception
, RuntimeException
)
225 if ( m_bConstructed
)
226 throw AlreadyInitializedException();
228 StlSyntaxSequence
< Any
> arguments( _arguments
);
229 if ( arguments
.empty() )
230 { // constructor: "createDefault()"
235 sal_Int32
nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
236 if ( arguments
.size() == 2 )
237 { // constructor: "createWithHelpSection( long, long )"
238 if ( !( arguments
[0] >>= nMinHelpTextLines
) || !( arguments
[1] >>= nMaxHelpTextLines
) )
239 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
240 createWithHelpSection( nMinHelpTextLines
, nMaxHelpTextLines
);
244 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
247 //--------------------------------------------------------------------
248 void DefaultFormComponentInspectorModel::createDefault()
250 m_bConstructed
= true;
253 //--------------------------------------------------------------------
254 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines
, sal_Int32 _nMaxHelpTextLines
)
256 if ( ( _nMinHelpTextLines
<= 0 ) || ( _nMaxHelpTextLines
<= 0 ) || ( _nMinHelpTextLines
> _nMaxHelpTextLines
) )
257 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
259 enableHelpSectionProperties( _nMinHelpTextLines
, _nMaxHelpTextLines
);
260 m_bConstructed
= true;
263 //........................................................................
265 //........................................................................
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */