summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-01-10 19:37:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-11 07:19:02 +0100
commitdd42f133f604ee2f7e0ffbca6a8d94fb8f95dfe5 (patch)
tree0d6dd54a8f6cb74ead327ee837389ea3f44ed91e /sfx2
parent46b6ddc000a12795af361062bce471fa6e997d9a (diff)
tdf#146375 Cannot rename user-defined categories in template manager
Regression from commit 3624a703361b108d22448bd60a97733f05e37820 tdf#135316 remove OTempFileService pessimisation So fix two things here (1) make it so the tempfile service flushes the SvStream buffer and resets the file position, so we can read the data after writing it. (2) Simplify the UCB usage to just write the contents of the tempfile via the tempfile InputStream, which is simpler and safer Change-Id: I15ed3b02c2d6415d10a9579f66374e6268188d5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128195 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/doctemplates.cxx21
1 files changed, 8 insertions, 13 deletions
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 9ac236b3b4f4..cbdbe676f6f1 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertyContainer.hpp>
#include <com/sun/star/beans/StringPair.hpp>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/util/theMacroExpander.hpp>
#include <com/sun/star/util/theOfficeInstallationDirectories.hpp>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
@@ -231,7 +232,7 @@ class SfxDocTplService_Impl
const OUString& aNewGroupName );
void RemoveUINamesForTemplateDir_Impl( const OUString& aUserPath,
std::u16string_view aGroupName );
- bool WriteUINamesForTemplateDir_Impl( const OUString& aUserPath,
+ bool WriteUINamesForTemplateDir_Impl( std::u16string_view aUserPath,
const std::vector< beans::StringPair >& aUINames );
OUString CreateNewGroupFsys( const OUString& rGroupName, Content& aGroup );
@@ -1264,7 +1265,7 @@ void SfxDocTplService_Impl::RemoveUINamesForTemplateDir_Impl( const OUString& aU
}
-bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const OUString& aUserPath,
+bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( std::u16string_view aUserPath,
const std::vector< beans::StringPair >& aUINames )
{
bool bResult = false;
@@ -1273,10 +1274,7 @@ bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const OUString& aUs
io::TempFile::create(mxContext),
uno::UNO_SET_THROW );
- OUString aTempURL = xTempFile->getUri();
-
- uno::Reference< io::XStream > xStream( xTempFile );
- uno::Reference< io::XOutputStream > xOutStream = xStream->getOutputStream();
+ uno::Reference< io::XOutputStream > xOutStream = xTempFile->getOutputStream();
if ( !xOutStream.is() )
throw uno::RuntimeException();
@@ -1287,17 +1285,14 @@ bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const OUString& aUs
} catch( uno::Exception& )
{}
- Content aTargetContent( aUserPath, maCmdEnv, comphelper::getProcessComponentContext() );
- Content aSourceContent( aTempURL, maCmdEnv, comphelper::getProcessComponentContext() );
- aTargetContent.transferContent( aSourceContent,
- InsertOperation::Copy,
- "groupuinames.xml",
- ucb::NameClash::OVERWRITE,
- "text/xml" );
+ uno::Reference < ucb::XSimpleFileAccess3 > xAccess(ucb::SimpleFileAccess::create(mxContext));
+ xAccess->writeFile(OUString::Concat(aUserPath) + "groupuinames.xml", xTempFile->getInputStream());
+
bResult = true;
}
catch ( uno::Exception& )
{
+ TOOLS_WARN_EXCEPTION("sfx.doc", "");
}
return bResult;