1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <jobs/jobresult.hxx>
21 #include <jobs/jobconst.hxx>
23 #include <vcl/svapp.hxx>
24 #include <comphelper/sequenceashashmap.hxx>
25 #include <comphelper/sequence.hxx>
31 @descr It initialize this new instance with a pure job execution result
32 and analyze it. Doing so, we update our other members.
35 It's a list of named values, packed inside this any.
36 Following protocol is used:
40 "SaveArguments" [sequence< css.beans.NamedValue >]
42 The returned list of (for this generic implementation unknown!)
43 properties, will be written directly to the configuration and replace
44 any old values there. There will no check for changes and we don't
45 support any merge feature here. They are written only. The job has
49 "SendDispatchResult" [css.frame.DispatchResultEvent]
51 The given event is send to all current registered listener.
52 But it's not guaranteed. In case no listener are available or
53 this job isn't part of the dispatch environment (because it was used
54 by the css..task.XJobExecutor->trigger() implementation) this option
58 "Deactivate" [boolean]
60 The job wish to be disabled. But note: There is no way, to enable it later
61 again by using this implementation. It can be done by using the configuration
62 only. (Means to register this job again.)
63 If a job knows, that there exist some status or result listener, it must use
64 the options "SendDispatchStatus" and "SendDispatchResult" (see before) too, to
65 inform it about the deactivation of this service.
72 JobResult::JobResult(/*IN*/ const css::uno::Any
& aResult
)
74 // reset the flag mask!
75 // It will reset the accessible state of this object.
76 // That can be useful if something will fail here ...
79 // analyze the result and update our other members
80 ::comphelper::SequenceAsHashMap
aProtocol(aResult
);
81 if (aProtocol
.empty())
84 ::comphelper::SequenceAsHashMap::const_iterator pIt
85 = aProtocol
.find(JobConst::ANSWER_DEACTIVATE_JOB
);
86 if (pIt
!= aProtocol
.end())
89 an executed job can force his deactivation
90 But we provide this information here only.
91 Doing so is part of any user of us.
93 bool bDeactivate(false);
94 pIt
->second
>>= bDeactivate
;
96 m_eParts
|= E_DEACTIVATE
;
99 pIt
= aProtocol
.find(JobConst::ANSWER_SAVE_ARGUMENTS
);
100 if (pIt
!= aProtocol
.end())
102 css::uno::Sequence
<css::beans::NamedValue
> aTmp
;
103 pIt
->second
>>= aTmp
;
104 comphelper::sequenceToContainer(m_lArguments
, aTmp
);
105 if (m_lArguments
.empty())
106 m_eParts
|= E_ARGUMENTS
;
109 pIt
= aProtocol
.find(JobConst::ANSWER_SEND_DISPATCHRESULT
);
110 if (pIt
!= aProtocol
.end())
112 if (pIt
->second
>>= m_aDispatchResult
)
113 m_eParts
|= E_DISPATCHRESULT
;
120 JobResult::JobResult(const JobResult
& rCopy
)
122 m_eParts
= rCopy
.m_eParts
;
123 m_lArguments
= rCopy
.m_lArguments
;
124 m_aDispatchResult
= rCopy
.m_aDispatchResult
;
129 @descr Free all internally used resources at the end of living.
131 JobResult::~JobResult()
133 // Nothing really to do here.
138 @descr Must be implemented to overwrite this instance with another one.
141 reference to the other instance, which should be used for copying.
143 JobResult
& JobResult::operator=(const JobResult
& rCopy
)
146 m_eParts
= rCopy
.m_eParts
;
147 m_lArguments
= rCopy
.m_lArguments
;
148 m_aDispatchResult
= rCopy
.m_aDispatchResult
;
153 @short checks for existing parts of the analyzed result
154 @descr The internal flag mask was set after analyzing of the pure result.
155 An user of us can check here, if the required part was really part
156 of this result. Otherwise it would use invalid information ...
157 by using our other members!
160 a flag mask too, which will be compared with our internally set one.
162 @return We return true only, if any set flag of the given mask match.
164 bool JobResult::existPart(sal_uInt32 eParts
) const
167 return ((m_eParts
& eParts
) == eParts
);
171 @short provides access to our internal members
172 @descr The return value will be valid only in case a call of
173 existPart(E_...) before returned true!
175 @return It returns the state of the internal member
178 std::vector
<css::beans::NamedValue
> JobResult::getArguments() const
184 css::frame::DispatchResultEvent
JobResult::getDispatchResult() const
187 return m_aDispatchResult
;
190 } // namespace framework
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */