summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-07-09 19:49:34 +1000
committerMike Kaganski <mike.kaganski@collabora.com>2018-07-10 18:38:40 +0200
commitedc62adae9a354ca1305e83b10c98a545f58d341 (patch)
tree5bdbcf8901df3e18183fcffc8c4ac6c9c6ae610a /dbaccess
parentd7cdb7fcc48a580cd5183ba899f73f2ad9bdbec9 (diff)
tdf#118634: Don't save embedded data source to a temporary preview document
Also don't use storeAsURL to store embedded datasource when the document is being saved using storeToURL. Change-Id: I69a7ee5ae066e591be5e45c87bcf57dff370decc Reviewed-on: https://gerrit.libreoffice.org/57178 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.cxx34
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.hxx13
2 files changed, 36 insertions, 11 deletions
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 516766ca81e3..44e43b9b2435 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -1029,15 +1029,8 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph
if ( bLocationChanged )
{
// create storage for target URL
- uno::Reference<embed::XStorage> xTargetStorage;
- _rArguments.get("TargetStorage") >>= xTargetStorage;
- if (!xTargetStorage.is())
- xTargetStorage = impl_createStorageFor_throw(_rURL);
-
- // In case we got a StreamRelPath, then xTargetStorage should reference that sub-storage.
- OUString sStreamRelPath = _rArguments.getOrDefault("StreamRelPath", OUString());
- if (!sStreamRelPath.isEmpty())
- xTargetStorage = xTargetStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READWRITE);
+ uno::Reference<embed::XStorage> xTargetStorage(
+ impl_GetStorageOrCreateFor_throw(_rArguments, _rURL));
if ( m_pImpl->isEmbeddedDatabase() )
m_pImpl->clearConnections();
@@ -1130,6 +1123,24 @@ Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const OUSt
return Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW );
}
+css::uno::Reference<css::embed::XStorage> ODatabaseDocument::impl_GetStorageOrCreateFor_throw(
+ const ::comphelper::NamedValueCollection& _rArguments, const OUString& _rURL) const
+{
+ // Try to get the storage from arguments, then create storage for target URL
+ uno::Reference<embed::XStorage> xTargetStorage;
+ _rArguments.get("TargetStorage") >>= xTargetStorage;
+ if (!xTargetStorage.is())
+ xTargetStorage = impl_createStorageFor_throw(_rURL);
+
+ // In case we got a StreamRelPath, then xTargetStorage should reference that sub-storage.
+ OUString sStreamRelPath = _rArguments.getOrDefault("StreamRelPath", OUString());
+ if (!sStreamRelPath.isEmpty())
+ xTargetStorage
+ = xTargetStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READWRITE);
+
+ return xTargetStorage;
+}
+
void SAL_CALL ODatabaseDocument::storeAsURL( const OUString& _rURL, const Sequence< PropertyValue >& _rArguments )
{
// SYNCHRONIZED ->
@@ -1232,11 +1243,12 @@ void SAL_CALL ODatabaseDocument::storeToURL( const OUString& _rURL, const Sequen
try
{
+ const ::comphelper::NamedValueCollection aArguments(_rArguments);
// create storage for target URL
- Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( _rURL ) );
+ Reference<XStorage> xTargetStorage(impl_GetStorageOrCreateFor_throw(aArguments, _rURL));
// extend media descriptor with URL
- Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
+ Sequence<PropertyValue> aMediaDescriptor(lcl_appendFileNameToDescriptor(aArguments, _rURL));
// store to this storage
impl_storeToStorage_throw( xTargetStorage, aMediaDescriptor, aGuard );
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx
index 9479511367ce..e910bff75d3e 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.hxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -546,6 +546,19 @@ private:
const OUString& _rURL
) const;
+ /** Extracts storage from arguments, or creates for the given URL, truncating it if a file with
+ this name already exists
+
+ @throws Exception
+ if creating the storage failed
+
+ @return
+ the storage that is either extracted from arguments, or newly created for the file at
+ the given URL
+ */
+ css::uno::Reference<css::embed::XStorage> impl_GetStorageOrCreateFor_throw(
+ const ::comphelper::NamedValueCollection& _rArguments, const OUString& _rURL) const;
+
/** sets our "modified" flag
will notify all our respective listeners, if the "modified" state actually changed