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