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