1cdf0e10cSrcweir /************************************************************************* 2cdf0e10cSrcweir * 3cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir * 5cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir * 7cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir * 9cdf0e10cSrcweir * This file is part of OpenOffice.org. 10cdf0e10cSrcweir * 11cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14cdf0e10cSrcweir * 15cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir * 21cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25cdf0e10cSrcweir * 26cdf0e10cSrcweir ************************************************************************/ 27cdf0e10cSrcweir 28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef GCC 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <stdio.h> 35cdf0e10cSrcweir #include <tools/rcid.h> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <cstdarg> 38cdf0e10cSrcweir #include <sfx2/module.hxx> 39cdf0e10cSrcweir #include <sfx2/app.hxx> 40cdf0e10cSrcweir #include "arrdecl.hxx" 41cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 42cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 43cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx> 44cdf0e10cSrcweir #include "sfx2/stbitem.hxx" 45cdf0e10cSrcweir #include <sfx2/mnuitem.hxx> 46cdf0e10cSrcweir #include <sfx2/childwin.hxx> 47cdf0e10cSrcweir #include <sfx2/mnumgr.hxx> 48cdf0e10cSrcweir #include <sfx2/docfac.hxx> 49cdf0e10cSrcweir #include <sfx2/objface.hxx> 50cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 51cdf0e10cSrcweir #include <svl/intitem.hxx> 52cdf0e10cSrcweir #include "sfx2/taskpane.hxx" 53cdf0e10cSrcweir #include <tools/diagnose_ex.h> 54cdf0e10cSrcweir #include <rtl/strbuf.hxx> 55cdf0e10cSrcweir 56cdf0e10cSrcweir #define SfxModule 57cdf0e10cSrcweir #include "sfxslots.hxx" 58cdf0e10cSrcweir 59cdf0e10cSrcweir static SfxModuleArr_Impl* pModules=0; 60cdf0e10cSrcweir 61cdf0e10cSrcweir class SfxModule_Impl 62cdf0e10cSrcweir { 63cdf0e10cSrcweir public: 64cdf0e10cSrcweir 65cdf0e10cSrcweir SfxSlotPool* pSlotPool; 66cdf0e10cSrcweir SfxTbxCtrlFactArr_Impl* pTbxCtrlFac; 67cdf0e10cSrcweir SfxStbCtrlFactArr_Impl* pStbCtrlFac; 68cdf0e10cSrcweir SfxMenuCtrlFactArr_Impl* pMenuCtrlFac; 69cdf0e10cSrcweir SfxChildWinFactArr_Impl* pFactArr; 70cdf0e10cSrcweir ImageList* pImgListSmall; 71cdf0e10cSrcweir ImageList* pImgListBig; 72cdf0e10cSrcweir ImageList* pImgListHiSmall; 73cdf0e10cSrcweir ImageList* pImgListHiBig; 74cdf0e10cSrcweir 75cdf0e10cSrcweir SfxModule_Impl(); 76cdf0e10cSrcweir ~SfxModule_Impl(); 77cdf0e10cSrcweir ImageList* GetImageList( ResMgr*, sal_Bool, sal_Bool bHiContrast = sal_False ); 78cdf0e10cSrcweir }; 79cdf0e10cSrcweir 80cdf0e10cSrcweir SfxModule_Impl::SfxModule_Impl() 81cdf0e10cSrcweir : pSlotPool(0) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir SfxModule_Impl::~SfxModule_Impl() 86cdf0e10cSrcweir { 87cdf0e10cSrcweir delete pSlotPool; 88cdf0e10cSrcweir delete pTbxCtrlFac; 89cdf0e10cSrcweir delete pStbCtrlFac; 90cdf0e10cSrcweir delete pMenuCtrlFac; 91cdf0e10cSrcweir delete pFactArr; 92cdf0e10cSrcweir delete pImgListSmall; 93cdf0e10cSrcweir delete pImgListBig; 94cdf0e10cSrcweir delete pImgListHiSmall; 95cdf0e10cSrcweir delete pImgListHiBig; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, sal_Bool bBig, sal_Bool bHiContrast ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir ImageList*& rpList = bBig ? ( bHiContrast ? pImgListHiBig: pImgListBig ) : 101cdf0e10cSrcweir ( bHiContrast ? pImgListHiSmall : pImgListSmall ); 102cdf0e10cSrcweir if ( !rpList ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir ResId aResId( bBig ? ( bHiContrast ? RID_DEFAULTIMAGELIST_LCH : RID_DEFAULTIMAGELIST_LC ) : 105cdf0e10cSrcweir ( bHiContrast ? RID_DEFAULTIMAGELIST_SCH : RID_DEFAULTIMAGELIST_SC ), *pResMgr ); 106cdf0e10cSrcweir aResId.SetRT( RSC_IMAGELIST ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir DBG_ASSERT( pResMgr->IsAvailable(aResId), "No default ImageList!" ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir if ( pResMgr->IsAvailable(aResId) ) 111cdf0e10cSrcweir rpList = new ImageList( aResId ); 112cdf0e10cSrcweir else 113cdf0e10cSrcweir rpList = new ImageList(); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir return rpList; } 117cdf0e10cSrcweir 118cdf0e10cSrcweir TYPEINIT1(SfxModule, SfxShell); 119cdf0e10cSrcweir 120cdf0e10cSrcweir //========================================================================= 121cdf0e10cSrcweir 122cdf0e10cSrcweir SFX_IMPL_INTERFACE(SfxModule,SfxShell,SfxResId(0)) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir //==================================================================== 127cdf0e10cSrcweir 128cdf0e10cSrcweir ResMgr* SfxModule::GetResMgr() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir return pResMgr; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir //==================================================================== 134cdf0e10cSrcweir /* 135cdf0e10cSrcweir SfxModule::SfxModule( ResMgr* pMgrP, sal_Bool bDummyP, 136cdf0e10cSrcweir SfxObjectFactory* pFactoryP ) 137cdf0e10cSrcweir : pResMgr( pMgrP ), bDummy( bDummyP ), pImpl(0L) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir Construct_Impl(); 140cdf0e10cSrcweir if ( pFactoryP ) 141cdf0e10cSrcweir pFactoryP->SetModule_Impl( this ); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir */ 144cdf0e10cSrcweir SfxModule::SfxModule( ResMgr* pMgrP, sal_Bool bDummyP, 145cdf0e10cSrcweir SfxObjectFactory* pFactoryP, ... ) 146cdf0e10cSrcweir : pResMgr( pMgrP ), bDummy( bDummyP ), pImpl(0L) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir Construct_Impl(); 149cdf0e10cSrcweir va_list pVarArgs; 150cdf0e10cSrcweir va_start( pVarArgs, pFactoryP ); 151cdf0e10cSrcweir for ( SfxObjectFactory *pArg = pFactoryP; pArg; 152cdf0e10cSrcweir pArg = va_arg( pVarArgs, SfxObjectFactory* ) ) 153cdf0e10cSrcweir pArg->SetModule_Impl( this ); 154cdf0e10cSrcweir va_end(pVarArgs); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir void SfxModule::Construct_Impl() 158cdf0e10cSrcweir { 159cdf0e10cSrcweir if( !bDummy ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir SfxApplication *pApp = SFX_APP(); 162cdf0e10cSrcweir SfxModuleArr_Impl& rArr = GetModules_Impl(); 163cdf0e10cSrcweir SfxModule* pPtr = (SfxModule*)this; 164cdf0e10cSrcweir rArr.C40_INSERT( SfxModule, pPtr, rArr.Count() ); 165cdf0e10cSrcweir pImpl = new SfxModule_Impl; 166cdf0e10cSrcweir pImpl->pSlotPool = new SfxSlotPool( &pApp->GetAppSlotPool_Impl(), pResMgr ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir pImpl->pTbxCtrlFac=0; 169cdf0e10cSrcweir pImpl->pStbCtrlFac=0; 170cdf0e10cSrcweir pImpl->pMenuCtrlFac=0; 171cdf0e10cSrcweir pImpl->pFactArr=0; 172cdf0e10cSrcweir pImpl->pImgListSmall=0; 173cdf0e10cSrcweir pImpl->pImgListBig=0; 174cdf0e10cSrcweir pImpl->pImgListHiSmall=0; 175cdf0e10cSrcweir pImpl->pImgListHiBig=0; 176cdf0e10cSrcweir 177cdf0e10cSrcweir SetPool( &pApp->GetPool() ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir //==================================================================== 182cdf0e10cSrcweir 183cdf0e10cSrcweir SfxModule::~SfxModule() 184cdf0e10cSrcweir { 185cdf0e10cSrcweir if( !bDummy ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir if ( SFX_APP()->Get_Impl() ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir // Das Modul wird noch vor dem DeInitialize zerst"ort, also auis dem Array entfernen 190cdf0e10cSrcweir SfxModuleArr_Impl& rArr = GetModules_Impl(); 191cdf0e10cSrcweir for( sal_uInt16 nPos = rArr.Count(); nPos--; ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir if( rArr[ nPos ] == this ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir rArr.Remove( nPos ); 196cdf0e10cSrcweir break; 197cdf0e10cSrcweir } 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir delete pImpl; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir delete pResMgr; 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir //------------------------------------------------------------------------- 208cdf0e10cSrcweir 209cdf0e10cSrcweir SfxSlotPool* SfxModule::GetSlotPool() const 210cdf0e10cSrcweir { 211cdf0e10cSrcweir return pImpl->pSlotPool; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir //------------------------------------------------------------------------- 215cdf0e10cSrcweir 216cdf0e10cSrcweir void SfxModule::RegisterChildWindow(SfxChildWinFactory *pFact) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir DBG_ASSERT( pImpl, "Kein echtes Modul!" ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir if (!pImpl->pFactArr) 221cdf0e10cSrcweir pImpl->pFactArr = new SfxChildWinFactArr_Impl; 222cdf0e10cSrcweir 223cdf0e10cSrcweir //#ifdef DBG_UTIL 224cdf0e10cSrcweir for (sal_uInt16 nFactory=0; nFactory<pImpl->pFactArr->Count(); ++nFactory) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir if (pFact->nId == (*pImpl->pFactArr)[nFactory]->nId) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir pImpl->pFactArr->Remove( nFactory ); 229cdf0e10cSrcweir DBG_ERROR("ChildWindow mehrfach registriert!"); 230cdf0e10cSrcweir return; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir } 233cdf0e10cSrcweir //#endif 234cdf0e10cSrcweir 235cdf0e10cSrcweir pImpl->pFactArr->C40_INSERT( 236cdf0e10cSrcweir SfxChildWinFactory, pFact, pImpl->pFactArr->Count() ); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir //------------------------------------------------------------------------- 240cdf0e10cSrcweir 241cdf0e10cSrcweir void SfxModule::RegisterChildWindowContext( sal_uInt16 nId, 242cdf0e10cSrcweir SfxChildWinContextFactory *pFact) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir DBG_ASSERT( pImpl, "Kein echtes Modul!" ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir sal_uInt16 nCount = pImpl->pFactArr->Count(); 247cdf0e10cSrcweir for (sal_uInt16 nFactory=0; nFactory<nCount; ++nFactory) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir SfxChildWinFactory *pF = (*pImpl->pFactArr)[nFactory]; 250cdf0e10cSrcweir if ( nId == pF->nId ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir if ( !pF->pArr ) 253cdf0e10cSrcweir pF->pArr = new SfxChildWinContextArr_Impl; 254cdf0e10cSrcweir pF->pArr->C40_INSERT( SfxChildWinContextFactory, pFact, pF->pArr->Count() ); 255cdf0e10cSrcweir return; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir DBG_ERROR( "Kein ChildWindow fuer diesen Context!" ); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir //------------------------------------------------------------------------- 263cdf0e10cSrcweir 264cdf0e10cSrcweir void SfxModule::RegisterToolBoxControl( SfxTbxCtrlFactory *pFact ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir if (!pImpl->pTbxCtrlFac) 267cdf0e10cSrcweir pImpl->pTbxCtrlFac = new SfxTbxCtrlFactArr_Impl; 268cdf0e10cSrcweir 269cdf0e10cSrcweir #ifdef DBG_UTIL 270cdf0e10cSrcweir for ( sal_uInt16 n=0; n<pImpl->pTbxCtrlFac->Count(); n++ ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir SfxTbxCtrlFactory *pF = (*pImpl->pTbxCtrlFac)[n]; 273cdf0e10cSrcweir if ( pF->nTypeId && pF->nTypeId == pFact->nTypeId && 274cdf0e10cSrcweir (pF->nSlotId == pFact->nSlotId || pF->nSlotId == 0) ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir DBG_WARNING("TbxController-Registrierung ist nicht eindeutig!"); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir } 279cdf0e10cSrcweir #endif 280cdf0e10cSrcweir 281cdf0e10cSrcweir pImpl->pTbxCtrlFac->C40_INSERT( SfxTbxCtrlFactory, pFact, pImpl->pTbxCtrlFac->Count() ); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir //------------------------------------------------------------------------- 285cdf0e10cSrcweir 286cdf0e10cSrcweir void SfxModule::RegisterStatusBarControl( SfxStbCtrlFactory *pFact ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir if (!pImpl->pStbCtrlFac) 289cdf0e10cSrcweir pImpl->pStbCtrlFac = new SfxStbCtrlFactArr_Impl; 290cdf0e10cSrcweir 291cdf0e10cSrcweir #ifdef DBG_UTIL 292cdf0e10cSrcweir for ( sal_uInt16 n=0; n<pImpl->pStbCtrlFac->Count(); n++ ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir SfxStbCtrlFactory *pF = (*pImpl->pStbCtrlFac)[n]; 295cdf0e10cSrcweir if ( pF->nTypeId && pF->nTypeId == pFact->nTypeId && 296cdf0e10cSrcweir (pF->nSlotId == pFact->nSlotId || pF->nSlotId == 0) ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir DBG_WARNING("StbController-Registrierung ist nicht eindeutig!"); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir } 301cdf0e10cSrcweir #endif 302cdf0e10cSrcweir 303cdf0e10cSrcweir pImpl->pStbCtrlFac->C40_INSERT( SfxStbCtrlFactory, pFact, pImpl->pStbCtrlFac->Count() ); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir //------------------------------------------------------------------------- 307cdf0e10cSrcweir 308cdf0e10cSrcweir void SfxModule::RegisterMenuControl( SfxMenuCtrlFactory *pFact ) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir if (!pImpl->pMenuCtrlFac) 311cdf0e10cSrcweir pImpl->pMenuCtrlFac = new SfxMenuCtrlFactArr_Impl; 312cdf0e10cSrcweir 313cdf0e10cSrcweir #ifdef DBG_UTIL 314cdf0e10cSrcweir for ( sal_uInt16 n=0; n<pImpl->pMenuCtrlFac->Count(); n++ ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir SfxMenuCtrlFactory *pF = (*pImpl->pMenuCtrlFac)[n]; 317cdf0e10cSrcweir if ( pF->nTypeId && pF->nTypeId == pFact->nTypeId && 318cdf0e10cSrcweir (pF->nSlotId == pFact->nSlotId || pF->nSlotId == 0) ) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir DBG_WARNING("MenuController-Registrierung ist nicht eindeutig!"); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir } 323cdf0e10cSrcweir #endif 324cdf0e10cSrcweir 325cdf0e10cSrcweir pImpl->pMenuCtrlFac->C40_INSERT( SfxMenuCtrlFactory, pFact, pImpl->pMenuCtrlFac->Count() ); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir //------------------------------------------------------------------------- 329cdf0e10cSrcweir 330cdf0e10cSrcweir SfxTbxCtrlFactArr_Impl* SfxModule::GetTbxCtrlFactories_Impl() const 331cdf0e10cSrcweir { 332cdf0e10cSrcweir return pImpl->pTbxCtrlFac; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir //------------------------------------------------------------------------- 336cdf0e10cSrcweir 337cdf0e10cSrcweir SfxStbCtrlFactArr_Impl* SfxModule::GetStbCtrlFactories_Impl() const 338cdf0e10cSrcweir { 339cdf0e10cSrcweir return pImpl->pStbCtrlFac; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir //------------------------------------------------------------------------- 343cdf0e10cSrcweir 344cdf0e10cSrcweir SfxMenuCtrlFactArr_Impl* SfxModule::GetMenuCtrlFactories_Impl() const 345cdf0e10cSrcweir { 346cdf0e10cSrcweir return pImpl->pMenuCtrlFac; 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir //------------------------------------------------------------------------- 350cdf0e10cSrcweir 351cdf0e10cSrcweir SfxChildWinFactArr_Impl* SfxModule::GetChildWinFactories_Impl() const 352cdf0e10cSrcweir { 353cdf0e10cSrcweir return pImpl->pFactArr; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir ImageList* SfxModule::GetImageList_Impl( sal_Bool bBig ) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir return pImpl->GetImageList( pResMgr, bBig, sal_False ); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir ImageList* SfxModule::GetImageList_Impl( sal_Bool bBig, sal_Bool bHiContrast ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir return pImpl->GetImageList( pResMgr, bBig, bHiContrast ); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir SfxTabPage* SfxModule::CreateTabPage( sal_uInt16, Window*, const SfxItemSet& ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir return NULL; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir SfxModuleArr_Impl& SfxModule::GetModules_Impl() 372cdf0e10cSrcweir { 373cdf0e10cSrcweir if( !pModules ) 374cdf0e10cSrcweir pModules = new SfxModuleArr_Impl; 375cdf0e10cSrcweir return *pModules; 376cdf0e10cSrcweir }; 377cdf0e10cSrcweir 378cdf0e10cSrcweir void SfxModule::DestroyModules_Impl() 379cdf0e10cSrcweir { 380cdf0e10cSrcweir if ( pModules ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir SfxModuleArr_Impl& rModules = *pModules; 383cdf0e10cSrcweir for( sal_uInt16 nPos = rModules.Count(); nPos--; ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir SfxModule* pMod = rModules.GetObject(nPos); 386cdf0e10cSrcweir delete pMod; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir } 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir void SfxModule::Invalidate( sal_uInt16 nId ) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst(); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) ) 394cdf0e10cSrcweir if ( pFrame->GetObjectShell()->GetModule() == this ) 395cdf0e10cSrcweir Invalidate_Impl( pFrame->GetBindings(), nId ); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir sal_Bool SfxModule::IsActive() const 399cdf0e10cSrcweir { 400cdf0e10cSrcweir SfxViewFrame* pFrame = SfxViewFrame::Current(); 401cdf0e10cSrcweir if ( pFrame && pFrame->GetObjectShell()->GetFactory().GetModule() == this ) 402cdf0e10cSrcweir return sal_True; 403cdf0e10cSrcweir return sal_False; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir bool SfxModule::IsChildWindowAvailable( const sal_uInt16 i_nId, const SfxViewFrame* i_pViewFrame ) const 407cdf0e10cSrcweir { 408cdf0e10cSrcweir if ( i_nId != SID_TASKPANE ) 409cdf0e10cSrcweir // by default, assume it is 410cdf0e10cSrcweir return true; 411cdf0e10cSrcweir 412cdf0e10cSrcweir const SfxViewFrame* pViewFrame = i_pViewFrame ? i_pViewFrame : GetFrame(); 413cdf0e10cSrcweir ENSURE_OR_RETURN( pViewFrame, "SfxModule::IsChildWindowAvailable: no frame to ask for the module identifier!", false ); 414cdf0e10cSrcweir return ::sfx2::ModuleTaskPane::ModuleHasToolPanels( pViewFrame->GetFrame().GetFrameInterface() ); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir SfxModule* SfxModule::GetActiveModule( SfxViewFrame* pFrame ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir if ( !pFrame ) 420cdf0e10cSrcweir pFrame = SfxViewFrame::Current(); 421cdf0e10cSrcweir SfxObjectShell* pSh = 0; 422cdf0e10cSrcweir if( pFrame ) 423cdf0e10cSrcweir pSh = pFrame->GetObjectShell(); 424cdf0e10cSrcweir return pSh ? pSh->GetModule() : 0; 425cdf0e10cSrcweir } 426cdf0e10cSrcweir 427cdf0e10cSrcweir FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir ENSURE_OR_RETURN( i_frame.is(), "SfxModule::GetModuleFieldUnit: invalid frame!", FUNIT_100TH_MM ); 430cdf0e10cSrcweir 431cdf0e10cSrcweir // find SfxViewFrame for the given XFrame 432cdf0e10cSrcweir SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); 433cdf0e10cSrcweir while ( pViewFrame != NULL ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir if ( pViewFrame->GetFrame().GetFrameInterface() == i_frame ) 436cdf0e10cSrcweir break; 437cdf0e10cSrcweir pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir ENSURE_OR_RETURN( pViewFrame != NULL, "SfxModule::GetModuleFieldUnit: unable to find an SfxViewFrame for the given XFrame", FUNIT_100TH_MM ); 440cdf0e10cSrcweir 441cdf0e10cSrcweir // find the module 442cdf0e10cSrcweir SfxModule const * pModule = GetActiveModule( pViewFrame ); 443cdf0e10cSrcweir ENSURE_OR_RETURN( pModule != NULL, "SfxModule::GetModuleFieldUnit: no SfxModule for the given frame!", FUNIT_100TH_MM ); 444*0d5343eeSMathias Bauer if ( pModule ) 445*0d5343eeSMathias Bauer return pModule->GetFieldUnit(); 446*0d5343eeSMathias Bauer return FUNIT_INCH; 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 449cdf0e10cSrcweir FieldUnit SfxModule::GetCurrentFieldUnit() 450cdf0e10cSrcweir { 451cdf0e10cSrcweir FieldUnit eUnit = FUNIT_INCH; 452cdf0e10cSrcweir SfxModule* pModule = GetActiveModule(); 453cdf0e10cSrcweir if ( pModule ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC ); 456cdf0e10cSrcweir if ( pItem ) 457cdf0e10cSrcweir eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue(); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir else 460cdf0e10cSrcweir DBG_ERRORFILE( "GetModuleFieldUnit(): no module found" ); 461cdf0e10cSrcweir return eUnit; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir FieldUnit SfxModule::GetFieldUnit() const 465cdf0e10cSrcweir { 466cdf0e10cSrcweir FieldUnit eUnit = FUNIT_INCH; 467cdf0e10cSrcweir const SfxPoolItem* pItem = GetItem( SID_ATTR_METRIC ); 468cdf0e10cSrcweir if ( pItem ) 469cdf0e10cSrcweir eUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue(); 470cdf0e10cSrcweir return eUnit; 471cdf0e10cSrcweir } 472