1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _LINGUISTIC_GRAMMARCHECKER_HXX_
25 #define _LINGUISTIC_GRAMMARCHECKER_HXX_
26 
27 
28 #include <com/sun/star/lang/XComponent.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/linguistic2/XGrammarChecker.hpp>
31 #include <com/sun/star/linguistic2/SingleGrammarError.hpp>
32 #include <com/sun/star/linguistic2/XSupportedLocales.hpp>
33 
34 #include <cppuhelper/implbase3.hxx>
35 #include <cppuhelper/interfacecontainer.h>
36 
37 #include <map>
38 
39 
40 class GrammarChecker:
41     public cppu::WeakImplHelper3
42     <
43         ::com::sun::star::linguistic2::XGrammarChecker,
44         ::com::sun::star::lang::XComponent,
45         ::com::sun::star::lang::XServiceInfo
46     >
47 {
48 //    com::sun::star::uno::Reference< uno::XComponentContext > m_xContext;
49 
50     // disallow use of copy c-tor and assignment operator
51     GrammarChecker( const GrammarChecker & );
52     GrammarChecker & operator = ( const GrammarChecker & );
53 
54 public:
55     explicit GrammarChecker( /* uno::Reference< uno::XComponentContext > const & rXContext */ );
56     virtual ~GrammarChecker();
57 
58     // XSupportedLocales
59     virtual ::sal_Bool SAL_CALL hasLocale( const ::com::sun::star::lang::Locale & aLocale) throw (::com::sun::star::uno::RuntimeException);
60     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales(  ) throw ( ::com::sun::star::uno::RuntimeException );
61 
62 	// XGrammarChecker
63     virtual ::sal_Bool SAL_CALL isSpellChecker(  ) throw (::com::sun::star::uno::RuntimeException);
64     virtual void SAL_CALL startDocument( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
65     virtual void SAL_CALL startParagraph( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
66     virtual void SAL_CALL endParagraph( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
67     virtual void SAL_CALL endDocument( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
68     virtual ::com::sun::star::linguistic2::GrammarCheckingResult SAL_CALL doGrammarChecking( ::sal_Int32 nDocId, const ::rtl::OUString& aText, const ::com::sun::star::lang::Locale& aLocale, ::sal_Int32 nStartOfSentencePos, ::sal_Int32 nSuggestedEndOfSentencePos, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& aLanguagePortions, const ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale >& aLanguagePortionsLocales ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
69     virtual ::sal_Bool SAL_CALL hasOptionsDialog(  ) throw (::com::sun::star::uno::RuntimeException);
70     virtual void SAL_CALL runOptionsDialog(  ) throw (::com::sun::star::uno::RuntimeException);
71 
72     // XComponent
73     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
74     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException );
75     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
76 
77     // XServiceInfo
78 	virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
79 	virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
80 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
81 
82 	static inline ::rtl::OUString getImplementationName_Static();
83 	static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
84 
85 	::com::sun::star::uno::Sequence< ::com::sun::star::linguistic2::SingleGrammarError > GrammarCheckingInDummy(
86         ::sal_Int32 nDocId, const ::rtl::OUString &rFlatParaText, const ::com::sun::star::lang::Locale & rLocale,
87 	    ::sal_Int32 nStartOfSentencePos, ::sal_Int32 nSuggestedSentenceEndPos );
88 
89 
GetMutex()90     inline ::osl::Mutex & GetMutex()
91     {
92         static osl::Mutex aMutex;
93         return aMutex;
94     }
95 };
96 
getImplementationName_Static()97 inline ::rtl::OUString GrammarChecker::getImplementationName_Static()
98 {
99     return A2OU( "com.sun.star.lingu2.GrammarChecker" );
100 }
101 
102 
103 #endif
104 
105