Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <recording/dispatchrecorder.hxx>
31 : : #include <com/sun/star/frame/DispatchStatement.hpp>
32 : : #include <threadhelp/writeguard.hxx>
33 : : #include <threadhelp/readguard.hxx>
34 : : #include <services.h>
35 : : #include <vcl/svapp.hxx>
36 : :
37 : : using namespace ::com::sun::star::uno;
38 : :
39 : : namespace framework{
40 : :
41 : : // used to mark a dispatch as comment (mostly it indicates an error) Changing of this wdefine will impact all using of such comments ...
42 : : #define REM_AS_COMMENT "rem "
43 : :
44 : : //*****************************************************************************************************************
45 : : // XInterface, XTypeProvider, XServiceInfo
46 : : //*****************************************************************************************************************
47 [ + + ][ + - ]: 196 : DEFINE_XINTERFACE_6(
48 : : DispatchRecorder,
49 : : OWeakObject,
50 : : DIRECT_INTERFACE(css::lang::XTypeProvider),
51 : : DIRECT_INTERFACE(css::lang::XServiceInfo),
52 : : DIRECT_INTERFACE(css::frame::XDispatchRecorder),
53 : : DIRECT_INTERFACE(css::container::XIndexReplace),
54 : : DIRECT_INTERFACE(css::container::XIndexAccess),
55 : : DIRECT_INTERFACE(css::container::XElementAccess))
56 : :
57 [ # # ][ # # ]: 0 : DEFINE_XTYPEPROVIDER_6(
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
58 : : DispatchRecorder,
59 : : css::lang::XTypeProvider,
60 : : css::lang::XServiceInfo,
61 : : css::frame::XDispatchRecorder,
62 : : css::container::XIndexReplace,
63 : : css::container::XIndexAccess,
64 : : css::container::XElementAccess)
65 : :
66 [ + - ][ + - ]: 36 : DEFINE_XSERVICEINFO_MULTISERVICE(
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
67 : : DispatchRecorder,
68 : : ::cppu::OWeakObject,
69 : : SERVICENAME_DISPATCHRECORDER,
70 : : IMPLEMENTATIONNAME_DISPATCHRECORDER)
71 : :
72 : 4 : DEFINE_INIT_SERVICE(
73 : : DispatchRecorder,
74 : : {
75 : : }
76 : : )
77 : :
78 : : #include <typelib/typedescription.h>
79 : :
80 : : //--------------------------------------------------------------------------------------------------
81 : 0 : void flatten_struct_members(
82 : : ::std::vector< Any > * vec, void const * data,
83 : : typelib_CompoundTypeDescription * pTD )
84 : : SAL_THROW(())
85 : : {
86 [ # # ]: 0 : if (pTD->pBaseTypeDescription)
87 : : {
88 : 0 : flatten_struct_members( vec, data, pTD->pBaseTypeDescription );
89 : : }
90 [ # # ]: 0 : for ( sal_Int32 nPos = 0; nPos < pTD->nMembers; ++nPos )
91 : : {
92 : : vec->push_back(
93 [ # # ]: 0 : Any( (char const *)data + pTD->pMemberOffsets[ nPos ], pTD->ppTypeRefs[ nPos ] ) );
94 : : }
95 : 0 : }
96 : : //==================================================================================================
97 : 0 : Sequence< Any > make_seq_out_of_struct(
98 : : Any const & val )
99 : : SAL_THROW( (RuntimeException) )
100 : : {
101 : 0 : Type const & type = val.getValueType();
102 : 0 : TypeClass eTypeClass = type.getTypeClass();
103 [ # # ][ # # ]: 0 : if (TypeClass_STRUCT != eTypeClass && TypeClass_EXCEPTION != eTypeClass)
104 : : {
105 : : throw RuntimeException(
106 : : type.getTypeName() +
107 : : ::rtl::OUString( "is no struct or exception!" ),
108 [ # # ]: 0 : Reference< XInterface >() );
109 : : }
110 : 0 : typelib_TypeDescription * pTD = 0;
111 [ # # ][ # # ]: 0 : TYPELIB_DANGER_GET( &pTD, type.getTypeLibType() );
[ # # ][ # # ]
[ # # ]
112 : : OSL_ASSERT( pTD );
113 [ # # ]: 0 : if (! pTD)
114 : : {
115 : : throw RuntimeException(
116 : : ::rtl::OUString( "cannot get type descr of type " ) +
117 : : type.getTypeName(),
118 [ # # ]: 0 : Reference< XInterface >() );
119 : : }
120 : :
121 [ # # ]: 0 : ::std::vector< Any > vec;
122 [ # # ]: 0 : vec.reserve( ((typelib_CompoundTypeDescription *)pTD)->nMembers ); // good guess
123 [ # # ]: 0 : flatten_struct_members( &vec, val.getValue(), (typelib_CompoundTypeDescription *)pTD );
124 [ # # ][ # # ]: 0 : TYPELIB_DANGER_RELEASE( pTD );
125 [ # # ]: 0 : return Sequence< Any >( &vec[ 0 ], vec.size() );
126 : : }
127 : :
128 : : //***********************************************************************
129 : 4 : DispatchRecorder::DispatchRecorder( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
130 : 4 : : ThreadHelpBase ( &Application::GetSolarMutex() )
131 : : , ::cppu::OWeakObject( )
132 : : , m_xSMGR ( xSMGR )
133 [ + - ][ + - ]: 4 : , m_xConverter( m_xSMGR->createInstance(::rtl::OUString("com.sun.star.script.Converter")), css::uno::UNO_QUERY )
[ + - ][ + - ]
134 : : {
135 : 4 : }
136 : :
137 : : //************************************************************************
138 [ + - ]: 4 : DispatchRecorder::~DispatchRecorder()
139 : : {
140 [ - + ]: 8 : }
141 : :
142 : : //*************************************************************************
143 : : // generate header
144 : 16 : void SAL_CALL DispatchRecorder::startRecording( const css::uno::Reference< css::frame::XFrame >& ) throw( css::uno::RuntimeException )
145 : : {
146 : : /* SAFE{ */
147 : : /* } */
148 : 16 : }
149 : :
150 : : //*************************************************************************
151 : 6 : void SAL_CALL DispatchRecorder::recordDispatch( const css::util::URL& aURL,
152 : : const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException )
153 : : {
154 : 6 : ::rtl::OUString aTarget;
155 : :
156 [ + - ]: 6 : com::sun::star::frame::DispatchStatement aStatement( aURL.Complete, aTarget, lArguments, 0, sal_False );
157 [ + - ][ + - ]: 6 : m_aStatements.push_back( aStatement );
158 : 6 : }
159 : :
160 : : //*************************************************************************
161 : 4 : void SAL_CALL DispatchRecorder::recordDispatchAsComment( const css::util::URL& aURL,
162 : : const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException )
163 : : {
164 : 4 : ::rtl::OUString aTarget;
165 : :
166 : : // last parameter must be set to true -> it's a comment
167 [ + - ]: 4 : com::sun::star::frame::DispatchStatement aStatement( aURL.Complete, aTarget, lArguments, 0, sal_True );
168 [ + - ][ + - ]: 4 : m_aStatements.push_back( aStatement );
169 : 4 : }
170 : :
171 : : //*************************************************************************
172 : 16 : void SAL_CALL DispatchRecorder::endRecording() throw( css::uno::RuntimeException )
173 : : {
174 : : /* SAFE{ */
175 [ + - ]: 16 : WriteGuard aWriteLock(m_aLock);
176 [ + - ]: 16 : m_aStatements.clear();
177 : : /* } */
178 : 16 : }
179 : :
180 : : //*************************************************************************
181 : 16 : ::rtl::OUString SAL_CALL DispatchRecorder::getRecordedMacro() throw( css::uno::RuntimeException )
182 : : {
183 : : /* SAFE{ */
184 [ + - ]: 16 : WriteGuard aWriteLock(m_aLock);
185 : :
186 [ + + ]: 16 : if ( m_aStatements.empty() )
187 : 8 : return ::rtl::OUString();
188 : :
189 : 8 : ::rtl::OUStringBuffer aScriptBuffer;
190 [ + - ]: 8 : aScriptBuffer.ensureCapacity(10000);
191 : 8 : m_nRecordingID = 1;
192 : :
193 [ + - ]: 8 : aScriptBuffer.appendAscii("rem ----------------------------------------------------------------------\n");
194 [ + - ]: 8 : aScriptBuffer.appendAscii("rem define variables\n");
195 [ + - ]: 8 : aScriptBuffer.appendAscii("dim document as object\n");
196 [ + - ]: 8 : aScriptBuffer.appendAscii("dim dispatcher as object\n");
197 [ + - ]: 8 : aScriptBuffer.appendAscii("rem ----------------------------------------------------------------------\n");
198 [ + - ]: 8 : aScriptBuffer.appendAscii("rem get access to the document\n");
199 [ + - ]: 8 : aScriptBuffer.appendAscii("document = ThisComponent.CurrentController.Frame\n");
200 [ + - ]: 8 : aScriptBuffer.appendAscii("dispatcher = createUnoService(\"com.sun.star.frame.DispatchHelper\")\n\n");
201 : :
202 : 8 : std::vector< com::sun::star::frame::DispatchStatement>::iterator p;
203 [ + - ][ + + ]: 16 : for ( p = m_aStatements.begin(); p != m_aStatements.end(); ++p )
204 [ + - ]: 8 : implts_recordMacro( p->aCommand, p->aArgs, p->bIsComment, aScriptBuffer );
205 [ + - ]: 8 : ::rtl::OUString sScript = aScriptBuffer.makeStringAndClear();
206 [ + - ]: 16 : return sScript;
207 : : /* } */
208 : : }
209 : :
210 : : //*************************************************************************
211 : 6 : void SAL_CALL DispatchRecorder::AppendToBuffer( css::uno::Any aValue, ::rtl::OUStringBuffer& aArgumentBuffer )
212 : : {
213 : : // if value == bool
214 [ - + ]: 6 : if (aValue.getValueTypeClass() == css::uno::TypeClass_STRUCT )
215 : : {
216 : : // structs are recorded as arrays, convert to "Sequence of any"
217 [ # # ]: 0 : Sequence< Any > aSeq = make_seq_out_of_struct( aValue );
218 [ # # ]: 0 : aArgumentBuffer.appendAscii("Array(");
219 [ # # ]: 0 : for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
220 : : {
221 [ # # ][ # # ]: 0 : AppendToBuffer( aSeq[nAny], aArgumentBuffer );
222 [ # # ]: 0 : if ( nAny+1 < aSeq.getLength() )
223 : : // not last argument
224 [ # # ]: 0 : aArgumentBuffer.appendAscii(",");
225 : : }
226 : :
227 [ # # ][ # # ]: 0 : aArgumentBuffer.appendAscii(")");
[ # # ]
228 : : }
229 [ - + ]: 6 : else if (aValue.getValueTypeClass() == css::uno::TypeClass_SEQUENCE )
230 : : {
231 : : // convert to "Sequence of any"
232 [ # # ]: 0 : css::uno::Sequence < css::uno::Any > aSeq;
233 : 0 : css::uno::Any aNew;
234 [ # # ][ # # ]: 0 : try { aNew = m_xConverter->convertTo( aValue, ::getCppuType((const css::uno::Sequence < css::uno::Any >*)0) ); }
[ # # ]
235 [ # # ]: 0 : catch (const css::uno::Exception&) {}
236 : :
237 [ # # ]: 0 : aNew >>= aSeq;
238 [ # # ]: 0 : aArgumentBuffer.appendAscii("Array(");
239 [ # # ]: 0 : for ( sal_Int32 nAny=0; nAny<aSeq.getLength(); nAny++ )
240 : : {
241 [ # # ][ # # ]: 0 : AppendToBuffer( aSeq[nAny], aArgumentBuffer );
242 [ # # ]: 0 : if ( nAny+1 < aSeq.getLength() )
243 : : // not last argument
244 [ # # ]: 0 : aArgumentBuffer.appendAscii(",");
245 : : }
246 : :
247 [ # # ][ # # ]: 0 : aArgumentBuffer.appendAscii(")");
248 : : }
249 [ + - ]: 6 : else if (aValue.getValueTypeClass() == css::uno::TypeClass_STRING )
250 : : {
251 : : // strings need \"
252 : 6 : ::rtl::OUString sVal;
253 : 6 : aValue >>= sVal;
254 : :
255 : : // encode non printable characters or '"' by using the CHR$ function
256 [ + - ]: 6 : if ( !sVal.isEmpty() )
257 : : {
258 : 6 : const sal_Unicode* pChars = sVal.getStr();
259 : 6 : sal_Bool bInString = sal_False;
260 [ + + ]: 210 : for ( sal_Int32 nChar=0; nChar<sVal.getLength(); nChar ++ )
261 : : {
262 [ + - ][ - + ]: 204 : if ( pChars[nChar] < 32 || pChars[nChar] == '"' )
263 : : {
264 : : // problematic character detected
265 [ # # ]: 0 : if ( bInString )
266 : : {
267 : : // close current string
268 [ # # ]: 0 : aArgumentBuffer.appendAscii("\"");
269 : 0 : bInString = sal_False;
270 : : }
271 : :
272 [ # # ]: 0 : if ( nChar>0 )
273 : : // if this is not the first character, parts of the string have already been added
274 [ # # ]: 0 : aArgumentBuffer.appendAscii("+");
275 : :
276 : : // add the character constant
277 [ # # ]: 0 : aArgumentBuffer.appendAscii("CHR$(");
278 [ # # ]: 0 : aArgumentBuffer.append( (sal_Int32) pChars[nChar] );
279 [ # # ]: 0 : aArgumentBuffer.appendAscii(")");
280 : : }
281 : : else
282 : : {
283 [ + + ]: 204 : if ( !bInString )
284 : : {
285 [ - + ]: 6 : if ( nChar>0 )
286 : : // if this is not the first character, parts of the string have already been added
287 [ # # ]: 0 : aArgumentBuffer.appendAscii("+");
288 : :
289 : : // start a new string
290 [ + - ]: 6 : aArgumentBuffer.appendAscii("\"");
291 : 6 : bInString = sal_True;
292 : : }
293 : :
294 [ + - ]: 204 : aArgumentBuffer.append( pChars[nChar] );
295 : : }
296 : : }
297 : :
298 : : // close string
299 [ + - ]: 6 : if ( bInString )
300 [ + - ]: 6 : aArgumentBuffer.appendAscii("\"");
301 : : }
302 : : else
303 [ # # ]: 6 : aArgumentBuffer.appendAscii("\"\"");
[ # # # ]
304 : : }
305 [ # # ]: 0 : else if (aValue.getValueType() == getCppuCharType())
306 : : {
307 : : // character variables are recorded as strings, back conversion must be handled in client code
308 : 0 : sal_Unicode nVal = *((sal_Unicode*)aValue.getValue());
309 : 0 : aArgumentBuffer.appendAscii("\"");
310 [ # # ]: 0 : if ( (sal_Unicode(nVal) == '\"') )
311 : : // encode \" to \"\"
312 : 0 : aArgumentBuffer.append((sal_Unicode)nVal);
313 : 0 : aArgumentBuffer.append((sal_Unicode)nVal);
314 : 0 : aArgumentBuffer.appendAscii("\"");
315 : : }
316 : : else
317 : : {
318 : 0 : css::uno::Any aNew;
319 : : try
320 : : {
321 [ # # ][ # # ]: 0 : aNew = m_xConverter->convertToSimpleType( aValue, css::uno::TypeClass_STRING );
322 : : }
323 [ # # ]: 0 : catch (const css::script::CannotConvertException&) {}
324 [ # # ]: 0 : catch (const css::uno::Exception&) {}
325 : 0 : ::rtl::OUString sVal;
326 : 0 : aNew >>= sVal;
327 : :
328 [ # # ]: 0 : if (aValue.getValueTypeClass() == css::uno::TypeClass_ENUM )
329 : : {
330 : 0 : ::rtl::OUString aName = aValue.getValueType().getTypeName();
331 [ # # ]: 0 : aArgumentBuffer.append( aName );
332 [ # # ]: 0 : aArgumentBuffer.appendAscii(".");
333 : : }
334 : :
335 [ # # ]: 0 : aArgumentBuffer.append(sVal);
336 : : }
337 : 6 : }
338 : :
339 : 8 : void SAL_CALL DispatchRecorder::implts_recordMacro( const ::rtl::OUString& aURL,
340 : : const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
341 : : sal_Bool bAsComment, ::rtl::OUStringBuffer& aScriptBuffer )
342 : : {
343 : 8 : ::rtl::OUStringBuffer aArgumentBuffer(1000);
344 : 8 : ::rtl::OUString sArrayName;
345 : : // this value is used to name the arrays of aArgumentBuffer
346 : 8 : sArrayName = ::rtl::OUString("args");
347 : 8 : sArrayName += ::rtl::OUString::valueOf((sal_Int32)m_nRecordingID);
348 : :
349 [ + - ]: 8 : aScriptBuffer.appendAscii("rem ----------------------------------------------------------------------\n");
350 : :
351 : 8 : sal_Int32 nLength = lArguments.getLength();
352 : 8 : sal_Int32 nValidArgs = 0;
353 [ + + ]: 14 : for( sal_Int32 i=0; i<nLength; ++i )
354 : : {
355 [ - + ]: 6 : if(!lArguments[i].Value.hasValue())
356 : 0 : continue;
357 : :
358 : 6 : ::rtl::OUStringBuffer sValBuffer(100);
359 : : try
360 : : {
361 [ + - ]: 6 : AppendToBuffer(lArguments[i].Value, sValBuffer);
362 : : }
363 [ # # # # ]: 0 : catch(const css::uno::Exception&)
364 : : {
365 [ # # ]: 0 : sValBuffer.setLength(0);
366 : : }
367 [ - + ]: 6 : if (!sValBuffer.getLength())
368 : 0 : continue;
369 : :
370 : : {
371 : : // add arg().Name
372 [ + + ]: 6 : if(bAsComment)
373 [ + - ]: 2 : aArgumentBuffer.appendAscii(REM_AS_COMMENT);
374 [ + - ]: 6 : aArgumentBuffer.append (sArrayName);
375 [ + - ]: 6 : aArgumentBuffer.appendAscii("(");
376 [ + - ]: 6 : aArgumentBuffer.append (nValidArgs);
377 [ + - ]: 6 : aArgumentBuffer.appendAscii(").Name = \"");
378 [ + - ]: 6 : aArgumentBuffer.append (lArguments[i].Name);
379 [ + - ]: 6 : aArgumentBuffer.appendAscii("\"\n");
380 : :
381 : : // add arg().Value
382 [ + + ]: 6 : if(bAsComment)
383 [ + - ]: 2 : aArgumentBuffer.appendAscii(REM_AS_COMMENT);
384 [ + - ]: 6 : aArgumentBuffer.append (sArrayName);
385 [ + - ]: 6 : aArgumentBuffer.appendAscii("(");
386 [ + - ]: 6 : aArgumentBuffer.append (nValidArgs);
387 [ + - ]: 6 : aArgumentBuffer.appendAscii(").Value = ");
388 [ + - ][ + - ]: 6 : aArgumentBuffer.append (sValBuffer.makeStringAndClear());
389 [ + - ]: 6 : aArgumentBuffer.appendAscii("\n");
390 : :
391 [ + - ]: 12 : ++nValidArgs;
392 : : }
393 : 6 : }
394 : :
395 : : // if aArgumentBuffer exist - pack it into the aScriptBuffer
396 [ + + ]: 8 : if(nValidArgs>0)
397 : : {
398 [ + + ]: 6 : if(bAsComment)
399 [ + - ]: 2 : aScriptBuffer.appendAscii(REM_AS_COMMENT);
400 [ + - ]: 6 : aScriptBuffer.appendAscii("dim ");
401 [ + - ]: 6 : aScriptBuffer.append (sArrayName);
402 [ + - ]: 6 : aScriptBuffer.appendAscii("(");
403 [ + - ]: 6 : aScriptBuffer.append ((sal_Int32)(nValidArgs-1)); // 0 based!
404 [ + - ]: 6 : aScriptBuffer.appendAscii(") as new com.sun.star.beans.PropertyValue\n");
405 [ + - ][ + - ]: 6 : aScriptBuffer.append (aArgumentBuffer.makeStringAndClear());
406 [ + - ]: 6 : aScriptBuffer.appendAscii("\n");
407 : : }
408 : :
409 : : // add code for dispatches
410 [ + + ]: 8 : if(bAsComment)
411 [ + - ]: 4 : aScriptBuffer.appendAscii(REM_AS_COMMENT);
412 [ + - ]: 8 : aScriptBuffer.appendAscii("dispatcher.executeDispatch(document, \"");
413 [ + - ]: 8 : aScriptBuffer.append (aURL);
414 [ + - ]: 8 : aScriptBuffer.appendAscii("\", \"\", 0, ");
415 [ + + ]: 8 : if(nValidArgs<1)
416 [ + - ]: 2 : aScriptBuffer.appendAscii("Array()");
417 : : else
418 : : {
419 [ + - ]: 6 : aScriptBuffer.append( sArrayName.getStr() );
420 [ + - ]: 6 : aScriptBuffer.appendAscii("()");
421 : : }
422 [ + - ]: 8 : aScriptBuffer.appendAscii(")\n\n");
423 : :
424 : : /* SAFE { */
425 : 8 : m_nRecordingID++;
426 : : /* } */
427 : 8 : }
428 : :
429 : 2 : com::sun::star::uno::Type SAL_CALL DispatchRecorder::getElementType() throw (::com::sun::star::uno::RuntimeException)
430 : : {
431 : 2 : return ::getCppuType((const com::sun::star::frame::DispatchStatement *)NULL);
432 : : }
433 : :
434 : 2 : sal_Bool SAL_CALL DispatchRecorder::hasElements() throw (::com::sun::star::uno::RuntimeException)
435 : : {
436 : 2 : return (! m_aStatements.empty());
437 : : }
438 : :
439 : 4 : sal_Int32 SAL_CALL DispatchRecorder::getCount() throw (::com::sun::star::uno::RuntimeException)
440 : : {
441 : 4 : return m_aStatements.size();
442 : : }
443 : :
444 : 12 : com::sun::star::uno::Any SAL_CALL DispatchRecorder::getByIndex(sal_Int32 idx) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
445 : : {
446 [ + + ]: 12 : if (idx >= (sal_Int32)m_aStatements.size()) {
447 : : throw com::sun::star::lang::IndexOutOfBoundsException(
448 : : ::rtl::OUString( "Dispatch recorder out of bounds" ),
449 [ + - ]: 2 : Reference< XInterface >() );
450 : :
451 : : }
452 : :
453 : 10 : Any element(&m_aStatements[idx],
454 : 20 : ::getCppuType((const com::sun::star::frame::DispatchStatement *)NULL));
455 : :
456 : 10 : return element;
457 : : }
458 : :
459 : 8 : void SAL_CALL DispatchRecorder::replaceByIndex(sal_Int32 idx, const com::sun::star::uno::Any& element) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
460 : : {
461 [ + + ]: 16 : if (element.getValueType() !=
462 [ + - ]: 16 : ::getCppuType((const com::sun::star::frame::DispatchStatement *)NULL)) {
463 : : throw com::sun::star::lang::IllegalArgumentException(
464 : : ::rtl::OUString( "Illegal argument in dispatch recorder" ),
465 [ + - ]: 2 : Reference< XInterface >(), 2 );
466 : : }
467 : :
468 [ + + ]: 6 : if (idx >= (sal_Int32)m_aStatements.size()) {
469 : : throw com::sun::star::lang::IndexOutOfBoundsException(
470 : : ::rtl::OUString( "Dispatch recorder out of bounds" ),
471 [ + - ]: 2 : Reference< XInterface >() );
472 : :
473 : : }
474 : :
475 : : com::sun::star::frame::DispatchStatement *pStatement;
476 : :
477 : 4 : pStatement = (com::sun::star::frame::DispatchStatement *)element.getValue();
478 : :
479 : : com::sun::star::frame::DispatchStatement aStatement(
480 : : pStatement->aCommand,
481 : : pStatement->aTarget,
482 : : pStatement->aArgs,
483 : : pStatement->nFlags,
484 [ + - ]: 4 : pStatement->bIsComment);
485 : :
486 [ + - ][ + - ]: 8 : m_aStatements[idx] = aStatement;
487 : 4 : }
488 : :
489 : : } // namespace framework
490 : :
491 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|