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