1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "propresid.hrc"
24 #include "formresid.hrc"
25 #include "modulepcr.hxx"
26 #include "propctrlr.hrc"
27 #include "formmetadata.hxx"
29 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
30 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 #include <cppuhelper/implbase1.hxx>
32 #include <osl/diagnose.h>
33 #include <sal/macros.h>
36 extern "C" void SAL_CALL
createRegistryInfo_DefaultFormComponentInspectorModel()
38 ::pcr::OAutoRegistration
< ::pcr::DefaultFormComponentInspectorModel
> aAutoRegistration
;
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
;
59 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( bool _bUseFormFormComponentHandlers
)
61 ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers
)
62 ,m_bConstructed( false )
63 ,m_pInfoService( new OPropertyInfoService
)
68 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
73 OUString SAL_CALL
DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException
, std::exception
)
75 return getImplementationName_static();
79 Sequence
< OUString
> SAL_CALL
DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException
, std::exception
)
81 return getSupportedServiceNames_static();
85 OUString
DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException
)
87 return OUString("org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
91 Sequence
< OUString
> DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException
)
93 Sequence
< OUString
> aSupported(1);
94 aSupported
[0] = "com.sun.star.form.inspection.DefaultFormComponentInspectorModel";
99 Reference
< XInterface
> SAL_CALL
DefaultFormComponentInspectorModel::Create( const Reference
< XComponentContext
>& )
101 return *new DefaultFormComponentInspectorModel();
105 Sequence
< Any
> SAL_CALL
DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException
, std::exception
)
107 ::osl::MutexGuard
aGuard( m_aMutex
);
109 // service names for all our handlers
112 const sal_Char
* serviceName
;
116 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
117 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
119 // generic virtual edit properties
120 { "com.sun.star.form.inspection.EditPropertyHandler", false },
122 // a handler which virtualizes the ButtonType property, to provide additional types like
123 // "move to next record"
124 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
126 // a handler for script events bound to form components or dialog elements
127 { "com.sun.star.form.inspection.EventHandler", false },
129 // a handler which introduces virtual properties for binding controls to spreadsheet cells
130 { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
132 // properties related to binding to an XForms DOM node
133 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
135 // properties related to the XSD data against which a control content is validated
136 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
138 // a handler which cares for XForms submissions
139 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
141 // a handler which cares for geometry properties of form controls
142 { "com.sun.star.form.inspection.FormGeometryHandler", true }
145 sal_Int32 nFactories
= SAL_N_ELEMENTS( aFactories
);
146 Sequence
< Any
> aReturn( nFactories
);
147 Any
* pReturn
= aReturn
.getArray();
148 for ( sal_Int32 i
= 0; i
< nFactories
; ++i
)
150 if ( aFactories
[i
].isFormOnly
&& !m_bUseFormComponentHandlers
)
152 *pReturn
++ <<= OUString::createFromAscii( aFactories
[i
].serviceName
);
154 aReturn
.realloc( pReturn
- aReturn
.getArray() );
160 Sequence
< PropertyCategoryDescriptor
> SAL_CALL
DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException
, std::exception
)
162 ::osl::MutexGuard
aGuard( m_aMutex
);
166 const sal_Char
* programmaticName
;
167 sal_uInt16 uiNameResId
;
168 const sal_Char
* helpId
;
170 { "General", RID_STR_PROPPAGE_DEFAULT
, HID_FM_PROPDLG_TAB_GENERAL
},
171 { "Data", RID_STR_PROPPAGE_DATA
, HID_FM_PROPDLG_TAB_DATA
},
172 { "Events", RID_STR_EVENTS
, HID_FM_PROPDLG_TAB_EVT
}
175 sal_Int32 nCategories
= SAL_N_ELEMENTS( aCategories
);
176 Sequence
< PropertyCategoryDescriptor
> aReturn( nCategories
);
177 PropertyCategoryDescriptor
* pReturn
= aReturn
.getArray();
178 for ( sal_Int32 i
=0; i
<nCategories
; ++i
, ++pReturn
)
180 pReturn
->ProgrammaticName
= OUString::createFromAscii( aCategories
[i
].programmaticName
);
181 pReturn
->UIName
= PcrRes( aCategories
[i
].uiNameResId
).toString();
182 pReturn
->HelpURL
= HelpIdUrl::getHelpURL( aCategories
[i
].helpId
);
189 ::sal_Int32 SAL_CALL
DefaultFormComponentInspectorModel::getPropertyOrderIndex( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
)
191 sal_Int32
nPropertyId( m_pInfoService
->getPropertyId( _rPropertyName
) );
192 if ( nPropertyId
== -1 )
194 if ( _rPropertyName
.indexOf( ';' ) != -1 )
195 // it's an event. Just give it an arbitrary number - events will be on a separate
196 // page, and by definition, if two properties have the same OrderIndex, then
197 // they will be ordered as they appear in the handler's getSupportedProperties.
201 return m_pInfoService
->getPropertyPos( nPropertyId
);
205 void SAL_CALL
DefaultFormComponentInspectorModel::initialize( const Sequence
< Any
>& _arguments
) throw (Exception
, RuntimeException
, std::exception
)
207 if ( m_bConstructed
)
208 throw AlreadyInitializedException();
210 StlSyntaxSequence
< Any
> arguments( _arguments
);
211 if ( arguments
.empty() )
212 { // constructor: "createDefault()"
217 sal_Int32
nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
218 if ( arguments
.size() == 2 )
219 { // constructor: "createWithHelpSection( long, long )"
220 if ( !( arguments
[0] >>= nMinHelpTextLines
) || !( arguments
[1] >>= nMaxHelpTextLines
) )
221 throw IllegalArgumentException( OUString(), *this, 0 );
222 createWithHelpSection( nMinHelpTextLines
, nMaxHelpTextLines
);
226 throw IllegalArgumentException( OUString(), *this, 0 );
230 void DefaultFormComponentInspectorModel::createDefault()
232 m_bConstructed
= true;
236 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines
, sal_Int32 _nMaxHelpTextLines
)
238 if ( ( _nMinHelpTextLines
<= 0 ) || ( _nMaxHelpTextLines
<= 0 ) || ( _nMinHelpTextLines
> _nMaxHelpTextLines
) )
239 throw IllegalArgumentException( OUString(), *this, 0 );
241 enableHelpSectionProperties( _nMinHelpTextLines
, _nMaxHelpTextLines
);
242 m_bConstructed
= true;
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */