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