1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svx/dbtoolsclient.hxx" 28cdf0e10cSrcweir #include "formcontrolfactory.hxx" 29cdf0e10cSrcweir #include "fmcontrollayout.hxx" 30cdf0e10cSrcweir #include "fmprop.hrc" 31cdf0e10cSrcweir #include "svx/fmresids.hrc" 32cdf0e10cSrcweir #include "fmservs.hxx" 33cdf0e10cSrcweir #include "svx/dialmgr.hxx" 34cdf0e10cSrcweir #include "svx/svdouno.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir /** === begin UNO includes === **/ 37cdf0e10cSrcweir #include <com/sun/star/form/XFormComponent.hpp> 38cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp> 39cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp> 40cdf0e10cSrcweir #include <com/sun/star/awt/MouseWheelBehavior.hpp> 41cdf0e10cSrcweir #include <com/sun/star/form/XGridColumnFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp> 43cdf0e10cSrcweir #include <com/sun/star/awt/LineEndFormat.hpp> 44cdf0e10cSrcweir #include <com/sun/star/awt/ImageScaleMode.hpp> 45cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 46cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatTypes.hpp> 47cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 48cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp> 49cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp> 50cdf0e10cSrcweir /** === end UNO includes === **/ 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 53cdf0e10cSrcweir #include <comphelper/numbers.hxx> 54cdf0e10cSrcweir #include <unotools/syslocale.hxx> 55cdf0e10cSrcweir #include <tools/gen.hxx> 56cdf0e10cSrcweir #include <tools/diagnose_ex.h> 57cdf0e10cSrcweir 58cdf0e10cSrcweir #include <set> 59cdf0e10cSrcweir 60cdf0e10cSrcweir //........................................................................ 61cdf0e10cSrcweir namespace svxform 62cdf0e10cSrcweir { 63cdf0e10cSrcweir //........................................................................ 64cdf0e10cSrcweir 65cdf0e10cSrcweir /** === begin UNO using === **/ 66cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 67cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 68cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 69cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 70cdf0e10cSrcweir using ::com::sun::star::uno::UNO_SET_THROW; 71cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 72cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 73cdf0e10cSrcweir using ::com::sun::star::uno::Any; 74cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 75cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 76cdf0e10cSrcweir using ::com::sun::star::uno::Type; 77cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 78cdf0e10cSrcweir using ::com::sun::star::awt::XControlModel; 79cdf0e10cSrcweir using ::com::sun::star::form::XFormComponent; 80cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess; 81cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySetInfo; 82cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 83cdf0e10cSrcweir using ::com::sun::star::container::XChild; 84cdf0e10cSrcweir using ::com::sun::star::form::XGridColumnFactory; 85cdf0e10cSrcweir using ::com::sun::star::style::VerticalAlignment_MIDDLE; 86cdf0e10cSrcweir using ::com::sun::star::beans::Property; 87cdf0e10cSrcweir using ::com::sun::star::uno::TypeClass_DOUBLE; 88cdf0e10cSrcweir using ::com::sun::star::uno::TypeClass_LONG; 89cdf0e10cSrcweir using ::com::sun::star::util::XNumberFormats; 90cdf0e10cSrcweir using ::com::sun::star::util::XNumberFormatTypes; 91cdf0e10cSrcweir using ::com::sun::star::awt::FontDescriptor; 92cdf0e10cSrcweir using ::com::sun::star::lang::Locale; 93cdf0e10cSrcweir using ::com::sun::star::lang::XServiceInfo; 94cdf0e10cSrcweir using ::com::sun::star::container::XNameAccess; 95cdf0e10cSrcweir /** === end UNO using === **/ 96cdf0e10cSrcweir namespace FormComponentType = ::com::sun::star::form::FormComponentType; 97cdf0e10cSrcweir namespace ScrollBarOrientation = ::com::sun::star::awt::ScrollBarOrientation; 98cdf0e10cSrcweir namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior; 99cdf0e10cSrcweir namespace LineEndFormat = ::com::sun::star::awt::LineEndFormat; 100cdf0e10cSrcweir namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; 101cdf0e10cSrcweir namespace DataType = ::com::sun::star::sdbc::DataType; 102cdf0e10cSrcweir namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; 103cdf0e10cSrcweir namespace WritingMode2 = ::com::sun::star::text::WritingMode2; 104cdf0e10cSrcweir 105cdf0e10cSrcweir //==================================================================== 106cdf0e10cSrcweir //= FormControlFactory_Data 107cdf0e10cSrcweir //==================================================================== 108cdf0e10cSrcweir struct FormControlFactory_Data 109cdf0e10cSrcweir { 110cdf0e10cSrcweir ::comphelper::ComponentContext m_aContext; 111cdf0e10cSrcweir FormControlFactory_Datasvxform::FormControlFactory_Data112cdf0e10cSrcweir FormControlFactory_Data( const ::comphelper::ComponentContext& _rContext ) 113cdf0e10cSrcweir :m_aContext( _rContext ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir } 116cdf0e10cSrcweir }; 117cdf0e10cSrcweir 118cdf0e10cSrcweir //==================================================================== 119cdf0e10cSrcweir //= FormControlFactory 120cdf0e10cSrcweir //==================================================================== 121cdf0e10cSrcweir //-------------------------------------------------------------------- FormControlFactory(const::comphelper::ComponentContext & _rContext)122cdf0e10cSrcweir FormControlFactory::FormControlFactory( const ::comphelper::ComponentContext& _rContext ) 123cdf0e10cSrcweir :m_pData( new FormControlFactory_Data( _rContext ) ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir //-------------------------------------------------------------------- ~FormControlFactory()128cdf0e10cSrcweir FormControlFactory::~FormControlFactory() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir //-------------------------------------------------------------------- initializeControlModel(const DocumentType _eDocType,const SdrUnoObj & _rObject)133cdf0e10cSrcweir sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const SdrUnoObj& _rObject ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir return initializeControlModel( 136cdf0e10cSrcweir _eDocType, 137cdf0e10cSrcweir Reference< XPropertySet >( _rObject.GetUnoControlModel(), UNO_QUERY ), 138cdf0e10cSrcweir _rObject.GetCurrentBoundRect() 139cdf0e10cSrcweir ); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir //-------------------------------------------------------------------- initializeControlModel(const DocumentType _eDocType,const Reference<XPropertySet> & _rxControlModel)143cdf0e10cSrcweir sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const Reference< XPropertySet >& _rxControlModel ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir return initializeControlModel( 146cdf0e10cSrcweir _eDocType, _rxControlModel, Rectangle() 147cdf0e10cSrcweir ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir // ----------------------------------------------------------------------------- 151cdf0e10cSrcweir namespace 152cdf0e10cSrcweir { 153cdf0e10cSrcweir //.................................................................... lcl_getUniqueLabel_nothrow(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rBaseLabel)154cdf0e10cSrcweir static ::rtl::OUString lcl_getUniqueLabel_nothrow( const Reference< XPropertySet >& _rxControlModel, const ::rtl::OUString& _rBaseLabel ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir ::rtl::OUString sLabel( _rBaseLabel ); 157cdf0e10cSrcweir try 158cdf0e10cSrcweir { 159cdf0e10cSrcweir typedef ::std::set< ::rtl::OUString > StringBag; 160cdf0e10cSrcweir StringBag aUsedLabels; 161cdf0e10cSrcweir 162cdf0e10cSrcweir Reference< XFormComponent > xFormComponent( _rxControlModel, UNO_QUERY_THROW ); 163cdf0e10cSrcweir Reference< XIndexAccess > xContainer( xFormComponent->getParent(), UNO_QUERY_THROW ); 164cdf0e10cSrcweir // loop through all siblings of the control model, and collect their labels 165cdf0e10cSrcweir for ( sal_Int32 index=xContainer->getCount(); index>0; ) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir Reference< XPropertySet > xElement( xContainer->getByIndex( --index ), UNO_QUERY_THROW ); 168cdf0e10cSrcweir if ( xElement == _rxControlModel ) 169cdf0e10cSrcweir continue; 170cdf0e10cSrcweir 171cdf0e10cSrcweir Reference< XPropertySetInfo > xPSI( xElement->getPropertySetInfo(), UNO_SET_THROW ); 172cdf0e10cSrcweir if ( !xPSI->hasPropertyByName( FM_PROP_LABEL ) ) 173cdf0e10cSrcweir continue; 174cdf0e10cSrcweir 175cdf0e10cSrcweir ::rtl::OUString sElementLabel; 176cdf0e10cSrcweir OSL_VERIFY( xElement->getPropertyValue( FM_PROP_LABEL ) >>= sElementLabel ); 177cdf0e10cSrcweir aUsedLabels.insert( sElementLabel ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir // now find a free label 181cdf0e10cSrcweir sal_Int32 i=2; 182cdf0e10cSrcweir while ( aUsedLabels.find( sLabel ) != aUsedLabels.end() ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir ::rtl::OUStringBuffer aBuffer( _rBaseLabel ); 185cdf0e10cSrcweir aBuffer.appendAscii( " " ); 186cdf0e10cSrcweir aBuffer.append( (sal_Int32)i++ ); 187cdf0e10cSrcweir sLabel = aBuffer.makeStringAndClear(); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir } 190cdf0e10cSrcweir catch( const Exception& ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir return sLabel; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir //.................................................................... lcl_getDataSourceIndirectProperties(const Reference<XPropertySet> & _rxControlModel,const::comphelper::ComponentContext & _rContext)198cdf0e10cSrcweir static Sequence< PropertyValue > lcl_getDataSourceIndirectProperties( const Reference< XPropertySet >& _rxControlModel, 199cdf0e10cSrcweir const ::comphelper::ComponentContext& _rContext ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir OSL_PRECOND( _rxControlModel.is(), "lcl_getDataSourceIndirectProperties: invalid model!" ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir Sequence< PropertyValue > aInfo; 204cdf0e10cSrcweir try 205cdf0e10cSrcweir { 206cdf0e10cSrcweir Reference< XChild > xChild( _rxControlModel, UNO_QUERY ); 207cdf0e10cSrcweir Reference< XPropertySet > xForm; 208cdf0e10cSrcweir if ( xChild.is() ) 209cdf0e10cSrcweir xForm = xForm.query( xChild->getParent() ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir if ( Reference< XGridColumnFactory >( xForm, UNO_QUERY ).is() ) 212cdf0e10cSrcweir { // hmm. the model is a grid column, in real 213cdf0e10cSrcweir xChild = xChild.query( xForm ); 214cdf0e10cSrcweir xForm = xForm.query( xChild->getParent() ); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir OSL_ENSURE( xForm.is(), "lcl_getDataSourceIndirectProperties: could not determine the form!" ); 218cdf0e10cSrcweir if ( !xForm.is() ) 219cdf0e10cSrcweir return aInfo; 220cdf0e10cSrcweir ::rtl::OUString sDataSourceName; 221cdf0e10cSrcweir xForm->getPropertyValue( FM_PROP_DATASOURCE ) >>= sDataSourceName; 222cdf0e10cSrcweir 223cdf0e10cSrcweir Reference< XPropertySet > xDsProperties; 224cdf0e10cSrcweir if ( sDataSourceName.getLength() ) 225cdf0e10cSrcweir xDsProperties = xDsProperties.query( OStaticDataAccessTools().getDataSource( sDataSourceName, _rContext.getLegacyServiceFactory() ) ); 226cdf0e10cSrcweir if ( xDsProperties.is() ) 227cdf0e10cSrcweir xDsProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Info" ) ) ) >>= aInfo; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir catch( const Exception& ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir OSL_ENSURE( sal_False, "lcl_getDataSourceIndirectProperties: caught an exception!" ); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir return aInfo; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir //.................................................................... 237cdf0e10cSrcweir static const sal_Char* aCharacterAndParagraphProperties[] = 238cdf0e10cSrcweir { 239cdf0e10cSrcweir "CharFontName", 240cdf0e10cSrcweir "CharFontStyleName", 241cdf0e10cSrcweir "CharFontFamily", 242cdf0e10cSrcweir "CharFontCharSet", 243cdf0e10cSrcweir "CharFontPitch", 244cdf0e10cSrcweir "CharColor", 245cdf0e10cSrcweir "CharEscapement", 246cdf0e10cSrcweir "CharHeight", 247cdf0e10cSrcweir "CharUnderline", 248cdf0e10cSrcweir "CharWeight", 249cdf0e10cSrcweir "CharPosture", 250cdf0e10cSrcweir "CharAutoKerning", 251cdf0e10cSrcweir "CharBackColor", 252cdf0e10cSrcweir "CharBackTransparent", 253cdf0e10cSrcweir "CharCaseMap", 254cdf0e10cSrcweir "CharCrossedOut", 255cdf0e10cSrcweir "CharFlash", 256cdf0e10cSrcweir "CharStrikeout", 257cdf0e10cSrcweir "CharWordMode", 258cdf0e10cSrcweir "CharKerning", 259cdf0e10cSrcweir "CharLocale", 260cdf0e10cSrcweir "CharKeepTogether", 261cdf0e10cSrcweir "CharNoLineBreak", 262cdf0e10cSrcweir "CharShadowed", 263cdf0e10cSrcweir "CharFontType", 264cdf0e10cSrcweir "CharStyleName", 265cdf0e10cSrcweir "CharContoured", 266cdf0e10cSrcweir "CharCombineIsOn", 267cdf0e10cSrcweir "CharCombinePrefix", 268cdf0e10cSrcweir "CharCombineSuffix", 269cdf0e10cSrcweir "CharEmphasize", 270cdf0e10cSrcweir "CharRelief", 271cdf0e10cSrcweir "RubyText", 272cdf0e10cSrcweir "RubyAdjust", 273cdf0e10cSrcweir "RubyCharStyleName", 274cdf0e10cSrcweir "RubyIsAbove", 275cdf0e10cSrcweir "CharRotation", 276cdf0e10cSrcweir "CharRotationIsFitToLine", 277cdf0e10cSrcweir "CharScaleWidth", 278cdf0e10cSrcweir "HyperLinkURL", 279cdf0e10cSrcweir "HyperLinkTarget", 280cdf0e10cSrcweir "HyperLinkName", 281cdf0e10cSrcweir "VisitedCharStyleName", 282cdf0e10cSrcweir "UnvisitedCharStyleName", 283cdf0e10cSrcweir "CharEscapementHeight", 284cdf0e10cSrcweir "CharNoHyphenation", 285cdf0e10cSrcweir "CharUnderlineColor", 286cdf0e10cSrcweir "CharUnderlineHasColor", 287cdf0e10cSrcweir "CharStyleNames", 288cdf0e10cSrcweir "CharHeightAsian", 289cdf0e10cSrcweir "CharWeightAsian", 290cdf0e10cSrcweir "CharFontNameAsian", 291cdf0e10cSrcweir "CharFontStyleNameAsian", 292cdf0e10cSrcweir "CharFontFamilyAsian", 293cdf0e10cSrcweir "CharFontCharSetAsian", 294cdf0e10cSrcweir "CharFontPitchAsian", 295cdf0e10cSrcweir "CharPostureAsian", 296cdf0e10cSrcweir "CharLocaleAsian", 297cdf0e10cSrcweir "ParaIsCharacterDistance", 298cdf0e10cSrcweir "ParaIsForbiddenRules", 299cdf0e10cSrcweir "ParaIsHangingPunctuation", 300cdf0e10cSrcweir "CharHeightComplex", 301cdf0e10cSrcweir "CharWeightComplex", 302cdf0e10cSrcweir "CharFontNameComplex", 303cdf0e10cSrcweir "CharFontStyleNameComplex", 304cdf0e10cSrcweir "CharFontFamilyComplex", 305cdf0e10cSrcweir "CharFontCharSetComplex", 306cdf0e10cSrcweir "CharFontPitchComplex", 307cdf0e10cSrcweir "CharPostureComplex", 308cdf0e10cSrcweir "CharLocaleComplex", 309cdf0e10cSrcweir "ParaAdjust", 310cdf0e10cSrcweir "ParaLineSpacing", 311cdf0e10cSrcweir "ParaBackColor", 312cdf0e10cSrcweir "ParaBackTransparent", 313cdf0e10cSrcweir "ParaBackGraphicURL", 314cdf0e10cSrcweir "ParaBackGraphicFilter", 315cdf0e10cSrcweir "ParaBackGraphicLocation", 316cdf0e10cSrcweir "ParaLastLineAdjust", 317cdf0e10cSrcweir "ParaExpandSingleWord", 318cdf0e10cSrcweir "ParaLeftMargin", 319cdf0e10cSrcweir "ParaRightMargin", 320cdf0e10cSrcweir "ParaTopMargin", 321cdf0e10cSrcweir "ParaBottomMargin", 322cdf0e10cSrcweir "ParaLineNumberCount", 323cdf0e10cSrcweir "ParaLineNumberStartValue", 324cdf0e10cSrcweir "PageDescName", 325cdf0e10cSrcweir "PageNumberOffset", 326cdf0e10cSrcweir "ParaRegisterModeActive", 327cdf0e10cSrcweir "ParaTabStops", 328cdf0e10cSrcweir "ParaStyleName", 329cdf0e10cSrcweir "DropCapFormat", 330cdf0e10cSrcweir "DropCapWholeWord", 331cdf0e10cSrcweir "ParaKeepTogether", 332cdf0e10cSrcweir "Setting", 333cdf0e10cSrcweir "ParaSplit", 334cdf0e10cSrcweir "Setting", 335cdf0e10cSrcweir "NumberingLevel", 336cdf0e10cSrcweir "NumberingRules", 337cdf0e10cSrcweir "NumberingStartValue", 338cdf0e10cSrcweir "ParaIsNumberingRestart", 339cdf0e10cSrcweir "NumberingStyleName", 340cdf0e10cSrcweir "ParaOrphans", 341cdf0e10cSrcweir "ParaWidows", 342cdf0e10cSrcweir "ParaShadowFormat", 343cdf0e10cSrcweir "LeftBorder", 344cdf0e10cSrcweir "RightBorder", 345cdf0e10cSrcweir "TopBorder", 346cdf0e10cSrcweir "BottomBorder", 347cdf0e10cSrcweir "BorderDistance", 348cdf0e10cSrcweir "LeftBorderDistance", 349cdf0e10cSrcweir "RightBorderDistance", 350cdf0e10cSrcweir "TopBorderDistance", 351cdf0e10cSrcweir "BottomBorderDistance", 352cdf0e10cSrcweir "BreakType", 353cdf0e10cSrcweir "DropCapCharStyleName", 354cdf0e10cSrcweir "ParaFirstLineIndent", 355cdf0e10cSrcweir "ParaIsAutoFirstLineIndent", 356cdf0e10cSrcweir "ParaIsHyphenation", 357cdf0e10cSrcweir "ParaHyphenationMaxHyphens", 358cdf0e10cSrcweir "ParaHyphenationMaxLeadingChars", 359cdf0e10cSrcweir "ParaHyphenationMaxTrailingChars", 360cdf0e10cSrcweir "ParaVertAlignment", 361cdf0e10cSrcweir "ParaUserDefinedAttributes", 362cdf0e10cSrcweir "NumberingIsNumber", 363cdf0e10cSrcweir "ParaIsConnectBorder", 364cdf0e10cSrcweir NULL 365cdf0e10cSrcweir }; 366cdf0e10cSrcweir 367cdf0e10cSrcweir //.................................................................... lcl_initializeCharacterAttributes(const Reference<XPropertySet> & _rxModel)368cdf0e10cSrcweir static void lcl_initializeCharacterAttributes( const Reference< XPropertySet >& _rxModel ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir try 371cdf0e10cSrcweir { 372cdf0e10cSrcweir Reference< XPropertySet > xStyle( ControlLayouter::getDefaultDocumentTextStyle( _rxModel ), UNO_SET_THROW ); 373cdf0e10cSrcweir 374cdf0e10cSrcweir // transfer all properties which are described by the style 375cdf0e10cSrcweir Reference< XPropertySetInfo > xSourcePropInfo( xStyle->getPropertySetInfo(), UNO_SET_THROW ); 376cdf0e10cSrcweir Reference< XPropertySetInfo > xDestPropInfo( _rxModel->getPropertySetInfo(), UNO_SET_THROW ); 377cdf0e10cSrcweir 378cdf0e10cSrcweir ::rtl::OUString sPropertyName; 379cdf0e10cSrcweir const sal_Char** pCharacterProperty = aCharacterAndParagraphProperties; 380cdf0e10cSrcweir while ( *pCharacterProperty ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir sPropertyName = ::rtl::OUString::createFromAscii( *pCharacterProperty ); 383cdf0e10cSrcweir 384cdf0e10cSrcweir if ( xSourcePropInfo->hasPropertyByName( sPropertyName ) && xDestPropInfo->hasPropertyByName( sPropertyName ) ) 385cdf0e10cSrcweir _rxModel->setPropertyValue( sPropertyName, xStyle->getPropertyValue( sPropertyName ) ); 386cdf0e10cSrcweir 387cdf0e10cSrcweir ++pCharacterProperty; 388cdf0e10cSrcweir } 389cdf0e10cSrcweir } 390cdf0e10cSrcweir catch( const Exception& ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir //-------------------------------------------------------------------- initializeControlModel(const DocumentType _eDocType,const Reference<XPropertySet> & _rxControlModel,const Rectangle & _rControlBoundRect)398cdf0e10cSrcweir sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const Reference< XPropertySet >& _rxControlModel, 399cdf0e10cSrcweir const Rectangle& _rControlBoundRect ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir sal_Int16 nClassId = FormComponentType::CONTROL; 402cdf0e10cSrcweir 403cdf0e10cSrcweir OSL_ENSURE( _rxControlModel.is(), "FormControlFactory::initializeControlModel: invalid model!" ); 404cdf0e10cSrcweir if ( !_rxControlModel.is() ) 405cdf0e10cSrcweir return nClassId; 406cdf0e10cSrcweir 407cdf0e10cSrcweir try 408cdf0e10cSrcweir { 409cdf0e10cSrcweir ControlLayouter::initializeControlLayout( _rxControlModel, _eDocType ); 410cdf0e10cSrcweir 411cdf0e10cSrcweir _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId; 412cdf0e10cSrcweir Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW ); 413cdf0e10cSrcweir switch ( nClassId ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir case FormComponentType::SCROLLBAR: 416cdf0e10cSrcweir _rxControlModel->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LiveScroll" ) ), makeAny( (sal_Bool)sal_True ) ); 417cdf0e10cSrcweir // NO break! 418cdf0e10cSrcweir case FormComponentType::SPINBUTTON: 419cdf0e10cSrcweir { 420cdf0e10cSrcweir sal_Int32 eOrientation = ScrollBarOrientation::HORIZONTAL; 421cdf0e10cSrcweir if ( !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() < _rControlBoundRect.GetHeight() ) ) 422cdf0e10cSrcweir eOrientation = ScrollBarOrientation::VERTICAL; 423cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_ORIENTATION, makeAny( eOrientation ) ); 424cdf0e10cSrcweir } 425cdf0e10cSrcweir break; 426cdf0e10cSrcweir 427cdf0e10cSrcweir case FormComponentType::LISTBOX: 428cdf0e10cSrcweir case FormComponentType::COMBOBOX: 429cdf0e10cSrcweir { 430cdf0e10cSrcweir sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() ); 431cdf0e10cSrcweir if ( xPSI->hasPropertyByName( FM_PROP_DROPDOWN ) ) 432cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) ); 433cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_LINECOUNT, makeAny( sal_Int16( 20 ) ) ); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir break; 436cdf0e10cSrcweir 437cdf0e10cSrcweir case FormComponentType::TEXTFIELD: 438cdf0e10cSrcweir { 439cdf0e10cSrcweir initializeTextFieldLineEnds( _rxControlModel ); 440cdf0e10cSrcweir lcl_initializeCharacterAttributes( _rxControlModel ); 441cdf0e10cSrcweir 442cdf0e10cSrcweir if ( !_rControlBoundRect.IsEmpty() 443cdf0e10cSrcweir && !( _rControlBoundRect.GetWidth() > 4 * _rControlBoundRect.GetHeight() ) 444cdf0e10cSrcweir ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir if ( xPSI->hasPropertyByName( FM_PROP_MULTILINE ) ) 447cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_MULTILINE, makeAny( (sal_Bool)sal_True ) ); 448cdf0e10cSrcweir } 449cdf0e10cSrcweir } 450cdf0e10cSrcweir break; 451cdf0e10cSrcweir 452cdf0e10cSrcweir case FormComponentType::RADIOBUTTON: 453cdf0e10cSrcweir case FormComponentType::CHECKBOX: 454cdf0e10cSrcweir case FormComponentType::FIXEDTEXT: 455cdf0e10cSrcweir { 456cdf0e10cSrcweir ::rtl::OUString sVertAlignPropertyName( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) ); 457cdf0e10cSrcweir if ( xPSI->hasPropertyByName( sVertAlignPropertyName ) ) 458cdf0e10cSrcweir _rxControlModel->setPropertyValue( sVertAlignPropertyName, makeAny( VerticalAlignment_MIDDLE ) ); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir break; 461cdf0e10cSrcweir 462cdf0e10cSrcweir case FormComponentType::IMAGEBUTTON: 463cdf0e10cSrcweir case FormComponentType::IMAGECONTROL: 464cdf0e10cSrcweir { 465cdf0e10cSrcweir const ::rtl::OUString sScaleModeProperty( RTL_CONSTASCII_USTRINGPARAM( "ScaleMode" ) ); 466cdf0e10cSrcweir if ( xPSI->hasPropertyByName( sScaleModeProperty ) ) 467*b6dc695eSAriel Constenla-Haile _rxControlModel->setPropertyValue( sScaleModeProperty, makeAny( ImageScaleMode::ISOTROPIC ) ); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir break; 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir // initial default label for the control 473cdf0e10cSrcweir if ( xPSI->hasPropertyByName( FM_PROP_LABEL ) ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir ::rtl::OUString sExistingLabel; 476cdf0e10cSrcweir OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_LABEL ) >>= sExistingLabel ); 477cdf0e10cSrcweir if ( !sExistingLabel.getLength() ) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir ::rtl::OUString sInitialLabel; 480cdf0e10cSrcweir OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_NAME ) >>= sInitialLabel ); 481cdf0e10cSrcweir 482cdf0e10cSrcweir sal_uInt16 nTitleResId = 0; 483cdf0e10cSrcweir switch ( nClassId ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir case FormComponentType::COMMANDBUTTON: nTitleResId = RID_STR_PROPTITLE_PUSHBUTTON; break; 486cdf0e10cSrcweir case FormComponentType::RADIOBUTTON: nTitleResId = RID_STR_PROPTITLE_RADIOBUTTON; break; 487cdf0e10cSrcweir case FormComponentType::CHECKBOX: nTitleResId = RID_STR_PROPTITLE_CHECKBOX; break; 488cdf0e10cSrcweir case FormComponentType::GROUPBOX: nTitleResId = RID_STR_PROPTITLE_GROUPBOX; break; 489cdf0e10cSrcweir case FormComponentType::FIXEDTEXT: nTitleResId = RID_STR_PROPTITLE_FIXEDTEXT; break; 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir if ( nTitleResId ) 493cdf0e10cSrcweir sInitialLabel = String( SVX_RES( nTitleResId ) ); 494cdf0e10cSrcweir 495cdf0e10cSrcweir _rxControlModel->setPropertyValue( 496cdf0e10cSrcweir FM_PROP_LABEL, 497cdf0e10cSrcweir makeAny( lcl_getUniqueLabel_nothrow( _rxControlModel, sInitialLabel ) ) 498cdf0e10cSrcweir ); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir // strict format = yes is the default (i93467) 503cdf0e10cSrcweir if ( xPSI->hasPropertyByName( FM_PROP_STRICTFORMAT ) ) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_STRICTFORMAT, makeAny( sal_Bool( sal_True ) ) ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir // mouse wheel: don't use it for scrolling by default (i110036) 509cdf0e10cSrcweir if ( xPSI->hasPropertyByName( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_MOUSE_WHEEL_BEHAVIOR, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) ); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir 514cdf0e10cSrcweir if ( xPSI->hasPropertyByName( FM_PROP_WRITING_MODE ) ) 515cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_WRITING_MODE, makeAny( WritingMode2::CONTEXT ) ); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir catch( const Exception& ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 520cdf0e10cSrcweir } 521cdf0e10cSrcweir return nClassId; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir //------------------------------------------------------------------------------ initializeTextFieldLineEnds(const Reference<XPropertySet> & _rxModel)525cdf0e10cSrcweir void FormControlFactory::initializeTextFieldLineEnds( const Reference< XPropertySet >& _rxModel ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir OSL_PRECOND( _rxModel.is(), "initializeTextFieldLineEnds: invalid model!" ); 528cdf0e10cSrcweir if ( !_rxModel.is() ) 529cdf0e10cSrcweir return; 530cdf0e10cSrcweir 531cdf0e10cSrcweir try 532cdf0e10cSrcweir { 533cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo = _rxModel->getPropertySetInfo(); 534cdf0e10cSrcweir if ( !xInfo.is() || !xInfo->hasPropertyByName( FM_PROP_LINEENDFORMAT ) ) 535cdf0e10cSrcweir return; 536cdf0e10cSrcweir 537cdf0e10cSrcweir // let's see if the data source which the form belongs to (if any) 538cdf0e10cSrcweir // has a setting for the preferred line end format 539cdf0e10cSrcweir sal_Bool bDosLineEnds = sal_False; 540cdf0e10cSrcweir Sequence< PropertyValue > aInfo = lcl_getDataSourceIndirectProperties( _rxModel, m_pData->m_aContext ); 541cdf0e10cSrcweir const PropertyValue* pInfo = aInfo.getConstArray(); 542cdf0e10cSrcweir const PropertyValue* pInfoEnd = pInfo + aInfo.getLength(); 543cdf0e10cSrcweir for ( ; pInfo != pInfoEnd; ++pInfo ) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir if ( pInfo->Name.equalsAscii( "PreferDosLikeLineEnds" ) ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir pInfo->Value >>= bDosLineEnds; 548cdf0e10cSrcweir break; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir sal_Int16 nLineEndFormat = bDosLineEnds ? LineEndFormat::CARRIAGE_RETURN_LINE_FEED : LineEndFormat::LINE_FEED; 553cdf0e10cSrcweir _rxModel->setPropertyValue( FM_PROP_LINEENDFORMAT, makeAny( nLineEndFormat ) ); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir catch( const Exception& ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir } 560cdf0e10cSrcweir 561cdf0e10cSrcweir //------------------------------------------------------------------------------ initializeFieldDependentProperties(const Reference<XPropertySet> & _rxDatabaseField,const Reference<XPropertySet> & _rxControlModel,const Reference<XNumberFormats> & _rxNumberFormats)562cdf0e10cSrcweir void FormControlFactory::initializeFieldDependentProperties( const Reference< XPropertySet >& _rxDatabaseField, 563cdf0e10cSrcweir const Reference< XPropertySet >& _rxControlModel, const Reference< XNumberFormats >& _rxNumberFormats ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir OSL_PRECOND( _rxDatabaseField.is() && _rxControlModel.is(), 566cdf0e10cSrcweir "FormControlFactory::initializeFieldDependentProperties: illegal params!" ); 567cdf0e10cSrcweir if ( !_rxDatabaseField.is() || !_rxControlModel.is() ) 568cdf0e10cSrcweir return; 569cdf0e10cSrcweir 570cdf0e10cSrcweir try 571cdf0e10cSrcweir { 572cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////// 573cdf0e10cSrcweir // if the field has a numeric format, and the model has a "Scale" property, sync it 574cdf0e10cSrcweir Reference< XPropertySetInfo > xFieldPSI( _rxDatabaseField->getPropertySetInfo(), UNO_SET_THROW ); 575cdf0e10cSrcweir Reference< XPropertySetInfo > xModelPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW ); 576cdf0e10cSrcweir 577cdf0e10cSrcweir if ( xModelPSI->hasPropertyByName( FM_PROP_DECIMAL_ACCURACY ) ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir sal_Int32 nFormatKey = 0; 580cdf0e10cSrcweir if ( xFieldPSI->hasPropertyByName( FM_PROP_FORMATKEY ) ) 581cdf0e10cSrcweir { 582cdf0e10cSrcweir _rxDatabaseField->getPropertyValue( FM_PROP_FORMATKEY ) >>= nFormatKey; 583cdf0e10cSrcweir } 584cdf0e10cSrcweir else 585cdf0e10cSrcweir { 586cdf0e10cSrcweir nFormatKey = OStaticDataAccessTools().getDefaultNumberFormat( 587cdf0e10cSrcweir _rxDatabaseField, 588cdf0e10cSrcweir Reference< XNumberFormatTypes >( _rxNumberFormats, UNO_QUERY ), 589cdf0e10cSrcweir SvtSysLocale().GetLocaleData().getLocale() 590cdf0e10cSrcweir ); 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir Any aScaleVal( ::comphelper::getNumberFormatDecimals( _rxNumberFormats, nFormatKey ) ); 594cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_DECIMAL_ACCURACY, aScaleVal ); 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////// 598cdf0e10cSrcweir // minimum and maximum of the control according to the type of the database field 599cdf0e10cSrcweir sal_Int32 nDataType = DataType::OTHER; 600cdf0e10cSrcweir OSL_VERIFY( _rxDatabaseField->getPropertyValue( FM_PROP_FIELDTYPE ) >>= nDataType ); 601cdf0e10cSrcweir 602cdf0e10cSrcweir if ( xModelPSI->hasPropertyByName( FM_PROP_VALUEMIN ) 603cdf0e10cSrcweir && xModelPSI->hasPropertyByName( FM_PROP_VALUEMAX ) 604cdf0e10cSrcweir ) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir sal_Int32 nMinValue = -1000000000, nMaxValue = 1000000000; 607cdf0e10cSrcweir switch ( nDataType ) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir case DataType::TINYINT : nMinValue = 0; nMaxValue = 255; break; 610cdf0e10cSrcweir case DataType::SMALLINT : nMinValue = -32768; nMaxValue = 32767; break; 611cdf0e10cSrcweir case DataType::INTEGER : nMinValue = 0x80000000; nMaxValue = 0x7FFFFFFF; break; 612cdf0e10cSrcweir // double and singles are ignored 613cdf0e10cSrcweir } 614cdf0e10cSrcweir 615cdf0e10cSrcweir Any aValue; 616cdf0e10cSrcweir 617cdf0e10cSrcweir // both the minimum and the maximum value properties can be either Long or Double 618cdf0e10cSrcweir Property aProperty = xModelPSI->getPropertyByName( FM_PROP_VALUEMIN ); 619cdf0e10cSrcweir if ( aProperty.Type.getTypeClass() == TypeClass_DOUBLE ) 620cdf0e10cSrcweir aValue <<= (double)nMinValue; 621cdf0e10cSrcweir else if ( aProperty.Type.getTypeClass() == TypeClass_LONG ) 622cdf0e10cSrcweir aValue <<= (sal_Int32)nMinValue; 623cdf0e10cSrcweir else 624cdf0e10cSrcweir { 625cdf0e10cSrcweir DBG_ERROR( "FormControlFactory::initializeFieldDependentProperties: unexpected property type (MinValue)!" ); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_VALUEMIN, aValue ); 628cdf0e10cSrcweir 629cdf0e10cSrcweir // both the minimum and the maximum value properties can be either Long or Double 630cdf0e10cSrcweir aProperty = xModelPSI->getPropertyByName( FM_PROP_VALUEMAX ); 631cdf0e10cSrcweir if ( aProperty.Type.getTypeClass() == TypeClass_DOUBLE ) 632cdf0e10cSrcweir aValue <<= (double)nMaxValue; 633cdf0e10cSrcweir else if ( aProperty.Type.getTypeClass() == TypeClass_LONG ) 634cdf0e10cSrcweir aValue <<= (sal_Int32)nMaxValue; 635cdf0e10cSrcweir else 636cdf0e10cSrcweir { 637cdf0e10cSrcweir DBG_ERROR( "FormControlFactory::initializeFieldDependentProperties: unexpected property type (MaxValue)!" ); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_VALUEMAX, aValue ); 640cdf0e10cSrcweir } 641cdf0e10cSrcweir 642cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////// 643cdf0e10cSrcweir // a check box can be tristate if and only if the column it is bound to is nullable 644cdf0e10cSrcweir sal_Int16 nClassId = FormComponentType::CONTROL; 645cdf0e10cSrcweir OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId ); 646cdf0e10cSrcweir if ( nClassId == FormComponentType::CHECKBOX ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN; 649cdf0e10cSrcweir OSL_VERIFY( _rxDatabaseField->getPropertyValue( FM_PROP_ISNULLABLE ) >>= nNullable ); 650cdf0e10cSrcweir _rxControlModel->setPropertyValue( FM_PROP_TRISTATE, makeAny( sal_Bool( ColumnValue::NO_NULLS != nNullable ) ) ); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir } 653cdf0e10cSrcweir catch( const Exception& ) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir } 658cdf0e10cSrcweir 659cdf0e10cSrcweir //------------------------------------------------------------------------------ getDefaultName(sal_Int16 _nClassId,const Reference<XServiceInfo> & _rxObject)660cdf0e10cSrcweir ::rtl::OUString FormControlFactory::getDefaultName( sal_Int16 _nClassId, const Reference< XServiceInfo >& _rxObject ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir sal_uInt16 nResId(0); 663cdf0e10cSrcweir 664cdf0e10cSrcweir switch ( _nClassId ) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir case FormComponentType::COMMANDBUTTON: nResId = RID_STR_PROPTITLE_PUSHBUTTON; break; 667cdf0e10cSrcweir case FormComponentType::RADIOBUTTON: nResId = RID_STR_PROPTITLE_RADIOBUTTON; break; 668cdf0e10cSrcweir case FormComponentType::CHECKBOX: nResId = RID_STR_PROPTITLE_CHECKBOX; break; 669cdf0e10cSrcweir case FormComponentType::LISTBOX: nResId = RID_STR_PROPTITLE_LISTBOX; break; 670cdf0e10cSrcweir case FormComponentType::COMBOBOX: nResId = RID_STR_PROPTITLE_COMBOBOX; break; 671cdf0e10cSrcweir case FormComponentType::GROUPBOX: nResId = RID_STR_PROPTITLE_GROUPBOX; break; 672cdf0e10cSrcweir case FormComponentType::IMAGEBUTTON: nResId = RID_STR_PROPTITLE_IMAGEBUTTON; break; 673cdf0e10cSrcweir case FormComponentType::FIXEDTEXT: nResId = RID_STR_PROPTITLE_FIXEDTEXT; break; 674cdf0e10cSrcweir case FormComponentType::GRIDCONTROL: nResId = RID_STR_PROPTITLE_DBGRID; break; 675cdf0e10cSrcweir case FormComponentType::FILECONTROL: nResId = RID_STR_PROPTITLE_FILECONTROL; break; 676cdf0e10cSrcweir case FormComponentType::DATEFIELD: nResId = RID_STR_PROPTITLE_DATEFIELD; break; 677cdf0e10cSrcweir case FormComponentType::TIMEFIELD: nResId = RID_STR_PROPTITLE_TIMEFIELD; break; 678cdf0e10cSrcweir case FormComponentType::NUMERICFIELD: nResId = RID_STR_PROPTITLE_NUMERICFIELD; break; 679cdf0e10cSrcweir case FormComponentType::CURRENCYFIELD: nResId = RID_STR_PROPTITLE_CURRENCYFIELD; break; 680cdf0e10cSrcweir case FormComponentType::PATTERNFIELD: nResId = RID_STR_PROPTITLE_PATTERNFIELD; break; 681cdf0e10cSrcweir case FormComponentType::IMAGECONTROL: nResId = RID_STR_PROPTITLE_IMAGECONTROL; break; 682cdf0e10cSrcweir case FormComponentType::HIDDENCONTROL: nResId = RID_STR_PROPTITLE_HIDDEN; break; 683cdf0e10cSrcweir case FormComponentType::SCROLLBAR: nResId = RID_STR_PROPTITLE_SCROLLBAR; break; 684cdf0e10cSrcweir case FormComponentType::SPINBUTTON: nResId = RID_STR_PROPTITLE_SPINBUTTON; break; 685cdf0e10cSrcweir case FormComponentType::NAVIGATIONBAR: nResId = RID_STR_PROPTITLE_NAVBAR; break; 686cdf0e10cSrcweir 687cdf0e10cSrcweir case FormComponentType::TEXTFIELD: 688cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_EDIT; 689cdf0e10cSrcweir if ( _rxObject.is() && _rxObject->supportsService( FM_SUN_COMPONENT_FORMATTEDFIELD ) ) 690cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_FORMATTED; 691cdf0e10cSrcweir break; 692cdf0e10cSrcweir 693cdf0e10cSrcweir default: 694cdf0e10cSrcweir nResId = RID_STR_CONTROL; break; 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir return String( SVX_RES( nResId ) ); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir //------------------------------------------------------------------------------ getDefaultUniqueName_ByComponentType(const Reference<XNameAccess> & _rxContainer,const Reference<XPropertySet> & _rxObject)701cdf0e10cSrcweir ::rtl::OUString FormControlFactory::getDefaultUniqueName_ByComponentType( const Reference< XNameAccess >& _rxContainer, 702cdf0e10cSrcweir const Reference< XPropertySet >& _rxObject ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir sal_Int16 nClassId = FormComponentType::CONTROL; 705cdf0e10cSrcweir OSL_VERIFY( _rxObject->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId ); 706cdf0e10cSrcweir ::rtl::OUString sBaseName = getDefaultName( nClassId, Reference< XServiceInfo >( _rxObject, UNO_QUERY ) ); 707cdf0e10cSrcweir 708cdf0e10cSrcweir return getUniqueName( _rxContainer, sBaseName ); 709cdf0e10cSrcweir } 710cdf0e10cSrcweir 711cdf0e10cSrcweir //------------------------------------------------------------------------------ getUniqueName(const Reference<XNameAccess> & _rxContainer,const::rtl::OUString & _rBaseName)712cdf0e10cSrcweir ::rtl::OUString FormControlFactory::getUniqueName( const Reference< XNameAccess >& _rxContainer, const ::rtl::OUString& _rBaseName ) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir sal_Int32 n = 0; 715cdf0e10cSrcweir ::rtl::OUString sName; 716cdf0e10cSrcweir do 717cdf0e10cSrcweir { 718cdf0e10cSrcweir ::rtl::OUStringBuffer aBuf( _rBaseName ); 719cdf0e10cSrcweir aBuf.appendAscii( " " ); 720cdf0e10cSrcweir aBuf.append( ++n ); 721cdf0e10cSrcweir sName = aBuf.makeStringAndClear(); 722cdf0e10cSrcweir } 723cdf0e10cSrcweir while ( _rxContainer->hasByName( sName ) ); 724cdf0e10cSrcweir 725cdf0e10cSrcweir return sName; 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir //........................................................................ 729cdf0e10cSrcweir } // namespace svxform 730cdf0e10cSrcweir //........................................................................ 731