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