LibreOffice Module desktop (master)  1
dp_interact.cxx
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 
21 #include <dp_interact.h>
22 
24 
25 #include <cppuhelper/exc_hlp.hxx>
26 #include <cppuhelper/implbase.hxx>
27 #include <com/sun/star/task/XInteractionAbort.hpp>
28 #include <osl/diagnose.h>
29 
30 
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::ucb;
34 
35 namespace dp_misc {
36 namespace {
37 
38 
39 class InteractionContinuationImpl : public ::cppu::OWeakObject,
40  public task::XInteractionContinuation
41 {
42  const Type m_type;
43  bool * m_pselect;
44 
45 public:
46  InteractionContinuationImpl( Type const & type, bool * pselect )
47  : m_type( type ),
48  m_pselect( pselect )
49  { OSL_ASSERT(
51 
52  // XInterface
53  virtual void SAL_CALL acquire() throw () override;
54  virtual void SAL_CALL release() throw () override;
55  virtual Any SAL_CALL queryInterface( Type const & type ) override;
56 
57  // XInteractionContinuation
58  virtual void SAL_CALL select() override;
59 };
60 
61 // XInterface
62 
63 void InteractionContinuationImpl::acquire() throw ()
64 {
65  OWeakObject::acquire();
66 }
67 
68 
69 void InteractionContinuationImpl::release() throw ()
70 {
71  OWeakObject::release();
72 }
73 
74 
75 Any InteractionContinuationImpl::queryInterface( Type const & type )
76 {
77  if (type.isAssignableFrom( m_type )) {
78  Reference<task::XInteractionContinuation> xThis(this);
79  return Any( &xThis, type );
80  }
81  else
82  return OWeakObject::queryInterface(type);
83 }
84 
85 // XInteractionContinuation
86 
87 void InteractionContinuationImpl::select()
88 {
89  *m_pselect = true;
90 }
91 
92 } // anon namespace
93 
94 
95 bool interactContinuation( Any const & request,
96  Type const & continuation,
97  Reference<XCommandEnvironment> const & xCmdEnv,
98  bool * pcont, bool * pabort )
99 {
100  OSL_ASSERT(
102  continuation ) );
103  if (xCmdEnv.is()) {
104  Reference<task::XInteractionHandler> xInteractionHandler(
105  xCmdEnv->getInteractionHandler() );
106  if (xInteractionHandler.is()) {
107  bool cont = false;
108  bool abort = false;
109  std::vector< Reference<task::XInteractionContinuation> > conts {
110  new InteractionContinuationImpl(continuation, &cont ),
111  new InteractionContinuationImpl( cppu::UnoType<task::XInteractionAbort>::get(), &abort ) };
112  xInteractionHandler->handle(
113  new ::comphelper::OInteractionRequest( request, conts ) );
114  if (cont || abort) {
115  if (pcont != nullptr)
116  *pcont = cont;
117  if (pabort != nullptr)
118  *pabort = abort;
119  return true;
120  }
121  }
122  }
123  return false;
124 }
125 
126 // XAbortChannel
127 
129 {
130  m_aborted = true;
131  if (m_xNext.is())
132  m_xNext->sendAbort();
133 }
134 
135 } // dp_misc
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
virtual void SAL_CALL sendAbort() override
bool isAssignableFrom(const Type &_rAssignable, const Type &_rFrom)
css::uno::Reference< css::task::XAbortChannel > m_xNext
Definition: dp_interact.h:110
bool * m_pselect
Definition: dp_interact.cxx:43
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)
const Type m_type
Definition: dp_interact.cxx:42