Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "propertyhandler.hxx"
30 : : #include "formmetadata.hxx"
31 : : #include "formbrowsertools.hxx"
32 : : #include "handlerhelper.hxx"
33 : : #include "formstrings.hxx"
34 : :
35 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
36 : : #include <com/sun/star/lang/NullPointerException.hpp>
37 : : #include <com/sun/star/util/XModifiable.hpp>
38 : :
39 : : #include <tools/debug.hxx>
40 : : #include <unotools/confignode.hxx>
41 : : #include <unotools/localedatawrapper.hxx>
42 : : #include <unotools/syslocale.hxx>
43 : : #include <toolkit/helper/vclunohelper.hxx>
44 : :
45 : : #include <algorithm>
46 : :
47 : : //........................................................................
48 : : namespace pcr
49 : : {
50 : : //........................................................................
51 : :
52 : : using namespace ::com::sun::star::uno;
53 : : using namespace ::com::sun::star::awt;
54 : : using namespace ::com::sun::star::beans;
55 : : using namespace ::com::sun::star::script;
56 : : using namespace ::com::sun::star::lang;
57 : : using namespace ::com::sun::star::util;
58 : : using namespace ::com::sun::star::frame;
59 : : using namespace ::com::sun::star::inspection;
60 : : using namespace ::comphelper;
61 : :
62 : : //====================================================================
63 : : //= PropertyHandler
64 : : //====================================================================
65 : : DBG_NAME( PropertyHandler )
66 : : //--------------------------------------------------------------------
67 : 0 : PropertyHandler::PropertyHandler( const Reference< XComponentContext >& _rxContext )
68 : : :PropertyHandler_Base( m_aMutex )
69 : : ,m_bSupportedPropertiesAreKnown( false )
70 : : ,m_aPropertyListeners( m_aMutex )
71 : : ,m_aContext( _rxContext )
72 : 0 : ,m_pInfoService ( new OPropertyInfoService )
73 : : {
74 : : DBG_CTOR( PropertyHandler, NULL );
75 : :
76 : : m_xTypeConverter = Reference< XTypeConverter >(
77 : : m_aContext.createComponent( "com.sun.star.script.Converter" ),
78 : : UNO_QUERY_THROW
79 : 0 : );
80 : 0 : }
81 : :
82 : : //--------------------------------------------------------------------
83 : 0 : PropertyHandler::~PropertyHandler()
84 : : {
85 : : DBG_DTOR( PropertyHandler, NULL );
86 : 0 : }
87 : :
88 : : //--------------------------------------------------------------------
89 : 0 : void SAL_CALL PropertyHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
90 : : {
91 : 0 : if ( !_rxIntrospectee.is() )
92 : 0 : throw NullPointerException();
93 : :
94 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
95 : :
96 : 0 : Reference< XPropertySet > xNewComponent( _rxIntrospectee, UNO_QUERY );
97 : 0 : if ( xNewComponent == m_xComponent )
98 : 0 : return;
99 : :
100 : : // remove all old property change listeners
101 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
102 : 0 : ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > removeListener = m_aPropertyListeners.createIterator();
103 : 0 : ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > readdListener = m_aPropertyListeners.createIterator(); // will copy the container as needed
104 : : SAL_WNODEPRECATED_DECLARATIONS_POP
105 : 0 : while ( removeListener->hasMoreElements() )
106 : 0 : removePropertyChangeListener( static_cast< XPropertyChangeListener* >( removeListener->next() ) );
107 : : OSL_ENSURE( m_aPropertyListeners.empty(), "PropertyHandler::inspect: derived classes are expected to forward the removePropertyChangeListener call to their base class (me)!" );
108 : :
109 : : // remember the new component, and give derived classes the chance to react on it
110 : 0 : m_xComponent = xNewComponent;
111 : 0 : onNewComponent();
112 : :
113 : : // add the listeners, again
114 : 0 : while ( readdListener->hasMoreElements() )
115 : 0 : addPropertyChangeListener( static_cast< XPropertyChangeListener* >( readdListener->next() ) );
116 : : }
117 : :
118 : : //--------------------------------------------------------------------
119 : 0 : void PropertyHandler::onNewComponent()
120 : : {
121 : 0 : if ( m_xComponent.is() )
122 : 0 : m_xComponentPropertyInfo = m_xComponent->getPropertySetInfo();
123 : : else
124 : 0 : m_xComponentPropertyInfo.clear();
125 : :
126 : 0 : m_bSupportedPropertiesAreKnown = false;
127 : 0 : m_aSupportedProperties.realloc( 0 );
128 : 0 : }
129 : :
130 : : //--------------------------------------------------------------------
131 : 0 : Sequence< Property > SAL_CALL PropertyHandler::getSupportedProperties() throw (RuntimeException)
132 : : {
133 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
134 : 0 : if ( !m_bSupportedPropertiesAreKnown )
135 : : {
136 : 0 : m_aSupportedProperties = doDescribeSupportedProperties();
137 : 0 : m_bSupportedPropertiesAreKnown = true;
138 : : }
139 : 0 : return (Sequence< Property >)m_aSupportedProperties;
140 : : }
141 : :
142 : : //--------------------------------------------------------------------
143 : 0 : Sequence< ::rtl::OUString > SAL_CALL PropertyHandler::getSupersededProperties( ) throw (RuntimeException)
144 : : {
145 : 0 : return Sequence< ::rtl::OUString >();
146 : : }
147 : :
148 : : //--------------------------------------------------------------------
149 : 0 : Sequence< ::rtl::OUString > SAL_CALL PropertyHandler::getActuatingProperties( ) throw (RuntimeException)
150 : : {
151 : 0 : return Sequence< ::rtl::OUString >();
152 : : }
153 : :
154 : : //--------------------------------------------------------------------
155 : 0 : Any SAL_CALL PropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
156 : : {
157 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
158 : 0 : PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
159 : 0 : Property aProperty( impl_getPropertyFromName_throw( _rPropertyName ) );
160 : :
161 : 0 : Any aPropertyValue;
162 : 0 : if ( !_rControlValue.hasValue() )
163 : : // NULL is converted to NULL
164 : : return aPropertyValue;
165 : :
166 : 0 : if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
167 : : {
168 : 0 : ::rtl::OUString sControlValue;
169 : 0 : OSL_VERIFY( _rControlValue >>= sControlValue );
170 : : ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
171 : 0 : new DefaultEnumRepresentation( *m_pInfoService, aProperty.Type, nPropId ) );
172 : : // TODO/UNOize: cache those converters?
173 : 0 : aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue );
174 : : }
175 : : else
176 : : aPropertyValue = PropertyHandlerHelper::convertToPropertyValue(
177 : 0 : m_aContext.getContext(),m_xTypeConverter, aProperty, _rControlValue );
178 : 0 : return aPropertyValue;
179 : : }
180 : :
181 : : //--------------------------------------------------------------------
182 : 0 : Any SAL_CALL PropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
183 : : {
184 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
185 : 0 : PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
186 : :
187 : 0 : if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
188 : : {
189 : : DBG_ASSERT( _rControlValueType.getTypeClass() == TypeClass_STRING, "PropertyHandler::convertToControlValue: ENUM, but not STRING?" );
190 : :
191 : : ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
192 : 0 : new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), nPropId ) );
193 : : // TODO/UNOize: cache those converters?
194 : 0 : return makeAny( aEnumConversion->getDescriptionForValue( _rPropertyValue ) );
195 : : }
196 : :
197 : : return PropertyHandlerHelper::convertToControlValue(
198 : 0 : m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType );
199 : : }
200 : :
201 : : //--------------------------------------------------------------------
202 : 0 : PropertyState SAL_CALL PropertyHandler::getPropertyState( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
203 : : {
204 : 0 : return PropertyState_DIRECT_VALUE;
205 : : }
206 : :
207 : : //--------------------------------------------------------------------
208 : 0 : LineDescriptor SAL_CALL PropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
209 : : const Reference< XPropertyControlFactory >& _rxControlFactory )
210 : : throw (UnknownPropertyException, NullPointerException, RuntimeException)
211 : : {
212 : 0 : if ( !_rxControlFactory.is() )
213 : 0 : throw NullPointerException();
214 : :
215 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
216 : 0 : PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
217 : 0 : const Property& rProperty( impl_getPropertyFromId_throw( nPropId ) );
218 : :
219 : 0 : LineDescriptor aDescriptor;
220 : 0 : if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
221 : : {
222 : : aDescriptor.Control = PropertyHandlerHelper::createListBoxControl(
223 : 0 : _rxControlFactory, m_pInfoService->getPropertyEnumRepresentations( nPropId ),
224 : 0 : PropertyHandlerHelper::requiresReadOnlyControl( rProperty.Attributes ), sal_False );
225 : : }
226 : : else
227 : 0 : PropertyHandlerHelper::describePropertyLine( rProperty, aDescriptor, _rxControlFactory );
228 : :
229 : 0 : aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
230 : 0 : aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
231 : :
232 : 0 : if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_DATA_PROPERTY ) != 0 )
233 : 0 : aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
234 : : else
235 : 0 : aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
236 : 0 : return aDescriptor;
237 : : }
238 : :
239 : : //--------------------------------------------------------------------
240 : 0 : ::sal_Bool SAL_CALL PropertyHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
241 : : {
242 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
243 : 0 : return m_pInfoService->isComposeable( _rPropertyName );
244 : : }
245 : :
246 : : //--------------------------------------------------------------------
247 : 0 : InteractiveSelectionResult SAL_CALL PropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& /*_rPropertyName*/, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/ ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
248 : : {
249 : : OSL_FAIL( "PropertyHandler::onInteractivePropertySelection: not implemented!" );
250 : 0 : return InteractiveSelectionResult_Cancelled;
251 : : }
252 : :
253 : : //--------------------------------------------------------------------
254 : 0 : void SAL_CALL PropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
255 : : {
256 : : OSL_FAIL( "PropertyHandler::actuatingPropertyChanged: not implemented!" );
257 : 0 : }
258 : :
259 : : //--------------------------------------------------------------------
260 : 0 : void SAL_CALL PropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
261 : : {
262 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
263 : 0 : if ( !_rxListener.is() )
264 : 0 : throw NullPointerException();
265 : 0 : m_aPropertyListeners.addListener( _rxListener );
266 : 0 : }
267 : :
268 : : //--------------------------------------------------------------------
269 : 0 : void SAL_CALL PropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
270 : : {
271 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
272 : 0 : m_aPropertyListeners.removeListener( _rxListener );
273 : 0 : }
274 : :
275 : : //--------------------------------------------------------------------
276 : 0 : sal_Bool SAL_CALL PropertyHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
277 : : {
278 : 0 : return sal_True;
279 : : }
280 : :
281 : : //--------------------------------------------------------------------
282 : 0 : IMPLEMENT_FORWARD_XCOMPONENT( PropertyHandler, PropertyHandler_Base )
283 : : //--------------------------------------------------------------------
284 : 0 : void SAL_CALL PropertyHandler::disposing()
285 : : {
286 : 0 : m_xComponent.clear();
287 : 0 : m_aPropertyListeners.clear();
288 : 0 : m_xTypeConverter.clear();
289 : 0 : m_aSupportedProperties.realloc( 0 );
290 : 0 : }
291 : :
292 : : //--------------------------------------------------------------------
293 : 0 : void PropertyHandler::firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId, const Any& _rOldValue, const Any& _rNewValue ) SAL_THROW(())
294 : : {
295 : 0 : PropertyChangeEvent aEvent;
296 : 0 : aEvent.Source = m_xComponent;
297 : 0 : aEvent.PropertyHandle = _nPropId;
298 : 0 : aEvent.PropertyName = _rPropName;
299 : 0 : aEvent.OldValue = _rOldValue;
300 : 0 : aEvent.NewValue = _rNewValue;
301 : 0 : m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
302 : 0 : }
303 : :
304 : : //--------------------------------------------------------------------
305 : 0 : const Property* PropertyHandler::impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const
306 : : {
307 : 0 : const_cast< PropertyHandler* >( this )->getSupportedProperties();
308 : : const Property* pFound = ::std::find_if( m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
309 : : FindPropertyByHandle( _nPropId )
310 : 0 : );
311 : 0 : if ( pFound != m_aSupportedProperties.end() )
312 : 0 : return &(*pFound);
313 : 0 : return NULL;
314 : : }
315 : :
316 : : //--------------------------------------------------------------------
317 : 0 : const Property& PropertyHandler::impl_getPropertyFromId_throw( PropertyId _nPropId ) const
318 : : {
319 : 0 : const Property* pProperty = impl_getPropertyFromId_nothrow( _nPropId );
320 : 0 : if ( !pProperty )
321 : 0 : throw UnknownPropertyException();
322 : :
323 : 0 : return *pProperty;
324 : : }
325 : :
326 : : //--------------------------------------------------------------------
327 : 0 : const Property& PropertyHandler::impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const
328 : : {
329 : 0 : const_cast< PropertyHandler* >( this )->getSupportedProperties();
330 : : StlSyntaxSequence< Property >::const_iterator pFound = ::std::find_if( m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
331 : : FindPropertyByName( _rPropertyName )
332 : 0 : );
333 : 0 : if ( pFound == m_aSupportedProperties.end() )
334 : 0 : throw UnknownPropertyException();
335 : :
336 : 0 : return *pFound;
337 : : }
338 : :
339 : : //--------------------------------------------------------------------
340 : 0 : void PropertyHandler::implAddPropertyDescription( ::std::vector< Property >& _rProperties, const ::rtl::OUString& _rPropertyName, const Type& _rType, sal_Int16 _nAttribs ) const
341 : : {
342 : : _rProperties.push_back( Property(
343 : : _rPropertyName,
344 : 0 : m_pInfoService->getPropertyId( _rPropertyName ),
345 : : _rType,
346 : : _nAttribs
347 : 0 : ) );
348 : 0 : }
349 : :
350 : : //------------------------------------------------------------------------
351 : 0 : Window* PropertyHandler::impl_getDefaultDialogParent_nothrow() const
352 : : {
353 : 0 : return PropertyHandlerHelper::getDialogParentWindow( m_aContext );
354 : : }
355 : :
356 : : //------------------------------------------------------------------------
357 : 0 : PropertyId PropertyHandler::impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const
358 : : {
359 : 0 : PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
360 : 0 : if ( nPropId == -1 )
361 : 0 : throw UnknownPropertyException();
362 : 0 : return nPropId;
363 : : }
364 : :
365 : : //------------------------------------------------------------------------
366 : 0 : void PropertyHandler::impl_setContextDocumentModified_nothrow() const
367 : : {
368 : 0 : Reference< XModifiable > xModifiable( impl_getContextDocument_nothrow(), UNO_QUERY );
369 : 0 : if ( xModifiable.is() )
370 : 0 : xModifiable->setModified( sal_True );
371 : 0 : }
372 : :
373 : : //------------------------------------------------------------------------
374 : 0 : bool PropertyHandler::impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const
375 : : {
376 : 0 : return m_xComponentPropertyInfo.is() && m_xComponentPropertyInfo->hasPropertyByName( _rPropName );
377 : : }
378 : :
379 : : //--------------------------------------------------------------------
380 : 0 : sal_Int16 PropertyHandler::impl_getDocumentMeasurementUnit_throw() const
381 : : {
382 : 0 : FieldUnit eUnit = FUNIT_NONE;
383 : :
384 : 0 : Reference< XServiceInfo > xDocumentSI( impl_getContextDocument_nothrow(), UNO_QUERY );
385 : : OSL_ENSURE( xDocumentSI.is(), "PropertyHandlerHelper::impl_getDocumentMeasurementUnit_throw: No context document - where do I live?" );
386 : 0 : if ( xDocumentSI.is() )
387 : : {
388 : : // determine the application type we live in
389 : 0 : ::rtl::OUString sConfigurationLocation;
390 : 0 : ::rtl::OUString sConfigurationProperty;
391 : 0 : if ( xDocumentSI->supportsService( SERVICE_WEB_DOCUMENT ) )
392 : : { // writer
393 : 0 : sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.WriterWeb/Layout/Other" ) );
394 : 0 : sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MeasureUnit" ) );
395 : : }
396 : 0 : else if ( xDocumentSI->supportsService( SERVICE_TEXT_DOCUMENT ) )
397 : : { // writer
398 : 0 : sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Writer/Layout/Other" ) );
399 : 0 : sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MeasureUnit" ) );
400 : : }
401 : 0 : else if ( xDocumentSI->supportsService( SERVICE_SPREADSHEET_DOCUMENT ) )
402 : : { // calc
403 : 0 : sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Calc/Layout/Other/MeasureUnit" ) );
404 : 0 : sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
405 : : }
406 : 0 : else if ( xDocumentSI->supportsService( SERVICE_DRAWING_DOCUMENT ) )
407 : : {
408 : 0 : sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Draw/Layout/Other/MeasureUnit" ) );
409 : 0 : sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
410 : : }
411 : 0 : else if ( xDocumentSI->supportsService( SERVICE_PRESENTATION_DOCUMENT ) )
412 : : {
413 : 0 : sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Impress/Layout/Other/MeasureUnit" ) );
414 : 0 : sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
415 : : }
416 : :
417 : : // read the measurement unit from the configuration
418 : 0 : if ( !(sConfigurationLocation.isEmpty() || sConfigurationProperty.isEmpty()) )
419 : : {
420 : : ::utl::OConfigurationTreeRoot aConfigTree( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
421 : 0 : m_aContext.getLegacyServiceFactory(), sConfigurationLocation, -1, ::utl::OConfigurationTreeRoot::CM_READONLY ) );
422 : 0 : sal_Int32 nUnitAsInt = (sal_Int32)FUNIT_NONE;
423 : 0 : aConfigTree.getNodeValue( sConfigurationProperty ) >>= nUnitAsInt;
424 : :
425 : : // if this denotes a valid (and accepted) unit, then use it
426 : 0 : if ( ( nUnitAsInt > FUNIT_NONE ) && ( nUnitAsInt <= FUNIT_100TH_MM ) )
427 : 0 : eUnit = static_cast< FieldUnit >( nUnitAsInt );
428 : 0 : }
429 : : }
430 : :
431 : 0 : if ( FUNIT_NONE == eUnit )
432 : : {
433 : 0 : MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
434 : 0 : eUnit = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
435 : : }
436 : :
437 : 0 : return VCLUnoHelper::ConvertToMeasurementUnit( eUnit, 1 );
438 : : }
439 : :
440 : : //====================================================================
441 : : //= PropertyHandlerComponent
442 : : //====================================================================
443 : : //------------------------------------------------------------------------
444 : 0 : PropertyHandlerComponent::PropertyHandlerComponent( const Reference< XComponentContext >& _rxContext )
445 : 0 : :PropertyHandler( _rxContext )
446 : : {
447 : 0 : }
448 : :
449 : : //--------------------------------------------------------------------
450 : 0 : IMPLEMENT_FORWARD_XINTERFACE2( PropertyHandlerComponent, PropertyHandler, PropertyHandlerComponent_Base )
451 : 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( PropertyHandlerComponent, PropertyHandler, PropertyHandlerComponent_Base )
452 : :
453 : : //--------------------------------------------------------------------
454 : 0 : ::sal_Bool SAL_CALL PropertyHandlerComponent::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
455 : : {
456 : 0 : StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
457 : 0 : return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
458 : : }
459 : :
460 : : //........................................................................
461 : : } // namespace pcr
462 : : //........................................................................
463 : :
464 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|