LibreOffice Module sfx2 (master) 1
appopen.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 <com/sun/star/uno/Reference.h>
21#include <com/sun/star/beans/PropertyValue.hpp>
22#include <com/sun/star/beans/NamedValue.hpp>
23#include <com/sun/star/frame/FrameSearchFlag.hpp>
24#include <com/sun/star/frame/XDispatchProvider.hpp>
25#include <com/sun/star/frame/XFrame.hpp>
26#include <com/sun/star/frame/Desktop.hpp>
27#include <com/sun/star/util/URL.hpp>
28#include <com/sun/star/util/URLTransformer.hpp>
29#include <com/sun/star/util/XURLTransformer.hpp>
30#include <com/sun/star/system/SystemShellExecuteException.hpp>
31#include <com/sun/star/document/XTypeDetection.hpp>
32#include <com/sun/star/document/MacroExecMode.hpp>
33#include <com/sun/star/document/UpdateDocMode.hpp>
34#include <com/sun/star/task/ErrorCodeRequest.hpp>
35#include <com/sun/star/task/InteractionHandler.hpp>
36#include <com/sun/star/beans/XPropertySet.hpp>
37#include <com/sun/star/embed/ElementModes.hpp>
38#include <com/sun/star/embed/XStorage.hpp>
39#include <com/sun/star/container/XNameAccess.hpp>
40#include <com/sun/star/packages/WrongPasswordException.hpp>
41#include <com/sun/star/uno/Sequence.h>
42#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
43#include <com/sun/star/lang/XMultiServiceFactory.hpp>
44#include <rtl/ustring.hxx>
45
49#include <comphelper/string.hxx>
51
52#include <svl/intitem.hxx>
53#include <svl/stritem.hxx>
54#include <svl/eitem.hxx>
55#include <sfx2/doctempl.hxx>
56#include <svtools/sfxecode.hxx>
58#include <svtools/ehdl.hxx>
64#include <vcl/svapp.hxx>
65#include <vcl/weld.hxx>
66
67#include <sfx2/app.hxx>
68#include <sfx2/bindings.hxx>
69#include <sfx2/dispatch.hxx>
70#include <sfx2/docfile.hxx>
71#include <sfx2/docfilt.hxx>
72#include <sfx2/fcontnr.hxx>
73#include <sfx2/objitem.hxx>
74#include <sfx2/objsh.hxx>
75#include <svl/slstitm.hxx>
76#include <appopen.hxx>
77#include <sfx2/request.hxx>
78#include <sfx2/sfxresid.hxx>
79#include <sfx2/viewsh.hxx>
80#include <sfx2/strings.hrc>
81#include <sfx2/viewfrm.hxx>
82#include <sfx2/sfxuno.hxx>
83#include <sfx2/objface.hxx>
85#include <sfx2/templatedlg.hxx>
86#include <sfx2/sfxsids.hrc>
87#include <o3tl/string_view.hxx>
88#include <openuriexternally.hxx>
89
90#include <officecfg/Office/ProtocolHandler.hxx>
91#include <officecfg/Office/Security.hxx>
92
93using namespace ::com::sun::star;
94using namespace ::com::sun::star::beans;
95using namespace ::com::sun::star::frame;
96using namespace ::com::sun::star::lang;
97using namespace ::com::sun::star::uno;
98using namespace ::com::sun::star::util;
99using namespace ::com::sun::star::task;
100using namespace ::com::sun::star::container;
101using namespace ::cppu;
102using namespace ::sfx2;
103
104void SetTemplate_Impl( std::u16string_view rFileName,
105 const OUString &rLongName,
106 SfxObjectShell *pDoc)
107{
108 // write TemplateName to DocumentProperties of document
109 // TemplateDate stays as default (=current date)
110 pDoc->ResetFromTemplate( rLongName, rFileName );
111}
112
113namespace {
114
115class SfxDocPasswordVerifier : public ::comphelper::IDocPasswordVerifier
116{
117public:
118 explicit SfxDocPasswordVerifier( const Reference< embed::XStorage >& rxStorage ) :
119 mxStorage( rxStorage ) {}
120
121 virtual ::comphelper::DocPasswordVerifierResult
122 verifyPassword( const OUString& rPassword, uno::Sequence< beans::NamedValue >& o_rEncryptionData ) override;
123 virtual ::comphelper::DocPasswordVerifierResult
124 verifyEncryptionData( const uno::Sequence< beans::NamedValue >& rEncryptionData ) override;
125
126
127private:
128 Reference< embed::XStorage > mxStorage;
129};
130
131}
132
133::comphelper::DocPasswordVerifierResult SfxDocPasswordVerifier::verifyPassword( const OUString& rPassword, uno::Sequence< beans::NamedValue >& o_rEncryptionData )
134{
135 o_rEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( rPassword );
136 return verifyEncryptionData( o_rEncryptionData );
137}
138
139
140::comphelper::DocPasswordVerifierResult SfxDocPasswordVerifier::verifyEncryptionData( const uno::Sequence< beans::NamedValue >& rEncryptionData )
141{
142 ::comphelper::DocPasswordVerifierResult eResult = ::comphelper::DocPasswordVerifierResult::WrongPassword;
143 try
144 {
145 // check the encryption data
146 // if the data correct is the stream will be opened successfully
147 // and immediately closed
149
150 mxStorage->openStreamElement(
151 "content.xml",
152 embed::ElementModes::READ | embed::ElementModes::NOCREATE );
153
154 // no exception -> success
155 eResult = ::comphelper::DocPasswordVerifierResult::OK;
156 }
157 catch( const packages::WrongPasswordException& )
158 {
159 eResult = ::comphelper::DocPasswordVerifierResult::WrongPassword;
160 }
161 catch( const uno::Exception& )
162 {
163 // unknown error, report it as wrong password
164 // TODO/LATER: we need an additional way to report unknown problems in this case
165 eResult = ::comphelper::DocPasswordVerifierResult::WrongPassword;
166 }
167 return eResult;
168}
169
170
172(
173 SfxObjectShell* pDoc,
174 SfxMedium* pFile // the Medium and its Password should be obtained
175)
176
177/* [Description]
178
179 Ask for the password for a medium, only works if it concerns storage.
180 If the password flag is set in the Document Info, then the password is
181 requested through a user dialogue and the set at the Set of the medium.
182 If the set does not exist the it is created.
183*/
184{
185 ErrCode nRet = ERRCODE_NONE;
186
187 if( !pFile->GetFilter() || pFile->IsStorage() )
188 {
189 uno::Reference< embed::XStorage > xStorage = pFile->GetStorage();
190 if( xStorage.is() )
191 {
192 uno::Reference< beans::XPropertySet > xStorageProps( xStorage, uno::UNO_QUERY );
193 if ( xStorageProps.is() )
194 {
195 bool bIsEncrypted = false;
196 uno::Sequence< uno::Sequence< beans::NamedValue > > aGpgProperties;
197 try {
198 xStorageProps->getPropertyValue("HasEncryptedEntries")
199 >>= bIsEncrypted;
200 xStorageProps->getPropertyValue("EncryptionGpGProperties")
201 >>= aGpgProperties;
202 } catch( uno::Exception& )
203 {
204 // TODO/LATER:
205 // the storage either has no encrypted elements or it's just
206 // does not allow to detect it, probably it should be implemented later
207 }
208
209 if ( bIsEncrypted )
210 {
211 css::uno::Reference<css::awt::XWindow> xWin(pDoc ? pDoc->GetDialogParent(pFile) : nullptr);
212 if (xWin)
213 xWin->setVisible(true);
214
216
217 SfxItemSet& rSet = pFile->GetItemSet();
218 Reference< css::task::XInteractionHandler > xInteractionHandler = pFile->GetInteractionHandler();
219 if( xInteractionHandler.is() )
220 {
221 // use the comphelper password helper to request a password
222 OUString aPassword;
223 const SfxStringItem* pPasswordItem = rSet.GetItem(SID_PASSWORD, false);
224 if ( pPasswordItem )
225 aPassword = pPasswordItem->GetValue();
226
227 uno::Sequence< beans::NamedValue > aEncryptionData;
228 const SfxUnoAnyItem* pEncryptionDataItem = rSet.GetItem(SID_ENCRYPTIONDATA, false);
229 if ( pEncryptionDataItem )
230 pEncryptionDataItem->GetValue() >>= aEncryptionData;
231
232 // try if one of the public key entries is
233 // decryptable, then extract session key
234 // from it
235 if ( !aEncryptionData.hasElements() && aGpgProperties.hasElements() )
236 aEncryptionData = ::comphelper::DocPasswordHelper::decryptGpgSession(aGpgProperties);
237
238 // tdf#93389: if recovering a document, encryption data should contain
239 // entries for the real filter, not only for recovery ODF, to keep it
240 // encrypted. Pass this in encryption data.
241 // TODO: pass here the real filter (from AutoRecovery::implts_openDocs)
242 // to marshal this to requestAndVerifyDocPassword
243 if (rSet.GetItemState(SID_DOC_SALVAGE, false) == SfxItemState::SET)
244 {
245 aEncryptionData = comphelper::concatSequences(
246 aEncryptionData, std::initializer_list<beans::NamedValue>{
247 { "ForSalvage", css::uno::Any(true) } });
248 }
249
250 SfxDocPasswordVerifier aVerifier( xStorage );
252 aVerifier, aEncryptionData, aPassword, xInteractionHandler, pFile->GetOrigURL(), comphelper::DocPasswordRequestType::Standard );
253
254 rSet.ClearItem( SID_PASSWORD );
255 rSet.ClearItem( SID_ENCRYPTIONDATA );
256
257 if ( aEncryptionData.hasElements() )
258 {
259 rSet.Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::Any( aEncryptionData ) ) );
260
261 try
262 {
263 // update the version list of the medium using the new password
264 pFile->GetVersionList();
265 }
266 catch( uno::Exception& )
267 {
268 // TODO/LATER: set the error code
269 }
270
271 nRet = ERRCODE_NONE;
272 }
273 else
274 nRet = ERRCODE_IO_ABORT;
275 }
276 }
277 }
278 else
279 {
280 OSL_FAIL( "A storage must implement XPropertySet interface!" );
282 }
283 }
284 }
285
286 return nRet;
287}
288
289
290ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString &rFileName, std::unique_ptr<SfxItemSet> pSet )
291{
292 std::shared_ptr<const SfxFilter> pFilter;
293 SfxMedium aMedium( rFileName, ( StreamMode::READ | StreamMode::SHARE_DENYNONE ) );
294
295 if ( !aMedium.GetStorage( false ).is() )
296 aMedium.GetInStream();
297
298 if ( aMedium.GetError() )
299 {
300 return aMedium.GetErrorCode();
301 }
302
303 aMedium.UseInteractionHandler( true );
304 ErrCode nErr = GetFilterMatcher().GuessFilter( aMedium, pFilter, SfxFilterFlags::TEMPLATE, SfxFilterFlags::NONE );
305 if ( ERRCODE_NONE != nErr)
306 {
308 }
309
310 if( !pFilter || !pFilter->IsAllowedAsTemplate() )
311 {
313 }
314
315 if ( pFilter->GetFilterFlags() & SfxFilterFlags::STARONEFILTER )
316 {
317 DBG_ASSERT( !xDoc.Is(), "Sorry, not implemented!" );
318 SfxStringItem aName( SID_FILE_NAME, rFileName );
319 SfxStringItem aReferer( SID_REFERER, "private:user" );
320 SfxStringItem aFlags( SID_OPTIONS, "T" );
321 SfxBoolItem aHidden( SID_HIDDEN, true );
323 SID_OPENDOC, SfxCallMode::SYNCHRON,
324 { &aName, &aHidden, &aReferer, &aFlags } );
325 const SfxObjectItem *pObj = dynamic_cast<const SfxObjectItem*>( pRet );
326 if ( pObj )
327 xDoc = dynamic_cast<SfxObjectShell*>( pObj->GetShell() );
328 else
329 {
330 const SfxViewFrameItem *pView = dynamic_cast<const SfxViewFrameItem*>( pRet );
331 if ( pView )
332 {
333 SfxViewFrame *pFrame = pView->GetFrame();
334 if ( pFrame )
335 xDoc = pFrame->GetObjectShell();
336 }
337 }
338
339 if ( !xDoc.Is() )
341 }
342 else
343 {
344 if ( !xDoc.Is() )
345 xDoc = SfxObjectShell::CreateObject( pFilter->GetServiceName() );
346
347 //pMedium takes ownership of pSet
348 SfxMedium *pMedium = new SfxMedium( rFileName, StreamMode::STD_READ, pFilter, std::move(pSet) );
349 if(!xDoc->DoLoad(pMedium))
350 {
351 ErrCode nErrCode = xDoc->GetErrorCode();
352 xDoc->DoClose();
353 xDoc.Clear();
354 return nErrCode;
355 }
356 }
357
358 try
359 {
360 // TODO: introduce error handling
361
362 uno::Reference< embed::XStorage > xTempStorage = ::comphelper::OStorageHelper::GetTemporaryStorage();
363 if( !xTempStorage.is() )
364 throw uno::RuntimeException();
365
366 xDoc->GetStorage()->copyToStorage( xTempStorage );
367
368 if ( !xDoc->DoSaveCompleted( new SfxMedium( xTempStorage, OUString() ) ) )
369 throw uno::RuntimeException();
370 }
371 catch( uno::Exception& )
372 {
373 xDoc->DoClose();
374 xDoc.Clear();
375
376 // TODO: transfer correct error outside
377 return ERRCODE_SFX_GENERAL;
378 }
379
380 SetTemplate_Impl( rFileName, OUString(), xDoc );
381
382 xDoc->SetNoName();
383 xDoc->InvalidateName();
384 xDoc->SetModified(false);
385 xDoc->ResetError();
386
387 css::uno::Reference< css::frame::XModel > xModel = xDoc->GetModel();
388 if ( xModel.is() )
389 {
390 std::unique_ptr<SfxItemSet> pNew = xDoc->GetMedium()->GetItemSet().Clone();
391 pNew->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL );
392 pNew->ClearItem( SID_FILTER_NAME );
393 css::uno::Sequence< css::beans::PropertyValue > aArgs;
394 TransformItems( SID_OPENDOC, *pNew, aArgs );
395 sal_Int32 nLength = aArgs.getLength();
396 aArgs.realloc( nLength + 1 );
397 auto pArgs = aArgs.getArray();
398 pArgs[nLength].Name = "Title";
399 pArgs[nLength].Value <<= xDoc->GetTitle( SFX_TITLE_DETECT );
400 xModel->attachResource( OUString(), aArgs );
401 }
402
403 return xDoc->GetErrorCode();
404}
405
406
408{
409 const SfxStringItem* pFactoryItem = rReq.GetArg<SfxStringItem>(SID_NEWDOCDIRECT);
410 OUString aFactName;
411 if ( pFactoryItem )
412 aFactName = pFactoryItem->GetValue();
413 else
415
416 SfxRequest aReq( SID_OPENDOC, SfxCallMode::SYNCHRON, GetPool() );
417 aReq.AppendItem( SfxStringItem( SID_FILE_NAME, "private:factory/" + aFactName ) );
418 aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, GetFrame() ) );
419 aReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
420
421 // TODO/LATER: Should the other arguments be transferred as well?
422 const SfxStringItem* pDefaultPathItem = rReq.GetArg<SfxStringItem>(SID_DEFAULTFILEPATH);
423 if ( pDefaultPathItem )
424 aReq.AppendItem( *pDefaultPathItem );
425 const SfxStringItem* pDefaultNameItem = rReq.GetArg<SfxStringItem>(SID_DEFAULTFILENAME);
426 if ( pDefaultNameItem )
427 aReq.AppendItem( *pDefaultNameItem );
428
429 SfxGetpApp()->ExecuteSlot( aReq );
430 const SfxViewFrameItem* pItem = dynamic_cast<const SfxViewFrameItem*>( aReq.GetReturnValue() );
431 if ( pItem )
432 rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) );
433}
434
436{
437 rSet.Put(SfxStringItem(SID_NEWDOCDIRECT, "private:factory/" + SvtModuleOptions().GetDefaultModuleName()));
438}
439
441{
442 // No Parameter from BASIC only Factory given?
443 const SfxStringItem* pTemplNameItem = rReq.GetArg<SfxStringItem>(SID_TEMPLATE_NAME);
444 const SfxStringItem* pTemplFileNameItem = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
445 const SfxStringItem* pTemplRegionNameItem = rReq.GetArg<SfxStringItem>(SID_TEMPLATE_REGIONNAME);
446
448
449 OUString aTemplateRegion, aTemplateName, aTemplateFileName;
450 bool bDirect = false; // through FileName instead of Region/Template
452 if ( !pTemplNameItem && !pTemplFileNameItem )
453 {
454 bool bNewWin = false;
455 weld::Window* pTopWin = GetTopWindow();
456
457 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
458 Reference<XModel> xModel;
459 if(pCurrentShell)
460 xModel = pCurrentShell->GetModel();
461
462 SfxTemplateManagerDlg aTemplDlg(rReq.GetFrameWeld());
463
464 if (xModel.is())
465 aTemplDlg.setDocumentModel(xModel);
466
467 int nRet = aTemplDlg.run();
468 if ( nRet == RET_OK )
469 {
470 rReq.Done();
471 if ( pTopWin != GetTopWindow() )
472 {
473 // the dialogue opens a document -> a new TopWindow appears
474 pTopWin = GetTopWindow();
475 bNewWin = true;
476 }
477 }
478
479 if (bNewWin && pTopWin)
480 {
481 // after the destruction of the dialogue its parent comes to top,
482 // but we want that the new document is on top
483 pTopWin->present();
484 }
485
486 return;
487 }
488 else
489 {
490 // Template-Name
491 if ( pTemplNameItem )
492 aTemplateName = pTemplNameItem->GetValue();
493
494 // Template-Region
495 if ( pTemplRegionNameItem )
496 aTemplateRegion = pTemplRegionNameItem->GetValue();
497
498 // Template-File-Name
499 if ( pTemplFileNameItem )
500 {
501 aTemplateFileName = pTemplFileNameItem->GetValue();
502 bDirect = true;
503 }
504 }
505
506 ErrCode lErr = ERRCODE_NONE;
507 if ( !bDirect )
508 {
509 SfxDocumentTemplates aTmpFac;
510 if( aTemplateFileName.isEmpty() )
511 aTmpFac.GetFull( aTemplateRegion, aTemplateName, aTemplateFileName );
512
513 if( aTemplateFileName.isEmpty() )
515 }
516
517 INetURLObject aObj( aTemplateFileName );
519
520 if ( lErr != ERRCODE_NONE )
521 {
522 ErrCode lFatalErr = lErr.IgnoreWarning();
523 if ( lFatalErr )
525 }
526 else
527 {
529
530 const SfxPoolItem *pRet=nullptr;
531 SfxStringItem aReferer( SID_REFERER, "private:user" );
532 SfxStringItem aTarget( SID_TARGETNAME, "_default" );
533 if ( !aTemplateFileName.isEmpty() )
534 {
535 DBG_ASSERT( aObj.GetProtocol() != INetProtocol::NotValid, "Illegal URL!" );
536
538 SfxStringItem aTemplName( SID_TEMPLATE_NAME, aTemplateName );
539 SfxStringItem aTemplRegionName( SID_TEMPLATE_REGIONNAME, aTemplateRegion );
540 pRet = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode,
541 {&aName, &aTarget, &aReferer, &aTemplName, &aTemplRegionName});
542 }
543 else
544 {
545 SfxStringItem aName( SID_FILE_NAME, "private:factory" );
546 pRet = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode,
547 { &aName, &aTarget, &aReferer } );
548 }
549
550 if ( pRet )
551 rReq.SetReturnValue( *pRet );
552 }
553}
554
555
556namespace {
557
564bool lcl_isFilterNativelySupported(const SfxFilter& rFilter)
565{
566 if (rFilter.IsOwnFormat())
567 return true;
568
569 const OUString& aName = rFilter.GetFilterName();
570 // We can handle all Excel variants natively.
571 return aName.startsWith("MS Excel");
572}
573
574}
575
577{
578 OUString aDocService;
579 const SfxStringItem* pDocSrvItem = rReq.GetArg<SfxStringItem>(SID_DOC_SERVICE);
580 if (pDocSrvItem)
581 aDocService = pDocSrvItem->GetValue();
582
583 sal_uInt16 nSID = rReq.GetSlot();
584 const SfxStringItem* pFileNameItem = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
585 if ( pFileNameItem )
586 {
587 OUString aCommand( pFileNameItem->GetValue() );
588 const SfxSlot* pSlot = GetInterface()->GetSlot( aCommand );
589 if ( pSlot )
590 {
591 pFileNameItem = nullptr;
592 }
593 else
594 {
595 if ( aCommand.startsWith("slot:") )
596 {
597 sal_uInt16 nSlotId = static_cast<sal_uInt16>(o3tl::toInt32(aCommand.subView(5)));
598 if ( nSlotId == SID_OPENDOC )
599 pFileNameItem = nullptr;
600 }
601 }
602 }
603
604 if ( !pFileNameItem )
605 {
606 // get FileName from dialog
607 std::vector<OUString> aURLList;
608 OUString aFilter;
609 std::optional<SfxAllItemSet> pSet;
610 OUString aPath;
611 const SfxStringItem* pFolderNameItem = rReq.GetArg<SfxStringItem>(SID_PATH);
612 if ( pFolderNameItem )
613 aPath = pFolderNameItem->GetValue();
614 else if ( nSID == SID_OPENTEMPLATE )
615 {
617 if (!aPath.isEmpty()) // if not empty then get last token
618 aPath = aPath.copy(aPath.lastIndexOf(';')+1); // lastIndexOf+copy works whether separator (';') is there or not
619 }
620
621 sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG;
622 const SfxBoolItem* pSystemDialogItem = rReq.GetArg<SfxBoolItem>(SID_FILE_DIALOG);
623 if ( pSystemDialogItem )
624 nDialog = pSystemDialogItem->GetValue() ? SFX2_IMPL_DIALOG_SYSTEM : SFX2_IMPL_DIALOG_OOO;
625
626 const SfxBoolItem* pRemoteDialogItem = rReq.GetArg<SfxBoolItem>(SID_REMOTE_DIALOG);
627 if ( pRemoteDialogItem && pRemoteDialogItem->GetValue())
628 nDialog = SFX2_IMPL_DIALOG_REMOTE;
629
630 sal_Int16 nDialogType = ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION;
632 const SfxBoolItem* pSignPDFItem = rReq.GetArg<SfxBoolItem>(SID_SIGNPDF);
633 if (pSignPDFItem && pSignPDFItem->GetValue())
634 {
635 eDialogFlags |= FileDialogFlags::SignPDF;
636 nDialogType = ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
637 }
638
639 OUString sStandardDir;
640
641 const SfxStringItem* pStandardDirItem = rReq.GetArg<SfxStringItem>(SID_STANDARD_DIR);
642 if ( pStandardDirItem )
643 sStandardDir = pStandardDirItem->GetValue();
644
645 css::uno::Sequence< OUString > aDenyList;
646
647 const SfxStringListItem* pDenyListItem = rReq.GetArg<SfxStringListItem>(SID_DENY_LIST);
648 if ( pDenyListItem )
649 pDenyListItem->GetStringList( aDenyList );
650
651 weld::Window* pTopWindow = GetTopWindow();
652 ErrCode nErr = sfx2::FileOpenDialog_Impl(pTopWindow,
653 nDialogType,
654 eDialogFlags, aURLList,
655 aFilter, pSet, &aPath, nDialog, sStandardDir, aDenyList);
656
657 if ( nErr == ERRCODE_ABORT )
658 {
659 aURLList.clear();
660 return;
661 }
662
663 rReq.SetArgs( *pSet );
664 if ( !aFilter.isEmpty() )
665 rReq.AppendItem( SfxStringItem( SID_FILTER_NAME, aFilter ) );
666 rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
667 rReq.AppendItem( SfxStringItem( SID_REFERER, "private:user" ) );
668 pSet.reset();
669
670 if(!aURLList.empty())
671 {
672 if ( nSID == SID_OPENTEMPLATE )
673 rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, false ) );
674
675 // This helper wraps an existing (or may new created InteractionHandler)
676 // intercept all incoming interactions and provide useful information
677 // later if the following transaction was finished.
678
680 uno::Reference<task::XInteractionHandler> xHandler(pHandler);
681 uno::Reference<task::XInteractionHandler> xWrappedHandler;
682
683 // wrap existing handler or create new UUI handler
684 const SfxUnoAnyItem* pInteractionItem = rReq.GetArg<SfxUnoAnyItem>(SID_INTERACTIONHANDLER);
685 if (pInteractionItem)
686 {
687 pInteractionItem->GetValue() >>= xWrappedHandler;
688 rReq.RemoveItem( SID_INTERACTIONHANDLER );
689 }
690 if (xWrappedHandler.is())
691 pHandler->setHandler(xWrappedHandler);
692 else
693 pHandler->useDefaultUUIHandler();
694 rReq.AppendItem( SfxUnoAnyItem(SID_INTERACTIONHANDLER,css::uno::Any(xHandler)) );
695
696 // define rules for this handler
697 css::uno::Type aInteraction = ::cppu::UnoType<css::task::ErrorCodeRequest>::get();
699 pHandler->addInteractionRule(aRule);
700
701 if (!aDocService.isEmpty())
702 {
703 rReq.RemoveItem(SID_DOC_SERVICE);
704 rReq.AppendItem(SfxStringItem(SID_DOC_SERVICE, aDocService));
705 }
706
707 for (auto const& url : aURLList)
708 {
709 rReq.RemoveItem( SID_FILE_NAME );
710 rReq.AppendItem( SfxStringItem( SID_FILE_NAME, url ) );
711
712 // Run synchronous, so that not the next document is loaded
713 // when rescheduling
714 // TODO/LATER: use URLList argument and always remove one document after another, each step in asynchronous execution, until finished
715 // but only if reschedule is a problem
716 GetDispatcher_Impl()->Execute( SID_OPENDOC, SfxCallMode::SYNCHRON, *rReq.GetArgs() );
717
718 // check for special interaction "NO MORE DOCUMENTS ALLOWED" and
719 // break loop then. Otherwise we risk showing the same interaction more than once.
720 if ( pHandler->getInteractionInfo(aInteraction, &aRule) )
721 {
722 if (aRule.m_nCallCount > 0)
723 {
724 if (aRule.m_xRequest.is())
725 {
726 css::task::ErrorCodeRequest aRequest;
727 if (aRule.m_xRequest->getRequest() >>= aRequest)
728 {
729 if (aRequest.ErrCode == sal_Int32(sal_uInt32(ERRCODE_SFX_NOMOREDOCUMENTSALLOWED)))
730 break;
731 }
732 }
733 }
734 }
735 }
736
737 aURLList.clear();
738 return;
739 }
740 aURLList.clear();
741 }
742
743 bool bHyperlinkUsed = false;
744
745 if ( SID_OPENURL == nSID )
746 {
747 // SID_OPENURL does the same as SID_OPENDOC!
748 rReq.SetSlot( SID_OPENDOC );
749 }
750 else if ( nSID == SID_OPENTEMPLATE )
751 {
752 rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, false ) );
753 }
754 // pass URL to OS by using ShellExecuter or open it internal
755 // if it seems to be an own format.
756 /* Attention!
757 There exist two possibilities to open hyperlinks:
758 a) using SID_OPENHYPERLINK (new)
759 b) using SID_BROWSE (old)
760 */
761 else if ( nSID == SID_OPENHYPERLINK )
762 {
763 rReq.SetSlot( SID_OPENDOC );
764 bHyperlinkUsed = true;
765 }
766
767 // no else here! It's optional ...
768 if (!bHyperlinkUsed)
769 {
770 const SfxBoolItem* pHyperLinkUsedItem = rReq.GetArg<SfxBoolItem>(SID_BROWSE);
771 if ( pHyperLinkUsedItem )
772 bHyperlinkUsed = pHyperLinkUsedItem->GetValue();
773 // no "official" item, so remove it from ItemSet before using UNO-API
774 rReq.RemoveItem( SID_BROWSE );
775 }
776
777 const SfxStringItem* pFileName = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
778 assert(pFileName && "SID_FILE_NAME is required");
779 OUString aFileName = pFileName->GetValue();
780
781 OUString aReferer;
782 const SfxStringItem* pRefererItem = rReq.GetArg<SfxStringItem>(SID_REFERER);
783 if ( pRefererItem )
784 aReferer = pRefererItem->GetValue();
785
786 const SfxStringItem* pFileFlagsItem = rReq.GetArg<SfxStringItem>(SID_OPTIONS);
787 if ( pFileFlagsItem )
788 {
789 const OUString aFileFlags = pFileFlagsItem->GetValue().toAsciiUpperCase();
790 if ( aFileFlags.indexOf('T') >= 0 )
791 {
792 rReq.RemoveItem( SID_TEMPLATE );
793 rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, true ) );
794 }
795
796 if ( aFileFlags.indexOf('H') >= 0 )
797 {
798 rReq.RemoveItem( SID_HIDDEN );
799 rReq.AppendItem( SfxBoolItem( SID_HIDDEN, true ) );
800 }
801
802 if ( aFileFlags.indexOf('R') >= 0 )
803 {
804 rReq.RemoveItem( SID_DOC_READONLY );
805 rReq.AppendItem( SfxBoolItem( SID_DOC_READONLY, true ) );
806 }
807
808 if ( aFileFlags.indexOf('B') >= 0 )
809 {
810 rReq.RemoveItem( SID_PREVIEW );
811 rReq.AppendItem( SfxBoolItem( SID_PREVIEW, true ) );
812 }
813
814 rReq.RemoveItem( SID_OPTIONS );
815 }
816
817 // Mark without URL cannot be handled by hyperlink code
818 if ( bHyperlinkUsed && !aFileName.isEmpty() && aFileName[0] != '#' )
819 {
820 uno::Reference<document::XTypeDetection> xTypeDetection(
821 comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"), UNO_QUERY);
822
823 if ( xTypeDetection.is() )
824 {
825 URL aURL;
826
827 aURL.Complete = aFileName;
828 Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
829 xTrans->parseStrict( aURL );
830
831 INetProtocol aINetProtocol = INetURLObject( aURL.Complete ).GetProtocol();
832 auto eMode = officecfg::Office::Security::Hyperlinks::Open::get();
833
834 if ( eMode == SvtExtendedSecurityOptions::OPEN_NEVER && aINetProtocol != INetProtocol::VndSunStarHelp )
835 {
836 SolarMutexGuard aGuard;
837 weld::Window *pWindow = SfxGetpApp()->GetTopWindow();
838
839 std::unique_ptr<weld::MessageDialog> xSecurityWarningBox(Application::CreateMessageDialog(pWindow,
840 VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_SECURITY_WARNING_NO_HYPERLINKS)));
841 xSecurityWarningBox->set_title(SfxResId(RID_SECURITY_WARNING_TITLE));
842 xSecurityWarningBox->run();
843 return;
844 }
845
846 std::shared_ptr<const SfxFilter> pFilter{};
847
848 // attempt loading native documents only if they are from a known protocol
849 // it might be sensible to limit the set of protocols even further, but that
850 // may cause regressions, needs further testing
851 // see tdf#136427 for details
852 if (aINetProtocol != INetProtocol::NotValid) {
853 const OUString aTypeName { xTypeDetection->queryTypeByURL( aURL.Main ) };
855 pFilter = rMatcher.GetFilter4EA( aTypeName );
856 }
857
858 if (!pFilter || !lcl_isFilterNativelySupported(*pFilter))
859 {
860 // hyperlink does not link to own type => special handling (http, ftp) browser and (other external protocols) OS
861 if ( aINetProtocol == INetProtocol::Mailto )
862 {
863 // don't dispatch mailto hyperlink to desktop dispatcher
864 rReq.RemoveItem( SID_TARGETNAME );
865 rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_self" ) );
866 }
867 else if ( aINetProtocol == INetProtocol::Ftp ||
868 aINetProtocol == INetProtocol::Http ||
869 aINetProtocol == INetProtocol::Https )
870 {
871 sfx2::openUriExternally(aURL.Complete, true, rReq.GetFrameWeld());
872 return;
873 }
874 else
875 {
876 // check for "internal" protocols that should not be forwarded to the system
877 // add special protocols that always should be treated as internal
878 std::vector < OUString > aProtocols { "private:*", "vnd.sun.star.*" };
879
880 // get registered protocol handlers from configuration
881 Reference < XNameAccess > xAccess(officecfg::Office::ProtocolHandler::HandlerSet::get());
882 const Sequence < OUString > aNames = xAccess->getElementNames();
883 for ( const auto& rName : aNames )
884 {
885 Reference < XPropertySet > xSet;
886 Any aRet = xAccess->getByName( rName );
887 aRet >>= xSet;
888 if ( xSet.is() )
889 {
890 // copy protocols
891 aRet = xSet->getPropertyValue("Protocols");
892 Sequence < OUString > aTmp;
893 aRet >>= aTmp;
894
895 aProtocols.insert(aProtocols.end(),std::cbegin(aTmp),std::cend(aTmp));
896 }
897 }
898
899 bool bFound = false;
900 for (const OUString & rProtocol : aProtocols)
901 {
902 WildCard aPattern(rProtocol);
903 if ( aPattern.Matches( aURL.Complete ) )
904 {
905 bFound = true;
906 break;
907 }
908 }
909
910 if ( !bFound )
911 {
912 bool bLoadInternal = false;
913 try
914 {
916 aURL.Complete, pFilter == nullptr, rReq.GetFrameWeld());
917 }
918 catch ( css::system::SystemShellExecuteException& )
919 {
920 rReq.RemoveItem( SID_TARGETNAME );
921 rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
922 bLoadInternal = true;
923 }
924 if ( !bLoadInternal )
925 return;
926 }
927 }
928 }
929 else
930 {
931 // hyperlink document must be loaded into a new frame
932 rReq.RemoveItem( SID_TARGETNAME );
933 rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
934 }
935 }
936 }
937
938 if (!SvtSecurityOptions::isSecureMacroUri(aFileName, aReferer))
939 {
940 SfxErrorContext aCtx( ERRCTX_SFX_OPENDOC, aFileName );
942 return;
943 }
944
945 SfxFrame* pTargetFrame = nullptr;
946 Reference< XFrame > xTargetFrame;
947
948 const SfxFrameItem* pFrameItem = rReq.GetArg<SfxFrameItem>(SID_DOCFRAME);
949 if ( pFrameItem )
950 pTargetFrame = pFrameItem->GetFrame();
951
952 if ( !pTargetFrame )
953 {
954 const SfxUnoFrameItem* pUnoFrameItem = rReq.GetArg<SfxUnoFrameItem>(SID_FILLFRAME);
955 if ( pUnoFrameItem )
956 xTargetFrame = pUnoFrameItem->GetFrame();
957 }
958
959 if (!pTargetFrame && !xTargetFrame.is())
960 {
961 if (const SfxViewFrame* pViewFrame = SfxViewFrame::Current())
962 pTargetFrame = &pViewFrame->GetFrame();
963 }
964
965 // check if caller has set a callback
966 std::unique_ptr<SfxLinkItem> pLinkItem;
967
968 // remove from Itemset, because it confuses the parameter transformation
969 if (auto pParamLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK))
970 pLinkItem.reset(pParamLinkItem->Clone());
971
972 rReq.RemoveItem( SID_DONELINK );
973
974 // check if the view must be hidden
975 bool bHidden = false;
976 const SfxBoolItem* pHidItem = rReq.GetArg<SfxBoolItem>(SID_HIDDEN);
977 if ( pHidItem )
978 bHidden = pHidItem->GetValue();
979
980 // This request is a UI call. We have to set the right values inside the MediaDescriptor
981 // for: InteractionHandler, StatusIndicator, MacroExecutionMode and DocTemplate.
982 // But we have to look for already existing values or for real hidden requests.
983 const SfxBoolItem* pPreviewItem = rReq.GetArg<SfxBoolItem>(SID_PREVIEW);
984 if (!bHidden && ( !pPreviewItem || !pPreviewItem->GetValue() ) )
985 {
986 const SfxUnoAnyItem* pInteractionItem = rReq.GetArg<SfxUnoAnyItem>(SID_INTERACTIONHANDLER);
987 const SfxUInt16Item* pMacroExecItem = rReq.GetArg<SfxUInt16Item>(SID_MACROEXECMODE);
988 const SfxUInt16Item* pDocTemplateItem = rReq.GetArg<SfxUInt16Item>(SID_UPDATEDOCMODE);
989
990 if (!pInteractionItem)
991 {
992 Reference < task::XInteractionHandler2 > xHdl = task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr );
993 rReq.AppendItem( SfxUnoAnyItem(SID_INTERACTIONHANDLER,css::uno::Any(xHdl)) );
994 }
995 if (!pMacroExecItem)
996 rReq.AppendItem( SfxUInt16Item(SID_MACROEXECMODE,css::document::MacroExecMode::USE_CONFIG) );
997 if (!pDocTemplateItem)
998 rReq.AppendItem( SfxUInt16Item(SID_UPDATEDOCMODE,css::document::UpdateDocMode::ACCORDING_TO_CONFIG) );
999 }
1000
1001 // extract target name
1002 OUString aTarget;
1003 const SfxStringItem* pTargetItem = rReq.GetArg<SfxStringItem>(SID_TARGETNAME);
1004 if ( pTargetItem )
1005 aTarget = pTargetItem->GetValue();
1006 else
1007 {
1008 const SfxBoolItem* pNewViewItem = rReq.GetArg<SfxBoolItem>(SID_OPEN_NEW_VIEW);
1009 if ( pNewViewItem && pNewViewItem->GetValue() )
1010 aTarget = "_blank" ;
1011 }
1012
1013 if ( bHidden )
1014 {
1015 aTarget = "_blank";
1016 DBG_ASSERT( rReq.IsSynchronCall() || pLinkItem, "Hidden load process must be done synchronously!" );
1017 }
1018
1019 Reference < XController > xController;
1020 // if a frame is given, it must be used for the starting point of the targeting mechanism
1021 // this code is also used if asynchronous loading is possible, because loadComponent always is synchron
1022 if ( !xTargetFrame.is() )
1023 {
1024 if ( pTargetFrame )
1025 {
1026 xTargetFrame = pTargetFrame->GetFrameInterface();
1027 }
1028 else
1029 {
1030 xTargetFrame = Desktop::create(::comphelper::getProcessComponentContext());
1031 }
1032 }
1033
1034 // make URL ready
1035 const SfxStringItem* pURLItem = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
1036 aFileName = pURLItem->GetValue();
1037 if( aFileName.startsWith("#") ) // Mark without URL
1038 {
1039 SfxViewFrame *pView = pTargetFrame ? pTargetFrame->GetCurrentViewFrame() : nullptr;
1040 if ( !pView )
1041 pView = SfxViewFrame::Current();
1042 pView->GetViewShell()->JumpToMark( aFileName.copy(1) );
1043 rReq.SetReturnValue( SfxViewFrameItem( pView ) );
1044 return;
1045 }
1046
1047 // convert items to properties for framework API calls
1048 Sequence < PropertyValue > aArgs;
1049 TransformItems( SID_OPENDOC, *rReq.GetArgs(), aArgs );
1050 // Any Referer (that was relevant in the above call to
1051 // SvtSecurityOptions::isSecureMacroUri) is no longer relevant, assuming
1052 // this "open" request is initiated directly by the user:
1053 auto pArg = std::find_if(std::cbegin(aArgs), std::cend(aArgs),
1054 [](const PropertyValue& rArg) { return rArg.Name == "Referer"; });
1055 if (pArg != std::cend(aArgs))
1056 {
1057 auto nIndex = static_cast<sal_Int32>(std::distance(std::cbegin(aArgs), pArg));
1059 }
1060
1061 // TODO/LATER: either remove LinkItem or create an asynchronous process for it
1062 if( bHidden || pLinkItem || rReq.IsSynchronCall() )
1063 {
1064 // if loading must be done synchron, we must wait for completion to get a return value
1065 // find frame by myself; I must know the exact frame to get the controller for the return value from it
1066 Reference < XComponent > xComp;
1067
1068 try
1069 {
1070 xComp = ::comphelper::SynchronousDispatch::dispatch( xTargetFrame, aFileName, aTarget, aArgs );
1071 }
1072 catch(const RuntimeException&)
1073 {
1074 throw;
1075 }
1076 catch(const css::uno::Exception&)
1077 {
1078 }
1079
1080 Reference < XModel > xModel( xComp, UNO_QUERY );
1081 if ( xModel.is() )
1082 xController = xModel->getCurrentController();
1083 else
1084 xController.set( xComp, UNO_QUERY );
1085
1086 }
1087 else
1088 {
1089 URL aURL;
1090 aURL.Complete = aFileName;
1091 Reference< util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
1092 xTrans->parseStrict( aURL );
1093
1094 Reference < XDispatchProvider > xProv( xTargetFrame, UNO_QUERY );
1095 Reference < XDispatch > xDisp = xProv.is() ? xProv->queryDispatch( aURL, aTarget, FrameSearchFlag::ALL ) : Reference < XDispatch >();
1096 if ( xDisp.is() )
1097 xDisp->dispatch( aURL, aArgs );
1098 }
1099
1100 if ( xController.is() )
1101 {
1102 // try to find the SfxFrame for the controller
1103 SfxFrame* pCntrFrame = nullptr;
1104 for ( SfxViewShell* pShell = SfxViewShell::GetFirst( false ); pShell; pShell = SfxViewShell::GetNext( *pShell, false ) )
1105 {
1106 if ( pShell->GetController() == xController )
1107 {
1108 pCntrFrame = &pShell->GetViewFrame().GetFrame();
1109 break;
1110 }
1111 }
1112
1113 if ( pCntrFrame )
1114 {
1115 SfxObjectShell* pSh = pCntrFrame->GetCurrentDocument();
1116 DBG_ASSERT( pSh, "Controller without ObjectShell ?!" );
1117
1118 rReq.SetReturnValue( SfxViewFrameItem( pCntrFrame->GetCurrentViewFrame() ) );
1119
1120 if ( bHidden )
1121 pSh->RestoreNoDelete();
1122 }
1123 }
1124
1125 if (pLinkItem)
1126 {
1127 const SfxPoolItem* pRetValue = rReq.GetReturnValue();
1128 if (pRetValue)
1129 {
1130 pLinkItem->GetValue().Call(pRetValue);
1131 }
1132 }
1133}
1134
1136{
1137 rReq.AppendItem( SfxBoolItem( SID_REMOTE_DIALOG, true ) );
1138 GetDispatcher_Impl()->Execute( SID_OPENDOC, SfxCallMode::SYNCHRON, *rReq.GetArgs() );
1139}
1140
1142{
1143 rReq.AppendItem(SfxBoolItem(SID_SIGNPDF, true));
1144 GetDispatcher_Impl()->Execute(SID_OPENDOC, SfxCallMode::SYNCHRON, *rReq.GetArgs());
1145}
1146
1147/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
SfxApplication * SfxGetpApp()
Definition: app.hxx:231
ErrCode CheckPasswd_Impl(SfxObjectShell *pDoc, SfxMedium *pFile)
Definition: appopen.cxx:172
void SetTemplate_Impl(std::u16string_view rFileName, const OUString &rLongName, SfxObjectShell *pDoc)
Definition: appopen.cxx:104
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
Definition: appuno.cxx:908
constexpr OUStringLiteral sStandardDir
Definition: appuno.cxx:142
SfxCallMode
Definition: bindings.hxx:57
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
ErrCode IgnoreWarning() const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString PathToFileName() const
INetProtocol GetProtocol() const
SfxFilterMatcher & GetFilterMatcher()
Definition: appmain.cxx:27
SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &)
Definition: appopen.cxx:440
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
Definition: app.cxx:228
SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &)
Definition: appopen.cxx:407
SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest &)
Definition: appopen.cxx:1141
SAL_DLLPRIVATE void OpenRemoteExec_Impl(SfxRequest &)
Definition: appopen.cxx:1135
ErrCode LoadTemplate(SfxObjectShellLock &xDoc, const OUString &rFileName, std::unique_ptr< SfxItemSet > pArgs)
Definition: appopen.cxx:290
SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &)
Definition: appopen.cxx:576
static SAL_DLLPRIVATE void NewDocDirectState_Impl(SfxItemSet &)
Definition: appopen.cxx:435
weld::Window * GetTopWindow() const
Definition: app.cxx:324
bool GetValue() const
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
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
bool GetFull(std::u16string_view rRegion, std::u16string_view rName, OUString &rPath)
Definition: doctempl.cxx:1098
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
Definition: fltfnc.cxx:341
std::shared_ptr< const SfxFilter > GetFilter4EA(const OUString &rEA, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
Definition: fltfnc.cxx:637
const OUString & GetFilterName() const
Definition: docfilt.hxx:90
bool IsOwnFormat() const
Definition: docfilt.hxx:78
SfxFrame * GetFrame() const
Definition: frame.hxx:166
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
SAL_WARN_UNUSED_RESULT SfxObjectShell * GetCurrentDocument() const
Definition: frame.cxx:250
SAL_WARN_UNUSED_RESULT SfxViewFrame * GetCurrentViewFrame() const
Definition: frame.cxx:234
const SfxSlot * GetSlot(sal_uInt16 nSlotId) const
Definition: objface.cxx:187
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const std::shared_ptr< const SfxFilter > & GetFilter() const
Definition: docfile.cxx:3111
void UseInteractionHandler(bool)
Definition: docfile.cxx:3069
SfxItemSet & GetItemSet() const
Definition: docfile.cxx:3647
ErrCode GetErrorCode() const
Definition: docfile.cxx:512
ErrCode GetError() const
Definition: docfile.hxx:147
const OUString & GetOrigURL() const
Definition: docfile.cxx:3364
const css::uno::Sequence< css::util::RevisionTag > & GetVersionList(bool _bNoReload=false)
Definition: docfile.cxx:3687
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
Definition: docfile.cxx:1703
bool IsStorage()
Definition: docfile.cxx:865
SvStream * GetInStream()
Definition: docfile.cxx:671
css::uno::Reference< css::task::XInteractionHandler > GetInteractionHandler(bool bGetAlways=false)
Definition: docfile.cxx:3076
SfxShell * GetShell() const
Definition: objitem.hxx:42
bool Is() const
Definition: objsh.hxx:847
static SfxObjectShell * CreateObject(const OUString &rServiceName, SfxObjectCreateMode=SfxObjectCreateMode::STANDARD)
Definition: objxtor.cxx:996
bool DoClose()
Definition: objxtor.cxx:818
void ResetFromTemplate(const OUString &rTemplateName, std::u16string_view rFileName)
Definition: objcont.cxx:586
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
Definition: objstor.cxx:1945
ErrCode GetErrorCode() const
Definition: objmisc.cxx:225
css::uno::Reference< css::awt::XWindow > GetDialogParent(SfxMedium const *pMedium=nullptr)
Definition: objmisc.cxx:1618
void SetNoName()
Definition: objmisc.cxx:870
SfxMedium * GetMedium() const
Definition: objsh.hxx:261
css::uno::Reference< css::frame::XModel3 > GetModel() const
Definition: objxtor.cxx:838
OUString GetTitle(sal_uInt16 nMaxLen=0) const
Definition: objmisc.cxx:710
css::uno::Reference< css::embed::XStorage > const & GetStorage()
Definition: objstor.cxx:3260
bool DoLoad(SfxMedium *pMedium)
Definition: objstor.cxx:572
void InvalidateName()
Definition: objmisc.cxx:839
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
Definition: objxtor.cxx:481
void ResetError()
Definition: objmisc.cxx:233
virtual void SetModified(bool bModified=true)
Definition: objmisc.cxx:301
sal_uInt16 GetSlot() const
Definition: request.hxx:68
void RemoveItem(sal_uInt16 nSlotId)
Definition: request.cxx:412
const SfxPoolItem * GetReturnValue() const
Definition: request.cxx:429
const SfxItemSet * GetArgs() const
Definition: request.hxx:75
void SetSlot(sal_uInt16 nNewSlot)
Definition: request.hxx:69
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 IsSynchronCall() const
Definition: request.cxx:295
weld::Window * GetFrameWeld() const
Return the window that should be used as the parent for any dialogs this request creates.
Definition: appserv.cxx:299
void SetArgs(const SfxAllItemSet &rArgs)
Definition: request.cxx:397
void Done(bool bRemove=false)
Definition: request.cxx:484
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
Definition: shell.hxx:511
SfxViewFrame * GetFrame() const
This method returns a pointer to the <SfxViewFrame> to which this SfxShell instance is associated or ...
Definition: shell.cxx:134
virtual SfxInterface * GetInterface() const
With this virtual method, which is automatically overridden by each subclass with its own slots throu...
Definition: shell.cxx:198
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
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
Definition: shell.cxx:129
Definition: msg.hxx:184
void GetStringList(css::uno::Sequence< OUString > &rList) const
virtual short run() override
void setDocumentModel(const css::uno::Reference< css::frame::XModel > &rModel)
const css::uno::Any & GetValue() const
Definition: frame.hxx:175
const css::uno::Reference< css::frame::XFrame > & GetFrame() const
Definition: frame.hxx:193
SfxViewFrame * GetFrame() const
Definition: viewfrm.hxx:275
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
Definition: viewfrm.cxx:1975
virtual SfxObjectShell * GetObjectShell() override
Definition: viewfrm.cxx:2218
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
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
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
Definition: viewsh.cxx:2017
void JumpToMark(const OUString &rMark)
Definition: viewsh.cxx:2642
OUString GetDefaultModuleName() const
const OUString & GetTemplatePath() const
bool Matches(std::u16string_view rStr) const
static css::uno::Sequence< css::beans::NamedValue > decryptGpgSession(const css::uno::Sequence< css::uno::Sequence< css::beans::NamedValue > > &rGpgProperties)
static css::uno::Sequence< css::beans::NamedValue > requestAndVerifyDocPassword(IDocPasswordVerifier &rVerifier, const css::uno::Sequence< css::beans::NamedValue > &rMediaEncData, const OUString &rMediaPassword, const css::uno::Reference< css::task::XInteractionHandler > &rxInteractHandler, const OUString &rDocumentUrl, DocPasswordRequestType eRequestType, const ::std::vector< OUString > *pDefaultPasswords=nullptr, bool *pbIsDefaultPassword=nullptr)
virtual DocPasswordVerifierResult verifyPassword(const OUString &rPassword, css::uno::Sequence< css::beans::NamedValue > &o_rEncryptionData)=0
virtual DocPasswordVerifierResult verifyEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &o_rEncryptionData)=0
static css::uno::Sequence< css::beans::NamedValue > CreatePackageEncryptionData(std::u16string_view aPassword)
static void SetCommonStorageEncryptionData(const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Sequence< css::beans::NamedValue > &aEncryptionData)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static COMPHELPER_DLLPUBLIC css::uno::Reference< css::lang::XComponent > dispatch(const css::uno::Reference< css::uno::XInterface > &xStartPoint, const OUString &sURL, const OUString &sTarget, const css::uno::Sequence< css::beans::PropertyValue > &lArguments)
css::uno::Type const & get()
Prevent us from showing the same interaction more than once during the same transaction.
virtual void present()=0
#define DBG_ASSERT(sCon, aError)
URL aURL
#define ERRCODE_IO_ACCESSDENIED
#define ERRCODE_IO_ABORT
#define ERRCODE_ABORT
#define ERRCODE_NONE
#define SFX2_IMPL_DIALOG_CONFIG
#define SFX2_IMPL_DIALOG_SYSTEM
FileDialogFlags
@ SignPDF
Sign existing PDF.
#define SFX2_IMPL_DIALOG_OOO
#define SFX2_IMPL_DIALOG_REMOTE
sal_Int32 nIndex
OUString aName
Mode eMode
bool isSecureMacroUri(OUString const &uri, OUString const &referer)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
DocPasswordVerifierResult
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
void removeElementAt(css::uno::Sequence< T > &_rSeq, sal_Int32 _nPos)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
ErrCode FileOpenDialog_Impl(weld::Window *pParent, sal_Int16 nDialogType, FileDialogFlags nFlags, std::vector< OUString > &rpURLList, OUString &rFilter, std::optional< SfxAllItemSet > &rpSet, const OUString *pPath, sal_Int16 nDialog, const OUString &rStandardDir, const css::uno::Sequence< OUString > &rDenyList)
void openUriExternally(const OUString &sURI, bool bHandleSystemShellExecuteException, weld::Widget *pDialogParent)
Open a URI via com.sun.star.system.SystemShellExecute.
#define SFX_TITLE_DETECT
Definition: objsh.hxx:116
Reference< XNameContainer > mxStorage
#define ERRCODE_SFX_GENERAL
#define ERRCTX_SFX_NEWDOC
#define ERRCODE_SFX_CANTGETPASSWD
#define ERRCODE_SFX_DOLOADFAILED
#define ERRCTX_SFX_LOADTEMPLATE
#define ERRCTX_SFX_OPENDOC
#define ERRCODE_SFX_TEMPLATENOTFOUND
#define ERRCODE_SFX_NOMOREDOCUMENTSALLOWED
#define ERRCODE_SFX_NOTATEMPLATE
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
static SfxItemSet & rSet
Definition: shell.cxx:534
sal_Int32 m_nCallCount
count how often this interaction was called.
css::uno::Reference< css::task::XInteractionRequest > m_xRequest
hold the last intercepted request (matching the set interaction type) alive so it can be used for fur...
Reference< XController > xController
Reference< XModel > xModel
OUString aCommand
INetProtocol
RET_OK
sal_Int32 nLength