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