1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_EXTENSIONS_SOURCE_SCANNER_SCANNER_HXX 21 #define INCLUDED_EXTENSIONS_SOURCE_SCANNER_SCANNER_HXX 22 23 #include <osl/mutex.hxx> 24 #include <rtl/ustring.hxx> 25 #include <cppuhelper/implbase.hxx> 26 #include <com/sun/star/uno/Reference.h> 27 #include <com/sun/star/uno/Sequence.h> 28 #include <com/sun/star/awt/XBitmap.hpp> 29 #include <com/sun/star/awt/XWindow.hpp> 30 #include <com/sun/star/lang/XInitialization.hpp> 31 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32 #include <com/sun/star/lang/XEventListener.hpp> 33 #include <com/sun/star/lang/XServiceInfo.hpp> 34 #include <com/sun/star/lang/EventObject.hpp> 35 #include <com/sun/star/scanner/XScannerManager2.hpp> 36 #include <com/sun/star/scanner/ScannerException.hpp> 37 38 using namespace cppu; 39 using namespace com::sun::star::uno; 40 using namespace com::sun::star::scanner; 41 42 class ScannerManager final : 43 public cppu::WeakImplHelper< 44 XScannerManager2, css::awt::XBitmap, css::lang::XServiceInfo, css::lang::XInitialization> 45 { 46 osl::Mutex maProtector; 47 css::uno::Reference<css::awt::XWindow> mxDialogParent; 48 void* mpData; 49 50 static void AcquireData(); 51 void ReleaseData(); 52 53 public: 54 55 ScannerManager(); 56 virtual ~ScannerManager() override; 57 58 // XScannerManager 59 virtual Sequence< ScannerContext > SAL_CALL getAvailableScanners() override; 60 virtual sal_Bool SAL_CALL configureScanner( ScannerContext& scanner_context ) override; 61 virtual sal_Bool SAL_CALL configureScannerAndScan( ScannerContext& scanner_context, const Reference< css::lang::XEventListener >& rxListener ) override; 62 virtual void SAL_CALL startScan( const ScannerContext& scanner_context, const Reference< css::lang::XEventListener >& rxListener ) override; 63 virtual ScanError SAL_CALL getError( const ScannerContext& scanner_context ) override; 64 virtual Reference< css::awt::XBitmap > SAL_CALL getBitmap( const ScannerContext& scanner_context ) override; 65 66 // XBitmap 67 virtual css::awt::Size SAL_CALL getSize() override; 68 virtual Sequence< sal_Int8 > SAL_CALL getDIB() override; 69 virtual Sequence< sal_Int8 > SAL_CALL getMaskDIB() override; 70 71 OUString SAL_CALL getImplementationName() override; 72 73 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; 74 75 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; 76 77 virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; 78 79 // Misc 80 static OUString getImplementationName_Static() throw(); 81 static Sequence< OUString > getSupportedServiceNames_Static() throw(); 82 83 #ifdef _WIN32 GetData() const84 void* GetData() const { return mpData; } 85 #endif SetData(void * pData)86 void SetData( void* pData ) { ReleaseData(); mpData = pData; } 87 }; 88 89 /// @throws Exception 90 Reference< XInterface > ScannerManager_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& rxFactory ); 91 92 #endif 93 94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 95