From a8e838010cd167e0d709c03819e2f243b66f98a3 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 13 Jan 2012 03:34:28 +0100 Subject: don't create lock files for unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit special thanks to Stephan for the configuration part Signed-off-by: Fridrich Štrba --- sfx2/source/doc/docfile.cxx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'sfx2') diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index fd2fb1ecfbc7..b9aeb16687e7 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -207,6 +207,31 @@ sal_Bool IsOOoLockFileUsed() return bOOoLockFileUsed; } +bool IsLockingUsed() +{ + bool bLocking = true; + try + { + + uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig( + ::comphelper::getProcessServiceFactory(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ), + ::comphelper::ConfigurationHelper::E_STANDARD ); + if ( !xCommonConfig.is() ) + throw uno::RuntimeException(); + + ::comphelper::ConfigurationHelper::readRelativeKey( + xCommonConfig, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLocking" ) ) ) >>= bLocking; + } + catch( const uno::Exception& ) + { + } + + return bLocking; +} + } // anonymous namespace //========================================================== @@ -1001,6 +1026,11 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) // if user cancel the loading the ERROR_ABORT is set sal_Bool bResult = sal_False; + if (!IsLockingUsed()) + { + return sal_True; + } + if ( !GetURLObject().HasError() ) try { if ( pImp->m_bLocked && bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) -- cgit