summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNickWingate <nick.wingate@collabora.com>2022-09-22 09:02:42 +0100
committerAndras Timar <andras.timar@collabora.com>2022-12-20 03:11:16 +0000
commit89f5912ad2eee786508414791653a017206a7c04 (patch)
tree72a2390a1d655e87a36d8982ff2b6e7031a2cb41 /sfx2
parent34709aa3f4f166879004670e60ff3b37ad3eacd5 (diff)
Async PDFExport dialog and parent methods
Filter dialogs are all called generically from guisaveas.cxx in GUIStoreModel() Signed-off-by: NickWingate <nick.wingate@collabora.com> Change-Id: Idfbe85c09f84d4a7cf3f00b9704d5af94868a051 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140403 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144511 Tested-by: Jenkins
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/guisaveas.hxx32
-rw-r--r--sfx2/source/doc/guisaveas.cxx246
-rw-r--r--sfx2/source/doc/objserv.cxx15
-rw-r--r--sfx2/source/view/ipclient.cxx3
4 files changed, 219 insertions, 77 deletions
diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx
index c19f78e3fdf1..88a69711c8fd 100644
--- a/sfx2/inc/guisaveas.hxx
+++ b/sfx2/inc/guisaveas.hxx
@@ -31,8 +31,15 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
+#include <comphelper/sequenceashashmap.hxx>
+
+#include <sfx2/bindings.hxx>
#include <sfx2/signaturestate.hxx>
+#include <svtools/dialogclosedlistener.hxx>
+
+#include <tools/urlobj.hxx>
+
namespace com::sun::star::document { class XDocumentProperties; }
@@ -48,10 +55,32 @@ private:
css::uno::Reference< css::container::XContainerQuery > m_xFilterQuery;
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
+ std::shared_ptr<ModelData_Impl> m_xModelData;
+ css::uno::Sequence< css::beans::PropertyValue > m_aArgsSequence;
+
css::uno::Reference< css::container::XNameAccess > const & GetFilterConfiguration();
css::uno::Reference< css::container::XContainerQuery > const & GetFilterQuery();
css::uno::Reference< css::frame::XModuleManager2 > const & GetModuleManager();
+ bool m_xDialogUsed;
+ bool m_bRemote;
+ bool m_bPreselectPassword;
+ bool m_bDialogUsed;
+ bool m_bSetStandardName;
+ sal_Int16 m_nStoreMode;
+
+ DECL_LINK(FilterDialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
+
+ 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);
+
+ void CallFinishGUIStoreModel();
+
public:
SfxStoringHelper();
@@ -60,7 +89,8 @@ public:
std::u16string_view aSlotName,
css::uno::Sequence< css::beans::PropertyValue >& aArgsSequence,
bool bPreselectPassword,
- SignatureState nDocumentSignatureState );
+ SignatureState nDocumentSignatureState,
+ bool bIsAsync );
static bool CheckFilterOptionsAppearance(
const css::uno::Reference< css::container::XNameAccess >& xFilterCFG,
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 7cce6b515db4..d95d2bb2c289 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -18,6 +18,7 @@
*/
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
@@ -55,16 +56,20 @@
#include <tools/debug.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
+#include <tools/json_writer.hxx>
+#include <tools/urlobj.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/mimeconfighelper.hxx>
#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
+#include <unotools/tempfile.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/strings.hrc>
@@ -72,6 +77,8 @@
#include <sfx2/filedlghelper.hxx>
#include <sfx2/app.hxx>
#include <sfx2/sfxuno.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/bindings.hxx>
#include <alienwarn.hxx>
#include <memory>
@@ -261,10 +268,15 @@ class ModelData_Impl
std::unique_ptr<::comphelper::SequenceAsHashMap> m_pDocumentPropsHM;
std::unique_ptr<::comphelper::SequenceAsHashMap> m_pModulePropsHM;
+ uno::Reference<beans::XPropertyAccess> m_xFilterProperties;
+ uno::Reference<ui::dialogs::XAsynchronousExecutableDialog> m_xFilterDialog;
+
::comphelper::SequenceAsHashMap m_aMediaDescrHM;
bool m_bRecommendReadOnly;
+ DECL_LINK(OptionsDialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
+
public:
ModelData_Impl( SfxStoringHelper& aOwner,
uno::Reference< frame::XModel > xModel,
@@ -296,7 +308,7 @@ public:
uno::Sequence< beans::PropertyValue > GetPreselectedFilter_Impl( sal_Int16 nStoreMode );
uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilter();
- bool ExecuteFilterDialog_Impl( const OUString& aFilterName );
+ bool ExecuteFilterDialog_Impl( const OUString& aFilterName, bool bAsync );
sal_Int8 CheckSaveAcceptable( sal_Int8 nCurStatus );
sal_Int8 CheckStateForSave();
@@ -322,7 +334,6 @@ public:
OUString GetRecommendedDir( const OUString& aSuggestedDir );
OUString GetRecommendedName( const OUString& aSuggestedName,
const OUString& aTypeName );
-
};
@@ -343,6 +354,8 @@ ModelData_Impl::~ModelData_Impl()
FreeDocumentProps();
m_pDocumentPropsHM.reset();
m_pModulePropsHM.reset();
+ if (m_xFilterProperties)
+ m_xFilterProperties.clear();
}
@@ -535,7 +548,7 @@ uno::Sequence< beans::PropertyValue > ModelData_Impl::GetPreselectedFilter_Impl(
}
-bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
+bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName, bool bIsAsync )
{
bool bDialogUsed = false;
@@ -557,15 +570,31 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
{"ParentWindow", uno::Any(SfxStoringHelper::GetModelXWindow(m_xModel))},
}));
- uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog(
- comphelper::getProcessServiceFactory()->createInstanceWithArguments(aServiceName, aDialogArgs), uno::UNO_QUERY );
- uno::Reference< beans::XPropertyAccess > xFilterProperties( xFilterDialog, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertyAccess > xFilterProperties;
+ uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog;
+ uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xAsyncFilterDialog;
+ uno::Reference< document::XExporter > xExporter;
- if( xFilterDialog.is() && xFilterProperties.is() )
+ if ( bIsAsync )
+ {
+ xAsyncFilterDialog = uno::Reference< ui::dialogs::XAsynchronousExecutableDialog >(
+ comphelper::getProcessServiceFactory()->createInstanceWithArguments( aServiceName, aDialogArgs ), uno::UNO_QUERY );
+ OSL_ENSURE(xAsyncFilterDialog.is(), "ModelData_Impl::ExecuteFilterDialog_Impl: Dialog is not async!");
+ xFilterProperties = uno::Reference< beans::XPropertyAccess >( xAsyncFilterDialog, uno::UNO_QUERY );
+ xExporter = uno::Reference< document::XExporter >( xAsyncFilterDialog, uno::UNO_QUERY );
+ }
+ else
+ {
+ xFilterDialog = uno::Reference< ui::dialogs::XExecutableDialog >(
+ comphelper::getProcessServiceFactory()->createInstanceWithArguments( aServiceName, aDialogArgs ), uno::UNO_QUERY );
+ xFilterProperties = uno::Reference< beans::XPropertyAccess >( xFilterDialog, uno::UNO_QUERY );
+ xExporter = uno::Reference< document::XExporter >( xFilterDialog, uno::UNO_QUERY );
+ }
+
+ if ( xFilterProperties.is() && ( xFilterDialog.is() || xAsyncFilterDialog.is() ) )
{
bDialogUsed = true;
- uno::Reference< document::XExporter > xExporter( xFilterDialog, uno::UNO_QUERY );
if( xExporter.is() )
xExporter->setSourceDocument( GetModel() );
@@ -573,19 +602,32 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
GetMediaDescr() >> aPropsForDialog;
xFilterProperties->setPropertyValues( aPropsForDialog );
- if( !xFilterDialog->execute() )
+ if ( bIsAsync )
{
- throw task::ErrorCodeIOException(
- ("ModelData_Impl::ExecuteFilterDialog_Impl:"
- " ERRCODE_IO_ABORT"),
- uno::Reference< uno::XInterface >(),
- sal_uInt32(ERRCODE_IO_ABORT));
- }
+ m_xFilterProperties = xFilterProperties;
+ m_xFilterDialog = xAsyncFilterDialog;
+
+ auto aDialogClosedListener = rtl::Reference(new svt::DialogClosedListener());
+ aDialogClosedListener->SetDialogClosedLink( LINK( this, ModelData_Impl, OptionsDialogClosedHdl ) );
- const uno::Sequence< beans::PropertyValue > aPropsFromDialog =
- xFilterProperties->getPropertyValues();
- for ( const auto& rProp : aPropsFromDialog )
- GetMediaDescr()[rProp.Name] = rProp.Value;
+ m_xFilterDialog->startExecuteModal( aDialogClosedListener );
+ }
+ else
+ {
+ if( !xFilterDialog->execute() )
+ {
+ throw task::ErrorCodeIOException(
+ ("ModelData_Impl::ExecuteFilterDialog_Impl:"
+ " ERRCODE_IO_ABORT"),
+ uno::Reference< uno::XInterface >(),
+ sal_uInt32(ERRCODE_IO_ABORT));
+ }
+
+ const uno::Sequence< beans::PropertyValue > aPropsFromDialog =
+ xFilterProperties->getPropertyValues();
+ for ( const auto& rProp : aPropsFromDialog )
+ GetMediaDescr()[rProp.Name] = rProp.Value;
+ }
}
}
}
@@ -611,6 +653,34 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
return bDialogUsed;
}
+void SfxStoringHelper::CallFinishGUIStoreModel()
+{
+ ::comphelper::SequenceAsHashMap::const_iterator aFileNameIter = m_xModelData->GetMediaDescr().find( OUString("URL") );
+ uno::Sequence< beans::PropertyValue > aFilterProps = m_xModelData->GetPreselectedFilter_Impl( m_nStoreMode );
+ const OUString aFilterFromMediaDescr = m_xModelData->GetMediaDescr().getUnpackedValueOrDefault( aFilterNameString, OUString() );
+ const OUString aOldFilterName = m_xModelData->GetDocProps().getUnpackedValueOrDefault( aFilterNameString, OUString() );
+ ::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
+ OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
+
+ SfxStoringHelper::FinishGUIStoreModel(aFileNameIter, *m_xModelData, m_bRemote, m_nStoreMode, aFilterProps,
+ m_bSetStandardName, m_bPreselectPassword, m_bDialogUsed,
+ aFilterFromMediaDescr, aOldFilterName, m_aArgsSequence, aFilterName);
+
+ if (SfxViewShell::Current())
+ SfxViewShell::Current()->SetStoringHelper(nullptr);
+}
+
+IMPL_LINK( ModelData_Impl, OptionsDialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvt, void )
+{
+ if (pEvt->DialogResult == RET_OK && m_xFilterProperties)
+ {
+ const uno::Sequence< beans::PropertyValue > aPropsFromDialog = m_xFilterProperties->getPropertyValues();
+ for ( const auto& rProp : aPropsFromDialog )
+ GetMediaDescr()[rProp.Name] = rProp.Value;
+
+ m_pOwner->CallFinishGUIStoreModel();
+ }
+}
sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus )
{
@@ -994,12 +1064,18 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
// aFilterName is a pure output parameter, pDialogParams is an in/out parameter
OUString aFilterName;
- if ( pFileDlg->Execute( pDialogParams, aFilterName ) != ERRCODE_NONE )
+ // in LOK case we don't show File Picker so it will fail, but execute to do other preparations
+ if ( pFileDlg->Execute( pDialogParams, aFilterName ) != ERRCODE_NONE
+ && !comphelper::LibreOfficeKit::isActive() )
{
throw task::ErrorCodeIOException(
"ModelData_Impl::OutputFileDialog: ERRCODE_IO_ABORT",
uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
}
+ else if (comphelper::LibreOfficeKit::isActive())
+ {
+ aFilterName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
+ }
// the following two arguments can not be converted in MediaDescriptor,
// so they should be removed from the ItemSet after retrieving
@@ -1022,9 +1098,6 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
const OUString aFilterFromMediaDescr = GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
const OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
- const OUString sFilterOptionsString(aFilterOptionsString);
- const OUString sFilterDataString(aFilterDataString);
-
if ( aFilterName == aFilterFromMediaDescr )
{
// preserve current settings if any
@@ -1034,32 +1107,32 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
if ( aFilterFromMediaDescr == aOldFilterName )
{
::comphelper::SequenceAsHashMap::const_iterator aIter =
- GetDocProps().find( sFilterOptionsString );
+ GetDocProps().find( aFilterOptionsString );
if ( aIter != GetDocProps().end()
- && GetMediaDescr().find( sFilterOptionsString ) == GetMediaDescr().end() )
+ && GetMediaDescr().find( aFilterOptionsString ) == GetMediaDescr().end() )
GetMediaDescr()[aIter->first] = aIter->second;
- aIter = GetDocProps().find( sFilterDataString );
+ aIter = GetDocProps().find( aFilterDataString );
if ( aIter != GetDocProps().end()
- && GetMediaDescr().find( sFilterDataString ) == GetMediaDescr().end() )
+ && GetMediaDescr().find( aFilterDataString ) == GetMediaDescr().end() )
GetMediaDescr()[aIter->first] = aIter->second;
}
}
else
{
- GetMediaDescr().erase( sFilterDataString );
- GetMediaDescr().erase( sFilterOptionsString );
+ GetMediaDescr().erase( aFilterDataString );
+ GetMediaDescr().erase( aFilterOptionsString );
if ( aFilterName == aOldFilterName )
{
// merge filter option of the document filter
::comphelper::SequenceAsHashMap::const_iterator aIter =
- GetDocProps().find( sFilterOptionsString );
+ GetDocProps().find( aFilterOptionsString );
if ( aIter != GetDocProps().end() )
GetMediaDescr()[aIter->first] = aIter->second;
- aIter = GetDocProps().find( sFilterDataString );
+ aIter = GetDocProps().find( aFilterDataString );
if ( aIter != GetDocProps().end() )
GetMediaDescr()[aIter->first] = aIter->second;
}
@@ -1083,8 +1156,8 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
aVal >>= bUseFilterOptions;
if ( !bUseFilterOptions )
bUseFilterOptions =
- ( GetMediaDescr().find( sFilterDataString ) == GetMediaDescr().end()
- && GetMediaDescr().find( sFilterOptionsString ) == GetMediaDescr().end() );
+ ( GetMediaDescr().find( aFilterDataString ) == GetMediaDescr().end()
+ && GetMediaDescr().find( aFilterOptionsString ) == GetMediaDescr().end() );
}
catch( const lang::IllegalArgumentException& )
{}
@@ -1309,24 +1382,26 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
std::u16string_view aSlotName,
uno::Sequence< beans::PropertyValue >& aArgsSequence,
bool bPreselectPassword,
- SignatureState nDocumentSignatureState )
+ SignatureState nDocumentSignatureState,
+ bool bIsAsync)
{
- ModelData_Impl aModelData( *this, xModel, aArgsSequence );
-
- bool bDialogUsed = false;
+ m_xModelData = std::make_shared<ModelData_Impl>( *this, xModel, aArgsSequence );
+ m_aArgsSequence = aArgsSequence;
+ ModelData_Impl& aModelData = *m_xModelData;
- INetURLObject aURL;
+ m_bDialogUsed = false;
- bool bSetStandardName = false; // can be set only for SaveAs
+ m_bSetStandardName = false; // can be set only for SaveAs
+ m_bPreselectPassword = bPreselectPassword;
// parse the slot name
- bool bRemote = false;
- sal_Int16 nStoreMode = getStoreModeFromSlotName( aSlotName );
+ m_bRemote = false;
+ m_nStoreMode = getStoreModeFromSlotName( aSlotName );
- if ( nStoreMode == SAVEASREMOTE_REQUESTED )
+ if ( m_nStoreMode == SAVEASREMOTE_REQUESTED )
{
- nStoreMode = SAVEAS_REQUESTED;
- bRemote = true;
+ m_nStoreMode = SAVEAS_REQUESTED;
+ m_bRemote = true;
}
sal_Int8 nStatusSave = STATUS_NO_ACTION;
@@ -1338,10 +1413,10 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
bool bSaveACopy = false;
aSaveACopyIter->second >>= bSaveACopy;
if ( bSaveACopy )
- nStoreMode = EXPORT_REQUESTED | SAVEACOPY_REQUESTED | WIDEEXPORT_REQUESTED;
+ m_nStoreMode = EXPORT_REQUESTED | SAVEACOPY_REQUESTED | WIDEEXPORT_REQUESTED;
}
// handle the special cases
- if ( nStoreMode & SAVEAS_REQUESTED )
+ if ( m_nStoreMode & SAVEAS_REQUESTED )
{
::comphelper::SequenceAsHashMap::const_iterator aSaveToIter =
aModelData.GetMediaDescr().find( OUString("SaveTo") );
@@ -1350,16 +1425,16 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
bool bWideExport = false;
aSaveToIter->second >>= bWideExport;
if ( bWideExport )
- nStoreMode = EXPORT_REQUESTED | WIDEEXPORT_REQUESTED;
+ m_nStoreMode = EXPORT_REQUESTED | WIDEEXPORT_REQUESTED;
}
// if saving is not acceptable the warning must be shown even in case of SaveAs operation
- if ( ( nStoreMode & SAVEAS_REQUESTED ) && aModelData.CheckSaveAcceptable( STATUS_SAVEAS ) == STATUS_NO_ACTION )
+ if ( ( m_nStoreMode & SAVEAS_REQUESTED ) && aModelData.CheckSaveAcceptable( STATUS_SAVEAS ) == STATUS_NO_ACTION )
throw task::ErrorCodeIOException(
"SfxStoringHelper::GUIStoreModel: ERRCODE_IO_ABORT",
uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
}
- else if ( nStoreMode & SAVE_REQUESTED )
+ else if ( m_nStoreMode & SAVE_REQUESTED )
{
// if saving is not acceptable by the configuration the warning must be shown
nStatusSave = aModelData.CheckSaveAcceptable( STATUS_SAVE );
@@ -1383,13 +1458,13 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
else if ( nStatusSave != STATUS_SAVE )
{
// this should be a usual SaveAs operation
- nStoreMode = SAVEAS_REQUESTED;
+ m_nStoreMode = SAVEAS_REQUESTED;
if ( nStatusSave == STATUS_SAVEAS_STANDARDNAME )
- bSetStandardName = true;
+ m_bSetStandardName = true;
}
}
- if (!comphelper::LibreOfficeKit::isActive() && !( nStoreMode & EXPORT_REQUESTED ) )
+ if (!comphelper::LibreOfficeKit::isActive() && !( m_nStoreMode & EXPORT_REQUESTED ) )
{
// if it is no export, warn user that the signature will be removed
if ( SignatureState::OK == nDocumentSignatureState
@@ -1409,7 +1484,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
}
}
- if ( nStoreMode & SAVE_REQUESTED && nStatusSave == STATUS_SAVE )
+ if ( m_nStoreMode & SAVE_REQUESTED && nStatusSave == STATUS_SAVE )
{
// Document properties can contain streams that should be freed before storing
aModelData.FreeDocumentProps();
@@ -1436,7 +1511,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
}
// preselect a filter for the storing process
- uno::Sequence< beans::PropertyValue > aFilterProps = aModelData.GetPreselectedFilter_Impl( nStoreMode );
+ uno::Sequence< beans::PropertyValue > aFilterProps = aModelData.GetPreselectedFilter_Impl( m_nStoreMode );
DBG_ASSERT( aFilterProps.hasElements(), "No filter for storing!\n" );
if ( !aFilterProps.hasElements() )
@@ -1447,33 +1522,50 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
::comphelper::SequenceAsHashMap aFilterPropsHM( aFilterProps );
OUString aFilterName = aFilterPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
- const OUString sFilterNameString(aFilterNameString);
+ const OUString aFilterFromMediaDescr = aModelData.GetMediaDescr().getUnpackedValueOrDefault( aFilterNameString, OUString() );
+ const OUString aOldFilterName = aModelData.GetDocProps().getUnpackedValueOrDefault( aFilterNameString, OUString() );
- const OUString aFilterFromMediaDescr = aModelData.GetMediaDescr().getUnpackedValueOrDefault( sFilterNameString, OUString() );
- const OUString aOldFilterName = aModelData.GetDocProps().getUnpackedValueOrDefault( sFilterNameString, OUString() );
-
- bool bUseFilterOptions = false;
::comphelper::SequenceAsHashMap::const_iterator aFileNameIter = aModelData.GetMediaDescr().find( OUString("URL") );
- const OUString sFilterOptionsString(aFilterOptionsString);
- const OUString sFilterDataString(aFilterDataString);
-
- bool bPDFOptions = (nStoreMode & PDFEXPORT_REQUESTED) && !(nStoreMode & PDFDIRECTEXPORT_REQUESTED);
- bool bEPUBOptions = (nStoreMode & EPUBEXPORT_REQUESTED) && !(nStoreMode & EPUBDIRECTEXPORT_REQUESTED);
- if ( ( nStoreMode & EXPORT_REQUESTED ) && (bPDFOptions || bEPUBOptions) )
+ bool bPDFOptions = (m_nStoreMode & PDFEXPORT_REQUESTED) && !(m_nStoreMode & PDFDIRECTEXPORT_REQUESTED);
+ bool bEPUBOptions = (m_nStoreMode & EPUBEXPORT_REQUESTED) && !(m_nStoreMode & EPUBDIRECTEXPORT_REQUESTED);
+ if ( ( m_nStoreMode & EXPORT_REQUESTED ) && (bPDFOptions || bEPUBOptions) )
{
// this is PDF or EPUB export, the filter options dialog should be shown before the export
- aModelData.GetMediaDescr()[sFilterNameString] <<= aFilterName;
+ aModelData.GetMediaDescr()[aFilterNameString] <<= aFilterName;
if ( aModelData.GetMediaDescr().find( "FilterFlags" ) == aModelData.GetMediaDescr().end()
- && aModelData.GetMediaDescr().find( sFilterOptionsString ) == aModelData.GetMediaDescr().end()
- && aModelData.GetMediaDescr().find( sFilterDataString ) == aModelData.GetMediaDescr().end() )
+ && aModelData.GetMediaDescr().find( aFilterOptionsString ) == aModelData.GetMediaDescr().end()
+ && aModelData.GetMediaDescr().find( aFilterDataString ) == aModelData.GetMediaDescr().end() )
{
// execute filter options dialog since no options are set in the media descriptor
- if ( aModelData.ExecuteFilterDialog_Impl( aFilterName ) )
- bDialogUsed = true;
+ if ( aModelData.ExecuteFilterDialog_Impl( aFilterName, bIsAsync ) )
+ m_bDialogUsed = true;
}
}
+ if (bIsAsync)
+ return false;
+
+ return SfxStoringHelper::FinishGUIStoreModel(aFileNameIter, aModelData, m_bRemote, m_nStoreMode, aFilterProps,
+ m_bSetStandardName, m_bPreselectPassword, m_bDialogUsed,
+ aFilterFromMediaDescr, aOldFilterName, aArgsSequence, aFilterName);
+}
+
+bool SfxStoringHelper::FinishGUIStoreModel(::comphelper::SequenceAsHashMap::const_iterator& aFileNameIter,
+ ModelData_Impl& aModelData, bool bRemote, sal_Int16 nStoreMode,
+ uno::Sequence< beans::PropertyValue >& aFilterProps,
+ bool bSetStandardName, bool bPreselectPassword, bool bDialogUsed,
+ std::u16string_view aFilterFromMediaDescr,
+ std::u16string_view aOldFilterName,
+ uno::Sequence< beans::PropertyValue >& aArgsSequence,
+ OUString aFilterName)
+{
+ const OUString sFilterNameString(aFilterNameString);
+ const OUString sFilterOptionsString(aFilterOptionsString);
+ const OUString sFilterDataString(aFilterDataString);
+ bool bUseFilterOptions = false;
+ INetURLObject aURL;
+
if ( aFileNameIter == aModelData.GetMediaDescr().end() )
{
sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG;
@@ -1605,7 +1697,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
&& ( ( nStoreMode & EXPORT_REQUESTED ) || bUseFilterOptions ) )
{
// execute filter options dialog
- if ( aModelData.ExecuteFilterDialog_Impl( aFilterName ) )
+ if ( aModelData.ExecuteFilterDialog_Impl( aFilterName, false ) )
{
bDialogUsed = true;
// check if the file is a pdf or not and change the storing mode at convenience
@@ -1681,7 +1773,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
}
// Launch PDF viewer
- if ( nStoreMode & PDFEXPORT_REQUESTED )
+ if ( nStoreMode & PDFEXPORT_REQUESTED && !comphelper::LibreOfficeKit::isActive() )
{
FilterConfigItem aItem(u"Office.Common/Filter/PDF/Export/");
bool aViewPDF = aItem.ReadBool( "ViewPDFAfterExport", false );
@@ -1693,6 +1785,16 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
}
}
+ if ( comphelper::LibreOfficeKit::isActive() )
+ {
+ if ( SfxViewShell* pShell = SfxViewShell::Current() )
+ {
+ OUString sURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ pShell->libreOfficeKitViewCallback( LOK_CALLBACK_EXPORT_FILE,
+ OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() );
+ }
+ }
+
return bDialogUsed;
}
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index f0bc6172ab1d..35716406cd80 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -590,6 +590,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
bool bIsPDFExport = false;
bool bIsAutoRedact = false;
+ bool bIsAsync = false;
std::vector<std::pair<RedactionTarget, OUString>> aRedactionTargets;
switch(nId)
{
@@ -896,6 +897,11 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
case SID_SAVEASREMOTE:
case SID_SAVEDOC:
{
+ // so far only pdf and epub support Async interface
+ if (comphelper::LibreOfficeKit::isActive() && rReq.GetCallMode() == SfxCallMode::ASYNCHRON
+ && (nId == SID_EXPORTDOCASEPUB || nId == SID_EXPORTDOCASPDF))
+ bIsAsync = true;
+
// derived class may decide to abort this
if( !QuerySlotExecutable( nId ) )
{
@@ -1014,7 +1020,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
if ( !pSlot )
throw uno::Exception("no slot", nullptr);
- SfxStoringHelper aHelper;
+ std::shared_ptr<SfxStoringHelper> xHelper = std::make_shared<SfxStoringHelper>();
+ if (bIsAsync && SfxViewShell::Current())
+ SfxViewShell::Current()->SetStoringHelper(xHelper);
if ( QueryHiddenInformation( bIsPDFExport ? HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving, nullptr ) != RET_YES )
{
@@ -1036,11 +1044,12 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
ExecuteSlot(aRequest);
}
- aHelper.GUIStoreModel( GetModel(),
+ xHelper->GUIStoreModel( GetModel(),
OUString::createFromAscii( pSlot->GetUnoName() ),
aDispatchArgs,
bPreselectPassword,
- GetDocumentSignatureState() );
+ GetDocumentSignatureState(),
+ bIsAsync );
if (bMailPrepareExport)
{
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index 03ed38a78f3b..fd52355f3ed5 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -922,7 +922,8 @@ ErrCode SfxInPlaceClient::DoVerb(sal_Int32 nVerb)
u"SaveAs",
aDispatchArgs,
false,
- SignatureState::NOSIGNATURES );
+ SignatureState::NOSIGNATURES,
+ false );
}
catch( const task::ErrorCodeIOException& aErrorEx )
{