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 : :
29 : : #ifndef _LINGUISTIC_DEFS_HXX_
30 : : #define _LINGUISTIC_DEFS_HXX_
31 : :
32 : : #include <com/sun/star/linguistic2/XSpellChecker.hpp>
33 : : #include <com/sun/star/linguistic2/XProofreader.hpp>
34 : : #include <com/sun/star/linguistic2/XHyphenator.hpp>
35 : : #include <com/sun/star/linguistic2/XThesaurus.hpp>
36 : :
37 : : #include <boost/shared_ptr.hpp>
38 : :
39 : : class SvStream;
40 : :
41 : :
42 : :
43 : : typedef boost::shared_ptr< SvStream > SvStreamPtr;
44 : :
45 : : namespace css = ::com::sun::star;
46 : :
47 : :
48 : 5986 : struct LangSvcEntries
49 : : {
50 : : css::uno::Sequence< ::rtl::OUString > aSvcImplNames;
51 : :
52 : : sal_Int16 nLastTriedSvcIndex;
53 : : bool bAlreadyWarned;
54 : : bool bDoWarnAgain;
55 : :
56 : : LangSvcEntries() : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) {}
57 : :
58 : 4048 : inline LangSvcEntries( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) :
59 : : aSvcImplNames(rSvcImplNames),
60 : 4048 : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
61 : : {
62 : 4048 : }
63 : :
64 : 2116 : inline LangSvcEntries( const ::rtl::OUString &rSvcImplName ) :
65 : 2116 : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
66 : : {
67 [ + - ]: 2116 : aSvcImplNames.realloc(1);
68 [ + - ]: 2116 : aSvcImplNames[0] = rSvcImplName;
69 : 2116 : }
70 : :
71 : : bool IsAlreadyWarned() const { return bAlreadyWarned != 0; }
72 : : void SetAlreadyWarned( bool bVal ) { bAlreadyWarned = 0 != bVal; }
73 : : bool IsDoWarnAgain() const { return bDoWarnAgain != 0; }
74 : : void SetDoWarnAgain( bool bVal ) { bDoWarnAgain = 0 != bVal; }
75 : :
76 : 268 : inline void Clear()
77 : : {
78 : 268 : aSvcImplNames.realloc(0);
79 : 268 : nLastTriedSvcIndex = -1;
80 : 268 : bAlreadyWarned = false;
81 : 268 : bDoWarnAgain = false;
82 : 268 : }
83 : : };
84 : :
85 [ + - ]: 1892 : struct LangSvcEntries_Spell : public LangSvcEntries
86 : : {
87 : : css::uno::Sequence< css::uno::Reference< css::linguistic2::XSpellChecker > > aSvcRefs;
88 : :
89 : : LangSvcEntries_Spell() : LangSvcEntries() {}
90 [ + - ]: 1978 : LangSvcEntries_Spell( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
91 : : };
92 : :
93 : : struct LangSvcEntries_Grammar : public LangSvcEntries
94 : : {
95 : : css::uno::Sequence< css::uno::Reference< css::linguistic2::XProofreader > > aSvcRefs;
96 : :
97 : : LangSvcEntries_Grammar() : LangSvcEntries() {}
98 : : LangSvcEntries_Grammar( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
99 : : };
100 : :
101 [ + - ]: 2024 : struct LangSvcEntries_Hyph : public LangSvcEntries
102 : : {
103 : : css::uno::Sequence< css::uno::Reference< css::linguistic2::XHyphenator > > aSvcRefs;
104 : :
105 : : LangSvcEntries_Hyph() : LangSvcEntries() {}
106 [ + - ]: 2116 : LangSvcEntries_Hyph( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
107 : : };
108 : :
109 [ + - ]: 2070 : struct LangSvcEntries_Thes : public LangSvcEntries
110 : : {
111 : : css::uno::Sequence< css::uno::Reference< css::linguistic2::XThesaurus > > aSvcRefs;
112 : :
113 : : LangSvcEntries_Thes() : LangSvcEntries() {}
114 [ + - ]: 2070 : LangSvcEntries_Thes( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
115 : : };
116 : :
117 : :
118 : : // virtual base class for the different dispatchers
119 : 188 : class LinguDispatcher
120 : : {
121 : : public:
122 : : enum DspType { DSP_SPELL, DSP_HYPH, DSP_THES, DSP_GRAMMAR };
123 : :
124 : : virtual void SetServiceList( const css::lang::Locale &rLocale, const css::uno::Sequence< rtl::OUString > &rSvcImplNames ) = 0;
125 : : virtual css::uno::Sequence< rtl::OUString > GetServiceList( const css::lang::Locale &rLocale ) const = 0;
126 : : virtual DspType GetDspType() const = 0;
127 : :
128 : : protected:
129 : 184 : ~LinguDispatcher() {}
130 : : };
131 : :
132 : :
133 : : #endif
134 : :
135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|