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