[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - editeng/source include/unotools sfx2/source unotools/source
Caolán McNamara
caolanm at redhat.com
Tue Aug 27 06:50:25 PDT 2013
editeng/source/misc/acorrcfg.cxx | 15 +++++++++++++--
include/unotools/ucbhelper.hxx | 18 +++++++++++++++---
sfx2/source/doc/docfile.cxx | 23 ++---------------------
unotools/source/ucbhelper/ucbhelper.cxx | 20 ++++++++++++++++++++
4 files changed, 50 insertions(+), 26 deletions(-)
New commits:
commit ef0a7a309d03c83f59a32595132f3f3e4c9893c0
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Aug 27 14:35:18 2013 +0100
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 <tbehrens at suse.com>
Tested-by: Thorsten Behrens <tbehrens at suse.com>
diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx
index 04a9bdf..af4d5bd 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 <comphelper/processfactory.hxx>
#include <editeng/acorrcfg.hxx>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
+#include <ucbhelper/content.hxx>
#include <unotools/pathoptions.hxx>
+#include <unotools/ucbhelper.hxx>
#include <svl/urihelper.hxx>
#include <editeng/svxacorr.hxx>
@@ -31,6 +33,7 @@
#include <rtl/instance.hxx>
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);
diff --git a/include/unotools/ucbhelper.hxx b/include/unotools/ucbhelper.hxx
index fad06ce..fe29a3a 100644
--- a/include/unotools/ucbhelper.hxx
+++ b/include/unotools/ucbhelper.hxx
@@ -26,9 +26,15 @@
#include "sal/types.h"
#include "unotools/unotoolsdllapi.h"
-namespace com { namespace sun { namespace star { namespace uno {
- class Any;
-} } } }
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class Any;
+ class XComponentContext;
+ }
+ namespace ucb{
+ class XCommandEnvironment;
+ }
+} } }
namespace ucbhelper { class Content; }
namespace utl { namespace UCBContentHelper {
@@ -53,6 +59,12 @@ UNOTOOLS_DLLPUBLIC bool MakeFolder(
ucbhelper::Content & parent, OUString const & title,
ucbhelper::Content & result, bool exclusive = false);
+/// like mkdir -p
+UNOTOOLS_DLLPUBLIC bool ensureFolder(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xCtx,
+ com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv,
+ const OUString& rFolder, ucbhelper::Content & result);
+
/// @return the value of the "Size" property of the given content, or zero if
/// obtaining the property yields a void value or raises a
/// non-RuntimeException (RuntimeExceptions are passed through)
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 25b7f27..c1ad603 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -2126,25 +2126,6 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont
aTransactTemp.EnableKillingFile( true );
}
-bool ensureFolder(
- uno::Reference< uno::XComponentContext > xCtx,
- uno::Reference< ucb::XCommandEnvironment > xEnv,
- const OUString& rFolder, ucbhelper::Content & result)
-{
- INetURLObject aURL( rFolder );
- OUString aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
- aURL.removeSegment();
- ::ucbhelper::Content aParent;
-
- if ( ::ucbhelper::Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ),
- xEnv, xCtx, aParent ) )
- {
- return ::utl::UCBContentHelper::MakeFolder(aParent, aTitle, result);
- }
-
- return false;
-}
-
//------------------------------------------------------------------
void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent )
{
@@ -2163,7 +2144,7 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont
// create content for the parent folder ( = backup folder )
::ucbhelper::Content aContent;
Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv;
- if( ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) )
+ if( ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) )
DoInternalBackup_Impl( aOriginalContent, aPrefix, aExtension, aBakDir );
if ( pImp->m_aBackupURL.isEmpty() )
@@ -2203,7 +2184,7 @@ void SfxMedium::DoBackup_Impl()
// create content for the parent folder ( = backup folder )
::ucbhelper::Content aContent;
Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv;
- if( ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) )
+ if( ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, aBakDir, aContent) )
{
// save as ".bak" file
INetURLObject aDest( aBakDir );
diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx
index 82b869f..2dc2bff 100644
--- a/unotools/source/ucbhelper/ucbhelper.cxx
+++ b/unotools/source/ucbhelper/ucbhelper.cxx
@@ -42,6 +42,7 @@
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/util/DateTime.hpp"
#include "comphelper/processfactory.hxx"
#include "cppuhelper/exc_hlp.hxx"
@@ -453,4 +454,23 @@ bool utl::UCBContentHelper::EqualURLs(
== 0;
}
+bool utl::UCBContentHelper::ensureFolder(
+ css::uno::Reference< css::uno::XComponentContext > xCtx,
+ css::uno::Reference< css::ucb::XCommandEnvironment > xEnv,
+ const OUString& rFolder, ucbhelper::Content & result)
+{
+ INetURLObject aURL( rFolder );
+ OUString aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ aURL.removeSegment();
+ ::ucbhelper::Content aParent;
+
+ if ( ::ucbhelper::Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ),
+ xEnv, xCtx, aParent ) )
+ {
+ return ::utl::UCBContentHelper::MakeFolder(aParent, aTitle, result);
+ }
+
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list