1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appchild.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
36 #include <svtools/whiter.hxx>
37 #include <svtools/eitem.hxx>
39 #include <sfx2/app.hxx>
40 #include "appdata.hxx"
41 #include "workwin.hxx"
42 #include <sfx2/childwin.hxx>
43 #include "arrdecl.hxx"
44 #include <sfx2/templdlg.hxx>
45 #include <sfx2/request.hxx>
46 #include <sfx2/bindings.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include "sfxtypes.hxx"
49 #include <sfx2/module.hxx>
50 #include <sfx2/sfxsids.hrc>
52 //=========================================================================
55 void SfxApplication::RegisterChildWindow_Impl( SfxModule
*pMod
, SfxChildWinFactory
*pFact
)
59 pMod
->RegisterChildWindow( pFact
);
63 if (!pAppData_Impl
->pFactArr
)
64 pAppData_Impl
->pFactArr
= new SfxChildWinFactArr_Impl
;
67 for (USHORT nFactory
=0; nFactory
<pAppData_Impl
->pFactArr
->Count(); ++nFactory
)
69 if (pFact
->nId
== (*pAppData_Impl
->pFactArr
)[nFactory
]->nId
)
71 pAppData_Impl
->pFactArr
->Remove( nFactory
);
72 // DBG_ERROR("ChildWindow mehrfach registriert!");
78 pAppData_Impl
->pFactArr
->C40_INSERT(
79 SfxChildWinFactory
, pFact
, pAppData_Impl
->pFactArr
->Count() );
82 void SfxApplication::RegisterChildWindowContext_Impl( SfxModule
*pMod
, USHORT nId
,
83 SfxChildWinContextFactory
*pFact
)
85 SfxChildWinFactArr_Impl
*pFactories
;
86 SfxChildWinFactory
*pF
= NULL
;
89 // Modul "ubergeben, ChildwindowFactory dort suchen
90 pFactories
= pMod
->GetChildWinFactories_Impl();
93 USHORT nCount
= pFactories
->Count();
94 for (USHORT nFactory
=0; nFactory
<nCount
; ++nFactory
)
96 SfxChildWinFactory
*pFac
= (*pFactories
)[nFactory
];
97 if ( nId
== pFac
->nId
)
99 // Factory gefunden, Context dort registrieren
109 // Factory an der Application suchen
110 DBG_ASSERT( pAppData_Impl
, "Keine AppDaten!" );
111 DBG_ASSERT( pAppData_Impl
->pFactArr
, "Keine Factories!" );
113 pFactories
= pAppData_Impl
->pFactArr
;
114 USHORT nCount
= pFactories
->Count();
115 for (USHORT nFactory
=0; nFactory
<nCount
; ++nFactory
)
117 SfxChildWinFactory
*pFac
= (*pFactories
)[nFactory
];
118 if ( nId
== pFac
->nId
)
122 // Wenn der Context von einem Modul registriert wurde,
123 // mu\s die ChildwindowFactory auch dort zur Verf"ugung
124 // stehen, sonst m"u\ste sich die Contextfactory im DLL-Exit
126 pF
= new SfxChildWinFactory( pFac
->pCtor
, pFac
->nId
,
128 pMod
->RegisterChildWindow( pF
);
140 pF
->pArr
= new SfxChildWinContextArr_Impl
;
141 pF
->pArr
->C40_INSERT( SfxChildWinContextFactory
, pFact
, pF
->pArr
->Count() );
145 DBG_ERROR( "Kein ChildWindow fuer diesen Context!" );
148 //--------------------------------------------------------------------
150 SfxChildWinFactArr_Impl
& SfxApplication::GetChildWinFactories_Impl() const
152 return ( *(pAppData_Impl
->pFactArr
));
155 //--------------------------------------------------------------------
157 SfxTemplateDialog
* SfxApplication::GetTemplateDialog()
159 if ( pAppData_Impl
->pViewFrame
)
161 SfxChildWindow
*pChild
= pAppData_Impl
->pViewFrame
->GetChildWindow(SfxTemplateDialogWrapper::GetChildWindowId());
162 return pChild
? (SfxTemplateDialog
*) pChild
->GetWindow() : 0;
168 //--------------------------------------------------------------------
170 SfxWorkWindow
* SfxApplication::GetWorkWindow_Impl(const SfxViewFrame
*pFrame
) const
173 return pFrame
->GetFrame()->GetWorkWindow_Impl();
174 else if ( pAppData_Impl
->pViewFrame
)
175 return pAppData_Impl
->pViewFrame
->GetFrame()->GetWorkWindow_Impl();