Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_LINGUISTIC_SOURCE_DEFS_HXX
21 : #define INCLUDED_LINGUISTIC_SOURCE_DEFS_HXX
22 :
23 : #include <com/sun/star/linguistic2/XSpellChecker.hpp>
24 : #include <com/sun/star/linguistic2/XProofreader.hpp>
25 : #include <com/sun/star/linguistic2/XHyphenator.hpp>
26 : #include <com/sun/star/linguistic2/XThesaurus.hpp>
27 :
28 : #include <boost/shared_ptr.hpp>
29 :
30 : class SvStream;
31 :
32 :
33 :
34 : typedef boost::shared_ptr< SvStream > SvStreamPtr;
35 :
36 2333 : struct LangSvcEntries
37 : {
38 : css::uno::Sequence< OUString > aSvcImplNames;
39 :
40 : sal_Int16 nLastTriedSvcIndex;
41 : bool bAlreadyWarned;
42 : bool bDoWarnAgain;
43 :
44 : LangSvcEntries() : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) {}
45 :
46 1628 : inline LangSvcEntries( const css::uno::Sequence< OUString > &rSvcImplNames ) :
47 : aSvcImplNames(rSvcImplNames),
48 1628 : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
49 : {
50 1628 : }
51 :
52 836 : inline LangSvcEntries( const OUString &rSvcImplName ) :
53 836 : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
54 : {
55 836 : aSvcImplNames.realloc(1);
56 836 : aSvcImplNames[0] = rSvcImplName;
57 836 : }
58 :
59 : bool IsAlreadyWarned() const { return bAlreadyWarned; }
60 : void SetAlreadyWarned( bool bVal ) { bAlreadyWarned = bVal; }
61 : bool IsDoWarnAgain() const { return bDoWarnAgain; }
62 : void SetDoWarnAgain( bool bVal ) { bDoWarnAgain = bVal; }
63 :
64 616 : inline void Clear()
65 : {
66 616 : aSvcImplNames.realloc(0);
67 616 : nLastTriedSvcIndex = -1;
68 616 : bAlreadyWarned = false;
69 616 : bDoWarnAgain = false;
70 616 : }
71 : };
72 :
73 779 : struct LangSvcEntries_Spell : public LangSvcEntries
74 : {
75 : css::uno::Sequence< css::uno::Reference< css::linguistic2::XSpellChecker > > aSvcRefs;
76 :
77 : LangSvcEntries_Spell() : LangSvcEntries() {}
78 836 : LangSvcEntries_Spell( const css::uno::Sequence< OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
79 : };
80 :
81 : struct LangSvcEntries_Grammar : public LangSvcEntries
82 : {
83 : css::uno::Sequence< css::uno::Reference< css::linguistic2::XProofreader > > aSvcRefs;
84 :
85 : LangSvcEntries_Grammar() : LangSvcEntries() {}
86 : LangSvcEntries_Grammar( const OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
87 : };
88 :
89 798 : struct LangSvcEntries_Hyph : public LangSvcEntries
90 : {
91 : css::uno::Sequence< css::uno::Reference< css::linguistic2::XHyphenator > > aSvcRefs;
92 :
93 : LangSvcEntries_Hyph() : LangSvcEntries() {}
94 836 : LangSvcEntries_Hyph( const OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
95 : };
96 :
97 756 : struct LangSvcEntries_Thes : public LangSvcEntries
98 : {
99 : css::uno::Sequence< css::uno::Reference< css::linguistic2::XThesaurus > > aSvcRefs;
100 :
101 : LangSvcEntries_Thes() : LangSvcEntries() {}
102 792 : LangSvcEntries_Thes( const css::uno::Sequence< OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
103 : };
104 :
105 :
106 : // virtual base class for the different dispatchers
107 220 : class LinguDispatcher
108 : {
109 : public:
110 : enum DspType { DSP_SPELL, DSP_HYPH, DSP_THES, DSP_GRAMMAR };
111 :
112 : virtual void SetServiceList( const css::lang::Locale &rLocale, const css::uno::Sequence< OUString > &rSvcImplNames ) = 0;
113 : virtual css::uno::Sequence< OUString > GetServiceList( const css::lang::Locale &rLocale ) const = 0;
114 : virtual DspType GetDspType() const = 0;
115 :
116 : protected:
117 207 : ~LinguDispatcher() {}
118 : };
119 :
120 :
121 : #endif
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|