1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 
31 #include "controltype.hxx"
32 #include "propctrlr.hrc"
33 #include "extensio.hrc"
34 #include "fontdialog.hxx"
35 #include "formcomponenthandler.hxx"
36 #include "formlinkdialog.hxx"
37 #include "formmetadata.hxx"
38 #include "formresid.hrc"
39 #include "formstrings.hxx"
40 #include "handlerhelper.hxx"
41 #include "listselectiondlg.hxx"
42 #include "pcrcommon.hxx"
43 #include "selectlabeldialog.hxx"
44 #include "taborder.hxx"
45 #include "usercontrol.hxx"
46 
47 /** === begin UNO includes === **/
48 #include <com/sun/star/lang/NullPointerException.hpp>
49 #include <com/sun/star/awt/XControlModel.hpp>
50 #include <com/sun/star/lang/XServiceInfo.hpp>
51 #include <com/sun/star/form/FormComponentType.hpp>
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
53 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
54 #include <com/sun/star/container/XNameAccess.hpp>
55 #include <com/sun/star/form/XForm.hpp>
56 #include <com/sun/star/container/XChild.hpp>
57 #include <com/sun/star/sdbc/XConnection.hpp>
58 #include <com/sun/star/sdb/CommandType.hpp>
59 #include <com/sun/star/form/XGridColumnFactory.hpp>
60 #include <com/sun/star/sdb/SQLContext.hpp>
61 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
62 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
63 #include <com/sun/star/form/ListSourceType.hpp>
64 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
65 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
66 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
67 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
68 #include <com/sun/star/awt/XTabControllerModel.hpp>
69 #include <com/sun/star/form/FormSubmitEncoding.hpp>
70 #include <com/sun/star/awt/VisualEffect.hpp>
71 #include <com/sun/star/form/FormButtonType.hpp>
72 #include <com/sun/star/inspection/PropertyControlType.hpp>
73 #include <com/sun/star/util/MeasureUnit.hpp>
74 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
75 #include <com/sun/star/inspection/PropertyLineElement.hpp>
76 #include <com/sun/star/resource/XStringResourceManager.hpp>
77 #include <com/sun/star/resource/MissingResourceException.hpp>
78 #include <com/sun/star/graphic/GraphicObject.hpp>
79 #include <com/sun/star/text/WritingMode2.hpp>
80 /** === end UNO includes === **/
81 
82 #include <comphelper/extract.hxx>
83 #include <connectivity/dbconversion.hxx>
84 #include <connectivity/dbexception.hxx>
85 #include <cppuhelper/exc_hlp.hxx>
86 #include <sfx2/app.hxx>
87 #include <sfx2/basedlgs.hxx>
88 #include <sfx2/docfilt.hxx>
89 #include <sfx2/filedlghelper.hxx>
90 #include <svl/ctloptions.hxx>
91 #include <svtools/colrdlg.hxx>
92 #include <svl/filenotation.hxx>
93 #include <svl/intitem.hxx>
94 #include <svl/itemset.hxx>
95 #include <unotools/moduleoptions.hxx>
96 #include <svl/numuno.hxx>
97 #include <svl/urihelper.hxx>
98 #include <svx/dialogs.hrc>
99 #include <svx/numinf.hxx>
100 #include <svx/svxdlg.hxx>
101 #include <svx/svxids.hrc>
102 #include <toolkit/helper/vclunohelper.hxx>
103 #include <tools/diagnose_ex.h>
104 #include <vcl/msgbox.hxx>
105 #include <vcl/stdtext.hxx>
106 #include <vcl/wrkwin.hxx>
107 #include <tools/StringListResource.hxx>
108 
109 #include <limits>
110 
111 #define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
112 //------------------------------------------------------------------------
113 extern "C" void SAL_CALL createRegistryInfo_FormComponentPropertyHandler()
114 {
115     ::pcr::FormComponentPropertyHandler::registerImplementation();
116 }
117 
118 //........................................................................
119 namespace pcr
120 {
121 //........................................................................
122 
123     using namespace ::com::sun::star;
124     using namespace uno;
125     using namespace lang;
126     using namespace beans;
127     using namespace frame;
128     using namespace script;
129     using namespace form;
130     using namespace util;
131     using namespace awt;
132     using namespace sdb;
133     using namespace sdbc;
134     using namespace sdbcx;
135     using namespace form;
136     using namespace container;
137     using namespace ui::dialogs;
138     using namespace inspection;
139     using namespace ::dbtools;
140 
141     namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
142 
143     //====================================================================
144     //= FormComponentPropertyHandler
145     //====================================================================
146     DBG_NAME( FormComponentPropertyHandler )
147 #define PROPERTY_ID_ROWSET 1
148     //--------------------------------------------------------------------
149     FormComponentPropertyHandler::FormComponentPropertyHandler( const Reference< XComponentContext >& _rxContext )
150         :FormComponentPropertyHandler_Base( _rxContext )
151         ,::comphelper::OPropertyContainer(FormComponentPropertyHandler_Base::rBHelper)
152         ,m_sDefaultValueString( String( PcrRes( RID_STR_STANDARD ) ) )
153         ,m_eComponentClass( eUnknown )
154         ,m_bComponentIsSubForm( false )
155         ,m_bHaveListSource( false )
156         ,m_bHaveCommand( false )
157         ,m_nClassId( 0 )
158     {
159         DBG_CTOR( FormComponentPropertyHandler, NULL );
160         registerProperty(PROPERTY_ROWSET,PROPERTY_ID_ROWSET,0,&m_xRowSet,::getCppuType(&m_xRowSet));
161     }
162 
163     //--------------------------------------------------------------------
164     FormComponentPropertyHandler::~FormComponentPropertyHandler()
165     {
166         DBG_DTOR( FormComponentPropertyHandler, NULL );
167     }
168     //--------------------------------------------------------------------
169     IMPLEMENT_FORWARD_XINTERFACE2(FormComponentPropertyHandler,FormComponentPropertyHandler_Base,::comphelper::OPropertyContainer)
170     //--------------------------------------------------------------------
171     ::rtl::OUString SAL_CALL FormComponentPropertyHandler::getImplementationName_static(  ) throw (RuntimeException)
172     {
173         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.FormComponentPropertyHandler" ) );
174     }
175 
176     //--------------------------------------------------------------------
177     Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getSupportedServiceNames_static(  ) throw (RuntimeException)
178     {
179         Sequence< ::rtl::OUString > aSupported( 1 );
180         aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) );
181         return aSupported;
182     }
183 
184 	//============================================
185 	// TODO: -> export from toolkit
186 	struct LanguageDependentProp
187 	{
188 		const char* pPropName;
189 		sal_Int32   nPropNameLength;
190 	};
191 
192 	static LanguageDependentProp aLanguageDependentProp[] =
193 	{
194 		{ "Text",            4 },
195 		{ "Label",           5 },
196 		{ "Title",           5 },
197 		{ "HelpText",        8 },
198 		{ "CurrencySymbol", 14 },
199 	    { "StringItemList", 14 },
200 		{ 0, 0                 }
201 	};
202 
203     namespace
204     {
205 		bool lcl_isLanguageDependentProperty( ::rtl::OUString aName )
206 		{
207 			bool bRet = false;
208 
209 			LanguageDependentProp* pLangDepProp = aLanguageDependentProp;
210 			while( pLangDepProp->pPropName != 0 )
211 			{
212 				if( aName.equalsAsciiL( pLangDepProp->pPropName, pLangDepProp->nPropNameLength ))
213 				{
214 					bRet = true;
215 					break;
216 				}
217 				pLangDepProp++;
218 			}
219 			return bRet;
220 		}
221 
222 		Reference< resource::XStringResourceResolver > lcl_getStringResourceResolverForProperty
223 			( Reference< XPropertySet > _xComponent, const ::rtl::OUString& _rPropertyName,
224 			  const Any& _rPropertyValue )
225 		{
226             Reference< resource::XStringResourceResolver > xRet;
227             const TypeClass eType = _rPropertyValue.getValueType().getTypeClass();
228             if ( (eType == TypeClass_STRING || eType == TypeClass_SEQUENCE) &&
229 				    lcl_isLanguageDependentProperty( _rPropertyName ) )
230             {
231                 static const ::rtl::OUString s_sResourceResolverPropName(RTL_CONSTASCII_USTRINGPARAM("ResourceResolver"));
232 
233 			    Reference< resource::XStringResourceResolver > xStringResourceResolver;
234 			    try
235 			    {
236 				    xStringResourceResolver.set( _xComponent->getPropertyValue( s_sResourceResolverPropName ),UNO_QUERY);
237                     if( xStringResourceResolver.is() &&
238 				        xStringResourceResolver->getLocales().getLength() > 0 )
239 			        {
240 				        xRet = xStringResourceResolver;
241 			        }
242 			    }
243 			    catch(UnknownPropertyException&)
244 			    {
245                     // nii
246                 }
247             }
248 
249 			return xRet;
250 		}
251 	}
252 
253     //--------------------------------------------------------------------
254     Any FormComponentPropertyHandler::impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName ) const
255     {
256         const PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
257 
258         Any aPropertyValue( m_xComponent->getPropertyValue( _rPropertyName ) );
259 
260 		Reference< resource::XStringResourceResolver > xStringResourceResolver
261 			= lcl_getStringResourceResolverForProperty( m_xComponent, _rPropertyName, aPropertyValue );
262 		if( xStringResourceResolver.is() )
263 	    {
264 	        TypeClass eType = aPropertyValue.getValueType().getTypeClass();
265 			if( eType == TypeClass_STRING )
266 			{
267 				::rtl::OUString aPropStr;
268 				aPropertyValue >>= aPropStr;
269 				if( aPropStr.getLength() > 1 )
270 				{
271 					::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
272 					if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
273 					{
274 						::rtl::OUString aResourceStr = xStringResourceResolver->resolveString( aPureIdStr );
275 						aPropertyValue <<= aResourceStr;
276 					}
277 				}
278 			}
279 			// StringItemList?
280 			else if( eType == TypeClass_SEQUENCE )
281 			{
282                 Sequence< ::rtl::OUString > aStrings;
283 				aPropertyValue >>= aStrings;
284 
285                 const ::rtl::OUString* pStrings = aStrings.getConstArray();
286 				sal_Int32 nCount = aStrings.getLength();
287 
288                 Sequence< ::rtl::OUString > aResolvedStrings;
289 				aResolvedStrings.realloc( nCount );
290                 ::rtl::OUString* pResolvedStrings = aResolvedStrings.getArray();
291 				try
292 				{
293 					for ( sal_Int32 i = 0; i < nCount; ++i )
294 					{
295 						::rtl::OUString aIdStr = pStrings[i];
296 						::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
297 						if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
298 							pResolvedStrings[i] = xStringResourceResolver->resolveString( aPureIdStr );
299 						else
300 							pResolvedStrings[i] = aIdStr;
301 					}
302 				}
303 				catch( resource::MissingResourceException & )
304 				{}
305 				aPropertyValue <<= aResolvedStrings;
306 			}
307 	    }
308 		else
309 	        impl_normalizePropertyValue_nothrow( aPropertyValue, nPropId );
310 
311         return aPropertyValue;
312     }
313 
314     //--------------------------------------------------------------------
315     Any SAL_CALL FormComponentPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
316     {
317         if( _rPropertyName == PROPERTY_ROWSET )
318             return ::comphelper::OPropertyContainer::getPropertyValue( _rPropertyName );
319 
320         ::osl::MutexGuard aGuard( m_aMutex );
321         return impl_getPropertyValue_throw( _rPropertyName );
322     }
323 
324     //--------------------------------------------------------------------
325     void SAL_CALL FormComponentPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
326     {
327         if( _rPropertyName == PROPERTY_ROWSET )
328         {
329             ::comphelper::OPropertyContainer::setPropertyValue( _rPropertyName, _rValue );
330             return;
331         }
332 
333         ::osl::MutexGuard aGuard( m_aMutex );
334         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); // check if property is known by the handler
335 
336         Reference< graphic::XGraphicObject > xGrfObj;
337         if ( PROPERTY_ID_IMAGE_URL == nPropId && ( _rValue >>= xGrfObj ) )
338         {
339             DBG_ASSERT( xGrfObj.is(), "FormComponentPropertyHandler::setPropertyValue() xGrfObj is invalid");
340             rtl::OUString sObjectID( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
341             sObjectID = sObjectID + xGrfObj->getUniqueID();
342             m_xComponent->setPropertyValue( _rPropertyName, uno::makeAny( sObjectID ) );
343         }
344         else if ( PROPERTY_ID_FONT == nPropId )
345         {
346             // special handling, the value is a faked value we generated ourself in impl_executeFontDialog_nothrow
347             Sequence< NamedValue > aFontPropertyValues;
348             OSL_VERIFY( _rValue >>= aFontPropertyValues );
349             const NamedValue* fontPropertyValue = aFontPropertyValues.getConstArray();
350             const NamedValue* fontPropertyValueEnd = fontPropertyValue + aFontPropertyValues.getLength();
351             for ( ; fontPropertyValue != fontPropertyValueEnd; ++fontPropertyValue )
352                 m_xComponent->setPropertyValue( fontPropertyValue->Name, fontPropertyValue->Value );
353         }
354         else
355         {
356 			Any aValue = _rValue;
357 
358 			Reference< resource::XStringResourceResolver > xStringResourceResolver
359 				= lcl_getStringResourceResolverForProperty( m_xComponent, _rPropertyName, _rValue );
360 			if( xStringResourceResolver.is() )
361 			{
362 				Reference< resource::XStringResourceManager >
363 					xStringResourceManager( xStringResourceResolver, UNO_QUERY );
364 				if( xStringResourceManager.is() )
365 				{
366 					Any aPropertyValue( m_xComponent->getPropertyValue( _rPropertyName ) );
367 					TypeClass eType = aPropertyValue.getValueType().getTypeClass();
368 					if( eType == TypeClass_STRING )
369 					{
370 						::rtl::OUString aPropStr;
371 						aPropertyValue >>= aPropStr;
372 						if( aPropStr.getLength() > 1 )
373 						{
374 							::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
375 							::rtl::OUString aValueStr;
376 							_rValue >>= aValueStr;
377 							xStringResourceManager->setString( aPureIdStr, aValueStr );
378 							aValue = aPropertyValue;	// set value to force modified
379 						}
380 					}
381 					// StringItemList?
382 					else if( eType == TypeClass_SEQUENCE )
383 					{
384 						static ::rtl::OUString aDot = ::rtl::OUString::createFromAscii( "." );
385 						static ::rtl::OUString aEsc = ::rtl::OUString::createFromAscii( "&" );
386 
387 						// Put strings into resource using new ids
388 						Sequence< ::rtl::OUString > aNewStrings;
389 						_rValue >>= aNewStrings;
390 
391 						const ::rtl::OUString* pNewStrings = aNewStrings.getConstArray();
392 						sal_Int32 nNewCount = aNewStrings.getLength();
393 
394 						// Create new Ids
395 						::rtl::OUString* pNewPureIds = new ::rtl::OUString[nNewCount];
396 						::rtl::OUString aIdStrBase = aDot;
397 						Any aNameAny = m_xComponent->getPropertyValue(PROPERTY_NAME);
398 						::rtl::OUString sControlName;
399 						aNameAny >>= sControlName;
400 						aIdStrBase += sControlName;
401 						aIdStrBase += aDot;
402 						aIdStrBase += _rPropertyName;
403 						sal_Int32 i;
404 						::rtl::OUString aDummyStr;
405 						for ( i = 0; i < nNewCount; ++i )
406 						{
407 							sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
408 							::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
409 							aPureIdStr += aIdStrBase;
410 							pNewPureIds[i] = aPureIdStr;
411 							// Force usage of next Unique Id
412 							xStringResourceManager->setString( aPureIdStr, aDummyStr );
413 						}
414 
415 						// Move strings to new Ids for all locales
416 						Sequence< Locale > aLocaleSeq = xStringResourceManager->getLocales();
417 						const Locale* pLocale = aLocaleSeq.getConstArray();
418 						sal_Int32 nLocaleCount = aLocaleSeq.getLength();
419 						Sequence< ::rtl::OUString > aOldIdStrings;
420 						aPropertyValue >>= aOldIdStrings;
421 						try
422 						{
423 							const ::rtl::OUString* pOldIdStrings = aOldIdStrings.getConstArray();
424 							sal_Int32 nOldIdCount = aOldIdStrings.getLength();
425 							for ( i = 0; i < nNewCount; ++i )
426 							{
427 								::rtl::OUString aOldIdStr;
428 								::rtl::OUString aOldPureIdStr;
429 								if( i < nOldIdCount )
430 								{
431 									aOldIdStr = pOldIdStrings[i];
432 									aOldPureIdStr = aOldIdStr.copy( 1 );
433 								}
434 								::rtl::OUString aNewPureIdStr = pNewPureIds[i];
435 
436 								for ( sal_Int32 iLocale = 0; iLocale < nLocaleCount; ++iLocale )
437 								{
438 									Locale aLocale = pLocale[iLocale];
439 
440 									::rtl::OUString aResourceStr;
441 									if( aOldPureIdStr.getLength() != 0 )
442 									{
443 										if( xStringResourceManager->hasEntryForIdAndLocale( aOldPureIdStr, aLocale ) )
444 										{
445 											aResourceStr = xStringResourceManager->
446 												resolveStringForLocale( aOldPureIdStr, aLocale );
447 										}
448 									}
449 									xStringResourceManager->setStringForLocale( aNewPureIdStr, aResourceStr, aLocale );
450 								}
451 							}
452 						}
453 						catch( resource::MissingResourceException & )
454 						{}
455 
456 
457 						// Set new strings for current locale and create
458 						// new Id sequence as new property value
459 						Sequence< ::rtl::OUString > aNewIdStrings;
460 						aNewIdStrings.realloc( nNewCount );
461 						::rtl::OUString* pNewIdStrings = aNewIdStrings.getArray();
462 						for ( i = 0; i < nNewCount; ++i )
463 						{
464 							::rtl::OUString aPureIdStr = pNewPureIds[i];
465 							::rtl::OUString aStr = pNewStrings[i];
466 							xStringResourceManager->setString( aPureIdStr, aStr );
467 
468 							::rtl::OUString aIdStr = aEsc;
469 							aIdStr += aPureIdStr;
470 							pNewIdStrings[i] = aIdStr;
471 						}
472 						aValue <<= aNewIdStrings;
473 
474 						// Remove old ids from resource for all locales
475 						const ::rtl::OUString* pOldIdStrings = aOldIdStrings.getConstArray();
476 						sal_Int32 nOldIdCount = aOldIdStrings.getLength();
477 						for( i = 0 ; i < nOldIdCount ; ++i )
478 						{
479 							::rtl::OUString aIdStr = pOldIdStrings[i];
480 							::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
481 							for ( sal_Int32 iLocale = 0; iLocale < nLocaleCount; ++iLocale )
482 							{
483 								Locale aLocale = pLocale[iLocale];
484 								try
485 								{
486 									xStringResourceManager->removeIdForLocale( aPureIdStr, aLocale );
487 								}
488 								catch( resource::MissingResourceException & )
489 								{}
490 							}
491 						}
492 						delete[] pNewPureIds;
493 					}
494 				}
495 			}
496 
497             m_xComponent->setPropertyValue( _rPropertyName, aValue );
498         }
499     }
500 
501     //--------------------------------------------------------------------
502     Any SAL_CALL FormComponentPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
503     {
504         ::osl::MutexGuard aGuard( m_aMutex );
505         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
506         Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
507 
508         Any aPropertyValue( _rControlValue );
509         if ( !aPropertyValue.hasValue() )
510         {
511             if ( ( aProperty.Attributes & PropertyAttribute::MAYBEVOID ) == 0 )
512                 // default construct an instance of the proper type
513                 aPropertyValue = Any( NULL, aProperty.Type );
514             // nothing to do
515             return aPropertyValue;
516         }
517 
518         /// care for the special "default" string, translate it to VOID
519         if ( m_aPropertiesWithDefListEntry.find( _rPropertyName ) != m_aPropertiesWithDefListEntry.end() )
520         {
521             // it's a control with a string list
522             ::rtl::OUString sStringValue;
523             if ( _rControlValue >>= sStringValue )
524             {   // note that ColorListBoxes might transfer values either as string or as css.util.Color,
525                 // so this check here is important
526                 if ( sStringValue == m_sDefaultValueString )
527                     return Any();
528             }
529         }
530 
531         switch ( nPropId )
532         {
533         case PROPERTY_ID_DATASOURCE:
534         {
535             ::rtl::OUString sControlValue;
536             OSL_VERIFY( _rControlValue >>= sControlValue );
537 
538             if ( sControlValue.getLength() )
539             {
540                 Reference< XNameAccess > xDatabaseContext;
541                 m_aContext.createComponent( (::rtl::OUString)SERVICE_DATABASE_CONTEXT, xDatabaseContext );
542                 if ( !xDatabaseContext.is() || !xDatabaseContext->hasByName( sControlValue ) )
543                 {
544                     ::svt::OFileNotation aTransformer(sControlValue);
545                     aPropertyValue <<= ::rtl::OUString( aTransformer.get( ::svt::OFileNotation::N_URL ) );
546                 }
547             }
548         }
549         break;  // case PROPERTY_ID_DATASOURCE
550 
551         case PROPERTY_ID_SHOW_POSITION:
552         case PROPERTY_ID_SHOW_NAVIGATION:
553         case PROPERTY_ID_SHOW_RECORDACTIONS:
554         case PROPERTY_ID_SHOW_FILTERSORT:
555         {
556             ::rtl::OUString sControlValue;
557             OSL_VERIFY( _rControlValue >>= sControlValue );
558 
559             ::std::vector< ::rtl::OUString > aListEntries;
560             tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
561             OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToPropertyValue: broken resource for Show/Hide!" );
562             sal_Bool bShow = ( aListEntries.size() < 2 ) || ( sControlValue == aListEntries[1] );
563 
564             aPropertyValue <<= bShow;
565         }
566         break;
567 
568         case PROPERTY_ID_TARGET_URL:
569         case PROPERTY_ID_IMAGE_URL:
570         {
571             ::rtl::OUString sControlValue;
572             OSL_VERIFY( _rControlValue >>= sControlValue );
573             // Don't convert a placeholder
574             if ( nPropId == PROPERTY_ID_IMAGE_URL && sControlValue.equals( String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) ) ) )
575                 aPropertyValue <<= sControlValue;
576             else
577             {
578                 INetURLObject aDocURL( impl_getDocumentURL_nothrow() );
579                 aPropertyValue <<= (::rtl::OUString)URIHelper::SmartRel2Abs( aDocURL, sControlValue, Link(), false, true, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI );
580             }
581         }
582         break;
583 
584         case PROPERTY_ID_DATEMIN:
585         case PROPERTY_ID_DATEMAX:
586         case PROPERTY_ID_DEFAULT_DATE:
587         case PROPERTY_ID_DATE:
588         {
589             util::Date aDate;
590             OSL_VERIFY( _rControlValue >>= aDate );
591             aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aDate );
592         }
593         break;
594 
595         case PROPERTY_ID_TIMEMIN:
596         case PROPERTY_ID_TIMEMAX:
597         case PROPERTY_ID_DEFAULT_TIME:
598         case PROPERTY_ID_TIME:
599         {
600             util::Time aTime;
601             OSL_VERIFY( _rControlValue >>= aTime );
602             aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aTime );
603         }
604         break;
605 
606         case PROPERTY_ID_WRITING_MODE:
607         {
608             aPropertyValue = FormComponentPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
609 
610             sal_Int16 nNormalizedValue( 2 );
611             OSL_VERIFY( aPropertyValue >>= nNormalizedValue );
612             sal_Int16 nWritingMode = WritingMode2::CONTEXT;
613             switch ( nNormalizedValue )
614             {
615             case 0: nWritingMode = WritingMode2::LR_TB;      break;
616             case 1: nWritingMode = WritingMode2::RL_TB;      break;
617             case 2: nWritingMode = WritingMode2::CONTEXT;    break;
618             default:
619                 OSL_ENSURE( false, "FormComponentPropertyHandler::convertToPropertyValue: unexpected 'normalized value' for WritingMode!" );
620                 nWritingMode = WritingMode2::CONTEXT;
621                 break;
622             }
623 
624             aPropertyValue <<= nWritingMode;
625         }
626         break;
627 
628         default:
629             aPropertyValue = FormComponentPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
630             break;  // default
631 
632         }   // switch ( nPropId )
633 
634         return aPropertyValue;
635     }
636 
637     //--------------------------------------------------------------------
638     Any SAL_CALL FormComponentPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
639     {
640         ::osl::MutexGuard aGuard( m_aMutex );
641         sal_Int32 nPropId = m_pInfoService->getPropertyId( _rPropertyName );
642         DBG_ASSERT( nPropId != -1, "FormComponentPropertyHandler::convertToPropertyValue: not one of my properties!!" );
643 
644         Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
645 
646         Any aControlValue( _rPropertyValue );
647         if ( !aControlValue.hasValue() )
648         {
649             // if the property is represented with a list box or color list box, we need to
650             // translate this into the string "Default"
651             if ( m_aPropertiesWithDefListEntry.find( _rPropertyName ) != m_aPropertiesWithDefListEntry.end() )
652                 aControlValue <<= m_sDefaultValueString;
653 
654             return aControlValue;
655         }
656 
657         switch ( nPropId )
658         {
659         //////////////////////////////////////////////////////////////
660         case PROPERTY_ID_SHOW_POSITION:
661         case PROPERTY_ID_SHOW_NAVIGATION:
662         case PROPERTY_ID_SHOW_RECORDACTIONS:
663         case PROPERTY_ID_SHOW_FILTERSORT:
664         {
665             ::std::vector< ::rtl::OUString > aListEntries;
666             tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
667             OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToControlValue: broken resource for Show/Hide!" );
668 
669             if ( aListEntries.size() == 2 )
670             {
671                 ::rtl::OUString sControlValue =     ::comphelper::getBOOL( _rPropertyValue )
672                                                 ?   aListEntries[1]
673                                                 :   aListEntries[0];
674                 aControlValue <<= sControlValue;
675             }
676         }
677         break;
678 
679         //////////////////////////////////////////////////////////////
680         case PROPERTY_ID_DATASOURCE:
681         {
682             OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
683                 "FormComponentPropertyHandler::convertToControlValue: wrong ControlValueType!" );
684 
685             ::rtl::OUString sDataSource;
686             _rPropertyValue >>= sDataSource;
687             if ( sDataSource.getLength() )
688             {
689                 ::svt::OFileNotation aTransformer( sDataSource );
690                 sDataSource = aTransformer.get( ::svt::OFileNotation::N_SYSTEM );
691             }
692             aControlValue <<= sDataSource;
693         }
694         break;
695 
696         //////////////////////////////////////////////////////////////
697         case PROPERTY_ID_CONTROLLABEL:
698         {
699             ::rtl::OUString sControlValue;
700 
701             Reference< XPropertySet >  xSet;
702             _rPropertyValue >>= xSet;
703             Reference< XPropertySetInfo > xPSI;
704             if ( xSet.is() )
705                 xPSI = xSet->getPropertySetInfo();
706             if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_LABEL ) )
707             {
708                 ::rtl::OUStringBuffer aValue;
709                 aValue.append( (sal_Unicode)'<' );
710                 ::rtl::OUString sLabel;
711                 OSL_VERIFY( xSet->getPropertyValue( PROPERTY_LABEL ) >>= sLabel );
712                 aValue.append( sLabel );
713                 aValue.append( (sal_Unicode)'>' );
714                 sControlValue = aValue.makeStringAndClear();
715             }
716 
717             aControlValue <<= sControlValue;
718         }
719         break;
720 
721         //////////////////////////////////////////////////////////////
722         case PROPERTY_ID_DATEMIN:
723         case PROPERTY_ID_DATEMAX:
724         case PROPERTY_ID_DEFAULT_DATE:
725         case PROPERTY_ID_DATE:
726         {
727             sal_Int32 nDate = 0;
728             OSL_VERIFY( _rPropertyValue >>= nDate );
729             aControlValue <<= DBTypeConversion::toDate( nDate );
730         }
731         break;
732 
733         case PROPERTY_ID_TIMEMIN:
734         case PROPERTY_ID_TIMEMAX:
735         case PROPERTY_ID_DEFAULT_TIME:
736         case PROPERTY_ID_TIME:
737         {
738             sal_Int32 nTime = 0;
739             OSL_VERIFY( _rPropertyValue >>= nTime );
740             aControlValue <<= DBTypeConversion::toTime( nTime );
741         }
742         break;
743 
744         case PROPERTY_ID_WRITING_MODE:
745         {
746             sal_Int16 nWritingMode( WritingMode2::CONTEXT );
747             OSL_VERIFY( _rPropertyValue >>= nWritingMode );
748             sal_Int16 nNormalized = 2;
749             switch ( nWritingMode )
750             {
751             case WritingMode2::LR_TB:   nNormalized = 0;    break;
752             case WritingMode2::RL_TB:   nNormalized = 1;    break;
753             case WritingMode2::CONTEXT: nNormalized = 2;    break;
754             default:
755                 OSL_ENSURE( false, "FormComponentPropertyHandler::convertToControlValue: unsupported API value for WritingMode!" );
756                 nNormalized = 2;
757                 break;
758             }
759 
760             aControlValue = FormComponentPropertyHandler_Base::convertToControlValue( _rPropertyName, makeAny( nNormalized ), _rControlValueType );
761         }
762         break;
763 
764         case PROPERTY_ID_FONT:
765         {
766             FontDescriptor aFont;
767             OSL_VERIFY( _rPropertyValue >>= aFont );
768 
769             ::rtl::OUStringBuffer displayName;
770             if ( !aFont.Name.getLength() )
771             {
772                 displayName.append( String( PcrRes( RID_STR_FONT_DEFAULT ) ) );
773             }
774             else
775             {
776                 // font name
777                 displayName.append( aFont.Name );
778                 displayName.appendAscii( ", " );
779 
780                 // font style
781                 ::FontWeight  eWeight = VCLUnoHelper::ConvertFontWeight( aFont.Weight );
782                 sal_uInt16 nStyleResID = RID_STR_FONTSTYLE_REGULAR;
783                 if ( aFont.Slant == FontSlant_ITALIC )
784                 {
785                     if ( eWeight > WEIGHT_NORMAL )
786                         nStyleResID = RID_STR_FONTSTYLE_BOLD_ITALIC;
787                     else
788                         nStyleResID = RID_STR_FONTSTYLE_ITALIC;
789                 }
790                 else
791                 {
792                     if ( eWeight > WEIGHT_NORMAL )
793                         nStyleResID = RID_STR_FONTSTYLE_BOLD;
794                 }
795                 displayName.append( String( PcrRes( nStyleResID ) ) );
796 
797                 // font size
798                 if ( aFont.Height )
799                 {
800                     displayName.appendAscii( ", " );
801                     displayName.append( sal_Int32( aFont.Height ) );
802                 }
803             }
804 
805             aControlValue <<= displayName.makeStringAndClear();
806         }
807         break;
808 
809         default:
810             aControlValue = FormComponentPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
811             break;
812 
813         }   // switch ( nPropId )
814 
815         return aControlValue;
816     }
817 
818     //--------------------------------------------------------------------
819     PropertyState SAL_CALL FormComponentPropertyHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
820     {
821         ::osl::MutexGuard aGuard( m_aMutex );
822         if ( m_xPropertyState.is() )
823             return m_xPropertyState->getPropertyState( _rPropertyName );
824         return PropertyState_DIRECT_VALUE;
825     }
826 
827     //--------------------------------------------------------------------
828     void SAL_CALL FormComponentPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
829     {
830         ::osl::MutexGuard aGuard( m_aMutex );
831         FormComponentPropertyHandler_Base::addPropertyChangeListener( _rxListener );
832         if ( m_xComponent.is() )
833             m_xComponent->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
834     }
835 
836     //--------------------------------------------------------------------
837     void SAL_CALL FormComponentPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
838     {
839         ::osl::MutexGuard aGuard( m_aMutex );
840         if ( m_xComponent.is() )
841             m_xComponent->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
842         FormComponentPropertyHandler_Base::removePropertyChangeListener( _rxListener );
843     }
844 
845     //--------------------------------------------------------------------
846     void FormComponentPropertyHandler::onNewComponent()
847     {
848         FormComponentPropertyHandler_Base::onNewComponent();
849         if ( !m_xComponentPropertyInfo.is() && m_xComponent.is() )
850             throw NullPointerException();
851 
852         m_xPropertyState.set( m_xComponent, UNO_QUERY );
853         m_eComponentClass = eUnknown;
854         m_bComponentIsSubForm = m_bHaveListSource = m_bHaveCommand = false;
855         m_nClassId = 0;
856 
857         impl_initComponentMetaData_throw();
858     }
859 
860     //--------------------------------------------------------------------
861     Sequence< Property > SAL_CALL FormComponentPropertyHandler::doDescribeSupportedProperties() const
862     {
863         if ( !m_xComponentPropertyInfo.is() )
864             return Sequence< Property >();
865 
866         ::std::vector< Property > aProperties;
867 
868         Sequence< Property > aAllProperties( m_xComponentPropertyInfo->getProperties() );
869         aProperties.reserve( aAllProperties.getLength() );
870 
871         // filter the properties
872         PropertyId nPropId( 0 );
873         ::rtl::OUString sDisplayName;
874 
875         Property* pProperty = aAllProperties.getArray();
876         Property* pPropertiesEnd = pProperty + aAllProperties.getLength();
877         for ( ; pProperty != pPropertiesEnd; ++pProperty )
878         {
879             nPropId = m_pInfoService->getPropertyId( pProperty->Name );
880             if ( nPropId == -1 )
881                 continue;
882             pProperty->Handle = nPropId;
883 
884             sDisplayName = m_pInfoService->getPropertyTranslation( nPropId );
885             if ( !sDisplayName.getLength() )
886                 continue;
887 
888             sal_uInt32  nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( nPropId );
889             bool bIsVisibleForForms   = ( nPropertyUIFlags & PROP_FLAG_FORM_VISIBLE   ) != 0;
890             bool bIsVisibleForDialogs = ( nPropertyUIFlags & PROP_FLAG_DIALOG_VISIBLE ) != 0;
891 
892             // depending on whether we're working for a form or a UNO dialog, some
893             // properties are not displayed
894             if  (  ( m_eComponentClass == eFormControl   && !bIsVisibleForForms )
895                 || ( m_eComponentClass == eDialogControl && !bIsVisibleForDialogs )
896                 )
897                 continue;
898 
899             // some generic sanity checks
900             if ( impl_shouldExcludeProperty_nothrow( *pProperty ) )
901                 continue;
902 
903             switch ( nPropId )
904             {
905             case PROPERTY_ID_BORDER:
906             case PROPERTY_ID_TABSTOP:
907                 // BORDER and TABSTOP are normalized (see impl_normalizePropertyValue_nothrow)
908                 // to not allow VOID values
909                 pProperty->Attributes &= ~( PropertyAttribute::MAYBEVOID );
910                 break;
911 
912             case PROPERTY_ID_LISTSOURCE:
913                 // no cursor source if no Base is installed. #124939#
914                 // This fix is not intendend to appear on the main trunk. If you find it there,
915                 // please tell me! frank.schoenheit@sun.com
916                 if ( SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
917                     const_cast< FormComponentPropertyHandler* >( this )->m_bHaveListSource = true;
918                 break;
919 
920             case PROPERTY_ID_COMMAND:
921                 // no cursor source if no Base is installed. #124939#
922                 // This fix is not intendend to appear on the main trunk. If you find it there,
923                 // please tell me! frank.schoenheit@sun.com
924                 if ( SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
925                     const_cast< FormComponentPropertyHandler* >( this )->m_bHaveCommand = true;
926                 break;
927             }   // switch ( nPropId )
928 
929             aProperties.push_back( *pProperty );
930         }
931 
932         if ( aProperties.empty() )
933             return Sequence< Property >();
934         return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
935     }
936 
937     //--------------------------------------------------------------------
938     Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
939     {
940         return Sequence< ::rtl::OUString >( );
941     }
942 
943     //--------------------------------------------------------------------
944     Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
945     {
946         ::osl::MutexGuard aGuard( m_aMutex );
947         ::std::vector< ::rtl::OUString > aInterestingProperties;
948         aInterestingProperties.push_back( PROPERTY_DATASOURCE );
949         aInterestingProperties.push_back( PROPERTY_COMMAND );
950         aInterestingProperties.push_back( PROPERTY_COMMANDTYPE );
951         aInterestingProperties.push_back( PROPERTY_LISTSOURCE );
952         aInterestingProperties.push_back( PROPERTY_LISTSOURCETYPE );
953         aInterestingProperties.push_back( PROPERTY_SUBMIT_ENCODING );
954         aInterestingProperties.push_back( PROPERTY_REPEAT );
955         aInterestingProperties.push_back( PROPERTY_TABSTOP );
956         aInterestingProperties.push_back( PROPERTY_BORDER );
957         aInterestingProperties.push_back( PROPERTY_CONTROLSOURCE );
958         aInterestingProperties.push_back( PROPERTY_DROPDOWN );
959         aInterestingProperties.push_back( PROPERTY_IMAGE_URL );
960         aInterestingProperties.push_back( PROPERTY_TARGET_URL );
961         aInterestingProperties.push_back( PROPERTY_STRINGITEMLIST );
962         aInterestingProperties.push_back( PROPERTY_BUTTONTYPE );
963         aInterestingProperties.push_back( PROPERTY_ESCAPE_PROCESSING );
964         aInterestingProperties.push_back( PROPERTY_TRISTATE );
965         aInterestingProperties.push_back( PROPERTY_DECIMAL_ACCURACY );
966         aInterestingProperties.push_back( PROPERTY_SHOWTHOUSANDSEP );
967         aInterestingProperties.push_back( PROPERTY_FORMATKEY );
968         aInterestingProperties.push_back( PROPERTY_EMPTY_IS_NULL );
969         aInterestingProperties.push_back( PROPERTY_TOGGLE );
970         return Sequence< ::rtl::OUString >( &(*aInterestingProperties.begin()), aInterestingProperties.size() );
971     }
972 
973     //--------------------------------------------------------------------
974     LineDescriptor SAL_CALL FormComponentPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
975         const Reference< XPropertyControlFactory >& _rxControlFactory )
976         throw (UnknownPropertyException, NullPointerException, RuntimeException)
977     {
978         if ( !_rxControlFactory.is() )
979             throw NullPointerException();
980 
981         ::osl::MutexGuard aGuard( m_aMutex );
982         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
983         Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
984 
985         //////////////////////////////////////////////////////////////////////
986         // for the MultiLine property, we have different UI translations depending on the control
987         // type
988         if ( nPropId == PROPERTY_ID_MULTILINE )
989         {
990             if (  ( m_nClassId == FormComponentType::FIXEDTEXT )
991                || ( m_nClassId == FormComponentType::COMMANDBUTTON )
992                || ( m_nClassId == FormComponentType::RADIOBUTTON )
993                || ( m_nClassId == FormComponentType::CHECKBOX )
994                )
995                 nPropId = PROPERTY_ID_WORDBREAK;
996         }
997 
998         String sDisplayName = m_pInfoService->getPropertyTranslation( nPropId );
999         if ( !sDisplayName.Len() )
1000         {
1001             DBG_ERROR( "FormComponentPropertyHandler::describePropertyLine: did getSupportedProperties not work properly?" );
1002             throw UnknownPropertyException();
1003         }
1004 
1005         //////////////////////////////////////////////////////////////////////
1006 
1007         LineDescriptor aDescriptor;
1008         aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
1009         aDescriptor.DisplayName = sDisplayName;
1010 
1011         // for the moment, assume a text field
1012         sal_Int16 nControlType = PropertyControlType::TextField;
1013         sal_Bool bReadOnly = sal_False;
1014         aDescriptor.Control.clear();
1015 
1016         //////////////////////////////////////////////////////////////////////
1017 
1018         bool bNeedDefaultStringIfVoidAllowed = false;
1019 
1020         TypeClass eType = aProperty.Type.getTypeClass();
1021 
1022         switch ( nPropId )
1023         {
1024         case PROPERTY_ID_DEFAULT_SELECT_SEQ:
1025         case PROPERTY_ID_SELECTEDITEMS:
1026             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SELECTION);
1027             break;
1028 
1029         case PROPERTY_ID_FILTER:
1030             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FILTER);
1031             break;
1032 
1033         case PROPERTY_ID_SORT:
1034             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_ORDER);
1035             break;
1036 
1037         case PROPERTY_ID_MASTERFIELDS:
1038         case PROPERTY_ID_DETAILFIELDS:
1039             nControlType = PropertyControlType::StringListField;
1040             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FORMLINKFIELDS);
1041             break;
1042 
1043         case PROPERTY_ID_COMMAND:
1044             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SQLCOMMAND);
1045             break;
1046 
1047         case PROPERTY_ID_TABINDEX:
1048         {
1049             Reference< XControlContainer > xControlContext( impl_getContextControlContainer_nothrow() );
1050             if ( xControlContext.is() )
1051                 aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_TABINDEX);
1052             nControlType = PropertyControlType::NumericField;
1053         };
1054         break;
1055 
1056         case PROPERTY_ID_FONT:
1057             bReadOnly = sal_True;
1058             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FONT_TYPE);
1059             break;
1060 
1061         case PROPERTY_ID_TARGET_URL:
1062         case PROPERTY_ID_IMAGE_URL:
1063         {
1064             aDescriptor.Control = new OFileUrlControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER );
1065 
1066             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(( PROPERTY_ID_TARGET_URL == nPropId )
1067                 ? UID_PROP_DLG_ATTR_TARGET_URL : UID_PROP_DLG_IMAGE_URL);
1068         }
1069         break;
1070 
1071         case PROPERTY_ID_ECHO_CHAR:
1072             nControlType = PropertyControlType::CharacterField;
1073             break;
1074 
1075         case PROPERTY_ID_BACKGROUNDCOLOR:
1076         case PROPERTY_ID_FILLCOLOR:
1077         case PROPERTY_ID_SYMBOLCOLOR:
1078         case PROPERTY_ID_BORDERCOLOR:
1079             nControlType = PropertyControlType::ColorListBox;
1080 
1081             switch( nPropId )
1082             {
1083             case PROPERTY_ID_BACKGROUNDCOLOR:
1084                 aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BACKGROUNDCOLOR); break;
1085             case PROPERTY_ID_FILLCOLOR:
1086                 aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_FILLCOLOR); break;
1087             case PROPERTY_ID_SYMBOLCOLOR:
1088                 aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SYMBOLCOLOR); break;
1089             case PROPERTY_ID_BORDERCOLOR:
1090                 aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BORDERCOLOR); break;
1091             }
1092             break;
1093 
1094         case PROPERTY_ID_LABEL:
1095             nControlType = PropertyControlType::MultiLineTextField;
1096             break;
1097 
1098         case PROPERTY_ID_DEFAULT_TEXT:
1099         {
1100             if (FormComponentType::FILECONTROL == m_nClassId)
1101                 nControlType = PropertyControlType::TextField;
1102             else
1103                 nControlType = PropertyControlType::MultiLineTextField;
1104         }
1105         break;
1106 
1107         case PROPERTY_ID_TEXT:
1108             if ( impl_componentHasProperty_throw( PROPERTY_MULTILINE ) )
1109                 nControlType = PropertyControlType::MultiLineTextField;
1110             break;
1111 
1112         case PROPERTY_ID_CONTROLLABEL:
1113             bReadOnly = sal_True;
1114             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_CONTROLLABEL);
1115             break;
1116 
1117         case PROPERTY_ID_FORMATKEY:
1118         case PROPERTY_ID_EFFECTIVE_MIN:
1119         case PROPERTY_ID_EFFECTIVE_MAX:
1120         case PROPERTY_ID_EFFECTIVE_DEFAULT:
1121         case PROPERTY_ID_EFFECTIVE_VALUE:
1122         {
1123             // and the supplier is really available
1124             Reference< XNumberFormatsSupplier >  xSupplier;
1125             m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier;
1126             if (xSupplier.is())
1127             {
1128                 Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
1129                 DBG_ASSERT(xTunnel.is(), "FormComponentPropertyHandler::describePropertyLine : xTunnel is invalid!");
1130                 SvNumberFormatsSupplierObj* pSupplier = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1131 
1132                 if (pSupplier != NULL)
1133                 {
1134                     sal_Bool bIsFormatKey = (PROPERTY_ID_FORMATKEY == nPropId);
1135 
1136                     bReadOnly = bIsFormatKey;
1137 
1138                     if ( bIsFormatKey )
1139                     {
1140                         OFormatSampleControl* pControl = new OFormatSampleControl( impl_getDefaultDialogParent_nothrow(), WB_READONLY | WB_TABSTOP | WB_BORDER );
1141                         aDescriptor.Control = pControl;
1142                         pControl->SetFormatSupplier( pSupplier );
1143 
1144                         aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_NUMBER_FORMAT);
1145                     }
1146                     else
1147                     {
1148                         OFormattedNumericControl* pControl = new OFormattedNumericControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER );
1149                         aDescriptor.Control = pControl;
1150 
1151                         FormatDescription aDesc;
1152                         aDesc.pSupplier = pSupplier;
1153                         Any aFormatKeyValue = m_xComponent->getPropertyValue(PROPERTY_FORMATKEY);
1154                         if ( !( aFormatKeyValue >>= aDesc.nKey ) )
1155                             aDesc.nKey = 0;
1156 
1157                         pControl->SetFormatDescription( aDesc );
1158                     }
1159                 }
1160             }
1161         }
1162         break;
1163 
1164         case PROPERTY_ID_DATEMIN:
1165         case PROPERTY_ID_DATEMAX:
1166         case PROPERTY_ID_DEFAULT_DATE:
1167         case PROPERTY_ID_DATE:
1168             nControlType = PropertyControlType::DateField;
1169             break;
1170 
1171         case PROPERTY_ID_TIMEMIN:
1172         case PROPERTY_ID_TIMEMAX:
1173         case PROPERTY_ID_DEFAULT_TIME:
1174         case PROPERTY_ID_TIME:
1175             nControlType = PropertyControlType::TimeField;
1176             break;
1177 
1178         case PROPERTY_ID_VALUEMIN:
1179         case PROPERTY_ID_VALUEMAX:
1180         case PROPERTY_ID_DEFAULT_VALUE:
1181         case PROPERTY_ID_VALUE:
1182             {
1183                 OFormattedNumericControl* pControl = new OFormattedNumericControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER | WB_SPIN | WB_REPEAT );
1184                 aDescriptor.Control = pControl;
1185 
1186                 // we don't set a formatter so the control uses a default (which uses the application
1187                 // language and a default numeric format)
1188                 // but we set the decimal digits
1189                 pControl->SetDecimalDigits(
1190                     ::comphelper::getINT16( m_xComponent->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) )
1191                 );
1192 
1193                 // and the thousands separator
1194                 pControl->SetThousandsSep(
1195                     ::comphelper::getBOOL( m_xComponent->getPropertyValue(PROPERTY_SHOWTHOUSANDSEP) )
1196                 );
1197 
1198                 // and the default value for the property
1199                 try
1200                 {
1201                     if (m_xPropertyState.is() && ((PROPERTY_ID_VALUEMIN == nPropId) || (PROPERTY_ID_VALUEMAX == nPropId)))
1202                     {
1203                         double nDefault = 0;
1204                         if ( m_xPropertyState->getPropertyDefault( aProperty.Name ) >>= nDefault )
1205                             pControl->SetDefaultValue( nDefault );
1206                     }
1207                 }
1208                 catch (Exception&)
1209                 {
1210                     // just ignore it
1211                 }
1212 
1213                 // and allow empty values only for the default value and the value
1214                 pControl->EnableEmptyField( ( PROPERTY_ID_DEFAULT_VALUE == nPropId )
1215                                         ||  ( PROPERTY_ID_VALUE == nPropId ) );
1216             }
1217             break;
1218 
1219         default:
1220             if ( TypeClass_BYTE <= eType && eType <= TypeClass_DOUBLE )
1221             {
1222                 sal_Int16 nDigits = 0;
1223                 sal_Int16 nValueUnit = -1;
1224                 sal_Int16 nDisplayUnit = -1;
1225                 if ( m_eComponentClass == eFormControl )
1226                 {
1227                     if  (  ( nPropId == PROPERTY_ID_WIDTH )
1228                         || ( nPropId == PROPERTY_ID_ROWHEIGHT )
1229                         || ( nPropId == PROPERTY_ID_HEIGHT )
1230                         )
1231                     {
1232                         nValueUnit = MeasureUnit::MM_10TH;
1233                         nDisplayUnit = impl_getDocumentMeasurementUnit_throw();
1234                         nDigits = 2;
1235                     }
1236                 }
1237 
1238                 Optional< double > aValueNotPresent( sal_False, 0 );
1239                 aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
1240                     _rxControlFactory, nDigits, aValueNotPresent, aValueNotPresent, sal_False );
1241 
1242                 Reference< XNumericControl > xNumericControl( aDescriptor.Control, UNO_QUERY_THROW );
1243                 if ( nValueUnit != -1 )
1244                     xNumericControl->setValueUnit( nValueUnit );
1245                 if ( nDisplayUnit != -1 )
1246                     xNumericControl->setDisplayUnit( nDisplayUnit );
1247             }
1248             break;
1249         }
1250 
1251         //////////////////////////////////////////////////////////////////////
1252         if ( eType == TypeClass_SEQUENCE )
1253             nControlType = PropertyControlType::StringListField;
1254 
1255         //////////////////////////////////////////////////////////////////////
1256         // boolean values
1257         if ( eType == TypeClass_BOOLEAN )
1258         {
1259             sal_uInt16 nResId = RID_RSC_ENUM_YESNO;
1260             if  (   ( nPropId == PROPERTY_ID_SHOW_POSITION )
1261                 ||  ( nPropId == PROPERTY_ID_SHOW_NAVIGATION )
1262                 ||  ( nPropId == PROPERTY_ID_SHOW_RECORDACTIONS )
1263                 ||  ( nPropId == PROPERTY_ID_SHOW_FILTERSORT )
1264                 )
1265                 nResId = RID_RSC_ENUM_SHOWHIDE;
1266 
1267             ::std::vector< ::rtl::OUString > aListEntries;
1268             tools::StringListResource aRes(PcrRes(nResId),aListEntries);
1269             aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
1270             bNeedDefaultStringIfVoidAllowed = true;
1271         }
1272 
1273         //////////////////////////////////////////////////////////////////////
1274         // enum properties
1275         sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( nPropId );
1276         bool bIsEnumProperty = ( nPropertyUIFlags & PROP_FLAG_ENUM ) != 0;
1277         if ( bIsEnumProperty || ( PROPERTY_ID_TARGET_FRAME == nPropId ) )
1278         {
1279             ::std::vector< ::rtl::OUString > aEnumValues = m_pInfoService->getPropertyEnumRepresentations( nPropId );
1280             ::std::vector< ::rtl::OUString >::const_iterator pStart = aEnumValues.begin();
1281             ::std::vector< ::rtl::OUString >::const_iterator pEnd = aEnumValues.end();
1282 
1283             // for a checkbox: if "ambiguous" is not allowed, remove this from the sequence
1284             if  (   ( PROPERTY_ID_DEFAULT_STATE == nPropId )
1285                 ||  ( PROPERTY_ID_STATE == nPropId )
1286                 )
1287             {
1288                 if ( impl_componentHasProperty_throw( PROPERTY_TRISTATE ) )
1289                 {
1290                     if ( !::comphelper::getBOOL( m_xComponent->getPropertyValue( PROPERTY_TRISTATE ) ) )
1291                     {   // remove the last sequence element
1292                         if ( pEnd > pStart )
1293                             --pEnd;
1294                     }
1295                 }
1296                 else
1297                     --pEnd;
1298             }
1299 
1300             if ( PROPERTY_ID_LISTSOURCETYPE == nPropId )
1301                 if ( FormComponentType::COMBOBOX == m_nClassId )
1302                     // remove the first sequence element -> value list not possible for combo boxes
1303                     ++pStart;
1304 
1305             // copy the sequence
1306             ::std::vector< ::rtl::OUString > aListEntries( pEnd - pStart );
1307             ::std::copy( pStart, pEnd, aListEntries.begin() );
1308 
1309             // create the control
1310             if ( PROPERTY_ID_TARGET_FRAME == nPropId )
1311                 aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
1312             else
1313             {
1314                 aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
1315                 bNeedDefaultStringIfVoidAllowed = true;
1316             }
1317         }
1318 
1319         //////////////////////////////////////////////////////////////////////
1320         switch( nPropId )
1321         {
1322             case PROPERTY_ID_REPEAT_DELAY:
1323             {
1324                 OTimeDurationControl* pControl = new OTimeDurationControl( impl_getDefaultDialogParent_nothrow(), WB_BORDER | WB_TABSTOP );
1325                 aDescriptor.Control = pControl;
1326 
1327                 pControl->setMinValue( Optional< double >( sal_True, 0 ) );
1328                 pControl->setMaxValue( Optional< double >( sal_True, ::std::numeric_limits< double >::max() ) );
1329             }
1330             break;
1331 
1332             case PROPERTY_ID_TABINDEX:
1333             case PROPERTY_ID_BOUNDCOLUMN:
1334             case PROPERTY_ID_VISIBLESIZE:
1335             case PROPERTY_ID_MAXTEXTLEN:
1336             case PROPERTY_ID_LINEINCREMENT:
1337             case PROPERTY_ID_BLOCKINCREMENT:
1338             case PROPERTY_ID_SPININCREMENT:
1339             {
1340                 Optional< double > aMinValue( sal_True, 0 );
1341                 Optional< double > aMaxValue( sal_True, 0x7FFFFFFF );
1342 
1343                 if ( nPropId == PROPERTY_ID_MAXTEXTLEN )
1344                     aMinValue.Value = -1;
1345                 else if ( nPropId == PROPERTY_ID_VISIBLESIZE )
1346                     aMinValue.Value = 1;
1347                 else
1348                     aMinValue.Value = 0;
1349 
1350                 aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
1351                     _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
1352             }
1353             break;
1354 
1355             case PROPERTY_ID_DECIMAL_ACCURACY:
1356             {
1357                 Optional< double > aMinValue( sal_True, 0 );
1358                 Optional< double > aMaxValue( sal_True, 20 );
1359 
1360                 aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
1361                     _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
1362             }
1363             break;
1364 
1365             //////////////////////////////////////////////////////////////////////
1366             // DataSource
1367             case PROPERTY_ID_DATASOURCE:
1368             {
1369                 aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_ATTR_DATASOURCE);
1370 
1371                 ::std::vector< ::rtl::OUString > aListEntries;
1372 
1373                 Reference< XNameAccess > xDatabaseContext;
1374                 m_aContext.createComponent( (rtl::OUString)SERVICE_DATABASE_CONTEXT, xDatabaseContext );
1375                 if (xDatabaseContext.is())
1376                 {
1377                     Sequence< ::rtl::OUString > aDatasources = xDatabaseContext->getElementNames();
1378                     aListEntries.resize( aDatasources.getLength() );
1379                     ::std::copy( aDatasources.getConstArray(), aDatasources.getConstArray() + aDatasources.getLength(),
1380                         aListEntries.begin() );
1381                 }
1382                 aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl(
1383                     _rxControlFactory, aListEntries, sal_False, sal_True );
1384             }
1385             break;
1386 
1387             case PROPERTY_ID_CONTROLSOURCE:
1388             {
1389                 ::std::vector< ::rtl::OUString > aFieldNames;
1390                 impl_initFieldList_nothrow( aFieldNames );
1391                 aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl(
1392                     _rxControlFactory, aFieldNames, sal_False, sal_False );
1393             }
1394             break;
1395 
1396             case PROPERTY_ID_COMMAND:
1397                 impl_describeCursorSource_nothrow( aDescriptor, _rxControlFactory );
1398                 break;
1399 
1400             case PROPERTY_ID_LISTSOURCE:
1401                 impl_describeListSourceUI_throw( aDescriptor, _rxControlFactory );
1402                 break;
1403         }
1404 
1405         if ( !aDescriptor.Control.is() )
1406             aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, bReadOnly );
1407 
1408         if ( ( aProperty.Attributes & PropertyAttribute::MAYBEVOID ) != 0 )
1409         {
1410             // insert the string "Default" string, if necessary
1411             if ( bNeedDefaultStringIfVoidAllowed || ( nControlType == PropertyControlType::ColorListBox ) )
1412             {
1413                 Reference< XStringListControl > xStringList( aDescriptor.Control, UNO_QUERY_THROW );
1414                 xStringList->prependListEntry( m_sDefaultValueString );
1415                 m_aPropertiesWithDefListEntry.insert( _rPropertyName );
1416             }
1417         }
1418 
1419         if ( aDescriptor.PrimaryButtonId.getLength() )
1420             aDescriptor.HasPrimaryButton = sal_True;
1421         if ( aDescriptor.SecondaryButtonId.getLength() )
1422             aDescriptor.HasSecondaryButton = sal_True;
1423 
1424         bool bIsDataProperty = ( nPropertyUIFlags & PROP_FLAG_DATA_PROPERTY ) != 0;
1425         aDescriptor.Category = ::rtl::OUString::createFromAscii( bIsDataProperty ? "Data" : "General" );
1426         return aDescriptor;
1427     }
1428 
1429     //--------------------------------------------------------------------
1430     InteractiveSelectionResult SAL_CALL FormComponentPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
1431     {
1432         if ( !_rxInspectorUI.is() )
1433             throw NullPointerException();
1434 
1435         ::osl::ClearableMutexGuard aGuard( m_aMutex );
1436         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
1437 
1438         InteractiveSelectionResult eResult = InteractiveSelectionResult_Cancelled;
1439         switch ( nPropId )
1440         {
1441         case PROPERTY_ID_DEFAULT_SELECT_SEQ:
1442         case PROPERTY_ID_SELECTEDITEMS:
1443             if ( impl_dialogListSelection_nothrow( _rPropertyName, aGuard ) )
1444                 eResult = InteractiveSelectionResult_Success;
1445             break;
1446 
1447         case PROPERTY_ID_FILTER:
1448         case PROPERTY_ID_SORT:
1449         {
1450             ::rtl::OUString sClause;
1451             if ( impl_dialogFilterOrSort_nothrow( PROPERTY_ID_FILTER == nPropId, sClause, aGuard ) )
1452             {
1453                 _rData <<= sClause;
1454                 eResult = InteractiveSelectionResult_ObtainedValue;
1455             }
1456         }
1457         break;
1458 
1459         case PROPERTY_ID_MASTERFIELDS:
1460         case PROPERTY_ID_DETAILFIELDS:
1461             if ( impl_dialogLinkedFormFields_nothrow( aGuard ) )
1462                 eResult = InteractiveSelectionResult_Success;
1463             break;
1464 
1465         case PROPERTY_ID_FORMATKEY:
1466             if ( impl_dialogFormatting_nothrow( _rData, aGuard ) )
1467                 eResult = InteractiveSelectionResult_ObtainedValue;
1468             break;
1469 
1470         case PROPERTY_ID_IMAGE_URL:
1471             if ( impl_browseForImage_nothrow( _rData, aGuard ) )
1472                 eResult = InteractiveSelectionResult_ObtainedValue;
1473             break;
1474 
1475         case PROPERTY_ID_TARGET_URL:
1476             if ( impl_browseForTargetURL_nothrow( _rData, aGuard ) )
1477                 eResult = InteractiveSelectionResult_ObtainedValue;
1478             break;
1479 
1480         case PROPERTY_ID_FONT:
1481             if ( impl_executeFontDialog_nothrow( _rData, aGuard ) )
1482                 eResult = InteractiveSelectionResult_ObtainedValue;
1483             break;
1484 
1485         case PROPERTY_ID_DATASOURCE:
1486             if ( impl_browseForDatabaseDocument_throw( _rData, aGuard ) )
1487                 eResult = InteractiveSelectionResult_ObtainedValue;
1488             break;
1489 
1490         case PROPERTY_ID_BACKGROUNDCOLOR:
1491         case PROPERTY_ID_FILLCOLOR:
1492         case PROPERTY_ID_SYMBOLCOLOR:
1493         case PROPERTY_ID_BORDERCOLOR:
1494             if ( impl_dialogColorChooser_throw( nPropId, _rData, aGuard ) )
1495                 eResult = InteractiveSelectionResult_ObtainedValue;
1496             break;
1497 
1498         case PROPERTY_ID_CONTROLLABEL:
1499             if ( impl_dialogChooseLabelControl_nothrow( _rData, aGuard ) )
1500                 eResult = InteractiveSelectionResult_ObtainedValue;
1501             break;
1502 
1503         case PROPERTY_ID_TABINDEX:
1504             if ( impl_dialogChangeTabOrder_nothrow( aGuard ) )
1505                 eResult = InteractiveSelectionResult_Success;
1506             break;
1507 
1508         case PROPERTY_ID_COMMAND:
1509         case PROPERTY_ID_LISTSOURCE:
1510             if ( impl_doDesignSQLCommand_nothrow( _rxInspectorUI, nPropId ) )
1511                 eResult = InteractiveSelectionResult_Pending;
1512             break;
1513         default:
1514             DBG_ERROR( "FormComponentPropertyHandler::onInteractivePropertySelection: request for a property which does not have dedicated UI!" );
1515             break;
1516         }
1517         return eResult;
1518     }
1519 
1520     //--------------------------------------------------------------------
1521     namespace
1522     {
1523         void lcl_rebuildAndResetCommand( const Reference< XObjectInspectorUI >& _rxInspectorUI, const Reference< XPropertyHandler >& _rxHandler )
1524         {
1525             OSL_PRECOND( _rxInspectorUI.is(), "lcl_rebuildAndResetCommand: invalid BrowserUI!" );
1526             OSL_PRECOND( _rxHandler.is(), "lcl_rebuildAndResetCommand: invalid handler!" );
1527             _rxInspectorUI->rebuildPropertyUI( PROPERTY_COMMAND );
1528             _rxHandler->setPropertyValue( PROPERTY_COMMAND, makeAny( ::rtl::OUString() ) );
1529         }
1530     }
1531 
1532     //--------------------------------------------------------------------
1533     void SAL_CALL FormComponentPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
1534     {
1535         if ( !_rxInspectorUI.is() )
1536             throw NullPointerException();
1537 
1538         ::osl::MutexGuard aGuard( m_aMutex );
1539         PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
1540 
1541         ::std::vector< PropertyId > aDependentProperties;
1542 
1543         switch ( nActuatingPropId )
1544         {
1545         // ----- EscapeProcessing -----
1546         case PROPERTY_ID_ESCAPE_PROCESSING:
1547             aDependentProperties.push_back( PROPERTY_ID_FILTER );
1548             aDependentProperties.push_back( PROPERTY_ID_SORT );
1549             break;  // case PROPERTY_ID_ESCAPE_PROCESSING
1550 
1551         // ----- CommandType -----
1552         case PROPERTY_ID_COMMANDTYPE:
1553             // available commands (tables or queries) might have changed
1554             if ( !_bFirstTimeInit && m_bHaveCommand )
1555                 lcl_rebuildAndResetCommand( _rxInspectorUI, this );
1556             aDependentProperties.push_back( PROPERTY_ID_COMMAND );
1557             break;  // case PROPERTY_ID_COMMANDTYPE
1558 
1559         // ----- DataSourceName -----
1560         case PROPERTY_ID_DATASOURCE:
1561             // reset the connection, now that we have a new data source
1562             impl_clearRowsetConnection_nothrow();
1563 
1564             // available list source values (tables or queries) might have changed
1565             if ( !_bFirstTimeInit && m_bHaveListSource )
1566                 _rxInspectorUI->rebuildPropertyUI( PROPERTY_LISTSOURCE );
1567 
1568             // available commands (tables or queries) might have changed
1569             if ( !_bFirstTimeInit && m_bHaveCommand )
1570                 lcl_rebuildAndResetCommand( _rxInspectorUI, this );
1571 
1572             // Command also depends on DataSource
1573             aDependentProperties.push_back( PROPERTY_ID_COMMAND );
1574             // NO break!
1575 
1576         // ----- Command -----
1577         case PROPERTY_ID_COMMAND:
1578             aDependentProperties.push_back( PROPERTY_ID_FILTER );
1579             aDependentProperties.push_back( PROPERTY_ID_SORT );
1580             if ( m_bComponentIsSubForm )
1581                 aDependentProperties.push_back( PROPERTY_ID_DETAILFIELDS );
1582             break;
1583 
1584         // ----- ListSourceType -----
1585         case PROPERTY_ID_LISTSOURCETYPE:
1586             if ( !_bFirstTimeInit && m_bHaveListSource )
1587                 // available list source values (tables or queries) might have changed
1588                 _rxInspectorUI->rebuildPropertyUI( PROPERTY_LISTSOURCE );
1589             aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
1590             aDependentProperties.push_back( PROPERTY_ID_STRINGITEMLIST );
1591             // NO break!
1592 
1593         // ----- StringItemList -----
1594         case PROPERTY_ID_STRINGITEMLIST:
1595             aDependentProperties.push_back( PROPERTY_ID_SELECTEDITEMS );
1596             aDependentProperties.push_back( PROPERTY_ID_DEFAULT_SELECT_SEQ );
1597             break;
1598 
1599         // ----- ListSource -----
1600         case PROPERTY_ID_LISTSOURCE:
1601             aDependentProperties.push_back( PROPERTY_ID_STRINGITEMLIST );
1602             break;
1603 
1604         // ----- DataField -----
1605         case PROPERTY_ID_CONTROLSOURCE:
1606         {
1607             ::rtl::OUString sControlSource;
1608             _rNewValue >>= sControlSource;
1609             if ( impl_componentHasProperty_throw( PROPERTY_FILTERPROPOSAL ) )
1610                 _rxInspectorUI->enablePropertyUI( PROPERTY_FILTERPROPOSAL, sControlSource.getLength() > 0 );
1611             if ( impl_componentHasProperty_throw( PROPERTY_EMPTY_IS_NULL ) )
1612                 _rxInspectorUI->enablePropertyUI( PROPERTY_EMPTY_IS_NULL, sControlSource.getLength() > 0 );
1613 
1614             aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
1615             aDependentProperties.push_back( PROPERTY_ID_SCALEIMAGE );
1616             aDependentProperties.push_back( PROPERTY_ID_SCALE_MODE );
1617             aDependentProperties.push_back( PROPERTY_ID_INPUT_REQUIRED );
1618         }
1619         break;
1620 
1621         case PROPERTY_ID_EMPTY_IS_NULL:
1622             aDependentProperties.push_back( PROPERTY_ID_INPUT_REQUIRED );
1623             break;
1624 
1625         // ----- SubmitEncoding -----
1626         case PROPERTY_ID_SUBMIT_ENCODING:
1627         {
1628             FormSubmitEncoding eEncoding = FormSubmitEncoding_URL;
1629             OSL_VERIFY( _rNewValue >>= eEncoding );
1630             _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMIT_METHOD, eEncoding == FormSubmitEncoding_URL );
1631         }
1632         break;
1633 
1634         // ----- Repeat -----
1635         case PROPERTY_ID_REPEAT:
1636         {
1637             sal_Bool bIsRepeating = sal_False;
1638             OSL_VERIFY( _rNewValue >>= bIsRepeating );
1639             _rxInspectorUI->enablePropertyUI( PROPERTY_REPEAT_DELAY, bIsRepeating );
1640         }
1641         break;
1642 
1643         // ----- TabStop -----
1644         case PROPERTY_ID_TABSTOP:
1645         {
1646             if ( !impl_componentHasProperty_throw( PROPERTY_TABINDEX ) )
1647                 break;
1648             sal_Bool bHasTabStop = sal_False;
1649             _rNewValue >>= bHasTabStop;
1650             _rxInspectorUI->enablePropertyUI( PROPERTY_TABINDEX, bHasTabStop );
1651         }
1652         break;
1653 
1654         // ----- Border -----
1655         case PROPERTY_ID_BORDER:
1656         {
1657             sal_Int16 nBordeType = VisualEffect::NONE;
1658             OSL_VERIFY( _rNewValue >>= nBordeType );
1659             _rxInspectorUI->enablePropertyUI( PROPERTY_BORDERCOLOR, nBordeType == VisualEffect::FLAT );
1660         }
1661         break;
1662 
1663         // ----- DropDown -----
1664         case PROPERTY_ID_DROPDOWN:
1665         {
1666             if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_LINECOUNT ) )
1667             {
1668                 sal_Bool bDropDown = sal_True;
1669                 _rNewValue >>= bDropDown;
1670                 _rxInspectorUI->enablePropertyUI( PROPERTY_LINECOUNT, bDropDown );
1671             }
1672         }
1673         break;
1674 
1675         // ----- ImageURL -----
1676         case PROPERTY_ID_IMAGE_URL:
1677         {
1678             if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_IMAGEPOSITION ) )
1679             {
1680                 ::rtl::OUString sImageURL;
1681                 OSL_VERIFY( _rNewValue >>= sImageURL );
1682                 _rxInspectorUI->enablePropertyUI( PROPERTY_IMAGEPOSITION, sImageURL.getLength() != 0 );
1683             }
1684 
1685             aDependentProperties.push_back( PROPERTY_ID_SCALEIMAGE );
1686             aDependentProperties.push_back( PROPERTY_ID_SCALE_MODE );
1687         }
1688         break;
1689 
1690         // ----- ButtonType -----
1691         case PROPERTY_ID_BUTTONTYPE:
1692         {
1693             FormButtonType eButtonType( FormButtonType_PUSH );
1694             OSL_VERIFY( _rNewValue >>= eButtonType );
1695             _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, FormButtonType_URL == eButtonType );
1696         }
1697         // NO break!
1698 
1699         // ----- TargetURL -----
1700         case PROPERTY_ID_TARGET_URL:
1701             aDependentProperties.push_back( PROPERTY_ID_TARGET_FRAME );
1702             break;  // case PROPERTY_ID_TARGET_URL
1703 
1704         // ----- TriState -----
1705         case PROPERTY_ID_TRISTATE:
1706             if ( !_bFirstTimeInit )
1707                 _rxInspectorUI->rebuildPropertyUI( m_eComponentClass == eFormControl ? PROPERTY_DEFAULT_STATE : PROPERTY_STATE );
1708             break;  // case PROPERTY_ID_TRISTATE
1709 
1710         // ----- DecimalAccuracy -----
1711         case PROPERTY_ID_DECIMAL_ACCURACY:
1712         // ----- ShowThousandsSeparator -----
1713         case PROPERTY_ID_SHOWTHOUSANDSEP:
1714         {
1715             sal_Bool bAccuracy = (PROPERTY_ID_DECIMAL_ACCURACY == nActuatingPropId);
1716             sal_uInt16  nNewDigits = 0;
1717             sal_Bool    bUseSep = sal_False;
1718             if ( bAccuracy )
1719                 OSL_VERIFY( _rNewValue >>= nNewDigits );
1720             else
1721                 OSL_VERIFY( _rNewValue >>= bUseSep );
1722 
1723             // propagate the changes to the min/max/default fields
1724             Any aCurrentProp;
1725             ::rtl::OUString aAffectedProps[] = { PROPERTY_VALUE, PROPERTY_DEFAULT_VALUE, PROPERTY_VALUEMIN, PROPERTY_VALUEMAX };
1726             for (sal_uInt16 i=0; i<sizeof(aAffectedProps)/sizeof(aAffectedProps[0]); ++i)
1727             {
1728                 Reference< XPropertyControl > xControl;
1729                 try
1730                 {
1731                     xControl = _rxInspectorUI->getPropertyControl( aAffectedProps[i] );
1732                 }
1733                 catch( const UnknownPropertyException& e ) { (void)e; }
1734                 if ( xControl.is() )
1735                 {
1736                     OFormattedNumericControl* pControl = dynamic_cast< OFormattedNumericControl* >( xControl.get() );
1737                     DBG_ASSERT( pControl, "FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
1738                     if ( pControl )
1739                     {
1740                         if ( bAccuracy )
1741                             pControl->SetDecimalDigits( nNewDigits );
1742                         else
1743                             pControl->SetThousandsSep( bUseSep );
1744                     }
1745                 }
1746             }
1747         }
1748         break;
1749 
1750         // ----- FormatKey -----
1751         case PROPERTY_ID_FORMATKEY:
1752         {
1753             FormatDescription aNewDesc;
1754 
1755             Reference< XNumberFormatsSupplier >  xSupplier;
1756             OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier );
1757 
1758             Reference< XUnoTunnel > xTunnel( xSupplier, UNO_QUERY );
1759             DBG_ASSERT(xTunnel.is(), "FormComponentPropertyHandler::actuatingPropertyChanged: xTunnel is invalid!");
1760             if ( xTunnel.is() )
1761             {
1762                 SvNumberFormatsSupplierObj* pSupplier = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1763                     // the same again
1764 
1765                 aNewDesc.pSupplier = pSupplier;
1766                 if ( !( _rNewValue >>= aNewDesc.nKey ) )
1767                     aNewDesc.nKey = 0;
1768 
1769                 // give each control which has to know this an own copy of the description
1770                 ::rtl::OUString aFormattedPropertyControls[] = {
1771                     PROPERTY_EFFECTIVE_MIN, PROPERTY_EFFECTIVE_MAX, PROPERTY_EFFECTIVE_DEFAULT, PROPERTY_EFFECTIVE_VALUE
1772                 };
1773                 for ( sal_uInt16 i=0; i<sizeof(aFormattedPropertyControls)/sizeof(aFormattedPropertyControls[0]); ++i )
1774                 {
1775                     Reference< XPropertyControl > xControl;
1776                     try
1777                     {
1778                         xControl = _rxInspectorUI->getPropertyControl( aFormattedPropertyControls[i] );
1779                     }
1780                     catch( const UnknownPropertyException& e ) { (void)e; }
1781                     if ( xControl.is() )
1782                     {
1783                         OFormattedNumericControl* pControl = dynamic_cast< OFormattedNumericControl* >( xControl.get() );
1784                         DBG_ASSERT( pControl, "FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
1785                         if ( pControl )
1786                             pControl->SetFormatDescription( aNewDesc );
1787                     }
1788                 }
1789             }
1790         }
1791         break;
1792 
1793         case PROPERTY_ID_TOGGLE:
1794         {
1795             sal_Bool bIsToggleButton = sal_False;
1796             OSL_VERIFY( _rNewValue >>= bIsToggleButton );
1797             _rxInspectorUI->enablePropertyUI( PROPERTY_DEFAULT_STATE, bIsToggleButton );
1798         }
1799         break;
1800 
1801         default:
1802             DBG_ERROR( "FormComponentPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
1803             break;
1804 
1805         }   // switch ( nActuatingPropId )
1806 
1807         for ( ::std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
1808               loopAffected != aDependentProperties.end();
1809               ++loopAffected
1810             )
1811         {
1812             if ( impl_isSupportedProperty_nothrow( *loopAffected ) )
1813                 impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
1814         }
1815     }
1816 
1817     //------------------------------------------------------------------------
1818     void FormComponentPropertyHandler::impl_updateDependentProperty_nothrow( PropertyId _nPropId, const Reference< XObjectInspectorUI >& _rxInspectorUI ) const
1819     {
1820         try
1821         {
1822             switch ( _nPropId )
1823             {
1824             // ----- StringItemList -----
1825             case PROPERTY_ID_STRINGITEMLIST:
1826             {
1827                 ListSourceType eLSType = ListSourceType_VALUELIST;
1828                 OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType );
1829 
1830                 ::rtl::OUString sListSource;
1831                 {
1832                     Sequence< ::rtl::OUString > aListSource;
1833                     Any aListSourceValue( impl_getPropertyValue_throw( PROPERTY_LISTSOURCE ) );
1834                     if ( aListSourceValue >>= aListSource )
1835                     {
1836                         if ( aListSource.getLength() )
1837                             sListSource = aListSource[0];
1838                     }
1839                     else
1840                         OSL_VERIFY( aListSourceValue >>= sListSource );
1841                 }
1842 
1843                 sal_Bool bIsEnabled =   (  ( eLSType == ListSourceType_VALUELIST )
1844                                         || ( sListSource.getLength() == 0 )
1845                                         );
1846                 _rxInspectorUI->enablePropertyUI( PROPERTY_STRINGITEMLIST, bIsEnabled );
1847             }
1848             break;  // case PROPERTY_ID_STRINGITEMLIST
1849 
1850             // ----- BoundColumn -----
1851             case PROPERTY_ID_BOUNDCOLUMN:
1852             {
1853                 ::rtl::OUString sControlSource;
1854                 OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource );
1855 
1856                 ListSourceType eLSType = ListSourceType_VALUELIST;
1857                 OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType );
1858 
1859                 _rxInspectorUI->enablePropertyUI( PROPERTY_BOUNDCOLUMN,
1860                         ( sControlSource.getLength() > 0 )
1861                     &&  ( eLSType != ListSourceType_TABLEFIELDS )
1862                     &&  ( eLSType != ListSourceType_VALUELIST )
1863                 );
1864             }
1865             break;  // case PROPERTY_ID_BOUNDCOLUMN
1866 
1867             // ----- ScaleImage, ScaleMode -----
1868             case PROPERTY_ID_SCALEIMAGE:
1869             case PROPERTY_ID_SCALE_MODE:
1870             {
1871                 ::rtl::OUString sControlSource;
1872                 if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_CONTROLSOURCE ) )
1873                     impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource;
1874 
1875                 ::rtl::OUString sImageURL;
1876                 impl_getPropertyValue_throw( PROPERTY_IMAGE_URL ) >>= sImageURL;
1877 
1878                 _rxInspectorUI->enablePropertyUI( impl_getPropertyNameFromId_nothrow( _nPropId ),
1879                     ( sControlSource.getLength() != 0 ) || ( sImageURL.getLength() != 0 )
1880                 );
1881             }
1882             break;  // case PROPERTY_ID_SCALEIMAGE, PROPERTY_ID_SCALE_MODE
1883 
1884             // ----- InputRequired -----
1885             case PROPERTY_ID_INPUT_REQUIRED:
1886             {
1887                 ::rtl::OUString sControlSource;
1888                 OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource );
1889 
1890                 sal_Bool bEmptyIsNULL = sal_False;
1891                 sal_Bool bHasEmptyIsNULL = impl_componentHasProperty_throw( PROPERTY_EMPTY_IS_NULL );
1892                 if ( bHasEmptyIsNULL )
1893                     OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_EMPTY_IS_NULL ) >>= bEmptyIsNULL );
1894 
1895                 // if the control is not bound to a DB field, there is no sense in having the "Input required"
1896                 // property
1897                 // Also, if an empty input of this control are *not* written as NULL, but as empty strings,
1898                 // then "Input required" does not make sense, too (since there's always an input, even if the control
1899                 // is empty).
1900                 _rxInspectorUI->enablePropertyUI( PROPERTY_INPUT_REQUIRED,
1901                     ( sControlSource.getLength() != 0 ) && ( !bHasEmptyIsNULL || bEmptyIsNULL )
1902                 );
1903             }
1904             break;
1905 
1906             // ----- SelectedItems, DefaultSelection -----
1907             case PROPERTY_ID_SELECTEDITEMS:
1908             case PROPERTY_ID_DEFAULT_SELECT_SEQ:
1909             {
1910                 Sequence< ::rtl::OUString > aEntries;
1911                 impl_getPropertyValue_throw( PROPERTY_STRINGITEMLIST ) >>= aEntries;
1912                 bool isEnabled = aEntries.getLength() != 0;
1913 
1914                 if ( ( m_nClassId == FormComponentType::LISTBOX ) && ( m_eComponentClass == eFormControl ) )
1915                 {
1916                     ListSourceType eLSType = ListSourceType_VALUELIST;
1917                     impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType;
1918                     isEnabled &= ( eLSType == ListSourceType_VALUELIST );
1919                 }
1920                 _rxInspectorUI->enablePropertyUIElements( impl_getPropertyNameFromId_nothrow( _nPropId ),
1921                     PropertyLineElement::PrimaryButton, isEnabled );
1922             }
1923             break;  // case PROPERTY_ID_DEFAULT_SELECT_SEQ
1924 
1925             // ----- TargetFrame ------
1926             case PROPERTY_ID_TARGET_FRAME:
1927             {
1928                 ::rtl::OUString sTargetURL;
1929                 impl_getPropertyValue_throw( PROPERTY_TARGET_URL ) >>= sTargetURL;
1930                 FormButtonType eButtonType( FormButtonType_URL );
1931                 if ( 0 != m_nClassId )
1932                 {
1933                     OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_BUTTONTYPE ) >>= eButtonType );
1934                 }
1935                 // if m_nClassId is 0, then we're inspecting a form. In this case, eButtonType is always
1936                 // FormButtonType_URL here
1937                 _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME,
1938                     ( eButtonType == FormButtonType_URL ) && ( sTargetURL.getLength() > 0 )
1939                 );
1940             }
1941             break;
1942 
1943             // ----- Order ------
1944             case PROPERTY_ID_SORT:
1945             // ----- Filter ------
1946             case PROPERTY_ID_FILTER:
1947             {
1948                 Reference< XConnection > xConnection;
1949                 bool bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
1950 
1951                 // if there's no escape processing, we cannot enter any values for this property
1952                 sal_Bool  bDoEscapeProcessing( sal_False );
1953                 impl_getPropertyValue_throw( PROPERTY_ESCAPE_PROCESSING ) >>= bDoEscapeProcessing;
1954                 _rxInspectorUI->enablePropertyUI(
1955                     impl_getPropertyNameFromId_nothrow( _nPropId ),
1956                     bDoEscapeProcessing
1957                 );
1958 
1959                 // also care for the browse button - enabled if we have escape processing, and a valid
1960                 // data source signature
1961                 _rxInspectorUI->enablePropertyUIElements(
1962                     impl_getPropertyNameFromId_nothrow( _nPropId ),
1963                     PropertyLineElement::PrimaryButton,
1964                         impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS )
1965                     &&  bDoEscapeProcessing
1966                 );
1967             }
1968             break;  // case PROPERTY_ID_FILTER:
1969 
1970             // ----- Command -----
1971             case PROPERTY_ID_COMMAND:
1972             {
1973                 sal_Int32   nCommandType( CommandType::COMMAND );
1974                 OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_COMMANDTYPE ) >>= nCommandType );
1975 
1976                 impl_ensureRowsetConnection_nothrow();
1977                 Reference< XConnection > xConnection = m_xRowSetConnection.getTyped();
1978                 bool bAllowEmptyDS = false;
1979                 if ( !xConnection.is() )
1980                     bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
1981 
1982                 bool doEnable = ( nCommandType == CommandType::COMMAND )
1983                             &&  (  m_xRowSetConnection.is()
1984                                 || xConnection.is()
1985 								|| impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS)
1986                                 );
1987 
1988                 _rxInspectorUI->enablePropertyUIElements(
1989                     PROPERTY_COMMAND,
1990                     PropertyLineElement::PrimaryButton,
1991                     doEnable
1992                 );
1993             }
1994             break;  // case PROPERTY_ID_COMMAND
1995 
1996             // ----- DetailFields -----
1997             case PROPERTY_ID_DETAILFIELDS:
1998             {
1999                 Reference< XConnection > xConnection;
2000                 bool bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
2001 
2002                 // both our current form, and it's parent form, need to have a valid
2003                 // data source signature
2004                 bool bDoEnableMasterDetailFields =
2005                         impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS )
2006                     &&  impl_hasValidDataSourceSignature_nothrow( Reference< XPropertySet >( m_xObjectParent, UNO_QUERY ), bAllowEmptyDS );
2007 
2008                 // in opposite to the other properties, here in real *two* properties are
2009                 // affected
2010                 _rxInspectorUI->enablePropertyUIElements( PROPERTY_DETAILFIELDS, PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
2011                 _rxInspectorUI->enablePropertyUIElements( PROPERTY_MASTERFIELDS, PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
2012             }
2013             break;
2014 
2015             default:
2016                 OSL_ENSURE( false, "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: unexpected property to update!" );
2017                 break;
2018 
2019             }   // switch
2020         }
2021         catch( const Exception& )
2022         {
2023         	OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
2024         }
2025     }
2026 
2027     //------------------------------------------------------------------------
2028     void SAL_CALL FormComponentPropertyHandler::disposing()
2029     {
2030         FormComponentPropertyHandler_Base::disposing();
2031         if ( m_xCommandDesigner.is() && m_xCommandDesigner->isActive() )
2032             m_xCommandDesigner->dispose();
2033     }
2034 
2035     //------------------------------------------------------------------------
2036     sal_Bool SAL_CALL FormComponentPropertyHandler::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
2037     {
2038         ::osl::MutexGuard aGuard( m_aMutex );
2039         if ( _bSuspend )
2040             if ( m_xCommandDesigner.is() && m_xCommandDesigner->isActive() )
2041                 return m_xCommandDesigner->suspend();
2042         return sal_True;
2043     }
2044 
2045     //------------------------------------------------------------------------
2046     void FormComponentPropertyHandler::impl_initComponentMetaData_throw()
2047     {
2048         try
2049         {
2050             //////////////////////////////////////////////////////////////////
2051             // component class
2052             m_eComponentClass = eUnknown;
2053 
2054             if  (   impl_componentHasProperty_throw( PROPERTY_WIDTH )
2055                 &&  impl_componentHasProperty_throw( PROPERTY_HEIGHT )
2056                 &&  impl_componentHasProperty_throw( PROPERTY_POSITIONX )
2057                 &&  impl_componentHasProperty_throw( PROPERTY_POSITIONY )
2058                 &&  impl_componentHasProperty_throw( PROPERTY_STEP )
2059                 &&  impl_componentHasProperty_throw( PROPERTY_TABINDEX )
2060                 )
2061             {
2062                 m_eComponentClass = eDialogControl;
2063             }
2064             else
2065             {
2066                 m_eComponentClass = eFormControl;
2067             }
2068 
2069             //////////////////////////////////////////////////////////////////
2070             // (database) sub form?
2071             Reference< XForm > xAsForm( m_xComponent, UNO_QUERY );
2072             if ( xAsForm.is() )
2073             {
2074                 Reference< XChild > xFormAsChild( xAsForm, UNO_QUERY );
2075                 Reference< XForm > xFormsParent;
2076                 if ( xFormAsChild.is() )
2077                     xFormsParent = xFormsParent.query( xFormAsChild->getParent() );
2078                 m_bComponentIsSubForm = xFormsParent.is();
2079             }
2080 
2081             //////////////////////////////////////////////////////////////////
2082             // ClassId
2083             Reference< XChild > xCompAsChild( m_xComponent, UNO_QUERY );
2084             if ( xCompAsChild.is() )
2085                 m_xObjectParent = xCompAsChild->getParent();
2086 
2087             //////////////////////////////////////////////////////////////////
2088             // ClassId
2089             impl_classifyControlModel_throw();
2090         }
2091         catch( const RuntimeException& )
2092         {
2093             throw;
2094         }
2095         catch( const Exception& )
2096         {
2097             OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_initComponentMetaData_throw: caught an exception!" );
2098         }
2099     }
2100 
2101     //------------------------------------------------------------------------
2102     void FormComponentPropertyHandler::impl_classifyControlModel_throw( )
2103     {
2104         if ( impl_componentHasProperty_throw( PROPERTY_CLASSID ) )
2105         {
2106             OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_CLASSID ) >>= m_nClassId );
2107         }
2108         else if ( eDialogControl == m_eComponentClass )
2109         {
2110             Reference< XControlModel > xControlModel( m_xComponent, UNO_QUERY );
2111             Reference< XServiceInfo > xServiceInfo( m_xComponent, UNO_QUERY );
2112             if ( xServiceInfo.is() )
2113             {
2114                 // it's a control model, and can tell about it's supported services
2115                 m_nClassId = FormComponentType::CONTROL;
2116 
2117                 const sal_Char* aControlModelServiceNames[] =
2118                 {
2119                     "UnoControlButtonModel",
2120                     "UnoControlCheckBoxModel",
2121                     "UnoControlComboBoxModel",
2122                     "UnoControlCurrencyFieldModel",
2123                     "UnoControlDateFieldModel",
2124                     "UnoControlEditModel",
2125                     "UnoControlFileControlModel",
2126                     "UnoControlFixedTextModel",
2127                     "UnoControlGroupBoxModel",
2128                     "UnoControlImageControlModel",
2129                     "UnoControlListBoxModel",
2130                     "UnoControlNumericFieldModel",
2131                     "UnoControlPatternFieldModel",
2132                     "UnoControlRadioButtonModel",
2133                     "UnoControlScrollBarModel",
2134                     "UnoControlSpinButtonModel",
2135                     "UnoControlTimeFieldModel",
2136 
2137                     "UnoControlFixedLineModel",
2138                     "UnoControlFormattedFieldModel",
2139                     "UnoControlProgressBarModel"
2140                 };
2141                 const sal_Int16 nClassIDs[] =
2142                 {
2143                     FormComponentType::COMMANDBUTTON,
2144                     FormComponentType::CHECKBOX,
2145                     FormComponentType::COMBOBOX,
2146                     FormComponentType::CURRENCYFIELD,
2147                     FormComponentType::DATEFIELD,
2148                     FormComponentType::TEXTFIELD,
2149                     FormComponentType::FILECONTROL,
2150                     FormComponentType::FIXEDTEXT,
2151                     FormComponentType::GROUPBOX,
2152                     FormComponentType::IMAGECONTROL,
2153                     FormComponentType::LISTBOX,
2154                     FormComponentType::NUMERICFIELD,
2155                     FormComponentType::PATTERNFIELD,
2156                     FormComponentType::RADIOBUTTON,
2157                     FormComponentType::SCROLLBAR,
2158                     FormComponentType::SPINBUTTON,
2159                     FormComponentType::TIMEFIELD,
2160 
2161                     ControlType::FIXEDLINE,
2162                     ControlType::FORMATTEDFIELD,
2163                     ControlType::PROGRESSBAR
2164                 };
2165 
2166                 sal_Int32 nKnownControlTypes = sizeof( aControlModelServiceNames ) / sizeof( aControlModelServiceNames[ 0 ] );
2167                 OSL_ENSURE( nKnownControlTypes == sizeof( nClassIDs ) / sizeof( nClassIDs[ 0 ] ),
2168                     "FormComponentPropertyHandler::impl_classifyControlModel_throw: inconsistence" );
2169 
2170                 for ( sal_Int32 i = 0; i < nKnownControlTypes; ++i )
2171                 {
2172                     ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt." ) );
2173                     sServiceName += ::rtl::OUString::createFromAscii( aControlModelServiceNames[ i ] );
2174 
2175                     if ( xServiceInfo->supportsService( sServiceName ) )
2176                     {
2177                         m_nClassId = nClassIDs[ i ];
2178                         break;
2179                     }
2180                 }
2181             }
2182         }
2183     }
2184 
2185     //------------------------------------------------------------------------
2186     void FormComponentPropertyHandler::impl_normalizePropertyValue_nothrow( Any& _rValue, PropertyId _nPropId ) const
2187     {
2188         switch ( _nPropId )
2189         {
2190         case PROPERTY_ID_TABSTOP:
2191             if ( !_rValue.hasValue() )
2192             {
2193                 switch ( m_nClassId )
2194                 {
2195                 case FormComponentType::COMMANDBUTTON:
2196                 case FormComponentType::RADIOBUTTON:
2197                 case FormComponentType::CHECKBOX:
2198                 case FormComponentType::TEXTFIELD:
2199                 case FormComponentType::LISTBOX:
2200                 case FormComponentType::COMBOBOX:
2201                 case FormComponentType::FILECONTROL:
2202                 case FormComponentType::DATEFIELD:
2203                 case FormComponentType::TIMEFIELD:
2204                 case FormComponentType::NUMERICFIELD:
2205                 case ControlType::FORMATTEDFIELD:
2206                 case FormComponentType::CURRENCYFIELD:
2207                 case FormComponentType::PATTERNFIELD:
2208                     _rValue = makeAny( (sal_Bool)sal_True );
2209                     break;
2210                 default:
2211                     _rValue = makeAny( (sal_Bool)sal_False );
2212                     break;
2213                 }
2214             }
2215             break;
2216         }
2217     }
2218 
2219     //------------------------------------------------------------------------
2220     bool FormComponentPropertyHandler::impl_shouldExcludeProperty_nothrow( const Property& _rProperty ) const
2221     {
2222         OSL_ENSURE( _rProperty.Handle == m_pInfoService->getPropertyId( _rProperty.Name ),
2223             "FormComponentPropertyHandler::impl_shouldExcludeProperty_nothrow: insonsistency in the property!" );
2224 
2225         if ( _rProperty.Handle == PROPERTY_ID_CONTROLLABEL )
2226             // prevent that this is caught below
2227             return false;
2228 
2229         if  (   ( _rProperty.Type.getTypeClass() == TypeClass_INTERFACE )
2230             ||  ( _rProperty.Type.getTypeClass() == TypeClass_ARRAY )
2231             ||  ( _rProperty.Type.getTypeClass() == TypeClass_UNKNOWN )
2232             )
2233             return true;
2234 
2235         if ( ( _rProperty.Attributes & PropertyAttribute::TRANSIENT ) && ( m_eComponentClass != eDialogControl ) )
2236             // strange enough, dialog controls declare a lot of their properties as transient
2237             return true;
2238 
2239         if ( _rProperty.Attributes & PropertyAttribute::READONLY )
2240             return true;
2241 
2242         switch ( _rProperty.Handle )
2243         {
2244         case PROPERTY_ID_MASTERFIELDS:
2245         case PROPERTY_ID_DETAILFIELDS:
2246             if ( !m_bComponentIsSubForm )
2247                 // no master and detail fields for forms which are no sub forms
2248                 return true;
2249             break;
2250 
2251         case PROPERTY_ID_DATASOURCE:
2252         {
2253             // don't show DataSource if the component is part of an embedded form document
2254             Reference< XConnection > xConn;
2255             if ( isEmbeddedInDatabase( m_xComponent, xConn ) )
2256                 return true;
2257         }
2258         break;
2259 
2260         case PROPERTY_ID_TEXT:
2261             // don't show the "Text" property of formatted fields
2262             if ( ControlType::FORMATTEDFIELD == m_nClassId )
2263                 return true;
2264             break;
2265 
2266         case PROPERTY_ID_FORMATKEY:
2267         case PROPERTY_ID_EFFECTIVE_MIN:
2268         case PROPERTY_ID_EFFECTIVE_MAX:
2269         case PROPERTY_ID_EFFECTIVE_DEFAULT:
2270         case PROPERTY_ID_EFFECTIVE_VALUE:
2271             // only if the set has a formats supplier, too
2272             if  ( !impl_componentHasProperty_throw( PROPERTY_FORMATSSUPPLIER ) )
2273                 return true;
2274             // (form) date and time fields also have a formats supplier, but the format itself
2275             // is reflected in another property
2276             if  (   ( FormComponentType::DATEFIELD == m_nClassId )
2277                 ||  ( FormComponentType::TIMEFIELD == m_nClassId )
2278                 )
2279                 return true;
2280             break;
2281 
2282         case PROPERTY_ID_SCALEIMAGE:
2283             if ( impl_componentHasProperty_throw( PROPERTY_SCALE_MODE ) )
2284                 // ScaleImage is superseded by ScaleMode
2285                 return true;
2286             break;
2287 
2288         case PROPERTY_ID_WRITING_MODE:
2289             if ( !SvtCTLOptions().IsCTLFontEnabled() )
2290                 return true;
2291             break;
2292         }
2293 
2294         sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( _rProperty.Handle );
2295 
2296         // don't show experimental properties unless allowed to do so
2297         if ( ( nPropertyUIFlags & PROP_FLAG_EXPERIMENTAL ) != 0 )
2298         {
2299             if ( true ) // TODO
2300                 return true;
2301         }
2302 
2303         // no data properties if no Base is installed. #124939#
2304         // This fix is not intendend to appear on the main trunk. If you find it there,
2305         // please tell me! frank.schoenheit@sun.com
2306         if ( ( nPropertyUIFlags & PROP_FLAG_DATA_PROPERTY ) != 0 )
2307             if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
2308                 return true;
2309 
2310         return false;
2311     }
2312 
2313     //------------------------------------------------------------------------
2314     Reference< XRowSet > FormComponentPropertyHandler::impl_getRowSet_throw( ) const
2315     {
2316         Reference< XRowSet > xRowSet = m_xRowSet;
2317         if ( !xRowSet.is() )
2318         {
2319             xRowSet.set( m_xComponent, UNO_QUERY );
2320             if ( !xRowSet.is() )
2321             {
2322                 xRowSet = Reference< XRowSet >( m_xObjectParent, UNO_QUERY );
2323                 if ( !xRowSet.is() )
2324                 {
2325                     // are we inspecting a grid column?
2326                     if (Reference< XGridColumnFactory >( m_xObjectParent, UNO_QUERY) .is())
2327                     {   // yes
2328                         Reference< XChild > xParentAsChild( m_xObjectParent, UNO_QUERY );
2329                         if ( xParentAsChild.is() )
2330                             xRowSet = Reference< XRowSet >( xParentAsChild->getParent(), UNO_QUERY );
2331                     }
2332                 }
2333                 if ( !xRowSet.is() )
2334                     xRowSet = m_xRowSet;
2335             }
2336             DBG_ASSERT( xRowSet.is(), "FormComponentPropertyHandler::impl_getRowSet_throw: could not obtain the rowset for the introspectee!" );
2337         }
2338         return xRowSet;
2339     }
2340 
2341     //------------------------------------------------------------------------
2342     Reference< XRowSet > FormComponentPropertyHandler::impl_getRowSet_nothrow( ) const
2343     {
2344         Reference< XRowSet > xReturn;
2345         try
2346         {
2347             xReturn = impl_getRowSet_throw();
2348         }
2349         catch( const Exception& )
2350         {
2351             OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_getRowSet_nothrow: caught an exception!" );
2352         }
2353         return xReturn;
2354     }
2355 
2356     //------------------------------------------------------------------------
2357     void FormComponentPropertyHandler::impl_initFieldList_nothrow( ::std::vector< ::rtl::OUString >& _rFieldNames ) const
2358     {
2359         clearContainer( _rFieldNames );
2360         try
2361         {
2362             WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
2363 
2364             Reference< XPreparedStatement >  xStatement;
2365 
2366             // get the form of the control we're inspecting
2367             Reference< XPropertySet > xFormSet( impl_getRowSet_throw(), UNO_QUERY );
2368             if ( !xFormSet.is() )
2369                 return;
2370 
2371             ::rtl::OUString sObjectName;
2372             OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMAND ) >>= sObjectName );
2373             // when there is no command we don't need to ask for columns
2374             if ( sObjectName.getLength() && impl_ensureRowsetConnection_nothrow() )
2375             {
2376                 ::rtl::OUString aDatabaseName;
2377                 OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_DATASOURCE ) >>= aDatabaseName );
2378                 sal_Int32 nObjectType = CommandType::COMMAND;
2379                 OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nObjectType );
2380 
2381                 Sequence< ::rtl::OUString > aFields( ::dbtools::getFieldNamesByCommandDescriptor( m_xRowSetConnection, nObjectType, sObjectName ) );
2382 
2383                 const ::rtl::OUString* pFields = aFields.getConstArray();
2384                 for ( sal_Int32 i = 0; i < aFields.getLength(); ++i, ++pFields )
2385                     _rFieldNames.push_back( *pFields );
2386             }
2387         }
2388         catch (Exception&)
2389         {
2390             DBG_ERROR( "FormComponentPropertyHandler::impl_initFieldList_nothrow: caught an exception!" );
2391         }
2392     }
2393 
2394     //------------------------------------------------------------------------
2395     void FormComponentPropertyHandler::impl_clearRowsetConnection_nothrow()
2396     {
2397         m_xRowSetConnection.clear();
2398     }
2399 
2400     //------------------------------------------------------------------------
2401     void FormComponentPropertyHandler::impl_displaySQLError_nothrow( const ::dbtools::SQLExceptionInfo& _rErrorDescriptor ) const
2402     {
2403         ::dbtools::showError( _rErrorDescriptor, VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ), m_aContext.getLegacyServiceFactory() );
2404     }
2405 
2406     //------------------------------------------------------------------------
2407     bool FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow() const
2408     {
2409         if ( !m_xRowSetConnection.is() )
2410         {
2411             uno::Reference<sdbc::XConnection> xConnection(m_aContext.getContextValueByAsciiName( "ActiveConnection" ),uno::UNO_QUERY);
2412             m_xRowSetConnection.reset(xConnection,::dbtools::SharedConnection::NoTakeOwnership);
2413         }
2414         if ( m_xRowSetConnection.is() )
2415             return true;
2416 
2417         Reference< XRowSet > xRowSet( impl_getRowSet_throw() );
2418         Reference< XPropertySet > xRowSetProps( xRowSet, UNO_QUERY );
2419 
2420         // connect the row set - this is delegated to elsewhere - while observing errors
2421         SQLExceptionInfo aError;
2422         try
2423         {
2424             if ( xRowSetProps.is() )
2425             {
2426                 WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
2427                 m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_aContext.getLegacyServiceFactory(), false );
2428             }
2429         }
2430         catch ( const SQLException& ) { aError = SQLExceptionInfo( ::cppu::getCaughtException() ); }
2431         catch ( const WrappedTargetException& e ) { aError = SQLExceptionInfo( e.TargetException ); }
2432         catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
2433 
2434         // report errors, if necessary
2435         if ( aError.isValid() )
2436         {
2437             ::rtl::OUString sDataSourceName;
2438             try
2439             {
2440                 xRowSetProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDataSourceName;
2441             }
2442             catch( const Exception& )
2443             {
2444                 DBG_ERROR( "FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow: caught an exception during error handling!" );
2445             }
2446             // additional info about what happended
2447             String sInfo( PcrRes( RID_STR_UNABLETOCONNECT ) );
2448             INetURLObject aParser( sDataSourceName );
2449             if ( aParser.GetProtocol() != INET_PROT_NOT_VALID )
2450                 sDataSourceName = aParser.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
2451             sInfo.SearchAndReplaceAllAscii( "$name$", sDataSourceName );
2452 
2453             SQLContext aContext;
2454             aContext.Message = sInfo;
2455             aContext.NextException = aError.get();
2456             impl_displaySQLError_nothrow( aContext );
2457         }
2458 
2459         return m_xRowSetConnection.is();
2460     }
2461 
2462     //------------------------------------------------------------------------
2463     void FormComponentPropertyHandler::impl_describeCursorSource_nothrow( LineDescriptor& _out_rProperty, const Reference< XPropertyControlFactory >& _rxControlFactory ) const
2464     {
2465         try
2466         {
2467             WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
2468 
2469             ////////////////////////////////////////////////////////////
2470             // Setzen der UI-Daten
2471             _out_rProperty.DisplayName = m_pInfoService->getPropertyTranslation( PROPERTY_ID_COMMAND );
2472 
2473             _out_rProperty.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( PROPERTY_ID_COMMAND ) );
2474             _out_rProperty.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_SQLCOMMAND);
2475 
2476             ////////////////////////////////////////////////////////////
2477             sal_Int32 nCommandType = CommandType::COMMAND;
2478             impl_getPropertyValue_throw( PROPERTY_COMMANDTYPE ) >>= nCommandType;
2479 
2480             switch ( nCommandType )
2481             {
2482             case CommandType::TABLE:
2483             case CommandType::QUERY:
2484             {
2485                 ::std::vector< ::rtl::OUString > aNames;
2486                 if ( impl_ensureRowsetConnection_nothrow() )
2487                 {
2488                     if ( nCommandType == CommandType::TABLE )
2489                         impl_fillTableNames_throw( aNames );
2490                     else
2491                         impl_fillQueryNames_throw( aNames );
2492                 }
2493                 _out_rProperty.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aNames, sal_False, sal_True );
2494             }
2495             break;
2496 
2497             default:
2498                 _out_rProperty.Control = _rxControlFactory->createPropertyControl( PropertyControlType::MultiLineTextField, sal_False );
2499                 break;
2500             }
2501         }
2502         catch (Exception&)
2503         {
2504             DBG_ERROR("FormComponentPropertyHandler::impl_describeCursorSource_nothrow: caught an exception !");
2505         }
2506     }
2507 
2508     //------------------------------------------------------------------------
2509     void FormComponentPropertyHandler::impl_fillTableNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const
2510     {
2511         OSL_PRECOND( m_xRowSetConnection.is(), "FormComponentPropertyHandler::impl_fillTableNames_throw: need a connection!" );
2512         _out_rNames.resize( 0 );
2513 
2514         Reference< XTablesSupplier > xSupplyTables( m_xRowSetConnection, UNO_QUERY );
2515         Reference< XNameAccess > xTableNames;
2516         if ( xSupplyTables.is() )
2517             xTableNames = xSupplyTables->getTables();
2518         DBG_ASSERT( xTableNames.is(), "FormComponentPropertyHandler::impl_fillTableNames_throw: no way to obtain the tables of the connection!" );
2519         if ( !xTableNames.is() )
2520             return;
2521 
2522         Sequence< ::rtl::OUString> aTableNames = xTableNames->getElementNames();
2523         sal_uInt32 nCount = aTableNames.getLength();
2524         const ::rtl::OUString* pTableNames = aTableNames.getConstArray();
2525 
2526         for ( sal_uInt32 i=0; i<nCount; ++i ,++pTableNames )
2527             _out_rNames.push_back( *pTableNames );
2528     }
2529 
2530     //------------------------------------------------------------------------
2531     void FormComponentPropertyHandler::impl_fillQueryNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const
2532     {
2533         OSL_PRECOND( m_xRowSetConnection.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: need a connection!" );
2534         _out_rNames.resize( 0 );
2535 
2536         Reference< XQueriesSupplier > xSupplyQueries( m_xRowSetConnection, UNO_QUERY );
2537         Reference< XNameAccess > xQueryNames;
2538         if ( xSupplyQueries.is() )
2539         {
2540             xQueryNames = xSupplyQueries->getQueries();
2541             impl_fillQueryNames_throw(xQueryNames,_out_rNames);
2542         }
2543     }
2544     //------------------------------------------------------------------------
2545     void FormComponentPropertyHandler::impl_fillQueryNames_throw( const Reference< XNameAccess >& _xQueryNames,::std::vector< ::rtl::OUString >& _out_rNames,const ::rtl::OUString& _sName ) const
2546     {
2547         DBG_ASSERT( _xQueryNames.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: no way to obtain the queries of the connection!" );
2548         if ( !_xQueryNames.is() )
2549             return;
2550 
2551         Sequence< ::rtl::OUString> aQueryNames = _xQueryNames->getElementNames();
2552         sal_uInt32 nCount = aQueryNames.getLength();
2553         const ::rtl::OUString* pQueryNames = aQueryNames.getConstArray();
2554         sal_Bool bAdd = _sName.getLength();
2555 
2556         for ( sal_uInt32 i=0; i<nCount; i++, ++pQueryNames )
2557         {
2558             ::rtl::OUStringBuffer sTemp;
2559             if ( bAdd )
2560             {
2561                 sTemp.append(_sName);
2562                 sTemp.appendAscii("/");
2563             }
2564             sTemp.append(*pQueryNames);
2565             Reference< XNameAccess > xSubQueries(_xQueryNames->getByName(*pQueryNames),UNO_QUERY);
2566             if ( xSubQueries.is() )
2567                 impl_fillQueryNames_throw(xSubQueries,_out_rNames,sTemp.makeStringAndClear());
2568             else
2569                 _out_rNames.push_back( sTemp.makeStringAndClear() );
2570         }
2571     }
2572 
2573     //------------------------------------------------------------------------
2574     void FormComponentPropertyHandler::impl_describeListSourceUI_throw( LineDescriptor& _out_rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory ) const
2575     {
2576         OSL_PRECOND( m_xComponent.is(), "FormComponentPropertyHandler::impl_describeListSourceUI_throw: no component!" );
2577 
2578         ////////////////////////////////////////////////////////////
2579         // Auslesen des ListSourceTypes
2580         Any aListSourceType( m_xComponent->getPropertyValue( PROPERTY_LISTSOURCETYPE ) );
2581 
2582         sal_Int32 nListSourceType = ListSourceType_VALUELIST;
2583         ::cppu::enum2int( nListSourceType, aListSourceType );
2584 
2585         _out_rDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( PROPERTY_ID_LISTSOURCE );
2586         _out_rDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( PROPERTY_ID_LISTSOURCE ) );
2587 
2588         ////////////////////////////////////////////////////////////
2589         // Enums setzen
2590         switch( nListSourceType )
2591         {
2592         case ListSourceType_VALUELIST:
2593             _out_rDescriptor.Control = _rxControlFactory->createPropertyControl( PropertyControlType::StringListField, sal_False );
2594             break;
2595 
2596         case ListSourceType_TABLEFIELDS:
2597         case ListSourceType_TABLE:
2598         case ListSourceType_QUERY:
2599         {
2600             ::std::vector< ::rtl::OUString > aListEntries;
2601             if ( impl_ensureRowsetConnection_nothrow() )
2602             {
2603                 if ( nListSourceType == ListSourceType_QUERY )
2604                     impl_fillQueryNames_throw( aListEntries );
2605                 else
2606                     impl_fillTableNames_throw( aListEntries );
2607             }
2608             _out_rDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
2609         }
2610         break;
2611         case ListSourceType_SQL:
2612         case ListSourceType_SQLPASSTHROUGH:
2613             impl_ensureRowsetConnection_nothrow();
2614             _out_rDescriptor.HasPrimaryButton = m_xRowSetConnection.is();
2615             break;
2616         }
2617     }
2618 
2619     //------------------------------------------------------------------------
2620     bool FormComponentPropertyHandler::impl_dialogListSelection_nothrow( const ::rtl::OUString& _rProperty, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2621     {
2622         OSL_PRECOND( m_pInfoService.get(), "FormComponentPropertyHandler::impl_dialogListSelection_nothrow: no property meta data!" );
2623 
2624         String sPropertyUIName( m_pInfoService->getPropertyTranslation( m_pInfoService->getPropertyId( _rProperty ) ) );
2625         ListSelectionDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, _rProperty, sPropertyUIName );
2626         _rClearBeforeDialog.clear();
2627         return ( RET_OK == aDialog.Execute() );
2628     }
2629 
2630     //------------------------------------------------------------------------
2631     bool FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow( bool _bFilter, ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2632     {
2633         OSL_PRECOND( Reference< XRowSet >( m_xComponent, UNO_QUERY ).is(),
2634             "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: to be called for forms only!" );
2635 
2636         _out_rSelectedClause = ::rtl::OUString();
2637         bool bSuccess = false;
2638         SQLExceptionInfo aErrorInfo;
2639         try
2640         {
2641             if ( !impl_ensureRowsetConnection_nothrow() )
2642                 return false;
2643 
2644             // get a composer for the statement which the form is currently based on
2645             Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_aContext.getLegacyServiceFactory() ) );
2646             OSL_ENSURE( xComposer.is(), "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: could not obtain a composer!" );
2647             if ( !xComposer.is() )
2648                 return false;
2649 
2650             ::rtl::OUString sPropertyUIName( m_pInfoService->getPropertyTranslation( _bFilter ? PROPERTY_ID_FILTER : PROPERTY_ID_SORT ) );
2651 
2652             const sal_Char* pAsciiServiceName = _bFilter ? "com.sun.star.sdb.FilterDialog" : "com.sun.star.sdb.OrderDialog";
2653 
2654             // create the dialog
2655             Reference< XExecutableDialog > xDialog;
2656             if ( !m_aContext.createComponent( pAsciiServiceName, xDialog ) )
2657             {
2658                 ShowServiceNotAvailableError( impl_getDefaultDialogParent_nothrow(), ::rtl::OUString::createFromAscii( pAsciiServiceName ), sal_True );
2659                 return false;
2660             }
2661 
2662             // initialize the dialog
2663             Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
2664             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" ) ), makeAny( xComposer ) );
2665             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowSet" ) ),        makeAny( m_xComponent ) );
2666             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ),  makeAny( VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ) ) );
2667             xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),         makeAny( sPropertyUIName ) );
2668 
2669             _rClearBeforeDialog.clear();
2670             bSuccess = ( xDialog->execute() != 0 );
2671             if ( bSuccess )
2672                 _out_rSelectedClause = _bFilter ? xComposer->getFilter() : xComposer->getOrder();
2673         }
2674         catch (SQLContext& e) { aErrorInfo = e; }
2675         catch (SQLWarning& e) { aErrorInfo = e; }
2676         catch (SQLException& e) { aErrorInfo = e; }
2677         catch( const Exception& )
2678         {
2679             OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: caught an exception!" );
2680         }
2681 
2682         if ( aErrorInfo.isValid() )
2683             impl_displaySQLError_nothrow( aErrorInfo );
2684 
2685         return bSuccess;
2686     }
2687 
2688     //------------------------------------------------------------------------
2689     bool FormComponentPropertyHandler::impl_dialogLinkedFormFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2690     {
2691         Reference< XForm > xDetailForm( m_xComponent, UNO_QUERY );
2692         Reference< XForm > xMasterForm( m_xObjectParent, UNO_QUERY );
2693         uno::Reference<beans::XPropertySet> xMasterProp(m_xObjectParent,uno::UNO_QUERY);
2694         OSL_PRECOND( xDetailForm.is() && xMasterForm.is(), "FormComponentPropertyHandler::impl_dialogLinkedFormFields_nothrow: no forms!" );
2695         if ( !xDetailForm.is() || !xMasterForm.is() )
2696             return false;
2697 
2698 
2699         FormLinkDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_aContext.getLegacyServiceFactory() );
2700         _rClearBeforeDialog.clear();
2701         return ( RET_OK == aDialog.Execute() );
2702     }
2703 
2704     //------------------------------------------------------------------------
2705     bool FormComponentPropertyHandler::impl_dialogFormatting_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2706     {
2707         bool bChanged = false;
2708         try
2709         {
2710             // create the itemset for the dialog
2711             SfxItemSet aCoreSet(SFX_APP()->GetPool(),
2712                 SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
2713                 SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
2714                 0);     // ripped this somewhere ... don't understand it :(
2715 
2716             // get the number formats supplier
2717             Reference< XNumberFormatsSupplier >  xSupplier;
2718             m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier;
2719 
2720             DBG_ASSERT(xSupplier.is(), "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: invalid call !" );
2721             Reference< XUnoTunnel > xTunnel( xSupplier, UNO_QUERY_THROW );
2722             SvNumberFormatsSupplierObj* pSupplier =
2723                 reinterpret_cast< SvNumberFormatsSupplierObj* >( xTunnel->getSomething( SvNumberFormatsSupplierObj::getUnoTunnelId() ) );
2724             DBG_ASSERT( pSupplier != NULL, "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: invalid call !" );
2725 
2726             sal_Int32 nFormatKey = 0;
2727             impl_getPropertyValue_throw( PROPERTY_FORMATKEY ) >>= nFormatKey;
2728             aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormatKey ) );
2729 
2730             SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
2731             double dPreviewVal = OFormatSampleControl::getPreviewValue(pFormatter,nFormatKey);
2732             SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, String( PcrRes( RID_STR_TEXT_FORMAT ) ), SID_ATTR_NUMBERFORMAT_INFO );
2733             aCoreSet.Put( aFormatter );
2734 
2735             // a tab dialog with a single page
2736             ::std::auto_ptr< SfxSingleTabDialog > pDialog( new SfxSingleTabDialog( impl_getDefaultDialogParent_nothrow(), aCoreSet, 0 ) );
2737             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2738             DBG_ASSERT( pFact, "CreateFactory fail!" );
2739             ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT );
2740             if ( !fnCreatePage )
2741                 throw RuntimeException();   // caught below
2742 
2743             SfxTabPage* pPage = (*fnCreatePage)( pDialog.get(), aCoreSet );
2744             pDialog->SetTabPage( pPage );
2745 
2746             _rClearBeforeDialog.clear();
2747             if ( RET_OK == pDialog->Execute() )
2748             {
2749                 const SfxItemSet* pResult = pDialog->GetOutputItemSet();
2750 
2751                 const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
2752                 const SvxNumberInfoItem* pInfoItem = dynamic_cast< const SvxNumberInfoItem* >( pItem );
2753                 if (pInfoItem && pInfoItem->GetDelCount())
2754                 {
2755                     const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
2756 
2757                     for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
2758                         pFormatter->DeleteEntry(*pDeletedKeys);
2759                 }
2760 
2761                 pItem = NULL;
2762                 if ( SFX_ITEM_SET == pResult->GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pItem ) )
2763                 {
2764                     _out_rNewValue <<= (sal_Int32)( static_cast< const SfxUInt32Item* >( pItem )->GetValue() );
2765                     bChanged = true;
2766                 }
2767             }
2768         }
2769         catch( const Exception& )
2770         {
2771             OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: : caught an exception!" );
2772         }
2773         return bChanged;
2774     }
2775 
2776     //------------------------------------------------------------------------
2777     bool FormComponentPropertyHandler::impl_browseForImage_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2778     {
2779         bool bIsLink = true;// reflect the legacy behavior
2780         ::rtl::OUString aStrTrans = m_pInfoService->getPropertyTranslation( PROPERTY_ID_IMAGE_URL );
2781 
2782         ::sfx2::FileDialogHelper aFileDlg(SFXWB_GRAPHIC);
2783 
2784         aFileDlg.SetTitle(aStrTrans);
2785         // non-linked images ( e.g. those located in the document
2786         // stream ) cannot *currently* be handled by openoffice basic dialogs.
2787         bool bHandleNonLink = ( m_eComponentClass == eFormControl );
2788 
2789         Reference< XFilePickerControlAccess > xController(aFileDlg.GetFilePicker(), UNO_QUERY);
2790         DBG_ASSERT(xController.is(), "FormComponentPropertyHandler::impl_browseForImage_nothrow: missing the controller interface on the file picker!");
2791         if (xController.is())
2792         {
2793             // do a preview by default
2794             xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True));
2795 
2796             xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any(bIsLink));
2797             xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, bHandleNonLink );
2798 
2799         }
2800 
2801         ::rtl::OUString sCurValue;
2802         OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_IMAGE_URL ) >>= sCurValue );
2803         if ( sCurValue.getLength() != 0 && sCurValue.compareToAscii(GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH(GRAPHOBJ_URLPREFIX) ) != 0 )
2804         {
2805             aFileDlg.SetDisplayDirectory( sCurValue );
2806             // TODO: need to set the display directory _and_ the default name
2807         }
2808 
2809         _rClearBeforeDialog.clear();
2810         bool bSuccess = ( 0 == aFileDlg.Execute() );
2811         if ( bSuccess )
2812         {
2813             if ( bHandleNonLink && xController.is() )
2814             {
2815                 xController->getValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bIsLink;
2816             }
2817             if ( !bIsLink )
2818             {
2819                 Graphic aGraphic;
2820                 aFileDlg.GetGraphic( aGraphic );
2821 
2822                 Reference< graphic::XGraphicObject > xGrfObj = graphic::GraphicObject::create( m_aContext.getUNOContext() );
2823                 xGrfObj->setGraphic( aGraphic.GetXGraphic() );
2824 
2825 
2826                 _out_rNewValue <<= xGrfObj;
2827 
2828             }
2829             else
2830                 _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
2831         }
2832         return bSuccess;
2833     }
2834 
2835     //------------------------------------------------------------------------
2836     bool FormComponentPropertyHandler::impl_browseForTargetURL_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2837     {
2838         ::sfx2::FileDialogHelper aFileDlg( WB_3DLOOK );
2839 
2840         ::rtl::OUString sURL;
2841         OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_TARGET_URL ) >>= sURL );
2842         INetURLObject aParser( sURL );
2843         if ( INET_PROT_FILE == aParser.GetProtocol() )
2844             // set the initial directory only for file-URLs. Everything else
2845             // is considered to be potentially expensive
2846             // 106126 - 2002/12/10 - fs@openoffice.org
2847             aFileDlg.SetDisplayDirectory( sURL );
2848 
2849         _rClearBeforeDialog.clear();
2850         bool bSuccess = ( 0 == aFileDlg.Execute() );
2851         if ( bSuccess )
2852             _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
2853         return bSuccess;
2854     }
2855 
2856     //------------------------------------------------------------------------
2857     bool FormComponentPropertyHandler::impl_executeFontDialog_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2858     {
2859         bool bSuccess = false;
2860 
2861         // create an item set for use with the dialog
2862         SfxItemSet* pSet = NULL;
2863         SfxItemPool* pPool = NULL;
2864         SfxPoolItem** pDefaults = NULL;
2865         ControlCharacterDialog::createItemSet(pSet, pPool, pDefaults);
2866         ControlCharacterDialog::translatePropertiesToItems(m_xComponent, pSet);
2867 
2868         {   // do this in an own block. The dialog needs to be destroyed before we call
2869             // destroyItemSet
2870             ControlCharacterDialog aDlg( impl_getDefaultDialogParent_nothrow(), *pSet );
2871             _rClearBeforeDialog.clear();
2872             if ( RET_OK == aDlg.Execute() )
2873             {
2874                 const SfxItemSet* pOut = aDlg.GetOutputItemSet();
2875                 if ( pOut )
2876                 {
2877                     Sequence< NamedValue > aFontPropertyValues;
2878                     ControlCharacterDialog::translateItemsToProperties( *pOut, aFontPropertyValues );
2879                     _out_rNewValue <<= aFontPropertyValues;
2880                     bSuccess = true;
2881                 }
2882             }
2883         }
2884 
2885         ControlCharacterDialog::destroyItemSet(pSet, pPool, pDefaults);
2886         return bSuccess;
2887     }
2888 
2889     //------------------------------------------------------------------------
2890     bool FormComponentPropertyHandler::impl_browseForDatabaseDocument_throw( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2891     {
2892         ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK|WB_OPEN,::String::CreateFromAscii("sdatabase"));
2893 
2894         ::rtl::OUString sDataSource;
2895         OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_DATASOURCE ) >>= sDataSource );
2896         INetURLObject aParser( sDataSource );
2897         if ( INET_PROT_FILE == aParser.GetProtocol() )
2898             // set the initial directory only for file-URLs. Everything else
2899             // is considered to be potentially expensive
2900             // 106126 - 2002/12/10 - fs@openoffice.org
2901             aFileDlg.SetDisplayDirectory( sDataSource );
2902 
2903         const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
2904         const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
2905         OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
2906         if ( pFilter )
2907         {
2908             aFileDlg.SetCurrentFilter(pFilter->GetUIName());
2909             //aFileDlg.AddFilter(pFilter->GetFilterName(),pFilter->GetDefaultExtension());
2910         }
2911 
2912         _rClearBeforeDialog.clear();
2913         bool bSuccess = ( 0 == aFileDlg.Execute() );
2914         if ( bSuccess )
2915             _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
2916         return bSuccess;
2917     }
2918 
2919     //------------------------------------------------------------------------
2920     bool FormComponentPropertyHandler::impl_dialogColorChooser_throw( sal_Int32 _nColorPropertyId, Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2921     {
2922         sal_Int32 nColor = 0;
2923         OSL_VERIFY( impl_getPropertyValue_throw( impl_getPropertyNameFromId_nothrow( _nColorPropertyId ) ) >>= nColor );
2924         ::Color aColor( nColor );
2925         SvColorDialog aColorDlg( impl_getDefaultDialogParent_nothrow() );
2926         aColorDlg.SetColor( aColor );
2927 
2928         _rClearBeforeDialog.clear();
2929         if ( !aColorDlg.Execute() )
2930             return false;
2931 
2932         aColor = aColorDlg.GetColor();
2933         nColor = aColor.GetColor();
2934         _out_rNewValue <<= (sal_Int32)nColor;
2935         return true;
2936     }
2937 
2938     //------------------------------------------------------------------------
2939     bool FormComponentPropertyHandler::impl_dialogChooseLabelControl_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2940     {
2941         OSelectLabelDialog dlgSelectLabel( impl_getDefaultDialogParent_nothrow(), m_xComponent );
2942         _rClearBeforeDialog.clear();
2943         bool bSuccess = ( RET_OK == dlgSelectLabel.Execute() );
2944         if ( bSuccess )
2945             _out_rNewValue <<= dlgSelectLabel.GetSelected();
2946         return bSuccess;
2947     }
2948 
2949     //------------------------------------------------------------------------
2950     Reference< XControlContainer > FormComponentPropertyHandler::impl_getContextControlContainer_nothrow() const
2951     {
2952         Reference< XControlContainer > xControlContext(
2953             m_aContext.getContextValueByAsciiName( "ControlContext" ),
2954             UNO_QUERY );
2955         return xControlContext;
2956     }
2957 
2958     //------------------------------------------------------------------------
2959     bool FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
2960     {
2961         OSL_PRECOND( impl_getContextControlContainer_nothrow().is(), "FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow: invalid control context!" );
2962 
2963         Reference< XTabControllerModel > xTabControllerModel( impl_getRowSet_nothrow(), UNO_QUERY );
2964         TabOrderDialog aDialog(
2965             impl_getDefaultDialogParent_nothrow(),
2966             xTabControllerModel,
2967             impl_getContextControlContainer_nothrow(),
2968             m_aContext.getLegacyServiceFactory()
2969         );
2970         _rClearBeforeDialog.clear();
2971         return ( RET_OK == aDialog.Execute() );
2972     }
2973 
2974     //------------------------------------------------------------------------
2975     namespace
2976     {
2977         //--------------------------------------------------------------------
2978         //- ISQLCommandPropertyUI
2979         //--------------------------------------------------------------------
2980         class ISQLCommandPropertyUI : public ISQLCommandAdapter
2981         {
2982         public:
2983             /** returns the empty-string-terminated list of names of properties
2984                 whose UI is to be disabled while the SQL command property is
2985                 being edited.
2986             */
2987             virtual ::rtl::OUString*    getPropertiesToDisable() = 0;
2988         };
2989 
2990         //--------------------------------------------------------------------
2991         //- SQLCommandPropertyUI
2992         //--------------------------------------------------------------------
2993         class SQLCommandPropertyUI : public ISQLCommandPropertyUI
2994         {
2995         protected:
2996             SQLCommandPropertyUI( const Reference< XPropertySet >& _rxObject )
2997                 :m_xObject( _rxObject )
2998             {
2999                 if ( !m_xObject.is() )
3000                     throw NullPointerException();
3001             }
3002 
3003             virtual oslInterlockedCount SAL_CALL acquire()
3004             {
3005                 return osl_incrementInterlockedCount( &m_refCount );
3006             }
3007 
3008             virtual oslInterlockedCount SAL_CALL release()
3009             {
3010                 if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
3011                 {
3012                     delete this;
3013                     return 0;
3014                 }
3015                 return m_refCount;
3016             }
3017 
3018         protected:
3019             Reference< XPropertySet >   m_xObject;
3020 
3021         private:
3022             oslInterlockedCount         m_refCount;
3023         };
3024 
3025         //--------------------------------------------------------------------
3026         //- FormSQLCommandUI - declaration
3027         //--------------------------------------------------------------------
3028         class FormSQLCommandUI : public SQLCommandPropertyUI
3029         {
3030         public:
3031             FormSQLCommandUI( const Reference< XPropertySet >& _rxForm );
3032 
3033             // ISQLCommandAdapter
3034             virtual ::rtl::OUString getSQLCommand() const;
3035             virtual sal_Bool        getEscapeProcessing() const;
3036             virtual void            setSQLCommand( const ::rtl::OUString& _rCommand ) const;
3037             virtual void            setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const;
3038 
3039             // ISQLCommandPropertyUI
3040             virtual ::rtl::OUString*    getPropertiesToDisable();
3041         };
3042 
3043         //--------------------------------------------------------------------
3044         //- FormSQLCommandUI - implementation
3045         //--------------------------------------------------------------------
3046         //....................................................................
3047         FormSQLCommandUI::FormSQLCommandUI( const Reference< XPropertySet >& _rxForm )
3048             :SQLCommandPropertyUI( _rxForm )
3049         {
3050         }
3051 
3052         //....................................................................
3053         ::rtl::OUString FormSQLCommandUI::getSQLCommand() const
3054         {
3055             ::rtl::OUString sCommand;
3056             OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
3057             return sCommand;
3058         }
3059 
3060         //....................................................................
3061         sal_Bool FormSQLCommandUI::getEscapeProcessing() const
3062         {
3063             sal_Bool bEscapeProcessing( sal_False );
3064             OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
3065             return bEscapeProcessing;
3066         }
3067 
3068         //....................................................................
3069         void FormSQLCommandUI::setSQLCommand( const ::rtl::OUString& _rCommand ) const
3070         {
3071             m_xObject->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
3072         }
3073 
3074         //....................................................................
3075         void FormSQLCommandUI::setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const
3076         {
3077             m_xObject->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( _bEscapeProcessing ) );
3078         }
3079 
3080         //....................................................................
3081         ::rtl::OUString* FormSQLCommandUI::getPropertiesToDisable()
3082         {
3083             static ::rtl::OUString s_aCommandProps[] = {
3084                 PROPERTY_DATASOURCE,
3085                 PROPERTY_COMMAND,
3086                 PROPERTY_COMMANDTYPE,
3087                 PROPERTY_ESCAPE_PROCESSING,
3088                 ::rtl::OUString()
3089             };
3090             return s_aCommandProps;
3091         }
3092         //--------------------------------------------------------------------
3093         //- ValueListCommandUI - declaration
3094         //--------------------------------------------------------------------
3095         class ValueListCommandUI : public SQLCommandPropertyUI
3096         {
3097         public:
3098             ValueListCommandUI( const Reference< XPropertySet >& _rxListOrCombo );
3099 
3100             // ISQLCommandAdapter
3101             virtual ::rtl::OUString getSQLCommand() const;
3102             virtual sal_Bool        getEscapeProcessing() const;
3103             virtual void            setSQLCommand( const ::rtl::OUString& _rCommand ) const;
3104             virtual void            setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const;
3105 
3106             // ISQLCommandPropertyUI
3107             virtual ::rtl::OUString*    getPropertiesToDisable();
3108         private:
3109             mutable bool    m_bPropertyValueIsList;
3110         };
3111 
3112         //--------------------------------------------------------------------
3113         //- ValueListCommandUI - implementation
3114         //--------------------------------------------------------------------
3115         //....................................................................
3116         ValueListCommandUI::ValueListCommandUI( const Reference< XPropertySet >& _rxListOrCombo )
3117             :SQLCommandPropertyUI( _rxListOrCombo )
3118             ,m_bPropertyValueIsList( false )
3119         {
3120         }
3121 
3122         //....................................................................
3123         ::rtl::OUString ValueListCommandUI::getSQLCommand() const
3124         {
3125             ::rtl::OUString sValue;
3126             m_bPropertyValueIsList = false;
3127 
3128             // for combo boxes, the property is a mere string
3129             Any aValue( m_xObject->getPropertyValue( PROPERTY_LISTSOURCE ) );
3130             if ( aValue >>= sValue )
3131                 return sValue;
3132 
3133             Sequence< ::rtl::OUString > aValueList;
3134             if ( aValue >>= aValueList )
3135             {
3136                 m_bPropertyValueIsList = true;
3137                 if ( aValueList.getLength() )
3138                     sValue = aValueList[0];
3139                 return sValue;
3140             }
3141 
3142             OSL_ENSURE( false, "ValueListCommandUI::getSQLCommand: unexpected property type!" );
3143             return sValue;
3144         }
3145 
3146         //....................................................................
3147         sal_Bool ValueListCommandUI::getEscapeProcessing() const
3148         {
3149             enum ListSourceType eType( ListSourceType_SQL );
3150             OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eType );
3151             OSL_ENSURE( ( eType == ListSourceType_SQL ) || ( eType == ListSourceType_SQLPASSTHROUGH ),
3152                 "ValueListCommandUI::getEscapeProcessing: unexpected list source type!" );
3153             return ( eType == ListSourceType_SQL );
3154         }
3155 
3156         //....................................................................
3157         void ValueListCommandUI::setSQLCommand( const ::rtl::OUString& _rCommand ) const
3158         {
3159             Any aValue;
3160             if ( m_bPropertyValueIsList )
3161                 aValue <<= Sequence< ::rtl::OUString >( &_rCommand, 1 );
3162             else
3163                 aValue <<= _rCommand;
3164             m_xObject->setPropertyValue( PROPERTY_LISTSOURCE, aValue );
3165         }
3166 
3167         //....................................................................
3168         void ValueListCommandUI::setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const
3169         {
3170             m_xObject->setPropertyValue( PROPERTY_LISTSOURCETYPE, makeAny(
3171                 _bEscapeProcessing ? ListSourceType_SQL : ListSourceType_SQLPASSTHROUGH ) );
3172         }
3173 
3174         //....................................................................
3175         ::rtl::OUString* ValueListCommandUI::getPropertiesToDisable()
3176         {
3177             static ::rtl::OUString s_aListSourceProps[] = {
3178                 PROPERTY_LISTSOURCETYPE,
3179                 PROPERTY_LISTSOURCE,
3180                 ::rtl::OUString()
3181             };
3182             return s_aListSourceProps;
3183         }
3184     }
3185 
3186     //------------------------------------------------------------------------
3187     bool FormComponentPropertyHandler::impl_doDesignSQLCommand_nothrow( const Reference< XObjectInspectorUI >& _rxInspectorUI, PropertyId _nDesignForProperty )
3188     {
3189         try
3190         {
3191             if ( m_xCommandDesigner.is() )
3192             {
3193                 if ( m_xCommandDesigner->isActive() )
3194                 {
3195                     m_xCommandDesigner->raise();
3196                     return true;
3197                 }
3198                 m_xCommandDesigner->dispose();
3199                 m_xCommandDesigner.set( NULL );
3200             }
3201 
3202             if ( !impl_ensureRowsetConnection_nothrow() )
3203                 return false;
3204 
3205             Reference< XPropertySet > xComponentProperties( m_xComponent, UNO_QUERY_THROW );
3206 
3207             ::rtl::Reference< ISQLCommandPropertyUI > xCommandUI;
3208             switch ( _nDesignForProperty )
3209             {
3210             case PROPERTY_ID_COMMAND:
3211                 xCommandUI = new FormSQLCommandUI( xComponentProperties );
3212                 break;
3213             case PROPERTY_ID_LISTSOURCE:
3214                 xCommandUI = new ValueListCommandUI( xComponentProperties );
3215                 break;
3216             default:
3217                 OSL_ENSURE( false, "FormComponentPropertyHandler::OnDesignerClosed: invalid property id!" );
3218                 return false;
3219             }
3220 
3221             m_xCommandDesigner.set( new SQLCommandDesigner( m_aContext.getUNOContext(), xCommandUI.get(), m_xRowSetConnection, LINK( this, FormComponentPropertyHandler, OnDesignerClosed ) ) );
3222 
3223             DBG_ASSERT( _rxInspectorUI.is(), "FormComponentPropertyHandler::OnDesignerClosed: no access to the property browser ui!" );
3224             if ( m_xCommandDesigner->isActive() && _rxInspectorUI.is() )
3225             {
3226                 m_xBrowserUI = _rxInspectorUI;
3227                 // disable everything which would affect this property
3228                 const ::rtl::OUString* pToDisable = xCommandUI->getPropertiesToDisable();
3229                 while ( pToDisable->getLength() )
3230                 {
3231                     m_xBrowserUI->enablePropertyUIElements( *pToDisable++, PropertyLineElement::All, sal_False );
3232                 }
3233 
3234                 // but enable the browse button for the property itself - so it can be used to raise the query designer
3235                 ::rtl::OUString sPropertyName( impl_getPropertyNameFromId_nothrow( _nDesignForProperty ) );
3236                 m_xBrowserUI->enablePropertyUIElements( sPropertyName, PropertyLineElement::PrimaryButton, sal_True );
3237             }
3238         }
3239         catch( const Exception& )
3240         {
3241             DBG_UNHANDLED_EXCEPTION();
3242         }
3243         return m_xCommandDesigner.is();
3244     }
3245 
3246     //------------------------------------------------------------------------
3247     IMPL_LINK( FormComponentPropertyHandler, OnDesignerClosed, void*, /*NOTINTERESTEDIN*/ )
3248     {
3249         OSL_ENSURE( m_xBrowserUI.is() && m_xCommandDesigner.is(), "FormComponentPropertyHandler::OnDesignerClosed: too many NULLs!" );
3250         if ( m_xBrowserUI.is() && m_xCommandDesigner.is() )
3251         {
3252             try
3253             {
3254                 ::rtl::Reference< ISQLCommandPropertyUI > xCommandUI(
3255                     dynamic_cast< ISQLCommandPropertyUI* >( m_xCommandDesigner->getPropertyAdapter().get() ) );
3256                 if ( !xCommandUI.is() )
3257                     throw NullPointerException();
3258 
3259                 const ::rtl::OUString* pToEnable = xCommandUI->getPropertiesToDisable();
3260                 while ( pToEnable->getLength() )
3261                 {
3262                     m_xBrowserUI->enablePropertyUIElements( *pToEnable++, PropertyLineElement::All, sal_True );
3263                 }
3264             }
3265             catch( const Exception& )
3266             {
3267             	DBG_UNHANDLED_EXCEPTION();
3268             }
3269         }
3270 
3271         return 0L;
3272     }
3273 
3274 	//------------------------------------------------------------------------
3275     bool FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow( const Reference< XPropertySet >& _xFormProperties, bool _bAllowEmptyDataSourceName ) SAL_THROW(())
3276     {
3277         bool bHas = false;
3278         if ( _xFormProperties.is() )
3279         {
3280             try
3281             {
3282                 ::rtl::OUString sPropertyValue;
3283                 // first, we need the name of an existent data source
3284                 if ( _xFormProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATASOURCE) )
3285                     _xFormProperties->getPropertyValue( PROPERTY_DATASOURCE ) >>= sPropertyValue;
3286                 bHas = ( sPropertyValue.getLength() != 0 ) || _bAllowEmptyDataSourceName;
3287 
3288                 // then, the command should not be empty
3289                 if ( bHas )
3290                 {
3291                     if ( _xFormProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND) )
3292                         _xFormProperties->getPropertyValue( PROPERTY_COMMAND ) >>= sPropertyValue;
3293                     bHas = ( sPropertyValue.getLength() != 0 );
3294                 }
3295             }
3296             catch( const Exception& )
3297             {
3298                 OSL_ENSURE( false, "FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow: caught an exception!" );
3299             }
3300         }
3301         return bHas;
3302     }
3303     //------------------------------------------------------------------------
3304     ::rtl::OUString FormComponentPropertyHandler::impl_getDocumentURL_nothrow() const
3305     {
3306         ::rtl::OUString sURL;
3307         try
3308         {
3309             Reference< XModel > xDocument( impl_getContextDocument_nothrow() );
3310             if ( xDocument.is() )
3311                 sURL = xDocument->getURL();
3312         }
3313         catch( const Exception& )
3314         {
3315             DBG_UNHANDLED_EXCEPTION();
3316         }
3317         return sURL;
3318     }
3319     // -------------------------------------------------------------------------
3320     ::cppu::IPropertyArrayHelper* FormComponentPropertyHandler::createArrayHelper( ) const
3321     {
3322         uno::Sequence< beans::Property > aProps;
3323 	    describeProperties(aProps);
3324 	    return new ::cppu::OPropertyArrayHelper(aProps);
3325 
3326     }
3327     // -------------------------------------------------------------------------
3328     ::cppu::IPropertyArrayHelper & FormComponentPropertyHandler::getInfoHelper()
3329     {
3330 	    return *const_cast<FormComponentPropertyHandler*>(this)->getArrayHelper();
3331     }
3332     // -----------------------------------------------------------------------------
3333     uno::Reference< beans::XPropertySetInfo > SAL_CALL FormComponentPropertyHandler::getPropertySetInfo(  ) throw(uno::RuntimeException)
3334     {
3335 	    return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
3336     }
3337 
3338 //........................................................................
3339 } // namespace pcr
3340 //........................................................................
3341 
3342