Eliminate hang in iOS app (and maybe the Android app) during export

When exporting a document via this path, such as exporting to PDF
via the .uno:ExportToPDF command, any exceptions thrown while saving
the current document will leave the app in a blocked state if a
"PENDING" message has been sent.

The iOS app (and maybe the Android app) fails to set the URL to
save to so we need to set it to a temporary file.
Note: the iOS app is responsible for deleting the temporary file.

Also, enable building iOS with TLS=OPENSSL by default.

Signed-off-by: Patrick Luby <plubius@libreoffice.org>
Change-Id: Ibc070bed4e792bb0a481d2b900d12d214e3c519f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161692
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162125
Tested-by: Jenkins
This commit is contained in:
Patrick Luby 2024-01-05 09:55:26 -05:00 committed by Andras Timar
parent b2500f0e32
commit 12b33dce25
3 changed files with 62 additions and 12 deletions

View file

@ -24,7 +24,8 @@
--disable-poppler
--disable-python
--without-tls
# OpenSSL is the default
#--with-tls=openssl
# iOS device
--host=arm64-apple-ios

View file

@ -24,7 +24,8 @@
--disable-poppler
--disable-python
--without-tls
# OpenSSL is the default
#--with-tls=openssl
# iOS simulator (debug)
--enable-ios-simulator

View file

@ -1101,12 +1101,48 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
if (comphelper::LibreOfficeKit::isActive())
{
// keep name with extension
aSuggestedName = aRecommendedName;
OUString aExtension;
if (size_t nPos = aSuggestedName.lastIndexOf('.') + 1)
aExtension = aSuggestedName.copy(nPos, aSuggestedName.getLength() - nPos);
aURL.SetExtension(aExtension);
#ifdef IOS
// The iOS app (and maybe the Android app) have fails to set the URL to
// save to so we need to set it to a temporary file.
// Note: the iOS app is responsible for deleting the temporary file.
if (nStoreMode & EXPORT_REQUESTED && aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE).isEmpty())
{
// Mirror the "export/docbasename.pdf" path format to match the
// format used in the "downloadas" message handler in the iOS app's
// -[DocumentViewController userContentController:didReceiveScriptMessage]
// selector.
// Important note: temporary files created here must be in their
// own subdirectory since the iOS app's UIDocumentPickerDelegate
// will try to delete both the temporary file and its parent
// directory.
OUString aFullName = u"export/" + aRecommendedName;
OUString aBaseName;
OUString aExtension;
sal_Int32 nPos = aFullName.lastIndexOf( '.' );
if ( nPos >= 0 )
{
aBaseName = aFullName.copy(0, nPos);
aExtension = aFullName.copy(nPos, aFullName.getLength() - nPos);
}
aURL = INetURLObject(::utl::CreateTempURL( aBaseName, false, aExtension, nullptr, true));
// Remove any stale files left from a previous export
OUString fileURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
if (!fileURL.isEmpty())
osl::File::remove(fileURL);
}
else
{
#endif
// keep name with extension
aSuggestedName = aRecommendedName;
OUString aExtension;
if (size_t nPos = aSuggestedName.lastIndexOf('.') + 1)
aExtension = aSuggestedName.copy(nPos, aSuggestedName.getLength() - nPos);
aURL.SetExtension(aExtension);
#ifdef IOS
}
#endif
}
else
{
@ -1822,10 +1858,22 @@ bool SfxStoringHelper::FinishGUIStoreModel(::comphelper::SequenceAsHashMap::cons
// this is actually a save operation with different parameters
// so storeTo or storeAs without DocInfo operations are used
if ( nStoreMode & EXPORT_REQUESTED )
aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
else
aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
#ifdef IOS
try
{
#endif
if ( nStoreMode & EXPORT_REQUESTED )
aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
else
aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aArgsSequence );
#ifdef IOS
}
catch( const uno::Exception& )
{
// When using the iOS app (and maybe the Android app), the app
// will remain blocked if we rethrow an exception.
}
#endif
}
// Launch PDF viewer