xref: /aoo42x/main/linguistic/source/defs.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _LINGUISTIC_DEFS_HXX_
29 #define _LINGUISTIC_DEFS_HXX_
30 
31 #include <com/sun/star/linguistic2/XSpellChecker.hpp>
32 #include <com/sun/star/linguistic2/XProofreader.hpp>
33 #include <com/sun/star/linguistic2/XHyphenator.hpp>
34 #include <com/sun/star/linguistic2/XThesaurus.hpp>
35 
36 #include <boost/shared_ptr.hpp>
37 
38 class SvStream;
39 
40 
41 ///////////////////////////////////////////////////////////////////////////
42 
43 #define A2OU(x)	::rtl::OUString::createFromAscii( x )
44 
45 typedef boost::shared_ptr< SvStream > SvStreamPtr;
46 
47 namespace css = ::com::sun::star;
48 
49 ///////////////////////////////////////////////////////////////////////////
50 
51 struct LangSvcEntries
52 {
53     css::uno::Sequence< ::rtl::OUString >   aSvcImplNames;
54 
55     sal_Int16   nLastTriedSvcIndex;
56     bool        bAlreadyWarned;
57     bool        bDoWarnAgain;
58 
59     LangSvcEntries() : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) {}
60 
61     inline LangSvcEntries( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) :
62 		aSvcImplNames(rSvcImplNames),
63         nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
64     {
65     }
66 
67     inline LangSvcEntries( const ::rtl::OUString &rSvcImplName ) :
68         nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
69     {
70         aSvcImplNames.realloc(1);
71         aSvcImplNames[0] = rSvcImplName;
72     }
73 
74     bool    IsAlreadyWarned() const         { return bAlreadyWarned != 0; }
75     void    SetAlreadyWarned( bool bVal )   { bAlreadyWarned = 0 != bVal; }
76     bool    IsDoWarnAgain() const           { return bDoWarnAgain != 0; }
77     void    SetDoWarnAgain( bool bVal )     { bDoWarnAgain = 0 != bVal; }
78 
79     inline void Clear()
80     {
81         aSvcImplNames.realloc(0);
82         nLastTriedSvcIndex  = -1;
83         bAlreadyWarned      = false;
84         bDoWarnAgain        = false;
85     }
86 };
87 
88 struct LangSvcEntries_Spell : public LangSvcEntries
89 {
90     css::uno::Sequence< css::uno::Reference< css::linguistic2::XSpellChecker > >  aSvcRefs;
91 
92     LangSvcEntries_Spell() : LangSvcEntries() {}
93     LangSvcEntries_Spell( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
94 };
95 
96 struct LangSvcEntries_Grammar : public LangSvcEntries
97 {
98     css::uno::Sequence< css::uno::Reference< css::linguistic2::XProofreader > >  aSvcRefs;
99 
100     LangSvcEntries_Grammar() : LangSvcEntries() {}
101     LangSvcEntries_Grammar( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
102 };
103 
104 struct LangSvcEntries_Hyph : public LangSvcEntries
105 {
106     css::uno::Sequence< css::uno::Reference< css::linguistic2::XHyphenator > >  aSvcRefs;
107 
108     LangSvcEntries_Hyph() : LangSvcEntries() {}
109     LangSvcEntries_Hyph( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
110 };
111 
112 struct LangSvcEntries_Thes : public LangSvcEntries
113 {
114     css::uno::Sequence< css::uno::Reference< css::linguistic2::XThesaurus > >  aSvcRefs;
115 
116     LangSvcEntries_Thes() : LangSvcEntries() {}
117     LangSvcEntries_Thes( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
118 };
119 
120 ///////////////////////////////////////////////////////////////////////////
121 
122 // virtual base class for the different dispatchers
123 class LinguDispatcher
124 {
125 public:
126     enum DspType    { DSP_SPELL, DSP_HYPH, DSP_THES, DSP_GRAMMAR };
127 
128     virtual void SetServiceList( const css::lang::Locale &rLocale, const css::uno::Sequence< rtl::OUString > &rSvcImplNames ) = 0;
129     virtual css::uno::Sequence< rtl::OUString > GetServiceList( const css::lang::Locale &rLocale ) const = 0;
130     virtual DspType GetDspType() const = 0;
131 };
132 
133 ///////////////////////////////////////////////////////////////////////////
134 
135 #endif
136 
137