diff options
Diffstat (limited to 'include/linguistic')
-rw-r--r-- | include/linguistic/hyphdta.hxx | 110 | ||||
-rw-r--r-- | include/linguistic/lngdllapi.h | 35 | ||||
-rw-r--r-- | include/linguistic/lngprophelp.hxx | 314 | ||||
-rw-r--r-- | include/linguistic/lngprops.hxx | 31 | ||||
-rw-r--r-- | include/linguistic/misc.hxx | 196 | ||||
-rw-r--r-- | include/linguistic/spelldta.hxx | 95 | ||||
-rw-r--r-- | include/linguistic/translate.hxx | 20 |
7 files changed, 801 insertions, 0 deletions
diff --git a/include/linguistic/hyphdta.hxx b/include/linguistic/hyphdta.hxx new file mode 100644 index 0000000000..48030b5717 --- /dev/null +++ b/include/linguistic/hyphdta.hxx @@ -0,0 +1,110 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_LINGUISTIC_HYPHDTA_HXX +#define INCLUDED_LINGUISTIC_HYPHDTA_HXX + +#include <com/sun/star/linguistic2/XHyphenatedWord.hpp> +#include <com/sun/star/linguistic2/XPossibleHyphens.hpp> +#include <cppuhelper/implbase.hxx> +#include <linguistic/lngdllapi.h> +#include <i18nlangtag/lang.h> +#include <config_options.h> + +namespace linguistic +{ + +class HyphenatedWord final : + public cppu::WeakImplHelper< css::linguistic2::XHyphenatedWord > +{ + OUString aWord; + OUString aHyphenatedWord; + sal_Int16 nHyphPos; + sal_Int16 nHyphenationPos; + LanguageType nLanguage; + bool bIsAltSpelling; + + HyphenatedWord(const HyphenatedWord &) = delete; + HyphenatedWord & operator = (const HyphenatedWord &) = delete; + +public: + HyphenatedWord(const OUString &rWord, LanguageType nLang, sal_Int16 nHyphenationPos, + const OUString &rHyphenatedWord, sal_Int16 nHyphenPos ); + virtual ~HyphenatedWord() override; + + // XHyphenatedWord + virtual OUString SAL_CALL + getWord() override; + virtual css::lang::Locale SAL_CALL + getLocale() override; + virtual sal_Int16 SAL_CALL + getHyphenationPos() override; + virtual OUString SAL_CALL + getHyphenatedWord() override; + virtual sal_Int16 SAL_CALL + getHyphenPos() override; + virtual sal_Bool SAL_CALL + isAlternativeSpelling() override; + + static css::uno::Reference <css::linguistic2::XHyphenatedWord> UNLESS_MERGELIBS(LNG_DLLPUBLIC) CreateHyphenatedWord( + const OUString &rWord, LanguageType nLang, sal_Int16 nHyphenationPos, + const OUString &rHyphenatedWord, sal_Int16 nHyphenPos ); +}; + + +class PossibleHyphens final : + public cppu::WeakImplHelper + < + css::linguistic2::XPossibleHyphens + > +{ + OUString aWord; + OUString aWordWithHyphens; + css::uno::Sequence< sal_Int16 > aOrigHyphenPos; + LanguageType nLanguage; + + PossibleHyphens(const PossibleHyphens &) = delete; + PossibleHyphens & operator = (const PossibleHyphens &) = delete; + +public: + PossibleHyphens(OUString aWord, LanguageType nLang, + OUString aHyphWord, + const css::uno::Sequence< sal_Int16 > &rPositions); + virtual ~PossibleHyphens() override; + + // XPossibleHyphens + virtual OUString SAL_CALL + getWord() override; + virtual css::lang::Locale SAL_CALL + getLocale() override; + virtual OUString SAL_CALL + getPossibleHyphens() override; + virtual css::uno::Sequence< sal_Int16 > SAL_CALL + getHyphenationPositions() override; + + static css::uno::Reference < css::linguistic2::XPossibleHyphens > UNLESS_MERGELIBS(LNG_DLLPUBLIC) CreatePossibleHyphens + (const OUString &rWord, LanguageType nLang, + const OUString &rHyphWord, + const css::uno::Sequence< sal_Int16 > &rPositions); +}; +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/linguistic/lngdllapi.h b/include/linguistic/lngdllapi.h new file mode 100644 index 0000000000..3944d47cfe --- /dev/null +++ b/include/linguistic/lngdllapi.h @@ -0,0 +1,35 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_LINGUISTIC_LNGDLLAPI_H +#define INCLUDED_LINGUISTIC_LNGDLLAPI_H + +#include <sal/config.h> +#include <sal/types.h> + +#if defined(LNG_DLLIMPLEMENTATION) +#define LNG_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define LNG_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define LNG_DLLPRIVATE SAL_DLLPRIVATE + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/linguistic/lngprophelp.hxx b/include/linguistic/lngprophelp.hxx new file mode 100644 index 0000000000..85b32b7cec --- /dev/null +++ b/include/linguistic/lngprophelp.hxx @@ -0,0 +1,314 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_LINGUISTIC_LNGPROPHELP_HXX +#define INCLUDED_LINGUISTIC_LNGPROPHELP_HXX + +#include <cppuhelper/implbase.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> +#include <linguistic/lngdllapi.h> +#include <rtl/ref.hxx> +#include <config_options.h> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::linguistic2 { struct LinguServiceEvent; } +namespace com::sun::star::linguistic2 { class XLinguProperties; } + + +namespace linguistic +{ + +// PropertyChgHelper +// Base class for all XPropertyChangeListener members of the +// various lingu services. + + +// Flags for type of events allowed to be launched +#define AE_SPELLCHECKER 1 +#define AE_HYPHENATOR 2 + +typedef cppu::WeakImplHelper +< + css::beans::XPropertyChangeListener, + css::linguistic2::XLinguServiceEventBroadcaster +> PropertyChgHelperBase; + +class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyChgHelper : + public PropertyChgHelperBase +{ + std::vector< OUString > aPropNames; + css::uno::Reference< css::uno::XInterface > xMyEvtObj; + ::comphelper::OInterfaceContainerHelper3<css::linguistic2::XLinguServiceEventListener> aLngSvcEvtListeners; + css::uno::Reference< css::beans::XPropertySet > xPropSet; + + int nEvtFlags; // flags for event types allowed to be launched + + // default values + bool bIsIgnoreControlCharacters; + bool bIsUseDictionaryList; + + // return values, will be set to default value or current temporary value + bool bResIsIgnoreControlCharacters; + bool bResIsUseDictionaryList; + + PropertyChgHelper( const PropertyChgHelper & ) = delete; + PropertyChgHelper & operator = ( const PropertyChgHelper & ) = delete; + +protected: + virtual void SetDefaultValues(); + virtual void GetCurrentValues(); + + std::vector< OUString > & GetPropNames() { return aPropNames; } + css::uno::Reference< + css::beans::XPropertySet > & + GetPropSet() { return xPropSet; } + + virtual bool propertyChange_Impl( const css::beans::PropertyChangeEvent& rEvt ); + +public: + PropertyChgHelper( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet, + int nAllowedEvents ); + virtual ~PropertyChgHelper() override; + + virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); + + // XEventListener + virtual void SAL_CALL + disposing( const css::lang::EventObject& rSource ) override; + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; + + // XLinguServiceEventBroadcaster + virtual sal_Bool SAL_CALL + addLinguServiceEventListener( + const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override; + virtual sal_Bool SAL_CALL + removeLinguServiceEventListener( + const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override; + + // non-UNO functions + void AddAsPropListener(); + void RemoveAsPropListener(); + void LaunchEvent( const css::linguistic2::LinguServiceEvent& rEvt ); + + const std::vector< OUString > & + GetPropNames() const { return aPropNames; } + const css::uno::Reference< css::beans::XPropertySet > & + GetPropSet() const { return xPropSet; } + const css::uno::Reference< css::uno::XInterface > & + GetEvtObj() const { return xMyEvtObj; } +}; + + +class PropertyHelper_Thes final : + public PropertyChgHelper +{ + PropertyHelper_Thes( const PropertyHelper_Thes & ) = delete; + PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ) = delete; + +public: + PropertyHelper_Thes( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); + virtual ~PropertyHelper_Thes() override; + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; +}; + +class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Thesaurus +{ + rtl::Reference< PropertyHelper_Thes > mxPropHelper; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Thesaurus( const PropertyHelper_Thes & ) = delete; + PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & ) = delete; + +public: + PropertyHelper_Thesaurus( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); + ~PropertyHelper_Thesaurus(); + void AddAsPropListener(); + void RemoveAsPropListener(); + void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); +}; + + +class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spell final : + public PropertyChgHelper +{ + // default values + bool bIsSpellUpperCase; + bool bIsSpellWithDigits; + bool bIsSpellCapitalization; + bool bIsSpellClosedCompound; + bool bIsSpellHyphenatedCompound; + + // return values, will be set to default value or current temporary value + bool bResIsSpellUpperCase; + bool bResIsSpellWithDigits; + bool bResIsSpellCapitalization; + bool bResIsSpellClosedCompound; + bool bResIsSpellHyphenatedCompound; + + PropertyHelper_Spell( const PropertyHelper_Spell & ) = delete; + PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ) = delete; + + // PropertyChgHelper + virtual void SetDefaultValues() override; + virtual void GetCurrentValues() override; + virtual bool propertyChange_Impl( + const css::beans::PropertyChangeEvent& rEvt ) override; + +public: + PropertyHelper_Spell( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); + virtual ~PropertyHelper_Spell() override; + + virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override; + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; + + bool IsSpellUpperCase() const { return bResIsSpellUpperCase; } + bool IsSpellWithDigits() const { return bResIsSpellWithDigits; } + bool IsSpellCapitalization() const { return bResIsSpellCapitalization; } + bool IsSpellClosedCompound() const { return bResIsSpellClosedCompound; } + bool IsSpellHyphenatedCompound() const { return bResIsSpellHyphenatedCompound; } +}; + + +class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spelling +{ + rtl::Reference< PropertyHelper_Spell > mxPropHelper; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Spelling( const PropertyHelper_Spell & ) = delete; + PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & ) = delete; + +public: + PropertyHelper_Spelling( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); + ~PropertyHelper_Spelling(); + + void AddAsPropListener(); + void RemoveAsPropListener(); + void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); + bool IsSpellUpperCase() const; + bool IsSpellWithDigits() const; + bool IsSpellCapitalization() const; + bool IsSpellClosedCompound() const; + bool IsSpellHyphenatedCompound() const; + /// @throws css::uno::RuntimeException + bool addLinguServiceEventListener( + const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); + /// @throws css::uno::RuntimeException + bool removeLinguServiceEventListener( + const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); +}; + + +class PropertyHelper_Hyphen final : + public PropertyChgHelper +{ + // default values + sal_Int16 nHyphMinLeading, + nHyphMinTrailing, + nHyphMinWordLength; + bool bNoHyphenateCaps; + + // return values, will be set to default value or current temporary value + sal_Int16 nResHyphMinLeading, + nResHyphMinTrailing, + nResHyphMinWordLength; + bool bResNoHyphenateCaps; + + PropertyHelper_Hyphen( const PropertyHelper_Hyphen & ) = delete; + PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ) = delete; + + // PropertyChgHelper + virtual void SetDefaultValues() override; + virtual void GetCurrentValues() override; + virtual bool propertyChange_Impl( + const css::beans::PropertyChangeEvent& rEvt ) override; + +public: + PropertyHelper_Hyphen( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet); + virtual ~PropertyHelper_Hyphen() override; + + virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override; + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; + + sal_Int16 GetMinLeading() const { return nResHyphMinLeading; } + sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; } + sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; } + bool IsNoHyphenateCaps() const { return bResNoHyphenateCaps; } +}; + +class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Hyphenation +{ + rtl::Reference< PropertyHelper_Hyphen > mxPropHelper; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & ) = delete; + PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & ) = delete; + +public: + PropertyHelper_Hyphenation( + const css::uno::Reference< css::uno::XInterface > &rxSource, + css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet); + ~PropertyHelper_Hyphenation(); + + void AddAsPropListener(); + void RemoveAsPropListener(); + void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); + sal_Int16 GetMinLeading() const; + sal_Int16 GetMinTrailing() const; + sal_Int16 GetMinWordLength() const; + bool IsNoHyphenateCaps() const; + /// @throws css::uno::RuntimeException + bool addLinguServiceEventListener( + const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); + /// @throws css::uno::RuntimeException + bool removeLinguServiceEventListener( + const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); +}; + +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/linguistic/lngprops.hxx b/include/linguistic/lngprops.hxx new file mode 100644 index 0000000000..b9a00d44c9 --- /dev/null +++ b/include/linguistic/lngprops.hxx @@ -0,0 +1,31 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_LINGUISTIC_LNGPROPS_HXX +#define INCLUDED_LINGUISTIC_LNGPROPS_HXX + +#include <rtl/ustring.hxx> + +// maximal number of suggestions to be returned in spelling context-menu +// (may not include results added by looking up user dictionaries) +inline constexpr OUString UPN_MAX_NUMBER_OF_SUGGESTIONS = u"MaxNumberOfSuggestions"_ustr; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx new file mode 100644 index 0000000000..57c7179a20 --- /dev/null +++ b/include/linguistic/misc.hxx @@ -0,0 +1,196 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_LINGUISTIC_MISC_HXX +#define INCLUDED_LINGUISTIC_MISC_HXX + +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/lang/Locale.hpp> + +#include <cppuhelper/implbase.hxx> +#include <i18nlangtag/lang.h> +#include <rtl/ustring.hxx> +#include <linguistic/lngdllapi.h> + +#include <vector> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::frame { class XDesktop2; } +namespace com::sun::star::linguistic2 { class XDictionary; } +namespace com::sun::star::linguistic2 { class XDictionaryEntry; } +namespace com::sun::star::linguistic2 { class XHyphenatedWord; } +namespace com::sun::star::linguistic2 { class XLinguProperties; } +namespace com::sun::star::linguistic2 { class XSearchableDictionaryList; } +namespace osl { class Mutex; } + +class CharClass; +class LocaleDataWrapper; + + +inline constexpr OUString SN_GRAMMARCHECKER = u"com.sun.star.linguistic2.Proofreader"_ustr; +inline constexpr OUString SN_SPELLCHECKER = u"com.sun.star.linguistic2.SpellChecker"_ustr; +inline constexpr OUString SN_HYPHENATOR = u"com.sun.star.linguistic2.Hyphenator"_ustr; +inline constexpr OUString SN_THESAURUS = u"com.sun.star.linguistic2.Thesaurus"_ustr; + + +namespace linguistic +{ + + +// AddEntryToDic return values +enum class DictionaryError +{ + NONE, FULL, READONLY, UNKNOWN, NOT_EXISTS +}; + +// values assigned to capitalization types +enum class CapType +{ + UNKNOWN, + NOCAP, + INITCAP, + ALLCAP, + MIXED +}; + +LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex(); + +const LocaleDataWrapper & GetLocaleDataWrapper( LanguageType nLang ); + +sal_Int32 LevDistance( std::u16string_view rTxt1, std::u16string_view rTxt2 ); + +/** Convert Locale to LanguageType for legacy handling. + Linguistic specific handling of an empty locale denoting LANGUAGE_NONE. + Does not resolve empty locale as system locale. + */ +LNG_DLLPUBLIC LanguageType LinguLocaleToLanguage( const css::lang::Locale& rLocale ); + +/** Convert LanguageType to Locale for legacy handling. + Linguistic specific handling of LANGUAGE_NONE resulting in an empty locale. + Avoid use! + */ +LNG_DLLPUBLIC css::lang::Locale LinguLanguageToLocale( LanguageType nLanguage ); + +/** Checks if a LanguageType is one of the values that denote absence of + language or undetermined language or multiple languages, in short all + values used in linguistic context that do not denote a specific language. + */ +LNG_DLLPUBLIC bool LinguIsUnspecified( LanguageType nLanguage ); + +/** The same as LinguIsUnspecified(LanguageType) but taking a BCP 47 language + tag string instead. */ +LNG_DLLPUBLIC bool LinguIsUnspecified( std::u16string_view rBcp47 ); + +std::vector< LanguageType > + LocaleSeqToLangVec( css::uno::Sequence< css::lang::Locale > const &rLocaleSeq ); +css::uno::Sequence<sal_Int16> + LocaleSeqToLangSeq( css::uno::Sequence< css::lang::Locale > const &rLocaleSeq ); + +// checks if file pointed to by rURL is readonly +// and may also check return if such a file exists or not +bool IsReadOnly( const OUString &rURL, bool *pbExist = nullptr ); + +// checks if a file with the given URL exists +bool FileExists( const OUString &rURL ); + + +OUString GetDictionaryWriteablePath(); +std::vector< OUString > GetDictionaryPaths(); + +/// @returns a URL for a new and writable dictionary rDicName. +/// The URL will point to the path given by 'GetDictionaryWriteablePath' +LNG_DLLPUBLIC OUString GetWritableDictionaryURL( std::u16string_view rDicName ); + +LNG_DLLPUBLIC sal_Int32 GetPosInWordToCheck( std::u16string_view rTxt, sal_Int32 nPos ); + +css::uno::Reference< css::linguistic2::XHyphenatedWord > + RebuildHyphensAndControlChars( + const OUString &rOrigWord, + css::uno::Reference< css::linguistic2::XHyphenatedWord > const &rxHyphWord ); + + +LNG_DLLPUBLIC bool IsUpper( const OUString &rText, sal_Int32 nPos, sal_Int32 nLen, LanguageType nLanguage ); + +inline bool IsUpper( const OUString &rText, LanguageType nLanguage ) { return IsUpper( rText, 0, rText.getLength(), nLanguage ); } +LNG_DLLPUBLIC CapType capitalType(const OUString&, CharClass const *); + +LNG_DLLPUBLIC bool HasDigits( const OUString &rText ); +LNG_DLLPUBLIC bool IsNumeric( std::u16string_view rText ); + + +LNG_DLLPUBLIC css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguProperties(); +css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList(); +css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList(); + + +bool IsUseDicList( const css::beans::PropertyValues &rProperties, + const css::uno::Reference< css::beans::XPropertySet > &rxPropSet ); + +bool IsIgnoreControlChars( const css::beans::PropertyValues &rProperties, + const css::uno::Reference< css::beans::XPropertySet > &rxPropSet ); + +css::uno::Reference< + css::linguistic2::XDictionaryEntry > + SearchDicList( + const css::uno::Reference< css::linguistic2::XSearchableDictionaryList >& rDicList, + const OUString& rWord, LanguageType nLanguage, + bool bSearchPosDics, bool bSearchSpellEntry ); + +LNG_DLLPUBLIC DictionaryError AddEntryToDic( + css::uno::Reference< css::linguistic2::XDictionary > const &rxDic, + const OUString &rWord, bool bIsNeg, + const OUString &rRplcTxt, + bool bStripDot = true ); + +LNG_DLLPUBLIC bool SaveDictionaries( const css::uno::Reference< css::linguistic2::XSearchableDictionaryList > &xDicList ); + +// AppExitLstnr: +// virtual base class that calls it AtExit function when the application +// (ie the Desktop) is about to terminate + +class AppExitListener : + public cppu::WeakImplHelper< css::frame::XTerminateListener > +{ + css::uno::Reference< css::frame::XDesktop2 > xDesktop; + +public: + AppExitListener(); + virtual ~AppExitListener() override; + + virtual void AtExit() = 0; + + void Activate(); + void Deactivate(); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XTerminateListener + virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override; +}; + +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/linguistic/spelldta.hxx b/include/linguistic/spelldta.hxx new file mode 100644 index 0000000000..d0057ffbd4 --- /dev/null +++ b/include/linguistic/spelldta.hxx @@ -0,0 +1,95 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_LINGUISTIC_SPELLDTA_HXX +#define INCLUDED_LINGUISTIC_SPELLDTA_HXX + +#include <vector> +#include <com/sun/star/linguistic2/XSpellAlternatives.hpp> +#include <com/sun/star/linguistic2/XSetSpellAlternatives.hpp> +#include <cppuhelper/implbase.hxx> +#include <linguistic/lngdllapi.h> +#include <i18nlangtag/lang.h> +#include <config_options.h> + +namespace com::sun::star::linguistic2 { class XSearchableDictionaryList; } + + +namespace linguistic +{ + +std::vector< OUString > + MergeProposalSeqs( + std::vector< OUString > &rAlt1, + std::vector< OUString > &rAlt2 ); + +void SeqRemoveNegEntries( + std::vector< OUString > &rSeq, + css::uno::Reference< css::linguistic2::XSearchableDictionaryList > const &rxDicList, + LanguageType nLanguage ); + +void SearchSimilarText( const OUString &rText, LanguageType nLanguage, + css::uno::Reference< css::linguistic2::XSearchableDictionaryList > const &xDicList, + std::vector< OUString > & rDicListProps ); + + +class SpellAlternatives final + : public cppu::WeakImplHelper + < + css::linguistic2::XSpellAlternatives, + css::linguistic2::XSetSpellAlternatives + > +{ + css::uno::Sequence< OUString > aAlt; // list of alternatives, may be empty. + OUString aWord; + sal_Int16 nType; // type of failure + LanguageType nLanguage; + +public: + UNLESS_MERGELIBS(LNG_DLLPUBLIC) SpellAlternatives(); + SpellAlternatives(OUString aWord, LanguageType nLang, + const css::uno::Sequence< OUString > &rAlternatives ); + virtual ~SpellAlternatives() override; + SpellAlternatives(const SpellAlternatives&) = delete; + SpellAlternatives& operator=( const SpellAlternatives& ) = delete; + + // XSpellAlternatives + virtual OUString SAL_CALL getWord( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + virtual ::sal_Int16 SAL_CALL getFailureType( ) override; + virtual ::sal_Int16 SAL_CALL getAlternativesCount( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getAlternatives( ) override; + + // XSetSpellAlternatives + virtual void SAL_CALL setAlternatives( const css::uno::Sequence< OUString >& aAlternatives ) override; + virtual void SAL_CALL setFailureType( ::sal_Int16 nFailureType ) override; + + // non-interface specific functions + void UNLESS_MERGELIBS(LNG_DLLPUBLIC) SetWordLanguage(const OUString &rWord, LanguageType nLang); + void UNLESS_MERGELIBS(LNG_DLLPUBLIC) SetFailureType(sal_Int16 nTypeP); + void UNLESS_MERGELIBS(LNG_DLLPUBLIC) SetAlternatives( const css::uno::Sequence< OUString > &rAlt ); + static css::uno::Reference < css::linguistic2::XSpellAlternatives > UNLESS_MERGELIBS(LNG_DLLPUBLIC) CreateSpellAlternatives( + const OUString &rWord, LanguageType nLang, sal_Int16 nTypeP, const css::uno::Sequence< OUString > &rAlt ); +}; + +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/linguistic/translate.hxx b/include/linguistic/translate.hxx new file mode 100644 index 0000000000..0d5643f056 --- /dev/null +++ b/include/linguistic/translate.hxx @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once +#include <linguistic/lngdllapi.h> +#include <rtl/string.hxx> + +namespace linguistic +{ +LNG_DLLPUBLIC OString Translate(const OString& rTargetLang, const OString& rAPIUrl, + const OString& rAuthKey, const OString& rData); +} // namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |