bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / dialogs / SpellAttrib.hxx
blobd50b851805e4ed5d36d8ae0ae3f72feb359d68f2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CUI_SOURCE_DIALOGS_SPELLATTRIB_HXX
20 #define INCLUDED_CUI_SOURCE_DIALOGS_SPELLATTRIB_HXX
22 #include <vcl/txtattr.hxx>
23 #include <i18nlangtag/lang.h>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/uno/Sequence.h>
26 #include <com/sun/star/lang/Locale.hpp>
27 #include <com/sun/star/linguistic2/XProofreader.hpp>
28 #include <tools/color.hxx>
30 #define TEXTATTR_SPELL_ERROR (TEXTATTR_USER_START + 1)
31 #define TEXTATTR_SPELL_LANGUAGE (TEXTATTR_USER_START + 2)
32 #define TEXTATTR_SPELL_BACKGROUND (TEXTATTR_USER_START + 3)
34 namespace svx{
35 struct SpellErrorDescription
37 bool bIsGrammarError;
38 OUString sErrorText;
39 OUString sDialogTitle;
40 OUString sExplanation;
41 OUString sExplanationURL;
42 ::com::sun::star::lang::Locale aLocale;
43 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > xGrammarChecker;
44 OUString sServiceName; ///< service name of GrammarChecker/SpellChecker
45 ::com::sun::star::uno::Sequence< OUString > aSuggestions;
46 OUString sRuleId;
48 SpellErrorDescription() :
49 bIsGrammarError( false ){}
51 SpellErrorDescription( bool bGrammar,
52 const OUString& rText,
53 const ::com::sun::star::lang::Locale& rLocale,
54 const ::com::sun::star::uno::Sequence< OUString >& rSuggestions,
55 ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > rxGrammarChecker,
56 const OUString& rServiceName,
57 const OUString* pDialogTitle = 0,
58 const OUString* pExplanation = 0,
59 const OUString* pRuleId = 0,
60 const OUString* pExplanationURL = 0 ) :
61 bIsGrammarError( bGrammar ),
62 sErrorText( rText ),
63 sDialogTitle( ),
64 sExplanation( ),
65 sExplanationURL( ),
66 aLocale( rLocale ),
67 xGrammarChecker( rxGrammarChecker ),
68 sServiceName( rServiceName ),
69 aSuggestions( rSuggestions )
71 if( pDialogTitle )
72 sDialogTitle = *pDialogTitle;
73 if( pExplanation )
74 sExplanation = *pExplanation;
75 if( pExplanationURL )
76 sExplanationURL = *pExplanationURL;
77 if( pRuleId )
78 sRuleId = *pRuleId;
81 bool operator==( const SpellErrorDescription& rDesc ) const
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 sExplanationURL.equals( rDesc.sExplanationURL ) &&
93 sRuleId == rDesc.sRuleId;
98 class SpellErrorAttrib : public TextAttrib
100 public:
102 private:
103 SpellErrorDescription m_aSpellErrorDescription;
105 //not accessible
106 SpellErrorAttrib();
107 public:
108 SpellErrorAttrib( const SpellErrorDescription& );
109 SpellErrorAttrib( const SpellErrorAttrib& rAttr );
110 virtual ~SpellErrorAttrib();
112 const SpellErrorDescription& GetErrorDescription() const { return m_aSpellErrorDescription; }
115 virtual void SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
116 virtual TextAttrib* Clone() const SAL_OVERRIDE;
117 virtual bool operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
121 class SpellLanguageAttrib : public TextAttrib
123 LanguageType m_eLanguage;
125 //not accessible
126 SpellLanguageAttrib();
128 public:
129 SpellLanguageAttrib(LanguageType eLanguage);
130 SpellLanguageAttrib( const SpellLanguageAttrib& rAttr );
131 virtual ~SpellLanguageAttrib();
133 LanguageType GetLanguage() const {return m_eLanguage;}
134 void SetLanguage(LanguageType eLang)
135 {m_eLanguage = eLang;}
138 virtual void SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
139 virtual TextAttrib* Clone() const SAL_OVERRIDE;
140 virtual bool operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
144 class SpellBackgroundAttrib : public TextAttrib
146 Color m_aBackgroundColor;
148 //not accessible
149 SpellBackgroundAttrib();
151 public:
152 SpellBackgroundAttrib(const Color& rCol);
153 SpellBackgroundAttrib( const SpellBackgroundAttrib& rAttr );
154 virtual ~SpellBackgroundAttrib();
156 const Color& GetColor() const { return m_aBackgroundColor;}
157 void SetColor( const Color& rNewCol ){m_aBackgroundColor = rNewCol;}
160 virtual void SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
161 virtual TextAttrib* Clone() const SAL_OVERRIDE;
162 virtual bool operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
164 }//namespace svx
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */