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