Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / defaultforminspection.cxx
blob3389d485b17212abffaab85e9e81d8d383f78b9d
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 #include "defaultforminspection.hxx"
30 #include "pcrcommon.hxx"
31 #include "propresid.hrc"
32 #include "formresid.hrc"
33 #include "modulepcr.hxx"
34 #include "propctrlr.hrc"
35 #include "formmetadata.hxx"
37 /** === begin UNO includes === **/
38 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
39 #include <com/sun/star/lang/IllegalArgumentException.hpp>
40 /** === end UNO includes === **/
41 #include <cppuhelper/implbase1.hxx>
42 #include <osl/diagnose.h>
43 #include <sal/macros.h>
45 //------------------------------------------------------------------------
46 extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel()
48 ::pcr::OAutoRegistration< ::pcr::DefaultFormComponentInspectorModel > aAutoRegistration;
51 //........................................................................
52 namespace pcr
54 //........................................................................
56 /** === begin UNO using === **/
57 using ::com::sun::star::uno::Reference;
58 using ::com::sun::star::uno::Sequence;
59 using ::com::sun::star::uno::Any;
60 using ::com::sun::star::uno::RuntimeException;
61 using ::com::sun::star::uno::XInterface;
62 using ::com::sun::star::uno::XComponentContext;
63 using ::com::sun::star::uno::Exception;
64 using ::com::sun::star::lang::EventObject;
65 using ::com::sun::star::inspection::PropertyCategoryDescriptor;
66 using ::com::sun::star::beans::UnknownPropertyException;
67 using ::com::sun::star::ucb::AlreadyInitializedException;
68 using ::com::sun::star::lang::IllegalArgumentException;
69 /** === end UNO using === **/
71 //====================================================================
72 //= DefaultFormComponentInspectorModel
73 //====================================================================
74 //--------------------------------------------------------------------
75 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference< XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers )
76 :ImplInspectorModel( _rxContext )
77 ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers )
78 ,m_bConstructed( false )
79 ,m_pInfoService( new OPropertyInfoService )
83 //------------------------------------------------------------------------
84 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
88 //------------------------------------------------------------------------
89 ::rtl::OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException)
91 return getImplementationName_static();
94 //------------------------------------------------------------------------
95 Sequence< ::rtl::OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException)
97 return getSupportedServiceNames_static();
100 //------------------------------------------------------------------------
101 ::rtl::OUString DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException)
103 return ::rtl::OUString("org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
106 //------------------------------------------------------------------------
107 Sequence< ::rtl::OUString > DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
109 Sequence< ::rtl::OUString > aSupported(1);
110 aSupported[0] = ::rtl::OUString("com.sun.star.form.inspection.DefaultFormComponentInspectorModel");
111 return aSupported;
114 //------------------------------------------------------------------------
115 Reference< XInterface > SAL_CALL DefaultFormComponentInspectorModel::Create( const Reference< XComponentContext >& _rxContext )
117 return *new DefaultFormComponentInspectorModel( _rxContext );
120 //--------------------------------------------------------------------
121 Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException)
123 ::osl::MutexGuard aGuard( m_aMutex );
125 // service names for all our handlers
126 struct
128 const sal_Char* serviceName;
129 bool isFormOnly;
130 } aFactories[] = {
132 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
133 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
135 // generic virtual edit properties
136 { "com.sun.star.form.inspection.EditPropertyHandler", false },
138 // a handler which virtualizes the ButtonType property, to provide additional types like
139 // "move to next record"
140 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
142 // a handler for script events bound to form components or dialog elements
143 { "com.sun.star.form.inspection.EventHandler", false },
145 // a handler which introduces virtual properties for binding controls to spreadsheet cells
146 { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
148 // properties related to binding to an XForms DOM node
149 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
151 // properties related to the XSD data against which a control content is validated
152 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
154 // a handler which cares for XForms submissions
155 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
157 // a handler which cares for geometry properties of form controls
158 { "com.sun.star.form.inspection.FormGeometryHandler", true }
161 sal_Int32 nFactories = SAL_N_ELEMENTS( aFactories );
162 Sequence< Any > aReturn( nFactories );
163 Any* pReturn = aReturn.getArray();
164 for ( sal_Int32 i = 0; i < nFactories; ++i )
166 if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers )
167 continue;
168 *pReturn++ <<= ::rtl::OUString::createFromAscii( aFactories[i].serviceName );
170 aReturn.realloc( pReturn - aReturn.getArray() );
172 return aReturn;
175 //--------------------------------------------------------------------
176 Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException)
178 ::osl::MutexGuard aGuard( m_aMutex );
180 struct
182 const sal_Char* programmaticName;
183 sal_uInt16 uiNameResId;
184 const sal_Char* helpId;
185 } aCategories[] = {
186 { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL },
187 { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA },
188 { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT }
191 sal_Int32 nCategories = SAL_N_ELEMENTS( aCategories );
192 Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
193 PropertyCategoryDescriptor* pReturn = aReturn.getArray();
194 for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn )
196 pReturn->ProgrammaticName = ::rtl::OUString::createFromAscii( aCategories[i].programmaticName );
197 pReturn->UIName = String( PcrRes( aCategories[i].uiNameResId ) );
198 pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
201 return aReturn;
204 //--------------------------------------------------------------------
205 ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
207 sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
208 if ( nPropertyId == -1 )
210 if ( _rPropertyName.indexOf( ';' ) != -1 )
211 // it's an event. Just give it an arbitrary number - events will be on a separate
212 // page, and by definition, if two properties have the same OrderIndex, then
213 // they will be ordered as they appear in the handler's getSupportedProperties.
214 return 1000;
215 return 0;
217 return m_pInfoService->getPropertyPos( nPropertyId );
220 //--------------------------------------------------------------------
221 void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
223 if ( m_bConstructed )
224 throw AlreadyInitializedException();
226 StlSyntaxSequence< Any > arguments( _arguments );
227 if ( arguments.empty() )
228 { // constructor: "createDefault()"
229 createDefault();
230 return;
233 sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
234 if ( arguments.size() == 2 )
235 { // constructor: "createWithHelpSection( long, long )"
236 if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) )
237 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
238 createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
239 return;
242 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
245 //--------------------------------------------------------------------
246 void DefaultFormComponentInspectorModel::createDefault()
248 m_bConstructed = true;
251 //--------------------------------------------------------------------
252 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
254 if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
255 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
257 enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
258 m_bConstructed = true;
261 //........................................................................
262 } // namespace pcr
263 //........................................................................
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */