xref: /aoo42x/main/sfx2/source/view/viewfrm.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <stdio.h>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/frame/XLoadable.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
40*cdf0e10cSrcweir #include <vcl/splitwin.hxx>
41*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
42*cdf0e10cSrcweir #include <svl/intitem.hxx>
43*cdf0e10cSrcweir #include <svl/visitem.hxx>
44*cdf0e10cSrcweir #include <svl/stritem.hxx>
45*cdf0e10cSrcweir #include <svl/eitem.hxx>
46*cdf0e10cSrcweir #include <svl/slstitm.hxx>
47*cdf0e10cSrcweir #include <svl/whiter.hxx>
48*cdf0e10cSrcweir #include <svl/undo.hxx>
49*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
50*cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
51*cdf0e10cSrcweir #include <svtools/ehdl.hxx>
52*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
53*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/frame/XFrames.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
60*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
61*cdf0e10cSrcweir #include <com/sun/star/frame/XModel2.hpp>
62*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
63*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
64*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
65*cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp>
66*cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp>
67*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
68*cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp>
69*cdf0e10cSrcweir #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
70*cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
71*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
72*cdf0e10cSrcweir #include <com/sun/star/document/XViewDataSupplier.hpp>
73*cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp>
74*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
77*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx>
78*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
79*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
80*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx>
81*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
82*cdf0e10cSrcweir #include <comphelper/docpasswordrequest.hxx>
83*cdf0e10cSrcweir #include <comphelper/docpasswordhelper.hxx>
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
86*cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp>
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir #include <basic/basmgr.hxx>
89*cdf0e10cSrcweir #include <basic/sbmod.hxx>
90*cdf0e10cSrcweir #include <basic/sbmeth.hxx>
91*cdf0e10cSrcweir #include <basic/sbx.hxx>
92*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
93*cdf0e10cSrcweir #include <svtools/asynclink.hxx>
94*cdf0e10cSrcweir #include <svl/sharecontrolfile.hxx>
95*cdf0e10cSrcweir #include <svtools/svtools.hrc>
96*cdf0e10cSrcweir #include <svtools/svtdata.hxx>
97*cdf0e10cSrcweir #include <framework/framelistanalyzer.hxx>
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir #include <boost/optional.hpp>
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir using namespace ::com::sun::star;
102*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
103*cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
104*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
105*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
106*cdf0e10cSrcweir using ::com::sun::star::awt::XWindow;
107*cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue;
108*cdf0e10cSrcweir using ::com::sun::star::document::XViewDataSupplier;
109*cdf0e10cSrcweir using ::com::sun::star::container::XIndexContainer;
110*cdf0e10cSrcweir namespace css = ::com::sun::star;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir // wg. ViewFrame::Current
113*cdf0e10cSrcweir #include "appdata.hxx"
114*cdf0e10cSrcweir #include <sfx2/taskpane.hxx>
115*cdf0e10cSrcweir #include <sfx2/app.hxx>
116*cdf0e10cSrcweir #include <sfx2/objface.hxx>
117*cdf0e10cSrcweir #include "openflag.hxx"
118*cdf0e10cSrcweir #include "objshimp.hxx"
119*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
120*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
121*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
122*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
123*cdf0e10cSrcweir #include "arrdecl.hxx"
124*cdf0e10cSrcweir #include "sfxtypes.hxx"
125*cdf0e10cSrcweir #include <sfx2/request.hxx>
126*cdf0e10cSrcweir #include <sfx2/docfac.hxx>
127*cdf0e10cSrcweir #include <sfx2/ipclient.hxx>
128*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
129*cdf0e10cSrcweir #include "appbas.hxx"
130*cdf0e10cSrcweir #include <sfx2/objitem.hxx>
131*cdf0e10cSrcweir #include "sfx2/viewfac.hxx"
132*cdf0e10cSrcweir #include <sfx2/event.hxx>
133*cdf0e10cSrcweir #include "fltfnc.hxx"
134*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
135*cdf0e10cSrcweir #include <sfx2/module.hxx>
136*cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
137*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
138*cdf0e10cSrcweir #include "viewimp.hxx"
139*cdf0e10cSrcweir #include <sfx2/sfxbasecontroller.hxx>
140*cdf0e10cSrcweir #include <sfx2/sfx.hrc>
141*cdf0e10cSrcweir #include "view.hrc"
142*cdf0e10cSrcweir #include <sfx2/frmdescr.hxx>
143*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
144*cdf0e10cSrcweir #include <sfx2/progress.hxx>
145*cdf0e10cSrcweir #include "workwin.hxx"
146*cdf0e10cSrcweir #include "helper.hxx"
147*cdf0e10cSrcweir #include "macro.hxx"
148*cdf0e10cSrcweir #include "sfx2/minfitem.hxx"
149*cdf0e10cSrcweir #include "../appl/app.hrc"
150*cdf0e10cSrcweir #include "impviewframe.hxx"
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir //-------------------------------------------------------------------------
153*cdf0e10cSrcweir DBG_NAME(SfxViewFrame)
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir #define SfxViewFrame
156*cdf0e10cSrcweir #include "sfxslots.hxx"
157*cdf0e10cSrcweir #undef SfxViewFrame
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir //-------------------------------------------------------------------------
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir SFX_IMPL_INTERFACE(SfxViewFrame,SfxShell,SfxResId(0))
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION( SID_BROWSER );
164*cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION( SID_RECORDING_FLOATWINDOW );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_FULLSCREEN | SFX_VISIBILITY_FULLSCREEN, SfxResId(RID_FULLSCREENTOOLBOX) );
167*cdf0e10cSrcweir     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_STANDARD, SfxResId(RID_ENVTOOLBOX) );
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir TYPEINIT2(SfxViewFrame,SfxShell,SfxListener);
171*cdf0e10cSrcweir TYPEINIT1(SfxViewFrameItem, SfxPoolItem);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir //=========================================================================
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir //-------------------------------------------------------------------------
176*cdf0e10cSrcweir namespace
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     bool moduleHasToolPanels( SfxViewFrame_Impl& i_rViewFrameImpl )
179*cdf0e10cSrcweir     {
180*cdf0e10cSrcweir         if ( !i_rViewFrameImpl.aHasToolPanels )
181*cdf0e10cSrcweir         {
182*cdf0e10cSrcweir             i_rViewFrameImpl.aHasToolPanels.reset( ::sfx2::ModuleTaskPane::ModuleHasToolPanels(
183*cdf0e10cSrcweir                 i_rViewFrameImpl.rFrame.GetFrameInterface() ) );
184*cdf0e10cSrcweir         }
185*cdf0e10cSrcweir         return *i_rViewFrameImpl.aHasToolPanels;
186*cdf0e10cSrcweir     }
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir //-------------------------------------------------------------------------
190*cdf0e10cSrcweir static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue > aInfo )
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir     // TODO/LATER: In future the info should replace the direct hash completely
193*cdf0e10cSrcweir     sal_Bool bResult = ( !nPasswordHash && !aInfo.getLength() );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     OSL_ENSURE( pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ), "PasswordToModify feature is active for a filter that does not support it!" );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     if ( pFilter && xHandler.is() )
198*cdf0e10cSrcweir     {
199*cdf0e10cSrcweir         sal_Bool bCancel = sal_False;
200*cdf0e10cSrcweir         sal_Bool bFirstTime = sal_True;
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir         while ( !bResult && !bCancel )
203*cdf0e10cSrcweir         {
204*cdf0e10cSrcweir             sal_Bool bMSType = !pFilter->IsOwnFormat();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir             ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest(
207*cdf0e10cSrcweir                  new ::comphelper::DocPasswordRequest(
208*cdf0e10cSrcweir                  bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD,
209*cdf0e10cSrcweir                  bFirstTime ? ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER : ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER,
210*cdf0e10cSrcweir                  aPath,
211*cdf0e10cSrcweir                  sal_True ) );
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir             uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() );
214*cdf0e10cSrcweir             xHandler->handle( rRequest );
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir             if ( pPasswordRequest->isPassword() )
217*cdf0e10cSrcweir             {
218*cdf0e10cSrcweir                 if ( aInfo.getLength() )
219*cdf0e10cSrcweir                 {
220*cdf0e10cSrcweir                     bResult = ::comphelper::DocPasswordHelper::IsModifyPasswordCorrect( pPasswordRequest->getPasswordToModify(), aInfo );
221*cdf0e10cSrcweir                 }
222*cdf0e10cSrcweir                 else
223*cdf0e10cSrcweir                 {
224*cdf0e10cSrcweir                     // the binary format
225*cdf0e10cSrcweir                     bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash );
226*cdf0e10cSrcweir                 }
227*cdf0e10cSrcweir             }
228*cdf0e10cSrcweir             else
229*cdf0e10cSrcweir                 bCancel = sal_True;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir             bFirstTime = sal_False;
232*cdf0e10cSrcweir         }
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     return bResult;
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir //-------------------------------------------------------------------------
239*cdf0e10cSrcweir void SfxViewFrame::SetDowning_Impl()
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     pImp->bIsDowning = sal_True;
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir //-------------------------------------------------------------------------
245*cdf0e10cSrcweir sal_Bool SfxViewFrame::IsDowning_Impl() const
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir     return pImp->bIsDowning;
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir //--------------------------------------------------------------------
252*cdf0e10cSrcweir class SfxViewNotificatedFrameList_Impl :
253*cdf0e10cSrcweir     public SfxListener, public SfxViewFrameArr_Impl
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir public:
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir     void InsertViewFrame( SfxViewFrame* pFrame )
258*cdf0e10cSrcweir     {
259*cdf0e10cSrcweir         StartListening( *pFrame );
260*cdf0e10cSrcweir         C40_INSERT( SfxViewFrame, pFrame, Count() );
261*cdf0e10cSrcweir     }
262*cdf0e10cSrcweir     void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
263*cdf0e10cSrcweir };
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir //-------------------------------------------------------------------------
266*cdf0e10cSrcweir void SfxViewNotificatedFrameList_Impl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
269*cdf0e10cSrcweir     {
270*cdf0e10cSrcweir         switch( ( (SfxSimpleHint&) rHint ).GetId() )
271*cdf0e10cSrcweir         {
272*cdf0e10cSrcweir             case SFX_HINT_DYING:
273*cdf0e10cSrcweir                 SfxViewFrame* pFrame = (SfxViewFrame*) &rBC;
274*cdf0e10cSrcweir                 if( pFrame )
275*cdf0e10cSrcweir                 {
276*cdf0e10cSrcweir                     sal_uInt16 nPos = C40_GETPOS( SfxViewFrame, pFrame );
277*cdf0e10cSrcweir                     if( nPos != USHRT_MAX )
278*cdf0e10cSrcweir 						Remove( nPos );
279*cdf0e10cSrcweir                 }
280*cdf0e10cSrcweir                 break;
281*cdf0e10cSrcweir         }
282*cdf0e10cSrcweir     }
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir //-------------------------------------------------------------------------
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir long ReloadDecouple_Impl( void* pObj, void* pArg )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir     ((SfxViewFrame*) pObj)->ExecReload_Impl( *(SfxRequest*)pArg );
290*cdf0e10cSrcweir     return 0;
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq, sal_Bool bAsync )
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir 	if( bAsync )
296*cdf0e10cSrcweir 	{
297*cdf0e10cSrcweir 		if( !pImp->pReloader )
298*cdf0e10cSrcweir             pImp->pReloader = new svtools::AsynchronLink(
299*cdf0e10cSrcweir 				Link( this, ReloadDecouple_Impl ) );
300*cdf0e10cSrcweir 		pImp->pReloader->Call( new SfxRequest( rReq ) );
301*cdf0e10cSrcweir 	}
302*cdf0e10cSrcweir 	else ExecReload_Impl( rReq );
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir     SfxFrame *pParent = GetFrame().GetParentFrame();
308*cdf0e10cSrcweir 	if ( rReq.GetSlot() == SID_RELOAD )
309*cdf0e10cSrcweir 	{
310*cdf0e10cSrcweir         // Bei CTRL-Reload den aktiven Frame reloaden
311*cdf0e10cSrcweir         SfxViewFrame* pActFrame = this;
312*cdf0e10cSrcweir         while ( pActFrame )
313*cdf0e10cSrcweir             pActFrame = pActFrame->GetActiveChildFrame_Impl();
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir         if ( pActFrame )
316*cdf0e10cSrcweir         {
317*cdf0e10cSrcweir             sal_uInt16 nModifier = rReq.GetModifier();
318*cdf0e10cSrcweir             if ( nModifier & KEY_MOD1 )
319*cdf0e10cSrcweir             {
320*cdf0e10cSrcweir                 pActFrame->ExecReload_Impl( rReq );
321*cdf0e10cSrcweir                 return;
322*cdf0e10cSrcweir             }
323*cdf0e10cSrcweir         }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 		// Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames
326*cdf0e10cSrcweir 		// gemacht werden soll
327*cdf0e10cSrcweir 		SfxFrame& rFrame = GetFrame();
328*cdf0e10cSrcweir 		if ( pParent == &rFrame && rFrame.GetChildFrameCount() )
329*cdf0e10cSrcweir 		{
330*cdf0e10cSrcweir 			sal_Bool bReloadAvailable = sal_False;
331*cdf0e10cSrcweir 			SfxFrameIterator aIter( rFrame, sal_False );
332*cdf0e10cSrcweir 			SfxFrame *pChild = aIter.FirstFrame();
333*cdf0e10cSrcweir 			while ( pChild )
334*cdf0e10cSrcweir 			{
335*cdf0e10cSrcweir 				SfxFrame *pNext = aIter.NextFrame( *pChild );
336*cdf0e10cSrcweir 				SfxObjectShell *pShell = pChild->GetCurrentDocument();
337*cdf0e10cSrcweir 				if( pShell && pShell->Get_Impl()->bReloadAvailable )
338*cdf0e10cSrcweir 				{
339*cdf0e10cSrcweir 					bReloadAvailable = sal_True;
340*cdf0e10cSrcweir 					pChild->GetCurrentViewFrame()->ExecuteSlot( rReq );
341*cdf0e10cSrcweir 				}
342*cdf0e10cSrcweir 				pChild = pNext;
343*cdf0e10cSrcweir 			}
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 			// Der TopLevel-Frame selbst het keine Graphiken!
346*cdf0e10cSrcweir 			if ( bReloadAvailable )
347*cdf0e10cSrcweir 				return;
348*cdf0e10cSrcweir 		}
349*cdf0e10cSrcweir     }
350*cdf0e10cSrcweir     else
351*cdf0e10cSrcweir     {
352*cdf0e10cSrcweir         // Bei CTRL-Edit den TopFrame bearbeiten
353*cdf0e10cSrcweir         sal_uInt16 nModifier = rReq.GetModifier();
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         if ( ( nModifier & KEY_MOD1 ) && pParent )
356*cdf0e10cSrcweir         {
357*cdf0e10cSrcweir             SfxViewFrame *pTop = GetTopViewFrame();
358*cdf0e10cSrcweir             pTop->ExecReload_Impl( rReq );
359*cdf0e10cSrcweir             return;
360*cdf0e10cSrcweir         }
361*cdf0e10cSrcweir     }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir     SfxObjectShell* pSh = GetObjectShell();
364*cdf0e10cSrcweir     switch ( rReq.GetSlot() )
365*cdf0e10cSrcweir     {
366*cdf0e10cSrcweir         case SID_EDITDOC:
367*cdf0e10cSrcweir         {
368*cdf0e10cSrcweir 			if ( GetFrame().HasComponent() )
369*cdf0e10cSrcweir 				break;
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir             // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
372*cdf0e10cSrcweir             // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
373*cdf0e10cSrcweir             // trotzdem nicht geht!
374*cdf0e10cSrcweir             if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ))
375*cdf0e10cSrcweir                 break;
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir             SfxMedium* pMed = pSh->GetMedium();
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir             SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
380*cdf0e10cSrcweir         	if ( pItem && pItem->GetValue() )
381*cdf0e10cSrcweir 			{
382*cdf0e10cSrcweir 				SfxApplication* pApp = SFX_APP();
383*cdf0e10cSrcweir 				SfxAllItemSet aSet( pApp->GetPool() );
384*cdf0e10cSrcweir 				aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetURLObject().GetMainURL(INetURLObject::NO_DECODE) ) );
385*cdf0e10cSrcweir 				aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
386*cdf0e10cSrcweir 				aSet.Put( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii("_blank") ) );
387*cdf0e10cSrcweir                 SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False );
388*cdf0e10cSrcweir 				if ( pReferer )
389*cdf0e10cSrcweir 					aSet.Put( *pReferer );
390*cdf0e10cSrcweir 		        SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pVersionItem, SfxInt16Item, SID_VERSION, sal_False );
391*cdf0e10cSrcweir 				if ( pVersionItem )
392*cdf0e10cSrcweir 					aSet.Put( *pVersionItem );
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 				if( pMed->GetFilter() )
395*cdf0e10cSrcweir 				{
396*cdf0e10cSrcweir                     aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
397*cdf0e10cSrcweir 			        SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
398*cdf0e10cSrcweir 					if ( pOptions )
399*cdf0e10cSrcweir 						aSet.Put( *pOptions );
400*cdf0e10cSrcweir 				}
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir                 GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
403*cdf0e10cSrcweir                 return;
404*cdf0e10cSrcweir 			}
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir             sal_uInt16 nOpenMode;
407*cdf0e10cSrcweir             sal_Bool bNeedsReload = sal_False;
408*cdf0e10cSrcweir             if ( !pSh->IsReadOnly() )
409*cdf0e10cSrcweir             {
410*cdf0e10cSrcweir                 // Speichern und Readonly Reloaden
411*cdf0e10cSrcweir                 if( pSh->IsModified() )
412*cdf0e10cSrcweir                 {
413*cdf0e10cSrcweir                     if ( pSh->PrepareClose() )
414*cdf0e10cSrcweir                     {
415*cdf0e10cSrcweir                         // the storing could let the medium be changed
416*cdf0e10cSrcweir                         pMed = pSh->GetMedium();
417*cdf0e10cSrcweir                         bNeedsReload = sal_True;
418*cdf0e10cSrcweir                     }
419*cdf0e10cSrcweir                     else
420*cdf0e10cSrcweir                     {
421*cdf0e10cSrcweir                         rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) );
422*cdf0e10cSrcweir                         return;
423*cdf0e10cSrcweir                     }
424*cdf0e10cSrcweir                 }
425*cdf0e10cSrcweir                 nOpenMode = SFX_STREAM_READONLY;
426*cdf0e10cSrcweir             }
427*cdf0e10cSrcweir             else
428*cdf0e10cSrcweir 			{
429*cdf0e10cSrcweir                 if ( pSh->IsReadOnlyMedium()
430*cdf0e10cSrcweir                   && ( pSh->GetModifyPasswordHash() || pSh->GetModifyPasswordInfo().getLength() )
431*cdf0e10cSrcweir                   && !pSh->IsModifyPasswordEntered() )
432*cdf0e10cSrcweir                 {
433*cdf0e10cSrcweir                     ::rtl::OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
434*cdf0e10cSrcweir                     if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash(), pSh->GetModifyPasswordInfo() ) )
435*cdf0e10cSrcweir                     {
436*cdf0e10cSrcweir                         // this is a read-only document, if it has "Password to modify"
437*cdf0e10cSrcweir                         // the user should enter password before he can edit the document
438*cdf0e10cSrcweir                         rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) );
439*cdf0e10cSrcweir                         return;
440*cdf0e10cSrcweir                     }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir                     pSh->SetModifyPasswordEntered();
443*cdf0e10cSrcweir                 }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir                 nOpenMode = SFX_STREAM_READWRITE;
446*cdf0e10cSrcweir                 pSh->SetReadOnlyUI( sal_False );
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir                 // if only the view was in the readonly mode then there is no need to do the reload
449*cdf0e10cSrcweir                 if ( !pSh->IsReadOnly() )
450*cdf0e10cSrcweir                     return;
451*cdf0e10cSrcweir 			}
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 			// Parameter auswerten
454*cdf0e10cSrcweir             // sal_Bool bReload = sal_True;
455*cdf0e10cSrcweir 			if ( rReq.IsAPI() )
456*cdf0e10cSrcweir 			{
457*cdf0e10cSrcweir 				// per API steuern ob r/w oder r/o
458*cdf0e10cSrcweir             	SFX_REQUEST_ARG(rReq, pEditItem, SfxBoolItem, SID_EDITDOC, sal_False);
459*cdf0e10cSrcweir 				if ( pEditItem )
460*cdf0e10cSrcweir 					nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
461*cdf0e10cSrcweir 			}
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 			// doing
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir             String aTemp;
466*cdf0e10cSrcweir             utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed->GetPhysicalName(), aTemp );
467*cdf0e10cSrcweir             INetURLObject aPhysObj( aTemp );
468*cdf0e10cSrcweir             SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(),
469*cdf0e10cSrcweir                              pVersionItem, SfxInt16Item, SID_VERSION, sal_False );
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir             INetURLObject aMedObj( pMed->GetName() );
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir             // the logic below is following, if the document seems not to need to be reloaded and the physical name is different
474*cdf0e10cSrcweir             // 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
475*cdf0e10cSrcweir             if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE &&
476*cdf0e10cSrcweir                     aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) &&
477*cdf0e10cSrcweir                     !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) ))
478*cdf0e10cSrcweir                   || pMed->IsRemote() ) )
479*cdf0e10cSrcweir                || pVersionItem )
480*cdf0e10cSrcweir             {
481*cdf0e10cSrcweir                 sal_Bool bOK = sal_False;
482*cdf0e10cSrcweir                 if ( !pVersionItem )
483*cdf0e10cSrcweir                 {
484*cdf0e10cSrcweir                     sal_Bool bHasStorage = pMed->HasStorage_Impl();
485*cdf0e10cSrcweir                     // switching edit mode could be possible without reload
486*cdf0e10cSrcweir                     if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() )
487*cdf0e10cSrcweir                     {
488*cdf0e10cSrcweir                         // TODO/LATER: faster creation of copy
489*cdf0e10cSrcweir                         if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) )
490*cdf0e10cSrcweir                             return;
491*cdf0e10cSrcweir                     }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir                     pMed->CloseAndRelease();
494*cdf0e10cSrcweir                     pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) );
495*cdf0e10cSrcweir                     pMed->SetOpenMode( nOpenMode, pMed->IsDirect() );
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir                     pMed->CompleteReOpen();
498*cdf0e10cSrcweir                     if ( nOpenMode & STREAM_WRITE )
499*cdf0e10cSrcweir                         pMed->LockOrigFileOnDemand( sal_False, sal_True );
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir                     // LockOrigFileOnDemand might set the readonly flag itself, it should be set back
502*cdf0e10cSrcweir                     pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir                     if ( !pMed->GetErrorCode() )
505*cdf0e10cSrcweir                         bOK = sal_True;
506*cdf0e10cSrcweir                 }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir                 if( !bOK )
509*cdf0e10cSrcweir                 {
510*cdf0e10cSrcweir                     ErrCode nErr = pMed->GetErrorCode();
511*cdf0e10cSrcweir                     if ( pVersionItem )
512*cdf0e10cSrcweir                         nErr = ERRCODE_IO_ACCESSDENIED;
513*cdf0e10cSrcweir                     else
514*cdf0e10cSrcweir                     {
515*cdf0e10cSrcweir                         pMed->ResetError();
516*cdf0e10cSrcweir                         pMed->SetOpenMode( SFX_STREAM_READONLY, pMed->IsDirect() );
517*cdf0e10cSrcweir                         pMed->ReOpen();
518*cdf0e10cSrcweir                         pSh->DoSaveCompleted( pMed );
519*cdf0e10cSrcweir                     }
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir                     // r/o-Doc kann nicht in Editmode geschaltet werden?
522*cdf0e10cSrcweir                     rReq.Done( sal_False );
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir                     if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
525*cdf0e10cSrcweir                     {
526*cdf0e10cSrcweir                         // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen
527*cdf0e10cSrcweir                         QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
528*cdf0e10cSrcweir                         if ( RET_YES == aBox.Execute() )
529*cdf0e10cSrcweir                         {
530*cdf0e10cSrcweir                             SfxApplication* pApp = SFX_APP();
531*cdf0e10cSrcweir                             SfxAllItemSet aSet( pApp->GetPool() );
532*cdf0e10cSrcweir                             aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
533*cdf0e10cSrcweir                             SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False );
534*cdf0e10cSrcweir                             if ( pReferer )
535*cdf0e10cSrcweir                                 aSet.Put( *pReferer );
536*cdf0e10cSrcweir                             aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
537*cdf0e10cSrcweir                             if ( pVersionItem )
538*cdf0e10cSrcweir                                 aSet.Put( *pVersionItem );
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir                             if( pMed->GetFilter() )
541*cdf0e10cSrcweir                             {
542*cdf0e10cSrcweir                                 aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
543*cdf0e10cSrcweir                                 SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions,
544*cdf0e10cSrcweir                                                  SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
545*cdf0e10cSrcweir                                 if ( pOptions )
546*cdf0e10cSrcweir                                     aSet.Put( *pOptions );
547*cdf0e10cSrcweir                             }
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir                             GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
550*cdf0e10cSrcweir                             return;
551*cdf0e10cSrcweir                         }
552*cdf0e10cSrcweir                         else
553*cdf0e10cSrcweir                             nErr = 0;
554*cdf0e10cSrcweir                     }
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir                     ErrorHandler::HandleError( nErr );
557*cdf0e10cSrcweir                     rReq.SetReturnValue(
558*cdf0e10cSrcweir                         SfxBoolItem( rReq.GetSlot(), sal_False ) );
559*cdf0e10cSrcweir                     return;
560*cdf0e10cSrcweir                 }
561*cdf0e10cSrcweir                 else
562*cdf0e10cSrcweir                 {
563*cdf0e10cSrcweir                     pSh->DoSaveCompleted( pMed );
564*cdf0e10cSrcweir                     pSh->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
565*cdf0e10cSrcweir                     rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_True ) );
566*cdf0e10cSrcweir                     rReq.Done( sal_True );
567*cdf0e10cSrcweir                     // if( nOpenMode == SFX_STREAM_READONLY )
568*cdf0e10cSrcweir                     //    pMed->Close();
569*cdf0e10cSrcweir                     return;
570*cdf0e10cSrcweir                 }
571*cdf0e10cSrcweir             }
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir             rReq.AppendItem( SfxBoolItem( SID_FORCERELOAD, sal_True) );
574*cdf0e10cSrcweir             rReq.AppendItem( SfxBoolItem( SID_SILENT, sal_True ));
575*cdf0e10cSrcweir         }
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir         case SID_RELOAD:
578*cdf0e10cSrcweir         {
579*cdf0e10cSrcweir             // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch
580*cdf0e10cSrcweir             // m"oglich, da\s der Slot zwar enabled ist, aber Ctrl-Click
581*cdf0e10cSrcweir             // trotzdem nicht geht!
582*cdf0e10cSrcweir             if ( !pSh || !pSh->CanReload_Impl() )
583*cdf0e10cSrcweir                 break;
584*cdf0e10cSrcweir             SfxApplication* pApp = SFX_APP();
585*cdf0e10cSrcweir             SFX_REQUEST_ARG(rReq, pForceReloadItem, SfxBoolItem,
586*cdf0e10cSrcweir                             SID_FORCERELOAD, sal_False);
587*cdf0e10cSrcweir             if(  pForceReloadItem && !pForceReloadItem->GetValue() &&
588*cdf0e10cSrcweir                 !pSh->GetMedium()->IsExpired() )
589*cdf0e10cSrcweir                 return;
590*cdf0e10cSrcweir             if( pImp->bReloading || pSh->IsInModalMode() )
591*cdf0e10cSrcweir                 return;
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir             // AutoLoad ist ggf. verboten
594*cdf0e10cSrcweir             SFX_REQUEST_ARG(rReq, pAutoLoadItem, SfxBoolItem, SID_AUTOLOAD, sal_False);
595*cdf0e10cSrcweir             if ( pAutoLoadItem && pAutoLoadItem->GetValue() &&
596*cdf0e10cSrcweir                  GetFrame().IsAutoLoadLocked_Impl() )
597*cdf0e10cSrcweir                 return;
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir             SfxObjectShellLock xOldObj( pSh );
600*cdf0e10cSrcweir             pImp->bReloading = sal_True;
601*cdf0e10cSrcweir             SFX_REQUEST_ARG(rReq, pURLItem, SfxStringItem,
602*cdf0e10cSrcweir                             SID_FILE_NAME, sal_False);
603*cdf0e10cSrcweir             // editierbar "offnen?
604*cdf0e10cSrcweir             sal_Bool bForEdit = !pSh->IsReadOnly();
605*cdf0e10cSrcweir             if ( rReq.GetSlot() == SID_EDITDOC )
606*cdf0e10cSrcweir                 bForEdit = !bForEdit;
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir             // ggf. beim User nachfragen
609*cdf0e10cSrcweir             sal_Bool bDo = ( GetViewShell()->PrepareClose() != sal_False );
610*cdf0e10cSrcweir             SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
611*cdf0e10cSrcweir             if ( bDo && GetFrame().DocIsModified_Impl() &&
612*cdf0e10cSrcweir 				 !rReq.IsAPI() && ( !pSilentItem || !pSilentItem->GetValue() ) )
613*cdf0e10cSrcweir             {
614*cdf0e10cSrcweir                 QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_LASTVERSION) );
615*cdf0e10cSrcweir                 bDo = ( RET_YES == aBox.Execute() );
616*cdf0e10cSrcweir             }
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir             if ( bDo )
619*cdf0e10cSrcweir             {
620*cdf0e10cSrcweir                 SfxMedium *pMedium = xOldObj->GetMedium();
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 				// Frameset abziehen, bevor FramesetView evtl. verschwindet
623*cdf0e10cSrcweir 				String aURL = pURLItem ? pURLItem->GetValue() :
624*cdf0e10cSrcweir 								pMedium->GetName();
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir                 sal_Bool bHandsOff =
627*cdf0e10cSrcweir                     ( pMedium->GetURLObject().GetProtocol() == INET_PROT_FILE && !xOldObj->IsDocShared() );
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir                 // bestehende SfxMDIFrames f"ur dieses Doc leeren
630*cdf0e10cSrcweir                 // eigenes Format oder R/O jetzt editierbar "offnen?
631*cdf0e10cSrcweir                 SfxObjectShellLock xNewObj;
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir                 // collect the views of the document
634*cdf0e10cSrcweir                 // TODO: when UNO ViewFactories are available for SFX-based documents, the below code should
635*cdf0e10cSrcweir                 // be UNOized, too
636*cdf0e10cSrcweir                 typedef ::std::pair< Reference< XFrame >, sal_uInt16 >  ViewDescriptor;
637*cdf0e10cSrcweir                 ::std::list< ViewDescriptor > aViewFrames;
638*cdf0e10cSrcweir                 SfxViewFrame *pView = GetFirst( xOldObj );
639*cdf0e10cSrcweir 				while ( pView )
640*cdf0e10cSrcweir 				{
641*cdf0e10cSrcweir                     Reference< XFrame > xFrame( pView->GetFrame().GetFrameInterface() );
642*cdf0e10cSrcweir                     OSL_ENSURE( xFrame.is(), "SfxViewFrame::ExecReload_Impl: no XFrame?!" );
643*cdf0e10cSrcweir 					aViewFrames.push_back( ViewDescriptor( xFrame, pView->GetCurViewId() ) );
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir                     pView = GetNext( *pView, xOldObj );
646*cdf0e10cSrcweir 				}
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir                 DELETEZ( xOldObj->Get_Impl()->pReloadTimer );
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir                 SfxItemSet* pNewSet = 0;
651*cdf0e10cSrcweir                 const SfxFilter *pFilter = pMedium->GetFilter();
652*cdf0e10cSrcweir                 if( pURLItem )
653*cdf0e10cSrcweir 				{
654*cdf0e10cSrcweir 					pNewSet = new SfxAllItemSet( pApp->GetPool() );
655*cdf0e10cSrcweir 					pNewSet->Put( *pURLItem );
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 					// Filter Detection
658*cdf0e10cSrcweir 					SfxMedium aMedium( pURLItem->GetValue(), SFX_STREAM_READWRITE );
659*cdf0e10cSrcweir 					SfxFilterMatcher().GuessFilter( aMedium, &pFilter );
660*cdf0e10cSrcweir 					if ( pFilter )
661*cdf0e10cSrcweir 	                    pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
662*cdf0e10cSrcweir 					pNewSet->Put( *aMedium.GetItemSet() );
663*cdf0e10cSrcweir 				}
664*cdf0e10cSrcweir 				else
665*cdf0e10cSrcweir 				{
666*cdf0e10cSrcweir 					pNewSet = new SfxAllItemSet( *pMedium->GetItemSet() );
667*cdf0e10cSrcweir 					pNewSet->ClearItem( SID_VIEW_ID );
668*cdf0e10cSrcweir 					pNewSet->ClearItem( SID_STREAM );
669*cdf0e10cSrcweir 					pNewSet->ClearItem( SID_INPUTSTREAM );
670*cdf0e10cSrcweir                     pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pMedium->GetFilter()->GetName() ) );
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir                     // let the current security settings be checked again
673*cdf0e10cSrcweir                     pNewSet->Put( SfxUInt16Item( SID_MACROEXECMODE, document::MacroExecMode::USE_CONFIG ) );
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir                     if ( rReq.GetSlot() == SID_EDITDOC || !bForEdit )
676*cdf0e10cSrcweir                         // edit mode is switched or reload of readonly document
677*cdf0e10cSrcweir                         pNewSet->Put( SfxBoolItem( SID_DOC_READONLY, !bForEdit ) );
678*cdf0e10cSrcweir                     else
679*cdf0e10cSrcweir                         // Reload of file opened for writing
680*cdf0e10cSrcweir                         pNewSet->ClearItem( SID_DOC_READONLY );
681*cdf0e10cSrcweir 				}
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 				// Falls eine salvagede Datei vorliegt, nicht nochmals die
684*cdf0e10cSrcweir 				// OrigURL mitschicken, denn die Tempdate ist nach Reload
685*cdf0e10cSrcweir 				// ungueltig
686*cdf0e10cSrcweir                 SFX_ITEMSET_ARG( pNewSet, pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, sal_False);
687*cdf0e10cSrcweir 				if( pSalvageItem )
688*cdf0e10cSrcweir 				{
689*cdf0e10cSrcweir 					aURL = pSalvageItem->GetValue();
690*cdf0e10cSrcweir 					pNewSet->ClearItem( SID_DOC_SALVAGE );
691*cdf0e10cSrcweir 				}
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir                 // TODO/LATER: Temporary solution, the SfxMedium must know the original URL as aLogicName
694*cdf0e10cSrcweir                 //             SfxMedium::Transfer_Impl() will be vorbidden then.
695*cdf0e10cSrcweir                 if ( xOldObj->IsDocShared() )
696*cdf0e10cSrcweir                     pNewSet->Put( SfxStringItem( SID_FILE_NAME, xOldObj->GetSharedFileURL() ) );
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir                 //pNewMedium = new SfxMedium( aURL, nMode, pMedium->IsDirect(), bUseFilter ? pMedium->GetFilter() : 0, pNewSet );
699*cdf0e10cSrcweir                 //pNewSet = pNewMedium->GetItemSet();
700*cdf0e10cSrcweir                 if ( pURLItem )
701*cdf0e10cSrcweir 					pNewSet->Put( SfxStringItem( SID_REFERER, pMedium->GetName() ) );
702*cdf0e10cSrcweir                 else
703*cdf0e10cSrcweir                     pNewSet->Put( SfxStringItem( SID_REFERER, String() ) );
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir                 xOldObj->CancelTransfers();
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir                 // eigentliches Reload
708*cdf0e10cSrcweir                 //pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) );
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir                 if ( pSilentItem && pSilentItem->GetValue() )
711*cdf0e10cSrcweir                     pNewSet->Put( SfxBoolItem( SID_SILENT, sal_True ) );
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 		        SFX_ITEMSET_ARG(pNewSet, pInteractionItem, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False);
714*cdf0e10cSrcweir 		        SFX_ITEMSET_ARG(pNewSet, pMacroExecItem  , SfxUInt16Item, SID_MACROEXECMODE     , sal_False);
715*cdf0e10cSrcweir 		        SFX_ITEMSET_ARG(pNewSet, pDocTemplateItem, SfxUInt16Item, SID_UPDATEDOCMODE     , sal_False);
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir 		        if (!pInteractionItem)
718*cdf0e10cSrcweir 		        {
719*cdf0e10cSrcweir 		            Reference < ::com::sun::star::task::XInteractionHandler > xHdl( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY );
720*cdf0e10cSrcweir 		            if (xHdl.is())
721*cdf0e10cSrcweir 		                pNewSet->Put( SfxUnoAnyItem(SID_INTERACTIONHANDLER,::com::sun::star::uno::makeAny(xHdl)) );
722*cdf0e10cSrcweir 		        }
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir 		        if (!pMacroExecItem)
725*cdf0e10cSrcweir 		            pNewSet->Put( SfxUInt16Item(SID_MACROEXECMODE,::com::sun::star::document::MacroExecMode::USE_CONFIG) );
726*cdf0e10cSrcweir 		        if (!pDocTemplateItem)
727*cdf0e10cSrcweir 		            pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir 				xOldObj->SetModified( sal_False );
730*cdf0e10cSrcweir                 // Altes Dok nicht cachen! Gilt nicht, wenn anderes
731*cdf0e10cSrcweir 				// Doc geladen wird.
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False);
734*cdf0e10cSrcweir                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False);
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir                 sal_Bool bHasStorage = pMedium->HasStorage_Impl();
737*cdf0e10cSrcweir                 if( bHandsOff )
738*cdf0e10cSrcweir                 {
739*cdf0e10cSrcweir                     if ( bHasStorage && pMedium->GetStorage() == xOldObj->GetStorage() )
740*cdf0e10cSrcweir                     {
741*cdf0e10cSrcweir                         // TODO/LATER: faster creation of copy
742*cdf0e10cSrcweir 						if ( !xOldObj->ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) )
743*cdf0e10cSrcweir                             return;
744*cdf0e10cSrcweir                     }
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir                     pMedium->CloseAndRelease();
747*cdf0e10cSrcweir                 }
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir                 xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_STANDARD );
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir                 if ( xOldObj->IsModifyPasswordEntered() )
752*cdf0e10cSrcweir                     xNewObj->SetModifyPasswordEntered();
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir                 uno::Sequence < beans::PropertyValue > aLoadArgs;
755*cdf0e10cSrcweir                 TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs );
756*cdf0e10cSrcweir                 try
757*cdf0e10cSrcweir                 {
758*cdf0e10cSrcweir                     uno::Reference < frame::XLoadable > xLoad( xNewObj->GetModel(), uno::UNO_QUERY );
759*cdf0e10cSrcweir                     xLoad->load( aLoadArgs );
760*cdf0e10cSrcweir                 }
761*cdf0e10cSrcweir                 catch ( uno::Exception& )
762*cdf0e10cSrcweir                 {
763*cdf0e10cSrcweir                     xNewObj->DoClose();
764*cdf0e10cSrcweir                     xNewObj = 0;
765*cdf0e10cSrcweir                 }
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 				DELETEZ( pNewSet );
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir                 if( !xNewObj.Is() )
770*cdf0e10cSrcweir                 {
771*cdf0e10cSrcweir 					if( bHandsOff )
772*cdf0e10cSrcweir                     {
773*cdf0e10cSrcweir                         // back to old medium
774*cdf0e10cSrcweir                         pMedium->ReOpen();
775*cdf0e10cSrcweir                         pMedium->LockOrigFileOnDemand( sal_False, sal_True );
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir                         xOldObj->DoSaveCompleted( pMedium );
778*cdf0e10cSrcweir                     }
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir                     // r/o-Doc couldn't be switched to writing mode
781*cdf0e10cSrcweir                     if ( bForEdit && SID_EDITDOC == rReq.GetSlot() )
782*cdf0e10cSrcweir                     {
783*cdf0e10cSrcweir                         // ask user for opening as template
784*cdf0e10cSrcweir                         QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) );
785*cdf0e10cSrcweir                         if ( RET_YES == aBox.Execute() )
786*cdf0e10cSrcweir                         {
787*cdf0e10cSrcweir 							SfxAllItemSet aSet( pApp->GetPool() );
788*cdf0e10cSrcweir                             aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) );
789*cdf0e10cSrcweir                             aSet.Put( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii("_blank") ) );
790*cdf0e10cSrcweir                             if ( pSavedOptions )
791*cdf0e10cSrcweir                                 aSet.Put( *pSavedOptions );
792*cdf0e10cSrcweir                             if ( pSavedReferer )
793*cdf0e10cSrcweir                                 aSet.Put( *pSavedReferer );
794*cdf0e10cSrcweir 							aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
795*cdf0e10cSrcweir                             if( pFilter )
796*cdf0e10cSrcweir                                 aSet.Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetFilterName() ) );
797*cdf0e10cSrcweir                             GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet );
798*cdf0e10cSrcweir                         }
799*cdf0e10cSrcweir                     }
800*cdf0e10cSrcweir 					else
801*cdf0e10cSrcweir 					{
802*cdf0e10cSrcweir                         // an error handling should be done here?!
803*cdf0e10cSrcweir                         // if ( !pSilentItem || !pSilentItem->GetValue() )
804*cdf0e10cSrcweir                         //    ErrorHandler::HandleError( nLoadError );
805*cdf0e10cSrcweir 					}
806*cdf0e10cSrcweir                 }
807*cdf0e10cSrcweir                 else
808*cdf0e10cSrcweir                 {
809*cdf0e10cSrcweir                     if ( xNewObj->GetModifyPasswordHash() && xNewObj->GetModifyPasswordHash() != xOldObj->GetModifyPasswordHash() )
810*cdf0e10cSrcweir                     {
811*cdf0e10cSrcweir                         xNewObj->SetModifyPasswordEntered( sal_False );
812*cdf0e10cSrcweir                         xNewObj->SetReadOnly();
813*cdf0e10cSrcweir                     }
814*cdf0e10cSrcweir                     else if ( rReq.GetSlot() == SID_EDITDOC && bForEdit && !xNewObj->IsReadOnlyMedium() )
815*cdf0e10cSrcweir                     {
816*cdf0e10cSrcweir                         // the filter might request setting of the document to readonly state
817*cdf0e10cSrcweir                         // but in case of SID_EDITDOC it should not happen if the document
818*cdf0e10cSrcweir                         // can be opened for editing
819*cdf0e10cSrcweir                         xNewObj->SetReadOnlyUI( sal_False );
820*cdf0e10cSrcweir                     }
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir                     if ( xNewObj->IsDocShared() )
823*cdf0e10cSrcweir                     {
824*cdf0e10cSrcweir                         // the file is shared but the closing can change the sharing control file
825*cdf0e10cSrcweir                         xOldObj->DoNotCleanShareControlFile();
826*cdf0e10cSrcweir                     }
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir                     // the Reload and Silent items were only temporary, remove them
829*cdf0e10cSrcweir 					xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_RELOAD );
830*cdf0e10cSrcweir 					xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_SILENT );
831*cdf0e10cSrcweir                     TransformItems( SID_OPENDOC, *xNewObj->GetMedium()->GetItemSet(), aLoadArgs );
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir 					UpdateDocument_Impl();
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir                     try
836*cdf0e10cSrcweir                     {
837*cdf0e10cSrcweir                         while ( !aViewFrames.empty() )
838*cdf0e10cSrcweir                         {
839*cdf0e10cSrcweir                             LoadViewIntoFrame_Impl( *xNewObj, aViewFrames.front().first, aLoadArgs, aViewFrames.front().second, false );
840*cdf0e10cSrcweir                             aViewFrames.pop_front();
841*cdf0e10cSrcweir                         }
842*cdf0e10cSrcweir                     }
843*cdf0e10cSrcweir                     catch( const Exception& )
844*cdf0e10cSrcweir                     {
845*cdf0e10cSrcweir                         // close the remaining frames
846*cdf0e10cSrcweir                         // Don't catch exceptions herein, if this fails, then we're left in an indetermined state, and
847*cdf0e10cSrcweir                         // crashing is better than trying to proceed
848*cdf0e10cSrcweir                         while ( !aViewFrames.empty() )
849*cdf0e10cSrcweir                         {
850*cdf0e10cSrcweir                             Reference< util::XCloseable > xClose( aViewFrames.front().first, UNO_QUERY_THROW );
851*cdf0e10cSrcweir                             xClose->close( sal_True );
852*cdf0e10cSrcweir                             aViewFrames.pop_front();
853*cdf0e10cSrcweir                         }
854*cdf0e10cSrcweir                     }
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir                     // Propagate document closure.
857*cdf0e10cSrcweir                     SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
858*cdf0e10cSrcweir                 }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir                 // als erledigt recorden
861*cdf0e10cSrcweir                 rReq.Done( sal_True );
862*cdf0e10cSrcweir                 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True));
863*cdf0e10cSrcweir                 return;
864*cdf0e10cSrcweir             }
865*cdf0e10cSrcweir             else
866*cdf0e10cSrcweir             {
867*cdf0e10cSrcweir                 // als nicht erledigt recorden
868*cdf0e10cSrcweir                 rReq.Done();
869*cdf0e10cSrcweir                 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_False));
870*cdf0e10cSrcweir                 pImp->bReloading = sal_False;
871*cdf0e10cSrcweir                 return;
872*cdf0e10cSrcweir             }
873*cdf0e10cSrcweir         }
874*cdf0e10cSrcweir     }
875*cdf0e10cSrcweir }
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir //-------------------------------------------------------------------------
878*cdf0e10cSrcweir void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet )
879*cdf0e10cSrcweir {
880*cdf0e10cSrcweir     SfxObjectShell* pSh = GetObjectShell();
881*cdf0e10cSrcweir 	if ( !pSh )
882*cdf0e10cSrcweir 		// Ich bin gerade am Reloaden und Yielde so vor mich hin ...
883*cdf0e10cSrcweir 		return;
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir     GetFrame().GetParentFrame();
886*cdf0e10cSrcweir     SfxWhichIter aIter( rSet );
887*cdf0e10cSrcweir     for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
888*cdf0e10cSrcweir     {
889*cdf0e10cSrcweir 		if ( GetFrame().HasComponent() )
890*cdf0e10cSrcweir 		{
891*cdf0e10cSrcweir 			// Wenn die Komponente es nicht selbst dispatched, dann
892*cdf0e10cSrcweir 			// macht es auch keinen Sinn!
893*cdf0e10cSrcweir 			rSet.DisableItem( nWhich );
894*cdf0e10cSrcweir 			continue;
895*cdf0e10cSrcweir 		}
896*cdf0e10cSrcweir 
897*cdf0e10cSrcweir         switch ( nWhich )
898*cdf0e10cSrcweir         {
899*cdf0e10cSrcweir             case SID_EDITDOC:
900*cdf0e10cSrcweir             {
901*cdf0e10cSrcweir 		        if ( !pSh || !pSh->HasName() || !( pSh->Get_Impl()->nLoadedFlags &  SFX_LOADED_MAINDOCUMENT )
902*cdf0e10cSrcweir 				  || pSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
903*cdf0e10cSrcweir 		            rSet.DisableItem( SID_EDITDOC );
904*cdf0e10cSrcweir 		        else
905*cdf0e10cSrcweir 				{
906*cdf0e10cSrcweir 					SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_EDITDOC, sal_False );
907*cdf0e10cSrcweir 					if ( pItem && !pItem->GetValue() )
908*cdf0e10cSrcweir 						rSet.DisableItem( SID_EDITDOC );
909*cdf0e10cSrcweir 					else
910*cdf0e10cSrcweir 						rSet.Put( SfxBoolItem( nWhich, !pSh->IsReadOnly() ) );
911*cdf0e10cSrcweir 				}
912*cdf0e10cSrcweir                 break;
913*cdf0e10cSrcweir             }
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir             case SID_RELOAD:
916*cdf0e10cSrcweir             {
917*cdf0e10cSrcweir 				SfxFrame* pFrame = &GetTopFrame();
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir                 if ( !pSh || !pSh->CanReload_Impl() || pSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
920*cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
921*cdf0e10cSrcweir                 else
922*cdf0e10cSrcweir 				{
923*cdf0e10cSrcweir 					// Wenn irgendein ChildFrame reloadable ist, wird der Slot
924*cdf0e10cSrcweir 					// enabled, damit man CTRL-Reload machen kann
925*cdf0e10cSrcweir 					sal_Bool bReloadAvailable = sal_False;
926*cdf0e10cSrcweir 					SfxFrameIterator aFrameIter( *pFrame, sal_True );
927*cdf0e10cSrcweir 					for( SfxFrame* pNextFrame = aFrameIter.FirstFrame();
928*cdf0e10cSrcweir 							pFrame;
929*cdf0e10cSrcweir 							pNextFrame = pNextFrame ?
930*cdf0e10cSrcweir 								aFrameIter.NextFrame( *pNextFrame ) : 0 )
931*cdf0e10cSrcweir 					{
932*cdf0e10cSrcweir 						SfxObjectShell *pShell = pFrame->GetCurrentDocument();
933*cdf0e10cSrcweir 						if( pShell && pShell->Get_Impl()->bReloadAvailable )
934*cdf0e10cSrcweir 						{
935*cdf0e10cSrcweir 							bReloadAvailable = sal_True;
936*cdf0e10cSrcweir 							break;
937*cdf0e10cSrcweir 						}
938*cdf0e10cSrcweir 						pFrame = pNextFrame;
939*cdf0e10cSrcweir 					}
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir                     rSet.Put( SfxBoolItem( nWhich, bReloadAvailable));
942*cdf0e10cSrcweir 				}
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir                 break;
945*cdf0e10cSrcweir             }
946*cdf0e10cSrcweir         }
947*cdf0e10cSrcweir     }
948*cdf0e10cSrcweir }
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir //--------------------------------------------------------------------
952*cdf0e10cSrcweir void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq )
953*cdf0e10cSrcweir {
954*cdf0e10cSrcweir     // gibt es an der obersten Shell einen Undo-Manager?
955*cdf0e10cSrcweir     SfxShell *pSh = GetDispatcher()->GetShell(0);
956*cdf0e10cSrcweir     ::svl::IUndoManager* pShUndoMgr = pSh->GetUndoManager();
957*cdf0e10cSrcweir     sal_Bool bOK = sal_False;
958*cdf0e10cSrcweir     if ( pShUndoMgr )
959*cdf0e10cSrcweir     {
960*cdf0e10cSrcweir         switch ( rReq.GetSlot() )
961*cdf0e10cSrcweir         {
962*cdf0e10cSrcweir             case SID_CLEARHISTORY:
963*cdf0e10cSrcweir                 pShUndoMgr->Clear();
964*cdf0e10cSrcweir                 bOK = sal_True;
965*cdf0e10cSrcweir                 break;
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir             case SID_UNDO:
968*cdf0e10cSrcweir                 pShUndoMgr->Undo();
969*cdf0e10cSrcweir                 GetBindings().InvalidateAll(sal_False);
970*cdf0e10cSrcweir                 bOK = sal_True;
971*cdf0e10cSrcweir                 break;
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir             case SID_REDO:
974*cdf0e10cSrcweir                 pShUndoMgr->Redo();
975*cdf0e10cSrcweir                 GetBindings().InvalidateAll(sal_False);
976*cdf0e10cSrcweir                 bOK = sal_True;
977*cdf0e10cSrcweir                 break;
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir             case SID_REPEAT:
980*cdf0e10cSrcweir                 if ( pSh->GetRepeatTarget() )
981*cdf0e10cSrcweir                     pShUndoMgr->Repeat( *pSh->GetRepeatTarget() );
982*cdf0e10cSrcweir                 bOK = sal_True;
983*cdf0e10cSrcweir                 break;
984*cdf0e10cSrcweir         }
985*cdf0e10cSrcweir     }
986*cdf0e10cSrcweir     else if ( GetViewShell() )
987*cdf0e10cSrcweir     {
988*cdf0e10cSrcweir         // der SW hat eigenes Undo an der View
989*cdf0e10cSrcweir         const SfxPoolItem *pRet = GetViewShell()->ExecuteSlot( rReq );
990*cdf0e10cSrcweir         if ( pRet )
991*cdf0e10cSrcweir             bOK = ((SfxBoolItem*)pRet)->GetValue();
992*cdf0e10cSrcweir     }
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir     rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bOK ) );
995*cdf0e10cSrcweir     rReq.Done();
996*cdf0e10cSrcweir }
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir //--------------------------------------------------------------------
999*cdf0e10cSrcweir void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet )
1000*cdf0e10cSrcweir {
1001*cdf0e10cSrcweir     // Undo-Manager suchen
1002*cdf0e10cSrcweir     SfxShell *pSh = GetDispatcher()->GetShell(0);
1003*cdf0e10cSrcweir 	if ( !pSh )
1004*cdf0e10cSrcweir 		// Ich bin gerade am Reloaden und Yielde so vor mich hin ...
1005*cdf0e10cSrcweir 		return;
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir     ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager();
1008*cdf0e10cSrcweir     if ( !pShUndoMgr )
1009*cdf0e10cSrcweir     {
1010*cdf0e10cSrcweir         // der SW hat eigenes Undo an der View
1011*cdf0e10cSrcweir         SfxWhichIter aIter( rSet );
1012*cdf0e10cSrcweir         SfxViewShell *pViewSh = GetViewShell();
1013*cdf0e10cSrcweir         if( !pViewSh ) return;
1014*cdf0e10cSrcweir         for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
1015*cdf0e10cSrcweir             pViewSh->GetSlotState( nSID, 0, &rSet );
1016*cdf0e10cSrcweir         return;
1017*cdf0e10cSrcweir     }
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir     if ( pShUndoMgr->GetUndoActionCount() == 0 &&
1020*cdf0e10cSrcweir          pShUndoMgr->GetRedoActionCount() == 0 &&
1021*cdf0e10cSrcweir          pShUndoMgr->GetRepeatActionCount() == 0 )
1022*cdf0e10cSrcweir         rSet.DisableItem( SID_CLEARHISTORY );
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir     if ( pShUndoMgr && pShUndoMgr->GetUndoActionCount() )
1025*cdf0e10cSrcweir 	{
1026*cdf0e10cSrcweir         String aTmp( SvtResId( STR_UNDO ) );
1027*cdf0e10cSrcweir 		aTmp+= pShUndoMgr->GetUndoActionComment(0);
1028*cdf0e10cSrcweir 		rSet.Put( SfxStringItem( SID_UNDO, aTmp ) );
1029*cdf0e10cSrcweir 	}
1030*cdf0e10cSrcweir     else
1031*cdf0e10cSrcweir         rSet.DisableItem( SID_UNDO );
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir     if ( pShUndoMgr && pShUndoMgr->GetRedoActionCount() )
1034*cdf0e10cSrcweir 	{
1035*cdf0e10cSrcweir         String aTmp( SvtResId(STR_REDO) );
1036*cdf0e10cSrcweir 		aTmp += pShUndoMgr->GetRedoActionComment(0);
1037*cdf0e10cSrcweir 	    rSet.Put( SfxStringItem( SID_REDO, aTmp ) );
1038*cdf0e10cSrcweir 	}
1039*cdf0e10cSrcweir     else
1040*cdf0e10cSrcweir         rSet.DisableItem( SID_REDO );
1041*cdf0e10cSrcweir     SfxRepeatTarget *pTarget = pSh->GetRepeatTarget();
1042*cdf0e10cSrcweir     if ( pShUndoMgr && pTarget && pShUndoMgr->GetRepeatActionCount() &&
1043*cdf0e10cSrcweir          pShUndoMgr->CanRepeat(*pTarget) )
1044*cdf0e10cSrcweir 	{
1045*cdf0e10cSrcweir         String aTmp( SvtResId(STR_REPEAT) );
1046*cdf0e10cSrcweir 		aTmp += pShUndoMgr->GetRepeatActionComment(*pTarget);
1047*cdf0e10cSrcweir 		rSet.Put( SfxStringItem( SID_REPEAT, aTmp ) );
1048*cdf0e10cSrcweir 	}
1049*cdf0e10cSrcweir     else
1050*cdf0e10cSrcweir         rSet.DisableItem( SID_REPEAT );
1051*cdf0e10cSrcweir }
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir //--------------------------------------------------------------------
1054*cdf0e10cSrcweir void SfxViewFrame::PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell )
1055*cdf0e10cSrcweir {
1056*cdf0e10cSrcweir     i_rViewShell.PopSubShells_Impl();
1057*cdf0e10cSrcweir     sal_uInt16 nLevel = pDispatcher->GetShellLevel( i_rViewShell );
1058*cdf0e10cSrcweir     if ( nLevel != USHRT_MAX )
1059*cdf0e10cSrcweir     {
1060*cdf0e10cSrcweir         if ( nLevel )
1061*cdf0e10cSrcweir         {
1062*cdf0e10cSrcweir             // more sub shells on the stack, which were not affected by PopSubShells_Impl
1063*cdf0e10cSrcweir             SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 );
1064*cdf0e10cSrcweir             if ( pSubShell == i_rViewShell.GetSubShell() )
1065*cdf0e10cSrcweir                 // "real" sub shells will be deleted elsewhere
1066*cdf0e10cSrcweir                 pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL );
1067*cdf0e10cSrcweir             else
1068*cdf0e10cSrcweir                 pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE );
1069*cdf0e10cSrcweir         }
1070*cdf0e10cSrcweir         pDispatcher->Pop( i_rViewShell );
1071*cdf0e10cSrcweir         pDispatcher->Flush();
1072*cdf0e10cSrcweir     }
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir }
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir //--------------------------------------------------------------------
1077*cdf0e10cSrcweir void SfxViewFrame::ReleaseObjectShell_Impl()
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir /*  [Beschreibung]
1080*cdf0e10cSrcweir 
1081*cdf0e10cSrcweir     Diese Methode entleert den SfxViewFrame, d.h. nimmt die <SfxObjectShell>
1082*cdf0e10cSrcweir     vom Dispatcher und beendet seine <SfxListener>-Beziehung zu dieser
1083*cdf0e10cSrcweir     SfxObjectShell (wodurch sie sich ggf. selbst zerst"ort).
1084*cdf0e10cSrcweir 
1085*cdf0e10cSrcweir     Somit kann durch Aufruf von ReleaseObjectShell() und SetObjectShell()
1086*cdf0e10cSrcweir     die SfxObjectShell ausgetauscht werden.
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir     Zwischen RealeaseObjectShell() und SetObjectShell() darf die Kontrolle
1089*cdf0e10cSrcweir     nicht an das System abgegeben werden.
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir     [Querverweise]
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir     <SfxViewFrame::SetObjectShell(SfxObjectShell&)>
1095*cdf0e10cSrcweir */
1096*cdf0e10cSrcweir {
1097*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1098*cdf0e10cSrcweir     DBG_ASSERT( xObjSh.Is(), "no SfxObjectShell to release!" );
1099*cdf0e10cSrcweir 
1100*cdf0e10cSrcweir 	GetFrame().ReleasingComponent_Impl( sal_True );
1101*cdf0e10cSrcweir 	if ( GetWindow().HasChildPathFocus( sal_True ) )
1102*cdf0e10cSrcweir 	{
1103*cdf0e10cSrcweir 		DBG_ASSERT( !GetActiveChildFrame_Impl(), "Wrong active child frame!" );
1104*cdf0e10cSrcweir 		GetWindow().GrabFocus();
1105*cdf0e10cSrcweir 	}
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir 	SfxViewShell *pDyingViewSh = GetViewShell();
1108*cdf0e10cSrcweir     if ( pDyingViewSh )
1109*cdf0e10cSrcweir     {
1110*cdf0e10cSrcweir         PopShellAndSubShells_Impl( *pDyingViewSh );
1111*cdf0e10cSrcweir         pDyingViewSh->DisconnectAllClients();
1112*cdf0e10cSrcweir         SetViewShell_Impl(0);
1113*cdf0e10cSrcweir         delete pDyingViewSh;
1114*cdf0e10cSrcweir     }
1115*cdf0e10cSrcweir #ifdef DBG_UTIL
1116*cdf0e10cSrcweir     else
1117*cdf0e10cSrcweir         DBG_ERROR("Keine Shell");
1118*cdf0e10cSrcweir #endif
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir     if ( xObjSh.Is() )
1121*cdf0e10cSrcweir     {
1122*cdf0e10cSrcweir          pImp->aLastType = xObjSh->Type();
1123*cdf0e10cSrcweir         pDispatcher->Pop( *xObjSh );
1124*cdf0e10cSrcweir         SfxModule* pModule = xObjSh->GetModule();
1125*cdf0e10cSrcweir         if( pModule )
1126*cdf0e10cSrcweir             pDispatcher->RemoveShell_Impl( *pModule );
1127*cdf0e10cSrcweir         pDispatcher->Flush();
1128*cdf0e10cSrcweir         EndListening( *xObjSh );
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir         Notify( *xObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) );
1131*cdf0e10cSrcweir         Notify( *xObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) );
1132*cdf0e10cSrcweir 
1133*cdf0e10cSrcweir         if ( 1 == xObjSh->GetOwnerLockCount() && pImp->bObjLocked && xObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1134*cdf0e10cSrcweir             xObjSh->DoClose();
1135*cdf0e10cSrcweir         SfxObjectShellRef xDyingObjSh = xObjSh;
1136*cdf0e10cSrcweir         xObjSh.Clear();
1137*cdf0e10cSrcweir         if( ( GetFrameType() & SFXFRAME_HASTITLE ) && pImp->nDocViewNo )
1138*cdf0e10cSrcweir             xDyingObjSh->GetNoSet_Impl().ReleaseIndex(pImp->nDocViewNo-1);
1139*cdf0e10cSrcweir         if ( pImp->bObjLocked )
1140*cdf0e10cSrcweir         {
1141*cdf0e10cSrcweir             xDyingObjSh->OwnerLock( sal_False );
1142*cdf0e10cSrcweir             pImp->bObjLocked = sal_False;
1143*cdf0e10cSrcweir         }
1144*cdf0e10cSrcweir     }
1145*cdf0e10cSrcweir 
1146*cdf0e10cSrcweir 	GetDispatcher()->SetDisableFlags( 0 );
1147*cdf0e10cSrcweir }
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir //--------------------------------------------------------------------
1150*cdf0e10cSrcweir sal_Bool SfxViewFrame::Close()
1151*cdf0e10cSrcweir {
1152*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir     DBG_ASSERT( GetFrame().IsClosing_Impl() || !GetFrame().GetFrameInterface().is(), "ViewFrame closed too early!" );
1155*cdf0e10cSrcweir 
1156*cdf0e10cSrcweir 	// Wenn bis jetzt noch nicht gespeichert wurde, sollen eingebettete Objekte
1157*cdf0e10cSrcweir 	// auch nicht mehr automatisch gespeichert werden!
1158*cdf0e10cSrcweir 	if ( GetViewShell() )
1159*cdf0e10cSrcweir 		GetViewShell()->DiscardClients_Impl();
1160*cdf0e10cSrcweir 	Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir     if (SfxViewFrame::Current() == this)
1163*cdf0e10cSrcweir         SfxViewFrame::SetViewFrame( NULL );
1164*cdf0e10cSrcweir 
1165*cdf0e10cSrcweir 	// Da der Dispatcher leer ger"aumt wird, kann man ihn auch nicht mehr
1166*cdf0e10cSrcweir 	// vern"unftig verwenden - also besser still legen
1167*cdf0e10cSrcweir 	GetDispatcher()->Lock(sal_True);
1168*cdf0e10cSrcweir 	delete this;
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir 	return sal_True;
1171*cdf0e10cSrcweir }
1172*cdf0e10cSrcweir 
1173*cdf0e10cSrcweir //--------------------------------------------------------------------
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir void SfxViewFrame::DoActivate( sal_Bool bUI, SfxViewFrame* pOldFrame )
1176*cdf0e10cSrcweir {
1177*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1178*cdf0e10cSrcweir     SFX_APP();
1179*cdf0e10cSrcweir 
1180*cdf0e10cSrcweir     pDispatcher->DoActivate_Impl( bUI, pOldFrame );
1181*cdf0e10cSrcweir 
1182*cdf0e10cSrcweir     // Wenn ich einen parent habe und dieser ist kein parent des alten
1183*cdf0e10cSrcweir     // ViewFrames, erh"alt er ein ParentActivate
1184*cdf0e10cSrcweir     if ( bUI )
1185*cdf0e10cSrcweir     {
1186*cdf0e10cSrcweir /*
1187*cdf0e10cSrcweir 		SfxMedium* pMed = GetObjectShell() ? GetObjectShell()->GetMedium() : NULL;
1188*cdf0e10cSrcweir 		if( pMed )
1189*cdf0e10cSrcweir 		{
1190*cdf0e10cSrcweir             SFX_ITEMSET_ARG(
1191*cdf0e10cSrcweir                 pMed->GetItemSet(), pInterceptorItem, SfxSlotInterceptorItem,
1192*cdf0e10cSrcweir                 SID_INTERCEPTOR, sal_False );
1193*cdf0e10cSrcweir 			if( pInterceptorItem )
1194*cdf0e10cSrcweir 			{
1195*cdf0e10cSrcweir 				SfxSlotInterceptor* pInter = pInterceptorItem->GetValue();
1196*cdf0e10cSrcweir 				if( !pInter->GetBindings() )
1197*cdf0e10cSrcweir 					pInter->SetBindings( &GetBindings() );
1198*cdf0e10cSrcweir 				pInter->Activate( sal_True );
1199*cdf0e10cSrcweir 			}
1200*cdf0e10cSrcweir 		}
1201*cdf0e10cSrcweir  */
1202*cdf0e10cSrcweir         SfxViewFrame *pFrame = GetParentViewFrame();
1203*cdf0e10cSrcweir         while ( pFrame )
1204*cdf0e10cSrcweir         {
1205*cdf0e10cSrcweir             if ( !pOldFrame || !pOldFrame->GetFrame().IsParent( &pFrame->GetFrame() ) )
1206*cdf0e10cSrcweir                 pFrame->pDispatcher->DoParentActivate_Impl();
1207*cdf0e10cSrcweir             pFrame = pFrame->GetParentViewFrame();
1208*cdf0e10cSrcweir         }
1209*cdf0e10cSrcweir     }
1210*cdf0e10cSrcweir }
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir //--------------------------------------------------------------------
1213*cdf0e10cSrcweir void SfxViewFrame::DoDeactivate(sal_Bool bUI, SfxViewFrame* pNewFrame )
1214*cdf0e10cSrcweir {
1215*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1216*cdf0e10cSrcweir     SFX_APP();
1217*cdf0e10cSrcweir     pDispatcher->DoDeactivate_Impl( bUI, pNewFrame );
1218*cdf0e10cSrcweir 
1219*cdf0e10cSrcweir     // Wenn ich einen parent habe und dieser ist kein parent des neuen
1220*cdf0e10cSrcweir     // ViewFrames, erh"alt er ein ParentDeactivate
1221*cdf0e10cSrcweir     if ( bUI )
1222*cdf0e10cSrcweir     {
1223*cdf0e10cSrcweir //        if ( GetFrame().GetWorkWindow_Impl() )
1224*cdf0e10cSrcweir //            GetFrame().GetWorkWindow_Impl()->SaveStatus_Impl();
1225*cdf0e10cSrcweir /*
1226*cdf0e10cSrcweir 		SfxMedium* pMed = GetObjectShell() ? GetObjectShell()->GetMedium() : NULL;
1227*cdf0e10cSrcweir 		if( pMed )
1228*cdf0e10cSrcweir 		{
1229*cdf0e10cSrcweir             SFX_ITEMSET_ARG(
1230*cdf0e10cSrcweir                 pMed->GetItemSet(), pInterceptorItem, SfxSlotInterceptorItem,
1231*cdf0e10cSrcweir                 SID_INTERCEPTOR, sal_False );
1232*cdf0e10cSrcweir 			if( pInterceptorItem )
1233*cdf0e10cSrcweir 				pInterceptorItem->GetValue()->Activate( sal_False );
1234*cdf0e10cSrcweir 		}
1235*cdf0e10cSrcweir */
1236*cdf0e10cSrcweir         SfxViewFrame *pFrame = GetParentViewFrame();
1237*cdf0e10cSrcweir         while ( pFrame )
1238*cdf0e10cSrcweir         {
1239*cdf0e10cSrcweir             if ( !pNewFrame || !pNewFrame->GetFrame().IsParent( &pFrame->GetFrame() ) )
1240*cdf0e10cSrcweir                 pFrame->pDispatcher->DoParentDeactivate_Impl();
1241*cdf0e10cSrcweir             pFrame = pFrame->GetParentViewFrame();
1242*cdf0e10cSrcweir         }
1243*cdf0e10cSrcweir     }
1244*cdf0e10cSrcweir }
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir //------------------------------------------------------------------------
1247*cdf0e10cSrcweir void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh )
1248*cdf0e10cSrcweir {
1249*cdf0e10cSrcweir     if( pSh && !nAdjustPosPixelLock )
1250*cdf0e10cSrcweir     {
1251*cdf0e10cSrcweir         if ( GetViewShell() && GetWindow().IsVisible() )
1252*cdf0e10cSrcweir         {
1253*cdf0e10cSrcweir             if ( GetFrame().IsInPlace() )
1254*cdf0e10cSrcweir             {
1255*cdf0e10cSrcweir                 /*
1256*cdf0e10cSrcweir                 Size aSize( GetViewShell()->GetWindow()->GetSizePixel() );
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir                 //Size aBorderSz( pEnv->GetBorderWin()->GetHatchBorderPixel() );
1259*cdf0e10cSrcweir                 Point aOfs; //( aBorderSz.Width(), aBorderSz.Height() );
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir                 DoAdjustPosSizePixel( GetViewShell(), aOfs, aSize );*/
1262*cdf0e10cSrcweir                 return;
1263*cdf0e10cSrcweir             }
1264*cdf0e10cSrcweir 
1265*cdf0e10cSrcweir             DoAdjustPosSizePixel( (SfxViewShell *) GetViewShell(), Point(),
1266*cdf0e10cSrcweir                                             GetWindow().GetOutputSizePixel() );
1267*cdf0e10cSrcweir         }
1268*cdf0e10cSrcweir     }
1269*cdf0e10cSrcweir }
1270*cdf0e10cSrcweir 
1271*cdf0e10cSrcweir //------------------------------------------------------------------------
1272*cdf0e10cSrcweir sal_Bool SfxViewFrame::SetBorderPixelImpl
1273*cdf0e10cSrcweir (
1274*cdf0e10cSrcweir     const SfxViewShell* pVSh,
1275*cdf0e10cSrcweir     const SvBorder&     rBorder
1276*cdf0e10cSrcweir )
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir {
1279*cdf0e10cSrcweir     pImp->aBorder = rBorder;
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir     if ( IsResizeInToOut_Impl() && !GetFrame().IsInPlace() )
1282*cdf0e10cSrcweir 	{
1283*cdf0e10cSrcweir 		Size aSize = pVSh->GetWindow()->GetOutputSizePixel();
1284*cdf0e10cSrcweir 		if ( aSize.Width() && aSize.Height() )
1285*cdf0e10cSrcweir 		{
1286*cdf0e10cSrcweir 			aSize.Width() += rBorder.Left() + rBorder.Right();
1287*cdf0e10cSrcweir 			aSize.Height() += rBorder.Top() + rBorder.Bottom();
1288*cdf0e10cSrcweir 
1289*cdf0e10cSrcweir 			Size aOldSize = GetWindow().GetOutputSizePixel();
1290*cdf0e10cSrcweir 			GetWindow().SetOutputSizePixel( aSize );
1291*cdf0e10cSrcweir 			Window* pParent = &GetWindow();
1292*cdf0e10cSrcweir 			while ( pParent->GetParent() )
1293*cdf0e10cSrcweir 				pParent = pParent->GetParent();
1294*cdf0e10cSrcweir 			Size aOuterSize = pParent->GetOutputSizePixel();
1295*cdf0e10cSrcweir 			aOuterSize.Width() += ( aSize.Width() - aOldSize.Width() );
1296*cdf0e10cSrcweir 			aOuterSize.Height() += ( aSize.Height() - aOldSize.Height() );
1297*cdf0e10cSrcweir 			pParent->SetOutputSizePixel( aOuterSize );
1298*cdf0e10cSrcweir 		}
1299*cdf0e10cSrcweir 	}
1300*cdf0e10cSrcweir 	else
1301*cdf0e10cSrcweir 	{
1302*cdf0e10cSrcweir 		Point aPoint;
1303*cdf0e10cSrcweir 		Rectangle aEditArea( aPoint, GetWindow().GetOutputSizePixel() );
1304*cdf0e10cSrcweir 		aEditArea.Left() += rBorder.Left();
1305*cdf0e10cSrcweir 		aEditArea.Right() -= rBorder.Right();
1306*cdf0e10cSrcweir 		aEditArea.Top() += rBorder.Top();
1307*cdf0e10cSrcweir 		aEditArea.Bottom() -= rBorder.Bottom();
1308*cdf0e10cSrcweir 		pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() );
1309*cdf0e10cSrcweir 	}
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir 	return sal_True;
1312*cdf0e10cSrcweir }
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir //------------------------------------------------------------------------
1315*cdf0e10cSrcweir const SvBorder& SfxViewFrame::GetBorderPixelImpl
1316*cdf0e10cSrcweir (
1317*cdf0e10cSrcweir     const SfxViewShell* /*pSh*/
1318*cdf0e10cSrcweir )   const
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir {
1321*cdf0e10cSrcweir     return pImp->aBorder;
1322*cdf0e10cSrcweir }
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir //--------------------------------------------------------------------
1325*cdf0e10cSrcweir void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
1326*cdf0e10cSrcweir {
1327*cdf0e10cSrcweir     {DBG_CHKTHIS(SfxViewFrame, 0);}
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir     if( IsDowning_Impl())
1330*cdf0e10cSrcweir         return;
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir     // we know only SimpleHints
1333*cdf0e10cSrcweir     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
1334*cdf0e10cSrcweir     {
1335*cdf0e10cSrcweir         switch( ( (SfxSimpleHint&) rHint ).GetId() )
1336*cdf0e10cSrcweir         {
1337*cdf0e10cSrcweir             case SFX_HINT_MODECHANGED:
1338*cdf0e10cSrcweir             {
1339*cdf0e10cSrcweir                 UpdateTitle();
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir                 if ( !xObjSh.Is() )
1342*cdf0e10cSrcweir                     break;
1343*cdf0e10cSrcweir 
1344*cdf0e10cSrcweir                 // r/o Umschaltung?
1345*cdf0e10cSrcweir                 SfxBindings& rBind = GetBindings();
1346*cdf0e10cSrcweir                 rBind.Invalidate( SID_RELOAD );
1347*cdf0e10cSrcweir                 SfxDispatcher *pDispat = GetDispatcher();
1348*cdf0e10cSrcweir                 sal_Bool bWasReadOnly = pDispat->GetReadOnly_Impl();
1349*cdf0e10cSrcweir                 sal_Bool bIsReadOnly = xObjSh->IsReadOnly();
1350*cdf0e10cSrcweir                 if ( !bWasReadOnly != !bIsReadOnly )
1351*cdf0e10cSrcweir             	{
1352*cdf0e10cSrcweir 					// Dann auch TITLE_CHANGED
1353*cdf0e10cSrcweir 					UpdateTitle();
1354*cdf0e10cSrcweir 	                rBind.Invalidate( SID_FILE_NAME );
1355*cdf0e10cSrcweir 	                rBind.Invalidate( SID_DOCINFO_TITLE );
1356*cdf0e10cSrcweir 					rBind.Invalidate( SID_EDITDOC );
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir                     pDispat->GetBindings()->InvalidateAll(sal_True);
1359*cdf0e10cSrcweir                     pDispat->SetReadOnly_Impl( bIsReadOnly );
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir 					// Dispatcher-Update nur erzwingen, wenn es nicht sowieso
1362*cdf0e10cSrcweir 					// demn"achst kommt, anderenfalls ist Zappelei oder gar
1363*cdf0e10cSrcweir 					// GPF m"oglich, da Writer z.B. gerne mal im Resize irgendwelche
1364*cdf0e10cSrcweir 					// Aktionen t"atigt, die ein SetReadOnlyUI am Dispatcher zur
1365*cdf0e10cSrcweir 					// Folge haben!
1366*cdf0e10cSrcweir 					if ( pDispat->IsUpdated_Impl() )
1367*cdf0e10cSrcweir                     	pDispat->Update_Impl(sal_True);
1368*cdf0e10cSrcweir                 }
1369*cdf0e10cSrcweir 
1370*cdf0e10cSrcweir                 Enable( !xObjSh->IsInModalMode() );
1371*cdf0e10cSrcweir 				break;
1372*cdf0e10cSrcweir             }
1373*cdf0e10cSrcweir 
1374*cdf0e10cSrcweir             case SFX_HINT_TITLECHANGED:
1375*cdf0e10cSrcweir             {
1376*cdf0e10cSrcweir 				UpdateTitle();
1377*cdf0e10cSrcweir                 SfxBindings& rBind = GetBindings();
1378*cdf0e10cSrcweir                 rBind.Invalidate( SID_FILE_NAME );
1379*cdf0e10cSrcweir                 rBind.Invalidate( SID_DOCINFO_TITLE );
1380*cdf0e10cSrcweir 				rBind.Invalidate( SID_EDITDOC );
1381*cdf0e10cSrcweir 				rBind.Invalidate( SID_RELOAD );
1382*cdf0e10cSrcweir                 break;
1383*cdf0e10cSrcweir             }
1384*cdf0e10cSrcweir 
1385*cdf0e10cSrcweir             case SFX_HINT_DEINITIALIZING:
1386*cdf0e10cSrcweir                 GetFrame().DoClose();
1387*cdf0e10cSrcweir                 break;
1388*cdf0e10cSrcweir             case SFX_HINT_DYING:
1389*cdf0e10cSrcweir                 // when the Object is being deleted, destroy the view too
1390*cdf0e10cSrcweir                 if ( xObjSh.Is() )
1391*cdf0e10cSrcweir                     ReleaseObjectShell_Impl();
1392*cdf0e10cSrcweir                 else
1393*cdf0e10cSrcweir                     GetFrame().DoClose();
1394*cdf0e10cSrcweir                 break;
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir         }
1397*cdf0e10cSrcweir     }
1398*cdf0e10cSrcweir     else if ( rHint.IsA(TYPE(SfxEventHint)) )
1399*cdf0e10cSrcweir     {
1400*cdf0e10cSrcweir         // Wenn das Document asynchron geladen wurde, wurde der Dispatcher
1401*cdf0e10cSrcweir         // auf ReadOnly gesetzt, was zur"?ckgenommen werden mu\s, wenn
1402*cdf0e10cSrcweir         // das Document selbst nicht ReadOnly ist und das Laden fertig ist.
1403*cdf0e10cSrcweir         switch ( ((SfxEventHint&)rHint).GetEventId() )
1404*cdf0e10cSrcweir         {
1405*cdf0e10cSrcweir             case SFX_EVENT_MODIFYCHANGED:
1406*cdf0e10cSrcweir             {
1407*cdf0e10cSrcweir                 SfxBindings& rBind = GetBindings();
1408*cdf0e10cSrcweir                 rBind.Invalidate( SID_DOC_MODIFIED );
1409*cdf0e10cSrcweir                 rBind.Invalidate( SID_SAVEDOC );
1410*cdf0e10cSrcweir                 rBind.Invalidate( SID_RELOAD );
1411*cdf0e10cSrcweir                 rBind.Invalidate( SID_EDITDOC );
1412*cdf0e10cSrcweir                 break;
1413*cdf0e10cSrcweir             }
1414*cdf0e10cSrcweir 
1415*cdf0e10cSrcweir             case SFX_EVENT_OPENDOC:
1416*cdf0e10cSrcweir             case SFX_EVENT_CREATEDOC:
1417*cdf0e10cSrcweir             {
1418*cdf0e10cSrcweir                 if ( !xObjSh.Is() )
1419*cdf0e10cSrcweir                     break;
1420*cdf0e10cSrcweir 
1421*cdf0e10cSrcweir                 SfxBindings& rBind = GetBindings();
1422*cdf0e10cSrcweir                 rBind.Invalidate( SID_RELOAD );
1423*cdf0e10cSrcweir                 rBind.Invalidate( SID_EDITDOC );
1424*cdf0e10cSrcweir                 if ( !xObjSh->IsReadOnly() )
1425*cdf0e10cSrcweir                 {
1426*cdf0e10cSrcweir                     // Im Gegensatz zu oben (TITLE_CHANGED) mu\s das UI nicht
1427*cdf0e10cSrcweir                     // upgedated werden, da es nicht gehidet war!
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir                     // #i21560# InvalidateAll() causes the assertion
1430*cdf0e10cSrcweir                     // 'SfxBindings::Invalidate while in update" when
1431*cdf0e10cSrcweir                     // the sfx slot SID_BASICIDE_APPEAR is executed
1432*cdf0e10cSrcweir                     // via API from another thread (Java).
1433*cdf0e10cSrcweir                     // According to MBA this call is not necessary anymore,
1434*cdf0e10cSrcweir                     // because each document has its own SfxBindings.
1435*cdf0e10cSrcweir                     //
1436*cdf0e10cSrcweir                     //GetDispatcher()->GetBindings()->InvalidateAll(sal_True);
1437*cdf0e10cSrcweir                 }
1438*cdf0e10cSrcweir 
1439*cdf0e10cSrcweir                 break;
1440*cdf0e10cSrcweir             }
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir             case SFX_EVENT_TOGGLEFULLSCREENMODE:
1443*cdf0e10cSrcweir             {
1444*cdf0e10cSrcweir                 if ( GetFrame().OwnsBindings_Impl() )
1445*cdf0e10cSrcweir                     GetBindings().GetDispatcher_Impl()->Update_Impl( sal_True );
1446*cdf0e10cSrcweir                 break;
1447*cdf0e10cSrcweir             }
1448*cdf0e10cSrcweir         }
1449*cdf0e10cSrcweir     }
1450*cdf0e10cSrcweir }
1451*cdf0e10cSrcweir 
1452*cdf0e10cSrcweir //------------------------------------------------------------------------
1453*cdf0e10cSrcweir void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
1454*cdf0e10cSrcweir {
1455*cdf0e10cSrcweir     pImp->bResizeInToOut = sal_True;
1456*cdf0e10cSrcweir     pImp->bDontOverwriteResizeInToOut = sal_False;
1457*cdf0e10cSrcweir     pImp->bObjLocked = sal_False;
1458*cdf0e10cSrcweir     pImp->pFocusWin = 0;
1459*cdf0e10cSrcweir     pImp->pActiveChild = NULL;
1460*cdf0e10cSrcweir     pImp->nCurViewId = 0;
1461*cdf0e10cSrcweir     pImp->bReloading = sal_False;
1462*cdf0e10cSrcweir     pImp->bIsDowning = sal_False;
1463*cdf0e10cSrcweir     pImp->bModal = sal_False;
1464*cdf0e10cSrcweir     pImp->bEnabled = sal_True;
1465*cdf0e10cSrcweir     pImp->nDocViewNo = 0;
1466*cdf0e10cSrcweir     pImp->aMargin = Size( -1, -1 );
1467*cdf0e10cSrcweir 	pImp->pWindow = 0;
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir 	SetPool( &SFX_APP()->GetPool() );
1470*cdf0e10cSrcweir     pDispatcher = new SfxDispatcher(this);
1471*cdf0e10cSrcweir     if ( !GetBindings().GetDispatcher() )
1472*cdf0e10cSrcweir         GetBindings().SetDispatcher( pDispatcher );
1473*cdf0e10cSrcweir 
1474*cdf0e10cSrcweir     xObjSh = pObjSh;
1475*cdf0e10cSrcweir 	if ( xObjSh.Is() && xObjSh->IsPreview() )
1476*cdf0e10cSrcweir 		SetQuietMode_Impl( sal_True );
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir     if ( pObjSh )
1479*cdf0e10cSrcweir     {
1480*cdf0e10cSrcweir         pDispatcher->Push( *SFX_APP() );
1481*cdf0e10cSrcweir         SfxModule* pModule = xObjSh->GetModule();
1482*cdf0e10cSrcweir         if( pModule )
1483*cdf0e10cSrcweir             pDispatcher->Push( *pModule );
1484*cdf0e10cSrcweir         pDispatcher->Push( *this );
1485*cdf0e10cSrcweir         pDispatcher->Push( *pObjSh );
1486*cdf0e10cSrcweir         pDispatcher->Flush();
1487*cdf0e10cSrcweir         StartListening( *pObjSh );
1488*cdf0e10cSrcweir         pObjSh->ViewAssigned();
1489*cdf0e10cSrcweir         Notify( *pObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) );
1490*cdf0e10cSrcweir         Notify( *pObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) );
1491*cdf0e10cSrcweir         pDispatcher->SetReadOnly_Impl( pObjSh->IsReadOnly() );
1492*cdf0e10cSrcweir     }
1493*cdf0e10cSrcweir     else
1494*cdf0e10cSrcweir     {
1495*cdf0e10cSrcweir         pDispatcher->Push( *SFX_APP() );
1496*cdf0e10cSrcweir         pDispatcher->Push( *this );
1497*cdf0e10cSrcweir         pDispatcher->Flush();
1498*cdf0e10cSrcweir     }
1499*cdf0e10cSrcweir 
1500*cdf0e10cSrcweir     SfxViewFrame *pThis = this; // wegen der kranken Array-Syntax
1501*cdf0e10cSrcweir     SfxViewFrameArr_Impl &rViewArr = SFX_APP()->GetViewFrames_Impl();
1502*cdf0e10cSrcweir     rViewArr.C40_INSERT(SfxViewFrame, pThis, rViewArr.Count() );
1503*cdf0e10cSrcweir }
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir SfxViewFrame::SfxViewFrame
1506*cdf0e10cSrcweir (
1507*cdf0e10cSrcweir 	SfxFrame&           rFrame,
1508*cdf0e10cSrcweir 	SfxObjectShell*     pObjShell
1509*cdf0e10cSrcweir )
1510*cdf0e10cSrcweir 
1511*cdf0e10cSrcweir /*	[Beschreibung]
1512*cdf0e10cSrcweir 
1513*cdf0e10cSrcweir 	Ctor des SfxViewFrame f"ur eine <SfxObjectShell> aus der Ressource.
1514*cdf0e10cSrcweir 	Die 'nViewId' der zu erzeugenden <SfxViewShell> kann angegeben werden
1515*cdf0e10cSrcweir 	(default ist die zuerst registrierte SfxViewShell-Subklasse).
1516*cdf0e10cSrcweir */
1517*cdf0e10cSrcweir 
1518*cdf0e10cSrcweir     : pImp( new SfxViewFrame_Impl( rFrame ) )
1519*cdf0e10cSrcweir     , pDispatcher(0)
1520*cdf0e10cSrcweir     , pBindings( new SfxBindings )
1521*cdf0e10cSrcweir     , nAdjustPosPixelLock( 0 )
1522*cdf0e10cSrcweir {
1523*cdf0e10cSrcweir     DBG_CTOR( SfxViewFrame, NULL );
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir     rFrame.SetCurrentViewFrame_Impl( this );
1526*cdf0e10cSrcweir     rFrame.SetFrameType_Impl( GetFrameType() | SFXFRAME_HASTITLE );
1527*cdf0e10cSrcweir     Construct_Impl( pObjShell );
1528*cdf0e10cSrcweir 
1529*cdf0e10cSrcweir     pImp->pWindow = new SfxFrameViewWindow_Impl( this, rFrame.GetWindow() );
1530*cdf0e10cSrcweir     pImp->pWindow->SetSizePixel( rFrame.GetWindow().GetOutputSizePixel() );
1531*cdf0e10cSrcweir 	rFrame.SetOwnsBindings_Impl( sal_True );
1532*cdf0e10cSrcweir     rFrame.CreateWorkWindow_Impl();
1533*cdf0e10cSrcweir }
1534*cdf0e10cSrcweir 
1535*cdf0e10cSrcweir //------------------------------------------------------------------------
1536*cdf0e10cSrcweir SfxViewFrame::~SfxViewFrame()
1537*cdf0e10cSrcweir {
1538*cdf0e10cSrcweir     DBG_DTOR(SfxViewFrame, 0);
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir 	SetDowning_Impl();
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir     if ( SfxViewFrame::Current() == this )
1543*cdf0e10cSrcweir         SfxViewFrame::SetViewFrame( NULL );
1544*cdf0e10cSrcweir 
1545*cdf0e10cSrcweir 	ReleaseObjectShell_Impl();
1546*cdf0e10cSrcweir 
1547*cdf0e10cSrcweir     if ( GetFrame().OwnsBindings_Impl() )
1548*cdf0e10cSrcweir 		// Die Bindings l"oscht der Frame!
1549*cdf0e10cSrcweir 		KillDispatcher_Impl();
1550*cdf0e10cSrcweir 
1551*cdf0e10cSrcweir     delete pImp->pWindow;
1552*cdf0e10cSrcweir 
1553*cdf0e10cSrcweir     if ( GetFrame().GetCurrentViewFrame() == this )
1554*cdf0e10cSrcweir         GetFrame().SetCurrentViewFrame_Impl( NULL );
1555*cdf0e10cSrcweir 
1556*cdf0e10cSrcweir     // von Frame-Liste abmelden
1557*cdf0e10cSrcweir     SfxApplication *pSfxApp = SFX_APP();
1558*cdf0e10cSrcweir     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
1559*cdf0e10cSrcweir     const SfxViewFrame *pThis = this;
1560*cdf0e10cSrcweir     rFrames.Remove( rFrames.GetPos(pThis) );
1561*cdf0e10cSrcweir 
1562*cdf0e10cSrcweir     // Member l"oschen
1563*cdf0e10cSrcweir     KillDispatcher_Impl();
1564*cdf0e10cSrcweir 
1565*cdf0e10cSrcweir     delete pImp;
1566*cdf0e10cSrcweir }
1567*cdf0e10cSrcweir 
1568*cdf0e10cSrcweir //------------------------------------------------------------------------
1569*cdf0e10cSrcweir void SfxViewFrame::KillDispatcher_Impl()
1570*cdf0e10cSrcweir 
1571*cdf0e10cSrcweir // Dispatcher abr"aumen und l"oschen
1572*cdf0e10cSrcweir 
1573*cdf0e10cSrcweir {
1574*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir     SfxModule* pModule = xObjSh.Is() ? xObjSh->GetModule() : 0;
1577*cdf0e10cSrcweir     if ( xObjSh.Is() )
1578*cdf0e10cSrcweir         ReleaseObjectShell_Impl();
1579*cdf0e10cSrcweir     if ( pDispatcher )
1580*cdf0e10cSrcweir     {
1581*cdf0e10cSrcweir         if( pModule )
1582*cdf0e10cSrcweir 			pDispatcher->Pop( *pModule, SFX_SHELL_POP_UNTIL );
1583*cdf0e10cSrcweir         else
1584*cdf0e10cSrcweir 			pDispatcher->Pop( *this );
1585*cdf0e10cSrcweir         DELETEZ(pDispatcher);
1586*cdf0e10cSrcweir     }
1587*cdf0e10cSrcweir }
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir //------------------------------------------------------------------------
1590*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::Current()
1591*cdf0e10cSrcweir {
1592*cdf0e10cSrcweir     return SfxApplication::Get() ? SFX_APP()->Get_Impl()->pViewFrame : NULL;
1593*cdf0e10cSrcweir }
1594*cdf0e10cSrcweir 
1595*cdf0e10cSrcweir //--------------------------------------------------------------------
1596*cdf0e10cSrcweir sal_uInt16 SfxViewFrame::Count()
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir /*  [Beschreibung]
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir     Liefert die Anzahl der sichtbaren <SfxViewFrame>-Instanzen.
1601*cdf0e10cSrcweir */
1602*cdf0e10cSrcweir 
1603*cdf0e10cSrcweir {
1604*cdf0e10cSrcweir     SfxApplication *pSfxApp = SFX_APP();
1605*cdf0e10cSrcweir     SfxViewFrameArr_Impl& rFrames = pSfxApp->GetViewFrames_Impl();
1606*cdf0e10cSrcweir     const sal_uInt16 nCount = rFrames.Count();
1607*cdf0e10cSrcweir     sal_uInt16 nFound = 0;
1608*cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < nCount; ++i )
1609*cdf0e10cSrcweir     {
1610*cdf0e10cSrcweir         SfxViewFrame *pFrame = rFrames[i];
1611*cdf0e10cSrcweir         if ( pFrame->IsVisible() )
1612*cdf0e10cSrcweir             ++nFound;
1613*cdf0e10cSrcweir     }
1614*cdf0e10cSrcweir     return nFound;
1615*cdf0e10cSrcweir }
1616*cdf0e10cSrcweir 
1617*cdf0e10cSrcweir //--------------------------------------------------------------------
1618*cdf0e10cSrcweir // returns the first window of spec. type viewing the specified doc.
1619*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::GetFirst
1620*cdf0e10cSrcweir (
1621*cdf0e10cSrcweir     const SfxObjectShell*   pDoc,
1622*cdf0e10cSrcweir     sal_Bool                    bOnlyIfVisible
1623*cdf0e10cSrcweir )
1624*cdf0e10cSrcweir {
1625*cdf0e10cSrcweir     SfxApplication *pSfxApp = SFX_APP();
1626*cdf0e10cSrcweir     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
1627*cdf0e10cSrcweir 
1628*cdf0e10cSrcweir     // search for a SfxDocument of the specified type
1629*cdf0e10cSrcweir     for ( sal_uInt16 nPos = 0; nPos < rFrames.Count(); ++nPos )
1630*cdf0e10cSrcweir     {
1631*cdf0e10cSrcweir         SfxViewFrame *pFrame = rFrames.GetObject(nPos);
1632*cdf0e10cSrcweir         if  (   ( !pDoc || pDoc == pFrame->GetObjectShell() )
1633*cdf0e10cSrcweir             &&  ( !bOnlyIfVisible || pFrame->IsVisible() )
1634*cdf0e10cSrcweir             )
1635*cdf0e10cSrcweir             return pFrame;
1636*cdf0e10cSrcweir     }
1637*cdf0e10cSrcweir 
1638*cdf0e10cSrcweir     return 0;
1639*cdf0e10cSrcweir }
1640*cdf0e10cSrcweir //--------------------------------------------------------------------
1641*cdf0e10cSrcweir 
1642*cdf0e10cSrcweir // returns thenext window of spec. type viewing the specified doc.
1643*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::GetNext
1644*cdf0e10cSrcweir (
1645*cdf0e10cSrcweir     const SfxViewFrame&     rPrev,
1646*cdf0e10cSrcweir     const SfxObjectShell*   pDoc,
1647*cdf0e10cSrcweir     sal_Bool                    bOnlyIfVisible
1648*cdf0e10cSrcweir )
1649*cdf0e10cSrcweir {
1650*cdf0e10cSrcweir     SfxApplication *pSfxApp = SFX_APP();
1651*cdf0e10cSrcweir     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir     // refind the specified predecessor
1654*cdf0e10cSrcweir 	sal_uInt16 nPos;
1655*cdf0e10cSrcweir     for ( nPos = 0; nPos < rFrames.Count(); ++nPos )
1656*cdf0e10cSrcweir         if ( rFrames.GetObject(nPos) == &rPrev )
1657*cdf0e10cSrcweir             break;
1658*cdf0e10cSrcweir 
1659*cdf0e10cSrcweir     // search for a Frame of the specified type
1660*cdf0e10cSrcweir     for ( ++nPos; nPos < rFrames.Count(); ++nPos )
1661*cdf0e10cSrcweir     {
1662*cdf0e10cSrcweir         SfxViewFrame *pFrame = rFrames.GetObject(nPos);
1663*cdf0e10cSrcweir         if  (   ( !pDoc || pDoc == pFrame->GetObjectShell() )
1664*cdf0e10cSrcweir             &&  ( !bOnlyIfVisible || pFrame->IsVisible() )
1665*cdf0e10cSrcweir             )
1666*cdf0e10cSrcweir             return pFrame;
1667*cdf0e10cSrcweir     }
1668*cdf0e10cSrcweir     return 0;
1669*cdf0e10cSrcweir }
1670*cdf0e10cSrcweir 
1671*cdf0e10cSrcweir void SfxViewFrame::CloseHiddenFrames_Impl()
1672*cdf0e10cSrcweir {
1673*cdf0e10cSrcweir     SfxApplication *pSfxApp = SFX_APP();
1674*cdf0e10cSrcweir     SfxViewFrameArr_Impl &rFrames = pSfxApp->GetViewFrames_Impl();
1675*cdf0e10cSrcweir     for ( sal_uInt16 nPos=0; nPos<rFrames.Count(); )
1676*cdf0e10cSrcweir     {
1677*cdf0e10cSrcweir         SfxViewFrame *pFrame = rFrames.GetObject(nPos);
1678*cdf0e10cSrcweir         if ( !pFrame->IsVisible() )
1679*cdf0e10cSrcweir 			pFrame->DoClose();
1680*cdf0e10cSrcweir 		else
1681*cdf0e10cSrcweir 			nPos++;
1682*cdf0e10cSrcweir 	}
1683*cdf0e10cSrcweir }
1684*cdf0e10cSrcweir 
1685*cdf0e10cSrcweir //--------------------------------------------------------------------
1686*cdf0e10cSrcweir SfxProgress* SfxViewFrame::GetProgress() const
1687*cdf0e10cSrcweir {
1688*cdf0e10cSrcweir     SfxObjectShell *pObjSh = GetObjectShell();
1689*cdf0e10cSrcweir     return pObjSh ? pObjSh->GetProgress() : 0;
1690*cdf0e10cSrcweir }
1691*cdf0e10cSrcweir 
1692*cdf0e10cSrcweir //--------------------------------------------------------------------
1693*cdf0e10cSrcweir void SfxViewFrame::ShowStatusText( const String& /*rText*/)
1694*cdf0e10cSrcweir {
1695*cdf0e10cSrcweir /* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx &
1696*cdf0e10cSrcweir              framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be
1697*cdf0e10cSrcweir              extended to support a new interface to support ShowStatusText/HideStatusText
1698*cdf0e10cSrcweir     SfxWorkWindow* pWorkWin = GetFrame().GetWorkWindow_Impl();
1699*cdf0e10cSrcweir     SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl();
1700*cdf0e10cSrcweir 	if ( pMgr )
1701*cdf0e10cSrcweir 	{
1702*cdf0e10cSrcweir 		pMgr->GetStatusBar()->HideItems();
1703*cdf0e10cSrcweir 		pMgr->GetStatusBar()->SetText( rText );
1704*cdf0e10cSrcweir 	}
1705*cdf0e10cSrcweir */
1706*cdf0e10cSrcweir }
1707*cdf0e10cSrcweir 
1708*cdf0e10cSrcweir //--------------------------------------------------------------------
1709*cdf0e10cSrcweir void SfxViewFrame::HideStatusText()
1710*cdf0e10cSrcweir {
1711*cdf0e10cSrcweir /* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx &
1712*cdf0e10cSrcweir              framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be
1713*cdf0e10cSrcweir              extended to support a new interface to support ShowStatusText/HideStatusText
1714*cdf0e10cSrcweir     SfxWorkWindow* pWorkWin = GetFrame().GetWorkWindow_Impl();
1715*cdf0e10cSrcweir     SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl();
1716*cdf0e10cSrcweir 	if ( pMgr )
1717*cdf0e10cSrcweir 		pMgr->GetStatusBar()->ShowItems();
1718*cdf0e10cSrcweir */
1719*cdf0e10cSrcweir }
1720*cdf0e10cSrcweir 
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir //--------------------------------------------------------------------
1723*cdf0e10cSrcweir #ifdef ENABLE_INIMANAGER//MUSTINI
1724*cdf0e10cSrcweir SfxIniManager* SfxViewFrame::GetIniManager() const
1725*cdf0e10cSrcweir {
1726*cdf0e10cSrcweir /*  SfxIniManager *pIniMgr = GetObjectShell()
1727*cdf0e10cSrcweir             ? GetObjectShell()->GetFactory().GetIniManager()
1728*cdf0e10cSrcweir             : 0;
1729*cdf0e10cSrcweir     if ( !pIniMgr )*/ //!
1730*cdf0e10cSrcweir         return SFX_APP()->GetAppIniManager();
1731*cdf0e10cSrcweir //  return pIniMgr;
1732*cdf0e10cSrcweir }
1733*cdf0e10cSrcweir #endif
1734*cdf0e10cSrcweir 
1735*cdf0e10cSrcweir //--------------------------------------------------------------------
1736*cdf0e10cSrcweir void SfxViewFrame::DoAdjustPosSizePixel //! teilen in Inner.../Outer...
1737*cdf0e10cSrcweir (
1738*cdf0e10cSrcweir     SfxViewShell*   pSh,
1739*cdf0e10cSrcweir     const Point&    rPos,
1740*cdf0e10cSrcweir     const Size&     rSize
1741*cdf0e10cSrcweir )
1742*cdf0e10cSrcweir {
1743*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1744*cdf0e10cSrcweir 
1745*cdf0e10cSrcweir 	// Components benutzen diese Methode nicht!
1746*cdf0e10cSrcweir     if( pSh && pSh->GetWindow() && !nAdjustPosPixelLock )
1747*cdf0e10cSrcweir     {
1748*cdf0e10cSrcweir         nAdjustPosPixelLock++;
1749*cdf0e10cSrcweir         if ( pImp->bResizeInToOut )
1750*cdf0e10cSrcweir             pSh->InnerResizePixel( rPos, rSize );
1751*cdf0e10cSrcweir         else
1752*cdf0e10cSrcweir             pSh->OuterResizePixel( rPos, rSize );
1753*cdf0e10cSrcweir         nAdjustPosPixelLock--;
1754*cdf0e10cSrcweir     }
1755*cdf0e10cSrcweir }
1756*cdf0e10cSrcweir 
1757*cdf0e10cSrcweir //========================================================================
1758*cdf0e10cSrcweir 
1759*cdf0e10cSrcweir int SfxViewFrameItem::operator==( const SfxPoolItem &rItem ) const
1760*cdf0e10cSrcweir {
1761*cdf0e10cSrcweir      return PTR_CAST(SfxViewFrameItem, &rItem)->pFrame== pFrame;
1762*cdf0e10cSrcweir }
1763*cdf0e10cSrcweir 
1764*cdf0e10cSrcweir //--------------------------------------------------------------------
1765*cdf0e10cSrcweir String SfxViewFrameItem::GetValueText() const
1766*cdf0e10cSrcweir {
1767*cdf0e10cSrcweir     return String();
1768*cdf0e10cSrcweir }
1769*cdf0e10cSrcweir 
1770*cdf0e10cSrcweir //--------------------------------------------------------------------
1771*cdf0e10cSrcweir SfxPoolItem* SfxViewFrameItem::Clone( SfxItemPool *) const
1772*cdf0e10cSrcweir {
1773*cdf0e10cSrcweir     return new SfxViewFrameItem( pFrame);
1774*cdf0e10cSrcweir }
1775*cdf0e10cSrcweir 
1776*cdf0e10cSrcweir //--------------------------------------------------------------------
1777*cdf0e10cSrcweir void SfxViewFrame::SetViewShell_Impl( SfxViewShell *pVSh )
1778*cdf0e10cSrcweir 
1779*cdf0e10cSrcweir /*  [Beschreibung]
1780*cdf0e10cSrcweir 
1781*cdf0e10cSrcweir     Interne Methode zum setzen der jeweils aktuellen <SfxViewShell>-Instanz,
1782*cdf0e10cSrcweir     die in diesem SfxViewFrame aktiv ist.
1783*cdf0e10cSrcweir */
1784*cdf0e10cSrcweir 
1785*cdf0e10cSrcweir {
1786*cdf0e10cSrcweir     SfxShell::SetViewShell_Impl( pVSh );
1787*cdf0e10cSrcweir 
1788*cdf0e10cSrcweir     // Hack: InPlaceMode
1789*cdf0e10cSrcweir     if ( pVSh )
1790*cdf0e10cSrcweir         pImp->bResizeInToOut = sal_False;
1791*cdf0e10cSrcweir }
1792*cdf0e10cSrcweir 
1793*cdf0e10cSrcweir //--------------------------------------------------------------------
1794*cdf0e10cSrcweir /*
1795*cdf0e10cSrcweir     Beschreibung:
1796*cdf0e10cSrcweir     Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace
1797*cdf0e10cSrcweir */
1798*cdf0e10cSrcweir 
1799*cdf0e10cSrcweir //TODO/LATER: is it still necessary? is there a replacement for GetParentViewFrame_Impl?
1800*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::GetParentViewFrame_Impl() const
1801*cdf0e10cSrcweir {
1802*cdf0e10cSrcweir     return NULL;
1803*cdf0e10cSrcweir }
1804*cdf0e10cSrcweir 
1805*cdf0e10cSrcweir //--------------------------------------------------------------------
1806*cdf0e10cSrcweir void SfxViewFrame::ForceOuterResize_Impl(sal_Bool bOn)
1807*cdf0e10cSrcweir {
1808*cdf0e10cSrcweir 	if ( !pImp->bDontOverwriteResizeInToOut )
1809*cdf0e10cSrcweir     	pImp->bResizeInToOut = !bOn;
1810*cdf0e10cSrcweir }
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir void SfxViewFrame::ForceInnerResize_Impl(sal_Bool bOn)
1813*cdf0e10cSrcweir {
1814*cdf0e10cSrcweir 	pImp->bDontOverwriteResizeInToOut = bOn;
1815*cdf0e10cSrcweir }
1816*cdf0e10cSrcweir 
1817*cdf0e10cSrcweir //--------------------------------------------------------------------
1818*cdf0e10cSrcweir sal_Bool SfxViewFrame::IsResizeInToOut_Impl() const
1819*cdf0e10cSrcweir {
1820*cdf0e10cSrcweir     return pImp->bResizeInToOut;
1821*cdf0e10cSrcweir }
1822*cdf0e10cSrcweir //--------------------------------------------------------------------
1823*cdf0e10cSrcweir void SfxViewFrame::DoAdjustPosSize( SfxViewShell *pSh,
1824*cdf0e10cSrcweir                                 const Point rPos, const Size &rSize )
1825*cdf0e10cSrcweir {
1826*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
1827*cdf0e10cSrcweir     if( pSh && !nAdjustPosPixelLock )
1828*cdf0e10cSrcweir     {
1829*cdf0e10cSrcweir         Window *pWindow = pSh->GetWindow();
1830*cdf0e10cSrcweir         Point aPos = pWindow->LogicToPixel(rPos);
1831*cdf0e10cSrcweir         Size aSize = pWindow->LogicToPixel(rSize);
1832*cdf0e10cSrcweir         DoAdjustPosSizePixel(pSh, aPos, aSize);
1833*cdf0e10cSrcweir     }
1834*cdf0e10cSrcweir }
1835*cdf0e10cSrcweir 
1836*cdf0e10cSrcweir //--------------------------------------------------------------------
1837*cdf0e10cSrcweir void SfxViewFrame::GetDocNumber_Impl()
1838*cdf0e10cSrcweir {
1839*cdf0e10cSrcweir     DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
1840*cdf0e10cSrcweir     GetObjectShell()->SetNamedVisibility_Impl();
1841*cdf0e10cSrcweir     pImp->nDocViewNo = GetObjectShell()->GetNoSet_Impl().GetFreeIndex()+1;
1842*cdf0e10cSrcweir }
1843*cdf0e10cSrcweir 
1844*cdf0e10cSrcweir //--------------------------------------------------------------------
1845*cdf0e10cSrcweir 
1846*cdf0e10cSrcweir void SfxViewFrame::Enable( sal_Bool bEnable )
1847*cdf0e10cSrcweir {
1848*cdf0e10cSrcweir     if ( bEnable != pImp->bEnabled )
1849*cdf0e10cSrcweir     {
1850*cdf0e10cSrcweir         pImp->bEnabled = bEnable;
1851*cdf0e10cSrcweir 
1852*cdf0e10cSrcweir         // e.g. InPlace-Frames have a parent...
1853*cdf0e10cSrcweir         SfxViewFrame *pParent = GetParentViewFrame_Impl();
1854*cdf0e10cSrcweir         if ( pParent )
1855*cdf0e10cSrcweir         {
1856*cdf0e10cSrcweir             pParent->Enable( bEnable );
1857*cdf0e10cSrcweir         }
1858*cdf0e10cSrcweir         else
1859*cdf0e10cSrcweir         {
1860*cdf0e10cSrcweir             Window *pWindow = &GetFrame().GetTopFrame().GetWindow();
1861*cdf0e10cSrcweir             if ( !bEnable )
1862*cdf0e10cSrcweir                 pImp->bWindowWasEnabled = pWindow->IsInputEnabled();
1863*cdf0e10cSrcweir             if ( !bEnable || pImp->bWindowWasEnabled )
1864*cdf0e10cSrcweir                 pWindow->EnableInput( bEnable, sal_True );
1865*cdf0e10cSrcweir         }
1866*cdf0e10cSrcweir 
1867*cdf0e10cSrcweir         // cursor and focus
1868*cdf0e10cSrcweir         SfxViewShell* pViewSh = GetViewShell();
1869*cdf0e10cSrcweir         if ( bEnable )
1870*cdf0e10cSrcweir         {
1871*cdf0e10cSrcweir             // show cursor
1872*cdf0e10cSrcweir             if ( pViewSh )
1873*cdf0e10cSrcweir                 pViewSh->ShowCursor();
1874*cdf0e10cSrcweir         }
1875*cdf0e10cSrcweir         else
1876*cdf0e10cSrcweir         {
1877*cdf0e10cSrcweir             // hide cursor
1878*cdf0e10cSrcweir             if ( pViewSh )
1879*cdf0e10cSrcweir                 pViewSh->ShowCursor(sal_False);
1880*cdf0e10cSrcweir         }
1881*cdf0e10cSrcweir /*
1882*cdf0e10cSrcweir         if ( !bEnable )
1883*cdf0e10cSrcweir             GetBindings().ENTERREGISTRATIONS();
1884*cdf0e10cSrcweir         GetDispatcher()->Lock( !bEnable );
1885*cdf0e10cSrcweir         if ( bEnable )
1886*cdf0e10cSrcweir             GetBindings().LEAVEREGISTRATIONS();
1887*cdf0e10cSrcweir */
1888*cdf0e10cSrcweir     }
1889*cdf0e10cSrcweir }
1890*cdf0e10cSrcweir 
1891*cdf0e10cSrcweir //--------------------------------------------------------------------
1892*cdf0e10cSrcweir void SfxViewFrame::Show()
1893*cdf0e10cSrcweir 
1894*cdf0e10cSrcweir /*  [Beschreibung]
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir     Diese Methode macht das Frame-Window sichtbar und ermittelt vorher
1897*cdf0e10cSrcweir     den Fenstername. Au\serdem wird das Dokument festgehalten. Man darf
1898*cdf0e10cSrcweir     i.d.R. nie das Window direkt showen!
1899*cdf0e10cSrcweir */
1900*cdf0e10cSrcweir 
1901*cdf0e10cSrcweir {
1902*cdf0e10cSrcweir     // zuerst locken damit in UpdateTitle() gilt: IsVisible() == sal_True (:#)
1903*cdf0e10cSrcweir     if ( xObjSh.Is() )
1904*cdf0e10cSrcweir     {
1905*cdf0e10cSrcweir         xObjSh->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN );
1906*cdf0e10cSrcweir         if ( !pImp->bObjLocked )
1907*cdf0e10cSrcweir             LockObjectShell_Impl( sal_True );
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir         // Doc-Shell Titel-Nummer anpassen, get unique view-no
1910*cdf0e10cSrcweir         if ( 0 == pImp->nDocViewNo  )
1911*cdf0e10cSrcweir         {
1912*cdf0e10cSrcweir             GetDocNumber_Impl();
1913*cdf0e10cSrcweir             UpdateTitle();
1914*cdf0e10cSrcweir         }
1915*cdf0e10cSrcweir     }
1916*cdf0e10cSrcweir     else
1917*cdf0e10cSrcweir         UpdateTitle();
1918*cdf0e10cSrcweir 
1919*cdf0e10cSrcweir     // Frame-Window anzeigen, aber nur wenn der ViewFrame kein eigenes Window
1920*cdf0e10cSrcweir 	// hat oder wenn er keine Component enth"alt
1921*cdf0e10cSrcweir 	if ( &GetWindow() == &GetFrame().GetWindow() || !GetFrame().HasComponent() )
1922*cdf0e10cSrcweir     	GetWindow().Show();
1923*cdf0e10cSrcweir     GetFrame().GetWindow().Show();
1924*cdf0e10cSrcweir 
1925*cdf0e10cSrcweir /*    SfxViewFrame* pCurrent = SfxViewFrame::Current();
1926*cdf0e10cSrcweir 	if ( GetFrame().GetFrameInterface()->isActive() &&
1927*cdf0e10cSrcweir 			pCurrent != this &&
1928*cdf0e10cSrcweir 			( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) &&
1929*cdf0e10cSrcweir 			!GetActiveChildFrame_Impl() )
1930*cdf0e10cSrcweir         MakeActive_Impl( sal_False );*/
1931*cdf0e10cSrcweir     if ( xObjSh.Is() && xObjSh->Get_Impl()->bHiddenLockedByAPI )
1932*cdf0e10cSrcweir     {
1933*cdf0e10cSrcweir         xObjSh->Get_Impl()->bHiddenLockedByAPI = sal_False;
1934*cdf0e10cSrcweir         xObjSh->OwnerLock(sal_False);
1935*cdf0e10cSrcweir     }
1936*cdf0e10cSrcweir }
1937*cdf0e10cSrcweir 
1938*cdf0e10cSrcweir //--------------------------------------------------------------------
1939*cdf0e10cSrcweir sal_Bool SfxViewFrame::IsVisible() const
1940*cdf0e10cSrcweir {
1941*cdf0e10cSrcweir     return pImp->bObjLocked;
1942*cdf0e10cSrcweir }
1943*cdf0e10cSrcweir 
1944*cdf0e10cSrcweir //--------------------------------------------------------------------
1945*cdf0e10cSrcweir void SfxViewFrame::Hide()
1946*cdf0e10cSrcweir {
1947*cdf0e10cSrcweir     GetWindow().Hide();
1948*cdf0e10cSrcweir     if ( pImp->bObjLocked )
1949*cdf0e10cSrcweir         LockObjectShell_Impl( sal_False );
1950*cdf0e10cSrcweir }
1951*cdf0e10cSrcweir 
1952*cdf0e10cSrcweir //--------------------------------------------------------------------
1953*cdf0e10cSrcweir void SfxViewFrame::LockObjectShell_Impl( sal_Bool bLock )
1954*cdf0e10cSrcweir {
1955*cdf0e10cSrcweir     DBG_ASSERT( pImp->bObjLocked != bLock, "Falscher Locked-Status!" );
1956*cdf0e10cSrcweir 
1957*cdf0e10cSrcweir     DBG_ASSERT( GetObjectShell(), "Kein Dokument!" );
1958*cdf0e10cSrcweir     GetObjectShell()->OwnerLock(bLock);
1959*cdf0e10cSrcweir     pImp->bObjLocked = bLock;
1960*cdf0e10cSrcweir }
1961*cdf0e10cSrcweir 
1962*cdf0e10cSrcweir //--------------------------------------------------------------------
1963*cdf0e10cSrcweir void SfxViewFrame::MakeActive_Impl( sal_Bool bGrabFocus )
1964*cdf0e10cSrcweir {
1965*cdf0e10cSrcweir 	if ( GetViewShell() && !GetFrame().IsClosing_Impl() )
1966*cdf0e10cSrcweir 	{
1967*cdf0e10cSrcweir         if ( IsVisible() )
1968*cdf0e10cSrcweir         {
1969*cdf0e10cSrcweir             if ( GetViewShell() )
1970*cdf0e10cSrcweir             {
1971*cdf0e10cSrcweir                 sal_Bool bPreview = sal_False;
1972*cdf0e10cSrcweir                 if ( GetObjectShell()->IsPreview() )
1973*cdf0e10cSrcweir                 {
1974*cdf0e10cSrcweir                     bPreview = sal_True;
1975*cdf0e10cSrcweir                 }
1976*cdf0e10cSrcweir                 else
1977*cdf0e10cSrcweir                 {
1978*cdf0e10cSrcweir                     SfxViewFrame* pParent = GetParentViewFrame();
1979*cdf0e10cSrcweir                     if ( pParent )
1980*cdf0e10cSrcweir                         pParent->SetActiveChildFrame_Impl( this );
1981*cdf0e10cSrcweir                 }
1982*cdf0e10cSrcweir 
1983*cdf0e10cSrcweir                 SfxViewFrame* pCurrent = SfxViewFrame::Current();
1984*cdf0e10cSrcweir                 css::uno::Reference< css::frame::XFrame > xFrame = GetFrame().GetFrameInterface();
1985*cdf0e10cSrcweir                 if ( !bPreview )
1986*cdf0e10cSrcweir                 {
1987*cdf0e10cSrcweir                     SetViewFrame( this );
1988*cdf0e10cSrcweir                     GetBindings().SetActiveFrame( css::uno::Reference< css::frame::XFrame >() );
1989*cdf0e10cSrcweir                     uno::Reference< frame::XFramesSupplier > xSupp( xFrame, uno::UNO_QUERY );
1990*cdf0e10cSrcweir                     if ( xSupp.is() )
1991*cdf0e10cSrcweir                         xSupp->setActiveFrame( uno::Reference < frame::XFrame >() );
1992*cdf0e10cSrcweir 
1993*cdf0e10cSrcweir                     css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow();
1994*cdf0e10cSrcweir                     Window* pWindow = VCLUnoHelper::GetWindow(xContainerWindow);
1995*cdf0e10cSrcweir                     if (pWindow && pWindow->HasChildPathFocus() && bGrabFocus)
1996*cdf0e10cSrcweir                     {
1997*cdf0e10cSrcweir                         SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient();
1998*cdf0e10cSrcweir                         if ( ( !pCli || !pCli->IsObjectUIActive() ) &&
1999*cdf0e10cSrcweir                             ( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) )
2000*cdf0e10cSrcweir                                 GetFrame().GrabFocusOnComponent_Impl();
2001*cdf0e10cSrcweir                     }
2002*cdf0e10cSrcweir                 }
2003*cdf0e10cSrcweir                 else
2004*cdf0e10cSrcweir                 {
2005*cdf0e10cSrcweir                     GetBindings().SetDispatcher( GetDispatcher() );
2006*cdf0e10cSrcweir                     GetBindings().SetActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () );
2007*cdf0e10cSrcweir                     GetDispatcher()->Update_Impl( sal_False );
2008*cdf0e10cSrcweir                 }
2009*cdf0e10cSrcweir             }
2010*cdf0e10cSrcweir         }
2011*cdf0e10cSrcweir 	}
2012*cdf0e10cSrcweir }
2013*cdf0e10cSrcweir 
2014*cdf0e10cSrcweir //-------------------------------------------------------------------------
2015*cdf0e10cSrcweir 
2016*cdf0e10cSrcweir void SfxViewFrame::SetQuietMode_Impl( sal_Bool bOn )
2017*cdf0e10cSrcweir {
2018*cdf0e10cSrcweir     GetDispatcher()->SetQuietMode_Impl( bOn );
2019*cdf0e10cSrcweir }
2020*cdf0e10cSrcweir 
2021*cdf0e10cSrcweir //-------------------------------------------------------------------------
2022*cdf0e10cSrcweir 
2023*cdf0e10cSrcweir SfxObjectShell* SfxViewFrame::GetObjectShell()
2024*cdf0e10cSrcweir {
2025*cdf0e10cSrcweir     return xObjSh;
2026*cdf0e10cSrcweir }
2027*cdf0e10cSrcweir 
2028*cdf0e10cSrcweir const Size& SfxViewFrame::GetMargin_Impl() const
2029*cdf0e10cSrcweir {
2030*cdf0e10cSrcweir     return pImp->aMargin;
2031*cdf0e10cSrcweir }
2032*cdf0e10cSrcweir 
2033*cdf0e10cSrcweir void SfxViewFrame::SetActiveChildFrame_Impl( SfxViewFrame *pViewFrame )
2034*cdf0e10cSrcweir {
2035*cdf0e10cSrcweir 	if ( pViewFrame != pImp->pActiveChild )
2036*cdf0e10cSrcweir 	{
2037*cdf0e10cSrcweir 	    if ( !pImp->pActiveChild )
2038*cdf0e10cSrcweir 	        GetDispatcher()->LockUI_Impl( sal_False );
2039*cdf0e10cSrcweir 
2040*cdf0e10cSrcweir 	    pImp->pActiveChild = pViewFrame;
2041*cdf0e10cSrcweir 
2042*cdf0e10cSrcweir 		Reference< XFramesSupplier > xFrame( GetFrame().GetFrameInterface(), UNO_QUERY );
2043*cdf0e10cSrcweir 		Reference< XFrame >  xActive;
2044*cdf0e10cSrcweir 		if ( pViewFrame )
2045*cdf0e10cSrcweir 			xActive = pViewFrame->GetFrame().GetFrameInterface();
2046*cdf0e10cSrcweir 
2047*cdf0e10cSrcweir 		if ( xFrame.is() )	// PB: #74432# xFrame cann be NULL
2048*cdf0e10cSrcweir 			xFrame->setActiveFrame( xActive );
2049*cdf0e10cSrcweir 	}
2050*cdf0e10cSrcweir }
2051*cdf0e10cSrcweir 
2052*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::GetActiveChildFrame_Impl() const
2053*cdf0e10cSrcweir {
2054*cdf0e10cSrcweir     SfxViewFrame *pViewFrame = pImp->pActiveChild;
2055*cdf0e10cSrcweir /*
2056*cdf0e10cSrcweir     if ( !pViewFrame )
2057*cdf0e10cSrcweir     {
2058*cdf0e10cSrcweir         // Wenn es keinen aktiven ChildFrame gibt, irgendeinen nehmen
2059*cdf0e10cSrcweir         for ( sal_uInt16 n=0; n<GetChildFrameCount(); n++ )
2060*cdf0e10cSrcweir         {
2061*cdf0e10cSrcweir             pViewFrame =
2062*cdf0e10cSrcweir                 PTR_CAST( SfxViewFrame, GetChildFrame(n)->GetChildFrame(0) );
2063*cdf0e10cSrcweir             if ( pViewFrame )
2064*cdf0e10cSrcweir                 break;
2065*cdf0e10cSrcweir         }
2066*cdf0e10cSrcweir     }
2067*cdf0e10cSrcweir 
2068*cdf0e10cSrcweir     pImp->pActiveChild = pViewFrame;
2069*cdf0e10cSrcweir */
2070*cdf0e10cSrcweir     return pViewFrame;
2071*cdf0e10cSrcweir }
2072*cdf0e10cSrcweir 
2073*cdf0e10cSrcweir //--------------------------------------------------------------------
2074*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
2075*cdf0e10cSrcweir                                                    const sal_uInt16 i_nViewId, const bool i_bHidden )
2076*cdf0e10cSrcweir {
2077*cdf0e10cSrcweir     Reference< XFrame > xFrame( i_rFrame );
2078*cdf0e10cSrcweir     bool bOwnFrame = false;
2079*cdf0e10cSrcweir     SfxViewShell* pSuccessView = NULL;
2080*cdf0e10cSrcweir     try
2081*cdf0e10cSrcweir     {
2082*cdf0e10cSrcweir         if ( !xFrame.is() )
2083*cdf0e10cSrcweir         {
2084*cdf0e10cSrcweir             ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
2085*cdf0e10cSrcweir             Reference < XFrame > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
2086*cdf0e10cSrcweir 
2087*cdf0e10cSrcweir             if ( !i_bHidden )
2088*cdf0e10cSrcweir             {
2089*cdf0e10cSrcweir                 try
2090*cdf0e10cSrcweir                 {
2091*cdf0e10cSrcweir                     // if there is a backing component, use it
2092*cdf0e10cSrcweir                     Reference< XFramesSupplier > xTaskSupplier( xDesktop , css::uno::UNO_QUERY_THROW );
2093*cdf0e10cSrcweir                     ::framework::FrameListAnalyzer aAnalyzer( xTaskSupplier, Reference< XFrame >(), ::framework::FrameListAnalyzer::E_BACKINGCOMPONENT );
2094*cdf0e10cSrcweir 
2095*cdf0e10cSrcweir                     if ( aAnalyzer.m_xBackingComponent.is() )
2096*cdf0e10cSrcweir                         xFrame = aAnalyzer.m_xBackingComponent;
2097*cdf0e10cSrcweir                 }
2098*cdf0e10cSrcweir                 catch( uno::Exception& )
2099*cdf0e10cSrcweir                 {}
2100*cdf0e10cSrcweir             }
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir             if ( !xFrame.is() )
2103*cdf0e10cSrcweir                 xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW );
2104*cdf0e10cSrcweir 
2105*cdf0e10cSrcweir             bOwnFrame = true;
2106*cdf0e10cSrcweir         }
2107*cdf0e10cSrcweir 
2108*cdf0e10cSrcweir         pSuccessView = LoadViewIntoFrame_Impl(
2109*cdf0e10cSrcweir             i_rDoc,
2110*cdf0e10cSrcweir             xFrame,
2111*cdf0e10cSrcweir             Sequence< PropertyValue >(),    // means "reuse existing model's args"
2112*cdf0e10cSrcweir             i_nViewId,
2113*cdf0e10cSrcweir             i_bHidden
2114*cdf0e10cSrcweir         );
2115*cdf0e10cSrcweir 
2116*cdf0e10cSrcweir         if ( bOwnFrame && !i_bHidden )
2117*cdf0e10cSrcweir         {
2118*cdf0e10cSrcweir             // ensure the frame/window is visible
2119*cdf0e10cSrcweir             Reference< XWindow > xContainerWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
2120*cdf0e10cSrcweir             xContainerWindow->setVisible( sal_True );
2121*cdf0e10cSrcweir         }
2122*cdf0e10cSrcweir     }
2123*cdf0e10cSrcweir     catch( const Exception& )
2124*cdf0e10cSrcweir     {
2125*cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
2126*cdf0e10cSrcweir     }
2127*cdf0e10cSrcweir 
2128*cdf0e10cSrcweir     if ( pSuccessView )
2129*cdf0e10cSrcweir         return pSuccessView->GetViewFrame();
2130*cdf0e10cSrcweir 
2131*cdf0e10cSrcweir     if ( bOwnFrame )
2132*cdf0e10cSrcweir     {
2133*cdf0e10cSrcweir         try
2134*cdf0e10cSrcweir         {
2135*cdf0e10cSrcweir             xFrame->dispose();
2136*cdf0e10cSrcweir         }
2137*cdf0e10cSrcweir         catch( const Exception& )
2138*cdf0e10cSrcweir         {
2139*cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
2140*cdf0e10cSrcweir         }
2141*cdf0e10cSrcweir     }
2142*cdf0e10cSrcweir 
2143*cdf0e10cSrcweir     return NULL;
2144*cdf0e10cSrcweir }
2145*cdf0e10cSrcweir 
2146*cdf0e10cSrcweir //--------------------------------------------------------------------
2147*cdf0e10cSrcweir SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
2148*cdf0e10cSrcweir                                            const Sequence< PropertyValue >& i_rLoadArgs, const sal_uInt16 i_nViewId,
2149*cdf0e10cSrcweir                                            const bool i_bHidden )
2150*cdf0e10cSrcweir {
2151*cdf0e10cSrcweir     Reference< XModel > xDocument( i_rDoc.GetModel(), UNO_SET_THROW );
2152*cdf0e10cSrcweir 
2153*cdf0e10cSrcweir     ::comphelper::NamedValueCollection aTransformLoadArgs( i_rLoadArgs.getLength() ? i_rLoadArgs : xDocument->getArgs() );
2154*cdf0e10cSrcweir     aTransformLoadArgs.put( "Model", xDocument );
2155*cdf0e10cSrcweir     if ( i_nViewId )
2156*cdf0e10cSrcweir         aTransformLoadArgs.put( "ViewId", sal_Int16( i_nViewId ) );
2157*cdf0e10cSrcweir     if ( i_bHidden )
2158*cdf0e10cSrcweir         aTransformLoadArgs.put( "Hidden", i_bHidden );
2159*cdf0e10cSrcweir     else
2160*cdf0e10cSrcweir         aTransformLoadArgs.remove( "Hidden" );
2161*cdf0e10cSrcweir 
2162*cdf0e10cSrcweir     ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) );
2163*cdf0e10cSrcweir     if ( !sURL.getLength() )
2164*cdf0e10cSrcweir         sURL = i_rDoc.GetFactory().GetFactoryURL();
2165*cdf0e10cSrcweir 
2166*cdf0e10cSrcweir     Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW );
2167*cdf0e10cSrcweir     xLoader->loadComponentFromURL( sURL, ::rtl::OUString::createFromAscii( "_self" ), 0,
2168*cdf0e10cSrcweir         aTransformLoadArgs.getPropertyValues() );
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir     SfxViewShell* pViewShell = SfxViewShell::Get( i_rFrame->getController() );
2171*cdf0e10cSrcweir     ENSURE_OR_THROW( pViewShell,
2172*cdf0e10cSrcweir         "SfxViewFrame::LoadViewIntoFrame_Impl: loading an SFX doc into a frame resulted in a non-SFX view - quite impossible" );
2173*cdf0e10cSrcweir     return pViewShell;
2174*cdf0e10cSrcweir }
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir //--------------------------------------------------------------------
2177*cdf0e10cSrcweir 
2178*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::LoadHiddenDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId )
2179*cdf0e10cSrcweir {
2180*cdf0e10cSrcweir     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, true );
2181*cdf0e10cSrcweir }
2182*cdf0e10cSrcweir 
2183*cdf0e10cSrcweir //--------------------------------------------------------------------
2184*cdf0e10cSrcweir 
2185*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::LoadDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId )
2186*cdf0e10cSrcweir {
2187*cdf0e10cSrcweir     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, false );
2188*cdf0e10cSrcweir }
2189*cdf0e10cSrcweir 
2190*cdf0e10cSrcweir //--------------------------------------------------------------------
2191*cdf0e10cSrcweir 
2192*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rTargetFrame, const sal_uInt16 i_nViewId )
2193*cdf0e10cSrcweir {
2194*cdf0e10cSrcweir     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_rTargetFrame, i_nViewId, false );
2195*cdf0e10cSrcweir }
2196*cdf0e10cSrcweir 
2197*cdf0e10cSrcweir //--------------------------------------------------------------------
2198*cdf0e10cSrcweir 
2199*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const sal_uInt16 i_nViewId )
2200*cdf0e10cSrcweir {
2201*cdf0e10cSrcweir     return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem && i_pFrameItem->GetFrame() ? i_pFrameItem->GetFrame()->GetFrameInterface() : NULL, i_nViewId, false );
2202*cdf0e10cSrcweir }
2203*cdf0e10cSrcweir 
2204*cdf0e10cSrcweir //--------------------------------------------------------------------
2205*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const sal_uInt16 i_nViewId )
2206*cdf0e10cSrcweir {
2207*cdf0e10cSrcweir     SFX_REQUEST_ARG( i_rCreateDocRequest, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
2208*cdf0e10cSrcweir     SFX_REQUEST_ARG( i_rCreateDocRequest, pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False );
2209*cdf0e10cSrcweir 
2210*cdf0e10cSrcweir     return LoadViewIntoFrame_Impl_NoThrow(
2211*cdf0e10cSrcweir         i_rDoc,
2212*cdf0e10cSrcweir         pFrameItem ? pFrameItem->GetFrame() : NULL,
2213*cdf0e10cSrcweir         i_nViewId,
2214*cdf0e10cSrcweir         pHiddenItem ? pHiddenItem->GetValue() : false
2215*cdf0e10cSrcweir     );
2216*cdf0e10cSrcweir }
2217*cdf0e10cSrcweir 
2218*cdf0e10cSrcweir //--------------------------------------------------------------------
2219*cdf0e10cSrcweir 
2220*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::Get( const Reference< XController>& i_rController, const SfxObjectShell* i_pDoc )
2221*cdf0e10cSrcweir {
2222*cdf0e10cSrcweir     if ( !i_rController.is() )
2223*cdf0e10cSrcweir         return NULL;
2224*cdf0e10cSrcweir 
2225*cdf0e10cSrcweir     const SfxObjectShell* pDoc = i_pDoc;
2226*cdf0e10cSrcweir     if ( !pDoc )
2227*cdf0e10cSrcweir     {
2228*cdf0e10cSrcweir         Reference< XModel > xDocument( i_rController->getModel() );
2229*cdf0e10cSrcweir         for (   pDoc = SfxObjectShell::GetFirst( 0, false );
2230*cdf0e10cSrcweir                 pDoc;
2231*cdf0e10cSrcweir                 pDoc = SfxObjectShell::GetNext( *pDoc, 0, false )
2232*cdf0e10cSrcweir             )
2233*cdf0e10cSrcweir         {
2234*cdf0e10cSrcweir             if ( pDoc->GetModel() == xDocument )
2235*cdf0e10cSrcweir                 break;
2236*cdf0e10cSrcweir         }
2237*cdf0e10cSrcweir     }
2238*cdf0e10cSrcweir 
2239*cdf0e10cSrcweir     SfxViewFrame* pViewFrame = NULL;
2240*cdf0e10cSrcweir     for (   pViewFrame = SfxViewFrame::GetFirst( pDoc, sal_False );
2241*cdf0e10cSrcweir             pViewFrame;
2242*cdf0e10cSrcweir             pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDoc, sal_False )
2243*cdf0e10cSrcweir         )
2244*cdf0e10cSrcweir     {
2245*cdf0e10cSrcweir         if ( pViewFrame->GetViewShell()->GetController() == i_rController )
2246*cdf0e10cSrcweir             break;
2247*cdf0e10cSrcweir     }
2248*cdf0e10cSrcweir 
2249*cdf0e10cSrcweir     return pViewFrame;
2250*cdf0e10cSrcweir }
2251*cdf0e10cSrcweir 
2252*cdf0e10cSrcweir //--------------------------------------------------------------------
2253*cdf0e10cSrcweir 
2254*cdf0e10cSrcweir void SfxViewFrame::SaveCurrentViewData_Impl( const sal_uInt16 i_nNewViewId )
2255*cdf0e10cSrcweir {
2256*cdf0e10cSrcweir     SfxViewShell* pCurrentShell = GetViewShell();
2257*cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( pCurrentShell != NULL, "SfxViewFrame::SaveCurrentViewData_Impl: no current view shell -> no current view data!" );
2258*cdf0e10cSrcweir 
2259*cdf0e10cSrcweir     // determine the logical (API) view name
2260*cdf0e10cSrcweir     const SfxObjectFactory& rDocFactory( pCurrentShell->GetObjectShell()->GetFactory() );
2261*cdf0e10cSrcweir     const sal_uInt16 nCurViewNo = rDocFactory.GetViewNo_Impl( GetCurViewId(), 0 );
2262*cdf0e10cSrcweir     const String sCurrentViewName = rDocFactory.GetViewFactory( nCurViewNo ).GetAPIViewName();
2263*cdf0e10cSrcweir     const sal_uInt16 nNewViewNo = rDocFactory.GetViewNo_Impl( i_nNewViewId, 0 );
2264*cdf0e10cSrcweir     const String sNewViewName = rDocFactory.GetViewFactory( nNewViewNo ).GetAPIViewName();
2265*cdf0e10cSrcweir     if ( ( sCurrentViewName.Len() == 0 ) || ( sNewViewName.Len() == 0 ) )
2266*cdf0e10cSrcweir     {
2267*cdf0e10cSrcweir         // can't say anything about the view, the respective application did not yet migrate its code to
2268*cdf0e10cSrcweir         // named view factories => bail out
2269*cdf0e10cSrcweir         OSL_ENSURE( false, "SfxViewFrame::SaveCurrentViewData_Impl: views without API names? Shouldn't happen anymore?" );
2270*cdf0e10cSrcweir         return;
2271*cdf0e10cSrcweir     }
2272*cdf0e10cSrcweir     OSL_ENSURE( !sNewViewName.Equals( sCurrentViewName ), "SfxViewFrame::SaveCurrentViewData_Impl: suspicious: new and old view name are identical!" );
2273*cdf0e10cSrcweir 
2274*cdf0e10cSrcweir     // save the view data only when we're moving from a non-print-preview to the print-preview view
2275*cdf0e10cSrcweir     if ( !sNewViewName.EqualsAscii( "PrintPreview" ) )
2276*cdf0e10cSrcweir         return;
2277*cdf0e10cSrcweir 
2278*cdf0e10cSrcweir     // retrieve the view data from the view
2279*cdf0e10cSrcweir     Sequence< PropertyValue > aViewData;
2280*cdf0e10cSrcweir     pCurrentShell->WriteUserDataSequence( aViewData );
2281*cdf0e10cSrcweir 
2282*cdf0e10cSrcweir     try
2283*cdf0e10cSrcweir     {
2284*cdf0e10cSrcweir         // retrieve view data (for *all* views) from the model
2285*cdf0e10cSrcweir         const Reference< XController > xController( pCurrentShell->GetController(), UNO_SET_THROW );
2286*cdf0e10cSrcweir         const Reference< XViewDataSupplier > xViewDataSupplier( xController->getModel(), UNO_QUERY_THROW );
2287*cdf0e10cSrcweir         const Reference< XIndexContainer > xViewData( xViewDataSupplier->getViewData(), UNO_QUERY_THROW );
2288*cdf0e10cSrcweir 
2289*cdf0e10cSrcweir         // look up the one view data item which corresponds to our current view, and remove it
2290*cdf0e10cSrcweir         const sal_Int32 nCount = xViewData->getCount();
2291*cdf0e10cSrcweir         for ( sal_Int32 i=0; i<nCount; ++i )
2292*cdf0e10cSrcweir         {
2293*cdf0e10cSrcweir             const ::comphelper::NamedValueCollection aCurViewData( xViewData->getByIndex(i) );
2294*cdf0e10cSrcweir             ::rtl::OUString sViewId( aCurViewData.getOrDefault( "ViewId", ::rtl::OUString() ) );
2295*cdf0e10cSrcweir             if ( sViewId.getLength() == 0 )
2296*cdf0e10cSrcweir                 continue;
2297*cdf0e10cSrcweir 
2298*cdf0e10cSrcweir             const SfxViewFactory* pViewFactory = rDocFactory.GetViewFactoryByViewName( sViewId );
2299*cdf0e10cSrcweir             if ( pViewFactory == NULL )
2300*cdf0e10cSrcweir                 continue;
2301*cdf0e10cSrcweir 
2302*cdf0e10cSrcweir             if ( pViewFactory->GetOrdinal() == GetCurViewId() )
2303*cdf0e10cSrcweir             {
2304*cdf0e10cSrcweir                 xViewData->removeByIndex(i);
2305*cdf0e10cSrcweir                 break;
2306*cdf0e10cSrcweir             }
2307*cdf0e10cSrcweir         }
2308*cdf0e10cSrcweir 
2309*cdf0e10cSrcweir         // then replace it with the most recent view data we just obtained
2310*cdf0e10cSrcweir         xViewData->insertByIndex( 0, makeAny( aViewData ) );
2311*cdf0e10cSrcweir     }
2312*cdf0e10cSrcweir     catch( const Exception& )
2313*cdf0e10cSrcweir     {
2314*cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
2315*cdf0e10cSrcweir     }
2316*cdf0e10cSrcweir }
2317*cdf0e10cSrcweir 
2318*cdf0e10cSrcweir //--------------------------------------------------------------------
2319*cdf0e10cSrcweir 
2320*cdf0e10cSrcweir sal_Bool SfxViewFrame::SwitchToViewShell_Impl
2321*cdf0e10cSrcweir (
2322*cdf0e10cSrcweir     sal_uInt16  nViewIdOrNo,    /*  > 0
2323*cdf0e10cSrcweir                                 Registrierungs-Id der View, auf die umge-
2324*cdf0e10cSrcweir                                 schaltet werden soll, bzw. die erstmalig
2325*cdf0e10cSrcweir                                 erzeugt werden soll.
2326*cdf0e10cSrcweir 
2327*cdf0e10cSrcweir                                 == 0
2328*cdf0e10cSrcweir                                 Es soll die Default-View verwendet werden. */
2329*cdf0e10cSrcweir 
2330*cdf0e10cSrcweir     sal_Bool    bIsIndex        /*  sal_True
2331*cdf0e10cSrcweir                                 'nViewIdOrNo' ist keine Registrations-Id sondern
2332*cdf0e10cSrcweir                                 ein Index in die f"ur die in diesem
2333*cdf0e10cSrcweir                                 <SfxViewFrame> dargestellte <SfxObjectShell>.
2334*cdf0e10cSrcweir                                 */
2335*cdf0e10cSrcweir )
2336*cdf0e10cSrcweir 
2337*cdf0e10cSrcweir /*  [Beschreibung]
2338*cdf0e10cSrcweir 
2339*cdf0e10cSrcweir     Interne Methode zum Umschalten auf eine andere <SfxViewShell>-Subklasse,
2340*cdf0e10cSrcweir     die in diesem SfxMDIFrame erzeugt werden soll. Existiert noch
2341*cdf0e10cSrcweir     keine SfxViewShell in diesem SfxMDIFrame, so wird erstmalig eine
2342*cdf0e10cSrcweir     erzeugt.
2343*cdf0e10cSrcweir 
2344*cdf0e10cSrcweir 
2345*cdf0e10cSrcweir     [R"uckgabewert]
2346*cdf0e10cSrcweir 
2347*cdf0e10cSrcweir     sal_Bool                        sal_True
2348*cdf0e10cSrcweir                                 die angeforderte SfxViewShell wurde erzeugt
2349*cdf0e10cSrcweir                                 und eine ggf. bestehende gel"oscht
2350*cdf0e10cSrcweir 
2351*cdf0e10cSrcweir                                 sal_False
2352*cdf0e10cSrcweir                                 die angeforderte SfxViewShell konnte nicht
2353*cdf0e10cSrcweir                                 erzeugt werden, die bestehende SfxViewShell
2354*cdf0e10cSrcweir                                 existiert daher weiterhin
2355*cdf0e10cSrcweir */
2356*cdf0e10cSrcweir 
2357*cdf0e10cSrcweir {
2358*cdf0e10cSrcweir     try
2359*cdf0e10cSrcweir     {
2360*cdf0e10cSrcweir         ENSURE_OR_THROW( GetObjectShell() != NULL, "not possible without a document" );
2361*cdf0e10cSrcweir 
2362*cdf0e10cSrcweir         // if we already have a view shell, remove it
2363*cdf0e10cSrcweir         SfxViewShell* pOldSh = GetViewShell();
2364*cdf0e10cSrcweir         OSL_PRECOND( pOldSh, "SfxViewFrame::SwitchToViewShell_Impl: that's called *switch* (not for *initial-load*) for a reason" );
2365*cdf0e10cSrcweir         if ( pOldSh )
2366*cdf0e10cSrcweir         {
2367*cdf0e10cSrcweir             // ask wether it can be closed
2368*cdf0e10cSrcweir             if ( !pOldSh->PrepareClose( sal_True ) )
2369*cdf0e10cSrcweir                 return sal_False;
2370*cdf0e10cSrcweir 
2371*cdf0e10cSrcweir             // remove sub shells from Dispatcher before switching to new ViewShell
2372*cdf0e10cSrcweir             PopShellAndSubShells_Impl( *pOldSh );
2373*cdf0e10cSrcweir         }
2374*cdf0e10cSrcweir 
2375*cdf0e10cSrcweir         GetBindings().ENTERREGISTRATIONS();
2376*cdf0e10cSrcweir         LockAdjustPosSizePixel();
2377*cdf0e10cSrcweir 
2378*cdf0e10cSrcweir         // ID of the new view
2379*cdf0e10cSrcweir         SfxObjectFactory& rDocFact = GetObjectShell()->GetFactory();
2380*cdf0e10cSrcweir         const sal_uInt16 nViewId = ( bIsIndex || !nViewIdOrNo ) ? rDocFact.GetViewFactory( nViewIdOrNo ).GetOrdinal() : nViewIdOrNo;
2381*cdf0e10cSrcweir 
2382*cdf0e10cSrcweir         // save the view data of the old view, so it can be restored later on (when needed)
2383*cdf0e10cSrcweir         SaveCurrentViewData_Impl( nViewId );
2384*cdf0e10cSrcweir 
2385*cdf0e10cSrcweir         // create and load new ViewShell
2386*cdf0e10cSrcweir         SfxViewShell* pNewSh = LoadViewIntoFrame_Impl(
2387*cdf0e10cSrcweir             *GetObjectShell(),
2388*cdf0e10cSrcweir             GetFrame().GetFrameInterface(),
2389*cdf0e10cSrcweir             Sequence< PropertyValue >(),    // means "reuse existing model's args"
2390*cdf0e10cSrcweir             nViewId,
2391*cdf0e10cSrcweir             false
2392*cdf0e10cSrcweir         );
2393*cdf0e10cSrcweir 
2394*cdf0e10cSrcweir         // allow resize events to be processed
2395*cdf0e10cSrcweir         UnlockAdjustPosSizePixel();
2396*cdf0e10cSrcweir 
2397*cdf0e10cSrcweir         if ( GetWindow().IsReallyVisible() )
2398*cdf0e10cSrcweir             DoAdjustPosSizePixel( pNewSh, Point(), GetWindow().GetOutputSizePixel() );
2399*cdf0e10cSrcweir 
2400*cdf0e10cSrcweir 	    GetBindings().LEAVEREGISTRATIONS();
2401*cdf0e10cSrcweir         delete pOldSh;
2402*cdf0e10cSrcweir     }
2403*cdf0e10cSrcweir     catch ( const com::sun::star::uno::Exception& )
2404*cdf0e10cSrcweir     {
2405*cdf0e10cSrcweir         // the SfxCode is not able to cope with exceptions thrown while creating views
2406*cdf0e10cSrcweir         // the code will crash in the stack unwinding procedure, so we shouldn't let exceptions go through here
2407*cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
2408*cdf0e10cSrcweir         return sal_False;
2409*cdf0e10cSrcweir     }
2410*cdf0e10cSrcweir 
2411*cdf0e10cSrcweir     DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" );
2412*cdf0e10cSrcweir     return sal_True;
2413*cdf0e10cSrcweir }
2414*cdf0e10cSrcweir 
2415*cdf0e10cSrcweir //-------------------------------------------------------------------------
2416*cdf0e10cSrcweir void SfxViewFrame::SetCurViewId_Impl( const sal_uInt16 i_nID )
2417*cdf0e10cSrcweir {
2418*cdf0e10cSrcweir     pImp->nCurViewId = i_nID;
2419*cdf0e10cSrcweir }
2420*cdf0e10cSrcweir 
2421*cdf0e10cSrcweir //-------------------------------------------------------------------------
2422*cdf0e10cSrcweir sal_uInt16 SfxViewFrame::GetCurViewId() const
2423*cdf0e10cSrcweir {
2424*cdf0e10cSrcweir     return pImp->nCurViewId;
2425*cdf0e10cSrcweir }
2426*cdf0e10cSrcweir 
2427*cdf0e10cSrcweir //-------------------------------------------------------------------------
2428*cdf0e10cSrcweir void SfxViewFrame::ExecView_Impl
2429*cdf0e10cSrcweir (
2430*cdf0e10cSrcweir     SfxRequest& rReq        // der auszuf"uhrende <SfxRequest>
2431*cdf0e10cSrcweir )
2432*cdf0e10cSrcweir 
2433*cdf0e10cSrcweir /*  [Beschreibung]
2434*cdf0e10cSrcweir 
2435*cdf0e10cSrcweir     Interne Methode zum Ausf"uhren der f"ur die <SfxShell> Subklasse
2436*cdf0e10cSrcweir     SfxViewFrame in der <SVIDL> beschriebenen Slots.
2437*cdf0e10cSrcweir */
2438*cdf0e10cSrcweir 
2439*cdf0e10cSrcweir {
2440*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
2441*cdf0e10cSrcweir 
2442*cdf0e10cSrcweir     // Wenn gerade die Shells ausgetauscht werden...
2443*cdf0e10cSrcweir     if ( !GetObjectShell() || !GetViewShell() )
2444*cdf0e10cSrcweir         return;
2445*cdf0e10cSrcweir 
2446*cdf0e10cSrcweir     switch ( rReq.GetSlot() )
2447*cdf0e10cSrcweir     {
2448*cdf0e10cSrcweir         case SID_TERMINATE_INPLACEACTIVATION :
2449*cdf0e10cSrcweir         {
2450*cdf0e10cSrcweir             SfxInPlaceClient* pClient = GetViewShell()->GetUIActiveClient();
2451*cdf0e10cSrcweir             if ( pClient )
2452*cdf0e10cSrcweir                 pClient->DeactivateObject();
2453*cdf0e10cSrcweir             break;
2454*cdf0e10cSrcweir         }
2455*cdf0e10cSrcweir 
2456*cdf0e10cSrcweir         case SID_VIEWSHELL:
2457*cdf0e10cSrcweir         {
2458*cdf0e10cSrcweir             const SfxPoolItem *pItem = 0;
2459*cdf0e10cSrcweir             if  (   rReq.GetArgs()
2460*cdf0e10cSrcweir                 &&  SFX_ITEM_SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, sal_False, &pItem )
2461*cdf0e10cSrcweir                 )
2462*cdf0e10cSrcweir             {
2463*cdf0e10cSrcweir                 const sal_uInt16 nViewId = static_cast< const SfxUInt16Item* >( pItem )->GetValue();
2464*cdf0e10cSrcweir                 sal_Bool bSuccess = SwitchToViewShell_Impl( nViewId );
2465*cdf0e10cSrcweir                 rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
2466*cdf0e10cSrcweir             }
2467*cdf0e10cSrcweir             break;
2468*cdf0e10cSrcweir         }
2469*cdf0e10cSrcweir 
2470*cdf0e10cSrcweir         case SID_VIEWSHELL0:
2471*cdf0e10cSrcweir         case SID_VIEWSHELL1:
2472*cdf0e10cSrcweir         case SID_VIEWSHELL2:
2473*cdf0e10cSrcweir         case SID_VIEWSHELL3:
2474*cdf0e10cSrcweir         case SID_VIEWSHELL4:
2475*cdf0e10cSrcweir         {
2476*cdf0e10cSrcweir             const sal_uInt16 nViewNo = rReq.GetSlot() - SID_VIEWSHELL0;
2477*cdf0e10cSrcweir             sal_Bool bSuccess = SwitchToViewShell_Impl( nViewNo, sal_True );
2478*cdf0e10cSrcweir             rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
2479*cdf0e10cSrcweir             break;
2480*cdf0e10cSrcweir         }
2481*cdf0e10cSrcweir 
2482*cdf0e10cSrcweir         case SID_NEWWINDOW:
2483*cdf0e10cSrcweir         {
2484*cdf0e10cSrcweir             // Hack. demnaechst virtuelle Funktion
2485*cdf0e10cSrcweir             if ( !GetViewShell()->NewWindowAllowed() )
2486*cdf0e10cSrcweir             {
2487*cdf0e10cSrcweir                 OSL_ENSURE( false, "You should have disabled the 'Window/New Window' slot!" );
2488*cdf0e10cSrcweir                 return;
2489*cdf0e10cSrcweir             }
2490*cdf0e10cSrcweir 
2491*cdf0e10cSrcweir 			// ViewData bei FrameSets rekursiv holen
2492*cdf0e10cSrcweir 			GetFrame().GetViewData_Impl();
2493*cdf0e10cSrcweir 			SfxMedium* pMed = GetObjectShell()->GetMedium();
2494*cdf0e10cSrcweir 
2495*cdf0e10cSrcweir             // do not open the new window hidden
2496*cdf0e10cSrcweir 			pMed->GetItemSet()->ClearItem( SID_HIDDEN );
2497*cdf0e10cSrcweir 
2498*cdf0e10cSrcweir             // the view ID (optional arg. TODO: this is currently not supported in the slot definition ...)
2499*cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pViewIdItem, SfxUInt16Item, SID_VIEW_ID, sal_False );
2500*cdf0e10cSrcweir             const sal_uInt16 nViewId = pViewIdItem ? pViewIdItem->GetValue() : GetCurViewId();
2501*cdf0e10cSrcweir 
2502*cdf0e10cSrcweir         	Reference < XFrame > xFrame;
2503*cdf0e10cSrcweir             // the frame (optional arg. TODO: this is currently not supported in the slot definition ...)
2504*cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
2505*cdf0e10cSrcweir             if ( pFrameItem )
2506*cdf0e10cSrcweir                 xFrame = pFrameItem->GetFrame();
2507*cdf0e10cSrcweir 
2508*cdf0e10cSrcweir             LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId, false );
2509*cdf0e10cSrcweir 
2510*cdf0e10cSrcweir 			rReq.Done();
2511*cdf0e10cSrcweir             break;
2512*cdf0e10cSrcweir         }
2513*cdf0e10cSrcweir 
2514*cdf0e10cSrcweir         case SID_OBJECT:
2515*cdf0e10cSrcweir         {
2516*cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, SID_OBJECT, sal_False );
2517*cdf0e10cSrcweir 
2518*cdf0e10cSrcweir 	        SfxViewShell *pViewShell = GetViewShell();
2519*cdf0e10cSrcweir 	        if ( pViewShell && pItem )
2520*cdf0e10cSrcweir 	        {
2521*cdf0e10cSrcweir 				pViewShell->DoVerb( pItem->GetValue() );
2522*cdf0e10cSrcweir                 rReq.Done();
2523*cdf0e10cSrcweir 				break;;
2524*cdf0e10cSrcweir             }
2525*cdf0e10cSrcweir         }
2526*cdf0e10cSrcweir     }
2527*cdf0e10cSrcweir }
2528*cdf0e10cSrcweir 
2529*cdf0e10cSrcweir //-------------------------------------------------------------------------
2530*cdf0e10cSrcweir /* TODO as96863:
2531*cdf0e10cSrcweir         This method try to collect informations about the count of currently open documents.
2532*cdf0e10cSrcweir         But the algorithm is implemented very simple ...
2533*cdf0e10cSrcweir         E.g. hidden documents should be ignored here ... but they are counted.
2534*cdf0e10cSrcweir         TODO: export special helper "framework::FrameListAnalyzer" within the framework module
2535*cdf0e10cSrcweir         and use it here.
2536*cdf0e10cSrcweir */
2537*cdf0e10cSrcweir sal_Bool impl_maxOpenDocCountReached()
2538*cdf0e10cSrcweir {
2539*cdf0e10cSrcweir     static ::rtl::OUString SERVICE_DESKTOP = ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop");
2540*cdf0e10cSrcweir 
2541*cdf0e10cSrcweir     try
2542*cdf0e10cSrcweir     {
2543*cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
2544*cdf0e10cSrcweir         css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
2545*cdf0e10cSrcweir                                 xSMGR,
2546*cdf0e10cSrcweir                                 ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/"),
2547*cdf0e10cSrcweir                                 ::rtl::OUString::createFromAscii("Misc"),
2548*cdf0e10cSrcweir                                 ::rtl::OUString::createFromAscii("MaxOpenDocuments"),
2549*cdf0e10cSrcweir                                 ::comphelper::ConfigurationHelper::E_READONLY);
2550*cdf0e10cSrcweir 
2551*cdf0e10cSrcweir         // NIL means: count of allowed documents = infinite !
2552*cdf0e10cSrcweir         if ( ! aVal.hasValue())
2553*cdf0e10cSrcweir             return sal_False;
2554*cdf0e10cSrcweir 
2555*cdf0e10cSrcweir         sal_Int32 nOpenDocs = 0;
2556*cdf0e10cSrcweir         sal_Int32 nMaxDocs  = 0;
2557*cdf0e10cSrcweir         aVal >>= nMaxDocs;
2558*cdf0e10cSrcweir 
2559*cdf0e10cSrcweir         css::uno::Reference< css::frame::XFramesSupplier >  xDesktop(xSMGR->createInstance(SERVICE_DESKTOP), css::uno::UNO_QUERY_THROW);
2560*cdf0e10cSrcweir         css::uno::Reference< css::container::XIndexAccess > xCont   (xDesktop->getFrames()                 , css::uno::UNO_QUERY_THROW);
2561*cdf0e10cSrcweir 
2562*cdf0e10cSrcweir         sal_Int32 c = xCont->getCount();
2563*cdf0e10cSrcweir         sal_Int32 i = 0;
2564*cdf0e10cSrcweir 
2565*cdf0e10cSrcweir         for (i=0; i<c; ++i)
2566*cdf0e10cSrcweir         {
2567*cdf0e10cSrcweir             try
2568*cdf0e10cSrcweir             {
2569*cdf0e10cSrcweir                 css::uno::Reference< css::frame::XFrame > xFrame;
2570*cdf0e10cSrcweir                 xCont->getByIndex(i) >>= xFrame;
2571*cdf0e10cSrcweir                 if ( ! xFrame.is())
2572*cdf0e10cSrcweir                     continue;
2573*cdf0e10cSrcweir 
2574*cdf0e10cSrcweir                 // a) do not count the help window
2575*cdf0e10cSrcweir                 if (xFrame->getName().equalsAscii("OFFICE_HELP_TASK"))
2576*cdf0e10cSrcweir                     continue;
2577*cdf0e10cSrcweir 
2578*cdf0e10cSrcweir                 // b) count all other frames
2579*cdf0e10cSrcweir                 ++nOpenDocs;
2580*cdf0e10cSrcweir             }
2581*cdf0e10cSrcweir             catch(const css::uno::Exception&)
2582*cdf0e10cSrcweir                 // A IndexOutOfBoundException can happen in multithreaded environments,
2583*cdf0e10cSrcweir                 // where any other thread can change this container !
2584*cdf0e10cSrcweir                 { continue; }
2585*cdf0e10cSrcweir         }
2586*cdf0e10cSrcweir 
2587*cdf0e10cSrcweir         return (nOpenDocs >= nMaxDocs);
2588*cdf0e10cSrcweir     }
2589*cdf0e10cSrcweir     catch(const css::uno::Exception&)
2590*cdf0e10cSrcweir         {}
2591*cdf0e10cSrcweir 
2592*cdf0e10cSrcweir     // Any internal error is no reason to stop opening documents !
2593*cdf0e10cSrcweir     // Limitation of opening documents is a special "nice to  have" feature.
2594*cdf0e10cSrcweir     // Otherwhise it can happen, that NO document will be opened ...
2595*cdf0e10cSrcweir     return sal_False;
2596*cdf0e10cSrcweir }
2597*cdf0e10cSrcweir 
2598*cdf0e10cSrcweir //-------------------------------------------------------------------------
2599*cdf0e10cSrcweir void SfxViewFrame::StateView_Impl
2600*cdf0e10cSrcweir (
2601*cdf0e10cSrcweir     SfxItemSet&     rSet            /*  leeres <SfxItemSet> mit <Which-Ranges>,
2602*cdf0e10cSrcweir                                         welche die Ids der zu erfragenden
2603*cdf0e10cSrcweir                                         Slots beschreiben. */
2604*cdf0e10cSrcweir )
2605*cdf0e10cSrcweir 
2606*cdf0e10cSrcweir /*  [Beschreibung]
2607*cdf0e10cSrcweir 
2608*cdf0e10cSrcweir     Diese interne Methode liefert in 'rSet' die Status der f"ur die
2609*cdf0e10cSrcweir     <SfxShell> Subklasse SfxViewFrame in der <SVIDL> beschriebenen <Slots>.
2610*cdf0e10cSrcweir 
2611*cdf0e10cSrcweir     In 'rSet' sind dabei genau die vom SFx als ung"ultig erkannten
2612*cdf0e10cSrcweir     Slot-Ids als Which-ranges enthalten. Falls der an dieser Shell gesetzte
2613*cdf0e10cSrcweir     <SfxItemPool> f"ur einzelne Slot-Ids ein Mapping hat, werden die
2614*cdf0e10cSrcweir     entsprechenden Which-Ids verwendet, so da\s Items ggf. direkt mit
2615*cdf0e10cSrcweir     einer mit Which-Ids arbeitenden Core-::com::sun::star::script::Engine ausgetauscht werden
2616*cdf0e10cSrcweir     k"onnen.
2617*cdf0e10cSrcweir */
2618*cdf0e10cSrcweir 
2619*cdf0e10cSrcweir {
2620*cdf0e10cSrcweir     DBG_CHKTHIS(SfxViewFrame, 0);
2621*cdf0e10cSrcweir 
2622*cdf0e10cSrcweir     SfxObjectShell *pDocSh = GetObjectShell();
2623*cdf0e10cSrcweir 
2624*cdf0e10cSrcweir     if ( !pDocSh )
2625*cdf0e10cSrcweir 		// Ich bin gerade am Reloaden und Yielde so vor mich hin ...
2626*cdf0e10cSrcweir         return;
2627*cdf0e10cSrcweir 
2628*cdf0e10cSrcweir     const sal_uInt16 *pRanges = rSet.GetRanges();
2629*cdf0e10cSrcweir     DBG_ASSERT(pRanges, "Set ohne Bereich");
2630*cdf0e10cSrcweir     while ( *pRanges )
2631*cdf0e10cSrcweir     {
2632*cdf0e10cSrcweir         for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich )
2633*cdf0e10cSrcweir         {
2634*cdf0e10cSrcweir             switch(nWhich)
2635*cdf0e10cSrcweir             {
2636*cdf0e10cSrcweir                 case SID_VIEWSHELL:
2637*cdf0e10cSrcweir                 {
2638*cdf0e10cSrcweir                     rSet.Put( SfxUInt16Item( nWhich, pImp->nCurViewId ) );
2639*cdf0e10cSrcweir                     break;
2640*cdf0e10cSrcweir                 }
2641*cdf0e10cSrcweir 
2642*cdf0e10cSrcweir                 case SID_VIEWSHELL0:
2643*cdf0e10cSrcweir                 case SID_VIEWSHELL1:
2644*cdf0e10cSrcweir                 case SID_VIEWSHELL2:
2645*cdf0e10cSrcweir                 case SID_VIEWSHELL3:
2646*cdf0e10cSrcweir                 case SID_VIEWSHELL4:
2647*cdf0e10cSrcweir                 {
2648*cdf0e10cSrcweir                     sal_uInt16 nViewNo = nWhich - SID_VIEWSHELL0;
2649*cdf0e10cSrcweir                     if ( GetObjectShell()->GetFactory().GetViewFactoryCount() >
2650*cdf0e10cSrcweir                          nViewNo && !GetObjectShell()->IsInPlaceActive() )
2651*cdf0e10cSrcweir                     {
2652*cdf0e10cSrcweir                         SfxViewFactory &rViewFactory =
2653*cdf0e10cSrcweir                             GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
2654*cdf0e10cSrcweir                         rSet.Put( SfxBoolItem(
2655*cdf0e10cSrcweir                             nWhich, pImp->nCurViewId == rViewFactory.GetOrdinal() ) );
2656*cdf0e10cSrcweir                     }
2657*cdf0e10cSrcweir                     else
2658*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
2659*cdf0e10cSrcweir                     break;
2660*cdf0e10cSrcweir                 }
2661*cdf0e10cSrcweir                 case SID_FRAMETITLE:
2662*cdf0e10cSrcweir                 {
2663*cdf0e10cSrcweir                     if( GetFrameType() & SFXFRAME_HASTITLE )
2664*cdf0e10cSrcweir                         rSet.Put( SfxStringItem(
2665*cdf0e10cSrcweir                             SID_FRAMETITLE, pImp->aFrameTitle) );
2666*cdf0e10cSrcweir                     else
2667*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
2668*cdf0e10cSrcweir                     break;
2669*cdf0e10cSrcweir                 }
2670*cdf0e10cSrcweir 
2671*cdf0e10cSrcweir 		        case SID_NEWWINDOW:
2672*cdf0e10cSrcweir 		        {
2673*cdf0e10cSrcweir                     if  (   !GetViewShell()->NewWindowAllowed()
2674*cdf0e10cSrcweir                         ||  impl_maxOpenDocCountReached()
2675*cdf0e10cSrcweir                         )
2676*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
2677*cdf0e10cSrcweir 					break;
2678*cdf0e10cSrcweir 				}
2679*cdf0e10cSrcweir             }
2680*cdf0e10cSrcweir         }
2681*cdf0e10cSrcweir     }
2682*cdf0e10cSrcweir }
2683*cdf0e10cSrcweir 
2684*cdf0e10cSrcweir //-------------------------------------------------------------------------
2685*cdf0e10cSrcweir void SfxViewFrame::ToTop()
2686*cdf0e10cSrcweir {
2687*cdf0e10cSrcweir     GetFrame().Appear();
2688*cdf0e10cSrcweir }
2689*cdf0e10cSrcweir 
2690*cdf0e10cSrcweir //-------------------------------------------------------------------------
2691*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::GetParentViewFrame() const
2692*cdf0e10cSrcweir /*
2693*cdf0e10cSrcweir     Beschreibung:
2694*cdf0e10cSrcweir     Der ParentViewFrame ist der ViewFrame des ParentFrames
2695*cdf0e10cSrcweir */
2696*cdf0e10cSrcweir {
2697*cdf0e10cSrcweir     SfxFrame *pFrame = GetFrame().GetParentFrame();
2698*cdf0e10cSrcweir     return pFrame ? pFrame->GetCurrentViewFrame() : NULL;
2699*cdf0e10cSrcweir }
2700*cdf0e10cSrcweir 
2701*cdf0e10cSrcweir //-------------------------------------------------------------------------
2702*cdf0e10cSrcweir SfxFrame& SfxViewFrame::GetFrame() const
2703*cdf0e10cSrcweir /*
2704*cdf0e10cSrcweir     Beschreibung:
2705*cdf0e10cSrcweir     GetFrame liefert den Frame, in dem sich der ViewFrame befindet
2706*cdf0e10cSrcweir */
2707*cdf0e10cSrcweir {
2708*cdf0e10cSrcweir     return pImp->rFrame;
2709*cdf0e10cSrcweir }
2710*cdf0e10cSrcweir 
2711*cdf0e10cSrcweir //-------------------------------------------------------------------------
2712*cdf0e10cSrcweir SfxViewFrame* SfxViewFrame::GetTopViewFrame() const
2713*cdf0e10cSrcweir {
2714*cdf0e10cSrcweir     return GetFrame().GetTopFrame().GetCurrentViewFrame();
2715*cdf0e10cSrcweir }
2716*cdf0e10cSrcweir 
2717*cdf0e10cSrcweir Window& SfxViewFrame::GetWindow() const
2718*cdf0e10cSrcweir {
2719*cdf0e10cSrcweir 	return pImp->pWindow ? *pImp->pWindow : GetFrame().GetWindow();
2720*cdf0e10cSrcweir }
2721*cdf0e10cSrcweir 
2722*cdf0e10cSrcweir sal_Bool SfxViewFrame::DoClose()
2723*cdf0e10cSrcweir {
2724*cdf0e10cSrcweir 	return GetFrame().DoClose();
2725*cdf0e10cSrcweir }
2726*cdf0e10cSrcweir 
2727*cdf0e10cSrcweir String SfxViewFrame::GetActualPresentationURL_Impl() const
2728*cdf0e10cSrcweir {
2729*cdf0e10cSrcweir 	if ( xObjSh.Is() )
2730*cdf0e10cSrcweir 		return xObjSh->GetMedium()->GetName();
2731*cdf0e10cSrcweir 	return String();
2732*cdf0e10cSrcweir }
2733*cdf0e10cSrcweir 
2734*cdf0e10cSrcweir void SfxViewFrame::SetModalMode( sal_Bool bModal )
2735*cdf0e10cSrcweir {
2736*cdf0e10cSrcweir     pImp->bModal = bModal;
2737*cdf0e10cSrcweir     if ( xObjSh.Is() )
2738*cdf0e10cSrcweir     {
2739*cdf0e10cSrcweir         for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( xObjSh );
2740*cdf0e10cSrcweir 			  !bModal && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, xObjSh ) )
2741*cdf0e10cSrcweir             bModal = pFrame->pImp->bModal;
2742*cdf0e10cSrcweir         xObjSh->SetModalMode_Impl( bModal );
2743*cdf0e10cSrcweir     }
2744*cdf0e10cSrcweir }
2745*cdf0e10cSrcweir 
2746*cdf0e10cSrcweir sal_Bool SfxViewFrame::IsInModalMode() const
2747*cdf0e10cSrcweir {
2748*cdf0e10cSrcweir     return pImp->bModal || GetFrame().GetWindow().IsInModalMode();
2749*cdf0e10cSrcweir }
2750*cdf0e10cSrcweir 
2751*cdf0e10cSrcweir void SfxViewFrame::Resize( sal_Bool bForce )
2752*cdf0e10cSrcweir {
2753*cdf0e10cSrcweir     Size aSize = GetWindow().GetOutputSizePixel();
2754*cdf0e10cSrcweir     if ( bForce || aSize != pImp->aSize )
2755*cdf0e10cSrcweir     {
2756*cdf0e10cSrcweir         pImp->aSize = aSize;
2757*cdf0e10cSrcweir         SfxViewShell *pShell = GetViewShell();
2758*cdf0e10cSrcweir         if ( pShell )
2759*cdf0e10cSrcweir         {
2760*cdf0e10cSrcweir             if ( GetFrame().IsInPlace() )
2761*cdf0e10cSrcweir             {
2762*cdf0e10cSrcweir                 Point aPoint = GetWindow().GetPosPixel();
2763*cdf0e10cSrcweir                 DoAdjustPosSizePixel( pShell, aPoint, aSize );
2764*cdf0e10cSrcweir             }
2765*cdf0e10cSrcweir             else
2766*cdf0e10cSrcweir             {
2767*cdf0e10cSrcweir                 DoAdjustPosSizePixel( pShell, Point(), aSize );
2768*cdf0e10cSrcweir             }
2769*cdf0e10cSrcweir         }
2770*cdf0e10cSrcweir     }
2771*cdf0e10cSrcweir }
2772*cdf0e10cSrcweir 
2773*cdf0e10cSrcweir #define LINE_SEP 0x0A
2774*cdf0e10cSrcweir 
2775*cdf0e10cSrcweir void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, sal_Bool bEraseTrailingEmptyLines )
2776*cdf0e10cSrcweir {
2777*cdf0e10cSrcweir 	sal_Int32 nStartPos = 0;
2778*cdf0e10cSrcweir 	sal_Int32 nEndPos = 0;
2779*cdf0e10cSrcweir 	sal_Int32 nLine = 0;
2780*cdf0e10cSrcweir 	while ( nLine < nStartLine )
2781*cdf0e10cSrcweir 	{
2782*cdf0e10cSrcweir         nStartPos = rStr.indexOf( LINE_SEP, nStartPos );
2783*cdf0e10cSrcweir         if( nStartPos == -1 )
2784*cdf0e10cSrcweir             break;
2785*cdf0e10cSrcweir 		nStartPos++;	// nicht das \n.
2786*cdf0e10cSrcweir 		nLine++;
2787*cdf0e10cSrcweir 	}
2788*cdf0e10cSrcweir 
2789*cdf0e10cSrcweir 	DBG_ASSERTWARNING( nStartPos != STRING_NOTFOUND, "CutLines: Startzeile nicht gefunden!" );
2790*cdf0e10cSrcweir 
2791*cdf0e10cSrcweir 	if ( nStartPos != -1 )
2792*cdf0e10cSrcweir 	{
2793*cdf0e10cSrcweir 		nEndPos = nStartPos;
2794*cdf0e10cSrcweir 		for ( sal_Int32 i = 0; i < nLines; i++ )
2795*cdf0e10cSrcweir 			nEndPos = rStr.indexOf( LINE_SEP, nEndPos+1 );
2796*cdf0e10cSrcweir 
2797*cdf0e10cSrcweir 		if ( nEndPos == -1 ) // kann bei letzter Zeile passieren
2798*cdf0e10cSrcweir 			nEndPos = rStr.getLength();
2799*cdf0e10cSrcweir         else
2800*cdf0e10cSrcweir 			nEndPos++;
2801*cdf0e10cSrcweir 
2802*cdf0e10cSrcweir         ::rtl::OUString aEndStr = rStr.copy( nEndPos );
2803*cdf0e10cSrcweir         rStr = rStr.copy( 0, nStartPos );
2804*cdf0e10cSrcweir         rStr += aEndStr;
2805*cdf0e10cSrcweir 	}
2806*cdf0e10cSrcweir 	if ( bEraseTrailingEmptyLines )
2807*cdf0e10cSrcweir 	{
2808*cdf0e10cSrcweir 		sal_Int32 n = nStartPos;
2809*cdf0e10cSrcweir 		sal_Int32 nLen = rStr.getLength();
2810*cdf0e10cSrcweir 		while ( ( n < nLen ) && ( rStr.getStr()[ n ] == LINE_SEP ) )
2811*cdf0e10cSrcweir 			n++;
2812*cdf0e10cSrcweir 
2813*cdf0e10cSrcweir 		if ( n > nStartPos )
2814*cdf0e10cSrcweir         {
2815*cdf0e10cSrcweir             ::rtl::OUString aEndStr = rStr.copy( n );
2816*cdf0e10cSrcweir             rStr = rStr.copy( 0, nStartPos );
2817*cdf0e10cSrcweir             rStr += aEndStr;
2818*cdf0e10cSrcweir         }
2819*cdf0e10cSrcweir 	}
2820*cdf0e10cSrcweir }
2821*cdf0e10cSrcweir 
2822*cdf0e10cSrcweir /*
2823*cdf0e10cSrcweir     add new recorded dispatch macro script into the application global basic lib container
2824*cdf0e10cSrcweir     It generates a new unique id for it and insert the macro by using this number as name for
2825*cdf0e10cSrcweir     the modul
2826*cdf0e10cSrcweir  */
2827*cdf0e10cSrcweir void SfxViewFrame::AddDispatchMacroToBasic_Impl( const ::rtl::OUString& sMacro )
2828*cdf0e10cSrcweir {
2829*cdf0e10cSrcweir     /*
2830*cdf0e10cSrcweir     // get lib and modul name from dialog
2831*cdf0e10cSrcweir     SfxModule *pMod = GetObjectShell()->GetModule();
2832*cdf0e10cSrcweir     SfxRequest aReq( SID_BASICCHOOSER, SFX_CALLMODE_SYNCHRON, pMod->GetPool() );
2833*cdf0e10cSrcweir     const SfxPoolItem* pRet = pMod->ExecuteSlot( aReq );
2834*cdf0e10cSrcweir     if ( pRet )
2835*cdf0e10cSrcweir         ::rtl::OUString = ((SfxStringItem*)pRet)->GetValue();
2836*cdf0e10cSrcweir     */
2837*cdf0e10cSrcweir     if ( !sMacro.getLength() )
2838*cdf0e10cSrcweir         return;
2839*cdf0e10cSrcweir 
2840*cdf0e10cSrcweir     SfxApplication* pSfxApp = SFX_APP();
2841*cdf0e10cSrcweir     SfxRequest aReq( SID_BASICCHOOSER, SFX_CALLMODE_SYNCHRON, pSfxApp->GetPool() );
2842*cdf0e10cSrcweir     aReq.AppendItem( SfxBoolItem(SID_RECORDMACRO,sal_True) );
2843*cdf0e10cSrcweir     const SfxPoolItem* pRet = SFX_APP()->ExecuteSlot( aReq );
2844*cdf0e10cSrcweir     String aScriptURL;
2845*cdf0e10cSrcweir     if ( pRet )
2846*cdf0e10cSrcweir         aScriptURL = ((SfxStringItem*)pRet)->GetValue();
2847*cdf0e10cSrcweir     if ( aScriptURL.Len() )
2848*cdf0e10cSrcweir     {
2849*cdf0e10cSrcweir         // parse scriptURL
2850*cdf0e10cSrcweir         String aLibName;
2851*cdf0e10cSrcweir         String aModuleName;
2852*cdf0e10cSrcweir         String aMacroName;
2853*cdf0e10cSrcweir         String aLocation;
2854*cdf0e10cSrcweir         Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory();
2855*cdf0e10cSrcweir         Reference< com::sun::star::uri::XUriReferenceFactory > xFactory( xSMgr->createInstance(
2856*cdf0e10cSrcweir             ::rtl::OUString::createFromAscii( "com.sun.star.uri.UriReferenceFactory" ) ), UNO_QUERY );
2857*cdf0e10cSrcweir         if ( xFactory.is() )
2858*cdf0e10cSrcweir         {
2859*cdf0e10cSrcweir             Reference< com::sun::star::uri::XVndSunStarScriptUrl > xUrl( xFactory->parse( aScriptURL ), UNO_QUERY );
2860*cdf0e10cSrcweir             if ( xUrl.is() )
2861*cdf0e10cSrcweir             {
2862*cdf0e10cSrcweir                 // get name
2863*cdf0e10cSrcweir                 ::rtl::OUString aName = xUrl->getName();
2864*cdf0e10cSrcweir                 sal_Unicode cTok = '.';
2865*cdf0e10cSrcweir                 sal_Int32 nIndex = 0;
2866*cdf0e10cSrcweir                 aLibName = aName.getToken( 0, cTok, nIndex );
2867*cdf0e10cSrcweir                 if ( nIndex != -1 )
2868*cdf0e10cSrcweir                     aModuleName = aName.getToken( 0, cTok, nIndex );
2869*cdf0e10cSrcweir                 if ( nIndex != -1 )
2870*cdf0e10cSrcweir                     aMacroName = aName.getToken( 0, cTok, nIndex );
2871*cdf0e10cSrcweir 
2872*cdf0e10cSrcweir                 // get location
2873*cdf0e10cSrcweir                 ::rtl::OUString aLocKey = ::rtl::OUString::createFromAscii( "location" );
2874*cdf0e10cSrcweir                 if ( xUrl->hasParameter( aLocKey ) )
2875*cdf0e10cSrcweir                     aLocation = xUrl->getParameter( aLocKey );
2876*cdf0e10cSrcweir             }
2877*cdf0e10cSrcweir         }
2878*cdf0e10cSrcweir 
2879*cdf0e10cSrcweir 		BasicManager* pBasMgr = 0;
2880*cdf0e10cSrcweir         if ( aLocation.EqualsIgnoreCaseAscii( "application" ) )
2881*cdf0e10cSrcweir         {
2882*cdf0e10cSrcweir 			// application basic
2883*cdf0e10cSrcweir 			pBasMgr = pSfxApp->GetBasicManager();
2884*cdf0e10cSrcweir 		}
2885*cdf0e10cSrcweir         else if ( aLocation.EqualsIgnoreCaseAscii( "document" ) )
2886*cdf0e10cSrcweir         {
2887*cdf0e10cSrcweir             pBasMgr = GetObjectShell()->GetBasicManager();
2888*cdf0e10cSrcweir 		}
2889*cdf0e10cSrcweir 
2890*cdf0e10cSrcweir         ::rtl::OUString aOUSource;
2891*cdf0e10cSrcweir         if ( pBasMgr)
2892*cdf0e10cSrcweir 		{
2893*cdf0e10cSrcweir 			StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
2894*cdf0e10cSrcweir 			if ( pBasic )
2895*cdf0e10cSrcweir 			{
2896*cdf0e10cSrcweir 				SbModule* pModule = pBasic->FindModule( aModuleName );
2897*cdf0e10cSrcweir 				if ( pModule )
2898*cdf0e10cSrcweir 				{
2899*cdf0e10cSrcweir                     SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD );
2900*cdf0e10cSrcweir                     aOUSource = pModule->GetSource32();
2901*cdf0e10cSrcweir                     sal_uInt16 nStart, nEnd;
2902*cdf0e10cSrcweir                     pMethod->GetLineRange( nStart, nEnd );
2903*cdf0e10cSrcweir                     sal_uIntPtr nlStart = nStart;
2904*cdf0e10cSrcweir                     sal_uIntPtr nlEnd = nEnd;
2905*cdf0e10cSrcweir                     CutLines( aOUSource, nlStart-1, nlEnd-nlStart+1, sal_True );
2906*cdf0e10cSrcweir 				}
2907*cdf0e10cSrcweir 			}
2908*cdf0e10cSrcweir 		}
2909*cdf0e10cSrcweir 
2910*cdf0e10cSrcweir         // open lib container and break operation if it couldn't be opened
2911*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibCont;
2912*cdf0e10cSrcweir         if ( aLocation.EqualsIgnoreCaseAscii( "application" ) )
2913*cdf0e10cSrcweir         {
2914*cdf0e10cSrcweir             xLibCont = SFX_APP()->GetBasicContainer();
2915*cdf0e10cSrcweir 		}
2916*cdf0e10cSrcweir         else if ( aLocation.EqualsIgnoreCaseAscii( "document" ) )
2917*cdf0e10cSrcweir         {
2918*cdf0e10cSrcweir             xLibCont = GetObjectShell()->GetBasicContainer();
2919*cdf0e10cSrcweir 		}
2920*cdf0e10cSrcweir 
2921*cdf0e10cSrcweir         if(!xLibCont.is())
2922*cdf0e10cSrcweir         {
2923*cdf0e10cSrcweir             DBG_ERRORFILE("couldn't get access to the basic lib container. Adding of macro isn't possible.");
2924*cdf0e10cSrcweir             return;
2925*cdf0e10cSrcweir         }
2926*cdf0e10cSrcweir 
2927*cdf0e10cSrcweir         // get LibraryContainer
2928*cdf0e10cSrcweir         com::sun::star::uno::Any aTemp;
2929*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xRoot(
2930*cdf0e10cSrcweir                 xLibCont,
2931*cdf0e10cSrcweir                 com::sun::star::uno::UNO_QUERY);
2932*cdf0e10cSrcweir 
2933*cdf0e10cSrcweir         ::rtl::OUString sLib( aLibName );
2934*cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xLib;
2935*cdf0e10cSrcweir         if(xRoot->hasByName(sLib))
2936*cdf0e10cSrcweir         {
2937*cdf0e10cSrcweir             // library must be loaded
2938*cdf0e10cSrcweir             aTemp = xRoot->getByName(sLib);
2939*cdf0e10cSrcweir             xLibCont->loadLibrary(sLib);
2940*cdf0e10cSrcweir             aTemp >>= xLib;
2941*cdf0e10cSrcweir         }
2942*cdf0e10cSrcweir         else
2943*cdf0e10cSrcweir         {
2944*cdf0e10cSrcweir             xLib = com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >(
2945*cdf0e10cSrcweir                         xLibCont->createLibrary(sLib),
2946*cdf0e10cSrcweir                         com::sun::star::uno::UNO_QUERY);
2947*cdf0e10cSrcweir         }
2948*cdf0e10cSrcweir 
2949*cdf0e10cSrcweir         // pack the macro as direct usable "sub" routine
2950*cdf0e10cSrcweir         ::rtl::OUString sCode;
2951*cdf0e10cSrcweir         ::rtl::OUStringBuffer sRoutine(10000);
2952*cdf0e10cSrcweir         ::rtl::OUString sMacroName( aMacroName );
2953*cdf0e10cSrcweir         sal_Bool bReplace = sal_False;
2954*cdf0e10cSrcweir 
2955*cdf0e10cSrcweir         // get module
2956*cdf0e10cSrcweir         ::rtl::OUString sModule( aModuleName );
2957*cdf0e10cSrcweir         if(xLib->hasByName(sModule))
2958*cdf0e10cSrcweir         {
2959*cdf0e10cSrcweir             if ( aOUSource.getLength() )
2960*cdf0e10cSrcweir             {
2961*cdf0e10cSrcweir                 sRoutine.append( aOUSource );
2962*cdf0e10cSrcweir             }
2963*cdf0e10cSrcweir             else
2964*cdf0e10cSrcweir             {
2965*cdf0e10cSrcweir                 aTemp = xLib->getByName(sModule);
2966*cdf0e10cSrcweir                 aTemp >>= sCode;
2967*cdf0e10cSrcweir                 sRoutine.append( sCode );
2968*cdf0e10cSrcweir             }
2969*cdf0e10cSrcweir 
2970*cdf0e10cSrcweir             bReplace = sal_True;
2971*cdf0e10cSrcweir         }
2972*cdf0e10cSrcweir 
2973*cdf0e10cSrcweir         // append new method
2974*cdf0e10cSrcweir         sRoutine.appendAscii("\nsub "     );
2975*cdf0e10cSrcweir         sRoutine.append     (sMacroName   );
2976*cdf0e10cSrcweir         sRoutine.appendAscii("\n"         );
2977*cdf0e10cSrcweir         sRoutine.append     (sMacro       );
2978*cdf0e10cSrcweir         sRoutine.appendAscii("\nend sub\n");
2979*cdf0e10cSrcweir 
2980*cdf0e10cSrcweir         // create the modul inside the library and insert the macro routine
2981*cdf0e10cSrcweir         aTemp <<= sRoutine.makeStringAndClear();
2982*cdf0e10cSrcweir         if ( bReplace )
2983*cdf0e10cSrcweir         {
2984*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xModulCont(
2985*cdf0e10cSrcweir                 xLib,
2986*cdf0e10cSrcweir                 com::sun::star::uno::UNO_QUERY);
2987*cdf0e10cSrcweir             xModulCont->replaceByName(sModule,aTemp);
2988*cdf0e10cSrcweir         }
2989*cdf0e10cSrcweir         else
2990*cdf0e10cSrcweir         {
2991*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xModulCont(
2992*cdf0e10cSrcweir                 xLib,
2993*cdf0e10cSrcweir                 com::sun::star::uno::UNO_QUERY);
2994*cdf0e10cSrcweir             xModulCont->insertByName(sModule,aTemp);
2995*cdf0e10cSrcweir         }
2996*cdf0e10cSrcweir 
2997*cdf0e10cSrcweir         // #i17355# update the Basic IDE
2998*cdf0e10cSrcweir         for ( SfxViewShell* pViewShell = SfxViewShell::GetFirst(); pViewShell; pViewShell = SfxViewShell::GetNext( *pViewShell ) )
2999*cdf0e10cSrcweir         {
3000*cdf0e10cSrcweir             if ( pViewShell->GetName().EqualsAscii( "BasicIDE" ) )
3001*cdf0e10cSrcweir             {
3002*cdf0e10cSrcweir                 SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
3003*cdf0e10cSrcweir                 SfxDispatcher* pDispat = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
3004*cdf0e10cSrcweir                 if ( pDispat )
3005*cdf0e10cSrcweir                 {
3006*cdf0e10cSrcweir                     SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLibName, aModuleName, String(), String() );
3007*cdf0e10cSrcweir                     pDispat->Execute( SID_BASICIDE_UPDATEMODULESOURCE, SFX_CALLMODE_SYNCHRON, &aInfoItem, 0L );
3008*cdf0e10cSrcweir                 }
3009*cdf0e10cSrcweir             }
3010*cdf0e10cSrcweir         }
3011*cdf0e10cSrcweir     }
3012*cdf0e10cSrcweir     else
3013*cdf0e10cSrcweir     {
3014*cdf0e10cSrcweir         // add code for "session only" macro
3015*cdf0e10cSrcweir     }
3016*cdf0e10cSrcweir }
3017*cdf0e10cSrcweir 
3018*cdf0e10cSrcweir void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
3019*cdf0e10cSrcweir {
3020*cdf0e10cSrcweir 	DBG_MEMTEST();
3021*cdf0e10cSrcweir 	switch ( rReq.GetSlot() )
3022*cdf0e10cSrcweir 	{
3023*cdf0e10cSrcweir         case SID_STOP_RECORDING :
3024*cdf0e10cSrcweir         case SID_RECORDMACRO :
3025*cdf0e10cSrcweir         {
3026*cdf0e10cSrcweir             // try to find any active recorder on this frame
3027*cdf0e10cSrcweir             ::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier");
3028*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
3029*cdf0e10cSrcweir                     GetFrame().GetFrameInterface(),
3030*cdf0e10cSrcweir                     com::sun::star::uno::UNO_QUERY);
3031*cdf0e10cSrcweir 
3032*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(xFrame,com::sun::star::uno::UNO_QUERY);
3033*cdf0e10cSrcweir             com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
3034*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
3035*cdf0e10cSrcweir             aProp >>= xSupplier;
3036*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
3037*cdf0e10cSrcweir             if (xSupplier.is())
3038*cdf0e10cSrcweir                 xRecorder = xSupplier->getDispatchRecorder();
3039*cdf0e10cSrcweir 
3040*cdf0e10cSrcweir             sal_Bool bIsRecording = xRecorder.is();
3041*cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_RECORDMACRO, sal_False);
3042*cdf0e10cSrcweir             if ( pItem && pItem->GetValue() == bIsRecording )
3043*cdf0e10cSrcweir                 return;
3044*cdf0e10cSrcweir 
3045*cdf0e10cSrcweir             if ( xRecorder.is() )
3046*cdf0e10cSrcweir             {
3047*cdf0e10cSrcweir                 // disable active recording
3048*cdf0e10cSrcweir                 aProp <<= com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier >();
3049*cdf0e10cSrcweir                 xSet->setPropertyValue(sProperty,aProp);
3050*cdf0e10cSrcweir 
3051*cdf0e10cSrcweir                 SFX_REQUEST_ARG( rReq, pRecordItem, SfxBoolItem, FN_PARAM_1, sal_False);
3052*cdf0e10cSrcweir                 if ( !pRecordItem || !pRecordItem->GetValue() )
3053*cdf0e10cSrcweir                     // insert script into basic library container of application
3054*cdf0e10cSrcweir                     AddDispatchMacroToBasic_Impl(xRecorder->getRecordedMacro());
3055*cdf0e10cSrcweir 
3056*cdf0e10cSrcweir                 xRecorder->endRecording();
3057*cdf0e10cSrcweir                 xRecorder = NULL;
3058*cdf0e10cSrcweir 				GetBindings().SetRecorder_Impl( xRecorder );
3059*cdf0e10cSrcweir 
3060*cdf0e10cSrcweir                 SetChildWindow( SID_RECORDING_FLOATWINDOW, sal_False );
3061*cdf0e10cSrcweir                 if ( rReq.GetSlot() != SID_RECORDMACRO )
3062*cdf0e10cSrcweir                     GetBindings().Invalidate( SID_RECORDMACRO );
3063*cdf0e10cSrcweir             }
3064*cdf0e10cSrcweir             else if ( rReq.GetSlot() == SID_RECORDMACRO )
3065*cdf0e10cSrcweir             {
3066*cdf0e10cSrcweir                 // enable recording
3067*cdf0e10cSrcweir                 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xFactory(
3068*cdf0e10cSrcweir                         ::comphelper::getProcessServiceFactory(),
3069*cdf0e10cSrcweir                         com::sun::star::uno::UNO_QUERY);
3070*cdf0e10cSrcweir 
3071*cdf0e10cSrcweir                 xRecorder = com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >(
3072*cdf0e10cSrcweir                         xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.frame.DispatchRecorder")),
3073*cdf0e10cSrcweir                         com::sun::star::uno::UNO_QUERY);
3074*cdf0e10cSrcweir 
3075*cdf0e10cSrcweir                 xSupplier = com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier >(
3076*cdf0e10cSrcweir                         xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.frame.DispatchRecorderSupplier")),
3077*cdf0e10cSrcweir                         com::sun::star::uno::UNO_QUERY);
3078*cdf0e10cSrcweir 
3079*cdf0e10cSrcweir                 xSupplier->setDispatchRecorder(xRecorder);
3080*cdf0e10cSrcweir                 xRecorder->startRecording(xFrame);
3081*cdf0e10cSrcweir                 aProp <<= xSupplier;
3082*cdf0e10cSrcweir                 xSet->setPropertyValue(sProperty,aProp);
3083*cdf0e10cSrcweir 				GetBindings().SetRecorder_Impl( xRecorder );
3084*cdf0e10cSrcweir                 SetChildWindow( SID_RECORDING_FLOATWINDOW, sal_True );
3085*cdf0e10cSrcweir             }
3086*cdf0e10cSrcweir 
3087*cdf0e10cSrcweir             rReq.Done();
3088*cdf0e10cSrcweir             break;
3089*cdf0e10cSrcweir         }
3090*cdf0e10cSrcweir 
3091*cdf0e10cSrcweir 		case SID_TOGGLESTATUSBAR:
3092*cdf0e10cSrcweir 		{
3093*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
3094*cdf0e10cSrcweir                     GetFrame().GetFrameInterface(),
3095*cdf0e10cSrcweir                     com::sun::star::uno::UNO_QUERY);
3096*cdf0e10cSrcweir 
3097*cdf0e10cSrcweir 	        Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
3098*cdf0e10cSrcweir             Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
3099*cdf0e10cSrcweir 	        if ( xPropSet.is() )
3100*cdf0e10cSrcweir 	        {
3101*cdf0e10cSrcweir 		        try
3102*cdf0e10cSrcweir 		        {
3103*cdf0e10cSrcweir 			        Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
3104*cdf0e10cSrcweir 			        aValue >>= xLayoutManager;
3105*cdf0e10cSrcweir                 }
3106*cdf0e10cSrcweir                 catch ( Exception& )
3107*cdf0e10cSrcweir                 {
3108*cdf0e10cSrcweir                 }
3109*cdf0e10cSrcweir             }
3110*cdf0e10cSrcweir 
3111*cdf0e10cSrcweir             if ( xLayoutManager.is() )
3112*cdf0e10cSrcweir             {
3113*cdf0e10cSrcweir                 rtl::OUString aStatusbarResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
3114*cdf0e10cSrcweir                 // Parameter auswerten
3115*cdf0e10cSrcweir 			    SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, rReq.GetSlot(), sal_False);
3116*cdf0e10cSrcweir                 sal_Bool bShow( sal_True );
3117*cdf0e10cSrcweir                 if ( !pShowItem )
3118*cdf0e10cSrcweir                     bShow = xLayoutManager->isElementVisible( aStatusbarResString );
3119*cdf0e10cSrcweir                 else
3120*cdf0e10cSrcweir                     bShow = pShowItem->GetValue();
3121*cdf0e10cSrcweir 
3122*cdf0e10cSrcweir                 if ( bShow )
3123*cdf0e10cSrcweir                 {
3124*cdf0e10cSrcweir                     xLayoutManager->createElement( aStatusbarResString );
3125*cdf0e10cSrcweir                     xLayoutManager->showElement( aStatusbarResString );
3126*cdf0e10cSrcweir                 }
3127*cdf0e10cSrcweir                 else
3128*cdf0e10cSrcweir                     xLayoutManager->hideElement( aStatusbarResString );
3129*cdf0e10cSrcweir 
3130*cdf0e10cSrcweir                 if ( !pShowItem )
3131*cdf0e10cSrcweir 				    rReq.AppendItem( SfxBoolItem( SID_TOGGLESTATUSBAR, bShow ) );
3132*cdf0e10cSrcweir             }
3133*cdf0e10cSrcweir 			rReq.Done();
3134*cdf0e10cSrcweir 			break;
3135*cdf0e10cSrcweir 		}
3136*cdf0e10cSrcweir 
3137*cdf0e10cSrcweir 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3138*cdf0e10cSrcweir 		case SID_WIN_FULLSCREEN:
3139*cdf0e10cSrcweir 		{
3140*cdf0e10cSrcweir             SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), sal_False);
3141*cdf0e10cSrcweir             SfxViewFrame *pTop = GetTopViewFrame();
3142*cdf0e10cSrcweir             if ( pTop )
3143*cdf0e10cSrcweir             {
3144*cdf0e10cSrcweir                 WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl();
3145*cdf0e10cSrcweir                 if ( pWork )
3146*cdf0e10cSrcweir                 {
3147*cdf0e10cSrcweir                     com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
3148*cdf0e10cSrcweir                             GetFrame().GetFrameInterface(),
3149*cdf0e10cSrcweir                             com::sun::star::uno::UNO_QUERY);
3150*cdf0e10cSrcweir 
3151*cdf0e10cSrcweir                     Reference< ::com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
3152*cdf0e10cSrcweir                     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
3153*cdf0e10cSrcweir 	                if ( xPropSet.is() )
3154*cdf0e10cSrcweir 	                {
3155*cdf0e10cSrcweir 		                try
3156*cdf0e10cSrcweir 		                {
3157*cdf0e10cSrcweir 			                Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
3158*cdf0e10cSrcweir 			                aValue >>= xLayoutManager;
3159*cdf0e10cSrcweir                         }
3160*cdf0e10cSrcweir                         catch ( Exception& )
3161*cdf0e10cSrcweir                         {
3162*cdf0e10cSrcweir                         }
3163*cdf0e10cSrcweir                     }
3164*cdf0e10cSrcweir 
3165*cdf0e10cSrcweir                     sal_Bool bNewFullScreenMode = pItem ? pItem->GetValue() : !pWork->IsFullScreenMode();
3166*cdf0e10cSrcweir 					if ( bNewFullScreenMode != pWork->IsFullScreenMode() )
3167*cdf0e10cSrcweir 					{
3168*cdf0e10cSrcweir                         Reference< ::com::sun::star::beans::XPropertySet > xLMPropSet( xLayoutManager, UNO_QUERY );
3169*cdf0e10cSrcweir                         if ( xLMPropSet.is() )
3170*cdf0e10cSrcweir                         {
3171*cdf0e10cSrcweir                             try
3172*cdf0e10cSrcweir                             {
3173*cdf0e10cSrcweir                                 xLMPropSet->setPropertyValue(
3174*cdf0e10cSrcweir                                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HideCurrentUI" )),
3175*cdf0e10cSrcweir                                     makeAny( bNewFullScreenMode ));
3176*cdf0e10cSrcweir                             }
3177*cdf0e10cSrcweir                             catch ( ::com::sun::star::beans::UnknownPropertyException& )
3178*cdf0e10cSrcweir                             {
3179*cdf0e10cSrcweir                             }
3180*cdf0e10cSrcweir                         }
3181*cdf0e10cSrcweir 	                    pWork->ShowFullScreenMode( bNewFullScreenMode );
3182*cdf0e10cSrcweir 	                    pWork->SetMenuBarMode( bNewFullScreenMode ? MENUBAR_MODE_HIDE : MENUBAR_MODE_NORMAL );
3183*cdf0e10cSrcweir 	                    GetFrame().GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode );
3184*cdf0e10cSrcweir 	                    if ( !pItem )
3185*cdf0e10cSrcweir 	                        rReq.AppendItem( SfxBoolItem( SID_WIN_FULLSCREEN, bNewFullScreenMode ) );
3186*cdf0e10cSrcweir 	                    rReq.Done();
3187*cdf0e10cSrcweir 					}
3188*cdf0e10cSrcweir 					else
3189*cdf0e10cSrcweir 						rReq.Ignore();
3190*cdf0e10cSrcweir                 }
3191*cdf0e10cSrcweir             }
3192*cdf0e10cSrcweir             else
3193*cdf0e10cSrcweir                 rReq.Ignore();
3194*cdf0e10cSrcweir 
3195*cdf0e10cSrcweir             GetDispatcher()->Update_Impl( sal_True );
3196*cdf0e10cSrcweir 			break;
3197*cdf0e10cSrcweir 		}
3198*cdf0e10cSrcweir 	}
3199*cdf0e10cSrcweir }
3200*cdf0e10cSrcweir 
3201*cdf0e10cSrcweir void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
3202*cdf0e10cSrcweir {
3203*cdf0e10cSrcweir 	DBG_MEMTEST();
3204*cdf0e10cSrcweir 
3205*cdf0e10cSrcweir 	const sal_uInt16 *pRanges = rSet.GetRanges();
3206*cdf0e10cSrcweir 	DBG_ASSERT(pRanges && *pRanges, "Set ohne Bereich");
3207*cdf0e10cSrcweir 	while ( *pRanges )
3208*cdf0e10cSrcweir 	{
3209*cdf0e10cSrcweir 		for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
3210*cdf0e10cSrcweir 		{
3211*cdf0e10cSrcweir 			switch(nWhich)
3212*cdf0e10cSrcweir 			{
3213*cdf0e10cSrcweir                 case SID_CURRENT_URL:
3214*cdf0e10cSrcweir                 {
3215*cdf0e10cSrcweir                     // Bei internem InPlace den ContainerFrame nehmen
3216*cdf0e10cSrcweir                     SfxViewFrame *pFrame = this;
3217*cdf0e10cSrcweir                     if ( pFrame->GetParentViewFrame_Impl() )
3218*cdf0e10cSrcweir                         pFrame = pFrame->GetParentViewFrame_Impl();
3219*cdf0e10cSrcweir                     rSet.Put( SfxStringItem( nWhich, pFrame->GetActualPresentationURL_Impl() ) );
3220*cdf0e10cSrcweir 	                break;
3221*cdf0e10cSrcweir                 }
3222*cdf0e10cSrcweir 
3223*cdf0e10cSrcweir                 case SID_RECORDMACRO :
3224*cdf0e10cSrcweir                 {
3225*cdf0e10cSrcweir 					const char* pName = GetObjectShell()->GetFactory().GetShortName();
3226*cdf0e10cSrcweir 					if (  strcmp(pName,"swriter") && strcmp(pName,"scalc") )
3227*cdf0e10cSrcweir 					{
3228*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
3229*cdf0e10cSrcweir 						break;
3230*cdf0e10cSrcweir 					}
3231*cdf0e10cSrcweir 
3232*cdf0e10cSrcweir                     ::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier");
3233*cdf0e10cSrcweir                     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
3234*cdf0e10cSrcweir                             GetFrame().GetFrameInterface(),
3235*cdf0e10cSrcweir                             com::sun::star::uno::UNO_QUERY);
3236*cdf0e10cSrcweir 
3237*cdf0e10cSrcweir                     com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
3238*cdf0e10cSrcweir                     com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
3239*cdf0e10cSrcweir                     if ( aProp >>= xSupplier )
3240*cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, xSupplier.is() ) );
3241*cdf0e10cSrcweir                     else
3242*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
3243*cdf0e10cSrcweir                     break;
3244*cdf0e10cSrcweir                 }
3245*cdf0e10cSrcweir 
3246*cdf0e10cSrcweir                 case SID_STOP_RECORDING :
3247*cdf0e10cSrcweir                 {
3248*cdf0e10cSrcweir 					const char* pName = GetObjectShell()->GetFactory().GetShortName();
3249*cdf0e10cSrcweir 					if (  strcmp(pName,"swriter") && strcmp(pName,"scalc") )
3250*cdf0e10cSrcweir 					{
3251*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
3252*cdf0e10cSrcweir 						break;
3253*cdf0e10cSrcweir 					}
3254*cdf0e10cSrcweir 
3255*cdf0e10cSrcweir                     ::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier");
3256*cdf0e10cSrcweir                     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
3257*cdf0e10cSrcweir                             GetFrame().GetFrameInterface(),
3258*cdf0e10cSrcweir                             com::sun::star::uno::UNO_QUERY);
3259*cdf0e10cSrcweir 
3260*cdf0e10cSrcweir                     com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty);
3261*cdf0e10cSrcweir                     com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
3262*cdf0e10cSrcweir                     if ( !(aProp >>= xSupplier) || !xSupplier.is() )
3263*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
3264*cdf0e10cSrcweir                     break;
3265*cdf0e10cSrcweir                 }
3266*cdf0e10cSrcweir 
3267*cdf0e10cSrcweir 				case SID_TOGGLESTATUSBAR:
3268*cdf0e10cSrcweir 				{
3269*cdf0e10cSrcweir                     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
3270*cdf0e10cSrcweir                     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
3271*cdf0e10cSrcweir                             GetFrame().GetFrameInterface(),
3272*cdf0e10cSrcweir                             com::sun::star::uno::UNO_QUERY);
3273*cdf0e10cSrcweir                     com::sun::star::uno::Any aProp = xSet->getPropertyValue(
3274*cdf0e10cSrcweir                         rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )) );
3275*cdf0e10cSrcweir 
3276*cdf0e10cSrcweir 			        if ( !( aProp >>= xLayoutManager ))
3277*cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, sal_False ));
3278*cdf0e10cSrcweir                     else
3279*cdf0e10cSrcweir                     {
3280*cdf0e10cSrcweir                         rtl::OUString aStatusbarResString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
3281*cdf0e10cSrcweir                         sal_Bool bShow = xLayoutManager->isElementVisible( aStatusbarResString );
3282*cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, bShow ));
3283*cdf0e10cSrcweir                     }
3284*cdf0e10cSrcweir 					break;
3285*cdf0e10cSrcweir 				}
3286*cdf0e10cSrcweir 
3287*cdf0e10cSrcweir 				case SID_WIN_FULLSCREEN:
3288*cdf0e10cSrcweir                 {
3289*cdf0e10cSrcweir                     SfxViewFrame* pTop = GetTopViewFrame();
3290*cdf0e10cSrcweir                     if ( pTop )
3291*cdf0e10cSrcweir                     {
3292*cdf0e10cSrcweir                         WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl();
3293*cdf0e10cSrcweir                         if ( pWork )
3294*cdf0e10cSrcweir                         {
3295*cdf0e10cSrcweir                             rSet.Put( SfxBoolItem( nWhich, pWork->IsFullScreenMode() ) );
3296*cdf0e10cSrcweir                             break;
3297*cdf0e10cSrcweir                         }
3298*cdf0e10cSrcweir                     }
3299*cdf0e10cSrcweir 
3300*cdf0e10cSrcweir                     rSet.DisableItem( nWhich );
3301*cdf0e10cSrcweir 					break;
3302*cdf0e10cSrcweir                 }
3303*cdf0e10cSrcweir 
3304*cdf0e10cSrcweir                 case SID_FORMATMENUSTATE :
3305*cdf0e10cSrcweir                 {
3306*cdf0e10cSrcweir                     DBG_ERROR("Outdated slot!");
3307*cdf0e10cSrcweir                     rSet.DisableItem( nWhich );
3308*cdf0e10cSrcweir                     break;
3309*cdf0e10cSrcweir                 }
3310*cdf0e10cSrcweir 
3311*cdf0e10cSrcweir 				default:
3312*cdf0e10cSrcweir 					//! DBG_ASSERT(FALSE, "Falscher Server fuer GetState");
3313*cdf0e10cSrcweir 					break;
3314*cdf0e10cSrcweir 			}
3315*cdf0e10cSrcweir 		}
3316*cdf0e10cSrcweir 
3317*cdf0e10cSrcweir 		++pRanges;
3318*cdf0e10cSrcweir 	}
3319*cdf0e10cSrcweir }
3320*cdf0e10cSrcweir 
3321*cdf0e10cSrcweir void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
3322*cdf0e10cSrcweir 
3323*cdf0e10cSrcweir /* 	[Beschreibung]
3324*cdf0e10cSrcweir 
3325*cdf0e10cSrcweir 	Diese Methode kann in der Execute-Methode f"ur das ein- und ausschalten
3326*cdf0e10cSrcweir 	von Child-Windows eingesetzt werden, um dieses inkl. API-Anbindung zu
3327*cdf0e10cSrcweir 	implementieren.
3328*cdf0e10cSrcweir 
3329*cdf0e10cSrcweir 	Einfach in der IDL als 'ExecuteMethod' eintragen.
3330*cdf0e10cSrcweir */
3331*cdf0e10cSrcweir 
3332*cdf0e10cSrcweir {
3333*cdf0e10cSrcweir 	// Parameter auswerten
3334*cdf0e10cSrcweir 	sal_uInt16 nSID = rReq.GetSlot();
3335*cdf0e10cSrcweir 
3336*cdf0e10cSrcweir 	SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSID, sal_False);
3337*cdf0e10cSrcweir     if ( nSID == SID_VIEW_DATA_SOURCE_BROWSER )
3338*cdf0e10cSrcweir     {
3339*cdf0e10cSrcweir         if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
3340*cdf0e10cSrcweir             return;
3341*cdf0e10cSrcweir         Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface();
3342*cdf0e10cSrcweir         Reference < XFrame > xBeamer( xFrame->findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN ) );
3343*cdf0e10cSrcweir         sal_Bool bShow = sal_False;
3344*cdf0e10cSrcweir         sal_Bool bHasChild = xBeamer.is();
3345*cdf0e10cSrcweir         bShow = pShowItem ? pShowItem->GetValue() : !bHasChild;
3346*cdf0e10cSrcweir         if ( pShowItem )
3347*cdf0e10cSrcweir         {
3348*cdf0e10cSrcweir             if( bShow == bHasChild )
3349*cdf0e10cSrcweir                 return;
3350*cdf0e10cSrcweir         }
3351*cdf0e10cSrcweir         else
3352*cdf0e10cSrcweir             rReq.AppendItem( SfxBoolItem( nSID, bShow ) );
3353*cdf0e10cSrcweir 
3354*cdf0e10cSrcweir         if ( !bShow )
3355*cdf0e10cSrcweir         {
3356*cdf0e10cSrcweir             SetChildWindow( SID_BROWSER, sal_False );
3357*cdf0e10cSrcweir         }
3358*cdf0e10cSrcweir         else
3359*cdf0e10cSrcweir         {
3360*cdf0e10cSrcweir             ::com::sun::star::util::URL aTargetURL;
3361*cdf0e10cSrcweir             aTargetURL.Complete = ::rtl::OUString::createFromAscii(".component:DB/DataSourceBrowser");
3362*cdf0e10cSrcweir             Reference < ::com::sun::star::util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY );
3363*cdf0e10cSrcweir             xTrans->parseStrict( aTargetURL );
3364*cdf0e10cSrcweir 
3365*cdf0e10cSrcweir             Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
3366*cdf0e10cSrcweir             Reference < ::com::sun::star::frame::XDispatch > xDisp;
3367*cdf0e10cSrcweir             if ( xProv.is() )
3368*cdf0e10cSrcweir                 xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString::createFromAscii("_beamer"), 31 );
3369*cdf0e10cSrcweir             if ( xDisp.is() )
3370*cdf0e10cSrcweir             {
3371*cdf0e10cSrcweir                 Sequence < ::com::sun::star::beans::PropertyValue > aArgs(1);
3372*cdf0e10cSrcweir                 ::com::sun::star::beans::PropertyValue* pArg = aArgs.getArray();
3373*cdf0e10cSrcweir                 pArg[0].Name = rtl::OUString::createFromAscii("Referer");
3374*cdf0e10cSrcweir                 pArg[0].Value <<= ::rtl::OUString::createFromAscii("private:user");
3375*cdf0e10cSrcweir                 xDisp->dispatch( aTargetURL, aArgs );
3376*cdf0e10cSrcweir             }
3377*cdf0e10cSrcweir         }
3378*cdf0e10cSrcweir 
3379*cdf0e10cSrcweir         rReq.Done();
3380*cdf0e10cSrcweir         return;
3381*cdf0e10cSrcweir     }
3382*cdf0e10cSrcweir 
3383*cdf0e10cSrcweir 	sal_Bool bShow = sal_False;
3384*cdf0e10cSrcweir 	sal_Bool bHasChild = HasChildWindow(nSID);
3385*cdf0e10cSrcweir 	bShow = pShowItem ? pShowItem->GetValue() : !bHasChild;
3386*cdf0e10cSrcweir 
3387*cdf0e10cSrcweir 	// ausf"uhren
3388*cdf0e10cSrcweir 	if ( !pShowItem || bShow != bHasChild )
3389*cdf0e10cSrcweir 		ToggleChildWindow( nSID );
3390*cdf0e10cSrcweir 
3391*cdf0e10cSrcweir 	GetBindings().Invalidate( nSID );
3392*cdf0e10cSrcweir     GetDispatcher()->Update_Impl( sal_True );
3393*cdf0e10cSrcweir 
3394*cdf0e10cSrcweir 	// ggf. recorden
3395*cdf0e10cSrcweir     if ( nSID == SID_HYPERLINK_DIALOG || nSID == SID_SEARCH_DLG )
3396*cdf0e10cSrcweir     {
3397*cdf0e10cSrcweir         rReq.Ignore();
3398*cdf0e10cSrcweir     }
3399*cdf0e10cSrcweir     else
3400*cdf0e10cSrcweir     {
3401*cdf0e10cSrcweir         rReq.AppendItem( SfxBoolItem( nSID, bShow ) );
3402*cdf0e10cSrcweir         rReq.Done();
3403*cdf0e10cSrcweir     }
3404*cdf0e10cSrcweir }
3405*cdf0e10cSrcweir 
3406*cdf0e10cSrcweir //--------------------------------------------------------------------
3407*cdf0e10cSrcweir 
3408*cdf0e10cSrcweir void SfxViewFrame::ChildWindowState( SfxItemSet& rState )
3409*cdf0e10cSrcweir 
3410*cdf0e10cSrcweir /* 	[Beschreibung]
3411*cdf0e10cSrcweir 
3412*cdf0e10cSrcweir 	Diese Methode kann in der Status-Methode f"ur das Ein- und Ausschalt-
3413*cdf0e10cSrcweir 	Zustand von Child-Windows eingesetzt werden, um dieses zu implementieren.
3414*cdf0e10cSrcweir 
3415*cdf0e10cSrcweir 	Einfach in der IDL als 'StateMethod' eintragen.
3416*cdf0e10cSrcweir */
3417*cdf0e10cSrcweir 
3418*cdf0e10cSrcweir {
3419*cdf0e10cSrcweir 	SfxWhichIter aIter( rState );
3420*cdf0e10cSrcweir 	for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
3421*cdf0e10cSrcweir 	{
3422*cdf0e10cSrcweir         if ( nSID == SID_VIEW_DATA_SOURCE_BROWSER )
3423*cdf0e10cSrcweir         {
3424*cdf0e10cSrcweir             rState.Put( SfxBoolItem( nSID, HasChildWindow( SID_BROWSER ) ) );
3425*cdf0e10cSrcweir         }
3426*cdf0e10cSrcweir         else if ( nSID == SID_HYPERLINK_DIALOG )
3427*cdf0e10cSrcweir 		{
3428*cdf0e10cSrcweir 			const SfxPoolItem* pDummy = NULL;
3429*cdf0e10cSrcweir             SfxItemState eState = GetDispatcher()->QueryState( SID_HYPERLINK_SETLINK, pDummy );
3430*cdf0e10cSrcweir 			if ( SFX_ITEM_DISABLED == eState )
3431*cdf0e10cSrcweir 				rState.DisableItem(nSID);
3432*cdf0e10cSrcweir 			else
3433*cdf0e10cSrcweir 			{
3434*cdf0e10cSrcweir 				if ( KnowsChildWindow(nSID) )
3435*cdf0e10cSrcweir 					rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID)) );
3436*cdf0e10cSrcweir 				else
3437*cdf0e10cSrcweir 					rState.DisableItem(nSID);
3438*cdf0e10cSrcweir 			}
3439*cdf0e10cSrcweir 		}
3440*cdf0e10cSrcweir         else if ( nSID == SID_BROWSER )
3441*cdf0e10cSrcweir 		{
3442*cdf0e10cSrcweir 			Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface()->
3443*cdf0e10cSrcweir 							findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN );
3444*cdf0e10cSrcweir 			if ( !xFrame.is() )
3445*cdf0e10cSrcweir 				rState.DisableItem( nSID );
3446*cdf0e10cSrcweir 			else if ( KnowsChildWindow(nSID) )
3447*cdf0e10cSrcweir 				rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
3448*cdf0e10cSrcweir 		}
3449*cdf0e10cSrcweir         else if ( nSID == SID_TASKPANE )
3450*cdf0e10cSrcweir         {
3451*cdf0e10cSrcweir             if  ( !KnowsChildWindow( nSID ) )
3452*cdf0e10cSrcweir             {
3453*cdf0e10cSrcweir                 OSL_ENSURE( false, "SID_TASKPANE state requested, but no task pane child window exists for this ID!" );
3454*cdf0e10cSrcweir 			    rState.DisableItem( nSID );
3455*cdf0e10cSrcweir             }
3456*cdf0e10cSrcweir             else if ( !moduleHasToolPanels( *pImp ) )
3457*cdf0e10cSrcweir             {
3458*cdf0e10cSrcweir                 rState.Put( SfxVisibilityItem( nSID, sal_False ) );
3459*cdf0e10cSrcweir             }
3460*cdf0e10cSrcweir             else
3461*cdf0e10cSrcweir             {
3462*cdf0e10cSrcweir 			    rState.Put( SfxBoolItem( nSID, HasChildWindow( nSID ) ) );
3463*cdf0e10cSrcweir             }
3464*cdf0e10cSrcweir         }
3465*cdf0e10cSrcweir 		else if ( KnowsChildWindow(nSID) )
3466*cdf0e10cSrcweir 			rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
3467*cdf0e10cSrcweir 		else
3468*cdf0e10cSrcweir 			rState.DisableItem(nSID);
3469*cdf0e10cSrcweir 	}
3470*cdf0e10cSrcweir }
3471*cdf0e10cSrcweir 
3472*cdf0e10cSrcweir //--------------------------------------------------------------------
3473*cdf0e10cSrcweir SfxWorkWindow* SfxViewFrame::GetWorkWindow_Impl( sal_uInt16 /*nId*/ )
3474*cdf0e10cSrcweir {
3475*cdf0e10cSrcweir     SfxWorkWindow* pWork = 0;
3476*cdf0e10cSrcweir     pWork = GetFrame().GetWorkWindow_Impl();
3477*cdf0e10cSrcweir     return pWork;
3478*cdf0e10cSrcweir }
3479*cdf0e10cSrcweir 
3480*cdf0e10cSrcweir /*
3481*cdf0e10cSrcweir void SfxViewFrame::SetChildWindow(sal_uInt16 nId, sal_Bool bOn)
3482*cdf0e10cSrcweir {
3483*cdf0e10cSrcweir     SetChildWindow( nId, bOn, sal_True );
3484*cdf0e10cSrcweir }*/
3485*cdf0e10cSrcweir 
3486*cdf0e10cSrcweir void SfxViewFrame::SetChildWindow(sal_uInt16 nId, sal_Bool bOn, sal_Bool bSetFocus )
3487*cdf0e10cSrcweir {
3488*cdf0e10cSrcweir     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
3489*cdf0e10cSrcweir     if ( pWork )
3490*cdf0e10cSrcweir         pWork->SetChildWindow_Impl( nId, bOn, bSetFocus );
3491*cdf0e10cSrcweir }
3492*cdf0e10cSrcweir 
3493*cdf0e10cSrcweir //--------------------------------------------------------------------
3494*cdf0e10cSrcweir 
3495*cdf0e10cSrcweir void SfxViewFrame::ToggleChildWindow(sal_uInt16 nId)
3496*cdf0e10cSrcweir {
3497*cdf0e10cSrcweir     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
3498*cdf0e10cSrcweir     if ( pWork )
3499*cdf0e10cSrcweir         pWork->ToggleChildWindow_Impl( nId, sal_True );
3500*cdf0e10cSrcweir }
3501*cdf0e10cSrcweir 
3502*cdf0e10cSrcweir //--------------------------------------------------------------------
3503*cdf0e10cSrcweir 
3504*cdf0e10cSrcweir sal_Bool SfxViewFrame::HasChildWindow( sal_uInt16 nId )
3505*cdf0e10cSrcweir {
3506*cdf0e10cSrcweir 	SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
3507*cdf0e10cSrcweir 	return pWork ? pWork->HasChildWindow_Impl(nId) : sal_False;
3508*cdf0e10cSrcweir }
3509*cdf0e10cSrcweir 
3510*cdf0e10cSrcweir //--------------------------------------------------------------------
3511*cdf0e10cSrcweir 
3512*cdf0e10cSrcweir sal_Bool SfxViewFrame::KnowsChildWindow( sal_uInt16 nId )
3513*cdf0e10cSrcweir {
3514*cdf0e10cSrcweir     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
3515*cdf0e10cSrcweir 	return pWork ? pWork->KnowsChildWindow_Impl(nId) : sal_False;
3516*cdf0e10cSrcweir }
3517*cdf0e10cSrcweir 
3518*cdf0e10cSrcweir //--------------------------------------------------------------------
3519*cdf0e10cSrcweir 
3520*cdf0e10cSrcweir void SfxViewFrame::ShowChildWindow( sal_uInt16 nId, sal_Bool bVisible )
3521*cdf0e10cSrcweir {
3522*cdf0e10cSrcweir     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
3523*cdf0e10cSrcweir     if ( pWork )
3524*cdf0e10cSrcweir     {
3525*cdf0e10cSrcweir         GetDispatcher()->Update_Impl(sal_True);
3526*cdf0e10cSrcweir         pWork->ShowChildWindow_Impl(nId, bVisible, sal_True );
3527*cdf0e10cSrcweir     }
3528*cdf0e10cSrcweir }
3529*cdf0e10cSrcweir 
3530*cdf0e10cSrcweir //--------------------------------------------------------------------
3531*cdf0e10cSrcweir 
3532*cdf0e10cSrcweir SfxChildWindow* SfxViewFrame::GetChildWindow(sal_uInt16 nId)
3533*cdf0e10cSrcweir {
3534*cdf0e10cSrcweir     SfxWorkWindow* pWork = GetWorkWindow_Impl( nId );
3535*cdf0e10cSrcweir 	return pWork ? pWork->GetChildWindow_Impl(nId) : NULL;
3536*cdf0e10cSrcweir }
3537*cdf0e10cSrcweir 
3538*cdf0e10cSrcweir void SfxViewFrame::UpdateDocument_Impl()
3539*cdf0e10cSrcweir {
3540*cdf0e10cSrcweir     SfxObjectShell* pDoc = GetObjectShell();
3541*cdf0e10cSrcweir 	if ( pDoc->IsLoadingFinished() )
3542*cdf0e10cSrcweir         pDoc->CheckSecurityOnLoading_Impl();
3543*cdf0e10cSrcweir 
3544*cdf0e10cSrcweir 	// check if document depends on a template
3545*cdf0e10cSrcweir     pDoc->UpdateFromTemplate_Impl();
3546*cdf0e10cSrcweir }
3547*cdf0e10cSrcweir 
3548*cdf0e10cSrcweir void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
3549*cdf0e10cSrcweir {
3550*cdf0e10cSrcweir     SFX_APP()->SetViewFrame_Impl( pFrame );
3551*cdf0e10cSrcweir }
3552*cdf0e10cSrcweir 
3553*cdf0e10cSrcweir // ---------------------------------------------------------------------------------------------------------------------
3554*cdf0e10cSrcweir void SfxViewFrame::ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL )
3555*cdf0e10cSrcweir {
3556*cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
3557*cdf0e10cSrcweir 
3558*cdf0e10cSrcweir     // look up the SfxFrame for the given XFrame
3559*cdf0e10cSrcweir     SfxFrame* pFrame = NULL;
3560*cdf0e10cSrcweir     for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
3561*cdf0e10cSrcweir     {
3562*cdf0e10cSrcweir         if ( pFrame->GetFrameInterface() == i_rFrame )
3563*cdf0e10cSrcweir             break;
3564*cdf0e10cSrcweir     }
3565*cdf0e10cSrcweir     SfxViewFrame* pViewFrame = pFrame ? pFrame->GetCurrentViewFrame() : NULL;
3566*cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( pViewFrame != NULL, "SfxViewFrame::ActivateToolPanel: did not find an SfxFrame for the given XFrame!" );
3567*cdf0e10cSrcweir 
3568*cdf0e10cSrcweir     pViewFrame->ActivateToolPanel_Impl( i_rPanelURL );
3569*cdf0e10cSrcweir }
3570*cdf0e10cSrcweir 
3571*cdf0e10cSrcweir // ---------------------------------------------------------------------------------------------------------------------
3572*cdf0e10cSrcweir void SfxViewFrame::ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL )
3573*cdf0e10cSrcweir {
3574*cdf0e10cSrcweir     // ensure the task pane is visible
3575*cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( KnowsChildWindow( SID_TASKPANE ), "SfxViewFrame::ActivateToolPanel: this frame/module does not allow for a task pane!" );
3576*cdf0e10cSrcweir     if ( !HasChildWindow( SID_TASKPANE ) )
3577*cdf0e10cSrcweir         ToggleChildWindow( SID_TASKPANE );
3578*cdf0e10cSrcweir 
3579*cdf0e10cSrcweir     SfxChildWindow* pTaskPaneChildWindow = GetChildWindow( SID_TASKPANE );
3580*cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( pTaskPaneChildWindow, "SfxViewFrame::ActivateToolPanel_Impl: just switched it on, but it is not there!" );
3581*cdf0e10cSrcweir 
3582*cdf0e10cSrcweir     ::sfx2::ITaskPaneToolPanelAccess* pPanelAccess = dynamic_cast< ::sfx2::ITaskPaneToolPanelAccess* >( pTaskPaneChildWindow );
3583*cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( pPanelAccess, "SfxViewFrame::ActivateToolPanel_Impl: task pane child window does not implement a required interface!" );
3584*cdf0e10cSrcweir     pPanelAccess->ActivateToolPanel( i_rPanelURL );
3585*cdf0e10cSrcweir }
3586