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