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