1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/embed/EmbedStates.hpp>
21 #include <com/sun/star/uno/Reference.h>
22 #include <com/sun/star/awt/XWindow.hpp>
23 #include <com/sun/star/util/XURLTransformer.hpp>
24 #include <com/sun/star/util/XCloseable.hpp>
25 #include <com/sun/star/util/CloseVetoException.hpp>
26 #include <com/sun/star/lang/XComponent.hpp>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <com/sun/star/container/XChild.hpp>
30 #include <vcl/menu.hxx>
31 #include <svl/intitem.hxx>
32 #include <vcl/splitwin.hxx>
33 #include <svl/eitem.hxx>
34 #include <svl/stritem.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <com/sun/star/awt/PosSize.hpp>
37 #include <comphelper/processfactory.hxx>
38 #include <vcl/msgbox.hxx>
41 #include "appdata.hxx"
42 #include <sfx2/app.hxx>
43 #include <sfx2/event.hxx>
44 #include <sfx2/unoctitm.hxx>
45 #include <sfx2/frame.hxx>
46 #include "arrdecl.hxx"
47 #include <sfx2/objsh.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/docfile.hxx>
50 #include <sfx2/docfilt.hxx>
51 #include <sfx2/frmdescr.hxx>
52 #include "openflag.hxx"
53 #include <sfx2/viewsh.hxx>
54 #include <sfx2/viewfrm.hxx>
55 #include <sfx2/request.hxx>
56 #include <sfx2/fcontnr.hxx>
57 #include "impframe.hxx"
58 #include <sfx2/appuno.hxx>
59 #include "workwin.hxx"
60 #include <sfx2/sfxuno.hxx>
61 #include <sfx2/msgpool.hxx>
62 #include "objshimp.hxx"
63 #include <sfx2/ipclient.hxx>
66 #include <sfx2/frmhtmlw.hxx>
69 using namespace com::sun::star
;
71 static SfxFrameArr_Impl
* pFramesArr_Impl
=0;
73 using namespace ::com::sun::star::uno
;
74 using namespace ::com::sun::star::util
;
75 using namespace ::com::sun::star::frame
;
76 using namespace ::com::sun::star::container
;
78 TYPEINIT1(SfxFrame
, SfxListener
);
79 TYPEINIT1_AUTOFACTORY(SfxFrameItem
, SfxPoolItem
);
80 TYPEINIT1(SfxUsrAnyItem
, SfxPoolItem
);
81 TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem
, SfxPoolItem
);
83 SvCompatWeakHdl
* SfxFrame::GetHdl()
85 return pImp
->GetHdl();
88 //--------------------------------------------------------------------
89 void SfxFrame::Construct_Impl()
91 pImp
= new SfxFrame_Impl( this );
92 if ( !pFramesArr_Impl
)
93 pFramesArr_Impl
= new SfxFrameArr_Impl
;
94 pFramesArr_Impl
->push_back( this );
97 //--------------------------------------------------------------------
101 RemoveTopFrame_Impl( this );
104 SfxFrameArr_Impl::iterator it
= std::find( pFramesArr_Impl
->begin(), pFramesArr_Impl
->end(), this );
105 if ( it
!= pFramesArr_Impl
->end() )
106 pFramesArr_Impl
->erase( it
);
110 pParentFrame
->RemoveChildFrame_Impl( this );
118 DBG_ASSERT( pChildArr
->empty(), "Children are not removed!" );
125 sal_Bool
SfxFrame::DoClose()
127 // Actually, one more PrepareClose is still needed!
128 sal_Bool bRet
= sal_False
;
129 if ( !pImp
->bClosing
)
131 pImp
->bClosing
= sal_True
;
134 // now close frame; it will be deleted if this call is successful, so don't use any members after that!
138 Reference
< XCloseable
> xCloseable ( pImp
->xFrame
, UNO_QUERY
);
139 if ( (!GetCurrentDocument() || !GetCurrentDocument()->Get_Impl()->bDisposing
) && xCloseable
.is())
140 xCloseable
->close(sal_True
);
141 else if ( pImp
->xFrame
.is() )
143 Reference
< XFrame
> xFrame
= pImp
->xFrame
;
144 xFrame
->setComponent( Reference
< com::sun::star::awt::XWindow
>(), Reference
< XController
>() );
148 bRet
= DoClose_Impl();
150 catch( ::com::sun::star::util::CloseVetoException
& )
152 pImp
->bClosing
= sal_False
;
155 catch( ::com::sun::star::lang::DisposedException
& )
163 sal_Bool
SfxFrame::DoClose_Impl()
165 sal_Bool bRet
= sal_True
;
166 SfxBindings
* pBindings
= NULL
;
167 if ( pImp
->pCurrentViewFrame
)
168 pBindings
= &pImp
->pCurrentViewFrame
->GetBindings();
170 // For internal tasks Controllers and Tools must be cleared
171 if ( pImp
->pWorkWin
)
172 pImp
->pWorkWin
->DeleteControllers_Impl();
174 if ( pImp
->pCurrentViewFrame
)
175 bRet
= pImp
->pCurrentViewFrame
->Close();
177 if ( pImp
->bOwnsBindings
)
178 DELETEZ( pBindings
);
181 DBG_ASSERT( bRet
, "Impossible state: frame closes, but controller refuses!");
185 sal_Bool
SfxFrame::DocIsModified_Impl()
187 if ( pImp
->pCurrentViewFrame
&& pImp
->pCurrentViewFrame
->GetObjectShell() &&
188 pImp
->pCurrentViewFrame
->GetObjectShell()->IsModified() )
190 for( sal_uInt16 nPos
= GetChildFrameCount(); nPos
--; )
191 if( (*pChildArr
)[ nPos
]->DocIsModified_Impl() )
196 sal_uInt16
SfxFrame::PrepareClose_Impl( sal_Bool bUI
, sal_Bool bForBrowsing
)
198 sal_uInt16 nRet
= RET_OK
;
200 // prevent recursive calls
201 if( !pImp
->bPrepClosing
)
203 pImp
->bPrepClosing
= sal_True
;
205 SfxObjectShell
* pCur
= GetCurrentDocument() ;
208 // SFX components have a known behaviour
209 // First check if this frame is the only view to its current document
210 int bOther
= sal_False
;
211 for ( const SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( pCur
);
212 !bOther
&& pFrame
; pFrame
= SfxViewFrame::GetNext( *pFrame
, pCur
) )
214 bOther
= ( &pFrame
->GetFrame() != this );
217 SFX_APP()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW
, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW
), pCur
, GetController() ) );
220 // if there are other views only the current view of this frame must be asked
221 nRet
= GetCurrentViewFrame()->GetViewShell()->PrepareClose( bUI
, bForBrowsing
);
223 // otherwise ask the document
224 nRet
= pCur
->PrepareClose( bUI
, bForBrowsing
);
227 if ( nRet
== RET_OK
)
229 // if this frame has child frames, ask them too
230 for( sal_uInt16 nPos
= GetChildFrameCount(); nRet
== RET_OK
&& nPos
--; )
231 nRet
= (*pChildArr
)[ nPos
]->PrepareClose_Impl( bUI
, bForBrowsing
);
234 pImp
->bPrepClosing
= sal_False
;
237 if ( nRet
== RET_OK
&& pImp
->pWorkWin
)
238 // if closing was accepted by the component the UI subframes must be asked also
239 nRet
= pImp
->pWorkWin
->PrepareClose_Impl();
244 //--------------------------------------------------------------------
246 SfxFrame
* SfxFrame::GetChildFrame( sal_uInt16 nPos
) const
248 if ( pChildArr
&& pChildArr
->size() > nPos
)
250 DBG_ASSERT( nPos
< pChildArr
->size(), "Wrong Index!");
251 return (*pChildArr
)[nPos
];
257 void SfxFrame::RemoveChildFrame_Impl( SfxFrame
* pFrame
)
259 DBG_ASSERT( pChildArr
, "Unknown Frame!");
260 SfxFrameArr_Impl::iterator it
= std::find( pChildArr
->begin(), pChildArr
->end(), pFrame
);
261 if ( it
!= pChildArr
->end() )
262 pChildArr
->erase( it
);
265 SfxFrame
& SfxFrame::GetTopFrame() const
267 const SfxFrame
* pParent
= this;
268 while ( pParent
->pParentFrame
)
269 pParent
= pParent
->pParentFrame
;
270 return *const_cast< SfxFrame
* >( pParent
);
273 sal_Bool
SfxFrame::IsClosing_Impl() const
275 return pImp
->bClosing
;
278 void SfxFrame::SetIsClosing_Impl()
280 pImp
->bClosing
= sal_True
;
283 sal_uInt16
SfxFrame::GetChildFrameCount() const
285 return pChildArr
? pChildArr
->size() : 0;
288 void SfxFrame::CancelTransfers( sal_Bool
/*bCancelLoadEnv*/ )
290 if( !pImp
->bInCancelTransfers
)
292 pImp
->bInCancelTransfers
= sal_True
;
293 SfxObjectShell
* pObj
= GetCurrentDocument();
294 if( pObj
) //&& !( pObj->Get_Impl()->nLoadedFlags & SFX_LOADED_ALL ))
297 for( pFrm
= SfxViewFrame::GetFirst( pObj
);
298 pFrm
&& &pFrm
->GetFrame() == this;
299 pFrm
= SfxViewFrame::GetNext( *pFrm
, pObj
) ) ;
300 // No more Frame in Document -> Cancel
303 pObj
->CancelTransfers();
304 GetCurrentDocument()->Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
308 // First stop multiload Frames
309 sal_uInt16 nCount
= GetChildFrameCount();
310 for( sal_uInt16 n
= 0; n
<nCount
; n
++ )
311 GetChildFrame( n
)->CancelTransfers();
313 // Check if StarOne-Loader should be canceled
314 SfxFrameWeak
wFrame( this );
316 pImp
->bInCancelTransfers
= sal_False
;
320 SfxViewFrame
* SfxFrame::GetCurrentViewFrame() const
322 return pImp
->pCurrentViewFrame
;
325 SfxDispatcher
* SfxFrame::GetDispatcher_Impl() const
327 if ( pImp
->pCurrentViewFrame
)
328 return pImp
->pCurrentViewFrame
->GetDispatcher();
329 return GetParentFrame()->GetDispatcher_Impl();
332 SfxObjectShell
* SfxFrame::GetCurrentDocument() const
334 return pImp
->pCurrentViewFrame
?
335 pImp
->pCurrentViewFrame
->GetObjectShell() :
339 void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame
*pFrame
)
341 pImp
->pCurrentViewFrame
= pFrame
;
344 sal_uInt32
SfxFrame::GetFrameType() const
349 void SfxFrame::SetFrameType_Impl( sal_uInt32 n
)
354 void SfxFrame::GetViewData_Impl()
356 // Update all modifiable data between load and unload, the
357 // fixed data is only processed once (after PrepareForDoc_Impl in
358 // updateDescriptor) to save time.
360 SfxViewFrame
* pViewFrame
= GetCurrentViewFrame();
361 if( pViewFrame
&& pViewFrame
->GetViewShell() )
363 const SfxMedium
*pMed
= GetCurrentDocument()->GetMedium();
364 sal_Bool bReadOnly
= pMed
->GetOpenMode() == SFX_STREAM_READONLY
;
365 GetDescriptor()->SetReadOnly( bReadOnly
);
367 SfxItemSet
*pSet
= GetDescriptor()->GetArgs();
368 sal_Bool bGetViewData
= sal_False
;
369 if ( GetController().is() && pSet
->GetItemState( SID_VIEW_DATA
) != SFX_ITEM_SET
)
371 ::com::sun::star::uno::Any aData
= GetController()->getViewData();
372 pSet
->Put( SfxUsrAnyItem( SID_VIEW_DATA
, aData
) );
373 bGetViewData
= sal_True
;
376 if ( pViewFrame
->GetCurViewId() )
377 pSet
->Put( SfxUInt16Item( SID_VIEW_ID
, pViewFrame
->GetCurViewId() ) );
380 // For Framesets also the data from the ChildViews hace to be processed
381 sal_uInt16 nCount
= pChildArr
->size();
382 for ( sal_uInt16 n
=nCount
; n
>0; n
--)
384 SfxFrame
* pFrame
= (*pChildArr
)[n
-1];
386 pFrame
->GetDescriptor()->GetArgs()->ClearItem( SID_VIEW_DATA
);
387 pFrame
->GetViewData_Impl();
393 void SfxFrame::UpdateDescriptor( SfxObjectShell
*pDoc
)
395 // For PrepareForDoc_Impl frames, the descriptor of the updated
396 // and new itemset to be initialized. All data fir restoring the view
397 // are thus saved. If the document be replaced, GetViewData_Impl (so)
398 // the latest information hinzugef by "added. All together then the
399 // browser-history saved in. When you activate such frame pick entry
400 // is complete itemsets and the descriptor in the OpenDoc sent;.
401 // Here only the fixed properties identified "other adjustable, the
402 // retrieved by GetViewData (saves time).
404 DBG_ASSERT( pDoc
, "NULL-Document inserted ?!" );
407 const SfxMedium
*pMed
= pDoc
->GetMedium();
408 GetDescriptor()->SetActualURL( String(pMed
->GetOrigURL()) );
410 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pItem
, SfxBoolItem
, SID_EDITDOC
, sal_False
);
411 sal_Bool bEditable
= ( !pItem
|| pItem
->GetValue() );
413 GetDescriptor()->SetEditable( bEditable
);
415 // Mark FileOpen parameter
416 SfxItemSet
* pItemSet
= pMed
->GetItemSet();
418 const SfxFilter
* pFilter
= pMed
->GetOrigFilter();
421 aFilter
= pFilter
->GetFilterName();
423 SFX_ITEMSET_ARG( pItemSet
, pRefererItem
, SfxStringItem
, SID_REFERER
, sal_False
);
424 SFX_ITEMSET_ARG( pItemSet
, pOptionsItem
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, sal_False
);
425 SFX_ITEMSET_ARG( pItemSet
, pTitle1Item
, SfxStringItem
, SID_DOCINFO_TITLE
, sal_False
);
427 SfxItemSet
*pSet
= GetDescriptor()->GetArgs();
429 // Delete all old Items
433 pSet
->Put( *pRefererItem
);
435 pSet
->Put( SfxStringItem( SID_REFERER
, String() ) );
438 pSet
->Put( *pOptionsItem
);
441 pSet
->Put( *pTitle1Item
);
443 pSet
->Put( SfxStringItem( SID_FILTER_NAME
, aFilter
));
446 //-------------------------------------------------------------------------
448 SfxFrameDescriptor
* SfxFrame::GetDescriptor() const
450 // Create a FrameDescriptor On Demand; if there is no TopLevel-Frame
451 // will result in an error, as no valid link is created.
455 DBG_ASSERT( !GetParentFrame(), "No TopLevel-Frame, but no Descriptor!" );
456 pImp
->pDescr
= new SfxFrameDescriptor
;
457 if ( GetCurrentDocument() )
458 pImp
->pDescr
->SetURL( GetCurrentDocument()->GetMedium()->GetOrigURL() );
463 //-------------------------------------------------------------------------
465 void SfxFrame::GetTargetList( TargetList
& rList
) const
467 if ( !GetParentFrame() )
469 // An empty string for 'No Target'
470 rList
.push_back( new String() );
471 rList
.push_back( new String( "_top" ) );
472 rList
.push_back( new String( "_parent" ) );
473 rList
.push_back( new String( "_blank" ) );
474 rList
.push_back( new String( "_self" ) );
477 SfxViewFrame
* pView
= GetCurrentViewFrame();
478 if( pView
&& pView
->GetViewShell() && pChildArr
)
480 sal_uInt16 nCount
= pChildArr
->size();
481 for ( sal_uInt16 n
=0; n
<nCount
; n
++)
483 SfxFrame
* pFrame
= (*pChildArr
)[n
];
484 pFrame
->GetTargetList( rList
);
489 //-------------------------------------------------------------------------
491 sal_Bool
SfxFrame::IsParent( SfxFrame
*pFrame
) const
493 SfxFrame
*pParent
= pParentFrame
;
496 if ( pParent
== pFrame
)
498 pParent
= pParent
->pParentFrame
;
504 void SfxFrame::InsertTopFrame_Impl( SfxFrame
* pFrame
)
506 SfxFrameArr_Impl
& rArr
= *SFX_APP()->Get_Impl()->pTopFrames
;
507 rArr
.push_back( pFrame
);
510 void SfxFrame::RemoveTopFrame_Impl( SfxFrame
* pFrame
)
512 SfxFrameArr_Impl
& rArr
= *SFX_APP()->Get_Impl()->pTopFrames
;
513 SfxFrameArr_Impl::iterator it
= std::find( rArr
.begin(), rArr
.end(), pFrame
);
514 if ( it
!= rArr
.end() )
518 SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId
, SfxViewFrame
*p
)
519 : SfxPoolItem( nWhichId
), pFrame( p
? &p
->GetFrame() : NULL
)
524 SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId
, SfxFrame
*p
):
525 SfxPoolItem( nWhichId
),
526 pFrame( p
), wFrame( p
)
530 SfxFrameItem::SfxFrameItem( SfxFrame
*p
):
532 pFrame( p
), wFrame( p
)
536 int SfxFrameItem::operator==( const SfxPoolItem
&rItem
) const
538 return ((SfxFrameItem
&)rItem
).pFrame
== pFrame
&&
539 ((SfxFrameItem
&)rItem
).wFrame
== wFrame
;
542 //--------------------------------------------------------------------
544 String
SfxFrameItem::GetValueText() const
549 SfxPoolItem
* SfxFrameItem::Clone( SfxItemPool
*) const
551 SfxFrameItem
* pNew
= new SfxFrameItem( wFrame
);
552 pNew
->SetFramePtr_Impl( pFrame
);
556 bool SfxFrameItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
560 rVal
<<= wFrame
->GetFrameInterface();
567 bool SfxFrameItem::PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
569 Reference
< XFrame
> xFrame
;
570 if ( (rVal
>>= xFrame
) && xFrame
.is() )
572 SfxFrame
* pFr
= SfxFrame::GetFirst();
575 if ( pFr
->GetFrameInterface() == xFrame
)
577 wFrame
= pFrame
= pFr
;
581 pFr
= SfxFrame::GetNext( *pFr
);
590 SfxUsrAnyItem::SfxUsrAnyItem( sal_uInt16 nWhichId
, const ::com::sun::star::uno::Any
& rAny
)
591 : SfxPoolItem( nWhichId
)
596 int SfxUsrAnyItem::operator==( const SfxPoolItem
& /*rItem*/ ) const
601 SfxPoolItem
* SfxUsrAnyItem::Clone( SfxItemPool
*) const
603 return new SfxUsrAnyItem( Which(), aValue
);
606 bool SfxUsrAnyItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
612 bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
618 SfxUnoFrameItem::SfxUnoFrameItem()
624 SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rFrame
)
625 : SfxPoolItem( nWhichId
)
626 , m_xFrame( i_rFrame
)
630 int SfxUnoFrameItem::operator==( const SfxPoolItem
& i_rItem
) const
632 return i_rItem
.ISA( SfxUnoFrameItem
) && static_cast< const SfxUnoFrameItem
& >( i_rItem
).m_xFrame
== m_xFrame
;
635 SfxPoolItem
* SfxUnoFrameItem::Clone( SfxItemPool
* ) const
637 return new SfxUnoFrameItem( Which(), m_xFrame
);
640 bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
646 bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
648 return ( rVal
>>= m_xFrame
);
651 SfxFrameIterator::SfxFrameIterator( const SfxFrame
& rFrame
, sal_Bool bRecur
)
653 , bRecursive( bRecur
)
656 SfxFrame
* SfxFrameIterator::FirstFrame()
658 // GetFirst starts the iteration at the first child frame
659 return pFrame
->GetChildFrame( 0 );
662 SfxFrame
* SfxFrameIterator::NextFrame( SfxFrame
& rPrev
)
664 // If recursion is requested testing is done first on Children.
665 SfxFrame
*pRet
= NULL
;
667 pRet
= rPrev
.GetChildFrame( 0 );
670 // In other case continue with the siblings of rPrev
671 pRet
= NextSibling_Impl( rPrev
);
678 SfxFrame
* SfxFrameIterator::NextSibling_Impl( SfxFrame
& rPrev
)
680 SfxFrame
*pRet
= NULL
;
681 if ( &rPrev
!= pFrame
)
683 SfxFrameArr_Impl
& rArr
= *rPrev
.pParentFrame
->pChildArr
;
684 SfxFrameArr_Impl::iterator it
= std::find( rArr
.begin(), rArr
.end(), &rPrev
);
685 if ( it
!= rArr
.end() && (++it
) != rArr
.end() )
688 if ( !pRet
&& rPrev
.pParentFrame
->pParentFrame
)
689 pRet
= NextSibling_Impl( *rPrev
.pParentFrame
);
695 sal_Bool
SfxFrame::HasComponent() const
700 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> SfxFrame::GetController() const
702 if ( pImp
->pCurrentViewFrame
&& pImp
->pCurrentViewFrame
->GetViewShell() )
703 return pImp
->pCurrentViewFrame
->GetViewShell()->GetController();
705 return ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> ();
708 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> SfxFrame::GetFrameInterface() const
713 void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
)
715 pImp
->xFrame
= rFrame
;
716 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorder
> xRecorder
;
717 if ( !rFrame
.is() && GetCurrentViewFrame() )
718 GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder
);
721 void SfxFrame::Appear()
723 if ( GetCurrentViewFrame() )
725 GetCurrentViewFrame()->Show();
727 pImp
->xFrame
->getContainerWindow()->setVisible( sal_True
);
729 pParentFrame
->Appear();
730 Reference
< ::com::sun::star::awt::XTopWindow
> xTopWindow( pImp
->xFrame
->getContainerWindow(), UNO_QUERY
);
731 if ( xTopWindow
.is() )
732 xTopWindow
->toFront();
736 void SfxFrame::AppearWithUpdate()
739 if ( GetCurrentViewFrame() )
740 GetCurrentViewFrame()->GetDispatcher()->Update_Impl( sal_True
);
743 void SfxFrame::SetOwnsBindings_Impl( sal_Bool bSet
)
745 pImp
->bOwnsBindings
= bSet
;
748 sal_Bool
SfxFrame::OwnsBindings_Impl() const
750 return pImp
->bOwnsBindings
;
753 void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder
& rBorder
)
755 pImp
->aBorder
= rBorder
;
756 SfxViewFrame
*pF
= GetCurrentViewFrame();
759 Point
aPos ( rBorder
.Left(), rBorder
.Top() );
760 Size
aSize( GetWindow().GetOutputSizePixel() );
761 long nDeltaX
= rBorder
.Left() + rBorder
.Right();
762 if ( aSize
.Width() > nDeltaX
)
763 aSize
.Width() -= nDeltaX
;
767 long nDeltaY
= rBorder
.Top() + rBorder
.Bottom();
768 if ( aSize
.Height() > nDeltaY
)
769 aSize
.Height() -= nDeltaY
;
773 if ( GetParentFrame() )
775 sal_Bool bHasTools
= rBorder
.Left() != rBorder
.Right() || rBorder
.Top() != rBorder
.Bottom();
776 pF
->GetWindow().SetBorderStyle( bHasTools
? WINDOW_BORDER_NORMAL
: WINDOW_BORDER_NOBORDER
);
779 pF
->GetWindow().SetPosSizePixel( aPos
, aSize
);
783 Rectangle
SfxFrame::GetTopOuterRectPixel_Impl() const
785 Size
aSize( GetWindow().GetOutputSizePixel() );
787 return ( Rectangle ( aPoint
, aSize
) );
790 SfxWorkWindow
* SfxFrame::GetWorkWindow_Impl() const
792 if ( pImp
->pWorkWin
)
793 return pImp
->pWorkWin
;
794 else if ( pParentFrame
)
795 return pParentFrame
->GetWorkWindow_Impl();
800 void SfxFrame::CreateWorkWindow_Impl()
802 SfxFrame
* pFrame
= this;
806 // this makes sence only for inplace activated objects
809 Reference
< XChild
> xChild( GetCurrentDocument()->GetModel(), UNO_QUERY
);
812 Reference
< XModel
> xParent( xChild
->getParent(), UNO_QUERY
);
815 Reference
< XController
> xParentCtrler
= xParent
->getCurrentController();
816 if ( xParentCtrler
.is() )
818 Reference
< XFrame
> xFrame( xParentCtrler
->getFrame() );
819 SfxFrame
* pFr
= SfxFrame::GetFirst();
822 if ( pFr
->GetFrameInterface() == xFrame
)
828 pFr
= SfxFrame::GetNext( *pFr
);
836 OSL_FAIL("SfxFrame::CreateWorkWindow_Impl: Exception cachted. Please try to submit a repoducable bug !");
840 pImp
->pWorkWin
= new SfxFrameWorkWin_Impl( &pFrame
->GetWindow(), this, pFrame
);
843 void SfxFrame::GrabFocusOnComponent_Impl()
845 if ( pImp
->bReleasingComponent
)
847 GetWindow().GrabFocus();
851 Window
* pFocusWindow
= &GetWindow();
852 if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
853 pFocusWindow
= GetCurrentViewFrame()->GetViewShell()->GetWindow();
855 if( !pFocusWindow
->HasChildPathFocus() )
856 pFocusWindow
->GrabFocus();
859 void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet
)
861 pImp
->bReleasingComponent
= bSet
;
864 sal_Bool
SfxFrame::IsInPlace() const
866 return pImp
->bInPlace
;
869 void SfxFrame::SetInPlace_Impl( sal_Bool bSet
)
871 pImp
->bInPlace
= bSet
;
874 void SfxFrame::Resize()
876 if ( IsClosing_Impl() )
879 if ( OwnsBindings_Impl() )
883 SetToolSpaceBorderPixel_Impl( SvBorder() );
887 // check for IPClient that contains UIactive object or object that is currently UI activating
888 SfxWorkWindow
*pWork
= GetWorkWindow_Impl();
889 SfxInPlaceClient
* pClient
= GetCurrentViewFrame()->GetViewShell() ? GetCurrentViewFrame()->GetViewShell()->GetUIActiveIPClient_Impl() : 0;
892 uno::Reference
< lang::XUnoTunnel
> xObj( pClient
->GetObject()->getComponent(), uno::UNO_QUERY
);
893 uno::Sequence
< sal_Int8
> aSeq( SvGlobalName( SFX_GLOBAL_CLASSID
).GetByteSequence() );
894 sal_Int64 nHandle
= (xObj
.is()? xObj
->getSomething( aSeq
): 0);
897 SfxObjectShell
* pDoc
= reinterpret_cast< SfxObjectShell
* >( sal::static_int_cast
< sal_IntPtr
>( nHandle
));
898 pWork
= SfxViewFrame::GetFirst( pDoc
)->GetFrame().GetWorkWindow_Impl();
904 pWork
->ArrangeChildren_Impl();
905 pWork
->ShowChildren_Impl();
908 // problem in presence of UIActive object: when the window is resized, but the toolspace border
909 // remains the same, setting the toolspace border at the ContainerEnvironment doesn't force a
910 // resize on the IPEnvironment; without that no resize is called for the SfxViewFrame. So always
911 // set the window size of the SfxViewFrame explicit.
912 SetToolSpaceBorderPixel_Impl( pImp
->aBorder
);
915 else if ( pImp
->pCurrentViewFrame
)
917 pImp
->pCurrentViewFrame
->GetWindow().SetSizePixel( GetWindow().GetOutputSizePixel() );
922 SfxFrame
* SfxFrame::GetFirst()
924 if ( !pFramesArr_Impl
)
926 return pFramesArr_Impl
->empty() ? 0 : pFramesArr_Impl
->front();
929 SfxFrame
* SfxFrame::GetNext( SfxFrame
& rFrame
)
931 SfxFrameArr_Impl::iterator it
= std::find( pFramesArr_Impl
->begin(), pFramesArr_Impl
->end(), &rFrame
);
932 if ( it
!= pFramesArr_Impl
->end() && (++it
) != pFramesArr_Impl
->end() )
938 const SfxPoolItem
* SfxFrame::OpenDocumentSynchron( SfxItemSet
& i_rSet
, const Reference
< XFrame
>& i_rTargetFrame
)
940 i_rSet
.Put( SfxUnoFrameItem( SID_FILLFRAME
, i_rTargetFrame
) );
941 i_rSet
.ClearItem( SID_TARGETNAME
);
942 return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC
, SFX_CALLMODE_SYNCHRON
, i_rSet
);
945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */