1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <tools/link.hxx>
23 #include <com/sun/star/awt/XImageConsumer.hpp>
24 #include <com/sun/star/awt/XImageProducer.hpp>
25 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <cppuhelper/weak.hxx>
28 #include <vcl/graph.hxx>
35 namespace com::sun::star::io
{ class XInputStream
; }
38 class ImageProducer
: public css::awt::XImageProducer
,
39 public css::lang::XInitialization
,
40 public css::lang::XServiceInfo
,
41 public ::cppu::OWeakObject
45 typedef std::vector
< css::uno::Reference
< css::awt::XImageConsumer
> > ConsumerList_t
;
48 ConsumerList_t maConsList
;
49 std::optional
<Graphic
>
51 std::unique_ptr
<SvStream
>
53 sal_uInt32 mnTransIndex
;
55 Link
<Graphic
*,void> maDoneHdl
;
57 bool ImplImportGraphic( Graphic
& rGraphic
);
58 void ImplUpdateData( const Graphic
& rGraphic
);
59 void ImplInitConsumer( const Graphic
& rGraphic
);
60 void ImplUpdateConsumer( const Graphic
& rGraphic
);
65 virtual ~ImageProducer() override
;
67 void SetImage( const OUString
& rPath
);
68 void SetImage( SvStream
& rStm
);
70 void NewDataAvailable();
72 void SetDoneHdl( const Link
<Graphic
*,void>& i_rHdl
) { maDoneHdl
= i_rHdl
; }
74 // css::uno::XInterface
75 css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
76 void SAL_CALL
acquire() noexcept override
{ OWeakObject::acquire(); }
77 void SAL_CALL
release() noexcept override
{ OWeakObject::release(); }
80 void setImage( css::uno::Reference
< css::io::XInputStream
> const & rStmRef
);
82 // css::awt::XImageProducer
83 void SAL_CALL
addConsumer( const css::uno::Reference
< css::awt::XImageConsumer
>& rxConsumer
) override
;
84 void SAL_CALL
removeConsumer( const css::uno::Reference
< css::awt::XImageConsumer
>& rxConsumer
) override
;
85 void SAL_CALL
startProduction( ) override
;
87 // css::lang::XInitialization
88 void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
90 OUString SAL_CALL
getImplementationName() override
;
91 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
) override
;
92 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */