fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / jobs / jobresult.cxx
blob36fc63e8108b1b0b7e464f8d82f87145575d80a9
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 #include <jobs/jobresult.hxx>
21 #include <jobs/jobconst.hxx>
22 #include <general.h>
23 #include <services.h>
25 #include <rtl/ustrbuf.hxx>
26 #include <vcl/svapp.hxx>
27 #include <comphelper/sequenceashashmap.hxx>
29 namespace framework{
31 /**
32 @short standard dtor
33 @descr It does nothing else ...
34 but it marks this new instance as non valid!
36 JobResult::JobResult()
37 : m_bDeactivate(false)
39 // reset the flag mask!
40 // It will reset the accessible state of this object.
41 // That can be useful if something will fail here ...
42 m_eParts = E_NOPART;
45 /**
46 @short special ctor
47 @descr It initialize this new instance with a pure job execution result
48 and analyze it. Doing so, we update our other members.
50 <p>
51 It's a list of named values, packed inside this any.
52 Following protocol is used:
53 <p>
54 <ul>
55 <li>
56 "SaveArguments" [sequence< css.beans.NamedValue >]
57 <br>
58 The returned list of (for this generic implementation unknown!)
59 properties, will be written directly to the configuration and replace
60 any old values there. There will no check for changes and we don't
61 support any mege feature here. They are written only. The job has
62 to modify this list.
63 </li>
64 <li>
65 "SendDispatchResult" [css.frame.DispatchResultEvent]
66 <br>
67 The given event is send to all current registered listener.
68 But it's not guaranteed. In case no listener are available or
69 this job isn't part of the dispatch environment (because it was used
70 by the css..task.XJobExecutor->trigger() implementation) this option
71 will be ignored.
72 </li>
73 <li>
74 "Deactivate" [boolean]
75 <br>
76 The job wish to be disabled. But note: There is no way, to enable it later
77 again by using this implementation. It can be done by using the configuration
78 only. (Means to register this job again.)
79 If a job knows, that there exist some status or result listener, it must use
80 the options "SendDispatchStatus" and "SendDispatchResult" (see before) too, to
81 inform it about the deactivation of this service.
82 </li>
83 </ul>
85 @param aResult
86 the job result
88 JobResult::JobResult( /*IN*/ const css::uno::Any& aResult )
89 : m_bDeactivate(false)
91 // safe the pure result
92 // May someone need it later ...
93 m_aPureResult = aResult;
95 // reset the flag mask!
96 // It will reset the accessible state of this object.
97 // That can be useful if something will fail here ...
98 m_eParts = E_NOPART;
100 // analyze the result and update our other members
101 ::comphelper::SequenceAsHashMap aProtocol(aResult);
102 if ( aProtocol.empty() )
103 return;
105 ::comphelper::SequenceAsHashMap::const_iterator pIt = aProtocol.find(JobConst::ANSWER_DEACTIVATE_JOB());
106 if (pIt != aProtocol.end())
108 pIt->second >>= m_bDeactivate;
109 if (m_bDeactivate)
110 m_eParts |= E_DEACTIVATE;
113 pIt = aProtocol.find(JobConst::ANSWER_SAVE_ARGUMENTS());
114 if (pIt != aProtocol.end())
116 pIt->second >>= m_lArguments;
117 if (m_lArguments.getLength() > 0)
118 m_eParts |= E_ARGUMENTS;
121 pIt = aProtocol.find(JobConst::ANSWER_SEND_DISPATCHRESULT());
122 if (pIt != aProtocol.end())
124 if (pIt->second >>= m_aDispatchResult)
125 m_eParts |= E_DISPATCHRESULT;
130 @short copy dtor
132 JobResult::JobResult( const JobResult& rCopy )
134 m_aPureResult = rCopy.m_aPureResult;
135 m_eParts = rCopy.m_eParts;
136 m_lArguments = rCopy.m_lArguments;
137 m_bDeactivate = rCopy.m_bDeactivate;
138 m_aDispatchResult = rCopy.m_aDispatchResult;
142 @short standard dtor
143 @descr Free all internally used resources at the end of living.
145 JobResult::~JobResult()
147 // Nothing really to do here.
151 @short =operator
152 @descr Must be implemented to overwrite this instance with another one.
154 @param rCopy
155 reference to the other instance, which should be used for copying.
157 void JobResult::operator=( const JobResult& rCopy )
159 SolarMutexGuard g;
160 m_aPureResult = rCopy.m_aPureResult;
161 m_eParts = rCopy.m_eParts;
162 m_lArguments = rCopy.m_lArguments;
163 m_bDeactivate = rCopy.m_bDeactivate;
164 m_aDispatchResult = rCopy.m_aDispatchResult;
168 @short checks for existing parts of the analyzed result
169 @descr The internal flag mask was set after analyzing of the pure result.
170 An user of us can check here, if the required part was really part
171 of this result. Otherwise it would use invalid information ...
172 by using our other members!
174 @param eParts
175 a flag mask too, which will be compared with our internally set one.
177 @return We return true only, if any set flag of the given mask match.
179 bool JobResult::existPart( sal_uInt32 eParts ) const
181 SolarMutexGuard g;
182 return ((m_eParts & eParts) == eParts);
186 @short provides access to our internal members
187 @descr The return value will be valid only in case a call of
188 existPart(E_...) before returned true!
190 @return It returns the state of the internal member
191 without any checks!
193 css::uno::Sequence< css::beans::NamedValue > JobResult::getArguments() const
195 SolarMutexGuard g;
196 return m_lArguments;
199 css::frame::DispatchResultEvent JobResult::getDispatchResult() const
201 SolarMutexGuard g;
202 return m_aDispatchResult;
205 } // namespace framework
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */