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