LibreOffice Module sfx2 (master) 1
guisaveas.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/ui/dialogs/XExecutableDialog.hpp>
21#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
22#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
23#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
24#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
25#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
26#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
27#include <com/sun/star/view/XSelectionSupplier.hpp>
28#include <com/sun/star/beans/PropertyExistException.hpp>
29#include <com/sun/star/beans/XPropertyAccess.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <com/sun/star/beans/XPropertyContainer.hpp>
32#include <com/sun/star/beans/PropertyAttribute.hpp>
33#include <com/sun/star/document/XExporter.hpp>
34#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
35#include <com/sun/star/document/XDocumentProperties.hpp>
36#include <com/sun/star/task/ErrorCodeIOException.hpp>
37#include <com/sun/star/task/InteractionHandler.hpp>
38#include <com/sun/star/util/URLTransformer.hpp>
39#include <com/sun/star/util/XURLTransformer.hpp>
40#include <com/sun/star/frame/ModuleManager.hpp>
41#include <com/sun/star/frame/XStorable.hpp>
42#include <com/sun/star/frame/XStorable2.hpp>
43#include <com/sun/star/frame/XDispatchProvider.hpp>
44#include <com/sun/star/frame/XDispatch.hpp>
45#include <com/sun/star/frame/XTitle.hpp>
46#include <com/sun/star/util/XModifiable.hpp>
47#include <com/sun/star/lang/XMultiServiceFactory.hpp>
48
49#include <com/sun/star/util/XCloneable.hpp>
50
51#include <guisaveas.hxx>
52
53#include <sal/log.hxx>
54#include <svl/itemset.hxx>
55#include <svl/eitem.hxx>
56#include <tools/debug.hxx>
58#include <tools/urlobj.hxx>
59#include <tools/json_writer.hxx>
60#include <tools/urlobj.hxx>
66#include <comphelper/lok.hxx>
67#include <LibreOfficeKit/LibreOfficeKitEnums.h>
68#include <utility>
69#include <vcl/svapp.hxx>
70#include <vcl/weld.hxx>
72#include <unotools/tempfile.hxx>
74
75#include <sfx2/objsh.hxx>
76#include <sfx2/sfxsids.hrc>
77#include <sfx2/strings.hrc>
78#include <sfx2/sfxresid.hxx>
80#include <sfx2/app.hxx>
81#include <sfx2/sfxuno.hxx>
82#include <sfx2/viewsh.hxx>
83#include <sfx2/bindings.hxx>
84#include <alienwarn.hxx>
85
86#include <memory>
87#include <string_view>
88
89#include <officecfg/Office/Common.hxx>
90
92#include <com/sun/star/system/SystemShellExecute.hpp>
93#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
94
95#include <osl/file.hxx>
96
97#ifdef _WIN32
98#include <Shlobj.h>
99#ifdef GetTempPath
100#undef GetTempPath
101#endif
102#endif
103
104// flags that specify requested operation
105#define EXPORT_REQUESTED 1
106#define PDFEXPORT_REQUESTED 2
107#define PDFDIRECTEXPORT_REQUESTED 4
108#define WIDEEXPORT_REQUESTED 8
109#define SAVE_REQUESTED 16
110#define SAVEAS_REQUESTED 32
111#define SAVEACOPY_REQUESTED 64
112#define EPUBEXPORT_REQUESTED 128
113#define EPUBDIRECTEXPORT_REQUESTED 256
114#define SAVEASREMOTE_REQUESTED -1
115
116// possible statuses of save operation
117#define STATUS_NO_ACTION 0
118#define STATUS_SAVE 1
119#define STATUS_SAVEAS 2
120#define STATUS_SAVEAS_STANDARDNAME 3
121
122constexpr OUStringLiteral aFilterNameString = u"FilterName";
123constexpr OUStringLiteral aFilterOptionsString = u"FilterOptions";
124constexpr OUStringLiteral aFilterDataString = u"FilterData";
125
126using namespace ::com::sun::star;
127using namespace css::system;
128
129namespace {
130
131sal_uInt16 getSlotIDFromMode( sal_Int16 nStoreMode )
132{
133 // This is a temporary hardcoded solution must be removed when
134 // dialogs do not need parameters in SidSet representation any more
135
136 sal_uInt16 nResult = 0;
137 if ( nStoreMode == EXPORT_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | SAVEACOPY_REQUESTED | WIDEEXPORT_REQUESTED ) )
138 nResult = SID_EXPORTDOC;
139 else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED ) )
140 nResult = SID_EXPORTDOCASPDF;
141 else if ( nStoreMode == ( EXPORT_REQUESTED | EPUBEXPORT_REQUESTED ) )
142 nResult = SID_EXPORTDOCASEPUB;
143 else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED | PDFDIRECTEXPORT_REQUESTED ) )
144 nResult = SID_DIRECTEXPORTDOCASPDF;
146 nResult = SID_DIRECTEXPORTDOCASEPUB;
147 else if ( nStoreMode == SAVEAS_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | WIDEEXPORT_REQUESTED ) )
148 nResult = SID_SAVEASDOC;
149 else if ( nStoreMode == SAVEASREMOTE_REQUESTED )
150 nResult = SID_SAVEASREMOTE;
151 else {
152 SAL_WARN( "sfx.doc", "Unacceptable slot name is provided!" );
153 }
154
155 return nResult;
156}
157
158
159sal_Int16 getStoreModeFromSlotName( std::u16string_view aSlotName )
160{
161 sal_Int16 nResult = 0;
162 if ( aSlotName == u"ExportTo" )
163 nResult = EXPORT_REQUESTED;
164 else if ( aSlotName == u"ExportToPDF" )
166 else if ( aSlotName == u"ExportDirectToPDF" )
168 else if ( aSlotName == u"ExportToEPUB" )
170 else if ( aSlotName == u"ExportDirectToEPUB" )
172 else if ( aSlotName == u"Save" )
173 nResult = SAVE_REQUESTED;
174 else if ( aSlotName == u"SaveAs" )
175 nResult = SAVEAS_REQUESTED;
176 else if ( aSlotName == u"SaveAsRemote" )
177 nResult = SAVEASREMOTE_REQUESTED;
178 else
179 throw task::ErrorCodeIOException(
180 (OUString::Concat("getStoreModeFromSlotName(\"") + aSlotName
181 + "): ERRCODE_IO_INVALIDPARAMETER"),
182 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_INVALIDPARAMETER) );
183
184 return nResult;
185}
186
187
188SfxFilterFlags getMustFlags( sal_Int16 nStoreMode )
189{
190 return ( SfxFilterFlags::EXPORT
191 | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SfxFilterFlags::NONE : SfxFilterFlags::IMPORT ) );
192}
193
194
195SfxFilterFlags getDontFlags( sal_Int16 nStoreMode )
196{
197 return ( SfxFilterFlags::INTERNAL
198 | SfxFilterFlags::NOTINFILEDLG
199 | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SfxFilterFlags::IMPORT : SfxFilterFlags::NONE ) );
200}
201
202
203
204
205class DocumentSettingsGuard
206{
207 uno::Reference< beans::XPropertySet > m_xDocumentSettings;
208 bool m_bPreserveReadOnly;
209 bool m_bReadOnlySupported;
210
211 bool m_bRestoreSettings;
212public:
213 DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, bool bReadOnly, bool bRestore )
214 : m_bPreserveReadOnly( false )
215 , m_bReadOnlySupported( false )
216 , m_bRestoreSettings( bRestore )
217 {
218 try
219 {
220 uno::Reference< lang::XMultiServiceFactory > xDocSettingsSupplier( xModel, uno::UNO_QUERY_THROW );
221 m_xDocumentSettings.set(
222 xDocSettingsSupplier->createInstance( "com.sun.star.document.Settings" ),
223 uno::UNO_QUERY_THROW );
224
225 try
226 {
227 OUString aLoadReadonlyString( "LoadReadonly" );
228 m_xDocumentSettings->getPropertyValue( aLoadReadonlyString ) >>= m_bPreserveReadOnly;
229 m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::Any( bReadOnly ) );
230 m_bReadOnlySupported = true;
231 }
232 catch( const uno::Exception& )
233 {}
234 }
235 catch( const uno::Exception& )
236 {}
237
238 if ( bReadOnly && !m_bReadOnlySupported )
239 throw uno::RuntimeException(); // the user could provide the data, so it must be stored
240 }
241
242 ~DocumentSettingsGuard()
243 {
244 if ( m_bRestoreSettings )
245 {
246 try
247 {
248 if ( m_bReadOnlySupported )
249 m_xDocumentSettings->setPropertyValue( "LoadReadonly", uno::Any( m_bPreserveReadOnly ) );
250 }
251 catch( const uno::Exception& )
252 {
253 TOOLS_WARN_EXCEPTION( "sfx.doc", "" );
254 }
255 }
256 }
257};
258} // anonymous namespace
259
260
261
263{
265 uno::Reference< frame::XModel > m_xModel;
266 uno::Reference< frame::XStorable > m_xStorable;
267 uno::Reference< frame::XStorable2 > m_xStorable2;
268
270 std::unique_ptr<::comphelper::SequenceAsHashMap> m_pDocumentPropsHM;
271 std::unique_ptr<::comphelper::SequenceAsHashMap> m_pModulePropsHM;
272
273 uno::Reference<beans::XPropertyAccess> m_xFilterProperties;
274 uno::Reference<ui::dialogs::XAsynchronousExecutableDialog> m_xFilterDialog;
275
277
279
280 DECL_LINK(OptionsDialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
281
282public:
284 uno::Reference< frame::XModel > xModel,
285 const uno::Sequence< beans::PropertyValue >& aMediaDescr );
286
288
289 void FreeDocumentProps();
290
291 uno::Reference< frame::XModel > const & GetModel() const;
292 uno::Reference< frame::XStorable > const & GetStorable();
293 uno::Reference< frame::XStorable2 > const & GetStorable2();
294
296
298
299 const ::comphelper::SequenceAsHashMap& GetDocProps();
300
301 OUString const & GetModuleName();
302 const ::comphelper::SequenceAsHashMap& GetModuleProps();
303
305
306
307 OUString GetDocServiceName();
308 uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilterCheckFlags( SfxFilterFlags nMust, SfxFilterFlags nDont );
309 uno::Sequence< beans::PropertyValue > GetDocServiceAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont );
310 uno::Sequence< beans::PropertyValue > GetPreselectedFilter_Impl( sal_Int16 nStoreMode );
311 uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilter();
312
313 bool ExecuteFilterDialog_Impl( const OUString& aFilterName, bool bAsync );
314
317
318 sal_Int8 CheckFilter( const OUString& );
319
321
322 bool OutputFileDialog( sal_Int16 nStoreMode,
323 const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM,
324 bool bSetStandardName,
325 OUString& aSuggestedName,
326 bool bPreselectPassword,
327 OUString& aSuggestedDir,
328 sal_Int16 nDialog,
329 const OUString& rStandardDir,
330 const css::uno::Sequence< OUString >& rDenyList
331 );
332
334
335 static OUString GetRecommendedExtension( const OUString& aTypeName );
336 OUString GetRecommendedDir( const OUString& aSuggestedDir );
337 OUString GetRecommendedName( const OUString& aSuggestedName,
338 const OUString& aTypeName );
339};
340
341
343 uno::Reference< frame::XModel > xModel,
344 const uno::Sequence< beans::PropertyValue >& aMediaDescr )
345: m_pOwner( &aOwner )
346, m_xModel(std::move( xModel ))
347, m_aMediaDescrHM( aMediaDescr )
348, m_bRecommendReadOnly( false )
349{
351}
352
353
355{
357 m_pDocumentPropsHM.reset();
358 m_pModulePropsHM.reset();
360 m_xFilterProperties.clear();
361}
362
363
365{
366 m_pDocumentPropsHM.reset();
367}
368
369
370uno::Reference< frame::XModel > const & ModelData_Impl::GetModel() const
371{
372 if ( !m_xModel.is() )
373 throw uno::RuntimeException();
374
375 return m_xModel;
376}
377
378
379uno::Reference< frame::XStorable > const & ModelData_Impl::GetStorable()
380{
381 if ( !m_xStorable.is() )
382 {
383 m_xStorable.set( m_xModel, uno::UNO_QUERY_THROW );
384 }
385
386 return m_xStorable;
387}
388
389
390uno::Reference< frame::XStorable2 > const & ModelData_Impl::GetStorable2()
391{
392 if ( !m_xStorable2.is() )
393 {
394 m_xStorable2.set( m_xModel, uno::UNO_QUERY_THROW );
395 }
396
397 return m_xStorable2;
398}
399
400
401const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetDocProps()
402{
403 if ( !m_pDocumentPropsHM )
404 m_pDocumentPropsHM.reset( new ::comphelper::SequenceAsHashMap( GetModel()->getArgs() ) );
405
406 return *m_pDocumentPropsHM;
407}
408
409
411{
412 if ( m_aModuleName.isEmpty() )
413 {
415 uno::Reference< uno::XInterface >( m_xModel, uno::UNO_QUERY ) );
416 if ( m_aModuleName.isEmpty() )
417 throw uno::RuntimeException(); // TODO:
418 }
419 return m_aModuleName;
420}
421
422
423const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetModuleProps()
424{
425 if ( !m_pModulePropsHM )
426 {
427 uno::Sequence< beans::PropertyValue > aModuleProps;
428 m_pOwner->GetModuleManager()->getByName( GetModuleName() ) >>= aModuleProps;
429 if ( !aModuleProps.hasElements() )
430 throw uno::RuntimeException(); // TODO;
431 m_pModulePropsHM.reset( new ::comphelper::SequenceAsHashMap( aModuleProps ) );
432 }
433
434 return *m_pModulePropsHM;
435}
436
437
439{
440 return GetModuleProps().getUnpackedValueOrDefault("ooSetupFactoryDocumentService", OUString());
441}
442
443
445{
446 static constexpr OUStringLiteral sInteractionHandler {u"InteractionHandler"};
448 m_aMediaDescrHM.find( sInteractionHandler );
449
450 if ( aInteractIter == m_aMediaDescrHM.end() )
451 {
452 try {
453 m_aMediaDescrHM[ sInteractionHandler ]
454 <<= task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr);
455 }
456 catch( const uno::Exception& )
457 {
458 }
459 }
460 else
461 {
462 uno::Reference< task::XInteractionHandler > xInteract;
463 DBG_ASSERT( ( aInteractIter->second >>= xInteract ) && xInteract.is(), "Broken interaction handler is provided!\n" );
464 }
465}
466
467
468uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceDefaultFilter()
469{
470 uno::Sequence< beans::PropertyValue > aProps;
471
472 const OUString aFilterName = GetModuleProps().getUnpackedValueOrDefault( "ooSetupFactoryDefaultFilter", OUString() );
473
474 m_pOwner->GetFilterConfiguration()->getByName( aFilterName ) >>= aProps;
475
476 return aProps;
477}
478
479
480uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceDefaultFilterCheckFlags( SfxFilterFlags nMust,
481 SfxFilterFlags nDont )
482{
483 uno::Sequence< beans::PropertyValue > aFilterProps;
484 uno::Sequence< beans::PropertyValue > aProps = GetDocServiceDefaultFilter();
485 if ( aProps.hasElements() )
486 {
487 ::comphelper::SequenceAsHashMap aFiltHM( aProps );
488 SfxFilterFlags nFlags = static_cast<SfxFilterFlags>(aFiltHM.getUnpackedValueOrDefault("Flags",
489 sal_Int32(0) ));
490 if ( ( ( nFlags & nMust ) == nMust ) && !( nFlags & nDont ) )
491 aFilterProps = aProps;
492 }
493
494 return aFilterProps;
495}
496
497
498uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont )
499{
500 uno::Sequence< beans::NamedValue > aSearchRequest { { "DocumentService", css::uno::Any(GetDocServiceName()) } };
501
502 return ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
503}
504
505
506uno::Sequence< beans::PropertyValue > ModelData_Impl::GetPreselectedFilter_Impl( sal_Int16 nStoreMode )
507{
508 if ( nStoreMode == SAVEASREMOTE_REQUESTED )
509 nStoreMode = SAVEAS_REQUESTED;
510
511 uno::Sequence< beans::PropertyValue > aFilterProps;
512
513 SfxFilterFlags nMust = getMustFlags( nStoreMode );
514 SfxFilterFlags nDont = getDontFlags( nStoreMode );
515
516 if ( ( nStoreMode != SAVEASREMOTE_REQUESTED ) && ( nStoreMode & PDFEXPORT_REQUESTED ) )
517 {
518 // Preselect PDF-Filter for EXPORT
519 uno::Sequence< beans::NamedValue > aSearchRequest
520 {
521 { "Type", css::uno::Any(OUString("pdf_Portable_Document_Format")) },
522 { "DocumentService", css::uno::Any(GetDocServiceName()) }
523 };
524
525 aFilterProps = ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
526 }
527 else if ( ( nStoreMode != SAVEASREMOTE_REQUESTED ) && ( nStoreMode & EPUBEXPORT_REQUESTED ) )
528 {
529 // Preselect EPUB filter for export.
530 uno::Sequence<beans::NamedValue> aSearchRequest
531 {
532 { "Type", css::uno::Any(OUString("writer_EPUB_Document")) },
533 { "DocumentService", css::uno::Any(GetDocServiceName()) }
534 };
535
536 aFilterProps = ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
537 }
538 else
539 {
540 aFilterProps = GetDocServiceDefaultFilterCheckFlags( nMust, nDont );
541
542 if ( !aFilterProps.hasElements() )
543 {
544 // the default filter was not found, use just the first acceptable one
545 aFilterProps = GetDocServiceAnyFilter( nMust, nDont );
546 }
547 }
548
549 return aFilterProps;
550}
551
552
553bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName, bool bIsAsync )
554{
555 bool bDialogUsed = false;
556
557 try {
558 uno::Sequence < beans::PropertyValue > aProps;
559 uno::Any aAny = m_pOwner->GetFilterConfiguration()->getByName( aFilterName );
560 if ( aAny >>= aProps )
561 {
562 auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps),
563 [](const beans::PropertyValue& rProp) { return rProp.Name == "UIComponent"; });
564 if (pProp != std::cend(aProps))
565 {
566 OUString aServiceName;
567 pProp->Value >>= aServiceName;
568 if( !aServiceName.isEmpty() )
569 {
570 uno::Sequence<uno::Any> aDialogArgs(comphelper::InitAnyPropertySequence(
571 {
573 }));
574
575 uno::Reference< beans::XPropertyAccess > xFilterProperties;
576 uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog;
577 uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xAsyncFilterDialog;
578 uno::Reference< document::XExporter > xExporter;
579
580 if ( bIsAsync )
581 {
582 xAsyncFilterDialog = uno::Reference< ui::dialogs::XAsynchronousExecutableDialog >(
583 comphelper::getProcessServiceFactory()->createInstanceWithArguments( aServiceName, aDialogArgs ), uno::UNO_QUERY );
584 OSL_ENSURE(xAsyncFilterDialog.is(), "ModelData_Impl::ExecuteFilterDialog_Impl: Dialog is not async!");
585 xFilterProperties = uno::Reference< beans::XPropertyAccess >( xAsyncFilterDialog, uno::UNO_QUERY );
586 xExporter = uno::Reference< document::XExporter >( xAsyncFilterDialog, uno::UNO_QUERY );
587 }
588 else
589 {
590 xFilterDialog = uno::Reference< ui::dialogs::XExecutableDialog >(
591 comphelper::getProcessServiceFactory()->createInstanceWithArguments( aServiceName, aDialogArgs ), uno::UNO_QUERY );
592 xFilterProperties = uno::Reference< beans::XPropertyAccess >( xFilterDialog, uno::UNO_QUERY );
593 xExporter = uno::Reference< document::XExporter >( xFilterDialog, uno::UNO_QUERY );
594 }
595
596 if ( xFilterProperties.is() && ( xFilterDialog.is() || xAsyncFilterDialog.is() ) )
597 {
598 bDialogUsed = true;
599
600 if( xExporter.is() )
601 xExporter->setSourceDocument( GetModel() );
602
603 uno::Sequence< beans::PropertyValue > aPropsForDialog;
604 GetMediaDescr() >> aPropsForDialog;
605 xFilterProperties->setPropertyValues( aPropsForDialog );
606
607 if ( bIsAsync )
608 {
609 m_xFilterProperties = xFilterProperties;
610 m_xFilterDialog = xAsyncFilterDialog;
611
612 auto aDialogClosedListener = rtl::Reference(new svt::DialogClosedListener());
613 aDialogClosedListener->SetDialogClosedLink( LINK( this, ModelData_Impl, OptionsDialogClosedHdl ) );
614
615 m_xFilterDialog->startExecuteModal( aDialogClosedListener );
616 }
617 else
618 {
619 if( !xFilterDialog->execute() )
620 {
621 throw task::ErrorCodeIOException(
622 ("ModelData_Impl::ExecuteFilterDialog_Impl:"
623 " ERRCODE_IO_ABORT"),
624 uno::Reference< uno::XInterface >(),
625 sal_uInt32(ERRCODE_IO_ABORT));
626 }
627
628 const uno::Sequence< beans::PropertyValue > aPropsFromDialog =
629 xFilterProperties->getPropertyValues();
630 for ( const auto& rProp : aPropsFromDialog )
631 GetMediaDescr()[rProp.Name] = rProp.Value;
632 }
633 }
634 }
635 }
636 }
637 }
638 catch( const container::NoSuchElementException& e )
639 {
640 // the filter name is unknown
641 throw task::ErrorCodeIOException(
642 ("ModelData_Impl::ExecuteFilterDialog_Impl: NoSuchElementException"
643 " \"" + e.Message + "\": ERRCODE_IO_ABORT"),
644 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_INVALIDPARAMETER));
645 }
646 catch( const task::ErrorCodeIOException& )
647 {
648 throw;
649 }
650 catch( const uno::Exception& )
651 {
652 TOOLS_WARN_EXCEPTION("sfx.doc", "ignoring");
653 }
654
655 return bDialogUsed;
656}
657
659{
660 ::comphelper::SequenceAsHashMap::const_iterator aFileNameIter = m_xModelData->GetMediaDescr().find( OUString("URL") );
661 uno::Sequence< beans::PropertyValue > aFilterProps = m_xModelData->GetPreselectedFilter_Impl( m_nStoreMode );
662 const OUString aFilterFromMediaDescr = m_xModelData->GetMediaDescr().getUnpackedValueOrDefault( aFilterNameString, OUString() );
663 const OUString aOldFilterName = m_xModelData->GetDocProps().getUnpackedValueOrDefault( aFilterNameString, OUString() );
664 ::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
665 OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
666
669 aFilterFromMediaDescr, aOldFilterName, m_aArgsSequence, aFilterName);
670
673}
674
675IMPL_LINK( ModelData_Impl, OptionsDialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvt, void )
676{
677 if (pEvt->DialogResult == RET_OK && m_xFilterProperties)
678 {
680 SfxViewShell::Current()->libreOfficeKitViewCallback( LOK_CALLBACK_EXPORT_FILE, "PENDING" );
681
682 const uno::Sequence< beans::PropertyValue > aPropsFromDialog = m_xFilterProperties->getPropertyValues();
683 for ( const auto& rProp : aPropsFromDialog )
684 GetMediaDescr()[rProp.Name] = rProp.Value;
685
686 m_pOwner->CallFinishGUIStoreModel();
687 }
689 {
690 SfxViewShell::Current()->libreOfficeKitViewCallback( LOK_CALLBACK_EXPORT_FILE, "ABORT" );
691 }
692}
693
695{
696 sal_Int8 nResult = nCurStatus;
697
698 if ( nResult != STATUS_NO_ACTION && GetStorable()->hasLocation() )
699 {
700 // the saving is acceptable
701 // in case the configuration entry is not set or set to false
702 // or in case of version creation
703 if ( officecfg::Office::Common::Save::Document::AlwaysSaveAs::get()
704 && GetMediaDescr().find( OUString("VersionComment") ) == GetMediaDescr().end() )
705 {
706 // notify the user that SaveAs is going to be done
707 std::unique_ptr<weld::MessageDialog> xMessageBox(Application::CreateMessageDialog(SfxStoringHelper::GetModelWindow(m_xModel),
708 VclMessageType::Question, VclButtonsType::OkCancel, SfxResId(STR_NEW_FILENAME_SAVE)));
709 if (xMessageBox->run() == RET_OK)
710 nResult = STATUS_SAVEAS;
711 else
712 nResult = STATUS_NO_ACTION;
713 }
714 }
715
716 return nResult;
717}
718
719
721{
722 // if the document is readonly or a new one a SaveAs operation must be used
723 if ( !GetStorable()->hasLocation() || GetStorable()->isReadonly() )
724 return STATUS_SAVEAS;
725
726 // check acceptable entries for media descriptor
728
729 static constexpr OUStringLiteral aVersionCommentString(u"VersionComment");
730 static constexpr OUStringLiteral aAuthorString(u"Author");
731 static constexpr OUStringLiteral aDontTerminateEdit(u"DontTerminateEdit");
732 static constexpr OUStringLiteral aInteractionHandlerString(u"InteractionHandler");
733 static constexpr OUStringLiteral aStatusIndicatorString(u"StatusIndicator");
734 static constexpr OUStringLiteral aFailOnWarningString(u"FailOnWarning");
735 static constexpr OUStringLiteral aNoFileSync(u"NoFileSync");
736
737 if ( GetMediaDescr().find( aVersionCommentString ) != GetMediaDescr().end() )
738 aAcceptedArgs[ aVersionCommentString ] = GetMediaDescr()[ aVersionCommentString ];
739 if ( GetMediaDescr().find( aAuthorString ) != GetMediaDescr().end() )
740 aAcceptedArgs[ aAuthorString ] = GetMediaDescr()[ aAuthorString ];
741 if ( GetMediaDescr().find( aDontTerminateEdit ) != GetMediaDescr().end() )
742 aAcceptedArgs[ aDontTerminateEdit ] = GetMediaDescr()[ aDontTerminateEdit ];
743 if ( GetMediaDescr().find( aInteractionHandlerString ) != GetMediaDescr().end() )
744 aAcceptedArgs[ aInteractionHandlerString ] = GetMediaDescr()[ aInteractionHandlerString ];
745 if ( GetMediaDescr().find( aStatusIndicatorString ) != GetMediaDescr().end() )
746 aAcceptedArgs[ aStatusIndicatorString ] = GetMediaDescr()[ aStatusIndicatorString ];
747 if ( GetMediaDescr().find( aFailOnWarningString ) != GetMediaDescr().end() )
748 aAcceptedArgs[ aFailOnWarningString ] = GetMediaDescr()[ aFailOnWarningString ];
749 if (GetMediaDescr().find(aNoFileSync) != GetMediaDescr().end())
750 aAcceptedArgs[aNoFileSync] = GetMediaDescr()[aNoFileSync];
751
752 // remove unacceptable entry if there is any
753 DBG_ASSERT( GetMediaDescr().size() == aAcceptedArgs.size(),
754 "Unacceptable parameters are provided in Save request!\n" );
755 if ( GetMediaDescr().size() != aAcceptedArgs.size() )
756 GetMediaDescr() = aAcceptedArgs;
757
758 // check that the old filter is acceptable
759 return CheckFilter( GetDocProps().getUnpackedValueOrDefault(aFilterNameString, OUString()) );
760}
761
762sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName )
763{
765 SfxFilterFlags nFiltFlags = SfxFilterFlags::NONE;
766 if ( !aFilterName.isEmpty() )
767 {
768 // get properties of filter
769 uno::Sequence< beans::PropertyValue > aFilterProps;
770 m_pOwner->GetFilterConfiguration()->getByName( aFilterName ) >>= aFilterProps;
771
772 aFiltPropsHM = ::comphelper::SequenceAsHashMap( aFilterProps );
773 nFiltFlags = static_cast<SfxFilterFlags>(aFiltPropsHM.getUnpackedValueOrDefault("Flags", sal_Int32(0) ));
774 }
775
776 // only a temporary solution until default filter retrieving feature is implemented
777 // then GetDocServiceDefaultFilter() must be used
778 ::comphelper::SequenceAsHashMap aDefFiltPropsHM = GetDocServiceDefaultFilterCheckFlags( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT, SfxFilterFlags::NONE );
779 SfxFilterFlags nDefFiltFlags = static_cast<SfxFilterFlags>(aDefFiltPropsHM.getUnpackedValueOrDefault("Flags", sal_Int32(0) ));
780
781 bool bAsk = false;
782
783 // if the old filter is not acceptable
784 // and there is no default filter or it is not acceptable for requested parameters then proceed with saveAs
785 if ( ( aFiltPropsHM.empty() || !( nFiltFlags & SfxFilterFlags::EXPORT ) )
786 && ( aDefFiltPropsHM.empty() || !( nDefFiltFlags & SfxFilterFlags::EXPORT ) || nDefFiltFlags & SfxFilterFlags::INTERNAL ) )
787 return STATUS_SAVEAS;
788
789 // so at this point there is either an acceptable old filter or default one
790 if ( aFiltPropsHM.empty() || !( nFiltFlags & SfxFilterFlags::EXPORT ) )
791 {
792 // so the default filter must be acceptable
794 }
795 else if ( ( !( nFiltFlags & SfxFilterFlags::OWN ) || ( nFiltFlags & SfxFilterFlags::ALIEN ) )
796 && !aDefFiltPropsHM.empty()
797 && ( nDefFiltFlags & SfxFilterFlags::EXPORT ) && !( nDefFiltFlags & SfxFilterFlags::INTERNAL ))
798 {
799 bAsk = true;
800 }
801
802 // check if EncryptionData supports this output format
803 {
804 OUString aSupportedFilters;
805 const ::comphelper::SequenceAsHashMap& rDocumentProperties = GetDocProps();
806 const css::uno::Sequence<css::beans::NamedValue> aEncryptionData = rDocumentProperties.getUnpackedValueOrDefault("EncryptionData", css::uno::Sequence<css::beans::NamedValue>());
807 if (aEncryptionData != css::uno::Sequence<css::beans::NamedValue>())
808 {
809 for (const css::beans::NamedValue& aNamedValue : aEncryptionData)
810 {
811 if (aNamedValue.Name == "SupportedFilters")
812 {
813 aNamedValue.Value >>= aSupportedFilters;
814 }
815 }
816 }
817
818 // if 'SupportedFilters' is empty assume that all filters are supported.
819 if (!aSupportedFilters.isEmpty())
820 {
821 const OUString aSelectedFilter = aFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString());
822
823 aSupportedFilters = ";" + aSupportedFilters + ";";
824 const OUString aSearchToken = ";" + aSelectedFilter + ";";
825 bAsk = (aSupportedFilters.indexOf(aSearchToken) < 0);
826 }
827 }
828
829 if (bAsk)
830 {
831 // the default filter is acceptable and the old filter is alien one
832 // so ask to make a saveAs operation
833 const OUString aUIName = aFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString() );
834 const OUString aDefUIName = aDefFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString() );
835 const OUString aPreusedFilterName = GetDocProps().getUnpackedValueOrDefault("PreusedFilterName", OUString() );
836 const OUString aDefType = aDefFiltPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
837 const OUString aDefExtension = GetRecommendedExtension( aDefType );
838
839 if ( aPreusedFilterName != aFilterName && aUIName != aDefUIName )
840 {
842 static_cast<bool>( nDefFiltFlags & SfxFilterFlags::ALIEN ) ) )
844 }
845 }
846
847 return STATUS_SAVE;
848}
849
850
852{
853 uno::Sequence< beans::NamedValue > aSearchRequest { { "DocumentService", css::uno::Any(GetDocServiceName()) } };
854
855 uno::Reference< container::XEnumeration > xFilterEnum =
856 m_pOwner->GetFilterQuery()->createSubSetEnumerationByProperties( aSearchRequest );
857
858 while ( xFilterEnum->hasMoreElements() )
859 {
860 uno::Sequence< beans::PropertyValue > aProps;
861 if ( xFilterEnum->nextElement() >>= aProps )
862 {
863 ::comphelper::SequenceAsHashMap aPropsHM( aProps );
864 if ( !aPropsHM.getUnpackedValueOrDefault("UIComponent", OUString()).isEmpty() )
865 return true;
866 }
867 }
868
869 return false;
870}
871
872
873bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
874 const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM,
875 bool bSetStandardName,
876 OUString& aSuggestedName,
877 bool bPreselectPassword,
878 OUString& aSuggestedDir,
879 sal_Int16 nDialog,
880 const OUString& rStandardDir,
881 const css::uno::Sequence< OUString >& rDenyList)
882{
883 if ( nStoreMode == SAVEASREMOTE_REQUESTED )
884 nStoreMode = SAVEAS_REQUESTED;
885
886 bool bUseFilterOptions = false;
887
889 GetMediaDescr().find( OUString("Overwrite") );
890
891 // the file name must be specified if overwrite option is set
892 if ( aOverwriteIter != GetMediaDescr().end() )
893 throw task::ErrorCodeIOException(
894 "ModelData_Impl::OutputFileDialog: ERRCODE_IO_INVALIDPARAMETER",
895 uno::Reference< uno::XInterface >(),
896 sal_uInt32(ERRCODE_IO_INVALIDPARAMETER));
897
898 // no target file name is specified
899 // we need to show the file dialog
900
901 // check if we have a filter which allows for filter options, so we need a corresponding checkbox in the dialog
902 bool bAllowOptions = false;
903
904 // in case of Export, filter options dialog is used if available
905 if( !( nStoreMode & EXPORT_REQUESTED ) || ( nStoreMode & WIDEEXPORT_REQUESTED ) )
906 bAllowOptions = CheckFilterOptionsDialogExistence();
907
908 // get the filename by dialog ...
909 // create the file dialog
910 sal_Int16 aDialogMode = bAllowOptions
911 ? css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS
912 : css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
914
915 if( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
916 {
917 if ( (nStoreMode & PDFEXPORT_REQUESTED) || (nStoreMode & EPUBEXPORT_REQUESTED) )
918 aDialogMode = css::ui::dialogs::TemplateDescription::
919 FILESAVE_AUTOEXTENSION;
920 else
921 aDialogMode = css::ui::dialogs::TemplateDescription::
922 FILESAVE_AUTOEXTENSION_SELECTION;
923 aDialogFlags = FileDialogFlags::Export;
924 }
925
926 if( ( nStoreMode & EXPORT_REQUESTED ) && ( nStoreMode & SAVEACOPY_REQUESTED ) && ( nStoreMode & WIDEEXPORT_REQUESTED ) )
927 {
928 aDialogFlags = FileDialogFlags::SaveACopy;
929 }
930
931 std::unique_ptr<sfx2::FileDialogHelper> pFileDlg;
932
933 const OUString aDocServiceName {GetDocServiceName()};
934 DBG_ASSERT( !aDocServiceName.isEmpty(), "No document service for this module set!" );
935
936 SfxFilterFlags nMust = getMustFlags( nStoreMode );
937 SfxFilterFlags nDont = getDontFlags( nStoreMode );
939 if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
940 {
941 if ( ( nStoreMode & PDFEXPORT_REQUESTED ) && !aPreselectedFilterPropsHM.empty() )
942 {
943 // this is a PDF export
944 // the filter options has been shown already
945 const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
946 pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, u"pdf", rStandardDir, rDenyList, pFrameWin ));
947 pFileDlg->SetCurrentFilter( aFilterUIName );
948 }
949 else if ((nStoreMode & EPUBEXPORT_REQUESTED) && !aPreselectedFilterPropsHM.empty())
950 {
951 // This is an EPUB export, the filter options has been shown already.
952 const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
953 pFileDlg.reset(new sfx2::FileDialogHelper(aDialogMode, aDialogFlags, aFilterUIName, u"epub", rStandardDir, rDenyList, pFrameWin));
954 pFileDlg->SetCurrentFilter(aFilterUIName);
955 }
956 else
957 {
958 // This is the normal dialog
959 pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rDenyList, pFrameWin ));
960 }
961
963 if ( aDocServiceName == "com.sun.star.drawing.DrawingDocument" )
965 else if ( aDocServiceName == "com.sun.star.presentation.PresentationDocument" )
967 else if ( aDocServiceName == "com.sun.star.text.TextDocument" )
969 else if ( aDocServiceName == "com.sun.star.sheet.SpreadsheetDocument" )
971
973 pFileDlg->SetContext( eCtxt );
974
975 pFileDlg->CreateMatcher( aDocServiceName );
976
977 uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = pFileDlg->GetFilePicker();
978 uno::Reference< ui::dialogs::XFilePickerControlAccess > xControlAccess( xFilePicker, uno::UNO_QUERY );
979
980 if ( xControlAccess.is() )
981 {
982 xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, SfxResId(STR_EXPORTBUTTON) );
983 xControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, SfxResId(STR_LABEL_FILEFORMAT) );
984 }
985 }
986 else
987 {
988 // This is the normal save as dialog
989 pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog,
990 nMust, nDont, rStandardDir, rDenyList, pFrameWin ));
991 pFileDlg->CreateMatcher( aDocServiceName );
992
994 if ( aDocServiceName == "com.sun.star.drawing.DrawingDocument" )
996 else if ( aDocServiceName == "com.sun.star.presentation.PresentationDocument" )
998 else if ( aDocServiceName == "com.sun.star.text.TextDocument" )
1000 else if ( aDocServiceName == "com.sun.star.sheet.SpreadsheetDocument" )
1002
1004 pFileDlg->SetContext( eCtxt );
1005 }
1006
1007 OUString aAdjustToType;
1008
1009 const OUString sFilterNameString(aFilterNameString);
1010
1011 if ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
1012 {
1013 // it is export, set the preselected filter
1014 pFileDlg->SetCurrentFilter( aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() ) );
1015 aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
1016 }
1017 // it is no export, bSetStandardName == true means that user agreed to store document in the default (default default ;-)) format
1018 else if ( bSetStandardName || GetStorable()->hasLocation() )
1019 {
1020 uno::Sequence< beans::PropertyValue > aOldFilterProps;
1021 const OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
1022
1023 if ( !aOldFilterName.isEmpty() )
1024 m_pOwner->GetFilterConfiguration()->getByName( aOldFilterName ) >>= aOldFilterProps;
1025
1026 ::comphelper::SequenceAsHashMap aOldFiltPropsHM( aOldFilterProps );
1027 SfxFilterFlags nOldFiltFlags = static_cast<SfxFilterFlags>(aOldFiltPropsHM.getUnpackedValueOrDefault("Flags", sal_Int32(0) ));
1028
1029 if ( bSetStandardName || ( nOldFiltFlags & nMust ) != nMust || bool(nOldFiltFlags & nDont) )
1030 {
1031 // the suggested type will be changed, the extension should be adjusted
1032 aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "Type", OUString() );
1033 pFileDlg->SetCurrentFilter( aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() ) );
1034 }
1035 else
1036 {
1037 pFileDlg->SetCurrentFilter( aOldFiltPropsHM.getUnpackedValueOrDefault(
1038 "UIName",
1039 OUString() ) );
1040 }
1041 }
1042
1043 const OUString aRecommendedDir {GetRecommendedDir( aSuggestedDir )};
1044 if ( !aRecommendedDir.isEmpty() )
1045 pFileDlg->SetDisplayFolder( aRecommendedDir );
1046 const OUString aRecommendedName {GetRecommendedName( aSuggestedName, aAdjustToType )};
1047 if ( !aRecommendedName.isEmpty() )
1048 pFileDlg->SetFileName( aRecommendedName );
1049
1050 uno::Reference < view::XSelectionSupplier > xSel( GetModel()->getCurrentController(), uno::UNO_QUERY );
1051 if ( xSel.is() && xSel->getSelection().hasValue() )
1052 GetMediaDescr()[OUString("SelectionOnly")] <<= true;
1053
1054 // This is a temporary hardcoded solution must be removed when
1055 // dialogs do not need parameters in SidSet representation any more
1056 sal_uInt16 nSlotID = getSlotIDFromMode( nStoreMode );
1057 if ( !nSlotID )
1058 throw lang::IllegalArgumentException(); // TODO:
1059
1060 // generate SidSet from MediaDescriptor and provide it into FileDialog
1061 // than merge changed SidSet back
1062 std::optional<SfxAllItemSet> pDialogParams( SfxGetpApp()->GetPool() );
1063 TransformParameters( nSlotID,
1064 GetMediaDescr().getAsConstPropertyValueList(),
1065 *pDialogParams );
1066
1067 if ( bPreselectPassword && !pDialogParams->HasItem( SID_ENCRYPTIONDATA ) )
1068 {
1069 // the file dialog preselects the password checkbox if the provided mediadescriptor has encryption data entry
1070 // after dialog execution the password interaction flag will be either removed or not
1071 pDialogParams->Put( SfxBoolItem( SID_PASSWORDINTERACTION, true ) );
1072 }
1073
1074 // aFilterName is a pure output parameter, pDialogParams is an in/out parameter
1075 OUString aFilterName;
1076 // in LOK case we don't show File Picker so it will fail, but execute to do other preparations
1077 if ( pFileDlg->Execute( pDialogParams, aFilterName ) != ERRCODE_NONE
1079 {
1080 throw task::ErrorCodeIOException(
1081 "ModelData_Impl::OutputFileDialog: ERRCODE_IO_ABORT",
1082 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
1083 }
1085 {
1086 aFilterName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
1087 }
1088
1089 // the following two arguments can not be converted in MediaDescriptor,
1090 // so they should be removed from the ItemSet after retrieving
1091 const SfxBoolItem* pRecommendReadOnly = SfxItemSet::GetItem<SfxBoolItem>(&*pDialogParams, SID_RECOMMENDREADONLY, false);
1092 m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() );
1093 pDialogParams->ClearItem( SID_RECOMMENDREADONLY );
1094
1095 uno::Sequence< beans::PropertyValue > aPropsFromDialog;
1096 TransformItems( nSlotID, *pDialogParams, aPropsFromDialog );
1097 GetMediaDescr() << aPropsFromDialog;
1098
1099 // get the path from the dialog
1100 INetURLObject aURL( pFileDlg->GetPath() );
1101
1103 {
1104 // keep name with extension
1105 aSuggestedName = aRecommendedName;
1106 OUString aExtension;
1107 if (size_t nPos = aSuggestedName.lastIndexOf('.') + 1)
1108 aExtension = aSuggestedName.copy(nPos, aSuggestedName.getLength() - nPos);
1109 aURL.SetExtension(aExtension);
1110 }
1111 else
1112 {
1113 // the path should be provided outside since it might be used for further calls to the dialog
1114 aSuggestedName = aURL.GetLastName(INetURLObject::DecodeMechanism::WithCharset);
1115 }
1116 aSuggestedDir = pFileDlg->GetDisplayDirectory();
1117
1118 // old filter options should be cleared in case different filter is used
1119
1120 const OUString aFilterFromMediaDescr = GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
1121 const OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
1122
1123 if ( aFilterName == aFilterFromMediaDescr )
1124 {
1125 // preserve current settings if any
1126 // if there no current settings and the name is the same
1127 // as old filter name use old filter settings
1128
1129 if ( aFilterFromMediaDescr == aOldFilterName )
1130 {
1133 if ( aIter != GetDocProps().end()
1135 GetMediaDescr()[aIter->first] = aIter->second;
1136
1137 aIter = GetDocProps().find( aFilterDataString );
1138 if ( aIter != GetDocProps().end()
1140 GetMediaDescr()[aIter->first] = aIter->second;
1141 }
1142 }
1143 else
1144 {
1147
1148 if ( aFilterName == aOldFilterName )
1149 {
1150 // merge filter option of the document filter
1151
1154 if ( aIter != GetDocProps().end() )
1155 GetMediaDescr()[aIter->first] = aIter->second;
1156
1157 aIter = GetDocProps().find( aFilterDataString );
1158 if ( aIter != GetDocProps().end() )
1159 GetMediaDescr()[aIter->first] = aIter->second;
1160 }
1161 }
1162
1163 uno::Reference< ui::dialogs::XFilePickerControlAccess > xExtFileDlg( pFileDlg->GetFilePicker(), uno::UNO_QUERY );
1164 if ( xExtFileDlg.is() )
1165 {
1167 bUseFilterOptions = true;
1168
1169 if ( ( !( nStoreMode & EXPORT_REQUESTED ) || ( nStoreMode & WIDEEXPORT_REQUESTED ) ) && bUseFilterOptions )
1170 {
1171 try
1172 {
1173 // for exporters: always show dialog if format uses options
1174 // for save: show dialog if format uses options and no options given or if forced by user
1175 uno::Any aVal =
1176 xExtFileDlg->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, 0 );
1177
1178 aVal >>= bUseFilterOptions;
1179 if ( !bUseFilterOptions )
1180 bUseFilterOptions =
1183 }
1184 catch( const lang::IllegalArgumentException& )
1185 {}
1186 }
1187 }
1188
1189 // merge in results of the dialog execution
1190 GetMediaDescr()[OUString("URL")] <<= aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
1191 GetMediaDescr()[sFilterNameString] <<= aFilterName;
1192
1193 return bUseFilterOptions;
1194}
1195
1196
1198{
1199 bool bDialogUsed = false;
1200
1201 try {
1202 uno::Reference< frame::XController > xController = GetModel()->getCurrentController();
1203 if ( xController.is() )
1204 {
1205 uno::Reference< frame::XDispatchProvider > xFrameDispatch( xController->getFrame(), uno::UNO_QUERY );
1206 if ( xFrameDispatch.is() )
1207 {
1208 util::URL aURL;
1209 aURL.Complete = ".uno:SetDocumentProperties";
1210
1211 uno::Reference < util::XURLTransformer > xTransformer( util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
1212 if ( xTransformer->parseStrict( aURL ) )
1213 {
1214 uno::Reference< frame::XDispatch > xDispatch = xFrameDispatch->queryDispatch(
1215 aURL,
1216 "_self",
1217 0 );
1218 if ( xDispatch.is() )
1219 {
1220 // tdf#119206 use (abuse?) a SynchronMode of true,
1221 // which will become SfxRequest::IsSynchronCall of true
1222 // in SfxObjectShell::ExecFile_Impl to request that we
1223 // do not want the properties dialog to be run async
1224 uno::Sequence< beans::PropertyValue > aProperties{
1225 comphelper::makePropertyValue("SynchronMode", true)
1226 };
1227 xDispatch->dispatch(aURL, aProperties);
1228 bDialogUsed = true;
1229 }
1230 }
1231 }
1232 }
1233 }
1234 catch ( const uno::Exception& )
1235 {
1236 }
1237
1238 return bDialogUsed;
1239}
1240
1241
1242OUString ModelData_Impl::GetRecommendedExtension( const OUString& aTypeName )
1243{
1244 if ( aTypeName.isEmpty() )
1245 return OUString();
1246
1247 uno::Reference< container::XNameAccess > xTypeDetection(
1248 comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"),
1249 uno::UNO_QUERY );
1250 if ( xTypeDetection.is() )
1251 {
1252 uno::Sequence< beans::PropertyValue > aTypeNameProps;
1253 if ( ( xTypeDetection->getByName( aTypeName ) >>= aTypeNameProps ) && aTypeNameProps.hasElements() )
1254 {
1255 ::comphelper::SequenceAsHashMap aTypeNamePropsHM( aTypeNameProps );
1256 uno::Sequence< OUString > aExtensions = aTypeNamePropsHM.getUnpackedValueOrDefault(
1257 "Extensions",
1258 ::uno::Sequence< OUString >() );
1259 if ( aExtensions.hasElements() )
1260 return aExtensions[0];
1261 }
1262 }
1263
1264 return OUString();
1265}
1266
1267
1268OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
1269{
1270 if ( ( !aSuggestedDir.isEmpty() || GetStorable()->hasLocation() )
1271 && !GetMediaDescr().getUnpackedValueOrDefault("RepairPackage", false ) )
1272 {
1273 INetURLObject aLocation;
1274 if ( !aSuggestedDir.isEmpty() )
1275 aLocation = INetURLObject( aSuggestedDir );
1276 else
1277 {
1278 const OUString aOldURL = GetStorable()->getLocation();
1279 if ( !aOldURL.isEmpty() )
1280 {
1281 INetURLObject aTmp( aOldURL );
1282 if ( aTmp.removeSegment() )
1283 aLocation = aTmp;
1284 }
1285
1286 if ( aLocation.HasError() )
1287 aLocation = INetURLObject();
1288 }
1289
1290 OUString sLocationURL( aLocation.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
1291 bool bIsInTempPath( false );
1292 OUString sSysTempPath;
1293 if( osl::FileBase::getTempDirURL( sSysTempPath ) == osl::FileBase::E_None )
1294 bIsInTempPath = !sSysTempPath.isEmpty() && sLocationURL.startsWith( sSysTempPath );
1295#ifdef _WIN32
1296 if( !bIsInTempPath )
1297 {
1298 wchar_t sPath[MAX_PATH+1];
1299 HRESULT hRes = SHGetFolderPathW( nullptr, CSIDL_INTERNET_CACHE, nullptr, SHGFP_TYPE_CURRENT, sPath );
1300 if( SUCCEEDED(hRes) )
1301 {
1302 OUString sTempINetFiles;
1303 if( osl::FileBase::getFileURLFromSystemPath(OUString(o3tl::toU(sPath)), sTempINetFiles) == osl::FileBase::E_None )
1304 bIsInTempPath = !sTempINetFiles.isEmpty() && sLocationURL.startsWith( sTempINetFiles );
1305 }
1306 }
1307#endif
1308 // Suggest somewhere other than the system's temp directory
1309 if( bIsInTempPath )
1310 aLocation = INetURLObject();
1311
1312 aLocation.setFinalSlash();
1313 if ( !aLocation.HasError() )
1315
1316 return OUString();
1317 }
1318
1319 return OUString();
1320}
1321
1322
1323OUString ModelData_Impl::GetRecommendedName( const OUString& aSuggestedName, const OUString& aTypeName )
1324{
1325 // the last used name might be provided by aSuggestedName from the old selection, or from the MediaDescriptor
1326 if ( !aSuggestedName.isEmpty() )
1327 return aSuggestedName;
1328
1329 OUString aRecommendedName{ INetURLObject(GetStorable()->getLocation())
1331 if ( aRecommendedName.isEmpty() )
1332 {
1333 try {
1334 uno::Reference< frame::XTitle > xTitle( GetModel(), uno::UNO_QUERY_THROW );
1335 aRecommendedName = xTitle->getTitle();
1336 } catch( const uno::Exception& ) {}
1337 }
1338
1339 if ( !aRecommendedName.isEmpty() && !aTypeName.isEmpty() )
1340 {
1341 // adjust the extension to the type
1342 uno::Reference< container::XNameAccess > xTypeDetection(
1343 comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"),
1344 uno::UNO_QUERY );
1345 if ( xTypeDetection.is() )
1346 {
1347 INetURLObject aObj( rtl::Concat2View("c:/" + aRecommendedName), INetProtocol::File,
1348 INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_UTF8, FSysStyle::Dos );
1349
1350 const OUString aExtension = GetRecommendedExtension( aTypeName );
1351 if ( !aExtension.isEmpty() )
1352 aObj.SetExtension( aExtension );
1353
1355 }
1356 }
1357
1358 return aRecommendedName;
1359}
1360
1362 : m_bRemote(false)
1363 , m_bPreselectPassword(false)
1364 , m_bDialogUsed(false)
1365 , m_bSetStandardName(false)
1366 , m_nStoreMode(0)
1367{
1368}
1369
1370uno::Reference< container::XNameAccess > const & SfxStoringHelper::GetFilterConfiguration()
1371{
1372 if ( !m_xFilterCFG.is() )
1373 {
1374 m_xFilterCFG.set( comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.FilterFactory"),
1375 uno::UNO_QUERY_THROW );
1376 }
1377
1378 return m_xFilterCFG;
1379}
1380
1381uno::Reference< container::XContainerQuery > const & SfxStoringHelper::GetFilterQuery()
1382{
1383 if ( !m_xFilterQuery.is() )
1384 {
1385 m_xFilterQuery.set( GetFilterConfiguration(), uno::UNO_QUERY_THROW );
1386 }
1387
1388 return m_xFilterQuery;
1389}
1390
1391uno::Reference< css::frame::XModuleManager2 > const & SfxStoringHelper::GetModuleManager()
1392{
1393 if ( !m_xModuleManager.is() )
1394 {
1395 m_xModuleManager = frame::ModuleManager::create(
1397 }
1398
1399 return m_xModuleManager;
1400}
1401
1402bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xModel,
1403 std::u16string_view aSlotName,
1404 uno::Sequence< beans::PropertyValue >& aArgsSequence,
1405 bool bPreselectPassword,
1406 SignatureState nDocumentSignatureState,
1407 bool bIsAsync)
1408{
1409 m_xModelData = std::make_shared<ModelData_Impl>( *this, xModel, aArgsSequence );
1410 m_aArgsSequence = aArgsSequence;
1411 ModelData_Impl& aModelData = *m_xModelData;
1412
1413 m_bDialogUsed = false;
1414
1415 m_bSetStandardName = false; // can be set only for SaveAs
1416 m_bPreselectPassword = bPreselectPassword;
1417
1418 // parse the slot name
1419 m_bRemote = false;
1420 m_nStoreMode = getStoreModeFromSlotName( aSlotName );
1421
1423 {
1425 m_bRemote = true;
1426 }
1427
1428 sal_Int8 nStatusSave = STATUS_NO_ACTION;
1429
1431 aModelData.GetMediaDescr().find( OUString("SaveACopy") );
1432 if ( aSaveACopyIter != aModelData.GetMediaDescr().end() )
1433 {
1434 bool bSaveACopy = false;
1435 aSaveACopyIter->second >>= bSaveACopy;
1436 if ( bSaveACopy )
1438 }
1439 // handle the special cases
1441 {
1443 aModelData.GetMediaDescr().find( OUString("SaveTo") );
1444 if ( aSaveToIter != aModelData.GetMediaDescr().end() )
1445 {
1446 bool bWideExport = false;
1447 aSaveToIter->second >>= bWideExport;
1448 if ( bWideExport )
1450 }
1451
1452 // if saving is not acceptable the warning must be shown even in case of SaveAs operation
1454 throw task::ErrorCodeIOException(
1455 "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
1456 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
1457 }
1458 else if ( m_nStoreMode & SAVE_REQUESTED )
1459 {
1460 // if saving is not acceptable by the configuration the warning must be shown
1461 nStatusSave = aModelData.CheckSaveAcceptable( STATUS_SAVE );
1462
1463 if ( nStatusSave == STATUS_NO_ACTION )
1464 throw task::ErrorCodeIOException(
1465 "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
1466 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
1467 else if ( nStatusSave == STATUS_SAVE )
1468 {
1469 // check whether it is possible to use save operation
1470 nStatusSave = aModelData.CheckStateForSave();
1471 }
1472
1473 if ( nStatusSave == STATUS_NO_ACTION )
1474 {
1475 throw task::ErrorCodeIOException(
1476 "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
1477 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
1478 }
1479 else if ( nStatusSave != STATUS_SAVE )
1480 {
1481 // this should be a usual SaveAs operation
1483 if ( nStatusSave == STATUS_SAVEAS_STANDARDNAME )
1484 m_bSetStandardName = true;
1485 }
1486 }
1487
1489 {
1491
1492 // if it is no export, warn user that the signature will be removed
1493 if ( !pDocShell->IsRememberingSignature()
1494 && (SignatureState::OK == nDocumentSignatureState
1495 || SignatureState::INVALID == nDocumentSignatureState
1496 || SignatureState::NOTVALIDATED == nDocumentSignatureState
1497 || SignatureState::PARTIAL_OK == nDocumentSignatureState) )
1498 {
1499 std::unique_ptr<weld::MessageDialog> xMessageBox(Application::CreateMessageDialog(SfxStoringHelper::GetModelWindow(xModel),
1500 VclMessageType::Question, VclButtonsType::YesNo, SfxResId(RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE)));
1501 if (xMessageBox->run() != RET_YES)
1502 {
1503 // the user has decided not to store the document
1504 throw task::ErrorCodeIOException(
1505 "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT (Preserve Signature)",
1506 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
1507 }
1508 }
1509 }
1510
1511 if ( m_nStoreMode & SAVE_REQUESTED && nStatusSave == STATUS_SAVE )
1512 {
1513 // Document properties can contain streams that should be freed before storing
1514 aModelData.FreeDocumentProps();
1515
1516 if ( aModelData.GetStorable2().is() )
1517 {
1518 try
1519 {
1520 aModelData.GetStorable2()->storeSelf( aModelData.GetMediaDescr().getAsConstPropertyValueList() );
1521 }
1522 catch (const lang::IllegalArgumentException&)
1523 {
1524 TOOLS_WARN_EXCEPTION("sfx.doc", "Ignoring parameters! ModelData considers this illegal");
1525 aModelData.GetStorable()->store();
1526 }
1527 }
1528 else
1529 {
1530 OSL_FAIL( "XStorable2 is not supported by the model!" );
1531 aModelData.GetStorable()->store();
1532 }
1533
1534 return false;
1535 }
1536
1537 // preselect a filter for the storing process
1538 uno::Sequence< beans::PropertyValue > aFilterProps = aModelData.GetPreselectedFilter_Impl( m_nStoreMode );
1539
1540 DBG_ASSERT( aFilterProps.hasElements(), "No filter for storing!\n" );
1541 if ( !aFilterProps.hasElements() )
1542 throw task::ErrorCodeIOException(
1543 "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_INVALIDPARAMETER",
1544 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_INVALIDPARAMETER));
1545
1546 ::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
1547 OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
1548
1549 const OUString aFilterFromMediaDescr = aModelData.GetMediaDescr().getUnpackedValueOrDefault( aFilterNameString, OUString() );
1550 const OUString aOldFilterName = aModelData.GetDocProps().getUnpackedValueOrDefault( aFilterNameString, OUString() );
1551
1552 ::comphelper::SequenceAsHashMap::const_iterator aFileNameIter = aModelData.GetMediaDescr().find( OUString("URL") );
1553
1556 if ( ( m_nStoreMode & EXPORT_REQUESTED ) && (bPDFOptions || bEPUBOptions) )
1557 {
1558 // this is PDF or EPUB export, the filter options dialog should be shown before the export
1559 aModelData.GetMediaDescr()[aFilterNameString] <<= aFilterName;
1560 if ( aModelData.GetMediaDescr().find( "FilterFlags" ) == aModelData.GetMediaDescr().end()
1561 && aModelData.GetMediaDescr().find( aFilterOptionsString ) == aModelData.GetMediaDescr().end()
1562 && aModelData.GetMediaDescr().find( aFilterDataString ) == aModelData.GetMediaDescr().end() )
1563 {
1564 // execute filter options dialog since no options are set in the media descriptor
1565 if ( aModelData.ExecuteFilterDialog_Impl( aFilterName, bIsAsync ) )
1566 m_bDialogUsed = true;
1567 }
1568 }
1569
1570 if (bIsAsync)
1571 return false;
1572
1573 return SfxStoringHelper::FinishGUIStoreModel(aFileNameIter, aModelData, m_bRemote, m_nStoreMode, aFilterProps,
1575 aFilterFromMediaDescr, aOldFilterName, aArgsSequence, aFilterName);
1576}
1577
1579 ModelData_Impl& aModelData, bool bRemote, sal_Int16 nStoreMode,
1580 uno::Sequence< beans::PropertyValue >& aFilterProps,
1581 bool bSetStandardName, bool bPreselectPassword, bool bDialogUsed,
1582 std::u16string_view aFilterFromMediaDescr,
1583 std::u16string_view aOldFilterName,
1584 uno::Sequence< beans::PropertyValue >& aArgsSequence,
1585 OUString aFilterName)
1586{
1587 const OUString sFilterNameString(aFilterNameString);
1588 const OUString sFilterOptionsString(aFilterOptionsString);
1589 const OUString sFilterDataString(aFilterDataString);
1590 bool bUseFilterOptions = false;
1592
1593 if ( aFileNameIter == aModelData.GetMediaDescr().end() )
1594 {
1595 sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG;
1596
1597 if( bRemote )
1598 {
1599 nDialog = SFX2_IMPL_DIALOG_REMOTE;
1600 }
1601 else
1602 {
1604 aModelData.GetMediaDescr().find( OUString("UseSystemDialog") );
1605 if ( aDlgIter != aModelData.GetMediaDescr().end() )
1606 {
1607 bool bUseSystemDialog = true;
1608 if ( aDlgIter->second >>= bUseSystemDialog )
1609 {
1610 if ( bUseSystemDialog )
1611 nDialog = SFX2_IMPL_DIALOG_SYSTEM;
1612 else
1613 nDialog = SFX2_IMPL_DIALOG_OOO;
1614 }
1615 }
1616 }
1617
1618 // The Dispatch supports parameter FolderName that overwrites SuggestedSaveAsDir
1619 OUString aSuggestedDir = aModelData.GetMediaDescr().getUnpackedValueOrDefault("FolderName", OUString() );
1620 if ( aSuggestedDir.isEmpty() )
1621 {
1622 aSuggestedDir = aModelData.GetMediaDescr().getUnpackedValueOrDefault("SuggestedSaveAsDir", OUString() );
1623 if ( aSuggestedDir.isEmpty() )
1624 aSuggestedDir = aModelData.GetDocProps().getUnpackedValueOrDefault("SuggestedSaveAsDir", OUString() );
1625 }
1626
1627 OUString aSuggestedName = aModelData.GetMediaDescr().getUnpackedValueOrDefault("SuggestedSaveAsName", OUString() );
1628 if ( aSuggestedName.isEmpty() )
1629 aSuggestedName = aModelData.GetDocProps().getUnpackedValueOrDefault("SuggestedSaveAsName", OUString() );
1630
1631 OUString sStandardDir;
1633 aModelData.GetMediaDescr().find( OUString("StandardDir") );
1634 if ( aStdDirIter != aModelData.GetMediaDescr().end() )
1635 aStdDirIter->second >>= sStandardDir;
1636
1637 css::uno::Sequence< OUString > aDenyList;
1638
1640 aModelData.GetMediaDescr().find( OUString("DenyList") );
1641 if ( aDenyListIter != aModelData.GetMediaDescr().end() )
1642 aDenyListIter->second >>= aDenyList;
1643
1644 for (;;)
1645 {
1646 // in case the dialog is opened a second time the folder should be the same as previously navigated to by the user, not what was handed over by initial parameters
1647 bUseFilterOptions = aModelData.OutputFileDialog( nStoreMode, aFilterProps, bSetStandardName, aSuggestedName, bPreselectPassword, aSuggestedDir, nDialog, sStandardDir, aDenyList );
1648 if ( nStoreMode == SAVEAS_REQUESTED )
1649 {
1650 // in case of saving check filter for possible alien warning
1651 const OUString aSelFilterName = aModelData.GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
1652 sal_Int8 nStatusFilterSave = aModelData.CheckFilter( aSelFilterName );
1653 if ( nStatusFilterSave == STATUS_SAVEAS_STANDARDNAME )
1654 {
1655 // switch to best filter
1656 bSetStandardName = true;
1657 }
1658 else if ( nStatusFilterSave == STATUS_SAVE )
1659 {
1660 // user confirmed alien filter or "good" filter is used
1661 break;
1662 }
1663 }
1664 else
1665 break;
1666 }
1667
1668 bDialogUsed = true;
1669 aFileNameIter = aModelData.GetMediaDescr().find( OUString("URL") );
1670 }
1671 else
1672 {
1673 // the target file name is provided so check if new filter options
1674 // are provided or old options can be used
1675 if ( aFilterFromMediaDescr == aOldFilterName )
1676 {
1678 aModelData.GetDocProps().find( sFilterOptionsString );
1679 if ( aIter != aModelData.GetDocProps().end()
1680 && aModelData.GetMediaDescr().find( sFilterOptionsString ) == aModelData.GetMediaDescr().end() )
1681 aModelData.GetMediaDescr()[aIter->first] = aIter->second;
1682
1683 aIter = aModelData.GetDocProps().find( sFilterDataString );
1684 if ( aIter != aModelData.GetDocProps().end()
1685 && aModelData.GetMediaDescr().find( sFilterDataString ) == aModelData.GetMediaDescr().end() )
1686 aModelData.GetMediaDescr()[aIter->first] = aIter->second;
1687 }
1688 }
1689
1690 if ( aFileNameIter != aModelData.GetMediaDescr().end() )
1691 {
1692 OUString aFileName;
1693 aFileNameIter->second >>= aFileName;
1694 aURL.SetURL( aFileName );
1695 DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "Illegal URL!" );
1696
1698 aModelData.GetMediaDescr().find( sFilterNameString );
1699
1700 if ( aIter != aModelData.GetMediaDescr().end() )
1701 aIter->second >>= aFilterName;
1702 else
1703 aModelData.GetMediaDescr()[sFilterNameString] <<= aFilterName;
1704
1705 DBG_ASSERT( !aFilterName.isEmpty(), "Illegal filter!" );
1706 }
1707 else
1708 {
1709 SAL_WARN( "sfx.doc", "This code must be unreachable!" );
1710 throw task::ErrorCodeIOException(
1711 "SfxStoringHelper::GUIStoreModel: ERRCODE_IO_INVALIDPARAMETER",
1712 uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_INVALIDPARAMETER));
1713 }
1714
1716 aModelData.GetMediaDescr().find( OUString("FilterFlags") );
1717 bool bFilterFlagsSet = ( aIter != aModelData.GetMediaDescr().end() );
1718
1719 // check if the filter Dialog has not been called before
1720 if( !( nStoreMode & PDFEXPORT_REQUESTED ) && !( nStoreMode & EPUBEXPORT_REQUESTED ) && !bFilterFlagsSet
1721 && ( ( nStoreMode & EXPORT_REQUESTED ) || bUseFilterOptions ) )
1722 {
1723 // execute filter options dialog
1724 if ( aModelData.ExecuteFilterDialog_Impl( aFilterName, false ) )
1725 {
1726 bDialogUsed = true;
1727 // check if the file is a pdf or not and change the storing mode at convenience
1728 if (aFilterName.endsWith("pdf_Export"))
1730 }
1731 }
1732
1733 // so the arguments will not change any more and can be stored to the main location
1734 aArgsSequence = aModelData.GetMediaDescr().getAsConstPropertyValueList();
1735
1736 // store the document and handle it's docinfo
1737
1738 DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), nStoreMode & EXPORT_REQUESTED );
1739
1740 // Treat attempted PDF export like a print: update document print statistics
1741 if ((nStoreMode & PDFEXPORT_REQUESTED) && SfxViewShell::Current())
1742 {
1744 const bool bWasEnableSetModified = pDocShell && pDocShell->IsEnableSetModified();
1745 bool bResetESM = false;
1746
1747 if (bWasEnableSetModified
1748 && !officecfg::Office::Common::Print::PrintingModifiesDocument::get())
1749 {
1750 pDocShell->EnableSetModified(false); // don't let export mark document as modified
1751 bResetESM = true;
1752 }
1753
1754 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1755 aModelData.GetModel(), uno::UNO_QUERY_THROW);
1756 uno::Reference<document::XDocumentProperties> xDocProps(xDPS->getDocumentProperties());
1757 xDocProps->setPrintDate(DateTime(DateTime::SYSTEM).GetUNODateTime());
1758
1759 OUString sPrintedBy(SfxResId(STR_SFX_FILTERNAME_PDF));
1760 if (pDocShell && pDocShell->IsUseUserData())
1761 {
1762 const OUString& sFullName = SvtUserOptions().GetFullName();
1763 if (!sFullName.isEmpty())
1764 sPrintedBy += ": " + sFullName;
1765 }
1766 xDocProps->setPrintedBy(sPrintedBy);
1767
1768 if (bResetESM)
1769 pDocShell->EnableSetModified(true);
1770 }
1771
1772 OSL_ENSURE( aModelData.GetMediaDescr().find( OUString( "Password" ) ) == aModelData.GetMediaDescr().end(), "The Password property of MediaDescriptor should not be used here!" );
1773 if ( officecfg::Office::Common::Save::Document::EditProperty::get()
1774 && ( !aModelData.GetStorable()->hasLocation()
1775 || INetURLObject( aModelData.GetStorable()->getLocation() ) != aURL ) )
1776 {
1777 // this is definitely not a Save operation
1778 // so the document info can be updated
1779
1780 // on export document info must be preserved
1781 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1782 aModelData.GetModel(), uno::UNO_QUERY_THROW);
1783 uno::Reference<util::XCloneable> xCloneable(
1784 xDPS->getDocumentProperties(), uno::UNO_QUERY_THROW);
1785 uno::Reference<document::XDocumentProperties> xOldDocProps(
1786 xCloneable->createClone(), uno::UNO_QUERY_THROW);
1787
1788 // use dispatch API to show document info dialog
1789 if ( aModelData.ShowDocumentInfoDialog() )
1790 bDialogUsed = true;
1791 else
1792 {
1793 OSL_FAIL( "Can't execute document info dialog!" );
1794 }
1795
1796 try {
1797 // Document properties can contain streams that should be freed before storing
1798 aModelData.FreeDocumentProps();
1799 if ( nStoreMode & EXPORT_REQUESTED )
1800 aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
1801 else
1802 aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
1803 }
1804 catch( const uno::Exception& )
1805 {
1806 if ( nStoreMode & EXPORT_REQUESTED )
1807 {
1808 SetDocInfoState(aModelData.GetModel(), xOldDocProps);
1809 }
1810 throw;
1811 }
1812
1813 if ( nStoreMode & EXPORT_REQUESTED )
1814 {
1815 SetDocInfoState(aModelData.GetModel(), xOldDocProps);
1816 }
1817 }
1818 else
1819 {
1820 // Document properties can contain streams that should be freed before storing
1821 aModelData.FreeDocumentProps();
1822
1823 // this is actually a save operation with different parameters
1824 // so storeTo or storeAs without DocInfo operations are used
1825 if ( nStoreMode & EXPORT_REQUESTED )
1826 aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
1827 else
1828 aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
1829 }
1830
1831 // Launch PDF viewer
1833 {
1834 FilterConfigItem aItem(u"Office.Common/Filter/PDF/Export/");
1835 bool aViewPDF = aItem.ReadBool( "ViewPDFAfterExport", false );
1836
1837 if ( aViewPDF )
1838 {
1839 uno::Reference<XSystemShellExecute> xSystemShellExecute(SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
1840 xSystemShellExecute->execute( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), "", SystemShellExecuteFlags::URIS_ONLY );
1841 }
1842 }
1843
1845 {
1846 if ( SfxViewShell* pShell = SfxViewShell::Current() )
1847 {
1848 OUString sURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
1849 pShell->libreOfficeKitViewCallback( LOK_CALLBACK_EXPORT_FILE, sURL.toUtf8() );
1850 }
1851 }
1852
1853 return bDialogUsed;
1854}
1855
1856
1857// static
1859 const uno::Reference< container::XNameAccess >& xFilterCFG,
1860 const OUString& aFilterName )
1861{
1862 bool bUseFilterOptions = false;
1863
1864 DBG_ASSERT( xFilterCFG.is(), "No filter configuration!\n" );
1865 if( xFilterCFG.is() )
1866 {
1867 try {
1868 uno::Sequence < beans::PropertyValue > aProps;
1869 uno::Any aAny = xFilterCFG->getByName( aFilterName );
1870 if ( aAny >>= aProps )
1871 {
1872 ::comphelper::SequenceAsHashMap aPropsHM( aProps );
1873 if( !aPropsHM.getUnpackedValueOrDefault( "UIComponent", OUString() ).isEmpty() )
1874 bUseFilterOptions = true;
1875 }
1876 }
1877 catch( const uno::Exception& )
1878 {
1879 }
1880 }
1881
1882 return bUseFilterOptions;
1883}
1884
1885
1886// static
1888 const uno::Reference< frame::XModel >& xModel,
1889 const uno::Reference< document::XDocumentProperties>& i_xOldDocProps )
1890{
1891 uno::Reference<document::XDocumentPropertiesSupplier> const
1892 xModelDocPropsSupplier(xModel, uno::UNO_QUERY_THROW);
1893 uno::Reference<document::XDocumentProperties> const xDocPropsToFill =
1894 xModelDocPropsSupplier->getDocumentProperties();
1895 uno::Reference< beans::XPropertySet > const xPropSet(
1896 i_xOldDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
1897
1898 uno::Reference< util::XModifiable > xModifiable( xModel, uno::UNO_QUERY );
1899 if ( !xModifiable.is() )
1900 throw uno::RuntimeException();
1901
1902 bool bIsModified = xModifiable->isModified();
1903
1904 try
1905 {
1906 uno::Reference< beans::XPropertySet > const xSet(
1907 xDocPropsToFill->getUserDefinedProperties(), uno::UNO_QUERY);
1908 uno::Reference< beans::XPropertyContainer > xContainer( xSet, uno::UNO_QUERY );
1909 uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
1910 const uno::Sequence< beans::Property > lProps = xSetInfo->getProperties();
1911 for (const beans::Property& rProp : lProps)
1912 {
1913 uno::Any aValue = xPropSet->getPropertyValue( rProp.Name );
1914 if ( rProp.Attributes & css::beans::PropertyAttribute::REMOVABLE )
1915 {
1916 try
1917 {
1918 // QUESTION: DefaultValue?!
1919 xContainer->addProperty( rProp.Name, rProp.Attributes, aValue );
1920 }
1921 catch (beans::PropertyExistException const&) {}
1922 try
1923 {
1924 // it is possible that the propertysets from XML and binary files differ; we shouldn't break then
1925 xSet->setPropertyValue( rProp.Name, aValue );
1926 }
1927 catch ( const uno::Exception& ) {}
1928 }
1929 }
1930
1931 // sigh... have to set these manually I'm afraid... wonder why
1932 // SfxObjectShell doesn't handle this internally, should be easier
1933 xDocPropsToFill->setAuthor(i_xOldDocProps->getAuthor());
1934 xDocPropsToFill->setGenerator(i_xOldDocProps->getGenerator());
1935 xDocPropsToFill->setCreationDate(i_xOldDocProps->getCreationDate());
1936 xDocPropsToFill->setTitle(i_xOldDocProps->getTitle());
1937 xDocPropsToFill->setSubject(i_xOldDocProps->getSubject());
1938 xDocPropsToFill->setDescription(i_xOldDocProps->getDescription());
1939 xDocPropsToFill->setKeywords(i_xOldDocProps->getKeywords());
1940 xDocPropsToFill->setModifiedBy(i_xOldDocProps->getModifiedBy());
1941 xDocPropsToFill->setModificationDate(i_xOldDocProps->getModificationDate());
1942 xDocPropsToFill->setPrintedBy(i_xOldDocProps->getPrintedBy());
1943 xDocPropsToFill->setPrintDate(i_xOldDocProps->getPrintDate());
1944 xDocPropsToFill->setAutoloadURL(i_xOldDocProps->getAutoloadURL());
1945 xDocPropsToFill->setAutoloadSecs(i_xOldDocProps->getAutoloadSecs());
1946 xDocPropsToFill->setDefaultTarget(i_xOldDocProps->getDefaultTarget());
1947 xDocPropsToFill->setEditingCycles(i_xOldDocProps->getEditingCycles());
1948 xDocPropsToFill->setEditingDuration(i_xOldDocProps->getEditingDuration());
1949 // other attributes e.g. DocumentStatistics are not editable from dialog
1950 }
1951 catch (const uno::Exception&)
1952 {
1953 TOOLS_INFO_EXCEPTION("sfx.doc", "SetDocInfoState");
1954 }
1955
1956 // set the modified flag back if required
1957 if ( bIsModified != bool(xModifiable->isModified()) )
1958 xModifiable->setModified( bIsModified );
1959}
1960
1961
1962// static
1963bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XModel >& xModel,
1964 std::u16string_view aOldUIName,
1965 const OUString& aDefExtension,
1966 bool bDefIsAlien )
1967{
1968 if ( !officecfg::Office::Common::Save::Document::WarnAlienFormat::get() )
1969 return true;
1970
1972 SfxAlienWarningDialog aDlg(pWin, aOldUIName, aDefExtension, bDefIsAlien);
1973
1974 return aDlg.run() == RET_OK;
1975}
1976
1977uno::Reference<awt::XWindow> SfxStoringHelper::GetModelXWindow(const uno::Reference<frame::XModel>& xModel)
1978{
1979 try {
1980 if ( xModel.is() )
1981 {
1982 uno::Reference< frame::XController > xController = xModel->getCurrentController();
1983 if ( xController.is() )
1984 {
1985 uno::Reference< frame::XFrame > xFrame = xController->getFrame();
1986 if ( xFrame.is() )
1987 {
1988 return xFrame->getContainerWindow();
1989 }
1990 }
1991 }
1992 }
1993 catch ( const uno::Exception& )
1994 {
1995 }
1996
1997 return uno::Reference<awt::XWindow>();
1998}
1999
2000weld::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel )
2001{
2002 weld::Window* pWin = nullptr;
2003
2004 try
2005 {
2007 }
2008 catch (const uno::Exception&)
2009 {
2010 }
2011
2012 return pWin;
2013}
2014
2015/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
SfxApplication * SfxGetpApp()
Definition: app.hxx:231
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
Definition: appuno.cxx:908
void TransformParameters(sal_uInt16 nSlotId, const uno::Sequence< beans::PropertyValue > &rArgs, SfxAllItemSet &rSet, const SfxSlot *pSlot)
Definition: appuno.cxx:170
constexpr OUStringLiteral sStandardDir
Definition: appuno.cxx:142
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
bool ReadBool(const OUString &rKey, bool bDefault)
void SetExtension(std::u16string_view rTheExtension)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool HasError() const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
bool setFinalSlash()
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
uno::Reference< frame::XModel > const & GetModel() const
Definition: guisaveas.cxx:370
uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilterCheckFlags(SfxFilterFlags nMust, SfxFilterFlags nDont)
Definition: guisaveas.cxx:480
const ::comphelper::SequenceAsHashMap & GetModuleProps()
Definition: guisaveas.cxx:423
uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilter()
Definition: guisaveas.cxx:468
uno::Reference< frame::XStorable > m_xStorable
Definition: guisaveas.cxx:266
bool m_bRecommendReadOnly
Definition: guisaveas.cxx:278
uno::Reference< beans::XPropertyAccess > m_xFilterProperties
Definition: guisaveas.cxx:273
bool IsRecommendReadOnly() const
Definition: guisaveas.cxx:297
uno::Sequence< beans::PropertyValue > GetDocServiceAnyFilter(SfxFilterFlags nMust, SfxFilterFlags nDont)
Definition: guisaveas.cxx:498
const ::comphelper::SequenceAsHashMap & GetDocProps()
Definition: guisaveas.cxx:401
bool CheckFilterOptionsDialogExistence()
Definition: guisaveas.cxx:851
sal_Int8 CheckFilter(const OUString &)
Definition: guisaveas.cxx:762
static OUString GetRecommendedExtension(const OUString &aTypeName)
Definition: guisaveas.cxx:1242
OUString GetRecommendedDir(const OUString &aSuggestedDir)
Definition: guisaveas.cxx:1268
DECL_LINK(OptionsDialogClosedHdl, css::ui::dialogs::DialogClosedEvent *, void)
sal_Int8 CheckStateForSave()
Definition: guisaveas.cxx:720
ModelData_Impl(SfxStoringHelper &aOwner, uno::Reference< frame::XModel > xModel, const uno::Sequence< beans::PropertyValue > &aMediaDescr)
Definition: guisaveas.cxx:342
void FreeDocumentProps()
Definition: guisaveas.cxx:364
bool OutputFileDialog(sal_Int16 nStoreMode, const ::comphelper::SequenceAsHashMap &aPreselectedFilterPropsHM, bool bSetStandardName, OUString &aSuggestedName, bool bPreselectPassword, OUString &aSuggestedDir, sal_Int16 nDialog, const OUString &rStandardDir, const css::uno::Sequence< OUString > &rDenyList)
Definition: guisaveas.cxx:873
uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > m_xFilterDialog
Definition: guisaveas.cxx:274
OUString GetDocServiceName()
Definition: guisaveas.cxx:438
void CheckInteractionHandler()
Definition: guisaveas.cxx:444
uno::Reference< frame::XStorable > const & GetStorable()
Definition: guisaveas.cxx:379
OUString GetRecommendedName(const OUString &aSuggestedName, const OUString &aTypeName)
Definition: guisaveas.cxx:1323
uno::Reference< frame::XStorable2 > const & GetStorable2()
Definition: guisaveas.cxx:390
::comphelper::SequenceAsHashMap m_aMediaDescrHM
Definition: guisaveas.cxx:276
std::unique_ptr<::comphelper::SequenceAsHashMap > m_pDocumentPropsHM
Definition: guisaveas.cxx:270
OUString m_aModuleName
Definition: guisaveas.cxx:269
sal_Int8 CheckSaveAcceptable(sal_Int8 nCurStatus)
Definition: guisaveas.cxx:694
OUString const & GetModuleName()
Definition: guisaveas.cxx:410
bool ExecuteFilterDialog_Impl(const OUString &aFilterName, bool bAsync)
Definition: guisaveas.cxx:553
std::unique_ptr<::comphelper::SequenceAsHashMap > m_pModulePropsHM
Definition: guisaveas.cxx:271
SfxStoringHelper * m_pOwner
Definition: guisaveas.cxx:264
::comphelper::SequenceAsHashMap & GetMediaDescr()
Definition: guisaveas.cxx:295
bool ShowDocumentInfoDialog()
Definition: guisaveas.cxx:1197
uno::Sequence< beans::PropertyValue > GetPreselectedFilter_Impl(sal_Int16 nStoreMode)
Definition: guisaveas.cxx:506
uno::Reference< frame::XStorable2 > m_xStorable2
Definition: guisaveas.cxx:267
uno::Reference< frame::XModel > m_xModel
Definition: guisaveas.cxx:265
bool GetValue() const
bool IsEnableSetModified() const
Definition: objmisc.cxx:248
bool IsUseUserData() const
Definition: objcont.cxx:623
void EnableSetModified(bool bEnable=true)
Definition: objmisc.cxx:241
bool IsRememberingSignature() const
Definition: objsh.hxx:466
static css::uno::Reference< css::awt::XWindow > GetModelXWindow(const css::uno::Reference< css::frame::XModel > &rModel)
Definition: guisaveas.cxx:1977
css::uno::Reference< css::container::XContainerQuery > const & GetFilterQuery()
Definition: guisaveas.cxx:1381
css::uno::Reference< css::container::XNameAccess > const & GetFilterConfiguration()
Definition: guisaveas.cxx:1370
css::uno::Reference< css::container::XNameAccess > m_xFilterCFG
Definition: guisaveas.hxx:54
bool m_bSetStandardName
Definition: guisaveas.hxx:68
bool GUIStoreModel(const css::uno::Reference< css::frame::XModel > &xModel, std::u16string_view aSlotName, css::uno::Sequence< css::beans::PropertyValue > &aArgsSequence, bool bPreselectPassword, SignatureState nDocumentSignatureState, bool bIsAsync)
Definition: guisaveas.cxx:1402
static bool WarnUnacceptableFormat(const css::uno::Reference< css::frame::XModel > &xModel, std::u16string_view aOldUIName, const OUString &aDefExtension, bool rDefaultIsAlien)
Definition: guisaveas.cxx:1963
static weld::Window * GetModelWindow(const css::uno::Reference< css::frame::XModel > &xModel)
Definition: guisaveas.cxx:2000
static bool CheckFilterOptionsAppearance(const css::uno::Reference< css::container::XNameAccess > &xFilterCFG, const OUString &aFilterName)
Definition: guisaveas.cxx:1858
static void SetDocInfoState(const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::document::XDocumentProperties > &i_xOldDocInfo)
Definition: guisaveas.cxx:1887
css::uno::Reference< css::container::XContainerQuery > m_xFilterQuery
Definition: guisaveas.hxx:55
bool m_bPreselectPassword
Definition: guisaveas.hxx:66
css::uno::Reference< css::frame::XModuleManager2 > const & GetModuleManager()
Definition: guisaveas.cxx:1391
sal_Int16 m_nStoreMode
Definition: guisaveas.hxx:69
void CallFinishGUIStoreModel()
Definition: guisaveas.cxx:658
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager
Definition: guisaveas.hxx:56
static bool FinishGUIStoreModel(::comphelper::SequenceAsHashMap::const_iterator &aFileNameIter, ModelData_Impl &aModelData, bool bRemote, sal_Int16 nStoreMode, css::uno::Sequence< css::beans::PropertyValue > &aFilterProps, bool bSetStandardName, bool bPreselectPassword, bool bDialogUsed, std::u16string_view aFilterFromMediaDescr, std::u16string_view aOldFilterName, css::uno::Sequence< css::beans::PropertyValue > &aArgsSequence, OUString aFilterName)
Definition: guisaveas.cxx:1578
css::uno::Sequence< css::beans::PropertyValue > m_aArgsSequence
Definition: guisaveas.hxx:59
std::shared_ptr< ModelData_Impl > m_xModelData
Definition: guisaveas.hxx:58
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
Invokes the registered callback, if there are any.
Definition: viewsh.cxx:2244
void SetStoringHelper(std::shared_ptr< SfxStoringHelper > xHelper)
Definition: viewsh.hxx:478
virtual SfxObjectShell * GetObjectShell() override
Definition: viewsh.cxx:2591
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
Definition: viewsh.cxx:1848
static css::uno::Sequence< css::beans::PropertyValue > SearchForFilter(const css::uno::Reference< css::container::XContainerQuery > &xFilterQuery, const css::uno::Sequence< css::beans::NamedValue > &aSearchRequest, SfxFilterFlags nMustFlags, SfxFilterFlags nDontFlags)
iterator erase(iterator it)
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
iterator find(const OUString &rKey)
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
SequenceAsHashMapBase::const_iterator const_iterator
virtual short run()
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
Reference< XDispatch > xDispatch
URL aURL
Reference< frame::XModel > m_xModel
SfxFilterFlags
float u
#define ERRCODE_IO_ABORT
#define ERRCODE_NONE
#define ERRCODE_IO_INVALIDPARAMETER
#define SFX2_IMPL_DIALOG_CONFIG
#define SFX2_IMPL_DIALOG_SYSTEM
FileDialogFlags
#define SFX2_IMPL_DIALOG_OOO
#define SFX2_IMPL_DIALOG_REMOTE
OUString aUIName
bool bReadOnly
#define EPUBEXPORT_REQUESTED
Definition: guisaveas.cxx:112
IMPL_LINK(ModelData_Impl, OptionsDialogClosedHdl, css::ui::dialogs::DialogClosedEvent *, pEvt, void)
Definition: guisaveas.cxx:675
#define EPUBDIRECTEXPORT_REQUESTED
Definition: guisaveas.cxx:113
constexpr OUStringLiteral aFilterDataString
Definition: guisaveas.cxx:124
#define STATUS_SAVE
Definition: guisaveas.cxx:118
#define SAVE_REQUESTED
Definition: guisaveas.cxx:109
#define STATUS_SAVEAS
Definition: guisaveas.cxx:119
#define STATUS_NO_ACTION
Definition: guisaveas.cxx:117
#define WIDEEXPORT_REQUESTED
Definition: guisaveas.cxx:108
#define STATUS_SAVEAS_STANDARDNAME
Definition: guisaveas.cxx:120
#define PDFDIRECTEXPORT_REQUESTED
Definition: guisaveas.cxx:107
#define EXPORT_REQUESTED
Definition: guisaveas.cxx:105
#define SAVEASREMOTE_REQUESTED
Definition: guisaveas.cxx:114
constexpr OUStringLiteral aFilterOptionsString
Definition: guisaveas.cxx:123
#define SAVEACOPY_REQUESTED
Definition: guisaveas.cxx:111
#define PDFEXPORT_REQUESTED
Definition: guisaveas.cxx:106
constexpr OUStringLiteral aFilterNameString
Definition: guisaveas.cxx:122
#define SAVEAS_REQUESTED
Definition: guisaveas.cxx:110
#define MAX_PATH
sal_uInt16 nPos
Definition: linksrc.cxx:118
#define SAL_WARN(area, stream)
size
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
end
ContentProvider * m_pOwner
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
SignatureState
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel
signed char sal_Int8
RET_OK
RET_YES