1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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 //________________________________
37 #include <jobs/jobresult.hxx>
38 #include <jobs/jobconst.hxx>
39 #include <threadhelp/readguard.hxx>
40 #include <threadhelp/writeguard.hxx>
44 //________________________________
47 //________________________________
48 // includes of other projects
50 #include <rtl/ustrbuf.hxx>
51 #include <vcl/svapp.hxx>
52 #include <comphelper/sequenceashashmap.hxx>
54 //________________________________
59 //________________________________
62 //________________________________
63 // non exported definitions
65 //________________________________
68 //________________________________
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 ...
83 //________________________________
86 @descr It initialize this new instance with a pure job execution result
87 and analyze it. Doing so, we actualize our other members.
90 It's a list of named values, packed inside this any.
91 Following protocol is used:
95 "SaveArguments" [sequence< css.beans.NamedValue >]
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
104 "SendDispatchResult" [css.frame.DispatchResultEvent]
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
113 "Deactivate" [boolean]
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.
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 ...
139 // analyze the result and actualize our other members
140 ::comphelper::SequenceAsHashMap
aProtocol(aResult
);
141 if ( aProtocol
.empty() )
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
;
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 //________________________________
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 //________________________________
188 @descr Free all internaly used ressources at the end of living.
190 JobResult::~JobResult()
192 // Nothing realy to do here.
195 //________________________________
198 @descr Must be implemented to overwrite this instance with another one.
201 reference to the other instance, which should be used for copying.
203 void JobResult::operator=( const JobResult
& rCopy
)
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
;
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!
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
232 ReadGuard
aReadLock(m_aLock
);
233 return ((m_eParts
& eParts
) == eParts
);
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
246 css::uno::Sequence
< css::beans::NamedValue
> JobResult::getArguments() const
249 ReadGuard
aReadLock(m_aLock
);
254 //________________________________
256 css::frame::DispatchResultEvent
JobResult::getDispatchResult() const
259 ReadGuard
aReadLock(m_aLock
);
260 return m_aDispatchResult
;
264 } // namespace framework