xref: /AOO41X/main/extensions/source/scanner/scanner.hxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
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 _EXT_SCANNER_HXX
25 #define _EXT_SCANNER_HXX
26 
27 #include <tools/stream.hxx>
28 #include <vos/mutex.hxx>
29 #ifndef __RTL_USTRING_HXX_
30 #include <rtl/ustring.hxx>
31 #endif
32 #include <cppuhelper/weak.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <com/sun/star/uno/Reference.h>
35 #include <com/sun/star/uno/Sequence.h>
36 #ifndef __COM_SUN_STAR_AWT_XBITMAP_HPP
37 #include <com/sun/star/awt/XBitmap.hpp>
38 #endif
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/lang/XEventListener.hpp>
41 #ifndef __COM_SUN_STAR_LANG_EVENTOBJECT_HPP
42 #include <com/sun/star/lang/EventObject.hpp>
43 #endif
44 #include <com/sun/star/scanner/XScannerManager.hpp>
45 #include <com/sun/star/scanner/ScannerException.hpp>
46 
47 using namespace rtl;
48 using namespace cppu;
49 using namespace com::sun::star::uno;
50 using namespace com::sun::star::scanner;
51 
52 // -----------
53 // - Defines -
54 // -----------
55 
56 #define REF( _def_Obj )                     Reference< _def_Obj >
57 #define SEQ( _def_Obj )                     Sequence< _def_Obj >
58 #define ANY                                 Any
59 #define AWT                                 com::sun::star::awt
60 
61 // ------------------
62 // - ScannerManager -
63 // ------------------
64 
65 class ScannerManager : public OWeakObject, XScannerManager, AWT::XBitmap
66 {
67 protected:
68 
69     vos::OMutex                             maProtector;
70     void*                                   mpData;
71 
72     void                                    AcquireData();
73     void                                    ReleaseData();
74 
75 public:
76 
77                                             ScannerManager();
78     virtual                                 ~ScannerManager();
79 
80     // XInterface
81     virtual ANY SAL_CALL                    queryInterface( const Type & rType ) throw( RuntimeException );
82     virtual void SAL_CALL                   acquire() throw();
83     virtual void SAL_CALL                   release() throw();
84 
85     // XScannerManager
86     virtual SEQ( ScannerContext ) SAL_CALL  getAvailableScanners() throw();
87     virtual sal_Bool SAL_CALL                   configureScanner( ScannerContext& scanner_context ) throw( ScannerException );
88     virtual void SAL_CALL                   startScan( const ScannerContext& scanner_context, const REF( com::sun::star::lang::XEventListener )& rxListener ) throw( ScannerException );
89     virtual ScanError SAL_CALL              getError( const ScannerContext& scanner_context ) throw( ScannerException );
90     virtual REF( AWT::XBitmap ) SAL_CALL    getBitmap( const ScannerContext& scanner_context ) throw( ScannerException );
91 
92     // XBitmap
93     virtual AWT::Size SAL_CALL              getSize() throw();
94     virtual SEQ( sal_Int8 ) SAL_CALL        getDIB() throw();
95     virtual SEQ( sal_Int8 ) SAL_CALL        getMaskDIB() throw();
96 
97     // Misc
98     static OUString                         getImplementationName_Static() throw();
99     static Sequence< OUString >             getSupportedServiceNames_Static() throw();
100 
101     void                                    Lock() { maProtector.acquire(); }
102     void                                    Unlock() { maProtector.release(); }
103 
104     void*                                   GetData() const { return mpData; }
105     void                                    SetData( void* pData ) { ReleaseData(); mpData = pData; }
106 };
107 
108 // -----------------------------------------------------------------------------
109 
110 REF( XInterface ) SAL_CALL ScannerManager_CreateInstance( const REF( com::sun::star::lang::XMultiServiceFactory )& rxFactory ) throw( Exception );
111 
112 #endif
113