Line data Source code
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 : #ifndef INCLUDED_FRAMEWORK_INC_INTERACTION_QUIETINTERACTION_HXX
21 : #define INCLUDED_FRAMEWORK_INC_INTERACTION_QUIETINTERACTION_HXX
22 :
23 : #include <macros/xinterface.hxx>
24 : #include <macros/xtypeprovider.hxx>
25 : #include <general.h>
26 :
27 : #include <com/sun/star/task/XInteractionHandler.hpp>
28 : #include <com/sun/star/task/XInteractionRequest.hpp>
29 :
30 : #include <cppuhelper/implbase1.hxx>
31 :
32 : namespace framework{
33 :
34 : /**
35 : @short handle interactions non visible
36 : @descr Sometimes it's necessary to use a non visible interaction handler.
37 : He can't do anything, which a visible one can handle.
38 : But it can be used to intercept problems e.g. during loading of documents.
39 :
40 : In current implementation we solve conflicts for following situations only:
41 : - InteractiveIOException
42 : - InteractiveAugmentedIOException
43 : All other requests will be aborted.
44 : */
45 6576 : class QuietInteraction : public ::cppu::WeakImplHelper1<
46 : css::task::XInteractionHandler >
47 : {
48 : // member
49 : private:
50 :
51 : /// in case an unknown interaction was aborted - we save it for our external user!
52 : css::uno::Any m_aRequest;
53 :
54 : // uno interface
55 : public:
56 :
57 : // XInterface, XTypeProvider
58 :
59 : /**
60 : @interface XInteractionHandler
61 : @short called from outside to handle a problem
62 : @descr The only interaction we can handle here is to
63 : decide which of two ambigous filters should be really used.
64 : We use the user selected one every time.
65 : All other request will be aborted and can break the code,
66 : which use this interaction handler.
67 :
68 : But you can use another method of this class to check for
69 : some special interactions too: IO Exceptions
70 : May a ComponentLoader needs that to throw suitable exception
71 : on his own interface.
72 :
73 : @threadsafe yes
74 : */
75 : virtual void SAL_CALL handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
76 :
77 : // c++ interface
78 : public:
79 : /**
80 : @short ctor to guarantee right initialized instances of this class
81 : @threadsafe not necessary
82 : */
83 : QuietInteraction();
84 :
85 : /**
86 : @short return the handled interaction request
87 : @descr We saved any getted interaction request internally.
88 : May the outside user of this class is interessted
89 : on that. Especially we gotted an unknown interaction
90 : and aborted it hard.
91 :
92 : @return [com.sun.star.uno.Any]
93 : the packed interaction request
94 : Can be empty if no interaction was used!
95 :
96 : @threadsafe yes
97 : */
98 : css::uno::Any getRequest() const;
99 :
100 : /**
101 : @short returns information if interaction was used
102 : @descr It can be useful to know the reason for a failed operation.
103 :
104 : @return [boolean]
105 : <TRUE/> for used interaction
106 : <FALSE/> otherwise
107 :
108 : @threadsafe yes
109 : */
110 : bool wasUsed() const;
111 : };
112 :
113 : } // namespace framework
114 :
115 : #endif // INCLUDED_FRAMEWORK_INC_INTERACTION_QUIETINTERACTION_HXX
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|