LibreOffice Module desktop (master)  1
dp_interact.h
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 <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 "dp_misc_api.hxx"
28 
29 namespace dp_misc
30 {
31 
32 inline void progressUpdate(
33  OUString const & status,
34  css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
35 {
36  if (xCmdEnv.is()) {
37  css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler(
38  xCmdEnv->getProgressHandler() );
39  if (xProgressHandler.is()) {
40  xProgressHandler->update( css::uno::makeAny(status) );
41  }
42  }
43 }
44 
45 
47 {
48  css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler;
49 
50 public:
51  inline ~ProgressLevel();
52  inline ProgressLevel(
53  css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
54  OUString const & status );
55 
56  inline void update( OUString const & status ) const;
57  inline void update( css::uno::Any const & status ) const;
58 };
59 
60 
62  css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv,
63  OUString const & status )
64 {
65  if (xCmdEnv.is())
66  m_xProgressHandler = xCmdEnv->getProgressHandler();
67  if (m_xProgressHandler.is())
68  m_xProgressHandler->push( css::uno::makeAny(status) );
69 }
70 
71 
73 {
74  if (m_xProgressHandler.is())
75  m_xProgressHandler->pop();
76 }
77 
78 
79 inline void ProgressLevel::update( OUString const & status ) const
80 {
81  if (m_xProgressHandler.is())
82  m_xProgressHandler->update( css::uno::makeAny(status) );
83 }
84 
85 
86 inline void ProgressLevel::update( css::uno::Any const & status ) const
87 {
88  if (m_xProgressHandler.is())
89  m_xProgressHandler->update( status );
90 }
91 
92 
93 
97  css::uno::Any const & request,
98  css::uno::Type const & continuation,
99  css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
100  bool * pcont, bool * pabort );
101 
102 
103 
104 
105 class UNLESS_MERGELIBS(DESKTOP_DEPLOYMENTMISC_DLLPUBLIC) AbortChannel :
106  public ::cppu::WeakImplHelper<css::task::XAbortChannel>
107 {
108  bool m_aborted;
109  css::uno::Reference<css::task::XAbortChannel> m_xNext;
110 
111 public:
112  AbortChannel() : m_aborted( false ) {}
113  static AbortChannel * get(
114  css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel )
115  { return static_cast<AbortChannel *>(xAbortChannel.get()); }
116 
117  bool isAborted() const { return m_aborted; }
118 
119  // XAbortChannel
120  virtual void SAL_CALL sendAbort() override;
121 
122  class SAL_DLLPRIVATE Chain
123  {
124  const ::rtl::Reference<AbortChannel> m_abortChannel;
125  public:
126  Chain(
127  ::rtl::Reference<AbortChannel> const & abortChannel,
128  css::uno::Reference<css::task::XAbortChannel> const & xNext )
129  : m_abortChannel( abortChannel )
130  { if (m_abortChannel.is()) m_abortChannel->m_xNext = xNext; }
131  ~Chain()
132  { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); }
133  };
134  friend class Chain;
135 };
136 
137 }
138 
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void progressUpdate(OUString const &status, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
Definition: dp_interact.h:32
void update(OUString const &status) const
Definition: dp_interact.h:79
#define DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
Definition: dp_misc_api.hxx:28
ProgressLevel(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, OUString const &status)
Definition: dp_interact.h:61
css::uno::Reference< css::ucb::XProgressHandler > m_xProgressHandler
Definition: dp_interact.h:48
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation(css::uno::Any const &request, css::uno::Type const &continuation, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool *pcont, bool *pabort)