Get the style color and number just once
[LibreOffice.git] / desktop / source / deployment / inc / dp_interact.h
blob6a041d99f179aede93262eaff5ba7261bf7e235a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <config_options.h>
23 #include <rtl/ref.hxx>
24 #include <cppuhelper/implbase.hxx>
25 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
26 #include <com/sun/star/task/XAbortChannel.hpp>
27 #include <utility>
28 #include "dp_misc_api.hxx"
30 namespace dp_misc
33 inline void progressUpdate(
34 OUString const & status,
35 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
37 if (xCmdEnv.is()) {
38 css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler(
39 xCmdEnv->getProgressHandler() );
40 if (xProgressHandler.is()) {
41 xProgressHandler->update( css::uno::Any(status) );
47 class ProgressLevel
49 css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler;
51 public:
52 inline ~ProgressLevel();
53 inline ProgressLevel(
54 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
55 OUString const & status );
57 inline void update( OUString const & status ) const;
58 inline void update( css::uno::Any const & status ) const;
62 inline ProgressLevel::ProgressLevel(
63 css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv,
64 OUString const & status )
66 if (xCmdEnv.is())
67 m_xProgressHandler = xCmdEnv->getProgressHandler();
68 if (m_xProgressHandler.is())
69 m_xProgressHandler->push( css::uno::Any(status) );
73 inline ProgressLevel::~ProgressLevel()
75 if (m_xProgressHandler.is())
76 m_xProgressHandler->pop();
80 inline void ProgressLevel::update( OUString const & status ) const
82 if (m_xProgressHandler.is())
83 m_xProgressHandler->update( css::uno::Any(status) );
87 inline void ProgressLevel::update( css::uno::Any const & status ) const
89 if (m_xProgressHandler.is())
90 m_xProgressHandler->update( status );
95 /** @return true if ia handler is present and any selection has been chosen
97 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation(
98 css::uno::Any const & request,
99 css::uno::Type const & continuation,
100 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
101 bool * pcont, bool * pabort );
106 class UNLESS_MERGELIBS(DESKTOP_DEPLOYMENTMISC_DLLPUBLIC) AbortChannel :
107 public ::cppu::WeakImplHelper<css::task::XAbortChannel>
109 bool m_aborted;
110 css::uno::Reference<css::task::XAbortChannel> m_xNext;
112 public:
113 AbortChannel() : m_aborted( false ) {}
114 static AbortChannel * get(
115 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel )
116 { return static_cast<AbortChannel *>(xAbortChannel.get()); }
118 bool isAborted() const { return m_aborted; }
120 // XAbortChannel
121 virtual void SAL_CALL sendAbort() override;
123 class SAL_DLLPRIVATE Chain
125 const ::rtl::Reference<AbortChannel> m_abortChannel;
126 public:
127 Chain(
128 ::rtl::Reference<AbortChannel> abortChannel,
129 css::uno::Reference<css::task::XAbortChannel> const & xNext )
130 : m_abortChannel(std::move( abortChannel ))
131 { if (m_abortChannel.is()) m_abortChannel->m_xNext = xNext; }
132 ~Chain()
133 { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); }
135 friend class Chain;
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */