1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <svl/whiter.hxx>
31 #include <svl/eitem.hxx>
33 #include <sfx2/app.hxx>
34 #include "appdata.hxx"
35 #include "workwin.hxx"
36 #include <sfx2/childwin.hxx>
37 #include "arrdecl.hxx"
38 #include <sfx2/templdlg.hxx>
39 #include <sfx2/request.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include "sfxtypes.hxx"
43 #include <sfx2/module.hxx>
44 #include <sfx2/sfxsids.hrc>
46 //=========================================================================
49 void SfxApplication::RegisterChildWindow_Impl( SfxModule
*pMod
, SfxChildWinFactory
*pFact
)
53 pMod
->RegisterChildWindow( pFact
);
57 if (!pAppData_Impl
->pFactArr
)
58 pAppData_Impl
->pFactArr
= new SfxChildWinFactArr_Impl
;
60 for (sal_uInt16 nFactory
=0; nFactory
<pAppData_Impl
->pFactArr
->Count(); ++nFactory
)
62 if (pFact
->nId
== (*pAppData_Impl
->pFactArr
)[nFactory
]->nId
)
64 pAppData_Impl
->pFactArr
->Remove( nFactory
);
68 pAppData_Impl
->pFactArr
->C40_INSERT(
69 SfxChildWinFactory
, pFact
, pAppData_Impl
->pFactArr
->Count() );
72 void SfxApplication::RegisterChildWindowContext_Impl( SfxModule
*pMod
, sal_uInt16 nId
,
73 SfxChildWinContextFactory
*pFact
)
75 SfxChildWinFactArr_Impl
*pFactories
;
76 SfxChildWinFactory
*pF
= NULL
;
79 // Abandon Module, search there for ChildwindowFactory
80 pFactories
= pMod
->GetChildWinFactories_Impl();
83 sal_uInt16 nCount
= pFactories
->Count();
84 for (sal_uInt16 nFactory
=0; nFactory
<nCount
; ++nFactory
)
86 SfxChildWinFactory
*pFac
= (*pFactories
)[nFactory
];
87 if ( nId
== pFac
->nId
)
89 // Factory found, registrer Context here.
99 // Search for Factory in the Application
100 DBG_ASSERT( pAppData_Impl
, "No AppData!" );
101 DBG_ASSERT( pAppData_Impl
->pFactArr
, "No Factories!" );
103 pFactories
= pAppData_Impl
->pFactArr
;
104 sal_uInt16 nCount
= pFactories
->Count();
105 for (sal_uInt16 nFactory
=0; nFactory
<nCount
; ++nFactory
)
107 SfxChildWinFactory
*pFac
= (*pFactories
)[nFactory
];
108 if ( nId
== pFac
->nId
)
112 // If the context of a module has been registered, then the
113 // ChildWindowFactory must also be available there,
114 // else the ContextFactory would have be unsubscribed on
116 pF
= new SfxChildWinFactory( pFac
->pCtor
, pFac
->nId
,
118 pMod
->RegisterChildWindow( pF
);
130 pF
->pArr
= new SfxChildWinContextArr_Impl
;
131 pF
->pArr
->C40_INSERT( SfxChildWinContextFactory
, pFact
, pF
->pArr
->Count() );
135 OSL_FAIL( "No ChildWindow for this Context!" );
138 //--------------------------------------------------------------------
140 SfxChildWinFactArr_Impl
& SfxApplication::GetChildWinFactories_Impl() const
142 return ( *(pAppData_Impl
->pFactArr
));
145 //--------------------------------------------------------------------
147 SfxTemplateDialog
* SfxApplication::GetTemplateDialog()
149 if ( pAppData_Impl
->pViewFrame
)
151 SfxChildWindow
*pChild
= pAppData_Impl
->pViewFrame
->GetChildWindow(SfxTemplateDialogWrapper::GetChildWindowId());
152 return pChild
? (SfxTemplateDialog
*) pChild
->GetWindow() : 0;
158 //--------------------------------------------------------------------
160 SfxWorkWindow
* SfxApplication::GetWorkWindow_Impl(const SfxViewFrame
*pFrame
) const
163 return pFrame
->GetFrame().GetWorkWindow_Impl();
164 else if ( pAppData_Impl
->pViewFrame
)
165 return pAppData_Impl
->pViewFrame
->GetFrame().GetWorkWindow_Impl();
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */