Prepare for removal of non-const operator[] from Sequence in cui
[LibreOffice.git] / cui / source / dialogs / SpellAttrib.hxx
blobd732aad69ba1597575ee2279b263892032ef2524
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 #pragma once
21 #include <com/sun/star/uno/Reference.h>
22 #include <com/sun/star/uno/Sequence.h>
23 #include <com/sun/star/lang/Locale.hpp>
24 #include <com/sun/star/linguistic2/XProofreader.hpp>
26 namespace svx{
27 struct SpellErrorDescription
29 bool bIsGrammarError;
30 OUString sErrorText;
31 OUString sDialogTitle;
32 OUString sExplanation;
33 OUString sExplanationURL;
34 css::lang::Locale aLocale;
35 css::uno::Reference< css::linguistic2::XProofreader > xGrammarChecker;
36 css::uno::Sequence< OUString > aSuggestions;
37 OUString sRuleId;
39 SpellErrorDescription( bool bGrammar,
40 const OUString& rText,
41 const css::lang::Locale& rLocale,
42 const css::uno::Sequence< OUString >& rSuggestions,
43 css::uno::Reference< css::linguistic2::XProofreader > const & rxGrammarChecker,
44 const OUString* pDialogTitle = nullptr,
45 const OUString* pExplanation = nullptr,
46 const OUString* pRuleId = nullptr,
47 const OUString* pExplanationURL = nullptr ) :
48 bIsGrammarError( bGrammar ),
49 sErrorText( rText ),
50 sDialogTitle( ),
51 sExplanation( ),
52 sExplanationURL( ),
53 aLocale( rLocale ),
54 xGrammarChecker( rxGrammarChecker ),
55 aSuggestions( rSuggestions )
57 if( pDialogTitle )
58 sDialogTitle = *pDialogTitle;
59 if( pExplanation )
60 sExplanation = *pExplanation;
61 if( pExplanationURL )
62 sExplanationURL = *pExplanationURL;
63 if( pRuleId )
64 sRuleId = *pRuleId;
67 SpellErrorDescription()
68 : bIsGrammarError(false)
72 bool operator==( const SpellErrorDescription& rDesc ) const
74 return bIsGrammarError == rDesc.bIsGrammarError &&
75 sErrorText == rDesc.sErrorText &&
76 aLocale.Language == rDesc.aLocale.Language &&
77 aLocale.Country == rDesc.aLocale.Country &&
78 aLocale.Variant == rDesc.aLocale.Variant &&
79 aSuggestions == rDesc.aSuggestions &&
80 xGrammarChecker == rDesc.xGrammarChecker &&
81 sDialogTitle == rDesc.sDialogTitle &&
82 sExplanation == rDesc.sExplanation &&
83 sExplanationURL == rDesc.sExplanationURL &&
84 sRuleId == rDesc.sRuleId;
87 css::uno::Sequence<css::uno::Any> toSequence() const
89 css::uno::Sequence<css::uno::Any> aEntries{ css::uno::Any(bIsGrammarError),
90 css::uno::Any(sErrorText),
91 css::uno::Any(sDialogTitle),
92 css::uno::Any(sExplanation),
93 css::uno::Any(sExplanationURL),
94 css::uno::Any(aLocale),
95 css::uno::Any(xGrammarChecker),
96 css::uno::Any(aSuggestions),
97 css::uno::Any(sRuleId) };
98 return aEntries;
101 void fromSequence(const css::uno::Sequence<css::uno::Any>& rEntries)
103 rEntries[0] >>= bIsGrammarError;
104 rEntries[1] >>= sErrorText;
105 rEntries[2] >>= sDialogTitle;
106 rEntries[3] >>= sExplanation;
107 rEntries[4] >>= sExplanationURL;
108 rEntries[5] >>= aLocale;
109 rEntries[6] >>= xGrammarChecker;
110 rEntries[7] >>= aSuggestions;
111 rEntries[8] >>= sRuleId;
115 }//namespace svx
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */