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