summaryrefslogtreecommitdiff
path: root/sfx2/source/view
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/view')
-rw-r--r--sfx2/source/view/frame.cxx684
-rw-r--r--sfx2/source/view/frame2.cxx484
-rw-r--r--sfx2/source/view/frmload.cxx998
-rw-r--r--sfx2/source/view/impframe.cxx55
-rw-r--r--sfx2/source/view/impframe.hxx67
-rw-r--r--sfx2/source/view/impviewframe.hxx94
-rw-r--r--sfx2/source/view/ipclient.cxx20
-rw-r--r--sfx2/source/view/makefile.mk6
-rw-r--r--sfx2/source/view/prnmon.cxx2
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx456
-rw-r--r--sfx2/source/view/topfrm.cxx1643
-rw-r--r--sfx2/source/view/view.hxx27
-rw-r--r--sfx2/source/view/viewfac.cxx12
-rw-r--r--sfx2/source/view/viewfrm.cxx1411
-rw-r--r--sfx2/source/view/viewfrm2.cxx523
-rw-r--r--sfx2/source/view/viewimp.hxx28
-rw-r--r--sfx2/source/view/viewprn.cxx10
-rw-r--r--sfx2/source/view/viewsh.cxx91
18 files changed, 2540 insertions, 4071 deletions
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index 2f6c4bb59903..090e94ecb63f 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -77,7 +77,7 @@
#include <sfx2/fcontnr.hxx>
#include "impframe.hxx"
#include <sfx2/appuno.hxx>
-#include <sfx2/topfrm.hxx>
+#include <sfx2/viewfrm.hxx>
#include "workwin.hxx"
#include <sfx2/sfxuno.hxx>
#include <sfx2/msgpool.hxx>
@@ -100,41 +100,29 @@ using namespace ::com::sun::star::container;
TYPEINIT1(SfxFrame, SfxListener);
TYPEINIT1_AUTOFACTORY(SfxFrameItem, SfxPoolItem);
TYPEINIT1(SfxUsrAnyItem, SfxPoolItem);
-
-SfxFrame::SfxFrame(SfxFrame* pParent):
- pParentFrame( pParent ),
- pChildArr(0),
- pUnoImp(0)
-{
- pImp = new SfxFrame_Impl( this );
- if ( pParent )
- pParent->InsertChildFrame_Impl( this );
- if ( !pFramesArr_Impl )
- pFramesArr_Impl = new SfxFrameArr_Impl;
- pFramesArr_Impl->Insert( this, pFramesArr_Impl->Count() );
-}
+TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem, SfxPoolItem);
SvCompatWeakHdl* SfxFrame::GetHdl()
{
return pImp->GetHdl();
}
-SfxCancelManager* SfxFrame::GetCancelManager() const
+//--------------------------------------------------------------------
+void SfxFrame::Construct_Impl()
{
- SfxFrame *pFrame = GetTopFrame();
- SfxCancelManager*& rpMgr = pFrame->pImp->pCancelMgr;
- if ( !rpMgr )
- {
- rpMgr = new SfxCancelManager( SFX_APP()->GetCancelManager() );
- pFrame->pImp->StartListening( *rpMgr );
- }
- return rpMgr;
+ pImp = new SfxFrame_Impl( this );
+ if ( !pFramesArr_Impl )
+ pFramesArr_Impl = new SfxFrameArr_Impl;
+ pFramesArr_Impl->Insert( this, pFramesArr_Impl->Count() );
}
//--------------------------------------------------------------------
SfxFrame::~SfxFrame()
{
+ RemoveTopFrame_Impl( this );
+ DELETEZ( pWindow );
+
pFramesArr_Impl->Remove( pFramesArr_Impl->GetPos( this ) );
if ( pParentFrame )
@@ -214,53 +202,6 @@ sal_Bool SfxFrame::DoClose_Impl()
return bRet;
}
-void SfxFrame::Clear_Impl()
-{
- CancelTransfers();
-
- // Bei FrameSets verhindern, da\s das Closen der Childs zu st"andigen
- // ReCalcs im SplitWindow f"uhrt; SetUpdateMode am FrameWindow wirkt
- // leider nicht auf dem MAC
- Window *pWin = NULL;
- SfxViewShell *pViewSh;
- if ( pImp->pCurrentViewFrame &&
- 0 != ( pViewSh = pImp->pCurrentViewFrame->GetViewShell() ) )
- {
- pWin = pViewSh->GetWindow();
- if ( pWin )
- pWin->Hide();
- }
-
- sal_Bool bRet = sal_True;
- SfxBindings* pBindings = NULL;
- if ( pImp->pCurrentViewFrame )
- {
- pBindings = &pImp->pCurrentViewFrame->GetBindings();
- pImp->bClosing = sal_True;
- bRet = pImp->pCurrentViewFrame->Close();
- pImp->bClosing = sal_False;
- }
-
- if ( bRet )
- {
- // Bei internen Tasks m"ussen Controller und Tools abger"aumt werden
- if ( pImp->pWorkWin )
- {
- pImp->pWorkWin->DeleteControllers_Impl();
- DELETEZ( pImp->pWorkWin );
- }
-
- if ( pImp->bOwnsBindings )
- delete pBindings;
- }
- else
- {
- if ( pWin )
- pWin->Show();
- }
-}
-
-
sal_Bool SfxFrame::DocIsModified_Impl()
{
if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetObjectShell() &&
@@ -290,7 +231,7 @@ sal_uInt16 SfxFrame::PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing )
for ( const SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pCur );
!bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pCur ) )
{
- bOther = ( pFrame->GetFrame() != this );
+ bOther = ( &pFrame->GetFrame() != this );
}
SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur) );
@@ -333,164 +274,19 @@ SfxFrame* SfxFrame::GetChildFrame( sal_uInt16 nPos ) const
return 0L;
}
-void SfxFrame::InsertChildFrame_Impl( SfxFrame* pFrame, sal_uInt16 nPos )
-{
- if ( !pChildArr )
- pChildArr = new SfxFrameArr_Impl;
- pChildArr->Insert( pFrame, nPos );
- pFrame->pParentFrame = this;
-}
-
-void SfxFrame::RemoveChildFrame_Impl( sal_uInt16 nPos )
-{
- DBG_ASSERT( pChildArr, "Unbekannter Frame!");
- pChildArr->Remove( nPos );
-};
-
void SfxFrame::RemoveChildFrame_Impl( SfxFrame* pFrame )
{
DBG_ASSERT( pChildArr, "Unbekannter Frame!");
sal_uInt16 nPos = pChildArr->GetPos(pFrame);
- RemoveChildFrame_Impl( nPos );
+ pChildArr->Remove( nPos );
};
-sal_Bool SfxFrame::CloseChildFrames()
-{
- sal_Bool bRet = sal_True;
- if ( pChildArr )
- {
- // Childs closen
- sal_uInt16 nCount = pChildArr->Count();
- for ( sal_uInt16 n=nCount; n>0; n--)
- {
- SfxFrame* pFrame = (*pChildArr)[n-1];
- // pFrame removed sich selbst
- bRet = pFrame->DoClose();
- if ( !bRet )
- break;
- }
- }
-
- return bRet;
-}
-
-SfxFrame* SfxFrame::SearchChildrenForName_Impl( const String& rName, sal_Bool bDeep ) const
-{
- if ( pChildArr )
- {
- sal_uInt16 nCount = pChildArr->Count();
- for ( sal_uInt16 n=nCount; n>0; n--)
- {
- SfxFrame* pFrame = (*pChildArr)[n-1];
- if ( rName.CompareIgnoreCaseToAscii( pFrame->GetFrameName() ) == COMPARE_EQUAL )
- return pFrame;
- if( bDeep )
- {
- pFrame = pFrame->SearchChildrenForName_Impl( rName );
- if ( pFrame )
- return pFrame;
- }
- }
- }
-
- return NULL;
-}
-
-SfxFrame* SfxFrame::GetTopFrame() const
+SfxFrame& SfxFrame::GetTopFrame() const
{
- SfxFrame *pParent = (SfxFrame*) this;
+ const SfxFrame* pParent = this;
while ( pParent->pParentFrame )
pParent = pParent->pParentFrame;
- return pParent;
-}
-
-SfxFrame* SfxFrame::SearchFrame( const String& rName, SfxMedium* /*pMedium*/ )
-{
- // Weil Netscape f"uhrende BLANKS "uberliest, m"ussen wir das wohl auch
- // Sollte besser auch bei den FrameNames gemacht werden!
- String aFrameName( rName );
- aFrameName.EraseLeadingChars();
-
- SfxFrame *pFrame = this;
- if( !aFrameName.Len() || aFrameName.CompareIgnoreCaseToAscii("_self") == COMPARE_EQUAL )
- {
- return pFrame;
- }
- else if ( aFrameName.CompareIgnoreCaseToAscii("_smartself") == COMPARE_EQUAL )
- {
- DBG_ERROR("Not supported!");
- return pFrame;
- }
- else if ( aFrameName.CompareIgnoreCaseToAscii( GetFrameName() ) == COMPARE_EQUAL)
- {
- // Eigener Name, kein Name oder Selbstbezug
- return pFrame;
- }
- else if ( aFrameName.CompareIgnoreCaseToAscii("_parent") == COMPARE_EQUAL )
- {
- // Gesucht ist das Parent Frameset
- return pParentFrame ? pParentFrame : this;
- }
- else if ( aFrameName.CompareIgnoreCaseToAscii("_blank") == COMPARE_EQUAL )
- {
- return NULL;
- }
- else if ( aFrameName.CompareIgnoreCaseToAscii("_top") == COMPARE_EQUAL )
- {
- while ( pFrame->GetParentFrame() )
- pFrame = pFrame->GetParentFrame();
- return pFrame;
- }
- else
- {
- // Zuerst unterhalb dieses Frames absuchen
- pFrame = SearchChildrenForName_Impl( aFrameName );
- }
-
- if ( !pFrame && GetParentFrame() )
- {
- // Noch nichts gefunden, nach oben weitergehen
- // Eigentlich m"u\sten Frames, die schon abgesucht wurden, aus
- // Performance-Gr"unden markiert werden
- SfxFrame *pParent = GetParentFrame();
- do
- {
- // Ist es der Parent ?
- if ( aFrameName.CompareIgnoreCaseToAscii( pParent->GetFrameName() ) == COMPARE_EQUAL )
- return pParent;
-
- // Weiter nach oben
- pParent = pParent->GetParentFrame();
- }
- while ( pParent );
- }
-
- if( !pFrame )
- {
- SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
- // keinen Frame im MDI-Fenster gefunden. Jetzt die anderen
- // Toplevel Frames checken.
- SfxFrame *pTop = GetTopFrame();
- for( sal_uInt16 nPos = rArr.Count(); nPos--; )
- {
- // Unser Topframe wurde bereits durchsucht
- SfxFrame* pCurFrame = rArr[ nPos ];
- if( pCurFrame != pTop )
- {
- if( aFrameName.CompareIgnoreCaseToAscii( pCurFrame->GetFrameName() ) ==
- COMPARE_EQUAL )
- return pCurFrame;
- else
- {
- pFrame = pCurFrame->SearchChildrenForName_Impl( aFrameName );
- if( pFrame )
- return pFrame;
- }
- }
- }
- }
-
- return pFrame;
+ return *const_cast< SfxFrame* >( pParent );
}
sal_Bool SfxFrame::IsClosing_Impl() const
@@ -503,21 +299,11 @@ void SfxFrame::SetIsClosing_Impl()
pImp->bClosing = TRUE;
}
-void SfxFrame::DocumentInserted( SfxObjectShell* /*pDoc*/ )
-{
-}
-
sal_uInt16 SfxFrame::GetChildFrameCount() const
{
return pChildArr ? pChildArr->Count() : 0;
}
-sal_Bool SfxFrame::InsertDocument( SfxObjectShell* pDoc )
-{
- DocumentInserted( pDoc );
- return sal_True;
-}
-
void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ )
{
if( !pImp->bInCancelTransfers )
@@ -528,7 +314,7 @@ void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ )
{
SfxViewFrame* pFrm;
for( pFrm = SfxViewFrame::GetFirst( pObj );
- pFrm && pFrm->GetFrame() == this;
+ pFrm && &pFrm->GetFrame() == this;
pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ;
// Keine anderer Frame mehr auf Doc -> Cancel
if( !pFrm )
@@ -566,12 +352,7 @@ SfxObjectShell* SfxFrame::GetCurrentDocument() const
{
return pImp->pCurrentViewFrame ?
pImp->pCurrentViewFrame->GetObjectShell() :
- pImp->pCurrentObjectShell;
-}
-
-void SfxFrame::SetCurrentDocument_Impl( SfxObjectShell *pDoc )
-{
- pImp->pCurrentObjectShell = pDoc;
+ NULL;
}
void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame *pFrame )
@@ -589,56 +370,10 @@ void SfxFrame::SetFrameType_Impl( sal_uInt32 n )
pImp->nType = n;
}
-void SfxFrame::CopyHistory_Impl( SfxFrame* /*pFrame*/ ) const
-{
-}
-
-
-void SfxFrame::ClearHistory()
-{
-}
-
-sal_Bool SfxFrame::ExecuteHistoryMenu_Impl( sal_uInt16 /*nWhich*/, const Rectangle& /*rRect*/, sal_uInt16 /*nFlags*/ )
-{
- return sal_True;
-}
-
-sal_Bool SfxFrame::Browse( sal_Bool /*bForward*/, sal_uInt16 /*nSteps*/, sal_Bool /*bNewFrame*/ )
-{
- return FALSE;
-}
-
-void SfxFrame::UpdatePickEntries()
-{
-}
-
-void SfxFrame::UpdatePickEntries( const ::com::sun::star::uno::Any& /*rValue*/ )
-{
-}
-
-void SfxFrame::UpdateUndoHistory_Impl( SfxObjectShell* /*pDocSh*/, const String* /*pNew*/, const String* /*pTitle*/ )
-{
-}
-
-void SfxFrame::UpdateCurrentHistory_Impl( SfxObjectShell* /*pDocSh*/, const String* /*pNew*/ )
-{
-}
-
-void SfxFrame::UpdateHistory( SfxObjectShell* /*pDocSh*/, const String* /*pNew*/ )
-{
-}
-
-void SfxFrame::UpdateHistory(
- const ::rtl::OUString& /*aURL*/,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& /*aArgs*/,
- const ::rtl::OUString& /*rTitle*/ )
-{
-}
-
void SfxFrame::GetViewData_Impl()
{
// Alle zwischen Laden und Entfernen "anderbaren Daten aktualisieren; die
- // festen Daten werden nur einmal ( nach InsertDocument in UpdateDescriptor )
+ // festen Daten werden nur einmal ( nach PrepareForDoc_Impl in UpdateDescriptor )
// geholt, um Zeit zu sparen.
SfxViewFrame* pViewFrame = GetCurrentViewFrame();
if( pViewFrame && pViewFrame->GetViewShell() )
@@ -647,10 +382,7 @@ void SfxFrame::GetViewData_Impl()
sal_Bool bReadOnly = pMed->GetOpenMode() == SFX_STREAM_READONLY;
GetDescriptor()->SetReadOnly( bReadOnly );
- String aUserData;
- pViewFrame->GetViewShell()->WriteUserData( aUserData, sal_True );
SfxItemSet *pSet = GetDescriptor()->GetArgs();
- pSet->Put( SfxStringItem( SID_USER_DATA, aUserData ));
sal_Bool bGetViewData = sal_False;
if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SFX_ITEM_SET )
{
@@ -678,9 +410,9 @@ void SfxFrame::GetViewData_Impl()
void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc )
{
- // Beim InsertDocument wird der Descriptor des Frames aktualisiert
+ // Beim PrepareForDoc_Impl wird der Descriptor des Frames aktualisiert
// und sein ItemSet neu initialisiert. Alle Daten, die f"ur ein sp"ateres
- // Restaurieren der ::com::sun::star::sdbcx::View n"otig sind, sind damit festgehalten.
+ // Restaurieren der View n"otig sind, sind damit festgehalten.
// Soll das Dokument ersetzt werden, wird durch GetViewData_Impl (s.o.)
// die neueste Information hinzugef"ugt. Alles zusammen wird dann in der
// Browse-History gesichert. Beim Aktivieren eines solchen FramePickEntry
@@ -732,20 +464,6 @@ void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc )
//-------------------------------------------------------------------------
-sal_Bool SfxFrame::CanBrowseBackward() const
-{
- return FALSE;
-}
-
-//-------------------------------------------------------------------------
-
-sal_Bool SfxFrame::CanBrowseForward() const
-{
- return FALSE;
-}
-
-//-------------------------------------------------------------------------
-
void SfxFrame::SetDescriptor( SfxFrameDescriptor *pD )
{
DBG_ASSERT( pD, "Kein Descriptor!" );
@@ -793,14 +511,12 @@ void SfxFrame::GetTargetList( TargetList& rList ) const
}
SfxViewFrame* pView = GetCurrentViewFrame();
- if( pView && pView->GetViewShell() && !pView->GetViewShell()->IsImplementedAsFrameset_Impl() && pChildArr )
+ if( pView && pView->GetViewShell() && pChildArr )
{
sal_uInt16 nCount = pChildArr->Count();
for ( sal_uInt16 n=0; n<nCount; n++)
{
SfxFrame* pFrame = (*pChildArr)[n];
- if ( pFrame->GetFrameName().Len() )
- rList.Insert( new String (pFrame->GetFrameName()) );
pFrame->GetTargetList( rList );
}
}
@@ -808,147 +524,11 @@ void SfxFrame::GetTargetList( TargetList& rList ) const
//-------------------------------------------------------------------------
-void SfxFrame::SetFrameId_Impl( sal_uInt16 nId )
-{
- pImp->nFrameId = nId;
- if ( GetCurrentViewFrame() )
- GetCurrentViewFrame()->UpdateTitle();
-}
-
-sal_uInt16 SfxFrame::GetFrameId_Impl() const
-{
- return pImp->nFrameId;
-}
-
-void SfxFrame::SetFrameIdName_Impl( const String& rName )
-{
- pImp->aFrameIdName = rName;
-}
-
-//-------------------------------------------------------------------------
-
-SfxFrame* SfxFrame::SearchFrame_Impl( sal_uInt16 nId, sal_Bool bDeep )
-{
- if ( pImp->nFrameId == nId )
- return this;
-
- if ( pChildArr )
- {
- sal_uInt16 nCount = pChildArr->Count();
- for ( sal_uInt16 n=0; n<nCount; n++)
- {
- SfxFrame* pFrame = (*pChildArr)[n];
- if ( pFrame->pImp->nFrameId == nId )
- return pFrame;
- if ( bDeep )
- {
- pFrame = pFrame->SearchFrame_Impl( nId, sal_True );
- if ( pFrame )
- return pFrame;
- }
- }
- }
-
- return NULL;
-}
-
-SfxFrame* SfxFrame::SearchFrame_Impl( const String& rName, sal_Bool bDeep )
-{
- if ( pImp->aFrameIdName == rName )
- return this;
-
- if ( pChildArr )
- {
- sal_uInt16 nCount = pChildArr->Count();
- for ( sal_uInt16 n=0; n<nCount; n++)
- {
- SfxFrame* pFrame = (*pChildArr)[n];
- if ( pFrame->pImp->aFrameIdName == rName )
- return pFrame;
- if ( bDeep )
- {
- pFrame = pFrame->SearchFrame_Impl( rName );
- if ( pFrame )
- return pFrame;
- }
- }
- }
-
- return NULL;
-}
-
-//-------------------------------------------------------------------------
-
-//-------------------------------------------------------------------------
-
-void SfxFrame::Activate_Impl( sal_Bool bBeamerOn )
-
-/* [Description]
-
- Internal Activate-Handler, called from derived classes which supports
- Activate-Handling.
-*/
-
-{
- if ( GetParentFrame() )
- GetParentFrame()->Activate_Impl( bBeamerOn );
-}
-
SfxBroadcaster& SfxFrame::GetBroadcaster() const
{
return *pImp;
}
-//-------------------------------------------------------------------------
-
-void SfxFrame::Deactivate_Impl()
-
-/* [Description]
-
- Internal Deactivate-Handler, called from derived classes which supports
- Activate-Handling.
-*/
-
-{
- if( GetParentFrame() )
- GetParentFrame()->Deactivate_Impl();
-}
-
-String SfxFrame::GetContent() const
-{
- SfxObjectShell *pObj = GetCurrentDocument();
- if ( !pObj || !pObj->GetMedium() )
- return String();
- else
- return pObj->GetMedium()->GetName();
-}
-
-sal_Bool SfxFrame::CheckContentForLoad_Impl()
-{
- if ( GetCurrentDocument() )
- {
- SfxMedium* pMedium = GetCurrentDocument()->GetMedium();
-#ifdef DEBUG
- SfxItemSet* pSet;
- pSet = pMedium->GetItemSet();
-#endif
- SfxItemSet* pNew = GetDescriptor()->GetArgs();
-
- // Falls URLs nicht uebereinstimmen
- if ( INetURLObject( GetDescriptor()->GetActualURL() ) != INetURLObject( pMedium->GetOrigURL() ) )
- return sal_True;
-
- // Falls die Filter nicht uebereinstimmen
- SFX_ITEMSET_ARG( pNew, pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False );
- if( pMedium->GetOrigFilter() && pFilterItem && pFilterItem->GetValue() != pMedium->GetOrigFilter()->GetFilterName() )
- return sal_True;
-
- return sal_False;
- }
-
- return (GetDescriptor()->GetActualURL().GetMainURL( INetURLObject::NO_DECODE ).getLength() != 0);
-}
-
sal_Bool SfxFrame::IsParent( SfxFrame *pFrame ) const
{
SfxFrame *pParent = pParentFrame;
@@ -975,7 +555,7 @@ void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame )
}
SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame *p )
- : SfxPoolItem( nWhichId ), pFrame( p ? p->GetFrame() : NULL )
+ : SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : NULL )
{
wFrame = pFrame;
}
@@ -1058,11 +638,6 @@ int SfxUsrAnyItem::operator==( const SfxPoolItem& /*rItem*/ ) const
return sal_False;
}
-String SfxUsrAnyItem::GetValueText() const
-{
- return String();
-}
-
SfxPoolItem* SfxUsrAnyItem::Clone( SfxItemPool *) const
{
return new SfxUsrAnyItem( Which(), aValue );
@@ -1080,9 +655,37 @@ sal_Bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*n
return sal_True;
}
-sal_Bool SfxFrame::BrowseInFrame( int /*nDelta*/ )
+SfxUnoFrameItem::SfxUnoFrameItem()
+ : SfxPoolItem()
+ , m_xFrame()
+{
+}
+
+SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame )
+ : SfxPoolItem( nWhichId )
+ , m_xFrame( i_rFrame )
{
- return sal_False;
+}
+
+int SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const
+{
+ return i_rItem.ISA( SfxUnoFrameItem ) && static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame;
+}
+
+SfxPoolItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const
+{
+ return new SfxUnoFrameItem( Which(), m_xFrame );
+}
+
+sal_Bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ rVal <<= m_xFrame;
+ return sal_True;
+}
+
+sal_Bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ return ( rVal >>= m_xFrame );
}
SfxFrameIterator::SfxFrameIterator( const SfxFrame& rFrame, sal_Bool bRecur )
@@ -1129,116 +732,6 @@ SfxFrame* SfxFrameIterator::NextSibling_Impl( SfxFrame& rPrev )
return pRet;
}
-void SfxFrame::SetFrameName( const String& rName )
-{
- if ( pImp->pDescr )
- pImp->pDescr->SetName( rName );
- aName = rName;
- if ( pImp->pCurrentViewFrame )
- pImp->pCurrentViewFrame->UpdateTitle();
- if ( GetFrameInterface().is() )
- GetFrameInterface()->setName( rName );
-}
-
-void SfxFrame::LoadFinished_Impl()
-{
-}
-
-SfxFrame* SfxFrame::findFrame(const ::rtl::OUString& aTargetframename, sal_Int32 nSearchFlags)
-{
- // Weil Netscape f"uhrende BLANKS "uberliest, m"ussen wir das wohl auch
- // Sollte besser auch bei den FrameNames gemacht werden!
- String aTargetName( aTargetframename );
- aTargetName.EraseLeadingChars();
-
- SfxFrame *pFrame = this;
-
- if ( !aTargetName.Len() && GetParentFrame() && GetParentFrame()->GetCurrentViewFrame()->GetViewShell()->IsImplementedAsFrameset_Impl() )
- return GetParentFrame();
-
- if( !aTargetName.Len() || aTargetName.CompareIgnoreCaseToAscii("_self") == COMPARE_EQUAL )
- return pFrame;
-
- if ( aTargetName.CompareIgnoreCaseToAscii("_smartself") == COMPARE_EQUAL )
- {
- DBG_ERROR("Not supported!");
- return pFrame;
- }
-
- if ( aTargetName.CompareIgnoreCaseToAscii("_parent") == COMPARE_EQUAL )
- {
- // Gesucht ist das Parent Frameset
- return pFrame->GetParentFrame();
- }
- else if ( aTargetName.CompareIgnoreCaseToAscii("_blank") == COMPARE_EQUAL )
- {
- return NULL;
-
- }
- else if ( aTargetName.CompareIgnoreCaseToAscii("_top") == COMPARE_EQUAL )
- {
- while ( pFrame->GetParentFrame() )
- pFrame = pFrame->GetParentFrame();
- return pFrame;
- }
-
- if ( ( nSearchFlags & FRAME_SEARCH_SELF ) && aTargetName.CompareIgnoreCaseToAscii( GetFrameName() ) == COMPARE_EQUAL )
- {
- // Eigener Name
- return pFrame;
- }
-
- if ( nSearchFlags & FRAME_SEARCH_CHILDREN )
- {
- // Zuerst unterhalb dieses Frames absuchen
- pFrame = SearchChildrenForName_Impl( aTargetName );
- }
-
- if ( ( nSearchFlags & FRAME_SEARCH_CHILDREN ) && !pFrame && GetParentFrame() )
- {
- // Noch nichts gefunden, nach oben weitergehen
- // Eigentlich m"u\sten Frames, die schon abgesucht wurden, aus
- // Performance-Gr"unden markiert werden
- SfxFrame *pParent = GetParentFrame();
- do
- {
- // Ist es der Parent ?
- if ( aTargetName.CompareIgnoreCaseToAscii( pParent->GetFrameName() ) == COMPARE_EQUAL )
- return pParent;
-
- // Weiter nach oben
- pParent = pParent->GetParentFrame();
- }
- while ( pParent );
- }
-
- if( !pFrame )
- {
- SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
- // keinen Frame im MDI-Fenster gefunden. Jetzt die anderen
- // Toplevel Frames checken.
- SfxFrame *pTop = GetTopFrame();
- for( sal_uInt16 nPos = rArr.Count(); nPos--; )
- {
- // Unser Topframe wurde bereits durchsucht
- SfxFrame* pCurFrame = rArr[ nPos ];
- if( pCurFrame != pTop )
- {
- if( aTargetName.CompareIgnoreCaseToAscii( pCurFrame->GetFrameName() ) == COMPARE_EQUAL )
- return pCurFrame;
- else
- {
- pFrame = pCurFrame->SearchChildrenForName_Impl( aTargetName );
- if( pFrame )
- return pFrame;
- }
- }
- }
- }
-
- return pFrame;
-}
-
sal_Bool SfxFrame::IsTop() const
{
return GetFrameInterface().is() ? GetFrameInterface()->isTop() : sal_False;
@@ -1262,7 +755,7 @@ sal_Bool SfxFrame::HasComponent() const
return pImp->xFrame;
}
-void SfxFrame::SetFrameInterface_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
+void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame )
{
pImp->xFrame = rFrame;
com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
@@ -1270,16 +763,6 @@ void SfxFrame::SetFrameInterface_Impl( ::com::sun::star::uno::Reference< ::com::
GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder );
}
-void SfxFrame::SetItemSet_Impl( const SfxItemSet* pSet )
-{
- pImp->pSet = pSet;
-}
-
-const SfxItemSet* SfxFrame::GetItemSet_Impl()
-{
- return pImp->pSet;
-}
-
void SfxFrame::Appear()
{
if ( GetCurrentViewFrame() )
@@ -1407,11 +890,6 @@ void SfxFrame::CreateWorkWindow_Impl()
pImp->pWorkWin = new SfxFrameWorkWin_Impl( &pFrame->GetWindow(), this, pFrame );
}
-const SvBorder& SfxFrame::GetBorder_Impl() const
-{
- return pImp->aBorder;
-}
-
void SfxFrame::GrabFocusOnComponent_Impl()
{
if ( pImp->bReleasingComponent )
@@ -1420,18 +898,12 @@ void SfxFrame::GrabFocusOnComponent_Impl()
return;
}
- Window* pWindow = &GetWindow();
+ Window* pFocusWindow = &GetWindow();
if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
- pWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow();
-
- if( !pWindow->HasChildPathFocus() )
- pWindow->GrabFocus();
-}
+ pFocusWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow();
-const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > SfxFrame::GetInterceptor_Impl()
-{
-//(mba)/compview: hier fehlt der Zugriff auf den Interceptor !!!!!
- return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > ();
+ if( !pFocusWindow->HasChildPathFocus() )
+ pFocusWindow->GrabFocus();
}
void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet )
@@ -1439,36 +911,6 @@ void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet )
pImp->bReleasingComponent = bSet;
}
-sal_Bool SfxFrame::LoadSfxComponent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & /*aFrame*/,
- const ::rtl::OUString& /*aURL*/,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& /*aArgs*/,
- const SfxObjectFactory* /*pFact*/ )
-{
- // get Implementation of xComponents ...
- DBG_ERROR( "Should not be called anymore!" );
- return sal_False;
-}
-
-void SfxFrame::LockFocus_Impl( sal_Bool bLock )
-{
- if ( pChildArr && pChildArr->Count() )
- {
- sal_uInt16 nCount = pChildArr->Count();
- for ( sal_uInt16 n=0; n<nCount; n++ )
- {
- SfxFrame* pFrame = (*pChildArr)[n];
- pFrame->pImp->bFocusLocked = bLock;
- pFrame->LockFocus_Impl( bLock );
- }
- }
-}
-
-sal_Bool SfxFrame::IsFocusLocked_Impl() const
-{
- return pImp->bFocusLocked;
-}
-
sal_Bool SfxFrame::IsInPlace() const
{
return pImp->bInPlace;
@@ -1503,7 +945,7 @@ void SfxFrame::Resize()
if ( nHandle )
{
SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
- pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame()->GetWorkWindow_Impl();
+ pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame().GetWorkWindow_Impl();
}
}
@@ -1543,10 +985,10 @@ SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame )
return NULL;
}
-const SfxPoolItem* SfxFrame::LoadDocumentSynchron( SfxItemSet& aSet )
+const SfxPoolItem* SfxFrame::OpenDocumentSynchron( SfxItemSet& i_rSet, const Reference< XFrame >& i_rTargetFrame )
{
- aSet.Put( SfxFrameItem( SID_DOCFRAME, this ) );
- aSet.ClearItem( SID_TARGETNAME );
- return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, aSet );
+ i_rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, i_rTargetFrame ) );
+ i_rSet.ClearItem( SID_TARGETNAME );
+ return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, i_rSet );
}
diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx
new file mode 100644
index 000000000000..d99ad8733e03
--- /dev/null
+++ b/sfx2/source/view/frame2.cxx
@@ -0,0 +1,484 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sfx2.hxx"
+
+#include "impframe.hxx"
+#include "objshimp.hxx"
+#include "sfxhelp.hxx"
+#include "workwin.hxx"
+
+#include "sfx2/app.hxx"
+#include "sfx2/bindings.hxx"
+#include "sfx2/dispatch.hxx"
+#include "sfx2/docfac.hxx"
+#include "sfx2/docfile.hxx"
+#include "sfx2/event.hxx"
+#include "sfx2/objface.hxx"
+#include "sfx2/request.hxx"
+
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/itemset.hxx>
+#include <svl/rectitem.hxx>
+#include <svl/stritem.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::lang::XComponent;
+using ::com::sun::star::frame::XComponentLoader;
+
+//------------------------------------------------------------------------
+
+class SfxFrameWindow_Impl : public Window
+{
+public:
+ SfxFrame* pFrame;
+
+ SfxFrameWindow_Impl( SfxFrame* pF, Window& i_rContainerWindow );
+ ~SfxFrameWindow_Impl( );
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual void StateChanged( StateChangedType nStateChange );
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual long Notify( NotifyEvent& rEvt );
+ virtual void Resize();
+ virtual void GetFocus();
+ void DoResize();
+ DECL_LINK( CloserHdl, void* );
+};
+
+SfxFrameWindow_Impl::SfxFrameWindow_Impl( SfxFrame* pF, Window& i_rContainerWindow )
+ : Window( &i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK )
+ , pFrame( pF )
+{
+}
+
+SfxFrameWindow_Impl::~SfxFrameWindow_Impl( )
+{
+}
+
+void SfxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+ SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl();
+ if ( pWorkWin )
+ pWorkWin->DataChanged_Impl( rDCEvt );
+}
+
+long SfxFrameWindow_Impl::Notify( NotifyEvent& rNEvt )
+{
+ if ( pFrame->IsClosing_Impl() || !pFrame->GetFrameInterface().is() )
+ return sal_False;
+
+ SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
+ if ( !pView || !pView->GetObjectShell() )
+ return Window::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_GETFOCUS )
+ {
+ if ( pView->GetViewShell() && !pView->GetViewShell()->GetUIActiveIPClient_Impl() && !pFrame->IsInPlace() )
+ {
+ DBG_TRACE("SfxFrame: GotFocus");
+ pView->MakeActive_Impl( FALSE );
+ }
+
+ // TODO/LATER: do we still need this code?
+ Window* pWindow = rNEvt.GetWindow();
+ ULONG nHelpId = 0;
+ while ( !nHelpId && pWindow )
+ {
+ nHelpId = pWindow->GetHelpId();
+ pWindow = pWindow->GetParent();
+ }
+
+ if ( nHelpId )
+ SfxHelp::OpenHelpAgent( pFrame, nHelpId );
+
+ // if focus was on an external window, the clipboard content might have been changed
+ pView->GetBindings().Invalidate( SID_PASTE );
+ pView->GetBindings().Invalidate( SID_PASTE_SPECIAL );
+ return sal_True;
+ }
+ else if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) )
+ return TRUE;
+ }
+ else if ( rNEvt.GetType() == EVENT_EXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTDISABLE*/ )
+ {
+ pView->SetModalMode( sal_True );
+ return sal_True;
+ }
+ else if ( rNEvt.GetType() == EVENT_ENDEXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTENABLE*/ )
+ {
+ //EnableInput( sal_True, sal_True );
+ pView->SetModalMode( sal_False );
+ return sal_True;
+ }
+
+ return Window::Notify( rNEvt );
+}
+
+long SfxFrameWindow_Impl::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+ if ( nType == EVENT_KEYINPUT || nType == EVENT_KEYUP )
+ {
+ SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
+ SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL;
+ if ( pShell && pShell->HasKeyListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) )
+ return sal_True;
+ }
+ else if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN )
+ {
+ Window* pWindow = rNEvt.GetWindow();
+ SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
+ SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL;
+ if ( pShell )
+ if ( pWindow == pShell->GetWindow() || pShell->GetWindow()->IsChild( pWindow ) )
+ if ( pShell->HasMouseClickListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) )
+ return sal_True;
+ }
+
+ if ( nType == EVENT_MOUSEBUTTONDOWN )
+ {
+ Window* pWindow = rNEvt.GetWindow();
+ const MouseEvent* pMEvent = rNEvt.GetMouseEvent();
+ Point aPos = pWindow->OutputToScreenPixel( pMEvent->GetPosPixel() );
+ SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl();
+ if ( pWorkWin )
+ pWorkWin->EndAutoShow_Impl( aPos );
+ }
+
+ return Window::PreNotify( rNEvt );
+}
+
+void SfxFrameWindow_Impl::GetFocus()
+{
+ if ( pFrame && !pFrame->IsClosing_Impl() && pFrame->GetCurrentViewFrame() && pFrame->GetFrameInterface().is() )
+ pFrame->GetCurrentViewFrame()->MakeActive_Impl( TRUE );
+}
+
+void SfxFrameWindow_Impl::Resize()
+{
+ if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() )
+ DoResize();
+}
+
+void SfxFrameWindow_Impl::StateChanged( StateChangedType nStateChange )
+{
+ if ( nStateChange == STATE_CHANGE_INITSHOW )
+ {
+ pFrame->pImp->bHidden = FALSE;
+ if ( pFrame->IsInPlace() )
+ // TODO/MBA: workaround for bug in LayoutManager: the final resize does not get through because the
+ // LayoutManager works asynchronously and between resize and time execution the DockingAcceptor was exchanged so that
+ // the resize event never is sent to the component
+ SetSizePixel( GetParent()->GetOutputSizePixel() );
+
+ DoResize();
+ SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
+ if ( pView )
+ pView->GetBindings().GetWorkWindow_Impl()->ShowChilds_Impl();
+ }
+
+ Window::StateChanged( nStateChange );
+}
+
+void SfxFrameWindow_Impl::DoResize()
+{
+ if ( !pFrame->pImp->bLockResize )
+ pFrame->Resize();
+}
+
+Reference < XFrame > SfxFrame::CreateBlankFrame()
+{
+ Reference < XFrame > xFrame;
+ try
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference < XFrame > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
+ xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xFrame;
+}
+
+SfxFrame* SfxFrame::Create( SfxObjectShell& rDoc, Window& rWindow, USHORT nViewId, bool bHidden )
+{
+ SfxFrame* pFrame = NULL;
+ try
+ {
+ // create and initialize new top level frame for this window
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference < XFramesSupplier > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
+ Reference < XFrame > xFrame( aContext.createComponent( "com.sun.star.frame.Frame"), UNO_QUERY_THROW );
+
+ Reference< awt::XWindow2 > xWin( VCLUnoHelper::GetInterface ( &rWindow ), uno::UNO_QUERY_THROW );
+ xFrame->initialize( xWin.get() );
+ xDesktop->getFrames()->append( xFrame );
+
+ if ( xWin->isActive() )
+ xFrame->activate();
+
+ // create load arguments
+ Sequence< PropertyValue > aLoadArgs;
+ TransformItems( SID_OPENDOC, *rDoc.GetMedium()->GetItemSet(), aLoadArgs );
+
+ ::comphelper::NamedValueCollection aArgs( aLoadArgs );
+ aArgs.put( "Model", rDoc.GetModel() );
+ aArgs.put( "Hidden", bHidden );
+ if ( nViewId )
+ aArgs.put( "ViewId", nViewId );
+
+ aLoadArgs = aArgs.getPropertyValues();
+
+ // load the doc into that frame
+ ::rtl::OUString sLoaderURL( rDoc.GetModel()->getURL() );
+ if ( sLoaderURL.getLength() == 0 )
+ sLoaderURL = rDoc.GetFactory().GetFactoryURL();
+
+ Reference< XComponentLoader > xLoader( xFrame, UNO_QUERY_THROW );
+ xLoader->loadComponentFromURL(
+ sLoaderURL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ),
+ 0,
+ aLoadArgs
+ );
+
+ for ( pFrame = SfxFrame::GetFirst();
+ pFrame;
+ pFrame = SfxFrame::GetNext( *pFrame )
+ )
+ {
+ if ( pFrame->GetFrameInterface() == xFrame )
+ break;
+ }
+
+ OSL_ENSURE( pFrame, "SfxFrame::Create: load succeeded, but no SfxFrame was created during this!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return pFrame;
+}
+
+SfxFrame* SfxFrame::Create( const Reference < XFrame >& i_rFrame )
+{
+ // create a new TopFrame to an external XFrame object ( wrap controller )
+ ENSURE_OR_THROW( i_rFrame.is(), "NULL frame not allowed" );
+ Window* pWindow = VCLUnoHelper::GetWindow( i_rFrame->getContainerWindow() );
+ ENSURE_OR_THROW( pWindow, "frame without container window not allowed" );
+
+ SfxFrame* pFrame = new SfxFrame( *pWindow, false );
+ pFrame->SetFrameInterface_Impl( i_rFrame );
+ return pFrame;
+}
+
+SfxFrame::SfxFrame( Window& i_rContainerWindow, bool i_bHidden )
+ :pParentFrame( NULL )
+ ,pChildArr( NULL )
+ ,pImp( NULL )
+ ,pWindow( NULL )
+{
+ Construct_Impl();
+
+ pImp->bHidden = i_bHidden;
+ InsertTopFrame_Impl( this );
+ pImp->pExternalContainerWindow = &i_rContainerWindow;
+
+ pWindow = new SfxFrameWindow_Impl( this, i_rContainerWindow );
+
+ // always show pWindow, which is the ComponentWindow of the XFrame we live in
+ // nowadays, since SfxFrames can be created with an XFrame only, hiding or showing the complete XFrame
+ // is not done at level of the container window, not at SFX level. Thus, the component window can
+ // always be visible.
+ pWindow->Show();
+}
+
+void SfxFrame::SetPresentationMode( BOOL bSet )
+{
+ if ( GetCurrentViewFrame() )
+ GetCurrentViewFrame()->GetWindow().SetBorderStyle( bSet ? WINDOW_BORDER_NOBORDER : WINDOW_BORDER_NORMAL );
+
+ Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
+
+ if ( xPropSet.is() )
+ {
+ Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
+ aValue >>= xLayoutManager;
+ }
+
+ if ( xLayoutManager.is() )
+ xLayoutManager->setVisible( !bSet ); // we don't want to have ui in presentation mode
+
+ SetMenuBarOn_Impl( !bSet );
+ if ( GetWorkWindow_Impl() )
+ GetWorkWindow_Impl()->SetDockingAllowed( !bSet );
+ if ( GetCurrentViewFrame() )
+ GetCurrentViewFrame()->GetDispatcher()->Update_Impl( TRUE );
+}
+
+SystemWindow* SfxFrame::GetSystemWindow() const
+{
+ return GetTopWindow_Impl();
+}
+
+SystemWindow* SfxFrame::GetTopWindow_Impl() const
+{
+ if ( pImp->pExternalContainerWindow->IsSystemWindow() )
+ return (SystemWindow*) pImp->pExternalContainerWindow;
+ else
+ return NULL;
+}
+
+Window& SfxFrame::GetWindow() const
+{
+ return *pWindow;
+}
+
+sal_Bool SfxFrame::Close()
+{
+ delete this;
+ return sal_True;
+}
+
+void SfxFrame::LockResize_Impl( BOOL bLock )
+{
+ pImp->bLockResize = bLock;
+}
+
+IMPL_LINK( SfxFrameWindow_Impl, CloserHdl, void*, EMPTYARG )
+{
+ if ( pFrame && !pFrame->PrepareClose_Impl( TRUE ) )
+ return 0L;
+
+ if ( pFrame )
+ pFrame->GetCurrentViewFrame()->GetBindings().Execute( SID_CLOSEWIN, 0, 0, SFX_CALLMODE_ASYNCHRON );
+ return 0L;
+}
+
+void SfxFrame::SetMenuBarOn_Impl( BOOL bOn )
+{
+ pImp->bMenuBarOn = bOn;
+
+ Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
+
+ if ( xPropSet.is() )
+ {
+ Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
+ aValue >>= xLayoutManager;
+ }
+
+ if ( xLayoutManager.is() )
+ {
+ rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ));
+
+ if ( bOn )
+ xLayoutManager->showElement( aMenuBarURL );
+ else
+ xLayoutManager->hideElement( aMenuBarURL );
+ }
+}
+
+BOOL SfxFrame::IsMenuBarOn_Impl() const
+{
+ return pImp->bMenuBarOn;
+}
+
+void SfxFrame::PositionWindow_Impl( const Rectangle& rWinArea ) const
+{
+ Window *pWin = pImp->pExternalContainerWindow;
+
+ // Groesse setzen
+ const Size aAppWindow( pImp->pExternalContainerWindow->GetDesktopRectPixel().GetSize() );
+ Point aPos( rWinArea.TopLeft() );
+ Size aSz( rWinArea.GetSize() );
+ if ( aSz.Width() && aSz.Height() )
+ {
+ aPos.X() = Min(aPos.X(),
+ long(aAppWindow.Width() - aSz.Width() + aSz.Width() / 2) );
+ aPos.Y() = Min(aPos.Y(),
+ long( aAppWindow.Height() - aSz.Height() + aSz.Height() / 2) );
+ if ( aPos.X() + aSz.Width() <
+ aAppWindow.Width() + aSz.Width() / 2 &&
+ aPos.Y() + aSz.Height() <
+ aAppWindow.Height() + aSz.Height() / 2 )
+ {
+ pWin->SetPosPixel( aPos );
+ pWin->SetOutputSizePixel( aSz );
+ }
+ }
+}
+
+void SfxFrame::PrepareForDoc_Impl( SfxObjectShell& i_rDoc )
+{
+ const ::comphelper::NamedValueCollection aDocumentArgs( i_rDoc.GetModel()->getArgs() );
+
+ // hidden?
+ OSL_ENSURE( !pImp->bHidden, "when does this happen?" );
+ pImp->bHidden = aDocumentArgs.getOrDefault( "Hidden", pImp->bHidden );
+
+ // update our descriptor
+ UpdateDescriptor( &i_rDoc );
+
+ // plugin mode
+ sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) );
+ if ( nPluginMode && ( nPluginMode != 2 ) )
+ SetInPlace_Impl( TRUE );
+}
+
+bool SfxFrame::IsMarkedHidden_Impl() const
+{
+ return pImp->bHidden;
+}
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index e1177e0a7b5f..ed158ce009e3 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -29,70 +29,85 @@
#include "precompiled_sfx2.hxx"
#include "frmload.hxx"
-
-#include <framework/interaction.hxx>
-#include <com/sun/star/frame/XLoadable.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include "objshimp.hxx"
+#include "viewfac.hxx"
+#include "sfx2/app.hxx"
+#include "sfx2/dispatch.hxx"
+#include "sfx2/docfac.hxx"
+#include "sfx2/docfile.hxx"
+#include "sfx2/docfilt.hxx"
+#include "sfx2/doctempl.hxx"
+#include "sfx2/fcontnr.hxx"
+#include "sfx2/frame.hxx"
+#include "sfx2/request.hxx"
+#include "sfx2/sfx.hrc"
+#include "sfx2/sfxsids.hrc"
+#include "sfx2/sfxuno.hxx"
+#include "sfx2/viewfrm.hxx"
+#include "sfx2/viewsh.hxx"
+
+/** === begin UNO includes === **/
#include <com/sun/star/container/XContainerQuery.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/document/XTypeDetection.hpp>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/awt/XWindow.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
-#include <comphelper/processfactory.hxx>
-#endif
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/task/XInteractionHandler.hpp>
-#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
-#include <com/sun/star/ucb/CommandAbortedException.hpp>
-#include <com/sun/star/ucb/InteractiveAppException.hpp>
-#include <com/sun/star/document/XTypeDetection.hpp>
-#include <framework/interaction.hxx>
-
-#ifndef _TOOLKIT_UNOHLP_HXX
-#include <toolkit/helper/vclunohelper.hxx>
-#endif
-#include <ucbhelper/simpleinteractionrequest.hxx>
+#include <com/sun/star/task/XInteractionHandler2.hpp>
+#include <com/sun/star/document/XViewDataSupplier.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+/** === end UNO includes === **/
-#include <rtl/ustring.h>
+#include <comphelper/interaction.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <framework/interaction.hxx>
#include <rtl/logfile.hxx>
-#include <svl/itemset.hxx>
-#include <vcl/window.hxx>
+#include <rtl/ustring.h>
+#include <sot/storinfo.hxx>
+#include <svtools/ehdl.hxx>
#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svtools/sfxecode.hxx>
#include <svl/stritem.hxx>
-#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <ucbhelper/simpleinteractionrequest.hxx>
#include <vos/mutex.hxx>
-#include <svtools/sfxecode.hxx>
-#include <svtools/ehdl.hxx>
-#include <sot/storinfo.hxx>
-#include <comphelper/sequenceashashmap.hxx>
-#include <comphelper/mediadescriptor.hxx>
-#include <unotools/moduleoptions.hxx>
-
-#ifndef css
-namespace css = ::com::sun::star;
-#endif
-
-#include <sfx2/doctempl.hxx>
-#include <sfx2/app.hxx>
-#include <sfx2/request.hxx>
-#include <sfx2/sfxsids.hrc>
-#include <sfx2/dispatch.hxx>
-#include <sfx2/sfxuno.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <sfx2/topfrm.hxx>
-#include <sfx2/frame.hxx>
-#include <sfx2/docfac.hxx>
-#include <sfx2/fcontnr.hxx>
-#include <sfx2/docfile.hxx>
-#include <sfx2/docfilt.hxx>
-#include "brokenpackageint.hxx"
-#include "objshimp.hxx"
-SfxFrameLoader_Impl::SfxFrameLoader_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& /*xFactory*/ )
+/** === begin UNO using === **/
+using ::com::sun::star::beans::PropertyValue;
+using ::com::sun::star::container::XContainerQuery;
+using ::com::sun::star::container::XEnumeration;
+using ::com::sun::star::document::XTypeDetection;
+using ::com::sun::star::frame::XFrame;
+using ::com::sun::star::frame::XLoadable;
+using ::com::sun::star::frame::XModel;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::task::XInteractionHandler;
+using ::com::sun::star::task::XInteractionHandler2;
+using ::com::sun::star::task::XInteractionRequest;
+using ::com::sun::star::task::XStatusIndicator;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::UNO_SET_THROW;
+using ::com::sun::star::uno::makeAny;
+using ::com::sun::star::util::XCloseable;
+using ::com::sun::star::document::XViewDataSupplier;
+using ::com::sun::star::container::XIndexAccess;
+using ::com::sun::star::frame::XController2;
+using ::com::sun::star::frame::XController;
+using ::com::sun::star::frame::XModel2;
+/** === end UNO using === **/
+
+SfxFrameLoader_Impl::SfxFrameLoader_Impl( const Reference< XMultiServiceFactory >& _rxFactory )
+ :m_aContext( _rxFactory )
{
}
@@ -100,54 +115,46 @@ SfxFrameLoader_Impl::~SfxFrameLoader_Impl()
{
}
-const SfxFilter* impl_detectFilterForURL(const ::rtl::OUString& sURL ,
- const css::uno::Sequence< css::beans::PropertyValue >& rArgs ,
- const SfxFilterMatcher& rMatcher)
+// --------------------------------------------------------------------------------------------------------------------
+const SfxFilter* SfxFrameLoader_Impl::impl_detectFilterForURL( const ::rtl::OUString& sURL,
+ const ::comphelper::NamedValueCollection& i_rDescriptor, const SfxFilterMatcher& rMatcher ) const
{
- static ::rtl::OUString SERVICENAME_TYPEDETECTION = ::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection");
-
::rtl::OUString sFilter;
try
{
- if (!sURL.getLength())
+ if ( !sURL.getLength() )
return 0;
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
- if (!xSMGR.is())
- return 0;
+ Reference< XTypeDetection > xDetect(
+ m_aContext.createComponent( "com.sun.star.document.TypeDetection" ),
+ UNO_QUERY_THROW);
+
+ ::comphelper::NamedValueCollection aNewArgs;
+ aNewArgs.put( "URL", sURL );
- css::uno::Reference< css::document::XTypeDetection > xDetect(
- xSMGR->createInstance(SERVICENAME_TYPEDETECTION),
- css::uno::UNO_QUERY_THROW);
-
- ::comphelper::MediaDescriptor lOrgArgs(rArgs);
- css::uno::Reference< css::task::XInteractionHandler > xInteraction = lOrgArgs.getUnpackedValueOrDefault(
- ::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER(),
- css::uno::Reference< css::task::XInteractionHandler >());
- css::uno::Reference< css::task::XStatusIndicator > xProgress = lOrgArgs.getUnpackedValueOrDefault(
- ::comphelper::MediaDescriptor::PROP_STATUSINDICATOR(),
- css::uno::Reference< css::task::XStatusIndicator >());
-
- ::comphelper::SequenceAsHashMap lNewArgs;
- lNewArgs[::comphelper::MediaDescriptor::PROP_URL()] <<= sURL;
- if (xInteraction.is())
- lNewArgs[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteraction;
- if (xProgress.is())
- lNewArgs[::comphelper::MediaDescriptor::PROP_STATUSINDICATOR()] <<= xProgress;
-
- css::uno::Sequence< css::beans::PropertyValue > lDescr = lNewArgs.getAsConstPropertyValueList();
- ::rtl::OUString sType = xDetect->queryTypeByDescriptor(lDescr, sal_True);
- if (sType.getLength())
+ if ( i_rDescriptor.has( "InteractionHandler" ) )
+ aNewArgs.put( "InteractionHandler", i_rDescriptor.get( "InteractionHandler" ) );
+ if ( i_rDescriptor.has( "StatusIndicator" ) )
+ aNewArgs.put( "StatusIndicator", i_rDescriptor.get( "StatusIndicator" ) );
+
+ Sequence< PropertyValue > aQueryArgs( aNewArgs.getPropertyValues() );
+ ::rtl::OUString sType = xDetect->queryTypeByDescriptor( aQueryArgs, sal_True );
+ if ( sType.getLength() )
{
- const SfxFilter* pFilter = rMatcher.GetFilter4EA(sType);
- if (pFilter)
+ const SfxFilter* pFilter = rMatcher.GetFilter4EA( sType );
+ if ( pFilter )
sFilter = pFilter->GetName();
}
}
- catch(const css::uno::RuntimeException& exRun)
- { throw exRun; }
- catch(const css::uno::Exception&)
- { sFilter = ::rtl::OUString(); }
+ catch ( const RuntimeException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ sFilter = ::rtl::OUString();
+ }
const SfxFilter* pFilter = 0;
if (sFilter.getLength())
@@ -155,453 +162,548 @@ const SfxFilter* impl_detectFilterForURL(const ::rtl::OUString&
return pFilter;
}
-sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const css::uno::Sequence< css::beans::PropertyValue >& rArgs ,
- const css::uno::Reference< css::frame::XFrame >& rFrame )
- throw( css::uno::RuntimeException )
+// --------------------------------------------------------------------------------------------------------------------
+const SfxFilter* SfxFrameLoader_Impl::impl_getFilterFromServiceName_nothrow( const ::rtl::OUString& i_rServiceName ) const
{
- static ::rtl::OUString PROP_URL = ::rtl::OUString::createFromAscii("URL" );
- static ::rtl::OUString PROP_FILENAME = ::rtl::OUString::createFromAscii("FileName" );
- static ::rtl::OUString PROP_TYPENAME = ::rtl::OUString::createFromAscii("TypeName" );
- static ::rtl::OUString PROP_FILTERNAME = ::rtl::OUString::createFromAscii("FilterName" );
- static ::rtl::OUString PROP_MODEL = ::rtl::OUString::createFromAscii("Model" );
- static ::rtl::OUString PROP_DOCUMENTSERVICE = ::rtl::OUString::createFromAscii("DocumentService" );
- static ::rtl::OUString PROP_READONLY = ::rtl::OUString::createFromAscii("ReadOnly" );
- static ::rtl::OUString PROP_ASTEMPLATE = ::rtl::OUString::createFromAscii("AsTemplate" );
- static ::rtl::OUString PROP_INTERACTIONHANDLER = ::rtl::OUString::createFromAscii("InteractionHandler");
-
- sal_Bool bLoadState = sal_False;
-
- // this methods assumes that the filter is detected before, usually by calling the detect() method below
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ try
+ {
+ ::comphelper::NamedValueCollection aQuery;
+ aQuery.put( "DocumentService", i_rServiceName );
- RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxFrameLoader::load" );
+ const Reference< XContainerQuery > xQuery(
+ m_aContext.createComponent( "com.sun.star.document.FilterFactory" ),
+ UNO_QUERY_THROW );
- if ( !rFrame.is() )
- return sal_False;
+ const SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
+ const SfxFilterFlags nMust = SFX_FILTER_IMPORT;
+ const SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED;
- ::comphelper::SequenceAsHashMap lDescriptor(rArgs);
- String rURL = lDescriptor.getUnpackedValueOrDefault(PROP_URL , ::rtl::OUString() );
- String aTypeName = lDescriptor.getUnpackedValueOrDefault(PROP_TYPENAME , ::rtl::OUString() );
- aFilterName = lDescriptor.getUnpackedValueOrDefault(PROP_FILTERNAME , ::rtl::OUString() );
- String aServiceName = lDescriptor.getUnpackedValueOrDefault(PROP_DOCUMENTSERVICE , ::rtl::OUString() );
- css::uno::Reference< css::task::XInteractionHandler > xInteraction = lDescriptor.getUnpackedValueOrDefault(PROP_INTERACTIONHANDLER, css::uno::Reference< css::task::XInteractionHandler >());
- css::uno::Reference< css::frame::XModel > xModel = lDescriptor.getUnpackedValueOrDefault(PROP_MODEL , css::uno::Reference< css::frame::XModel >() );
+ Reference < XEnumeration > xEnum( xQuery->createSubSetEnumerationByProperties(
+ aQuery.getNamedValues() ), UNO_SET_THROW );
+ while ( xEnum->hasMoreElements() )
+ {
+ ::comphelper::NamedValueCollection aType( xEnum->nextElement() );
+ ::rtl::OUString sFilterName = aType.getOrDefault( "Name", ::rtl::OUString() );
+ if ( !sFilterName.getLength() )
+ continue;
+
+ const SfxFilter* pFilter = rMatcher.GetFilter4FilterName( sFilterName );
+ if ( !pFilter )
+ continue;
+
+ SfxFilterFlags nFlags = pFilter->GetFilterFlags();
+ if ( ( ( nFlags & nMust ) == nMust )
+ && ( ( nFlags & nDont ) == 0 )
+ )
+ {
+ return pFilter;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
- const SfxFilter* pFilter = NULL;
- const SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
+// --------------------------------------------------------------------------------------------------------------------
+::rtl::OUString SfxFrameLoader_Impl::impl_askForFilter_nothrow( const Reference< XInteractionHandler >& i_rxHandler,
+ const ::rtl::OUString& i_rDocumentURL ) const
+{
+ ENSURE_OR_THROW( i_rxHandler.is(), "invalid interaction handler" );
- /* special mode: use already loaded model ...
- In such case no filter name will be selected and no URL will be given!
- Such informations are not neccessary. We have to create a new view only
- and call setComponent() at the corresponding frame. */
- if( !xModel.is() )
+ ::rtl::OUString sFilterName;
+ try
{
+ ::framework::RequestFilterSelect* pRequest = new ::framework::RequestFilterSelect( i_rDocumentURL );
+ Reference< XInteractionRequest > xRequest ( pRequest );
+ i_rxHandler->handle( xRequest );
+ if( !pRequest->isAbort() )
+ sFilterName = pRequest->getFilter();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
- // get filter by its name directly ...
- if( aFilterName.Len() )
- pFilter = rMatcher.GetFilter4FilterName( aFilterName );
+ return sFilterName;
+}
- // or search the preferred filter for the detected type ...
- if( !pFilter && aTypeName.Len() )
- pFilter = rMatcher.GetFilter4EA(aTypeName);
+// --------------------------------------------------------------------------------------------------------------------
+namespace
+{
+ sal_Bool lcl_getDispatchResult( const SfxPoolItem* _pResult )
+ {
+ if ( !_pResult )
+ return sal_False;
- // or use given document service for detection too!
- if (!pFilter && aServiceName.Len())
- {
- ::comphelper::SequenceAsHashMap lQuery;
+ // default must be set to true, because some return values
+ // cant be checked, but nonetheless indicate "success"!
+ sal_Bool bSuccess = sal_True;
- if (aServiceName.Len())
- lQuery[::rtl::OUString::createFromAscii("DocumentService")] <<= ::rtl::OUString(aServiceName);
+ // On the other side some special slots return a boolean state,
+ // which can be set to FALSE.
+ SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, _pResult );
+ if ( pItem )
+ bSuccess = pItem->GetValue();
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery > xQuery ( xServiceManager->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.document.FilterFactory" ) ), ::com::sun::star::uno::UNO_QUERY );
+ return bSuccess;
+ }
+}
- SfxFilterFlags nMust = SFX_FILTER_IMPORT;
- SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED;
+// --------------------------------------------------------------------------------------------------------------------
+sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlotID, const Reference< XFrame >& i_rxFrame,
+ const bool i_bHidden )
+{
+ SfxRequest aRequest( _nSlotID, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
+ aRequest.AppendItem( SfxUnoFrameItem( SID_FILLFRAME, i_rxFrame ) );
+ if ( i_bHidden )
+ aRequest.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) );
+ return lcl_getDispatchResult( SFX_APP()->ExecuteSlot( aRequest ) );
+}
- ::com::sun::star::uno::Reference < com::sun::star::container::XEnumeration > xEnum = xQuery->createSubSetEnumerationByProperties(lQuery.getAsConstNamedValueList());
- while ( xEnum->hasMoreElements() )
- {
- ::comphelper::SequenceAsHashMap aType( xEnum->nextElement() );
- aFilterName = aType.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Name"), ::rtl::OUString());
- if (!aFilterName.Len())
- continue;
- pFilter = rMatcher.GetFilter4FilterName(aFilterName);
- if (!pFilter)
- continue;
- SfxFilterFlags nFlags = pFilter->GetFilterFlags();
- if (
- ((nFlags & nMust) == nMust) &&
- (!(nFlags & nDont ))
- )
- {
- break;
- }
- pFilter = 0; //! in case we reach end of enumeration we must have a valid value ...
- }
- }
+// --------------------------------------------------------------------------------------------------------------------
+void SfxFrameLoader_Impl::impl_lockHiddenDocument( SfxObjectShell& i_rDocument, const ::comphelper::NamedValueCollection& i_rDescriptor ) const
+{
+ const sal_Bool bHidden = i_rDescriptor.getOrDefault( "Hidden", sal_False );
+ if ( !bHidden )
+ return;
+
+ const SfxViewFrame* pExistingViewFrame = SfxViewFrame::GetFirst( &i_rDocument );
+ if ( pExistingViewFrame )
+ return;
+
+ // the document is to be loaded hidden, and it is not yet displayed in any other frame
+ // To prevent it from being closed when the loader returns, increase its OwnerLock
+ // (the OwnerLock is normally increased by every frame in which the document is displayed, and by this loader)
+ i_rDocument.RestoreNoDelete();
+ i_rDocument.OwnerLock( TRUE );
+ i_rDocument.Get_Impl()->bHiddenLockedByAPI = TRUE;
+}
- // or use interaction to ask user for right filter.
- if ( !pFilter && xInteraction.is() && rURL.Len() )
- {
- ::framework::RequestFilterSelect* pRequest = new ::framework::RequestFilterSelect( rURL );
- css::uno::Reference< css::task::XInteractionRequest > xRequest ( pRequest );
- xInteraction->handle( xRequest );
- if( !pRequest->isAbort() )
- {
- aFilterName = pRequest->getFilter();
- pFilter = rMatcher.GetFilter4FilterName( aFilterName );
- }
- }
+// --------------------------------------------------------------------------------------------------------------------
+void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollection& io_rDescriptor ) const
+{
+ const ::rtl::OUString sURL = io_rDescriptor.getOrDefault( "URL", ::rtl::OUString() );
+ const ::rtl::OUString sTypeName = io_rDescriptor.getOrDefault( "TypeName", ::rtl::OUString() );
+ const ::rtl::OUString sFilterName = io_rDescriptor.getOrDefault( "FilterName", ::rtl::OUString() );
+ const ::rtl::OUString sServiceName = io_rDescriptor.getOrDefault( "DocumentService", ::rtl::OUString() );
+ const Reference< XInteractionHandler >
+ xInteraction = io_rDescriptor.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() );
- if( !pFilter )
- return sal_False;
+ const SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
+ const SfxFilter* pFilter = NULL;
+
+ // get filter by its name directly ...
+ if ( sFilterName.getLength() )
+ pFilter = rMatcher.GetFilter4FilterName( sFilterName );
+
+ // or search the preferred filter for the detected type ...
+ if ( !pFilter && sTypeName.getLength() )
+ pFilter = rMatcher.GetFilter4EA( sTypeName );
- aTypeName = pFilter->GetTypeName();
- // use filter names without prefix
- aFilterName = pFilter->GetFilterName();
+ // or use given document service for detection, too
+ if ( !pFilter && sServiceName.getLength() )
+ pFilter = impl_getFilterFromServiceName_nothrow( sServiceName );
+
+ // or use interaction to ask user for right filter.
+ if ( !pFilter && xInteraction.is() && sURL.getLength() )
+ {
+ ::rtl::OUString sSelectedFilter = impl_askForFilter_nothrow( xInteraction, sURL );
+ if ( sSelectedFilter.getLength() )
+ pFilter = rMatcher.GetFilter4FilterName( sSelectedFilter );
+ }
+
+ if ( pFilter )
+ {
+ io_rDescriptor.put( "FilterName", ::rtl::OUString( pFilter->GetFilterName() ) );
// If detected filter indicates using of an own template format
- // add property "AsTemplate" to descriptor. But supress this step
+ // add property "AsTemplate" to descriptor. But suppress this step
// if such property already exists.
- if( pFilter->IsOwnTemplateFormat())
+ if ( pFilter->IsOwnTemplateFormat() && !io_rDescriptor.has( "AsTemplate" ) )
+ io_rDescriptor.put( "AsTemplate", sal_Bool( sal_True ) );
+
+ // The DocumentService property will finally be used to determine the document type to create, so
+ // override it with the service name as indicated by the found filter.
+ io_rDescriptor.put( "DocumentService", ::rtl::OUString( pFilter->GetServiceName() ) );
+ }
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+SfxObjectShellLock SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const
+{
+ for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) )
+ {
+ if ( i_rxDocument == pDoc->GetModel() )
{
- ::comphelper::SequenceAsHashMap::iterator pIt = lDescriptor.find(PROP_ASTEMPLATE);
- if (pIt == lDescriptor.end())
- lDescriptor[PROP_ASTEMPLATE] <<= sal_True;
+ return pDoc;
}
}
- xFrame = rFrame;
+ DBG_ERROR( "SfxFrameLoader_Impl::impl_findObjectShell: model is not based on SfxObjectShell - wrong frame loader usage!" );
+ return NULL;
+}
- // Achtung: beim Abraeumen der Objekte kann die SfxApp destruiert werden, vorher noch Deinitialize_Impl rufen
- SfxApplication* pApp = SFX_APP();
+// --------------------------------------------------------------------------------------------------------------------
+bool SfxFrameLoader_Impl::impl_determineTemplateDocument( ::comphelper::NamedValueCollection& io_rDescriptor ) const
+{
+ const ::rtl::OUString sTemplateRegioName = io_rDescriptor.getOrDefault( "TemplateRegionName", ::rtl::OUString() );
+ const ::rtl::OUString sTemplateName = io_rDescriptor.getOrDefault( "TemplateName", ::rtl::OUString() );
+ const ::rtl::OUString sServiceName = io_rDescriptor.getOrDefault( "DocumentService", ::rtl::OUString() );
+ const ::rtl::OUString sURL = io_rDescriptor.getOrDefault( "URL", ::rtl::OUString() );
+
+ // determine the full URL of the template to use, if any
+ String sTemplateURL;
+ if ( sTemplateRegioName.getLength() && sTemplateName.getLength() )
+ {
+ SfxDocumentTemplates aTmpFac;
+ aTmpFac.GetFull( sTemplateRegioName, sTemplateName, sTemplateURL );
+ }
+ else
+ {
+ if ( sServiceName.getLength() )
+ sTemplateURL = SfxObjectFactory::GetStandardTemplate( sServiceName );
+ else
+ sTemplateURL = SfxObjectFactory::GetStandardTemplate( SfxObjectShell::GetServiceNameFromFactory( sURL ) );
+ }
- // Attention! Because lDescriptor is a copy of rArgs
- // and was might by changed (e.g. for AsTemplate)
- // move all changes there back!
- SfxAllItemSet aSet( pApp->GetPool() );
- TransformParameters( SID_OPENDOC, lDescriptor.getAsConstPropertyValueList(), aSet );
+ if ( sTemplateURL.Len() > 0 )
+ {
+ // detect the filter for the template. Might still be NULL (if the template is broken, or does not
+ // exist, or some such), but this is handled by our caller the same way as if no template/URL was present.
+ const SfxFilter* pTemplateFilter = impl_detectFilterForURL( sTemplateURL, io_rDescriptor, SFX_APP()->GetFilterMatcher() );
+ if ( pTemplateFilter )
+ {
+ // load the template document, but, well, "as template"
+ io_rDescriptor.put( "FilterName", ::rtl::OUString( pTemplateFilter->GetName() ) );
+ io_rDescriptor.put( "FileName", ::rtl::OUString( sTemplateURL ) );
+ io_rDescriptor.put( "AsTemplate", sal_True );
- SFX_ITEMSET_ARG( &aSet, pRefererItem, SfxStringItem, SID_REFERER, FALSE );
- if ( !pRefererItem )
- aSet.Put( SfxStringItem( SID_REFERER, String() ) );
+ // #i21583#
+ // the DocumentService property will finally be used to create the document. Thus, override any possibly
+ // present value with the document service of the template.
+ io_rDescriptor.put( "DocumentService", ::rtl::OUString( pTemplateFilter->GetServiceName() ) );
+ return true;
+ }
+ }
+ return false;
+}
- SfxFrame* pFrame=0;
- for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
+// --------------------------------------------------------------------------------------------------------------------
+USHORT SfxFrameLoader_Impl::impl_findSlotParam( const ::rtl::OUString& i_rFactoryURL ) const
+{
+ ::rtl::OUString sSlotParam;
+ const sal_Int32 nParamPos = i_rFactoryURL.indexOf( '?' );
+ if ( nParamPos >= 0 )
{
- if ( pFrame->GetFrameInterface() == xFrame )
- break;
+ // currently only the "slot" parameter is supported
+ const sal_Int32 nSlotPos = i_rFactoryURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "slot=" ), nParamPos );
+ if ( nSlotPos > 0 )
+ sSlotParam = i_rFactoryURL.copy( nSlotPos + 5 );
}
- BOOL bFrameCreated = FALSE;
- if ( !pFrame )
+ if ( sSlotParam.getLength() )
+ return USHORT( sSlotParam.toInt32() );
+
+ return 0;
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+void SfxFrameLoader_Impl::impl_handleCaughtError_nothrow( const Any& i_rCaughtError, const ::comphelper::NamedValueCollection& i_rDescriptor ) const
+{
+ try
+ {
+ const Reference< XInteractionHandler > xInteraction =
+ i_rDescriptor.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() );
+ if ( !xInteraction.is() )
+ return;
+ ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( i_rCaughtError ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
+ pRequest->addContinuation( pApprove.get() );
+
+ const Reference< XInteractionHandler2 > xHandler( xInteraction, UNO_QUERY );
+ #if OSL_DEBUG_LEVEL > 0
+ const sal_Bool bHandled =
+ #endif
+ xHandler.is() && xHandler->handleInteractionRequest( pRequest.get() );
+
+ #if OSL_DEBUG_LEVEL > 0
+ if ( !bHandled )
+ // the interaction handler couldn't deal with this error
+ // => report it as assertion, at least (done in the DBG_UNHANDLED_EXCEPTION below)
+ ::cppu::throwException( i_rCaughtError );
+ #endif
+ }
+ catch( const Exception& )
{
- pFrame = SfxTopFrame::Create( rFrame );
- bFrameCreated = TRUE;
+ DBG_UNHANDLED_EXCEPTION();
}
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+void SfxFrameLoader_Impl::impl_removeLoaderArguments( ::comphelper::NamedValueCollection& io_rDescriptor )
+{
+ // remove the arguments which are for the loader only, and not for a call to attachResource
+ io_rDescriptor.remove( "StatusIndicator" );
+ io_rDescriptor.remove( "Model" );
+}
- if ( xModel.is() )
+// --------------------------------------------------------------------------------------------------------------------
+::comphelper::NamedValueCollection SfxFrameLoader_Impl::impl_extractViewCreationArgs( ::comphelper::NamedValueCollection& io_rDescriptor )
+{
+ const sal_Char* pKnownViewArgs[] = {
+ "JumpMark"
+ };
+
+ ::comphelper::NamedValueCollection aViewArgs;
+ for ( size_t i=0; i < sizeof( pKnownViewArgs ) / sizeof( pKnownViewArgs[0] ); ++i )
{
- // !TODO: replace by ViewFactory
- if ( pFrame->GetFrameInterface()->getController().is() )
+ if ( io_rDescriptor.has( pKnownViewArgs[i] ) )
{
- // remove old component
- // if a frame was created already, it can't be an SfxComponent!
- pFrame->GetFrameInterface()->setComponent( 0, 0 );
- if ( !bFrameCreated )
- pFrame = SfxTopFrame::Create( rFrame );
+ aViewArgs.put( pKnownViewArgs[i], io_rDescriptor.get( pKnownViewArgs[i] ) );
+ io_rDescriptor.remove( pKnownViewArgs[i] );
}
+ }
+ return aViewArgs;
+}
- aSet.Put( SfxFrameItem( SID_DOCFRAME, pFrame ) );
-
- for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) )
+// --------------------------------------------------------------------------------------------------------------------
+sal_Int16 SfxFrameLoader_Impl::impl_determineEffectiveViewId_nothrow( const SfxObjectShell& i_rDocument, const ::comphelper::NamedValueCollection& i_rDescriptor )
+{
+ sal_Int16 nViewId = i_rDescriptor.getOrDefault( "ViewId", sal_Int16( 0 ) );
+ try
+ {
+ if ( nViewId == 0 ) do
{
- if ( xModel == pDoc->GetModel() )
- {
- pFrame->SetItemSet_Impl( &aSet );
- ::comphelper::SequenceAsHashMap lUpdateDescr( lDescriptor );
- lUpdateDescr.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ) );
- lUpdateDescr.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) );
-
- xModel->attachResource( rURL, lUpdateDescr.getAsConstPropertyValueList() );
- return pFrame->InsertDocument( pDoc );
- }
+ Reference< XViewDataSupplier > xViewDataSupplier( i_rDocument.GetModel(), UNO_QUERY );
+ Reference< XIndexAccess > xViewData;
+ if ( xViewDataSupplier.is() )
+ xViewData.set( xViewDataSupplier->getViewData() );
+
+ if ( !xViewData.is() || ( xViewData->getCount() == 0 ) )
+ // no view data stored together with the model
+ break;
+
+ // obtain the ViewID from the view data
+ Sequence< PropertyValue > aViewData;
+ if ( !( xViewData->getByIndex( 0 ) >>= aViewData ) )
+ break;
+
+ ::comphelper::NamedValueCollection aNamedViewData( aViewData );
+ ::rtl::OUString sViewId = aNamedViewData.getOrDefault( "ViewId", ::rtl::OUString() );
+ if ( !sViewId.getLength() )
+ break;
+
+ // somewhat weird convention here ... in the view data, the ViewId is a string, effectively describing
+ // a view name. In the document load descriptor, the ViewId is in fact the numeric ID.
+
+ SfxViewFactory* pViewFactory = i_rDocument.GetFactory().GetViewFactoryByViewName( sViewId );
+ if ( pViewFactory )
+ nViewId = sal_Int16( pViewFactory->GetOrdinal() );
}
-
- DBG_ERROR("Model is not based on SfxObjectShell - wrong frame loader use!");
- return sal_False;
+ while ( false );
}
-
- // check for the URL pattern of our factory URLs
- SfxFrameWeak wFrame = pFrame;
- String aPrefix = String::CreateFromAscii( "private:factory/" );
- String aFact( rURL );
- if ( aPrefix.Len() == aFact.Match( aPrefix ) )
+ catch( const Exception& )
{
- if ( !aServiceName.Len() )
- aServiceName = SfxObjectShell::GetServiceNameFromFactory( rURL );
+ DBG_UNHANDLED_EXCEPTION();
+ }
- // it's a factory URL
- aFact.Erase( 0, aPrefix.Len() );
+ if ( nViewId == 0 )
+ nViewId = i_rDocument.GetFactory().GetViewFactory( 0 ).GetOrdinal();
+ return nViewId;
+}
- // look for parameters
- String aParam;
- USHORT nPos = aFact.Search( '?' );
- if ( nPos != STRING_NOTFOUND )
- {
- // currently only the "slot" parameter is supported
- USHORT nParamPos = aFact.Search( String::CreateFromAscii("slot="), nPos );
- if ( nParamPos != STRING_NOTFOUND )
- aParam = aFact.Copy( nParamPos+5, aFact.Len() );
- aFact.Erase( nPos, aFact.Len() );
- }
+// --------------------------------------------------------------------------------------------------------------------
+Reference< XController2 > SfxFrameLoader_Impl::impl_createDocumentView( const Reference< XModel2 >& i_rModel,
+ const Reference< XFrame >& i_rFrame, const ::comphelper::NamedValueCollection& i_rViewFactoryArgs,
+ const ::rtl::OUString& i_rViewName )
+{
+ // let the model create a new controller
+ const Reference< XController2 > xController( i_rModel->createViewController(
+ i_rViewName,
+ i_rViewFactoryArgs.getPropertyValues(),
+ i_rFrame
+ ), UNO_SET_THROW );
+
+ // introduce model/view/controller to each other
+ xController->attachModel( i_rModel.get() );
+ i_rModel->connectController( xController.get() );
+ i_rFrame->setComponent( xController->getComponentWindow(), xController.get() );
+ xController->attachFrame( i_rFrame );
+ i_rModel->setCurrentController( xController.get() );
+
+ return xController;
+}
- WildCard aSearchedFac( aFact.EraseAllChars('4').ToUpperAscii() );
- SFX_ITEMSET_ARG( &aSet, pDocumentTitleItem, SfxStringItem, SID_DOCINFO_TITLE, FALSE );
- INetURLObject aObj( rURL );
+// --------------------------------------------------------------------------------------------------------------------
+sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rArgs,
+ const Reference< XFrame >& _rTargetFrame )
+ throw( RuntimeException )
+{
+ ENSURE_OR_THROW( _rTargetFrame.is(), "illegal NULL frame" );
- if ( aParam.Len() )
- {
- sal_uInt16 nSlotId = (sal_uInt16) aParam.ToInt32();
- SfxRequest aReq( nSlotId, SFX_CALLMODE_SYNCHRON, pApp->GetPool() );
- aReq.AppendItem( SfxFrameItem ( SID_DOCFRAME, pFrame ) );
- const SfxPoolItem* pRet = pApp->ExecuteSlot( aReq );
- if ( pRet )
- {
- // default must be set to true, because some return values
- // cant be checked ... but indicates "success"!
- bLoadState = sal_True;
-
- // On the other side some special slots return a boolean state,
- // which can be set to FALSE.
- SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, pRet );
- if (pItem)
- bLoadState = pItem->GetValue();
- }
- else
- bLoadState = sal_False;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
- if ( !bLoadState && bFrameCreated && wFrame && !wFrame->GetCurrentDocument() )
- {
- css::uno::Reference< css::frame::XFrame > axFrame;
- wFrame->SetFrameInterface_Impl( axFrame );
- wFrame->DoClose();
- }
+ RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxFrameLoader::load" );
- xFrame.clear();
- xListener.clear();
- return bLoadState;
- }
+ ::comphelper::NamedValueCollection aDescriptor( rArgs );
- String sTemplateURL;
- SFX_ITEMSET_ARG( &aSet, pTemplateRegionItem, SfxStringItem, SID_TEMPLATE_REGIONNAME, FALSE );
- SFX_ITEMSET_ARG( &aSet, pTemplateNameItem, SfxStringItem, SID_TEMPLATE_NAME, FALSE );
- if ( pTemplateRegionItem && pTemplateNameItem )
- {
- SfxDocumentTemplates aTmpFac;
- aTmpFac.GetFull( pTemplateRegionItem->GetValue(), pTemplateNameItem->GetValue(), sTemplateURL );
- }
- else
+ // ensure the descriptor contains a referrer
+ if ( !aDescriptor.has( "Referer" ) )
+ aDescriptor.put( "Referer", ::rtl::OUString() );
+
+ // TODO: is this needed? finally, when loading is successfull, then there should be no need for this item,
+ // as the document can always obtain its frame. In particular, there might be situations where this frame
+ // is accessed, but already disposed: Imagine the user loading a document, opening a second view on it, and
+ // then closing the first view/frame.
+ aDescriptor.put( "Frame", _rTargetFrame );
+
+ // did the caller already pass a model?
+ Reference< XModel2 > xModel = aDescriptor.getOrDefault( "Model", Reference< XModel2 >() );
+ const bool bExternalModel = xModel.is();
+
+ // check for factory URLs to create a new doc, instead of loading one
+ const ::rtl::OUString sURL = aDescriptor.getOrDefault( "URL", ::rtl::OUString() );
+ const bool bIsFactoryURL = ( sURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "private:factory/" ) ) == 0 );
+ bool bInitNewModel = bIsFactoryURL;
+ if ( bIsFactoryURL && !bExternalModel )
+ {
+ const ::rtl::OUString sFactory = sURL.copy( sizeof( "private:factory/" ) -1 );
+ // special handling for some weird factory URLs a la private:factory/swriter?slot=21053
+ const USHORT nSlotParam = impl_findSlotParam( sFactory );
+ if ( nSlotParam != 0 )
{
- sTemplateURL = SfxObjectFactory::GetStandardTemplate( aServiceName );
+ return impl_createNewDocWithSlotParam( nSlotParam, _rTargetFrame, aDescriptor.getOrDefault( "Hidden", false ) );
}
- BOOL bUseTemplate = (sTemplateURL.Len()>0);
- if( bUseTemplate )
+ const bool bDescribesValidTemplate = impl_determineTemplateDocument( aDescriptor );
+ if ( bDescribesValidTemplate )
{
- // #i21583#
- // Forget the filter, which was detected for the corresponding "private:factory/xxx" URL.
- // We must use the right filter, matching to this document ... not to the private URL!
- const SfxFilter* pTemplateFilter = impl_detectFilterForURL(sTemplateURL, rArgs, rMatcher);
- if (pTemplateFilter)
- {
- pFilter = pTemplateFilter;
- aFilterName = pTemplateFilter->GetName();
- // standard template set -> load it "AsTemplate"
- aSet.Put( SfxStringItem ( SID_FILE_NAME, sTemplateURL ) );
- aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
- }
-
- // #119268#
- // something is wrong with the set default template (e.g. unknown format, missing file etcpp)
- // The we have to jump into the following special code, where "private:factory/ URL's are handled.
- // We cant "load" such private/factory URL's!
- else
- bUseTemplate = FALSE;
+ // if the media descriptor allowed us to determine a template document to create the new document
+ // from, then do not init a new document model from scratch (below), but instead load the
+ // template document
+ bInitNewModel = false;
}
-
- if ( !bUseTemplate )
+ else
{
- // execute "NewDocument" request
- /* Attention!
- #107913#
- Pointers can't be used to check if two objects are equals!
- E.g. the memory manager can reuse freed memory ...
- and then the holded copy of a pointer will point to another
- (and different!) object - may using the same type then before.
- In such case we compare one object with itself ...
- */
- SfxRequest aReq( SID_NEWDOCDIRECT, SFX_CALLMODE_SYNCHRON, aSet );
- aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, pFrame ) );
- aReq.AppendItem( SfxStringItem( SID_NEWDOCDIRECT, aFact ) );
-
- if ( pDocumentTitleItem )
- aReq.AppendItem( *pDocumentTitleItem );
-
- const SfxPoolItem* pRet = pApp->NewDocDirectExec_ImplOld(aReq);
- if (pRet)
- {
- // default must be set to true, because some return values
- // cant be checked ... but indicates "success"!
- bLoadState = sal_True;
-
- // On the other side some special slots return a boolean state,
- // which can be set to FALSE.
- SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, pRet );
- if (pItem)
- bLoadState = pItem->GetValue();
- }
- else
- bLoadState = sal_False;
-
- if ( !bLoadState && bFrameCreated && wFrame && !wFrame->GetCurrentDocument() )
- {
- css::uno::Reference< css::frame::XFrame > axFrame;
- wFrame->SetFrameInterface_Impl( axFrame );
- wFrame->DoClose();
- }
-
- xFrame.clear();
- xListener.clear();
- return bLoadState;
+ const ::rtl::OUString sServiceName = SfxObjectShell::GetServiceNameFromFactory( sFactory );
+ aDescriptor.put( "DocumentService", sServiceName );
}
}
else
{
- // load the desired file
- aSet.Put( SfxStringItem ( SID_FILE_NAME, rURL ) );
+ // compatibility
+ aDescriptor.put( "FileName", aDescriptor.get( "URL" ) );
}
- aSet.Put( SfxFrameItem( SID_DOCFRAME, pFrame ) );
- aSet.Put( SfxUnoAnyItem( SID_FILLFRAME, css::uno::makeAny(xFrame) ) );
- aSet.Put( SfxStringItem( SID_FILTER_NAME, aFilterName ) );
-
- // !TODO: replace by direct construction of model (needs view factory)
- DBG_ASSERT( pFilter, "No filter set!" );
- if ( !pFilter )
- return sal_False;
-
- sal_Bool bDisaster = sal_False;
- SfxObjectShell* pDoc = SfxObjectShell::CreateObject( pFilter->GetServiceName() );
- if ( pDoc )
+ sal_Bool bLoadSuccess = sal_False;
+ try
{
- css::uno::Reference< css::frame::XLoadable > xLoadable = css::uno::Reference< css::frame::XLoadable >( pDoc->GetModel(), css::uno::UNO_QUERY );
- css::uno::Sequence < css::beans::PropertyValue > aLoadArgs;
- TransformItems( SID_OPENDOC, aSet, aLoadArgs );
- try
+ // extract view releant arguments from the loader args
+ ::comphelper::NamedValueCollection aViewCreationArgs( impl_extractViewCreationArgs( aDescriptor ) );
+
+ // no model passed from outside? => create one from scratch
+ if ( !xModel.is() )
{
- xLoadable->load( aLoadArgs );
-
- SfxMedium* pDocMedium = pDoc->GetMedium();
- BOOL bHidden = FALSE;
- SFX_ITEMSET_ARG( pDocMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False);
- if ( pHidItem )
- bHidden = pHidItem->GetValue();
-
- // !TODO: will be done by Framework!
- pDocMedium->SetUpdatePickList( !bHidden );
-
- /*
- #121119#
- We dont know why pFrame can be corrupt here.
- But if it was deleted it shouldnt exists inside our global list.
- May be we can use the damaged pointer to detect if it was removed from
- this global list.
- */
- SfxFrame* pTmp=0;
- for ( pTmp = SfxFrame::GetFirst(); pTmp; pTmp = SfxFrame::GetNext( *pTmp ) )
+ // beforehand, determine the filter to use, and update the descriptor with its information
+ if ( !bInitNewModel )
{
- if ( pFrame == pTmp )
- break;
+ impl_determineFilter( aDescriptor );
}
- if ( pTmp == pFrame )
+ // create the new doc
+ const ::rtl::OUString sServiceName = aDescriptor.getOrDefault( "DocumentService", ::rtl::OUString() );
+ xModel.set( m_aContext.createComponent( sServiceName ), UNO_QUERY_THROW );
+
+ // load resp. init it
+ const Reference< XLoadable > xLoadable( xModel, UNO_QUERY_THROW );
+ if ( bInitNewModel )
{
- // !TODO: replace by ViewFactory
- if ( pFrame->GetFrameInterface()->getController().is() )
- {
- // remove old component
- // if a frame was created already, it can't be an SfxComponent!
- // pFrame->GetFrameInterface()->setComponent( 0, 0 );
- if ( !bFrameCreated )
- pFrame = SfxTopFrame::Create( rFrame );
- }
-
- wFrame = pFrame;
- aSet.Put( SfxFrameItem( SID_DOCFRAME, pFrame ) );
- if( pFrame->InsertDocument( pDoc ) )
- {
- pFrame->GetCurrentViewFrame()->UpdateDocument_Impl();
- String aURL = pDoc->GetMedium()->GetName();
- SFX_APP()->Broadcast( SfxStringHint( SID_OPENURL, aURL ) );
- bLoadState = sal_True;
- }
- else
- bDisaster = sal_True;
+ xLoadable->initNew();
+
+ impl_removeLoaderArguments( aDescriptor );
+ xModel->attachResource( ::rtl::OUString(), aDescriptor.getPropertyValues() );
}
else
{
- DBG_ERROR("#121119# You found the reason for a stacktrace! Frame destroyed while loading document.");
- bLoadState = sal_False;
+ xLoadable->load( aDescriptor.getPropertyValues() );
}
}
- catch ( css::uno::Exception& )
+ else
{
- bDisaster = sal_True;
+ // tell the doc its (current) load args.
+ impl_removeLoaderArguments( aDescriptor );
+ xModel->attachResource( xModel->getURL(), aDescriptor.getPropertyValues() );
+ // TODO: not sure this is correct. The original, pre-refactoring code did it this way. However, I could
+ // imagine scenarios where it is *not* correct to overrule the *existing* model args (XModel::getArgs)
+ // with the ones passed to the loader here. For instance, what about the MacroExecutionMode? The document
+ // might have a mode other than the one passed to the loader, and we always overwrite the former with
+ // the latter.
}
- if ( bDisaster )
- {
- if ( wFrame && !wFrame->GetCurrentDocument() )
- {
- // document loading was not successful; close SfxFrame (but not XFrame!)
- css::uno::Reference< css::frame::XFrame > axFrame;
- wFrame->SetFrameInterface_Impl( axFrame );
- wFrame->DoClose();
- aSet.ClearItem( SID_DOCFRAME );
- }
+ // get the SfxObjectShell (still needed at the moment)
+ const SfxObjectShellLock xDoc = impl_findObjectShell( xModel );
+ ENSURE_OR_THROW( xDoc.Is(), "no SfxObjectShell for the given model" );
+
+ // ensure the ID of the to-be-created view is in the descriptor, if possible
+ const sal_Int16 nViewId = impl_determineEffectiveViewId_nothrow( *xDoc, aDescriptor );
+ const sal_Int16 nViewNo = xDoc->GetFactory().GetViewNo_Impl( nViewId, 0 );
+ const ::rtl::OUString sViewName( xDoc->GetFactory().GetViewFactory( nViewNo ).GetViewName() );
+
+ // if the document is created hidden, prevent it from being deleted until it is shown or disposed
+ impl_lockHiddenDocument( *xDoc, aDescriptor );
+ // TODO; if we wouldn't use a SfxObjectShellLock instance for xDoc, but a simple SfxObjectShellRef,
+ // then this would not be necessary, /me thinks. That is, the *Lock classes inc/dec a "Lock" counter
+ // (additional to the ref counter) in their ctor/dtor, and if the lock counter goes to 0, the
+ // object is closed (DoClose). The impl_lockHiddenDocument is to prevent exactly that premature
+ // closing. However, a *Ref object wouldn't close, anyway. And in case of unsuccessfull loading, the
+ // code at the very end of this method cares for closing the XModel, which should also close the
+ // ObjectShell.
+
+ // plug the document into the frame
+ impl_createDocumentView( xModel, _rTargetFrame, aViewCreationArgs, sViewName );
+ bLoadSuccess = sal_True;
+ }
+ catch ( Exception& )
+ {
+ const Any aError( ::cppu::getCaughtException() );
+ if ( !aDescriptor.getOrDefault( "Silent", sal_False ) )
+ impl_handleCaughtError_nothrow( aError, aDescriptor );
+ }
- css::uno::Reference< css::util::XCloseable > xCloseable( xLoadable, css::uno::UNO_QUERY );
- if ( xCloseable.is() )
- {
- try {
- xCloseable->close( sal_True );
- } catch ( css::uno::Exception& )
- {}
- }
+ // if loading was not successful, close the document
+ if ( !bLoadSuccess && !bExternalModel )
+ {
+ try
+ {
+ const Reference< XCloseable > xCloseable( xModel, UNO_QUERY_THROW );
+ xCloseable->close( sal_True );
+ }
+ catch ( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
}
- xFrame.clear();
- xListener.clear();
- return bLoadState;
+ return bLoadSuccess;
}
-void SfxFrameLoader_Impl::cancel() throw( RUNTIME_EXCEPTION )
+void SfxFrameLoader_Impl::cancel() throw( RuntimeException )
{
}
SFX_IMPL_SINGLEFACTORY( SfxFrameLoader_Impl )
/* XServiceInfo */
-UNOOUSTRING SAL_CALL SfxFrameLoader_Impl::getImplementationName() throw( UNORUNTIMEEXCEPTION )
+UNOOUSTRING SAL_CALL SfxFrameLoader_Impl::getImplementationName() throw( RuntimeException )
{
return impl_getStaticImplementationName();
}
\
/* XServiceInfo */
-sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const UNOOUSTRING& sServiceName ) throw( UNORUNTIMEEXCEPTION )
+sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const UNOOUSTRING& sServiceName ) throw( RuntimeException )
{
UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames();
const UNOOUSTRING* pArray = seqServiceNames.getConstArray();
@@ -616,7 +718,7 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const UNOOUSTRING& sServ
}
/* XServiceInfo */
-UNOSEQUENCE< UNOOUSTRING > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() throw( UNORUNTIMEEXCEPTION )
+UNOSEQUENCE< UNOOUSTRING > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() throw( RuntimeException )
{
return impl_getStaticSupportedServiceNames();
}
diff --git a/sfx2/source/view/impframe.cxx b/sfx2/source/view/impframe.cxx
deleted file mode 100644
index 997637b3a531..000000000000
--- a/sfx2/source/view/impframe.cxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sfx2.hxx"
-
-#ifndef GCC
-#endif
-
-#include "impframe.hxx"
-
-#include <svl/smplhint.hxx>
-
-#include <sfx2/frame.hxx>
-#include <sfx2/bindings.hxx>
-#include <sfx2/viewfrm.hxx>
-
-void SfxFrame_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
-{
- SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint );
- if( pHint && pHint->GetId() == SFX_HINT_CANCELLABLE && pCurrentViewFrame )
- {
- // vom Cancel-Manager
- SfxBindings &rBind = pCurrentViewFrame->GetBindings();
- rBind.Invalidate( SID_BROWSE_STOP );
- if ( !rBind.IsInRegistrations() )
- rBind.Update( SID_BROWSE_STOP );
- rBind.Invalidate( SID_BROWSE_STOP );
- }
-}
-
diff --git a/sfx2/source/view/impframe.hxx b/sfx2/source/view/impframe.hxx
index 9098ffd8f842..72f322036efb 100644
--- a/sfx2/source/view/impframe.hxx
+++ b/sfx2/source/view/impframe.hxx
@@ -28,8 +28,6 @@
#ifndef _SFX_IMPFRAME_HXX
#define _SFX_IMPFRAME_HXX
-#include <svl/cancel.hxx>
-
#include <sfx2/frame.hxx>
#include <sfx2/viewfrm.hxx> // SvBorder
@@ -51,60 +49,51 @@ class SfxObjectShell;
#define FRAME_SEARCH_CREATE 0x00000008
#endif
-class SfxFrame_Impl : public SfxBroadcaster, public SvCompatWeakBase, public SfxListener
+class SfxFrame_Impl : public SfxBroadcaster, public SvCompatWeakBase
{
-friend class SfxFrame;
-
+public:
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
- String aFrameIdName;
sal_uInt32 nType;
- sal_uInt32 nHistoryPos;
SfxViewFrame* pCurrentViewFrame;
- SfxObjectShell* pCurrentObjectShell;
SfxFrameDescriptor* pDescr;
- sal_uInt16 nFrameId;
sal_uInt16 nLocks;
- sal_Bool bCloseOnUnlock : 1;
sal_Bool bClosing : 1;
sal_Bool bPrepClosing : 1;
sal_Bool bInCancelTransfers : 1;
sal_Bool bOwnsBindings : 1;
sal_Bool bReleasingComponent : 1;
- sal_Bool bFocusLocked : 1;
sal_Bool bInPlace : 1;
- SfxCancelManager* pCancelMgr;
- SfxCancellable* pLoadCancellable;
SfxFrame* pFrame;
- const SfxItemSet* pSet;
SfxWorkWindow* pWorkWin;
SvBorder aBorder;
+ // formerly SfxTopFrame
+ Window* pExternalContainerWindow;
+ bool bHidden;
+ bool bLockResize;
+ bool bMenuBarOn;
- SfxFrame_Impl( SfxFrame* pAntiImplP ) :
- SvCompatWeakBase( pAntiImplP ),
- nType( 0L ),
- nHistoryPos( 0 ),
- pCurrentViewFrame( NULL ),
- pCurrentObjectShell( NULL ),
- pDescr( NULL ),
- nFrameId( 0 ),
- nLocks( 0 ),
- bCloseOnUnlock( sal_False ),
- bClosing(sal_False),
- bPrepClosing(sal_False),
- bInCancelTransfers( sal_False ),
- bOwnsBindings( sal_False ),
- bReleasingComponent( sal_False ),
- bFocusLocked( sal_False ),
- bInPlace( sal_False ),
- pCancelMgr( 0 ),
- pLoadCancellable( 0 ),
- pFrame( pAntiImplP ),
- pSet( 0 ),
- pWorkWin( 0 )
- {}
+ SfxFrame_Impl( SfxFrame* pAntiImplP )
+ :SvCompatWeakBase( pAntiImplP )
+ ,nType( 0L )
+ ,pCurrentViewFrame( NULL )
+ ,pDescr( NULL )
+ ,nLocks( 0 )
+ ,bClosing(sal_False)
+ ,bPrepClosing(sal_False)
+ ,bInCancelTransfers( sal_False )
+ ,bOwnsBindings( sal_False )
+ ,bReleasingComponent( sal_False )
+ ,bInPlace( sal_False )
+ ,pFrame( pAntiImplP )
+ ,pWorkWin( 0 )
+ ,pExternalContainerWindow( NULL )
+ ,bHidden( false )
+ ,bLockResize( false )
+ ,bMenuBarOn( true )
+ {
+ }
- virtual ~SfxFrame_Impl() { delete pCancelMgr; delete pLoadCancellable; }
- virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ virtual ~SfxFrame_Impl() { }
};
#endif
diff --git a/sfx2/source/view/impviewframe.hxx b/sfx2/source/view/impviewframe.hxx
new file mode 100644
index 000000000000..5460d613c7e8
--- /dev/null
+++ b/sfx2/source/view/impviewframe.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef SFX2_IMPVIEWFRAME_HXX
+#define SFX2_IMPVIEWFRAME_HXX
+
+#include "sfx2/viewfrm.hxx"
+
+#include <svtools/asynclink.hxx>
+#include <vcl/window.hxx>
+
+struct SfxViewFrame_Impl
+{
+ SvBorder aBorder;
+ Size aMargin;
+ Size aSize;
+ String aFrameTitle;
+ TypeId aLastType;
+ String aActualURL;
+ SfxFrame& rFrame;
+ svtools::AsynchronLink* pReloader;
+ Window* pWindow;
+ SfxViewFrame* pActiveChild;
+ Window* pFocusWin;
+ sal_uInt16 nDocViewNo;
+ sal_uInt16 nCurViewId;
+ sal_Bool bResizeInToOut:1;
+ sal_Bool bDontOverwriteResizeInToOut:1;
+ sal_Bool bObjLocked:1;
+ sal_Bool bReloading:1;
+ sal_Bool bIsDowning:1;
+ sal_Bool bModal:1;
+ sal_Bool bEnabled:1;
+ sal_Bool bWindowWasEnabled:1;
+ sal_Bool bActive;
+ String aFactoryName;
+
+ SfxViewFrame_Impl( SfxFrame& i_rFrame )
+ : rFrame( i_rFrame )
+ , pReloader(0 )
+ , pWindow( 0 )
+ , bWindowWasEnabled(sal_True)
+ , bActive( sal_False )
+ {
+ }
+
+ ~SfxViewFrame_Impl()
+ {
+ delete pReloader;
+ }
+};
+
+class SfxFrameViewWindow_Impl : public Window
+{
+ BOOL bActive;
+ SfxViewFrame* pFrame;
+
+public:
+ SfxFrameViewWindow_Impl( SfxViewFrame* p, Window& rParent, WinBits nBits=0 ) :
+ Window( &rParent, nBits | WB_BORDER | WB_CLIPCHILDREN ),
+ bActive( FALSE ),
+ pFrame( p )
+ {
+ p->GetFrame().GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER );
+ }
+
+ virtual void Resize();
+ virtual void StateChanged( StateChangedType nStateChange );
+};
+
+#endif // SFX2_IMPVIEWFRAME_HXX
+
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index 56e14f43a08c..6d61f4182bbb 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -57,7 +57,7 @@
#include <sfx2/dispatch.hxx>
#include "workwin.hxx"
#include "guisaveas.hxx"
-#include <sfx2/topfrm.hxx>
+#include <sfx2/viewfrm.hxx>
#include <cppuhelper/implbase5.hxx>
#include <vcl/salbtype.hxx>
#include <svtools/ehdl.hxx>
@@ -201,7 +201,7 @@ throw (::com::sun::star::uno::RuntimeException)
// currently needs SFX code
SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDoc );
- SfxWorkWindow *pWorkWin = pFrame->GetFrame()->GetWorkWindow_Impl();
+ SfxWorkWindow *pWorkWin = pFrame->GetFrame().GetWorkWindow_Impl();
pWorkWin->UpdateObjectBars_Impl();
}
*/
@@ -231,7 +231,7 @@ uno::Reference < frame::XFrame > SfxInPlaceClient_Impl::GetFrame() const
{
if ( !m_pClient )
throw uno::RuntimeException();
- return m_pClient->GetViewShell()->GetViewFrame()->GetFrame()->GetFrameInterface();
+ return m_pClient->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
}
void SAL_CALL SfxInPlaceClient_Impl::saveObject()
@@ -733,7 +733,7 @@ void SfxInPlaceClient::SetObject( const uno::Reference < embed::XEmbeddedObject
}
}
- if ( !m_pViewSh || m_pViewSh->GetViewFrame()->GetFrame()->IsClosing_Impl() )
+ if ( !m_pViewSh || m_pViewSh->GetViewFrame()->GetFrame().IsClosing_Impl() )
// sometimes applications reconnect clients on shutting down because it happens in their Paint methods
return;
@@ -983,7 +983,7 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb )
{
if ( m_pViewSh )
- ((SfxTopFrame*)m_pViewSh->GetViewFrame()->GetTopFrame())->LockResize_Impl(TRUE);
+ m_pViewSh->GetViewFrame()->GetTopFrame().LockResize_Impl(TRUE);
try
{
m_pImp->m_xObject->setClientSite( m_pImp->m_xClient );
@@ -1033,8 +1033,8 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb )
if ( m_pViewSh )
{
SfxViewFrame* pFrame = m_pViewSh->GetViewFrame();
- ((SfxTopFrame*)pFrame->GetTopFrame())->LockResize_Impl(FALSE);
- pFrame->GetTopFrame()->Resize();
+ pFrame->GetTopFrame().LockResize_Impl(FALSE);
+ pFrame->GetTopFrame().Resize();
}
}
}
@@ -1094,7 +1094,7 @@ void SfxInPlaceClient::DeactivateObject()
}
if ( m_pViewSh )
- ((SfxTopFrame*)m_pViewSh->GetViewFrame()->GetTopFrame())->LockResize_Impl(TRUE);
+ m_pViewSh->GetViewFrame()->GetTopFrame().LockResize_Impl(TRUE);
if ( m_pImp->m_xObject->getStatus( m_pImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
{
@@ -1116,8 +1116,8 @@ void SfxInPlaceClient::DeactivateObject()
{
SfxViewFrame* pFrame = m_pViewSh->GetViewFrame();
SfxViewFrame::SetViewFrame( pFrame );
- ((SfxTopFrame*)pFrame->GetTopFrame())->LockResize_Impl(FALSE);
- pFrame->GetTopFrame()->Resize();
+ pFrame->GetTopFrame().LockResize_Impl(FALSE);
+ pFrame->GetTopFrame().Resize();
}
}
catch (com::sun::star::uno::Exception& )
diff --git a/sfx2/source/view/makefile.mk b/sfx2/source/view/makefile.mk
index 758fd5ccb806..9c257f4c9f75 100644
--- a/sfx2/source/view/makefile.mk
+++ b/sfx2/source/view/makefile.mk
@@ -45,17 +45,17 @@ SRC1FILES = \
view.src
SLOFILES = \
- $(SLO)$/ipclient.obj \
+ $(SLO)$/ipclient.obj \
$(SLO)$/viewsh.obj \
$(SLO)$/frmload.obj \
$(SLO)$/frame.obj \
+ $(SLO)$/frame2.obj \
$(SLO)$/printer.obj \
$(SLO)$/viewprn.obj \
$(SLO)$/viewfac.obj \
$(SLO)$/orgmgr.obj \
$(SLO)$/viewfrm.obj \
- $(SLO)$/impframe.obj \
- $(SLO)$/topfrm.obj \
+ $(SLO)$/viewfrm2.obj \
$(SLO)$/sfxbasecontroller.obj \
$(SLO)$/userinputinterception.obj
diff --git a/sfx2/source/view/prnmon.cxx b/sfx2/source/view/prnmon.cxx
index 9f42f438cffa..a4e96ab1065e 100644
--- a/sfx2/source/view/prnmon.cxx
+++ b/sfx2/source/view/prnmon.cxx
@@ -319,7 +319,7 @@ SfxPrintProgress::~SfxPrintProgress()
pImp->pViewShell->GetPrinter()->EnablePrintFile( pImp->bOldEnablePrintFile );
// EndPrint-Notification an Frame
- //pImp->pViewShell->GetViewFrame()->GetFrame()->Lock_Impl(FALSE);
+ //pImp->pViewShell->GetViewFrame()->GetFrame().Lock_Impl(FALSE);
pImp->EndListening( *(pImp->pViewShell->GetObjectShell()) );
// the following call might destroy the view or even the document
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index 88afc2796429..f5c24b195af7 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -46,6 +46,7 @@
#include <com/sun/star/util/XCloseBroadcaster.hpp>
#include <com/sun/star/util/XCloseListener.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
+#include <com/sun/star/document/XViewDataSupplier.hpp>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#include <com/sun/star/frame/FrameActionEvent.hpp>
@@ -53,15 +54,18 @@
#include <com/sun/star/frame/CommandGroup.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XBorderResizeListener.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/EventObject.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/implbase1.hxx>
#include <basic/sbstar.hxx>
#include <uno/mapping.hxx>
#include <sfx2/viewsh.hxx>
+#include <sfx2/docfac.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/app.hxx>
@@ -84,10 +88,12 @@
#include <toolkit/helper/convert.hxx>
#include <framework/titlehelper.hxx>
#include <comphelper/processfactory.hxx>
+#include <tools/diagnose_ex.h>
#include <hash_map>
#include <sfx2/event.hxx>
+#include "viewfac.hxx"
#define OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper
#define OINTERFACECONTAINERHELPER ::cppu::OInterfaceContainerHelper
@@ -109,6 +115,24 @@
#define TIMEOUT_START_RESCHEDULE 10L /* 10th s */
using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::lang::DisposedException;
+using ::com::sun::star::awt::XWindow;
+using ::com::sun::star::frame::XController;
+using ::com::sun::star::frame::XDispatchProvider;
+using ::com::sun::star::document::XViewDataSupplier;
+using ::com::sun::star::container::XIndexAccess;
+using ::com::sun::star::beans::PropertyValue;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::frame::XFrame;
+using ::com::sun::star::frame::XFrameActionListener;
+using ::com::sun::star::util::XCloseListener;
+using ::com::sun::star::task::XStatusIndicator;
+using ::com::sun::star::frame::XTitle;
namespace css = ::com::sun::star;
struct GroupIDToCommandGroup
@@ -220,7 +244,7 @@ void reschedule()
class SfxStatusIndicator : public ::cppu::WeakImplHelper2< ::com::sun::star::task::XStatusIndicator, ::com::sun::star::lang::XEventListener >
{
friend class SfxBaseController;
- ::com::sun::star::uno::Reference < XCONTROLLER > xOwner;
+ ::com::sun::star::uno::Reference < XController > xOwner;
::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator > xProgress;
SfxWorkWindow* pWorkWindow;
sal_Int32 _nRange;
@@ -427,29 +451,19 @@ void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::notifyClosing( const E
struct IMPL_SfxBaseController_DataContainer
{
- REFERENCE < XFRAME > m_xFrame;
- REFERENCE < XFRAMEACTIONLISTENER > m_xListener ;
- REFERENCE < XCLOSELISTENER > m_xCloseListener ;
+ Reference< XFrame > m_xFrame ;
+ Reference< XFrameActionListener > m_xListener ;
+ Reference< XCloseListener > m_xCloseListener ;
::sfx2::UserInputInterception m_aUserInputInterception;
OMULTITYPEINTERFACECONTAINERHELPER m_aListenerContainer ;
- OINTERFACECONTAINERHELPER m_aInterceptorContainer ;
- REFERENCE < ::com::sun::star::task::XStatusIndicator > m_xIndicator;
+ OINTERFACECONTAINERHELPER m_aInterceptorContainer ;
+ Reference< XStatusIndicator > m_xIndicator ;
SfxViewShell* m_pViewShell ;
SfxBaseController* m_pController ;
sal_Bool m_bDisposing ;
- sal_Bool m_bSuspendState;
- /** When this flag is <true/> (the default) then in dispose() the frame
- and with it the view shell are released together with the
- controller.
- A derived class can set the flag to <false/> when it wants to
- exchange controllers that work on the same view shell. One
- application is the Impress Multi Pane GUI that changes shells that
- are stacked on one view shell. Controllers are associated with the
- stacked shells and thus must not destroy the view shell which is not
- affected by the switching.
- */
- sal_Bool m_bIsFrameReleasedWithController;
- css::uno::Reference< css::frame::XTitle > m_xTitleHelper;
+ sal_Bool m_bSuspendState ;
+ Reference< XTitle > m_xTitleHelper ;
+ Sequence< PropertyValue > m_aCreationArgs ;
IMPL_SfxBaseController_DataContainer( MUTEX& aMutex ,
SfxViewShell* pViewShell ,
@@ -463,7 +477,6 @@ struct IMPL_SfxBaseController_DataContainer
, m_pController ( pController )
, m_bDisposing ( sal_False )
, m_bSuspendState ( sal_False )
- , m_bIsFrameReleasedWithController( sal_True )
{
}
@@ -525,8 +538,7 @@ void SAL_CALL IMPL_SfxBaseController_ListenerHelper::disposing( const EVENTOBJEC
//________________________________________________________________________________________________________
DBG_NAME(sfx2_SfxBaseController)
SfxBaseController::SfxBaseController( SfxViewShell* pViewShell )
- : IMPL_SfxBaseController_MutexContainer ( )
- , m_pData ( new IMPL_SfxBaseController_DataContainer( m_aMutex, pViewShell, this ))
+ : m_pData ( new IMPL_SfxBaseController_DataContainer( m_aMutex, pViewShell, this ))
{
DBG_CTOR(sfx2_SfxBaseController,NULL);
m_pData->m_pViewShell->SetController( this );
@@ -543,138 +555,60 @@ SfxBaseController::~SfxBaseController()
}
//________________________________________________________________________________________________________
-// SfxBaseController -> XInterface
-//________________________________________________________________________________________________________
-ANY SAL_CALL SfxBaseController::queryInterface( const UNOTYPE& rType ) throw( RUNTIMEEXCEPTION )
-{
- // Attention:
- // Don't use mutex or guard in this method!!! Is a method of XInterface.
-
- // Ask for my own supported interfaces ...
- ANY aReturn( ::cppu::queryInterface( rType ,
- static_cast< XTYPEPROVIDER* > ( this ) ,
- static_cast< XCOMPONENT* > ( this ) ,
- static_cast< XCONTROLLER* > ( this ) ,
- static_cast< XCONTROLLERBORDER* > ( this ) ,
- static_cast< XUSERINPUTINTERCEPTION* > ( this ) ,
- static_cast< XSTATUSINDICATORSUPPLIER* > ( this ) ,
- static_cast< XCONTEXTMENUINTERCEPTION* > ( this ) ,
- static_cast< XDISPATCHPROVIDER* > ( this ),
- static_cast< XTITLE* > ( this ),
- static_cast< XTITLECHANGEBROADCASTER* > ( this ),
- static_cast< XDISPATCHINFORMATIONPROVIDER* > ( this ) ) ) ;
-
- // If searched interface supported by this class ...
- if ( aReturn.hasValue() == sal_True )
- {
- // ... return this information.
- return aReturn ;
- }
- else
- {
- // Else; ... ask baseclass for interfaces!
- return OWeakObject::queryInterface( rType ) ;
- }
-}
-
-//________________________________________________________________________________________________________
-// SfxBaseController -> XInterface
-//________________________________________________________________________________________________________
-
-void SAL_CALL SfxBaseController::acquire() throw()
-{
- // Attention:
- // Don't use mutex or guard in this method!!! Is a method of XInterface.
-
- // Forward to baseclass
- OWeakObject::acquire() ;
-}
-
-//________________________________________________________________________________________________________
-// SfxBaseController -> XInterface
+// SfxBaseController -> XController2
//________________________________________________________________________________________________________
-void SAL_CALL SfxBaseController::release() throw()
+Reference< XWindow > SAL_CALL SfxBaseController::getComponentWindow() throw (RuntimeException)
{
- // Attention:
- // Don't use mutex or guard in this method!!! Is a method of XInterface.
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->m_pViewShell )
+ throw DisposedException();
- // Forward to baseclass
- OWeakObject::release() ;
+ return Reference< XWindow >( GetViewFrame_Impl().GetFrame().GetWindow().GetComponentInterface(), UNO_QUERY_THROW );
}
-//________________________________________________________________________________________________________
-// SfxBaseController -> XTypeProvider
-//________________________________________________________________________________________________________
-
-SEQUENCE< UNOTYPE > SAL_CALL SfxBaseController::getTypes() throw( RUNTIMEEXCEPTION )
+::rtl::OUString SAL_CALL SfxBaseController::getViewControllerName() throw (RuntimeException)
{
- // Optimize this method !
- // We initialize a static variable only one time. And we don't must use a mutex at every call!
- // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
- static OTYPECOLLECTION* pTypeCollection = NULL ;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() )
+ throw DisposedException();
- if ( pTypeCollection == NULL )
- {
- // Ready for multithreading; get global mutex for first call of this method only! see before
- MUTEXGUARD aGuard( MUTEX::getGlobalMutex() ) ;
+ const SfxObjectFactory& rDocFac( m_pData->m_pViewShell->GetObjectShell()->GetFactory() );
+ sal_uInt16 nViewNo = rDocFac.GetViewNo_Impl( GetViewFrame_Impl().GetCurViewId(), rDocFac.GetViewFactoryCount() );
+ OSL_ENSURE( nViewNo < rDocFac.GetViewFactoryCount(), "SfxBaseController::getViewControllerName: view ID not found in view factories!" );
- // Control these pointer again ... it can be, that another instance will be faster then these!
- if ( pTypeCollection == NULL )
- {
- // Create a static typecollection ...
- static OTYPECOLLECTION aTypeCollection( ::getCppuType(( const REFERENCE< XTYPEPROVIDER >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XCONTROLLER >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XCONTROLLERBORDER >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XDISPATCHPROVIDER >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XSTATUSINDICATORSUPPLIER >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XCONTEXTMENUINTERCEPTION >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XUSERINPUTINTERCEPTION >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XTITLE >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XTITLECHANGEBROADCASTER >*)NULL ) ,
- ::getCppuType(( const REFERENCE< XDISPATCHINFORMATIONPROVIDER >*)NULL ) );
- // ... and set his address to static pointer!
- pTypeCollection = &aTypeCollection ;
- }
- }
+ ::rtl::OUString sViewName;
+ if ( nViewNo < rDocFac.GetViewFactoryCount() )
+ sViewName = rDocFac.GetViewFactory( nViewNo ).GetViewName();
- return pTypeCollection->getTypes() ;
+ return sViewName;
}
-//________________________________________________________________________________________________________
-// SfxBaseController -> XTypeProvider
-//________________________________________________________________________________________________________
-
-SEQUENCE< sal_Int8 > SAL_CALL SfxBaseController::getImplementationId() throw( RUNTIMEEXCEPTION )
+Sequence< PropertyValue > SAL_CALL SfxBaseController::getCreationArguments() throw (RuntimeException)
{
- // Create one Id for all instances of this class.
- // Use ethernet address to do this! (sal_True)
-
- // Optimize this method
- // We initialize a static variable only one time. And we don't must use a mutex at every call!
- // For the first call; pID is NULL - for the second call pID is different from NULL!
- static OIMPLEMENTATIONID* pID = NULL ;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() )
+ throw DisposedException();
- if ( pID == NULL )
- {
- // Ready for multithreading; get global mutex for first call of this method only! see before
- MUTEXGUARD aGuard( MUTEX::getGlobalMutex() ) ;
+ return m_pData->m_aCreationArgs;
+}
- // Control these pointer again ... it can be, that another instance will be faster then these!
- if ( pID == NULL )
- {
- // Create a new static ID ...
- static OIMPLEMENTATIONID aID( sal_False ) ;
- // ... and set his address to static pointer!
- pID = &aID ;
- }
- }
+void SfxBaseController::SetCreationArguments_Impl( const Sequence< PropertyValue >& i_rCreationArgs )
+{
+ OSL_ENSURE( m_pData->m_aCreationArgs.getLength() == 0, "SfxBaseController::SetCreationArguments_Impl: not intended to be called twice!" );
+ m_pData->m_aCreationArgs = i_rCreationArgs;
+}
- return pID->getImplementationId() ;
+SfxViewFrame& SfxBaseController::GetViewFrame_Impl() const
+{
+ ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" );
+ SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame();
+ ENSURE_OR_THROW( pActFrame, "a view shell without a view frame is pretty pathological" );
+ return *pActFrame;
}
//________________________________________________________________________________________________________
-// SfxBaseController -> XController
+// SfxBaseController -> XController2 -> XController
//________________________________________________________________________________________________________
void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame ) throw( ::com::sun::star::uno::RuntimeException )
@@ -701,32 +635,11 @@ void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame
if ( m_pData->m_pViewShell )
{
- SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame() ;
- pActFrame->Enable( TRUE );
- pActFrame->GetDispatcher()->Lock( FALSE );
+ ConnectSfxFrame_Impl( E_CONNECT );
- if ( ( m_pData->m_pViewShell->GetObjectShell() != NULL )
- && ( m_pData->m_pViewShell->GetObjectShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
- )
- {
- SfxViewFrame* pViewFrm = m_pData->m_pViewShell->GetViewFrame();
- if ( !pViewFrm->GetFrame()->IsInPlace() )
- {
- // for outplace embedded objects, we want the layout manager to keep the content window
- // size constant, if possible
- try
- {
- uno::Reference< beans::XPropertySet > xFrameProps( m_pData->m_xFrame, uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xLayouterProps(
- xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ), uno::UNO_QUERY_THROW );
- xLayouterProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreserveContentSize" ) ), uno::makeAny( sal_True ) );
- }
- catch( const uno::Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
- }
+ // attaching the frame to the controller is the last step in the creation of a new view, so notify this
+ SfxEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell() );
+ SFX_APP()->NotifyEvent( aHint );
}
}
}
@@ -787,9 +700,7 @@ sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) throw( ::com::
BOOL bRet = bOther || pDocShell->PrepareClose();
if ( bRet )
{
- // disable window and dispatcher until suspend call is withdrawn
- pActFrame->Enable( FALSE );
- pActFrame->GetDispatcher()->Lock( TRUE );
+ ConnectSfxFrame_Impl( E_DISCONNECT );
m_pData->m_bSuspendState = sal_True;
}
@@ -802,9 +713,7 @@ sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) throw( ::com::
if ( m_pData->m_pViewShell )
{
- SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame() ;
- pActFrame->Enable( TRUE );
- pActFrame->GetDispatcher()->Lock( FALSE );
+ ConnectSfxFrame_Impl( E_RECONNECT );
}
m_pData->m_bSuspendState = sal_False;
@@ -893,7 +802,7 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU
if ( xFrame.is() )
xFrame->setName( sTargetFrameName );
- REFERENCE < XDISPATCHPROVIDER > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY );
+ Reference< XDispatchProvider > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY );
if ( xProv.is() )
return xProv->queryDispatch( aURL, sTargetFrameName, ::com::sun::star::frame::FrameSearchFlag::SELF );
}
@@ -911,13 +820,13 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU
pSlot = rSlotPool.GetUnoSlot( aMasterCommand );
else
pSlot = rSlotPool.GetUnoSlot( aURL.Path );
- if ( pSlot && ( !pAct->GetFrame()->IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
+ if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
return pAct->GetBindings().GetDispatch( pSlot, aURL, bMasterCommand );
else
{
// try to find parent SfxViewFrame
uno::Reference< frame::XFrame > xParentFrame;
- uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame()->GetFrameInterface();
+ uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface();
if ( xOwnFrame.is() )
xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY );
@@ -932,7 +841,7 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU
pFrame;
pFrame = SfxViewFrame::GetNext( *pFrame ) )
{
- if ( pFrame->GetFrame()->GetFrameInterface() == xParentFrame )
+ if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame )
{
pParentFrame = pFrame;
break;
@@ -968,13 +877,13 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU
SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct );
const SfxSlot* pSlot = rSlotPool.GetSlot( nId );
- if ( pSlot && ( !pAct->GetFrame()->IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
+ if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) )
return pAct->GetBindings().GetDispatch( pSlot, aURL, sal_False );
else
{
// try to find parent SfxViewFrame
uno::Reference< frame::XFrame > xParentFrame;
- uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame()->GetFrameInterface();
+ uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface();
if ( xOwnFrame.is() )
xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY );
@@ -989,7 +898,7 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU
pFrame;
pFrame = SfxViewFrame::GetNext( *pFrame ) )
{
- if ( pFrame->GetFrame()->GetFrameInterface() == xParentFrame )
+ if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame )
{
pParentFrame = pFrame;
break;
@@ -1123,19 +1032,14 @@ void SfxBaseController::BorderWidthsChanged_Impl()
// SfxBaseController -> XComponent
//________________________________________________________________________________________________________
-void SfxBaseController::FrameIsReleasedWithController (sal_Bool bFlag)
-{
- m_pData->m_bIsFrameReleasedWithController = bFlag;
-}
-
void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::RuntimeException )
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
- REFERENCE < XCONTROLLER > xTmp( this );
+ Reference< XController > xTmp( this );
m_pData->m_bDisposing = sal_True ;
EVENTOBJECT aEventObject;
- aEventObject.Source = (XCONTROLLER*)this ;
+ aEventObject.Source = *this ;
m_pData->m_aListenerContainer.disposeAndClear( aEventObject ) ;
if ( m_pData->m_pController && m_pData->m_pController->getFrame().is() )
@@ -1144,18 +1048,15 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime
if ( m_pData->m_pViewShell )
{
SfxViewFrame* pFrame = m_pData->m_pViewShell->GetViewFrame() ;
- if (m_pData->m_bIsFrameReleasedWithController)
- {
- if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell )
- pFrame->GetFrame()->SetIsClosing_Impl();
- m_pData->m_pViewShell->DiscardClients_Impl();
- m_pData->m_pViewShell->pImp->bControllerSet = sal_False ;
- }
+ if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell )
+ pFrame->GetFrame().SetIsClosing_Impl();
+ m_pData->m_pViewShell->DiscardClients_Impl();
+ m_pData->m_pViewShell->pImp->bControllerSet = sal_False ;
if ( pFrame )
{
EVENTOBJECT aObject;
- aObject.Source = (OWEAKOBJECT*)this ;
+ aObject.Source = *this ;
SfxObjectShell* pDoc = pFrame->GetObjectShell() ;
SfxViewFrame *pView = SfxViewFrame::GetFirst(pDoc);
@@ -1167,12 +1068,9 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime
pView = SfxViewFrame::GetNext( *pView, pDoc );
}
- if ( m_pData->m_bIsFrameReleasedWithController )
- {
- SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc ) );
- if ( !pView )
- SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) );
- }
+ SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc ) );
+ if ( !pView )
+ SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) );
REFERENCE< XMODEL > xModel = pDoc->GetModel();
REFERENCE < ::com::sun::star::util::XCloseable > xCloseable( xModel, com::sun::star::uno::UNO_QUERY );
@@ -1189,14 +1087,13 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime
m_pData->m_xListener->disposing( aObject );
SfxViewShell *pShell = m_pData->m_pViewShell;
m_pData->m_pViewShell = NULL;
- if ( pFrame->GetViewShell() == pShell
- && m_pData->m_bIsFrameReleasedWithController)
+ if ( pFrame->GetViewShell() == pShell )
{
// Enter registrations only allowed if we are the owner!
- if ( pFrame->GetFrame()->OwnsBindings_Impl() )
+ if ( pFrame->GetFrame().OwnsBindings_Impl() )
pFrame->GetBindings().ENTERREGISTRATIONS();
- pFrame->GetFrame()->SetFrameInterface_Impl( aXFrame );
- pFrame->GetFrame()->DoClose_Impl();
+ pFrame->GetFrame().SetFrameInterface_Impl( aXFrame );
+ pFrame->GetFrame().DoClose_Impl();
}
}
}
@@ -1250,7 +1147,7 @@ SfxViewShell* SfxBaseController::GetViewShell_Impl() const
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
if ( m_pData->m_pViewShell && !m_pData->m_xIndicator.is() )
- m_pData->m_xIndicator = new SfxStatusIndicator( this, m_pData->m_pViewShell->GetViewFrame()->GetFrame()->GetWorkWindow_Impl() );
+ m_pData->m_xIndicator = new SfxStatusIndicator( this, m_pData->m_pViewShell->GetViewFrame()->GetFrame().GetWorkWindow_Impl() );
return m_pData->m_xIndicator;
}
@@ -1395,6 +1292,165 @@ BOOL SfxBaseController::HasMouseClickListeners_Impl()
return m_pData->m_aUserInputInterception.hasMouseClickListeners();
}
+void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect )
+{
+ ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" );
+ SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame();
+ ENSURE_OR_THROW( pViewFrame, "a view shell without a view frame is pretty pathological" );
+
+ const bool bConnect = ( i_eConnect != E_DISCONNECT );
+
+ // disable window and dispatcher
+ pViewFrame->Enable( bConnect );
+ pViewFrame->GetDispatcher()->Lock( !bConnect );
+
+ if ( bConnect )
+ {
+ if ( i_eConnect == E_CONNECT )
+ {
+ if ( ( m_pData->m_pViewShell->GetObjectShell() != NULL )
+ && ( m_pData->m_pViewShell->GetObjectShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ )
+ {
+ SfxViewFrame* pViewFrm = m_pData->m_pViewShell->GetViewFrame();
+ if ( !pViewFrm->GetFrame().IsInPlace() )
+ {
+ // for outplace embedded objects, we want the layout manager to keep the content window
+ // size constant, if possible
+ try
+ {
+ uno::Reference< beans::XPropertySet > xFrameProps( m_pData->m_xFrame, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xLayouterProps(
+ xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ), uno::UNO_QUERY_THROW );
+ xLayouterProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreserveContentSize" ) ), uno::makeAny( sal_True ) );
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+
+ // upon DISCONNECT, we did *not* pop the shells from the stack (this is done elsewhere), so upon
+ // RECONNECT, we're not allowed to push them
+ if ( i_eConnect != E_RECONNECT )
+ {
+ pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell );
+ if ( m_pData->m_pViewShell->GetSubShell() )
+ pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell->GetSubShell() );
+ m_pData->m_pViewShell->PushSubShells_Impl();
+ pViewFrame->GetDispatcher()->Flush();
+ }
+
+ Window* pEditWin = m_pData->m_pViewShell->GetWindow();
+ if ( pEditWin && m_pData->m_pViewShell->IsShowView_Impl() )
+ pEditWin->Show();
+
+ if ( SfxViewFrame::Current() == pViewFrame )
+ pViewFrame->GetDispatcher()->Update_Impl( sal_True );
+
+ Window* pFrameWin = &pViewFrame->GetWindow();
+ if ( pFrameWin != &pViewFrame->GetFrame().GetWindow() )
+ pFrameWin->Show();
+
+ if ( i_eConnect == E_CONNECT )
+ {
+ ::comphelper::NamedValueCollection aDocumentArgs( getModel()->getArgs() );
+
+ const sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) );
+ const bool bHasPluginMode = ( nPluginMode != 0 );
+
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ SfxObjectShell& rDoc = *m_pData->m_pViewShell->GetObjectShell();
+ if ( !rFrame.IsMarkedHidden_Impl() )
+ {
+ if ( rDoc.IsHelpDocument() || ( nPluginMode == 2 ) )
+ pViewFrame->GetDispatcher()->HideUI( TRUE );
+ else
+ pViewFrame->GetDispatcher()->HideUI( FALSE );
+
+ if ( rFrame.IsInPlace() )
+ pViewFrame->LockAdjustPosSizePixel();
+
+ if ( nPluginMode == 3 )
+ rFrame.GetWorkWindow_Impl()->SetInternalDockingAllowed( FALSE );
+
+ if ( !rFrame.IsInPlace() )
+ pViewFrame->GetDispatcher()->Update_Impl();
+ pViewFrame->Show();
+ rFrame.GetWindow().Show();
+ if ( !rFrame.IsInPlace() || ( nPluginMode == 3 ) )
+ pViewFrame->MakeActive_Impl( rFrame.GetFrameInterface()->isActive() );
+
+ if ( rFrame.IsInPlace() )
+ {
+ pViewFrame->UnlockAdjustPosSizePixel();
+ // force resize for OLE server to fix layout problems of writer and math
+ // see i53651
+ if ( nPluginMode == 3 )
+ pViewFrame->Resize( TRUE );
+ }
+ }
+ else
+ {
+ DBG_ASSERT( !rFrame.IsInPlace() && !bHasPluginMode, "Special modes not compatible with hidden mode!" );
+ rFrame.GetWindow().Show();
+ }
+
+ // Jetzt UpdateTitle, hidden TopFrames haben sonst keinen Namen!
+ pViewFrame->UpdateTitle();
+
+ if ( !rFrame.IsInPlace() )
+ pViewFrame->Resize( TRUE );
+
+ // if there's a JumpMark given, then, well, jump to it
+ ::comphelper::NamedValueCollection aViewArgs( getCreationArguments() );
+ const ::rtl::OUString sJumpMark = aViewArgs.getOrDefault( "JumpMark", ::rtl::OUString() );
+ const bool bHasJumpMark = ( sJumpMark.getLength() > 0 );
+ OSL_ENSURE( ( !m_pData->m_pViewShell->GetObjectShell()->IsLoading() )
+ || ( !sJumpMark.getLength() ),
+ "SfxBaseController::ConnectSfxFrame_Impl: so this code wasn't dead?" );
+ // Before CWS autorecovery, there was code which postponed jumping to the Mark to a later time
+ // (SfxObjectShell::PositionView_Impl), but it seems this branch was never used, since this method
+ // here is never called before the load process finished. At least not with a non-empty jump mark
+ if ( sJumpMark.getLength() )
+ m_pData->m_pViewShell->JumpToMark( sJumpMark );
+
+ // if no plugin mode and no jump mark was supplied, check whether the document itself can provide view data, and
+ // if so, forward it to the view/shell.
+ if ( !bHasPluginMode && !bHasJumpMark )
+ {
+ try
+ {
+ Reference< XViewDataSupplier > xViewDataSupplier( getModel(), UNO_QUERY );
+ Reference< XIndexAccess > xViewData;
+ if ( xViewDataSupplier.is() )
+ xViewData = xViewDataSupplier->getViewData();
+ if ( xViewData.is() && xViewData->getCount() > 0 )
+ {
+ Sequence< PropertyValue > aViewData;
+ if ( ( xViewData->getByIndex( 0 ) >>= aViewData ) && ( aViewData.getLength() ) )
+ {
+ m_pData->m_pViewShell->ReadUserDataSequence( aViewData, TRUE );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+
+ // invalidate slot corresponding to the view shell
+ const sal_uInt16 nViewNo = m_pData->m_pViewShell->GetObjectShell()->GetFactory().GetViewNo_Impl( pViewFrame->GetCurViewId(), USHRT_MAX );
+ DBG_ASSERT( nViewNo != USHRT_MAX, "view shell id not found" );
+ if ( nViewNo != USHRT_MAX )
+ pViewFrame->GetBindings().Invalidate( nViewNo + SID_VIEWSHELL0 );
+}
+
//=============================================================================
css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper ()
{
diff --git a/sfx2/source/view/topfrm.cxx b/sfx2/source/view/topfrm.cxx
deleted file mode 100644
index 5af48806153f..000000000000
--- a/sfx2/source/view/topfrm.cxx
+++ /dev/null
@@ -1,1643 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sfx2.hxx"
-#ifndef GCC
-#endif
-
-#include <sfx2/topfrm.hxx>
-#include <sfx2/signaturestate.hxx>
-#include <com/sun/star/frame/XModuleManager.hpp>
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/frame/XFrame.hpp>
-#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
-#include <comphelper/processfactory.hxx>
-#endif
-#include <com/sun/star/frame/XFramesSupplier.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/util/CloseVetoException.hpp>
-#ifndef _TOOLKIT_UNOHLP_HXX
-#include <toolkit/helper/vclunohelper.hxx>
-#endif
-#ifndef _UNO_COM_SUN_STAR_AWT_POSSIZE_HPP_
-#include <com/sun/star/awt/PosSize.hpp>
-#endif
-#include <com/sun/star/container/XIndexAccess.hpp>
-#ifndef _COM_SUN_STAR_CONTAINER_XPROPERTYSET_HPP_
-#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#include <com/sun/star/frame/XLayoutManager.hpp>
-#include <com/sun/star/beans/NamedValue.hpp>
-#include <com/sun/star/beans/XMaterialHolder.hpp>
-#include <com/sun/star/awt/XWindow2.hpp>
-#include <vcl/menu.hxx>
-#include <svl/rectitem.hxx>
-#include <svl/intitem.hxx>
-#include <svl/eitem.hxx>
-#include <svl/stritem.hxx>
-#include <svtools/asynclink.hxx>
-#include <svtools/sfxecode.hxx>
-#include <vcl/dialog.hxx>
-#include <svl/urihelper.hxx>
-#include <unotools/moduleoptions.hxx>
-#include <unotools/configmgr.hxx>
-#include <unotools/bootstrap.hxx>
-
-#include <sfxresid.hxx>
-
-// wg. pTopFrames
-#include "appdata.hxx"
-#include <sfx2/app.hxx>
-#include <sfx2/sfx.hrc>
-#include <sfx2/objsh.hxx>
-#include <sfx2/docfile.hxx>
-#include <sfx2/viewsh.hxx>
-#include <sfx2/bindings.hxx>
-#include <sfx2/dispatch.hxx>
-#include <sfx2/request.hxx>
-#include <sfx2/objitem.hxx>
-#include <sfx2/objface.hxx>
-#include <sfx2/msg.hxx>
-#include "objshimp.hxx"
-#include "workwin.hxx"
-#include "sfxtypes.hxx"
-#include "splitwin.hxx"
-#include "arrdecl.hxx"
-#include "sfxhelp.hxx"
-#include <sfx2/fcontnr.hxx>
-#include <sfx2/docfac.hxx>
-#include "statcach.hxx"
-#include <sfx2/event.hxx>
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::util;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::beans;
-
-//------------------------------------------------------------------------
-
-#define SfxTopViewFrame
-#include "sfxslots.hxx"
-
-DBG_NAME(SfxTopViewFrame)
-
-#include <comphelper/sequenceashashmap.hxx>
-static ::rtl::OUString GetModuleName_Impl( const ::rtl::OUString& sDocService )
-{
- uno::Reference< container::XNameAccess > xMM( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")), uno::UNO_QUERY );
- ::rtl::OUString sVar;
- if ( !xMM.is() )
- return sVar;
-
- try
- {
- ::comphelper::SequenceAsHashMap aAnalyzer( xMM->getByName(sDocService) );
- sVar = aAnalyzer.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("ooSetupFactoryUIName"), ::rtl::OUString() );
- }
- catch( uno::Exception& )
- {
- sVar = ::rtl::OUString();
- }
-
- return sVar;
-}
-
-class SfxTopFrame_Impl
-{
-public:
- Window* pWindow; // maybe external
- BOOL bHidden;
- BOOL bLockResize;
- BOOL bMenuBarOn;
-};
-
-class SfxTopWindow_Impl : public Window
-{
-public:
- SfxTopFrame* pFrame;
-
- SfxTopWindow_Impl( SfxTopFrame* pF );
-// : Window( pF->pImp->pWindow, WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK )
-// , pFrame( pF )
-// { SetBackground(); }
- ~SfxTopWindow_Impl( );
-
- virtual void DataChanged( const DataChangedEvent& rDCEvt );
- virtual void StateChanged( StateChangedType nStateChange );
- virtual long PreNotify( NotifyEvent& rNEvt );
- virtual long Notify( NotifyEvent& rEvt );
- virtual void Resize();
- virtual void GetFocus();
- void DoResize();
- DECL_LINK( CloserHdl, void* );
-};
-
-SfxTopWindow_Impl::SfxTopWindow_Impl( SfxTopFrame* pF )
- : Window( pF->pImp->pWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK )
- , pFrame( pF )
-{
-}
-
-SfxTopWindow_Impl::~SfxTopWindow_Impl( )
-{
-}
-
-void SfxTopWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
-{
- Window::DataChanged( rDCEvt );
- SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl();
- if ( pWorkWin )
- pWorkWin->DataChanged_Impl( rDCEvt );
-}
-
-long SfxTopWindow_Impl::Notify( NotifyEvent& rNEvt )
-{
- if ( pFrame->IsClosing_Impl() || !pFrame->GetFrameInterface().is() )
- return sal_False;
-
- SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
- if ( !pView || !pView->GetObjectShell() )
- return Window::Notify( rNEvt );
-
- if ( rNEvt.GetType() == EVENT_GETFOCUS )
- {
- if ( pView->GetViewShell() && !pView->GetViewShell()->GetUIActiveIPClient_Impl() && !pFrame->IsInPlace() )
- {
- DBG_TRACE("SfxTopFrame: GotFocus");
- pView->MakeActive_Impl( FALSE );
- }
-
- // TODO/LATER: do we still need this code?
- Window* pWindow = rNEvt.GetWindow();
- ULONG nHelpId = 0;
- while ( !nHelpId && pWindow )
- {
- nHelpId = pWindow->GetHelpId();
- pWindow = pWindow->GetParent();
- }
-
- if ( nHelpId )
- SfxHelp::OpenHelpAgent( pFrame, nHelpId );
-
- // if focus was on an external window, the clipboard content might have been changed
- pView->GetBindings().Invalidate( SID_PASTE );
- pView->GetBindings().Invalidate( SID_PASTE_SPECIAL );
- return sal_True;
- }
- else if( rNEvt.GetType() == EVENT_KEYINPUT )
- {
- if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) )
- return TRUE;
- }
- else if ( rNEvt.GetType() == EVENT_EXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTDISABLE*/ )
- {
- pView->SetModalMode( sal_True );
- return sal_True;
- }
- else if ( rNEvt.GetType() == EVENT_ENDEXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTENABLE*/ )
- {
- //EnableInput( sal_True, sal_True );
- pView->SetModalMode( sal_False );
- return sal_True;
- }
-
- return Window::Notify( rNEvt );
-}
-
-long SfxTopWindow_Impl::PreNotify( NotifyEvent& rNEvt )
-{
- USHORT nType = rNEvt.GetType();
- if ( nType == EVENT_KEYINPUT || nType == EVENT_KEYUP )
- {
- SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
- SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL;
- if ( pShell && pShell->HasKeyListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) )
- return sal_True;
- }
- else if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN )
- {
- Window* pWindow = rNEvt.GetWindow();
- SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
- SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL;
- if ( pShell )
- if ( pWindow == pShell->GetWindow() || pShell->GetWindow()->IsChild( pWindow ) )
- if ( pShell->HasMouseClickListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) )
- return sal_True;
- }
-
- if ( nType == EVENT_MOUSEBUTTONDOWN )
- {
- Window* pWindow = rNEvt.GetWindow();
- const MouseEvent* pMEvent = rNEvt.GetMouseEvent();
- Point aPos = pWindow->OutputToScreenPixel( pMEvent->GetPosPixel() );
- SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl();
- if ( pWorkWin )
- pWorkWin->EndAutoShow_Impl( aPos );
- }
-
- return Window::PreNotify( rNEvt );
-}
-
-void SfxTopWindow_Impl::GetFocus()
-{
- if ( pFrame && !pFrame->IsClosing_Impl() && pFrame->GetCurrentViewFrame() && pFrame->GetFrameInterface().is() )
- pFrame->GetCurrentViewFrame()->MakeActive_Impl( TRUE );
-}
-
-void SfxTopWindow_Impl::Resize()
-{
- if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() )
- DoResize();
-}
-
-void SfxTopWindow_Impl::StateChanged( StateChangedType nStateChange )
-{
- if ( nStateChange == STATE_CHANGE_INITSHOW )
- {
- pFrame->pImp->bHidden = FALSE;
- if ( pFrame->IsInPlace() )
- // TODO/MBA: workaround for bug in LayoutManager: the final resize does not get through because the
- // LayoutManager works asynchronously and between resize and time execution the DockingAcceptor was exchanged so that
- // the resize event never is sent to the component
- SetSizePixel( GetParent()->GetOutputSizePixel() );
-
- DoResize();
- SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
- if ( pView )
- pView->GetBindings().GetWorkWindow_Impl()->ShowChilds_Impl();
- }
-
- Window::StateChanged( nStateChange );
-}
-
-void SfxTopWindow_Impl::DoResize()
-{
- if ( !pFrame->pImp->bLockResize )
- pFrame->Resize();
-}
-
-class StopButtonTimer_Impl : public Timer
-{
- BOOL bState;
- SfxViewFrame* pFrame;
-protected:
- virtual void Timeout();
-public:
- StopButtonTimer_Impl( SfxViewFrame*);
- void SetButtonState( BOOL bStateP );
- BOOL GetButtonState() const { return bState; }
-};
-
-StopButtonTimer_Impl::StopButtonTimer_Impl( SfxViewFrame*p)
- : bState( FALSE )
- , pFrame( p )
-{
- SetTimeout( 200 );
-}
-
-void StopButtonTimer_Impl::SetButtonState( BOOL bStateP )
-{
- if( bStateP )
- {
- bState = TRUE;
- Stop();
- }
- else if( bState )
- Start();
-}
-
-void StopButtonTimer_Impl::Timeout()
-{
- bState = FALSE;
- pFrame->GetBindings().Invalidate( SID_BROWSE_STOP );
-}
-
-class SfxTopViewWin_Impl : public Window
-{
-friend class SfxInternalFrame;
-
- BOOL bActive;
- SfxTopViewFrame* pFrame;
-
-public:
- SfxTopViewWin_Impl( SfxTopViewFrame* p,
- Window *pParent, WinBits nBits=0 ) :
- Window( pParent, nBits | WB_BORDER | WB_CLIPCHILDREN ),
- bActive( FALSE ),
- pFrame( p )
- {
- p->GetFrame()->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER );
- }
-
- virtual void Resize();
- virtual void StateChanged( StateChangedType nStateChange );
-};
-
-//--------------------------------------------------------------------
-void SfxTopViewWin_Impl::StateChanged( StateChangedType nStateChange )
-{
- if ( nStateChange == STATE_CHANGE_INITSHOW )
- {
- SfxObjectShell* pDoc = pFrame->GetObjectShell();
- if ( pDoc && !pFrame->IsVisible() )
- pFrame->Show();
-
- pFrame->Resize();
- }
- else
- Window::StateChanged( nStateChange );
-}
-
-void SfxTopViewWin_Impl::Resize()
-{
- if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() )
- pFrame->Resize();
-}
-
-class SfxTopViewFrame_Impl
-{
-public:
- sal_Bool bActive;
- Window* pWindow;
- String aFactoryName;
- StopButtonTimer_Impl* pStopButtonTimer;
-
- SfxTopViewFrame_Impl()
- : bActive( sal_False )
- , pWindow( 0 )
- , pStopButtonTimer( 0 )
- {}
-};
-
-static svtools::AsynchronLink* pPendingCloser = 0;
-
-static String _getTabString()
-{
- String result;
-
- Reference < XMaterialHolder > xHolder(
- ::comphelper::getProcessServiceFactory()->createInstance(
- DEFINE_CONST_UNICODE("com.sun.star.tab.tabreg") ), UNO_QUERY );
- if (xHolder.is())
- {
- rtl::OUString aTabString;
- Sequence< NamedValue > sMaterial;
- if (xHolder->getMaterial() >>= sMaterial) {
- for (int i=0; i < sMaterial.getLength(); i++) {
- if ((sMaterial[i].Name.equalsAscii("title")) &&
- (sMaterial[i].Value >>= aTabString))
- {
- result += ' ';
- result += String(aTabString);
- }
- }
- }
- }
- return result;
-}
-
-SfxTopFrame* SfxTopFrame::Create( SfxObjectShell* pDoc, USHORT nViewId, BOOL bHidden, const SfxItemSet* pSet )
-{
- Reference < XFrame > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
- SfxTopFrame *pFrame = NULL;
- BOOL bNewView = FALSE;
- if ( pSet )
- {
- SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_OPEN_NEW_VIEW, sal_False );
- bNewView = pItem && pItem->GetValue();
- }
-
- if ( pDoc && !bHidden && !bNewView )
- {
- URL aTargetURL;
- aTargetURL.Complete = pDoc->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
-
- BOOL bIsBasic = FALSE;
- if ( !aTargetURL.Complete.getLength() )
- {
- String sFactory = String::CreateFromAscii(pDoc->GetFactory().GetShortName());
- bIsBasic = (sFactory.CompareIgnoreCaseToAscii("sbasic")==COMPARE_EQUAL);
-
- if (!bIsBasic)
- {
- String aURL = String::CreateFromAscii("private:factory/");
- aURL += sFactory;
- aTargetURL.Complete = aURL;
- }
- }
-
- if (bIsBasic)
- {
- Reference < XFramesSupplier > xSupplier( xDesktop, UNO_QUERY );
- if (xSupplier.is())
- {
- Reference < XIndexAccess > xContainer(xSupplier->getFrames(), UNO_QUERY);
- if (xContainer.is())
- {
- Reference< ::com::sun::star::frame::XModuleManager > xCheck(::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager" )), UNO_QUERY);
- sal_Int32 nCount = xContainer->getCount();
- for (sal_Int32 i=0; i<nCount; ++i)
- {
- try
- {
- Reference < XFrame > xFrame;
- if (!(xContainer->getByIndex(i) >>= xFrame) || !xFrame.is())
- continue;
- ::rtl::OUString sModule = xCheck->identify(xFrame);
- if (sModule.equalsAscii("com.sun.star.frame.StartModule"))
- {
- pFrame = Create(xFrame);
- break;
- }
- }
- catch(const Exception&) {}
- }
- }
- }
- }
- else
- {
- Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY );
- xTrans->parseStrict( aTargetURL );
-
- Reference < ::com::sun::star::frame::XDispatchProvider > xProv( xDesktop, UNO_QUERY );
- Reference < ::com::sun::star::frame::XDispatch > xDisp;
- if ( xProv.is() )
- {
- Sequence < ::com::sun::star::beans::PropertyValue > aSeq(1);
- aSeq[0].Name = ::rtl::OUString::createFromAscii("Model");
- aSeq[0].Value <<= pDoc->GetModel();
- ::rtl::OUString aTargetFrame( ::rtl::OUString::createFromAscii("_default") );
- xDisp = xProv->queryDispatch( aTargetURL, aTargetFrame , 0 );
- if ( xDisp.is() )
- xDisp->dispatch( aTargetURL, aSeq );
- }
-
- SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
- for( USHORT nPos = rArr.Count(); nPos--; )
- {
- SfxTopFrame *pF = (SfxTopFrame*) rArr[ nPos ];
- if ( pF->GetCurrentDocument() == pDoc )
- {
- pFrame = pF;
- break;
- }
- }
- }
- }
-
- if ( !pFrame )
- {
- Reference < XFrame > xFrame = xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 );
- pFrame = Create( xFrame );
- }
-
- pFrame->pImp->bHidden = bHidden;
- Window* pWindow = pFrame->GetTopWindow_Impl();
- if ( pWindow && pDoc )
- {
- ::rtl::OUString aDocServiceName( pDoc->GetFactory().GetDocumentServiceName() );
- ::rtl::OUString aProductName;
- ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName;
- String aTitle = pDoc->GetTitle( SFX_TITLE_DETECT );
- aTitle += String::CreateFromAscii( " - " );
- aTitle += String(aProductName);
- aTitle += ' ';
- aTitle += String( GetModuleName_Impl( aDocServiceName ) );
-#ifdef DBG_UTIL
- ::rtl::OUString aDefault;
- aTitle += DEFINE_CONST_UNICODE(" [");
- String aVerId( utl::Bootstrap::getBuildIdData( aDefault ));
- aTitle += aVerId;
- aTitle += ']';
-#endif
-
- // append TAB string if available
- aTitle += _getTabString();
-
- /* AS_TITLE
- pWindow->SetText( aTitle );
- */
-
- /* AS_ICON
- if( pWindow->GetType() == WINDOW_WORKWINDOW )
- {
- SvtModuleOptions::EFactory eFactory;
- if( SvtModuleOptions::ClassifyFactoryByName( aDocServiceName, eFactory ) )
- {
- WorkWindow* pWorkWindow = (WorkWindow*)pWindow;
- pWorkWindow->SetIcon( (sal_uInt16) SvtModuleOptions().GetFactoryIcon( eFactory ) );
- }
- }
- */
- }
-
- pFrame->SetItemSet_Impl( pSet );
- if ( pDoc && pDoc != pFrame->GetCurrentDocument() )
- {
- if ( nViewId )
- pDoc->GetMedium()->GetItemSet()->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) );
- pFrame->InsertDocument( pDoc );
- if ( pWindow && !bHidden )
- pWindow->Show();
- }
-
- return pFrame;
-}
-
-SfxTopFrame* SfxTopFrame::Create( SfxObjectShell* pDoc, Window* pWindow, USHORT nViewId, BOOL bHidden, const SfxItemSet* pSet )
-{
- Reference < ::com::sun::star::lang::XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
- Reference < XFramesSupplier > xDesktop ( xFact->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
- Reference < XFrame > xFrame( xFact->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Frame") ), UNO_QUERY );
-
- xFrame->initialize( VCLUnoHelper::GetInterface ( pWindow ) );
- if ( xDesktop.is() )
- xDesktop->getFrames()->append( xFrame );
-
- uno::Reference< awt::XWindow2 > xWin( VCLUnoHelper::GetInterface ( pWindow ), uno::UNO_QUERY );
- if ( xWin.is() && xWin->isActive() )
- xFrame->activate();
-
- SfxTopFrame* pFrame = new SfxTopFrame( pWindow );
- pFrame->SetFrameInterface_Impl( xFrame );
- pFrame->pImp->bHidden = bHidden;
-
- pFrame->SetItemSet_Impl( pSet );
- if ( pDoc )
- {
- if ( nViewId )
- pDoc->GetMedium()->GetItemSet()->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) );
- pFrame->InsertDocument( pDoc );
- }
-
- return pFrame;
-}
-
-SfxTopFrame* SfxTopFrame::Create( Reference < XFrame > xFrame )
-{
- // create a new TopFrame to an external XFrame object ( wrap controller )
- DBG_ASSERT( xFrame.is(), "Wrong parameter!" );
-
- Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
- SfxTopFrame* pFrame = new SfxTopFrame( pWindow );
- pFrame->SetFrameInterface_Impl( xFrame );
- return pFrame;
-}
-
-SfxTopFrame::SfxTopFrame( Window* pExternal, sal_Bool bHidden )
- : SfxFrame( NULL )
- , pWindow( NULL )
-{
- pImp = new SfxTopFrame_Impl;
- pImp->bHidden = bHidden;
- pImp->bLockResize = FALSE;
- pImp->bMenuBarOn = TRUE;
- InsertTopFrame_Impl( this );
- if ( pExternal )
- {
- pImp->pWindow = pExternal;
- }
- else
- {
- DBG_ERROR( "TopFrame without window created!" );
-/*
- pImp->pWindow = new SfxTopFrameWindow_Impl( this );
- pImp->pWindow->SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
- pImp->pWindow->SetPosSizePixel( Point( 20,20 ), Size( 800,600 ) );
- if ( GetFrameInterface().is() )
- GetFrameInterface()->initialize( VCLUnoHelper::GetInterface( pImp->pWindow ) );
- pImp->pWindow->Show();
- */
- }
-
- pWindow = new SfxTopWindow_Impl( this );
-/** AS:
- Hide this window till the component was realy loaded. Otherwhise it overpaint e.g. the old component hardly
- and produce repaint errors.
- pWindow->Show();
- */
-}
-
-SfxTopFrame::~SfxTopFrame()
-{
- RemoveTopFrame_Impl( this );
- DELETEZ( pWindow );
- delete pImp;
-}
-
-void SfxTopFrame::SetPresentationMode( BOOL bSet )
-{
- if ( GetCurrentViewFrame() )
- GetCurrentViewFrame()->GetWindow().SetBorderStyle( bSet ? WINDOW_BORDER_NOBORDER : WINDOW_BORDER_NORMAL );
-
- Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
- Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
-
- if ( xPropSet.is() )
- {
- Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
- aValue >>= xLayoutManager;
- }
-
- if ( xLayoutManager.is() )
- xLayoutManager->setVisible( !bSet ); // we don't want to have ui in presentation mode
-
- SetMenuBarOn_Impl( !bSet );
- if ( GetWorkWindow_Impl() )
- GetWorkWindow_Impl()->SetDockingAllowed( !bSet );
- if ( GetCurrentViewFrame() )
- GetCurrentViewFrame()->GetDispatcher()->Update_Impl( TRUE );
-}
-
-SystemWindow*
-SfxTopFrame::GetSystemWindow() const
-{
- return GetTopWindow_Impl();
-}
-
-SystemWindow* SfxTopFrame::GetTopWindow_Impl() const
-{
- if ( pImp->pWindow->IsSystemWindow() )
- return (SystemWindow*) pImp->pWindow;
- else
- return NULL;
-}
-
-Window& SfxTopFrame::GetWindow() const
-{
- return *pWindow;
-}
-
-sal_Bool SfxTopFrame::Close()
-{
- delete this;
- return sal_True;
-}
-
-void SfxTopFrame::LockResize_Impl( BOOL bLock )
-{
- pImp->bLockResize = bLock;
-}
-
-IMPL_LINK( SfxTopWindow_Impl, CloserHdl, void*, EMPTYARG )
-{
- if ( pFrame && !pFrame->PrepareClose_Impl( TRUE ) )
- return 0L;
-
- if ( pFrame )
- pFrame->GetCurrentViewFrame()->GetBindings().Execute( SID_CLOSEWIN, 0, 0, SFX_CALLMODE_ASYNCHRON );
- return 0L;
-}
-
-void SfxTopFrame::SetMenuBarOn_Impl( BOOL bOn )
-{
- pImp->bMenuBarOn = bOn;
-
- Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
- Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
-
- if ( xPropSet.is() )
- {
- Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
- aValue >>= xLayoutManager;
- }
-
- if ( xLayoutManager.is() )
- {
- rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ));
-
- if ( bOn )
- xLayoutManager->showElement( aMenuBarURL );
- else
- xLayoutManager->hideElement( aMenuBarURL );
- }
-}
-
-BOOL SfxTopFrame::IsMenuBarOn_Impl() const
-{
- return pImp->bMenuBarOn;
-}
-
-String SfxTopFrame::GetWindowData()
-{
- String aActWinData;
- char cToken = ',';
-
- SfxViewFrame *pActFrame = SfxViewFrame::Current();
- SfxViewFrame *pFrame = GetCurrentViewFrame();
- const sal_Bool bActWin = ( pActFrame->GetTopViewFrame() == pFrame );
-
- // ::com::sun::star::sdbcx::User-Daten der ViewShell
- String aUserData;
- pFrame->GetViewShell()->WriteUserData(aUserData);
-
- // assemble ini-data
- String aWinData;
- aWinData += String::CreateFromInt32( pFrame->GetCurViewId() );
- aWinData += cToken;
-
- aWinData += '1'; // former attribute "isfloating"
- aWinData += cToken;
-
- // aktives kennzeichnen
- aWinData += cToken;
- aWinData += bActWin ? '1' : '0';
-
- aWinData += cToken;
- aWinData += aUserData;
-
- return aWinData;
-}
-
-sal_Bool SfxTopFrame::InsertDocument( SfxObjectShell* pDoc )
-/* [Beschreibung]
- */
-{
- // Spezielle Bedingungen testen: nicht im ModalMode!
- if ( !SfxFrame::InsertDocument( pDoc ) )
- return sal_False;
-
- SfxObjectShell *pOld = GetCurrentDocument();
-
- // Position und Groesse testen
- // Wenn diese schon gesetzt sind, soll offensichtlich nicht noch
- // LoadWindows_Impl aufgerufen werden ( z.B. weil dieses ein CreateFrame()
- // an einer Task aufgerufen hat! )
- const SfxItemSet* pSet = GetItemSet_Impl();
- if ( !pSet )
- pSet = pDoc->GetMedium()->GetItemSet();
- SetItemSet_Impl(0);
-
- // Position und Gr"o\se
- SFX_ITEMSET_ARG(
- pSet, pAreaItem, SfxRectangleItem, SID_VIEW_POS_SIZE, sal_False );
- // View-Id
- SFX_ITEMSET_ARG(
- pSet, pViewIdItem, SfxUInt16Item, SID_VIEW_ID, sal_False );
- // Zoom
- SFX_ITEMSET_ARG(
- pSet, pModeItem, SfxUInt16Item, SID_VIEW_ZOOM_MODE, sal_False );
- // Hidden
- SFX_ITEMSET_ARG(
- pSet, pHidItem, SfxBoolItem, SID_HIDDEN, sal_False);
- // ViewDaten
- SFX_ITEMSET_ARG(
- pSet, pViewDataItem, SfxStringItem, SID_USER_DATA, sal_False );
- // ViewOnly
- SFX_ITEMSET_ARG(
- pSet, pEditItem, SfxBoolItem, SID_VIEWONLY, sal_False);
- // InPlace (Hack)
- SFX_ITEMSET_ARG(
- pSet, pPluginItem, SfxUInt16Item, SID_PLUGIN_MODE, sal_False );
-
- // Plugin (external InPlace)
- SFX_ITEMSET_ARG(
- pSet, pPluginMode, SfxUInt16Item, SID_PLUGIN_MODE, sal_False);
- // Jump (GotoBookmark)
- SFX_ITEMSET_ARG(
- pSet, pJumpItem, SfxStringItem, SID_JUMPMARK, sal_False);
-
- if ( pEditItem && pEditItem->GetValue() )
- SetMenuBarOn_Impl( FALSE );
-
- if ( pHidItem )
- pImp->bHidden = pHidItem->GetValue();
-
- if( !pImp->bHidden )
- pDoc->OwnerLock( sal_True );
-
- // Wenn z.B. eine Fenstergr"o\se gesetzt wurde, soll keine Fensterinformation
- // aus den Dokument geladen werden, z.B. weil InsertDocument seinerseits
- // aus LoadWindows_Impl aufgerufen wurde!
- if ( !pJumpItem && !pPluginMode && pDoc && !pAreaItem && !pViewIdItem && !pModeItem &&
- pDoc->LoadWindows_Impl( this ) )
- {
- if ( GetCurrentDocument() != pDoc )
- // something went wrong during insertion
- return sal_False;
- pDoc->OwnerLock( sal_False );
- return sal_True;
- }
-
- if ( pDoc )
- {
- UpdateHistory( pDoc );
- UpdateDescriptor( pDoc );
- }
-
- SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET );
- sal_Bool bBrowsing = sal_True;
- SfxViewFrame *pFrame = GetCurrentViewFrame();
- if ( pFrame )
- {
- sal_Bool bChildActivated = sal_False;
- if ( pFrame->GetActiveChildFrame_Impl() && pFrame->GetActiveChildFrame_Impl() == SfxViewFrame::Current() )
- {
-// ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier > xFrames( GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY );
-// if ( xFrames.is() )
-// xFrames->setActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () );
- pFrame->SetActiveChildFrame_Impl(0);
- SfxViewFrame::SetViewFrame( pFrame );
- bChildActivated = sal_True;
- }
-
- if ( pFrame->GetObjectShell() )
- {
- pFrame->ReleaseObjectShell_Impl( sal_False );
- }
-
- if ( pViewIdItem )
- pFrame->SetViewData_Impl( pViewIdItem->GetValue(), String() );
- if ( pDoc )
- pFrame->SetObjectShell_Impl( *pDoc );
- }
- else
- {
- // 1: internal embedded object
- // 2: external embedded object
- // 3: OLE server
- if ( pPluginItem && pPluginItem->GetValue() != 2 )
- SetInPlace_Impl( TRUE );
-
- bBrowsing = sal_False;
- pFrame = new SfxTopViewFrame( this, pDoc, pViewIdItem ? pViewIdItem->GetValue() : 0 );
- if ( !pFrame->GetViewShell() )
- return sal_False;
-
- if ( pPluginItem && pPluginItem->GetValue() == 1 )
- {
- pFrame->ForceOuterResize_Impl( FALSE );
- pFrame->GetBindings().HidePopups(TRUE);
-
- // MBA: layoutmanager of inplace frame starts locked and invisible
- GetWorkWindow_Impl()->MakeVisible_Impl( FALSE );
- GetWorkWindow_Impl()->Lock_Impl( TRUE );
-
- GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER );
- if ( GetCurrentViewFrame() )
- GetCurrentViewFrame()->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER );
- }
- }
-
- String aMark;
- SFX_ITEMSET_ARG( pSet, pMarkItem, SfxStringItem, SID_JUMPMARK, FALSE );
- if ( pMarkItem )
- aMark = pMarkItem->GetValue();
-
- if ( pDoc->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT )
- {
- if ( pViewDataItem )
- pFrame->GetViewShell()->ReadUserData( pViewDataItem->GetValue(), sal_True );
- else if( aMark.Len() )
- GetCurrentViewFrame()->GetViewShell()->JumpToMark( aMark );
- }
- else
- {
- // Daten setzen, die in FinishedLoading ausgewertet werden
- MarkData_Impl*& rpMark = pDoc->Get_Impl()->pMarkData;
- if (!rpMark)
- rpMark = new MarkData_Impl;
- rpMark->pFrame = GetCurrentViewFrame();
- if ( pViewDataItem )
- rpMark->aUserData = pViewDataItem->GetValue();
- else
- rpMark->aMark = aMark;
- }
-
- // Position und Groesse setzen
- //sal_uInt16 nWinMode = pModeItem ? pModeItem->GetValue() : 1;
- if ( pAreaItem && !pOld )
- {
- Window *pWin = pImp->pWindow;
-
- // Groesse setzen
- const Rectangle aWinRect( pAreaItem->GetValue() );
- const Size aAppWindow( pImp->pWindow->GetDesktopRectPixel().GetSize() );
- Point aPos( aWinRect.TopLeft() );
- Size aSz(aWinRect.GetSize());
- if ( aSz.Width() && aSz.Height() )
- {
- aPos.X() = Min(aPos.X(),
- long(aAppWindow.Width() - aSz.Width() + aSz.Width() / 2) );
- aPos.Y() = Min(aPos.Y(),
- long( aAppWindow.Height() - aSz.Height() + aSz.Height() / 2) );
- if ( aPos.X() + aSz.Width() <
- aAppWindow.Width() + aSz.Width() / 2 &&
- aPos.Y() + aSz.Height() <
- aAppWindow.Height() + aSz.Height() / 2 )
- {
- pWin->SetPosPixel( aPos );
- pWin->SetOutputSizePixel( aSz );
- }
- }
- }
-
- if ( !pImp->bHidden )
- {
- if ( pDoc->IsHelpDocument() || (pPluginItem && pPluginItem->GetValue() == 2) )
- pFrame->GetDispatcher()->HideUI( TRUE );
- else
- pFrame->GetDispatcher()->HideUI( FALSE );
-
- if ( IsInPlace() )
- pFrame->LockAdjustPosSizePixel();
-
- if ( pPluginMode && pPluginMode->GetValue() == 3)
- GetWorkWindow_Impl()->SetInternalDockingAllowed(FALSE);
-
- if ( !IsInPlace() )
- pFrame->GetDispatcher()->Update_Impl();
- pFrame->Show();
- GetWindow().Show();
- if ( !IsInPlace() || (pPluginItem && pPluginItem->GetValue() == 3) )
- pFrame->MakeActive_Impl( GetFrameInterface()->isActive() );
- pDoc->OwnerLock( sal_False );
-
- // Dont show container window! Its done by framework or directly
- // by SfxTopFrame::Create() or SfxViewFrame::ExecView_Impl() ...
-
- if ( IsInPlace() )
- {
- pFrame->UnlockAdjustPosSizePixel();
- // force resize for OLE server to fix layout problems of writer and math
- // see i53651
- if ( pPluginItem && pPluginItem->GetValue() == 3 )
- pFrame->Resize(TRUE);
- }
- }
- else
- {
- DBG_ASSERT( !IsInPlace() && !pPluginMode && !pPluginItem, "Special modes not compatible with hidden mode!" );
- GetWindow().Show();
- }
-
- // Jetzt UpdateTitle, hidden TopFrames haben sonst keinen Namen!
- pFrame->UpdateTitle();
-
- if ( !IsInPlace() )
- {
- if ( pFrame->GetViewShell()->UseObjectSize() )
- {
- GetCurrentViewFrame()->UnlockAdjustPosSizePixel();
- GetCurrentViewFrame()->Resize(TRUE);
- GetCurrentViewFrame()->ForceInnerResize_Impl( FALSE );
- GetCurrentViewFrame()->Resize(TRUE);
- }
- else
- GetCurrentViewFrame()->Resize(TRUE);
- }
-
- SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), pDoc ) );
- return sal_True;
-}
-
-
-//========================================================================
-
-long SfxViewFrameClose_Impl( void* /*pObj*/, void* pArg )
-{
- ((SfxViewFrame*)pArg)->GetFrame()->DoClose();
- return 0;
-}
-
-TYPEINIT1(SfxTopFrame, SfxFrame);
-TYPEINIT1(SfxTopViewFrame, SfxViewFrame);
-
-//--------------------------------------------------------------------
-SFX_IMPL_INTERFACE(SfxTopViewFrame,SfxViewFrame,SfxResId(0))
-{
-}
-
-//--------------------------------------------------------------------
-String SfxTopViewFrame::UpdateTitle()
-
-/* [Beschreibung]
-
- Mit dieser Methode kann der SfxTopViewFrame gezwungen werden, sich sofort
- den neuen Titel vom der <SfxObjectShell> zu besorgen.
-
- [Anmerkung]
-
- Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener
- zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren
- m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxTopViewFrames)
- jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung
- nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden.
-
-
- [Beispiel]
-
- void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
- {
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
- {
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
- {
- case SFX_HINT_TITLECHANGED:
- for ( SfxTopViewFrame *pTop = (SfxTopViewFrame*)
- SfxViewFrame::GetFirst(this, TYPE(SfxTopViewFrame));
- pTop;
- pTop = (SfxTopViewFrame*)
- SfxViewFrame::GetNext(this, TYPE(SfxTopViewFrame));
- {
- pTop->UpdateTitle();
- ... pTop->GetName() ...
- }
- break;
- ...
- }
- }
- }
-*/
-
-{
- DBG_CHKTHIS(SfxTopViewFrame, 0);
-
- const SfxObjectFactory &rFact = GetObjectShell()->GetFactory();
- pImp->aFactoryName = String::CreateFromAscii( rFact.GetShortName() );
-
- String aTitle = SfxViewFrame::UpdateTitle();
-
- ::rtl::OUString aProductName;
- ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName;
-
- aTitle += String::CreateFromAscii( " - " );
- aTitle += String(aProductName);
- aTitle += ' ';
- ::rtl::OUString aDocServiceName( GetObjectShell()->GetFactory().GetDocumentServiceName() );
- aTitle += String( GetModuleName_Impl( aDocServiceName ) );
-#ifdef DBG_UTIL
- ::rtl::OUString aDefault;
- aTitle += DEFINE_CONST_UNICODE(" [");
- String aVerId( utl::Bootstrap::getBuildIdData( aDefault ));
- aTitle += aVerId;
- aTitle += ']';
-#endif
-
- // append TAB string if available
- aTitle += _getTabString();
-
- GetBindings().Invalidate( SID_NEWDOCDIRECT );
-
- /* AS_TITLE
- Window* pWindow = GetTopFrame_Impl()->GetTopWindow_Impl();
- if ( pWindow && pWindow->GetText() != aTitle )
- pWindow->SetText( aTitle );
- */
- return aTitle;
-}
-
-//--------------------------------------------------------------------
-void SfxTopViewFrame::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
-{
- {DBG_CHKTHIS(SfxTopViewFrame, 0);}
-
- if( IsDowning_Impl())
- return;
-
- // we know only SimpleHints
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
- {
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
- {
- case SFX_HINT_MODECHANGED:
- case SFX_HINT_TITLECHANGED:
- // when the document changes its title, change views too
- UpdateTitle();
- break;
-
- case SFX_HINT_DEINITIALIZING:
- // on all other changes force repaint
- GetFrame()->DoClose();
- return;
- }
- }
-
- SfxViewFrame::Notify( rBC, rHint );
-}
-
-//--------------------------------------------------------------------
-sal_Bool SfxTopViewFrame::Close()
-{
- {DBG_CHKTHIS(SfxTopViewFrame, 0);}
-
- // Modaler Dialog oben ??
-// if ( pImp->GetModalDialog() )
-// return sal_False;
-
- // eigentliches Schlie\sen
- if ( SfxViewFrame::Close() )
- {
- if (SfxViewFrame::Current() == this)
- SfxViewFrame::SetViewFrame(0);
-
- // Da der Dispatcher leer ger"aumt wird, kann man ihn auch nicht mehr
- // vern"unftig verwenden - also besser still legen
- GetDispatcher()->Lock(sal_True);
- delete this;
-
- return sal_True;
- }
-
- return sal_False;
-}
-
-SfxTopViewFrame::SfxTopViewFrame
-(
- SfxFrame* pFrame,
- SfxObjectShell* pObjShell,
- sal_uInt16 nViewId
-)
-
-/* [Beschreibung]
-
- Ctor des SfxTopViewFrame f"ur eine <SfxObjectShell> aus der Ressource.
- Die 'nViewId' der zu erzeugenden <SfxViewShell> kann angegeben werden
- (default ist die zuerst registrierte SfxViewShell-Subklasse).
-*/
-
- : SfxViewFrame( *(new SfxBindings), pFrame, pObjShell, SFXFRAME_HASTITLE )
-{
- DBG_CTOR(SfxTopViewFrame, 0);
-
- pCloser = 0;
- pImp = new SfxTopViewFrame_Impl;
- pImp->pStopButtonTimer = new StopButtonTimer_Impl(this);
-
-//(mba)/task if ( !pFrame->GetTask() )
- {
- pImp->pWindow = new SfxTopViewWin_Impl( this, &pFrame->GetWindow() );
- pImp->pWindow->SetSizePixel( pFrame->GetWindow().GetOutputSizePixel() );
- SetWindow_Impl( pImp->pWindow );
- pFrame->SetOwnsBindings_Impl( sal_True );
- pFrame->CreateWorkWindow_Impl();
- }
-
- sal_uInt32 nType = SFXFRAME_OWNSDOCUMENT | SFXFRAME_HASTITLE;
- if ( pObjShell && pObjShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
- nType |= SFXFRAME_EXTERNAL;
- GetFrame()->SetFrameType_Impl( GetFrame()->GetFrameType() | nType );
-
- if ( GetFrame()->IsInPlace() )
- {
- LockAdjustPosSizePixel();
- }
-
- try
- {
- if ( pObjShell )
- SwitchToViewShell_Impl( nViewId );
- }
- catch (com::sun::star::uno::Exception& )
- {
- // make sure that the ctor is left regularly
- ReleaseObjectShell_Impl();
- return;
- }
-
- if ( GetFrame()->IsInPlace() )
- {
- UnlockAdjustPosSizePixel();
- }
- else if ( GetViewShell() && GetViewShell()->UseObjectSize() )
- {
- // initiale Gr"o\se festlegen
- // Zuerst die logischen Koordinaten von IP-Objekt und EditWindow
- // ber"ucksichtigen
- LockAdjustPosSizePixel();
- ForceInnerResize_Impl( TRUE );
-
- Window *pWindow = GetViewShell()->GetWindow();
-
- // Da in den Applikationen bei der R"ucktransformation immer die
- // Eckpunkte tranformiert werden und nicht die Size (um die Ecken
- // alignen zu k"onnen), transformieren wir hier auch die Punkte, um
- // m"oglichst wenig Rundungsfehler zu erhalten.
-/*
- Rectangle aRect = pWindow->LogicToLogic( GetObjectShell()->GetVisArea(),
- GetObjectShell()->GetMapUnit(),
- pWindow->GetMapMode() );
-*/
- Rectangle aRect = pWindow->LogicToPixel( GetObjectShell()->GetVisArea() );
- Size aSize = aRect.GetSize();
- GetViewShell()->GetWindow()->SetSizePixel( aSize );
- DoAdjustPosSizePixel(GetViewShell(), Point(), aSize );
- }
-}
-
-//------------------------------------------------------------------------
-SfxTopViewFrame::~SfxTopViewFrame()
-{
- DBG_DTOR(SfxTopViewFrame, 0);
-
- SetDowning_Impl();
-
- if ( SfxViewFrame::Current() == this )
- SfxViewFrame::SetViewFrame(NULL);
-
- ReleaseObjectShell_Impl();
- if ( pPendingCloser == pCloser )
- pPendingCloser = 0;
- delete pCloser;
- if ( GetFrame()->OwnsBindings_Impl() )
- // Die Bindings l"oscht der Frame!
- KillDispatcher_Impl();
-
- delete pImp->pWindow;
- delete pImp->pStopButtonTimer;
- delete pImp;
-}
-
-//------------------------------------------------------------------------
-sal_Bool SfxTopViewFrame::SetBorderPixelImpl( const SfxViewShell *pVSh, const SvBorder &rBorder )
-{
- if( SfxViewFrame::SetBorderPixelImpl( GetViewShell(), rBorder ) )
- {
- if ( IsResizeInToOut_Impl() && !GetFrame()->IsInPlace() )
- {
- Size aSize = pVSh->GetWindow()->GetOutputSizePixel();
- if ( aSize.Width() && aSize.Height() )
- {
- aSize.Width() += rBorder.Left() + rBorder.Right();
- aSize.Height() += rBorder.Top() + rBorder.Bottom();
-
- Size aOldSize = GetWindow().GetOutputSizePixel();
- GetWindow().SetOutputSizePixel( aSize );
- Window* pParent = &GetWindow();
- while ( pParent->GetParent() )
- pParent = pParent->GetParent();
- Size aOuterSize = pParent->GetOutputSizePixel();
- aOuterSize.Width() += ( aSize.Width() - aOldSize.Width() );
- aOuterSize.Height() += ( aSize.Height() - aOldSize.Height() );
- pParent->SetOutputSizePixel( aOuterSize );
- }
- }
- else
- {
- Point aPoint;
- Rectangle aEditArea( aPoint, GetWindow().GetOutputSizePixel() );
- aEditArea.Left() += rBorder.Left();
- aEditArea.Right() -= rBorder.Right();
- aEditArea.Top() += rBorder.Top();
- aEditArea.Bottom() -= rBorder.Bottom();
- pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() );
- }
- return sal_True;
-
- }
- return sal_False;
-}
-
-void SfxTopViewFrame::Exec_Impl(SfxRequest &rReq )
-{
- // Wenn gerade die Shells ausgetauscht werden...
- if ( !GetObjectShell() || !GetViewShell() )
- return;
-
- switch ( rReq.GetSlot() )
- {
- case SID_SHOWPOPUPS :
- {
- SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, SID_SHOWPOPUPS, FALSE);
- BOOL bShow = pShowItem ? pShowItem->GetValue() : TRUE;
- SFX_REQUEST_ARG(rReq, pIdItem, SfxUInt16Item, SID_CONFIGITEMID, FALSE);
- USHORT nId = pIdItem ? pIdItem->GetValue() : 0;
-
- // ausfuehren
- SfxWorkWindow *pWorkWin = GetFrame()->GetWorkWindow_Impl();
- if ( bShow )
- {
- // Zuerst die Floats auch anzeigbar machen
- pWorkWin->MakeChildsVisible_Impl( bShow );
- GetDispatcher()->Update_Impl( TRUE );
-
- // Dann anzeigen
- GetBindings().HidePopups( !bShow );
- }
- else
- {
- // Alles hiden
- SfxBindings *pBind = &GetBindings();
- while ( pBind )
- {
- pBind->HidePopupCtrls_Impl( !bShow );
- pBind = pBind->GetSubBindings_Impl();
- }
-
- pWorkWin->HidePopups_Impl( !bShow, TRUE, nId );
- pWorkWin->MakeChildsVisible_Impl( bShow );
- }
-
- Invalidate( rReq.GetSlot() );
- rReq.Done();
- break;
- }
-
- case SID_ACTIVATE:
- {
- MakeActive_Impl( TRUE );
- rReq.SetReturnValue( SfxObjectItem( 0, this ) );
- break;
- }
-
- case SID_WIN_POSSIZE:
- break;
-
- case SID_NEWDOCDIRECT :
- {
- SFX_REQUEST_ARG( rReq, pFactoryItem, SfxStringItem, SID_NEWDOCDIRECT, FALSE);
- String aFactName;
- if ( pFactoryItem )
- aFactName = pFactoryItem->GetValue();
- else if ( pImp->aFactoryName.Len() )
- aFactName = pImp->aFactoryName;
- else
- {
- DBG_ERROR("Missing argument!");
- break;
- }
-
- SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, GetPool() );
- String aFact = String::CreateFromAscii("private:factory/");
- aFact += aFactName;
- aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) );
- aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, GetFrame() ) );
- aReq.AppendItem( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii( "_blank" ) ) );
- SFX_APP()->ExecuteSlot( aReq );
- const SfxViewFrameItem* pItem = PTR_CAST( SfxViewFrameItem, aReq.GetReturnValue() );
- if ( pItem )
- rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) );
- break;
- }
-
- case SID_CLOSEWIN:
- {
- // disable CloseWin, if frame is not a task
- Reference < XCloseable > xTask( GetFrame()->GetFrameInterface(), UNO_QUERY );
- if ( !xTask.is() )
- break;
-
- if ( GetViewShell()->PrepareClose() )
- {
- // weitere Views auf dasselbe Doc?
- SfxObjectShell *pDocSh = GetObjectShell();
- int bOther = sal_False;
- for ( const SfxTopViewFrame *pFrame =
- (SfxTopViewFrame *)SfxViewFrame::GetFirst( pDocSh, TYPE(SfxTopViewFrame) );
- !bOther && pFrame;
- pFrame = (SfxTopViewFrame *)SfxViewFrame::GetNext( *pFrame, pDocSh, TYPE(SfxTopViewFrame) ) )
- bOther = (pFrame != this);
-
- // Doc braucht nur gefragt zu werden, wenn keine weitere View
- sal_Bool bClosed = sal_False;
- sal_Bool bUI = TRUE;
- if ( ( bOther || pDocSh->PrepareClose( bUI ) ) )
- {
- if ( !bOther )
- pDocSh->SetModified( FALSE );
- rReq.Done(); // unbedingt vor Close() rufen!
- bClosed = sal_False;
- try
- {
- xTask->close(sal_True);
- bClosed = sal_True;
- }
- catch( CloseVetoException& )
- {
- bClosed = sal_False;
- }
- }
-
- rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bClosed ));
- }
- return;
- }
- }
-
- rReq.Done();
-}
-
-void SfxTopViewFrame::GetState_Impl( SfxItemSet &rSet )
-{
- SfxObjectShell *pDocSh = GetObjectShell();
-
- if ( !pDocSh )
- return;
-
- const sal_uInt16 *pRanges = rSet.GetRanges();
- DBG_ASSERT(pRanges, "Set ohne Bereich");
- while ( *pRanges )
- {
- for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich )
- {
- switch(nWhich)
- {
- case SID_NEWDOCDIRECT :
- {
- if ( pImp->aFactoryName.Len() )
- {
- String aFact = String::CreateFromAscii("private:factory/");
- aFact += pImp->aFactoryName;
- rSet.Put( SfxStringItem( nWhich, aFact ) );
- }
- break;
- }
-
- case SID_NEWWINDOW:
- rSet.DisableItem(nWhich);
- break;
-
- case SID_CLOSEWIN:
- {
- // disable CloseWin, if frame is not a task
- Reference < XCloseable > xTask( GetFrame()->GetFrameInterface(), UNO_QUERY );
- if ( !xTask.is() )
- rSet.DisableItem(nWhich);
- break;
- }
-
- case SID_SHOWPOPUPS :
- break;
-
- case SID_WIN_POSSIZE:
- {
- rSet.Put( SfxRectangleItem( nWhich, Rectangle(
- GetWindow().GetPosPixel(), GetWindow().GetSizePixel() ) ) );
- break;
- }
-
- default:
- DBG_ERROR( "invalid message-id" );
- }
- }
- ++pRanges;
- }
-}
-
-void SfxTopViewFrame::INetExecute_Impl( SfxRequest &rRequest )
-{
- sal_uInt16 nSlotId = rRequest.GetSlot();
- switch( nSlotId )
- {
- case SID_BROWSE_FORWARD:
- case SID_BROWSE_BACKWARD:
- {
- // Anzeige der n"achsten oder vorherigen Seite aus der History
- SFX_REQUEST_ARG( rRequest, pSteps, SfxUInt16Item, nSlotId, sal_False );
- GetFrame()->Browse( nSlotId == SID_BROWSE_FORWARD, pSteps ? pSteps->GetValue() : 1,
- (rRequest.GetModifier() & KEY_MOD1) != 0 );
- break;
- }
- case SID_CREATELINK:
- {
-/*! (pb) we need new implementation to create a link
-*/
- break;
- }
- case SID_BROWSE_STOP:
- {
- if ( GetCancelManager() )
- GetCancelManager()->Cancel( TRUE );
-
- // cancel jobs in hidden tasks
- SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames;
- for( USHORT nPos = rArr.Count(); nPos--; )
- {
- SfxFrame *pFrame = rArr[ nPos ];
- if ( !pFrame->GetCurrentViewFrame() )
- pFrame->GetCancelManager()->Cancel( TRUE );
- }
-
- break;
- }
- case SID_FOCUSURLBOX:
- {
- SfxStateCache *pCache = GetBindings().GetAnyStateCache_Impl( SID_OPENURL );
- if( pCache )
- {
- SfxControllerItem* pCtrl = pCache->GetItemLink();
- while( pCtrl )
- {
- pCtrl->StateChanged( SID_FOCUSURLBOX, SFX_ITEM_UNKNOWN, 0 );
- pCtrl = pCtrl->GetItemLink();
- }
- }
- }
- }
-
- // Recording
- rRequest.Done();
-}
-
-void SfxTopViewFrame::INetState_Impl( SfxItemSet &rItemSet )
-{
- if ( !GetFrame()->CanBrowseForward() )
- rItemSet.DisableItem( SID_BROWSE_FORWARD );
-
- if ( !GetFrame()->CanBrowseBackward() )
- rItemSet.DisableItem( SID_BROWSE_BACKWARD );
-
- // Add/SaveToBookmark bei BASIC-IDE, QUERY-EDITOR etc. disablen
- SfxObjectShell *pDocSh = GetObjectShell();
- sal_Bool bPseudo = pDocSh && !( pDocSh->GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC );
- sal_Bool bEmbedded = pDocSh && pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED;
- if ( !pDocSh || bPseudo || bEmbedded || !pDocSh->HasName() )
- rItemSet.DisableItem( SID_CREATELINK );
-
- pImp->pStopButtonTimer->SetButtonState( GetCancelManager()->CanCancel() );
- if ( !pImp->pStopButtonTimer->GetButtonState() )
- rItemSet.DisableItem( SID_BROWSE_STOP );
-}
-
-void SfxTopViewFrame::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY )
-{
- GetViewShell()->SetZoomFactor( rZoomX, rZoomY );
-}
-
-void SfxTopViewFrame::Activate( sal_Bool bMDI )
-{
- DBG_ASSERT(GetViewShell(), "Keine Shell");
- if ( bMDI )
- pImp->bActive = sal_True;
-//(mba): hier evtl. wie in Beanframe NotifyEvent ?!
-}
-
-void SfxTopViewFrame::Deactivate( sal_Bool bMDI )
-{
- DBG_ASSERT(GetViewShell(), "Keine Shell");
- if ( bMDI )
- pImp->bActive = sal_False;
-//(mba): hier evtl. wie in Beanframe NotifyEvent ?!
-}
-
-void SfxTopFrame::CheckMenuCloser_Impl( MenuBar* pMenuBar )
-{
- Reference < ::com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
-
- // checks if there is more than one "real" (not help) task window
- // in this case a close button is inserted into the menubar
-
- DBG_ASSERT( xFrame.is(), "Attention: this bug is very hard to reproduce. Please try to remember how you triggered it!");
- if ( !xFrame.is() || !xFrame->getController().is() )
- // dummy component
- return;
-
- Reference < ::com::sun::star::frame::XFramesSupplier > xDesktop( xFrame->getCreator(), UNO_QUERY );
- if ( !xDesktop.is() )
- // test only for task windows
- return;
-
- sal_Bool bLastTask = sal_False;
- Reference < ::com::sun::star::container::XIndexAccess >
- xList ( xDesktop->getFrames(), ::com::sun::star::uno::UNO_QUERY );
- sal_Int32 nCount = xList->getCount();
- if ( nCount<=1 )
- // only one task
- bLastTask = sal_True;
- else if ( nCount==2 )
- {
- // if we have to tasks, one can be the help task, that should be ignored
- for( sal_Int32 i=0; i<nCount; ++i )
- {
- Reference < ::com::sun::star::frame::XFrame > xTask;
- ::com::sun::star::uno::Any aVal = xList->getByIndex(i);
- if ( (aVal>>=xTask) && xTask.is() && xTask->getName().compareToAscii("OFFICE_HELP_TASK") == COMPARE_EQUAL )
- {
- // one of the two open tasks was the help task -> ignored
- bLastTask = sal_True;
- break;
- }
- }
- }
-
- pMenuBar->ShowCloser(bLastTask);
-}
diff --git a/sfx2/source/view/view.hxx b/sfx2/source/view/view.hxx
deleted file mode 100644
index 20e542d90bc7..000000000000
--- a/sfx2/source/view/view.hxx
+++ /dev/null
@@ -1,27 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
diff --git a/sfx2/source/view/viewfac.cxx b/sfx2/source/view/viewfac.cxx
index e8052594f8c8..b58bbc2840da 100644
--- a/sfx2/source/view/viewfac.cxx
+++ b/sfx2/source/view/viewfac.cxx
@@ -29,10 +29,8 @@
#include "precompiled_sfx2.hxx"
// INCLUDE ---------------------------------------------------------------
-#ifndef GCC
-#endif
-
#include <sfx2/app.hxx>
+#include <rtl/ustrbuf.hxx>
#include "viewfac.hxx"
// STATIC DATA -----------------------------------------------------------
@@ -51,6 +49,14 @@ void SfxViewFactory::InitFactory()
(*fnInit)();
}
+String SfxViewFactory::GetViewName() const
+{
+ ::rtl::OUStringBuffer aViewName;
+ aViewName.appendAscii( "view" );
+ aViewName.append( sal_Int32( GetOrdinal() ) );
+ return aViewName.makeStringAndClear();
+}
+
// CTOR / DTOR -----------------------------------------------------------
SfxViewFactory::SfxViewFactory( SfxViewCtor fnC, SfxViewInit fnI,
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 2291e8079b3a..66af0d7ac8ba 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/unohlp.hxx>
@@ -53,6 +54,7 @@
#endif
#include <svtools/sfxecode.hxx>
#include <svtools/ehdl.hxx>
+#include <tools/diagnose_ex.h>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
@@ -61,8 +63,9 @@
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/frame/XController.hpp>
-#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/document/UpdateDocMode.hpp>
@@ -76,6 +79,8 @@
#include <unotools/localfilehelper.hxx>
#include <unotools/ucbhelper.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/configurationhelper.hxx>
#include <com/sun/star/uno/Reference.h>
@@ -94,6 +99,8 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
+using ::com::sun::star::awt::XWindow;
+using ::com::sun::star::beans::PropertyValue;
namespace css = ::com::sun::star;
#ifndef GCC
@@ -123,7 +130,7 @@ namespace css = ::com::sun::star;
#include <sfx2/docfile.hxx>
#include <sfx2/module.hxx>
#include <sfx2/msgpool.hxx>
-#include <sfx2/topfrm.hxx>
+#include <sfx2/viewfrm.hxx>
#include "viewimp.hxx"
#include <sfx2/sfxbasecontroller.hxx>
#include <sfx2/sfx.hrc>
@@ -136,11 +143,14 @@ namespace css = ::com::sun::star;
#include "macro.hxx"
#include "minfitem.hxx"
#include "../appl/app.hrc"
+#include "impviewframe.hxx"
+
//-------------------------------------------------------------------------
DBG_NAME(SfxViewFrame)
#define SfxViewFrame
#include "sfxslots.hxx"
+#undef SfxViewFrame
//-------------------------------------------------------------------------
@@ -158,54 +168,6 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem);
//=========================================================================
-struct SfxViewFrame_Impl
-{
- SvBorder aBorder;
- Size aMargin;
- Size aSize;
- String aViewData;
- String aFrameTitle;
- TypeId aLastType;
- String aActualURL;
- String aActualPresentationURL;
- SfxFrame* pFrame;
- SfxCancelManager* pCancelMgr;
- svtools::AsynchronLink* pReloader;
- //SfxInPlaceFrame* pIPFrame;
- Window* pWindow;
- SfxViewFrame* pActiveChild;
- SfxViewFrame* pParentViewFrame;
- SfxObjectShell* pImportShell;
- Window* pFocusWin;
- SfxMacro* pMacro;
- sal_uInt16 nDocViewNo;
- sal_uInt16 nCurViewId;
- sal_Bool bResizeInToOut:1;
- sal_Bool bDontOverwriteResizeInToOut:1;
- sal_Bool bObjLocked:1;
- sal_Bool bRestoreView:1;
- sal_Bool bSetViewFrameLocked:1;
- sal_Bool bReloading:1;
- sal_Bool bIsDowning:1;
- sal_Bool bInCtor:1;
- sal_Bool bModal:1;
- sal_Bool bEnabled:1;
- sal_Bool bEventFlag:1;
- sal_Bool bWindowWasEnabled:1;
-
- SfxViewFrame_Impl()
- : pReloader(0 )
- , pMacro( 0 )
- , bWindowWasEnabled(sal_True)
- {}
-
- ~SfxViewFrame_Impl()
- {
- delete pReloader;
- delete pCancelMgr;
- }
-};
-
//-------------------------------------------------------------------------
void SfxViewFrame::SetDowning_Impl()
{
@@ -219,31 +181,7 @@ sal_Bool SfxViewFrame::IsDowning_Impl() const
}
-//-------------------------------------------------------------------------
-void SfxViewFrame::SetSetViewFrameAllowed_Impl( sal_Bool bSet )
-{
- pImp->bSetViewFrameLocked = !bSet;
-};
-
-//-------------------------------------------------------------------------
-sal_Bool SfxViewFrame::IsSetViewFrameAllowed_Impl() const
-{
- return !pImp->bSetViewFrameLocked;
-}
-
-//-------------------------------------------------------------------------
-void SfxViewFrame::SetImportingObjectShell_Impl( SfxObjectShell* pSh )
-{
- pImp->pImportShell = pSh;
-}
-
//--------------------------------------------------------------------
-SfxObjectShell* SfxViewFrame::GetImportingObjectShell_Impl() const
-{
- return pImp->pImportShell;
-}
-
-
class SfxViewNotificatedFrameList_Impl :
public SfxListener, public SfxViewFrameArr_Impl
{
@@ -299,7 +237,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq, sal_Bool bAsync )
void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
{
- SfxFrame *pParent = GetFrame()->GetParentFrame();
+ SfxFrame *pParent = GetFrame().GetParentFrame();
if ( rReq.GetSlot() == SID_RELOAD )
{
// Bei CTRL-Reload den aktiven Frame reloaden
@@ -319,11 +257,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
// Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames
// gemacht werden soll
- SfxFrame *pFrame = GetFrame();
- if ( pParent == pFrame && pFrame->GetChildFrameCount() )
+ SfxFrame& rFrame = GetFrame();
+ if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
{
sal_Bool bReloadAvailable = sal_False;
- SfxFrameIterator aIter( *pFrame, sal_False );
+ SfxFrameIterator aIter( rFrame, sal_False );
SfxFrame *pChild = aIter.FirstFrame();
while ( pChild )
{
@@ -356,13 +294,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
}
SfxObjectShell* pSh = GetObjectShell();
- sal_Bool bWasReadonly = pSh->IsReadOnly();
-
switch ( rReq.GetSlot() )
{
case SID_EDITDOC:
{
- if ( GetFrame()->HasComponent() )
+ if ( GetFrame().HasComponent() )
break;
// Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
@@ -498,12 +434,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
// r/o-Doc kann nicht in Editmode geschaltet werden?
rReq.Done( sal_False );
- SFX_REQUEST_ARG( rReq, pFSetItem, SfxBoolItem, SID_EDIT_FRAMESET, sal_False);
if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
{
// dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen
QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
- if ( !pFSetItem && RET_YES == aBox.Execute() )
+ if ( RET_YES == aBox.Execute() )
{
SfxApplication* pApp = SFX_APP();
SfxAllItemSet aSet( pApp->GetPool() );
@@ -544,16 +479,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
rReq.Done( sal_True );
// if( nOpenMode == SFX_STREAM_READONLY )
// pMed->Close();
-
- // ReloadForEdit bei Framesets schaltet auch FramesetEditmode
- sal_Bool bIsReadonly = GetObjectShell()->IsReadOnly();
- if ( bIsReadonly != bWasReadonly && !GetFrame()->GetParentFrame() )
- {
- SfxBoolItem aItem( SID_EDIT_FRAMESET, !bIsReadonly );
- GetDispatcher()->Execute( SID_EDIT_FRAMESET,
- SFX_CALLMODE_RECORD, &aItem, 0L );
- pSh->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) );
- }
return;
}
}
@@ -596,7 +521,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
// AutoLoad ist ggf. verboten
SFX_REQUEST_ARG(rReq, pAutoLoadItem, SfxBoolItem, SID_AUTOLOAD, sal_False);
if ( pAutoLoadItem && pAutoLoadItem->GetValue() &&
- GetFrame()->IsAutoLoadLocked_Impl() )
+ GetFrame().IsAutoLoadLocked_Impl() )
return;
SfxObjectShellLock xOldObj( pSh );
@@ -611,7 +536,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
// ggf. beim User nachfragen
sal_Bool bDo = ( GetViewShell()->PrepareClose() != FALSE );
SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
- if ( bDo && GetFrame()->DocIsModified_Impl() &&
+ if ( bDo && GetFrame().DocIsModified_Impl() &&
!rReq.IsAPI() && ( !pSilentItem || !pSilentItem->GetValue() ) )
{
QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_LASTVERSION) );
@@ -631,25 +556,21 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
// bestehende SfxMDIFrames f"ur dieses Doc leeren
// eigenes Format oder R/O jetzt editierbar "offnen?
- SfxViewNotificatedFrameList_Impl aFrames;
SfxObjectShellLock xNewObj;
- sal_Bool bRestoreView = ( pURLItem == NULL );
- TypeId aOldType = xOldObj->Type();
- SfxViewFrame *pView = GetFirst(xOldObj);
- while(pView)
+ // collect the views of the document
+ // TODO: when UNO ViewFactories are available for SFX-based documents, the below code should
+ // be UNOized, too
+ typedef ::std::pair< Reference< XFrame >, USHORT > ViewDescriptor;
+ ::std::list< ViewDescriptor > aViewFrames;
+ SfxViewFrame *pView = GetFirst( xOldObj );
+ while ( pView )
{
- if( bHandsOff )
- pView->GetDispatcher()->LockUI_Impl(sal_True);
- aFrames.InsertViewFrame( pView );
- pView->GetBindings().ENTERREGISTRATIONS();
-
- // RestoreView nur wenn keine neue Datei geladen
- // (Client-Pull-Reloading)
- pView = /*bHandsOff ? (SfxTopViewFrame*) GetFirst(
- xOldObj, TYPE(SfxTopViewFrame) ) :*/
- (SfxTopViewFrame*)GetNext( *pView, xOldObj,
- TYPE( SfxTopViewFrame ) );
+ Reference< XFrame > xFrame( pView->GetFrame().GetFrameInterface() );
+ OSL_ENSURE( xFrame.is(), "SfxViewFrame::ExecReload_Impl: no XFrame?!" );
+ aViewFrames.push_back( ViewDescriptor( xFrame, pView->GetCurViewId() ) );
+
+ pView = GetNext( *pView, xOldObj );
}
DELETEZ( xOldObj->Get_Impl()->pReloadTimer );
@@ -672,7 +593,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
{
pNewSet = new SfxAllItemSet( *pMedium->GetItemSet() );
pNewSet->ClearItem( SID_VIEW_ID );
- pNewSet->ClearItem( SID_USER_DATA );
pNewSet->ClearItem( SID_STREAM );
pNewSet->ClearItem( SID_INPUTSTREAM );
pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pMedium->GetFilter()->GetName() ) );
@@ -741,9 +661,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
- if( !pURLItem || pURLItem->GetValue() == xOldObj->GetMedium()->GetName() )
- xOldObj->Get_Impl()->bForbidCaching = sal_True;
-
sal_Bool bHasStorage = pMedium->HasStorage_Impl();
if( bHandsOff )
{
@@ -758,12 +675,12 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
}
xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_STANDARD );
+ uno::Sequence < beans::PropertyValue > aLoadArgs;
+ TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs );
try
{
- uno::Sequence < beans::PropertyValue > aProps;
- TransformItems( SID_OPENDOC, *pNewSet, aProps );
uno::Reference < frame::XLoadable > xLoad( xNewObj->GetModel(), uno::UNO_QUERY );
- xLoad->load( aProps );
+ xLoad->load( aLoadArgs );
}
catch ( uno::Exception& )
{
@@ -815,54 +732,41 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
{
if ( xNewObj->IsDocShared() )
{
- // the file is shared but the closing can chang the sharing control file
+ // the file is shared but the closing can change the sharing control file
xOldObj->DoNotCleanShareControlFile();
}
+ // the Reload and Silent items were only temporary, remove them
xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_RELOAD );
xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_SILENT );
- UpdateDocument_Impl();
- }
+ TransformItems( SID_OPENDOC, *xNewObj->GetMedium()->GetItemSet(), aLoadArgs );
- SfxViewFrame* pThis = (SfxViewFrame*)this;
- sal_Bool bDeleted = aFrames.C40_GETPOS( SfxViewFrame, pThis ) == USHRT_MAX;
-
- if( !bDeleted )
- {
- GetBindings().Invalidate( SID_RELOAD );
- pImp->bReloading = sal_False;
+ UpdateDocument_Impl();
}
- // neues Doc in die bestehenden SfxMDIFrames einsetzen; wenn
- // das Reload geklappt hat, mu\s in diesem Frame kein Dokument
- // eingesetzt werden, weil das schon vom LoadEnvironment
- // gemacht wurde
- if ( xNewObj.Is() && xNewObj->Type() != aOldType )
- // RestoreView nur, wenn gleicher Dokumenttyp
- bRestoreView = sal_False;
-
- const sal_uInt16 nCount = aFrames.Count();
- for(sal_uInt16 i = 0; i < nCount; ++i)
+ if ( xNewObj.Is() )
{
- SfxViewFrame *pCurrView = aFrames.GetObject( i );
- if ( xNewObj.Is() )
+ try
{
- //if( /*!bHandsOff &&*/ this != pView )
- pCurrView->ReleaseObjectShell_Impl( bRestoreView );
- pCurrView->SetRestoreView_Impl( bRestoreView );
- //if( pView != this || !xNewObj.Is() )
+ while ( !aViewFrames.empty() )
{
- SfxFrame *pFrame = pCurrView->GetFrame();
- pFrame->InsertDocument(xNewObj.Is() ? xNewObj : xOldObj );
+ LoadViewIntoFrame_Impl( *xNewObj, aViewFrames.front().first, aLoadArgs, aViewFrames.front().second, false );
+ aViewFrames.pop_front();
+ }
+ }
+ catch( const Exception& )
+ {
+ // close the remaining frames
+ // Don't catch exceptions herein, if this fails, then we're left in an indetermined state, and
+ // crashing is better than trying to proceed
+ while ( !aViewFrames.empty() )
+ {
+ Reference< util::XCloseable > xClose( aViewFrames.front().first, UNO_QUERY_THROW );
+ xClose->close( sal_True );
+ aViewFrames.pop_front();
}
}
- pCurrView->GetBindings().LEAVEREGISTRATIONS();
- pCurrView->GetDispatcher()->LockUI_Impl( sal_False );
- }
-
- if ( xNewObj.Is() )
- {
// Propagate document closure.
SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
}
@@ -870,11 +774,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
// als erledigt recorden
rReq.Done( sal_True );
rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
- if( !bDeleted )
- {
- Notify( *GetObjectShell(), SfxSimpleHint(
- SFX_HINT_TITLECHANGED ));
- }
return;
}
else
@@ -897,11 +796,11 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
// Ich bin gerade am Reloaden und Yielde so vor mich hin ...
return;
- GetFrame()->GetParentFrame();
+ GetFrame().GetParentFrame();
SfxWhichIter aIter( rSet );
for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
{
- if ( GetFrame()->HasComponent() )
+ if ( GetFrame().HasComponent() )
{
// Wenn die Komponente es nicht selbst dispatched, dann
// macht es auch keinen Sinn!
@@ -929,16 +828,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
case SID_RELOAD:
{
- SfxFrame* pFrame = GetTopFrame();
- SfxViewFrame *pView = pFrame->GetCurrentViewFrame();
- if ( pView && pView->GetViewShell() &&
- pView->GetViewShell()->IsImplementedAsFrameset_Impl() &&
- pView->GetViewShell()->GetInterface()->GetSlot( nWhich ) )
- {
- // Hack f"ur Explorer: Reload wird an der ViewShell ausgef"uhrt
- pView->GetViewShell()->GetSlotState( nWhich, 0, &rSet );
- break;
- }
+ SfxFrame* pFrame = &GetTopFrame();
if ( !pSh || !pSh->CanReload_Impl() || pSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
rSet.DisableItem(nWhich);
@@ -1009,7 +899,7 @@ void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq )
}
else if ( GetViewShell() )
{
- // der SW hat eigenes Undo an der ::com::sun::star::sdbcx::View
+ // der SW hat eigenes Undo an der View
const SfxPoolItem *pRet = GetViewShell()->ExecuteSlot( rReq );
if ( pRet )
bOK = ((SfxBoolItem*)pRet)->GetValue();
@@ -1031,7 +921,7 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet )
SfxUndoManager *pShUndoMgr = pSh->GetUndoManager();
if ( !pShUndoMgr )
{
- // der SW hat eigenes Undo an der ::com::sun::star::sdbcx::View
+ // der SW hat eigenes Undo an der View
SfxWhichIter aIter( rSet );
SfxViewShell *pViewSh = GetViewShell();
if( !pViewSh ) return;
@@ -1075,86 +965,30 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet )
}
//--------------------------------------------------------------------
-void SfxViewFrame::SetObjectShell_Impl
-(
- SfxObjectShell& rObjSh, // eine initialisierte SfxObjectShell,
- FASTBOOL bDefaultView // sal_True: nicht restaurieren
-)
-
-/* [Beschreibung]
-
- Diese Methode setzt eine <SfxObjectShell> in den SfxViewFrame ein.
-
- Zuvor mu\s die vorherige SfxObjectShell, insofern schein eine gesetzt
- wurde, mit der Methode ReleaseObjectShell() entfernt worden sein. Somit
- kann durch Aufruf von ReleaseObjectShell() und SetObjectShell() die
- SfxObjectShell ausgetauscht werden.
-
-
- [Querverweise]
-
- <SfxViewFrame::ReleaseObjectShell()>
-*/
-
+void SfxViewFrame::PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell )
{
- DBG_CHKTHIS(SfxViewFrame, 0);
- DBG_ASSERT( !xObjSh.Is(), "old feature used: only one Object per View!" );
-
- GetFrame()->ReleasingComponent_Impl( sal_False );
-
- // Doc einsetzen
- xObjSh = &rObjSh;
- if ( xObjSh.Is() && xObjSh->IsPreview() )
- SetQuietMode_Impl( sal_True );
-
- GetFrame()->SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET );
-
- // Modulshell einf"ugen
- SfxModule* pModule = xObjSh->GetModule();
- if( pModule )
- pDispatcher->InsertShell_Impl( *pModule, 1 );
-
- pDispatcher->Push( rObjSh );
- pDispatcher->Flush();
- StartListening( rObjSh );
-
- rObjSh.ViewAssigned();
- pDispatcher->SetReadOnly_Impl( rObjSh.IsReadOnly() );
-
- const SfxMedium *pMedium = GetObjectShell()->GetMedium();
- SFX_ITEMSET_ARG(
- pMedium->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False );
- if ( !pHiddenItem || !pHiddenItem->GetValue() )
+ i_rViewShell.PopSubShells_Impl();
+ sal_uInt16 nLevel = pDispatcher->GetShellLevel( i_rViewShell );
+ if ( nLevel != USHRT_MAX )
{
- LockObjectShell_Impl(sal_True);
- GetDocNumber_Impl();
+ if ( nLevel )
+ {
+ // more sub shells on the stack, which were not affected by PopSubShells_Impl
+ SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 );
+ if ( pSubShell == i_rViewShell.GetSubShell() )
+ // "real" sub shells will be deleted elsewhere
+ pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL );
+ else
+ pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE );
+ }
+ pDispatcher->Pop( i_rViewShell );
+ pDispatcher->Flush();
}
- // ::com::sun::star::sdbcx::View erzeugen
- if ( bDefaultView )
- SetRestoreView_Impl( sal_False );
-
-// So darf man es nicht machen, da LaodWindows hierueber laeuft. Kann meiner Meinung nach
-// auch nur beim Reload mit Dokumenttypwechsel passieren.
-/* if ( xObjSh->Type() != pImp->aLastType )
- SetRestoreView_Impl( sal_False ); */
-
- SwitchToViewShell_Impl( !IsRestoreView_Impl() ? (sal_uInt16) 0 : GetCurViewId() );
- rObjSh.PostActivateEvent_Impl( this );
- if ( Current() == this )
- SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), &rObjSh ) );
-
- Notify( rObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) );
- Notify( rObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) );
-
- // Zur Sicherheit, aber eigentlich sollte jetzt nichts mehr passieren
- // ( kein erzwungenes Update )
- if ( SfxViewFrame::Current() == this )
- GetDispatcher()->Update_Impl();
}
//--------------------------------------------------------------------
-void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView )
+void SfxViewFrame::ReleaseObjectShell_Impl()
/* [Beschreibung]
@@ -1166,7 +1000,7 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView )
die SfxObjectShell ausgetauscht werden.
Zwischen RealeaseObjectShell() und SetObjectShell() darf die Kontrolle
- nicht an das ::com::sun::star::chaos::System abgegeben werden.
+ nicht an das System abgegeben werden.
[Querverweise]
@@ -1177,7 +1011,7 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView )
DBG_CHKTHIS(SfxViewFrame, 0);
DBG_ASSERT( xObjSh.Is(), "no SfxObjectShell to release!" );
- GetFrame()->ReleasingComponent_Impl( sal_True );
+ GetFrame().ReleasingComponent_Impl( sal_True );
if ( GetWindow().HasChildPathFocus( sal_True ) )
{
DBG_ASSERT( !GetActiveChildFrame_Impl(), "Wrong active child frame!" );
@@ -1187,25 +1021,7 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView )
SfxViewShell *pDyingViewSh = GetViewShell();
if ( pDyingViewSh )
{
- SetRestoreView_Impl( bStoreView );
- if ( bStoreView )
- pDyingViewSh->WriteUserData( GetViewData_Impl(), sal_True );
-
- // Jetzt alle SubShells wechhauen
- pDyingViewSh->PushSubShells_Impl( sal_False );
- sal_uInt16 nLevel = pDispatcher->GetShellLevel( *pDyingViewSh );
- if ( nLevel && nLevel != USHRT_MAX )
- {
- // Es gibt immer nocht SubShells
- SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 );
- if ( pSubShell == pDyingViewSh->GetSubShell() )
- //"Echte" Subshells nicht deleten
- pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL );
- else
- pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE );
- }
- pDispatcher->Pop( *pDyingViewSh );
- pDispatcher->Flush();
+ PopShellAndSubShells_Impl( *pDyingViewSh );
pDyingViewSh->DisconnectAllClients();
SetViewShell_Impl(0);
delete pDyingViewSh;
@@ -1244,116 +1060,26 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView )
GetDispatcher()->SetDisableFlags( 0 );
}
-//-------------------------------------------------------------------------
-
-String SfxViewFrame::UpdateTitle()
-
-/* [Beschreibung]
-
- Mit dieser Methode kann der SfxMDIFrame gezwungen werden, sich sofort
- den neuen Titel vom der <SfxObjectShell> zu besorgen.
-
- [Anmerkung]
-
- Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener
- zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren
- m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxMDIFrames)
- jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung
- nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden.
-
-
- [Beispiel]
-
- void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
- {
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
- {
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
- {
- case SFX_HINT_TITLECHANGED:
- for ( SfxMDIFrame *pMDI = (SfxMDIFrame*)
- SfxViewFrame::GetFirst(this, TYPE(SfxMDIFrame));
- pMDI;
- pMDI = (SfxMDIFrame*)
- SfxViewFrame::GetNext(this, TYPE(SfxMDIFrame));
- {
- pMDI->UpdateTitle();
- ... pMDI->GetName() ...
- }
- break;
- ...
- }
- }
- }
-*/
-
-{
- SfxObjectShell *pObjSh = GetObjectShell();
- if ( !pObjSh )
- return String();
-
-// if ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
-// // kein UpdateTitle mit Embedded-ObjectShell
-// return String();
-
- const SfxMedium *pMedium = pObjSh->GetMedium();
- String aURL;
- GetFrame(); // -Wall required??
- if ( pObjSh->HasName() )
- {
- INetURLObject aTmp( pMedium->GetName() );
- aURL = aTmp.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
- }
-
- if ( aURL != pImp->aActualURL )
- // URL hat sich ge"andert
- pImp->aActualURL = aURL;
-
- // gibt es noch eine weitere View?
- sal_uInt16 nViews=0;
- for ( SfxViewFrame *pView= GetFirst(pObjSh);
- pView && nViews<2;
- pView = GetNext(*pView,pObjSh) )
- if ( ( pView->GetFrameType() & SFXFRAME_HASTITLE ) &&
- !IsDowning_Impl())
- nViews++;
-
- // Titel des Fensters
- String aTitle;
- if ( nViews == 2 || pImp->nDocViewNo > 1 )
- // dann die Nummer dranh"angen
- aTitle = pObjSh->UpdateTitle( NULL, pImp->nDocViewNo );
- else
- aTitle = pObjSh->UpdateTitle();
-
- // Name des SbxObjects
- String aSbxName = pObjSh->SfxShell::GetName();
- if ( IsVisible() )
- {
- aSbxName += ':';
- aSbxName += String::CreateFromInt32(pImp->nDocViewNo);
- }
-
- SetName( aSbxName );
- pImp->aFrameTitle = aTitle;
- GetBindings().Invalidate( SID_FRAMETITLE );
- GetBindings().Invalidate( SID_CURRENT_URL );
- return aTitle;
-}
-
-
//--------------------------------------------------------------------
sal_Bool SfxViewFrame::Close()
{
DBG_CHKTHIS(SfxViewFrame, 0);
- DBG_ASSERT( GetFrame()->IsClosing_Impl() || !GetFrame()->GetFrameInterface().is(), "ViewFrame closed too early!" );
+ DBG_ASSERT( GetFrame().IsClosing_Impl() || !GetFrame().GetFrameInterface().is(), "ViewFrame closed too early!" );
// Wenn bis jetzt noch nicht gespeichert wurde, sollen eingebettete Objekte
// auch nicht mehr automatisch gespeichert werden!
if ( GetViewShell() )
GetViewShell()->DiscardClients_Impl();
- Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
+ Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
+
+ if (SfxViewFrame::Current() == this)
+ SfxViewFrame::SetViewFrame( NULL );
+
+ // Da der Dispatcher leer ger"aumt wird, kann man ihn auch nicht mehr
+ // vern"unftig verwenden - also besser still legen
+ GetDispatcher()->Lock(sal_True);
+ delete this;
return sal_True;
}
@@ -1394,7 +1120,7 @@ void SfxViewFrame::DoActivate( sal_Bool bUI, SfxViewFrame* pOldFrame )
SfxViewFrame *pFrame = GetParentViewFrame();
while ( pFrame )
{
- if ( !pOldFrame || !pOldFrame->GetFrame()->IsParent( pFrame->GetFrame() ) )
+ if ( !pOldFrame || !pOldFrame->GetFrame().IsParent( &pFrame->GetFrame() ) )
pFrame->pDispatcher->DoParentActivate_Impl();
pFrame = pFrame->GetParentViewFrame();
}
@@ -1412,8 +1138,8 @@ void SfxViewFrame::DoDeactivate(sal_Bool bUI, SfxViewFrame* pNewFrame )
// ViewFrames, erh"alt er ein ParentDeactivate
if ( bUI )
{
-// if ( GetFrame()->GetWorkWindow_Impl() )
-// GetFrame()->GetWorkWindow_Impl()->SaveStatus_Impl();
+// if ( GetFrame().GetWorkWindow_Impl() )
+// GetFrame().GetWorkWindow_Impl()->SaveStatus_Impl();
/*
SfxMedium* pMed = GetObjectShell() ? GetObjectShell()->GetMedium() : NULL;
if( pMed )
@@ -1428,7 +1154,7 @@ void SfxViewFrame::DoDeactivate(sal_Bool bUI, SfxViewFrame* pNewFrame )
SfxViewFrame *pFrame = GetParentViewFrame();
while ( pFrame )
{
- if ( !pNewFrame || !pNewFrame->GetFrame()->IsParent( pFrame->GetFrame() ) )
+ if ( !pNewFrame || !pNewFrame->GetFrame().IsParent( &pFrame->GetFrame() ) )
pFrame->pDispatcher->DoParentDeactivate_Impl();
pFrame = pFrame->GetParentViewFrame();
}
@@ -1445,7 +1171,7 @@ void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh )
{
if ( GetViewShell() && GetWindow().IsVisible() )
{
- if ( GetFrame()->IsInPlace() )
+ if ( GetFrame().IsInPlace() )
{
/*
Size aSize( GetViewShell()->GetWindow()->GetSizePixel() );
@@ -1457,24 +1183,8 @@ void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh )
return;
}
- if ( GetViewShell()->UseObjectSize() )
- {
- // Zun"achst die Gr"o\se des MDI-Fensters berechnen
-
- DoAdjustPosSizePixel( GetViewShell(), Point(),
- GetViewShell()->GetWindow()->GetSizePixel() );
-
- // Da nach einem InnerResize die Position des EditFensters und
- // damit auch der Tools nocht stimmt, mu\s nun noch einmal von
- // au\sen resized werden !
-
- ForceOuterResize_Impl(sal_True);
- }
-
DoAdjustPosSizePixel( (SfxViewShell *) GetViewShell(), Point(),
GetWindow().GetOutputSizePixel() );
- if ( GetViewShell()->UseObjectSize() )
- ForceOuterResize_Impl(sal_False);
}
}
}
@@ -1482,12 +1192,43 @@ void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh )
//------------------------------------------------------------------------
sal_Bool SfxViewFrame::SetBorderPixelImpl
(
- const SfxViewShell* /*pSh*/,
+ const SfxViewShell* pVSh,
const SvBorder& rBorder
)
{
pImp->aBorder = rBorder;
+
+ if ( IsResizeInToOut_Impl() && !GetFrame().IsInPlace() )
+ {
+ Size aSize = pVSh->GetWindow()->GetOutputSizePixel();
+ if ( aSize.Width() && aSize.Height() )
+ {
+ aSize.Width() += rBorder.Left() + rBorder.Right();
+ aSize.Height() += rBorder.Top() + rBorder.Bottom();
+
+ Size aOldSize = GetWindow().GetOutputSizePixel();
+ GetWindow().SetOutputSizePixel( aSize );
+ Window* pParent = &GetWindow();
+ while ( pParent->GetParent() )
+ pParent = pParent->GetParent();
+ Size aOuterSize = pParent->GetOutputSizePixel();
+ aOuterSize.Width() += ( aSize.Width() - aOldSize.Width() );
+ aOuterSize.Height() += ( aSize.Height() - aOldSize.Height() );
+ pParent->SetOutputSizePixel( aOuterSize );
+ }
+ }
+ else
+ {
+ Point aPoint;
+ Rectangle aEditArea( aPoint, GetWindow().GetOutputSizePixel() );
+ aEditArea.Left() += rBorder.Left();
+ aEditArea.Right() -= rBorder.Right();
+ aEditArea.Top() += rBorder.Top();
+ aEditArea.Bottom() -= rBorder.Bottom();
+ pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() );
+ }
+
return sal_True;
}
@@ -1505,15 +1246,22 @@ const SvBorder& SfxViewFrame::GetBorderPixelImpl
void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{
{DBG_CHKTHIS(SfxViewFrame, 0);}
- if ( !xObjSh.Is() )
+
+ if( IsDowning_Impl())
return;
+ // we know only SimpleHints
if ( rHint.IsA(TYPE(SfxSimpleHint)) )
{
switch( ( (SfxSimpleHint&) rHint ).GetId() )
{
case SFX_HINT_MODECHANGED:
{
+ UpdateTitle();
+
+ if ( !xObjSh.Is() )
+ break;
+
// r/o Umschaltung?
SfxBindings& rBind = GetBindings();
rBind.Invalidate( SID_RELOAD );
@@ -1555,13 +1303,15 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
break;
}
- case SFX_HINT_DYING:
case SFX_HINT_DEINITIALIZING:
+ GetFrame().DoClose();
+ break;
+ case SFX_HINT_DYING:
// when the Object is being deleted, destroy the view too
if ( xObjSh.Is() )
ReleaseObjectShell_Impl();
else
- GetFrame()->DoClose();
+ GetFrame().DoClose();
break;
}
@@ -1586,6 +1336,9 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
case SFX_EVENT_OPENDOC:
case SFX_EVENT_CREATEDOC:
{
+ if ( !xObjSh.Is() )
+ break;
+
SfxBindings& rBind = GetBindings();
rBind.Invalidate( SID_RELOAD );
rBind.Invalidate( SID_EDITDOC );
@@ -1609,7 +1362,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
case SFX_EVENT_TOGGLEFULLSCREENMODE:
{
- if ( GetFrame()->OwnsBindings_Impl() )
+ if ( GetFrame().OwnsBindings_Impl() )
GetBindings().GetDispatcher_Impl()->Update_Impl( sal_True );
break;
}
@@ -1620,26 +1373,18 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
//------------------------------------------------------------------------
void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
{
- pImp->pFrame->DocumentInserted( pObjSh );
- pImp->bInCtor = sal_True;
- pImp->pParentViewFrame = 0;
pImp->bResizeInToOut = sal_True;
pImp->bDontOverwriteResizeInToOut = sal_False;
- pImp->pImportShell = 0;
pImp->bObjLocked = sal_False;
- pImp->bEventFlag = sal_True;
pImp->pFocusWin = 0;
pImp->pActiveChild = NULL;
- pImp->bRestoreView = sal_False;
pImp->nCurViewId = 0;
- pImp->bSetViewFrameLocked = sal_False;
pImp->bReloading = sal_False;
pImp->bIsDowning = sal_False;
pImp->bModal = sal_False;
pImp->bEnabled = sal_True;
pImp->nDocViewNo = 0;
pImp->aMargin = Size( -1, -1 );
- pImp->pCancelMgr = 0;
pImp->pWindow = 0;
SetPool( &SFX_APP()->GetPool() );
@@ -1651,7 +1396,6 @@ void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
if ( xObjSh.Is() && xObjSh->IsPreview() )
SetQuietMode_Impl( sal_True );
- GetFrame()->SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET );
if ( pObjSh )
{
pDispatcher->Push( *SFX_APP() );
@@ -1677,56 +1421,36 @@ void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
SfxViewFrame *pThis = this; // wegen der kranken Array-Syntax
SfxViewFrameArr_Impl &rViewArr = SFX_APP()->GetViewFrames_Impl();
rViewArr.C40_INSERT(SfxViewFrame, pThis, rViewArr.Count() );
- pImp->bInCtor = sal_False;
}
-//------------------------------------------------------------------------
-SfxViewFrame::SfxViewFrame( SfxObjectShell &rObjShell, SfxBindings &rBindings,
- SfxFrame* pParent, sal_uInt32 nType )
-:
- pImp( new SfxViewFrame_Impl ),
- pDispatcher(0),
- pBindings(&rBindings),
- nAdjustPosPixelLock( 0 )
-{
- DBG_CTOR(SfxViewFrame, 0);
-
- SetFrame_Impl( pParent );
- pImp->pFrame->SetCurrentViewFrame_Impl( this );
- GetFrame()->SetFrameType_Impl( GetFrameType() | nType );
- Construct_Impl( &rObjShell );
-}
+SfxViewFrame::SfxViewFrame
+(
+ SfxFrame& rFrame,
+ SfxObjectShell* pObjShell
+)
-//------------------------------------------------------------------------
-SfxViewFrame::SfxViewFrame(const SfxViewFrame &rCopy, SfxBindings &rBindings,
- SfxFrame *pFrame )
-:
- pImp( new SfxViewFrame_Impl ),
- pDispatcher(0),
- pBindings(&rBindings),
- nAdjustPosPixelLock( 0 )
-{
- DBG_CTOR(SfxViewFrame, 0);
+/* [Beschreibung]
- SetFrame_Impl( pFrame );
- pImp->pFrame->SetCurrentViewFrame_Impl( this );
- GetFrame()->SetFrameType_Impl( rCopy.GetFrameType() );
- Construct_Impl( rCopy.GetObjectShell() );
-}
+ Ctor des SfxViewFrame f"ur eine <SfxObjectShell> aus der Ressource.
+ Die 'nViewId' der zu erzeugenden <SfxViewShell> kann angegeben werden
+ (default ist die zuerst registrierte SfxViewShell-Subklasse).
+*/
-SfxViewFrame::SfxViewFrame( SfxBindings& rBindings, SfxFrame *pFrame,
- SfxObjectShell *pDoc, sal_uInt32 nType )
- : pImp( new SfxViewFrame_Impl )
+ : pImp( new SfxViewFrame_Impl( rFrame ) )
, pDispatcher(0)
- , pBindings(&rBindings)
+ , pBindings( new SfxBindings )
, nAdjustPosPixelLock( 0 )
{
- DBG_CTOR(SfxViewFrame, 0);
+ DBG_CTOR( SfxViewFrame, NULL );
+
+ rFrame.SetCurrentViewFrame_Impl( this );
+ rFrame.SetFrameType_Impl( GetFrameType() | SFXFRAME_HASTITLE );
+ Construct_Impl( pObjShell );
- SetFrame_Impl( pFrame );
- pImp->pFrame->SetCurrentViewFrame_Impl( this );
- GetFrame()->SetFrameType_Impl( GetFrameType() | nType );
- Construct_Impl( pDoc);
+ pImp->pWindow = new SfxFrameViewWindow_Impl( this, rFrame.GetWindow() );
+ pImp->pWindow->SetSizePixel( rFrame.GetWindow().GetOutputSizePixel() );
+ rFrame.SetOwnsBindings_Impl( sal_True );
+ rFrame.CreateWorkWindow_Impl();
}
//------------------------------------------------------------------------
@@ -1734,12 +1458,21 @@ SfxViewFrame::~SfxViewFrame()
{
DBG_DTOR(SfxViewFrame, 0);
- if ( GetFrame() && GetFrame()->GetCurrentViewFrame() == this )
- GetFrame()->SetCurrentViewFrame_Impl( NULL );
+ SetDowning_Impl();
- SfxObjectShell* pSh = pImp->pImportShell;
- if( pSh )
- pSh->AbortImport();
+ if ( SfxViewFrame::Current() == this )
+ SfxViewFrame::SetViewFrame( NULL );
+
+ ReleaseObjectShell_Impl();
+
+ if ( GetFrame().OwnsBindings_Impl() )
+ // Die Bindings l"oscht der Frame!
+ KillDispatcher_Impl();
+
+ delete pImp->pWindow;
+
+ if ( GetFrame().GetCurrentViewFrame() == this )
+ GetFrame().SetCurrentViewFrame_Impl( NULL );
// von Frame-Liste abmelden
SfxApplication *pSfxApp = SFX_APP();
@@ -1781,12 +1514,11 @@ SfxViewFrame* SfxViewFrame::Current()
}
//--------------------------------------------------------------------
-sal_uInt16 SfxViewFrame::Count(TypeId aType)
+sal_uInt16 SfxViewFrame::Count()
/* [Beschreibung]
- Liefert die Anzahl der sichtbaren <SfxViewFrame>-Instanzen vom Typ
- 'aType' bzw. aller sichtbaren, falls 'aType==0' (default).
+ Liefert die Anzahl der sichtbaren <SfxViewFrame>-Instanzen.
*/
{
@@ -1797,8 +1529,7 @@ sal_uInt16 SfxViewFrame::Count(TypeId aType)
for ( sal_uInt16 i = 0; i < nCount; ++i )
{
SfxViewFrame *pFrame = rFrames[i];
- if ( ( !aType || pFrame->IsA(aType) ) &&
- pFrame->IsVisible() )
+ if ( pFrame->IsVisible() )
++nFound;
}
return nFound;
@@ -1809,7 +1540,6 @@ sal_uInt16 SfxViewFrame::Count(TypeId aType)
SfxViewFrame* SfxViewFrame::GetFirst
(
const SfxObjectShell* pDoc,
- TypeId aType,
sal_Bool bOnlyIfVisible
)
{
@@ -1820,9 +1550,9 @@ SfxViewFrame* SfxViewFrame::GetFirst
for ( sal_uInt16 nPos = 0; nPos < rFrames.Count(); ++nPos )
{
SfxViewFrame *pFrame = rFrames.GetObject(nPos);
- if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) &&
- ( !aType || pFrame->IsA(aType) ) &&
- ( !bOnlyIfVisible || pFrame->IsVisible()) )
+ if ( ( !pDoc || pDoc == pFrame->GetObjectShell() )
+ && ( !bOnlyIfVisible || pFrame->IsVisible() )
+ )
return pFrame;
}
@@ -1835,7 +1565,6 @@ SfxViewFrame* SfxViewFrame::GetNext
(
const SfxViewFrame& rPrev,
const SfxObjectShell* pDoc,
- TypeId aType,
sal_Bool bOnlyIfVisible
)
{
@@ -1852,9 +1581,9 @@ SfxViewFrame* SfxViewFrame::GetNext
for ( ++nPos; nPos < rFrames.Count(); ++nPos )
{
SfxViewFrame *pFrame = rFrames.GetObject(nPos);
- if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) &&
- ( !aType || pFrame->IsA(aType) ) &&
- ( !bOnlyIfVisible || pFrame->IsVisible()) )
+ if ( ( !pDoc || pDoc == pFrame->GetObjectShell() )
+ && ( !bOnlyIfVisible || pFrame->IsVisible() )
+ )
return pFrame;
}
return 0;
@@ -1887,7 +1616,7 @@ void SfxViewFrame::ShowStatusText( const String& /*rText*/)
/* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx &
framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be
extended to support a new interface to support ShowStatusText/HideStatusText
- SfxWorkWindow* pWorkWin = GetFrame()->GetWorkWindow_Impl();
+ SfxWorkWindow* pWorkWin = GetFrame().GetWorkWindow_Impl();
SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl();
if ( pMgr )
{
@@ -1903,7 +1632,7 @@ void SfxViewFrame::HideStatusText()
/* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx &
framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be
extended to support a new interface to support ShowStatusText/HideStatusText
- SfxWorkWindow* pWorkWin = GetFrame()->GetWorkWindow_Impl();
+ SfxWorkWindow* pWorkWin = GetFrame().GetWorkWindow_Impl();
SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl();
if ( pMgr )
pMgr->GetStatusBar()->ShowItems();
@@ -1978,7 +1707,7 @@ void SfxViewFrame::SetViewShell_Impl( SfxViewShell *pVSh )
SfxShell::SetViewShell_Impl( pVSh );
// Hack: InPlaceMode
- if ( pVSh && !pVSh->UseObjectSize() )
+ if ( pVSh )
pImp->bResizeInToOut = sal_False;
}
@@ -1988,21 +1717,10 @@ void SfxViewFrame::SetViewShell_Impl( SfxViewShell *pVSh )
Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace
*/
-void SfxViewFrame::SetParentViewFrame_Impl(SfxViewFrame *pFrame)
-{
- pImp->pParentViewFrame = pFrame;
-}
-
-//--------------------------------------------------------------------
-/*
- Beschreibung:
- Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace
-*/
-
//TODO/LATER: is it still necessary? is there a replacement for GetParentViewFrame_Impl?
SfxViewFrame* SfxViewFrame::GetParentViewFrame_Impl() const
{
- return pImp->pParentViewFrame;
+ return NULL;
}
//--------------------------------------------------------------------
@@ -2027,7 +1745,7 @@ void SfxViewFrame::DoAdjustPosSize( SfxViewShell *pSh,
const Point rPos, const Size &rSize )
{
DBG_CHKTHIS(SfxViewFrame, 0);
- if( pSh && !nAdjustPosPixelLock && pSh->UseObjectSize())
+ if( pSh && !nAdjustPosPixelLock )
{
Window *pWindow = pSh->GetWindow();
Point aPos = pWindow->LogicToPixel(rPos);
@@ -2060,7 +1778,7 @@ void SfxViewFrame::Enable( sal_Bool bEnable )
}
else
{
- Window *pWindow = &GetFrame()->GetTopFrame()->GetWindow();
+ Window *pWindow = &GetFrame().GetTopFrame().GetWindow();
if ( !bEnable )
pImp->bWindowWasEnabled = pWindow->IsInputEnabled();
if ( !bEnable || pImp->bWindowWasEnabled )
@@ -2110,7 +1828,7 @@ void SfxViewFrame::Show()
LockObjectShell_Impl( sal_True );
// Doc-Shell Titel-Nummer anpassen, get unique view-no
- if ( 0 == pImp->nDocViewNo && !(GetFrameType() & SFXFRAME_PLUGIN ) )
+ if ( 0 == pImp->nDocViewNo )
{
GetDocNumber_Impl();
UpdateTitle();
@@ -2121,12 +1839,12 @@ void SfxViewFrame::Show()
// Frame-Window anzeigen, aber nur wenn der ViewFrame kein eigenes Window
// hat oder wenn er keine Component enth"alt
- if ( &GetWindow() == &GetFrame()->GetWindow() || !GetFrame()->HasComponent() )
+ if ( &GetWindow() == &GetFrame().GetWindow() || !GetFrame().HasComponent() )
GetWindow().Show();
- GetFrame()->GetWindow().Show();
+ GetFrame().GetWindow().Show();
/* SfxViewFrame* pCurrent = SfxViewFrame::Current();
- if ( GetFrame()->GetFrameInterface()->isActive() &&
+ if ( GetFrame().GetFrameInterface()->isActive() &&
pCurrent != this &&
( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) &&
!GetActiveChildFrame_Impl() )
@@ -2141,8 +1859,6 @@ void SfxViewFrame::Show()
//--------------------------------------------------------------------
sal_Bool SfxViewFrame::IsVisible() const
{
- //Window *pWin = pImp->bInCtor ? 0 : &GetWindow();
- //return GetFrame()->HasComponent() || pImp->bObjLocked || ( pWin && pWin->IsVisible() );
return pImp->bObjLocked;
}
@@ -2167,7 +1883,7 @@ void SfxViewFrame::LockObjectShell_Impl( sal_Bool bLock )
//--------------------------------------------------------------------
void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus )
{
- if ( GetViewShell() && !GetFrame()->IsClosing_Impl() )
+ if ( GetViewShell() && !GetFrame().IsClosing_Impl() )
{
if ( IsVisible() )
{
@@ -2186,7 +1902,7 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus )
}
SfxViewFrame* pCurrent = SfxViewFrame::Current();
- css::uno::Reference< css::frame::XFrame > xFrame = GetFrame()->GetFrameInterface();
+ css::uno::Reference< css::frame::XFrame > xFrame = GetFrame().GetFrameInterface();
if ( !bPreview )
{
SetViewFrame( this );
@@ -2202,7 +1918,7 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus )
SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient();
if ( ( !pCli || !pCli->IsObjectUIActive() ) &&
( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) )
- GetFrame()->GrabFocusOnComponent_Impl();
+ GetFrame().GrabFocusOnComponent_Impl();
}
}
else
@@ -2216,89 +1932,6 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus )
}
}
-//--------------------------------------------------------------------
-
-SfxViewShell* SfxViewFrame::CreateView_Impl( sal_uInt16 nViewId )
-
-/* [Beschreibung]
-
- Erzeugt eine SfxViewShell f"ur diesen SfxViewFrame. Wird auch aus
- <SfxObjectShell::LoadWindows_Impl()>
- gerufen.
-*/
-
-{
- DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
-
- LockAdjustPosSizePixel();
-
- // passende ::com::sun::star::sdbcx::View-Factory suchen
- SfxObjectFactory &rDocFact = GetObjectShell()->GetFactory();
- sal_uInt16 nNewNo = nViewId ? USHRT_MAX : 0;
- for ( sal_uInt16 nNo = 0;
- nNo < rDocFact.GetViewFactoryCount();
- ++nNo )
- {
- sal_uInt16 nFoundId = rDocFact.GetViewFactory(nNo).GetOrdinal();
- if ( nNewNo == USHRT_MAX )
- {
- if ( nViewId == nFoundId )
- nNewNo = nNo;
- }
- }
-
- // per Factory erzeugen
- GetBindings().ENTERREGISTRATIONS();
- SfxViewFactory &rViewFactory = rDocFact.GetViewFactory( nNewNo );
- SfxViewShell *pViewShell = rViewFactory.CreateInstance(this, 0);
- SetViewShell_Impl(pViewShell);
- UnlockAdjustPosSizePixel();
-
- if ( GetWindow().IsReallyVisible() )
- DoAdjustPosSizePixel(pViewShell, Point(), GetWindow().GetOutputSizePixel());
-
- // erste jetzt anzeigen (ausser wenn MTs BASIC-IDE mal wieder keins hat)
- Window *pViewWin = pViewShell->GetWindow();
- if ( pViewWin && pViewShell->IsShowView_Impl() )
- pViewWin->Show();
-
- // Dispatcher
- GetDispatcher()->Push( *pViewShell );
- if ( pViewShell->GetSubShell() )
- GetDispatcher()->Push( *pViewShell->GetSubShell() );
- pViewShell->PushSubShells_Impl();
-
-#if defined SFX_HINT_VIEWCREATED
- GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_VIEWCREATED ) );
-#endif
-
- GetBindings().LEAVEREGISTRATIONS();
-
- DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" );
- return pViewShell;
-}
-
-//-------------------------------------------------------------------------
-SfxViewFrame* SfxViewFrame::SearchViewFrame( SfxViewFrame *pViewFrame,
- const String& rName )
-{
- if ( !pViewFrame )
- pViewFrame = SfxViewFrame::Current();
- if ( !pViewFrame )
- return NULL;
- SfxFrame *pFrame = pViewFrame->GetFrame()->SearchFrame( rName );
- if ( !pFrame )
- return NULL;
-
- // Der Frame ist selbst ein ViewFrame oder enth"alt einen
-/*
- pViewFrame = PTR_CAST( SfxViewFrame, pFrame );
- if ( !pViewFrame && pFrame->GetChildFrameCount() )
- pViewFrame = PTR_CAST( SfxViewFrame, pFrame->GetChildFrame(0) );
-*/
- return pFrame->GetCurrentViewFrame();
-}
-
//-------------------------------------------------------------------------
void SfxViewFrame::SetQuietMode_Impl( sal_Bool bOn )
@@ -2313,11 +1946,6 @@ SfxObjectShell* SfxViewFrame::GetObjectShell()
return xObjSh;
}
-void SfxViewFrame::SetMargin_Impl( const Size& rMargin )
-{
- pImp->aMargin = rMargin;
-}
-
const Size& SfxViewFrame::GetMargin_Impl() const
{
return pImp->aMargin;
@@ -2332,10 +1960,10 @@ void SfxViewFrame::SetActiveChildFrame_Impl( SfxViewFrame *pViewFrame )
pImp->pActiveChild = pViewFrame;
- Reference< XFramesSupplier > xFrame( GetFrame()->GetFrameInterface(), UNO_QUERY );
+ Reference< XFramesSupplier > xFrame( GetFrame().GetFrameInterface(), UNO_QUERY );
Reference< XFrame > xActive;
if ( pViewFrame )
- xActive = pViewFrame->GetFrame()->GetFrameInterface();
+ xActive = pViewFrame->GetFrame().GetFrameInterface();
if ( xFrame.is() ) // PB: #74432# xFrame cann be NULL
xFrame->setActiveFrame( xActive );
@@ -2364,20 +1992,181 @@ SfxViewFrame* SfxViewFrame::GetActiveChildFrame_Impl() const
}
//--------------------------------------------------------------------
+SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
+ const USHORT i_nViewId, const bool i_bHidden )
+{
+ Reference< XFrame > xFrame( i_rFrame );
+ bool bOwnFrame = false;
+ SfxViewShell* pSuccessView = NULL;
+ try
+ {
+ if ( !xFrame.is() )
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference < XFrame > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
+ xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW );
+ bOwnFrame = true;
+ }
+
+ pSuccessView = LoadViewIntoFrame_Impl(
+ i_rDoc,
+ xFrame,
+ Sequence< PropertyValue >(), // means "reuse existing model's args"
+ i_nViewId,
+ i_bHidden
+ );
+
+ if ( bOwnFrame && !i_bHidden )
+ {
+ // ensure the frame/window is visible
+ Reference< XWindow > xContainerWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
+ xContainerWindow->setVisible( sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( pSuccessView )
+ return pSuccessView->GetViewFrame();
+
+ if ( bOwnFrame )
+ {
+ try
+ {
+ xFrame->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return NULL;
+}
+
+//--------------------------------------------------------------------
+SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
+ const Sequence< PropertyValue >& i_rLoadArgs, const USHORT i_nViewId,
+ const bool i_bHidden )
+{
+ Reference< XModel > xDocument( i_rDoc.GetModel(), UNO_SET_THROW );
+
+ ::comphelper::NamedValueCollection aTransformLoadArgs( i_rLoadArgs.getLength() ? i_rLoadArgs : xDocument->getArgs() );
+ aTransformLoadArgs.put( "Model", xDocument );
+ if ( i_nViewId )
+ aTransformLoadArgs.put( "ViewId", sal_Int16( i_nViewId ) );
+ if ( i_bHidden )
+ aTransformLoadArgs.put( "Hidden", i_bHidden );
+ else
+ aTransformLoadArgs.remove( "Hidden" );
+
+ ::rtl::OUString sURL( xDocument->getURL() );
+ if ( !sURL.getLength() )
+ sURL = i_rDoc.GetFactory().GetFactoryURL();
+
+ Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW );
+ xLoader->loadComponentFromURL( sURL, ::rtl::OUString::createFromAscii( "_self" ), 0,
+ aTransformLoadArgs.getPropertyValues() );
+
+ SfxViewShell* pViewShell = SfxViewShell::Get( i_rFrame->getController() );
+ ENSURE_OR_THROW( pViewShell,
+ "SfxViewFrame::LoadViewIntoFrame_Impl: loading an SFX doc into a frame resulted in a non-SFX view - quite impossible" );
+ return pViewShell;
+}
+
+//--------------------------------------------------------------------
+
+SfxViewFrame* SfxViewFrame::LoadHiddenDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId )
+{
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, true );
+}
+
+//--------------------------------------------------------------------
+
+SfxViewFrame* SfxViewFrame::LoadDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId )
+{
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, false );
+}
+
+//--------------------------------------------------------------------
+
+SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rTargetFrame, const USHORT i_nViewId )
+{
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_rTargetFrame, i_nViewId, false );
+}
+
+//--------------------------------------------------------------------
+
+SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const USHORT i_nViewId )
+{
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem && i_pFrameItem->GetFrame() ? i_pFrameItem->GetFrame()->GetFrameInterface() : NULL, i_nViewId, false );
+}
+
+//--------------------------------------------------------------------
+SfxViewFrame* SfxViewFrame::DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const USHORT i_nViewId )
+{
+ SFX_REQUEST_ARG( i_rCreateDocRequest, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE );
+ SFX_REQUEST_ARG( i_rCreateDocRequest, pHiddenItem, SfxBoolItem, SID_HIDDEN, FALSE );
+
+ return LoadViewIntoFrame_Impl_NoThrow(
+ i_rDoc,
+ pFrameItem ? pFrameItem->GetFrame() : NULL,
+ i_nViewId,
+ pHiddenItem ? pHiddenItem->GetValue() : false
+ );
+}
+
+//--------------------------------------------------------------------
+
+SfxViewFrame* SfxViewFrame::Get( const Reference< XController>& i_rController, const SfxObjectShell* i_pDoc )
+{
+ if ( !i_rController.is() )
+ return NULL;
+
+ const SfxObjectShell* pDoc = i_pDoc;
+ if ( !pDoc )
+ {
+ Reference< XModel > xDocument( i_rController->getModel() );
+ for ( pDoc = SfxObjectShell::GetFirst( 0, false );
+ pDoc;
+ pDoc = SfxObjectShell::GetNext( *pDoc, 0, false )
+ )
+ {
+ if ( pDoc->GetModel() == xDocument )
+ break;
+ }
+ }
+
+ SfxViewFrame* pViewFrame = NULL;
+ for ( pViewFrame = SfxViewFrame::GetFirst( pDoc, FALSE );
+ pViewFrame;
+ pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDoc, FALSE )
+ )
+ {
+ if ( pViewFrame->GetViewShell()->GetController() == i_rController )
+ break;
+ }
+
+ return pViewFrame;
+}
+
+//--------------------------------------------------------------------
sal_Bool SfxViewFrame::SwitchToViewShell_Impl
(
- sal_uInt16 nViewId, /* > 0
- Registrierungs-Id der ::com::sun::star::sdbcx::View, auf die umge-
+ sal_uInt16 nViewIdOrNo, /* > 0
+ Registrierungs-Id der View, auf die umge-
schaltet werden soll, bzw. die erstmalig
erzeugt werden soll.
== 0
- Es soll die Default-::com::sun::star::sdbcx::View verwendet werden. */
+ Es soll die Default-View verwendet werden. */
sal_Bool bIsIndex /* sal_True
- 'nViewId' ist keine Registrations-Id sondern
- ein ::com::sun::star::sdbcx::Index in die f"ur die in diesem
+ 'nViewIdOrNo' ist keine Registrations-Id sondern
+ ein Index in die f"ur die in diesem
<SfxViewFrame> dargestellte <SfxObjectShell>.
*/
)
@@ -2403,174 +2192,64 @@ sal_Bool SfxViewFrame::SwitchToViewShell_Impl
*/
{
- try{
- DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
-
- SfxObjectFactory &rDocFact = GetObjectShell()->GetFactory();
-
- // find index of old and new ViewShell
- sal_uInt16 nOldNo = USHRT_MAX, nNewNo = USHRT_MAX;
- bIsIndex |= 0 == nViewId;
- for ( sal_uInt16 nNo = 0; nNo < rDocFact.GetViewFactoryCount(); ++nNo )
- {
- sal_uInt16 nFoundId = rDocFact.GetViewFactory(nNo).GetOrdinal();
- if ( nNewNo == USHRT_MAX )
- {
- if ( bIsIndex && nViewId == nNo )
- {
- nNewNo = nNo;
- nViewId = nFoundId; // for nViewId == 0
- }
- else if ( !bIsIndex && nViewId == nFoundId )
- nNewNo = nNo;
- }
- if ( pImp->nCurViewId == nFoundId )
- nOldNo = nNo;
- }
-
- if ( nNewNo == USHRT_MAX )
- {
- // unknown ID -> fall back to default
- sal_uInt16 nFoundId = rDocFact.GetViewFactory(0).GetOrdinal();
- nNewNo = 0;
- nViewId = nFoundId;
- if ( pImp->nCurViewId == nFoundId )
- nOldNo = 0;
- }
-
- SfxViewShell *pSh = GetViewShell();
-
- DBG_ASSERT( !pSh || nOldNo != USHRT_MAX, "old shell id not found" );
-
- // does a ViewShell exist already?
- SfxViewShell *pOldSh = pSh;
- if ( pOldSh )
+ try
{
- // ask wether it can be closed
- if ( !pOldSh->PrepareClose() )
- return sal_False;
+ ENSURE_OR_THROW( GetObjectShell() != NULL, "not possible without a document" );
- // remove SubShells from Dispatcher before switching to new ViewShell
- pOldSh->PushSubShells_Impl( sal_False );
- sal_uInt16 nLevel = pDispatcher->GetShellLevel( *pOldSh );
- if ( nLevel )
+ // if we already have a view shell, remove it
+ SfxViewShell* pOldSh = GetViewShell();
+ OSL_PRECOND( pOldSh, "SfxViewFrame::SwitchToViewShell_Impl: that's called *switch* (not for *initial-load*) for a reason" );
+ if ( pOldSh )
{
- SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 );
- if ( pSubShell == pOldSh->GetSubShell() )
- //"real" SubShells are not deleted
- pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL );
- else
- // SubShells only known to Dispatcher must be deleted
- pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE );
- }
-
- pDispatcher->Pop( *pOldSh );
- GetBindings().Invalidate( nOldNo + SID_VIEWSHELL0 );
- }
-
- // remember ViewID
- pImp->nCurViewId = nViewId;
- GetBindings().Invalidate( nNewNo + SID_VIEWSHELL0 );
-
- // create new ViewShell
- SfxViewFactory &rViewFactory = rDocFact.GetViewFactory( nNewNo );
- LockAdjustPosSizePixel();
-
- GetBindings().ENTERREGISTRATIONS();
- pSh = rViewFactory.CreateInstance(this, pOldSh);
-
- Window *pEditWin = pSh->GetWindow();
- DBG_ASSERT( !pEditWin || !pEditWin->IsReallyVisible(), "don`t show your ViewShell`s Window by yourself!" );
+ // ask wether it can be closed
+ if ( !pOldSh->PrepareClose( TRUE ) )
+ return sal_False;
- // by setting the ViewShell it is prevented that disposing the Controller will destroy this ViewFrame also
- GetDispatcher()->SetDisableFlags( 0 );
- SetViewShell_Impl(pSh);
-
- Reference < ::com::sun::star::awt::XWindow > xWindow(
- GetFrame()->GetWindow().GetComponentInterface(), UNO_QUERY );
- Reference < XFrame > xFrame( GetFrame()->GetFrameInterface() );
- if ( !pSh->GetController().is() )
- pSh->SetController( new SfxBaseController( pSh ) );
- Reference < XController > xController( pSh->GetController() );
- xFrame->setComponent( xWindow, xController );
-
- xController->attachFrame( xFrame );
- Reference < XModel > xModel( GetObjectShell()->GetModel() );
- if ( xModel.is() )
- {
- xController->attachModel( xModel );
- xModel->connectController( xController );
- xModel->setCurrentController( xController );
- }
-
- GetDispatcher()->Push( *pSh );
- if ( pSh->GetSubShell() )
- GetDispatcher()->Push( *pSh->GetSubShell() );
- pSh->PushSubShells_Impl();
- GetDispatcher()->Flush();
-
- if ( pImp->bRestoreView && pImp->aViewData.Len() )
- {
- // restore view data if required
- pSh->ReadUserData( pImp->aViewData, sal_True );
- pImp->bRestoreView = sal_False;
- }
+ // remove sub shells from Dispatcher before switching to new ViewShell
+ PopShellAndSubShells_Impl( *pOldSh );
+ }
- // create UI elements before size is set
- if ( SfxViewFrame::Current() == this )
- GetDispatcher()->Update_Impl( sal_True );
+ GetBindings().ENTERREGISTRATIONS();
+ LockAdjustPosSizePixel();
- // allow resize events to be processed
- UnlockAdjustPosSizePixel();
+ // ID of the new view
+ SfxObjectFactory& rDocFact = GetObjectShell()->GetFactory();
+ const USHORT nViewId = ( bIsIndex || !nViewIdOrNo ) ? rDocFact.GetViewFactory( nViewIdOrNo ).GetOrdinal() : nViewIdOrNo;
- Window* pFrameWin = &GetWindow();
- if ( pFrameWin != &GetFrame()->GetWindow() )
- pFrameWin->Show();
+ // create and load new ViewShell
+ SfxViewShell* pNewSh = LoadViewIntoFrame_Impl(
+ *GetObjectShell(),
+ GetFrame().GetFrameInterface(),
+ Sequence< PropertyValue >(), // means "reuse existing model's args"
+ nViewId,
+ false
+ );
- if ( GetWindow().IsReallyVisible() )
- DoAdjustPosSizePixel( pSh, Point(), GetWindow().GetOutputSizePixel() );
+ // allow resize events to be processed
+ UnlockAdjustPosSizePixel();
- if ( pEditWin && pSh->IsShowView_Impl() )
- pEditWin->Show();
+ if ( GetWindow().IsReallyVisible() )
+ DoAdjustPosSizePixel( pNewSh, Point(), GetWindow().GetOutputSizePixel() );
- GetBindings().LEAVEREGISTRATIONS();
- delete pOldSh;
+ GetBindings().LEAVEREGISTRATIONS();
+ delete pOldSh;
}
- catch ( com::sun::star::uno::Exception& )
+ catch ( const com::sun::star::uno::Exception& )
{
// the SfxCode is not able to cope with exceptions thrown while creating views
// the code will crash in the stack unwinding procedure, so we shouldn't let exceptions go through here
- DBG_ERROR("Exception in SwitchToViewShell_Impl - urgent issue. Please contact development!");
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
}
DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" );
return sal_True;
}
-//--------------------------------------------------------------------
-
-void SfxViewFrame::SetViewData_Impl( sal_uInt16 nViewId, const String &rViewData )
-{
- pImp->bRestoreView = sal_True;
- pImp->nCurViewId = nViewId;
- pImp->aViewData = rViewData;
-}
//-------------------------------------------------------------------------
-String& SfxViewFrame::GetViewData_Impl()
+void SfxViewFrame::SetCurViewId_Impl( const USHORT i_nID )
{
- return pImp->aViewData;
-}
-
-//-------------------------------------------------------------------------
-sal_Bool SfxViewFrame::IsRestoreView_Impl() const
-{
- return pImp->bRestoreView;
-}
-
-//-------------------------------------------------------------------------
-void SfxViewFrame::SetRestoreView_Impl( sal_Bool bOn )
-{
- pImp->bRestoreView = bOn;
+ pImp->nCurViewId = i_nID;
}
//-------------------------------------------------------------------------
@@ -2608,58 +2287,17 @@ void SfxViewFrame::ExecView_Impl
break;
}
- case SID_FILLFRAME:
- {
- // Bei Mail etc. k"onnen die Frames nicht angesprochen werden
- SfxFrame *pParent = GetFrame()->GetParentFrame();
- if ( pParent && pParent->GetCurrentViewFrame()->
- GetViewShell()->IsImplementedAsFrameset_Impl() )
- break;
-
- SfxViewFrame *pRet = NULL;
- SFX_REQUEST_ARG(
- rReq, pItem, SfxStringItem, SID_FILLFRAME, sal_False );
- if ( pItem )
- {
- String aName( pItem->GetValue() );
- sal_uInt16 nFrame = (sal_uInt16) aName.ToInt32();
- if ( nFrame == 0 )
- nFrame = USHRT_MAX;
-
- SfxFrameIterator aIter( *GetFrame(), sal_False );
- SfxFrame *pFrame = aIter.FirstFrame();
- sal_uInt16 nActFrame = 1;
- while ( pFrame )
- {
- SfxViewFrame *pView = pFrame->GetCurrentViewFrame();
- if (
- nActFrame == nFrame ||
- (
- pView &&
- aName.CompareIgnoreCaseToAscii( pView->SfxShell::GetName() ) == COMPARE_EQUAL
- )
- )
- {
- pRet = pView;
- break;
- }
-
- pFrame = aIter.NextFrame( *pFrame );
- nActFrame++;
- }
- }
-
- rReq.SetReturnValue( SfxObjectItem( SID_DOCFRAME, pRet ) );
- break;
- }
-
case SID_VIEWSHELL:
{
const SfxPoolItem *pItem = 0;
- if ( rReq.GetArgs() &&
- SFX_ITEM_SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, sal_False, &pItem ) )
- rReq.SetReturnValue( SfxBoolItem(0, SwitchToViewShell_Impl(
- (sal_uInt16)((const SfxUInt16Item*) pItem)->GetValue()) ));
+ if ( rReq.GetArgs()
+ && SFX_ITEM_SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, sal_False, &pItem )
+ )
+ {
+ const sal_uInt16 nViewId = static_cast< const SfxUInt16Item* >( pItem )->GetValue();
+ BOOL bSuccess = SwitchToViewShell_Impl( nViewId );
+ rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
+ }
break;
}
@@ -2669,86 +2307,40 @@ void SfxViewFrame::ExecView_Impl
case SID_VIEWSHELL3:
case SID_VIEWSHELL4:
{
- rReq.SetReturnValue( SfxBoolItem(0,
- SwitchToViewShell_Impl( rReq.GetSlot() - SID_VIEWSHELL0, sal_True ) ) );
+ const sal_uInt16 nViewNo = rReq.GetSlot() - SID_VIEWSHELL0;
+ BOOL bSuccess = SwitchToViewShell_Impl( nViewNo, sal_True );
+ rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
break;
}
case SID_NEWWINDOW:
{
// Hack. demnaechst virtuelle Funktion
- if ( !GetViewShell()->NewWindowAllowed() && !GetObjectShell()->HasName() )
- return;
-
- // ViewData bei FrameSets rekursiv holen
- GetFrame()->GetViewData_Impl();
- SfxMedium *pMed = GetObjectShell()->GetMedium();
- String aUserData;
- GetViewShell()->WriteUserData( aUserData, sal_True );
if ( !GetViewShell()->NewWindowAllowed() )
{
- SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, sal_False );
- SfxFrame *pFrame = NULL;
- Reference < XFrame > xFrame;
- if ( pFrameItem )
- {
- pFrameItem->GetValue() >>= xFrame;
- pFrame = SfxTopFrame::Create( xFrame );
- }
- else
- pFrame = SfxTopFrame::Create();
-
- SfxAllItemSet aSet( SFX_APP()->GetPool() );
- SFX_REQUEST_ARG( rReq, pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False );
- if ( pHiddenItem )
- aSet.Put( *pHiddenItem );
-
- SFX_ITEMSET_ARG( pMed->GetItemSet(), pRefererItem, SfxStringItem, SID_REFERER, sal_False );
- SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private:user" ) );
- if ( !pRefererItem )
- pRefererItem = &aReferer;
-
- aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
- aSet.Put( SfxStringItem( SID_USER_DATA, aUserData ) );
- aSet.Put( SfxUInt16Item( SID_VIEW_ID, GetCurViewId() ) );
- aSet.Put( *pRefererItem );
- if( pMed->GetFilter() )
- aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName()) );
- aSet.Put( SfxFrameItem ( SID_DOCFRAME, pFrame ) );
- if ( xFrame.is() )
- GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, aSet );
- else
- GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
- }
- else
- {
- pMed->GetItemSet()->Put( SfxStringItem( SID_USER_DATA, aUserData ) );
-
- BOOL bHidden = FALSE;
- SFX_REQUEST_ARG( rReq, pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False );
- if ( pHiddenItem )
- bHidden = pHiddenItem->GetValue();
- SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, sal_False );
- if ( pFrameItem )
- {
- Reference < XFrame > xFrame;
- pFrameItem->GetValue() >>= xFrame;
- SfxFrame* pFrame = SfxTopFrame::Create( xFrame );
- pMed->GetItemSet()->ClearItem( SID_HIDDEN );
- pFrame->InsertDocument( GetObjectShell() );
- if ( !bHidden )
- xFrame->getContainerWindow()->setVisible( sal_True );
- }
- else
- {
- SfxAllItemSet aSet( GetPool() );
- aSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, TRUE ) );
- SfxFrame* pFrame = SfxTopFrame::Create( GetObjectShell(), GetCurViewId(), bHidden, &aSet );
- if ( bHidden )
- pFrame->GetCurrentViewFrame()->LockObjectShell_Impl( TRUE );
- }
+ OSL_ENSURE( false, "You should have disabled the 'Window/New Window' slot!" );
+ return;
}
+ // ViewData bei FrameSets rekursiv holen
+ GetFrame().GetViewData_Impl();
+ SfxMedium* pMed = GetObjectShell()->GetMedium();
+
+ // do not open the new window hidden
+ pMed->GetItemSet()->ClearItem( SID_HIDDEN );
+
+ // the view ID (optional arg. TODO: this is currently not supported in the slot definition ...)
+ SFX_REQUEST_ARG( rReq, pViewIdItem, SfxUInt16Item, SID_VIEW_ID, sal_False );
+ const USHORT nViewId = pViewIdItem ? pViewIdItem->GetValue() : GetCurViewId();
+
+ Reference < XFrame > xFrame;
+ // the frame (optional arg. TODO: this is currently not supported in the slot definition ...)
+ SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
+ if ( pFrameItem )
+ xFrame = pFrameItem->GetFrame();
+
+ LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId, false );
+
rReq.Done();
break;
}
@@ -2912,13 +2504,10 @@ void SfxViewFrame::StateView_Impl
case SID_NEWWINDOW:
{
- if ( !GetViewShell()->NewWindowAllowed() /* && !pDocSh->HasName() */ )
- rSet.DisableItem( nWhich );
- else
- {
- if (impl_maxOpenDocCountReached())
- rSet.DisableItem( nWhich );
- }
+ if ( !GetViewShell()->NewWindowAllowed()
+ || impl_maxOpenDocCountReached()
+ )
+ rSet.DisableItem( nWhich );
break;
}
}
@@ -2927,22 +2516,9 @@ void SfxViewFrame::StateView_Impl
}
//-------------------------------------------------------------------------
-void SfxViewFrame::GetState_Impl( SfxItemSet &rSet )
-{
- if ( GetViewShell() && GetViewShell()->GetVerbs().getLength() && !GetObjectShell()->IsInPlaceActive() )
- {
- uno::Any aAny;
- aAny <<= GetViewShell()->GetVerbs();
- rSet.Put( SfxUnoAnyItem( USHORT( SID_OBJECT ), aAny ) );
- }
- else
- rSet.DisableItem( SID_OBJECT );
-}
-
-//-------------------------------------------------------------------------
void SfxViewFrame::ToTop()
{
- GetFrame()->Appear();
+ GetFrame().Appear();
}
//-------------------------------------------------------------------------
@@ -2952,66 +2528,41 @@ SfxViewFrame* SfxViewFrame::GetParentViewFrame() const
Der ParentViewFrame ist der ViewFrame des ParentFrames
*/
{
- SfxFrame *pFrame = GetFrame()->GetParentFrame();
+ SfxFrame *pFrame = GetFrame().GetParentFrame();
return pFrame ? pFrame->GetCurrentViewFrame() : NULL;
}
//-------------------------------------------------------------------------
-SfxFrame* SfxViewFrame::GetFrame() const
+SfxFrame& SfxViewFrame::GetFrame() const
/*
Beschreibung:
GetFrame liefert den Frame, in dem sich der ViewFrame befindet
*/
{
- return pImp->pFrame;
-}
-
-//-------------------------------------------------------------------------
-void SfxViewFrame::SetFrame_Impl( SfxFrame *pFrame )
-{
- pImp->pFrame = pFrame;
+ return pImp->rFrame;
}
//-------------------------------------------------------------------------
SfxViewFrame* SfxViewFrame::GetTopViewFrame() const
{
- return GetFrame()->GetTopFrame()->GetCurrentViewFrame();
-}
-
-//-------------------------------------------------------------------------
-
-SfxCancelManager *SfxViewFrame::GetCancelManager() const
-
-/* <H3>Description</H3>
-
- Returns a pointer to the <SfxCancelManager> of the top-view-frame of
- this view-frame.
-*/
-
-{
- return GetTopViewFrame()->GetFrame()->GetCancelManager();
-}
-
-void SfxViewFrame::SetWindow_Impl( Window *pWin )
-{
- pImp->pWindow = pWin;
+ return GetFrame().GetTopFrame().GetCurrentViewFrame();
}
Window& SfxViewFrame::GetWindow() const
{
- return pImp->pWindow ? *pImp->pWindow : GetFrame()->GetWindow();
+ return pImp->pWindow ? *pImp->pWindow : GetFrame().GetWindow();
}
sal_Bool SfxViewFrame::DoClose()
{
- return GetFrame()->DoClose();
+ return GetFrame().DoClose();
}
String SfxViewFrame::GetActualPresentationURL_Impl() const
{
if ( xObjSh.Is() )
return xObjSh->GetMedium()->GetName();
- return pImp->aActualPresentationURL;
+ return String();
}
void SfxViewFrame::SetModalMode( sal_Bool bModal )
@@ -3028,7 +2579,7 @@ void SfxViewFrame::SetModalMode( sal_Bool bModal )
BOOL SfxViewFrame::IsInModalMode() const
{
- return pImp->bModal || GetFrame()->GetWindow().IsInModalMode();
+ return pImp->bModal || GetFrame().GetWindow().IsInModalMode();
}
void SfxViewFrame::Resize( BOOL bForce )
@@ -3040,18 +2591,14 @@ void SfxViewFrame::Resize( BOOL bForce )
SfxViewShell *pShell = GetViewShell();
if ( pShell )
{
- if ( GetFrame()->IsInPlace() )
+ if ( GetFrame().IsInPlace() )
{
Point aPoint = GetWindow().GetPosPixel();
DoAdjustPosSizePixel( pShell, aPoint, aSize );
}
else
{
- if ( pShell->UseObjectSize() )
- ForceOuterResize_Impl(TRUE);
DoAdjustPosSizePixel( pShell, Point(), aSize );
- if ( pShell->UseObjectSize() )
- ForceOuterResize_Impl(FALSE);
}
}
}
@@ -3324,7 +2871,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
// try to find any active recorder on this frame
::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier");
com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
- GetFrame()->GetFrameInterface(),
+ GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(xFrame,com::sun::star::uno::UNO_QUERY);
@@ -3389,7 +2936,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
case SID_TOGGLESTATUSBAR:
{
com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
- GetFrame()->GetFrameInterface(),
+ GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
@@ -3436,14 +2983,14 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
case SID_WIN_FULLSCREEN:
{
SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), FALSE);
- SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, GetTopViewFrame() );
+ SfxViewFrame *pTop = GetTopViewFrame();
if ( pTop )
{
- WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetTopWindow_Impl();
+ WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl();
if ( pWork )
{
com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
- GetFrame()->GetFrameInterface(),
+ GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
Reference< ::com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
@@ -3478,7 +3025,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
}
pWork->ShowFullScreenMode( bNewFullScreenMode );
pWork->SetMenuBarMode( bNewFullScreenMode ? MENUBAR_MODE_HIDE : MENUBAR_MODE_NORMAL );
- GetFrame()->GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode );
+ GetFrame().GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode );
if ( !pItem )
rReq.AppendItem( SfxBoolItem( SID_WIN_FULLSCREEN, bNewFullScreenMode ) );
rReq.Done();
@@ -3532,7 +3079,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier");
com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
- GetFrame()->GetFrameInterface(),
+ GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
@@ -3555,7 +3102,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier");
com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
- GetFrame()->GetFrameInterface(),
+ GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
@@ -3569,7 +3116,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
{
com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
- GetFrame()->GetFrameInterface(),
+ GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
com::sun::star::uno::Any aProp = xSet->getPropertyValue(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )) );
@@ -3587,10 +3134,10 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
case SID_WIN_FULLSCREEN:
{
- SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, GetTopViewFrame() );
+ SfxViewFrame* pTop = GetTopViewFrame();
if ( pTop )
{
- WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetTopWindow_Impl();
+ WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl();
if ( pWork )
{
rSet.Put( SfxBoolItem( nWhich, pWork->IsFullScreenMode() ) );
@@ -3639,7 +3186,7 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
{
if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
return;
- Reference < XFrame > xFrame = GetFrame()->GetTopFrame()->GetFrameInterface();
+ Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface();
Reference < XFrame > xBeamer( xFrame->findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN ) );
BOOL bShow = FALSE;
BOOL bHasChild = xBeamer.is();
@@ -3740,7 +3287,7 @@ void SfxViewFrame::ChildWindowState( SfxItemSet& rState )
}
else if ( nSID == SID_BROWSER )
{
- Reference < XFrame > xFrame = GetFrame()->GetTopFrame()->GetFrameInterface()->
+ Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface()->
findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN );
if ( !xFrame.is() )
rState.DisableItem( nSID );
@@ -3758,7 +3305,7 @@ void SfxViewFrame::ChildWindowState( SfxItemSet& rState )
SfxWorkWindow* SfxViewFrame::GetWorkWindow_Impl( USHORT /*nId*/ )
{
SfxWorkWindow* pWork = 0;
- pWork = GetFrame()->GetWorkWindow_Impl();
+ pWork = GetFrame().GetWorkWindow_Impl();
return pWork;
}
@@ -3820,11 +3367,6 @@ SfxChildWindow* SfxViewFrame::GetChildWindow(USHORT nId)
return pWork ? pWork->GetChildWindow_Impl(nId) : NULL;
}
-SfxMacro* SfxViewFrame::GetRecordingMacro_Impl()
-{
- return pImp->pMacro;
-}
-
void SfxViewFrame::UpdateDocument_Impl()
{
SfxObjectShell* pDoc = GetObjectShell();
@@ -3835,29 +3377,6 @@ void SfxViewFrame::UpdateDocument_Impl()
pDoc->UpdateFromTemplate_Impl();
}
-BOOL SfxViewFrame::ClearEventFlag_Impl()
-{
- if ( pImp->bEventFlag )
- {
- pImp->bEventFlag = FALSE;
- return TRUE;
- }
- else
- return FALSE;
-}
-
-SfxViewFrame* SfxViewFrame::CreateViewFrame( SfxObjectShell& rDoc, sal_uInt16 nViewId, sal_Bool bHidden )
-{
- SfxItemSet *pSet = rDoc.GetMedium()->GetItemSet();
- if ( nViewId )
- pSet->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) );
- if ( bHidden )
- pSet->Put( SfxBoolItem( SID_HIDDEN, sal_True ) );
-
- SfxFrame *pFrame = SfxTopFrame::Create( &rDoc, 0, bHidden );
- return pFrame->GetCurrentViewFrame();
-}
-
void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
{
SFX_APP()->SetViewFrame_Impl( pFrame );
diff --git a/sfx2/source/view/viewfrm2.cxx b/sfx2/source/view/viewfrm2.cxx
new file mode 100644
index 000000000000..480b5307df2e
--- /dev/null
+++ b/sfx2/source/view/viewfrm2.cxx
@@ -0,0 +1,523 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sfx2.hxx"
+
+#include "impviewframe.hxx"
+#include "statcach.hxx"
+#include "viewfac.hxx"
+#include "workwin.hxx"
+
+#include "sfx2/app.hxx"
+#include "sfx2/bindings.hxx"
+#include "sfx2/ctrlitem.hxx"
+#include "sfx2/dispatch.hxx"
+#include "sfx2/docfac.hxx"
+#include "sfx2/docfile.hxx"
+#include "sfx2/objitem.hxx"
+#include "sfx2/objsh.hxx"
+#include "sfx2/request.hxx"
+#include "sfx2/viewfrm.hxx"
+#include "sfx2/viewsh.hxx"
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svtools/asynclink.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/rectitem.hxx>
+#include <svl/stritem.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <unotools/bootstrap.hxx>
+#include <unotools/configmgr.hxx>
+#include <vcl/window.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::lang::XComponent;
+
+//------------------------------------------------------------------------
+
+static ::rtl::OUString GetModuleName_Impl( const ::rtl::OUString& sDocService )
+{
+ uno::Reference< container::XNameAccess > xMM( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")), uno::UNO_QUERY );
+ ::rtl::OUString sVar;
+ if ( !xMM.is() )
+ return sVar;
+
+ try
+ {
+ ::comphelper::NamedValueCollection aAnalyzer( xMM->getByName( sDocService ) );
+ sVar = aAnalyzer.getOrDefault( "ooSetupFactoryUIName", ::rtl::OUString() );
+ }
+ catch( uno::Exception& )
+ {
+ sVar = ::rtl::OUString();
+ }
+
+ return sVar;
+}
+
+//--------------------------------------------------------------------
+void SfxFrameViewWindow_Impl::StateChanged( StateChangedType nStateChange )
+{
+ if ( nStateChange == STATE_CHANGE_INITSHOW )
+ {
+ SfxObjectShell* pDoc = pFrame->GetObjectShell();
+ if ( pDoc && !pFrame->IsVisible() )
+ pFrame->Show();
+
+ pFrame->Resize();
+ }
+ else
+ Window::StateChanged( nStateChange );
+}
+
+void SfxFrameViewWindow_Impl::Resize()
+{
+ if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() )
+ pFrame->Resize();
+}
+
+static String _getTabString()
+{
+ String result;
+
+ Reference < XMaterialHolder > xHolder(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ DEFINE_CONST_UNICODE("com.sun.star.tab.tabreg") ), UNO_QUERY );
+ if (xHolder.is())
+ {
+ rtl::OUString aTabString;
+ Sequence< NamedValue > sMaterial;
+ if (xHolder->getMaterial() >>= sMaterial) {
+ for (int i=0; i < sMaterial.getLength(); i++) {
+ if ((sMaterial[i].Name.equalsAscii("title")) &&
+ (sMaterial[i].Value >>= aTabString))
+ {
+ result += ' ';
+ result += String(aTabString);
+ }
+ }
+ }
+ }
+ return result;
+}
+
+//========================================================================
+
+//--------------------------------------------------------------------
+String SfxViewFrame::UpdateTitle()
+
+/* [Beschreibung]
+
+ Mit dieser Methode kann der SfxViewFrame gezwungen werden, sich sofort
+ den neuen Titel vom der <SfxObjectShell> zu besorgen.
+
+ [Anmerkung]
+
+ Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener
+ zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren
+ m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxTopViewFrames)
+ jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung
+ nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden.
+
+
+ [Beispiel]
+
+ void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+ {
+ if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ {
+ switch( ( (SfxSimpleHint&) rHint ).GetId() )
+ {
+ case SFX_HINT_TITLECHANGED:
+ for ( SfxViewFrame *pTop = SfxViewFrame::GetFirst( this );
+ pTop;
+ pTop = SfxViewFrame::GetNext( this );
+ {
+ pTop->UpdateTitle();
+ ... pTop->GetName() ...
+ }
+ break;
+ ...
+ }
+ }
+ }
+*/
+
+{
+ DBG_CHKTHIS(SfxViewFrame, 0);
+
+ const SfxObjectFactory &rFact = GetObjectShell()->GetFactory();
+ pImp->aFactoryName = String::CreateFromAscii( rFact.GetShortName() );
+
+ SfxObjectShell *pObjSh = GetObjectShell();
+ if ( !pObjSh )
+ return String();
+
+// if ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+// // kein UpdateTitle mit Embedded-ObjectShell
+// return String();
+
+ const SfxMedium *pMedium = pObjSh->GetMedium();
+ String aURL;
+ GetFrame(); // -Wall required??
+ if ( pObjSh->HasName() )
+ {
+ INetURLObject aTmp( pMedium->GetName() );
+ aURL = aTmp.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ }
+
+ if ( aURL != pImp->aActualURL )
+ // URL hat sich ge"andert
+ pImp->aActualURL = aURL;
+
+ // gibt es noch eine weitere View?
+ sal_uInt16 nViews=0;
+ for ( SfxViewFrame *pView= GetFirst(pObjSh);
+ pView && nViews<2;
+ pView = GetNext(*pView,pObjSh) )
+ if ( ( pView->GetFrameType() & SFXFRAME_HASTITLE ) &&
+ !IsDowning_Impl())
+ nViews++;
+
+ // Titel des Fensters
+ String aTitle;
+ if ( nViews == 2 || pImp->nDocViewNo > 1 )
+ // dann die Nummer dranh"angen
+ aTitle = pObjSh->UpdateTitle( NULL, pImp->nDocViewNo );
+ else
+ aTitle = pObjSh->UpdateTitle();
+
+ // Name des SbxObjects
+ String aSbxName = pObjSh->SfxShell::GetName();
+ if ( IsVisible() )
+ {
+ aSbxName += ':';
+ aSbxName += String::CreateFromInt32(pImp->nDocViewNo);
+ }
+
+ SetName( aSbxName );
+ pImp->aFrameTitle = aTitle;
+ GetBindings().Invalidate( SID_FRAMETITLE );
+ GetBindings().Invalidate( SID_CURRENT_URL );
+
+ ::rtl::OUString aProductName;
+ ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName;
+
+ aTitle += String::CreateFromAscii( " - " );
+ aTitle += String(aProductName);
+ aTitle += ' ';
+ ::rtl::OUString aDocServiceName( GetObjectShell()->GetFactory().GetDocumentServiceName() );
+ aTitle += String( GetModuleName_Impl( aDocServiceName ) );
+#ifdef DBG_UTIL
+ ::rtl::OUString aDefault;
+ aTitle += DEFINE_CONST_UNICODE(" [");
+ String aVerId( utl::Bootstrap::getBuildIdData( aDefault ));
+ aTitle += aVerId;
+ aTitle += ']';
+#endif
+
+ // append TAB string if available
+ aTitle += _getTabString();
+
+ GetBindings().Invalidate( SID_NEWDOCDIRECT );
+
+ /* AS_TITLE
+ Window* pWindow = GetFrame()->GetTopWindow_Impl();
+ if ( pWindow && pWindow->GetText() != aTitle )
+ pWindow->SetText( aTitle );
+ */
+ return aTitle;
+}
+
+void SfxViewFrame::Exec_Impl(SfxRequest &rReq )
+{
+ // Wenn gerade die Shells ausgetauscht werden...
+ if ( !GetObjectShell() || !GetViewShell() )
+ return;
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_SHOWPOPUPS :
+ {
+ SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, SID_SHOWPOPUPS, FALSE);
+ BOOL bShow = pShowItem ? pShowItem->GetValue() : TRUE;
+ SFX_REQUEST_ARG(rReq, pIdItem, SfxUInt16Item, SID_CONFIGITEMID, FALSE);
+ USHORT nId = pIdItem ? pIdItem->GetValue() : 0;
+
+ // ausfuehren
+ SfxWorkWindow *pWorkWin = GetFrame().GetWorkWindow_Impl();
+ if ( bShow )
+ {
+ // Zuerst die Floats auch anzeigbar machen
+ pWorkWin->MakeChildsVisible_Impl( bShow );
+ GetDispatcher()->Update_Impl( TRUE );
+
+ // Dann anzeigen
+ GetBindings().HidePopups( !bShow );
+ }
+ else
+ {
+ // Alles hiden
+ SfxBindings *pBind = &GetBindings();
+ while ( pBind )
+ {
+ pBind->HidePopupCtrls_Impl( !bShow );
+ pBind = pBind->GetSubBindings_Impl();
+ }
+
+ pWorkWin->HidePopups_Impl( !bShow, TRUE, nId );
+ pWorkWin->MakeChildsVisible_Impl( bShow );
+ }
+
+ Invalidate( rReq.GetSlot() );
+ rReq.Done();
+ break;
+ }
+
+ case SID_ACTIVATE:
+ {
+ MakeActive_Impl( TRUE );
+ rReq.SetReturnValue( SfxObjectItem( 0, this ) );
+ break;
+ }
+
+ case SID_NEWDOCDIRECT :
+ {
+ SFX_REQUEST_ARG( rReq, pFactoryItem, SfxStringItem, SID_NEWDOCDIRECT, FALSE);
+ String aFactName;
+ if ( pFactoryItem )
+ aFactName = pFactoryItem->GetValue();
+ else if ( pImp->aFactoryName.Len() )
+ aFactName = pImp->aFactoryName;
+ else
+ {
+ DBG_ERROR("Missing argument!");
+ break;
+ }
+
+ SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, GetPool() );
+ String aFact = String::CreateFromAscii("private:factory/");
+ aFact += aFactName;
+ aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) );
+ aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, &GetFrame() ) );
+ aReq.AppendItem( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii( "_blank" ) ) );
+ SFX_APP()->ExecuteSlot( aReq );
+ const SfxViewFrameItem* pItem = PTR_CAST( SfxViewFrameItem, aReq.GetReturnValue() );
+ if ( pItem )
+ rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) );
+ break;
+ }
+
+ case SID_CLOSEWIN:
+ {
+ // disable CloseWin, if frame is not a task
+ Reference < XCloseable > xTask( GetFrame().GetFrameInterface(), UNO_QUERY );
+ if ( !xTask.is() )
+ break;
+
+ if ( GetViewShell()->PrepareClose() )
+ {
+ // weitere Views auf dasselbe Doc?
+ SfxObjectShell *pDocSh = GetObjectShell();
+ int bOther = sal_False;
+ for ( const SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh );
+ !bOther && pFrame;
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh ) )
+ bOther = (pFrame != this);
+
+ // Doc braucht nur gefragt zu werden, wenn keine weitere View
+ sal_Bool bClosed = sal_False;
+ sal_Bool bUI = TRUE;
+ if ( ( bOther || pDocSh->PrepareClose( bUI ) ) )
+ {
+ if ( !bOther )
+ pDocSh->SetModified( FALSE );
+ rReq.Done(); // unbedingt vor Close() rufen!
+ bClosed = sal_False;
+ try
+ {
+ xTask->close(sal_True);
+ bClosed = sal_True;
+ }
+ catch( CloseVetoException& )
+ {
+ bClosed = sal_False;
+ }
+ }
+
+ rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bClosed ));
+ }
+ return;
+ }
+ }
+
+ rReq.Done();
+}
+
+void SfxViewFrame::GetState_Impl( SfxItemSet &rSet )
+{
+ SfxObjectShell *pDocSh = GetObjectShell();
+
+ if ( !pDocSh )
+ return;
+
+ const sal_uInt16 *pRanges = rSet.GetRanges();
+ DBG_ASSERT(pRanges, "Set ohne Bereich");
+ while ( *pRanges )
+ {
+ for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich )
+ {
+ switch(nWhich)
+ {
+ case SID_NEWDOCDIRECT :
+ {
+ if ( pImp->aFactoryName.Len() )
+ {
+ String aFact = String::CreateFromAscii("private:factory/");
+ aFact += pImp->aFactoryName;
+ rSet.Put( SfxStringItem( nWhich, aFact ) );
+ }
+ break;
+ }
+
+ case SID_NEWWINDOW:
+ rSet.DisableItem(nWhich);
+ break;
+
+ case SID_CLOSEWIN:
+ {
+ // disable CloseWin, if frame is not a task
+ Reference < XCloseable > xTask( GetFrame().GetFrameInterface(), UNO_QUERY );
+ if ( !xTask.is() )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+
+ case SID_SHOWPOPUPS :
+ break;
+
+ case SID_OBJECT:
+ if ( GetViewShell() && GetViewShell()->GetVerbs().getLength() && !GetObjectShell()->IsInPlaceActive() )
+ {
+ uno::Any aAny;
+ aAny <<= GetViewShell()->GetVerbs();
+ rSet.Put( SfxUnoAnyItem( USHORT( SID_OBJECT ), aAny ) );
+ }
+ else
+ rSet.DisableItem( SID_OBJECT );
+ break;
+
+ default:
+ DBG_ERROR( "invalid message-id" );
+ }
+ }
+ ++pRanges;
+ }
+}
+
+void SfxViewFrame::INetExecute_Impl( SfxRequest &rRequest )
+{
+ sal_uInt16 nSlotId = rRequest.GetSlot();
+ switch( nSlotId )
+ {
+ case SID_BROWSE_FORWARD:
+ case SID_BROWSE_BACKWARD:
+ OSL_ENSURE( false, "SfxViewFrame::INetExecute_Impl: SID_BROWSE_FORWARD/BACKWARD are dead!" );
+ break;
+ case SID_CREATELINK:
+ {
+/*! (pb) we need new implementation to create a link
+*/
+ break;
+ }
+ case SID_FOCUSURLBOX:
+ {
+ SfxStateCache *pCache = GetBindings().GetAnyStateCache_Impl( SID_OPENURL );
+ if( pCache )
+ {
+ SfxControllerItem* pCtrl = pCache->GetItemLink();
+ while( pCtrl )
+ {
+ pCtrl->StateChanged( SID_FOCUSURLBOX, SFX_ITEM_UNKNOWN, 0 );
+ pCtrl = pCtrl->GetItemLink();
+ }
+ }
+ }
+ }
+
+ // Recording
+ rRequest.Done();
+}
+
+void SfxViewFrame::INetState_Impl( SfxItemSet &rItemSet )
+{
+ rItemSet.DisableItem( SID_BROWSE_FORWARD );
+ rItemSet.DisableItem( SID_BROWSE_BACKWARD );
+
+ // Add/SaveToBookmark bei BASIC-IDE, QUERY-EDITOR etc. disablen
+ SfxObjectShell *pDocSh = GetObjectShell();
+ sal_Bool bPseudo = pDocSh && !( pDocSh->GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC );
+ sal_Bool bEmbedded = pDocSh && pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED;
+ if ( !pDocSh || bPseudo || bEmbedded || !pDocSh->HasName() )
+ rItemSet.DisableItem( SID_CREATELINK );
+}
+
+void SfxViewFrame::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY )
+{
+ GetViewShell()->SetZoomFactor( rZoomX, rZoomY );
+}
+
+void SfxViewFrame::Activate( sal_Bool bMDI )
+{
+ DBG_ASSERT(GetViewShell(), "Keine Shell");
+ if ( bMDI )
+ pImp->bActive = sal_True;
+//(mba): hier evtl. wie in Beanframe NotifyEvent ?!
+}
+
+void SfxViewFrame::Deactivate( sal_Bool bMDI )
+{
+ DBG_ASSERT(GetViewShell(), "Keine Shell");
+ if ( bMDI )
+ pImp->bActive = sal_False;
+//(mba): hier evtl. wie in Beanframe NotifyEvent ?!
+}
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index 981d13cc0f9a..1c9e219cf180 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -30,20 +30,16 @@
// include ---------------------------------------------------------------
-#ifndef __SBX_SBXOBJ_HXX
#include <basic/sbxobj.hxx>
-#endif
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx> // SvBorder
#include <osl/mutex.hxx>
#include <cppuhelper/interfacecontainer.hxx>
-
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <svtools/acceleratorexecute.hxx>
-
#include <rtl/ref.hxx>
-
+#include <vcl/print.hxx>
#include <queue>
// forward ---------------------------------------------------------------
@@ -54,24 +50,6 @@ class SfxBaseController;
typedef SfxShell* SfxShellPtr_Impl;
SV_DECL_PTRARR( SfxShellArr_Impl, SfxShellPtr_Impl, 4, 4 )
-// struct SfxViewShell_Impl ----------------------------------------------
-#if 0
-class SfxAsyncPrintExec_Impl : public SfxListener
-{
- SfxViewShell* pView;
- ::std::queue < SfxRequest*> aReqs;
-
- virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
-
-public:
- SfxAsyncPrintExec_Impl( SfxViewShell* pShell)
- : pView( pShell )
- {}
-
- void AddRequest( SfxRequest& rReq );
-};
-#endif
-
class SfxClipboardChangeListener;
struct SfxViewShell_Impl
@@ -84,12 +62,10 @@ struct SfxViewShell_Impl
Size aOptimalSize;
Size aMargin;
USHORT nPrinterLocks;
- BOOL bUseObjectSize;
BOOL bCanPrint;
BOOL bHasPrintOptions;
BOOL bPlugInsActive;
BOOL bIsShowView;
- BOOL bFrameSetImpl;
BOOL bOwnsMenu;
BOOL bGotOwnerShip;
BOOL bGotFrameOwnerShip;
@@ -97,9 +73,9 @@ struct SfxViewShell_Impl
USHORT nFamily;
SfxBaseController* pController;
::svt::AcceleratorExecute* pAccExec;
-// SfxAsyncPrintExec_Impl* pPrinterCommandQueue;
com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aPrintOpts;
::rtl::Reference< SfxClipboardChangeListener > xClipboardListener;
+ vcl::PrinterController* pPrinterController;
SfxViewShell_Impl();
};
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 2d5403b72abd..4d9016d81f6b 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -329,6 +329,9 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt
if ( m_bNeedsChange )
mpObjectShell->EnableSetModified( m_bOrigStatus );
+
+ if ( mpViewShell )
+ mpViewShell->pImp->pPrinterController = 0;
}
}
@@ -639,6 +642,8 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro
this,
rProps
) );
+ pImp->pPrinterController = pController.get();
+
SfxObjectShell *pObjShell = GetObjectShell();
pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ),
makeAny( rtl::OUString( pObjShell->GetTitle(0) ) ) );
@@ -653,6 +658,11 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro
Printer::PrintJob( pController, aJobSetup );
}
+Printer* SfxViewShell::GetActivePrinter() const
+{
+ return pImp->pPrinterController ? pImp->pPrinterController->getPrinter().get() : 0;
+}
+
void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
{
// USHORT nCopies=1;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 3224d1c18d5c..5c65c967434f 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -81,7 +81,7 @@
#include "view.hrc"
#include "sfxlocal.hrc"
#include <sfx2/sfxbasecontroller.hxx>
-#include <sfx2/topfrm.hxx>
+#include <sfx2/viewfrm.hxx>
#include "mailmodelapi.hxx"
#include <sfx2/event.hxx>
#include <sfx2/fcontnr.hxx>
@@ -389,7 +389,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
case SID_ACTIVATE_STYLE_APPLY:
{
com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
- GetViewFrame()->GetFrame()->GetFrameInterface(),
+ GetViewFrame()->GetFrame().GetFrameInterface(),
com::sun::star::uno::UNO_QUERY);
Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
@@ -485,7 +485,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
if ( pMailDocType )
aDocType = pMailDocType->GetValue();
- uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() );
+ uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_ERROR;
if ( nId == SID_MAIL_SENDDOC )
@@ -529,7 +529,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
const sal_Int32 FILTERFLAG_EXPORT = 0x00000002;
css::uno::Reference< lang::XMultiServiceFactory > xSMGR(::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW);
- css::uno::Reference < css::frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() );
+ css::uno::Reference < css::frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
css::uno::Reference< css::frame::XModel > xModel;
const rtl::OUString aModuleManager( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ));
@@ -686,8 +686,8 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
// ausfuehren
if ( !pShowItem || bActive != pImp->bPlugInsActive )
{
- SfxFrame* pTopFrame = GetFrame()->GetTopFrame();
- if ( pTopFrame != GetFrame()->GetFrame() )
+ SfxFrame* pTopFrame = &GetFrame()->GetTopFrame();
+ if ( pTopFrame != &GetFrame()->GetFrame() )
{
// FramesetDocument
SfxViewShell *pShell = pTopFrame->GetCurrentViewFrame()->GetViewShell();
@@ -773,7 +773,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
aPrinterName = Printer::GetDefaultPrinterName();
if ( aPrinterName.getLength() > 0 )
{
- uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() );
+ uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
::rtl::OUStringBuffer aBuffer( 60 );
aBuffer.append( RetrieveLabelFromCommand(
@@ -871,7 +871,7 @@ ErrCode SfxViewShell::DoVerb(long /*nVerb*/)
void SfxViewShell::OutplaceActivated( sal_Bool bActive, SfxInPlaceClient* /*pClient*/ )
{
if ( !bActive )
- GetFrame()->GetFrame()->Appear();
+ GetFrame()->GetFrame().Appear();
}
//--------------------------------------------------------------------
@@ -893,7 +893,7 @@ void SfxViewShell::InplaceDeactivated( SfxInPlaceClient* /*pClient*/ )
void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ )
{
- uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame()->GetFrameInterface() );
+ uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() );
uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
if ( xParentFrame.is() )
xParentFrame->setActiveFrame( xOwnFrame );
@@ -906,12 +906,12 @@ void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ )
void SfxViewShell::UIDeactivated( SfxInPlaceClient* /*pClient*/ )
{
- if ( !pFrame->GetFrame()->IsClosing_Impl() ||
+ if ( !pFrame->GetFrame().IsClosing_Impl() ||
SfxViewFrame::Current() != pFrame )
pFrame->GetDispatcher()->Update_Impl( TRUE );
pFrame->GetBindings().HidePopups(FALSE);
- // uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame()->GetFrameInterface() );
+ // uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() );
// uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
// if ( xParentFrame.is() )
// xParentFrame->setActiveFrame( uno::Reference < frame::XFrame >() );
@@ -992,7 +992,7 @@ void SfxViewShell::Activate( BOOL bMDI )
{
SfxObjectShell *pSh = GetViewFrame()->GetObjectShell();
if ( pSh->GetModel().is() )
- pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame()->GetController() );
+ pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame().GetController() );
SetCurrentDocument();
}
@@ -1252,8 +1252,6 @@ SfxViewShell::SfxViewShell
,pFrame(pViewFrame)
,pSubShell(0)
,pWindow(0)
- ,bMaximizeFirst( 0 != (nFlags & SFX_VIEW_MAXIMIZE_FIRST) )
- ,bOptimizeEach(0 != (nFlags & SFX_VIEW_OPTIMIZE_EACH))
,bNoNewWindow( 0 != (nFlags & SFX_VIEW_NO_NEWWINDOW) )
{
DBG_CTOR(SfxViewShell, 0);
@@ -1263,11 +1261,7 @@ SfxViewShell::SfxViewShell
pImp->bIsShowView =
!(SFX_VIEW_NO_SHOW == (nFlags & SFX_VIEW_NO_SHOW));
- pImp->bUseObjectSize = FALSE;
-// SFX_CREATE_MODE_EMBEDDED==pFrame->GetObjectShell()->GetCreateMode() &&
-// SFX_VIEW_OBJECTSIZE_EMBEDDED == (nFlags & SFX_VIEW_OBJECTSIZE_EMBEDDED);
pImp->bCanPrint = SFX_VIEW_CAN_PRINT == (nFlags & SFX_VIEW_CAN_PRINT);
- pImp->bFrameSetImpl = (nFlags & SFX_VIEW_IMPLEMENTED_AS_FRAMESET) != 0;
pImp->bHasPrintOptions =
SFX_VIEW_HAS_PRINTOPTIONS == (nFlags & SFX_VIEW_HAS_PRINTOPTIONS);
pImp->bPlugInsActive = TRUE;
@@ -1363,6 +1357,24 @@ SfxViewShell* SfxViewShell::Current()
//--------------------------------------------------------------------
+SfxViewShell* SfxViewShell::Get( const Reference< XController>& i_rController )
+{
+ if ( !i_rController.is() )
+ return NULL;
+
+ for ( SfxViewShell* pViewShell = SfxViewShell::GetFirst( NULL, FALSE );
+ pViewShell;
+ pViewShell = SfxViewShell::GetNext( *pViewShell, NULL, FALSE )
+ )
+ {
+ if ( pViewShell->GetController() == i_rController )
+ return pViewShell;
+ }
+ return NULL;
+}
+
+//--------------------------------------------------------------------
+
SdrView* SfxViewShell::GetDrawView() const
/* [Beschreibung]
@@ -1514,16 +1526,12 @@ void SfxViewShell::PushSubShells_Impl( BOOL bPush )
{
for ( USHORT n=0; n<nCount; n++ )
pDisp->Push( *pImp->aArr[n] );
-
-// HACK(evtl. PushSubShells fuer SW virtuell machen oder im SW umbauen)
-// Notify( *this, SfxSimpleHint( SFX_HINT_RESERVED4 ) );
}
else if ( nCount )
{
- pDisp->Pop( *pImp->aArr[0], SFX_SHELL_POP_UNTIL );
-
-// HACK(evtl. PushSubShells fuer SW virtuell machen oder im SW umbauen)
-// Notify( *this, SfxSimpleHint( SFX_HINT_RESERVED3 ) );
+ SfxShell& rPopUntil = *pImp->aArr[0];
+ if ( pDisp->GetShellLevel( rPopUntil ) != USHRT_MAX )
+ pDisp->Pop( rPopUntil, SFX_SHELL_POP_UNTIL );
}
pDisp->Flush();
@@ -1674,7 +1682,7 @@ BOOL SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
if (!pImp->pAccExec)
{
pImp->pAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper();
- pImp->pAccExec->init(::comphelper::getProcessServiceFactory(), pFrame->GetFrame()->GetFrameInterface());
+ pImp->pAccExec->init(::comphelper::getProcessServiceFactory(), pFrame->GetFrame().GetFrameInterface());
}
return pImp->pAccExec->execute(aKey.GetKeyCode());
@@ -1779,13 +1787,6 @@ void SfxViewShell::DisconnectAllClients()
//--------------------------------------------------------------------
-BOOL SfxViewShell::UseObjectSize() const
-{
- return pImp->bUseObjectSize;
-}
-
-//--------------------------------------------------------------------
-
void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const
{
}
@@ -1795,14 +1796,7 @@ void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const
void SfxViewShell::AdjustVisArea(const Rectangle& rRect)
{
DBG_ASSERT (pFrame, "Kein Frame?");
- if ( UseObjectSize() )
- {
- Point aPos = rRect.TopLeft();
- Size aSize = GetObjectShell()->GetVisArea().GetSize();
- GetObjectShell()->SetVisArea( Rectangle(aPos, aSize) );
- }
- else
- GetObjectShell()->SetVisArea( rRect );
+ GetObjectShell()->SetVisArea( rRect );
}
//--------------------------------------------------------------------
@@ -1974,13 +1968,6 @@ SfxFrame* SfxViewShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ )
return pSelf;
}
-//--------------------------------------------------------------------
-
-BOOL SfxViewShell::IsImplementedAsFrameset_Impl( ) const
-{
- return pImp->bFrameSetImpl;
-}
-
//------------------------------------------------------------------------
void SfxViewShell::JumpToMark( const String& rMark )
@@ -2020,6 +2007,11 @@ Reference < XController > SfxViewShell::GetController()
return pImp->pController;
}
+SfxBaseController* SfxViewShell::GetBaseController_Impl() const
+{
+ return pImp->pController;
+}
+
void SfxViewShell::AddContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor )
{
pImp->aInterceptorContainer.addInterface( xInterceptor );
@@ -2174,7 +2166,7 @@ void SfxViewShell::CheckOwnerShip_Impl()
{
// document couldn't be closed or it shouldn't, now try at least to close the frame
com::sun::star::uno::Reference < com::sun::star::util::XCloseable > xFrame(
- GetViewFrame()->GetFrame()->GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
+ GetViewFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
if ( xFrame.is() )
{
try
@@ -2253,3 +2245,4 @@ void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransf
{
}
}
+