1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SVX_SPELL_ATTRIB 28 #define _SVX_SPELL_ATTRIB 29 30 #include <svtools/txtattr.hxx> 31 #include <i18npool/lang.h> 32 #include <com/sun/star/uno/Reference.h> 33 #include <com/sun/star/uno/Sequence.h> 34 #include <com/sun/star/lang/Locale.hpp> 35 #include <com/sun/star/linguistic2/XProofreader.hpp> 36 #include <tools/color.hxx> 37 //namespace com{ namespace sun{ namespace star{ namespace linguistic2{ 38 // class XSpellAlternatives; 39 //}}}} 40 41 #define TEXTATTR_SPELL_ERROR (TEXTATTR_USER_START + 1) 42 #define TEXTATTR_SPELL_LANGUAGE (TEXTATTR_USER_START + 2) 43 #define TEXTATTR_SPELL_BACKGROUND (TEXTATTR_USER_START + 3) 44 45 namespace svx{ 46 struct SpellErrorDescription 47 { 48 bool bIsGrammarError; 49 ::rtl::OUString sErrorText; 50 ::rtl::OUString sDialogTitle; 51 ::rtl::OUString sExplanation; 52 ::com::sun::star::lang::Locale aLocale; 53 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > xGrammarChecker; 54 ::rtl::OUString sServiceName; //service name of GrammarChecker/SpellChecker 55 ::com::sun::star::uno::Sequence< ::rtl::OUString > aSuggestions; 56 ::rtl::OUString sRuleId; 57 58 SpellErrorDescription() : 59 bIsGrammarError( false ){} 60 61 SpellErrorDescription( bool bGrammar, 62 const ::rtl::OUString& rText, 63 const ::com::sun::star::lang::Locale& rLocale, 64 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSuggestions, 65 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > rxGrammarChecker, 66 const ::rtl::OUString& rServiceName, 67 const ::rtl::OUString* pDialogTitle = 0, 68 const ::rtl::OUString* pExplanation = 0, 69 const ::rtl::OUString* pRuleId = 0 ) : 70 bIsGrammarError( bGrammar ), 71 sErrorText( rText ), 72 aLocale( rLocale ), 73 xGrammarChecker( rxGrammarChecker ), 74 sServiceName( rServiceName ), 75 aSuggestions( rSuggestions ) 76 { 77 if( pDialogTitle ) 78 sDialogTitle = *pDialogTitle; 79 if( pExplanation ) 80 sExplanation = *pExplanation; 81 if( pRuleId ) 82 sRuleId = *pRuleId; 83 }; 84 85 int operator==( const SpellErrorDescription& rDesc ) const 86 { 87 return bIsGrammarError == rDesc.bIsGrammarError && 88 sErrorText.equals( rDesc.sErrorText ) && 89 aLocale.Language.equals( rDesc.aLocale.Language ) && 90 aLocale.Country.equals( rDesc.aLocale.Country ) && 91 aLocale.Variant.equals( rDesc.aLocale.Variant ) && 92 aSuggestions == rDesc.aSuggestions && 93 xGrammarChecker == rDesc.xGrammarChecker && 94 sDialogTitle.equals( rDesc.sDialogTitle ) && 95 sExplanation.equals( rDesc.sExplanation ) && 96 sRuleId == rDesc.sRuleId; 97 } 98 }; 99 /* -----------------10.09.2003 14:23----------------- 100 101 --------------------------------------------------*/ 102 class SpellErrorAttrib : public TextAttrib 103 { 104 public: 105 106 private: 107 //com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> m_xAlternatives; 108 SpellErrorDescription m_aSpellErrorDescription; 109 110 //not accessible 111 SpellErrorAttrib(); 112 public: 113 // SpellErrorAttrib(com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> xAlternatives); 114 SpellErrorAttrib( const SpellErrorDescription& ); 115 SpellErrorAttrib( const SpellErrorAttrib& rAttr ); 116 ~SpellErrorAttrib(); 117 118 const SpellErrorDescription& GetErrorDescription() const { return m_aSpellErrorDescription; } 119 120 121 virtual void SetFont( Font& rFont ) const; 122 virtual TextAttrib* Clone() const; 123 virtual int operator==( const TextAttrib& rAttr ) const; 124 }; 125 /* -----------------10.09.2003 14:23----------------- 126 127 --------------------------------------------------*/ 128 class SpellLanguageAttrib : public TextAttrib 129 { 130 LanguageType m_eLanguage; 131 132 //not accessible 133 SpellLanguageAttrib(); 134 135 public: 136 SpellLanguageAttrib(LanguageType eLanguage); 137 SpellLanguageAttrib( const SpellLanguageAttrib& rAttr ); 138 ~SpellLanguageAttrib(); 139 140 LanguageType GetLanguage() const {return m_eLanguage;} 141 void SetLanguage(LanguageType eLang) 142 {m_eLanguage = eLang;} 143 144 145 virtual void SetFont( Font& rFont ) const; 146 virtual TextAttrib* Clone() const; 147 virtual int operator==( const TextAttrib& rAttr ) const; 148 }; 149 /* -----------------31.10.2003 16:01----------------- 150 151 --------------------------------------------------*/ 152 class SpellBackgroundAttrib : public TextAttrib 153 { 154 Color m_aBackgroundColor; 155 156 //not accessible 157 SpellBackgroundAttrib(); 158 159 public: 160 SpellBackgroundAttrib(const Color& rCol); 161 SpellBackgroundAttrib( const SpellBackgroundAttrib& rAttr ); 162 ~SpellBackgroundAttrib(); 163 164 const Color& GetColor() const { return m_aBackgroundColor;} 165 void SetColor( const Color& rNewCol ){m_aBackgroundColor = rNewCol;} 166 167 168 virtual void SetFont( Font& rFont ) const; 169 virtual TextAttrib* Clone() const; 170 virtual int operator==( const TextAttrib& rAttr ) const; 171 }; 172 }//namespace svx 173 #endif 174