diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/linguistic | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/linguistic')
-rw-r--r-- | include/linguistic/hyphdta.hxx | 136 | ||||
-rw-r--r-- | include/linguistic/lngdllapi.h | 35 | ||||
-rw-r--r-- | include/linguistic/lngprophelp.hxx | 360 | ||||
-rw-r--r-- | include/linguistic/lngprops.hxx | 55 | ||||
-rw-r--r-- | include/linguistic/misc.hxx | 215 | ||||
-rw-r--r-- | include/linguistic/spelldta.hxx | 117 |
6 files changed, 918 insertions, 0 deletions
diff --git a/include/linguistic/hyphdta.hxx b/include/linguistic/hyphdta.hxx new file mode 100644 index 000000000000..9dec2d6dc15e --- /dev/null +++ b/include/linguistic/hyphdta.hxx @@ -0,0 +1,136 @@ +/* -*- 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 _LINGUISTIC_HYPHDTA_HXX_ +#define _LINGUISTIC_HYPHDTA_HXX_ + +#include <com/sun/star/linguistic2/XHyphenatedWord.hpp> +#include <com/sun/star/linguistic2/XPossibleHyphens.hpp> +#include <tools/solar.h> +#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type +#include <cppuhelper/implbase1.hxx> // helper for implementations +#include <linguistic/lngdllapi.h> + +namespace linguistic +{ + +class HyphenatedWord : + public cppu::WeakImplHelper1 + < + ::com::sun::star::linguistic2::XHyphenatedWord + > +{ + OUString aWord; + OUString aHyphenatedWord; + sal_Int16 nHyphPos; + sal_Int16 nHyphenationPos; + sal_Int16 nLanguage; + sal_Bool bIsAltSpelling; + + // disallow copy-constructor and assignment-operator for now + HyphenatedWord(const HyphenatedWord &); + HyphenatedWord & operator = (const HyphenatedWord &); + +public: + HyphenatedWord(const OUString &rWord, sal_Int16 nLang, sal_Int16 nHyphenationPos, + const OUString &rHyphenatedWord, sal_Int16 nHyphenPos ); + virtual ~HyphenatedWord(); + + // XHyphenatedWord + virtual OUString SAL_CALL + getWord() + throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL + getLocale() + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL + getHyphenationPos() + throw(::com::sun::star::uno::RuntimeException); + virtual OUString SAL_CALL + getHyphenatedWord() + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL + getHyphenPos() + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL + isAlternativeSpelling() + throw(::com::sun::star::uno::RuntimeException); + + OUString GetWord() { return aWord; } + OUString GetHyphenatedWord() { return aHyphenatedWord; } + sal_Int16 GetLanguage() { return nLanguage; } + void SetWord( OUString &rTxt ) { aWord = rTxt; } + void SetHyphenatedWord( OUString &rTxt ) { aHyphenatedWord = rTxt; } + void SetLanguage( sal_Int16 nLang ) { nLanguage = nLang; } + static com::sun::star::uno::Reference <com::sun::star::linguistic2::XHyphenatedWord> LNG_DLLPUBLIC CreateHyphenatedWord( + const OUString &rWord, sal_Int16 nLang, sal_Int16 nHyphenationPos, + const OUString &rHyphenatedWord, sal_Int16 nHyphenPos ); +}; + + +class PossibleHyphens : + public cppu::WeakImplHelper1 + < + ::com::sun::star::linguistic2::XPossibleHyphens + > +{ + OUString aWord; + OUString aWordWithHyphens; + ::com::sun::star::uno::Sequence< sal_Int16 > aOrigHyphenPos; + sal_Int16 nLanguage; + + // disallow copy-constructor and assignment-operator for now + PossibleHyphens(const PossibleHyphens &); + PossibleHyphens & operator = (const PossibleHyphens &); + +public: + PossibleHyphens(const OUString &rWord, sal_Int16 nLang, + const OUString &rHyphWord, + const ::com::sun::star::uno::Sequence< sal_Int16 > &rPositions); + virtual ~PossibleHyphens(); + + // XPossibleHyphens + virtual OUString SAL_CALL + getWord() + throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL + getLocale() + throw(::com::sun::star::uno::RuntimeException); + virtual OUString SAL_CALL + getPossibleHyphens() + throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL + getHyphenationPositions() + throw(::com::sun::star::uno::RuntimeException); + + OUString GetWord() { return aWord; } + sal_Int16 GetLanguage() { return nLanguage; } + void SetWord( OUString &rTxt ) { aWord = rTxt; } + void SetLanguage( sal_Int16 nLang ) { nLanguage = nLang; } + + static com::sun::star::uno::Reference < com::sun::star::linguistic2::XPossibleHyphens > LNG_DLLPUBLIC CreatePossibleHyphens + (const OUString &rWord, sal_Int16 nLang, + const OUString &rHyphWord, + const ::com::sun::star::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 000000000000..0da35fe7e123 --- /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 _LNG_DLLAPI_H +#define _LNG_DLLAPI_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 000000000000..3995d87cc1e4 --- /dev/null +++ b/include/linguistic/lngprophelp.hxx @@ -0,0 +1,360 @@ +/* -*- 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 _LINGUISTIC_LNGPROPHELP_HXX_ +#define _LINGUISTIC_LNGPROPHELP_HXX_ + +#include <tools/solar.h> +#include <uno/lbnames.h> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/interfacecontainer.h> +#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> + +namespace com { namespace sun { namespace star { namespace beans { + class XPropertySet; +}}}} + +namespace com { namespace sun { namespace star { namespace linguistic2 { + struct LinguServiceEvent; +}}}} + + +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::WeakImplHelper2 +< + ::com::sun::star::beans::XPropertyChangeListener, + ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster +> PropertyChgHelperBase; + +class PropertyChgHelper : + public PropertyChgHelperBase +{ + ::com::sun::star::uno::Sequence< OUString > aPropNames; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > xMyEvtObj; + ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > xPropSet; + + int nEvtFlags; // flags for event types allowed to be launched + + // default values + sal_Bool bIsIgnoreControlCharacters; + sal_Bool bIsUseDictionaryList; + + // return values, will be set to default value or current temporary value + sal_Bool bResIsIgnoreControlCharacters; + sal_Bool bResIsUseDictionaryList; + + + // disallow use of copy-constructor and assignment-operator + PropertyChgHelper( const PropertyChgHelper & ); + PropertyChgHelper & operator = ( const PropertyChgHelper & ); + +protected: + virtual void SetDefaultValues(); + virtual void GetCurrentValues(); + + ::com::sun::star::uno::Sequence< OUString > & + GetPropNames() { return aPropNames; } + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & + GetPropSet() { return xPropSet; } + + void AddPropNames( const char *pNewNames[], sal_Int32 nCount ); + + virtual sal_Bool propertyChange_Impl( + const ::com::sun::star::beans::PropertyChangeEvent& rEvt ); + +public: + PropertyChgHelper( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet, + int nAllowedEvents ); + virtual ~PropertyChgHelper(); + + virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); + + // XEventListener + virtual void SAL_CALL + disposing( const ::com::sun::star::lang::EventObject& rSource ) + throw(::com::sun::star::uno::RuntimeException); + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) + throw(::com::sun::star::uno::RuntimeException); + + // XLinguServiceEventBroadcaster + virtual sal_Bool SAL_CALL + addLinguServiceEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) + throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL + removeLinguServiceEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) + throw(::com::sun::star::uno::RuntimeException); + + // non-UNO functions + void LNG_DLLPUBLIC AddAsPropListener(); + void LNG_DLLPUBLIC RemoveAsPropListener(); + void LaunchEvent( + const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt ); + + const ::com::sun::star::uno::Sequence< OUString > & + GetPropNames() const { return aPropNames; } + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & + GetPropSet() const { return xPropSet; } + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > & + GetEvtObj() const { return xMyEvtObj; } + + sal_Bool IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; } + sal_Bool IsUseDictionaryList() const { return bResIsUseDictionaryList; } +}; + + +class PropertyHelper_Thes : + public PropertyChgHelper +{ + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Thes( const PropertyHelper_Thes & ); + PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ); + +public: + PropertyHelper_Thes( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet ); + virtual ~PropertyHelper_Thes(); + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) + throw(::com::sun::star::uno::RuntimeException); +}; + +class LNG_DLLPUBLIC PropertyHelper_Thesaurus +{ + PropertyHelper_Thes* pInst; + com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Thesaurus( const PropertyHelper_Thes & ); + PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & ); + +public: + PropertyHelper_Thesaurus( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet ); + ~PropertyHelper_Thesaurus(); + void AddAsPropListener(); + void RemoveAsPropListener(); + void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); +}; + + +class LNG_DLLPUBLIC PropertyHelper_Spell : + public PropertyChgHelper +{ + // default values + sal_Bool bIsSpellUpperCase; + sal_Bool bIsSpellWithDigits; + sal_Bool bIsSpellCapitalization; + + // return values, will be set to default value or current temporary value + sal_Int16 nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently + sal_Bool bResIsSpellUpperCase; + sal_Bool bResIsSpellWithDigits; + sal_Bool bResIsSpellCapitalization; + + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Spell( const PropertyHelper_Spell & ); + PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ); + +protected: + // PropertyChgHelper + virtual void SetDefaultValues(); + virtual void GetCurrentValues(); + virtual sal_Bool propertyChange_Impl( + const ::com::sun::star::beans::PropertyChangeEvent& rEvt ); + +public: + PropertyHelper_Spell( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet ); + virtual ~PropertyHelper_Spell(); + + virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) + throw(::com::sun::star::uno::RuntimeException); + + virtual sal_Int16 GetDefaultNumberOfSuggestions() const; + + sal_Int16 GetMaxNumberOfSuggestions() const { return nResMaxNumberOfSuggestions; } + sal_Bool IsSpellUpperCase() const { return bResIsSpellUpperCase; } + sal_Bool IsSpellWithDigits() const { return bResIsSpellWithDigits; } + sal_Bool IsSpellCapitalization() const { return bResIsSpellCapitalization; } +}; + + +class LNG_DLLPUBLIC PropertyHelper_Spelling +{ + PropertyHelper_Spell* pInst; + com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Spelling( const PropertyHelper_Spell & ); + PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & ); + +public: + PropertyHelper_Spelling( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet ); + ~PropertyHelper_Spelling(); + + void AddAsPropListener(); + void RemoveAsPropListener(); + void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); + sal_Bool IsSpellUpperCase() const; + sal_Bool IsSpellWithDigits() const; + sal_Bool IsSpellCapitalization() const; + sal_Bool addLinguServiceEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) + throw(::com::sun::star::uno::RuntimeException); + sal_Bool removeLinguServiceEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) + throw(::com::sun::star::uno::RuntimeException); +}; + + +class PropertyHelper_Hyphen : + public PropertyChgHelper +{ + // default values + sal_Int16 nHyphMinLeading, + nHyphMinTrailing, + nHyphMinWordLength; + + // return values, will be set to default value or current temporary value + sal_Int16 nResHyphMinLeading, + nResHyphMinTrailing, + nResHyphMinWordLength; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Hyphen( const PropertyHelper_Hyphen & ); + PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ); + +protected: + // PropertyChgHelper + virtual void SetDefaultValues(); + virtual void GetCurrentValues(); + virtual sal_Bool propertyChange_Impl( + const ::com::sun::star::beans::PropertyChangeEvent& rEvt ); + +public: + PropertyHelper_Hyphen( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet); + virtual ~PropertyHelper_Hyphen(); + + virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); + + // XPropertyChangeListener + virtual void SAL_CALL + propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) + throw(::com::sun::star::uno::RuntimeException); + + sal_Int16 GetMinLeading() const { return nResHyphMinLeading; } + sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; } + sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; } +}; + +class LNG_DLLPUBLIC PropertyHelper_Hyphenation +{ + PropertyHelper_Hyphen* pInst; + com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper; + + // disallow use of copy-constructor and assignment-operator + PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & ); + PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & ); + +public: + PropertyHelper_Hyphenation( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > &rxSource, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet); + ~PropertyHelper_Hyphenation(); + + void AddAsPropListener(); + void RemoveAsPropListener(); + void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); + sal_Int16 GetMinLeading() const; + sal_Int16 GetMinTrailing() const; + sal_Int16 GetMinWordLength() const; + sal_Bool addLinguServiceEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) + throw(::com::sun::star::uno::RuntimeException); + sal_Bool removeLinguServiceEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) + throw(::com::sun::star::uno::RuntimeException); +}; + +} // 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 000000000000..2f8339f9b0b8 --- /dev/null +++ b/include/linguistic/lngprops.hxx @@ -0,0 +1,55 @@ +/* -*- 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 _LINGUISTIC_LNGPROPS_HHX_ +#define _LINGUISTIC_LNGPROPS_HHX_ + +#include <unotools/linguprops.hxx> + +// maximal number of suggestions to be returned in spelling context-menu +// (may not include results added by looking up user dictionaries) +#define UPN_MAX_NUMBER_OF_SUGGESTIONS "MaxNumberOfSuggestions" + +// WIDs for property names +//!! Don't change values! They are used as the property handles in +//!! the service description +#define WID_IS_GERMAN_PRE_REFORM UPH_IS_GERMAN_PRE_REFORM /*! deprecated !*/ +#define WID_IS_USE_DICTIONARY_LIST UPH_IS_USE_DICTIONARY_LIST +#define WID_IS_IGNORE_CONTROL_CHARACTERS UPH_IS_IGNORE_CONTROL_CHARACTERS +#define WID_IS_SPELL_UPPER_CASE UPH_IS_SPELL_UPPER_CASE +#define WID_IS_SPELL_WITH_DIGITS UPH_IS_SPELL_WITH_DIGITS +#define WID_IS_SPELL_CAPITALIZATION UPH_IS_SPELL_CAPITALIZATION +#define WID_HYPH_MIN_LEADING UPH_HYPH_MIN_LEADING +#define WID_HYPH_MIN_TRAILING UPH_HYPH_MIN_TRAILING +#define WID_HYPH_MIN_WORD_LENGTH UPH_HYPH_MIN_WORD_LENGTH +#define WID_DEFAULT_LOCALE UPH_DEFAULT_LOCALE +#define WID_IS_SPELL_AUTO UPH_IS_SPELL_AUTO +#define WID_IS_SPELL_HIDE UPH_IS_SPELL_HIDE /*! deprecated !*/ +#define WID_IS_SPELL_IN_ALL_LANGUAGES UPH_IS_SPELL_IN_ALL_LANGUAGES /*! deprecated !*/ +#define WID_IS_SPELL_SPECIAL UPH_IS_SPELL_SPECIAL +#define WID_IS_HYPH_AUTO UPH_IS_HYPH_AUTO +#define WID_IS_HYPH_SPECIAL UPH_IS_HYPH_SPECIAL +#define WID_IS_WRAP_REVERSE UPH_IS_WRAP_REVERSE +#define WID_DEFAULT_LANGUAGE UPH_DEFAULT_LANGUAGE +#define WID_DEFAULT_LOCALE_CJK UPH_DEFAULT_LOCALE_CJK +#define WID_DEFAULT_LOCALE_CTL UPH_DEFAULT_LOCALE_CTL + +#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 000000000000..c15d2fc70dab --- /dev/null +++ b/include/linguistic/misc.hxx @@ -0,0 +1,215 @@ +/* -*- 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 _LINGUISTIC_MISC_HXX_ +#define _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 <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/linguistic2/XDictionaryEntry.hpp> +#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> +#include <com/sun/star/linguistic2/XHyphenatedWord.hpp> + +#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type +#include <cppuhelper/implbase1.hxx> // helper for implementations +#include <unotools/pathoptions.hxx> +#include <i18nlangtag/lang.h> +#include <tools/string.hxx> +#include <unotools/charclass.hxx> +#include <osl/thread.h> +#include <osl/mutex.hxx> +#include <linguistic/lngdllapi.h> + +namespace com { namespace sun { namespace star { namespace beans { + class XPropertySet; + class XFastPropertySet; +}}}} + +namespace com { namespace sun { namespace star { namespace frame { + class XDesktop2; +}}}} + +class LocaleDataWrapper; + + +#define SN_GRAMMARCHECKER "com.sun.star.linguistic2.Proofreader" +#define SN_SPELLCHECKER "com.sun.star.linguistic2.SpellChecker" +#define SN_HYPHENATOR "com.sun.star.linguistic2.Hyphenator" +#define SN_THESAURUS "com.sun.star.linguistic2.Thesaurus" +#define SN_LINGU_PROPERTIES "com.sun.star.linguistic2.LinguProperties" + + +namespace linguistic +{ + +/// Flags to be used with the multi-path related functions +/// @see GetDictionaryPaths +#define PATH_FLAG_INTERNAL 0x01 +#define PATH_FLAG_USER 0x02 +#define PATH_FLAG_WRITABLE 0x04 +#define PATH_FLAG_ALL (PATH_FLAG_INTERNAL | PATH_FLAG_USER | PATH_FLAG_WRITABLE) + + +// AddEntryToDic return values +#define DIC_ERR_NONE 0 +#define DIC_ERR_FULL 1 +#define DIC_ERR_READONLY 2 +#define DIC_ERR_UNKNOWN 3 +#define DIC_ERR_NOT_EXISTS 4 + +// values asigned to capitalization types +enum CapType +{ + CAPTYPE_UNKNOWN, + CAPTYPE_NOCAP, + CAPTYPE_INITCAP, + CAPTYPE_ALLCAP, + CAPTYPE_MIXED +}; + +LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex(); + +LocaleDataWrapper & GetLocaleDataWrapper( sal_Int16 nLang ); + +sal_Int32 LevDistance( const OUString &rTxt1, const OUString &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 ::com::sun::star::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 ::com::sun::star::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 ); + +::com::sun::star::uno::Sequence< sal_Int16 > + LocaleSeqToLangSeq( ::com::sun::star::uno::Sequence< + ::com::sun::star::lang::Locale > &rLocaleSeq ); + +// checks if file pointed to by rURL is readonly +// and may also check return if such a file exists or not +sal_Bool IsReadOnly( const String &rURL, sal_Bool *pbExist = 0 ); + +// checks if a file with the given URL exists +sal_Bool FileExists( const String &rURL ); + + +OUString GetDictionaryWriteablePath(); +::com::sun::star::uno::Sequence< OUString > GetDictionaryPaths( sal_Int16 nPathFlags = PATH_FLAG_ALL ); + +/// @returns an URL for a new and writable dictionary rDicName. +/// The URL will point to the path given by 'GetDictionaryWriteablePath' +LNG_DLLPUBLIC String GetWritableDictionaryURL( const String &rDicName ); + +LNG_DLLPUBLIC sal_Int32 GetPosInWordToCheck( const OUString &rTxt, sal_Int32 nPos ); + +::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XHyphenatedWord > + RebuildHyphensAndControlChars( const OUString &rOrigWord, + ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XHyphenatedWord > &rxHyphWord ); + + +LNG_DLLPUBLIC sal_Bool IsUpper( const String &rText, xub_StrLen nPos, xub_StrLen nLen, sal_Int16 nLanguage ); + +inline sal_Bool IsUpper( const String &rText, sal_Int16 nLanguage ) { return IsUpper( rText, 0, rText.Len(), nLanguage ); } +LNG_DLLPUBLIC CapType SAL_CALL capitalType(const OUString&, CharClass *); + +String ToLower( const String &rText, sal_Int16 nLanguage ); +LNG_DLLPUBLIC sal_Bool HasDigits( const OUString &rText ); +LNG_DLLPUBLIC sal_Bool IsNumeric( const String &rText ); + + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > GetOneInstanceService( const char *pServiceName ); +LNG_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetLinguProperties(); +::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > GetDictionaryList(); +::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > GetIgnoreAllList(); + + +sal_Bool IsUseDicList( const ::com::sun::star::beans::PropertyValues &rProperties, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet ); + +sal_Bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rProperties, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > &rxPropSet ); + +::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XDictionaryEntry > + SearchDicList( + const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList >& rDicList, + const OUString& rWord, sal_Int16 nLanguage, + sal_Bool bSearchPosDics, sal_Bool bSearchSpellEntry ); + +LNG_DLLPUBLIC sal_uInt8 AddEntryToDic( + ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > &rxDic, + const OUString &rWord, sal_Bool bIsNeg, + const OUString &rRplcTxt, sal_Int16 nRplcLang, + sal_Bool bStripDot = sal_True ); + +LNG_DLLPUBLIC sal_Bool SaveDictionaries( const ::com::sun::star::uno::Reference< ::com::sun::star::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::WeakImplHelper1 + < + ::com::sun::star::frame::XTerminateListener + > +{ + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDesktop2 > xDesktop; + +public: + AppExitListener(); + virtual ~AppExitListener(); + + virtual void AtExit() = 0; + + void Activate(); + void Deactivate(); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); +}; + +} // 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 000000000000..92f9cd680c77 --- /dev/null +++ b/include/linguistic/spelldta.hxx @@ -0,0 +1,117 @@ +/* -*- 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 _LINGUISTIC_SPELLDTA_HXX_ +#define _LINGUISTIC_SPELLDTA_HXX_ + +#include <vector> +#include <com/sun/star/linguistic2/XSpellAlternatives.hpp> +#include <com/sun/star/linguistic2/XSetSpellAlternatives.hpp> +#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> + +#include <tools/solar.h> + +#include <uno/lbnames.h> +#include <cppuhelper/implbase2.hxx> +#include <linguistic/lngdllapi.h> + +#include <boost/noncopyable.hpp> + +namespace com { namespace sun { namespace star { + namespace linguistic2 { + class XDictionaryList; + } +} } } + + +namespace linguistic +{ + +::com::sun::star::uno::Sequence< OUString > + MergeProposalSeqs( + ::com::sun::star::uno::Sequence< OUString > &rAlt1, + ::com::sun::star::uno::Sequence< OUString > &rAlt2, + sal_Bool bAllowDuplicates ); + +void SeqRemoveNegEntries( + ::com::sun::star::uno::Sequence< OUString > &rSeq, + ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XSearchableDictionaryList > &rxDicList, + sal_Int16 nLanguage ); + +sal_Bool SeqHasEntry( + const ::com::sun::star::uno::Sequence< OUString > &rSeq, + const OUString &rTxt); + +/////////////////////////////////////////////////////////////////////////// + +void SearchSimilarText( const OUString &rText, sal_Int16 nLanguage, + ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XSearchableDictionaryList > &xDicList, + std::vector< OUString > & rDicListProps ); + +/////////////////////////////////////////////////////////////////////////// + + +class SpellAlternatives + : public cppu::WeakImplHelper2 + < + ::com::sun::star::linguistic2::XSpellAlternatives, + ::com::sun::star::linguistic2::XSetSpellAlternatives + > + , private ::boost::noncopyable +{ + ::com::sun::star::uno::Sequence< OUString > aAlt; // list of alternatives, may be empty. + OUString aWord; + sal_Int16 nType; // type of failure + sal_Int16 nLanguage; + +public: + LNG_DLLPUBLIC SpellAlternatives(); + SpellAlternatives(const OUString &rWord, sal_Int16 nLang, sal_Int16 nFailureType, + const ::com::sun::star::uno::Sequence< OUString > &rAlternatives ); + virtual ~SpellAlternatives(); + + // XSpellAlternatives + virtual OUString SAL_CALL getWord( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getFailureType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getAlternativesCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAlternatives( ) throw (::com::sun::star::uno::RuntimeException); + + // XSetSpellAlternatives + virtual void SAL_CALL setAlternatives( const ::com::sun::star::uno::Sequence< OUString >& aAlternatives ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFailureType( ::sal_Int16 nFailureType ) throw (::com::sun::star::uno::RuntimeException); + + // non-interface specific functions + void LNG_DLLPUBLIC SetWordLanguage(const OUString &rWord, sal_Int16 nLang); + void LNG_DLLPUBLIC SetFailureType(sal_Int16 nTypeP); + void LNG_DLLPUBLIC SetAlternatives( const ::com::sun::star::uno::Sequence< OUString > &rAlt ); + static com::sun::star::uno::Reference < com::sun::star::linguistic2::XSpellAlternatives > LNG_DLLPUBLIC CreateSpellAlternatives( + const OUString &rWord, sal_Int16 nLang, sal_Int16 nTypeP, const ::com::sun::star::uno::Sequence< OUString > &rAlt ); +}; + + +/////////////////////////////////////////////////////////////////////////// + +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |