From ef0a7a309d03c83f59a32595132f3f3e4c9893c0 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 27 Aug 2013 14:35:18 +0100 Subject: Resolves: fdo#67743 ensure user autocorr config dir exists We try and copy the shared one to the user location the first time we create a customized user file. If the dir doesn't exist then that migration doesn't happen. The new autocorr file is then written, creating the dir, and any further operations will reattempt the skipped share copy, and this time succeed because the dir now exists. Which overwrites the previously written customized content. This is similar to fdo#65501 "ensure configured backup dir exists before using it", so reuse that code and move it into unotools. Change-Id: I38fa621b8d7295d70b09172a028569ea95404120 (cherry picked from commit 68dea1c1b61a99cdef556ba7d8ccfdad1be8a663) Reviewed-on: https://gerrit.libreoffice.org/5645 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- editeng/source/misc/acorrcfg.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'editeng') diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx index 04a9bdf5ffa2..af4d5bde0d9a 100644 --- a/editeng/source/misc/acorrcfg.cxx +++ b/editeng/source/misc/acorrcfg.cxx @@ -17,11 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include #include #include #include +#include #include +#include #include #include @@ -31,6 +33,7 @@ #include using namespace utl; +using namespace com::sun::star; using namespace com::sun::star::uno; @@ -47,10 +50,18 @@ SvxAutoCorrCfg::SvxAutoCorrCfg() : SvtPathOptions aPathOpt; String sSharePath, sUserPath, sAutoPath( aPathOpt.GetAutoCorrectPath() ); + sSharePath = sAutoPath.GetToken(0, ';'); + sUserPath = sAutoPath.GetToken(1, ';'); + + //fdo#67743 ensure the userdir exists so that any later attempt to copy the + //shared autocorrect file into the user dir will succeed + ::ucbhelper::Content aContent; + Reference < ucb::XCommandEnvironment > xEnv; + ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, sUserPath, aContent); + String* pS = &sSharePath; for( sal_uInt16 n = 0; n < 2; ++n, pS = &sUserPath ) { - *pS = sAutoPath.GetToken( n, ';' ); INetURLObject aPath( *pS ); aPath.insertName(OUString("acor")); *pS = aPath.GetMainURL(INetURLObject::DECODE_TO_IURI); -- cgit v1.2.3