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