merge the formfield patch from ooo-build
[ooovba.git] / framework / source / jobs / jobresult.cxx
blob98a08211805c4da158def20d730a861781345962
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: jobresult.cxx,v $
10 * $Revision: 1.8.82.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 //________________________________
35 // my own includes
37 #include <jobs/jobresult.hxx>
38 #include <jobs/jobconst.hxx>
39 #include <threadhelp/readguard.hxx>
40 #include <threadhelp/writeguard.hxx>
41 #include <general.h>
42 #include <services.h>
44 //________________________________
45 // interface includes
47 //________________________________
48 // includes of other projects
50 #include <rtl/ustrbuf.hxx>
51 #include <vcl/svapp.hxx>
52 #include <comphelper/sequenceashashmap.hxx>
54 //________________________________
55 // namespace
57 namespace framework{
59 //________________________________
60 // non exported const
62 //________________________________
63 // non exported definitions
65 //________________________________
66 // declarations
68 //________________________________
69 /**
70 @short standard dtor
71 @descr It does nothing else ...
72 but it marks this new instance as non valid!
74 JobResult::JobResult()
75 : ThreadHelpBase(&Application::GetSolarMutex())
77 // reset the flag mask!
78 // It will reset the accessible state of this object.
79 // That can be usefull if something will fail here ...
80 m_eParts = E_NOPART;
83 //________________________________
84 /**
85 @short special ctor
86 @descr It initialize this new instance with a pure job execution result
87 and analyze it. Doing so, we actualize our other members.
89 <p>
90 It's a list of named values, packed inside this any.
91 Following protocol is used:
92 <p>
93 <ul>
94 <li>
95 "SaveArguments" [sequence< css.beans.NamedValue >]
96 <br>
97 The returned list of (for this generic implementation unknown!)
98 properties, will be written directly to the configuration and replace
99 any old values there. There will no check for changes and we doesn't
100 support any mege feature here. They are written only. The job has
101 to modify this list.
102 </li>
103 <li>
104 "SendDispatchResult" [css.frame.DispatchResultEvent]
105 <br>
106 The given event is send to all current registered listener.
107 But it's not guaranteed. In case no listener are available or
108 this job isn't part of the dispatch environment (because it was used
109 by the css..task.XJobExecutor->trigger() implementation) this option
110 will be ignored.
111 </li>
112 <li>
113 "Deactivate" [boolean]
114 <br>
115 The job whish to be disabled. But note: There is no way, to enable it later
116 again by using this implementation. It can be done by using the configuration
117 only. (Means to register this job again.)
118 If a job knows, that there exist some status or result listener, it must use
119 the options "SendDispatchStatus" and "SendDispatchResult" (see before) too, to
120 inform it about the deactivation of this service.
121 </li>
122 </ul>
124 @param aResult
125 the job result
127 JobResult::JobResult( /*IN*/ const css::uno::Any& aResult )
128 : ThreadHelpBase(&Application::GetSolarMutex())
130 // safe the pure result
131 // May someone need it later ...
132 m_aPureResult = aResult;
134 // reset the flag mask!
135 // It will reset the accessible state of this object.
136 // That can be usefull if something will fail here ...
137 m_eParts = E_NOPART;
139 // analyze the result and actualize our other members
140 ::comphelper::SequenceAsHashMap aProtocol(aResult);
141 if ( aProtocol.empty() )
142 return;
144 ::comphelper::SequenceAsHashMap::const_iterator pIt = aProtocol.end();
146 pIt = aProtocol.find(JobConst::ANSWER_DEACTIVATE_JOB());
147 if (pIt != aProtocol.end())
149 pIt->second >>= m_bDeactivate;
150 if (m_bDeactivate)
151 m_eParts |= E_DEACTIVATE;
154 pIt = aProtocol.find(JobConst::ANSWER_SAVE_ARGUMENTS());
155 if (pIt != aProtocol.end())
157 pIt->second >>= m_lArguments;
158 if (m_lArguments.getLength() > 0)
159 m_eParts |= E_ARGUMENTS;
162 pIt = aProtocol.find(JobConst::ANSWER_SEND_DISPATCHRESULT());
163 if (pIt != aProtocol.end())
165 if (pIt->second >>= m_aDispatchResult)
166 m_eParts |= E_DISPATCHRESULT;
170 //________________________________
172 @short copy dtor
173 @descr -
175 JobResult::JobResult( const JobResult& rCopy )
176 : ThreadHelpBase(&Application::GetSolarMutex())
178 m_aPureResult = rCopy.m_aPureResult ;
179 m_eParts = rCopy.m_eParts ;
180 m_lArguments = rCopy.m_lArguments ;
181 m_bDeactivate = rCopy.m_bDeactivate ;
182 m_aDispatchResult = rCopy.m_aDispatchResult ;
185 //________________________________
187 @short standard dtor
188 @descr Free all internaly used ressources at the end of living.
190 JobResult::~JobResult()
192 // Nothing realy to do here.
195 //________________________________
197 @short =operator
198 @descr Must be implemented to overwrite this instance with another one.
200 @param rCopy
201 reference to the other instance, which should be used for copying.
203 void JobResult::operator=( const JobResult& rCopy )
205 /* SAFE { */
206 WriteGuard aWriteLock(m_aLock);
207 m_aPureResult = rCopy.m_aPureResult ;
208 m_eParts = rCopy.m_eParts ;
209 m_lArguments = rCopy.m_lArguments ;
210 m_bDeactivate = rCopy.m_bDeactivate ;
211 m_aDispatchResult = rCopy.m_aDispatchResult ;
212 aWriteLock.unlock();
213 /* } SAFE */
216 //________________________________
218 @short checks for existing parts of the analyzed result
219 @descr The internal flag mask was set after analyzing of the pure result.
220 An user of us can check here, if the required part was realy part
221 of this result. Otherwhise it would use invalid informations ...
222 by using our other members!
224 @param eParts
225 a flag mask too, which will be compared with our internaly set one.
227 @return We return true only, if any set flag of the given mask match.
229 sal_Bool JobResult::existPart( sal_uInt32 eParts ) const
231 /* SAFE { */
232 ReadGuard aReadLock(m_aLock);
233 return ((m_eParts & eParts) == eParts);
234 /* } SAFE */
237 //________________________________
239 @short provides access to our internal members
240 @descr The return value will be valid only in case a call of
241 existPart(E_...) before returned true!
243 @return It returns the state of the internal member
244 without any checks!
246 css::uno::Sequence< css::beans::NamedValue > JobResult::getArguments() const
248 /* SAFE { */
249 ReadGuard aReadLock(m_aLock);
250 return m_lArguments;
251 /* } SAFE */
254 //________________________________
256 css::frame::DispatchResultEvent JobResult::getDispatchResult() const
258 /* SAFE { */
259 ReadGuard aReadLock(m_aLock);
260 return m_aDispatchResult;
261 /* } SAFE */
264 } // namespace framework