xref: /aoo41x/main/cui/source/dialogs/SpellAttrib.hxx (revision c4eee24d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_SPELL_ATTRIB
24 #define _SVX_SPELL_ATTRIB
25 
26 #include <svtools/txtattr.hxx>
27 #include <i18npool/lang.h>
28 #include <com/sun/star/uno/Reference.h>
29 #include <com/sun/star/uno/Sequence.h>
30 #include <com/sun/star/lang/Locale.hpp>
31 #include <com/sun/star/linguistic2/XProofreader.hpp>
32 #include <tools/color.hxx>
33 //namespace com{ namespace sun{ namespace star{ namespace linguistic2{
34 //    class XSpellAlternatives;
35 //}}}}
36 
37 #define TEXTATTR_SPELL_ERROR            (TEXTATTR_USER_START + 1)
38 #define TEXTATTR_SPELL_LANGUAGE         (TEXTATTR_USER_START + 2)
39 #define TEXTATTR_SPELL_BACKGROUND       (TEXTATTR_USER_START + 3)
40 
41 namespace svx{
42 struct SpellErrorDescription
43 {
44     bool                                                bIsGrammarError;
45     ::rtl::OUString                                     sErrorText;
46     ::rtl::OUString                                     sDialogTitle;
47     ::rtl::OUString                                     sExplanation;
48     ::com::sun::star::lang::Locale                      aLocale;
49     ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > xGrammarChecker;
50     ::rtl::OUString                                     sServiceName; //service name of GrammarChecker/SpellChecker
51     ::com::sun::star::uno::Sequence< ::rtl::OUString >  aSuggestions;
52     ::rtl::OUString                                     sRuleId;
53 
SpellErrorDescriptionsvx::SpellErrorDescription54     SpellErrorDescription() :
55         bIsGrammarError( false ){}
56 
SpellErrorDescriptionsvx::SpellErrorDescription57     SpellErrorDescription( bool bGrammar,
58                       const ::rtl::OUString& rText,
59                       const ::com::sun::star::lang::Locale& rLocale,
60                       const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rSuggestions,
61                       ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > rxGrammarChecker,
62                       const ::rtl::OUString& rServiceName,
63                       const ::rtl::OUString* pDialogTitle = 0,
64                       const ::rtl::OUString* pExplanation = 0,
65                       const ::rtl::OUString* pRuleId = 0 ) :
66         bIsGrammarError( bGrammar ),
67         sErrorText( rText ),
68         aLocale( rLocale ),
69         xGrammarChecker( rxGrammarChecker ),
70         sServiceName( rServiceName ),
71         aSuggestions( rSuggestions )
72         {
73             if( pDialogTitle )
74                 sDialogTitle = *pDialogTitle;
75             if( pExplanation )
76                 sExplanation = *pExplanation;
77             if( pRuleId )
78                 sRuleId = *pRuleId;
79         };
80 
operator ==svx::SpellErrorDescription81     int operator==( const SpellErrorDescription& rDesc ) const
82     {
83         return bIsGrammarError == rDesc.bIsGrammarError &&
84                 sErrorText.equals( rDesc.sErrorText ) &&
85                 aLocale.Language.equals( rDesc.aLocale.Language ) &&
86                 aLocale.Country.equals( rDesc.aLocale.Country ) &&
87                 aLocale.Variant.equals( rDesc.aLocale.Variant ) &&
88                 aSuggestions == rDesc.aSuggestions &&
89                 xGrammarChecker == rDesc.xGrammarChecker &&
90                 sDialogTitle.equals( rDesc.sDialogTitle ) &&
91                 sExplanation.equals( rDesc.sExplanation ) &&
92                 sRuleId == rDesc.sRuleId;
93     }
94 };
95 /* -----------------10.09.2003 14:23-----------------
96 
97  --------------------------------------------------*/
98 class SpellErrorAttrib : public TextAttrib
99 {
100 public:
101 
102 private:
103     //com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> m_xAlternatives;
104     SpellErrorDescription        m_aSpellErrorDescription;
105 
106                             //not accessible
107                             SpellErrorAttrib();
108 public:
109 //                            SpellErrorAttrib(com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> xAlternatives);
110                             SpellErrorAttrib( const SpellErrorDescription& );
111                             SpellErrorAttrib( const SpellErrorAttrib& rAttr );
112                             ~SpellErrorAttrib();
113 
GetErrorDescription() const114     const SpellErrorDescription& GetErrorDescription() const { return m_aSpellErrorDescription; }
115 
116 
117     virtual void            SetFont( Font& rFont ) const;
118     virtual TextAttrib*     Clone() const;
119     virtual int             operator==( const TextAttrib& rAttr ) const;
120 };
121 /* -----------------10.09.2003 14:23-----------------
122 
123  --------------------------------------------------*/
124 class SpellLanguageAttrib : public TextAttrib
125 {
126     LanguageType m_eLanguage;
127 
128                             //not accessible
129                             SpellLanguageAttrib();
130 
131 public:
132                             SpellLanguageAttrib(LanguageType eLanguage);
133                             SpellLanguageAttrib( const SpellLanguageAttrib& rAttr );
134                             ~SpellLanguageAttrib();
135 
GetLanguage() const136     LanguageType            GetLanguage() const {return m_eLanguage;}
SetLanguage(LanguageType eLang)137     void                    SetLanguage(LanguageType eLang)
138                                         {m_eLanguage = eLang;}
139 
140 
141     virtual void            SetFont( Font& rFont ) const;
142     virtual TextAttrib*     Clone() const;
143     virtual int             operator==( const TextAttrib& rAttr ) const;
144 };
145 /* -----------------31.10.2003 16:01-----------------
146 
147  --------------------------------------------------*/
148 class SpellBackgroundAttrib : public TextAttrib
149 {
150     Color   m_aBackgroundColor;
151 
152                             //not accessible
153                             SpellBackgroundAttrib();
154 
155 public:
156                             SpellBackgroundAttrib(const Color& rCol);
157                             SpellBackgroundAttrib( const SpellBackgroundAttrib& rAttr );
158                             ~SpellBackgroundAttrib();
159 
GetColor() const160     const   Color&          GetColor() const { return m_aBackgroundColor;}
SetColor(const Color & rNewCol)161     void                    SetColor( const Color& rNewCol ){m_aBackgroundColor = rNewCol;}
162 
163 
164     virtual void            SetFont( Font& rFont ) const;
165     virtual TextAttrib*     Clone() const;
166     virtual int             operator==( const TextAttrib& rAttr ) const;
167 };
168 }//namespace svx
169 #endif
170