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