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_GRAMMARCHECKER_HXX_ 29 #define _LINGUISTIC_GRAMMARCHECKER_HXX_ 30 31 32 #include <com/sun/star/lang/XComponent.hpp> 33 #include <com/sun/star/lang/XServiceInfo.hpp> 34 #include <com/sun/star/linguistic2/XGrammarChecker.hpp> 35 #include <com/sun/star/linguistic2/SingleGrammarError.hpp> 36 #include <com/sun/star/linguistic2/XSupportedLocales.hpp> 37 38 #include <cppuhelper/implbase3.hxx> 39 #include <cppuhelper/interfacecontainer.h> 40 41 #include <map> 42 43 44 class GrammarChecker: 45 public cppu::WeakImplHelper3 46 < 47 ::com::sun::star::linguistic2::XGrammarChecker, 48 ::com::sun::star::lang::XComponent, 49 ::com::sun::star::lang::XServiceInfo 50 > 51 { 52 // com::sun::star::uno::Reference< uno::XComponentContext > m_xContext; 53 54 // disallow use of copy c-tor and assignment operator 55 GrammarChecker( const GrammarChecker & ); 56 GrammarChecker & operator = ( const GrammarChecker & ); 57 58 public: 59 explicit GrammarChecker( /* uno::Reference< uno::XComponentContext > const & rXContext */ ); 60 virtual ~GrammarChecker(); 61 62 // XSupportedLocales 63 virtual ::sal_Bool SAL_CALL hasLocale( const ::com::sun::star::lang::Locale & aLocale) throw (::com::sun::star::uno::RuntimeException); 64 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( ) throw ( ::com::sun::star::uno::RuntimeException ); 65 66 // XGrammarChecker 67 virtual ::sal_Bool SAL_CALL isSpellChecker( ) throw (::com::sun::star::uno::RuntimeException); 68 virtual void SAL_CALL startDocument( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 69 virtual void SAL_CALL startParagraph( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 70 virtual void SAL_CALL endParagraph( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 71 virtual void SAL_CALL endDocument( ::sal_Int32 nDocId ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 72 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); 73 virtual ::sal_Bool SAL_CALL hasOptionsDialog( ) throw (::com::sun::star::uno::RuntimeException); 74 virtual void SAL_CALL runOptionsDialog( ) throw (::com::sun::star::uno::RuntimeException); 75 76 // XComponent 77 virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); 78 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException ); 79 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 80 81 // XServiceInfo 82 virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException); 83 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 84 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException); 85 86 static inline ::rtl::OUString getImplementationName_Static(); 87 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 88 89 ::com::sun::star::uno::Sequence< ::com::sun::star::linguistic2::SingleGrammarError > GrammarCheckingInDummy( 90 ::sal_Int32 nDocId, const ::rtl::OUString &rFlatParaText, const ::com::sun::star::lang::Locale & rLocale, 91 ::sal_Int32 nStartOfSentencePos, ::sal_Int32 nSuggestedSentenceEndPos ); 92 93 94 inline ::osl::Mutex & GetMutex() 95 { 96 static osl::Mutex aMutex; 97 return aMutex; 98 } 99 }; 100 101 inline ::rtl::OUString GrammarChecker::getImplementationName_Static() 102 { 103 return A2OU( "com.sun.star.lingu2.GrammarChecker" ); 104 } 105 106 107 #endif 108 109