bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / defaultforminspection.cxx
blobe139745d79d88ab90c26e12189a68dd15dbf6d7b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "defaultforminspection.hxx"
21 #include "pcrcommon.hxx"
22 #include "pcrservices.hxx"
23 #include <helpids.h>
24 #include <strings.hrc>
25 #include "modulepcr.hxx"
26 #include <propctrlr.h>
27 #include "formmetadata.hxx"
29 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
30 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 #include <sal/macros.h>
34 extern "C" void createRegistryInfo_DefaultFormComponentInspectorModel()
36 ::pcr::OAutoRegistration< ::pcr::DefaultFormComponentInspectorModel > aAutoRegistration;
40 namespace pcr
44 using ::com::sun::star::uno::Reference;
45 using ::com::sun::star::uno::Sequence;
46 using ::com::sun::star::uno::Any;
47 using ::com::sun::star::uno::XInterface;
48 using ::com::sun::star::uno::XComponentContext;
49 using ::com::sun::star::inspection::PropertyCategoryDescriptor;
50 using ::com::sun::star::ucb::AlreadyInitializedException;
51 using ::com::sun::star::lang::IllegalArgumentException;
53 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( bool _bUseFormFormComponentHandlers )
54 :ImplInspectorModel()
55 ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers )
56 ,m_bConstructed( false )
57 ,m_pInfoService( new OPropertyInfoService )
62 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
67 OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( )
69 return getImplementationName_static();
73 Sequence< OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( )
75 return getSupportedServiceNames_static();
79 OUString DefaultFormComponentInspectorModel::getImplementationName_static( )
81 return OUString("org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
85 Sequence< OUString > DefaultFormComponentInspectorModel::getSupportedServiceNames_static( )
87 Sequence< OUString > aSupported { "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" };
88 return aSupported;
92 Reference< XInterface > DefaultFormComponentInspectorModel::Create( const Reference< XComponentContext >& )
94 return *new DefaultFormComponentInspectorModel();
98 Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories()
100 ::osl::MutexGuard aGuard( m_aMutex );
102 // service names for all our handlers
103 static struct
105 const sal_Char* serviceName;
106 bool isFormOnly;
107 } const aFactories[] = {
109 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
110 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
112 // generic virtual edit properties
113 { "com.sun.star.form.inspection.EditPropertyHandler", false },
115 // a handler which virtualizes the ButtonType property, to provide additional types like
116 // "move to next record"
117 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
119 // a handler for script events bound to form components or dialog elements
120 { "com.sun.star.form.inspection.EventHandler", false },
122 // a handler which introduces virtual properties for binding controls to spreadsheet cells
123 { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
125 // properties related to binding to an XForms DOM node
126 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
128 // properties related to the XSD data against which a control content is validated
129 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
131 // a handler which cares for XForms submissions
132 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
134 // a handler which cares for geometry properties of form controls
135 { "com.sun.star.form.inspection.FormGeometryHandler", true }
138 sal_Int32 nFactories = SAL_N_ELEMENTS( aFactories );
139 Sequence< Any > aReturn( nFactories );
140 Any* pReturn = aReturn.getArray();
141 for ( sal_Int32 i = 0; i < nFactories; ++i )
143 if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers )
144 continue;
145 *pReturn++ <<= OUString::createFromAscii( aFactories[i].serviceName );
147 aReturn.realloc( pReturn - aReturn.getArray() );
149 return aReturn;
153 Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( )
155 ::osl::MutexGuard aGuard( m_aMutex );
157 static struct
159 const sal_Char* programmaticName;
160 const char* uiNameResId;
161 const sal_Char* helpId;
162 } const aCategories[] = {
163 { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL },
164 { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA },
165 { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT }
168 sal_Int32 nCategories = SAL_N_ELEMENTS( aCategories );
169 Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
170 PropertyCategoryDescriptor* pReturn = aReturn.getArray();
171 for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn )
173 pReturn->ProgrammaticName = OUString::createFromAscii( aCategories[i].programmaticName );
174 pReturn->UIName = PcrRes( aCategories[i].uiNameResId );
175 pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
178 return aReturn;
182 ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const OUString& _rPropertyName )
184 sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
185 if ( nPropertyId == -1 )
187 if ( _rPropertyName.indexOf( ';' ) != -1 )
188 // it's an event. Just give it an arbitrary number - events will be on a separate
189 // page, and by definition, if two properties have the same OrderIndex, then
190 // they will be ordered as they appear in the handler's getSupportedProperties.
191 return 1000;
192 return 0;
194 return m_pInfoService->getPropertyPos( nPropertyId );
198 void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments )
200 if ( m_bConstructed )
201 throw AlreadyInitializedException();
203 StlSyntaxSequence< Any > arguments( _arguments );
204 if ( arguments.empty() )
205 { // constructor: "createDefault()"
206 m_bConstructed = true;
207 return;
210 sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
211 if ( arguments.size() == 2 )
212 { // constructor: "createWithHelpSection( long, long )"
213 if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) )
214 throw IllegalArgumentException( OUString(), *this, 0 );
215 createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
216 return;
219 throw IllegalArgumentException( OUString(), *this, 0 );
223 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
225 if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
226 throw IllegalArgumentException( OUString(), *this, 0 );
228 enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
229 m_bConstructed = true;
233 } // namespace pcr
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */