tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / extensions / source / propctrlr / defaultforminspection.cxx
blobd6336eccf957770d3184d0ac8532fea0b3f2cd10
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 <helpids.h>
23 #include <strings.hrc>
24 #include "modulepcr.hxx"
25 #include "formmetadata.hxx"
27 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
28 #include <com/sun/star/lang/IllegalArgumentException.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <sal/macros.h>
33 namespace pcr
37 using ::com::sun::star::uno::Sequence;
38 using ::com::sun::star::uno::Any;
39 using ::com::sun::star::uno::XInterface;
40 using ::com::sun::star::uno::XComponentContext;
41 using ::com::sun::star::inspection::PropertyCategoryDescriptor;
42 using ::com::sun::star::ucb::AlreadyInitializedException;
43 using ::com::sun::star::lang::IllegalArgumentException;
45 DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( bool _bUseFormFormComponentHandlers )
46 :m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers )
47 ,m_bConstructed( false )
48 ,m_pInfoService( new OPropertyInfoService )
53 DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
58 OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( )
60 return u"org.openoffice.comp.extensions.DefaultFormComponentInspectorModel"_ustr;
64 Sequence< OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( )
66 return { u"com.sun.star.form.inspection.DefaultFormComponentInspectorModel"_ustr };
70 Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories()
72 ::osl::MutexGuard aGuard( m_aMutex );
74 // service names for all our handlers
75 static struct
77 const char* serviceName;
78 bool isFormOnly;
79 } const aFactories[] = {
81 // a generic handler for form component properties (must precede the ButtonNavigationHandler)
82 { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
84 // generic virtual edit properties
85 { "com.sun.star.form.inspection.EditPropertyHandler", false },
87 // a handler which virtualizes the ButtonType property, to provide additional types like
88 // "move to next record"
89 { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
91 // a handler for script events bound to form components or dialog elements
92 { "com.sun.star.form.inspection.EventHandler", false },
94 // a handler which introduces virtual properties for binding controls to spreadsheet cells
95 { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
97 // properties related to binding to an XForms DOM node
98 { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
100 // properties related to the XSD data against which a control content is validated
101 { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
103 // a handler which cares for XForms submissions
104 { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
106 // a handler which cares for geometry properties of form controls
107 { "com.sun.star.form.inspection.FormGeometryHandler", true }
110 sal_Int32 nFactories = SAL_N_ELEMENTS( aFactories );
111 Sequence< Any > aReturn( nFactories );
112 Any* pReturn = aReturn.getArray();
113 for ( sal_Int32 i = 0; i < nFactories; ++i )
115 if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers )
116 continue;
117 *pReturn++ <<= OUString::createFromAscii( aFactories[i].serviceName );
119 aReturn.realloc( pReturn - aReturn.getArray() );
121 return aReturn;
125 Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( )
127 ::osl::MutexGuard aGuard( m_aMutex );
129 static struct
131 const char* programmaticName;
132 TranslateId uiNameResId;
133 OUString helpId;
134 } constexpr aCategories[] = {
135 { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL },
136 { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA },
137 { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT }
140 sal_Int32 nCategories = SAL_N_ELEMENTS( aCategories );
141 Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
142 PropertyCategoryDescriptor* pReturn = aReturn.getArray();
143 for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn )
145 pReturn->ProgrammaticName = OUString::createFromAscii( aCategories[i].programmaticName );
146 pReturn->UIName = PcrRes( aCategories[i].uiNameResId );
147 pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
150 return aReturn;
154 ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const OUString& _rPropertyName )
156 sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
157 if ( nPropertyId == -1 )
159 if ( _rPropertyName.indexOf( ';' ) != -1 )
160 // it's an event. Just give it an arbitrary number - events will be on a separate
161 // page, and by definition, if two properties have the same OrderIndex, then
162 // they will be ordered as they appear in the handler's getSupportedProperties.
163 return 1000;
164 return 0;
166 return m_pInfoService->getPropertyPos( nPropertyId );
170 void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments )
172 if ( m_bConstructed )
173 throw AlreadyInitializedException();
175 StlSyntaxSequence< Any > arguments( _arguments );
176 if ( arguments.empty() )
177 { // constructor: "createDefault()"
178 m_bConstructed = true;
179 return;
182 if ( arguments.size() == 2 )
183 { // constructor: "createWithHelpSection( long, long )"
184 sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
185 if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) )
186 throw IllegalArgumentException( OUString(), *this, 0 );
187 createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
188 return;
191 throw IllegalArgumentException( OUString(), *this, 0 );
195 void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
197 if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
198 throw IllegalArgumentException( OUString(), *this, 0 );
200 enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
201 m_bConstructed = true;
205 } // namespace pcr
207 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
208 extensions_propctrlr_DefaultFormComponentInspectorModel_get_implementation(
209 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
211 return cppu::acquire(new pcr::DefaultFormComponentInspectorModel(context));
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */