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 "workwin.hxx"
59 #include <sfx2/sfxuno.hxx>
60 #include <sfx2/msgpool.hxx>
61 #include "objshimp.hxx"
62 #include <sfx2/ipclient.hxx>
63 #include <childwinimpl.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 void SfxFrame::Construct_Impl()
85 pImp
= new SfxFrame_Impl( this );
86 if ( !pFramesArr_Impl
)
87 pFramesArr_Impl
= new SfxFrameArr_Impl
;
88 pFramesArr_Impl
->push_back( this );
95 RemoveTopFrame_Impl( this );
96 pWindow
.disposeAndClear();
98 SfxFrameArr_Impl::iterator it
= std::find( pFramesArr_Impl
->begin(), pFramesArr_Impl
->end(), this );
99 if ( it
!= pFramesArr_Impl
->end() )
100 pFramesArr_Impl
->erase( it
);
104 pParentFrame
->RemoveChildFrame_Impl( this );
112 DBG_ASSERT( pChildArr
->empty(), "Children are not removed!" );
119 bool SfxFrame::DoClose()
121 // Actually, one more PrepareClose is still needed!
123 if ( !pImp
->bClosing
)
125 pImp
->bClosing
= true;
128 // now close frame; it will be deleted if this call is successful, so don't use any members after that!
132 Reference
< XCloseable
> xCloseable ( pImp
->xFrame
, UNO_QUERY
);
133 if ( (!GetCurrentDocument() || !GetCurrentDocument()->Get_Impl()->bDisposing
) && xCloseable
.is())
134 xCloseable
->close(sal_True
);
135 else if ( pImp
->xFrame
.is() )
137 Reference
< XFrame
> xFrame
= pImp
->xFrame
;
138 xFrame
->setComponent( Reference
< com::sun::star::awt::XWindow
>(), Reference
< XController
>() );
142 bRet
= DoClose_Impl();
144 catch( ::com::sun::star::util::CloseVetoException
& )
146 pImp
->bClosing
= false;
149 catch( ::com::sun::star::lang::DisposedException
& )
157 bool SfxFrame::DoClose_Impl()
159 SfxBindings
* pBindings
= NULL
;
160 if ( pImp
->pCurrentViewFrame
)
161 pBindings
= &pImp
->pCurrentViewFrame
->GetBindings();
163 // For internal tasks Controllers and Tools must be cleared
164 if ( pImp
->pWorkWin
)
165 pImp
->pWorkWin
->DeleteControllers_Impl();
167 if ( pImp
->pCurrentViewFrame
)
168 pImp
->pCurrentViewFrame
->Close();
170 if ( pImp
->bOwnsBindings
)
171 DELETEZ( pBindings
);
174 DBG_ASSERT( bRet
, "Impossible state: frame closes, but controller refuses!");
178 bool SfxFrame::DocIsModified_Impl()
180 if ( pImp
->pCurrentViewFrame
&& pImp
->pCurrentViewFrame
->GetObjectShell() &&
181 pImp
->pCurrentViewFrame
->GetObjectShell()->IsModified() )
183 for( sal_uInt16 nPos
= GetChildFrameCount(); nPos
--; )
184 if( (*pChildArr
)[ nPos
]->DocIsModified_Impl() )
189 bool SfxFrame::PrepareClose_Impl( bool bUI
)
193 // prevent recursive calls
194 if( !pImp
->bPrepClosing
)
196 pImp
->bPrepClosing
= true;
198 SfxObjectShell
* pCur
= GetCurrentDocument() ;
201 // SFX components have a known behaviour
202 // First check if this frame is the only view to its current document
204 for ( const SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( pCur
);
205 !bOther
&& pFrame
; pFrame
= SfxViewFrame::GetNext( *pFrame
, pCur
) )
207 bOther
= ( &pFrame
->GetFrame() != this );
210 SfxGetpApp()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW
, GlobalEventConfig::GetEventName( GlobalEventId::PREPARECLOSEVIEW
), pCur
, GetController() ) );
213 // if there are other views only the current view of this frame must be asked
214 nRet
= GetCurrentViewFrame()->GetViewShell()->PrepareClose( bUI
);
216 // otherwise ask the document
217 nRet
= pCur
->PrepareClose( bUI
);
222 // if this frame has child frames, ask them too
223 for( sal_uInt16 nPos
= GetChildFrameCount(); nRet
&& nPos
--; )
224 nRet
= (*pChildArr
)[ nPos
]->PrepareClose_Impl( bUI
);
227 pImp
->bPrepClosing
= false;
230 if ( nRet
&& pImp
->pWorkWin
)
231 // if closing was accepted by the component the UI subframes must be asked also
232 nRet
= pImp
->pWorkWin
->PrepareClose_Impl();
239 SfxFrame
* SfxFrame::GetChildFrame( sal_uInt16 nPos
) const
241 if ( pChildArr
&& pChildArr
->size() > nPos
)
243 DBG_ASSERT( nPos
< pChildArr
->size(), "Wrong Index!");
244 return (*pChildArr
)[nPos
];
250 void SfxFrame::RemoveChildFrame_Impl( SfxFrame
* pFrame
)
252 DBG_ASSERT( pChildArr
, "Unknown Frame!");
253 SfxFrameArr_Impl::iterator it
= std::find( pChildArr
->begin(), pChildArr
->end(), pFrame
);
254 if ( it
!= pChildArr
->end() )
255 pChildArr
->erase( it
);
258 SfxFrame
& SfxFrame::GetTopFrame() const
260 const SfxFrame
* pParent
= this;
261 while ( pParent
->pParentFrame
)
262 pParent
= pParent
->pParentFrame
;
263 return *const_cast< SfxFrame
* >( pParent
);
266 bool SfxFrame::IsClosing_Impl() const
268 return pImp
->bClosing
;
271 void SfxFrame::SetIsClosing_Impl()
273 pImp
->bClosing
= true;
276 sal_uInt16
SfxFrame::GetChildFrameCount() const
278 return pChildArr
? pChildArr
->size() : 0;
281 void SfxFrame::CancelTransfers( bool /*bCancelLoadEnv*/ )
283 if( !pImp
->bInCancelTransfers
)
285 pImp
->bInCancelTransfers
= true;
286 SfxObjectShell
* pObj
= GetCurrentDocument();
287 if( pObj
) //&& !( pObj->Get_Impl()->nLoadedFlags & SfxLoadedFlags::ALL ))
290 for( pFrm
= SfxViewFrame::GetFirst( pObj
);
291 pFrm
&& &pFrm
->GetFrame() == this;
292 pFrm
= SfxViewFrame::GetNext( *pFrm
, pObj
) ) ;
293 // No more Frame in Document -> Cancel
296 pObj
->CancelTransfers();
297 GetCurrentDocument()->Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
301 // First stop multiload Frames
302 sal_uInt16 nCount
= GetChildFrameCount();
303 for( sal_uInt16 n
= 0; n
<nCount
; n
++ )
304 GetChildFrame( n
)->CancelTransfers();
306 // Check if StarOne-Loader should be canceled
307 SfxFrameWeakRef
wFrame( this );
309 pImp
->bInCancelTransfers
= false;
313 SfxViewFrame
* SfxFrame::GetCurrentViewFrame() const
315 return pImp
->pCurrentViewFrame
;
318 SfxDispatcher
* SfxFrame::GetDispatcher_Impl() const
320 if ( pImp
->pCurrentViewFrame
)
321 return pImp
->pCurrentViewFrame
->GetDispatcher();
322 return GetParentFrame()->GetDispatcher_Impl();
325 bool SfxFrame::IsAutoLoadLocked_Impl() const
327 // Its own Docucument is locked?
328 const SfxObjectShell
* pObjSh
= GetCurrentDocument();
329 if ( !pObjSh
|| !pObjSh
->IsAutoLoadLocked() )
332 // Its children are locked?
333 for ( sal_uInt16 n
= GetChildFrameCount(); n
--; )
334 if ( !GetChildFrame(n
)->IsAutoLoadLocked_Impl() )
337 // otherwise allow AutoLoad
341 SfxObjectShell
* SfxFrame::GetCurrentDocument() const
343 return pImp
->pCurrentViewFrame
?
344 pImp
->pCurrentViewFrame
->GetObjectShell() :
348 void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame
*pFrame
)
350 pImp
->pCurrentViewFrame
= pFrame
;
353 sal_uInt32
SfxFrame::GetFrameType() const
358 void SfxFrame::SetFrameType_Impl( sal_uInt32 n
)
363 void SfxFrame::GetViewData_Impl()
365 // Update all modifiable data between load and unload, the
366 // fixed data is only processed once (after PrepareForDoc_Impl in
367 // updateDescriptor) to save time.
369 SfxViewFrame
* pViewFrame
= GetCurrentViewFrame();
370 if( pViewFrame
&& pViewFrame
->GetViewShell() )
372 const SfxMedium
*pMed
= GetCurrentDocument()->GetMedium();
373 bool bReadOnly
= pMed
->GetOpenMode() == SFX_STREAM_READONLY
;
374 GetDescriptor()->SetReadOnly( bReadOnly
);
376 SfxItemSet
*pSet
= GetDescriptor()->GetArgs();
377 bool bGetViewData
= false;
378 if ( GetController().is() && pSet
->GetItemState( SID_VIEW_DATA
) != SfxItemState::SET
)
380 ::com::sun::star::uno::Any aData
= GetController()->getViewData();
381 pSet
->Put( SfxUsrAnyItem( SID_VIEW_DATA
, aData
) );
385 if ( pViewFrame
->GetCurViewId() )
386 pSet
->Put( SfxUInt16Item( SID_VIEW_ID
, pViewFrame
->GetCurViewId() ) );
389 // For Framesets also the data from the ChildViews hace to be processed
390 sal_uInt16 nCount
= pChildArr
->size();
391 for ( sal_uInt16 n
=nCount
; n
>0; n
--)
393 SfxFrame
* pFrame
= (*pChildArr
)[n
-1];
395 pFrame
->GetDescriptor()->GetArgs()->ClearItem( SID_VIEW_DATA
);
396 pFrame
->GetViewData_Impl();
402 void SfxFrame::UpdateDescriptor( SfxObjectShell
*pDoc
)
404 // For PrepareForDoc_Impl frames, the descriptor of the updated
405 // and new itemset to be initialized. All data fir restoring the view
406 // are thus saved. If the document be replaced, GetViewData_Impl (so)
407 // the latest information hinzugef by "added. All together then the
408 // browser-history saved in. When you activate such frame pick entry
409 // is complete itemsets and the descriptor in the OpenDoc sent;.
410 // Here only the fixed properties identified "other adjustable, the
411 // retrieved by GetViewData (saves time).
413 assert(pDoc
&& "NULL-Document inserted ?!");
416 const SfxMedium
*pMed
= pDoc
->GetMedium();
417 GetDescriptor()->SetActualURL( pMed
->GetOrigURL() );
419 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pItem
, SfxBoolItem
, SID_EDITDOC
, false );
420 bool bEditable
= ( !pItem
|| pItem
->GetValue() );
422 GetDescriptor()->SetEditable( bEditable
);
424 // Mark FileOpen parameter
425 SfxItemSet
* pItemSet
= pMed
->GetItemSet();
427 const SfxFilter
* pFilter
= pMed
->GetOrigFilter();
430 aFilter
= pFilter
->GetFilterName();
432 SFX_ITEMSET_ARG( pItemSet
, pRefererItem
, SfxStringItem
, SID_REFERER
, false);
433 SFX_ITEMSET_ARG( pItemSet
, pOptionsItem
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, false);
434 SFX_ITEMSET_ARG( pItemSet
, pTitle1Item
, SfxStringItem
, SID_DOCINFO_TITLE
, false);
436 SfxItemSet
*pSet
= GetDescriptor()->GetArgs();
438 // Delete all old Items
442 pSet
->Put( *pRefererItem
);
444 pSet
->Put( SfxStringItem( SID_REFERER
, OUString() ) );
447 pSet
->Put( *pOptionsItem
);
450 pSet
->Put( *pTitle1Item
);
452 pSet
->Put( SfxStringItem( SID_FILTER_NAME
, aFilter
));
457 SfxFrameDescriptor
* SfxFrame::GetDescriptor() const
459 // Create a FrameDescriptor On Demand; if there is no TopLevel-Frame
460 // will result in an error, as no valid link is created.
464 DBG_ASSERT( !GetParentFrame(), "No TopLevel-Frame, but no Descriptor!" );
465 pImp
->pDescr
= new SfxFrameDescriptor
;
466 if ( GetCurrentDocument() )
467 pImp
->pDescr
->SetURL( GetCurrentDocument()->GetMedium()->GetOrigURL() );
472 void SfxFrame::GetDefaultTargetList(TargetList
& rList
)
474 // An empty string for 'No Target'
475 rList
.push_back( OUString() );
476 rList
.push_back( OUString( "_top" ) );
477 rList
.push_back( OUString( "_parent" ) );
478 rList
.push_back( OUString( "_blank" ) );
479 rList
.push_back( OUString( "_self" ) );
482 void SfxFrame::GetTargetList( TargetList
& rList
) const
484 if ( !GetParentFrame() )
486 SfxFrame::GetDefaultTargetList(rList
);
489 SfxViewFrame
* pView
= GetCurrentViewFrame();
490 if( pView
&& pView
->GetViewShell() && pChildArr
)
492 sal_uInt16 nCount
= pChildArr
->size();
493 for ( sal_uInt16 n
=0; n
<nCount
; n
++)
495 SfxFrame
* pFrame
= (*pChildArr
)[n
];
496 pFrame
->GetTargetList( rList
);
501 bool SfxFrame::IsParent( SfxFrame
*pFrame
) const
503 SfxFrame
*pParent
= pParentFrame
;
506 if ( pParent
== pFrame
)
508 pParent
= pParent
->pParentFrame
;
514 void SfxFrame::InsertTopFrame_Impl( SfxFrame
* pFrame
)
516 SfxFrameArr_Impl
& rArr
= *SfxGetpApp()->Get_Impl()->pTopFrames
;
517 rArr
.push_back( pFrame
);
520 void SfxFrame::RemoveTopFrame_Impl( SfxFrame
* pFrame
)
522 SfxFrameArr_Impl
& rArr
= *SfxGetpApp()->Get_Impl()->pTopFrames
;
523 SfxFrameArr_Impl::iterator it
= std::find( rArr
.begin(), rArr
.end(), pFrame
);
524 if ( it
!= rArr
.end() )
528 SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId
, SfxViewFrame
*p
)
529 : SfxPoolItem( nWhichId
), pFrame( p
? &p
->GetFrame() : NULL
)
534 SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId
, SfxFrame
*p
):
535 SfxPoolItem( nWhichId
),
536 pFrame( p
), wFrame( p
)
540 SfxFrameItem::SfxFrameItem( SfxFrame
*p
):
542 pFrame( p
), wFrame( p
)
546 bool SfxFrameItem::operator==( const SfxPoolItem
&rItem
) const
548 return static_cast<const SfxFrameItem
&>(rItem
).pFrame
== pFrame
&&
549 static_cast<const SfxFrameItem
&>(rItem
).wFrame
== wFrame
;
552 SfxPoolItem
* SfxFrameItem::Clone( SfxItemPool
*) const
554 SfxFrameItem
* pNew
= new SfxFrameItem( wFrame
);
555 pNew
->SetFramePtr_Impl( pFrame
);
559 bool SfxFrameItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
563 rVal
<<= wFrame
->GetFrameInterface();
570 bool SfxFrameItem::PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
572 Reference
< XFrame
> xFrame
;
573 if ( (rVal
>>= xFrame
) && xFrame
.is() )
575 SfxFrame
* pFr
= SfxFrame::GetFirst();
578 if ( pFr
->GetFrameInterface() == xFrame
)
580 wFrame
= pFrame
= pFr
;
584 pFr
= SfxFrame::GetNext( *pFr
);
593 SfxUsrAnyItem::SfxUsrAnyItem( sal_uInt16 nWhichId
, const ::com::sun::star::uno::Any
& rAny
)
594 : SfxPoolItem( nWhichId
)
599 bool SfxUsrAnyItem::operator==( const SfxPoolItem
& /*rItem*/ ) const
604 SfxPoolItem
* SfxUsrAnyItem::Clone( SfxItemPool
*) const
606 return new SfxUsrAnyItem( Which(), aValue
);
609 bool SfxUsrAnyItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
615 bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
621 SfxUnoFrameItem::SfxUnoFrameItem()
627 SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rFrame
)
628 : SfxPoolItem( nWhichId
)
629 , m_xFrame( i_rFrame
)
633 bool SfxUnoFrameItem::operator==( const SfxPoolItem
& i_rItem
) const
635 return i_rItem
.ISA( SfxUnoFrameItem
) && static_cast< const SfxUnoFrameItem
& >( i_rItem
).m_xFrame
== m_xFrame
;
638 SfxPoolItem
* SfxUnoFrameItem::Clone( SfxItemPool
* ) const
640 return new SfxUnoFrameItem( Which(), m_xFrame
);
643 bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
649 bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
651 return ( rVal
>>= m_xFrame
);
654 SfxFrameIterator::SfxFrameIterator( const SfxFrame
& rFrame
, bool bRecur
)
656 , bRecursive( bRecur
)
659 SfxFrame
* SfxFrameIterator::FirstFrame()
661 // GetFirst starts the iteration at the first child frame
662 return pFrame
->GetChildFrame( 0 );
665 SfxFrame
* SfxFrameIterator::NextFrame( SfxFrame
& rPrev
)
667 // If recursion is requested testing is done first on Children.
668 SfxFrame
*pRet
= NULL
;
670 pRet
= rPrev
.GetChildFrame( 0 );
673 // In other case continue with the siblings of rPrev
674 pRet
= NextSibling_Impl( rPrev
);
681 SfxFrame
* SfxFrameIterator::NextSibling_Impl( SfxFrame
& rPrev
)
683 SfxFrame
*pRet
= NULL
;
684 if ( &rPrev
!= pFrame
)
686 SfxFrameArr_Impl
& rArr
= *rPrev
.pParentFrame
->pChildArr
;
687 SfxFrameArr_Impl::iterator it
= std::find( rArr
.begin(), rArr
.end(), &rPrev
);
688 if ( it
!= rArr
.end() && (++it
) != rArr
.end() )
691 if ( !pRet
&& rPrev
.pParentFrame
->pParentFrame
)
692 pRet
= NextSibling_Impl( *rPrev
.pParentFrame
);
698 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> SfxFrame::GetController() const
700 if ( pImp
->pCurrentViewFrame
&& pImp
->pCurrentViewFrame
->GetViewShell() )
701 return pImp
->pCurrentViewFrame
->GetViewShell()->GetController();
703 return ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> ();
706 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> SfxFrame::GetFrameInterface() const
711 void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
)
713 pImp
->xFrame
= rFrame
;
714 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorder
> xRecorder
;
715 if ( !rFrame
.is() && GetCurrentViewFrame() )
716 GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder
);
719 void SfxFrame::Appear()
721 if ( GetCurrentViewFrame() )
723 GetCurrentViewFrame()->Show();
725 pImp
->xFrame
->getContainerWindow()->setVisible( sal_True
);
727 pParentFrame
->Appear();
728 Reference
< ::com::sun::star::awt::XTopWindow
> xTopWindow( pImp
->xFrame
->getContainerWindow(), UNO_QUERY
);
729 if ( xTopWindow
.is() )
730 xTopWindow
->toFront();
734 void SfxFrame::AppearWithUpdate()
737 if ( GetCurrentViewFrame() )
738 GetCurrentViewFrame()->GetDispatcher()->Update_Impl( true );
741 void SfxFrame::SetOwnsBindings_Impl( bool bSet
)
743 pImp
->bOwnsBindings
= bSet
;
746 bool SfxFrame::OwnsBindings_Impl() const
748 return pImp
->bOwnsBindings
;
751 void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder
& rBorder
)
753 pImp
->aBorder
= rBorder
;
754 SfxViewFrame
*pF
= GetCurrentViewFrame();
757 Point
aPos ( rBorder
.Left(), rBorder
.Top() );
758 Size
aSize( GetWindow().GetOutputSizePixel() );
759 long nDeltaX
= rBorder
.Left() + rBorder
.Right();
760 if ( aSize
.Width() > nDeltaX
)
761 aSize
.Width() -= nDeltaX
;
765 long nDeltaY
= rBorder
.Top() + rBorder
.Bottom();
766 if ( aSize
.Height() > nDeltaY
)
767 aSize
.Height() -= nDeltaY
;
771 if ( GetParentFrame() )
773 bool bHasTools
= rBorder
.Left() != rBorder
.Right() || rBorder
.Top() != rBorder
.Bottom();
774 pF
->GetWindow().SetBorderStyle( bHasTools
? WindowBorderStyle::NORMAL
: WindowBorderStyle::NOBORDER
);
777 pF
->GetWindow().SetPosSizePixel( aPos
, aSize
);
781 Rectangle
SfxFrame::GetTopOuterRectPixel_Impl() const
783 Size
aSize( GetWindow().GetOutputSizePixel() );
785 return ( Rectangle ( aPoint
, aSize
) );
788 SfxWorkWindow
* SfxFrame::GetWorkWindow_Impl() const
790 if ( pImp
->pWorkWin
)
791 return pImp
->pWorkWin
;
792 else if ( pParentFrame
)
793 return pParentFrame
->GetWorkWindow_Impl();
798 void SfxFrame::CreateWorkWindow_Impl()
800 SfxFrame
* pFrame
= this;
804 // this makes sense only for inplace activated objects
807 Reference
< XChild
> xChild( GetCurrentDocument()->GetModel(), UNO_QUERY
);
810 Reference
< XModel
> xParent( xChild
->getParent(), UNO_QUERY
);
813 Reference
< XController
> xParentCtrler
= xParent
->getCurrentController();
814 if ( xParentCtrler
.is() )
816 Reference
< XFrame
> xFrame( xParentCtrler
->getFrame() );
817 SfxFrame
* pFr
= SfxFrame::GetFirst();
820 if ( pFr
->GetFrameInterface() == xFrame
)
826 pFr
= SfxFrame::GetNext( *pFr
);
834 OSL_FAIL("SfxFrame::CreateWorkWindow_Impl: Exception caught. Please try to submit a reproducable bug!");
838 pImp
->pWorkWin
= new SfxFrameWorkWin_Impl( &pFrame
->GetWindow(), this, pFrame
);
841 void SfxFrame::GrabFocusOnComponent_Impl()
843 if ( pImp
->bReleasingComponent
)
845 GetWindow().GrabFocus();
849 vcl::Window
* pFocusWindow
= &GetWindow();
850 if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
851 pFocusWindow
= GetCurrentViewFrame()->GetViewShell()->GetWindow();
853 if( !pFocusWindow
->HasChildPathFocus() )
854 pFocusWindow
->GrabFocus();
857 void SfxFrame::ReleasingComponent_Impl( bool bSet
)
859 pImp
->bReleasingComponent
= bSet
;
862 bool SfxFrame::IsInPlace() const
864 return pImp
->bInPlace
;
867 void SfxFrame::SetInPlace_Impl( bool bSet
)
869 pImp
->bInPlace
= bSet
;
872 void SfxFrame::Resize()
874 if ( IsClosing_Impl() )
877 if ( OwnsBindings_Impl() )
881 SetToolSpaceBorderPixel_Impl( SvBorder() );
885 // check for IPClient that contains UIactive object or object that is currently UI activating
886 SfxWorkWindow
*pWork
= GetWorkWindow_Impl();
887 SfxInPlaceClient
* pClient
= GetCurrentViewFrame()->GetViewShell() ? GetCurrentViewFrame()->GetViewShell()->GetUIActiveIPClient_Impl() : 0;
890 uno::Reference
< lang::XUnoTunnel
> xObj( pClient
->GetObject()->getComponent(), uno::UNO_QUERY
);
891 uno::Sequence
< sal_Int8
> aSeq( SvGlobalName( SFX_GLOBAL_CLASSID
).GetByteSequence() );
892 sal_Int64 nHandle
= (xObj
.is()? xObj
->getSomething( aSeq
): 0);
895 SfxObjectShell
* pDoc
= reinterpret_cast< SfxObjectShell
* >( sal::static_int_cast
< sal_IntPtr
>( nHandle
));
896 SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( pDoc
);
897 pWork
= pFrame
? pFrame
->GetFrame().GetWorkWindow_Impl() : NULL
;
903 pWork
->ArrangeChildren_Impl();
904 pWork
->ShowChildren_Impl();
907 // problem in presence of UIActive object: when the window is resized, but the toolspace border
908 // remains the same, setting the toolspace border at the ContainerEnvironment doesn't force a
909 // resize on the IPEnvironment; without that no resize is called for the SfxViewFrame. So always
910 // set the window size of the SfxViewFrame explicit.
911 SetToolSpaceBorderPixel_Impl( pImp
->aBorder
);
914 else if ( pImp
->pCurrentViewFrame
)
916 pImp
->pCurrentViewFrame
->GetWindow().SetSizePixel( GetWindow().GetOutputSizePixel() );
921 SfxFrame
* SfxFrame::GetFirst()
923 if ( !pFramesArr_Impl
)
925 return pFramesArr_Impl
->empty() ? 0 : pFramesArr_Impl
->front();
928 SfxFrame
* SfxFrame::GetNext( SfxFrame
& rFrame
)
930 SfxFrameArr_Impl::iterator it
= std::find( pFramesArr_Impl
->begin(), pFramesArr_Impl
->end(), &rFrame
);
931 if ( it
!= pFramesArr_Impl
->end() && (++it
) != pFramesArr_Impl
->end() )
937 const SfxPoolItem
* SfxFrame::OpenDocumentSynchron( SfxItemSet
& i_rSet
, const Reference
< XFrame
>& i_rTargetFrame
)
939 i_rSet
.Put( SfxUnoFrameItem( SID_FILLFRAME
, i_rTargetFrame
) );
940 i_rSet
.ClearItem( SID_TARGETNAME
);
941 return SfxGetpApp()->GetDispatcher_Impl()->Execute( SID_OPENDOC
, SfxCallMode::SYNCHRON
, i_rSet
);
944 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */