1*2a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2a97ec55SAndrew Rist * distributed with this work for additional information 6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an 15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 17*2a97ec55SAndrew Rist * specific language governing permissions and limitations 18*2a97ec55SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2a97ec55SAndrew Rist *************************************************************/ 21*2a97ec55SAndrew Rist 22*2a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir #include "defaultforminspection.hxx" 27cdf0e10cSrcweir #include "pcrcommon.hxx" 28cdf0e10cSrcweir #ifndef EXTENSIONS_PROPRESID_HRC 29cdf0e10cSrcweir #include "propresid.hrc" 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_ 32cdf0e10cSrcweir #include "formresid.hrc" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_ 35cdf0e10cSrcweir #include "modulepcr.hxx" 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #include "propctrlr.hrc" 38cdf0e10cSrcweir #include "formmetadata.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir /** === begin UNO includes === **/ 41cdf0e10cSrcweir #include <com/sun/star/ucb/AlreadyInitializedException.hpp> 42cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 43cdf0e10cSrcweir /** === end UNO includes === **/ 44cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 45cdf0e10cSrcweir #include <osl/diagnose.h> 46cdf0e10cSrcweir 47cdf0e10cSrcweir //------------------------------------------------------------------------ 48cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel() 49cdf0e10cSrcweir { 50cdf0e10cSrcweir ::pcr::OAutoRegistration< ::pcr::DefaultFormComponentInspectorModel > aAutoRegistration; 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir //........................................................................ 54cdf0e10cSrcweir namespace pcr 55cdf0e10cSrcweir { 56cdf0e10cSrcweir //........................................................................ 57cdf0e10cSrcweir 58cdf0e10cSrcweir /** === begin UNO using === **/ 59cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 60cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 61cdf0e10cSrcweir using ::com::sun::star::uno::Any; 62cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 63cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 64cdf0e10cSrcweir using ::com::sun::star::uno::XComponentContext; 65cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 66cdf0e10cSrcweir using ::com::sun::star::lang::EventObject; 67cdf0e10cSrcweir using ::com::sun::star::inspection::PropertyCategoryDescriptor; 68cdf0e10cSrcweir using ::com::sun::star::beans::UnknownPropertyException; 69cdf0e10cSrcweir using ::com::sun::star::ucb::AlreadyInitializedException; 70cdf0e10cSrcweir using ::com::sun::star::lang::IllegalArgumentException; 71cdf0e10cSrcweir /** === end UNO using === **/ 72cdf0e10cSrcweir 73cdf0e10cSrcweir //==================================================================== 74cdf0e10cSrcweir //= DefaultFormComponentInspectorModel 75cdf0e10cSrcweir //==================================================================== 76cdf0e10cSrcweir //-------------------------------------------------------------------- 77cdf0e10cSrcweir DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference< XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers ) 78cdf0e10cSrcweir :ImplInspectorModel( _rxContext ) 79cdf0e10cSrcweir ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers ) 80cdf0e10cSrcweir ,m_bConstructed( false ) 81cdf0e10cSrcweir ,m_pInfoService( new OPropertyInfoService ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir //------------------------------------------------------------------------ 86cdf0e10cSrcweir DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir //------------------------------------------------------------------------ 91cdf0e10cSrcweir ::rtl::OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir return getImplementationName_static(); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir //------------------------------------------------------------------------ 97cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir return getSupportedServiceNames_static(); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir //------------------------------------------------------------------------ 103cdf0e10cSrcweir ::rtl::OUString DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultFormComponentInspectorModel"); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir //------------------------------------------------------------------------ 109cdf0e10cSrcweir Sequence< ::rtl::OUString > DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(1); 112cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" ); 113cdf0e10cSrcweir return aSupported; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir //------------------------------------------------------------------------ 117cdf0e10cSrcweir Reference< XInterface > SAL_CALL DefaultFormComponentInspectorModel::Create( const Reference< XComponentContext >& _rxContext ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir return *new DefaultFormComponentInspectorModel( _rxContext ); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir //-------------------------------------------------------------------- 123cdf0e10cSrcweir Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 126cdf0e10cSrcweir 127cdf0e10cSrcweir // service names for all our handlers 128cdf0e10cSrcweir struct 129cdf0e10cSrcweir { 130cdf0e10cSrcweir const sal_Char* serviceName; 131cdf0e10cSrcweir bool isFormOnly; 132cdf0e10cSrcweir } aFactories[] = { 133cdf0e10cSrcweir 134cdf0e10cSrcweir // a generic handler for form component properties (must precede the ButtonNavigationHandler) 135cdf0e10cSrcweir { "com.sun.star.form.inspection.FormComponentPropertyHandler", false }, 136cdf0e10cSrcweir 137cdf0e10cSrcweir // generic virtual edit properties 138cdf0e10cSrcweir { "com.sun.star.form.inspection.EditPropertyHandler", false }, 139cdf0e10cSrcweir 140cdf0e10cSrcweir // a handler which virtualizes the ButtonType property, to provide additional types like 141cdf0e10cSrcweir // "move to next record" 142cdf0e10cSrcweir { "com.sun.star.form.inspection.ButtonNavigationHandler", false }, 143cdf0e10cSrcweir 144cdf0e10cSrcweir // a handler for script events bound to form components or dialog elements 145cdf0e10cSrcweir { "com.sun.star.form.inspection.EventHandler", false }, 146cdf0e10cSrcweir 147cdf0e10cSrcweir // a handler which introduces virtual properties for binding controls to spreadsheet cells 148cdf0e10cSrcweir { "com.sun.star.form.inspection.CellBindingPropertyHandler", true }, 149cdf0e10cSrcweir 150cdf0e10cSrcweir // properties related to binding to an XForms DOM node 151cdf0e10cSrcweir { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true }, 152cdf0e10cSrcweir 153cdf0e10cSrcweir // properties related to the XSD data against which a control content is validated 154cdf0e10cSrcweir { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true }, 155cdf0e10cSrcweir 156cdf0e10cSrcweir // a handler which cares for XForms submissions 157cdf0e10cSrcweir { "com.sun.star.form.inspection.SubmissionPropertyHandler", true }, 158cdf0e10cSrcweir 159cdf0e10cSrcweir // a handler which cares for geometry properties of form controls 160cdf0e10cSrcweir { "com.sun.star.form.inspection.FormGeometryHandler", true } 161cdf0e10cSrcweir }; 162cdf0e10cSrcweir 163cdf0e10cSrcweir sal_Int32 nFactories = sizeof( aFactories ) / sizeof( aFactories[ 0 ] ); 164cdf0e10cSrcweir Sequence< Any > aReturn( nFactories ); 165cdf0e10cSrcweir Any* pReturn = aReturn.getArray(); 166cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nFactories; ++i ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers ) 169cdf0e10cSrcweir continue; 170cdf0e10cSrcweir *pReturn++ <<= ::rtl::OUString::createFromAscii( aFactories[i].serviceName ); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir aReturn.realloc( pReturn - aReturn.getArray() ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir return aReturn; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir //-------------------------------------------------------------------- 178cdf0e10cSrcweir Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir struct 183cdf0e10cSrcweir { 184cdf0e10cSrcweir const sal_Char* programmaticName; 185cdf0e10cSrcweir sal_uInt16 uiNameResId; 186cdf0e10cSrcweir const sal_Char* helpId; 187cdf0e10cSrcweir } aCategories[] = { 188cdf0e10cSrcweir { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL }, 189cdf0e10cSrcweir { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA }, 190cdf0e10cSrcweir { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT } 191cdf0e10cSrcweir }; 192cdf0e10cSrcweir 193cdf0e10cSrcweir sal_Int32 nCategories = sizeof( aCategories ) / sizeof( aCategories[0] ); 194cdf0e10cSrcweir Sequence< PropertyCategoryDescriptor > aReturn( nCategories ); 195cdf0e10cSrcweir PropertyCategoryDescriptor* pReturn = aReturn.getArray(); 196cdf0e10cSrcweir for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir pReturn->ProgrammaticName = ::rtl::OUString::createFromAscii( aCategories[i].programmaticName ); 199cdf0e10cSrcweir pReturn->UIName = String( PcrRes( aCategories[i].uiNameResId ) ); 200cdf0e10cSrcweir pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId ); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir return aReturn; 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir //-------------------------------------------------------------------- 207cdf0e10cSrcweir ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) ); 210cdf0e10cSrcweir if ( nPropertyId == -1 ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir if ( _rPropertyName.indexOf( ';' ) != -1 ) 213cdf0e10cSrcweir // it's an event. Just give it an arbitrary number - events will be on a separate 214cdf0e10cSrcweir // page, and by definition, if two properties have the same OrderIndex, then 215cdf0e10cSrcweir // they will be ordered as they appear in the handler's getSupportedProperties. 216cdf0e10cSrcweir return 1000; 217cdf0e10cSrcweir return 0; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir return m_pInfoService->getPropertyPos( nPropertyId ); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir //-------------------------------------------------------------------- 223cdf0e10cSrcweir void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir if ( m_bConstructed ) 226cdf0e10cSrcweir throw AlreadyInitializedException(); 227cdf0e10cSrcweir 228cdf0e10cSrcweir StlSyntaxSequence< Any > arguments( _arguments ); 229cdf0e10cSrcweir if ( arguments.empty() ) 230cdf0e10cSrcweir { // constructor: "createDefault()" 231cdf0e10cSrcweir createDefault(); 232cdf0e10cSrcweir return; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 ); 236cdf0e10cSrcweir if ( arguments.size() == 2 ) 237cdf0e10cSrcweir { // constructor: "createWithHelpSection( long, long )" 238cdf0e10cSrcweir if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) ) 239cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString(), *this, 0 ); 240cdf0e10cSrcweir createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines ); 241cdf0e10cSrcweir return; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString(), *this, 0 ); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir //-------------------------------------------------------------------- 248cdf0e10cSrcweir void DefaultFormComponentInspectorModel::createDefault() 249cdf0e10cSrcweir { 250cdf0e10cSrcweir m_bConstructed = true; 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir //-------------------------------------------------------------------- 254cdf0e10cSrcweir void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines ) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) ) 257cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString(), *this, 0 ); 258cdf0e10cSrcweir 259cdf0e10cSrcweir enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines ); 260cdf0e10cSrcweir m_bConstructed = true; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir //........................................................................ 264cdf0e10cSrcweir } // namespace pcr 265cdf0e10cSrcweir //........................................................................ 266cdf0e10cSrcweir 267