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
10cdf0e10cSrcweir *
11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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 #include <com/sun/star/embed/EmbedStates.hpp>
27cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
28cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
29cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
30cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
31cdf0e10cSrcweir #include <com/sun/star/util/CloseVetoException.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
34cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #ifndef _MENU_HXX //autogen
37cdf0e10cSrcweir #include <vcl/menu.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <svl/intitem.hxx>
40cdf0e10cSrcweir #ifndef _SPLITWIN_HXX //autogen
41cdf0e10cSrcweir #include <vcl/splitwin.hxx>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #include <svl/eitem.hxx>
44cdf0e10cSrcweir #include <svl/stritem.hxx>
45cdf0e10cSrcweir #ifndef _TOOLKIT_UNOHLP_HXX
46cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
49cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
50cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <vcl/msgbox.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir #ifndef GCC
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir
57cdf0e10cSrcweir // wg. pTopFrames
58cdf0e10cSrcweir #include "appdata.hxx"
59cdf0e10cSrcweir #include <sfx2/app.hxx>
60cdf0e10cSrcweir #include <sfx2/event.hxx>
61cdf0e10cSrcweir #include <sfx2/unoctitm.hxx>
62cdf0e10cSrcweir #include <sfx2/frame.hxx>
63cdf0e10cSrcweir #include "arrdecl.hxx"
64cdf0e10cSrcweir #include <sfx2/objsh.hxx>
65cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
66cdf0e10cSrcweir #include <sfx2/docfile.hxx>
67cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
68cdf0e10cSrcweir #include <sfx2/frmdescr.hxx>
69cdf0e10cSrcweir #include "openflag.hxx"
70cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
71cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
72cdf0e10cSrcweir #include <sfx2/request.hxx>
73cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
74cdf0e10cSrcweir #include "impframe.hxx"
75cdf0e10cSrcweir #include <sfx2/appuno.hxx>
76cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
77cdf0e10cSrcweir #include "workwin.hxx"
78cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
79cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
80cdf0e10cSrcweir #include "objshimp.hxx"
81cdf0e10cSrcweir #include <sfx2/ipclient.hxx>
82cdf0e10cSrcweir
83cdf0e10cSrcweir #ifdef DBG_UTIL
84cdf0e10cSrcweir #include <sfx2/frmhtmlw.hxx>
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir
87cdf0e10cSrcweir using namespace com::sun::star;
88cdf0e10cSrcweir
89cdf0e10cSrcweir static SfxFrameArr_Impl* pFramesArr_Impl=0;
90cdf0e10cSrcweir
91cdf0e10cSrcweir using namespace ::com::sun::star::uno;
92cdf0e10cSrcweir using namespace ::com::sun::star::util;
93cdf0e10cSrcweir using namespace ::com::sun::star::frame;
94cdf0e10cSrcweir using namespace ::com::sun::star::container;
95cdf0e10cSrcweir
96cdf0e10cSrcweir TYPEINIT1(SfxFrame, SfxListener);
97cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxFrameItem, SfxPoolItem);
98cdf0e10cSrcweir TYPEINIT1(SfxUsrAnyItem, SfxPoolItem);
99cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem, SfxPoolItem);
100cdf0e10cSrcweir
GetHdl()101cdf0e10cSrcweir SvCompatWeakHdl* SfxFrame::GetHdl()
102cdf0e10cSrcweir {
103cdf0e10cSrcweir return pImp->GetHdl();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir //--------------------------------------------------------------------
Construct_Impl()107cdf0e10cSrcweir void SfxFrame::Construct_Impl()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir pImp = new SfxFrame_Impl( this );
110cdf0e10cSrcweir if ( !pFramesArr_Impl )
111cdf0e10cSrcweir pFramesArr_Impl = new SfxFrameArr_Impl;
112cdf0e10cSrcweir pFramesArr_Impl->Insert( this, pFramesArr_Impl->Count() );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir //--------------------------------------------------------------------
116cdf0e10cSrcweir
~SfxFrame()117cdf0e10cSrcweir SfxFrame::~SfxFrame()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir RemoveTopFrame_Impl( this );
120cdf0e10cSrcweir DELETEZ( pWindow );
121cdf0e10cSrcweir
122cdf0e10cSrcweir pFramesArr_Impl->Remove( pFramesArr_Impl->GetPos( this ) );
123cdf0e10cSrcweir
124cdf0e10cSrcweir if ( pParentFrame )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir pParentFrame->RemoveChildFrame_Impl( this );
127cdf0e10cSrcweir pParentFrame = 0;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir delete pImp->pDescr;
131cdf0e10cSrcweir
132cdf0e10cSrcweir if ( pChildArr )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir DBG_ASSERT( !pChildArr->Count(), "Childs nicht entfernt!" );
135cdf0e10cSrcweir delete pChildArr;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir delete pImp;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
DoClose()141cdf0e10cSrcweir sal_Bool SfxFrame::DoClose()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir // Eigentlich wird noch ein PrepareClose gebraucht !!!
144cdf0e10cSrcweir sal_Bool bRet = sal_False;
145cdf0e10cSrcweir if ( !pImp->bClosing )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir pImp->bClosing = sal_True;
148cdf0e10cSrcweir CancelTransfers();
149cdf0e10cSrcweir
150cdf0e10cSrcweir // now close frame; it will be deleted if this call is successful, so don't use any members after that!
151cdf0e10cSrcweir bRet = sal_True;
152cdf0e10cSrcweir try
153cdf0e10cSrcweir {
154cdf0e10cSrcweir Reference< XCloseable > xCloseable ( pImp->xFrame, UNO_QUERY );
155cdf0e10cSrcweir if ( (!GetCurrentDocument() || !GetCurrentDocument()->Get_Impl()->bDisposing ) && xCloseable.is())
156cdf0e10cSrcweir xCloseable->close(sal_True);
157cdf0e10cSrcweir else if ( pImp->xFrame.is() )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir Reference < XFrame > xFrame = pImp->xFrame;
160cdf0e10cSrcweir xFrame->setComponent( Reference < com::sun::star::awt::XWindow >(), Reference < XController >() );
161cdf0e10cSrcweir xFrame->dispose();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir else
164cdf0e10cSrcweir bRet = DoClose_Impl();
165cdf0e10cSrcweir }
166cdf0e10cSrcweir catch( ::com::sun::star::util::CloseVetoException& )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir pImp->bClosing = sal_False;
169cdf0e10cSrcweir bRet = sal_False;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir catch( ::com::sun::star::lang::DisposedException& )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir return bRet;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
DoClose_Impl()179cdf0e10cSrcweir sal_Bool SfxFrame::DoClose_Impl()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir sal_Bool bRet = sal_True;
182cdf0e10cSrcweir SfxBindings* pBindings = NULL;
183cdf0e10cSrcweir if ( pImp->pCurrentViewFrame )
184cdf0e10cSrcweir pBindings = &pImp->pCurrentViewFrame->GetBindings();
185cdf0e10cSrcweir
186cdf0e10cSrcweir // Bei internen Tasks m"ussen Controller und Tools abger"aumt werden
187cdf0e10cSrcweir if ( pImp->pWorkWin )
188cdf0e10cSrcweir pImp->pWorkWin->DeleteControllers_Impl();
189cdf0e10cSrcweir
190cdf0e10cSrcweir if ( pImp->pCurrentViewFrame )
191cdf0e10cSrcweir bRet = pImp->pCurrentViewFrame->Close();
192cdf0e10cSrcweir
193cdf0e10cSrcweir if ( pImp->bOwnsBindings )
194cdf0e10cSrcweir DELETEZ( pBindings );
195cdf0e10cSrcweir
196cdf0e10cSrcweir bRet = Close();
197cdf0e10cSrcweir DBG_ASSERT( bRet, "Impossible state: frame closes, but controller refuses!");
198cdf0e10cSrcweir return bRet;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
DocIsModified_Impl()201cdf0e10cSrcweir sal_Bool SfxFrame::DocIsModified_Impl()
202cdf0e10cSrcweir {
203cdf0e10cSrcweir if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetObjectShell() &&
204cdf0e10cSrcweir pImp->pCurrentViewFrame->GetObjectShell()->IsModified() )
205cdf0e10cSrcweir return sal_True;
206cdf0e10cSrcweir for( sal_uInt16 nPos = GetChildFrameCount(); nPos--; )
207cdf0e10cSrcweir if( pChildArr->GetObject( nPos )->DocIsModified_Impl() )
208cdf0e10cSrcweir return sal_True;
209cdf0e10cSrcweir return sal_False;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
PrepareClose_Impl(sal_Bool bUI,sal_Bool bForBrowsing)212cdf0e10cSrcweir sal_uInt16 SfxFrame::PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir sal_uInt16 nRet = RET_OK;
215cdf0e10cSrcweir
216cdf0e10cSrcweir // prevent recursive calls
217cdf0e10cSrcweir if( !pImp->bPrepClosing )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir pImp->bPrepClosing = sal_True;
220cdf0e10cSrcweir
221cdf0e10cSrcweir SfxObjectShell* pCur = GetCurrentDocument() ;
222cdf0e10cSrcweir if( pCur )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir // SFX components have a known behaviour
225cdf0e10cSrcweir // First check if this frame is the only view to its current document
226cdf0e10cSrcweir int bOther = sal_False;
227cdf0e10cSrcweir for ( const SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pCur );
228cdf0e10cSrcweir !bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pCur ) )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir bOther = ( &pFrame->GetFrame() != this );
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
233cdf0e10cSrcweir SFX_APP()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur, GetController() ) );
234cdf0e10cSrcweir
235cdf0e10cSrcweir if ( bOther )
236cdf0e10cSrcweir // if there are other views only the current view of this frame must be asked
237cdf0e10cSrcweir nRet = GetCurrentViewFrame()->GetViewShell()->PrepareClose( bUI, bForBrowsing );
238cdf0e10cSrcweir else
239cdf0e10cSrcweir // otherwise ask the document
240cdf0e10cSrcweir nRet = pCur->PrepareClose( bUI, bForBrowsing );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
243cdf0e10cSrcweir if ( nRet == RET_OK )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir // if this frame has child frames, ask them too
246cdf0e10cSrcweir for( sal_uInt16 nPos = GetChildFrameCount(); nRet == RET_OK && nPos--; )
247cdf0e10cSrcweir nRet = pChildArr->GetObject( nPos )->PrepareClose_Impl( bUI, bForBrowsing );
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir pImp->bPrepClosing = sal_False;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir if ( nRet == RET_OK && pImp->pWorkWin )
254cdf0e10cSrcweir // if closing was accepted by the component the UI subframes must be asked also
255cdf0e10cSrcweir nRet = pImp->pWorkWin->PrepareClose_Impl();
256cdf0e10cSrcweir
257cdf0e10cSrcweir return nRet;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir //--------------------------------------------------------------------
261cdf0e10cSrcweir
GetChildFrame(sal_uInt16 nPos) const262cdf0e10cSrcweir SfxFrame* SfxFrame::GetChildFrame( sal_uInt16 nPos ) const
263cdf0e10cSrcweir {
264cdf0e10cSrcweir if ( pChildArr && pChildArr->Count() > nPos )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir DBG_ASSERT( nPos < pChildArr->Count(), "Falscher Index!");
267cdf0e10cSrcweir return (*pChildArr)[nPos];
268cdf0e10cSrcweir }
269cdf0e10cSrcweir
270cdf0e10cSrcweir return 0L;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
RemoveChildFrame_Impl(SfxFrame * pFrame)273cdf0e10cSrcweir void SfxFrame::RemoveChildFrame_Impl( SfxFrame* pFrame )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir DBG_ASSERT( pChildArr, "Unbekannter Frame!");
276cdf0e10cSrcweir sal_uInt16 nPos = pChildArr->GetPos(pFrame);
277cdf0e10cSrcweir pChildArr->Remove( nPos );
278cdf0e10cSrcweir };
279cdf0e10cSrcweir
GetTopFrame() const280cdf0e10cSrcweir SfxFrame& SfxFrame::GetTopFrame() const
281cdf0e10cSrcweir {
282cdf0e10cSrcweir const SfxFrame* pParent = this;
283cdf0e10cSrcweir while ( pParent->pParentFrame )
284cdf0e10cSrcweir pParent = pParent->pParentFrame;
285cdf0e10cSrcweir return *const_cast< SfxFrame* >( pParent );
286cdf0e10cSrcweir }
287cdf0e10cSrcweir
IsClosing_Impl() const288cdf0e10cSrcweir sal_Bool SfxFrame::IsClosing_Impl() const
289cdf0e10cSrcweir {
290cdf0e10cSrcweir return pImp->bClosing;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir
SetIsClosing_Impl()293cdf0e10cSrcweir void SfxFrame::SetIsClosing_Impl()
294cdf0e10cSrcweir {
295cdf0e10cSrcweir pImp->bClosing = sal_True;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
GetChildFrameCount() const298cdf0e10cSrcweir sal_uInt16 SfxFrame::GetChildFrameCount() const
299cdf0e10cSrcweir {
300cdf0e10cSrcweir return pChildArr ? pChildArr->Count() : 0;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
CancelTransfers(sal_Bool)303cdf0e10cSrcweir void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir if( !pImp->bInCancelTransfers )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir pImp->bInCancelTransfers = sal_True;
308cdf0e10cSrcweir SfxObjectShell* pObj = GetCurrentDocument();
309cdf0e10cSrcweir if( pObj ) //&& !( pObj->Get_Impl()->nLoadedFlags & SFX_LOADED_ALL ))
310cdf0e10cSrcweir {
311cdf0e10cSrcweir SfxViewFrame* pFrm;
312cdf0e10cSrcweir for( pFrm = SfxViewFrame::GetFirst( pObj );
313cdf0e10cSrcweir pFrm && &pFrm->GetFrame() == this;
314cdf0e10cSrcweir pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ;
315cdf0e10cSrcweir // Keine anderer Frame mehr auf Doc -> Cancel
316cdf0e10cSrcweir if( !pFrm )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir pObj->CancelTransfers();
319cdf0e10cSrcweir GetCurrentDocument()->Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir }
322cdf0e10cSrcweir
323cdf0e10cSrcweir // zuerst Nachladende Frames stoppen
324cdf0e10cSrcweir sal_uInt16 nCount = GetChildFrameCount();
325cdf0e10cSrcweir for( sal_uInt16 n = 0; n<nCount; n++ )
326cdf0e10cSrcweir GetChildFrame( n )->CancelTransfers();
327cdf0e10cSrcweir
328cdf0e10cSrcweir // ggf. StarOne-Loader canceln
329cdf0e10cSrcweir SfxFrameWeak wFrame( this );
330cdf0e10cSrcweir if (wFrame.Is())
331cdf0e10cSrcweir pImp->bInCancelTransfers = sal_False;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
GetCurrentViewFrame() const335cdf0e10cSrcweir SfxViewFrame* SfxFrame::GetCurrentViewFrame() const
336cdf0e10cSrcweir {
337cdf0e10cSrcweir return pImp->pCurrentViewFrame;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
GetDispatcher_Impl() const340cdf0e10cSrcweir SfxDispatcher* SfxFrame::GetDispatcher_Impl() const
341cdf0e10cSrcweir {
342cdf0e10cSrcweir if ( pImp->pCurrentViewFrame )
343cdf0e10cSrcweir return pImp->pCurrentViewFrame->GetDispatcher();
344cdf0e10cSrcweir return GetParentFrame()->GetDispatcher_Impl();
345cdf0e10cSrcweir }
346cdf0e10cSrcweir
GetCurrentDocument() const347cdf0e10cSrcweir SfxObjectShell* SfxFrame::GetCurrentDocument() const
348cdf0e10cSrcweir {
349cdf0e10cSrcweir return pImp->pCurrentViewFrame ?
350cdf0e10cSrcweir pImp->pCurrentViewFrame->GetObjectShell() :
351cdf0e10cSrcweir NULL;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
SetCurrentViewFrame_Impl(SfxViewFrame * pFrame)354cdf0e10cSrcweir void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame *pFrame )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir pImp->pCurrentViewFrame = pFrame;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
GetFrameType() const359cdf0e10cSrcweir sal_uInt32 SfxFrame::GetFrameType() const
360cdf0e10cSrcweir {
361cdf0e10cSrcweir return pImp->nType;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
SetFrameType_Impl(sal_uInt32 n)364cdf0e10cSrcweir void SfxFrame::SetFrameType_Impl( sal_uInt32 n )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir pImp->nType = n;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
GetViewData_Impl()369cdf0e10cSrcweir void SfxFrame::GetViewData_Impl()
370cdf0e10cSrcweir {
371cdf0e10cSrcweir // Alle zwischen Laden und Entfernen "anderbaren Daten aktualisieren; die
372cdf0e10cSrcweir // festen Daten werden nur einmal ( nach PrepareForDoc_Impl in UpdateDescriptor )
373cdf0e10cSrcweir // geholt, um Zeit zu sparen.
374cdf0e10cSrcweir SfxViewFrame* pViewFrame = GetCurrentViewFrame();
375cdf0e10cSrcweir if( pViewFrame && pViewFrame->GetViewShell() )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir const SfxMedium *pMed = GetCurrentDocument()->GetMedium();
378cdf0e10cSrcweir sal_Bool bReadOnly = pMed->GetOpenMode() == SFX_STREAM_READONLY;
379cdf0e10cSrcweir GetDescriptor()->SetReadOnly( bReadOnly );
380cdf0e10cSrcweir
381cdf0e10cSrcweir SfxItemSet *pSet = GetDescriptor()->GetArgs();
382cdf0e10cSrcweir sal_Bool bGetViewData = sal_False;
383cdf0e10cSrcweir if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SFX_ITEM_SET )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir ::com::sun::star::uno::Any aData = GetController()->getViewData();
386cdf0e10cSrcweir pSet->Put( SfxUsrAnyItem( SID_VIEW_DATA, aData ) );
387cdf0e10cSrcweir bGetViewData = sal_True;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir if ( pViewFrame->GetCurViewId() )
391cdf0e10cSrcweir pSet->Put( SfxUInt16Item( SID_VIEW_ID, pViewFrame->GetCurViewId() ) );
392cdf0e10cSrcweir if ( pChildArr )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir // Bei Framesets m"ussen auch die Daten der ChildViews geholt werden
395cdf0e10cSrcweir sal_uInt16 nCount = pChildArr->Count();
396cdf0e10cSrcweir for ( sal_uInt16 n=nCount; n>0; n--)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir SfxFrame* pFrame = (*pChildArr)[n-1];
399cdf0e10cSrcweir if ( bGetViewData )
400cdf0e10cSrcweir pFrame->GetDescriptor()->GetArgs()->ClearItem( SID_VIEW_DATA );
401cdf0e10cSrcweir pFrame->GetViewData_Impl();
402cdf0e10cSrcweir }
403cdf0e10cSrcweir }
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
UpdateDescriptor(SfxObjectShell * pDoc)407cdf0e10cSrcweir void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir // Beim PrepareForDoc_Impl wird der Descriptor des Frames aktualisiert
410cdf0e10cSrcweir // und sein ItemSet neu initialisiert. Alle Daten, die f"ur ein sp"ateres
411cdf0e10cSrcweir // Restaurieren der View n"otig sind, sind damit festgehalten.
412cdf0e10cSrcweir // Soll das Dokument ersetzt werden, wird durch GetViewData_Impl (s.o.)
413cdf0e10cSrcweir // die neueste Information hinzugef"ugt. Alles zusammen wird dann in der
414cdf0e10cSrcweir // Browse-History gesichert. Beim Aktivieren eines solchen FramePickEntry
415cdf0e10cSrcweir // wird das komplette ItemSet und der Descriptor im OpenDoc mitgeschickt.
416cdf0e10cSrcweir // Hier werden nur die festen Eigenschaften gesichert; die "anderbaren werden
417cdf0e10cSrcweir // durch GetViewData geholt ( spart Zeit ).
418cdf0e10cSrcweir DBG_ASSERT( pDoc, "NULL-Document inserted ?!" );
419cdf0e10cSrcweir
420cdf0e10cSrcweir GetParentFrame();
421cdf0e10cSrcweir const SfxMedium *pMed = pDoc->GetMedium();
422cdf0e10cSrcweir GetDescriptor()->SetActualURL( pMed->GetOrigURL() );
423cdf0e10cSrcweir
424cdf0e10cSrcweir SFX_ITEMSET_ARG( pMed->GetItemSet(), pItem, SfxBoolItem, SID_EDITDOC, sal_False );
425cdf0e10cSrcweir sal_Bool bEditable = ( !pItem || pItem->GetValue() );
426cdf0e10cSrcweir
427cdf0e10cSrcweir GetDescriptor()->SetEditable( bEditable );
428cdf0e10cSrcweir
429cdf0e10cSrcweir // FileOpen-Parameter merken
430cdf0e10cSrcweir SfxItemSet* pItemSet = pMed->GetItemSet();
431cdf0e10cSrcweir String aMedName( pMed->GetName() );
432cdf0e10cSrcweir
433cdf0e10cSrcweir const SfxFilter* pFilter = pMed->GetOrigFilter();
434cdf0e10cSrcweir String aFilter;
435cdf0e10cSrcweir if ( pFilter )
436cdf0e10cSrcweir aFilter = pFilter->GetFilterName();
437cdf0e10cSrcweir
438cdf0e10cSrcweir SFX_ITEMSET_ARG( pItemSet, pRefererItem, SfxStringItem, SID_REFERER, sal_False);
439cdf0e10cSrcweir SFX_ITEMSET_ARG( pItemSet, pOptionsItem, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
440cdf0e10cSrcweir SFX_ITEMSET_ARG( pItemSet, pTitle1Item, SfxStringItem, SID_DOCINFO_TITLE, sal_False);
441cdf0e10cSrcweir
442cdf0e10cSrcweir SfxItemSet *pSet = GetDescriptor()->GetArgs();
443cdf0e10cSrcweir
444cdf0e10cSrcweir // Alle alten Items l"oschen
445cdf0e10cSrcweir pSet->ClearItem();
446cdf0e10cSrcweir
447cdf0e10cSrcweir if ( pRefererItem )
448cdf0e10cSrcweir pSet->Put( *pRefererItem );
449cdf0e10cSrcweir else
450cdf0e10cSrcweir pSet->Put( SfxStringItem( SID_REFERER, String() ) );
451cdf0e10cSrcweir
452cdf0e10cSrcweir if ( pOptionsItem )
453cdf0e10cSrcweir pSet->Put( *pOptionsItem );
454cdf0e10cSrcweir
455cdf0e10cSrcweir if ( pTitle1Item )
456cdf0e10cSrcweir pSet->Put( *pTitle1Item );
457cdf0e10cSrcweir
458cdf0e10cSrcweir pSet->Put( SfxStringItem( SID_FILTER_NAME, aFilter ));
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461cdf0e10cSrcweir //-------------------------------------------------------------------------
462cdf0e10cSrcweir
SetDescriptor(SfxFrameDescriptor * pD)463cdf0e10cSrcweir void SfxFrame::SetDescriptor( SfxFrameDescriptor *pD )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir DBG_ASSERT( pD, "Kein Descriptor!" );
466cdf0e10cSrcweir DBG_ASSERT( pD != pImp->pDescr, "Descriptor ist schon gesetzt!" );
467cdf0e10cSrcweir
468cdf0e10cSrcweir if ( pImp->pDescr )
469cdf0e10cSrcweir {
470cdf0e10cSrcweir // Nur TopLevel-Frames verwalten ihren Descriptor selbst, bei den
471cdf0e10cSrcweir // anderen tut es das Frameset
472cdf0e10cSrcweir if ( !pParentFrame )
473cdf0e10cSrcweir delete pImp->pDescr;
474cdf0e10cSrcweir }
475cdf0e10cSrcweir pImp->pDescr = pD;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir
478cdf0e10cSrcweir //-------------------------------------------------------------------------
479cdf0e10cSrcweir
GetDescriptor() const480cdf0e10cSrcweir SfxFrameDescriptor* SfxFrame::GetDescriptor() const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir // On Demand einen FrameDescriptor anlegen; wenn es kein TopLevel-Frame
483cdf0e10cSrcweir // ist, f"uhrt es zu Fehlern, da keine g"ulige Verkettung hergestellt wird
484cdf0e10cSrcweir
485cdf0e10cSrcweir if ( !pImp->pDescr )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir DBG_ASSERT( !GetParentFrame(), "Kein TopLevel-Frame, aber kein Descriptor!" );
488cdf0e10cSrcweir pImp->pDescr = new SfxFrameDescriptor;
489cdf0e10cSrcweir if ( GetCurrentDocument() )
490cdf0e10cSrcweir pImp->pDescr->SetURL( GetCurrentDocument()->GetMedium()->GetOrigURL() );
491cdf0e10cSrcweir }
492cdf0e10cSrcweir return pImp->pDescr;
493cdf0e10cSrcweir }
494cdf0e10cSrcweir
495cdf0e10cSrcweir //-------------------------------------------------------------------------
496cdf0e10cSrcweir
GetTargetList(TargetList & rList) const497cdf0e10cSrcweir void SfxFrame::GetTargetList( TargetList& rList ) const
498cdf0e10cSrcweir {
499cdf0e10cSrcweir if ( !GetParentFrame() )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir // Einen Leerstring f"ur 'Kein Target'
502cdf0e10cSrcweir rList.Insert( new String() );
503cdf0e10cSrcweir rList.Insert( new String( DEFINE_CONST_UNICODE( "_top" ) ) );
504cdf0e10cSrcweir rList.Insert( new String( DEFINE_CONST_UNICODE( "_parent" ) ) );
505cdf0e10cSrcweir rList.Insert( new String( DEFINE_CONST_UNICODE( "_blank" ) ) );
506cdf0e10cSrcweir rList.Insert( new String( DEFINE_CONST_UNICODE( "_self" ) ) );
507cdf0e10cSrcweir }
508cdf0e10cSrcweir
509cdf0e10cSrcweir SfxViewFrame* pView = GetCurrentViewFrame();
510cdf0e10cSrcweir if( pView && pView->GetViewShell() && pChildArr )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir sal_uInt16 nCount = pChildArr->Count();
513cdf0e10cSrcweir for ( sal_uInt16 n=0; n<nCount; n++)
514cdf0e10cSrcweir {
515cdf0e10cSrcweir SfxFrame* pFrame = (*pChildArr)[n];
516cdf0e10cSrcweir pFrame->GetTargetList( rList );
517cdf0e10cSrcweir }
518cdf0e10cSrcweir }
519cdf0e10cSrcweir }
520cdf0e10cSrcweir
521cdf0e10cSrcweir //-------------------------------------------------------------------------
522cdf0e10cSrcweir
GetBroadcaster() const523cdf0e10cSrcweir SfxBroadcaster& SfxFrame::GetBroadcaster() const
524cdf0e10cSrcweir {
525cdf0e10cSrcweir return *pImp;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir
IsParent(SfxFrame * pFrame) const528cdf0e10cSrcweir sal_Bool SfxFrame::IsParent( SfxFrame *pFrame ) const
529cdf0e10cSrcweir {
530cdf0e10cSrcweir SfxFrame *pParent = pParentFrame;
531cdf0e10cSrcweir while ( pParent )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir if ( pParent == pFrame )
534cdf0e10cSrcweir return sal_True;
535cdf0e10cSrcweir pParent = pParent->pParentFrame;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir
538cdf0e10cSrcweir return sal_False;
539cdf0e10cSrcweir }
540cdf0e10cSrcweir
InsertTopFrame_Impl(SfxFrame * pFrame)541cdf0e10cSrcweir void SfxFrame::InsertTopFrame_Impl( SfxFrame* pFrame )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
544cdf0e10cSrcweir rArr.Insert( pFrame, rArr.Count() );
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
RemoveTopFrame_Impl(SfxFrame * pFrame)547cdf0e10cSrcweir void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
550cdf0e10cSrcweir rArr.Remove( rArr.GetPos( pFrame ) );
551cdf0e10cSrcweir }
552cdf0e10cSrcweir
SfxFrameItem(sal_uInt16 nWhichId,SfxViewFrame * p)553cdf0e10cSrcweir SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame *p )
554cdf0e10cSrcweir : SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : NULL )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir wFrame = pFrame;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
SfxFrameItem(sal_uInt16 nWhichId,SfxFrame * p)559cdf0e10cSrcweir SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxFrame *p ):
560cdf0e10cSrcweir SfxPoolItem( nWhichId ),
561cdf0e10cSrcweir pFrame( p ), wFrame( p )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
SfxFrameItem(SfxFrame * p)565cdf0e10cSrcweir SfxFrameItem::SfxFrameItem( SfxFrame *p ):
566cdf0e10cSrcweir SfxPoolItem( 0 ),
567cdf0e10cSrcweir pFrame( p ), wFrame( p )
568cdf0e10cSrcweir {
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
operator ==(const SfxPoolItem & rItem) const571cdf0e10cSrcweir int SfxFrameItem::operator==( const SfxPoolItem &rItem ) const
572cdf0e10cSrcweir {
573cdf0e10cSrcweir return ((SfxFrameItem&)rItem).pFrame == pFrame &&
574cdf0e10cSrcweir ((SfxFrameItem&)rItem).wFrame == wFrame;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir
577cdf0e10cSrcweir //--------------------------------------------------------------------
578cdf0e10cSrcweir
GetValueText() const579cdf0e10cSrcweir String SfxFrameItem::GetValueText() const
580cdf0e10cSrcweir {
581cdf0e10cSrcweir return String();
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
Clone(SfxItemPool *) const584cdf0e10cSrcweir SfxPoolItem* SfxFrameItem::Clone( SfxItemPool *) const
585cdf0e10cSrcweir {
586cdf0e10cSrcweir SfxFrameItem* pNew = new SfxFrameItem( wFrame);
587cdf0e10cSrcweir pNew->SetFramePtr_Impl( pFrame );
588cdf0e10cSrcweir return pNew;
589cdf0e10cSrcweir }
590cdf0e10cSrcweir
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const591cdf0e10cSrcweir sal_Bool SfxFrameItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
592cdf0e10cSrcweir {
593cdf0e10cSrcweir if ( wFrame )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir rVal <<= wFrame->GetFrameInterface();
596cdf0e10cSrcweir return sal_True;
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
599cdf0e10cSrcweir return sal_False;
600cdf0e10cSrcweir }
601cdf0e10cSrcweir
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)602cdf0e10cSrcweir sal_Bool SfxFrameItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir Reference < XFrame > xFrame;
605cdf0e10cSrcweir if ( (rVal >>= xFrame) && xFrame.is() )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir SfxFrame* pFr = SfxFrame::GetFirst();
608cdf0e10cSrcweir while ( pFr )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir if ( pFr->GetFrameInterface() == xFrame )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir wFrame = pFrame = pFr;
613cdf0e10cSrcweir return sal_True;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir pFr = SfxFrame::GetNext( *pFr );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir return sal_True;
619cdf0e10cSrcweir }
620cdf0e10cSrcweir
621cdf0e10cSrcweir return sal_False;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir
SfxUsrAnyItem(sal_uInt16 nWhichId,const::com::sun::star::uno::Any & rAny)625cdf0e10cSrcweir SfxUsrAnyItem::SfxUsrAnyItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Any& rAny )
626cdf0e10cSrcweir : SfxPoolItem( nWhichId )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir aValue = rAny;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir
operator ==(const SfxPoolItem &) const631cdf0e10cSrcweir int SfxUsrAnyItem::operator==( const SfxPoolItem& /*rItem*/ ) const
632cdf0e10cSrcweir {
633cdf0e10cSrcweir // return rItem.ISA( SfxUsrAnyItem ) && ((SfxUsrAnyItem&)rItem).aValue == aValue;
634cdf0e10cSrcweir return sal_False;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir
Clone(SfxItemPool *) const637cdf0e10cSrcweir SfxPoolItem* SfxUsrAnyItem::Clone( SfxItemPool *) const
638cdf0e10cSrcweir {
639cdf0e10cSrcweir return new SfxUsrAnyItem( Which(), aValue );
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const642cdf0e10cSrcweir sal_Bool SfxUsrAnyItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
643cdf0e10cSrcweir {
644cdf0e10cSrcweir rVal = aValue;
645cdf0e10cSrcweir return sal_True;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)648cdf0e10cSrcweir sal_Bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir aValue = rVal;
651cdf0e10cSrcweir return sal_True;
652cdf0e10cSrcweir }
653cdf0e10cSrcweir
SfxUnoFrameItem()654cdf0e10cSrcweir SfxUnoFrameItem::SfxUnoFrameItem()
655cdf0e10cSrcweir : SfxPoolItem()
656cdf0e10cSrcweir , m_xFrame()
657cdf0e10cSrcweir {
658cdf0e10cSrcweir }
659cdf0e10cSrcweir
SfxUnoFrameItem(sal_uInt16 nWhichId,const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & i_rFrame)660cdf0e10cSrcweir SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame )
661cdf0e10cSrcweir : SfxPoolItem( nWhichId )
662cdf0e10cSrcweir , m_xFrame( i_rFrame )
663cdf0e10cSrcweir {
664cdf0e10cSrcweir }
665cdf0e10cSrcweir
operator ==(const SfxPoolItem & i_rItem) const666cdf0e10cSrcweir int SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const
667cdf0e10cSrcweir {
668cdf0e10cSrcweir return i_rItem.ISA( SfxUnoFrameItem ) && static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir
Clone(SfxItemPool *) const671cdf0e10cSrcweir SfxPoolItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const
672cdf0e10cSrcweir {
673cdf0e10cSrcweir return new SfxUnoFrameItem( Which(), m_xFrame );
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const676cdf0e10cSrcweir sal_Bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
677cdf0e10cSrcweir {
678cdf0e10cSrcweir rVal <<= m_xFrame;
679cdf0e10cSrcweir return sal_True;
680cdf0e10cSrcweir }
681cdf0e10cSrcweir
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)682cdf0e10cSrcweir sal_Bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir return ( rVal >>= m_xFrame );
685cdf0e10cSrcweir }
686cdf0e10cSrcweir
SfxFrameIterator(const SfxFrame & rFrame,sal_Bool bRecur)687cdf0e10cSrcweir SfxFrameIterator::SfxFrameIterator( const SfxFrame& rFrame, sal_Bool bRecur )
688cdf0e10cSrcweir : pFrame( &rFrame )
689cdf0e10cSrcweir , bRecursive( bRecur )
690cdf0e10cSrcweir {}
691cdf0e10cSrcweir
FirstFrame()692cdf0e10cSrcweir SfxFrame* SfxFrameIterator::FirstFrame()
693cdf0e10cSrcweir {
694cdf0e10cSrcweir // GetFirst beginnt die Iteration beim ersten ChildFrame
695cdf0e10cSrcweir return pFrame->GetChildFrame( 0 );
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
NextFrame(SfxFrame & rPrev)698cdf0e10cSrcweir SfxFrame* SfxFrameIterator::NextFrame( SfxFrame& rPrev )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir // Zuerst auf Kinder testen, wenn Rekursion erw"unscht
701cdf0e10cSrcweir SfxFrame *pRet = NULL;
702cdf0e10cSrcweir if ( bRecursive )
703cdf0e10cSrcweir pRet = rPrev.GetChildFrame( 0 );
704cdf0e10cSrcweir if ( !pRet )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir // Anderenfalls mit den Geschwistern von rPrev weitermachen
707cdf0e10cSrcweir pRet = NextSibling_Impl( rPrev );
708cdf0e10cSrcweir }
709cdf0e10cSrcweir
710cdf0e10cSrcweir return pRet;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir
NextSibling_Impl(SfxFrame & rPrev)714cdf0e10cSrcweir SfxFrame* SfxFrameIterator::NextSibling_Impl( SfxFrame& rPrev )
715cdf0e10cSrcweir {
716cdf0e10cSrcweir SfxFrame *pRet = NULL;
717cdf0e10cSrcweir if ( &rPrev != pFrame )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir SfxFrameArr_Impl& rArr = *rPrev.pParentFrame->pChildArr;
720cdf0e10cSrcweir sal_uInt16 nPos = rArr.GetPos( &rPrev );
721cdf0e10cSrcweir if ( nPos+1 < rArr.Count() )
722cdf0e10cSrcweir pRet = rArr[nPos+1];
723cdf0e10cSrcweir
724cdf0e10cSrcweir if ( !pRet && rPrev.pParentFrame->pParentFrame )
725cdf0e10cSrcweir pRet = NextSibling_Impl( *rPrev.pParentFrame );
726cdf0e10cSrcweir }
727cdf0e10cSrcweir
728cdf0e10cSrcweir return pRet;
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
IsTop() const731cdf0e10cSrcweir sal_Bool SfxFrame::IsTop() const
732cdf0e10cSrcweir {
733cdf0e10cSrcweir return GetFrameInterface().is() ? GetFrameInterface()->isTop() : sal_False;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir
HasComponent() const736cdf0e10cSrcweir sal_Bool SfxFrame::HasComponent() const
737cdf0e10cSrcweir {
738cdf0e10cSrcweir return sal_False;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir
GetController() const741cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SfxFrame::GetController() const
742cdf0e10cSrcweir {
743cdf0e10cSrcweir if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetViewShell() )
744cdf0e10cSrcweir return pImp->pCurrentViewFrame->GetViewShell()->GetController();
745cdf0e10cSrcweir else
746cdf0e10cSrcweir return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > ();
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
GetFrameInterface() const749cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxFrame::GetFrameInterface() const
750cdf0e10cSrcweir {
751cdf0e10cSrcweir return pImp->xFrame;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
SetFrameInterface_Impl(const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & rFrame)754cdf0e10cSrcweir void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
755cdf0e10cSrcweir {
756cdf0e10cSrcweir pImp->xFrame = rFrame;
757cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
758cdf0e10cSrcweir if ( !rFrame.is() && GetCurrentViewFrame() )
759cdf0e10cSrcweir GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder );
760cdf0e10cSrcweir }
761cdf0e10cSrcweir
Appear()762cdf0e10cSrcweir void SfxFrame::Appear()
763cdf0e10cSrcweir {
764cdf0e10cSrcweir if ( GetCurrentViewFrame() )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir GetCurrentViewFrame()->Show();
767cdf0e10cSrcweir GetWindow().Show();
768cdf0e10cSrcweir pImp->xFrame->getContainerWindow()->setVisible( sal_True );
769cdf0e10cSrcweir if ( pParentFrame )
770cdf0e10cSrcweir pParentFrame->Appear();
771cdf0e10cSrcweir Reference < ::com::sun::star::awt::XTopWindow > xTopWindow( pImp->xFrame->getContainerWindow(), UNO_QUERY );
772cdf0e10cSrcweir if ( xTopWindow.is() )
773cdf0e10cSrcweir xTopWindow->toFront();
774cdf0e10cSrcweir }
775cdf0e10cSrcweir }
776cdf0e10cSrcweir
AppearWithUpdate()777cdf0e10cSrcweir void SfxFrame::AppearWithUpdate()
778cdf0e10cSrcweir {
779cdf0e10cSrcweir Appear();
780cdf0e10cSrcweir if ( GetCurrentViewFrame() )
781cdf0e10cSrcweir GetCurrentViewFrame()->GetDispatcher()->Update_Impl( sal_True );
782cdf0e10cSrcweir }
783cdf0e10cSrcweir
SetOwnsBindings_Impl(sal_Bool bSet)784cdf0e10cSrcweir void SfxFrame::SetOwnsBindings_Impl( sal_Bool bSet )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir pImp->bOwnsBindings = bSet;
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
OwnsBindings_Impl() const789cdf0e10cSrcweir sal_Bool SfxFrame::OwnsBindings_Impl() const
790cdf0e10cSrcweir {
791cdf0e10cSrcweir return pImp->bOwnsBindings;
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
SetToolSpaceBorderPixel_Impl(const SvBorder & rBorder)794cdf0e10cSrcweir void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder& rBorder )
795cdf0e10cSrcweir {
796cdf0e10cSrcweir pImp->aBorder = rBorder;
797cdf0e10cSrcweir SfxViewFrame *pF = GetCurrentViewFrame();
798cdf0e10cSrcweir if ( pF )
799cdf0e10cSrcweir {
800cdf0e10cSrcweir Point aPos ( rBorder.Left(), rBorder.Top() );
801cdf0e10cSrcweir Size aSize( GetWindow().GetOutputSizePixel() );
802cdf0e10cSrcweir long nDeltaX = rBorder.Left() + rBorder.Right();
803cdf0e10cSrcweir if ( aSize.Width() > nDeltaX )
804cdf0e10cSrcweir aSize.Width() -= nDeltaX;
805cdf0e10cSrcweir else
806cdf0e10cSrcweir aSize.Width() = 0;
807cdf0e10cSrcweir
808cdf0e10cSrcweir long nDeltaY = rBorder.Top() + rBorder.Bottom();
809cdf0e10cSrcweir if ( aSize.Height() > nDeltaY )
810cdf0e10cSrcweir aSize.Height() -= nDeltaY;
811cdf0e10cSrcweir else
812cdf0e10cSrcweir aSize.Height() = 0;
813cdf0e10cSrcweir
814cdf0e10cSrcweir if ( GetParentFrame() )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir sal_Bool bHasTools = rBorder.Left() != rBorder.Right() || rBorder.Top() != rBorder.Bottom();
817cdf0e10cSrcweir pF->GetWindow().SetBorderStyle( bHasTools ? WINDOW_BORDER_NORMAL : WINDOW_BORDER_NOBORDER );
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir pF->GetWindow().SetPosSizePixel( aPos, aSize );
821cdf0e10cSrcweir }
822cdf0e10cSrcweir }
823cdf0e10cSrcweir
GetTopOuterRectPixel_Impl() const824cdf0e10cSrcweir Rectangle SfxFrame::GetTopOuterRectPixel_Impl() const
825cdf0e10cSrcweir {
826cdf0e10cSrcweir Size aSize( GetWindow().GetOutputSizePixel() );
827cdf0e10cSrcweir Point aPoint;
828cdf0e10cSrcweir return ( Rectangle ( aPoint, aSize ) );
829cdf0e10cSrcweir }
830cdf0e10cSrcweir
GetWorkWindow_Impl() const831cdf0e10cSrcweir SfxWorkWindow* SfxFrame::GetWorkWindow_Impl() const
832cdf0e10cSrcweir {
833cdf0e10cSrcweir if ( pImp->pWorkWin )
834cdf0e10cSrcweir return pImp->pWorkWin;
835cdf0e10cSrcweir else if ( pParentFrame )
836cdf0e10cSrcweir return pParentFrame->GetWorkWindow_Impl();
837cdf0e10cSrcweir else
838cdf0e10cSrcweir return NULL;
839cdf0e10cSrcweir }
840cdf0e10cSrcweir
SetWorkWindow_Impl(SfxWorkWindow * pWorkwin)841cdf0e10cSrcweir void SfxFrame::SetWorkWindow_Impl( SfxWorkWindow* pWorkwin )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir pImp->pWorkWin = pWorkwin;
844cdf0e10cSrcweir }
845cdf0e10cSrcweir
CreateWorkWindow_Impl()846cdf0e10cSrcweir void SfxFrame::CreateWorkWindow_Impl()
847cdf0e10cSrcweir {
848cdf0e10cSrcweir SfxFrame* pFrame = this;
849cdf0e10cSrcweir
850cdf0e10cSrcweir if ( IsInPlace() )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir // this makes sence only for inplace activated objects
853cdf0e10cSrcweir try
854cdf0e10cSrcweir {
855cdf0e10cSrcweir Reference < XChild > xChild( GetCurrentDocument()->GetModel(), UNO_QUERY );
856cdf0e10cSrcweir if ( xChild.is() )
857cdf0e10cSrcweir {
858cdf0e10cSrcweir Reference < XModel > xParent( xChild->getParent(), UNO_QUERY );
859cdf0e10cSrcweir if ( xParent.is() )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir Reference< XController > xParentCtrler = xParent->getCurrentController();
862cdf0e10cSrcweir if ( xParentCtrler.is() )
863cdf0e10cSrcweir {
864cdf0e10cSrcweir Reference < XFrame > xFrame( xParentCtrler->getFrame() );
865cdf0e10cSrcweir SfxFrame* pFr = SfxFrame::GetFirst();
866cdf0e10cSrcweir while ( pFr )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir if ( pFr->GetFrameInterface() == xFrame )
869cdf0e10cSrcweir {
870cdf0e10cSrcweir pFrame = pFr;
871cdf0e10cSrcweir break;
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
874cdf0e10cSrcweir pFr = SfxFrame::GetNext( *pFr );
875cdf0e10cSrcweir }
876cdf0e10cSrcweir }
877cdf0e10cSrcweir }
878cdf0e10cSrcweir }
879cdf0e10cSrcweir }
880cdf0e10cSrcweir catch(Exception&)
881cdf0e10cSrcweir {
882cdf0e10cSrcweir OSL_ENSURE(0,"SfxFrame::CreateWorkWindow_Impl: Exception cachted. Please try to submit a repoducable bug !");
883cdf0e10cSrcweir }
884cdf0e10cSrcweir }
885cdf0e10cSrcweir
886cdf0e10cSrcweir pImp->pWorkWin = new SfxFrameWorkWin_Impl( &pFrame->GetWindow(), this, pFrame );
887cdf0e10cSrcweir }
888cdf0e10cSrcweir
GrabFocusOnComponent_Impl()889cdf0e10cSrcweir void SfxFrame::GrabFocusOnComponent_Impl()
890cdf0e10cSrcweir {
891cdf0e10cSrcweir if ( pImp->bReleasingComponent )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir GetWindow().GrabFocus();
894cdf0e10cSrcweir return;
895cdf0e10cSrcweir }
896cdf0e10cSrcweir
897cdf0e10cSrcweir Window* pFocusWindow = &GetWindow();
898cdf0e10cSrcweir if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
899cdf0e10cSrcweir pFocusWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow();
900cdf0e10cSrcweir
901cdf0e10cSrcweir if( !pFocusWindow->HasChildPathFocus() )
902cdf0e10cSrcweir pFocusWindow->GrabFocus();
903cdf0e10cSrcweir }
904cdf0e10cSrcweir
ReleasingComponent_Impl(sal_Bool bSet)905cdf0e10cSrcweir void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir pImp->bReleasingComponent = bSet;
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
IsInPlace() const910cdf0e10cSrcweir sal_Bool SfxFrame::IsInPlace() const
911cdf0e10cSrcweir {
912cdf0e10cSrcweir return pImp->bInPlace;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir
SetInPlace_Impl(sal_Bool bSet)915cdf0e10cSrcweir void SfxFrame::SetInPlace_Impl( sal_Bool bSet )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir pImp->bInPlace = bSet;
918cdf0e10cSrcweir }
919cdf0e10cSrcweir
Resize()920cdf0e10cSrcweir void SfxFrame::Resize()
921cdf0e10cSrcweir {
922cdf0e10cSrcweir if ( IsClosing_Impl() )
923cdf0e10cSrcweir return;
924cdf0e10cSrcweir
925cdf0e10cSrcweir if ( OwnsBindings_Impl() )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir if ( IsInPlace() )
928cdf0e10cSrcweir {
929cdf0e10cSrcweir SetToolSpaceBorderPixel_Impl( SvBorder() );
930cdf0e10cSrcweir }
931cdf0e10cSrcweir else
932cdf0e10cSrcweir {
933cdf0e10cSrcweir // check for IPClient that contains UIactive object or object that is currently UI activating
934cdf0e10cSrcweir SfxWorkWindow *pWork = GetWorkWindow_Impl();
935cdf0e10cSrcweir SfxInPlaceClient* pClient = GetCurrentViewFrame()->GetViewShell() ? GetCurrentViewFrame()->GetViewShell()->GetUIActiveIPClient_Impl() : 0;
936cdf0e10cSrcweir if ( pClient )
937cdf0e10cSrcweir {
938cdf0e10cSrcweir uno::Reference < lang::XUnoTunnel > xObj( pClient->GetObject()->getComponent(), uno::UNO_QUERY );
939cdf0e10cSrcweir uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
940cdf0e10cSrcweir sal_Int64 nHandle = (xObj.is()? xObj->getSomething( aSeq ): 0);
941cdf0e10cSrcweir if ( nHandle )
942cdf0e10cSrcweir {
943cdf0e10cSrcweir SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
944cdf0e10cSrcweir pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame().GetWorkWindow_Impl();
945cdf0e10cSrcweir }
946cdf0e10cSrcweir }
947cdf0e10cSrcweir
948cdf0e10cSrcweir if ( pWork )
949cdf0e10cSrcweir {
950cdf0e10cSrcweir pWork->ArrangeChilds_Impl();
951cdf0e10cSrcweir pWork->ShowChilds_Impl();
952cdf0e10cSrcweir }
953cdf0e10cSrcweir
954cdf0e10cSrcweir // problem in presence of UIActive object: when the window is resized, but the toolspace border
955cdf0e10cSrcweir // remains the same, setting the toolspace border at the ContainerEnvironment doesn't force a
956cdf0e10cSrcweir // resize on the IPEnvironment; without that no resize is called for the SfxViewFrame. So always
957cdf0e10cSrcweir // set the window size of the SfxViewFrame explicit.
958cdf0e10cSrcweir SetToolSpaceBorderPixel_Impl( pImp->aBorder );
959cdf0e10cSrcweir }
960cdf0e10cSrcweir }
961cdf0e10cSrcweir else if ( pImp->pCurrentViewFrame )
962cdf0e10cSrcweir {
963cdf0e10cSrcweir pImp->pCurrentViewFrame->GetWindow().SetSizePixel( GetWindow().GetOutputSizePixel() );
964cdf0e10cSrcweir }
965cdf0e10cSrcweir
966cdf0e10cSrcweir }
967cdf0e10cSrcweir
GetFirst()968cdf0e10cSrcweir SfxFrame* SfxFrame::GetFirst()
969cdf0e10cSrcweir {
970cdf0e10cSrcweir if ( !pFramesArr_Impl )
971cdf0e10cSrcweir return 0;
972cdf0e10cSrcweir return pFramesArr_Impl->Count() ? pFramesArr_Impl->GetObject(0) : 0;
973cdf0e10cSrcweir }
974cdf0e10cSrcweir
GetNext(SfxFrame & rFrame)975cdf0e10cSrcweir SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir sal_uInt16 nPos = pFramesArr_Impl->GetPos( &rFrame );
978cdf0e10cSrcweir if ( nPos+1 < pFramesArr_Impl->Count() )
979cdf0e10cSrcweir return pFramesArr_Impl->GetObject(nPos+1);
980cdf0e10cSrcweir else
981cdf0e10cSrcweir return NULL;
982cdf0e10cSrcweir }
983cdf0e10cSrcweir
OpenDocumentSynchron(SfxItemSet & i_rSet,const Reference<XFrame> & i_rTargetFrame)984cdf0e10cSrcweir const SfxPoolItem* SfxFrame::OpenDocumentSynchron( SfxItemSet& i_rSet, const Reference< XFrame >& i_rTargetFrame )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir i_rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, i_rTargetFrame ) );
987cdf0e10cSrcweir i_rSet.ClearItem( SID_TARGETNAME );
988cdf0e10cSrcweir return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, i_rSet );
989cdf0e10cSrcweir }
990cdf0e10cSrcweir
991