LibreOffice Module sfx2 (master) 1
viewfrm.cxx
Go to the documentation of this file.
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#include <config_feature_desktop.h>
21#include <config_wasm_strip.h>
22
23#include <osl/file.hxx>
24#include <sfx2/docfilt.hxx>
25#include <sfx2/infobar.hxx>
26#include <sfx2/sfxsids.hrc>
27#include <sfx2/viewfrm.hxx>
30#include <com/sun/star/document/MacroExecMode.hpp>
31#include <com/sun/star/frame/Desktop.hpp>
32#include <com/sun/star/frame/DispatchRecorder.hpp>
33#include <com/sun/star/frame/DispatchRecorderSupplier.hpp>
34#include <com/sun/star/frame/XLoadable.hpp>
35#include <com/sun/star/frame/XLayoutManager.hpp>
36#include <com/sun/star/frame/XComponentLoader.hpp>
37#include <com/sun/star/task/PasswordContainer.hpp>
38#include <officecfg/Office/Common.hxx>
39#include <officecfg/Setup.hxx>
41#include <vcl/wrkwin.hxx>
43#include <svl/intitem.hxx>
44#include <svl/visitem.hxx>
45#include <svl/stritem.hxx>
46#include <svl/eitem.hxx>
47#include <svl/whiter.hxx>
48#include <svl/undo.hxx>
49#include <vcl/help.hxx>
50#include <vcl/stdtext.hxx>
51#include <vcl/weld.hxx>
52#include <vcl/weldutils.hxx>
53#if !ENABLE_WASM_STRIP_PINGUSER
55#endif
57#include <svtools/miscopt.hxx>
59#include <com/sun/star/container/XIndexAccess.hpp>
60#include <com/sun/star/frame/XFramesSupplier.hpp>
61#include <com/sun/star/frame/FrameSearchFlag.hpp>
62#include <com/sun/star/frame/XFrame.hpp>
63#include <com/sun/star/awt/XWindow.hpp>
64#include <com/sun/star/frame/XController.hpp>
65#include <com/sun/star/util/URLTransformer.hpp>
66#include <com/sun/star/util/XURLTransformer.hpp>
67#include <com/sun/star/util/XCloseable.hpp>
68#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
69#include <com/sun/star/document/UpdateDocMode.hpp>
70#include <com/sun/star/beans/XPropertySet.hpp>
71#include <com/sun/star/uri/UriReferenceFactory.hpp>
72#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
73#include <com/sun/star/document/XViewDataSupplier.hpp>
74#include <com/sun/star/container/XIndexContainer.hpp>
75#include <com/sun/star/task/InteractionHandler.hpp>
76#include <com/sun/star/drawing/XDrawView.hpp>
77#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
78#include <rtl/ustrbuf.hxx>
79#include <sal/log.hxx>
80
82#include <comphelper/lok.hxx>
87
88#include <com/sun/star/uno/Reference.h>
89
90#include <basic/basmgr.hxx>
91#include <basic/sbmod.hxx>
92#include <basic/sbmeth.hxx>
93#include <svtools/strings.hrc>
94#include <svtools/svtresid.hxx>
96
97#include <optional>
98
100
102
103
104using namespace ::com::sun::star;
105using namespace ::com::sun::star::uno;
106using namespace ::com::sun::star::ucb;
107using namespace ::com::sun::star::frame;
108using namespace ::com::sun::star::lang;
109using ::com::sun::star::awt::XWindow;
110using ::com::sun::star::beans::PropertyValue;
111using ::com::sun::star::document::XViewDataSupplier;
112using ::com::sun::star::container::XIndexContainer;
113
114// Due to ViewFrame::Current
115#include <appdata.hxx>
116#include <sfx2/app.hxx>
117#include <sfx2/objface.hxx>
118#include <openflag.hxx>
119#include <objshimp.hxx>
120#include <sfx2/viewsh.hxx>
121#include <sfx2/objsh.hxx>
122#include <sfx2/bindings.hxx>
123#include <sfx2/dispatch.hxx>
124#include <sfx2/request.hxx>
125#include <sfx2/docfac.hxx>
126#include <sfx2/ipclient.hxx>
127#include <sfx2/sfxresid.hxx>
128#include <sfx2/viewfac.hxx>
129#include <sfx2/event.hxx>
130#include <sfx2/fcontnr.hxx>
131#include <sfx2/docfile.hxx>
132#include <sfx2/module.hxx>
133#include <sfx2/sfxuno.hxx>
134#include <sfx2/progress.hxx>
136#include <workwin.hxx>
137#include <sfx2/minfitem.hxx>
138#include <sfx2/strings.hrc>
139#include "impviewframe.hxx"
141#include <vcl/svapp.hxx>
142
143#define ShellClass_SfxViewFrame
144#include <sfxslots.hxx>
145
146constexpr OUStringLiteral CHANGES_STR = u"private:resource/toolbar/changes";
147
149
150void SfxViewFrame::InitInterface_Impl()
151{
152 GetStaticInterface()->RegisterChildWindow(SID_BROWSER);
153 GetStaticInterface()->RegisterChildWindow(SID_RECORDING_FLOATWINDOW);
154#if HAVE_FEATURE_DESKTOP
156 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard, ToolbarId::EnvToolbox);
157#endif
158}
159
160namespace {
162class SfxEditDocumentDialog : public weld::MessageDialogController
163{
164public:
165 SfxEditDocumentDialog(weld::Widget* pParent);
166};
167
168SfxEditDocumentDialog::SfxEditDocumentDialog(weld::Widget* pParent)
169 : MessageDialogController(pParent, "sfx/ui/editdocumentdialog.ui",
170 "EditDocumentDialog")
171{
172}
173
174class SfxQueryOpenAsTemplate
175{
176private:
177 std::unique_ptr<weld::MessageDialog> m_xQueryBox;
178public:
179 SfxQueryOpenAsTemplate(weld::Window* pParent, bool bAllowIgnoreLock, LockFileEntry& rLockData)
180 : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Question,
181 VclButtonsType::NONE, ""))
182 {
183 m_xQueryBox->add_button(SfxResId(STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN), RET_YES);
184 bAllowIgnoreLock
185 = bAllowIgnoreLock && officecfg::Office::Common::Misc::AllowOverrideLocking::get();
186 if (bAllowIgnoreLock)
187 m_xQueryBox->add_button(SfxResId(STR_QUERY_OPENASTEMPLATE_OPEN_BTN), RET_IGNORE);
188 m_xQueryBox->add_button(GetStandardText( StandardButtonType::Cancel ), RET_CANCEL);
189 m_xQueryBox->set_primary_text(QueryString(bAllowIgnoreLock, rLockData));
190 m_xQueryBox->set_default_response(RET_YES);
191 }
192 short run() { return m_xQueryBox->run(); }
193
194private:
195 static OUString QueryString(bool bAllowIgnoreLock, LockFileEntry& rLockData)
196 {
197 OUString sLockUserData;
198 if (!rLockData[LockFileComponent::OOOUSERNAME].isEmpty())
199 sLockUserData = rLockData[LockFileComponent::OOOUSERNAME];
200 else
201 sLockUserData = rLockData[LockFileComponent::SYSUSERNAME];
202
203 if (!sLockUserData.isEmpty() && !rLockData[LockFileComponent::EDITTIME].isEmpty())
204 sLockUserData += " ( " + rLockData[LockFileComponent::EDITTIME] + " )";
205
206 if (!sLockUserData.isEmpty())
207 sLockUserData = "\n\n" + sLockUserData + "\n";
208
209 const bool bUseLockStr = bAllowIgnoreLock || !sLockUserData.isEmpty();
210
211 OUString sMsg(
212 SfxResId(bUseLockStr ? STR_QUERY_OPENASTEMPLATE_LOCKED : STR_QUERY_OPENASTEMPLATE));
213
214 if (bAllowIgnoreLock)
215 sMsg += "\n\n" + SfxResId(STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE);
216
217 return sMsg.replaceFirst("%LOCKINFO", sLockUserData);
218 }
219};
220
221bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const OUString& aPath, const std::shared_ptr<const SfxFilter>& pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue >& aInfo )
222{
223 // TODO/LATER: In future the info should replace the direct hash completely
224 bool bResult = ( !nPasswordHash && !aInfo.hasElements() );
225
226 SAL_WARN_IF( !(pFilter && ( pFilter->GetFilterFlags() & SfxFilterFlags::PASSWORDTOMODIFY )), "sfx.view",
227 "PasswordToModify feature is active for a filter that does not support it!");
228
229 if ( pFilter && xHandler.is() )
230 {
231 bool bCancel = false;
232 bool bFirstTime = true;
233
234 while ( !bResult && !bCancel )
235 {
236 bool bMSType = !pFilter->IsOwnFormat();
237
239 new ::comphelper::DocPasswordRequest(
240 bMSType ? ::comphelper::DocPasswordRequestType::MS : ::comphelper::DocPasswordRequestType::Standard,
241 bFirstTime ? css::task::PasswordRequestMode_PASSWORD_ENTER : css::task::PasswordRequestMode_PASSWORD_REENTER,
242 aPath,
243 true ) );
244
245 xHandler->handle( pPasswordRequest );
246
247 if ( pPasswordRequest->isPassword() )
248 {
249 if ( aInfo.hasElements() )
250 {
251 bResult = ::comphelper::DocPasswordHelper::IsModifyPasswordCorrect( pPasswordRequest->getPasswordToModify(), aInfo );
252 }
253 else
254 {
255 // the binary format
256 bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), pFilter->GetServiceName()=="com.sun.star.text.TextDocument" ) == nPasswordHash );
257 }
258 }
259 else
260 bCancel = true;
261
262 bFirstTime = false;
263 }
264 }
265
266 return bResult;
267}
268
269bool physObjIsOlder(INetURLObject const & aMedObj, INetURLObject const & aPhysObj) {
270 return ::utl::UCBContentHelper::IsYounger(aMedObj.GetMainURL( INetURLObject::DecodeMechanism::NONE),
272}
273}
274
276{
278 switch ( rReq.GetSlot() )
279 {
280 case SID_EDITDOC:
281 case SID_READONLYDOC:
282 {
283 // Due to Double occupancy in toolboxes (with or without Ctrl),
284 // it is also possible that the slot is enabled, but Ctrl-click
285 // despite this is not!
286 if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ))
287 break;
288
289 if (pSh->isEditDocLocked())
290 break;
291
292 // Only change read-only UI and remove info bar when we succeed
293 struct ReadOnlyUIGuard
294 {
295 SfxViewFrame* m_pFrame;
296 SfxObjectShell* m_pSh;
297 SfxMedium* m_pMed = nullptr;
298 bool m_bSetRO;
299 ReadOnlyUIGuard(SfxViewFrame* pFrame, SfxObjectShell* p_Sh)
300 : m_pFrame(pFrame), m_pSh(p_Sh), m_bSetRO(p_Sh->IsReadOnlyUI())
301 {}
302 ~ReadOnlyUIGuard() COVERITY_NOEXCEPT_FALSE
303 {
304 if (m_bSetRO != m_pSh->IsReadOnlyUI())
305 {
306 m_pSh->SetReadOnlyUI(m_bSetRO);
307 if (!m_bSetRO)
308 m_pFrame->RemoveInfoBar(u"readonly");
309 if (m_pMed)
310 {
311 bool const isEnableSetModified(m_pSh->IsEnableSetModified());
312 m_pSh->EnableSetModified(false);
313 // tdf#116066: DoSaveCompleted should be called after SetReadOnlyUI
314 m_pSh->DoSaveCompleted(m_pMed);
315 m_pSh->Broadcast(SfxHint(SfxHintId::ModeChanged));
316 m_pSh->EnableSetModified(isEnableSetModified);
317 }
318 }
319 }
320 } aReadOnlyUIGuard(this, pSh);
321
322 SfxMedium* pMed = pSh->GetMedium();
323
324 std::shared_ptr<std::recursive_mutex> pChkEditMutex = pMed->GetCheckEditableMutex();
325 std::unique_lock<std::recursive_mutex> chkEditLock;
326 if (pChkEditMutex != nullptr)
327 chkEditLock = std::unique_lock<std::recursive_mutex>(*pChkEditMutex);
329
330 const SfxBoolItem* pItem = pMed->GetItemSet().GetItem(SID_VIEWONLY, false);
331 if ( pItem && pItem->GetValue() )
332 {
333 SfxApplication* pApp = SfxGetpApp();
334 SfxAllItemSet aSet( pApp->GetPool() );
336 aSet.Put( SfxBoolItem( SID_TEMPLATE, true ) );
337 aSet.Put( SfxStringItem( SID_TARGETNAME, "_blank" ) );
338 const SfxStringItem* pReferer = pMed->GetItemSet().GetItem(SID_REFERER, false);
339 if ( pReferer )
340 aSet.Put( *pReferer );
341 const SfxInt16Item* pVersionItem = pMed->GetItemSet().GetItem(SID_VERSION, false);
342 if ( pVersionItem )
343 aSet.Put( *pVersionItem );
344
345 if( pMed->GetFilter() )
346 {
347 aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
348 const SfxStringItem* pOptions = pMed->GetItemSet().GetItem(SID_FILE_FILTEROPTIONS, false);
349 if ( pOptions )
350 aSet.Put( *pOptions );
351 }
352
353 GetDispatcher()->Execute( SID_OPENDOC, SfxCallMode::ASYNCHRON, aSet );
354 return;
355 }
356
357 StreamMode nOpenMode;
358 bool bNeedsReload = false;
359 bool bPasswordEntered = false;
360 if ( !pSh->IsReadOnly() )
361 {
362 // Save and reload Readonly
363 if( pSh->IsModified() )
364 {
365 if ( pSh->PrepareClose() )
366 {
367 // the storing could let the medium be changed
368 pMed = pSh->GetMedium();
369 bNeedsReload = true;
370 }
371 else
372 {
373 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), false ) );
374 return;
375 }
376 }
377 nOpenMode = SFX_STREAM_READONLY;
378 aReadOnlyUIGuard.m_bSetRO = true;
379 }
380 else
381 {
382 if ( pSh->IsReadOnlyMedium()
383 && ( pSh->GetModifyPasswordHash() || pSh->GetModifyPasswordInfo().hasElements() )
384 && !pSh->IsModifyPasswordEntered() )
385 {
386 const OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
387 if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetFilter(), pSh->GetModifyPasswordHash(), pSh->GetModifyPasswordInfo() ) )
388 {
389 // this is a read-only document, if it has "Password to modify"
390 // the user should enter password before he can edit the document
391 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), false ) );
392 return;
393 }
394
396 bPasswordEntered = true;
397 }
398
400 aReadOnlyUIGuard.m_bSetRO = false;
401
402 // if only the view was in the readonly mode then there is no need to do the reload
403 if ( !pSh->IsReadOnlyMedium() )
404 {
405 // SetReadOnlyUI causes recomputation of window title, using
406 // open mode among other things, so call SetOpenMode before
407 // SetReadOnlyUI:
408 pMed->SetOpenMode( nOpenMode );
409 return;
410 }
411 }
412
413 if ( rReq.IsAPI() )
414 {
415 // Control through API if r/w or r/o
416 const SfxBoolItem* pEditItem = rReq.GetArg<SfxBoolItem>(SID_EDITDOC);
417 if ( pEditItem )
418 nOpenMode = pEditItem->GetValue() ? SFX_STREAM_READWRITE : SFX_STREAM_READONLY;
419 }
420
421 // doing
422
423 OUString sTemp;
424 osl::FileBase::getFileURLFromSystemPath( pMed->GetPhysicalName(), sTemp );
425 INetURLObject aPhysObj( sTemp );
426 const SfxInt16Item* pVersionItem = pMed->GetItemSet().GetItem(SID_VERSION, false);
427
428 INetURLObject aMedObj( pMed->GetName() );
429
430 // -> tdf#82744
431 // the logic below is following:
432 // if the document seems not to need to be reloaded
433 // and the physical name is different to the logical one,
434 // then on file system it can be checked that the copy is still newer than the original and no document reload is required.
435 // Did some semplification to enhance readability of the 'if' expression
436 //
437 // when the 'http/https' protocol is active, the bool bPhysObjIsYounger relies upon the getlastmodified Property of a WebDAV resource.
438 // Said property should be implemented, but sometimes it's not.
439 // implemented. On this case the reload activated here will not work properly.
440 // TODO: change the check age method for WebDAV to etag (entity-tag) property value, need some rethinking, since the
441 // etag tells that the cache representation (e.g. in LO) is different from the one on the server,
442 // but tells nothing about the age
443 // Details at this link: http://tools.ietf.org/html/rfc4918#section-15, section 15.7
444 bool bIsWebDAV = aMedObj.isAnyKnownWebDAVScheme();
445
446 // tdf#118938 Reload the document when the user enters the editing password,
447 // even if the physical name isn't different to the logical name.
448 if ( ( !bNeedsReload && ( ( aMedObj.GetProtocol() == INetProtocol::File &&
449 ( aMedObj.getFSysPath( FSysStyle::Detect ) != aPhysObj.getFSysPath( FSysStyle::Detect )
450 || bPasswordEntered ) &&
451 !physObjIsOlder(aMedObj, aPhysObj))
452 || (bIsWebDAV && !physObjIsOlder(aMedObj, aPhysObj))
453 || ( pMed->IsRemote() && !bIsWebDAV ) ) )
454 || pVersionItem )
455 // <- tdf#82744
456 {
457 bool bOK = false;
458 bool bRetryIgnoringLock = false;
459 bool bOpenTemplate = false;
460 std::optional<bool> aOrigROVal;
461 if (!pVersionItem)
462 {
463 auto pRO = pMed->GetItemSet().GetItem<SfxBoolItem>(SID_DOC_READONLY, false);
464 if (pRO)
465 aOrigROVal = pRO->GetValue();
466 }
467 do {
468 LockFileEntry aLockData;
469 if ( !pVersionItem )
470 {
471 if (bRetryIgnoringLock)
472 pMed->ResetError();
473
474 bool bHasStorage = pMed->HasStorage_Impl();
475 // switching edit mode could be possible without reload
476 if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() )
477 {
478 // TODO/LATER: faster creation of copy
479 if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) )
480 return;
481 }
482
483 pMed->CloseAndRelease();
484 pMed->SetOpenMode( nOpenMode );
485 // We need to clear the SID_DOC_READONLY item from the set, to allow
486 // MediaDescriptor::impl_openStreamWithURL (called indirectly by
487 // SfxMedium::CompleteReOpen) to properly fill input stream of the
488 // descriptor, even when the file can't be open in read-write mode.
489 // Only then can following call to SfxMedium::LockOrigFileOnDemand
490 // return proper information about who has locked the file, to show
491 // in the SfxQueryOpenAsTemplate box below; otherwise it exits right
492 // after call to SfxMedium::GetMedium_Impl. This mimics what happens
493 // when the file is opened initially, when filter detection code also
494 // calls MediaDescriptor::impl_openStreamWithURL without the item set.
495 pMed->GetItemSet().ClearItem(SID_DOC_READONLY);
496 pMed->CompleteReOpen();
497 pMed->GetItemSet().Put(
498 SfxBoolItem(SID_DOC_READONLY, !(nOpenMode & StreamMode::WRITE)));
499 if ( nOpenMode & StreamMode::WRITE )
500 {
501 auto eResult = pMed->LockOrigFileOnDemand(
502 true, true, bRetryIgnoringLock, &aLockData);
503 bRetryIgnoringLock
505 }
506
507 // LockOrigFileOnDemand might set the readonly flag itself, it should be set back
508 pMed->GetItemSet().Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & StreamMode::WRITE ) ) );
509
510 if ( !pMed->GetErrorCode() )
511 bOK = true;
512 }
513
514 if( !bOK )
515 {
516 if (nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI())
517 {
518 // css::sdbcx::User offering to open it as a template
519 SfxQueryOpenAsTemplate aBox(GetWindow().GetFrameWeld(),
520 bRetryIgnoringLock, aLockData);
521
522 short nUserAnswer = aBox.run();
523 bOpenTemplate = RET_YES == nUserAnswer;
524 // Always reset this here to avoid infinite loop
525 bRetryIgnoringLock = RET_IGNORE == nUserAnswer;
526 if (RET_CANCEL == nUserAnswer)
528 }
529 else
530 bRetryIgnoringLock = false;
531 }
532 }
533 while ( !bOK && bRetryIgnoringLock );
534
535 if( !bOK )
536 {
537 ErrCode nErr = pMed->GetErrorCode();
538 if ( pVersionItem )
540 else
541 {
542 pMed->ResetError();
544 if (aOrigROVal)
545 pMed->GetItemSet().Put(SfxBoolItem(SID_DOC_READONLY, *aOrigROVal));
546 else
547 pMed->GetItemSet().ClearItem(SID_DOC_READONLY);
548 pMed->ReOpen();
549 pSh->DoSaveCompleted( pMed );
550 }
551
552 // Readonly document can not be switched to edit mode?
553 rReq.Done();
554
555 if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() )
556 {
557 if ( bOpenTemplate )
558 {
559 SfxApplication* pApp = SfxGetpApp();
560 SfxAllItemSet aSet( pApp->GetPool() );
561 aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
562 const SfxStringItem* pReferer = pMed->GetItemSet().GetItem(SID_REFERER, false);
563 if ( pReferer )
564 aSet.Put( *pReferer );
565 aSet.Put( SfxBoolItem( SID_TEMPLATE, true ) );
566 if ( pVersionItem )
567 aSet.Put( *pVersionItem );
568
569 if( pMed->GetFilter() )
570 {
571 aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
572 const SfxStringItem* pOptions = pMed->GetItemSet().GetItem(SID_FILE_FILTEROPTIONS, false);
573 if ( pOptions )
574 aSet.Put( *pOptions );
575 }
576
577 GetDispatcher()->Execute( SID_OPENDOC, SfxCallMode::ASYNCHRON, aSet );
578 return;
579 }
580
581 nErr = ERRCODE_NONE;
582 }
583
584 // Keep the read-only UI
585 aReadOnlyUIGuard.m_bSetRO = true;
586
588 rReq.SetReturnValue(
589 SfxBoolItem( rReq.GetSlot(), false ) );
590 return;
591 }
592 else
593 {
594 aReadOnlyUIGuard.m_pMed = pMed;
595 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), true ) );
596 rReq.Done( true );
597 return;
598 }
599 }
600
601 rReq.AppendItem( SfxBoolItem(SID_FORCERELOAD,
602 (rReq.GetSlot() == SID_EDITDOC
603 // tdf#151715 exclude files loaded from /tmp to avoid Notebookbar bugs
605 || bNeedsReload) );
606 rReq.AppendItem( SfxBoolItem( SID_SILENT, true ));
607
608 [[fallthrough]]; //TODO ???
609 }
610
611 case SID_RELOAD:
612 {
613 // Due to Double occupancy in toolboxes (with or without Ctrl),
614 // it is also possible that the slot is enabled, but Ctrl-click
615 // despite this is not!
616 if ( !pSh || !pSh->CanReload_Impl() )
617 break;
618 SfxApplication* pApp = SfxGetpApp();
619 const SfxBoolItem* pForceReloadItem = rReq.GetArg<SfxBoolItem>(SID_FORCERELOAD);
620 if( pForceReloadItem && !pForceReloadItem->GetValue() &&
621 !pSh->GetMedium()->IsExpired() )
622 return;
623 if( m_pImpl->bReloading || pSh->IsInModalMode() )
624 return;
625
626 // AutoLoad is prohibited if possible
627 const SfxBoolItem* pAutoLoadItem = rReq.GetArg<SfxBoolItem>(SID_AUTOLOAD);
628 if ( pAutoLoadItem && pAutoLoadItem->GetValue() &&
630 return;
631
632 SfxObjectShellLock xOldObj( pSh );
633 m_pImpl->bReloading = true;
634 const SfxStringItem* pURLItem = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
635 // Open as editable?
636 bool bForEdit = !pSh->IsReadOnly();
637
638 // If possible ask the User
639 bool bDo = GetViewShell()->PrepareClose();
640 const SfxBoolItem* pSilentItem = rReq.GetArg<SfxBoolItem>(SID_SILENT);
641 if (getenv("SAL_NO_QUERYSAVE"))
642 bDo = true;
643 else if (bDo && GetFrame().DocIsModified_Impl() && !rReq.IsAPI()
644 && (!pSilentItem || !pSilentItem->GetValue()))
645 {
646 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
647 GetWindow().GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
648 SfxResId(STR_QUERY_LASTVERSION)));
649 bDo = RET_YES == xBox->run();
650 }
651
652 if ( bDo )
653 {
654 SfxMedium *pMedium = xOldObj->GetMedium();
655 std::shared_ptr<std::recursive_mutex> pChkEditMutex
656 = pMedium->GetCheckEditableMutex();
657 std::unique_lock<std::recursive_mutex> chkEditLock;
658 if (pChkEditMutex != nullptr)
659 chkEditLock = std::unique_lock<std::recursive_mutex>(*pChkEditMutex);
660 pMedium->CancelCheckEditableEntry();
661
662 bool bHandsOff =
663 ( pMedium->GetURLObject().GetProtocol() == INetProtocol::File && !xOldObj->IsDocShared() );
664
665 // Empty existing SfxMDIFrames for this Document
666 // in native format or R/O, open it now for editing?
667 SfxObjectShellLock xNewObj;
668
669 // collect the views of the document
670 // TODO: when UNO ViewFactories are available for SFX-based documents, the below code should
671 // be UNOized, too
672 typedef ::std::pair< Reference< XFrame >, SfxInterfaceId > ViewDescriptor;
673 ::std::vector< ViewDescriptor > aViewFrames;
674 SfxViewFrame *pView = GetFirst( xOldObj );
675 while ( pView )
676 {
677 Reference< XFrame > xFrame( pView->GetFrame().GetFrameInterface() );
678 SAL_WARN_IF( !xFrame.is(), "sfx.view", "SfxViewFrame::ExecReload_Impl: no XFrame?!");
679 aViewFrames.emplace_back( xFrame, pView->GetCurViewId() );
680
681 pView = GetNext( *pView, xOldObj );
682 }
683
684 xOldObj->Get_Impl()->pReloadTimer.reset();
685
686 std::optional<SfxAllItemSet> pNewSet;
687 std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
688 if( pURLItem )
689 {
690 pNewSet.emplace( pApp->GetPool() );
691 pNewSet->Put( *pURLItem );
692
693 // Filter Detection
694 OUString referer;
695 const SfxStringItem* refererItem = rReq.GetArg<SfxStringItem>(SID_REFERER);
696 if (refererItem != nullptr) {
697 referer = refererItem->GetValue();
698 }
699 SfxMedium aMedium( pURLItem->GetValue(), referer, SFX_STREAM_READWRITE );
700 SfxFilterMatcher().GuessFilter( aMedium, pFilter );
701 if ( pFilter )
702 pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
703 pNewSet->Put( aMedium.GetItemSet() );
704 }
705 else
706 {
707 pNewSet.emplace( pMedium->GetItemSet() );
708 pNewSet->ClearItem( SID_VIEW_ID );
709 pNewSet->ClearItem( SID_STREAM );
710 pNewSet->ClearItem( SID_INPUTSTREAM );
711 pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pMedium->GetFilter()->GetName() ) );
712
713 // let the current security settings be checked again
714 pNewSet->Put( SfxUInt16Item( SID_MACROEXECMODE, document::MacroExecMode::USE_CONFIG ) );
715
718 // edit mode is switched or reload of readonly document
719 pNewSet->Put( SfxBoolItem( SID_DOC_READONLY, true ) );
720 else
721 // Reload of file opened for writing
722 pNewSet->ClearItem( SID_DOC_READONLY );
723 }
724
725 // If a salvaged file is present, do not enclose the OrigURL
726 // again, since the Template is invalid after reload.
727 const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(&*pNewSet, SID_DOC_SALVAGE, false);
728 if( pSalvageItem )
729 {
730 pNewSet->ClearItem( SID_DOC_SALVAGE );
731 }
732
733#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
734 // TODO/LATER: Temporary solution, the SfxMedium must know the original URL as aLogicName
735 // SfxMedium::Transfer_Impl() will be forbidden then.
736 if ( xOldObj->IsDocShared() )
737 pNewSet->Put( SfxStringItem( SID_FILE_NAME, xOldObj->GetSharedFileURL() ) );
738#endif
739 if ( pURLItem )
740 pNewSet->Put( SfxStringItem( SID_REFERER, pMedium->GetName() ) );
741 else
742 pNewSet->Put( SfxStringItem( SID_REFERER, OUString() ) );
743
744 xOldObj->CancelTransfers();
745
746
747 if ( pSilentItem && pSilentItem->GetValue() )
748 pNewSet->Put( SfxBoolItem( SID_SILENT, true ) );
749
750 const SfxUnoAnyItem* pInteractionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(&*pNewSet, SID_INTERACTIONHANDLER, false);
751 const SfxUInt16Item* pMacroExecItem = SfxItemSet::GetItem<SfxUInt16Item>(&*pNewSet, SID_MACROEXECMODE, false);
752 const SfxUInt16Item* pDocTemplateItem = SfxItemSet::GetItem<SfxUInt16Item>(&*pNewSet, SID_UPDATEDOCMODE, false);
753
754 if (!pInteractionItem)
755 {
756 Reference < task::XInteractionHandler2 > xHdl = task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr );
757 if (xHdl.is())
758 pNewSet->Put( SfxUnoAnyItem(SID_INTERACTIONHANDLER,css::uno::Any(xHdl)) );
759 }
760
761 if (!pMacroExecItem)
762 pNewSet->Put( SfxUInt16Item(SID_MACROEXECMODE,css::document::MacroExecMode::USE_CONFIG) );
763 if (!pDocTemplateItem)
764 pNewSet->Put( SfxUInt16Item(SID_UPDATEDOCMODE,css::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
765
766 xOldObj->SetModified( false );
767 // Do not cache the old Document! Is invalid when loading
768 // another document.
769
770 bool bHasStorage = pMedium->HasStorage_Impl();
771 if( bHandsOff )
772 {
773 if ( bHasStorage && pMedium->GetStorage() == xOldObj->GetStorage() )
774 {
775 // TODO/LATER: faster creation of copy
776 if ( !xOldObj->ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) )
777 return;
778 }
779
780 pMedium->CloseAndRelease();
781 }
782
783 xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName() );
784
785 if ( xOldObj->IsModifyPasswordEntered() )
786 xNewObj->SetModifyPasswordEntered();
787
788 uno::Sequence < beans::PropertyValue > aLoadArgs;
789 TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs );
790 try
791 {
792 uno::Reference < frame::XLoadable > xLoad( xNewObj->GetModel(), uno::UNO_QUERY );
793 xLoad->load( aLoadArgs );
794 }
795 catch ( uno::Exception& )
796 {
797 xNewObj->DoClose();
798 xNewObj = nullptr;
800 }
801
802 pNewSet.reset();
803
804 if( !xNewObj.Is() )
805 {
806 if( bHandsOff )
807 {
808 // back to old medium
809 pMedium->ReOpen();
810 pMedium->LockOrigFileOnDemand( false, true );
811
812 xOldObj->DoSaveCompleted( pMedium );
813 }
814 }
815 else
816 {
817 if ( xNewObj->GetModifyPasswordHash() && xNewObj->GetModifyPasswordHash() != xOldObj->GetModifyPasswordHash() )
818 {
819 xNewObj->SetModifyPasswordEntered( false );
820 xNewObj->SetReadOnly();
821 }
822 else if ( rReq.GetSlot() == SID_EDITDOC || rReq.GetSlot() == SID_READONLYDOC )
823 {
824 xNewObj->SetReadOnlyUI( !bForEdit );
825 }
826
827#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
828 if ( xNewObj->IsDocShared() )
829 {
830 // the file is shared but the closing can change the sharing control file
832 }
833#endif
834 // the Reload and Silent items were only temporary, remove them
835 xNewObj->GetMedium()->GetItemSet().ClearItem( SID_RELOAD );
836 xNewObj->GetMedium()->GetItemSet().ClearItem( SID_SILENT );
837 TransformItems( SID_OPENDOC, xNewObj->GetMedium()->GetItemSet(), aLoadArgs );
838
840
841 auto sModule = vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame().GetFrameInterface());
842 OUString sReloadNotebookBar;
843 if (sModule == "com.sun.star.text.TextDocument")
844 sReloadNotebookBar = u"modules/swriter/ui/";
845 else if (sModule == "com.sun.star.sheet.SpreadsheetDocument")
846 sReloadNotebookBar = u"modules/scalc/ui/";
848 && sModule != "presentation.PresentationDocument"
849 && sModule != "com.sun.star.drawing.DrawingDocument")
850 {
851 assert(false && "SID_RELOAD Notebookbar active, but not refreshed here");
852 }
853
854 try
855 {
856 for (auto const& viewFrame : aViewFrames)
857 {
858 LoadViewIntoFrame_Impl( *xNewObj, viewFrame.first, aLoadArgs, viewFrame.second, false );
859 }
860 aViewFrames.clear();
861 }
862 catch( const Exception& )
863 {
864 // close the remaining frames
865 // Don't catch exceptions herein, if this fails, then we're left in an indetermined state, and
866 // crashing is better than trying to proceed
867 for (auto const& viewFrame : aViewFrames)
868 {
869 Reference< util::XCloseable > xClose( viewFrame.first, UNO_QUERY_THROW );
870 xClose->close( true );
871 }
872 aViewFrames.clear();
873 }
874
875 const SfxInt32Item* pPageNumber = rReq.GetArg<SfxInt32Item>(SID_PAGE_NUMBER);
876 if (pPageNumber && pPageNumber->GetValue() >= 0)
877 {
878 // Restore current page after reload.
879 uno::Reference<drawing::XDrawView> xController(
880 xNewObj->GetModel()->getCurrentController(), uno::UNO_QUERY);
881 uno::Reference<drawing::XDrawPagesSupplier> xSupplier(xNewObj->GetModel(),
882 uno::UNO_QUERY);
883 uno::Reference<drawing::XDrawPages> xDrawPages = xSupplier->getDrawPages();
884 uno::Reference<drawing::XDrawPage> xDrawPage(
885 xDrawPages->getByIndex(pPageNumber->GetValue()), uno::UNO_QUERY);
886 xController->setCurrentPage(xDrawPage);
887 }
888
889 // Propagate document closure.
891
892 // tdf#126006 Calc needs to reload the notebookbar after closing the document
893 if (!sReloadNotebookBar.isEmpty())
894 sfx2::SfxNotebookBar::ReloadNotebookBar(sReloadNotebookBar);
895 }
896
897 // Record as done
898 rReq.Done( true );
899 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), true));
900 return;
901 }
902 else
903 {
904 // Record as not done
905 rReq.Done();
906 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), false));
907 m_pImpl->bReloading = false;
908 return;
909 }
910 }
911 }
912}
913
915{
917 if ( !pSh )
918 {
919 // I'm just on reload and am yielding myself ...
920 return;
921 }
922
923 SfxWhichIter aIter( rSet );
924 for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
925 {
926 switch ( nWhich )
927 {
928 case SID_EDITDOC:
929 case SID_READONLYDOC:
930 {
931 const SfxViewShell *pVSh;
932 const SfxShell *pFSh;
933 if ( !pSh->HasName() ||
935 (pSh->isEditDocLocked()) ||
937 ( !(pVSh = pSh->GetViewShell()) ||
938 !(pFSh = pVSh->GetFormShell()) ||
939 !pFSh->IsDesignMode())))
940 rSet.DisableItem( nWhich );
941 else
942 {
943 const SfxBoolItem* pItem = pSh->GetMedium()->GetItemSet().GetItem(SID_EDITDOC, false);
944 if ( pItem && !pItem->GetValue() )
945 rSet.DisableItem( nWhich );
946 else
947 {
948 if (nWhich==SID_EDITDOC)
949 rSet.Put( SfxBoolItem( nWhich, !pSh->IsReadOnly() ) );
950 else if (nWhich==SID_READONLYDOC)
951 rSet.Put( SfxBoolItem( nWhich, pSh->IsReadOnly() ) );
952 }
953 }
954 break;
955 }
956
957 case SID_RELOAD:
958 {
960 rSet.DisableItem(nWhich);
961 else
962 {
963 // If any ChildFrame is reloadable, the slot is enabled,
964 // so you can perform CTRL-Reload
965 rSet.Put( SfxBoolItem( nWhich, false));
966 }
967
968 break;
969 }
970 }
971 }
972}
973
975{
976 // Is there an Undo-Manager on the top Shell?
977 SfxShell *pSh = GetDispatcher()->GetShell(0);
978 if (!pSh)
979 return;
980
981 SfxUndoManager* pShUndoMgr = pSh->GetUndoManager();
982 bool bOK = false;
983 if ( pShUndoMgr )
984 {
985 switch ( rReq.GetSlot() )
986 {
987 case SID_CLEARHISTORY:
988 pShUndoMgr->Clear();
989 bOK = true;
990 break;
991
992 case SID_UNDO:
993 pShUndoMgr->Undo();
994 GetBindings().InvalidateAll(false);
995 bOK = true;
996 break;
997
998 case SID_REDO:
999 pShUndoMgr->Redo();
1000 GetBindings().InvalidateAll(false);
1001 bOK = true;
1002 break;
1003
1004 case SID_REPEAT:
1005 if ( pSh->GetRepeatTarget() )
1006 pShUndoMgr->Repeat( *pSh->GetRepeatTarget() );
1007 bOK = true;
1008 break;
1009 }
1010 }
1011 else if ( GetViewShell() )
1012 {
1013 // The SW has its own undo in the View
1014 const SfxPoolItem *pRet = GetViewShell()->ExecuteSlot( rReq );
1015 if ( pRet )
1016 bOK = static_cast<const SfxBoolItem*>(pRet)->GetValue();
1017 }
1018
1019 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bOK ) );
1020 rReq.Done();
1021}
1022
1024{
1025 // Search for Undo-Manager
1026 SfxShell *pSh = GetDispatcher()->GetShell(0);
1027 if ( !pSh )
1028 // I'm just on reload and am yielding myself ...
1029 return;
1030
1031 SfxUndoManager *pShUndoMgr = pSh->GetUndoManager();
1032 if ( !pShUndoMgr )
1033 {
1034 // The SW has its own undo in the View
1035 SfxWhichIter aIter( rSet );
1036 SfxViewShell *pViewSh = GetViewShell();
1037 if( !pViewSh ) return;
1038 for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
1039 pViewSh->GetSlotState( nSID, nullptr, &rSet );
1040 return;
1041 }
1042
1043 if ( pShUndoMgr->GetUndoActionCount() == 0 &&
1044 pShUndoMgr->GetRedoActionCount() == 0 &&
1045 pShUndoMgr->GetRepeatActionCount() == 0 )
1046 rSet.DisableItem( SID_CLEARHISTORY );
1047
1048 if (pShUndoMgr->GetUndoActionCount())
1049 {
1050 const SfxUndoAction* pAction = pShUndoMgr->GetUndoAction();
1051 SfxViewShell *pViewSh = GetViewShell();
1052 if (pViewSh && pAction->GetViewShellId() != pViewSh->GetViewShellId())
1053 {
1054 rSet.Put(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)));
1055 }
1056 else
1057 {
1058 rSet.Put( SfxStringItem( SID_UNDO, SvtResId(STR_UNDO)+pShUndoMgr->GetUndoActionComment() ) );
1059 }
1060 }
1061 else
1062 rSet.DisableItem( SID_UNDO );
1063
1064 if (pShUndoMgr->GetRedoActionCount())
1065 {
1066 const SfxUndoAction* pAction = pShUndoMgr->GetRedoAction();
1067 SfxViewShell *pViewSh = GetViewShell();
1068 if (pViewSh && pAction->GetViewShellId() != pViewSh->GetViewShellId())
1069 {
1070 rSet.Put(SfxUInt32Item(SID_REDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)));
1071 }
1072 else
1073 {
1074 rSet.Put(SfxStringItem(SID_REDO, SvtResId(STR_REDO) + pShUndoMgr->GetRedoActionComment()));
1075 }
1076 }
1077 else
1078 rSet.DisableItem( SID_REDO );
1079
1080 SfxRepeatTarget *pTarget = pSh->GetRepeatTarget();
1081 if (pTarget && pShUndoMgr->GetRepeatActionCount() && pShUndoMgr->CanRepeat(*pTarget))
1082 rSet.Put( SfxStringItem( SID_REPEAT, SvtResId(STR_REPEAT)+pShUndoMgr->GetRepeatActionComment(*pTarget) ) );
1083 else
1084 rSet.DisableItem( SID_REPEAT );
1085}
1086
1088{
1089 i_rViewShell.PopSubShells_Impl();
1090 sal_uInt16 nLevel = m_pDispatcher->GetShellLevel( i_rViewShell );
1091 if ( nLevel != USHRT_MAX )
1092 {
1093 if ( nLevel )
1094 {
1095 // more sub shells on the stack, which were not affected by PopSubShells_Impl
1096 SfxShell *pSubShell = m_pDispatcher->GetShell( nLevel-1 );
1098 }
1099 m_pDispatcher->Pop( i_rViewShell );
1100 m_pDispatcher->Flush();
1101 }
1102
1103}
1104
1105/* [Description]
1106
1107 This method empties the SfxViewFrame, i.e. takes the <SfxObjectShell>
1108 from the dispatcher and ends its <SfxListener> Relationship to this
1109 SfxObjectShell (by which they may even destroy themselves).
1110
1111 Thus, by invoking ReleaseObjectShell() and SetObjectShell() the
1112 SfxObjectShell can be replaced.
1113
1114 Between ReleaseObjectShell() and SetObjectShell() the control cannot
1115 be handed over to the system.
1116
1117 [Cross-reference]
1118
1119 <SfxViewFrame::SetObjectShell(SfxObjectShell&)>
1120*/
1122{
1123 DBG_ASSERT( m_xObjSh.is(), "no SfxObjectShell to release!" );
1124
1126 if ( GetWindow().HasChildPathFocus( true ) )
1127 {
1128 GetWindow().GrabFocus();
1129 }
1130
1131 SfxViewShell *pDyingViewSh = GetViewShell();
1132 if ( pDyingViewSh )
1133 {
1134 PopShellAndSubShells_Impl( *pDyingViewSh );
1135 pDyingViewSh->DisconnectAllClients();
1136 SetViewShell_Impl(nullptr);
1137 delete pDyingViewSh;
1138 }
1139#ifdef DBG_UTIL
1140 else
1141 OSL_FAIL("No Shell");
1142#endif
1143
1144 if ( m_xObjSh.is() )
1145 {
1146 m_pDispatcher->Pop( *m_xObjSh );
1147 SfxModule* pModule = m_xObjSh->GetModule();
1148 if( pModule )
1149 m_pDispatcher->RemoveShell_Impl( *pModule );
1150 m_pDispatcher->Flush();
1152
1153 Notify( *m_xObjSh, SfxHint(SfxHintId::TitleChanged) );
1154 Notify( *m_xObjSh, SfxHint(SfxHintId::DocChanged) );
1155
1156 if ( 1 == m_xObjSh->GetOwnerLockCount() && m_pImpl->bObjLocked && m_xObjSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
1157 m_xObjSh->DoClose();
1158 SfxObjectShellRef xDyingObjSh = m_xObjSh;
1159 m_xObjSh.clear();
1160 if( GetFrame().GetHasTitle() && m_pImpl->nDocViewNo )
1161 xDyingObjSh->GetNoSet_Impl().ReleaseIndex(m_pImpl->nDocViewNo-1);
1162 if ( m_pImpl->bObjLocked )
1163 {
1164 xDyingObjSh->OwnerLock( false );
1165 m_pImpl->bObjLocked = false;
1166 }
1167 }
1168
1170}
1171
1173{
1174
1175 DBG_ASSERT( GetFrame().IsClosing_Impl() || !GetFrame().GetFrameInterface().is(), "ViewFrame closed too early!" );
1176
1177 // If no saving have been made up until now, then embedded Objects should
1178 // not be saved automatically anymore.
1179 if ( GetViewShell() )
1181 Broadcast( SfxHint( SfxHintId::Dying ) );
1182
1183 if (SfxViewFrame::Current() == this)
1184 SfxViewFrame::SetViewFrame( nullptr );
1185
1186 // Since the Dispatcher is emptied, it can not be used in any reasonable
1187 // manner, thus it is better to let the dispatcher be.
1188 GetDispatcher()->Lock(true);
1189 delete this;
1190}
1191
1193{
1194 m_pDispatcher->DoActivate_Impl( bUI );
1195}
1196
1197void SfxViewFrame::DoDeactivate(bool bUI, SfxViewFrame const * pNewFrame )
1198{
1199 m_pDispatcher->DoDeactivate_Impl( bUI, pNewFrame );
1200}
1201
1203{
1204 if( !pSh || m_nAdjustPosPixelLock )
1205 return;
1206
1207 if ( GetViewShell() && GetWindow().IsVisible() )
1208 {
1209 if ( GetFrame().IsInPlace() )
1210 {
1211 return;
1212 }
1213
1215 GetWindow().GetOutputSizePixel(),
1216 false );
1217 }
1218}
1219
1221(
1222 const SfxViewShell* pVSh,
1223 const SvBorder& rBorder
1224)
1225
1226{
1227 m_pImpl->aBorder = rBorder;
1228
1229 if ( m_pImpl->bResizeInToOut && !GetFrame().IsInPlace() )
1230 {
1231 Size aSize = pVSh->GetWindow()->GetOutputSizePixel();
1232 if ( aSize.Width() && aSize.Height() )
1233 {
1234 aSize.AdjustWidth(rBorder.Left() + rBorder.Right() );
1235 aSize.AdjustHeight(rBorder.Top() + rBorder.Bottom() );
1236
1237 Size aOldSize = GetWindow().GetOutputSizePixel();
1238 GetWindow().SetOutputSizePixel( aSize );
1239 vcl::Window* pParent = &GetWindow();
1240 while ( pParent->GetParent() )
1241 pParent = pParent->GetParent();
1242 Size aOuterSize = pParent->GetOutputSizePixel();
1243 aOuterSize.AdjustWidth( aSize.Width() - aOldSize.Width() );
1244 aOuterSize.AdjustHeight( aSize.Height() - aOldSize.Height() );
1245 pParent->SetOutputSizePixel( aOuterSize );
1246 }
1247 }
1248 else
1249 {
1250 tools::Rectangle aEditArea( Point(), GetWindow().GetOutputSizePixel() );
1251 aEditArea.AdjustLeft(rBorder.Left() );
1252 aEditArea.AdjustRight( -(rBorder.Right()) );
1253 aEditArea.AdjustTop(rBorder.Top() );
1254 aEditArea.AdjustBottom( -(rBorder.Bottom()) );
1255 pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() );
1256 }
1257}
1258
1260{
1261 return m_pImpl->aBorder;
1262}
1263
1265{
1266 bool bSignPDF = m_xObjSh->IsSignPDF();
1267 bool bSignWithCert = false;
1268 if (bSignPDF)
1269 {
1270 SfxObjectShell* pObjectShell = GetObjectShell();
1271 uno::Reference<security::XCertificate> xCertificate = pObjectShell->GetSignPDFCertificate();
1272 bSignWithCert = xCertificate.is();
1273 }
1274
1275 auto pInfoBar = AppendInfoBar("readonly", "",
1276 SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT),
1278 if (!pInfoBar)
1279 return;
1280
1281 if (bSignPDF)
1282 {
1283 // SID_SIGNPDF opened a read-write PDF
1284 // read-only for signing purposes.
1285 weld::Button& rSignButton = pInfoBar->addButton();
1286 if (bSignWithCert)
1287 {
1288 rSignButton.set_label(SfxResId(STR_READONLY_FINISH_SIGN));
1289 }
1290 else
1291 {
1292 rSignButton.set_label(SfxResId(STR_READONLY_SIGN));
1293 }
1294
1295 rSignButton.connect_clicked(LINK(this, SfxViewFrame, SignDocumentHandler));
1296 }
1297
1298 bool showEditDocumentButton = true;
1299 if (m_xObjSh->isEditDocLocked())
1300 showEditDocumentButton = false;
1301
1302 if (showEditDocumentButton)
1303 {
1304 weld::Button& rBtn = pInfoBar->addButton();
1305 rBtn.set_label(SfxResId(STR_READONLY_EDIT));
1306 rBtn.connect_clicked(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
1307 }
1308}
1309
1311{
1312 SfxObjectShell_Impl* pObjImpl = m_xObjSh->Get_Impl();
1313
1314 // what's the difference between pObjImpl->documentStorageHasMacros() and pObjImpl->aMacroMode.hasMacroLibrary() ?
1315 bool bHasDocumentMacros = pObjImpl->aMacroMode.hasMacroLibrary();
1316
1317 Reference<XModel> xModel = m_xObjSh->GetModel();
1318 uno::Reference<document::XEventsSupplier> xSupplier(xModel, uno::UNO_QUERY);
1319 bool bHasBoundConfigEvents(false);
1320 if (xSupplier.is())
1321 {
1322 css::uno::Reference<css::container::XNameReplace> xDocumentEvents = xSupplier->getEvents();
1323
1324 Sequence<OUString> eventNames = xDocumentEvents->getElementNames();
1325 sal_Int32 nEventCount = eventNames.getLength();
1326 for (sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent)
1327 {
1328 OUString url;
1329 try
1330 {
1331 Any aAny(xDocumentEvents->getByName(eventNames[nEvent]));
1332 Sequence<beans::PropertyValue> props;
1333 if (aAny >>= props)
1334 {
1336 url = aProps.getOrDefault("Script", url);
1337 }
1338 }
1339 catch (const Exception&)
1340 {
1341 }
1342 if (!url.isEmpty())
1343 {
1344 bHasBoundConfigEvents = true;
1345 break;
1346 }
1347 }
1348 }
1349
1350 if (bHasDocumentMacros || bHasBoundConfigEvents)
1351 {
1352 auto aResId = STR_CONTAINS_MACROS;
1354 aResId = STR_MACROS_DISABLED;
1355 else if (pObjImpl->aMacroMode.hasUnsignedContentError())
1356 aResId = STR_MACROS_DISABLED_CONTENT_UNSIGNED;
1357 auto pInfoBar = AppendInfoBar("macro", SfxResId(STR_MACROS_DISABLED_TITLE),
1359 if (!pInfoBar)
1360 return;
1361
1362 // No access to macro dialog when macros are disabled globally.
1364 return;
1365
1366 if (bHasDocumentMacros)
1367 {
1368 weld::Button& rMacroButton = pInfoBar->addButton();
1369 rMacroButton.set_label(SfxResId(STR_MACROS));
1370 rMacroButton.connect_clicked(LINK(this, SfxViewFrame, MacroButtonHandler));
1371 }
1372
1373 if (bHasBoundConfigEvents)
1374 {
1375 weld::Button& rEventButton = pInfoBar->addButton();
1376 rEventButton.set_label(SfxResId(STR_EVENTS));
1377 rEventButton.connect_clicked(LINK(this, SfxViewFrame, EventButtonHandler));
1378 }
1379 }
1380}
1381
1382namespace
1383{
1384css::uno::Reference<css::frame::XLayoutManager> getLayoutManager(const SfxFrame& rFrame)
1385{
1386 css::uno::Reference<css::frame::XLayoutManager> xLayoutManager;
1387 css::uno::Reference<css::beans::XPropertySet> xPropSet(rFrame.GetFrameInterface(),
1388 uno::UNO_QUERY);
1389 if (xPropSet.is())
1390 {
1391 try
1392 {
1393 xLayoutManager.set(xPropSet->getPropertyValue("LayoutManager"), uno::UNO_QUERY);
1394 }
1395 catch (const Exception& e)
1396 {
1397 SAL_WARN("sfx.view", "Failure getting layout manager: " + e.Message);
1398 }
1399 }
1400 return xLayoutManager;
1401}
1402}
1403
1405{
1407 return true;
1408
1409 bool bIsUITest = false; //uitest.uicheck fails when the dialog is open
1410 for (sal_uInt16 i = 0, nCount = Application::GetCommandLineParamCount(); i < nCount; ++i)
1411 {
1412 if (Application::GetCommandLineParam(i) == "--nologo")
1413 {
1414 bIsUITest = true;
1415 break;
1416 }
1417 }
1418 return bIsUITest;
1419}
1420
1422{
1423 const bool bShowTipOfTheDay = officecfg::Office::Common::Misc::ShowTipOfTheDay::get();
1424 if (!bShowTipOfTheDay)
1425 return false;
1426
1427 const auto t0 = std::chrono::system_clock::now().time_since_epoch();
1428
1429 // show tip-of-the-day dialog ?
1430 const sal_Int32 nLastTipOfTheDay = officecfg::Office::Common::Misc::LastTipOfTheDayShown::get();
1431 const sal_Int32 nDay = std::chrono::duration_cast<std::chrono::hours>(t0).count()/24; // days since 1970-01-01
1432 return nDay - nLastTipOfTheDay > 0; //only once per day
1433}
1434
1435void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
1436{
1437 if(m_pImpl->bIsDowning)
1438 return;
1439
1440 // we know only SfxEventHint or simple SfxHint
1441 if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint))
1442 {
1443 // When the Document is loaded asynchronously, was the Dispatcher
1444 // set as ReadOnly, to what must be returned when the document itself
1445 // is not read only, and the loading is finished.
1446 switch ( pEventHint->GetEventId() )
1447 {
1449 {
1450 SfxBindings& rBind = GetBindings();
1451 rBind.Invalidate( SID_DOC_MODIFIED );
1452 rBind.Invalidate( SID_RELOAD );
1453 rBind.Invalidate( SID_EDITDOC );
1454 break;
1455 }
1456
1459 {
1460 if ( !m_xObjSh.is() )
1461 break;
1462
1463 SfxBindings& rBind = GetBindings();
1464 rBind.Invalidate( SID_RELOAD );
1465 rBind.Invalidate( SID_EDITDOC );
1466
1467#if !ENABLE_WASM_STRIP_PINGUSER
1468 bool bIsHeadlessOrUITest = SfxApplication::IsHeadlessOrUITest(); //uitest.uicheck fails when the dialog is open
1469
1470 //what's new infobar
1471 if (utl::isProductVersionUpgraded(true) && !bIsHeadlessOrUITest)
1472 {
1473 VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("whatsnew", "", SfxResId(STR_WHATSNEW_TEXT), InfobarType::INFO);
1474 if (pInfoBar)
1475 {
1476 weld::Button& rWhatsNewButton = pInfoBar->addButton();
1477 rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
1478 rWhatsNewButton.connect_clicked(LINK(this, SfxViewFrame, WhatsNewHandler));
1479 }
1480 }
1481
1482 // show tip-of-the-day dialog if it due, but not if there is the impress modal template dialog
1483 // open where SdModule::ExecuteNewDocument will launch it instead when that dialog is dismissed
1484 if (SfxApplication::IsTipOfTheDayDue() && !bIsHeadlessOrUITest && !IsInModalMode())
1485 {
1486 // tdf#127946 pass in argument for dialog parent
1487 SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface());
1488 GetDispatcher()->ExecuteList(SID_TIPOFTHEDAY, SfxCallMode::SLOT, {}, { &aDocFrame });
1489 }
1490
1491 // inform about the community involvement
1492 const auto t0 = std::chrono::system_clock::now().time_since_epoch();
1493 const sal_Int64 nLastGetInvolvedShown = officecfg::Setup::Product::LastTimeGetInvolvedShown::get();
1494 const sal_Int64 nNow = std::chrono::duration_cast<std::chrono::seconds>(t0).count();
1495 const sal_Int64 nPeriodSec(60 * 60 * 24 * 180); // 180 days in seconds
1496 bool bUpdateLastTimeGetInvolvedShown = false;
1497
1498 if (nLastGetInvolvedShown == 0)
1499 bUpdateLastTimeGetInvolvedShown = true;
1500 else if (nPeriodSec < nNow && nLastGetInvolvedShown < (nNow + nPeriodSec/2) - nPeriodSec) // 90d alternating with donation
1501 {
1502 bUpdateLastTimeGetInvolvedShown = true;
1503
1504 VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("getinvolved", "", SfxResId(STR_GET_INVOLVED_TEXT), InfobarType::INFO);
1505
1506 if (pInfoBar)
1507 {
1508 weld::Button& rGetInvolvedButton = pInfoBar->addButton();
1509 rGetInvolvedButton.set_label(SfxResId(STR_GET_INVOLVED_BUTTON));
1510 rGetInvolvedButton.connect_clicked(LINK(this, SfxViewFrame, GetInvolvedHandler));
1511 }
1512 }
1513
1514 if (bUpdateLastTimeGetInvolvedShown
1515 && !officecfg::Setup::Product::LastTimeGetInvolvedShown::isReadOnly())
1516 {
1517 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
1518 officecfg::Setup::Product::LastTimeGetInvolvedShown::set(nNow, batch);
1519 batch->commit();
1520 }
1521
1522 // inform about donations
1523 const sal_Int64 nLastDonateShown = officecfg::Setup::Product::LastTimeDonateShown::get();
1524 bool bUpdateLastTimeDonateShown = false;
1525
1526 if (nLastDonateShown == 0)
1527 bUpdateLastTimeDonateShown = true;
1528 else if (nPeriodSec < nNow && nLastDonateShown < nNow - nPeriodSec) // 90d alternating with getinvolved
1529 {
1530 bUpdateLastTimeDonateShown = true;
1531
1532 VclPtr<SfxInfoBarWindow> pInfoBar = AppendInfoBar("donate", "", SfxResId(STR_DONATE_TEXT), InfobarType::INFO);
1533 if (pInfoBar)
1534 {
1535 weld::Button& rDonateButton = pInfoBar->addButton();
1536 rDonateButton.set_label(SfxResId(STR_DONATE_BUTTON));
1537 rDonateButton.connect_clicked(LINK(this, SfxViewFrame, DonationHandler));
1538 }
1539 }
1540
1541 if (bUpdateLastTimeDonateShown
1542 && !officecfg::Setup::Product::LastTimeDonateShown::isReadOnly())
1543 {
1544 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
1545 officecfg::Setup::Product::LastTimeDonateShown::set(nNow, batch);
1546 batch->commit();
1547 }
1548#endif
1549 if (officecfg::Office::Common::Passwords::HasMaster::get() &&
1550 officecfg::Office::Common::Passwords::StorageVersion::get() == 0)
1551 {
1552 // master password stored in deprecated format
1553 VclPtr<SfxInfoBarWindow> pOldMasterPasswordInfoBar =
1554 AppendInfoBar("oldmasterpassword", "",
1555 SfxResId(STR_REFRESH_MASTER_PASSWORD), InfobarType::DANGER, false);
1556 if (pOldMasterPasswordInfoBar)
1557 {
1558 weld::Button& rButton = pOldMasterPasswordInfoBar->addButton();
1559 rButton.set_label(SfxResId(STR_REFRESH_PASSWORD));
1560 rButton.connect_clicked(LINK(this,
1561 SfxViewFrame, RefreshMasterPasswordHdl));
1563 {
1564 weld::Button& rHelp = pOldMasterPasswordInfoBar->addButton();
1565 rHelp.set_label(SfxResId(RID_STR_HELP));
1566 rHelp.connect_clicked(LINK(this, SfxViewFrame, HelpMasterPasswordHdl));
1567 }
1568 }
1569 }
1570
1571 const bool bEmbedded = m_xObjSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED;
1572
1573 // read-only infobar if necessary
1574 const SfxViewShell *pVSh;
1575 const SfxShell *pFSh;
1576 if ( m_xObjSh->IsReadOnly() &&
1577 ! m_xObjSh->IsSecurityOptOpenReadOnly() &&
1578 ( !bEmbedded ||
1579 (( pVSh = m_xObjSh->GetViewShell()) && (pFSh = pVSh->GetFormShell()) && pFSh->IsDesignMode())))
1580 {
1582 }
1583
1584 if (!bEmbedded && m_xObjSh->Get_Impl()->getCurrentMacroExecMode() == css::document::MacroExecMode::NEVER_EXECUTE)
1586
1587 if (vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame().GetFrameInterface()) == "com.sun.star.text.TextDocument")
1588 sfx2::SfxNotebookBar::ReloadNotebookBar(u"modules/swriter/ui/");
1589
1590 if (SfxClassificationHelper::IsClassified(m_xObjSh->getDocProperties()))
1591 {
1592 // Document has BAILS properties, display an infobar accordingly.
1593 SfxClassificationHelper aHelper(m_xObjSh->getDocProperties());
1594 aHelper.UpdateInfobar(*this);
1595 }
1596
1597 // Add pending infobars
1598 std::vector<InfobarData>& aPendingInfobars = m_xObjSh->getPendingInfobars();
1599 while (!aPendingInfobars.empty())
1600 {
1601 InfobarData& aInfobarData = aPendingInfobars.back();
1602
1603 // don't show Track Changes infobar, if Track Changes toolbar is visible
1604 if (aInfobarData.msId == "hiddentrackchanges")
1605 {
1606 if (auto xLayoutManager = getLayoutManager(GetFrame()))
1607 {
1608 if ( xLayoutManager->getElement(CHANGES_STR).is() )
1609 {
1610 aPendingInfobars.pop_back();
1611 continue;
1612 }
1613 }
1614 }
1615
1616 // Track Changes infobar: add a button to show/hide Track Changes functions
1617 // Hyphenation infobar: add a button to get more information
1618 // tdf#148913 limit VclPtr usage for these
1619 bool bTrackChanges = aInfobarData.msId == "hiddentrackchanges";
1620 if ( bTrackChanges || aInfobarData.msId == "hyphenationmissing" )
1621 {
1622 VclPtr<SfxInfoBarWindow> pInfoBar =
1623 AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage,
1624 aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType,
1625 aInfobarData.mbShowCloseButton);
1626
1627 // tdf#148913 don't extend this condition to keep it thread-safe
1628 if (pInfoBar)
1629 {
1630 weld::Button& rButton = pInfoBar->addButton();
1631 rButton.set_label(SfxResId(bTrackChanges
1632 ? STR_TRACK_CHANGES_BUTTON
1633 : STR_HYPHENATION_BUTTON));
1634 if (bTrackChanges)
1635 {
1636 rButton.connect_clicked(LINK(this,
1637 SfxViewFrame, HiddenTrackChangesHandler));
1638 }
1639 else
1640 {
1641 rButton.connect_clicked(LINK(this,
1642 SfxViewFrame, HyphenationMissingHandler));
1643 }
1644 }
1645 }
1646 else
1647 {
1648 AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage,
1649 aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType,
1650 aInfobarData.mbShowCloseButton);
1651 }
1652
1653 aPendingInfobars.pop_back();
1654 }
1655
1656 break;
1657 }
1658 default: break;
1659 }
1660 }
1661 else
1662 {
1663 switch( rHint.GetId() )
1664 {
1665 case SfxHintId::ModeChanged:
1666 {
1667 UpdateTitle();
1668
1669 if ( !m_xObjSh.is() )
1670 break;
1671
1672 // Switch r/o?
1673 SfxBindings& rBind = GetBindings();
1674 rBind.Invalidate( SID_RELOAD );
1675 SfxDispatcher *pDispat = GetDispatcher();
1676 bool bWasReadOnly = pDispat->GetReadOnly_Impl();
1677 bool bIsReadOnly = m_xObjSh->IsReadOnly();
1678 if ( bWasReadOnly != bIsReadOnly )
1679 {
1680 // Then also TITLE_CHANGED
1681 UpdateTitle();
1682 rBind.Invalidate( SID_FILE_NAME );
1683 rBind.Invalidate( SID_DOCINFO_TITLE );
1684 rBind.Invalidate( SID_EDITDOC );
1685
1686 pDispat->GetBindings()->InvalidateAll(true);
1687 pDispat->SetReadOnly_Impl( bIsReadOnly );
1688
1689 // Only force and Dispatcher-Update, if it is done next
1690 // anyway, otherwise flickering or GPF is possible since
1691 // the Writer for example prefers in Resize perform some
1692 // actions which has a SetReadOnlyUI in Dispatcher as a
1693 // result!
1694
1695 if ( pDispat->IsUpdated_Impl() )
1696 pDispat->Update_Impl(true);
1697 }
1698
1699 Enable( !m_xObjSh->IsInModalMode() );
1700 break;
1701 }
1702
1703 case SfxHintId::TitleChanged:
1704 {
1705 UpdateTitle();
1706 SfxBindings& rBind = GetBindings();
1707 rBind.Invalidate( SID_FILE_NAME );
1708 rBind.Invalidate( SID_DOCINFO_TITLE );
1709 rBind.Invalidate( SID_EDITDOC );
1710 rBind.Invalidate( SID_RELOAD );
1711 break;
1712 }
1713
1714 case SfxHintId::DocumentRepair:
1715 {
1716 GetBindings().Invalidate( SID_DOC_REPAIR );
1717 break;
1718 }
1719
1720 case SfxHintId::Deinitializing:
1721 {
1722 vcl::Window* pFrameWin = GetWindow().GetFrameWindow();
1723 if (pFrameWin && pFrameWin->GetLOKNotifier())
1724 pFrameWin->ReleaseLOKNotifier();
1725
1726 GetFrame().DoClose();
1727 break;
1728 }
1729 case SfxHintId::Dying:
1730 // when the Object is being deleted, destroy the view too
1731 if ( m_xObjSh.is() )
1733 else
1734 GetFrame().DoClose();
1735 break;
1736 default: break;
1737 }
1738 }
1739}
1740
1741#if !ENABLE_WASM_STRIP_PINGUSER
1743{
1744 GetDispatcher()->Execute(SID_WHATSNEW);
1745}
1746
1747IMPL_LINK_NOARG(SfxViewFrame, GetInvolvedHandler, weld::Button&, void)
1748{
1749 GetDispatcher()->Execute(SID_GETINVOLVED);
1750}
1751
1753{
1754 GetDispatcher()->Execute(SID_DONATION);
1755}
1756#endif
1757
1758IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, weld::Button&, rButton, void)
1759{
1760 if (m_xObjSh.is() && m_xObjSh->IsSignPDF())
1761 {
1762 SfxEditDocumentDialog aDialog(&rButton);
1763 if (aDialog.run() != RET_OK)
1764 return;
1765 }
1766 GetDispatcher()->Execute(SID_EDITDOC);
1767}
1768
1769IMPL_LINK_NOARG(SfxViewFrame, SignDocumentHandler, weld::Button&, void)
1770{
1771 GetDispatcher()->Execute(SID_SIGNATURE);
1772}
1773
1774IMPL_LINK(SfxViewFrame, HiddenTrackChangesHandler, weld::Button&, rButton, void)
1775{
1776 // enable Track Changes toolbar, if it is disabled.
1777 // Otherwise disable the toolbar, and close the infobar
1778 auto xLayoutManager = getLayoutManager(GetFrame());
1779 if (!xLayoutManager)
1780 return;
1781
1782 if (!xLayoutManager->getElement(CHANGES_STR).is())
1783 {
1784 xLayoutManager->createElement(CHANGES_STR);
1785 xLayoutManager->showElement(CHANGES_STR);
1786 rButton.set_label(SfxResId(STR_TRACK_CHANGES_BUTTON_HIDE));
1787 }
1788 else
1789 {
1790 xLayoutManager->hideElement(CHANGES_STR);
1791 xLayoutManager->destroyElement(CHANGES_STR);
1792 RemoveInfoBar(u"hiddentrackchanges");
1793 }
1794}
1795
1796IMPL_LINK_NOARG(SfxViewFrame, HyphenationMissingHandler, weld::Button&, void)
1797{
1798 GetDispatcher()->Execute(SID_HYPHENATIONMISSING);
1799 RemoveInfoBar(u"hyphenationmissing");
1800}
1801
1802IMPL_LINK_NOARG(SfxViewFrame, MacroButtonHandler, weld::Button&, void)
1803{
1804 // start with tab 0 displayed
1805 SfxUInt16Item aTabItem(SID_MACROORGANIZER, 0);
1806 SfxBoolItem aCurrentDocItem(FN_PARAM_2, true);
1807 SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface());
1808 GetDispatcher()->ExecuteList(SID_MACROORGANIZER, SfxCallMode::ASYNCHRON,
1809 { &aTabItem, &aCurrentDocItem }, { &aDocFrame });
1810}
1811
1812IMPL_LINK_NOARG(SfxViewFrame, EventButtonHandler, weld::Button&, void)
1813{
1814 SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface());
1816 {}, { &aDocFrame });
1817}
1818
1819IMPL_LINK_NOARG(SfxViewFrame, RefreshMasterPasswordHdl, weld::Button&, void)
1820{
1821 bool bChanged = false;
1822 try
1823 {
1824 Reference< task::XPasswordContainer2 > xMasterPasswd(
1825 task::PasswordContainer::create(comphelper::getProcessComponentContext()));
1826
1827 css::uno::Reference<css::frame::XFrame> xFrame = GetFrame().GetFrameInterface();
1828 css::uno::Reference<css::awt::XWindow> xContainerWindow = xFrame->getContainerWindow();
1829
1830 uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
1831 xContainerWindow));
1832 bChanged = xMasterPasswd->changeMasterPassword(xTmpHandler);
1833 }
1834 catch (const Exception&)
1835 {}
1836 if (bChanged)
1837 RemoveInfoBar(u"oldmasterpassword");
1838}
1839
1840IMPL_STATIC_LINK_NOARG(SfxViewFrame, HelpMasterPasswordHdl, weld::Button&, void)
1841{
1842 if (Help* pHelp = Application::GetHelp())
1843 pHelp->Start("cui/ui/optsecuritypage/savepassword");
1844}
1845
1847{
1848 m_pImpl->bResizeInToOut = true;
1849 m_pImpl->bObjLocked = false;
1850 m_pImpl->nCurViewId = SFX_INTERFACE_NONE;
1851 m_pImpl->bReloading = false;
1852 m_pImpl->bIsDowning = false;
1853 m_pImpl->bModal = false;
1854 m_pImpl->bEnabled = true;
1855 m_pImpl->nDocViewNo = 0;
1856 m_pImpl->aMargin = Size( -1, -1 );
1857 m_pImpl->pWindow = nullptr;
1858
1859 SetPool( &SfxGetpApp()->GetPool() );
1860 m_pDispatcher.reset( new SfxDispatcher(this) );
1861 if ( !GetBindings().GetDispatcher() )
1863
1864 m_xObjSh = pObjSh;
1865 if ( m_xObjSh.is() && m_xObjSh->IsPreview() )
1867
1868 if ( pObjSh )
1869 {
1870 m_pDispatcher->Push( *SfxGetpApp() );
1871 SfxModule* pModule = m_xObjSh->GetModule();
1872 if( pModule )
1873 m_pDispatcher->Push( *pModule );
1874 m_pDispatcher->Push( *this );
1875 m_pDispatcher->Push( *pObjSh );
1876 m_pDispatcher->Flush();
1877 StartListening( *pObjSh );
1878 Notify( *pObjSh, SfxHint(SfxHintId::TitleChanged) );
1879 Notify( *pObjSh, SfxHint(SfxHintId::DocChanged) );
1880 m_pDispatcher->SetReadOnly_Impl( pObjSh->IsReadOnly() );
1881 }
1882 else
1883 {
1884 m_pDispatcher->Push( *SfxGetpApp() );
1885 m_pDispatcher->Push( *this );
1886 m_pDispatcher->Flush();
1887 }
1888
1889 SfxGetpApp()->GetViewFrames_Impl().push_back(this);
1890}
1891
1892/* [Description]
1893
1894 Constructor of SfxViewFrame for a <SfxObjectShell> from the Resource.
1895 The 'nViewId' to the created <SfxViewShell> can be returned.
1896 (default is the SfxViewShell-Subclass that was registered first).
1897*/
1899(
1900 SfxFrame& rFrame,
1901 SfxObjectShell* pObjShell
1902)
1903 : m_pImpl( new SfxViewFrame_Impl( rFrame ) )
1904 , m_pBindings( new SfxBindings )
1905 , m_pHelpData(CreateSVHelpData())
1906 , m_pWinData(CreateSVWinData())
1907 , m_nAdjustPosPixelLock( 0 )
1908 , m_pCommandPopupHandler(new CommandPopupHandler)
1909{
1910
1911 rFrame.SetCurrentViewFrame_Impl( this );
1912 rFrame.SetHasTitle( true );
1913 Construct_Impl( pObjShell );
1914
1915 m_pImpl->pWindow = VclPtr<SfxFrameViewWindow_Impl>::Create( this, rFrame.GetWindow() );
1916 m_pImpl->pWindow->SetSizePixel( rFrame.GetWindow().GetOutputSizePixel() );
1917 rFrame.SetOwnsBindings_Impl( true );
1918 rFrame.CreateWorkWindow_Impl();
1919}
1920
1922{
1923 m_pImpl->bIsDowning = true;
1924
1925 if ( SfxViewFrame::Current() == this )
1926 SfxViewFrame::SetViewFrame( nullptr );
1927
1929
1930 if ( GetFrame().OwnsBindings_Impl() )
1931 // The Bindings delete the Frame!
1933
1934 m_pImpl->pWindow.disposeAndClear();
1935
1936 if ( GetFrame().GetCurrentViewFrame() == this )
1938
1939 // Unregister from the Frame List.
1941 if (pSfxApp)
1942 {
1943 auto &rFrames = pSfxApp->GetViewFrames_Impl();
1944 auto it = std::find( rFrames.begin(), rFrames.end(), this );
1945 rFrames.erase( it );
1946 }
1947
1948 // Delete Member
1950
1952 m_pHelpData = nullptr;
1953
1955 m_pWinData = nullptr;
1956}
1957
1958// Remove and delete the Dispatcher.
1960{
1961
1962 SfxModule* pModule = m_xObjSh.is() ? m_xObjSh->GetModule() : nullptr;
1963 if ( m_xObjSh.is() )
1965 if ( m_pDispatcher )
1966 {
1967 if( pModule )
1969 else
1970 m_pDispatcher->Pop( *this );
1971 m_pDispatcher.reset();
1972 }
1973}
1974
1976{
1978 return pApp ? pApp->Get_Impl()->pViewFrame : nullptr;
1979}
1980
1981// returns the first window of spec. type viewing the specified doc.
1983(
1984 const SfxObjectShell* pDoc,
1985 bool bOnlyIfVisible
1986)
1987{
1989 if (!pSfxApp)
1990 return nullptr;
1991
1992 // search for a SfxDocument of the specified type
1993 for (SfxViewFrame* pFrame : pSfxApp->GetViewFrames_Impl())
1994 {
1995 if ( ( !pDoc || pDoc == pFrame->GetObjectShell() )
1996 && ( !bOnlyIfVisible || pFrame->IsVisible() )
1997 )
1998 return pFrame;
1999 }
2000
2001 return nullptr;
2002}
2003
2004// returns the next window of spec. type viewing the specified doc.
2006(
2007 const SfxViewFrame& rPrev,
2008 const SfxObjectShell* pDoc,
2009 bool bOnlyIfVisible
2010)
2011{
2013 if (!pSfxApp)
2014 return nullptr;
2015
2016 auto &rFrames = pSfxApp->GetViewFrames_Impl();
2017
2018 // refind the specified predecessor
2019 size_t nPos;
2020 for ( nPos = 0; nPos < rFrames.size(); ++nPos )
2021 if ( rFrames[nPos] == &rPrev )
2022 break;
2023
2024 // search for a Frame of the specified type
2025 for ( ++nPos; nPos < rFrames.size(); ++nPos )
2026 {
2027 SfxViewFrame *pFrame = rFrames[nPos];
2028 if ( ( !pDoc || pDoc == pFrame->GetObjectShell() )
2029 && ( !bOnlyIfVisible || pFrame->IsVisible() )
2030 )
2031 return pFrame;
2032 }
2033 return nullptr;
2034}
2035
2037{
2038 SfxObjectShell *pObjSh = m_xObjSh.get();
2039 return pObjSh ? pObjSh->GetProgress() : nullptr;
2040}
2041
2043(
2044 SfxViewShell* pSh,
2045 const Point& rPos,
2046 const Size& rSize,
2047 bool inplaceEditModeChange
2048)
2049{
2050
2051 // Components do not use this Method!
2052 if( pSh && pSh->GetWindow() && !m_nAdjustPosPixelLock )
2053 {
2054 m_nAdjustPosPixelLock++;
2055 if ( m_pImpl->bResizeInToOut )
2056 pSh->InnerResizePixel( rPos, rSize, inplaceEditModeChange );
2057 else
2058 pSh->OuterResizePixel( rPos, rSize );
2059 m_nAdjustPosPixelLock--;
2060 }
2061}
2062
2064{
2065 return SfxPoolItem::operator==(rItem) &&
2066 static_cast<const SfxViewFrameItem&>(rItem).pFrame == pFrame;
2067}
2068
2070{
2071 return new SfxViewFrameItem( *this );
2072}
2073
2075/* [Description]
2076
2077 Internal Method to set the current <SfxViewShell> Instance,
2078 that is active int this SfxViewFrame at the moment.
2079*/
2080{
2082
2083 // Hack: InPlaceMode
2084 if ( pVSh )
2085 m_pImpl->bResizeInToOut = false;
2086}
2087
2089{
2090 m_pImpl->bResizeInToOut = true;
2091}
2092
2094{
2095 DBG_ASSERT( GetObjectShell(), "No Document!" );
2097 m_pImpl->nDocViewNo = GetObjectShell()->GetNoSet_Impl().GetFreeIndex()+1;
2098}
2099
2100void SfxViewFrame::Enable( bool bEnable )
2101{
2102 if ( bEnable == m_pImpl->bEnabled )
2103 return;
2104
2105 m_pImpl->bEnabled = bEnable;
2106
2107 vcl::Window *pWindow = &GetFrame().GetWindow();
2108 if ( !bEnable )
2109 m_pImpl->bWindowWasEnabled = pWindow->IsInputEnabled();
2110 if ( !bEnable || m_pImpl->bWindowWasEnabled )
2111 pWindow->EnableInput( bEnable );
2112
2113 // cursor and focus
2114 SfxViewShell* pViewSh = GetViewShell();
2115 if ( bEnable )
2116 {
2117 // show cursor
2118 if ( pViewSh )
2119 pViewSh->ShowCursor();
2120 }
2121 else
2122 {
2123 // hide cursor
2124 if ( pViewSh )
2125 pViewSh->ShowCursor(false);
2126 }
2127}
2128
2129/* [Description]
2130
2131 This method makes the Frame-Window visible and before transmits the
2132 window name. In addition, the document is held. In general one can never
2133 show the window directly!
2134*/
2136{
2137 // First lock the objectShell so that UpdateTitle() is valid:
2138 // IsVisible() == true (:#)
2139 if ( m_xObjSh.is() )
2140 {
2141 m_xObjSh->GetMedium()->GetItemSet().ClearItem( SID_HIDDEN );
2142 if ( !m_pImpl->bObjLocked )
2144
2145 // Adjust Doc-Shell title number, get unique view-no
2146 if ( 0 == m_pImpl->nDocViewNo )
2147 {
2149 UpdateTitle();
2150 }
2151 }
2152 else
2153 UpdateTitle();
2154
2155 // Display Frame-window, but only if the ViewFrame has no window of its
2156 // own or if it does not contain a Component
2157 GetWindow().Show();
2158 GetFrame().GetWindow().Show();
2159}
2160
2161
2163{
2164 return m_pImpl->bObjLocked;
2165}
2166
2167
2169{
2170 DBG_ASSERT( !m_pImpl->bObjLocked, "Wrong Locked status!" );
2171
2172 DBG_ASSERT( GetObjectShell(), "No Document!" );
2173 GetObjectShell()->OwnerLock(true);
2174 m_pImpl->bObjLocked = true;
2175}
2176
2177
2178void SfxViewFrame::MakeActive_Impl( bool bGrabFocus )
2179{
2180 if ( !GetViewShell() || GetFrame().IsClosing_Impl() )
2181 return;
2182
2183 if ( !IsVisible() )
2184 return;
2185
2186 bool bPreview = false;
2187 if (GetObjectShell()->IsPreview())
2188 {
2189 bPreview = true;
2190 }
2191
2192 css::uno::Reference<css::frame::XFrame> xFrame = GetFrame().GetFrameInterface();
2193 if (!bPreview)
2194 {
2195 SetViewFrame(this);
2196 GetBindings().SetActiveFrame(css::uno::Reference<css::frame::XFrame>());
2197 uno::Reference<frame::XFramesSupplier> xSupp(xFrame, uno::UNO_QUERY);
2198 if (xSupp.is())
2199 xSupp->setActiveFrame(uno::Reference<frame::XFrame>());
2200
2201 css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow();
2202 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow);
2203 if (pWindow && pWindow->HasChildPathFocus() && bGrabFocus)
2204 {
2206 if (!pCli || !pCli->IsObjectUIActive())
2208 }
2209 }
2210 else
2211 {
2213 GetBindings().SetActiveFrame(css::uno::Reference<css::frame::XFrame>());
2215 }
2216}
2217
2219{
2220 return m_xObjSh.get();
2221}
2222
2224{
2225 return m_pImpl->aMargin;
2226}
2227
2228SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
2229 const SfxInterfaceId i_nViewId, const bool i_bHidden )
2230{
2231 Reference< XFrame > xFrame( i_rFrame );
2232 bool bOwnFrame = false;
2233 SfxViewShell* pSuccessView = nullptr;
2234 try
2235 {
2236 if ( !xFrame.is() )
2237 {
2238 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
2239
2240 if ( !i_bHidden )
2241 {
2242 try
2243 {
2244 // if there is a backing component, use it
2245 ::framework::FrameListAnalyzer aAnalyzer( xDesktop, Reference< XFrame >(), FrameAnalyzerFlags::BackingComponent );
2246
2247 if ( aAnalyzer.m_xBackingComponent.is() )
2248 xFrame = aAnalyzer.m_xBackingComponent;
2249 }
2250 catch( uno::Exception& )
2251 {}
2252 }
2253
2254 if ( !xFrame.is() )
2255 xFrame.set( xDesktop->findFrame( "_blank", 0 ), UNO_SET_THROW );
2256
2257 bOwnFrame = true;
2258 }
2259
2260 pSuccessView = LoadViewIntoFrame_Impl(
2261 i_rDoc,
2262 xFrame,
2263 Sequence< PropertyValue >(), // means "reuse existing model's args"
2264 i_nViewId,
2265 i_bHidden
2266 );
2267
2268 if ( bOwnFrame && !i_bHidden )
2269 {
2270 // ensure the frame/window is visible
2271 Reference< XWindow > xContainerWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
2272 xContainerWindow->setVisible( true );
2273 }
2274 }
2275 catch( const Exception& )
2276 {
2277 DBG_UNHANDLED_EXCEPTION("sfx.view");
2278 }
2279
2280 if ( pSuccessView )
2281 return &pSuccessView->GetViewFrame();
2282
2283 if ( bOwnFrame )
2284 {
2285 try
2286 {
2287 xFrame->dispose();
2288 }
2289 catch( const Exception& )
2290 {
2291 DBG_UNHANDLED_EXCEPTION("sfx.view");
2292 }
2293 }
2294
2295 return nullptr;
2296}
2297
2298SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame,
2299 const Sequence< PropertyValue >& i_rLoadArgs, const SfxInterfaceId i_nViewId,
2300 const bool i_bHidden )
2301{
2302 Reference< XModel > xDocument( i_rDoc.GetModel(), UNO_SET_THROW );
2303
2304 ::comphelper::NamedValueCollection aTransformLoadArgs( i_rLoadArgs.hasElements() ? i_rLoadArgs : xDocument->getArgs() );
2305 aTransformLoadArgs.put( "Model", xDocument );
2306 if ( i_nViewId )
2307 aTransformLoadArgs.put( "ViewId", sal_uInt16( i_nViewId ) );
2308 if ( i_bHidden )
2309 aTransformLoadArgs.put( "Hidden", i_bHidden );
2310 else
2311 aTransformLoadArgs.remove( "Hidden" );
2312
2313 Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW );
2314 xLoader->loadComponentFromURL( "private:object", "_self", 0,
2315 aTransformLoadArgs.getPropertyValues() );
2316
2317 SfxViewShell* pViewShell = SfxViewShell::Get( i_rFrame->getController() );
2318 ENSURE_OR_THROW( pViewShell,
2319 "SfxViewFrame::LoadViewIntoFrame_Impl: loading an SFX doc into a frame resulted in a non-SFX view - quite impossible" );
2320 return pViewShell;
2321}
2322
2324{
2325 return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, true );
2326}
2327
2329{
2330 return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, false );
2331}
2332
2333SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell const & i_rDoc, const Reference< XFrame >& i_rTargetFrame )
2334{
2335 return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_rTargetFrame, SFX_INTERFACE_NONE, false );
2336}
2337
2339{
2340 return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem && i_pFrameItem->GetFrame() ? i_pFrameItem->GetFrame()->GetFrameInterface() : nullptr, i_nViewId, false );
2341}
2342
2343SfxViewFrame* SfxViewFrame::DisplayNewDocument( SfxObjectShell const & i_rDoc, const SfxRequest& i_rCreateDocRequest )
2344{
2345 const SfxUnoFrameItem* pFrameItem = i_rCreateDocRequest.GetArg<SfxUnoFrameItem>(SID_FILLFRAME);
2346 const SfxBoolItem* pHiddenItem = i_rCreateDocRequest.GetArg<SfxBoolItem>(SID_HIDDEN);
2347
2349 i_rDoc,
2350 pFrameItem ? pFrameItem->GetFrame() : nullptr,
2352 pHiddenItem && pHiddenItem->GetValue()
2353 );
2354}
2355
2356SfxViewFrame* SfxViewFrame::Get( const Reference< XController>& i_rController, const SfxObjectShell* i_pDoc )
2357{
2358 if ( !i_rController.is() )
2359 return nullptr;
2360
2361 const SfxObjectShell* pDoc = i_pDoc;
2362 if ( !pDoc )
2363 {
2364 Reference< XModel > xDocument( i_rController->getModel() );
2365 for ( pDoc = SfxObjectShell::GetFirst( nullptr, false );
2366 pDoc;
2367 pDoc = SfxObjectShell::GetNext( *pDoc, nullptr, false )
2368 )
2369 {
2370 if ( pDoc->GetModel() == xDocument )
2371 break;
2372 }
2373 }
2374
2375 SfxViewFrame* pViewFrame = nullptr;
2376 for ( pViewFrame = SfxViewFrame::GetFirst( pDoc, false );
2377 pViewFrame;
2378 pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDoc, false )
2379 )
2380 {
2381 if ( pViewFrame->GetViewShell()->GetController() == i_rController )
2382 break;
2383 }
2384
2385 return pViewFrame;
2386}
2387
2389{
2390 SfxViewShell* pCurrentShell = GetViewShell();
2391 ENSURE_OR_RETURN_VOID( pCurrentShell != nullptr, "SfxViewFrame::SaveCurrentViewData_Impl: no current view shell -> no current view data!" );
2392
2393 // determine the logical (API) view name
2394 const SfxObjectFactory& rDocFactory( pCurrentShell->GetObjectShell()->GetFactory() );
2395 const sal_uInt16 nCurViewNo = rDocFactory.GetViewNo_Impl( GetCurViewId(), 0 );
2396 const OUString sCurrentViewName = rDocFactory.GetViewFactory( nCurViewNo ).GetAPIViewName();
2397 const sal_uInt16 nNewViewNo = rDocFactory.GetViewNo_Impl( i_nNewViewId, 0 );
2398 const OUString sNewViewName = rDocFactory.GetViewFactory( nNewViewNo ).GetAPIViewName();
2399 if ( sCurrentViewName.isEmpty() || sNewViewName.isEmpty() )
2400 {
2401 // can't say anything about the view, the respective application did not yet migrate its code to
2402 // named view factories => bail out
2403 OSL_FAIL( "SfxViewFrame::SaveCurrentViewData_Impl: views without API names? Shouldn't happen anymore?" );
2404 return;
2405 }
2406 SAL_WARN_IF(sNewViewName == sCurrentViewName, "sfx.view", "SfxViewFrame::SaveCurrentViewData_Impl: suspicious: new and old view name are identical!");
2407
2408 // save the view data only when we're moving from a non-print-preview to the print-preview view
2409 if ( sNewViewName != "PrintPreview" )
2410 return;
2411
2412 // retrieve the view data from the view
2413 Sequence< PropertyValue > aViewData;
2414 pCurrentShell->WriteUserDataSequence( aViewData );
2415
2416 try
2417 {
2418 // retrieve view data (for *all* views) from the model
2419 const Reference< XController > xController( pCurrentShell->GetController(), UNO_SET_THROW );
2420 const Reference< XViewDataSupplier > xViewDataSupplier( xController->getModel(), UNO_QUERY_THROW );
2421 const Reference< XIndexContainer > xViewData( xViewDataSupplier->getViewData(), UNO_QUERY_THROW );
2422
2423 // look up the one view data item which corresponds to our current view, and remove it
2424 const sal_Int32 nCount = xViewData->getCount();
2425 for ( sal_Int32 i=0; i<nCount; ++i )
2426 {
2427 const ::comphelper::NamedValueCollection aCurViewData( xViewData->getByIndex(i) );
2428 const OUString sViewId( aCurViewData.getOrDefault( "ViewId", OUString() ) );
2429 if ( sViewId.isEmpty() )
2430 continue;
2431
2432 const SfxViewFactory* pViewFactory = rDocFactory.GetViewFactoryByViewName( sViewId );
2433 if ( pViewFactory == nullptr )
2434 continue;
2435
2436 if ( pViewFactory->GetOrdinal() == GetCurViewId() )
2437 {
2438 xViewData->removeByIndex(i);
2439 break;
2440 }
2441 }
2442
2443 // then replace it with the most recent view data we just obtained
2444 xViewData->insertByIndex( 0, Any( aViewData ) );
2445 }
2446 catch( const Exception& )
2447 {
2448 DBG_UNHANDLED_EXCEPTION("sfx.view");
2449 }
2450}
2451
2452/* [Description]
2453
2454 Internal Method for switching to another <SfxViewShell> subclass,
2455 which should be created in this SfxMDIFrame. If no SfxViewShell exist
2456 in this SfxMDIFrame, then one will first be created.
2457
2458
2459 [Return Value]
2460
2461 bool true
2462 requested SfxViewShell was created and a
2463 possibly existing one deleted
2464
2465 false
2466 SfxViewShell requested could not be created,
2467 the existing SfxViewShell thus continue to exist
2468*/
2470(
2471 sal_uInt16 nViewIdOrNo, /* > 0
2472 Registration-Id of the View, to which the
2473 method should switch, for example the one
2474 that will be created.
2475
2476 == 0
2477 First use the Default view. */
2478
2479 bool bIsIndex /* true
2480 'nViewIdOrNo' is no Registration-Id instead
2481 an Index of <SfxViewFrame> in <SfxObjectShell>.
2482 */
2483)
2484{
2485 try
2486 {
2487 ENSURE_OR_THROW( GetObjectShell() != nullptr, "not possible without a document" );
2488
2489 // if we already have a view shell, remove it
2490 SfxViewShell* pOldSh = GetViewShell();
2491 OSL_PRECOND( pOldSh, "SfxViewFrame::SwitchToViewShell_Impl: that's called *switch* (not for *initial-load*) for a reason" );
2492 if ( pOldSh )
2493 {
2494 // ask whether it can be closed
2495 if ( !pOldSh->PrepareClose() )
2496 return false;
2497
2498 // remove sub shells from Dispatcher before switching to new ViewShell
2499 PopShellAndSubShells_Impl( *pOldSh );
2500 }
2501
2502 GetBindings().ENTERREGISTRATIONS();
2504
2505 // ID of the new view
2507 const SfxInterfaceId nViewId = ( bIsIndex || !nViewIdOrNo ) ? rDocFact.GetViewFactory( nViewIdOrNo ).GetOrdinal() : SfxInterfaceId(nViewIdOrNo);
2508
2509 // save the view data of the old view, so it can be restored later on (when needed)
2510 SaveCurrentViewData_Impl( nViewId );
2511
2512 // create and load new ViewShell
2514 *GetObjectShell(),
2515 GetFrame().GetFrameInterface(),
2516 Sequence< PropertyValue >(), // means "reuse existing model's args"
2517 nViewId,
2518 false
2519 );
2520
2521 // allow resize events to be processed
2523
2524 if ( GetWindow().IsReallyVisible() )
2525 DoAdjustPosSizePixel( pNewSh, Point(), GetWindow().GetOutputSizePixel(), false );
2526
2527 GetBindings().LEAVEREGISTRATIONS();
2528 delete pOldSh;
2529 }
2530 catch ( const css::uno::Exception& )
2531 {
2532 // the SfxCode is not able to cope with exceptions thrown while creating views
2533 // the code will crash in the stack unwinding procedure, so we shouldn't let exceptions go through here
2534 DBG_UNHANDLED_EXCEPTION("sfx.view");
2535 return false;
2536 }
2537
2538 DBG_ASSERT( SfxGetpApp()->GetViewFrames_Impl().size() == SfxGetpApp()->GetViewShells_Impl().size(), "Inconsistent view arrays!" );
2539 return true;
2540}
2541
2543{
2544 m_pImpl->nCurViewId = i_nID;
2545}
2546
2548{
2549 return m_pImpl->nCurViewId;
2550}
2551
2552/* [Description]
2553
2554 Internal method to run the slot for the <SfxShell> Subclass in the
2555 SfxViewFrame <SVIDL> described slots.
2556*/
2558(
2559 SfxRequest& rReq // The executable <SfxRequest>
2560)
2561{
2562
2563 // If the Shells are just being replaced...
2564 if ( !GetObjectShell() || !GetViewShell() )
2565 return;
2566
2567 switch ( rReq.GetSlot() )
2568 {
2569 case SID_TERMINATE_INPLACEACTIVATION :
2570 {
2572 if ( pClient )
2573 pClient->DeactivateObject();
2574 break;
2575 }
2576
2577 case SID_VIEWSHELL:
2578 {
2579 const SfxUInt16Item *pItem = nullptr;
2580 if ( rReq.GetArgs()
2581 && (pItem = rReq.GetArgs()->GetItemIfSet( SID_VIEWSHELL, false ))
2582 )
2583 {
2584 const sal_uInt16 nViewId = pItem->GetValue();
2585 bool bSuccess = SwitchToViewShell_Impl( nViewId );
2586 rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
2587 }
2588 break;
2589 }
2590
2591 case SID_VIEWSHELL0:
2592 case SID_VIEWSHELL1:
2593 case SID_VIEWSHELL2:
2594 case SID_VIEWSHELL3:
2595 case SID_VIEWSHELL4:
2596 {
2597 const sal_uInt16 nViewNo = rReq.GetSlot() - SID_VIEWSHELL0;
2598 bool bSuccess = SwitchToViewShell_Impl( nViewNo, true );
2599 rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) );
2600 break;
2601 }
2602
2603 case SID_NEWWINDOW:
2604 {
2605 // Hack. at the moment a virtual Function
2606 if ( !GetViewShell()->NewWindowAllowed() )
2607 {
2608 OSL_FAIL( "You should have disabled the 'Window/New Window' slot!" );
2609 return;
2610 }
2611
2612 // Get ViewData of FrameSets recursively.
2614 SfxMedium* pMed = GetObjectShell()->GetMedium();
2615
2616 // do not open the new window hidden
2617 pMed->GetItemSet().ClearItem( SID_HIDDEN );
2618
2619 // the view ID (optional arg. TODO: this is currently not supported in the slot definition ...)
2620 const SfxUInt16Item* pViewIdItem = rReq.GetArg<SfxUInt16Item>(SID_VIEW_ID);
2621 const SfxInterfaceId nViewId = pViewIdItem ? SfxInterfaceId(pViewIdItem->GetValue()) : GetCurViewId();
2622
2623 Reference < XFrame > xFrame;
2624 // the frame (optional arg. TODO: this is currently not supported in the slot definition ...)
2625 const SfxUnoFrameItem* pFrameItem = rReq.GetArg<SfxUnoFrameItem>(SID_FILLFRAME);
2626 if ( pFrameItem )
2627 xFrame = pFrameItem->GetFrame();
2628
2630
2631 rReq.Done();
2632 break;
2633 }
2634
2635 case SID_OBJECT:
2636 {
2637 const SfxInt16Item* pItem = rReq.GetArg<SfxInt16Item>(SID_OBJECT);
2638
2639 if (pItem)
2640 {
2641 GetViewShell()->DoVerb( pItem->GetValue() );
2642 rReq.Done();
2643 break;
2644 }
2645 }
2646 }
2647}
2648
2649/* TODO as96863:
2650 This method try to collect information about the count of currently open documents.
2651 But the algorithm is implemented very simple ...
2652 E.g. hidden documents should be ignored here ... but they are counted.
2653 TODO: export special helper "framework::FrameListAnalyzer" within the framework module
2654 and use it here.
2655*/
2657{
2658 css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
2659 std::optional<sal_Int32> x(officecfg::Office::Common::Misc::MaxOpenDocuments::get());
2660 // NIL means: count of allowed documents = infinite !
2661 if (!x)
2662 return false;
2663 sal_Int32 nMaxDocs(*x);
2664 sal_Int32 nOpenDocs = 0;
2665
2666 css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(xContext);
2667 css::uno::Reference< css::container::XIndexAccess > xCont(xDesktop->getFrames(), css::uno::UNO_QUERY_THROW);
2668
2669 sal_Int32 c = xCont->getCount();
2670 sal_Int32 i = 0;
2671
2672 for (i=0; i<c; ++i)
2673 {
2674 try
2675 {
2676 css::uno::Reference< css::frame::XFrame > xFrame;
2677 xCont->getByIndex(i) >>= xFrame;
2678 if ( ! xFrame.is())
2679 continue;
2680
2681 // a) do not count the help window
2682 if ( xFrame->getName() == "OFFICE_HELP_TASK" )
2683 continue;
2684
2685 // b) count all other frames
2686 ++nOpenDocs;
2687 }
2688 catch(const css::uno::Exception&)
2689 // An IndexOutOfBoundsException can happen in multithreaded
2690 // environments, where any other thread can change this
2691 // container !
2692 { continue; }
2693 }
2694
2695 return (nOpenDocs >= nMaxDocs);
2696}
2697
2698/* [Description]
2699
2700 This internal method returns in 'rSet' the Status for the <SfxShell>
2701 Subclass SfxViewFrame in the <SVIDL> described <Slots>.
2702
2703 Thus exactly those Slots-IDs that are recognized as being invalid by Sfx
2704 are included as Which-ranges in 'rSet'. If there exists a mapping for
2705 single slot-IDs of the <SfxItemPool> set in the shell, then the respective
2706 Which-IDs are used so that items can be replaced directly with a working
2707 Core::sun::com::star::script::Engine of the Which-IDs if possible. .
2708*/
2710(
2711 SfxItemSet& rSet /* empty <SfxItemSet> with <Which-Ranges>,
2712 which describes the Slot Ids */
2713)
2714{
2715
2716 SfxObjectShell *pDocSh = GetObjectShell();
2717
2718 if ( !pDocSh )
2719 // I'm just on reload and am yielding myself ...
2720 return;
2721
2722 const WhichRangesContainer & pRanges = rSet.GetRanges();
2723 assert(!pRanges.empty() && "Set with no Range");
2724 for ( auto const & pRange : pRanges )
2725 {
2726 sal_uInt16 nStartWhich = pRange.first;
2727 sal_uInt16 nEndWhich = pRange.second;
2728 for ( sal_uInt16 nWhich = nStartWhich; nWhich <= nEndWhich; ++nWhich )
2729 {
2730 switch(nWhich)
2731 {
2732 case SID_VIEWSHELL:
2733 {
2734 rSet.Put( SfxUInt16Item( nWhich, sal_uInt16(m_pImpl->nCurViewId )) );
2735 break;
2736 }
2737
2738 case SID_VIEWSHELL0:
2739 case SID_VIEWSHELL1:
2740 case SID_VIEWSHELL2:
2741 case SID_VIEWSHELL3:
2742 case SID_VIEWSHELL4:
2743 {
2744 sal_uInt16 nViewNo = nWhich - SID_VIEWSHELL0;
2745 if ( GetObjectShell()->GetFactory().GetViewFactoryCount() >
2746 nViewNo && !GetObjectShell()->IsInPlaceActive() )
2747 {
2748 SfxViewFactory &rViewFactory =
2751 nWhich, m_pImpl->nCurViewId == rViewFactory.GetOrdinal() ) );
2752 }
2753 else
2754 rSet.DisableItem( nWhich );
2755 break;
2756 }
2757
2758 case SID_NEWWINDOW:
2759 {
2760 if ( !GetViewShell()->NewWindowAllowed()
2762 )
2763 rSet.DisableItem( nWhich );
2764 break;
2765 }
2766 }
2767 }
2768 }
2769}
2770
2771
2773{
2774 GetFrame().Appear();
2775}
2776
2777
2778/* [Description]
2779
2780 GetFrame returns the Frame, in which the ViewFrame is located.
2781*/
2783{
2784 return m_pImpl->rFrame;
2785}
2786
2788{
2789 return GetFrame().GetCurrentViewFrame();
2790}
2791
2793{
2794 return m_pImpl->pWindow ? *m_pImpl->pWindow : GetFrame().GetWindow();
2795}
2796
2798{
2799 return GetWindow().GetFrameWeld();
2800}
2801
2803{
2804 return GetFrame().DoClose();
2805}
2806
2808{
2809 if ( m_xObjSh.is() )
2810 return m_xObjSh->GetMedium()->GetName();
2811 return OUString();
2812}
2813
2815{
2816 // no real modality for LOK
2818 return;
2819
2820 m_pImpl->bModal = bModal;
2821 if ( m_xObjSh.is() )
2822 {
2823 for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( m_xObjSh.get() );
2824 !bModal && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, m_xObjSh.get() ) )
2825 bModal = pFrame->m_pImpl->bModal;
2826 m_xObjSh->SetModalMode_Impl( bModal );
2827 }
2828}
2829
2831{
2832 return m_pImpl->bModal || GetFrame().GetWindow().IsInModalMode();
2833}
2834
2835void SfxViewFrame::Resize( bool bForce )
2836{
2837 Size aSize = GetWindow().GetOutputSizePixel();
2838 if ( !bForce && aSize == m_pImpl->aSize )
2839 return;
2840
2841 m_pImpl->aSize = aSize;
2842 SfxViewShell *pShell = GetViewShell();
2843 if ( pShell )
2844 {
2845 if ( GetFrame().IsInPlace() )
2846 {
2847 Point aPoint = GetWindow().GetPosPixel();
2848 DoAdjustPosSizePixel( pShell, aPoint, aSize, true );
2849 }
2850 else
2851 {
2852 DoAdjustPosSizePixel( pShell, Point(), aSize, false );
2853 }
2854 }
2855}
2856
2857#if HAVE_FEATURE_SCRIPTING
2858
2859#define LINE_SEP 0x0A
2860
2861static void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
2862{
2863 sal_Int32 nStartPos = 0;
2864 sal_Int32 nLine = 0;
2865 while ( nLine < nStartLine )
2866 {
2867 nStartPos = rStr.indexOf( LINE_SEP, nStartPos );
2868 if( nStartPos == -1 )
2869 break;
2870 nStartPos++; // not the \n.
2871 nLine++;
2872 }
2873
2874 SAL_WARN_IF(nStartPos == -1, "sfx.view", "CutLines: Start row not found!");
2875
2876 if ( nStartPos != -1 )
2877 {
2878 sal_Int32 nEndPos = nStartPos;
2879 for ( sal_Int32 i = 0; i < nLines; i++ )
2880 nEndPos = rStr.indexOf( LINE_SEP, nEndPos+1 );
2881
2882 if ( nEndPos == -1 ) // Can happen at the last row.
2883 nEndPos = rStr.getLength();
2884 else
2885 nEndPos++;
2886
2887 rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( nEndPos );
2888 }
2889 // erase trailing lines
2890 if ( nStartPos != -1 )
2891 {
2892 sal_Int32 n = nStartPos;
2893 sal_Int32 nLen = rStr.getLength();
2894 while ( ( n < nLen ) && ( rStr[ n ] == LINE_SEP ) )
2895 n++;
2896
2897 if ( n > nStartPos )
2898 rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( n );
2899 }
2900}
2901
2902#endif
2903
2904/*
2905 add new recorded dispatch macro script into the application global basic
2906 lib container. It generates a new unique id for it and insert the macro
2907 by using this number as name for the module
2908 */
2910{
2911#if !HAVE_FEATURE_SCRIPTING
2912 (void) sMacro;
2913#else
2914 if ( sMacro.isEmpty() )
2915 return;
2916
2917 SfxApplication* pSfxApp = SfxGetpApp();
2918 SfxItemPool& rPool = pSfxApp->GetPool();
2919 SfxRequest aReq(SID_BASICCHOOSER, SfxCallMode::SYNCHRON, rPool);
2920
2921 //seen in tdf#122598, no parent for subsequent dialog
2922 SfxAllItemSet aSet(rPool);
2923 css::uno::Reference< css::frame::XFrame > xFrame =
2925 aSet.Put(SfxUnoFrameItem(SID_FILLFRAME, xFrame));
2926 aReq.SetInternalArgs_Impl(aSet);
2927
2928 aReq.AppendItem( SfxBoolItem(SID_RECORDMACRO,true) );
2929 const SfxPoolItem* pRet = SfxGetpApp()->ExecuteSlot( aReq );
2930 OUString aScriptURL;
2931 if ( pRet )
2932 aScriptURL = static_cast<const SfxStringItem*>(pRet)->GetValue();
2933 if ( !aScriptURL.isEmpty() )
2934 {
2935 // parse scriptURL
2936 OUString aLibName;
2937 OUString aModuleName;
2938 OUString aMacroName;
2939 OUString aLocation;
2940 Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
2941 Reference< css::uri::XUriReferenceFactory > xFactory =
2942 css::uri::UriReferenceFactory::create( xContext );
2943 Reference< css::uri::XVndSunStarScriptUrl > xUrl( xFactory->parse( aScriptURL ), UNO_QUERY );
2944 if ( xUrl.is() )
2945 {
2946 // get name
2947 const OUString aName = xUrl->getName();
2948 const sal_Unicode cTok = '.';
2949 sal_Int32 nIndex = 0;
2950 aLibName = aName.getToken( 0, cTok, nIndex );
2951 if ( nIndex != -1 )
2952 aModuleName = aName.getToken( 0, cTok, nIndex );
2953 if ( nIndex != -1 )
2954 aMacroName = aName.getToken( 0, cTok, nIndex );
2955
2956 // get location
2957 aLocation = xUrl->getParameter( "location" );
2958 }
2959
2960 BasicManager* pBasMgr = nullptr;
2961 if ( aLocation == "application" )
2962 {
2963 // application basic
2965 }
2966 else if ( aLocation == "document" )
2967 {
2968 pBasMgr = GetObjectShell()->GetBasicManager();
2969 }
2970
2971 OUString aOUSource;
2972 if ( pBasMgr)
2973 {
2974 StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
2975 if ( pBasic )
2976 {
2977 SbModule* pModule = pBasic->FindModule( aModuleName );
2978 SbMethod* pMethod = pModule ? pModule->FindMethod(aMacroName, SbxClassType::Method) : nullptr;
2979 if (pMethod)
2980 {
2981 aOUSource = pModule->GetSource32();
2982 sal_uInt16 nStart, nEnd;
2983 pMethod->GetLineRange( nStart, nEnd );
2984 sal_uInt16 nlStart = nStart;
2985 sal_uInt16 nlEnd = nEnd;
2986 CutLines( aOUSource, nlStart-1, nlEnd-nlStart+1 );
2987 }
2988 }
2989 }
2990
2991 // open lib container and break operation if it couldn't be opened
2992 css::uno::Reference< css::script::XLibraryContainer > xLibCont;
2993 if ( aLocation == "application" )
2994 {
2995 xLibCont = SfxGetpApp()->GetBasicContainer();
2996 }
2997 else if ( aLocation == "document" )
2998 {
2999 xLibCont = GetObjectShell()->GetBasicContainer();
3000 }
3001
3002 if(!xLibCont.is())
3003 {
3004 SAL_WARN("sfx.view", "couldn't get access to the basic lib container. Adding of macro isn't possible.");
3005 return;
3006 }
3007
3008 // get LibraryContainer
3009 css::uno::Any aTemp;
3010
3011 css::uno::Reference< css::container::XNameAccess > xLib;
3012 if(xLibCont->hasByName(aLibName))
3013 {
3014 // library must be loaded
3015 aTemp = xLibCont->getByName(aLibName);
3016 xLibCont->loadLibrary(aLibName);
3017 aTemp >>= xLib;
3018 }
3019 else
3020 {
3021 xLib = xLibCont->createLibrary(aLibName);
3022 }
3023
3024 // pack the macro as direct usable "sub" routine
3025 OUStringBuffer sRoutine(10000);
3026 bool bReplace = false;
3027
3028 // get module
3029 if(xLib->hasByName(aModuleName))
3030 {
3031 if ( !aOUSource.isEmpty() )
3032 {
3033 sRoutine.append( aOUSource );
3034 }
3035 else
3036 {
3037 OUString sCode;
3038 aTemp = xLib->getByName(aModuleName);
3039 aTemp >>= sCode;
3040 sRoutine.append( sCode );
3041 }
3042
3043 bReplace = true;
3044 }
3045
3046 // append new method
3047 sRoutine.append( "\nsub "
3048 + aMacroName
3049 + "\n"
3050 + sMacro
3051 + "\nend sub\n" );
3052
3053 // create the module inside the library and insert the macro routine
3054 aTemp <<= sRoutine.makeStringAndClear();
3055 if ( bReplace )
3056 {
3057 css::uno::Reference< css::container::XNameContainer > xModulCont(
3058 xLib,
3059 css::uno::UNO_QUERY);
3060 xModulCont->replaceByName(aModuleName,aTemp);
3061 }
3062 else
3063 {
3064 css::uno::Reference< css::container::XNameContainer > xModulCont(
3065 xLib,
3066 css::uno::UNO_QUERY);
3067 xModulCont->insertByName(aModuleName,aTemp);
3068 }
3069
3070 // #i17355# update the Basic IDE
3071 for ( SfxViewShell* pViewShell = SfxViewShell::GetFirst(); pViewShell; pViewShell = SfxViewShell::GetNext( *pViewShell ) )
3072 {
3073 if ( pViewShell->GetName() == "BasicIDE" )
3074 {
3075 SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
3076 SfxDispatcher* pDispat = rViewFrame.GetDispatcher();
3077 if ( pDispat )
3078 {
3079 SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLibName, aModuleName, OUString(), OUString() );
3080 pDispat->ExecuteList(SID_BASICIDE_UPDATEMODULESOURCE,
3081 SfxCallMode::SYNCHRON, { &aInfoItem });
3082 }
3083 }
3084 }
3085 }
3086 else
3087 {
3088 // add code for "session only" macro
3089 }
3090#endif
3091}
3092
3094{
3095 switch ( rReq.GetSlot() )
3096 {
3097 case SID_STOP_RECORDING :
3098 case SID_RECORDMACRO :
3099 {
3100 // try to find any active recorder on this frame
3101 static constexpr OUStringLiteral sProperty(u"DispatchRecorderSupplier");
3102 css::uno::Reference< css::frame::XFrame > xFrame =
3104
3105 css::uno::Reference< css::beans::XPropertySet > xSet(xFrame,css::uno::UNO_QUERY);
3106 css::uno::Any aProp = xSet->getPropertyValue(sProperty);
3107 css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
3108 aProp >>= xSupplier;
3109 css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
3110 if (xSupplier.is())
3111 xRecorder = xSupplier->getDispatchRecorder();
3112
3113 bool bIsRecording = xRecorder.is();
3114 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_RECORDMACRO);
3115 if ( pItem && pItem->GetValue() == bIsRecording )
3116 return;
3117
3118 if ( xRecorder.is() )
3119 {
3120 // disable active recording
3121 aProp <<= css::uno::Reference< css::frame::XDispatchRecorderSupplier >();
3122 xSet->setPropertyValue(sProperty,aProp);
3123
3124 const SfxBoolItem* pRecordItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
3125 if ( !pRecordItem || !pRecordItem->GetValue() )
3126 // insert script into basic library container of application
3127 AddDispatchMacroToBasic_Impl(xRecorder->getRecordedMacro());
3128
3129 xRecorder->endRecording();
3130 xRecorder = nullptr;
3131 GetBindings().SetRecorder_Impl( xRecorder );
3132
3133 SetChildWindow( SID_RECORDING_FLOATWINDOW, false );
3134 if ( rReq.GetSlot() != SID_RECORDMACRO )
3135 GetBindings().Invalidate( SID_RECORDMACRO );
3136 }
3137 else if ( rReq.GetSlot() == SID_RECORDMACRO )
3138 {
3139 // enable recording
3140 css::uno::Reference< css::uno::XComponentContext > xContext(
3141 ::comphelper::getProcessComponentContext());
3142
3143 xRecorder = css::frame::DispatchRecorder::create( xContext );
3144
3145 xSupplier = css::frame::DispatchRecorderSupplier::create( xContext );
3146
3147 xSupplier->setDispatchRecorder(xRecorder);
3148 xRecorder->startRecording(xFrame);
3149 aProp <<= xSupplier;
3150 xSet->setPropertyValue(sProperty,aProp);
3151 GetBindings().SetRecorder_Impl( xRecorder );
3152 SetChildWindow( SID_RECORDING_FLOATWINDOW, true );
3153 }
3154
3155 rReq.Done();
3156 break;
3157 }
3158
3159 case SID_TOGGLESTATUSBAR:
3160 {
3161 if ( auto xLayoutManager = getLayoutManager(GetFrame()) )
3162 {
3163 static constexpr OUStringLiteral aStatusbarResString( u"private:resource/statusbar/statusbar" );
3164 // Evaluate parameter.
3165 const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot());
3166 bool bShow( true );
3167 if ( !pShowItem )
3168 bShow = xLayoutManager->isElementVisible( aStatusbarResString );
3169 else
3170 bShow = pShowItem->GetValue();
3171
3172 if ( bShow )
3173 {
3174 xLayoutManager->createElement( aStatusbarResString );
3175 xLayoutManager->showElement( aStatusbarResString );
3176 }
3177 else
3178 xLayoutManager->hideElement( aStatusbarResString );
3179
3180 if ( !pShowItem )
3181 rReq.AppendItem( SfxBoolItem( SID_TOGGLESTATUSBAR, bShow ) );
3182 }
3183 rReq.Done();
3184 break;
3185 }
3186 case SID_COMMAND_POPUP:
3187 {
3188 tools::Rectangle aRectangle(Point(0,0), GetWindow().GetSizePixel());
3189 weld::Window* pParent = weld::GetPopupParent(GetWindow(), aRectangle);
3190 m_pCommandPopupHandler->showPopup(pParent, GetFrame().GetFrameInterface());
3191
3192 rReq.Done();
3193 break;
3194 }
3195 case SID_WIN_FULLSCREEN:
3196 {
3197 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot());
3198 SfxViewFrame *pTop = GetTopViewFrame();
3199 if ( pTop )
3200 {
3201 WorkWindow* pWork = static_cast<WorkWindow*>( pTop->GetFrame().GetTopWindow_Impl() );
3202 if ( pWork )
3203 {
3204 Reference< css::frame::XLayoutManager > xLayoutManager = getLayoutManager(GetFrame());
3205 bool bNewFullScreenMode = pItem ? pItem->GetValue() : !pWork->IsFullScreenMode();
3206 if ( bNewFullScreenMode != pWork->IsFullScreenMode() )
3207 {
3208 if ( bNewFullScreenMode )
3210 else
3212
3213 Reference< css::beans::XPropertySet > xLMPropSet( xLayoutManager, UNO_QUERY );
3214 if ( xLMPropSet.is() )
3215 {
3216 try
3217 {
3218 xLMPropSet->setPropertyValue(
3219 "HideCurrentUI",
3220 Any( bNewFullScreenMode ));
3221 }
3222 catch ( css::beans::UnknownPropertyException& )
3223 {
3224 }
3225 }
3226 pWork->ShowFullScreenMode( bNewFullScreenMode );
3227 pWork->SetMenuBarMode( bNewFullScreenMode ? MenuBarMode::Hide : MenuBarMode::Normal );
3228 GetFrame().GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode );
3229 if ( !pItem )
3230 rReq.AppendItem( SfxBoolItem( SID_WIN_FULLSCREEN, bNewFullScreenMode ) );
3231 rReq.Done();
3232 }
3233 else
3234 rReq.Ignore();
3235 }
3236 }
3237 else
3238 rReq.Ignore();
3239
3240 GetDispatcher()->Update_Impl( true );
3241 break;
3242 }
3243 }
3244}
3245
3247{
3248 const WhichRangesContainer & pRanges = rSet.GetRanges();
3249 DBG_ASSERT(!pRanges.empty(), "Set without range");
3250 for ( auto const & pRange : pRanges )
3251 {
3252 for(sal_uInt16 nWhich = pRange.first; nWhich <= pRange.second; ++nWhich)
3253 {
3254 switch(nWhich)
3255 {
3256 case SID_CURRENT_URL:
3257 {
3259 break;
3260 }
3261
3262 case SID_RECORDMACRO :
3263 {
3264 const OUString& sName{GetObjectShell()->GetFactory().GetFactoryName()};
3265 bool bMacrosDisabled = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
3266 if (bMacrosDisabled ||
3267 !officecfg::Office::Common::Misc::MacroRecorderMode::get() ||
3268 ( sName!="swriter" && sName!="scalc" ) )
3269 {
3270 rSet.DisableItem( nWhich );
3271 rSet.Put(SfxVisibilityItem(nWhich, false));
3272 break;
3273 }
3274
3275 css::uno::Reference< css::beans::XPropertySet > xSet(
3276 GetFrame().GetFrameInterface(),
3277 css::uno::UNO_QUERY);
3278
3279 css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier");
3280 css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
3281 if ( aProp >>= xSupplier )
3282 rSet.Put( SfxBoolItem( nWhich, xSupplier.is() ) );
3283 else
3284 rSet.DisableItem( nWhich );
3285 break;
3286 }
3287
3288 case SID_STOP_RECORDING :
3289 {
3290 const OUString& sName{GetObjectShell()->GetFactory().GetFactoryName()};
3291 if ( !officecfg::Office::Common::Misc::MacroRecorderMode::get() ||
3292 ( sName!="swriter" && sName!="scalc" ) )
3293 {
3294 rSet.DisableItem( nWhich );
3295 break;
3296 }
3297
3298 css::uno::Reference< css::beans::XPropertySet > xSet(
3299 GetFrame().GetFrameInterface(),
3300 css::uno::UNO_QUERY);
3301
3302 css::uno::Any aProp = xSet->getPropertyValue("DispatchRecorderSupplier");
3303 css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
3304 if ( !(aProp >>= xSupplier) || !xSupplier.is() )
3305 rSet.DisableItem( nWhich );
3306 break;
3307 }
3308
3309 case SID_TOGGLESTATUSBAR:
3310 {
3311 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
3312 css::uno::Reference< css::beans::XPropertySet > xSet(
3313 GetFrame().GetFrameInterface(),
3314 css::uno::UNO_QUERY);
3315 css::uno::Any aProp = xSet->getPropertyValue( "LayoutManager" );
3316
3317 if ( !( aProp >>= xLayoutManager ))
3318 rSet.Put( SfxBoolItem( nWhich, false ));
3319 else
3320 {
3321 bool bShow = xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" );
3322 rSet.Put( SfxBoolItem( nWhich, bShow ));
3323 }
3324 break;
3325 }
3326
3327 case SID_WIN_FULLSCREEN:
3328 {
3329 SfxViewFrame* pTop = GetTopViewFrame();
3330 if ( pTop )
3331 {
3332 WorkWindow* pWork = static_cast<WorkWindow*>( pTop->GetFrame().GetTopWindow_Impl() );
3333 if ( pWork )
3334 {
3335 rSet.Put( SfxBoolItem( nWhich, pWork->IsFullScreenMode() ) );
3336 break;
3337 }
3338 }
3339
3340 rSet.DisableItem( nWhich );
3341 break;
3342 }
3343
3344 default:
3345 break;
3346 }
3347 }
3348 }
3349}
3350
3351/* [Description]
3352
3353 This method can be included in the Execute method for the on- and off-
3354 switching of ChildWindows, to implement this and API-bindings.
3355
3356 Simply include as 'ExecuteMethod' in the IDL.
3357*/
3359{
3360 // Evaluate Parameter
3361 sal_uInt16 nSID = rReq.GetSlot();
3362
3363 if (nSID == SID_SIDEBAR_DECK)
3364 {
3365 const SfxStringItem* pDeckIdItem = rReq.GetArg<SfxStringItem>(SID_SIDEBAR_DECK);
3366 if (pDeckIdItem)
3367 {
3368 const OUString aDeckId(pDeckIdItem->GetValue());
3369 const SfxBoolItem* pToggleItem = rReq.GetArg<SfxBoolItem>(SID_SIDEBAR_DECK_TOGGLE);
3370 bool bToggle = pToggleItem && pToggleItem->GetValue();
3371 ::sfx2::sidebar::Sidebar::ShowDeck(aDeckId, this, bToggle);
3372 }
3373 rReq.Done();
3374 return;
3375 }
3376
3377 const SfxBoolItem* pShowItem = rReq.GetArg<SfxBoolItem>(nSID);
3378 if ( nSID == SID_VIEW_DATA_SOURCE_BROWSER )
3379 {
3381 return;
3382 Reference < XFrame > xFrame = GetFrame().GetFrameInterface();
3383 Reference < XFrame > xBeamer( xFrame->findFrame( "_beamer", FrameSearchFlag::CHILDREN ) );
3384 bool bHasChild = xBeamer.is();
3385 bool bShow = pShowItem ? pShowItem->GetValue() : !bHasChild;
3386 if ( pShowItem )
3387 {
3388 if( bShow == bHasChild )
3389 return;
3390 }
3391 else
3392 rReq.AppendItem( SfxBoolItem( nSID, bShow ) );
3393
3394 if ( !bShow )
3395 {
3396 SetChildWindow( SID_BROWSER, false );
3397 }
3398 else
3399 {
3400 css::util::URL aTargetURL;
3401 aTargetURL.Complete = ".component:DB/DataSourceBrowser";
3402 Reference < css::util::XURLTransformer > xTrans(
3403 css::util::URLTransformer::create(
3404 ::comphelper::getProcessComponentContext() ) );
3405 xTrans->parseStrict( aTargetURL );
3406
3407 Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
3408 Reference < css::frame::XDispatch > xDisp;
3409 if ( xProv.is() )
3410 xDisp = xProv->queryDispatch( aTargetURL, "_beamer", 31 );
3411 if ( xDisp.is() )
3412 {
3413 Sequence < css::beans::PropertyValue > aArgs(1);
3414 css::beans::PropertyValue* pArg = aArgs.getArray();
3415 pArg[0].Name = "Referer";
3416 pArg[0].Value <<= OUString("private:user");
3417 xDisp->dispatch( aTargetURL, aArgs );
3418 }
3419 }
3420
3421 rReq.Done();
3422 return;
3423 }
3424 if (nSID == SID_STYLE_DESIGNER)
3425 {
3426 // First make sure that the sidebar is visible
3427 ShowChildWindow(SID_SIDEBAR);
3428
3429 ::sfx2::sidebar::Sidebar::ShowPanel(u"StyleListPanel",
3430 GetFrame().GetFrameInterface(), true);
3431 rReq.Done();
3432 return;
3433 }
3434 if (nSID == SID_NAVIGATOR)
3435 {
3437 {
3438 ShowChildWindow(SID_SIDEBAR);
3439 ::sfx2::sidebar::Sidebar::ShowDeck(u"NavigatorDeck", this, true);
3440 rReq.Done();
3441 return;
3442 }
3443 }
3444
3445 bool bHasChild = HasChildWindow(nSID);
3446 bool bShow = pShowItem ? pShowItem->GetValue() : !bHasChild;
3447 GetDispatcher()->Update_Impl( true );
3448
3449 // Perform action.
3450 if ( !pShowItem || bShow != bHasChild )
3451 ToggleChildWindow( nSID );
3452
3453 GetBindings().Invalidate( nSID );
3454
3455 // Record if possible.
3456 if ( nSID == SID_HYPERLINK_DIALOG || nSID == SID_SEARCH_DLG )
3457 {
3458 rReq.Ignore();
3459 }
3460 else
3461 {
3462 rReq.AppendItem( SfxBoolItem( nSID, bShow ) );
3463 rReq.Done();
3464 }
3465}
3466
3467/* [Description]
3468
3469 This method can be used in the state method for the on and off-state
3470 of child-windows, in order to implement this.
3471
3472 Just register the IDL as 'StateMethod'.
3473*/
3475{
3476 SfxWhichIter aIter( rState );
3477 for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
3478 {
3479 if ( nSID == SID_VIEW_DATA_SOURCE_BROWSER )
3480 {
3481 rState.Put( SfxBoolItem( nSID, HasChildWindow( SID_BROWSER ) ) );
3482 }
3483 else if ( nSID == SID_HYPERLINK_DIALOG )
3484 {
3485 const SfxPoolItem* pDummy = nullptr;
3486 SfxItemState eState = GetDispatcher()->QueryState( SID_HYPERLINK_SETLINK, pDummy );
3487 if ( SfxItemState::DISABLED == eState )
3488 rState.DisableItem(nSID);
3489 else
3490 {
3491 if ( KnowsChildWindow(nSID) )
3492 rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID)) );
3493 else
3494 rState.DisableItem(nSID);
3495 }
3496 }
3497 else if ( nSID == SID_BROWSER )
3498 {
3499 Reference < XFrame > xFrame = GetFrame().GetFrameInterface()->
3500 findFrame( "_beamer", FrameSearchFlag::CHILDREN );
3501 if ( !xFrame.is() )
3502 rState.DisableItem( nSID );
3503 else if ( KnowsChildWindow(nSID) )
3504 rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
3505 }
3506 else if ( nSID == SID_SIDEBAR )
3507 {
3508 if ( !KnowsChildWindow( nSID ) )
3509 {
3510 SAL_INFO("sfx.view", "SID_SIDEBAR state requested, but no task pane child window exists for this ID!");
3511 rState.DisableItem( nSID );
3512 }
3513 else
3514 {
3515 rState.Put( SfxBoolItem( nSID, HasChildWindow( nSID ) ) );
3516 }
3517 }
3518 else if ( KnowsChildWindow(nSID) )
3519 rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
3520 else
3521 rState.DisableItem(nSID);
3522 }
3523}
3524
3526{
3528 return pWork;
3529}
3530
3531void SfxViewFrame::SetChildWindow(sal_uInt16 nId, bool bOn, bool bSetFocus )
3532{
3534 if ( pWork )
3535 pWork->SetChildWindow_Impl( nId, bOn, bSetFocus );
3536}
3537
3539{
3541 if ( pWork )
3542 pWork->ToggleChildWindow_Impl( nId, true );
3543}
3544
3545bool SfxViewFrame::HasChildWindow( sal_uInt16 nId )
3546{
3548 return pWork && pWork->HasChildWindow_Impl(nId);
3549}
3550
3552{
3554 return pWork && pWork->KnowsChildWindow_Impl(nId);
3555}
3556
3557void SfxViewFrame::ShowChildWindow( sal_uInt16 nId, bool bVisible )
3558{
3560 if ( pWork )
3561 {
3562 GetDispatcher()->Update_Impl(true);
3563 pWork->ShowChildWindow_Impl(nId, bVisible, true );
3564 }
3565}
3566
3568{
3570 return pWork ? pWork->GetChildWindow_Impl(nId) : nullptr;
3571}
3572
3574{
3576 if ( pDoc->IsLoadingFinished() )
3578
3579 // check if document depends on a template
3581}
3582
3584{
3585 if(pFrame)
3586 SetSVHelpData(pFrame->m_pHelpData);
3587
3588 SetSVWinData(pFrame ? pFrame->m_pWinData : nullptr);
3589
3590 SfxGetpApp()->SetViewFrame_Impl( pFrame );
3591}
3592
3594 const OUString& sPrimaryMessage,
3595 const OUString& sSecondaryMessage,
3596 InfobarType aInfobarType, bool bShowCloseButton)
3597{
3598 SfxChildWindow* pChild = GetChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
3599 if (!pChild)
3600 return nullptr;
3601
3602 if (HasInfoBarWithID(sId))
3603 return nullptr;
3604
3605 SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
3606 auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sPrimaryMessage, sSecondaryMessage,
3607 aInfobarType, bShowCloseButton);
3608 ShowChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
3609 return pInfoBar;
3610}
3611
3612void SfxViewFrame::UpdateInfoBar(std::u16string_view sId, const OUString& sPrimaryMessage,
3613 const OUString& sSecondaryMessage, InfobarType eType)
3614{
3615 const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
3616
3617 // Make sure the InfoBar container is visible
3618 if (!HasChildWindow(nId))
3620
3622 if (pChild)
3623 {
3624 SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
3625 auto pInfoBar = pInfoBarContainer->getInfoBar(sId);
3626
3627 if (pInfoBar)
3628 pInfoBar->Update(sPrimaryMessage, sSecondaryMessage, eType);
3629 }
3630}
3631
3632void SfxViewFrame::RemoveInfoBar( std::u16string_view sId )
3633{
3634 const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
3635
3636 // Make sure the InfoBar container is visible
3637 if (!HasChildWindow(nId))
3639
3641 if (pChild)
3642 {
3643 SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
3644 auto pInfoBar = pInfoBarContainer->getInfoBar(sId);
3645 pInfoBarContainer->removeInfoBar(pInfoBar);
3647 }
3648}
3649
3650bool SfxViewFrame::HasInfoBarWithID( std::u16string_view sId )
3651{
3652 const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
3653
3655 if (pChild)
3656 {
3657 SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
3658 return pInfoBarContainer->hasInfoBarWithID(sId);
3659 }
3660
3661 return false;
3662}
3663
3664/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
SfxApplication * SfxGetpApp()
Definition: app.hxx:231
static BasicDLL * pBasic
Definition: appdata.cxx:44
constexpr OUStringLiteral sViewId
Definition: appuno.cxx:102
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
Definition: appuno.cxx:908
std::unique_ptr< weld::MessageDialog > m_xQueryBox
static sal_uInt16 GetCommandLineParamCount()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static Help * GetHelp()
static OUString GetCommandLineParam(sal_uInt16 nParam)
static bool IsHeadlessModeEnabled()
StarBASIC * GetLib(sal_uInt16 nLib) const
sal_Int32 GetValue() const
sal_uInt16 GetValue() const
const OUString & GetValue() const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static OUString GetEventName(GlobalEventId nID)
bool isAnyKnownWebDAVScheme() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetProtocol GetProtocol() const
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
sal_uInt16 GetFreeIndex()
Definition: bitset.cxx:95
OUString msId
Definition: infobar.hxx:32
OUString msPrimaryMessage
Definition: infobar.hxx:33
bool mbShowCloseButton
Definition: infobar.hxx:36
InfobarType maInfobarType
Definition: infobar.hxx:35
OUString msSecondaryMessage
Definition: infobar.hxx:34
void GetLineRange(sal_uInt16 &, sal_uInt16 &)
SbMethod * FindMethod(const OUString &, SbxClassType)
const OUString & GetSource32() const
SfxViewFrame * pViewFrame
Definition: appdata.hxx:109
SAL_DLLPRIVATE SfxAppData_Impl * Get_Impl() const
Definition: app.hxx:169
SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame)
Definition: app.cxx:234
static SfxApplication * Get()
Definition: app.cxx:70
css::script::XLibraryContainer * GetBasicContainer()
Definition: appbas.cxx:87
SAL_DLLPRIVATE std::vector< SfxViewFrame * > & GetViewFrames_Impl() const
Definition: app.cxx:360
static bool IsHeadlessOrUITest()
if true then dialog/infobar notifications like the tip of the day or version change infobar should be...
Definition: viewfrm.cxx:1404
static BasicManager * GetBasicManager()
Definition: appbas.cxx:62
void NotifyEvent(const SfxEventHint &rEvent, bool bSynchron=true)
Definition: appcfg.cxx:338
static bool IsTipOfTheDayDue()
Definition: viewfrm.cxx:1421
void Invalidate(sal_uInt16 nId)
Definition: bindings.cxx:639
SAL_DLLPRIVATE void SetRecorder_Impl(css::uno::Reference< css::frame::XDispatchRecorder > const &)
Definition: bindings.cxx:1739
void SetActiveFrame(const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: bindings.cxx:1703
void SetDispatcher(SfxDispatcher *pDisp)
Definition: bindings.cxx:1420
void InvalidateAll(bool bWithMsg)
Definition: bindings.cxx:498
bool GetValue() const
void Broadcast(const SfxHint &rHint)
vcl::Window * GetWindow() const
Definition: childwin.hxx:117
Shared code to handle Business Authorization Identification and Labeling Scheme (BAILS) properties.
static bool IsClassified(const css::uno::Reference< css::document::XDocumentProperties > &xDocumentProperties)
Does the document have any BAILS properties?
SAL_DLLPRIVATE void Update_Impl(bool bForce=false)
Definition: dispatch.cxx:1034
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
Method to execute a <SfxSlot>s over the Slot-Id.
Definition: dispatch.cxx:833
SAL_DLLPRIVATE void SetQuietMode_Impl(bool bOn)
With 'bOn' the Dispatcher is quasi dead and transfers everything to the Parent-Dispatcher.
Definition: dispatch.cxx:1962
SfxBindings * GetBindings() const
This method returns a pointer to the <SfxBinding> Instance on which the SfxDispatcher is currently bo...
Definition: dispatch.cxx:545
void SetDisableFlags(SfxDisableFlags nFlags)
Definition: dispatch.cxx:2078
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
Method to execute a <SfxSlot>s over the Slot-Id.
Definition: dispatch.cxx:931
SAL_DLLPRIVATE bool IsUpdated_Impl() const
Definition: dispatch.cxx:2073
SAL_DLLPRIVATE void SetReadOnly_Impl(bool bOn)
Definition: dispatch.cxx:1949
void Lock(bool bLock)
With this method the SfxDispatcher can be locked and released.
Definition: dispatch.cxx:1895
SfxShell * GetShell(sal_uInt16 nIdx) const
Returns a pointer to the <SfxShell> which is at the position nIdx (from the top, last pushed is 0) on...
Definition: dispatch.cxx:529
SAL_DLLPRIVATE bool GetReadOnly_Impl() const
Definition: dispatch.cxx:1954
SfxItemState QueryState(sal_uInt16 nSID, const SfxPoolItem *&rpState)
Definition: dispatch.cxx:1970
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
Definition: fltfnc.cxx:341
SfxFrame * GetFrame() const
Definition: frame.hxx:166
void Appear()
Definition: frame.cxx:528
SAL_DLLPRIVATE void SetOwnsBindings_Impl(bool bSet)
Definition: frame.cxx:548
SAL_DLLPRIVATE void GetViewData_Impl()
Definition: frame.cxx:272
SAL_DLLPRIVATE void CreateWorkWindow_Impl()
Definition: frame.cxx:593
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
SAL_DLLPRIVATE void GrabFocusOnComponent_Impl()
Definition: frame.cxx:636
SAL_DLLPRIVATE SystemWindow * GetTopWindow_Impl() const
Definition: frame2.cxx:341
SAL_DLLPRIVATE void SetHasTitle(bool)
Definition: frame.cxx:267
SAL_DLLPRIVATE void ReleasingComponent_Impl()
Definition: frame.cxx:652
SAL_DLLPRIVATE bool DocIsModified_Impl()
Definition: frame.cxx:149
SAL_DLLPRIVATE SfxWorkWindow * GetWorkWindow_Impl() const
Definition: frame.cxx:588
SAL_DLLPRIVATE bool IsAutoLoadLocked_Impl() const
Definition: frame.cxx:239
SAL_DLLPRIVATE void SetCurrentViewFrame_Impl(SfxViewFrame *)
Definition: frame.cxx:257
bool DoClose()
Definition: frame.cxx:89
vcl::Window & GetWindow() const
Definition: frame.hxx:85
SAL_WARN_UNUSED_RESULT SfxViewFrame * GetCurrentViewFrame() const
Definition: frame.cxx:234
SfxHintId GetId() const
bool IsObjectUIActive() const
Definition: ipclient.cxx:844
void DeactivateObject()
Definition: ipclient.cxx:1062
VclPtr< SfxInfoBarWindow > appendInfoBar(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType ibType, bool bShowCloseButton)
Definition: infobar.cxx:371
bool hasInfoBarWithID(std::u16string_view sId)
Definition: infobar.cxx:405
void removeInfoBar(VclPtr< SfxInfoBarWindow > const &pInfoBar)
Definition: infobar.cxx:410
VclPtr< SfxInfoBarWindow > getInfoBar(std::u16string_view sId)
Definition: infobar.cxx:395
sal_Int16 GetValue() const
const WhichRangesContainer & GetRanges() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
bool IsExpired() const
Definition: docfile.cxx:3618
void SetOpenMode(StreamMode nStorOpen, bool bDontClose=false)
Definition: docfile.cxx:1962
const std::shared_ptr< const SfxFilter > & GetFilter() const
Definition: docfile.cxx:3111
void ResetError()
Definition: docfile.cxx:483
const INetURLObject & GetURLObject() const
Definition: docfile.cxx:3597
void CloseAndRelease()
Definition: docfile.cxx:3149
SfxItemSet & GetItemSet() const
Definition: docfile.cxx:3647
LockFileResult LockOrigFileOnDemand(bool bLoading, bool bNoUI, bool bTryIgnoreLockFile=false, LockFileEntry *pLockData=nullptr)
Definition: docfile.cxx:1293
ErrCode GetErrorCode() const
Definition: docfile.cxx:512
static sal_uInt32 CreatePasswordToModifyHash(std::u16string_view aPasswd, bool bWriter)
Definition: docfile.cxx:3116
const OUString & GetOrigURL() const
Definition: docfile.cxx:3364
const OUString & GetName() const
Definition: docfile.cxx:3592
const std::shared_ptr< std::recursive_mutex > & GetCheckEditableMutex() const
Definition: docfile.cxx:4545
void CancelCheckEditableEntry(bool bRemoveEvent=true)
Definition: docfile.cxx:4614
bool IsRemote() const
Definition: docfile.cxx:2914
SAL_DLLPRIVATE bool HasStorage_Impl() const
Definition: docfile.cxx:4327
void ReOpen()
Definition: docfile.cxx:3385
void CompleteReOpen()
Definition: docfile.cxx:3393
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
Definition: docfile.cxx:1703
void AddToCheckEditableWorkerList()
Definition: docfile.cxx:4563
const OUString & GetPhysicalName() const
Definition: docfile.cxx:809
css::uno::Reference< css::task::XInteractionHandler > GetInteractionHandler(bool bGetAlways=false)
Definition: docfile.cxx:3076
const OUString & GetFactoryName() const
Definition: docfac.hxx:52
SfxViewFactory * GetViewFactoryByViewName(std::u16string_view i_rViewName) const
returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical nam...
Definition: docfac.cxx:339
SfxViewFactory & GetViewFactory(sal_uInt16 i=0) const
Definition: docfac.cxx:117
SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl(const SfxInterfaceId i_nViewId, const sal_uInt16 i_nFallback) const
Definition: docfac.cxx:328
bool Is() const
Definition: objsh.hxx:847
static SfxObjectShell * CreateObject(const OUString &rServiceName, SfxObjectCreateMode=SfxObjectCreateMode::STANDARD)
Definition: objxtor.cxx:996
SAL_DLLPRIVATE void SetModifyPasswordEntered(bool bEntered=true)
Definition: objcont.cxx:716
bool IsOriginallyReadOnlyMedium() const
Definition: objmisc.cxx:362
bool DoClose()
Definition: objxtor.cxx:818
bool isEditDocLocked() const
Definition: objmisc.cxx:1884
virtual bool PrepareClose(bool bUI=true)
Definition: objxtor.cxx:506
virtual void CancelTransfers()
Definition: objmisc.cxx:1264
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
Definition: objxtor.cxx:731
SAL_DLLPRIVATE void SetNamedVisibility_Impl()
Definition: objmisc.cxx:855
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
Definition: objstor.cxx:1945
virtual SfxObjectShell * GetObjectShell() override
Definition: objxtor.cxx:824
SAL_DLLPRIVATE bool CanReload_Impl()
Definition: objstor.cxx:3059
bool IsInModalMode() const
Definition: objmisc.cxx:422
bool IsLoadingFinished() const
Definition: objmisc.cxx:1033
bool IsReadOnlyMedium() const
Definition: objmisc.cxx:349
OUString GetSharedFileURL() const
Definition: objmisc.cxx:644
sal_uInt32 GetModifyPasswordHash() const
Definition: objcont.cxx:678
SfxProgress * GetProgress() const
Definition: objmisc.cxx:877
BasicManager * GetBasicManager() const
Definition: objxtor.cxx:644
bool HasName() const
Definition: objsh.hxx:266
bool IsEnableSetModified() const
Definition: objmisc.cxx:248
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
Definition: objxtor.cxx:452
virtual SfxObjectFactory & GetFactory() const =0
bool IsReadOnly() const
Definition: objmisc.cxx:416
bool IsOriginallyLoadedReadOnlyMedium() const
Definition: objmisc.cxx:367
bool IsReadOnlyUI() const
Definition: objmisc.cxx:336
bool IsDocShared() const
Definition: objmisc.cxx:634
bool IsModified() const
Definition: objmisc.cxx:259
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
Definition: objsh.hxx:718
SfxMedium * GetMedium() const
Definition: objsh.hxx:261
void SetReadOnlyUI(bool bReadOnly=true)
Definition: objmisc.cxx:373
SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl()
Definition: objmisc.cxx:944
css::uno::Reference< css::frame::XModel3 > GetModel() const
Definition: objxtor.cxx:838
css::uno::Reference< css::embed::XStorage > const & GetStorage()
Definition: objstor.cxx:3260
SAL_DLLPRIVATE void UpdateFromTemplate_Impl()
Definition: objcont.cxx:435
void EnableSetModified(bool bEnable=true)
Definition: objmisc.cxx:241
SAL_DLLPRIVATE IndexBitSet & GetNoSet_Impl()
Definition: objmisc.cxx:659
css::uno::Reference< css::security::XCertificate > GetSignPDFCertificate() const
Gets the certificate that is already picked by the user but not yet used for signing.
Definition: objserv.cxx:415
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
Definition: objxtor.cxx:427
SfxObjectCreateMode GetCreateMode() const
Definition: objsh.hxx:487
SAL_DLLPRIVATE bool IsModifyPasswordEntered() const
Definition: objcont.cxx:721
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
Definition: objcont.cxx:697
SAL_DLLPRIVATE bool ConnectTmpStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xStorage, SfxMedium *pMedium)
Definition: objstor.cxx:1801
SAL_DLLPRIVATE void DoNotCleanShareControlFile()
void SetReadOnly()
Definition: objmisc.cxx:390
virtual void SetModified(bool bModified=true)
Definition: objmisc.cxx:301
virtual bool operator==(const SfxPoolItem &) const=0
sal_uInt16 GetSlot() const
Definition: request.hxx:68
void Ignore()
Definition: request.cxx:521
const SfxItemSet * GetArgs() const
Definition: request.hxx:75
const T * GetArg(sal_uInt16 nSlotId) const
Templatized access to the individual parameters of the SfxRequest.
Definition: request.hxx:84
void AppendItem(const SfxPoolItem &)
Definition: request.cxx:404
void SetReturnValue(const SfxPoolItem &)
Definition: request.cxx:422
bool IsAPI() const
Definition: request.cxx:705
void SetInternalArgs_Impl(const SfxAllItemSet &rArgs)
Definition: request.cxx:309
void Done(bool bRemove=false)
Definition: request.cxx:484
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
This method returns the status of the slot with the specified slot ID on the specified interface.
Definition: shell.cxx:462
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
Definition: shell.hxx:511
void SetViewShell_Impl(SfxViewShell *pView)
Definition: shell.cxx:708
SfxRepeatTarget * GetRepeatTarget() const
Returns a pointer to the <SfxRepeatTarget> instance that is used in SID_REPEAT as repeat target when ...
Definition: shell.cxx:224
virtual bool IsDesignMode() const
Definition: shell.hxx:337
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
This method allows you to forward a <SfxRequest> to the specified base <SfxShell>.
Definition: shell.cxx:438
virtual SfxUndoManager * GetUndoManager()
Each Subclass of SfxShell can have a <SfxUndoManager>.
Definition: shell.cxx:203
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
Definition: shell.cxx:129
void SetPool(SfxItemPool *pNewPool)
With this method, the subclasses register their special <SfxItemPool> in the SfxShell.
Definition: shell.hxx:525
virtual ViewShellId GetViewShellId() const
virtual bool Undo()
virtual void Clear()
SfxUndoAction * GetRedoAction(size_t nNo=0) const
OUString GetRedoActionComment(size_t nNo=0, bool const i_currentLevel=CurrentLevel) const
OUString GetUndoActionComment(size_t nNo=0, bool const i_currentLevel=CurrentLevel) const
bool CanRepeat(SfxRepeatTarget &rTarget) const
bool Repeat(SfxRepeatTarget &rTarget)
virtual bool Redo()
virtual size_t GetRedoActionCount(bool const i_currentLevel=CurrentLevel) const
OUString GetRepeatActionComment(SfxRepeatTarget &rTarget) const
size_t GetRepeatActionCount() const
virtual size_t GetUndoActionCount(bool const i_currentLevel=CurrentLevel) const
SfxUndoAction * GetUndoAction(size_t nNo=0) const
const css::uno::Reference< css::frame::XFrame > & GetFrame() const
Definition: frame.hxx:193
OUString GetAPIViewName() const
returns an API-compatible view name.
Definition: viewfac.cxx:34
SfxInterfaceId GetOrdinal() const
Definition: viewfac.hxx:40
virtual bool operator==(const SfxPoolItem &) const override
Definition: viewfrm.cxx:2063
SfxViewFrame * pFrame
Definition: viewfrm.hxx:264
virtual SfxViewFrameItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: viewfrm.cxx:2069
SfxViewFrameItem(SfxViewFrame *pViewFrame)
Definition: viewfrm.hxx:267
void LockAdjustPosSizePixel()
Definition: viewfrm.hxx:117
ImplSVHelpData * m_pHelpData
Definition: viewfrm.hxx:56
SAL_DLLPRIVATE const SvBorder & GetBorderPixelImpl() const
Definition: viewfrm.cxx:1259
SAL_DLLPRIVATE void InvalidateBorderImpl(const SfxViewShell *pSh)
Definition: viewfrm.cxx:1202
SfxViewFrame(SfxFrame &rFrame, SfxObjectShell *pDoc)
Definition: viewfrm.cxx:1899
SAL_DLLPRIVATE void StateHistory_Impl(SfxItemSet &rSet)
Definition: viewfrm.cxx:1023
SAL_DLLPRIVATE void UpdateDocument_Impl()
Definition: viewfrm.cxx:3573
static SAL_DLLPRIVATE SfxViewShell * LoadViewIntoFrame_Impl(const SfxObjectShell &i_rDoc, const css::uno::Reference< css::frame::XFrame > &i_rFrame, const css::uno::Sequence< css::beans::PropertyValue > &i_rLoadArgs, const SfxInterfaceId i_nViewId, const bool i_bHidden)
loads the given existing document into the given frame
Definition: viewfrm.cxx:2298
SAL_DLLPRIVATE void SaveCurrentViewData_Impl(const SfxInterfaceId i_nNewViewId)
Definition: viewfrm.cxx:2388
void DoDeactivate(bool bMDI, SfxViewFrame const *pOld)
Definition: viewfrm.cxx:1197
void ToggleChildWindow(sal_uInt16)
Definition: viewfrm.cxx:3538
static SfxViewFrame * LoadDocument(SfxObjectShell const &i_rDoc, SfxInterfaceId i_nViewId)
Definition: viewfrm.cxx:2328
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
Definition: viewfrm.cxx:1975
void SetModalMode(bool)
Definition: viewfrm.cxx:2814
void RemoveInfoBar(std::u16string_view sId)
Definition: viewfrm.cxx:3632
SAL_DLLPRIVATE bool SwitchToViewShell_Impl(sal_uInt16 nNo, bool bIsIndex=false)
Definition: viewfrm.cxx:2470
static SAL_DLLPRIVATE SfxViewFrame * LoadViewIntoFrame_Impl_NoThrow(const SfxObjectShell &i_rDoc, const css::uno::Reference< css::frame::XFrame > &i_rFrame, const SfxInterfaceId i_nViewId, const bool i_bHidden)
loads the given existing document into the given frame
Definition: viewfrm.cxx:2228
vcl::Window & GetWindow() const
Definition: viewfrm.cxx:2792
void ExecReload_Impl(SfxRequest &rReq)
Definition: viewfrm.cxx:275
SAL_DLLPRIVATE void SetViewShell_Impl(SfxViewShell *pVSh)
Definition: viewfrm.cxx:2074
SAL_DLLPRIVATE void KillDispatcher_Impl()
Definition: viewfrm.cxx:1959
bool DoClose()
Definition: viewfrm.cxx:2802
bool IsInModalMode() const
Definition: viewfrm.cxx:2830
SAL_DLLPRIVATE void GetDocNumber_Impl()
Definition: viewfrm.cxx:2093
SfxBindings & GetBindings()
Definition: viewfrm.hxx:110
SAL_DLLPRIVATE void LockObjectShell_Impl()
Definition: viewfrm.cxx:2168
SAL_DLLPRIVATE void SetBorderPixelImpl(const SfxViewShell *pSh, const SvBorder &rBorder)
Definition: viewfrm.cxx:1221
static SfxViewFrame * LoadDocumentIntoFrame(SfxObjectShell const &i_rDoc, const SfxFrameItem *i_pFrameItem, SfxInterfaceId i_nViewId)
Definition: viewfrm.cxx:2338
SAL_DLLPRIVATE void StateView_Impl(SfxItemSet &rSet)
Definition: viewfrm.cxx:2710
void ToTop()
Definition: viewfrm.cxx:2772
bool HasChildWindow(sal_uInt16)
Definition: viewfrm.cxx:3545
void Resize(bool bForce=false)
Definition: viewfrm.cxx:2835
void AppendReadOnlyInfobar()
Definition: viewfrm.cxx:1264
SfxProgress * GetProgress() const
Definition: viewfrm.cxx:2036
SfxInterfaceId GetCurViewId() const
Definition: viewfrm.cxx:2547
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
Definition: viewfrm.cxx:3531
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
Definition: viewfrm.cxx:2006
SfxDispatcher * GetDispatcher()
Definition: viewfrm.hxx:109
std::unique_ptr< CommandPopupHandler > m_pCommandPopupHandler
Definition: viewfrm.hxx:60
SAL_DLLPRIVATE void ExecHistory_Impl(SfxRequest &rReq)
Definition: viewfrm.cxx:974
SfxViewFrame * GetTopViewFrame() const
Definition: viewfrm.cxx:2787
SfxChildWindow * GetChildWindow(sal_uInt16)
Definition: viewfrm.cxx:3567
SAL_DLLPRIVATE SfxWorkWindow * GetWorkWindow_Impl()
Definition: viewfrm.cxx:3525
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
Definition: viewfrm.cxx:1983
SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const OUString &sMacro)
Definition: viewfrm.cxx:2909
void DoActivate(bool bMDI)
Definition: viewfrm.cxx:1192
SAL_DLLPRIVATE void ReleaseObjectShell_Impl()
Definition: viewfrm.cxx:1121
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2782
virtual SfxObjectShell * GetObjectShell() override
Definition: viewfrm.cxx:2218
SAL_DLLPRIVATE OUString GetActualPresentationURL_Impl() const
Definition: viewfrm.cxx:2807
weld::Window * GetFrameWeld() const
Definition: viewfrm.cxx:2797
SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &)
Definition: viewfrm.cxx:3093
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Get(const css::uno::Reference< css::frame::XController > &i_rController, const SfxObjectShell *i_pDoc)
Definition: viewfrm.cxx:2356
sal_uInt16 m_nAdjustPosPixelLock
Definition: viewfrm.hxx:58
SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &)
Definition: viewfrm.cxx:3246
bool HasInfoBarWithID(std::u16string_view sId)
Definition: viewfrm.cxx:3650
void Close()
Definition: viewfrm.cxx:1172
virtual ~SfxViewFrame() override
Definition: viewfrm.cxx:1921
bool KnowsChildWindow(sal_uInt16)
Definition: viewfrm.cxx:3551
SAL_DLLPRIVATE void ForceOuterResize_Impl()
Definition: viewfrm.cxx:2088
SAL_DLLPRIVATE void PopShellAndSubShells_Impl(SfxViewShell &i_rViewShell)
Definition: viewfrm.cxx:1087
SAL_DLLPRIVATE const Size & GetMargin_Impl() const
Definition: viewfrm.cxx:2223
void DoAdjustPosSizePixel(SfxViewShell *pSh, const Point &rPos, const Size &rSize, bool inplaceEditModeChange)
divide on Inner.../Outer...
Definition: viewfrm.cxx:2043
SfxObjectShellRef m_xObjSh
Definition: viewfrm.hxx:53
VclPtr< SfxInfoBarWindow > AppendInfoBar(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType aInfobarType, bool bShowCloseButton=true)
Append a new InfoBar (see https://wiki.documentfoundation.org/Design/Whiteboards/Infobar).
Definition: viewfrm.cxx:3593
SAL_DLLPRIVATE void StateReload_Impl(SfxItemSet &rSet)
Definition: viewfrm.cxx:914
void UpdateTitle()
Definition: viewfrm2.cxx:76
void ChildWindowState(SfxItemSet &)
Definition: viewfrm.cxx:3474
void Show()
Definition: viewfrm.cxx:2135
static SfxViewFrame * LoadHiddenDocument(SfxObjectShell const &i_rDoc, SfxInterfaceId i_nViewId)
Definition: viewfrm.cxx:2323
void AppendContainsMacrosInfobar()
Definition: viewfrm.cxx:1310
std::unique_ptr< SfxDispatcher > m_pDispatcher
Definition: viewfrm.hxx:54
bool IsVisible() const
Definition: viewfrm.cxx:2162
SAL_DLLPRIVATE void Construct_Impl(SfxObjectShell *pObjSh)
Definition: viewfrm.cxx:1846
void Enable(bool bEnable)
Definition: viewfrm.cxx:2100
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: viewfrm.cxx:1435
SAL_DLLPRIVATE void MakeActive_Impl(bool bActivate)
Definition: viewfrm.cxx:2178
static SfxViewFrame * DisplayNewDocument(SfxObjectShell const &i_rDoc, const SfxRequest &i_rCreateDocRequest)
Definition: viewfrm.cxx:2343
void ShowChildWindow(sal_uInt16, bool bVisible=true)
Definition: viewfrm.cxx:3557
static void SetViewFrame(SfxViewFrame *)
Definition: viewfrm.cxx:3583
ImplSVWinData * m_pWinData
Definition: viewfrm.hxx:57
SAL_DLLPRIVATE void SetCurViewId_Impl(const SfxInterfaceId i_nID)
Definition: viewfrm.cxx:2542
SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &rReq)
Definition: viewfrm.cxx:2558
void ChildWindowExecute(SfxRequest &)
Definition: viewfrm.cxx:3358
void UnlockAdjustPosSizePixel()
Definition: viewfrm.hxx:119
std::unique_ptr< struct SfxViewFrame_Impl > m_pImpl
Definition: viewfrm.hxx:51
void UpdateInfoBar(std::u16string_view sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType eType)
Definition: viewfrm.cxx:3612
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
virtual bool PrepareClose(bool bUI=true)
Initialize is called after the frame has been loaded and the controller has been set.
Definition: viewsh.cxx:1817
SfxInPlaceClient * GetUIActiveClient() const
Definition: viewsh.cxx:1516
css::uno::Reference< css::frame::XController > GetController() const
Definition: viewsh.cxx:2662
virtual void ShowCursor(bool bOn=true)
Definition: viewsh.cxx:2501
void DisconnectAllClients()
Definition: viewsh.cxx:2528
ViewShellId GetViewShellId() const override
See OutlinerViewShell::GetViewShellId().
Definition: viewsh.cxx:2426
SfxViewFrame & GetViewFrame() const
Definition: viewsh.hxx:290
static SAL_WARN_UNUSED_RESULT SfxViewShell * Get(const css::uno::Reference< css::frame::XController > &i_rController)
Definition: viewsh.cxx:1855
SAL_DLLPRIVATE void PopSubShells_Impl()
Definition: viewsh.hxx:377
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
Definition: viewsh.cxx:2046
virtual void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &)
Definition: viewsh.cxx:2010
virtual ErrCode DoVerb(sal_Int32 nVerb)
Definition: viewsh.cxx:1433
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
Definition: viewsh.cxx:2017
virtual SfxObjectShell * GetObjectShell() override
Definition: viewsh.cxx:2591
virtual SfxShell * GetFormShell()
Definition: viewsh.hxx:260
vcl::Window * GetWindow() const
Definition: viewsh.hxx:272
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
bool HasChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:1883
bool KnowsChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:1937
void SetChildWindow_Impl(sal_uInt16, bool bOn, bool bSetFocus)
Definition: workwin.cxx:1960
void ShowChildWindow_Impl(sal_uInt16, bool bVisible, bool bSetFocus)
Definition: workwin.cxx:1994
SfxChildWindow * GetChildWindow_Impl(sal_uInt16)
Definition: workwin.cxx:2075
void SetFullScreen_Impl(bool bSet)
Definition: workwin.hxx:262
void ToggleChildWindow_Impl(sal_uInt16, bool)
Definition: workwin.cxx:1788
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
void OwnerLock(bool bLock)
tools::Long & Left()
tools::Long & Top()
tools::Long & Right()
tools::Long & Bottom()
bool IsModuleInstalled(EModule eModule) const
void SetMenuBarMode(MenuBarMode nMode)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
static VclPtr< reference_type > Create(Arg &&... arg)
bool IsFullScreenMode() const
void ShowFullScreenMode(bool bFullScreenMode, sal_Int32 nDisplayScreen)
static std::shared_ptr< ConfigurationChanges > create()
static bool IsModifyPasswordCorrect(std::u16string_view aPassword, const css::uno::Sequence< css::beans::PropertyValue > &aInfo)
bool remove(const OUString &_rValueName)
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
bool hasUnsignedContentError() const
bool hasMacroLibrary() const
determines whether the document actually has a macros library
static void UnlockNotebookBar()
Method restores normal behaviour of the Notebookbar.
static void LockNotebookBar()
Method temporarily blocks showing of the NotebookBar.
static void ReloadNotebookBar(std::u16string_view sUIPath)
static bool IsActive(bool bConsiderSingleToolbar=false)
static void ShowPanel(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame, bool bFocus=false)
Switch to the deck that contains the specified panel and make sure that the panel is visible (expande...
Definition: Sidebar.cxx:64
static void ShowDeck(std::u16string_view rsDeckId, SfxViewFrame *pViewFrame, bool bToggle)
Definition: Sidebar.cxx:34
constexpr Point TopLeft() const
constexpr Size GetSize() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
T * get() const
bool is() const
vcl::Window * GetParent() const
bool IsInputEnabled() const
void GrabFocus()
void ReleaseLOKNotifier()
virtual Point GetPosPixel() const
virtual void SetOutputSizePixel(const Size &rNewSize)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
bool IsInModalMode() const
Size GetOutputSizePixel() const
weld::Window * GetFrameWeld() const
vcl::Window * GetFrameWindow() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
void EnableInput(bool bEnable=true, bool bChild=true)
virtual void set_label(const OUString &rText)=0
void connect_clicked(const Link< Button &, void > &rLink)
int nCount
#define DBG_ASSERT(sCon, aError)
#define ENSURE_OR_THROW(c, m)
#define DBG_UNHANDLED_EXCEPTION(...)
#define ENSURE_OR_RETURN_VOID(c, m)
float u
float x
#define ERRCODE_IO_ACCESSDENIED
#define ERRCODE_NONE
Any aHelper
Reference< XSingleServiceFactory > xFactory
DocumentType eType
OUString sName
InfobarType
Definition: infobar.hxx:22
sal_Int32 nIndex
OUString aName
sal_Int64 n
sal_uInt16 nPos
Definition: linksrc.cxx:118
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
def run(arg=None, arg2=-1)
NONE
SfxDispatcher * GetDispatcher()
void CutLines(OUString &rStr, sal_Int32 nStartLine, sal_Int32 nLines)
size
@ Exception
Reference< XComponentContext > getProcessComponentContext()
int i
dictionary props
SwAbstractDialogFactory & GetFactory()
static bool isProductVersionUpgraded(bool aUpdateVersion)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
#define SFX_OBJECTBAR_APPLICATION
Definition: objface.hxx:33
#define SFX_OBJECTBAR_FULLSCREEN
Definition: objface.hxx:37
sal_Int16 nId
const char GetValue[]
#define SFX_STREAM_READONLY
Definition: openflag.hxx:26
#define SFX_STREAM_READWRITE
Definition: openflag.hxx:23
SfxItemState
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
static SfxItemSet & rSet
Definition: shell.cxx:534
#define SFX_IMPL_SUPERCLASS_INTERFACE(Class, SuperClass)
Definition: shell.hxx:570
o3tl::strong_int< sal_uInt16, struct SfxInterfaceIdTag > SfxInterfaceId
Id for <SfxInterface>s, gives a quasi-static access to the interface through an array to <SfxApplicat...
Definition: shell.hxx:52
constexpr auto SFX_INTERFACE_NONE
Definition: shell.hxx:60
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)
StreamMode
::sfx2::DocumentMacroMode aMacroMode
Definition: objshimp.hxx:62
std::unique_ptr< AutoReloadTimer_Impl > pReloadTimer
Definition: objshimp.hxx:100
SfxLoadedFlags nLoadedFlags
Definition: objshimp.hxx:101
bool empty() const noexcept
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel
VCL_DLLPUBLIC ImplSVHelpData * CreateSVHelpData()
VCL_DLLPUBLIC void DestroySVHelpData(ImplSVHelpData *)
VCL_DLLPUBLIC void SetSVHelpData(ImplSVHelpData *)
VCL_DLLPUBLIC void SetSVWinData(ImplSVWinData *)
VCL_DLLPUBLIC ImplSVWinData * CreateSVWinData()
VCL_DLLPUBLIC void DestroySVWinData(ImplSVWinData *)
SVT_DLLPUBLIC OUString SvtResId(TranslateId aId)
@ FullScreenToolbox
bool bVisible
sal_uInt16 sal_Unicode
OUString aTargetURL
OUString sId
RET_OK
RET_CANCEL
RET_IGNORE
RET_YES
VclMessageType
VclButtonsType
constexpr OUStringLiteral CHANGES_STR
Definition: viewfrm.cxx:146
static bool impl_maxOpenDocCountReached()
Definition: viewfrm.cxx:2656
IMPL_LINK_NOARG(SfxViewFrame, WhatsNewHandler, weld::Button &, void)
Definition: viewfrm.cxx:1742
IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, weld::Button &, rButton, void)
Definition: viewfrm.cxx:1758
IMPL_STATIC_LINK_NOARG(SfxViewFrame, HelpMasterPasswordHdl, weld::Button &, void)
Definition: viewfrm.cxx:1840