diff options
Diffstat (limited to 'linguistic/source/dlistimp.cxx')
-rw-r--r-- | linguistic/source/dlistimp.cxx | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx index 0436504c2b..0c27c945af 100644 --- a/linguistic/source/dlistimp.cxx +++ b/linguistic/source/dlistimp.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -30,27 +30,30 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_linguistic.hxx" -#include "dlistimp.hxx" -#include "dicimp.hxx" -#include "lngopt.hxx" #include <osl/file.hxx> #include <tools/fsys.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> #include <i18npool/mslangid.hxx> -#include <svtools/pathoptions.hxx> -#include <svtools/useroptions.hxx> -#include <sfx2/docfile.hxx> -#include <vcl/svapp.hxx> +#include <unotools/pathoptions.hxx> +#include <unotools/useroptions.hxx> #include <cppuhelper/factory.hxx> // helper for factories #include <unotools/localfilehelper.hxx> +#include <comphelper/processfactory.hxx> +#include <unotools/ucbstreamhelper.hxx> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/linguistic2/DictionaryEventFlags.hpp> #include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp> #include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> + +#include "defs.hxx" +#include "dlistimp.hxx" +#include "dicimp.hxx" +#include "lngopt.hxx" //using namespace utl; using namespace osl; @@ -317,9 +320,9 @@ DicList::~DicList() } -void DicList::SearchForDictionaries( +void DicList::SearchForDictionaries( DictionaryVec_t&rDicList, - const String &rDicDirURL, + const String &rDicDirURL, BOOL bIsWriteablePath ) { osl::MutexGuard aGuard( GetLinguMutex() ); @@ -374,10 +377,10 @@ void DicList::SearchForDictionaries( { // get decoded dictionary file name INetURLObject aURLObj( aURL ); - String aDicName = aURLObj.getName( INetURLObject::LAST_SEGMENT, - true, INetURLObject::DECODE_WITH_CHARSET, + String aDicName = aURLObj.getName( INetURLObject::LAST_SEGMENT, + true, INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8 ); - + DictionaryType eType = bNeg ? DictionaryType_NEGATIVE : DictionaryType_POSITIVE; uno::Reference< XDictionary > xDic = new DictionaryNeo( aDicName, nLang, eType, aURL, bIsWriteablePath ); @@ -686,8 +689,8 @@ void DicList::_CreateDicList() xIgnAll->setActive( TRUE ); addDictionary( xIgnAll ); } - - + + // evaluate list of dictionaries to be activated from configuration // //! to suppress overwriting the list of active dictionaries in the @@ -707,11 +710,11 @@ void DicList::_CreateDicList() xDic->setActive( TRUE ); } } - + // suppress collected events during creation of the dictionary list. // there should be no events during creation. pDicEvtLstnrHelper->ClearEvents(); - + pDicEvtLstnrHelper->EndCollectEvents(); bInCreation = FALSE; @@ -930,13 +933,31 @@ static BOOL IsVers2OrNewer( const String& rFileURL, USHORT& nLng, BOOL& bNeg ) return FALSE; // get stream to be used - SfxMedium aMedium( rFileURL, STREAM_READ | STREAM_SHARE_DENYWRITE, FALSE ); - SvStream *pStream = aMedium.GetInStream(); + uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() ); + + // get XInputStream stream + uno::Reference< io::XInputStream > xStream; + try + { + uno::Reference< ucb::XSimpleFileAccess > xAccess( xServiceFactory->createInstance( + A2OU( "com.sun.star.ucb.SimpleFileAccess" ) ), uno::UNO_QUERY_THROW ); + xStream = xAccess->openFileRead( rFileURL ); + } + catch (uno::Exception & e) + { + DBG_ASSERT( 0, "failed to get input stream" ); + (void) e; + } + DBG_ASSERT( xStream.is(), "failed to get stream for read" ); + if (!xStream.is()) + return FALSE; + + SvStreamPtr pStream = SvStreamPtr( utl::UcbStreamHelper::CreateStream( xStream ) ); - int nDicVersion = ReadDicVersion (pStream, nLng, bNeg); + int nDicVersion = ReadDicVersion(pStream, nLng, bNeg); if (2 == nDicVersion || nDicVersion >= 5) return TRUE; - + return FALSE; } |