1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewfrm.cxx,v $
10 * $Revision: 1.136.8.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
36 #include <sfx2/viewfrm.hxx>
37 #include <com/sun/star/document/MacroExecMode.hpp>
38 #include <com/sun/star/frame/XLoadable.hpp>
39 #include <com/sun/star/frame/XLayoutManager.hpp>
41 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
42 #include <toolkit/unohlp.hxx>
44 #ifndef _SPLITWIN_HXX //autogen
45 #include <vcl/splitwin.hxx>
47 #include <svtools/moduleoptions.hxx>
48 #include <svtools/intitem.hxx>
49 #include <svtools/stritem.hxx>
50 #include <svtools/eitem.hxx>
51 #include <svtools/slstitm.hxx>
52 #include <svtools/whiter.hxx>
53 #include <svtools/undo.hxx>
54 #ifndef _MSGBOX_HXX //autogen
55 #include <vcl/msgbox.hxx>
57 #include <svtools/sfxecode.hxx>
58 #include <svtools/ehdl.hxx>
59 #include <com/sun/star/container/XIndexAccess.hpp>
60 #include <com/sun/star/frame/XFramesSupplier.hpp>
61 #include <com/sun/star/frame/FrameSearchFlag.hpp>
62 #include <com/sun/star/frame/XFrame.hpp>
63 #include <com/sun/star/frame/XFrames.hpp>
64 #include <com/sun/star/frame/XFramesSupplier.hpp>
65 #include <com/sun/star/awt/XWindow.hpp>
66 #include <com/sun/star/frame/XController.hpp>
67 #include <com/sun/star/frame/XModel.hpp>
68 #include <com/sun/star/util/XURLTransformer.hpp>
69 #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
70 #include <com/sun/star/document/MacroExecMode.hpp>
71 #include <com/sun/star/document/UpdateDocMode.hpp>
72 #include <com/sun/star/beans/XPropertySet.hpp>
73 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
74 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
75 #include <com/sun/star/embed/XStorage.hpp>
76 #include <com/sun/star/embed/EmbedStates.hpp>
77 #include <rtl/ustrbuf.hxx>
79 #include <unotools/localfilehelper.hxx>
80 #include <unotools/ucbhelper.hxx>
81 #include <comphelper/processfactory.hxx>
82 #include <comphelper/configurationhelper.hxx>
84 #include <com/sun/star/uno/Reference.h>
85 #include <com/sun/star/ucb/XContent.hpp>
87 #include <basic/basmgr.hxx>
88 #include <basic/sbmod.hxx>
89 #include <basic/sbmeth.hxx>
90 #include <basic/sbx.hxx>
91 #include <comphelper/storagehelper.hxx>
92 #include <svtools/asynclink.hxx>
93 #include <svtools/sharecontrolfile.hxx>
95 using namespace ::com::sun::star
;
96 using namespace ::com::sun::star::uno
;
97 using namespace ::com::sun::star::ucb
;
98 using namespace ::com::sun::star::frame
;
99 using namespace ::com::sun::star::lang
;
100 namespace css
= ::com::sun::star
;
105 // wg. ViewFrame::Current
106 #include "appdata.hxx"
107 #include <sfx2/app.hxx>
108 #include <sfx2/objface.hxx>
109 #include "openflag.hxx"
110 #include "objshimp.hxx"
111 #include <sfx2/viewsh.hxx>
112 #include <sfx2/objsh.hxx>
113 #include <sfx2/bindings.hxx>
114 #include <sfx2/dispatch.hxx>
115 #include "arrdecl.hxx"
116 #include "sfxtypes.hxx"
117 #include <sfx2/request.hxx>
118 #include <sfx2/docfac.hxx>
119 #include <sfx2/ipclient.hxx>
120 #include "sfxresid.hxx"
121 #include "appbas.hxx"
122 #include <sfx2/objitem.hxx>
123 #include "viewfac.hxx"
124 #include <sfx2/event.hxx>
125 #include "fltfnc.hxx"
126 #include <sfx2/docfile.hxx>
127 #include <sfx2/module.hxx>
128 #include <sfx2/msgpool.hxx>
129 #include <sfx2/topfrm.hxx>
130 #include "viewimp.hxx"
131 #include <sfx2/sfxbasecontroller.hxx>
132 #include <sfx2/sfx.hrc>
134 #include <sfx2/frmdescr.hxx>
135 #include <sfx2/sfxuno.hxx>
136 #include <sfx2/progress.hxx>
137 #include "workwin.hxx"
138 #include "helper.hxx"
140 #include "minfitem.hxx"
141 #include "../appl/app.hrc"
142 //-------------------------------------------------------------------------
143 DBG_NAME(SfxViewFrame
)
146 #include "sfxslots.hxx"
148 //-------------------------------------------------------------------------
150 SFX_IMPL_INTERFACE(SfxViewFrame
,SfxShell
,SfxResId(0))
152 SFX_CHILDWINDOW_REGISTRATION( SID_BROWSER
);
153 SFX_CHILDWINDOW_REGISTRATION( SID_RECORDING_FLOATWINDOW
);
155 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_FULLSCREEN
| SFX_VISIBILITY_FULLSCREEN
, SfxResId(RID_FULLSCREENTOOLBOX
) );
156 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION
| SFX_VISIBILITY_STANDARD
, SfxResId(RID_ENVTOOLBOX
) );
159 TYPEINIT2(SfxViewFrame
,SfxShell
,SfxListener
);
160 TYPEINIT1(SfxViewFrameItem
, SfxPoolItem
);
162 //=========================================================================
164 struct SfxViewFrame_Impl
173 String aActualPresentationURL
;
175 SfxCancelManager
* pCancelMgr
;
176 svtools::AsynchronLink
* pReloader
;
177 //SfxInPlaceFrame* pIPFrame;
179 SfxViewFrame
* pActiveChild
;
180 SfxViewFrame
* pParentViewFrame
;
181 SfxObjectShell
* pImportShell
;
184 sal_uInt16 nDocViewNo
;
185 sal_uInt16 nCurViewId
;
186 sal_Bool bResizeInToOut
:1;
187 sal_Bool bDontOverwriteResizeInToOut
:1;
188 sal_Bool bObjLocked
:1;
189 sal_Bool bRestoreView
:1;
190 sal_Bool bSetViewFrameLocked
:1;
191 sal_Bool bReloading
:1;
192 sal_Bool bIsDowning
:1;
196 sal_Bool bEventFlag
:1;
197 sal_Bool bWindowWasEnabled
:1;
202 , bWindowWasEnabled(sal_True
)
212 //-------------------------------------------------------------------------
213 void SfxViewFrame::SetDowning_Impl()
215 pImp
->bIsDowning
= sal_True
;
218 //-------------------------------------------------------------------------
219 sal_Bool
SfxViewFrame::IsDowning_Impl() const
221 return pImp
->bIsDowning
;
225 //-------------------------------------------------------------------------
226 void SfxViewFrame::SetSetViewFrameAllowed_Impl( sal_Bool bSet
)
228 pImp
->bSetViewFrameLocked
= !bSet
;
231 //-------------------------------------------------------------------------
232 sal_Bool
SfxViewFrame::IsSetViewFrameAllowed_Impl() const
234 return !pImp
->bSetViewFrameLocked
;
237 //-------------------------------------------------------------------------
238 void SfxViewFrame::SetImportingObjectShell_Impl( SfxObjectShell
* pSh
)
240 pImp
->pImportShell
= pSh
;
243 //--------------------------------------------------------------------
244 SfxObjectShell
* SfxViewFrame::GetImportingObjectShell_Impl() const
246 return pImp
->pImportShell
;
250 class SfxViewNotificatedFrameList_Impl
:
251 public SfxListener
, public SfxViewFrameArr_Impl
255 void InsertViewFrame( SfxViewFrame
* pFrame
)
257 StartListening( *pFrame
);
258 C40_INSERT( SfxViewFrame
, pFrame
, Count() );
260 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
263 //-------------------------------------------------------------------------
264 void SfxViewNotificatedFrameList_Impl::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
266 if ( rHint
.IsA(TYPE(SfxSimpleHint
)) )
268 switch( ( (SfxSimpleHint
&) rHint
).GetId() )
271 SfxViewFrame
* pFrame
= (SfxViewFrame
*) &rBC
;
274 sal_uInt16 nPos
= C40_GETPOS( SfxViewFrame
, pFrame
);
275 if( nPos
!= USHRT_MAX
)
283 //-------------------------------------------------------------------------
285 long ReloadDecouple_Impl( void* pObj
, void* pArg
)
287 ((SfxViewFrame
*) pObj
)->ExecReload_Impl( *(SfxRequest
*)pArg
);
291 void SfxViewFrame::ExecReload_Impl( SfxRequest
& rReq
, sal_Bool bAsync
)
295 if( !pImp
->pReloader
)
296 pImp
->pReloader
= new svtools::AsynchronLink(
297 Link( this, ReloadDecouple_Impl
) );
298 pImp
->pReloader
->Call( new SfxRequest( rReq
) );
300 else ExecReload_Impl( rReq
);
303 void SfxViewFrame::ExecReload_Impl( SfxRequest
& rReq
)
305 SfxFrame
*pParent
= GetFrame()->GetParentFrame();
306 if ( rReq
.GetSlot() == SID_RELOAD
)
308 // Bei CTRL-Reload den aktiven Frame reloaden
309 SfxViewFrame
* pActFrame
= this;
311 pActFrame
= pActFrame
->GetActiveChildFrame_Impl();
315 sal_uInt16 nModifier
= rReq
.GetModifier();
316 if ( nModifier
& KEY_MOD1
)
318 pActFrame
->ExecReload_Impl( rReq
);
323 // Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames
324 // gemacht werden soll
325 SfxFrame
*pFrame
= GetFrame();
326 if ( pParent
== pFrame
&& pFrame
->GetChildFrameCount() )
328 sal_Bool bReloadAvailable
= sal_False
;
329 SfxFrameIterator
aIter( *pFrame
, sal_False
);
330 SfxFrame
*pChild
= aIter
.FirstFrame();
333 SfxFrame
*pNext
= aIter
.NextFrame( *pChild
);
334 SfxObjectShell
*pShell
= pChild
->GetCurrentDocument();
335 if( pShell
&& pShell
->Get_Impl()->bReloadAvailable
)
337 bReloadAvailable
= sal_True
;
338 pChild
->GetCurrentViewFrame()->ExecuteSlot( rReq
);
343 // Der TopLevel-Frame selbst het keine Graphiken!
344 if ( bReloadAvailable
)
350 // Bei CTRL-Edit den TopFrame bearbeiten
351 sal_uInt16 nModifier
= rReq
.GetModifier();
353 if ( ( nModifier
& KEY_MOD1
) && pParent
)
355 SfxViewFrame
*pTop
= GetTopViewFrame();
356 pTop
->ExecReload_Impl( rReq
);
361 SfxObjectShell
* pSh
= GetObjectShell();
362 sal_Bool bWasReadonly
= pSh
->IsReadOnly();
364 switch ( rReq
.GetSlot() )
368 if ( GetFrame()->HasComponent() )
371 // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
372 // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
373 // trotzdem nicht geht!
374 if( !pSh
|| !pSh
->HasName() || !(pSh
->Get_Impl()->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
))
377 SFX_ITEMSET_ARG( pSh
->GetMedium()->GetItemSet(), pItem
, SfxBoolItem
, SID_VIEWONLY
, sal_False
);
378 if ( pItem
&& pItem
->GetValue() )
380 SfxMedium
* pMed
= pSh
->GetMedium();
381 SfxApplication
* pApp
= SFX_APP();
382 SfxAllItemSet
aSet( pApp
->GetPool() );
383 aSet
.Put( SfxStringItem( SID_FILE_NAME
, pMed
->GetURLObject().GetMainURL(INetURLObject::NO_DECODE
) ) );
384 aSet
.Put( SfxBoolItem( SID_TEMPLATE
, sal_True
) );
385 aSet
.Put( SfxStringItem( SID_TARGETNAME
, String::CreateFromAscii("_blank") ) );
386 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pReferer
, SfxStringItem
, SID_REFERER
, sal_False
);
388 aSet
.Put( *pReferer
);
389 SFX_ITEMSET_ARG( pSh
->GetMedium()->GetItemSet(), pVersionItem
, SfxInt16Item
, SID_VERSION
, sal_False
);
391 aSet
.Put( *pVersionItem
);
393 if( pMed
->GetFilter() )
395 aSet
.Put( SfxStringItem( SID_FILTER_NAME
, pMed
->GetFilter()->GetFilterName() ) );
396 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pOptions
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, sal_False
);
398 aSet
.Put( *pOptions
);
401 GetDispatcher()->Execute( SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
, aSet
);
405 sal_uInt16 nOpenMode
;
406 sal_Bool bNeedsReload
= sal_False
;
407 if ( !pSh
->IsReadOnly() )
409 // Speichern und Readonly Reloaden
410 if( pSh
->IsModified() )
412 if ( !pSh
->PrepareClose() )
414 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), sal_False
) );
417 else bNeedsReload
= sal_True
;
419 nOpenMode
= SFX_STREAM_READONLY
;
423 nOpenMode
= SFX_STREAM_READWRITE
;
424 pSh
->SetReadOnlyUI( sal_False
);
426 // if only the view was in the readonly mode then there is no need to do the reload
427 if ( !pSh
->IsReadOnly() )
431 // Parameter auswerten
432 // sal_Bool bReload = sal_True;
435 // per API steuern ob r/w oder r/o
436 SFX_REQUEST_ARG(rReq
, pEditItem
, SfxBoolItem
, SID_EDITDOC
, sal_False
);
438 nOpenMode
= pEditItem
->GetValue() ? SFX_STREAM_READWRITE
: SFX_STREAM_READONLY
;
444 SfxMedium
* pMed
= pSh
->GetMedium();
446 utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed
->GetPhysicalName(), aTemp
);
447 INetURLObject
aPhysObj( aTemp
);
448 SFX_ITEMSET_ARG( pSh
->GetMedium()->GetItemSet(),
449 pVersionItem
, SfxInt16Item
, SID_VERSION
, sal_False
);
451 INetURLObject
aMedObj( pMed
->GetName() );
453 // the logic below is following, if the document seems not to need to be reloaded and the physical name is different
454 // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required
455 if ( ( !bNeedsReload
&& ( (aMedObj
.GetProtocol() == INET_PROT_FILE
&&
456 aMedObj
.getFSysPath(INetURLObject::FSYS_DETECT
) != aPhysObj
.getFSysPath(INetURLObject::FSYS_DETECT
) &&
457 !::utl::UCBContentHelper::IsYounger( aMedObj
.GetMainURL( INetURLObject::NO_DECODE
), aPhysObj
.GetMainURL( INetURLObject::NO_DECODE
) ))
458 || pMed
->IsRemote() ) )
461 sal_Bool bOK
= sal_False
;
464 sal_Bool bHasStorage
= pMed
->HasStorage_Impl();
465 // switching edit mode could be possible without reload
466 if ( bHasStorage
&& pMed
->GetStorage() == pSh
->GetStorage() )
468 // TODO/LATER: faster creation of copy
469 if ( !pSh
->ConnectTmpStorage_Impl( pMed
->GetStorage(), pMed
) )
473 pMed
->CloseAndRelease();
474 pMed
->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY
, !( nOpenMode
& STREAM_WRITE
) ) );
475 pMed
->SetOpenMode( nOpenMode
, pMed
->IsDirect() );
477 pMed
->CompleteReOpen();
478 if ( nOpenMode
& STREAM_WRITE
)
479 pMed
->LockOrigFileOnDemand( sal_False
, sal_True
);
481 // LockOrigFileOnDemand might set the readonly flag itself, it should be set back
482 pMed
->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY
, !( nOpenMode
& STREAM_WRITE
) ) );
484 if ( !pMed
->GetErrorCode() )
490 ErrCode nErr
= pMed
->GetErrorCode();
492 nErr
= ERRCODE_IO_ACCESSDENIED
;
496 pMed
->SetOpenMode( SFX_STREAM_READONLY
, pMed
->IsDirect() );
498 pSh
->DoSaveCompleted( pMed
);
501 // r/o-Doc kann nicht in Editmode geschaltet werden?
502 rReq
.Done( sal_False
);
504 SFX_REQUEST_ARG( rReq
, pFSetItem
, SfxBoolItem
, SID_EDIT_FRAMESET
, sal_False
);
505 if ( nOpenMode
== SFX_STREAM_READWRITE
&& !rReq
.IsAPI() )
507 // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen
508 QueryBox
aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE
) );
509 if ( !pFSetItem
&& RET_YES
== aBox
.Execute() )
511 SfxApplication
* pApp
= SFX_APP();
512 SfxAllItemSet
aSet( pApp
->GetPool() );
513 aSet
.Put( SfxStringItem( SID_FILE_NAME
, pMed
->GetName() ) );
514 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pReferer
, SfxStringItem
, SID_REFERER
, sal_False
);
516 aSet
.Put( *pReferer
);
517 aSet
.Put( SfxBoolItem( SID_TEMPLATE
, sal_True
) );
519 aSet
.Put( *pVersionItem
);
521 if( pMed
->GetFilter() )
523 aSet
.Put( SfxStringItem( SID_FILTER_NAME
, pMed
->GetFilter()->GetFilterName() ) );
524 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pOptions
,
525 SfxStringItem
, SID_FILE_FILTEROPTIONS
, sal_False
);
527 aSet
.Put( *pOptions
);
530 GetDispatcher()->Execute( SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
, aSet
);
537 ErrorHandler::HandleError( nErr
);
539 SfxBoolItem( rReq
.GetSlot(), sal_False
) );
544 pSh
->DoSaveCompleted( pMed
);
545 pSh
->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED
) );
546 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), sal_True
) );
547 rReq
.Done( sal_True
);
548 // if( nOpenMode == SFX_STREAM_READONLY )
551 // ReloadForEdit bei Framesets schaltet auch FramesetEditmode
552 sal_Bool bIsReadonly
= GetObjectShell()->IsReadOnly();
553 if ( bIsReadonly
!= bWasReadonly
&& !GetFrame()->GetParentFrame() )
555 SfxBoolItem
aItem( SID_EDIT_FRAMESET
, !bIsReadonly
);
556 GetDispatcher()->Execute( SID_EDIT_FRAMESET
,
557 SFX_CALLMODE_RECORD
, &aItem
, 0L );
558 pSh
->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED
) );
567 // Es soll nicht reloaded werden
568 SfxErrorContext aEc( ERRCODE_SFX_NODOCRELOAD );
569 ErrorHandler::HandleError( ERRCODE_SFX_NODOCRELOAD );
571 SfxBoolItem( rReq.GetSlot(), sal_False ) );
575 // Ansonsten ( lokal und arbeiten auf Kopie ) muss gereloaded
579 rReq
.AppendItem( SfxBoolItem( SID_FORCERELOAD
, sal_True
) );
580 rReq
.AppendItem( SfxBoolItem( SID_SILENT
, sal_True
));
585 // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
586 // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
587 // trotzdem nicht geht!
588 if ( !pSh
|| !pSh
->CanReload_Impl() )
590 SfxApplication
* pApp
= SFX_APP();
591 SFX_REQUEST_ARG(rReq
, pForceReloadItem
, SfxBoolItem
,
592 SID_FORCERELOAD
, sal_False
);
593 if( pForceReloadItem
&& !pForceReloadItem
->GetValue() &&
594 !pSh
->GetMedium()->IsExpired() )
596 if( pImp
->bReloading
|| pSh
->IsInModalMode() )
599 // AutoLoad ist ggf. verboten
600 SFX_REQUEST_ARG(rReq
, pAutoLoadItem
, SfxBoolItem
, SID_AUTOLOAD
, sal_False
);
601 if ( pAutoLoadItem
&& pAutoLoadItem
->GetValue() &&
602 GetFrame()->IsAutoLoadLocked_Impl() )
605 SfxObjectShellLock
xOldObj( pSh
);
606 pImp
->bReloading
= sal_True
;
607 SFX_REQUEST_ARG(rReq
, pURLItem
, SfxStringItem
,
608 SID_FILE_NAME
, sal_False
);
609 // editierbar "offnen?
610 sal_Bool bForEdit
= !pSh
->IsReadOnly();
611 if ( rReq
.GetSlot() == SID_EDITDOC
)
612 bForEdit
= !bForEdit
;
614 // ggf. beim User nachfragen
615 sal_Bool bDo
= ( GetViewShell()->PrepareClose() != FALSE
);
616 SFX_REQUEST_ARG(rReq
, pSilentItem
, SfxBoolItem
, SID_SILENT
, sal_False
);
617 if ( bDo
&& GetFrame()->DocIsModified_Impl() &&
618 !rReq
.IsAPI() && ( !pSilentItem
|| !pSilentItem
->GetValue() ) )
620 QueryBox
aBox( &GetWindow(), SfxResId(MSG_QUERY_LASTVERSION
) );
621 bDo
= ( RET_YES
== aBox
.Execute() );
626 SfxMedium
*pMedium
= xOldObj
->GetMedium();
628 // Frameset abziehen, bevor FramesetView evtl. verschwindet
629 String aURL
= pURLItem
? pURLItem
->GetValue() :
633 ( pMedium
->GetURLObject().GetProtocol() == INET_PROT_FILE
&& !xOldObj
->IsDocShared() );
635 // bestehende SfxMDIFrames f"ur dieses Doc leeren
636 // eigenes Format oder R/O jetzt editierbar "offnen?
637 SfxViewNotificatedFrameList_Impl aFrames
;
638 SfxObjectShellLock xNewObj
;
639 sal_Bool bRestoreView
= ( pURLItem
== NULL
);
640 TypeId aOldType
= xOldObj
->Type();
642 SfxViewFrame
*pView
= GetFirst(xOldObj
);
646 pView
->GetDispatcher()->LockUI_Impl(sal_True
);
647 aFrames
.InsertViewFrame( pView
);
648 pView
->GetBindings().ENTERREGISTRATIONS();
650 // RestoreView nur wenn keine neue Datei geladen
651 // (Client-Pull-Reloading)
652 pView
= /*bHandsOff ? (SfxTopViewFrame*) GetFirst(
653 xOldObj, TYPE(SfxTopViewFrame) ) :*/
654 (SfxTopViewFrame
*)GetNext( *pView
, xOldObj
,
655 TYPE( SfxTopViewFrame
) );
658 DELETEZ( xOldObj
->Get_Impl()->pReloadTimer
);
660 SfxItemSet
* pNewSet
= 0;
661 const SfxFilter
*pFilter
= pMedium
->GetFilter();
664 pNewSet
= new SfxAllItemSet( pApp
->GetPool() );
665 pNewSet
->Put( *pURLItem
);
668 SfxMedium
aMedium( pURLItem
->GetValue(), SFX_STREAM_READWRITE
);
669 SfxFilterMatcher().GuessFilter( aMedium
, &pFilter
);
671 pNewSet
->Put( SfxStringItem( SID_FILTER_NAME
, pFilter
->GetName() ) );
672 pNewSet
->Put( *aMedium
.GetItemSet() );
676 pNewSet
= new SfxAllItemSet( *pMedium
->GetItemSet() );
677 pNewSet
->ClearItem( SID_VIEW_ID
);
678 pNewSet
->ClearItem( SID_USER_DATA
);
679 pNewSet
->ClearItem( SID_STREAM
);
680 pNewSet
->ClearItem( SID_INPUTSTREAM
);
681 pNewSet
->Put( SfxStringItem( SID_FILTER_NAME
, pMedium
->GetFilter()->GetName() ) );
683 // let the current security settings be checked again
684 pNewSet
->Put( SfxUInt16Item( SID_MACROEXECMODE
, document::MacroExecMode::USE_CONFIG
) );
686 if ( rReq
.GetSlot() == SID_EDITDOC
|| !bForEdit
)
687 // edit mode is switched or reload of readonly document
688 pNewSet
->Put( SfxBoolItem( SID_DOC_READONLY
, !bForEdit
) );
690 // Reload of file opened for writing
691 pNewSet
->ClearItem( SID_DOC_READONLY
);
694 // Falls eine salvagede Datei vorliegt, nicht nochmals die
695 // OrigURL mitschicken, denn die Tempdate ist nach Reload
697 SFX_ITEMSET_ARG( pNewSet
, pSalvageItem
, SfxStringItem
, SID_DOC_SALVAGE
, sal_False
);
700 aURL
= pSalvageItem
->GetValue();
701 pNewSet
->ClearItem( SID_DOC_SALVAGE
);
704 // TODO/LATER: Temporary solution, the SfxMedium must know the original URL as aLogicName
705 // SfxMedium::Transfer_Impl() will be vorbidden then.
706 if ( xOldObj
->IsDocShared() )
707 pNewSet
->Put( SfxStringItem( SID_FILE_NAME
, xOldObj
->GetSharedFileURL() ) );
709 //pNewMedium = new SfxMedium( aURL, nMode, pMedium->IsDirect(), bUseFilter ? pMedium->GetFilter() : 0, pNewSet );
710 //pNewSet = pNewMedium->GetItemSet();
712 pNewSet
->Put( SfxStringItem( SID_REFERER
, pMedium
->GetName() ) );
714 pNewSet
->Put( SfxStringItem( SID_REFERER
, String() ) );
716 xOldObj
->CancelTransfers();
718 // eigentliches Reload
719 //pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) );
721 if ( pSilentItem
&& pSilentItem
->GetValue() )
722 pNewSet
->Put( SfxBoolItem( SID_SILENT
, sal_True
) );
724 SFX_ITEMSET_ARG(pNewSet
, pInteractionItem
, SfxUnoAnyItem
, SID_INTERACTIONHANDLER
, FALSE
);
725 SFX_ITEMSET_ARG(pNewSet
, pMacroExecItem
, SfxUInt16Item
, SID_MACROEXECMODE
, FALSE
);
726 SFX_ITEMSET_ARG(pNewSet
, pDocTemplateItem
, SfxUInt16Item
, SID_UPDATEDOCMODE
, FALSE
);
728 if (!pInteractionItem
)
730 Reference
< ::com::sun::star::task::XInteractionHandler
> xHdl( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY
);
732 pNewSet
->Put( SfxUnoAnyItem(SID_INTERACTIONHANDLER
,::com::sun::star::uno::makeAny(xHdl
)) );
736 pNewSet
->Put( SfxUInt16Item(SID_MACROEXECMODE
,::com::sun::star::document::MacroExecMode::USE_CONFIG
) );
737 if (!pDocTemplateItem
)
738 pNewSet
->Put( SfxUInt16Item(SID_UPDATEDOCMODE
,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG
) );
740 xOldObj
->SetModified( sal_False
);
741 // Altes Dok nicht cachen! Gilt nicht, wenn anderes
744 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pSavedOptions
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, sal_False
);
745 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pSavedReferer
, SfxStringItem
, SID_REFERER
, sal_False
);
747 if( !pURLItem
|| pURLItem
->GetValue() == xOldObj
->GetMedium()->GetName() )
748 xOldObj
->Get_Impl()->bForbidCaching
= sal_True
;
750 sal_Bool bHasStorage
= pMedium
->HasStorage_Impl();
753 if ( bHasStorage
&& pMedium
->GetStorage() == xOldObj
->GetStorage() )
755 // TODO/LATER: faster creation of copy
756 if ( !xOldObj
->ConnectTmpStorage_Impl( pMedium
->GetStorage(), pMedium
) )
760 pMedium
->CloseAndRelease();
763 xNewObj
= SfxObjectShell::CreateObject( pFilter
->GetServiceName(), SFX_CREATE_MODE_STANDARD
);
766 uno::Sequence
< beans::PropertyValue
> aProps
;
767 TransformItems( SID_OPENDOC
, *pNewSet
, aProps
);
768 uno::Reference
< frame::XLoadable
> xLoad( xNewObj
->GetModel(), uno::UNO_QUERY
);
769 xLoad
->load( aProps
);
771 catch ( uno::Exception
& )
783 // back to old medium
785 pMedium
->LockOrigFileOnDemand( sal_False
, sal_True
);
787 xOldObj
->DoSaveCompleted( pMedium
);
790 // r/o-Doc couldn't be switched to writing mode
791 if ( bForEdit
&& SID_EDITDOC
== rReq
.GetSlot() )
793 // ask user for opening as template
794 QueryBox
aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE
) );
795 if ( RET_YES
== aBox
.Execute() )
797 SfxAllItemSet
aSet( pApp
->GetPool() );
798 aSet
.Put( SfxStringItem( SID_FILE_NAME
, pMedium
->GetName() ) );
799 aSet
.Put( SfxStringItem( SID_TARGETNAME
, String::CreateFromAscii("_blank") ) );
801 aSet
.Put( *pSavedOptions
);
803 aSet
.Put( *pSavedReferer
);
804 aSet
.Put( SfxBoolItem( SID_TEMPLATE
, sal_True
) );
806 aSet
.Put( SfxStringItem( SID_FILTER_NAME
, pFilter
->GetFilterName() ) );
807 GetDispatcher()->Execute( SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
, aSet
);
812 // an error handling should be done here?!
813 // if ( !pSilentItem || !pSilentItem->GetValue() )
814 // ErrorHandler::HandleError( nLoadError );
819 if ( xNewObj
->IsDocShared() )
821 // the file is shared but the closing can chang the sharing control file
822 xOldObj
->DoNotCleanShareControlFile();
825 xNewObj
->GetMedium()->GetItemSet()->ClearItem( SID_RELOAD
);
826 xNewObj
->GetMedium()->GetItemSet()->ClearItem( SID_SILENT
);
827 UpdateDocument_Impl();
830 SfxViewFrame
* pThis
= (SfxViewFrame
*)this;
831 sal_Bool bDeleted
= aFrames
.C40_GETPOS( SfxViewFrame
, pThis
) == USHRT_MAX
;
835 GetBindings().Invalidate( SID_RELOAD
);
836 pImp
->bReloading
= sal_False
;
839 // neues Doc in die bestehenden SfxMDIFrames einsetzen; wenn
840 // das Reload geklappt hat, mu\s in diesem Frame kein Dokument
841 // eingesetzt werden, weil das schon vom LoadEnvironment
843 if ( xNewObj
.Is() && xNewObj
->Type() != aOldType
)
844 // RestoreView nur, wenn gleicher Dokumenttyp
845 bRestoreView
= sal_False
;
847 const sal_uInt16 nCount
= aFrames
.Count();
848 for(sal_uInt16 i
= 0; i
< nCount
; ++i
)
850 SfxViewFrame
*pCurrView
= aFrames
.GetObject( i
);
853 //if( /*!bHandsOff &&*/ this != pView )
854 pCurrView
->ReleaseObjectShell_Impl( bRestoreView
);
855 pCurrView
->SetRestoreView_Impl( bRestoreView
);
856 //if( pView != this || !xNewObj.Is() )
858 SfxFrame
*pFrame
= pCurrView
->GetFrame();
859 pFrame
->InsertDocument(xNewObj
.Is() ? xNewObj
: xOldObj
);
863 pCurrView
->GetBindings().LEAVEREGISTRATIONS();
864 pCurrView
->GetDispatcher()->LockUI_Impl( sal_False
);
869 // Propagate document closure.
870 SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC
, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC
), xOldObj
) );
873 // als erledigt recorden
874 rReq
.Done( sal_True
);
875 rReq
.SetReturnValue(SfxBoolItem(rReq
.GetSlot(), sal_True
));
878 Notify( *GetObjectShell(), SfxSimpleHint(
879 SFX_HINT_TITLECHANGED
));
885 // als nicht erledigt recorden
887 rReq
.SetReturnValue(SfxBoolItem(rReq
.GetSlot(), sal_False
));
888 pImp
->bReloading
= sal_False
;
895 //-------------------------------------------------------------------------
896 void SfxViewFrame::StateReload_Impl( SfxItemSet
& rSet
)
898 SfxObjectShell
* pSh
= GetObjectShell();
900 // Ich bin gerade am Reloaden und Yielde so vor mich hin ...
903 GetFrame()->GetParentFrame();
904 SfxWhichIter
aIter( rSet
);
905 for ( sal_uInt16 nWhich
= aIter
.FirstWhich(); nWhich
; nWhich
= aIter
.NextWhich() )
907 if ( GetFrame()->HasComponent() )
909 // Wenn die Komponente es nicht selbst dispatched, dann
910 // macht es auch keinen Sinn!
911 rSet
.DisableItem( nWhich
);
919 if ( !pSh
|| !pSh
->HasName() || !( pSh
->Get_Impl()->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
)
920 || pSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
921 rSet
.DisableItem( SID_EDITDOC
);
924 SFX_ITEMSET_ARG( pSh
->GetMedium()->GetItemSet(), pItem
, SfxBoolItem
, SID_EDITDOC
, sal_False
);
925 if ( pItem
&& !pItem
->GetValue() )
926 rSet
.DisableItem( SID_EDITDOC
);
928 rSet
.Put( SfxBoolItem( nWhich
, !pSh
->IsReadOnly() ) );
935 SfxFrame
* pFrame
= GetTopFrame();
936 SfxViewFrame
*pView
= pFrame
->GetCurrentViewFrame();
937 if ( pView
&& pView
->GetViewShell() &&
938 pView
->GetViewShell()->IsImplementedAsFrameset_Impl() &&
939 pView
->GetViewShell()->GetInterface()->GetSlot( nWhich
) )
941 // Hack f"ur Explorer: Reload wird an der ViewShell ausgef"uhrt
942 pView
->GetViewShell()->GetSlotState( nWhich
, 0, &rSet
);
946 if ( !pSh
|| !pSh
->CanReload_Impl() || pSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
947 rSet
.DisableItem(nWhich
);
950 // Wenn irgendein ChildFrame reloadable ist, wird der Slot
951 // enabled, damit man CTRL-Reload machen kann
952 sal_Bool bReloadAvailable
= sal_False
;
953 SfxFrameIterator
aFrameIter( *pFrame
, sal_True
);
954 for( SfxFrame
* pNextFrame
= aFrameIter
.FirstFrame();
956 pNextFrame
= pNextFrame
?
957 aFrameIter
.NextFrame( *pNextFrame
) : 0 )
959 SfxObjectShell
*pShell
= pFrame
->GetCurrentDocument();
960 if( pShell
&& pShell
->Get_Impl()->bReloadAvailable
)
962 bReloadAvailable
= sal_True
;
968 rSet
.Put( SfxBoolItem( nWhich
, bReloadAvailable
));
978 //--------------------------------------------------------------------
979 void SfxViewFrame::ExecHistory_Impl( SfxRequest
&rReq
)
981 // gibt es an der obersten Shell einen Undo-Manager?
982 SfxShell
*pSh
= GetDispatcher()->GetShell(0);
983 SfxUndoManager
* pShUndoMgr
= pSh
->GetUndoManager();
984 sal_Bool bOK
= sal_False
;
987 switch ( rReq
.GetSlot() )
989 case SID_CLEARHISTORY
:
996 GetBindings().InvalidateAll(sal_False
);
1001 pShUndoMgr
->Redo(0);
1002 GetBindings().InvalidateAll(sal_False
);
1007 if ( pSh
->GetRepeatTarget() )
1008 pShUndoMgr
->Repeat( *pSh
->GetRepeatTarget(), 0);
1013 else if ( GetViewShell() )
1015 // der SW hat eigenes Undo an der ::com::sun::star::sdbcx::View
1016 const SfxPoolItem
*pRet
= GetViewShell()->ExecuteSlot( rReq
);
1018 bOK
= ((SfxBoolItem
*)pRet
)->GetValue();
1021 rReq
.SetReturnValue( SfxBoolItem( rReq
.GetSlot(), bOK
) );
1025 //--------------------------------------------------------------------
1026 void SfxViewFrame::StateHistory_Impl( SfxItemSet
&rSet
)
1028 // Undo-Manager suchen
1029 SfxShell
*pSh
= GetDispatcher()->GetShell(0);
1031 // Ich bin gerade am Reloaden und Yielde so vor mich hin ...
1034 SfxUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
1037 // der SW hat eigenes Undo an der ::com::sun::star::sdbcx::View
1038 SfxWhichIter
aIter( rSet
);
1039 SfxViewShell
*pViewSh
= GetViewShell();
1040 if( !pViewSh
) return;
1041 for ( sal_uInt16 nSID
= aIter
.FirstWhich(); nSID
; nSID
= aIter
.NextWhich() )
1042 pViewSh
->GetSlotState( nSID
, 0, &rSet
);
1046 if ( pShUndoMgr
->GetUndoActionCount() == 0 &&
1047 pShUndoMgr
->GetRedoActionCount() == 0 &&
1048 pShUndoMgr
->GetRepeatActionCount() == 0 )
1049 rSet
.DisableItem( SID_CLEARHISTORY
);
1051 if ( pShUndoMgr
&& pShUndoMgr
->GetUndoActionCount() )
1053 String
aTmp( SfxResId( STR_UNDO
) );
1054 aTmp
+= pShUndoMgr
->GetUndoActionComment(0);
1055 rSet
.Put( SfxStringItem( SID_UNDO
, aTmp
) );
1058 rSet
.DisableItem( SID_UNDO
);
1060 if ( pShUndoMgr
&& pShUndoMgr
->GetRedoActionCount() )
1062 String
aTmp( SfxResId(STR_REDO
) );
1063 aTmp
+= pShUndoMgr
->GetRedoActionComment(0);
1064 rSet
.Put( SfxStringItem( SID_REDO
, aTmp
) );
1067 rSet
.DisableItem( SID_REDO
);
1068 SfxRepeatTarget
*pTarget
= pSh
->GetRepeatTarget();
1069 if ( pShUndoMgr
&& pTarget
&& pShUndoMgr
->GetRepeatActionCount() &&
1070 pShUndoMgr
->CanRepeat(*pTarget
, 0) )
1072 String
aTmp( SfxResId(STR_REPEAT
) );
1073 aTmp
+= pShUndoMgr
->GetRepeatActionComment(*pTarget
, 0);
1074 rSet
.Put( SfxStringItem( SID_REPEAT
, aTmp
) );
1077 rSet
.DisableItem( SID_REPEAT
);
1080 //--------------------------------------------------------------------
1081 void SfxViewFrame::SetObjectShell_Impl
1083 SfxObjectShell
& rObjSh
, // eine initialisierte SfxObjectShell,
1084 FASTBOOL bDefaultView
// sal_True: nicht restaurieren
1089 Diese Methode setzt eine <SfxObjectShell> in den SfxViewFrame ein.
1091 Zuvor mu\s die vorherige SfxObjectShell, insofern schein eine gesetzt
1092 wurde, mit der Methode ReleaseObjectShell() entfernt worden sein. Somit
1093 kann durch Aufruf von ReleaseObjectShell() und SetObjectShell() die
1094 SfxObjectShell ausgetauscht werden.
1099 <SfxViewFrame::ReleaseObjectShell()>
1103 DBG_CHKTHIS(SfxViewFrame
, 0);
1104 DBG_ASSERT( !xObjSh
.Is(), "old feature used: only one Object per View!" );
1106 GetFrame()->ReleasingComponent_Impl( sal_False
);
1110 if ( xObjSh
.Is() && xObjSh
->IsPreview() )
1111 SetQuietMode_Impl( sal_True
);
1113 GetFrame()->SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET
);
1115 // Modulshell einf"ugen
1116 SfxModule
* pModule
= xObjSh
->GetModule();
1118 pDispatcher
->InsertShell_Impl( *pModule
, 1 );
1120 pDispatcher
->Push( rObjSh
);
1121 pDispatcher
->Flush();
1122 StartListening( rObjSh
);
1124 rObjSh
.ViewAssigned();
1125 pDispatcher
->SetReadOnly_Impl( rObjSh
.IsReadOnly() );
1127 const SfxMedium
*pMedium
= GetObjectShell()->GetMedium();
1129 pMedium
->GetItemSet(), pHiddenItem
, SfxBoolItem
, SID_HIDDEN
, sal_False
);
1130 if ( !pHiddenItem
|| !pHiddenItem
->GetValue() )
1132 LockObjectShell_Impl(sal_True
);
1133 GetDocNumber_Impl();
1136 // ::com::sun::star::sdbcx::View erzeugen
1138 SetRestoreView_Impl( sal_False
);
1140 // So darf man es nicht machen, da LaodWindows hierueber laeuft. Kann meiner Meinung nach
1141 // auch nur beim Reload mit Dokumenttypwechsel passieren.
1142 /* if ( xObjSh->Type() != pImp->aLastType )
1143 SetRestoreView_Impl( sal_False ); */
1145 SwitchToViewShell_Impl( !IsRestoreView_Impl() ? (sal_uInt16
) 0 : GetCurViewId() );
1146 rObjSh
.PostActivateEvent_Impl( this );
1147 if ( Current() == this )
1148 SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC
, GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC
), &rObjSh
) );
1150 Notify( rObjSh
, SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
1151 Notify( rObjSh
, SfxSimpleHint(SFX_HINT_DOCCHANGED
) );
1153 // Zur Sicherheit, aber eigentlich sollte jetzt nichts mehr passieren
1154 // ( kein erzwungenes Update )
1155 if ( SfxViewFrame::Current() == this )
1156 GetDispatcher()->Update_Impl();
1159 //--------------------------------------------------------------------
1160 void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView
)
1164 Diese Methode entleert den SfxViewFrame, d.h. nimmt die <SfxObjectShell>
1165 vom Dispatcher und beendet seine <SfxListener>-Beziehung zu dieser
1166 SfxObjectShell (wodurch sie sich ggf. selbst zerst"ort).
1168 Somit kann durch Aufruf von ReleaseObjectShell() und SetObjectShell()
1169 die SfxObjectShell ausgetauscht werden.
1171 Zwischen RealeaseObjectShell() und SetObjectShell() darf die Kontrolle
1172 nicht an das ::com::sun::star::chaos::System abgegeben werden.
1177 <SfxViewFrame::SetObjectShell(SfxObjectShell&)>
1180 DBG_CHKTHIS(SfxViewFrame
, 0);
1181 DBG_ASSERT( xObjSh
.Is(), "no SfxObjectShell to release!" );
1183 GetFrame()->ReleasingComponent_Impl( sal_True
);
1184 if ( GetWindow().HasChildPathFocus( sal_True
) )
1186 DBG_ASSERT( !GetActiveChildFrame_Impl(), "Wrong active child frame!" );
1187 GetWindow().GrabFocus();
1190 SfxViewShell
*pDyingViewSh
= GetViewShell();
1193 SetRestoreView_Impl( bStoreView
);
1195 pDyingViewSh
->WriteUserData( GetViewData_Impl(), sal_True
);
1197 // Jetzt alle SubShells wechhauen
1198 pDyingViewSh
->PushSubShells_Impl( sal_False
);
1199 sal_uInt16 nLevel
= pDispatcher
->GetShellLevel( *pDyingViewSh
);
1200 if ( nLevel
&& nLevel
!= USHRT_MAX
)
1202 // Es gibt immer nocht SubShells
1203 SfxShell
*pSubShell
= pDispatcher
->GetShell( nLevel
-1 );
1204 if ( pSubShell
== pDyingViewSh
->GetSubShell() )
1205 //"Echte" Subshells nicht deleten
1206 pDispatcher
->Pop( *pSubShell
, SFX_SHELL_POP_UNTIL
);
1208 pDispatcher
->Pop( *pSubShell
, SFX_SHELL_POP_UNTIL
| SFX_SHELL_POP_DELETE
);
1210 pDispatcher
->Pop( *pDyingViewSh
);
1211 pDispatcher
->Flush();
1212 pDyingViewSh
->DisconnectAllClients();
1213 SetViewShell_Impl(0);
1214 delete pDyingViewSh
;
1218 DBG_ERROR("Keine Shell");
1223 pImp
->aLastType
= xObjSh
->Type();
1224 pDispatcher
->Pop( *xObjSh
);
1225 SfxModule
* pModule
= xObjSh
->GetModule();
1227 pDispatcher
->RemoveShell_Impl( *pModule
);
1228 pDispatcher
->Flush();
1229 EndListening( *xObjSh
);
1231 Notify( *xObjSh
, SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
1232 Notify( *xObjSh
, SfxSimpleHint(SFX_HINT_DOCCHANGED
) );
1234 if ( 1 == xObjSh
->GetOwnerLockCount() && pImp
->bObjLocked
&& xObjSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
1236 SfxObjectShellRef xDyingObjSh
= xObjSh
;
1238 if( ( GetFrameType() & SFXFRAME_HASTITLE
) && pImp
->nDocViewNo
)
1239 xDyingObjSh
->GetNoSet_Impl().ReleaseIndex(pImp
->nDocViewNo
-1);
1240 if ( pImp
->bObjLocked
)
1242 xDyingObjSh
->OwnerLock( sal_False
);
1243 pImp
->bObjLocked
= sal_False
;
1247 GetDispatcher()->SetDisableFlags( 0 );
1250 //-------------------------------------------------------------------------
1252 String
SfxViewFrame::UpdateTitle()
1256 Mit dieser Methode kann der SfxMDIFrame gezwungen werden, sich sofort
1257 den neuen Titel vom der <SfxObjectShell> zu besorgen.
1261 Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener
1262 zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren
1263 m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxMDIFrames)
1264 jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung
1265 nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden.
1270 void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1272 if ( rHint.IsA(TYPE(SfxSimpleHint)) )
1274 switch( ( (SfxSimpleHint&) rHint ).GetId() )
1276 case SFX_HINT_TITLECHANGED:
1277 for ( SfxMDIFrame *pMDI = (SfxMDIFrame*)
1278 SfxViewFrame::GetFirst(this, TYPE(SfxMDIFrame));
1280 pMDI = (SfxMDIFrame*)
1281 SfxViewFrame::GetNext(this, TYPE(SfxMDIFrame));
1283 pMDI->UpdateTitle();
1284 ... pMDI->GetName() ...
1294 SfxObjectShell
*pObjSh
= GetObjectShell();
1298 // if ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1299 // // kein UpdateTitle mit Embedded-ObjectShell
1302 const SfxMedium
*pMedium
= pObjSh
->GetMedium();
1304 GetFrame(); // -Wall required??
1305 if ( pObjSh
->HasName() )
1307 INetURLObject
aTmp( pMedium
->GetName() );
1308 aURL
= aTmp
.getName( INetURLObject::LAST_SEGMENT
, true, INetURLObject::DECODE_WITH_CHARSET
);
1311 if ( aURL
!= pImp
->aActualURL
)
1312 // URL hat sich ge"andert
1313 pImp
->aActualURL
= aURL
;
1315 // gibt es noch eine weitere View?
1316 sal_uInt16 nViews
=0;
1317 for ( SfxViewFrame
*pView
= GetFirst(pObjSh
);
1319 pView
= GetNext(*pView
,pObjSh
) )
1320 if ( ( pView
->GetFrameType() & SFXFRAME_HASTITLE
) &&
1324 // Titel des Fensters
1326 if ( nViews
== 2 || pImp
->nDocViewNo
> 1 )
1327 // dann die Nummer dranh"angen
1328 aTitle
= pObjSh
->UpdateTitle( NULL
, pImp
->nDocViewNo
);
1330 aTitle
= pObjSh
->UpdateTitle();
1332 // Name des SbxObjects
1333 String aSbxName
= pObjSh
->SfxShell::GetName();
1334 if ( IsVisible_Impl() )
1337 aSbxName
+= String::CreateFromInt32(pImp
->nDocViewNo
);
1340 SetName( aSbxName
);
1341 pImp
->aFrameTitle
= aTitle
;
1342 GetBindings().Invalidate( SID_FRAMETITLE
);
1343 GetBindings().Invalidate( SID_CURRENT_URL
);
1348 //--------------------------------------------------------------------
1349 sal_Bool
SfxViewFrame::Close()
1351 DBG_CHKTHIS(SfxViewFrame
, 0);
1353 DBG_ASSERT( GetFrame()->IsClosing_Impl() || !GetFrame()->GetFrameInterface().is(), "ViewFrame closed too early!" );
1355 // Wenn bis jetzt noch nicht gespeichert wurde, sollen eingebettete Objekte
1356 // auch nicht mehr automatisch gespeichert werden!
1357 if ( GetViewShell() )
1358 GetViewShell()->DiscardClients_Impl();
1359 Broadcast( SfxSimpleHint(SFX_HINT_DYING
) );
1364 //--------------------------------------------------------------------
1366 void SfxViewFrame::DoActivate( sal_Bool bUI
, SfxViewFrame
* pOldFrame
)
1368 DBG_CHKTHIS(SfxViewFrame
, 0);
1372 pSfxApp
->TestFreeResources_Impl();
1375 pDispatcher
->DoActivate_Impl( bUI
, pOldFrame
);
1377 // Wenn ich einen parent habe und dieser ist kein parent des alten
1378 // ViewFrames, erh"alt er ein ParentActivate
1382 SfxMedium* pMed = GetObjectShell() ? GetObjectShell()->GetMedium() : NULL;
1386 pMed->GetItemSet(), pInterceptorItem, SfxSlotInterceptorItem,
1387 SID_INTERCEPTOR, sal_False );
1388 if( pInterceptorItem )
1390 SfxSlotInterceptor* pInter = pInterceptorItem->GetValue();
1391 if( !pInter->GetBindings() )
1392 pInter->SetBindings( &GetBindings() );
1393 pInter->Activate( sal_True );
1397 SfxViewFrame
*pFrame
= GetParentViewFrame();
1400 if ( !pOldFrame
|| !pOldFrame
->GetFrame()->IsParent( pFrame
->GetFrame() ) )
1401 pFrame
->pDispatcher
->DoParentActivate_Impl();
1402 pFrame
= pFrame
->GetParentViewFrame();
1407 //--------------------------------------------------------------------
1408 void SfxViewFrame::DoDeactivate(sal_Bool bUI
, SfxViewFrame
* pNewFrame
)
1410 DBG_CHKTHIS(SfxViewFrame
, 0);
1412 pDispatcher
->DoDeactivate_Impl( bUI
, pNewFrame
);
1414 // Wenn ich einen parent habe und dieser ist kein parent des neuen
1415 // ViewFrames, erh"alt er ein ParentDeactivate
1418 // if ( GetFrame()->GetWorkWindow_Impl() )
1419 // GetFrame()->GetWorkWindow_Impl()->SaveStatus_Impl();
1421 SfxMedium* pMed = GetObjectShell() ? GetObjectShell()->GetMedium() : NULL;
1425 pMed->GetItemSet(), pInterceptorItem, SfxSlotInterceptorItem,
1426 SID_INTERCEPTOR, sal_False );
1427 if( pInterceptorItem )
1428 pInterceptorItem->GetValue()->Activate( sal_False );
1431 SfxViewFrame
*pFrame
= GetParentViewFrame();
1434 if ( !pNewFrame
|| !pNewFrame
->GetFrame()->IsParent( pFrame
->GetFrame() ) )
1435 pFrame
->pDispatcher
->DoParentDeactivate_Impl();
1436 pFrame
= pFrame
->GetParentViewFrame();
1440 pSfxApp
->TestFreeResources_Impl();
1444 //------------------------------------------------------------------------
1445 void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell
* pSh
)
1447 if( pSh
&& !nAdjustPosPixelLock
)
1449 if ( GetViewShell() && GetWindow().IsVisible() )
1451 if ( GetFrame()->IsInPlace() )
1454 Size aSize( GetViewShell()->GetWindow()->GetSizePixel() );
1456 //Size aBorderSz( pEnv->GetBorderWin()->GetHatchBorderPixel() );
1457 Point aOfs; //( aBorderSz.Width(), aBorderSz.Height() );
1459 DoAdjustPosSizePixel( GetViewShell(), aOfs, aSize );*/
1463 if ( GetViewShell()->UseObjectSize() )
1465 // Zun"achst die Gr"o\se des MDI-Fensters berechnen
1467 DoAdjustPosSizePixel( GetViewShell(), Point(),
1468 GetViewShell()->GetWindow()->GetSizePixel() );
1470 // Da nach einem InnerResize die Position des EditFensters und
1471 // damit auch der Tools nocht stimmt, mu\s nun noch einmal von
1472 // au\sen resized werden !
1474 ForceOuterResize_Impl(sal_True
);
1477 DoAdjustPosSizePixel( (SfxViewShell
*) GetViewShell(), Point(),
1478 GetWindow().GetOutputSizePixel() );
1479 if ( GetViewShell()->UseObjectSize() )
1480 ForceOuterResize_Impl(sal_False
);
1485 //------------------------------------------------------------------------
1486 sal_Bool
SfxViewFrame::SetBorderPixelImpl
1488 const SfxViewShell
* /*pSh*/,
1489 const SvBorder
& rBorder
1493 pImp
->aBorder
= rBorder
;
1497 //------------------------------------------------------------------------
1498 const SvBorder
& SfxViewFrame::GetBorderPixelImpl
1500 const SfxViewShell
* /*pSh*/
1504 return pImp
->aBorder
;
1507 //--------------------------------------------------------------------
1508 void SfxViewFrame::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
1510 {DBG_CHKTHIS(SfxViewFrame
, 0);}
1514 if ( rHint
.IsA(TYPE(SfxSimpleHint
)) )
1516 switch( ( (SfxSimpleHint
&) rHint
).GetId() )
1518 case SFX_HINT_MODECHANGED
:
1521 SfxBindings
& rBind
= GetBindings();
1522 rBind
.Invalidate( SID_RELOAD
);
1523 SfxDispatcher
*pDispat
= GetDispatcher();
1524 sal_Bool bWasReadOnly
= pDispat
->GetReadOnly_Impl();
1525 sal_Bool bIsReadOnly
= xObjSh
->IsReadOnly();
1526 if ( !bWasReadOnly
!= !bIsReadOnly
)
1528 // Dann auch TITLE_CHANGED
1530 rBind
.Invalidate( SID_FILE_NAME
);
1531 rBind
.Invalidate( SID_DOCINFO_TITLE
);
1532 rBind
.Invalidate( SID_EDITDOC
);
1534 pDispat
->GetBindings()->InvalidateAll(sal_True
);
1535 pDispat
->SetReadOnly_Impl( bIsReadOnly
);
1537 // Dispatcher-Update nur erzwingen, wenn es nicht sowieso
1538 // demn"achst kommt, anderenfalls ist Zappelei oder gar
1539 // GPF m"oglich, da Writer z.B. gerne mal im Resize irgendwelche
1540 // Aktionen t"atigt, die ein SetReadOnlyUI am Dispatcher zur
1542 if ( pDispat
->IsUpdated_Impl() )
1543 pDispat
->Update_Impl(sal_True
);
1546 Enable( !xObjSh
->IsInModalMode() );
1550 case SFX_HINT_TITLECHANGED
:
1553 SfxBindings
& rBind
= GetBindings();
1554 rBind
.Invalidate( SID_FILE_NAME
);
1555 rBind
.Invalidate( SID_DOCINFO_TITLE
);
1556 rBind
.Invalidate( SID_EDITDOC
);
1557 rBind
.Invalidate( SID_RELOAD
);
1561 case SFX_HINT_DYING
:
1562 case SFX_HINT_DEINITIALIZING
:
1563 // when the Object is being deleted, destroy the view too
1565 ReleaseObjectShell_Impl();
1567 GetFrame()->DoClose();
1572 else if ( rHint
.IsA(TYPE(SfxEventHint
)) )
1574 // Wenn das Document asynchron geladen wurde, wurde der Dispatcher
1575 // auf ReadOnly gesetzt, was zur"?ckgenommen werden mu\s, wenn
1576 // das Document selbst nicht ReadOnly ist und das Laden fertig ist.
1577 switch ( ((SfxEventHint
&)rHint
).GetEventId() )
1579 case SFX_EVENT_MODIFYCHANGED
:
1581 SfxBindings
& rBind
= GetBindings();
1582 rBind
.Invalidate( SID_DOC_MODIFIED
);
1583 rBind
.Invalidate( SID_SAVEDOC
);
1584 rBind
.Invalidate( SID_RELOAD
);
1585 rBind
.Invalidate( SID_EDITDOC
);
1589 case SFX_EVENT_OPENDOC
:
1590 case SFX_EVENT_CREATEDOC
:
1592 SfxBindings
& rBind
= GetBindings();
1593 rBind
.Invalidate( SID_RELOAD
);
1594 rBind
.Invalidate( SID_EDITDOC
);
1595 if ( !xObjSh
->IsReadOnly() )
1597 // Im Gegensatz zu oben (TITLE_CHANGED) mu\s das UI nicht
1598 // upgedated werden, da es nicht gehidet war!
1600 // #i21560# InvalidateAll() causes the assertion
1601 // 'SfxBindings::Invalidate while in update" when
1602 // the sfx slot SID_BASICIDE_APPEAR is executed
1603 // via API from another thread (Java).
1604 // According to MBA this call is not necessary anymore,
1605 // because each document has its own SfxBindings.
1607 //GetDispatcher()->GetBindings()->InvalidateAll(sal_True);
1613 case SFX_EVENT_TOGGLEFULLSCREENMODE
:
1615 if ( GetFrame()->OwnsBindings_Impl() )
1616 GetBindings().GetDispatcher_Impl()->Update_Impl( sal_True
);
1623 //------------------------------------------------------------------------
1624 void SfxViewFrame::Construct_Impl( SfxObjectShell
*pObjSh
)
1626 pImp
->pFrame
->DocumentInserted( pObjSh
);
1627 pImp
->bInCtor
= sal_True
;
1628 pImp
->pParentViewFrame
= 0;
1629 pImp
->bResizeInToOut
= sal_True
;
1630 pImp
->bDontOverwriteResizeInToOut
= sal_False
;
1631 pImp
->pImportShell
= 0;
1632 pImp
->bObjLocked
= sal_False
;
1633 pImp
->bEventFlag
= sal_True
;
1634 pImp
->pFocusWin
= 0;
1635 pImp
->pActiveChild
= NULL
;
1636 pImp
->bRestoreView
= sal_False
;
1637 pImp
->nCurViewId
= 0;
1638 pImp
->bSetViewFrameLocked
= sal_False
;
1639 pImp
->bReloading
= sal_False
;
1640 pImp
->bIsDowning
= sal_False
;
1641 pImp
->bModal
= sal_False
;
1642 pImp
->bEnabled
= sal_True
;
1643 pImp
->nDocViewNo
= 0;
1644 pImp
->aMargin
= Size( -1, -1 );
1645 pImp
->pCancelMgr
= 0;
1648 SetPool( &SFX_APP()->GetPool() );
1649 pDispatcher
= new SfxDispatcher(this);
1650 if ( !GetBindings().GetDispatcher() )
1651 GetBindings().SetDispatcher( pDispatcher
);
1654 if ( xObjSh
.Is() && xObjSh
->IsPreview() )
1655 SetQuietMode_Impl( sal_True
);
1657 GetFrame()->SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET
);
1660 pDispatcher
->Push( *SFX_APP() );
1661 SfxModule
* pModule
= xObjSh
->GetModule();
1663 pDispatcher
->Push( *pModule
);
1664 pDispatcher
->Push( *this );
1665 pDispatcher
->Push( *pObjSh
);
1666 pDispatcher
->Flush();
1667 StartListening( *pObjSh
);
1668 pObjSh
->ViewAssigned();
1669 Notify( *pObjSh
, SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
1670 Notify( *pObjSh
, SfxSimpleHint(SFX_HINT_DOCCHANGED
) );
1671 pDispatcher
->SetReadOnly_Impl( pObjSh
->IsReadOnly() );
1675 pDispatcher
->Push( *SFX_APP() );
1676 pDispatcher
->Push( *this );
1677 pDispatcher
->Flush();
1680 SfxViewFrame
*pThis
= this; // wegen der kranken Array-Syntax
1681 SfxViewFrameArr_Impl
&rViewArr
= SFX_APP()->GetViewFrames_Impl();
1682 rViewArr
.C40_INSERT(SfxViewFrame
, pThis
, rViewArr
.Count() );
1683 pImp
->bInCtor
= sal_False
;
1686 //------------------------------------------------------------------------
1687 SfxViewFrame::SfxViewFrame( SfxObjectShell
&rObjShell
, SfxBindings
&rBindings
,
1688 SfxFrame
* pParent
, sal_uInt32 nType
)
1690 pImp( new SfxViewFrame_Impl
),
1692 pBindings(&rBindings
),
1693 nAdjustPosPixelLock( 0 )
1695 DBG_CTOR(SfxViewFrame
, 0);
1697 SetFrame_Impl( pParent
);
1698 pImp
->pFrame
->SetCurrentViewFrame_Impl( this );
1699 GetFrame()->SetFrameType_Impl( GetFrameType() | nType
);
1700 Construct_Impl( &rObjShell
);
1703 //------------------------------------------------------------------------
1704 SfxViewFrame::SfxViewFrame(const SfxViewFrame
&rCopy
, SfxBindings
&rBindings
,
1707 pImp( new SfxViewFrame_Impl
),
1709 pBindings(&rBindings
),
1710 nAdjustPosPixelLock( 0 )
1712 DBG_CTOR(SfxViewFrame
, 0);
1714 SetFrame_Impl( pFrame
);
1715 pImp
->pFrame
->SetCurrentViewFrame_Impl( this );
1716 GetFrame()->SetFrameType_Impl( rCopy
.GetFrameType() );
1717 Construct_Impl( rCopy
.GetObjectShell() );
1720 SfxViewFrame::SfxViewFrame( SfxBindings
& rBindings
, SfxFrame
*pFrame
,
1721 SfxObjectShell
*pDoc
, sal_uInt32 nType
)
1722 : pImp( new SfxViewFrame_Impl
)
1724 , pBindings(&rBindings
)
1725 , nAdjustPosPixelLock( 0 )
1727 DBG_CTOR(SfxViewFrame
, 0);
1729 SetFrame_Impl( pFrame
);
1730 pImp
->pFrame
->SetCurrentViewFrame_Impl( this );
1731 GetFrame()->SetFrameType_Impl( GetFrameType() | nType
);
1732 Construct_Impl( pDoc
);
1735 //------------------------------------------------------------------------
1736 SfxViewFrame::~SfxViewFrame()
1738 DBG_DTOR(SfxViewFrame
, 0);
1740 if ( GetFrame() && GetFrame()->GetCurrentViewFrame() == this )
1741 GetFrame()->SetCurrentViewFrame_Impl( NULL
);
1743 SfxObjectShell
* pSh
= pImp
->pImportShell
;
1747 // von Frame-Liste abmelden
1748 SfxApplication
*pSfxApp
= SFX_APP();
1749 SfxViewFrameArr_Impl
&rFrames
= pSfxApp
->GetViewFrames_Impl();
1750 const SfxViewFrame
*pThis
= this;
1751 rFrames
.Remove( rFrames
.GetPos(pThis
) );
1754 KillDispatcher_Impl();
1759 //------------------------------------------------------------------------
1760 void SfxViewFrame::KillDispatcher_Impl()
1762 // Dispatcher abr"aumen und l"oschen
1765 DBG_CHKTHIS(SfxViewFrame
, 0);
1767 SfxModule
* pModule
= xObjSh
.Is() ? xObjSh
->GetModule() : 0;
1769 ReleaseObjectShell_Impl();
1773 pDispatcher
->Pop( *pModule
, SFX_SHELL_POP_UNTIL
);
1775 pDispatcher
->Pop( *this );
1776 DELETEZ(pDispatcher
);
1780 //------------------------------------------------------------------------
1781 SfxViewFrame
* SfxViewFrame::Current()
1783 return SfxApplication::Is_Impl() ? SFX_APP()->Get_Impl()->pViewFrame
: NULL
;
1786 //--------------------------------------------------------------------
1787 sal_uInt16
SfxViewFrame::Count(TypeId aType
)
1791 Liefert die Anzahl der sichtbaren <SfxViewFrame>-Instanzen vom Typ
1792 'aType' bzw. aller sichtbaren, falls 'aType==0' (default).
1796 SfxApplication
*pSfxApp
= SFX_APP();
1797 SfxViewFrameArr_Impl
& rFrames
= pSfxApp
->GetViewFrames_Impl();
1798 const sal_uInt16 nCount
= rFrames
.Count();
1799 sal_uInt16 nFound
= 0;
1800 for ( sal_uInt16 i
= 0; i
< nCount
; ++i
)
1802 SfxViewFrame
*pFrame
= rFrames
[i
];
1803 if ( ( !aType
|| pFrame
->IsA(aType
) ) &&
1804 pFrame
->IsVisible_Impl() )
1810 //--------------------------------------------------------------------
1811 // returns the first window of spec. type viewing the specified doc.
1812 SfxViewFrame
* SfxViewFrame::GetFirst
1814 const SfxObjectShell
* pDoc
,
1816 sal_Bool bOnlyIfVisible
1819 SfxApplication
*pSfxApp
= SFX_APP();
1820 SfxViewFrameArr_Impl
&rFrames
= pSfxApp
->GetViewFrames_Impl();
1822 // search for a SfxDocument of the specified type
1823 for ( sal_uInt16 nPos
= 0; nPos
< rFrames
.Count(); ++nPos
)
1825 SfxViewFrame
*pFrame
= rFrames
.GetObject(nPos
);
1826 if ( ( !pDoc
|| pDoc
== pFrame
->GetObjectShell() ) &&
1827 ( !aType
|| pFrame
->IsA(aType
) ) &&
1828 ( !bOnlyIfVisible
|| pFrame
->IsVisible_Impl()) )
1834 //--------------------------------------------------------------------
1836 // returns thenext window of spec. type viewing the specified doc.
1837 SfxViewFrame
* SfxViewFrame::GetNext
1839 const SfxViewFrame
& rPrev
,
1840 const SfxObjectShell
* pDoc
,
1842 sal_Bool bOnlyIfVisible
1845 SfxApplication
*pSfxApp
= SFX_APP();
1846 SfxViewFrameArr_Impl
&rFrames
= pSfxApp
->GetViewFrames_Impl();
1848 // refind the specified predecessor
1850 for ( nPos
= 0; nPos
< rFrames
.Count(); ++nPos
)
1851 if ( rFrames
.GetObject(nPos
) == &rPrev
)
1854 // search for a Frame of the specified type
1855 for ( ++nPos
; nPos
< rFrames
.Count(); ++nPos
)
1857 SfxViewFrame
*pFrame
= rFrames
.GetObject(nPos
);
1858 if ( ( !pDoc
|| pDoc
== pFrame
->GetObjectShell() ) &&
1859 ( !aType
|| pFrame
->IsA(aType
) ) &&
1860 ( !bOnlyIfVisible
|| pFrame
->IsVisible_Impl()) )
1866 void SfxViewFrame::CloseHiddenFrames_Impl()
1868 SfxApplication
*pSfxApp
= SFX_APP();
1869 SfxViewFrameArr_Impl
&rFrames
= pSfxApp
->GetViewFrames_Impl();
1870 for ( sal_uInt16 nPos
=0; nPos
<rFrames
.Count(); )
1872 SfxViewFrame
*pFrame
= rFrames
.GetObject(nPos
);
1873 if ( !pFrame
->IsVisible_Impl() )
1880 //--------------------------------------------------------------------
1881 SfxProgress
* SfxViewFrame::GetProgress() const
1883 SfxObjectShell
*pObjSh
= GetObjectShell();
1884 return pObjSh
? pObjSh
->GetProgress() : 0;
1887 //--------------------------------------------------------------------
1888 void SfxViewFrame::ShowStatusText( const String
& /*rText*/)
1890 /* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx &
1891 framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be
1892 extended to support a new interface to support ShowStatusText/HideStatusText
1893 SfxWorkWindow* pWorkWin = GetFrame()->GetWorkWindow_Impl();
1894 SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl();
1897 pMgr->GetStatusBar()->HideItems();
1898 pMgr->GetStatusBar()->SetText( rText );
1903 //--------------------------------------------------------------------
1904 void SfxViewFrame::HideStatusText()
1906 /* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx &
1907 framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be
1908 extended to support a new interface to support ShowStatusText/HideStatusText
1909 SfxWorkWindow* pWorkWin = GetFrame()->GetWorkWindow_Impl();
1910 SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl();
1912 pMgr->GetStatusBar()->ShowItems();
1917 //--------------------------------------------------------------------
1918 #ifdef ENABLE_INIMANAGER//MUSTINI
1919 SfxIniManager
* SfxViewFrame::GetIniManager() const
1921 /* SfxIniManager *pIniMgr = GetObjectShell()
1922 ? GetObjectShell()->GetFactory().GetIniManager()
1924 if ( !pIniMgr )*/ //!
1925 return SFX_APP()->GetAppIniManager();
1930 //--------------------------------------------------------------------
1931 void SfxViewFrame::DoAdjustPosSizePixel
//! teilen in Inner.../Outer...
1938 DBG_CHKTHIS(SfxViewFrame
, 0);
1940 // Components benutzen diese Methode nicht!
1941 if( pSh
&& pSh
->GetWindow() && !nAdjustPosPixelLock
)
1943 nAdjustPosPixelLock
++;
1944 if ( pImp
->bResizeInToOut
)
1945 pSh
->InnerResizePixel( rPos
, rSize
);
1947 pSh
->OuterResizePixel( rPos
, rSize
);
1948 nAdjustPosPixelLock
--;
1952 //========================================================================
1954 int SfxViewFrameItem::operator==( const SfxPoolItem
&rItem
) const
1956 return PTR_CAST(SfxViewFrameItem
, &rItem
)->pFrame
== pFrame
;
1959 //--------------------------------------------------------------------
1960 String
SfxViewFrameItem::GetValueText() const
1965 //--------------------------------------------------------------------
1966 SfxPoolItem
* SfxViewFrameItem::Clone( SfxItemPool
*) const
1968 return new SfxViewFrameItem( pFrame
);
1971 //--------------------------------------------------------------------
1972 void SfxViewFrame::SetViewShell_Impl( SfxViewShell
*pVSh
)
1976 Interne Methode zum setzen der jeweils aktuellen <SfxViewShell>-Instanz,
1977 die in diesem SfxViewFrame aktiv ist.
1981 SfxShell::SetViewShell_Impl( pVSh
);
1983 // Hack: InPlaceMode
1984 if ( pVSh
&& !pVSh
->UseObjectSize() )
1985 pImp
->bResizeInToOut
= sal_False
;
1988 //--------------------------------------------------------------------
1991 Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace
1994 void SfxViewFrame::SetParentViewFrame_Impl(SfxViewFrame
*pFrame
)
1996 pImp
->pParentViewFrame
= pFrame
;
1999 //--------------------------------------------------------------------
2002 Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace
2005 //TODO/LATER: is it still necessary? is there a replacement for GetParentViewFrame_Impl?
2006 SfxViewFrame
* SfxViewFrame::GetParentViewFrame_Impl() const
2008 return pImp
->pParentViewFrame
;
2011 //--------------------------------------------------------------------
2012 void SfxViewFrame::ForceOuterResize_Impl(sal_Bool bOn
)
2014 if ( !pImp
->bDontOverwriteResizeInToOut
)
2015 pImp
->bResizeInToOut
= !bOn
;
2018 void SfxViewFrame::ForceInnerResize_Impl(sal_Bool bOn
)
2020 pImp
->bDontOverwriteResizeInToOut
= bOn
;
2023 //--------------------------------------------------------------------
2024 sal_Bool
SfxViewFrame::IsResizeInToOut_Impl() const
2026 return pImp
->bResizeInToOut
;
2028 //--------------------------------------------------------------------
2029 void SfxViewFrame::DoAdjustPosSize( SfxViewShell
*pSh
,
2030 const Point rPos
, const Size
&rSize
)
2032 DBG_CHKTHIS(SfxViewFrame
, 0);
2033 if( pSh
&& !nAdjustPosPixelLock
&& pSh
->UseObjectSize())
2035 Window
*pWindow
= pSh
->GetWindow();
2036 Point aPos
= pWindow
->LogicToPixel(rPos
);
2037 Size aSize
= pWindow
->LogicToPixel(rSize
);
2038 DoAdjustPosSizePixel(pSh
, aPos
, aSize
);
2042 //--------------------------------------------------------------------
2043 void SfxViewFrame::GetDocNumber_Impl()
2045 DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
2046 GetObjectShell()->SetNamedVisibility_Impl();
2047 pImp
->nDocViewNo
= GetObjectShell()->GetNoSet_Impl().GetFreeIndex()+1;
2050 //--------------------------------------------------------------------
2052 void SfxViewFrame::Enable( sal_Bool bEnable
)
2054 if ( bEnable
!= pImp
->bEnabled
)
2056 pImp
->bEnabled
= bEnable
;
2058 // e.g. InPlace-Frames have a parent...
2059 SfxViewFrame
*pParent
= GetParentViewFrame_Impl();
2062 pParent
->Enable( bEnable
);
2066 Window
*pWindow
= &GetFrame()->GetTopFrame()->GetWindow();
2068 pImp
->bWindowWasEnabled
= pWindow
->IsInputEnabled();
2069 if ( !bEnable
|| pImp
->bWindowWasEnabled
)
2070 pWindow
->EnableInput( bEnable
, TRUE
);
2074 SfxViewShell
* pViewSh
= GetViewShell();
2079 pViewSh
->ShowCursor();
2085 pViewSh
->ShowCursor(sal_False
);
2089 GetBindings().ENTERREGISTRATIONS();
2090 GetDispatcher()->Lock( !bEnable );
2092 GetBindings().LEAVEREGISTRATIONS();
2097 //--------------------------------------------------------------------
2098 void SfxViewFrame::Show()
2102 Diese Methode macht das Frame-Window sichtbar und ermittelt vorher
2103 den Fenstername. Au\serdem wird das Dokument festgehalten. Man darf
2104 i.d.R. nie das Window direkt showen!
2108 // zuerst locken damit in UpdateTitle() gilt: IsVisible() == sal_True (:#)
2111 xObjSh
->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN
);
2112 if ( !pImp
->bObjLocked
)
2113 LockObjectShell_Impl( sal_True
);
2115 // Doc-Shell Titel-Nummer anpassen, get unique view-no
2116 if ( 0 == pImp
->nDocViewNo
&& !(GetFrameType() & SFXFRAME_PLUGIN
) )
2118 GetDocNumber_Impl();
2125 // Frame-Window anzeigen, aber nur wenn der ViewFrame kein eigenes Window
2126 // hat oder wenn er keine Component enth"alt
2127 if ( &GetWindow() == &GetFrame()->GetWindow() || !GetFrame()->HasComponent() )
2129 GetFrame()->GetWindow().Show();
2131 /* SfxViewFrame* pCurrent = SfxViewFrame::Current();
2132 if ( GetFrame()->GetFrameInterface()->isActive() &&
2134 ( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) &&
2135 !GetActiveChildFrame_Impl() )
2136 MakeActive_Impl( FALSE );*/
2137 if ( xObjSh
.Is() && xObjSh
->Get_Impl()->bHiddenLockedByAPI
)
2139 xObjSh
->Get_Impl()->bHiddenLockedByAPI
= FALSE
;
2140 xObjSh
->OwnerLock(FALSE
);
2144 //--------------------------------------------------------------------
2145 sal_Bool
SfxViewFrame::IsVisible_Impl() const
2147 //Window *pWin = pImp->bInCtor ? 0 : &GetWindow();
2148 //return GetFrame()->HasComponent() || pImp->bObjLocked || ( pWin && pWin->IsVisible() );
2149 return pImp
->bObjLocked
;
2152 //--------------------------------------------------------------------
2153 void SfxViewFrame::Hide()
2156 if ( pImp
->bObjLocked
)
2157 LockObjectShell_Impl( sal_False
);
2160 //--------------------------------------------------------------------
2161 void SfxViewFrame::LockObjectShell_Impl( sal_Bool bLock
)
2163 DBG_ASSERT( pImp
->bObjLocked
!= bLock
, "Falscher Locked-Status!" );
2165 DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
2166 GetObjectShell()->OwnerLock(bLock
);
2167 pImp
->bObjLocked
= bLock
;
2170 //--------------------------------------------------------------------
2171 void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus
)
2173 if ( GetViewShell() && !GetFrame()->IsClosing_Impl() )
2175 if ( IsVisible_Impl() )
2177 if ( GetViewShell() )
2179 BOOL bPreview
= FALSE
;
2180 if ( GetObjectShell()->IsPreview() )
2186 SfxViewFrame
* pParent
= GetParentViewFrame();
2188 pParent
->SetActiveChildFrame_Impl( this );
2191 SfxViewFrame
* pCurrent
= SfxViewFrame::Current();
2192 css::uno::Reference
< css::frame::XFrame
> xFrame
= GetFrame()->GetFrameInterface();
2195 SetViewFrame( this );
2196 GetBindings().SetActiveFrame( css::uno::Reference
< css::frame::XFrame
>() );
2197 uno::Reference
< frame::XFramesSupplier
> xSupp( xFrame
, uno::UNO_QUERY
);
2199 xSupp
->setActiveFrame( uno::Reference
< frame::XFrame
>() );
2201 css::uno::Reference
< css::awt::XWindow
> xContainerWindow
= xFrame
->getContainerWindow();
2202 Window
* pWindow
= VCLUnoHelper::GetWindow(xContainerWindow
);
2203 if (pWindow
&& pWindow
->HasChildPathFocus() && bGrabFocus
)
2205 SfxInPlaceClient
*pCli
= GetViewShell()->GetUIActiveClient();
2206 if ( ( !pCli
|| !pCli
->IsObjectUIActive() ) &&
2207 ( !pCurrent
|| pCurrent
->GetParentViewFrame_Impl() != this ) )
2208 GetFrame()->GrabFocusOnComponent_Impl();
2213 GetBindings().SetDispatcher( GetDispatcher() );
2214 GetBindings().SetActiveFrame( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> () );
2215 GetDispatcher()->Update_Impl( FALSE
);
2222 //--------------------------------------------------------------------
2224 SfxViewShell
* SfxViewFrame::CreateView_Impl( sal_uInt16 nViewId
)
2228 Erzeugt eine SfxViewShell f"ur diesen SfxViewFrame. Wird auch aus
2229 <SfxObjectShell::LoadWindows_Impl()>
2234 DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
2236 LockAdjustPosSizePixel();
2238 // passende ::com::sun::star::sdbcx::View-Factory suchen
2239 SfxObjectFactory
&rDocFact
= GetObjectShell()->GetFactory();
2240 sal_uInt16 nNewNo
= nViewId
? USHRT_MAX
: 0;
2241 for ( sal_uInt16 nNo
= 0;
2242 nNo
< rDocFact
.GetViewFactoryCount();
2245 sal_uInt16 nFoundId
= rDocFact
.GetViewFactory(nNo
).GetOrdinal();
2246 if ( nNewNo
== USHRT_MAX
)
2248 if ( nViewId
== nFoundId
)
2253 // per Factory erzeugen
2254 GetBindings().ENTERREGISTRATIONS();
2255 SfxViewFactory
&rViewFactory
= rDocFact
.GetViewFactory( nNewNo
);
2256 SfxViewShell
*pViewShell
= rViewFactory
.CreateInstance(this, 0);
2257 SetViewShell_Impl(pViewShell
);
2258 UnlockAdjustPosSizePixel();
2260 if ( GetWindow().IsReallyVisible() )
2261 DoAdjustPosSizePixel(pViewShell
, Point(), GetWindow().GetOutputSizePixel());
2263 // erste jetzt anzeigen (ausser wenn MTs BASIC-IDE mal wieder keins hat)
2264 Window
*pViewWin
= pViewShell
->GetWindow();
2265 if ( pViewWin
&& pViewShell
->IsShowView_Impl() )
2269 GetDispatcher()->Push( *pViewShell
);
2270 if ( pViewShell
->GetSubShell() )
2271 GetDispatcher()->Push( *pViewShell
->GetSubShell() );
2272 pViewShell
->PushSubShells_Impl();
2274 #if defined SFX_HINT_VIEWCREATED
2275 GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_VIEWCREATED
) );
2278 GetBindings().LEAVEREGISTRATIONS();
2280 DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" );
2284 //-------------------------------------------------------------------------
2285 SfxViewFrame
* SfxViewFrame::SearchViewFrame( SfxViewFrame
*pViewFrame
,
2286 const String
& rName
)
2289 pViewFrame
= SfxViewFrame::Current();
2292 SfxFrame
*pFrame
= pViewFrame
->GetFrame()->SearchFrame( rName
);
2296 // Der Frame ist selbst ein ViewFrame oder enth"alt einen
2298 pViewFrame = PTR_CAST( SfxViewFrame, pFrame );
2299 if ( !pViewFrame && pFrame->GetChildFrameCount() )
2300 pViewFrame = PTR_CAST( SfxViewFrame, pFrame->GetChildFrame(0) );
2302 return pFrame
->GetCurrentViewFrame();
2305 //-------------------------------------------------------------------------
2307 void SfxViewFrame::SetQuietMode_Impl( sal_Bool bOn
)
2309 GetDispatcher()->SetQuietMode_Impl( bOn
);
2312 //-------------------------------------------------------------------------
2314 SfxObjectShell
* SfxViewFrame::GetObjectShell()
2319 void SfxViewFrame::SetMargin_Impl( const Size
& rMargin
)
2321 pImp
->aMargin
= rMargin
;
2324 const Size
& SfxViewFrame::GetMargin_Impl() const
2326 return pImp
->aMargin
;
2329 void SfxViewFrame::SetActiveChildFrame_Impl( SfxViewFrame
*pViewFrame
)
2331 if ( pViewFrame
!= pImp
->pActiveChild
)
2333 if ( !pImp
->pActiveChild
)
2334 GetDispatcher()->LockUI_Impl( sal_False
);
2336 pImp
->pActiveChild
= pViewFrame
;
2338 Reference
< XFramesSupplier
> xFrame( GetFrame()->GetFrameInterface(), UNO_QUERY
);
2339 Reference
< XFrame
> xActive
;
2341 xActive
= pViewFrame
->GetFrame()->GetFrameInterface();
2343 if ( xFrame
.is() ) // PB: #74432# xFrame cann be NULL
2344 xFrame
->setActiveFrame( xActive
);
2348 SfxViewFrame
* SfxViewFrame::GetActiveChildFrame_Impl() const
2350 SfxViewFrame
*pViewFrame
= pImp
->pActiveChild
;
2354 // Wenn es keinen aktiven ChildFrame gibt, irgendeinen nehmen
2355 for ( sal_uInt16 n=0; n<GetChildFrameCount(); n++ )
2358 PTR_CAST( SfxViewFrame, GetChildFrame(n)->GetChildFrame(0) );
2364 pImp->pActiveChild = pViewFrame;
2369 //--------------------------------------------------------------------
2371 sal_Bool
SfxViewFrame::SwitchToViewShell_Impl
2373 sal_uInt16 nViewId
, /* > 0
2374 Registrierungs-Id der ::com::sun::star::sdbcx::View, auf die umge-
2375 schaltet werden soll, bzw. die erstmalig
2376 erzeugt werden soll.
2379 Es soll die Default-::com::sun::star::sdbcx::View verwendet werden. */
2381 sal_Bool bIsIndex
/* sal_True
2382 'nViewId' ist keine Registrations-Id sondern
2383 ein ::com::sun::star::sdbcx::Index in die f"ur die in diesem
2384 <SfxViewFrame> dargestellte <SfxObjectShell>.
2390 Interne Methode zum Umschalten auf eine andere <SfxViewShell>-Subklasse,
2391 die in diesem SfxMDIFrame erzeugt werden soll. Existiert noch
2392 keine SfxViewShell in diesem SfxMDIFrame, so wird erstmalig eine
2399 die angeforderte SfxViewShell wurde erzeugt
2400 und eine ggf. bestehende gel"oscht
2403 die angeforderte SfxViewShell konnte nicht
2404 erzeugt werden, die bestehende SfxViewShell
2405 existiert daher weiterhin
2410 DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
2412 SfxObjectFactory
&rDocFact
= GetObjectShell()->GetFactory();
2414 // find index of old and new ViewShell
2415 sal_uInt16 nOldNo
= USHRT_MAX
, nNewNo
= USHRT_MAX
;
2416 bIsIndex
|= 0 == nViewId
;
2417 for ( sal_uInt16 nNo
= 0; nNo
< rDocFact
.GetViewFactoryCount(); ++nNo
)
2419 sal_uInt16 nFoundId
= rDocFact
.GetViewFactory(nNo
).GetOrdinal();
2420 if ( nNewNo
== USHRT_MAX
)
2422 if ( bIsIndex
&& nViewId
== nNo
)
2425 nViewId
= nFoundId
; // for nViewId == 0
2427 else if ( !bIsIndex
&& nViewId
== nFoundId
)
2430 if ( pImp
->nCurViewId
== nFoundId
)
2434 if ( nNewNo
== USHRT_MAX
)
2436 // unknown ID -> fall back to default
2437 sal_uInt16 nFoundId
= rDocFact
.GetViewFactory(0).GetOrdinal();
2440 if ( pImp
->nCurViewId
== nFoundId
)
2444 SfxViewShell
*pSh
= GetViewShell();
2446 DBG_ASSERT( !pSh
|| nOldNo
!= USHRT_MAX
, "old shell id not found" );
2448 // does a ViewShell exist already?
2449 SfxViewShell
*pOldSh
= pSh
;
2452 // ask wether it can be closed
2453 if ( !pOldSh
->PrepareClose() )
2456 // remove SubShells from Dispatcher before switching to new ViewShell
2457 pOldSh
->PushSubShells_Impl( sal_False
);
2458 sal_uInt16 nLevel
= pDispatcher
->GetShellLevel( *pOldSh
);
2461 SfxShell
*pSubShell
= pDispatcher
->GetShell( nLevel
-1 );
2462 if ( pSubShell
== pOldSh
->GetSubShell() )
2463 //"real" SubShells are not deleted
2464 pDispatcher
->Pop( *pSubShell
, SFX_SHELL_POP_UNTIL
);
2466 // SubShells only known to Dispatcher must be deleted
2467 pDispatcher
->Pop( *pSubShell
, SFX_SHELL_POP_UNTIL
| SFX_SHELL_POP_DELETE
);
2470 pDispatcher
->Pop( *pOldSh
);
2471 GetBindings().Invalidate( nOldNo
+ SID_VIEWSHELL0
);
2475 pImp
->nCurViewId
= nViewId
;
2476 GetBindings().Invalidate( nNewNo
+ SID_VIEWSHELL0
);
2478 // create new ViewShell
2479 SfxViewFactory
&rViewFactory
= rDocFact
.GetViewFactory( nNewNo
);
2480 LockAdjustPosSizePixel();
2482 GetBindings().ENTERREGISTRATIONS();
2483 pSh
= rViewFactory
.CreateInstance(this, pOldSh
);
2485 Window
*pEditWin
= pSh
->GetWindow();
2486 DBG_ASSERT( !pEditWin
|| !pEditWin
->IsReallyVisible(), "don`t show your ViewShell`s Window by yourself!" );
2488 // by setting the ViewShell it is prevented that disposing the Controller will destroy this ViewFrame also
2489 GetDispatcher()->SetDisableFlags( 0 );
2490 SetViewShell_Impl(pSh
);
2492 Reference
< ::com::sun::star::awt::XWindow
> xWindow(
2493 GetFrame()->GetWindow().GetComponentInterface(), UNO_QUERY
);
2494 Reference
< XFrame
> xFrame( GetFrame()->GetFrameInterface() );
2495 if ( !pSh
->GetController().is() )
2496 pSh
->SetController( new SfxBaseController( pSh
) );
2497 Reference
< XController
> xController( pSh
->GetController() );
2498 xFrame
->setComponent( xWindow
, xController
);
2500 xController
->attachFrame( xFrame
);
2501 Reference
< XModel
> xModel( GetObjectShell()->GetModel() );
2504 xController
->attachModel( xModel
);
2505 xModel
->connectController( xController
);
2506 xModel
->setCurrentController( xController
);
2509 GetDispatcher()->Push( *pSh
);
2510 if ( pSh
->GetSubShell() )
2511 GetDispatcher()->Push( *pSh
->GetSubShell() );
2512 pSh
->PushSubShells_Impl();
2513 GetDispatcher()->Flush();
2515 if ( pImp
->bRestoreView
&& pImp
->aViewData
.Len() )
2517 // restore view data if required
2518 pSh
->ReadUserData( pImp
->aViewData
, sal_True
);
2519 pImp
->bRestoreView
= sal_False
;
2522 // create UI elements before size is set
2523 if ( SfxViewFrame::Current() == this )
2524 GetDispatcher()->Update_Impl( sal_True
);
2526 // allow resize events to be processed
2527 UnlockAdjustPosSizePixel();
2529 Window
* pFrameWin
= &GetWindow();
2530 if ( pFrameWin
!= &GetFrame()->GetWindow() )
2533 if ( GetWindow().IsReallyVisible() )
2534 DoAdjustPosSizePixel( pSh
, Point(), GetWindow().GetOutputSizePixel() );
2536 if ( pEditWin
&& pSh
->IsShowView_Impl() )
2539 GetBindings().LEAVEREGISTRATIONS();
2542 catch ( com::sun::star::uno::Exception
& )
2544 // the SfxCode is not able to cope with exceptions thrown while creating views
2545 // the code will crash in the stack unwinding procedure, so we shouldn't let exceptions go through here
2546 DBG_ERROR("Exception in SwitchToViewShell_Impl - urgent issue. Please contact development!");
2549 DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" );
2552 //--------------------------------------------------------------------
2554 void SfxViewFrame::SetViewData_Impl( sal_uInt16 nViewId
, const String
&rViewData
)
2556 pImp
->bRestoreView
= sal_True
;
2557 pImp
->nCurViewId
= nViewId
;
2558 pImp
->aViewData
= rViewData
;
2561 //-------------------------------------------------------------------------
2562 String
& SfxViewFrame::GetViewData_Impl()
2564 return pImp
->aViewData
;
2567 //-------------------------------------------------------------------------
2568 sal_Bool
SfxViewFrame::IsRestoreView_Impl() const
2570 return pImp
->bRestoreView
;
2573 //-------------------------------------------------------------------------
2574 void SfxViewFrame::SetRestoreView_Impl( sal_Bool bOn
)
2576 pImp
->bRestoreView
= bOn
;
2579 //-------------------------------------------------------------------------
2580 sal_uInt16
SfxViewFrame::GetCurViewId() const
2582 return pImp
->nCurViewId
;
2585 //-------------------------------------------------------------------------
2586 void SfxViewFrame::ExecView_Impl
2588 SfxRequest
& rReq
// der auszuf"uhrende <SfxRequest>
2593 Interne Methode zum Ausf"uhren der f"ur die <SfxShell> Subklasse
2594 SfxViewFrame in der <SVIDL> beschriebenen Slots.
2598 DBG_CHKTHIS(SfxViewFrame
, 0);
2600 // Wenn gerade die Shells ausgetauscht werden...
2601 if ( !GetObjectShell() || !GetViewShell() )
2604 switch ( rReq
.GetSlot() )
2606 case SID_TERMINATE_INPLACEACTIVATION
:
2608 SfxInPlaceClient
* pClient
= GetViewShell()->GetUIActiveClient();
2610 pClient
->DeactivateObject();
2616 // Bei Mail etc. k"onnen die Frames nicht angesprochen werden
2617 SfxFrame
*pParent
= GetFrame()->GetParentFrame();
2618 if ( pParent
&& pParent
->GetCurrentViewFrame()->
2619 GetViewShell()->IsImplementedAsFrameset_Impl() )
2622 SfxViewFrame
*pRet
= NULL
;
2624 rReq
, pItem
, SfxStringItem
, SID_FILLFRAME
, sal_False
);
2627 String
aName( pItem
->GetValue() );
2628 sal_uInt16 nFrame
= (sal_uInt16
) aName
.ToInt32();
2632 SfxFrameIterator
aIter( *GetFrame(), sal_False
);
2633 SfxFrame
*pFrame
= aIter
.FirstFrame();
2634 sal_uInt16 nActFrame
= 1;
2637 SfxViewFrame
*pView
= pFrame
->GetCurrentViewFrame();
2639 nActFrame
== nFrame
||
2642 aName
.CompareIgnoreCaseToAscii( pView
->SfxShell::GetName() ) == COMPARE_EQUAL
2650 pFrame
= aIter
.NextFrame( *pFrame
);
2655 rReq
.SetReturnValue( SfxObjectItem( SID_DOCFRAME
, pRet
) );
2661 const SfxPoolItem
*pItem
= 0;
2662 if ( rReq
.GetArgs() &&
2663 SFX_ITEM_SET
== rReq
.GetArgs()->GetItemState( SID_VIEWSHELL
, sal_False
, &pItem
) )
2664 rReq
.SetReturnValue( SfxBoolItem(0, SwitchToViewShell_Impl(
2665 (sal_uInt16
)((const SfxUInt16Item
*) pItem
)->GetValue()) ));
2669 case SID_VIEWSHELL0
:
2670 case SID_VIEWSHELL1
:
2671 case SID_VIEWSHELL2
:
2672 case SID_VIEWSHELL3
:
2673 case SID_VIEWSHELL4
:
2675 rReq
.SetReturnValue( SfxBoolItem(0,
2676 SwitchToViewShell_Impl( rReq
.GetSlot() - SID_VIEWSHELL0
, sal_True
) ) );
2682 // Hack. demnaechst virtuelle Funktion
2683 if ( !GetViewShell()->NewWindowAllowed() && !GetObjectShell()->HasName() )
2686 // ViewData bei FrameSets rekursiv holen
2687 GetFrame()->GetViewData_Impl();
2688 SfxMedium
*pMed
= GetObjectShell()->GetMedium();
2690 GetViewShell()->WriteUserData( aUserData
, sal_True
);
2691 if ( !GetViewShell()->NewWindowAllowed() )
2693 SFX_REQUEST_ARG( rReq
, pFrameItem
, SfxUnoAnyItem
, SID_FILLFRAME
, sal_False
);
2694 SfxFrame
*pFrame
= NULL
;
2695 Reference
< XFrame
> xFrame
;
2698 pFrameItem
->GetValue() >>= xFrame
;
2699 pFrame
= SfxTopFrame::Create( xFrame
);
2702 pFrame
= SfxTopFrame::Create();
2704 SfxAllItemSet
aSet( SFX_APP()->GetPool() );
2705 SFX_REQUEST_ARG( rReq
, pHiddenItem
, SfxBoolItem
, SID_HIDDEN
, sal_False
);
2707 aSet
.Put( *pHiddenItem
);
2709 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pRefererItem
, SfxStringItem
, SID_REFERER
, sal_False
);
2710 SfxStringItem
aReferer( SID_REFERER
, DEFINE_CONST_UNICODE( "private:user" ) );
2711 if ( !pRefererItem
)
2712 pRefererItem
= &aReferer
;
2714 aSet
.Put( SfxStringItem( SID_FILE_NAME
, pMed
->GetName() ) );
2715 aSet
.Put( SfxStringItem( SID_USER_DATA
, aUserData
) );
2716 aSet
.Put( SfxUInt16Item( SID_VIEW_ID
, GetCurViewId() ) );
2717 aSet
.Put( *pRefererItem
);
2718 if( pMed
->GetFilter() )
2719 aSet
.Put( SfxStringItem( SID_FILTER_NAME
, pMed
->GetFilter()->GetFilterName()) );
2720 aSet
.Put( SfxFrameItem ( SID_DOCFRAME
, pFrame
) );
2722 GetDispatcher()->Execute( SID_OPENDOC
, SFX_CALLMODE_SYNCHRON
, aSet
);
2724 GetDispatcher()->Execute( SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
, aSet
);
2728 pMed
->GetItemSet()->Put( SfxStringItem( SID_USER_DATA
, aUserData
) );
2730 BOOL bHidden
= FALSE
;
2731 SFX_REQUEST_ARG( rReq
, pHiddenItem
, SfxBoolItem
, SID_HIDDEN
, sal_False
);
2733 bHidden
= pHiddenItem
->GetValue();
2734 SFX_REQUEST_ARG( rReq
, pFrameItem
, SfxUnoAnyItem
, SID_FILLFRAME
, sal_False
);
2737 Reference
< XFrame
> xFrame
;
2738 pFrameItem
->GetValue() >>= xFrame
;
2739 SfxFrame
* pFrame
= SfxTopFrame::Create( xFrame
);
2740 pMed
->GetItemSet()->ClearItem( SID_HIDDEN
);
2741 pFrame
->InsertDocument( GetObjectShell() );
2743 xFrame
->getContainerWindow()->setVisible( sal_True
);
2747 SfxAllItemSet
aSet( GetPool() );
2748 aSet
.Put( SfxBoolItem( SID_OPEN_NEW_VIEW
, TRUE
) );
2749 SfxFrame
* pFrame
= SfxTopFrame::Create( GetObjectShell(), GetCurViewId(), bHidden
, &aSet
);
2751 pFrame
->GetCurrentViewFrame()->LockObjectShell_Impl( TRUE
);
2761 SFX_REQUEST_ARG( rReq
, pItem
, SfxUInt16Item
, SID_OBJECT
, sal_False
);
2763 SfxViewShell
*pViewShell
= GetViewShell();
2764 if ( pViewShell
&& pItem
)
2766 pViewShell
->DoVerb( pItem
->GetValue() );
2774 //-------------------------------------------------------------------------
2776 This method try to collect informations about the count of currently open documents.
2777 But the algorithm is implemented very simple ...
2778 E.g. hidden documents should be ignored here ... but they are counted.
2779 TODO: export special helper "framework::FrameListAnalyzer" within the framework module
2782 sal_Bool
impl_maxOpenDocCountReached()
2784 static ::rtl::OUString SERVICE_DESKTOP
= ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop");
2788 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR
= ::comphelper::getProcessServiceFactory();
2789 css::uno::Any aVal
= ::comphelper::ConfigurationHelper::readDirectKey(
2791 ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/"),
2792 ::rtl::OUString::createFromAscii("Misc"),
2793 ::rtl::OUString::createFromAscii("MaxOpenDocuments"),
2794 ::comphelper::ConfigurationHelper::E_READONLY
);
2796 // NIL means: count of allowed documents = infinite !
2797 if ( ! aVal
.hasValue())
2800 sal_Int32 nOpenDocs
= 0;
2801 sal_Int32 nMaxDocs
= 0;
2804 css::uno::Reference
< css::frame::XFramesSupplier
> xDesktop(xSMGR
->createInstance(SERVICE_DESKTOP
), css::uno::UNO_QUERY_THROW
);
2805 css::uno::Reference
< css::container::XIndexAccess
> xCont (xDesktop
->getFrames() , css::uno::UNO_QUERY_THROW
);
2807 sal_Int32 c
= xCont
->getCount();
2814 css::uno::Reference
< css::frame::XFrame
> xFrame
;
2815 xCont
->getByIndex(i
) >>= xFrame
;
2819 // a) do not count the help window
2820 if (xFrame
->getName().equalsAscii("OFFICE_HELP_TASK"))
2823 // b) count all other frames
2826 catch(const css::uno::Exception
&)
2827 // A IndexOutOfBoundException can happen in multithreaded environments,
2828 // where any other thread can change this container !
2832 return (nOpenDocs
>= nMaxDocs
);
2834 catch(const css::uno::Exception
&)
2837 // Any internal error is no reason to stop opening documents !
2838 // Limitation of opening documents is a special "nice to have" feature.
2839 // Otherwhise it can happen, that NO document will be opened ...
2843 //-------------------------------------------------------------------------
2844 void SfxViewFrame::StateView_Impl
2846 SfxItemSet
& rSet
/* leeres <SfxItemSet> mit <Which-Ranges>,
2847 welche die Ids der zu erfragenden
2848 Slots beschreiben. */
2853 Diese interne Methode liefert in 'rSet' die Status der f"ur die
2854 <SfxShell> Subklasse SfxViewFrame in der <SVIDL> beschriebenen <Slots>.
2856 In 'rSet' sind dabei genau die vom SFx als ung"ultig erkannten
2857 Slot-Ids als Which-ranges enthalten. Falls der an dieser Shell gesetzte
2858 <SfxItemPool> f"ur einzelne Slot-Ids ein Mapping hat, werden die
2859 entsprechenden Which-Ids verwendet, so da\s Items ggf. direkt mit
2860 einer mit Which-Ids arbeitenden Core-::com::sun::star::script::Engine ausgetauscht werden
2865 DBG_CHKTHIS(SfxViewFrame
, 0);
2867 SfxObjectShell
*pDocSh
= GetObjectShell();
2870 // Ich bin gerade am Reloaden und Yielde so vor mich hin ...
2873 const sal_uInt16
*pRanges
= rSet
.GetRanges();
2874 DBG_ASSERT(pRanges
, "Set ohne Bereich");
2877 for ( sal_uInt16 nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
2883 rSet
.Put( SfxUInt16Item( nWhich
, pImp
->nCurViewId
) );
2887 case SID_VIEWSHELL0
:
2888 case SID_VIEWSHELL1
:
2889 case SID_VIEWSHELL2
:
2890 case SID_VIEWSHELL3
:
2891 case SID_VIEWSHELL4
:
2893 sal_uInt16 nViewNo
= nWhich
- SID_VIEWSHELL0
;
2894 if ( GetObjectShell()->GetFactory().GetViewFactoryCount() >
2895 nViewNo
&& !GetObjectShell()->IsInPlaceActive() )
2897 SfxViewFactory
&rViewFactory
=
2898 GetObjectShell()->GetFactory().GetViewFactory(nViewNo
);
2899 rSet
.Put( SfxBoolItem(
2900 nWhich
, pImp
->nCurViewId
== rViewFactory
.GetOrdinal() ) );
2903 rSet
.DisableItem( nWhich
);
2906 case SID_FRAMETITLE
:
2908 if( GetFrameType() & SFXFRAME_HASTITLE
)
2909 rSet
.Put( SfxStringItem(
2910 SID_FRAMETITLE
, pImp
->aFrameTitle
) );
2912 rSet
.DisableItem( nWhich
);
2918 if ( !GetViewShell()->NewWindowAllowed() /* && !pDocSh->HasName() */ )
2919 rSet
.DisableItem( nWhich
);
2922 if (impl_maxOpenDocCountReached())
2923 rSet
.DisableItem( nWhich
);
2932 //-------------------------------------------------------------------------
2933 void SfxViewFrame::GetState_Impl( SfxItemSet
&rSet
)
2935 if ( GetViewShell() && GetViewShell()->GetVerbs().getLength() && !GetObjectShell()->IsInPlaceActive() )
2938 aAny
<<= GetViewShell()->GetVerbs();
2939 rSet
.Put( SfxUnoAnyItem( USHORT( SID_OBJECT
), aAny
) );
2942 rSet
.DisableItem( SID_OBJECT
);
2945 //-------------------------------------------------------------------------
2946 void SfxViewFrame::ToTop()
2948 GetFrame()->Appear();
2951 //-------------------------------------------------------------------------
2952 SfxViewFrame
* SfxViewFrame::GetParentViewFrame() const
2955 Der ParentViewFrame ist der ViewFrame des ParentFrames
2958 SfxFrame
*pFrame
= GetFrame()->GetParentFrame();
2959 return pFrame
? pFrame
->GetCurrentViewFrame() : NULL
;
2962 //-------------------------------------------------------------------------
2963 SfxFrame
* SfxViewFrame::GetFrame() const
2966 GetFrame liefert den Frame, in dem sich der ViewFrame befindet
2969 return pImp
->pFrame
;
2972 //-------------------------------------------------------------------------
2973 void SfxViewFrame::SetFrame_Impl( SfxFrame
*pFrame
)
2975 pImp
->pFrame
= pFrame
;
2978 //-------------------------------------------------------------------------
2979 SfxViewFrame
* SfxViewFrame::GetTopViewFrame() const
2981 return GetFrame()->GetTopFrame()->GetCurrentViewFrame();
2984 //-------------------------------------------------------------------------
2986 SfxCancelManager
*SfxViewFrame::GetCancelManager() const
2988 /* <H3>Description</H3>
2990 Returns a pointer to the <SfxCancelManager> of the top-view-frame of
2995 return GetTopViewFrame()->GetFrame()->GetCancelManager();
2998 void SfxViewFrame::SetWindow_Impl( Window
*pWin
)
3000 pImp
->pWindow
= pWin
;
3003 Window
& SfxViewFrame::GetWindow() const
3005 return pImp
->pWindow
? *pImp
->pWindow
: GetFrame()->GetWindow();
3008 sal_Bool
SfxViewFrame::DoClose()
3010 return GetFrame()->DoClose();
3013 String
SfxViewFrame::GetActualPresentationURL_Impl() const
3016 return xObjSh
->GetMedium()->GetName();
3017 return pImp
->aActualPresentationURL
;
3020 void SfxViewFrame::SetModalMode( sal_Bool bModal
)
3022 pImp
->bModal
= bModal
;
3025 for ( SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( xObjSh
);
3026 !bModal
&& pFrame
; pFrame
= SfxViewFrame::GetNext( *pFrame
, xObjSh
) )
3027 bModal
= pFrame
->pImp
->bModal
;
3028 xObjSh
->SetModalMode_Impl( bModal
);
3032 BOOL
SfxViewFrame::IsInModalMode() const
3034 return pImp
->bModal
|| GetFrame()->GetWindow().IsInModalMode();
3037 void SfxViewFrame::Resize( BOOL bForce
)
3039 Size aSize
= GetWindow().GetOutputSizePixel();
3040 if ( bForce
|| aSize
!= pImp
->aSize
)
3042 pImp
->aSize
= aSize
;
3043 SfxViewShell
*pShell
= GetViewShell();
3046 if ( GetFrame()->IsInPlace() )
3048 Point aPoint
= GetWindow().GetPosPixel();
3049 DoAdjustPosSizePixel( pShell
, aPoint
, aSize
);
3053 if ( pShell
->UseObjectSize() )
3054 ForceOuterResize_Impl(TRUE
);
3055 DoAdjustPosSizePixel( pShell
, Point(), aSize
);
3056 if ( pShell
->UseObjectSize() )
3057 ForceOuterResize_Impl(FALSE
);
3063 #define LINE_SEP 0x0A
3065 void CutLines( ::rtl::OUString
& rStr
, sal_Int32 nStartLine
, sal_Int32 nLines
, BOOL bEraseTrailingEmptyLines
)
3067 sal_Int32 nStartPos
= 0;
3068 sal_Int32 nEndPos
= 0;
3069 sal_Int32 nLine
= 0;
3070 while ( nLine
< nStartLine
)
3072 nStartPos
= rStr
.indexOf( LINE_SEP
, nStartPos
);
3073 if( nStartPos
== -1 )
3075 nStartPos
++; // nicht das \n.
3079 DBG_ASSERTWARNING( nStartPos
!= STRING_NOTFOUND
, "CutLines: Startzeile nicht gefunden!" );
3081 if ( nStartPos
!= -1 )
3083 nEndPos
= nStartPos
;
3084 for ( sal_Int32 i
= 0; i
< nLines
; i
++ )
3085 nEndPos
= rStr
.indexOf( LINE_SEP
, nEndPos
+1 );
3087 if ( nEndPos
== -1 ) // kann bei letzter Zeile passieren
3088 nEndPos
= rStr
.getLength();
3092 ::rtl::OUString aEndStr
= rStr
.copy( nEndPos
);
3093 rStr
= rStr
.copy( 0, nStartPos
);
3096 if ( bEraseTrailingEmptyLines
)
3098 sal_Int32 n
= nStartPos
;
3099 sal_Int32 nLen
= rStr
.getLength();
3100 while ( ( n
< nLen
) && ( rStr
.getStr()[ n
] == LINE_SEP
) )
3103 if ( n
> nStartPos
)
3105 ::rtl::OUString aEndStr
= rStr
.copy( n
);
3106 rStr
= rStr
.copy( 0, nStartPos
);
3113 add new recorded dispatch macro script into the application global basic lib container
3114 It generates a new unique id for it and insert the macro by using this number as name for
3117 void SfxViewFrame::AddDispatchMacroToBasic_Impl( const ::rtl::OUString
& sMacro
)
3120 // get lib and modul name from dialog
3121 SfxModule *pMod = GetObjectShell()->GetModule();
3122 SfxRequest aReq( SID_BASICCHOOSER, SFX_CALLMODE_SYNCHRON, pMod->GetPool() );
3123 const SfxPoolItem* pRet = pMod->ExecuteSlot( aReq );
3125 ::rtl::OUString = ((SfxStringItem*)pRet)->GetValue();
3127 if ( !sMacro
.getLength() )
3130 SfxApplication
* pSfxApp
= SFX_APP();
3131 SfxRequest
aReq( SID_BASICCHOOSER
, SFX_CALLMODE_SYNCHRON
, pSfxApp
->GetPool() );
3132 aReq
.AppendItem( SfxBoolItem(SID_RECORDMACRO
,TRUE
) );
3133 const SfxPoolItem
* pRet
= SFX_APP()->ExecuteSlot( aReq
);
3136 aScriptURL
= ((SfxStringItem
*)pRet
)->GetValue();
3137 if ( aScriptURL
.Len() )
3144 Reference
< XMultiServiceFactory
> xSMgr
= ::comphelper::getProcessServiceFactory();
3145 Reference
< com::sun::star::uri::XUriReferenceFactory
> xFactory( xSMgr
->createInstance(
3146 ::rtl::OUString::createFromAscii( "com.sun.star.uri.UriReferenceFactory" ) ), UNO_QUERY
);
3147 if ( xFactory
.is() )
3149 Reference
< com::sun::star::uri::XVndSunStarScriptUrl
> xUrl( xFactory
->parse( aScriptURL
), UNO_QUERY
);
3153 ::rtl::OUString aName
= xUrl
->getName();
3154 sal_Unicode cTok
= '.';
3155 sal_Int32 nIndex
= 0;
3156 aLibName
= aName
.getToken( 0, cTok
, nIndex
);
3158 aModuleName
= aName
.getToken( 0, cTok
, nIndex
);
3160 aMacroName
= aName
.getToken( 0, cTok
, nIndex
);
3163 ::rtl::OUString aLocKey
= ::rtl::OUString::createFromAscii( "location" );
3164 if ( xUrl
->hasParameter( aLocKey
) )
3165 aLocation
= xUrl
->getParameter( aLocKey
);
3169 pSfxApp
->EnterBasicCall();
3171 BasicManager
* pBasMgr
= 0;
3172 if ( aLocation
.EqualsIgnoreCaseAscii( "application" ) )
3174 // application basic
3175 pBasMgr
= pSfxApp
->GetBasicManager();
3177 else if ( aLocation
.EqualsIgnoreCaseAscii( "document" ) )
3179 pBasMgr
= GetObjectShell()->GetBasicManager();
3182 ::rtl::OUString aOUSource
;
3185 StarBASIC
* pBasic
= pBasMgr
->GetLib( aLibName
);
3188 SbModule
* pModule
= pBasic
->FindModule( aModuleName
);
3191 SbMethod
* pMethod
= (SbMethod
*)pModule
->GetMethods()->Find( aMacroName
, SbxCLASS_METHOD
);
3192 aOUSource
= pModule
->GetSource32();
3193 USHORT nStart
, nEnd
;
3194 pMethod
->GetLineRange( nStart
, nEnd
);
3195 ULONG nlStart
= nStart
;
3197 CutLines( aOUSource
, nlStart
-1, nlEnd
-nlStart
+1, TRUE
);
3202 // open lib container and break operation if it couldn't be opened
3203 com::sun::star::uno::Reference
< com::sun::star::script::XLibraryContainer
> xLibCont
;
3204 if ( aLocation
.EqualsIgnoreCaseAscii( "application" ) )
3206 xLibCont
= SFX_APP()->GetBasicContainer();
3208 else if ( aLocation
.EqualsIgnoreCaseAscii( "document" ) )
3210 xLibCont
= GetObjectShell()->GetBasicContainer();
3215 DBG_ERRORFILE("couldn't get access to the basic lib container. Adding of macro isn't possible.");
3219 // get LibraryContainer
3220 com::sun::star::uno::Any aTemp
;
3221 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> xRoot(
3223 com::sun::star::uno::UNO_QUERY
);
3225 ::rtl::OUString
sLib( aLibName
);
3226 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> xLib
;
3227 if(xRoot
->hasByName(sLib
))
3229 // library must be loaded
3230 aTemp
= xRoot
->getByName(sLib
);
3231 xLibCont
->loadLibrary(sLib
);
3236 xLib
= com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
>(
3237 xLibCont
->createLibrary(sLib
),
3238 com::sun::star::uno::UNO_QUERY
);
3241 // pack the macro as direct usable "sub" routine
3242 ::rtl::OUString sCode
;
3243 ::rtl::OUStringBuffer
sRoutine(10000);
3244 ::rtl::OUString
sMacroName( aMacroName
);
3245 BOOL bReplace
= FALSE
;
3248 ::rtl::OUString
sModule( aModuleName
);
3249 if(xLib
->hasByName(sModule
))
3251 if ( aOUSource
.getLength() )
3253 sRoutine
.append( aOUSource
);
3257 aTemp
= xLib
->getByName(sModule
);
3259 sRoutine
.append( sCode
);
3265 // append new method
3266 sRoutine
.appendAscii("\nsub " );
3267 sRoutine
.append (sMacroName
);
3268 sRoutine
.appendAscii("\n" );
3269 sRoutine
.append (sMacro
);
3270 sRoutine
.appendAscii("\nend sub\n");
3272 // create the modul inside the library and insert the macro routine
3273 aTemp
<<= sRoutine
.makeStringAndClear();
3276 com::sun::star::uno::Reference
< com::sun::star::container::XNameContainer
> xModulCont(
3278 com::sun::star::uno::UNO_QUERY
);
3279 xModulCont
->replaceByName(sModule
,aTemp
);
3283 com::sun::star::uno::Reference
< com::sun::star::container::XNameContainer
> xModulCont(
3285 com::sun::star::uno::UNO_QUERY
);
3286 xModulCont
->insertByName(sModule
,aTemp
);
3289 // #i17355# update the Basic IDE
3290 for ( SfxViewShell
* pViewShell
= SfxViewShell::GetFirst(); pViewShell
; pViewShell
= SfxViewShell::GetNext( *pViewShell
) )
3292 if ( pViewShell
->GetName().EqualsAscii( "BasicIDE" ) )
3294 SfxViewFrame
* pViewFrame
= pViewShell
->GetViewFrame();
3295 SfxDispatcher
* pDispat
= pViewFrame
? pViewFrame
->GetDispatcher() : NULL
;
3298 SfxMacroInfoItem
aInfoItem( SID_BASICIDE_ARG_MACROINFO
, pBasMgr
, aLibName
, aModuleName
, String(), String() );
3299 pDispat
->Execute( SID_BASICIDE_UPDATEMODULESOURCE
, SFX_CALLMODE_SYNCHRON
, &aInfoItem
, 0L );
3304 pSfxApp
->LeaveBasicCall();
3308 // add code for "session only" macro
3312 FILE* pFile = fopen( "macro.bas", "a" );
3313 fprintf( pFile, "%s", ::rtl::OUStringToOString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8).getStr() );
3318 void SfxViewFrame::MiscExec_Impl( SfxRequest
& rReq
)
3321 FASTBOOL bDone
= FALSE
;
3322 switch ( rReq
.GetSlot() )
3324 case SID_STOP_RECORDING
:
3325 case SID_RECORDMACRO
:
3327 // try to find any active recorder on this frame
3328 ::rtl::OUString sProperty
= rtl::OUString::createFromAscii("DispatchRecorderSupplier");
3329 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> xFrame(
3330 GetFrame()->GetFrameInterface(),
3331 com::sun::star::uno::UNO_QUERY
);
3333 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> xSet(xFrame
,com::sun::star::uno::UNO_QUERY
);
3334 com::sun::star::uno::Any aProp
= xSet
->getPropertyValue(sProperty
);
3335 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorderSupplier
> xSupplier
;
3336 aProp
>>= xSupplier
;
3337 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorder
> xRecorder
;
3339 xRecorder
= xSupplier
->getDispatchRecorder();
3341 BOOL bIsRecording
= xRecorder
.is();
3342 SFX_REQUEST_ARG( rReq
, pItem
, SfxBoolItem
, SID_RECORDMACRO
, sal_False
);
3343 if ( pItem
&& pItem
->GetValue() == bIsRecording
)
3346 if ( xRecorder
.is() )
3348 // disable active recording
3349 aProp
<<= com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorderSupplier
>();
3350 xSet
->setPropertyValue(sProperty
,aProp
);
3352 SFX_REQUEST_ARG( rReq
, pRecordItem
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
3353 if ( !pRecordItem
|| !pRecordItem
->GetValue() )
3354 // insert script into basic library container of application
3355 AddDispatchMacroToBasic_Impl(xRecorder
->getRecordedMacro());
3357 xRecorder
->endRecording();
3359 GetBindings().SetRecorder_Impl( xRecorder
);
3361 SetChildWindow( SID_RECORDING_FLOATWINDOW
, FALSE
);
3362 if ( rReq
.GetSlot() != SID_RECORDMACRO
)
3363 GetBindings().Invalidate( SID_RECORDMACRO
);
3365 else if ( rReq
.GetSlot() == SID_RECORDMACRO
)
3368 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> xFactory(
3369 ::comphelper::getProcessServiceFactory(),
3370 com::sun::star::uno::UNO_QUERY
);
3372 xRecorder
= com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorder
>(
3373 xFactory
->createInstance(rtl::OUString::createFromAscii("com.sun.star.frame.DispatchRecorder")),
3374 com::sun::star::uno::UNO_QUERY
);
3376 xSupplier
= com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorderSupplier
>(
3377 xFactory
->createInstance(rtl::OUString::createFromAscii("com.sun.star.frame.DispatchRecorderSupplier")),
3378 com::sun::star::uno::UNO_QUERY
);
3380 xSupplier
->setDispatchRecorder(xRecorder
);
3381 xRecorder
->startRecording(xFrame
);
3382 aProp
<<= xSupplier
;
3383 xSet
->setPropertyValue(sProperty
,aProp
);
3384 GetBindings().SetRecorder_Impl( xRecorder
);
3385 SetChildWindow( SID_RECORDING_FLOATWINDOW
, TRUE
);
3392 case SID_TOGGLESTATUSBAR
:
3394 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> xFrame(
3395 GetFrame()->GetFrameInterface(),
3396 com::sun::star::uno::UNO_QUERY
);
3398 Reference
< com::sun::star::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
3399 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
3400 if ( xPropSet
.is() )
3404 Any aValue
= xPropSet
->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
3405 aValue
>>= xLayoutManager
;
3407 catch ( Exception
& )
3412 if ( xLayoutManager
.is() )
3414 rtl::OUString
aStatusbarResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
3415 // Parameter auswerten
3416 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, rReq
.GetSlot(), FALSE
);
3419 bShow
= xLayoutManager
->isElementVisible( aStatusbarResString
);
3421 bShow
= pShowItem
->GetValue();
3425 xLayoutManager
->createElement( aStatusbarResString
);
3426 xLayoutManager
->showElement( aStatusbarResString
);
3429 xLayoutManager
->hideElement( aStatusbarResString
);
3432 rReq
.AppendItem( SfxBoolItem( SID_TOGGLESTATUSBAR
, bShow
) );
3438 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3439 case SID_WIN_FULLSCREEN
:
3441 SFX_REQUEST_ARG(rReq
, pItem
, SfxBoolItem
, rReq
.GetSlot(), FALSE
);
3442 SfxTopViewFrame
*pTop
= PTR_CAST( SfxTopViewFrame
, GetTopViewFrame() );
3445 WorkWindow
* pWork
= (WorkWindow
*) pTop
->GetTopFrame_Impl()->GetTopWindow_Impl();
3448 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> xFrame(
3449 GetFrame()->GetFrameInterface(),
3450 com::sun::star::uno::UNO_QUERY
);
3452 Reference
< ::com::sun::star::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
3453 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
3454 if ( xPropSet
.is() )
3458 Any aValue
= xPropSet
->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
3459 aValue
>>= xLayoutManager
;
3461 catch ( Exception
& )
3466 BOOL bNewFullScreenMode
= pItem
? pItem
->GetValue() : !pWork
->IsFullScreenMode();
3467 if ( bNewFullScreenMode
!= pWork
->IsFullScreenMode() )
3469 Reference
< ::com::sun::star::beans::XPropertySet
> xLMPropSet( xLayoutManager
, UNO_QUERY
);
3470 if ( xLMPropSet
.is() )
3474 xLMPropSet
->setPropertyValue(
3475 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HideCurrentUI" )),
3476 makeAny( bNewFullScreenMode
));
3478 catch ( ::com::sun::star::beans::UnknownPropertyException
& )
3482 pWork
->ShowFullScreenMode( bNewFullScreenMode
);
3483 pWork
->SetMenuBarMode( bNewFullScreenMode
? MENUBAR_MODE_HIDE
: MENUBAR_MODE_NORMAL
);
3484 GetFrame()->GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode
);
3486 rReq
.AppendItem( SfxBoolItem( SID_WIN_FULLSCREEN
, bNewFullScreenMode
) );
3496 GetDispatcher()->Update_Impl( TRUE
);
3505 void SfxViewFrame::MiscState_Impl(SfxItemSet
&rSet
)
3509 const USHORT
*pRanges
= rSet
.GetRanges();
3510 DBG_ASSERT(pRanges
&& *pRanges
, "Set ohne Bereich");
3513 for(USHORT nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
3517 case SID_CURRENT_URL
:
3519 // Bei internem InPlace den ContainerFrame nehmen
3520 SfxViewFrame
*pFrame
= this;
3521 if ( pFrame
->GetParentViewFrame_Impl() )
3522 pFrame
= pFrame
->GetParentViewFrame_Impl();
3523 rSet
.Put( SfxStringItem( nWhich
, pFrame
->GetActualPresentationURL_Impl() ) );
3527 case SID_RECORDMACRO
:
3529 const char* pName
= GetObjectShell()->GetFactory().GetShortName();
3530 if ( strcmp(pName
,"swriter") && strcmp(pName
,"scalc") )
3532 rSet
.DisableItem( nWhich
);
3536 ::rtl::OUString sProperty
= rtl::OUString::createFromAscii("DispatchRecorderSupplier");
3537 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> xSet(
3538 GetFrame()->GetFrameInterface(),
3539 com::sun::star::uno::UNO_QUERY
);
3541 com::sun::star::uno::Any aProp
= xSet
->getPropertyValue(sProperty
);
3542 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorderSupplier
> xSupplier
;
3543 if ( aProp
>>= xSupplier
)
3544 rSet
.Put( SfxBoolItem( nWhich
, xSupplier
.is() ) );
3546 rSet
.DisableItem( nWhich
);
3550 case SID_STOP_RECORDING
:
3552 const char* pName
= GetObjectShell()->GetFactory().GetShortName();
3553 if ( strcmp(pName
,"swriter") && strcmp(pName
,"scalc") )
3555 rSet
.DisableItem( nWhich
);
3559 ::rtl::OUString sProperty
= rtl::OUString::createFromAscii("DispatchRecorderSupplier");
3560 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> xSet(
3561 GetFrame()->GetFrameInterface(),
3562 com::sun::star::uno::UNO_QUERY
);
3564 com::sun::star::uno::Any aProp
= xSet
->getPropertyValue(sProperty
);
3565 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatchRecorderSupplier
> xSupplier
;
3566 if ( !(aProp
>>= xSupplier
) || !xSupplier
.is() )
3567 rSet
.DisableItem( nWhich
);
3571 case SID_TOGGLESTATUSBAR
:
3573 com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
3574 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> xSet(
3575 GetFrame()->GetFrameInterface(),
3576 com::sun::star::uno::UNO_QUERY
);
3577 com::sun::star::uno::Any aProp
= xSet
->getPropertyValue(
3578 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )) );
3580 if ( !( aProp
>>= xLayoutManager
))
3581 rSet
.Put( SfxBoolItem( nWhich
, FALSE
));
3584 rtl::OUString
aStatusbarResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
3585 BOOL bShow
= xLayoutManager
->isElementVisible( aStatusbarResString
);
3586 rSet
.Put( SfxBoolItem( nWhich
, bShow
));
3591 case SID_WIN_FULLSCREEN
:
3593 SfxTopViewFrame
*pTop
= PTR_CAST( SfxTopViewFrame
, GetTopViewFrame() );
3596 WorkWindow
* pWork
= (WorkWindow
*) pTop
->GetTopFrame_Impl()->GetTopWindow_Impl();
3599 rSet
.Put( SfxBoolItem( nWhich
, pWork
->IsFullScreenMode() ) );
3604 rSet
.DisableItem( nWhich
);
3608 case SID_FORMATMENUSTATE
:
3610 DBG_ERROR("Outdated slot!");
3611 rSet
.DisableItem( nWhich
);
3616 //! DBG_ASSERT(FALSE, "Falscher Server fuer GetState");
3625 void SfxViewFrame::ChildWindowExecute( SfxRequest
&rReq
)
3629 Diese Methode kann in der Execute-Methode f"ur das ein- und ausschalten
3630 von Child-Windows eingesetzt werden, um dieses inkl. API-Anbindung zu
3633 Einfach in der IDL als 'ExecuteMethod' eintragen.
3637 // Parameter auswerten
3638 USHORT nSID
= rReq
.GetSlot();
3640 SFX_REQUEST_ARG(rReq
, pShowItem
, SfxBoolItem
, nSID
, FALSE
);
3641 if ( nSID
== SID_VIEW_DATA_SOURCE_BROWSER
)
3643 if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE
))
3645 Reference
< XFrame
> xFrame
= GetFrame()->GetTopFrame()->GetFrameInterface();
3646 Reference
< XFrame
> xBeamer( xFrame
->findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN
) );
3648 BOOL bHasChild
= xBeamer
.is();
3649 bShow
= pShowItem
? pShowItem
->GetValue() : !bHasChild
;
3652 if( bShow
== bHasChild
)
3656 rReq
.AppendItem( SfxBoolItem( nSID
, bShow
) );
3660 SetChildWindow( SID_BROWSER
, FALSE
);
3664 ::com::sun::star::util::URL aTargetURL
;
3665 aTargetURL
.Complete
= ::rtl::OUString::createFromAscii(".component:DB/DataSourceBrowser");
3666 Reference
< ::com::sun::star::util::XURLTransformer
> xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY
);
3667 xTrans
->parseStrict( aTargetURL
);
3669 Reference
< XDispatchProvider
> xProv( xFrame
, UNO_QUERY
);
3670 Reference
< ::com::sun::star::frame::XDispatch
> xDisp
;
3672 xDisp
= xProv
->queryDispatch( aTargetURL
, ::rtl::OUString::createFromAscii("_beamer"), 31 );
3675 Sequence
< ::com::sun::star::beans::PropertyValue
> aArgs(1);
3676 ::com::sun::star::beans::PropertyValue
* pArg
= aArgs
.getArray();
3677 pArg
[0].Name
= rtl::OUString::createFromAscii("Referer");
3678 pArg
[0].Value
<<= ::rtl::OUString::createFromAscii("private:user");
3679 xDisp
->dispatch( aTargetURL
, aArgs
);
3688 BOOL bHasChild
= HasChildWindow(nSID
);
3689 bShow
= pShowItem
? pShowItem
->GetValue() : !bHasChild
;
3692 if ( !pShowItem
|| bShow
!= bHasChild
)
3693 ToggleChildWindow( nSID
);
3695 GetBindings().Invalidate( nSID
);
3696 GetDispatcher()->Update_Impl( TRUE
);
3699 if ( nSID
== SID_HYPERLINK_DIALOG
|| nSID
== SID_SEARCH_DLG
)
3705 rReq
.AppendItem( SfxBoolItem( nSID
, bShow
) );
3710 //--------------------------------------------------------------------
3712 void SfxViewFrame::ChildWindowState( SfxItemSet
& rState
)
3716 Diese Methode kann in der Status-Methode f"ur das Ein- und Ausschalt-
3717 Zustand von Child-Windows eingesetzt werden, um dieses zu implementieren.
3719 Einfach in der IDL als 'StateMethod' eintragen.
3723 SfxWhichIter
aIter( rState
);
3724 for ( USHORT nSID
= aIter
.FirstWhich(); nSID
; nSID
= aIter
.NextWhich() )
3726 if ( nSID
== SID_VIEW_DATA_SOURCE_BROWSER
)
3728 rState
.Put( SfxBoolItem( nSID
, HasChildWindow( SID_BROWSER
) ) );
3730 else if ( nSID
== SID_HYPERLINK_DIALOG
)
3732 const SfxPoolItem
* pDummy
= NULL
;
3733 SfxItemState eState
= GetDispatcher()->QueryState( SID_HYPERLINK_SETLINK
, pDummy
);
3734 if ( SFX_ITEM_DISABLED
== eState
)
3735 rState
.DisableItem(nSID
);
3738 if ( KnowsChildWindow(nSID
) )
3739 rState
.Put( SfxBoolItem( nSID
, HasChildWindow(nSID
)) );
3741 rState
.DisableItem(nSID
);
3744 else if ( nSID
== SID_BROWSER
)
3746 Reference
< XFrame
> xFrame
= GetFrame()->GetTopFrame()->GetFrameInterface()->
3747 findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN
);
3749 rState
.DisableItem( nSID
);
3750 else if ( KnowsChildWindow(nSID
) )
3751 rState
.Put( SfxBoolItem( nSID
, HasChildWindow(nSID
) ) );
3753 else if ( KnowsChildWindow(nSID
) )
3754 rState
.Put( SfxBoolItem( nSID
, HasChildWindow(nSID
) ) );
3756 rState
.DisableItem(nSID
);
3760 //--------------------------------------------------------------------
3761 SfxWorkWindow
* SfxViewFrame::GetWorkWindow_Impl( USHORT
/*nId*/ )
3763 SfxWorkWindow
* pWork
= 0;
3764 pWork
= GetFrame()->GetWorkWindow_Impl();
3769 void SfxViewFrame::SetChildWindow(USHORT nId, BOOL bOn)
3771 SetChildWindow( nId, bOn, TRUE );
3774 void SfxViewFrame::SetChildWindow(USHORT nId
, BOOL bOn
, BOOL bSetFocus
)
3776 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( nId
);
3778 pWork
->SetChildWindow_Impl( nId
, bOn
, bSetFocus
);
3781 //--------------------------------------------------------------------
3783 void SfxViewFrame::ToggleChildWindow(USHORT nId
)
3785 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( nId
);
3787 pWork
->ToggleChildWindow_Impl( nId
, TRUE
);
3790 //--------------------------------------------------------------------
3792 BOOL
SfxViewFrame::HasChildWindow( USHORT nId
)
3794 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( nId
);
3795 return pWork
? pWork
->HasChildWindow_Impl(nId
) : FALSE
;
3798 //--------------------------------------------------------------------
3800 BOOL
SfxViewFrame::KnowsChildWindow( USHORT nId
)
3802 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( nId
);
3803 return pWork
? pWork
->KnowsChildWindow_Impl(nId
) : FALSE
;
3806 //--------------------------------------------------------------------
3808 void SfxViewFrame::ShowChildWindow( USHORT nId
, BOOL bVisible
)
3810 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( nId
);
3813 GetDispatcher()->Update_Impl(sal_True
);
3814 pWork
->ShowChildWindow_Impl(nId
, bVisible
, TRUE
);
3818 //--------------------------------------------------------------------
3820 SfxChildWindow
* SfxViewFrame::GetChildWindow(USHORT nId
)
3822 SfxWorkWindow
* pWork
= GetWorkWindow_Impl( nId
);
3823 return pWork
? pWork
->GetChildWindow_Impl(nId
) : NULL
;
3826 SfxMacro
* SfxViewFrame::GetRecordingMacro_Impl()
3828 return pImp
->pMacro
;
3831 void SfxViewFrame::UpdateDocument_Impl()
3833 SfxObjectShell
* pDoc
= GetObjectShell();
3834 if ( pDoc
->IsLoadingFinished() )
3835 pDoc
->CheckSecurityOnLoading_Impl();
3837 // check if document depends on a template
3838 pDoc
->UpdateFromTemplate_Impl();
3841 BOOL
SfxViewFrame::ClearEventFlag_Impl()
3843 if ( pImp
->bEventFlag
)
3845 pImp
->bEventFlag
= FALSE
;
3852 SfxViewFrame
* SfxViewFrame::CreateViewFrame( SfxObjectShell
& rDoc
, sal_uInt16 nViewId
, sal_Bool bHidden
)
3854 SfxItemSet
*pSet
= rDoc
.GetMedium()->GetItemSet();
3856 pSet
->Put( SfxUInt16Item( SID_VIEW_ID
, nViewId
) );
3858 pSet
->Put( SfxBoolItem( SID_HIDDEN
, sal_True
) );
3860 SfxFrame
*pFrame
= SfxTopFrame::Create( &rDoc
, 0, bHidden
);
3861 return pFrame
->GetCurrentViewFrame();
3864 void SfxViewFrame::SetViewFrame( SfxViewFrame
* pFrame
)
3866 SFX_APP()->SetViewFrame_Impl( pFrame
);