Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "defaultforminspection.hxx"
21 : #include "pcrcommon.hxx"
22 : #include "propresid.hrc"
23 : #include "formresid.hrc"
24 : #include "modulepcr.hxx"
25 : #include "propctrlr.hrc"
26 : #include "formmetadata.hxx"
27 :
28 : #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
29 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
30 : #include <cppuhelper/implbase1.hxx>
31 : #include <osl/diagnose.h>
32 : #include <sal/macros.h>
33 :
34 : //------------------------------------------------------------------------
35 0 : extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel()
36 : {
37 0 : ::pcr::OAutoRegistration< ::pcr::DefaultFormComponentInspectorModel > aAutoRegistration;
38 0 : }
39 :
40 : //........................................................................
41 : namespace pcr
42 : {
43 : //........................................................................
44 :
45 : /** === begin UNO using === **/
46 : using ::com::sun::star::uno::Reference;
47 : using ::com::sun::star::uno::Sequence;
48 : using ::com::sun::star::uno::Any;
49 : using ::com::sun::star::uno::RuntimeException;
50 : using ::com::sun::star::uno::XInterface;
51 : using ::com::sun::star::uno::XComponentContext;
52 : using ::com::sun::star::uno::Exception;
53 : using ::com::sun::star::lang::EventObject;
54 : using ::com::sun::star::inspection::PropertyCategoryDescriptor;
55 : using ::com::sun::star::beans::UnknownPropertyException;
56 : using ::com::sun::star::ucb::AlreadyInitializedException;
57 : using ::com::sun::star::lang::IllegalArgumentException;
58 : /** === end UNO using === **/
59 :
60 : //====================================================================
61 : //= DefaultFormComponentInspectorModel
62 : //====================================================================
63 : //--------------------------------------------------------------------
64 0 : DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference< XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers )
65 : :ImplInspectorModel( _rxContext )
66 : ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers )
67 : ,m_bConstructed( false )
68 0 : ,m_pInfoService( new OPropertyInfoService )
69 : {
70 0 : }
71 :
72 : //------------------------------------------------------------------------
73 0 : DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
74 : {
75 0 : }
76 :
77 : //------------------------------------------------------------------------
78 0 : ::rtl::OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException)
79 : {
80 0 : return getImplementationName_static();
81 : }
82 :
83 : //------------------------------------------------------------------------
84 0 : Sequence< ::rtl::OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException)
85 : {
86 0 : return getSupportedServiceNames_static();
87 : }
88 :
89 : //------------------------------------------------------------------------
90 0 : ::rtl::OUString DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException)
91 : {
92 0 : return ::rtl::OUString("org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
93 : }
94 :
95 : //------------------------------------------------------------------------
96 0 : Sequence< ::rtl::OUString > DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
97 : {
98 0 : Sequence< ::rtl::OUString > aSupported(1);
99 0 : aSupported[0] = ::rtl::OUString("com.sun.star.form.inspection.DefaultFormComponentInspectorModel");
100 0 : return aSupported;
101 : }
102 :
103 : //------------------------------------------------------------------------
104 0 : Reference< XInterface > SAL_CALL DefaultFormComponentInspectorModel::Create( const Reference< XComponentContext >& _rxContext )
105 : {
106 0 : return *new DefaultFormComponentInspectorModel( _rxContext );
107 : }
108 :
109 : //--------------------------------------------------------------------
110 0 : Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException)
111 : {
112 0 : ::osl::MutexGuard aGuard( m_aMutex );
113 :
114 : // service names for all our handlers
115 : struct
116 : {
117 : const sal_Char* serviceName;
118 : bool isFormOnly;
119 : } aFactories[] = {
120 :
121 : // a generic handler for form component properties (must precede the ButtonNavigationHandler)
122 : { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
123 :
124 : // generic virtual edit properties
125 : { "com.sun.star.form.inspection.EditPropertyHandler", false },
126 :
127 : // a handler which virtualizes the ButtonType property, to provide additional types like
128 : // "move to next record"
129 : { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
130 :
131 : // a handler for script events bound to form components or dialog elements
132 : { "com.sun.star.form.inspection.EventHandler", false },
133 :
134 : // a handler which introduces virtual properties for binding controls to spreadsheet cells
135 : { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
136 :
137 : // properties related to binding to an XForms DOM node
138 : { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
139 :
140 : // properties related to the XSD data against which a control content is validated
141 : { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
142 :
143 : // a handler which cares for XForms submissions
144 : { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
145 :
146 : // a handler which cares for geometry properties of form controls
147 : { "com.sun.star.form.inspection.FormGeometryHandler", true }
148 0 : };
149 :
150 0 : sal_Int32 nFactories = SAL_N_ELEMENTS( aFactories );
151 0 : Sequence< Any > aReturn( nFactories );
152 0 : Any* pReturn = aReturn.getArray();
153 0 : for ( sal_Int32 i = 0; i < nFactories; ++i )
154 : {
155 0 : if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers )
156 0 : continue;
157 0 : *pReturn++ <<= ::rtl::OUString::createFromAscii( aFactories[i].serviceName );
158 : }
159 0 : aReturn.realloc( pReturn - aReturn.getArray() );
160 :
161 0 : return aReturn;
162 : }
163 :
164 : //--------------------------------------------------------------------
165 0 : Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException)
166 : {
167 0 : ::osl::MutexGuard aGuard( m_aMutex );
168 :
169 : struct
170 : {
171 : const sal_Char* programmaticName;
172 : sal_uInt16 uiNameResId;
173 : const sal_Char* helpId;
174 : } aCategories[] = {
175 : { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL },
176 : { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA },
177 : { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT }
178 0 : };
179 :
180 0 : sal_Int32 nCategories = SAL_N_ELEMENTS( aCategories );
181 0 : Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
182 0 : PropertyCategoryDescriptor* pReturn = aReturn.getArray();
183 0 : for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn )
184 : {
185 0 : pReturn->ProgrammaticName = ::rtl::OUString::createFromAscii( aCategories[i].programmaticName );
186 0 : pReturn->UIName = String( PcrRes( aCategories[i].uiNameResId ) );
187 0 : pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
188 : }
189 :
190 0 : return aReturn;
191 : }
192 :
193 : //--------------------------------------------------------------------
194 0 : ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
195 : {
196 0 : sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
197 0 : if ( nPropertyId == -1 )
198 : {
199 0 : if ( _rPropertyName.indexOf( ';' ) != -1 )
200 : // it's an event. Just give it an arbitrary number - events will be on a separate
201 : // page, and by definition, if two properties have the same OrderIndex, then
202 : // they will be ordered as they appear in the handler's getSupportedProperties.
203 0 : return 1000;
204 0 : return 0;
205 : }
206 0 : return m_pInfoService->getPropertyPos( nPropertyId );
207 : }
208 :
209 : //--------------------------------------------------------------------
210 0 : void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
211 : {
212 0 : if ( m_bConstructed )
213 0 : throw AlreadyInitializedException();
214 :
215 0 : StlSyntaxSequence< Any > arguments( _arguments );
216 0 : if ( arguments.empty() )
217 : { // constructor: "createDefault()"
218 0 : createDefault();
219 : return;
220 : }
221 :
222 0 : sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
223 0 : if ( arguments.size() == 2 )
224 : { // constructor: "createWithHelpSection( long, long )"
225 0 : if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) )
226 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
227 0 : createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
228 : return;
229 : }
230 :
231 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
232 : }
233 :
234 : //--------------------------------------------------------------------
235 0 : void DefaultFormComponentInspectorModel::createDefault()
236 : {
237 0 : m_bConstructed = true;
238 0 : }
239 :
240 : //--------------------------------------------------------------------
241 0 : void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
242 : {
243 0 : if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
244 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
245 :
246 0 : enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
247 0 : m_bConstructed = true;
248 0 : }
249 :
250 : //........................................................................
251 : } // namespace pcr
252 : //........................................................................
253 :
254 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|