LibreOffice Module forms (master) 1
imgprod.hxx
Go to the documentation of this file.
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#pragma once
21
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>
29#include <memory>
30#include <optional>
31#include <vector>
32
33
34class SvStream;
35namespace com::sun::star::io { class XInputStream; }
36
37
38class ImageProducer : public css::awt::XImageProducer,
39 public css::lang::XInitialization,
40 public css::lang::XServiceInfo,
42{
43private:
44
45 typedef std::vector< css::uno::Reference< css::awt::XImageConsumer > > ConsumerList_t;
46
47 OUString maURL;
49 std::optional<Graphic>
51 std::unique_ptr<SvStream>
53 sal_uInt32 mnTransIndex;
56
57 bool ImplImportGraphic( Graphic& rGraphic );
58 void ImplUpdateData( const Graphic& rGraphic );
59 void ImplInitConsumer( const Graphic& rGraphic );
60 void ImplUpdateConsumer( const Graphic& rGraphic );
61
62public:
63
65 virtual ~ImageProducer() override;
66
67 void SetImage( const OUString& rPath );
68 void SetImage( SvStream& rStm );
69
70 void NewDataAvailable();
71
72 void SetDoneHdl( const Link<Graphic*,void>& i_rHdl ) { maDoneHdl = i_rHdl; }
73
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(); }
78
79 // MT: ???
80 void setImage( css::uno::Reference< css::io::XInputStream > const & rStmRef );
81
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;
86
87 // css::lang::XInitialization
88 void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
89
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;
93
94};
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SAL_CALL removeConsumer(const css::uno::Reference< css::awt::XImageConsumer > &rxConsumer) override
Definition: imgprod.cxx:194
bool ImplImportGraphic(Graphic &rGraphic)
Definition: imgprod.cxx:296
void SAL_CALL startProduction() override
Definition: imgprod.cxx:252
OUString SAL_CALL getImplementationName() override
Definition: imgprod.cxx:486
ConsumerList_t maConsList
Definition: imgprod.hxx:48
std::unique_ptr< SvStream > mpStm
Definition: imgprod.hxx:52
void SetDoneHdl(const Link< Graphic *, void > &i_rHdl)
Definition: imgprod.hxx:72
void SAL_CALL addConsumer(const css::uno::Reference< css::awt::XImageConsumer > &rxConsumer) override
Definition: imgprod.cxx:186
std::vector< css::uno::Reference< css::awt::XImageConsumer > > ConsumerList_t
Definition: imgprod.hxx:45
bool mbConsInit
Definition: imgprod.hxx:54
sal_uInt32 mnTransIndex
Definition: imgprod.hxx:53
OUString maURL
Definition: imgprod.hxx:47
void SAL_CALL release() noexcept override
Definition: imgprod.hxx:77
void ImplUpdateData(const Graphic &rGraphic)
Definition: imgprod.cxx:315
virtual ~ImageProducer() override
Definition: imgprod.cxx:170
void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: imgprod.cxx:473
void ImplInitConsumer(const Graphic &rGraphic)
Definition: imgprod.cxx:334
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: imgprod.cxx:494
void SetImage(const OUString &rPath)
Definition: imgprod.cxx:203
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: imgprod.cxx:176
void ImplUpdateConsumer(const Graphic &rGraphic)
Definition: imgprod.cxx:360
void NewDataAvailable()
Definition: imgprod.cxx:245
std::optional< Graphic > moGraphic
Definition: imgprod.hxx:50
Link< Graphic *, void > maDoneHdl
Definition: imgprod.hxx:55
void SAL_CALL acquire() noexcept override
Definition: imgprod.hxx:76
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: imgprod.cxx:490
void setImage(css::uno::Reference< css::io::XInputStream > const &rStmRef)
Definition: imgprod.cxx:233
unsigned char sal_Bool