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