/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
//! Dummy implementation in order to avoid loading of lingu DLL //! when only the XSupportedLocales interface is used. //! The dummy accesses the real implementation (and thus loading the DLL) //! when "real" work needs to be done only. class ThesDummy_Impl : public cppu::WeakImplHelper< XThesaurus >
{
uno::Reference< XThesaurus > xThes; // the real one...
std::unique_ptr<Sequence< lang::Locale >> pLocaleSeq;
if (xThes.is())
{ // no longer needed...
pLocaleSeq.reset();
}
}
}
uno::Sequence< lang::Locale > SAL_CALL
ThesDummy_Impl::getLocales()
{
GetThes_Impl(); if (xThes.is()) return xThes->getLocales(); elseif (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
GetCfgLocales(); return *pLocaleSeq;
}
sal_Bool SAL_CALL
ThesDummy_Impl::hasLocale( const lang::Locale& rLocale )
{
GetThes_Impl(); if (xThes.is()) return xThes->hasLocale( rLocale ); elseif (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
GetCfgLocales(); bool bFound = false;
sal_Int32 nLen = pLocaleSeq->getLength(); const lang::Locale *pLocale = pLocaleSeq->getConstArray(); const lang::Locale *pEnd = pLocale + nLen; for ( ; pLocale < pEnd && !bFound; ++pLocale)
{
bFound = pLocale->Language == rLocale.Language &&
pLocale->Country == rLocale.Country &&
pLocale->Variant == rLocale.Variant;
} return bFound;
}
//! Dummy implementation in order to avoid loading of lingu DLL. //! The dummy accesses the real implementation (and thus loading the DLL) //! when it needs to be done only. class SpellDummy_Impl : public cppu::WeakImplHelper< XSpellChecker1 >
{
uno::Reference< XSpellChecker1 > xSpell; // the real one...
//! Dummy implementation in order to avoid loading of lingu DLL. //! The dummy accesses the real implementation (and thus loading the DLL) //! when it needs to be done only. class HyphDummy_Impl : public cppu::WeakImplHelper< XHyphenator >
{
uno::Reference< XHyphenator > xHyph; // the real one...
LinguMgrExitLstnr::LinguMgrExitLstnr()
{ // add object to frame::Desktop EventListeners in order to properly call // the AtExit function at application exit.
LinguMgrExitLstnr::~LinguMgrExitLstnr()
{ if (xDesktop.is())
{
xDesktop->removeEventListener( this );
xDesktop = nullptr; //! release reference to desktop
}
OSL_ENSURE(!xDesktop.is(), "reference to desktop should be released");
}
void LinguMgrExitLstnr::disposing(const EventObject& rSource)
{ if (xDesktop.is() && rSource.Source == xDesktop)
{
xDesktop->removeEventListener( this );
xDesktop = nullptr; //! release reference to desktop
uno::Reference< XDictionary > LinguMgr::GetStandardDic()
{ //! don't hold reference to this //! (it may be removed from dictionary list and needs to be //! created empty if accessed again) return GetStandard();
}
uno::Reference< XSpellChecker1 > LinguMgr::GetSpell()
{ if (bExiting) return nullptr;
if (!pExitLstnr)
pExitLstnr = new LinguMgrExitLstnr;
//! use dummy implementation in order to avoid loading of lingu DLL
xSpell = new SpellDummy_Impl; return xSpell;
}
uno::Reference< XHyphenator > LinguMgr::GetHyph()
{ if (bExiting) return nullptr;
if (!pExitLstnr)
pExitLstnr = new LinguMgrExitLstnr;
//! use dummy implementation in order to avoid loading of lingu DLL
xHyph = new HyphDummy_Impl; return xHyph;
}
uno::Reference< XThesaurus > LinguMgr::GetThes()
{ if (bExiting) return nullptr;
if (!pExitLstnr)
pExitLstnr = new LinguMgrExitLstnr;
//! use dummy implementation in order to avoid loading of lingu DLL //! when only the XSupportedLocales interface is used. //! The dummy accesses the real implementation (and thus loading the DLL) //! when "real" work needs to be done only.
xThes = new ThesDummy_Impl; return xThes;
}
uno::Reference< XSearchableDictionaryList > LinguMgr::GetDicList()
{ if (bExiting) return nullptr;
if (!pExitLstnr)
pExitLstnr = new LinguMgrExitLstnr;
uno::Reference< XDictionary > LinguMgr::GetStandard()
{ // Tries to return a dictionary which may hold positive entries is // persistent and not read-only.
if (bExiting) return nullptr;
uno::Reference< XSearchableDictionaryList > xTmpDicList( GetDictionaryList() ); if (!xTmpDicList.is()) return nullptr;
// count number of chars from the left to the // hyphenation pos / hyphen pos that are equal
sal_Int16 nL = 0; while (nL <= nHyphenationPos && nL <= nHyphenPos
&& pWord[ nL ] == pAltWord[ nL ])
++nL; // count number of chars from the right to the // hyphenation pos / hyphen pos that are equal
sal_Int16 nR = 0;
sal_Int32 nIdx = nLen - 1;
sal_Int32 nAltIdx = nAltLen - 1; while (nIdx > nHyphenationPos && nAltIdx > nHyphenPos
&& pWord[ nIdx-- ] == pAltWord[ nAltIdx-- ])
++nR;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.