Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <toolkit/controls/controlmodelcontainerbase.hxx>
31 : : #include <vcl/svapp.hxx>
32 : : #include <vcl/window.hxx>
33 : : #include <vcl/wall.hxx>
34 : : #include <osl/mutex.hxx>
35 : : #include <toolkit/helper/property.hxx>
36 : : #include <toolkit/helper/unopropertyarrayhelper.hxx>
37 : : #include <toolkit/controls/geometrycontrolmodel.hxx>
38 : : #include <toolkit/controls/unocontrols.hxx>
39 : : #include "toolkit/controls/formattedcontrol.hxx"
40 : : #include "toolkit/controls/roadmapcontrol.hxx"
41 : : #include "toolkit/controls/tkscrollbar.hxx"
42 : : #include <toolkit/controls/stdtabcontroller.hxx>
43 : : #include <com/sun/star/awt/PosSize.hpp>
44 : : #include <com/sun/star/awt/WindowAttribute.hpp>
45 : : #include <com/sun/star/resource/XStringResourceResolver.hpp>
46 : : #include <com/sun/star/graphic/XGraphicProvider.hpp>
47 : : #include <cppuhelper/typeprovider.hxx>
48 : : #include <tools/debug.hxx>
49 : : #include <tools/diagnose_ex.h>
50 : : #include <comphelper/processfactory.hxx>
51 : : #include <vcl/svapp.hxx>
52 : : #include <vcl/outdev.hxx>
53 : : #include <comphelper/types.hxx>
54 : :
55 : : #include <comphelper/componentcontext.hxx>
56 : : #include <toolkit/helper/vclunohelper.hxx>
57 : : #include <toolkit/helper/tkresmgr.hxx>
58 : : #include <unotools/ucbstreamhelper.hxx>
59 : : #include <vcl/graph.hxx>
60 : : #include <vcl/image.hxx>
61 : :
62 : : #include "tree/treecontrol.hxx"
63 : : #include "grid/gridcontrol.hxx"
64 : : #include <toolkit/controls/tabpagecontainer.hxx>
65 : :
66 : : #include <boost/bind.hpp>
67 : :
68 : : #include <map>
69 : : #include <algorithm>
70 : : #include <functional>
71 : : #include "tools/urlobj.hxx"
72 : : #include "osl/file.hxx"
73 : : #include "toolkit/controls/dialogcontrol.hxx"
74 : :
75 : : using namespace ::com::sun::star;
76 : : using namespace ::com::sun::star::uno;
77 : : using namespace ::com::sun::star::awt;
78 : : using namespace ::com::sun::star::lang;
79 : : using namespace ::com::sun::star::container;
80 : : using namespace ::com::sun::star::beans;
81 : : using namespace ::com::sun::star::util;
82 : : using namespace toolkit;
83 : :
84 : : #define PROPERTY_RESOURCERESOLVER ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ))
85 : :
86 : : //HELPER
87 : : ::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl );
88 : :
89 : : struct LanguageDependentProp
90 : : {
91 : : const char* pPropName;
92 : : sal_Int32 nPropNameLength;
93 : : };
94 : :
95 : : // ----------------------------------------------------------------------------
96 : : namespace
97 : : {
98 : 0 : static const Sequence< ::rtl::OUString >& lcl_getLanguageDependentProperties()
99 : : {
100 [ # # ][ # # ]: 0 : static Sequence< ::rtl::OUString > s_aLanguageDependentProperties;
[ # # ][ # # ]
101 [ # # ]: 0 : if ( s_aLanguageDependentProperties.getLength() == 0 )
102 : : {
103 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
104 [ # # ]: 0 : if ( s_aLanguageDependentProperties.getLength() == 0 )
105 : : {
106 [ # # ]: 0 : s_aLanguageDependentProperties.realloc( 2 );
107 [ # # ][ # # ]: 0 : s_aLanguageDependentProperties[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) );
108 [ # # ][ # # ]: 0 : s_aLanguageDependentProperties[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) );
109 : : // note: properties must be sorted
110 [ # # ]: 0 : }
111 : : }
112 : 0 : return s_aLanguageDependentProperties;
113 : : }
114 : : }
115 : :
116 : : // ----------------------------------------------------------------------------
117 : : // functor for disposing a control model
118 : : struct DisposeControlModel : public ::std::unary_function< Reference< XControlModel >, void >
119 : : {
120 : 4 : void operator()( Reference< XControlModel >& _rxModel )
121 : : {
122 : : try
123 : : {
124 [ + - ]: 4 : ::comphelper::disposeComponent( _rxModel );
125 : : }
126 : 0 : catch (const Exception&)
127 : : {
128 : : OSL_TRACE( "DisposeControlModel::(): caught an exception while disposing a component!" );
129 : : }
130 [ # # ]: 4 : }
131 : : };
132 : :
133 : : // ----------------------------------------------------------------------------
134 : : // functor for searching control model by name
135 : : struct FindControlModel : public ::std::unary_function< ControlModelContainerBase::UnoControlModelHolder, bool >
136 : : {
137 : : private:
138 : : const ::rtl::OUString& m_rName;
139 : :
140 : : public:
141 : 66 : FindControlModel( const ::rtl::OUString& _rName ) : m_rName( _rName ) { }
142 : :
143 : 108 : bool operator()( const ControlModelContainerBase::UnoControlModelHolder& _rCompare )
144 : : {
145 : 108 : return ( _rCompare.second == m_rName ) ? true : false;
146 : : }
147 : : };
148 : :
149 : : // ----------------------------------------------------------------------------
150 : : // functor for cloning a control model, and insertion into a target list
151 : : struct CloneControlModel : public ::std::unary_function< ControlModelContainerBase::UnoControlModelHolder, void >
152 : : {
153 : : private:
154 : : ControlModelContainerBase::UnoControlModelHolderList& m_rTargetList;
155 : :
156 : : public:
157 : 2 : CloneControlModel( ControlModelContainerBase::UnoControlModelHolderList& _rTargetList )
158 : 2 : :m_rTargetList( _rTargetList )
159 : : {
160 : 2 : }
161 : :
162 : 4 : void operator()( const ControlModelContainerBase::UnoControlModelHolder& _rSource )
163 : : {
164 : : // clone the source object
165 [ + - ]: 4 : Reference< XCloneable > xCloneSource( _rSource.first, UNO_QUERY );
166 [ + - ][ + - ]: 4 : Reference< XControlModel > xClone( xCloneSource->createClone(), UNO_QUERY );
[ + - ]
167 : : // add to target list
168 [ + - ][ + - ]: 4 : m_rTargetList.push_back( ControlModelContainerBase::UnoControlModelHolder( xClone, _rSource.second ) );
[ + - ]
169 : 4 : }
170 : : };
171 : :
172 : : // ----------------------------------------------------------------------------
173 : : // functor for comparing a XControlModel with a given reference
174 : 0 : struct CompareControlModel : public ::std::unary_function< ControlModelContainerBase::UnoControlModelHolder, bool >
175 : : {
176 : : private:
177 : : Reference< XControlModel > m_xReference;
178 : : public:
179 : 0 : CompareControlModel( const Reference< XControlModel >& _rxReference ) : m_xReference( _rxReference ) { }
180 : :
181 : 0 : bool operator()( const ControlModelContainerBase::UnoControlModelHolder& _rCompare )
182 : : {
183 : 0 : return ( _rCompare.first.get() == m_xReference.get() ) ? true : false;
184 : : }
185 : : };
186 : :
187 : : // ----------------------------------------------------------------------------
188 : 2 : static void lcl_throwIllegalArgumentException( )
189 : : { // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this ....
190 [ + - ]: 2 : throw IllegalArgumentException();
191 : : }
192 : :
193 : : // ----------------------------------------------------------------------------
194 : 4 : static void lcl_throwNoSuchElementException( )
195 : : { // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this ....
196 [ + - ]: 4 : throw NoSuchElementException();
197 : : }
198 : :
199 : : // ----------------------------------------------------------------------------
200 : 2 : static void lcl_throwElementExistException( )
201 : : { // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this ....
202 [ + - ]: 2 : throw ElementExistException();
203 : : }
204 : :
205 : : // ----------------------------------------------------------------------------
206 : 80 : static const ::rtl::OUString& getTabIndexPropertyName( )
207 : : {
208 [ + + ][ + - ]: 80 : static const ::rtl::OUString s_sTabIndexProperty( RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) );
[ + - ][ # # ]
209 : 80 : return s_sTabIndexProperty;
210 : : }
211 : :
212 : : // ----------------------------------------------------------------------------
213 : 0 : static const ::rtl::OUString& getStepPropertyName( )
214 : : {
215 [ # # ][ # # ]: 0 : static const ::rtl::OUString s_sStepProperty( RTL_CONSTASCII_USTRINGPARAM( "Step" ) );
[ # # ][ # # ]
216 : 0 : return s_sStepProperty;
217 : : }
218 : :
219 : : // ----------------------------------------------------
220 : : // class ControlModelContainerBase
221 : : // ----------------------------------------------------
222 : 14 : ControlModelContainerBase::ControlModelContainerBase( const Reference< XMultiServiceFactory >& i_factory )
223 : : :ControlModelContainer_IBase( i_factory )
224 : : ,maContainerListeners( *this )
225 : 14 : ,maChangeListeners ( GetMutex() )
226 [ + - + - ]: 28 : ,mbGroupsUpToDate( sal_False )
[ + - ][ + - ]
227 : : {
228 : 14 : }
229 : :
230 : 2 : ControlModelContainerBase::ControlModelContainerBase( const ControlModelContainerBase& rModel )
231 : : : ControlModelContainer_IBase( rModel )
232 : : , maContainerListeners( *this )
233 : 2 : , maChangeListeners ( GetMutex() )
234 [ + - + - ]: 4 : , mbGroupsUpToDate( sal_False )
[ + - ][ + - ]
235 : : {
236 : 2 : }
237 : :
238 [ + - ][ + - ]: 8 : ControlModelContainerBase::~ControlModelContainerBase()
239 : : {
240 : 8 : maModels.clear();
241 : 8 : mbGroupsUpToDate = sal_False;
242 [ - + ]: 8 : }
243 : :
244 : 58 : Any ControlModelContainerBase::ImplGetDefaultValue( sal_uInt16 nPropId ) const
245 : : {
246 : 58 : Any aAny;
247 : :
248 [ - + ]: 58 : switch ( nPropId )
249 : : {
250 : : case BASEPROPERTY_DEFAULTCONTROL:
251 [ # # ]: 0 : aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialog );
252 : 0 : break;
253 : : default:
254 [ + - ]: 58 : aAny = UnoControlModel::ImplGetDefaultValue( nPropId );
255 : : }
256 : :
257 : 58 : return aAny;
258 : : }
259 : :
260 : 0 : ::cppu::IPropertyArrayHelper& ControlModelContainerBase::getInfoHelper()
261 : : {
262 : : static UnoPropertyArrayHelper* pHelper = NULL;
263 [ # # ]: 0 : if ( !pHelper )
264 : : {
265 [ # # ]: 0 : Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
266 [ # # ][ # # ]: 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
267 : : }
268 : 0 : return *pHelper;
269 : : }
270 : :
271 : 8 : void SAL_CALL ControlModelContainerBase::dispose( ) throw(RuntimeException)
272 : : {
273 : : // ====================================================================
274 : : // tell our listeners
275 : : {
276 [ + - ]: 8 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
277 : :
278 [ + - ]: 8 : EventObject aDisposeEvent;
279 [ + - ]: 8 : aDisposeEvent.Source = static_cast< XAggregation* >( static_cast< ::cppu::OWeakAggObject* >( this ) );
280 : :
281 [ + - ]: 8 : maContainerListeners.disposeAndClear( aDisposeEvent );
282 [ + - ][ + - ]: 8 : maChangeListeners.disposeAndClear( aDisposeEvent );
[ + - ]
283 : : }
284 : :
285 : : // ====================================================================
286 : : // call the base class
287 [ + - ]: 8 : UnoControlModel::dispose();
288 : :
289 : : // ====================================================================
290 : : // dispose our child models
291 : : // for this, collect the models (we collect them from maModels, and this is modified when disposing children)
292 [ + - ]: 8 : ::std::vector< Reference< XControlModel > > aChildModels( maModels.size() );
293 : :
294 : : ::std::transform(
295 : : maModels.begin(), maModels.end(), // source range
296 : : aChildModels.begin(), // target location
297 : : ::boost::bind( &UnoControlModelHolder::first, _1 ) // operation to apply -> select the XControlModel part
298 [ + - ][ + - ]: 8 : );
299 : :
300 : : // now dispose
301 [ + - ]: 8 : ::std::for_each( aChildModels.begin(), aChildModels.end(), DisposeControlModel() );
302 : 8 : aChildModels.clear();
303 : :
304 : 8 : mbGroupsUpToDate = sal_False;
305 : 8 : }
306 : :
307 : : // XMultiPropertySet
308 : 0 : Reference< XPropertySetInfo > ControlModelContainerBase::getPropertySetInfo( ) throw(RuntimeException)
309 : : {
310 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
311 : 0 : return xInfo;
312 : : }
313 : 2 : void ControlModelContainerBase::Clone_Impl(ControlModelContainerBase& _rClone) const
314 : : {
315 : : // clone all children
316 : : ::std::for_each(
317 : : maModels.begin(), maModels.end(),
318 : : CloneControlModel( _rClone.maModels )
319 [ + - ]: 2 : );
320 : 2 : }
321 : 0 : UnoControlModel* ControlModelContainerBase::Clone() const
322 : : {
323 : : // clone the container itself
324 [ # # ]: 0 : ControlModelContainerBase* pClone = new ControlModelContainerBase( *this );
325 : 0 : Clone_Impl(*pClone);
326 : :
327 : 0 : return pClone;
328 : : }
329 : :
330 : 66 : ControlModelContainerBase::UnoControlModelHolderList::iterator ControlModelContainerBase::ImplFindElement( const ::rtl::OUString& rName )
331 : : {
332 [ + - ]: 66 : return ::std::find_if( maModels.begin(), maModels.end(), FindControlModel( rName ) );
333 : : }
334 : :
335 : : // ::XMultiServiceFactory
336 : 76 : Reference< XInterface > ControlModelContainerBase::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(Exception, RuntimeException)
337 : : {
338 [ + - ]: 76 : SolarMutexGuard aGuard;
339 : :
340 : 76 : OGeometryControlModel_Base* pNewModel = NULL;
341 : :
342 [ + - ]: 76 : const Reference< XMultiServiceFactory > xFactory( maContext.getLegacyServiceFactory() );
343 [ + + ]: 76 : if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlEditModel ) == 0 )
344 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlEditModel >( xFactory );
345 [ + + ]: 74 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFormattedFieldModel ) == 0 )
346 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlFormattedFieldModel >( xFactory );
347 [ + + ]: 72 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFileControlModel ) == 0 )
348 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlFileControlModel >( xFactory );
349 [ + + ]: 70 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlButtonModel ) == 0 )
350 [ + - ]: 8 : pNewModel = new OGeometryControlModel< UnoControlButtonModel >( xFactory );
351 [ + + ]: 62 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlImageControlModel ) == 0 )
352 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlImageControlModel >( xFactory );
353 [ + + ]: 60 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlRadioButtonModel ) == 0 )
354 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlRadioButtonModel >( xFactory );
355 [ + + ]: 58 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlCheckBoxModel ) == 0 )
356 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlCheckBoxModel >( xFactory );
357 [ - + ]: 56 : else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlFixedHyperlinkModel ) == 0 )
358 [ # # ]: 0 : pNewModel = new OGeometryControlModel< UnoControlFixedHyperlinkModel >( xFactory );
359 [ - + ]: 56 : else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlFixedTextModel ) == 0 )
360 [ # # ]: 0 : pNewModel = new OGeometryControlModel< UnoControlFixedTextModel >( xFactory );
361 [ + + ]: 56 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlGroupBoxModel ) == 0 )
362 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlGroupBoxModel >( xFactory );
363 [ + + ]: 54 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlListBoxModel ) == 0 )
364 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlListBoxModel >( xFactory );
365 [ + + ]: 52 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlComboBoxModel ) == 0 )
366 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlComboBoxModel >( xFactory );
367 [ + + ]: 50 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlDateFieldModel ) == 0 )
368 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlDateFieldModel >( xFactory );
369 [ + + ]: 48 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlTimeFieldModel ) == 0 )
370 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlTimeFieldModel >( xFactory );
371 [ + + ]: 46 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlNumericFieldModel ) == 0 )
372 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlNumericFieldModel >( xFactory );
373 [ + + ]: 44 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlCurrencyFieldModel ) == 0 )
374 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlCurrencyFieldModel >( xFactory );
375 [ + + ]: 42 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlPatternFieldModel ) == 0 )
376 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlPatternFieldModel >( xFactory );
377 [ + + ]: 40 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlProgressBarModel ) == 0 )
378 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlProgressBarModel >( xFactory );
379 [ + + ]: 38 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlScrollBarModel ) == 0 )
380 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlScrollBarModel >( xFactory );
381 [ + + ]: 36 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFixedLineModel ) == 0 )
382 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlFixedLineModel >( xFactory );
383 [ + + ]: 34 : else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlRoadmapModel ) == 0 )
384 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlRoadmapModel >( xFactory );
385 [ + + ]: 32 : else if ( aServiceSpecifier.compareToAscii( szServiceName_TreeControlModel ) == 0 )
386 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoTreeModel >( xFactory );
387 [ + + ]: 30 : else if ( aServiceSpecifier.compareToAscii( szServiceName_GridControlModel ) == 0 )
388 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoGridModel >( xFactory );
389 [ + + ]: 28 : else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlTabPageContainerModel ) == 0 )
390 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoControlTabPageContainerModel >( xFactory );
391 [ + + ]: 26 : else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoMultiPageModel ) == 0 )
392 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoMultiPageModel >( xFactory );
393 [ - + ]: 24 : else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoPageModel ) == 0 )
394 [ # # ]: 0 : pNewModel = new OGeometryControlModel< UnoPageModel >( xFactory );
395 [ + + ]: 24 : else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoFrameModel ) == 0 )
396 [ + - ]: 2 : pNewModel = new OGeometryControlModel< UnoFrameModel >( xFactory );
397 : :
398 [ + + ]: 76 : if ( !pNewModel )
399 : : {
400 [ + - ]: 22 : if ( xFactory.is() )
401 : : {
402 [ + - ][ + - ]: 22 : Reference< XInterface > xObject = xFactory->createInstance( aServiceSpecifier );
403 [ + - ]: 22 : Reference< XServiceInfo > xSI( xObject, UNO_QUERY );
404 [ + - ]: 22 : Reference< XCloneable > xCloneAccess( xSI, UNO_QUERY );
405 [ + - ]: 22 : Reference< XAggregation > xAgg( xCloneAccess, UNO_QUERY );
406 [ + - ]: 22 : if ( xAgg.is() )
407 : : {
408 [ + - ][ + - ]: 22 : if ( xSI->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlModel"))) )
[ + - ][ + - ]
409 : : {
410 : : // release 3 of the 4 references we have to the object
411 : 22 : xAgg.clear();
412 : 22 : xSI.clear();
413 : 22 : xObject.clear();
414 : :
415 [ + - ]: 22 : pNewModel = new OCommonGeometryControlModel( xCloneAccess, aServiceSpecifier );
416 : : }
417 : 22 : }
418 : : }
419 : : }
420 : :
421 [ + - ][ + - ]: 76 : Reference< XInterface > xNewModel = (::cppu::OWeakObject*)pNewModel;
422 [ + - ]: 76 : return xNewModel;
423 : : }
424 : :
425 : 0 : Reference< XInterface > ControlModelContainerBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /* Arguments */ ) throw(Exception, RuntimeException)
426 : : {
427 : 0 : return createInstance( ServiceSpecifier );
428 : : }
429 : :
430 : 2 : Sequence< ::rtl::OUString > ControlModelContainerBase::getAvailableServiceNames() throw(RuntimeException)
431 : : {
432 : : static Sequence< ::rtl::OUString >* pNamesSeq = NULL;
433 [ + - ]: 2 : if ( !pNamesSeq )
434 : : {
435 [ + - ]: 2 : pNamesSeq = new Sequence< ::rtl::OUString >( 26 );
436 : 2 : ::rtl::OUString* pNames = pNamesSeq->getArray();
437 : 2 : pNames[0] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlEditModel );
438 : 2 : pNames[1] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFormattedFieldModel );
439 : 2 : pNames[2] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFileControlModel );
440 : 2 : pNames[3] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlButtonModel );
441 : 2 : pNames[4] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlImageControlModel );
442 : 2 : pNames[5] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRadioButtonModel );
443 : 2 : pNames[6] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlCheckBoxModel );
444 : 2 : pNames[7] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedTextModel );
445 : 2 : pNames[8] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlGroupBoxModel );
446 : 2 : pNames[9] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlListBoxModel );
447 : 2 : pNames[10] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlComboBoxModel );
448 : 2 : pNames[11] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlDateFieldModel );
449 : 2 : pNames[12] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlTimeFieldModel );
450 : 2 : pNames[13] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlNumericFieldModel );
451 : 2 : pNames[14] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlCurrencyFieldModel );
452 : 2 : pNames[15] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlPatternFieldModel );
453 : 2 : pNames[16] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlProgressBarModel );
454 : 2 : pNames[17] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlScrollBarModel );
455 : 2 : pNames[18] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedLineModel );
456 : 2 : pNames[19] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRoadmapModel );
457 : 2 : pNames[20] = ::rtl::OUString::createFromAscii( szServiceName_TreeControlModel );
458 : 2 : pNames[21] = ::rtl::OUString::createFromAscii( szServiceName_GridControlModel );
459 : 2 : pNames[22] = ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainerModel );
460 : 2 : pNames[23] = ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageModel );
461 : 2 : pNames[24] = ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
462 : 2 : pNames[25] = ::rtl::OUString::createFromAscii( szServiceName_UnoFrameModel );
463 : : }
464 : 2 : return *pNamesSeq;
465 : : }
466 : :
467 : : // XContainer
468 : 10 : void ControlModelContainerBase::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException)
469 : : {
470 : 10 : maContainerListeners.addInterface( l );
471 : 10 : }
472 : :
473 : 4 : void ControlModelContainerBase::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException)
474 : : {
475 : 4 : maContainerListeners.removeInterface( l );
476 : 4 : }
477 : :
478 : : // XElementAcces
479 : 2 : Type ControlModelContainerBase::getElementType() throw(RuntimeException)
480 : : {
481 : 2 : Type aType = getCppuType( ( Reference< XControlModel>* ) NULL );
482 : 2 : return aType;
483 : : }
484 : :
485 : 2 : sal_Bool ControlModelContainerBase::hasElements() throw(RuntimeException)
486 : : {
487 : 2 : return !maModels.empty();
488 : : }
489 : :
490 : : // XNameContainer, XNameReplace, XNameAccess
491 : 8 : void ControlModelContainerBase::replaceByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
492 : : {
493 [ + - ]: 8 : SolarMutexGuard aGuard;
494 : :
495 : 8 : Reference< XControlModel > xNewModel;
496 [ + - ]: 8 : aElement >>= xNewModel;
497 [ - + ]: 8 : if ( !xNewModel.is() )
498 [ # # ]: 0 : lcl_throwIllegalArgumentException();
499 : :
500 [ + - ]: 8 : UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName );
501 [ - + ]: 8 : if ( maModels.end() == aElementPos )
502 [ # # ]: 0 : lcl_throwNoSuchElementException();
503 : : // Dialog behaviour is to have all containee names unique ( MSO Userform is the same )
504 : : // With container controls you could have constructed an existing hierachy and are now
505 : : // add this to an existing container, in this case a name nested in the containment
506 : : // hierachy of the added control could contain a name clash, if we have access to the
507 : : // list of global names then recursively check for previously existing names ( we need
508 : : // to do this obviously before the 'this' objects container is updated
509 [ + - ][ + - ]: 8 : Reference< XNameContainer > xAllChildren( getPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ) ), UNO_QUERY );
[ + - ]
510 [ + - ]: 8 : if ( xAllChildren.is() )
511 : : {
512 : : // remove old control ( and children ) from global list of containees
513 [ + - ]: 8 : updateUserFormChildren( xAllChildren, aName, Remove, uno::Reference< XControlModel >() );
514 : : // Add new control ( and containees if they exist )
515 [ + - ]: 8 : updateUserFormChildren( xAllChildren, aName, Insert, xNewModel );
516 : : }
517 : : // stop listening at the old model
518 [ + - ]: 8 : stopControlListening( aElementPos->first );
519 : 8 : Reference< XControlModel > xReplaced( aElementPos->first );
520 : : // remember the new model, and start listening
521 [ + - ]: 8 : aElementPos->first = xNewModel;
522 [ + - ]: 8 : startControlListening( xNewModel );
523 : :
524 [ + - ]: 8 : ContainerEvent aEvent;
525 [ + - ][ + - ]: 8 : aEvent.Source = *this;
526 : 8 : aEvent.Element = aElement;
527 [ + - ]: 8 : aEvent.ReplacedElement <<= xReplaced;
528 [ + - ]: 8 : aEvent.Accessor <<= aName;
529 : :
530 : : // notify the container listener
531 [ + - ]: 8 : maContainerListeners.elementReplaced( aEvent );
532 : :
533 : : // our "tab controller model" has potentially changed -> notify this
534 [ + - ][ + - ]: 8 : implNotifyTabModelChange( aName );
[ + - ]
535 : 8 : }
536 : :
537 : 22 : Any ControlModelContainerBase::getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
538 : : {
539 [ + - ]: 22 : UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName );
540 [ + + ]: 22 : if ( maModels.end() == aElementPos )
541 [ - + ]: 2 : lcl_throwNoSuchElementException();
542 : :
543 [ + - ]: 22 : return makeAny( aElementPos->first );
544 : : }
545 : :
546 : 26 : Sequence< ::rtl::OUString > ControlModelContainerBase::getElementNames() throw(RuntimeException)
547 : : {
548 : 26 : Sequence< ::rtl::OUString > aNames( maModels.size() );
549 : :
550 : : ::std::transform(
551 : : maModels.begin(), maModels.end(), // source range
552 : : aNames.getArray(), // target range
553 : : ::boost::bind( &UnoControlModelHolder::second, _1 ) // operator to apply: select the second element (the name)
554 [ + - ][ + - ]: 26 : );
[ + - ]
555 : :
556 : 26 : return aNames;
557 : : }
558 : :
559 : 8 : sal_Bool ControlModelContainerBase::hasByName( const ::rtl::OUString& aName ) throw(RuntimeException)
560 : : {
561 : 8 : return maModels.end() != ImplFindElement( aName );
562 : : }
563 : :
564 : 22 : void ControlModelContainerBase::insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
565 : : {
566 [ + - ]: 22 : SolarMutexGuard aGuard;
567 : :
568 : 22 : Reference< XControlModel > xM;
569 [ + - ]: 22 : aElement >>= xM;
570 : :
571 [ + + ]: 22 : if ( xM.is() )
572 : : {
573 [ + - ]: 20 : Reference< beans::XPropertySet > xProps( xM, UNO_QUERY );
574 [ + - ]: 20 : if ( xProps.is() )
575 : : {
576 : :
577 [ + - ][ + - ]: 20 : Reference< beans::XPropertySetInfo > xPropInfo = xProps.get()->getPropertySetInfo();
578 : :
579 [ + - ]: 20 : ::rtl::OUString sImageSourceProperty = GetPropertyName( BASEPROPERTY_IMAGEURL );
580 [ + - ][ + + ]: 20 : if ( xPropInfo.get()->hasPropertyByName( sImageSourceProperty ) && ImplHasProperty(BASEPROPERTY_DIALOGSOURCEURL) )
[ + - ][ + - ]
[ + + ][ + - ]
581 : : {
582 [ + - ][ + - ]: 6 : Any aUrl = xProps.get()->getPropertyValue( sImageSourceProperty );
583 : :
584 : : ::rtl::OUString absoluteUrl =
585 [ + - ][ + - ]: 6 : getPhysicalLocation( getPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL ) ), aUrl );
[ + - ]
586 : :
587 [ + - ]: 6 : aUrl <<= absoluteUrl;
588 : :
589 [ + - ][ + - ]: 6 : xProps.get()->setPropertyValue( sImageSourceProperty , aUrl );
590 : 20 : }
591 : 20 : }
592 : : }
593 : :
594 : :
595 : :
596 [ + - ][ + + ]: 22 : if ( aName.isEmpty() || !xM.is() )
[ + + ]
597 [ - + ]: 2 : lcl_throwIllegalArgumentException();
598 : :
599 [ + - ]: 20 : UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName );
600 [ + + ]: 20 : if ( maModels.end() != aElementPos )
601 [ - + ]: 2 : lcl_throwElementExistException();
602 : :
603 : : // Dialog behaviour is to have all containee names unique ( MSO Userform is the same )
604 : : // With container controls you could have constructed an existing hierachy and are now
605 : : // add this to an existing container, in this case a name nested in the containment
606 : : // hierachy of the added control could contain a name clash, if we have access to the
607 : : // list of global names then we need to recursively check for previously existing
608 : : // names ( we need to do this obviously before the 'this' objects container is updated
609 : : // remove old control ( and children ) from global list of containees
610 [ + - ][ + - ]: 18 : Reference< XNameContainer > xAllChildren( getPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ) ), UNO_QUERY );
[ + - ]
611 : :
612 [ + - ]: 18 : if ( xAllChildren.is() )
613 [ + - ]: 18 : updateUserFormChildren( xAllChildren, aName, Insert, xM );
614 [ + - ][ + - ]: 18 : maModels.push_back( UnoControlModelHolder( xM, aName ) );
[ + - ]
615 : 18 : mbGroupsUpToDate = sal_False;
616 [ + - ]: 18 : startControlListening( xM );
617 : :
618 [ + - ]: 18 : ContainerEvent aEvent;
619 [ + - ][ + - ]: 18 : aEvent.Source = *this;
620 [ + - ]: 18 : aEvent.Element <<= aElement;
621 [ + - ]: 18 : aEvent.Accessor <<= aName;
622 [ + - ]: 18 : maContainerListeners.elementInserted( aEvent );
623 : :
624 : : // our "tab controller model" has potentially changed -> notify this
625 [ + - ][ + - ]: 22 : implNotifyTabModelChange( aName );
[ + - ]
626 : 18 : }
627 : :
628 : 8 : void ControlModelContainerBase::removeByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
629 : : {
630 [ + - ]: 8 : SolarMutexGuard aGuard;
631 : :
632 [ + - ]: 8 : UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName );
633 [ + + ]: 8 : if ( maModels.end() == aElementPos )
634 [ - + ]: 2 : lcl_throwNoSuchElementException();
635 : :
636 : : // Dialog behaviour is to have all containee names unique ( MSO Userform is the same )
637 : : // With container controls you could have constructed an existing hierachy and are now
638 : : // removing this control from an existing container, in this case all nested names in
639 : : // the containment hierachy of the control to be removed need to be removed from the global
640 : : // names cache ( we need to do this obviously before the 'this' objects container is updated )
641 [ + - ][ + - ]: 6 : Reference< XNameContainer > xAllChildren( getPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ) ), UNO_QUERY );
[ + - ]
642 [ + - ]: 6 : if ( xAllChildren.is() )
643 [ + - ]: 6 : updateUserFormChildren( xAllChildren, aName, Remove, uno::Reference< XControlModel >() );
644 : :
645 [ + - ]: 6 : ContainerEvent aEvent;
646 [ + - ][ + - ]: 6 : aEvent.Source = *this;
647 [ + - ]: 6 : aEvent.Element <<= aElementPos->first;
648 [ + - ]: 6 : aEvent.Accessor <<= aName;
649 [ + - ]: 6 : maContainerListeners.elementRemoved( aEvent );
650 : :
651 [ + - ]: 6 : stopControlListening( aElementPos->first );
652 [ + - ]: 6 : Reference< XPropertySet > xPS( aElementPos->first, UNO_QUERY );
653 [ + - ]: 6 : maModels.erase( aElementPos );
654 : 6 : mbGroupsUpToDate = sal_False;
655 : :
656 [ + - ]: 6 : if ( xPS.is() )
657 : : {
658 : : try
659 : : {
660 [ + - ][ + - ]: 6 : xPS->setPropertyValue( PROPERTY_RESOURCERESOLVER, makeAny( Reference< resource::XStringResourceResolver >() ) );
[ + - ][ + - ]
[ # # ]
661 : : }
662 [ # # ]: 0 : catch (const Exception&)
663 : : {
664 : : DBG_UNHANDLED_EXCEPTION();
665 : : }
666 : : }
667 : :
668 : : // our "tab controller model" has potentially changed -> notify this
669 [ + - ][ + - ]: 8 : implNotifyTabModelChange( aName );
[ + - ]
670 : 6 : }
671 : :
672 : : // ----------------------------------------------------------------------------
673 : 2 : sal_Bool SAL_CALL ControlModelContainerBase::getGroupControl( ) throw (RuntimeException)
674 : : {
675 : 2 : return sal_True;
676 : : }
677 : :
678 : : // ----------------------------------------------------------------------------
679 : 0 : void SAL_CALL ControlModelContainerBase::setGroupControl( sal_Bool ) throw (RuntimeException)
680 : : {
681 : : OSL_TRACE( "UnoControlDialogModel::setGroupControl: explicit grouping not supported" );
682 : 0 : }
683 : :
684 : : // ----------------------------------------------------------------------------
685 : 0 : void SAL_CALL ControlModelContainerBase::setControlModels( const Sequence< Reference< XControlModel > >& _rControls ) throw (RuntimeException)
686 : : {
687 [ # # ]: 0 : SolarMutexGuard aGuard;
688 : :
689 : : // set the tab indexes according to the order of models in the sequence
690 : 0 : const Reference< XControlModel >* pControls = _rControls.getConstArray( );
691 : 0 : const Reference< XControlModel >* pControlsEnd = _rControls.getConstArray( ) + _rControls.getLength();
692 : :
693 : 0 : sal_Int16 nTabIndex = 1;
694 : :
695 [ # # ]: 0 : for ( ; pControls != pControlsEnd; ++pControls )
696 : : {
697 : : // look up the control in our own structure. This is to prevent invalid arguments
698 : : UnoControlModelHolderList::const_iterator aPos =
699 : : ::std::find_if(
700 : : maModels.begin(), maModels.end(),
701 : : CompareControlModel( *pControls )
702 [ # # ][ # # ]: 0 : );
[ # # ]
703 [ # # ]: 0 : if ( maModels.end() != aPos )
704 : : {
705 : : // okay, this is an existent model
706 : : // now set the TabIndex property (if applicable)
707 [ # # ]: 0 : Reference< XPropertySet > xProps( aPos->first, UNO_QUERY );
708 : 0 : Reference< XPropertySetInfo > xPSI;
709 [ # # ]: 0 : if ( xProps.is() )
710 [ # # ][ # # ]: 0 : xPSI = xProps->getPropertySetInfo();
[ # # ]
711 [ # # ][ # # ]: 0 : if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) )
[ # # ][ # # ]
[ # # ][ # # ]
712 [ # # ][ # # ]: 0 : xProps->setPropertyValue( getTabIndexPropertyName(), makeAny( nTabIndex++ ) );
[ # # ][ # # ]
713 : : }
714 : 0 : mbGroupsUpToDate = sal_False;
715 [ # # ]: 0 : }
716 : 0 : }
717 : :
718 : :
719 : : typedef ::std::multimap< sal_Int32, Reference< XControlModel >, ::std::less< sal_Int32 > > MapIndexToModel;
720 : :
721 : : // ----------------------------------------------------------------------------
722 : 6 : Sequence< Reference< XControlModel > > SAL_CALL ControlModelContainerBase::getControlModels( ) throw (RuntimeException)
723 : : {
724 [ + - ]: 6 : SolarMutexGuard aGuard;
725 : :
726 [ + - ]: 6 : MapIndexToModel aSortedModels;
727 : : // will be the sorted container of all models which have a tab index property
728 [ + - ]: 6 : ::std::vector< Reference< XControlModel > > aUnindexedModels;
729 : : // will be the container of all models which do not have a tab index property
730 : :
731 : 6 : UnoControlModelHolderList::const_iterator aLoop = maModels.begin();
732 [ - + ]: 6 : for ( ; aLoop != maModels.end(); ++aLoop )
733 : : {
734 : 0 : Reference< XControlModel > xModel( aLoop->first );
735 : :
736 : : // see if the model has a TabIndex property
737 [ # # ]: 0 : Reference< XPropertySet > xControlProps( xModel, UNO_QUERY );
738 : 0 : Reference< XPropertySetInfo > xPSI;
739 [ # # ]: 0 : if ( xControlProps.is() )
740 [ # # ][ # # ]: 0 : xPSI = xControlProps->getPropertySetInfo( );
[ # # ]
741 : : DBG_ASSERT( xPSI.is(), "UnoControlDialogModel::getControlModels: invalid child model!" );
742 : :
743 : : // has it?
744 [ # # ][ # # ]: 0 : if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) )
[ # # ][ # # ]
[ # # ][ # # ]
745 : : { // yes
746 : 0 : sal_Int32 nTabIndex = -1;
747 [ # # ][ # # ]: 0 : xControlProps->getPropertyValue( getTabIndexPropertyName() ) >>= nTabIndex;
[ # # ]
748 : :
749 [ # # ][ # # ]: 0 : aSortedModels.insert( MapIndexToModel::value_type( nTabIndex, xModel ) );
[ # # ]
750 : : }
751 [ # # ]: 0 : else if ( xModel.is() )
752 : : // no, it hasn't, but we have to include it, anyway
753 [ # # ]: 0 : aUnindexedModels.push_back( xModel );
754 : 0 : }
755 : :
756 : : // okay, here we have a container of all our models, sorted by tab index,
757 : : // plus a container of "unindexed" models
758 : : // -> merge them
759 [ + - ]: 6 : Sequence< Reference< XControlModel > > aReturn( aUnindexedModels.size() + aSortedModels.size() );
760 : : ::std::transform(
761 : : aSortedModels.begin(), aSortedModels.end(),
762 : : ::std::copy( aUnindexedModels.begin(), aUnindexedModels.end(), aReturn.getArray() ),
763 : : ::boost::bind( &MapIndexToModel::value_type::second, _1 )
764 [ + - ][ + - ]: 6 : );
[ + - ][ + - ]
765 : :
766 [ + - ]: 6 : return aReturn;
767 : : }
768 : :
769 : : // ----------------------------------------------------------------------------
770 : 0 : void SAL_CALL ControlModelContainerBase::setGroup( const Sequence< Reference< XControlModel > >&, const ::rtl::OUString& ) throw (RuntimeException)
771 : : {
772 : : // not supported. We have only implicit grouping:
773 : : // We only have a sequence of control models, and we _know_ (yes, that's a HACK relying on
774 : : // implementation details) that VCL does grouping according to the order of controls automatically
775 : : // At least VCL does this for all we're interested in: Radio buttons.
776 : : OSL_TRACE( "UnoControlDialogModel::setGroup: grouping not supported" );
777 : 0 : }
778 : :
779 : : ////----- XInitialization -------------------------------------------------------------------
780 : 0 : void SAL_CALL ControlModelContainerBase::initialize (const Sequence<Any>& rArguments) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
781 : : {
782 [ # # ]: 0 : if ( rArguments.getLength() == 1 )
783 : : {
784 : 0 : sal_Int16 nPageId = -1;
785 [ # # ]: 0 : if ( !( rArguments[ 0 ] >>= nPageId ))
786 [ # # ]: 0 : throw lang::IllegalArgumentException();
787 : 0 : m_nTabPageId = nPageId;
788 : : }
789 : : else
790 : 0 : m_nTabPageId = -1;
791 : 0 : }
792 : 0 : ::sal_Int16 SAL_CALL ControlModelContainerBase::getTabPageID() throw (::com::sun::star::uno::RuntimeException)
793 : : {
794 : 0 : return m_nTabPageId;
795 : : }
796 : 0 : ::sal_Bool SAL_CALL ControlModelContainerBase::getEnabled() throw (::com::sun::star::uno::RuntimeException)
797 : : {
798 : 0 : return m_bEnabled;
799 : : }
800 : 0 : void SAL_CALL ControlModelContainerBase::setEnabled( ::sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException)
801 : : {
802 : 0 : m_bEnabled = _enabled;
803 : 0 : }
804 : 0 : ::rtl::OUString SAL_CALL ControlModelContainerBase::getTitle() throw (::com::sun::star::uno::RuntimeException)
805 : : {
806 [ # # ]: 0 : SolarMutexGuard aGuard;
807 [ # # ][ # # ]: 0 : Reference<XPropertySet> xThis(*this,UNO_QUERY);
808 : 0 : ::rtl::OUString sTitle;
809 [ # # ][ # # ]: 0 : xThis->getPropertyValue(GetPropertyName(BASEPROPERTY_TITLE)) >>= sTitle;
[ # # ]
810 [ # # ]: 0 : return sTitle;
811 : : //return m_sTitle;
812 : : }
813 : 0 : void SAL_CALL ControlModelContainerBase::setTitle( const ::rtl::OUString& _title ) throw (::com::sun::star::uno::RuntimeException)
814 : : {
815 [ # # ]: 0 : SolarMutexGuard aGuard;
816 [ # # ][ # # ]: 0 : Reference<XPropertySet> xThis(*this,UNO_QUERY);
817 [ # # ][ # # ]: 0 : xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_TITLE),makeAny(_title));
[ # # ][ # # ]
[ # # ]
818 : 0 : }
819 : 0 : ::rtl::OUString SAL_CALL ControlModelContainerBase::getImageURL() throw (::com::sun::star::uno::RuntimeException)
820 : : {
821 : 0 : return m_sImageURL;
822 : : }
823 : 0 : void SAL_CALL ControlModelContainerBase::setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException)
824 : : {
825 : 0 : m_sImageURL = _imageurl;
826 : 0 : }
827 : 0 : ::rtl::OUString SAL_CALL ControlModelContainerBase::getTooltip() throw (::com::sun::star::uno::RuntimeException)
828 : : {
829 : 0 : return m_sTooltip;
830 : : }
831 : 0 : void SAL_CALL ControlModelContainerBase::setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException)
832 : : {
833 : 0 : m_sTooltip = _tooltip;
834 : 0 : }
835 : :
836 : : // ----------------------------------------------------------------------------
837 : : namespace
838 : : {
839 : : enum GroupingMachineState
840 : : {
841 : : eLookingForGroup,
842 : : eExpandingGroup
843 : : };
844 : :
845 : : // ........................................................................
846 : 0 : static sal_Int32 lcl_getDialogStep( const Reference< XControlModel >& _rxModel )
847 : : {
848 : 0 : sal_Int32 nStep = 0;
849 : : try
850 : : {
851 [ # # ]: 0 : Reference< XPropertySet > xModelProps( _rxModel, UNO_QUERY );
852 [ # # ][ # # ]: 0 : xModelProps->getPropertyValue( getStepPropertyName() ) >>= nStep;
[ # # ][ # # ]
853 : : }
854 [ # # ]: 0 : catch (const Exception&)
855 : : {
856 : : OSL_TRACE( "lcl_getDialogStep: caught an exception while determining the dialog page!" );
857 : : }
858 : 0 : return nStep;
859 : : }
860 : : }
861 : :
862 : : // ----------------------------------------------------------------------------
863 : 2 : sal_Int32 SAL_CALL ControlModelContainerBase::getGroupCount( ) throw (RuntimeException)
864 : : {
865 [ + - ]: 2 : SolarMutexGuard aGuard;
866 : :
867 [ + - ]: 2 : implUpdateGroupStructure();
868 : :
869 [ + - ]: 2 : return maGroups.size();
870 : : }
871 : :
872 : : // ----------------------------------------------------------------------------
873 : 0 : void SAL_CALL ControlModelContainerBase::getGroup( sal_Int32 _nGroup, Sequence< Reference< XControlModel > >& _rGroup, ::rtl::OUString& _rName ) throw (RuntimeException)
874 : : {
875 [ # # ]: 0 : SolarMutexGuard aGuard;
876 : :
877 [ # # ]: 0 : implUpdateGroupStructure();
878 : :
879 [ # # ][ # # ]: 0 : if ( ( _nGroup < 0 ) || ( _nGroup >= (sal_Int32)maGroups.size() ) )
[ # # ]
880 : : {
881 : : OSL_TRACE( "UnoControlDialogModel::getGroup: invalid argument and I am not allowed to throw an exception!" );
882 [ # # ]: 0 : _rGroup.realloc( 0 );
883 : 0 : _rName = ::rtl::OUString();
884 : : }
885 : : else
886 : : {
887 [ # # ][ # # ]: 0 : AllGroups::const_iterator aGroupPos = maGroups.begin() + _nGroup;
888 [ # # ]: 0 : _rGroup.realloc( aGroupPos->size() );
889 : : // copy the models
890 [ # # ][ # # ]: 0 : ::std::copy( aGroupPos->begin(), aGroupPos->end(), _rGroup.getArray() );
891 : : // give the group a name
892 : 0 : _rName = ::rtl::OUString::valueOf( _nGroup );
893 [ # # ]: 0 : }
894 : 0 : }
895 : :
896 : : // ----------------------------------------------------------------------------
897 : 0 : void SAL_CALL ControlModelContainerBase::getGroupByName( const ::rtl::OUString& _rName, Sequence< Reference< XControlModel > >& _rGroup ) throw (RuntimeException)
898 : : {
899 [ # # ]: 0 : SolarMutexGuard aGuard;
900 : :
901 : 0 : ::rtl::OUString sDummyName;
902 [ # # ][ # # ]: 0 : getGroup( _rName.toInt32( ), _rGroup, sDummyName );
903 : 0 : }
904 : :
905 : : // ----------------------------------------------------------------------------
906 : 8 : void SAL_CALL ControlModelContainerBase::addChangesListener( const Reference< XChangesListener >& _rxListener ) throw (RuntimeException)
907 : : {
908 : 8 : maChangeListeners.addInterface( _rxListener );
909 : 8 : }
910 : :
911 : : // ----------------------------------------------------------------------------
912 : 2 : void SAL_CALL ControlModelContainerBase::removeChangesListener( const Reference< XChangesListener >& _rxListener ) throw (RuntimeException)
913 : : {
914 : 2 : maChangeListeners.removeInterface( _rxListener );
915 : 2 : }
916 : :
917 : : // ----------------------------------------------------------------------------
918 : 32 : void ControlModelContainerBase::implNotifyTabModelChange( const ::rtl::OUString& _rAccessor )
919 : : {
920 : : // multiplex to our change listeners:
921 : : // the changes event
922 [ + - ]: 32 : ChangesEvent aEvent;
923 [ + - ][ + - ]: 32 : aEvent.Source = *this;
924 [ + - ]: 32 : aEvent.Base <<= aEvent.Source; // the "base of the changes root" is also ourself
925 [ + - ]: 32 : aEvent.Changes.realloc( 1 ); // exactly one change
926 [ + - ][ + - ]: 32 : aEvent.Changes[ 0 ].Accessor <<= _rAccessor;
927 : :
928 : :
929 [ + - ]: 32 : Sequence< Reference< XInterface > > aChangeListeners( maChangeListeners.getElements() );
930 : 32 : const Reference< XInterface >* pListener = aChangeListeners.getConstArray();
931 : 32 : const Reference< XInterface >* pListenerEnd = aChangeListeners.getConstArray() + aChangeListeners.getLength();
932 [ + + ]: 52 : for ( ; pListener != pListenerEnd; ++pListener )
933 : : {
934 [ + - ]: 20 : if ( pListener->is() )
935 [ + - ][ + - ]: 20 : static_cast< XChangesListener* >( pListener->get() )->changesOccurred( aEvent );
936 [ + - ][ + - ]: 32 : }
937 : 32 : }
938 : :
939 : :
940 : : // ----------------------------------------------------------------------------
941 : 2 : void ControlModelContainerBase::implUpdateGroupStructure()
942 : : {
943 [ + - ]: 2 : if ( mbGroupsUpToDate )
944 : : // nothing to do
945 : 2 : return;
946 : :
947 : : // conditions for a group:
948 : : // * all elements of the group are radio buttons
949 : : // * all elements of the group are on the same dialog page
950 : : // * in the overall control order (determined by the tab index), all elements are subsequent
951 : :
952 : 2 : maGroups.clear();
953 : :
954 [ + - ]: 2 : Sequence< Reference< XControlModel > > aControlModels = getControlModels();
955 : 2 : const Reference< XControlModel >* pControlModels = aControlModels.getConstArray();
956 : 2 : const Reference< XControlModel >* pControlModelsEnd = pControlModels + aControlModels.getLength();
957 : :
958 : : // in extreme we have as much groups as controls
959 [ + - ]: 2 : maGroups.reserve( aControlModels.getLength() );
960 : :
961 : 2 : GroupingMachineState eState = eLookingForGroup; // the current state of our machine
962 : 2 : Reference< XServiceInfo > xModelSI; // for checking for a radion button
963 : 2 : AllGroups::iterator aCurrentGroup = maGroups.end(); // the group which we're currently building
964 : 2 : sal_Int32 nCurrentGroupStep = -1; // the step which all controls of the current group belong to
965 : : sal_Bool bIsRadioButton; // is it a radio button?
966 : :
967 : : #if OSL_DEBUG_LEVEL > 1
968 : : ::std::vector< ::rtl::OUString > aCurrentGroupLabels;
969 : : #endif
970 : :
971 [ - + ]: 2 : for ( ; pControlModels != pControlModelsEnd; ++pControlModels )
972 : : {
973 : : // we'll need this in every state
974 [ # # ][ # # ]: 0 : xModelSI = xModelSI.query( *pControlModels );
975 [ # # ][ # # ]: 0 : bIsRadioButton = xModelSI.is() && xModelSI->supportsService( ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRadioButtonModel ) );
[ # # ][ # # ]
[ # # ][ # # ]
976 : :
977 [ # # # ]: 0 : switch ( eState )
978 : : {
979 : : case eLookingForGroup:
980 : : {
981 [ # # ]: 0 : if ( !bIsRadioButton )
982 : : // this is no radio button -> still looking for the beginning of a group
983 : 0 : continue;
984 : : // the current model is a radio button
985 : : // -> we found the beginning of a new group
986 : : // create the place for this group
987 : 0 : size_t nGroups = maGroups.size();
988 [ # # ]: 0 : maGroups.resize( nGroups + 1 );
989 [ # # ]: 0 : aCurrentGroup = maGroups.begin() + nGroups;
990 : : // and add the (only, til now) member
991 [ # # ]: 0 : aCurrentGroup->push_back( *pControlModels );
992 : :
993 : : // get the step which all controls of this group now have to belong to
994 [ # # ]: 0 : nCurrentGroupStep = lcl_getDialogStep( *pControlModels );
995 : : // new state: looking for further members
996 : 0 : eState = eExpandingGroup;
997 : :
998 : : #if OSL_DEBUG_LEVEL > 1
999 : : Reference< XPropertySet > xModelProps( *pControlModels, UNO_QUERY );
1000 : : ::rtl::OUString sLabel;
1001 : : if ( xModelProps.is() && xModelProps->getPropertySetInfo().is() && xModelProps->getPropertySetInfo()->hasPropertyByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) ) )
1002 : : xModelProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) ) >>= sLabel;
1003 : : aCurrentGroupLabels.push_back( sLabel );
1004 : : #endif
1005 : : }
1006 : 0 : break;
1007 : :
1008 : : case eExpandingGroup:
1009 : : {
1010 [ # # ]: 0 : if ( !bIsRadioButton )
1011 : : { // no radio button -> the group is done
1012 : 0 : aCurrentGroup = maGroups.end();
1013 : 0 : eState = eLookingForGroup;
1014 : : #if OSL_DEBUG_LEVEL > 1
1015 : : aCurrentGroupLabels.clear();
1016 : : #endif
1017 : 0 : continue;
1018 : : }
1019 : :
1020 : : // it is a radio button - is it on the proper page?
1021 [ # # ]: 0 : const sal_Int32 nThisModelStep = lcl_getDialogStep( *pControlModels );
1022 [ # # ][ # # ]: 0 : if ( ( nThisModelStep == nCurrentGroupStep ) // the current button is on the same dialog page
1023 : : || ( 0 == nThisModelStep ) // the current button appears on all pages
1024 : : )
1025 : : {
1026 : : // -> it belongs to the same group
1027 [ # # ]: 0 : aCurrentGroup->push_back( *pControlModels );
1028 : : // state still is eExpandingGroup - we're looking for further elements
1029 : 0 : eState = eExpandingGroup;
1030 : :
1031 : : #if OSL_DEBUG_LEVEL > 1
1032 : : Reference< XPropertySet > xModelProps( *pControlModels, UNO_QUERY );
1033 : : ::rtl::OUString sLabel;
1034 : : if ( xModelProps.is() && xModelProps->getPropertySetInfo().is() && xModelProps->getPropertySetInfo()->hasPropertyByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) ) )
1035 : : xModelProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) ) >>= sLabel;
1036 : : aCurrentGroupLabels.push_back( sLabel );
1037 : : #endif
1038 : 0 : continue;
1039 : : }
1040 : :
1041 : : // it's a radio button, but on a different page
1042 : : // -> we open a new group for it
1043 : :
1044 : : // close the old group
1045 : 0 : aCurrentGroup = maGroups.end();
1046 : : #if OSL_DEBUG_LEVEL > 1
1047 : : aCurrentGroupLabels.clear();
1048 : : #endif
1049 : :
1050 : : // open a new group
1051 : 0 : size_t nGroups = maGroups.size();
1052 [ # # ]: 0 : maGroups.resize( nGroups + 1 );
1053 [ # # ]: 0 : aCurrentGroup = maGroups.begin() + nGroups;
1054 : : // and add the (only, til now) member
1055 [ # # ]: 0 : aCurrentGroup->push_back( *pControlModels );
1056 : :
1057 : 0 : nCurrentGroupStep = nThisModelStep;
1058 : :
1059 : : // state is the same: we still are looking for further elements of the current group
1060 : 0 : eState = eExpandingGroup;
1061 : : #if OSL_DEBUG_LEVEL > 1
1062 : : Reference< XPropertySet > xModelProps( *pControlModels, UNO_QUERY );
1063 : : ::rtl::OUString sLabel;
1064 : : if ( xModelProps.is() && xModelProps->getPropertySetInfo().is() && xModelProps->getPropertySetInfo()->hasPropertyByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) ) )
1065 : : xModelProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")) ) >>= sLabel;
1066 : : aCurrentGroupLabels.push_back( sLabel );
1067 : : #endif
1068 : : }
1069 : 0 : break;
1070 : : }
1071 : : }
1072 : :
1073 [ + - ]: 2 : mbGroupsUpToDate = sal_True;
1074 : : }
1075 : :
1076 : : // ----------------------------------------------------------------------------
1077 : 0 : void SAL_CALL ControlModelContainerBase::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
1078 : : {
1079 [ # # ]: 0 : SolarMutexGuard aGuard;
1080 : :
1081 : : DBG_ASSERT( 0 == _rEvent.PropertyName.compareToAscii( "TabIndex" ),
1082 : : "UnoControlDialogModel::propertyChange: not listening for this property!" );
1083 : :
1084 : : // the accessor for the changed element
1085 : 0 : ::rtl::OUString sAccessor;
1086 : : UnoControlModelHolderList::const_iterator aPos =
1087 : : ::std::find_if(
1088 : : maModels.begin(), maModels.end(),
1089 : : CompareControlModel( Reference< XControlModel >( _rEvent.Source, UNO_QUERY ) )
1090 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
1091 : : OSL_ENSURE( maModels.end() != aPos, "UnoControlDialogModel::propertyChange: don't know this model!" );
1092 [ # # ]: 0 : if ( maModels.end() != aPos )
1093 : 0 : sAccessor = aPos->second;
1094 : :
1095 : : // our groups are not up-to-date
1096 : 0 : mbGroupsUpToDate = sal_False;
1097 : :
1098 : : // notify
1099 [ # # ][ # # ]: 0 : implNotifyTabModelChange( sAccessor );
1100 : 0 : }
1101 : :
1102 : : // ----------------------------------------------------------------------------
1103 : 0 : void SAL_CALL ControlModelContainerBase::disposing( const EventObject& /*rEvent*/ ) throw (RuntimeException)
1104 : : {
1105 : 0 : }
1106 : :
1107 : : // ----------------------------------------------------------------------------
1108 : 26 : void ControlModelContainerBase::startControlListening( const Reference< XControlModel >& _rxChildModel )
1109 : : {
1110 [ + - ]: 26 : SolarMutexGuard aGuard;
1111 : :
1112 [ + - ]: 26 : Reference< XPropertySet > xModelProps( _rxChildModel, UNO_QUERY );
1113 : 26 : Reference< XPropertySetInfo > xPSI;
1114 [ + - ]: 26 : if ( xModelProps.is() )
1115 [ + - ][ + - ]: 26 : xPSI = xModelProps->getPropertySetInfo();
[ + - ]
1116 : :
1117 [ + - ][ + - ]: 26 : if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) )
[ + - ][ + - ]
[ + - ][ + - ]
1118 [ + - ][ + - ]: 26 : xModelProps->addPropertyChangeListener( getTabIndexPropertyName(), this );
[ + - ][ + - ]
[ + - ]
1119 : 26 : }
1120 : :
1121 : : // ----------------------------------------------------------------------------
1122 : 14 : void ControlModelContainerBase::stopControlListening( const Reference< XControlModel >& _rxChildModel )
1123 : : {
1124 [ + - ]: 14 : SolarMutexGuard aGuard;
1125 : :
1126 [ + - ]: 14 : Reference< XPropertySet > xModelProps( _rxChildModel, UNO_QUERY );
1127 : 14 : Reference< XPropertySetInfo > xPSI;
1128 [ + - ]: 14 : if ( xModelProps.is() )
1129 [ + - ][ + - ]: 14 : xPSI = xModelProps->getPropertySetInfo();
[ + - ]
1130 : :
1131 [ + - ][ + - ]: 14 : if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) )
[ + - ][ + - ]
[ + - ][ + - ]
1132 [ + - ][ + - ]: 14 : xModelProps->removePropertyChangeListener( getTabIndexPropertyName(), this );
[ + - ][ + - ]
[ + - ]
1133 : 14 : }
1134 : :
1135 : : // ============================================================================
1136 : : // = class ResourceListener
1137 : : // ============================================================================
1138 : :
1139 : 8 : ResourceListener::ResourceListener(
1140 : : const Reference< util::XModifyListener >& rListener ) :
1141 : : OWeakObject(),
1142 : : m_xListener( rListener ),
1143 [ + - ]: 8 : m_bListening( false )
1144 : : {
1145 : 8 : }
1146 : :
1147 [ + - ][ + - ]: 2 : ResourceListener::~ResourceListener()
1148 : : {
1149 [ - + ]: 4 : }
1150 : :
1151 : : // XInterface
1152 : 18 : Any SAL_CALL ResourceListener::queryInterface( const Type& rType )
1153 : : throw ( RuntimeException )
1154 : : {
1155 : : Any a = ::cppu::queryInterface(
1156 : : rType ,
1157 : : static_cast< XModifyListener* >( this ),
1158 [ + - ]: 18 : static_cast< XEventListener* >( this ));
1159 : :
1160 [ + - ]: 18 : if ( a.hasValue() )
1161 : 18 : return a;
1162 : :
1163 [ # # ]: 18 : return OWeakObject::queryInterface( rType );
1164 : : }
1165 : :
1166 : 60 : void SAL_CALL ResourceListener::acquire() throw ()
1167 : : {
1168 : 60 : OWeakObject::acquire();
1169 : 60 : }
1170 : :
1171 : 54 : void SAL_CALL ResourceListener::release() throw ()
1172 : : {
1173 : 54 : OWeakObject::release();
1174 : 54 : }
1175 : :
1176 : 16 : void ResourceListener::startListening(
1177 : : const Reference< resource::XStringResourceResolver >& rResource )
1178 : : {
1179 [ + - ]: 16 : Reference< util::XModifyBroadcaster > xModifyBroadcaster( rResource, UNO_QUERY );
1180 : :
1181 : : {
1182 : : // --- SAFE ---
1183 [ + - ]: 16 : ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
1184 : 16 : bool bListening( m_bListening );
1185 : 16 : bool bResourceSet( m_xResource.is() );
1186 [ + - ]: 16 : aGuard.clear();
1187 : : // --- SAFE ---
1188 : :
1189 [ - + ][ # # ]: 16 : if ( bListening && bResourceSet )
1190 [ # # ]: 0 : stopListening();
1191 : :
1192 : : // --- SAFE ---
1193 [ + - ]: 16 : aGuard.reset();
1194 [ + - ]: 16 : m_xResource = rResource;
1195 [ + - ][ + - ]: 16 : aGuard.clear();
1196 : : // --- SAFE ---
1197 : : }
1198 : :
1199 [ + - ]: 16 : Reference< util::XModifyListener > xThis( static_cast<OWeakObject*>( this ), UNO_QUERY );
1200 [ - + ]: 16 : if ( xModifyBroadcaster.is() )
1201 : : {
1202 : : try
1203 : : {
1204 [ # # ][ # # ]: 0 : xModifyBroadcaster->addModifyListener( xThis );
1205 : :
1206 : : // --- SAFE ---
1207 [ # # ]: 0 : ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
1208 [ # # ]: 0 : m_bListening = true;
1209 : : // --- SAFE ---
1210 : : }
1211 [ # # # ]: 0 : catch (const RuntimeException&)
1212 : : {
1213 : 0 : throw;
1214 : : }
1215 [ # # ]: 0 : catch (const Exception&)
1216 : : {
1217 : : }
1218 : 16 : }
1219 : 16 : }
1220 : :
1221 : 0 : void ResourceListener::stopListening()
1222 : : {
1223 : 0 : Reference< util::XModifyBroadcaster > xModifyBroadcaster;
1224 : :
1225 : : // --- SAFE ---
1226 [ # # ]: 0 : ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
1227 [ # # ][ # # ]: 0 : if ( m_bListening && m_xResource.is() )
[ # # ]
1228 [ # # ][ # # ]: 0 : xModifyBroadcaster = Reference< util::XModifyBroadcaster >( m_xResource, UNO_QUERY );
1229 [ # # ]: 0 : aGuard.clear();
1230 : : // --- SAFE ---
1231 : :
1232 [ # # ]: 0 : Reference< util::XModifyListener > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1233 [ # # ]: 0 : if ( xModifyBroadcaster.is() )
1234 : : {
1235 : : try
1236 : : {
1237 : : // --- SAFE ---
1238 [ # # ]: 0 : aGuard.reset();
1239 : 0 : m_bListening = false;
1240 : 0 : m_xResource.clear();
1241 [ # # ]: 0 : aGuard.clear();
1242 : : // --- SAFE ---
1243 : :
1244 [ # # ][ # # ]: 0 : xModifyBroadcaster->removeModifyListener( xThis );
1245 : : }
1246 [ # # # ]: 0 : catch (const RuntimeException&)
1247 : : {
1248 : 0 : throw;
1249 : : }
1250 [ # # ]: 0 : catch (const Exception&)
1251 : : {
1252 : : }
1253 [ # # ]: 0 : }
1254 : 0 : }
1255 : :
1256 : : // XModifyListener
1257 : 0 : void SAL_CALL ResourceListener::modified(
1258 : : const lang::EventObject& aEvent )
1259 : : throw ( RuntimeException )
1260 : : {
1261 : 0 : Reference< util::XModifyListener > xListener;
1262 : :
1263 : : // --- SAFE ---
1264 [ # # ]: 0 : ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
1265 [ # # ]: 0 : xListener = m_xListener;
1266 [ # # ]: 0 : aGuard.clear();
1267 : : // --- SAFE ---
1268 : :
1269 [ # # ]: 0 : if ( xListener.is() )
1270 : : {
1271 : : try
1272 : : {
1273 [ # # ][ # # ]: 0 : xListener->modified( aEvent );
1274 : : }
1275 [ # # # ]: 0 : catch (const RuntimeException&)
1276 : : {
1277 : 0 : throw;
1278 : : }
1279 [ # # ]: 0 : catch (const Exception&)
1280 : : {
1281 : : }
1282 [ # # ]: 0 : }
1283 : 0 : }
1284 : :
1285 : : // XEventListener
1286 : 2 : void SAL_CALL ResourceListener::disposing(
1287 : : const EventObject& Source )
1288 : : throw ( RuntimeException )
1289 : : {
1290 : 2 : Reference< lang::XEventListener > xListener;
1291 : 2 : Reference< resource::XStringResourceResolver > xResource;
1292 : :
1293 : : // --- SAFE ---
1294 [ + - ]: 2 : ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
1295 [ + - ]: 2 : Reference< XInterface > xIfacRes( m_xResource, UNO_QUERY );
1296 [ + - ]: 2 : Reference< XInterface > xIfacList( m_xListener, UNO_QUERY );
1297 [ + - ]: 2 : aGuard.clear();
1298 : : // --- SAFE ---
1299 : :
1300 [ + - ][ - + ]: 2 : if ( Source.Source == xIfacRes )
1301 : : {
1302 : : // --- SAFE ---
1303 [ # # ]: 0 : aGuard.reset();
1304 : 0 : m_bListening = false;
1305 [ # # ]: 0 : xResource = m_xResource;
1306 [ # # ][ # # ]: 0 : xListener = Reference< lang::XEventListener >( m_xListener, UNO_QUERY );
1307 : 0 : m_xResource.clear();
1308 [ # # ]: 0 : aGuard.clear();
1309 : : // --- SAFE ---
1310 : :
1311 [ # # ]: 0 : if ( xListener.is() )
1312 : : {
1313 : : try
1314 : : {
1315 [ # # ][ # # ]: 0 : xListener->disposing( Source );
1316 : : }
1317 [ # # # ]: 0 : catch (const RuntimeException&)
1318 : : {
1319 : 0 : throw;
1320 : : }
1321 [ # # ]: 0 : catch (const Exception&)
1322 : : {
1323 : : }
1324 : : }
1325 : : }
1326 [ + - ][ - + ]: 2 : else if ( Source.Source == xIfacList )
1327 : : {
1328 : : // --- SAFE ---
1329 [ # # ]: 0 : aGuard.reset();
1330 : 0 : m_bListening = false;
1331 [ # # ][ # # ]: 0 : xListener = Reference< lang::XEventListener >( m_xListener, UNO_QUERY );
1332 [ # # ]: 0 : xResource = m_xResource;
1333 : 0 : m_xResource.clear();
1334 : 0 : m_xListener.clear();
1335 [ # # ]: 0 : aGuard.clear();
1336 : : // --- SAFE ---
1337 : :
1338 : : // Remove ourself as listener from resource resolver
1339 [ # # ]: 0 : Reference< util::XModifyBroadcaster > xModifyBroadcaster( xResource, UNO_QUERY );
1340 [ # # ]: 0 : Reference< util::XModifyListener > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1341 [ # # ]: 0 : if ( xModifyBroadcaster.is() )
1342 : : {
1343 : : try
1344 : : {
1345 [ # # ][ # # ]: 0 : xModifyBroadcaster->removeModifyListener( xThis );
1346 : : }
1347 [ # # # ]: 0 : catch (const RuntimeException&)
1348 : : {
1349 : 0 : throw;
1350 : : }
1351 [ # # ]: 0 : catch (const Exception&)
1352 : : {
1353 : : }
1354 : 0 : }
1355 [ + - ]: 2 : }
1356 : 2 : }
1357 : :
1358 : : //===============================================================
1359 : : // ----------------------------------------------------
1360 : : // class DialogContainerControl
1361 : : // ----------------------------------------------------
1362 : 8 : ControlContainerBase::ControlContainerBase( const Reference< XMultiServiceFactory >& i_factory )
1363 : : :ContainerControl_IBase( i_factory )
1364 : : ,mbSizeModified(false)
1365 : 8 : ,mbPosModified(false)
1366 : : {
1367 : 8 : maComponentInfos.nWidth = 280;
1368 : 8 : maComponentInfos.nHeight = 400;
1369 : : mxListener = new ResourceListener( Reference< util::XModifyListener >(
1370 [ + - ][ + - ]: 8 : static_cast< OWeakObject* >( this ), UNO_QUERY ));
[ + - ]
1371 : 8 : }
1372 : :
1373 : 0 : ControlContainerBase::~ControlContainerBase()
1374 : : {
1375 [ # # ]: 0 : }
1376 : :
1377 : 0 : void ControlContainerBase::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException)
1378 : : {
1379 [ # # ]: 0 : SolarMutexGuard aGuard;
1380 [ # # ][ # # ]: 0 : UnoControlContainer::createPeer( rxToolkit, rParentPeer );
1381 : 0 : }
1382 : :
1383 : 26 : void ControlContainerBase::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName )
1384 : : {
1385 [ + - ]: 26 : Reference< XPropertySet > xP( rxModel, UNO_QUERY );
1386 : :
1387 : 26 : ::rtl::OUString aDefCtrl;
1388 [ + - ][ + - ]: 26 : xP->getPropertyValue( GetPropertyName( BASEPROPERTY_DEFAULTCONTROL ) ) >>= aDefCtrl;
[ + - ]
1389 : 26 : Reference < XControl > xCtrl;
1390 [ + - ]: 26 : maContext.createComponent( aDefCtrl, xCtrl );
1391 : :
1392 : : DBG_ASSERT( xCtrl.is(), "UnoDialogControl::ImplInsertControl: could not create the control!" );
1393 [ + - ]: 26 : if ( xCtrl.is() )
1394 : : {
1395 [ + - ][ + - ]: 26 : xCtrl->setModel( rxModel );
1396 [ + - ]: 26 : addControl( rName, xCtrl );
1397 : : // will implicitly call addingControl, where we can add the PropertiesChangeListener to the model
1398 : : // (which we formerly did herein)
1399 : : // 08.01.2001 - 96008 - fs@openoffice.org
1400 : :
1401 [ + - ]: 26 : ImplSetPosSize( xCtrl );
1402 : 26 : }
1403 : 26 : }
1404 : :
1405 : 14 : void ControlContainerBase::ImplRemoveControl( Reference< XControlModel >& rxModel )
1406 : : {
1407 [ + - ]: 14 : Sequence< Reference< XControl > > aControls = getControls();
1408 [ + - ]: 14 : Reference< XControl > xCtrl = StdTabController::FindControl( aControls, rxModel );
1409 [ + - ]: 14 : if ( xCtrl.is() )
1410 : : {
1411 [ + - ]: 14 : removeControl( xCtrl );
1412 : : try
1413 : : {
1414 [ + - ]: 14 : Reference< XComponent > const xControlComp( xCtrl, UNO_QUERY_THROW );
1415 [ + - ][ + - ]: 14 : xControlComp->dispose();
[ # # ]
1416 : : }
1417 [ # # ]: 0 : catch (const Exception&)
1418 : : {
1419 : : DBG_UNHANDLED_EXCEPTION();
1420 : : }
1421 [ + - ]: 14 : }
1422 : 14 : }
1423 : :
1424 : 78 : void ControlContainerBase::ImplSetPosSize( Reference< XControl >& rxCtrl )
1425 : : {
1426 [ + - ][ + - ]: 78 : Reference< XPropertySet > xP( rxCtrl->getModel(), UNO_QUERY );
[ + - ]
1427 : :
1428 : 78 : sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
1429 [ + - ][ + - ]: 78 : xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) ) >>= nX;
[ + - ]
1430 [ + - ][ + - ]: 78 : xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ) ) >>= nY;
[ + - ]
1431 [ + - ][ + - ]: 78 : xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) >>= nWidth;
[ + - ]
1432 [ + - ][ + - ]: 78 : xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) >>= nHeight;
[ + - ]
1433 [ + - ]: 78 : MapMode aMode( MAP_APPFONT );
1434 [ + - ]: 78 : OutputDevice*pOutDev = Application::GetDefaultDevice();
1435 [ + - ]: 78 : if ( pOutDev )
1436 : : {
1437 : 78 : ::Size aTmp( nX, nY );
1438 [ + - ]: 78 : aTmp = pOutDev->LogicToPixel( aTmp, aMode );
1439 : 78 : nX = aTmp.Width();
1440 : 78 : nY = aTmp.Height();
1441 : 78 : aTmp = ::Size( nWidth, nHeight );
1442 [ + - ]: 78 : aTmp = pOutDev->LogicToPixel( aTmp, aMode );
1443 : 78 : nWidth = aTmp.Width();
1444 : 78 : nHeight = aTmp.Height();
1445 : : }
1446 : : else
1447 : : {
1448 [ # # ]: 0 : Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True );
1449 [ # # ]: 0 : Reference< XDevice > xD( xPeer, UNO_QUERY );
1450 : :
1451 : 0 : SimpleFontMetric aFM;
1452 : 0 : FontDescriptor aFD;
1453 [ # # ][ # # ]: 0 : Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
1454 [ # # ]: 0 : aVal >>= aFD;
1455 [ # # ]: 0 : if ( !aFD.StyleName.isEmpty() )
1456 : : {
1457 [ # # ][ # # ]: 0 : Reference< XFont > xFont = xD->getFont( aFD );
1458 [ # # ][ # # ]: 0 : aFM = xFont->getFontMetric();
1459 : : }
1460 : : else
1461 : : {
1462 [ # # ][ # # ]: 0 : Reference< XGraphics > xG = xD->createGraphics();
1463 [ # # ][ # # ]: 0 : aFM = xG->getFontMetric();
1464 : : }
1465 : :
1466 : 0 : sal_Int16 nH = aFM.Ascent + aFM.Descent;
1467 : 0 : sal_Int16 nW = nH/2; // calculate avarage width?!
1468 : :
1469 : 0 : nX *= nW;
1470 : 0 : nX /= 4;
1471 : 0 : nWidth *= nW;
1472 : 0 : nWidth /= 4;
1473 : 0 : nY *= nH;
1474 : 0 : nY /= 8;
1475 : 0 : nHeight *= nH;
1476 : 0 : nHeight /= 8;
1477 : : }
1478 [ + - ]: 78 : Reference < XWindow > xW( rxCtrl, UNO_QUERY );
1479 [ + - ][ + - ]: 78 : xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
[ + - ]
1480 : 78 : }
1481 : :
1482 : 2 : void ControlContainerBase::dispose() throw(RuntimeException)
1483 : : {
1484 [ + - ]: 2 : EventObject aEvt;
1485 [ + - ]: 2 : aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
1486 : : // Notify our listener helper about dispose
1487 : : // --- SAFE ---
1488 : :
1489 [ + - ]: 2 : SolarMutexClearableGuard aGuard;
1490 [ + - ]: 2 : Reference< XEventListener > xListener( mxListener, UNO_QUERY );
1491 : 2 : mxListener.clear();
1492 [ + - ]: 2 : aGuard.clear();
1493 : : // --- SAFE ---
1494 : :
1495 [ + - ]: 2 : if ( xListener.is() )
1496 [ + - ][ + - ]: 2 : xListener->disposing( aEvt );
1497 [ + - ][ + - ]: 2 : UnoControlContainer::dispose();
[ + - ]
1498 : 2 : }
1499 : :
1500 : 4 : void SAL_CALL ControlContainerBase::disposing(
1501 : : const EventObject& Source )
1502 : : throw(RuntimeException)
1503 : : {
1504 : 4 : UnoControlContainer::disposing( Source );
1505 : 4 : }
1506 : :
1507 : 10 : sal_Bool ControlContainerBase::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException)
1508 : : {
1509 [ + - ]: 10 : SolarMutexGuard aGuard;
1510 : :
1511 : : // destroy the old tab controller, if existent
1512 [ + + ]: 10 : if ( mxTabController.is() )
1513 : : {
1514 [ + - ][ + - ]: 2 : mxTabController->setModel( NULL ); // just to be sure, should not be necessary
[ + - ]
1515 [ + - ]: 2 : removeTabController( mxTabController );
1516 [ + - ]: 2 : ::comphelper::disposeComponent( mxTabController ); // just to be sure, should not be necessary
1517 : 2 : mxTabController.clear();
1518 : : }
1519 : :
1520 [ + - ][ + + ]: 10 : if ( getModel().is() )
1521 : : {
1522 [ + - ]: 2 : Sequence< Reference< XControl > > aControls = getControls();
1523 : 2 : const Reference< XControl >* pCtrls = aControls.getConstArray();
1524 : 2 : const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength();
1525 : :
1526 [ - + ]: 2 : for ( ; pCtrls < pCtrlsEnd; ++pCtrls )
1527 [ # # ]: 0 : removeControl( *pCtrls );
1528 : : // will implicitly call removingControl, which will remove the PropertyChangeListener
1529 : : // (which we formerly did herein)
1530 : : // 08.01.2001 - 96008 - fs@openoffice.org
1531 : :
1532 [ + - ][ + - ]: 2 : Reference< XContainer > xC( getModel(), UNO_QUERY );
1533 [ + - ]: 2 : if ( xC.is() )
1534 [ + - ][ + - ]: 2 : xC->removeContainerListener( this );
[ + - ]
1535 : :
1536 [ + - ][ + - ]: 2 : Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY );
1537 [ + - ]: 2 : if ( xChangeNotifier.is() )
1538 [ + - ][ + - ]: 2 : xChangeNotifier->removeChangesListener( this );
[ + - ][ + - ]
1539 : : }
1540 : :
1541 [ + - ]: 10 : sal_Bool bRet = UnoControl::setModel( rxModel );
1542 : :
1543 [ + - ][ + + ]: 10 : if ( getModel().is() )
1544 : : {
1545 [ + - ][ + - ]: 8 : Reference< XNameAccess > xNA( getModel(), UNO_QUERY );
1546 [ + - ]: 8 : if ( xNA.is() )
1547 : : {
1548 [ + - ][ + - ]: 8 : Sequence< ::rtl::OUString > aNames = xNA->getElementNames();
1549 : 8 : const ::rtl::OUString* pNames = aNames.getConstArray();
1550 : 8 : sal_uInt32 nCtrls = aNames.getLength();
1551 : :
1552 : 8 : Reference< XControlModel > xCtrlModel;
1553 [ + + ]: 20 : for( sal_uInt32 n = 0; n < nCtrls; ++n, ++pNames )
1554 : : {
1555 [ + - ][ + - ]: 12 : xNA->getByName( *pNames ) >>= xCtrlModel;
[ + - ]
1556 [ + - ]: 12 : ImplInsertControl( xCtrlModel, *pNames );
1557 [ + - ]: 8 : }
1558 : : }
1559 : :
1560 [ + - ][ + - ]: 8 : Reference< XContainer > xC( getModel(), UNO_QUERY );
1561 [ + - ]: 8 : if ( xC.is() )
1562 [ + - ][ + - ]: 8 : xC->addContainerListener( this );
[ + - ]
1563 : :
1564 [ + - ][ + - ]: 8 : Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY );
1565 [ + - ]: 8 : if ( xChangeNotifier.is() )
1566 [ + - ][ + - ]: 8 : xChangeNotifier->addChangesListener( this );
[ + - ]
1567 : : }
1568 : :
1569 [ + - ][ + - ]: 10 : Reference< XTabControllerModel > xTabbing( getModel(), UNO_QUERY );
1570 [ + + ]: 10 : if ( xTabbing.is() )
1571 : : {
1572 [ + - ][ + - ]: 8 : mxTabController = new StdTabController;
1573 [ + - ][ + - ]: 8 : mxTabController->setModel( xTabbing );
1574 [ + - ]: 8 : addTabController( mxTabController );
1575 : : }
1576 [ + - ]: 10 : ImplStartListingForResourceEvents();
1577 : :
1578 [ + - ]: 10 : return bRet;
1579 : : }
1580 : 0 : void ControlContainerBase::setDesignMode( sal_Bool bOn ) throw(RuntimeException)
1581 : : {
1582 [ # # ]: 0 : SolarMutexGuard aGuard;
1583 : :
1584 [ # # ]: 0 : UnoControl::setDesignMode( bOn );
1585 : :
1586 [ # # ]: 0 : Sequence< Reference< XControl > > xCtrls = getControls();
1587 : 0 : sal_Int32 nControls = xCtrls.getLength();
1588 [ # # ]: 0 : Reference< XControl >* pControls = xCtrls.getArray();
1589 [ # # ]: 0 : for ( sal_Int32 n = 0; n < nControls; n++ )
1590 [ # # ][ # # ]: 0 : pControls[n]->setDesignMode( bOn );
1591 : :
1592 : : // #109067# in design mode the tab controller is not notified about
1593 : : // tab index changes, therefore the tab order must be activated
1594 : : // when switching from design mode to live mode
1595 [ # # ][ # # ]: 0 : if ( mxTabController.is() && !bOn )
[ # # ]
1596 [ # # ][ # # ]: 0 : mxTabController->activateTabOrder();
[ # # ][ # # ]
1597 : 0 : }
1598 : :
1599 : 6 : void ControlContainerBase::elementInserted( const ContainerEvent& Event ) throw(RuntimeException)
1600 : : {
1601 [ + - ]: 6 : SolarMutexGuard aGuard;
1602 : :
1603 : 6 : Reference< XControlModel > xModel;
1604 : 6 : ::rtl::OUString aName;
1605 : :
1606 : 6 : Event.Accessor >>= aName;
1607 [ + - ]: 6 : Event.Element >>= xModel;
1608 [ - + ]: 12 : ENSURE_OR_RETURN_VOID( xModel.is(), "UnoDialogControl::elementInserted: illegal element!" );
1609 : : try
1610 : : {
1611 [ + - ]: 6 : ImplInsertControl( xModel, aName );
1612 : : }
1613 [ # # # ]: 0 : catch (const RuntimeException&)
1614 : : {
1615 : 0 : throw;
1616 : : }
1617 [ # # ]: 0 : catch (const Exception&)
1618 : : {
1619 : : DBG_UNHANDLED_EXCEPTION();
1620 [ - + ][ - + ]: 6 : }
[ + - ][ + - ]
1621 : : }
1622 : :
1623 : 6 : void ControlContainerBase::elementRemoved( const ContainerEvent& Event ) throw(RuntimeException)
1624 : : {
1625 [ + - ]: 6 : SolarMutexGuard aGuard;
1626 : :
1627 : 6 : Reference< XControlModel > xModel;
1628 [ + - ]: 6 : Event.Element >>= xModel;
1629 [ - + ]: 12 : ENSURE_OR_RETURN_VOID( xModel.is(), "UnoDialogControl::elementRemoved: illegal element!" );
1630 : : try
1631 : : {
1632 [ + - ]: 6 : ImplRemoveControl( xModel );
1633 : : }
1634 [ # # # ]: 0 : catch (const RuntimeException&)
1635 : : {
1636 : 0 : throw;
1637 : : }
1638 [ # # ]: 0 : catch (const Exception&)
1639 : : {
1640 : : DBG_UNHANDLED_EXCEPTION();
1641 [ - + ][ + - ]: 6 : }
[ + - ]
1642 : : }
1643 : :
1644 : 8 : void ControlContainerBase::elementReplaced( const ContainerEvent& Event ) throw(RuntimeException)
1645 : : {
1646 [ + - ]: 8 : SolarMutexGuard aGuard;
1647 : :
1648 : 8 : Reference< XControlModel > xModel;
1649 [ + - ]: 8 : Event.ReplacedElement >>= xModel;
1650 : : try
1651 : : {
1652 : : OSL_ENSURE( xModel.is(), "UnoDialogControl::elementReplaced: invalid ReplacedElement!" );
1653 [ + - ]: 8 : if ( xModel.is() )
1654 [ + - ]: 8 : ImplRemoveControl( xModel );
1655 : : }
1656 [ # # # ]: 0 : catch (const RuntimeException&)
1657 : : {
1658 : 0 : throw;
1659 : : }
1660 [ # # ]: 0 : catch (const Exception&)
1661 : : {
1662 : : DBG_UNHANDLED_EXCEPTION();
1663 : : }
1664 : :
1665 : 8 : ::rtl::OUString aName;
1666 : 8 : Event.Accessor >>= aName;
1667 [ + - ]: 8 : Event.Element >>= xModel;
1668 [ - + ]: 16 : ENSURE_OR_RETURN_VOID( xModel.is(), "UnoDialogControl::elementReplaced: invalid new element!" );
1669 : : try
1670 : : {
1671 [ + - ]: 8 : ImplInsertControl( xModel, aName );
1672 : : }
1673 [ # # # ]: 0 : catch (const RuntimeException&)
1674 : : {
1675 : 0 : throw;
1676 : : }
1677 [ # # ]: 0 : catch (const Exception&)
1678 : : {
1679 : : DBG_UNHANDLED_EXCEPTION();
1680 [ - + ][ - + ]: 8 : }
[ + - ][ + - ]
1681 : : }
1682 : :
1683 : : // XPropertiesChangeListener
1684 : 364 : void ControlContainerBase::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException)
1685 : : {
1686 [ + - ][ + - ]: 364 : if( !isDesignMode() && !mbCreatingCompatiblePeer )
[ + - ]
1687 : : {
1688 [ + - ]: 364 : ::rtl::OUString s1( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) );
1689 [ + - ]: 364 : ::rtl::OUString s2( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) );
1690 [ + - ]: 364 : ::rtl::OUString s3( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
1691 [ + - ]: 364 : ::rtl::OUString s4( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
1692 : :
1693 : 364 : sal_Int32 nLen = rEvents.getLength();
1694 [ + + ]: 840 : for( sal_Int32 i = 0; i < nLen; i++ )
1695 : : {
1696 : 476 : const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
1697 [ + - ]: 476 : Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
1698 [ + - ][ + - ]: 476 : sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get();
[ + - ]
1699 [ + + ][ + + : 1832 : if ( ( rEvt.PropertyName == s1 ) ||
+ + + + +
+ ]
1700 : 464 : ( rEvt.PropertyName == s2 ) ||
1701 : 452 : ( rEvt.PropertyName == s3 ) ||
1702 : 440 : ( rEvt.PropertyName == s4 ) )
1703 : : {
1704 [ + - ]: 54 : if ( bOwnModel )
1705 : : {
1706 [ + - ][ + + ]: 54 : if ( !mbPosModified && !mbSizeModified )
1707 : : {
1708 : : // Don't set new pos/size if we get new values from window listener
1709 [ + - ]: 52 : Reference< XControl > xThis( (XAggregation*)(::cppu::OWeakAggObject*)this, UNO_QUERY );
1710 [ + - ]: 52 : ImplSetPosSize( xThis );
1711 : : }
1712 : : }
1713 : : else
1714 : : {
1715 [ # # ]: 0 : Sequence<Reference<XControl> > aControlSequence(getControls());
1716 [ # # ]: 0 : Reference<XControl> aControlRef( StdTabController::FindControl( aControlSequence, xModel ) );
1717 [ # # ][ # # ]: 476 : ImplSetPosSize( aControlRef );
1718 : : }
1719 : : break;
1720 : : }
1721 [ + + ]: 840 : }
1722 : : }
1723 : :
1724 : 364 : UnoControlContainer::ImplModelPropertiesChanged( rEvents );
1725 : 364 : }
1726 : :
1727 : 28 : void ControlContainerBase::addingControl( const Reference< XControl >& _rxControl )
1728 : : {
1729 [ + - ]: 28 : SolarMutexGuard aGuard;
1730 [ + - ]: 28 : UnoControlContainer::addingControl( _rxControl );
1731 : :
1732 [ + - ]: 28 : if ( _rxControl.is() )
1733 : : {
1734 [ + - ][ + - ]: 28 : Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY );
[ + - ]
1735 [ + - ]: 28 : if ( xProps.is() )
1736 : : {
1737 [ + - ]: 28 : Sequence< ::rtl::OUString > aNames( 4 );
1738 [ + - ]: 28 : ::rtl::OUString* pNames = aNames.getArray();
1739 [ + - ]: 28 : *pNames++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionX") );
1740 [ + - ]: 28 : *pNames++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionY") );
1741 [ + - ]: 28 : *pNames++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Width"));
1742 [ + - ]: 28 : *pNames++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Height"));
1743 : :
1744 [ + - ][ + - ]: 28 : xProps->addPropertiesChangeListener( aNames, this );
[ + - ][ + - ]
1745 : 28 : }
1746 [ + - ]: 28 : }
1747 : 28 : }
1748 : :
1749 : 16 : void ControlContainerBase::removingControl( const Reference< XControl >& _rxControl )
1750 : : {
1751 [ + - ]: 16 : SolarMutexGuard aGuard;
1752 [ + - ]: 16 : UnoControlContainer::removingControl( _rxControl );
1753 : :
1754 [ + - ]: 16 : if ( _rxControl.is() )
1755 : : {
1756 [ + - ][ + - ]: 16 : Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY );
[ + - ]
1757 [ + - ]: 16 : if ( xProps.is() )
1758 [ + - ][ + - ]: 16 : xProps->removePropertiesChangeListener( this );
[ + - ]
1759 [ + - ]: 16 : }
1760 : :
1761 : 16 : }
1762 : :
1763 : 20 : void SAL_CALL ControlContainerBase::changesOccurred( const ChangesEvent& ) throw (RuntimeException)
1764 : : {
1765 [ + - ]: 20 : SolarMutexGuard aGuard;
1766 : : // a tab controller model may have changed
1767 : :
1768 : : // #109067# in design mode don't notify the tab controller
1769 : : // about tab index changes
1770 [ + - ][ + - ]: 20 : if ( mxTabController.is() && !mbDesignMode )
[ + - ]
1771 [ + - ][ + - ]: 20 : mxTabController->activateTabOrder();
[ + - ]
1772 : 20 : }
1773 : 0 : void lcl_ApplyResolverToNestedContainees( const Reference< resource::XStringResourceResolver >& xStringResourceResolver, const Reference< XControlContainer >& xContainer )
1774 : : {
1775 [ # # ]: 0 : rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
1776 : :
1777 [ # # ]: 0 : Any xNewStringResourceResolver; xNewStringResourceResolver <<= xStringResourceResolver;
1778 : :
1779 [ # # ]: 0 : Sequence< rtl::OUString > aPropNames(1);
1780 [ # # ]: 0 : aPropNames[0] = aPropName;
1781 : :
1782 [ # # ][ # # ]: 0 : const Sequence< Reference< awt::XControl > > aSeq = xContainer->getControls();
1783 [ # # ]: 0 : for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
1784 : : {
1785 : 0 : Reference< XControl > xControl( aSeq[i] );
1786 : 0 : Reference< XPropertySet > xPropertySet;
1787 : :
1788 [ # # ]: 0 : if ( xControl.is() )
1789 [ # # ][ # # ]: 0 : xPropertySet = Reference< XPropertySet >( xControl->getModel(), UNO_QUERY );
[ # # ][ # # ]
1790 : :
1791 [ # # ]: 0 : if ( !xPropertySet.is() )
1792 : 0 : continue;
1793 : :
1794 : : try
1795 : : {
1796 : 0 : Reference< resource::XStringResourceResolver > xCurrStringResourceResolver;
1797 [ # # ][ # # ]: 0 : Any aOldValue = xPropertySet->getPropertyValue( aPropName );
1798 [ # # ][ # # ]: 0 : if ( ( aOldValue >>= xCurrStringResourceResolver )
[ # # ][ # # ]
1799 [ # # ]: 0 : && ( xStringResourceResolver == xCurrStringResourceResolver )
1800 : : )
1801 : : {
1802 [ # # ]: 0 : Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY );
1803 [ # # ]: 0 : Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY );
1804 [ # # ][ # # ]: 0 : xMultiPropSet->firePropertiesChangeEvent( aPropNames, xListener );
1805 : : }
1806 : : else
1807 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue( aPropName, xNewStringResourceResolver );
[ # # ]
1808 : : }
1809 [ # # ]: 0 : catch (const Exception&)
1810 : : {
1811 : : }
1812 : :
1813 [ # # ]: 0 : uno::Reference< XControlContainer > xNestedContainer( xControl, uno::UNO_QUERY );
1814 [ # # ]: 0 : if ( xNestedContainer.is() )
1815 [ # # ]: 0 : lcl_ApplyResolverToNestedContainees( xStringResourceResolver, xNestedContainer );
1816 : :
1817 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1818 : :
1819 : 0 : }
1820 : 20 : void ControlContainerBase::ImplStartListingForResourceEvents()
1821 : : {
1822 : 20 : Reference< resource::XStringResourceResolver > xStringResourceResolver;
1823 : :
1824 [ + - ][ + - ]: 20 : ImplGetPropertyValue( PROPERTY_RESOURCERESOLVER ) >>= xStringResourceResolver;
[ + - ]
1825 : :
1826 : : // Add our helper as listener to retrieve notifications about changes
1827 : 20 : Reference< util::XModifyListener > rListener( mxListener );
1828 [ + - ]: 20 : ResourceListener* pResourceListener = static_cast< ResourceListener* >( rListener.get() );
1829 : :
1830 : : // resource listener will stop listening if resolver reference is empty
1831 [ + + ]: 20 : if ( pResourceListener )
1832 [ + - ]: 16 : pResourceListener->startListening( xStringResourceResolver );
1833 [ + - ]: 20 : ImplUpdateResourceResolver();
1834 : 20 : }
1835 : :
1836 : 20 : void ControlContainerBase::ImplUpdateResourceResolver()
1837 : : {
1838 [ + - ]: 20 : rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER );
1839 : 20 : Reference< resource::XStringResourceResolver > xStringResourceResolver;
1840 : :
1841 [ + - ][ + - ]: 20 : ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver;
1842 [ + - ]: 20 : if ( !xStringResourceResolver.is() )
1843 : 20 : return;
1844 : :
1845 [ # # ][ # # ]: 0 : lcl_ApplyResolverToNestedContainees( xStringResourceResolver, this );
1846 : :
1847 : : // propagate resource resolver changes to language dependent props of the dialog
1848 [ # # ][ # # ]: 0 : Reference< XPropertySet > xPropertySet( getModel(), UNO_QUERY );
1849 [ # # ]: 0 : if ( xPropertySet.is() )
1850 : : {
1851 [ # # ]: 0 : Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY );
1852 [ # # ]: 0 : Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY );
1853 [ # # ][ # # ]: 0 : xMultiPropSet->firePropertiesChangeEvent( lcl_getLanguageDependentProperties(), xListener );
[ # # ]
1854 [ + - ][ - + ]: 20 : }
1855 : : }
1856 : :
1857 : : //// ----------------------------------------------------
1858 : : //// Helper Method to convert relative url to physical location
1859 : : //// ----------------------------------------------------
1860 : :
1861 : 10 : ::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl )
1862 : : {
1863 : :
1864 : 10 : ::rtl::OUString baseLocation;
1865 : 10 : ::rtl::OUString url;
1866 : :
1867 : 10 : rbase >>= baseLocation;
1868 : 10 : rUrl >>= url;
1869 : :
1870 : 10 : ::rtl::OUString absoluteURL( url );
1871 [ + + ]: 10 : if ( !url.isEmpty() )
1872 : : {
1873 [ + - ]: 4 : INetURLObject urlObj(baseLocation);
1874 [ + - ]: 4 : urlObj.removeSegment();
1875 [ + - ]: 4 : baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE );
1876 : :
1877 [ + - ]: 4 : const INetURLObject protocolCheck( url );
1878 : 4 : const INetProtocol protocol = protocolCheck.GetProtocol();
1879 [ + - ]: 4 : if ( protocol == INET_PROT_NOT_VALID )
1880 : : {
1881 : 4 : ::rtl::OUString testAbsoluteURL;
1882 [ - + ][ + - ]: 4 : if ( ::osl::FileBase::E_None == ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, testAbsoluteURL ) )
1883 : 4 : absoluteURL = testAbsoluteURL;
1884 [ + - ][ + - ]: 4 : }
1885 : : }
1886 : :
1887 : 10 : return absoluteURL;
1888 : : }
1889 : :
1890 : : void
1891 : 40 : ControlModelContainerBase::updateUserFormChildren( const Reference< XNameContainer >& xAllChildren, const rtl::OUString& aName, ChildOperation Operation, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xTarget ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
1892 : : {
1893 [ + - ][ - + ]: 40 : if ( Operation < Insert || Operation > Remove )
1894 [ # # ]: 0 : throw IllegalArgumentException();
1895 : :
1896 [ + - ]: 40 : if ( xAllChildren.is() )
1897 : : {
1898 [ + + ]: 40 : if ( Operation == Remove )
1899 : : {
1900 [ + - ][ + - ]: 14 : Reference< XControlModel > xOldModel( xAllChildren->getByName( aName ), UNO_QUERY );
[ + - ]
1901 [ + - ][ + - ]: 14 : xAllChildren->removeByName( aName );
1902 : :
1903 [ + - ]: 14 : Reference< XNameContainer > xChildContainer( xOldModel, UNO_QUERY );
1904 [ - + ]: 14 : if ( xChildContainer.is() )
1905 : : {
1906 [ # # ]: 0 : Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY );
1907 : : // container control is being removed from this container, reset the
1908 : : // global list of containees
1909 [ # # ]: 0 : if ( xProps.is() )
1910 [ # # ][ # # ]: 0 : xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( uno::Reference< XNameContainer >() ) );
[ # # ][ # # ]
1911 [ # # ][ # # ]: 0 : Sequence< rtl::OUString > aChildNames = xChildContainer->getElementNames();
1912 [ # # ]: 0 : for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index )
1913 [ # # ][ # # ]: 0 : updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, Reference< XControlModel > () );
[ # # ]
1914 : 14 : }
1915 : : }
1916 [ + - ]: 26 : else if ( Operation == Insert )
1917 : : {
1918 [ + - ][ + - ]: 26 : xAllChildren->insertByName( aName, uno::makeAny( xTarget ) );
[ + - ]
1919 [ + - ]: 26 : Reference< XNameContainer > xChildContainer( xTarget, UNO_QUERY );
1920 [ - + ]: 26 : if ( xChildContainer.is() )
1921 : : {
1922 : : // container control is being added from this container, reset the
1923 : : // global list of containees to point to the correct global list
1924 [ # # ]: 0 : Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY );
1925 [ # # ]: 0 : if ( xProps.is() )
1926 [ # # ][ # # ]: 0 : xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( xAllChildren ) );
[ # # ][ # # ]
1927 [ # # ][ # # ]: 0 : Sequence< rtl::OUString > aChildNames = xChildContainer->getElementNames();
1928 [ # # ]: 0 : for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index )
1929 : : {
1930 [ # # ][ # # ]: 0 : Reference< XControlModel > xChildTarget( xChildContainer->getByName( aChildNames[ index ] ), UNO_QUERY );
[ # # ][ # # ]
1931 [ # # ][ # # ]: 0 : updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, xChildTarget );
1932 [ # # ]: 0 : }
1933 : 26 : }
1934 : : }
1935 : : }
1936 : : else
1937 [ # # ]: 0 : throw IllegalArgumentException();
1938 [ + - ][ + - ]: 883 : }
1939 : :
1940 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|