Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifdef _MSC_VER
21 : #pragma warning( disable : 4290 )
22 : #endif
23 :
24 : #include "sfx2/appuno.hxx"
25 :
26 : #include "SfxDocumentMetaData.hxx"
27 : #include "appbaslib.hxx"
28 : #include "doctemplates.hxx"
29 : #include "eventsupplier.hxx"
30 : #include "fltoptint.hxx"
31 : #include "frmload.hxx"
32 : #include "iframe.hxx"
33 : #include "objshimp.hxx"
34 : #include "plugin.hxx"
35 : #include "sfx2/app.hxx"
36 : #include "sfx2/brokenpackageint.hxx"
37 : #include "sfx2/dispatch.hxx"
38 : #include "sfx2/dllapi.h"
39 : #include "sfx2/docfile.hxx"
40 : #include "sfx2/fcontnr.hxx"
41 : #include "sfx2/frame.hxx"
42 : #include "sfx2/module.hxx"
43 : #include "sfx2/msg.hxx"
44 : #include "sfx2/msgpool.hxx"
45 : #include "sfx2/objsh.hxx"
46 : #include "sfx2/request.hxx"
47 : #include "sfx2/sfxbasecontroller.hxx"
48 : #include "sfx2/sfxsids.hrc"
49 : #include "sfx2/sfxuno.hxx"
50 : #include "sfx2/unoctitm.hxx"
51 : #include "sfxslots.hxx"
52 : #include "sfxtypes.hxx"
53 : #include "shutdownicon.hxx"
54 : #include "xpackcreator.hxx"
55 :
56 : #include "sal/config.h"
57 : #include <basic/basmgr.hxx>
58 : #include <basic/sberrors.hxx>
59 : #include <basic/sbmeth.hxx>
60 : #include <basic/sbuno.hxx>
61 : #include <basic/sbx.hxx>
62 : #include <basic/sbxcore.hxx>
63 : #include <basic/sbxmeth.hxx>
64 : #include <basic/sbxobj.hxx>
65 : #include <comphelper/interaction.hxx>
66 : #include <comphelper/processfactory.hxx>
67 : #include <comphelper/sequence.hxx>
68 : #include <framework/documentundoguard.hxx>
69 : #include <osl/mutex.hxx>
70 : #include <ownsubfilterservice.hxx>
71 : #include <rtl/ustrbuf.hxx>
72 : #include <svl/eitem.hxx>
73 : #include <svl/intitem.hxx>
74 : #include <svl/itempool.hxx>
75 : #include <svl/lckbitem.hxx>
76 : #include <svl/ownlist.hxx>
77 : #include <svl/rectitem.hxx>
78 : #include <svl/slstitm.hxx>
79 : #include <svl/stritem.hxx>
80 : #include <tools/config.hxx>
81 : #include <tools/debug.hxx>
82 : #include <tools/urlobj.hxx>
83 :
84 : #include <com/sun/star/awt/PosSize.hpp>
85 : #include <com/sun/star/awt/XButton.hpp>
86 : #include <com/sun/star/awt/XTopWindow.hpp>
87 : #include <com/sun/star/awt/XWindow.hpp>
88 : #include <com/sun/star/beans/XPropertySet.hpp>
89 : #include <com/sun/star/container/ContainerEvent.hpp>
90 : #include <com/sun/star/container/XContainer.hpp>
91 : #include <com/sun/star/container/XContainerListener.hpp>
92 : #include <com/sun/star/container/XIndexContainer.hpp>
93 : #include <com/sun/star/container/XIndexReplace.hpp>
94 : #include <com/sun/star/container/XNameContainer.hpp>
95 : #include <com/sun/star/container/XNameReplace.hpp>
96 : #include <com/sun/star/container/XSet.hpp>
97 : #include <com/sun/star/document/MacroExecMode.hpp>
98 : #include <com/sun/star/document/UpdateDocMode.hpp>
99 : #include <com/sun/star/frame/DispatchResultEvent.hpp>
100 : #include <com/sun/star/frame/DispatchResultState.hpp>
101 : #include <com/sun/star/frame/FrameAction.hpp>
102 : #include <com/sun/star/frame/FrameActionEvent.hpp>
103 : #include <com/sun/star/frame/XComponentLoader.hpp>
104 : #include <com/sun/star/frame/XFrame.hpp>
105 : #include <com/sun/star/frame/XFrameActionListener.hpp>
106 : #include <com/sun/star/frame/XModel.hpp>
107 : #include <com/sun/star/io/XInputStream.hpp>
108 : #include <com/sun/star/registry/RegistryValueType.hpp>
109 : #include <com/sun/star/task/XInteractionHandler.hpp>
110 : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
111 : #include <com/sun/star/ucb/XContent.hpp>
112 :
113 : #include <boost/scoped_ptr.hpp>
114 :
115 : #define PROTOCOLHANDLER_SERVICENAME "com.sun.star.frame.ProtocolHandler"
116 :
117 : using namespace ::com::sun::star;
118 : using namespace ::com::sun::star::ucb;
119 : using namespace ::com::sun::star::uno;
120 : using namespace ::com::sun::star::registry;
121 : using namespace ::com::sun::star::frame;
122 : using namespace ::com::sun::star::beans;
123 : using namespace ::com::sun::star::io;
124 :
125 : // needs to be converted to a better data structure
126 : SfxFormalArgument aFormalArgs[] = {
127 : SFX_ARGUMENT(SID_DEFAULTFILENAME,"SuggestedSaveAsName",SfxStringItem),
128 : SFX_ARGUMENT(SID_DEFAULTFILEPATH,"SuggestedSaveAsDir",SfxStringItem),
129 : SFX_ARGUMENT(SID_DOCINFO_AUTHOR,"VersionAuthor",SfxStringItem),
130 : SFX_ARGUMENT(SID_DOCINFO_COMMENTS,"VersionComment",SfxStringItem),
131 : SFX_ARGUMENT(SID_DOCINFO_MAJOR,"VersionMajor",SfxBoolItem),
132 : SFX_ARGUMENT(SID_FILE_FILTEROPTIONS,"FilterOptions",SfxStringItem),
133 : SFX_ARGUMENT(SID_FILTER_NAME,"FilterName",SfxStringItem),
134 : // SFX_ARGUMENT(SID_FILE_NAME,"FileName",SfxStringItem),
135 : SFX_ARGUMENT(SID_FILE_NAME,"URL",SfxStringItem),
136 : SFX_ARGUMENT(SID_OPTIONS,"OpenFlags",SfxStringItem),
137 : SFX_ARGUMENT(SID_OVERWRITE,"Overwrite",SfxBoolItem),
138 : SFX_ARGUMENT(SID_PASSWORD,"Password",SfxStringItem),
139 : SFX_ARGUMENT(SID_PASSWORDINTERACTION,"PasswordInteraction",SfxBoolItem),
140 : SFX_ARGUMENT(SID_REFERER,"Referer",SfxStringItem),
141 : SFX_ARGUMENT(SID_SAVETO,"SaveTo",SfxBoolItem),
142 : SFX_ARGUMENT(SID_TEMPLATE_NAME,"TemplateName",SfxStringItem),
143 : SFX_ARGUMENT(SID_TEMPLATE_REGIONNAME,"TemplateRegion",SfxStringItem),
144 : // SFX_ARGUMENT(SID_TEMPLATE_REGIONNAME,"Region",SfxStringItem),
145 : // SFX_ARGUMENT(SID_TEMPLATE_NAME,"Name",SfxStringItem),
146 : SFX_ARGUMENT(SID_UNPACK,"Unpacked",SfxBoolItem),
147 : SFX_ARGUMENT(SID_VERSION,"Version",SfxInt16Item),
148 : SFX_ARGUMENT(SID_SAVEACOPYITEM,"SaveACopy",SfxBoolItem),
149 : };
150 :
151 : static sal_uInt16 nMediaArgsCount = sizeof(aFormalArgs) / sizeof (SfxFormalArgument);
152 :
153 : static char const sTemplateRegionName[] = "TemplateRegionName";
154 : static char const sTemplateName[] = "TemplateName";
155 : static char const sAsTemplate[] = "AsTemplate";
156 : static char const sOpenNewView[] = "OpenNewView";
157 : static char const sViewId[] = "ViewId";
158 : static char const sPluginMode[] = "PluginMode";
159 : static char const sReadOnly[] = "ReadOnly";
160 : static char const sDdeReconnect[] = "DDEReconnect";
161 : static char const sStartPresentation[] = "StartPresentation";
162 : static char const sFrameName[] = "FrameName";
163 : static char const sMediaType[] = "MediaType";
164 : static char const sPostData[] = "PostData";
165 : static char const sCharacterSet[] = "CharacterSet";
166 : static char const sInputStream[] = "InputStream";
167 : static char const sStream[] = "Stream";
168 : static char const sOutputStream[] = "OutputStream";
169 : static char const sHidden[] = "Hidden";
170 : static char const sPreview[] = "Preview";
171 : static char const sViewOnly[] = "ViewOnly";
172 : static char const sDontEdit[] = "DontEdit";
173 : static char const sSilent[] = "Silent";
174 : static char const sJumpMark[] = "JumpMark";
175 : static char const sFileName[] = "FileName";
176 : static char const sSalvagedFile[] = "SalvagedFile";
177 : static char const sStatusInd[] = "StatusIndicator";
178 : static char const sModel[] = "Model";
179 : static char const sFrame[] = "Frame";
180 : static char const sViewData[] = "ViewData";
181 : static char const sFilterData[] = "FilterData";
182 : static char const sSelectionOnly[] = "SelectionOnly";
183 : static char const sFilterFlags[] = "FilterFlags";
184 : static char const sMacroExecMode[] = "MacroExecutionMode";
185 : static char const sUpdateDocMode[] = "UpdateDocMode";
186 : static char const sMinimized[] = "Minimized";
187 : static char const sInteractionHdl[] = "InteractionHandler";
188 : static char const sUCBContent[] = "UCBContent";
189 : static char const sRepairPackage[] = "RepairPackage";
190 : static char const sDocumentTitle[] = "DocumentTitle";
191 : static char const sComponentData[] = "ComponentData";
192 : static char const sComponentContext[] = "ComponentContext";
193 : static char const sDocumentBaseURL[] = "DocumentBaseURL";
194 : static char const sHierarchicalDocumentName[] = "HierarchicalDocumentName";
195 : static char const sCopyStreamIfPossible[] = "CopyStreamIfPossible";
196 : static char const sNoAutoSave[] = "NoAutoSave";
197 : static char const sFolderName[] = "FolderName";
198 : static char const sUseSystemDialog[] = "UseSystemDialog";
199 : static char const sStandardDir[] = "StandardDir";
200 : static char const sBlackList[] = "BlackList";
201 : static char const sModifyPasswordInfo[] = "ModifyPasswordInfo";
202 : static char const sSuggestedSaveAsDir[] = "SuggestedSaveAsDir";
203 : static char const sSuggestedSaveAsName[] = "SuggestedSaveAsName";
204 : static char const sEncryptionData[] = "EncryptionData";
205 : static char const sFailOnWarning[] = "FailOnWarning";
206 : static char const sDocumentService[] = "DocumentService";
207 : static char const sFilterProvider[] = "FilterProvider";
208 :
209 23039 : static bool isMediaDescriptor( sal_uInt16 nSlotId )
210 : {
211 524 : return ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC ||
212 5 : nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
213 5 : nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF ||
214 23044 : nSlotId == SID_DIRECTEXPORTDOCASPDF || nSlotId == SID_SAVEACOPY ||
215 23039 : nSlotId == SID_SAVEACOPYITEM);
216 : }
217 :
218 9618 : void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
219 : {
220 9618 : if ( !pSlot )
221 9434 : pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
222 :
223 9618 : if ( !pSlot )
224 0 : return;
225 :
226 9618 : if ( nSlotId == SID_OPENURL )
227 0 : nSlotId = SID_OPENDOC;
228 9618 : if ( nSlotId == SID_SAVEASURL )
229 0 : nSlotId = SID_SAVEASDOC;
230 :
231 9618 : sal_Int32 nCount = rArgs.getLength();
232 9618 : if ( !nCount )
233 216 : return;
234 :
235 9402 : const beans::PropertyValue* pPropsVal = rArgs.getConstArray();
236 9402 : if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
237 : {
238 : // slot is a property
239 153 : const SfxType* pType = pSlot->GetType();
240 153 : boost::scoped_ptr<SfxPoolItem> pItem(pType->CreateItem());
241 :
242 153 : if ( !pItem )
243 : {
244 : #ifdef DBG_UTIL
245 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
246 : "No creator method for item: "));
247 : aStr.append(static_cast<sal_Int32>(nSlotId));
248 : OSL_FAIL(aStr.getStr());
249 : #endif
250 0 : return;
251 : }
252 :
253 153 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
254 153 : sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
255 153 : pItem->SetWhich( nWhich );
256 153 : sal_uInt16 nSubCount = pType->nAttribs;
257 :
258 153 : const beans::PropertyValue& rProp = pPropsVal[0];
259 306 : String aName = rProp.Name;
260 153 : if ( nCount == 1 && aName.CompareToAscii( pSlot->pUnoName ) == COMPARE_EQUAL )
261 : {
262 : // there is only one parameter and its name matches the name of the property,
263 : // so it's either a simple property or a complex property in one single UNO struct
264 153 : if( pItem->PutValue( rProp.Value, bConvertTwips ? CONVERT_TWIPS : 0 ) )
265 : // only use successfully converted items
266 153 : rSet.Put( *pItem );
267 : #ifdef DBG_UTIL
268 : else
269 : {
270 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property not convertible: "));
271 : aStr.append(pSlot->pUnoName);
272 : OSL_FAIL( aStr.getStr() );
273 : }
274 : #endif
275 : }
276 : #ifdef DBG_UTIL
277 : else if ( nSubCount == 0 )
278 : {
279 : // for a simple property there can be only one parameter and its name *must* match
280 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property name does not match: "));
281 : aStr.append(OUStringToOString(aName, RTL_TEXTENCODING_UTF8));
282 : OSL_FAIL( aStr.getStr() );
283 : }
284 : #endif
285 : else
286 : {
287 : // there is more than one parameter and the property is a complex one
288 : #ifdef DBG_UTIL
289 : // if the dispatch API is used for UI purposes or from the testtool,
290 : // it is possible to skip some or all arguments,
291 : // but it indicates an error for macro recording;
292 : // so this should be notified as a warning only
293 : if ( nCount != nSubCount )
294 : {
295 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
296 : "MacroPlayer: wrong number of parameters for slot: "));
297 : aStr.append(static_cast<sal_Int32>(nSlotId));
298 : DBG_WARNING(aStr.getStr());
299 : }
300 : #endif
301 : // complex property; collect sub items from the parameter set and reconstruct complex item
302 0 : sal_uInt16 nFound=0;
303 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
304 : {
305 0 : const beans::PropertyValue& rPropValue = pPropsVal[n];
306 : sal_uInt16 nSub;
307 0 : for ( nSub=0; nSub<nSubCount; nSub++ )
308 : {
309 : // search sub item by name
310 0 : OStringBuffer aStr;
311 0 : aStr.append(pSlot->pUnoName).append('.').append(pType->aAttrib[nSub].pName);
312 0 : if ( rPropValue.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
313 : {
314 0 : sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[nSub].nAID;
315 0 : if ( bConvertTwips )
316 0 : nSubId |= CONVERT_TWIPS;
317 0 : if ( pItem->PutValue( rPropValue.Value, nSubId ) )
318 0 : nFound++;
319 : #ifdef DBG_UTIL
320 : else
321 : {
322 : OStringBuffer aDbgStr(RTL_CONSTASCII_STRINGPARAM("Property not convertible: "));
323 : aDbgStr.append(pSlot->pUnoName);
324 : OSL_FAIL( aDbgStr.getStr() );
325 : }
326 : #endif
327 0 : break;
328 : }
329 0 : }
330 :
331 : #ifdef DBG_UTIL
332 : if ( nSub >= nSubCount )
333 : {
334 : // there was a parameter with a name that didn't match to any of the members
335 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property name does not match: "));
336 : aStr.append(OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8));
337 : OSL_FAIL( aStr.getStr() );
338 : }
339 : #endif
340 : }
341 :
342 : // at least one part of the complex item must be present; other parts can have default values
343 0 : if ( nFound > 0 )
344 0 : rSet.Put( *pItem );
345 : }
346 :
347 306 : return;
348 : }
349 :
350 : OSL_ASSERT(nCount > 0);
351 :
352 : #ifdef DBG_UTIL
353 : // detect parameters that don't match to any formal argument or one of its members
354 : sal_Int32 nFoundArgs = 0;
355 : #endif
356 : // slot is a method
357 9249 : bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
358 9249 : sal_uInt16 nMaxArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
359 184890 : for ( sal_uInt16 nArgs=0; nArgs<nMaxArgs; nArgs++ )
360 : {
361 175641 : const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArgs] : pSlot->GetFormalArgument( nArgs );
362 175641 : boost::scoped_ptr<SfxPoolItem> pItem(rArg.CreateItem());
363 175641 : if ( !pItem )
364 : {
365 : #ifdef DBG_UTIL
366 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("No creator method for argument: "));
367 : aStr.append(rArg.pName);
368 : OSL_FAIL( aStr.getStr() );
369 : #endif
370 0 : return;
371 : }
372 :
373 175641 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich(rArg.nSlotId);
374 175641 : sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
375 175641 : pItem->SetWhich( nWhich );
376 175641 : const SfxType* pType = rArg.pType;
377 175641 : sal_uInt16 nSubCount = pType->nAttribs;
378 175641 : if ( nSubCount == 0 )
379 : {
380 : // "simple" (base type) argument
381 885645 : for ( sal_uInt16 n=0; n<nCount; n++ )
382 : {
383 717708 : const beans::PropertyValue& rProp = pPropsVal[n];
384 717708 : String aName = rProp.Name;
385 717708 : if ( aName.CompareToAscii(rArg.pName) == COMPARE_EQUAL )
386 : {
387 : #ifdef DBG_UTIL
388 : ++nFoundArgs;
389 : #endif
390 7704 : if( pItem->PutValue( rProp.Value ) )
391 : // only use successfully converted items
392 7704 : rSet.Put( *pItem );
393 : #ifdef DBG_UTIL
394 : else
395 : {
396 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property not convertible: "));
397 : aStr.append(rArg.pName);
398 : OSL_FAIL( aStr.getStr() );
399 : }
400 : #endif
401 7704 : break;
402 : }
403 710004 : }
404 : }
405 : else
406 : {
407 : // complex argument, could be passed in one struct
408 0 : sal_Bool bAsWholeItem = sal_False;
409 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
410 : {
411 0 : const beans::PropertyValue& rProp = pPropsVal[n];
412 0 : String aName = rProp.Name;
413 0 : if ( aName.CompareToAscii(rArg.pName) == COMPARE_EQUAL )
414 : {
415 0 : bAsWholeItem = sal_True;
416 : #ifdef DBG_UTIL
417 : ++nFoundArgs;
418 : #endif
419 0 : if( pItem->PutValue( rProp.Value ) )
420 : // only use successfully converted items
421 0 : rSet.Put( *pItem );
422 : #ifdef DBG_UTIL
423 : else
424 : {
425 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property not convertible: "));
426 : aStr.append(rArg.pName);
427 : OSL_FAIL( aStr.getStr() );
428 : }
429 : #endif
430 : }
431 0 : }
432 :
433 0 : if ( !bAsWholeItem )
434 : {
435 : // complex argument; collect sub items from argument array and reconstruct complex item
436 : // only put item if at least one member was found and had the correct type
437 : // (is this a good idea?! Should we ask for *all* members?)
438 0 : sal_Bool bRet = sal_False;
439 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
440 : {
441 0 : const beans::PropertyValue& rProp = pPropsVal[n];
442 0 : for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
443 : {
444 : // search sub item by name
445 0 : OStringBuffer aStr;
446 0 : aStr.append(rArg.pName).append('.').append(pType->aAttrib[nSub].pName);
447 0 : if ( rProp.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
448 : {
449 : // at least one member found ...
450 0 : bRet = sal_True;
451 : #ifdef DBG_UTIL
452 : ++nFoundArgs;
453 : #endif
454 0 : sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[nSub].nAID;
455 0 : if ( bConvertTwips )
456 0 : nSubId |= CONVERT_TWIPS;
457 0 : if (!pItem->PutValue( rProp.Value, nSubId ) )
458 : {
459 : // ... but it was not convertible
460 0 : bRet = sal_False;
461 : #ifdef DBG_UTIL
462 : OStringBuffer aDbgStr(RTL_CONSTASCII_STRINGPARAM("Property not convertible: "));
463 : aDbgStr.append(rArg.pName);
464 : OSL_FAIL( aDbgStr.getStr() );
465 : #endif
466 : }
467 :
468 0 : break;
469 : }
470 0 : }
471 : }
472 :
473 0 : if ( bRet )
474 : // only use successfully converted items
475 0 : rSet.Put( *pItem );
476 :
477 : }
478 : }
479 175641 : }
480 :
481 : // special additional parameters for some slots not seen in the slot definitions
482 : // Some of these slots are not considered to be used for macro recording, because they shouldn't be recorded as slots,
483 : // but as dispatching or factory or arbitrary URLs to the frame
484 : // Some also can use additional arguments that are not recordable (will be changed later,
485 : // f.e. "SaveAs" shouldn't support parameters not in the slot definition!)
486 9249 : if ( nSlotId == SID_NEWWINDOW )
487 : {
488 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
489 : {
490 0 : const beans::PropertyValue& rProp = pPropsVal[n];
491 0 : OUString aName = rProp.Name;
492 0 : if ( aName == sFrame )
493 : {
494 0 : Reference< XFrame > xFrame;
495 0 : OSL_VERIFY( rProp.Value >>= xFrame );
496 0 : rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
497 : }
498 : else
499 0 : if ( aName == sHidden )
500 : {
501 0 : sal_Bool bVal = sal_False;
502 0 : if (rProp.Value >>= bVal)
503 0 : rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
504 : }
505 0 : }
506 : }
507 9249 : else if ( bIsMediaDescriptor )
508 : {
509 48763 : for ( sal_uInt16 n=0; n<nCount; n++ )
510 : {
511 : #ifdef DBG_UTIL
512 : ++nFoundArgs;
513 : #endif
514 39519 : const beans::PropertyValue& rProp = pPropsVal[n];
515 39519 : const OUString& aName = rProp.Name;
516 39519 : if ( aName == sModel )
517 0 : rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) );
518 39519 : else if ( aName == sComponentData )
519 : {
520 8 : rSet.Put( SfxUnoAnyItem( SID_COMPONENTDATA, rProp.Value ) );
521 : }
522 39511 : else if ( aName == sComponentContext )
523 : {
524 0 : rSet.Put( SfxUnoAnyItem( SID_COMPONENTCONTEXT, rProp.Value ) );
525 : }
526 39511 : else if ( aName == sStatusInd )
527 : {
528 460 : Reference<task::XStatusIndicator> xVal;
529 460 : sal_Bool bOK = (rProp.Value >>= xVal);
530 : DBG_ASSERT( bOK, "invalid type for StatusIndicator" );
531 460 : if (bOK && xVal.is())
532 460 : rSet.Put( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, rProp.Value ) );
533 : }
534 39051 : else if ( aName == sInteractionHdl )
535 : {
536 3620 : Reference<task::XInteractionHandler> xVal;
537 3620 : sal_Bool bOK = (rProp.Value >>= xVal);
538 : DBG_ASSERT( bOK, "invalid type for InteractionHandler" );
539 3620 : if (bOK && xVal.is())
540 3615 : rSet.Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, rProp.Value ) );
541 : }
542 35431 : else if ( aName == sViewData )
543 0 : rSet.Put( SfxUnoAnyItem( SID_VIEW_DATA, rProp.Value ) );
544 35431 : else if ( aName == sFilterData )
545 0 : rSet.Put( SfxUnoAnyItem( SID_FILTER_DATA, rProp.Value ) );
546 35431 : else if ( aName == sInputStream )
547 : {
548 1472 : Reference< XInputStream > xVal;
549 1472 : sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
550 : DBG_ASSERT( bOK, "invalid type for InputStream" );
551 1472 : if (bOK)
552 1472 : rSet.Put( SfxUnoAnyItem( SID_INPUTSTREAM, rProp.Value ) );
553 : }
554 33959 : else if ( aName == sStream )
555 : {
556 57 : Reference< XInputStream > xVal;
557 57 : sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
558 : DBG_ASSERT( bOK, "invalid type for Stream" );
559 57 : if (bOK)
560 57 : rSet.Put( SfxUnoAnyItem( SID_STREAM, rProp.Value ) );
561 : }
562 33902 : else if ( aName == sUCBContent )
563 : {
564 2353 : Reference< XContent > xVal;
565 2353 : sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
566 : DBG_ASSERT( bOK, "invalid type for UCBContent" );
567 2353 : if (bOK)
568 2353 : rSet.Put( SfxUnoAnyItem( SID_CONTENT, rProp.Value ) );
569 : }
570 31549 : else if ( aName == sOutputStream )
571 : {
572 0 : Reference< XOutputStream > xVal;
573 0 : sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
574 : DBG_ASSERT( bOK, "invalid type for OutputStream" );
575 0 : if (bOK)
576 0 : rSet.Put( SfxUnoAnyItem( SID_OUTPUTSTREAM, rProp.Value ) );
577 : }
578 31549 : else if ( aName == sPostData )
579 : {
580 0 : Reference< XInputStream > xVal;
581 0 : sal_Bool bOK = (rProp.Value >>= xVal);
582 : DBG_ASSERT( bOK, "invalid type for PostData" );
583 0 : if (bOK)
584 0 : rSet.Put( SfxUnoAnyItem( SID_POSTDATA, rProp.Value ) );
585 : }
586 31549 : else if ( aName == sFrame )
587 : {
588 0 : Reference< XFrame > xFrame;
589 0 : sal_Bool bOK = (rProp.Value >>= xFrame);
590 : DBG_ASSERT( bOK, "invalid type for Frame" );
591 0 : if (bOK)
592 0 : rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
593 : }
594 31549 : else if ( aName == sAsTemplate )
595 : {
596 72 : sal_Bool bVal = sal_False;
597 72 : sal_Bool bOK = (rProp.Value >>= bVal);
598 : DBG_ASSERT( bOK, "invalid type for AsTemplate" );
599 72 : if (bOK)
600 72 : rSet.Put( SfxBoolItem( SID_TEMPLATE, bVal ) );
601 : }
602 31477 : else if ( aName == sOpenNewView )
603 : {
604 0 : sal_Bool bVal = sal_False;
605 0 : sal_Bool bOK = (rProp.Value >>= bVal);
606 : DBG_ASSERT( bOK, "invalid type for OpenNewView" );
607 0 : if (bOK)
608 0 : rSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, bVal ) );
609 : }
610 31477 : else if ( aName == sFailOnWarning )
611 : {
612 0 : sal_Bool bVal = sal_False;
613 0 : sal_Bool bOK = (rProp.Value >>= bVal);
614 : DBG_ASSERT( bOK, "invalid type for FailOnWarning" );
615 0 : if (bOK)
616 0 : rSet.Put( SfxBoolItem( SID_FAIL_ON_WARNING, bVal ) );
617 : }
618 31477 : else if ( aName == sViewId )
619 : {
620 20 : sal_Int16 nVal = -1;
621 20 : sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
622 : DBG_ASSERT( bOK, "invalid type for ViewId" );
623 20 : if (bOK)
624 20 : rSet.Put( SfxUInt16Item( SID_VIEW_ID, nVal ) );
625 : }
626 31457 : else if ( aName == sPluginMode )
627 : {
628 0 : sal_Int16 nVal = -1;
629 0 : sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
630 : DBG_ASSERT( bOK, "invalid type for PluginMode" );
631 0 : if (bOK)
632 0 : rSet.Put( SfxUInt16Item( SID_PLUGIN_MODE, nVal ) );
633 : }
634 31457 : else if ( aName == sReadOnly )
635 : {
636 280 : sal_Bool bVal = sal_False;
637 280 : sal_Bool bOK = (rProp.Value >>= bVal);
638 : DBG_ASSERT( bOK, "invalid type for ReadOnly" );
639 280 : if (bOK)
640 280 : rSet.Put( SfxBoolItem( SID_DOC_READONLY, bVal ) );
641 : }
642 31177 : else if ( aName == sDdeReconnect )
643 : {
644 0 : sal_Bool bVal = sal_True;
645 0 : sal_Bool bOK = (rProp.Value >>= bVal);
646 : DBG_ASSERT( bOK, "invalid type for DDEReconnect" );
647 0 : if (bOK)
648 0 : rSet.Put( SfxBoolItem( SID_DDE_RECONNECT_ONLOAD, bVal ) );
649 : }
650 31177 : else if ( aName == sStartPresentation )
651 : {
652 0 : sal_Bool bVal = sal_False;
653 0 : sal_Bool bOK = (rProp.Value >>= bVal);
654 : DBG_ASSERT( bOK, "invalid type for StartPresentation" );
655 0 : if (bOK)
656 0 : rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, bVal ) );
657 : }
658 31177 : else if ( aName == sSelectionOnly )
659 : {
660 0 : sal_Bool bVal = sal_False;
661 0 : sal_Bool bOK = (rProp.Value >>= bVal);
662 : DBG_ASSERT( bOK, "invalid type for SelectionOnly" );
663 0 : if (bOK)
664 0 : rSet.Put( SfxBoolItem( SID_SELECTION, bVal ) );
665 : }
666 31177 : else if ( aName == sHidden )
667 : {
668 65 : sal_Bool bVal = sal_False;
669 65 : sal_Bool bOK = (rProp.Value >>= bVal);
670 : DBG_ASSERT( bOK, "invalid type for Hidden" );
671 65 : if (bOK)
672 65 : rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
673 : }
674 31112 : else if ( aName == sMinimized )
675 : {
676 0 : sal_Bool bVal = sal_False;
677 0 : sal_Bool bOK = (rProp.Value >>= bVal);
678 : DBG_ASSERT( bOK, "invalid type for Minimized" );
679 0 : if (bOK)
680 0 : rSet.Put( SfxBoolItem( SID_MINIMIZED, bVal ) );
681 : }
682 31112 : else if ( aName == sSilent )
683 : {
684 0 : sal_Bool bVal = sal_False;
685 0 : sal_Bool bOK = (rProp.Value >>= bVal);
686 : DBG_ASSERT( bOK, "invalid type for Silent" );
687 0 : if (bOK)
688 0 : rSet.Put( SfxBoolItem( SID_SILENT, bVal ) );
689 : }
690 31112 : else if ( aName == sPreview )
691 : {
692 0 : sal_Bool bVal = sal_False;
693 0 : sal_Bool bOK = (rProp.Value >>= bVal);
694 : DBG_ASSERT( bOK, "invalid type for Preview" );
695 0 : if (bOK)
696 0 : rSet.Put( SfxBoolItem( SID_PREVIEW, bVal ) );
697 : }
698 31112 : else if ( aName == sViewOnly )
699 : {
700 0 : sal_Bool bVal = sal_False;
701 0 : sal_Bool bOK = (rProp.Value >>= bVal);
702 : DBG_ASSERT( bOK, "invalid type for ViewOnly" );
703 0 : if (bOK)
704 0 : rSet.Put( SfxBoolItem( SID_VIEWONLY, bVal ) );
705 : }
706 31112 : else if ( aName == sDontEdit )
707 : {
708 0 : sal_Bool bVal = sal_False;
709 0 : sal_Bool bOK = (rProp.Value >>= bVal);
710 : DBG_ASSERT( bOK, "invalid type for ViewOnly" );
711 0 : if (bOK)
712 0 : rSet.Put( SfxBoolItem( SID_EDITDOC, !bVal ) );
713 : }
714 31112 : else if ( aName == sUseSystemDialog )
715 : {
716 0 : sal_Bool bVal = sal_False;
717 0 : sal_Bool bOK = (rProp.Value >>= bVal);
718 : DBG_ASSERT( bOK, "invalid type for ViewOnly" );
719 0 : if (bOK)
720 0 : rSet.Put( SfxBoolItem( SID_FILE_DIALOG, bVal ) );
721 : }
722 31112 : else if ( aName == sStandardDir )
723 : {
724 0 : OUString sVal;
725 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
726 : DBG_ASSERT( bOK, "invalid type or value for StandardDir" );
727 0 : if (bOK)
728 0 : rSet.Put( SfxStringItem( SID_STANDARD_DIR, sVal ) );
729 : }
730 31112 : else if ( aName == sBlackList )
731 : {
732 0 : uno::Sequence<OUString> xVal;
733 0 : sal_Bool bOK = (rProp.Value >>= xVal);
734 : DBG_ASSERT( bOK, "invalid type or value for BlackList" );
735 0 : if (bOK)
736 : {
737 0 : SfxStringListItem stringList(SID_BLACK_LIST);
738 0 : stringList.SetStringList( xVal );
739 0 : rSet.Put( stringList );
740 0 : }
741 : }
742 31112 : else if ( aName == sFileName )
743 : {
744 531 : OUString sVal;
745 531 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
746 : DBG_ASSERT( bOK, "invalid type or value for FileName" );
747 531 : if (bOK)
748 531 : rSet.Put( SfxStringItem( SID_FILE_NAME, sVal ) );
749 : }
750 30581 : else if ( aName == sSalvagedFile )
751 : {
752 0 : OUString sVal;
753 0 : sal_Bool bOK = (rProp.Value >>= sVal);
754 : DBG_ASSERT( bOK, "invalid type or value for SalvagedFile" );
755 0 : if (bOK)
756 0 : rSet.Put( SfxStringItem( SID_DOC_SALVAGE, sVal ) );
757 : }
758 30581 : else if ( aName == sFolderName )
759 : {
760 0 : OUString sVal;
761 0 : sal_Bool bOK = (rProp.Value >>= sVal);
762 : DBG_ASSERT( bOK, "invalid type or value for FolderName" );
763 0 : if (bOK)
764 0 : rSet.Put( SfxStringItem( SID_PATH, sVal ) );
765 : }
766 30581 : else if ( aName == sFrameName )
767 : {
768 0 : OUString sVal;
769 0 : sal_Bool bOK = (rProp.Value >>= sVal);
770 : DBG_ASSERT( bOK, "invalid type for FrameName" );
771 0 : if (bOK && !sVal.isEmpty())
772 0 : rSet.Put( SfxStringItem( SID_TARGETNAME, sVal ) );
773 : }
774 30581 : else if ( aName == sMediaType )
775 : {
776 4 : OUString sVal;
777 4 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
778 : DBG_ASSERT( bOK, "invalid type or value for MediaType" );
779 4 : if (bOK)
780 4 : rSet.Put( SfxStringItem( SID_CONTENTTYPE, sVal ) );
781 : }
782 30577 : else if ( aName == sTemplateName )
783 : {
784 0 : OUString sVal;
785 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
786 : DBG_ASSERT( bOK, "invalid type or value for TemplateName" );
787 0 : if (bOK)
788 0 : rSet.Put( SfxStringItem( SID_TEMPLATE_NAME, sVal ) );
789 : }
790 30577 : else if ( aName == sTemplateRegionName )
791 : {
792 0 : OUString sVal;
793 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
794 : DBG_ASSERT( bOK, "invalid type or value for TemplateRegionName" );
795 0 : if (bOK)
796 0 : rSet.Put( SfxStringItem( SID_TEMPLATE_REGIONNAME, sVal ) );
797 : }
798 30577 : else if ( aName == sJumpMark )
799 : {
800 0 : OUString sVal;
801 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
802 : DBG_ASSERT( bOK, "invalid type or value for JumpMark" );
803 0 : if (bOK)
804 0 : rSet.Put( SfxStringItem( SID_JUMPMARK, sVal ) );
805 : }
806 30577 : else if ( aName == sCharacterSet )
807 : {
808 0 : OUString sVal;
809 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
810 : DBG_ASSERT( bOK, "invalid type or value for CharacterSet" );
811 0 : if (bOK)
812 0 : rSet.Put( SfxStringItem( SID_CHARSET, sVal ) );
813 : }
814 30577 : else if ( aName == sFilterFlags )
815 : {
816 0 : OUString sVal;
817 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
818 : DBG_ASSERT( bOK, "invalid type or value for FilterFlags" );
819 0 : if (bOK)
820 0 : rSet.Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sVal ) );
821 : }
822 30577 : else if ( aName == sMacroExecMode )
823 : {
824 4638 : sal_Int16 nVal =-1;
825 4638 : sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
826 : DBG_ASSERT( bOK, "invalid type for MacroExecMode" );
827 4638 : if (bOK)
828 4638 : rSet.Put( SfxUInt16Item( SID_MACROEXECMODE, nVal ) );
829 : }
830 25939 : else if ( aName == sUpdateDocMode )
831 : {
832 3659 : sal_Int16 nVal =-1;
833 3659 : sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
834 : DBG_ASSERT( bOK, "invalid type for UpdateDocMode" );
835 3659 : if (bOK)
836 3659 : rSet.Put( SfxUInt16Item( SID_UPDATEDOCMODE, nVal ) );
837 : }
838 22280 : else if ( aName == sRepairPackage )
839 : {
840 0 : sal_Bool bVal = sal_False;
841 0 : sal_Bool bOK = (rProp.Value >>= bVal);
842 : DBG_ASSERT( bOK, "invalid type for RepairPackage" );
843 0 : if (bOK)
844 0 : rSet.Put( SfxBoolItem( SID_REPAIRPACKAGE, bVal ) );
845 : }
846 22280 : else if ( aName == sDocumentTitle )
847 : {
848 0 : OUString sVal;
849 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
850 : DBG_ASSERT( bOK, "invalid type or value for DocumentTitle" );
851 0 : if (bOK)
852 0 : rSet.Put( SfxStringItem( SID_DOCINFO_TITLE, sVal ) );
853 : }
854 22280 : else if ( aName == sDocumentBaseURL )
855 : {
856 1836 : OUString sVal;
857 : // the base url can be set to empty ( for embedded objects for example )
858 1836 : sal_Bool bOK = (rProp.Value >>= sVal);
859 : DBG_ASSERT( bOK, "invalid type or value for DocumentBaseURL" );
860 1836 : if (bOK)
861 1836 : rSet.Put( SfxStringItem( SID_DOC_BASEURL, sVal ) );
862 : }
863 20444 : else if ( aName == sHierarchicalDocumentName )
864 : {
865 297 : OUString sVal;
866 297 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
867 : DBG_ASSERT( bOK, "invalid type or value for HierarchicalDocumentName" );
868 297 : if (bOK)
869 297 : rSet.Put( SfxStringItem( SID_DOC_HIERARCHICALNAME, sVal ) );
870 : }
871 20147 : else if ( aName == sCopyStreamIfPossible )
872 : {
873 0 : sal_Bool bVal = sal_False;
874 0 : sal_Bool bOK = (rProp.Value >>= bVal);
875 : DBG_ASSERT( bOK, "invalid type for CopyStreamIfPossible" );
876 0 : if (bOK)
877 0 : rSet.Put( SfxBoolItem( SID_COPY_STREAM_IF_POSSIBLE, bVal ) );
878 : }
879 20147 : else if ( aName == sNoAutoSave )
880 : {
881 0 : sal_Bool bVal = sal_False;
882 0 : sal_Bool bOK = (rProp.Value >>= bVal);
883 : DBG_ASSERT( bOK, "invalid type for NoAutoSave" );
884 0 : if (bOK)
885 0 : rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) );
886 : }
887 20147 : else if ( aName == sModifyPasswordInfo )
888 : {
889 0 : rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) );
890 : }
891 20147 : else if ( aName == sEncryptionData )
892 : {
893 3 : rSet.Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, rProp.Value ) );
894 : }
895 20144 : else if ( aName == sSuggestedSaveAsDir )
896 : {
897 0 : OUString sVal;
898 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
899 : DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsDir" );
900 0 : if (bOK)
901 0 : rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASDIR, sVal ) );
902 : }
903 20144 : else if ( aName == sSuggestedSaveAsName )
904 : {
905 0 : OUString sVal;
906 0 : sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
907 : DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsName" );
908 0 : if (bOK)
909 0 : rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASNAME, sVal ) );
910 : }
911 20144 : else if (aName == sDocumentService)
912 : {
913 3620 : OUString aVal;
914 3620 : bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
915 3620 : if (bOK)
916 3620 : rSet.Put(SfxStringItem(SID_DOC_SERVICE, aVal));
917 : }
918 16524 : else if (aName == sFilterProvider)
919 : {
920 0 : OUString aVal;
921 0 : bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
922 0 : if (bOK)
923 0 : rSet.Put(SfxStringItem(SID_FILTER_PROVIDER, aVal));
924 : }
925 : #ifdef DBG_UTIL
926 : else
927 : --nFoundArgs;
928 : #endif
929 : }
930 : }
931 : // API to raise options dialog with a specified options ab page (#i83757#)
932 : else
933 : {
934 : // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
935 5 : String sSlotName( "OptionsTreeDialog" );
936 10 : String sPropName( "OptionsPageURL" );
937 5 : if ( sSlotName.EqualsAscii( pSlot->pUnoName ) )
938 : {
939 0 : for ( sal_uInt16 n = 0; n < nCount; ++n )
940 : {
941 0 : const PropertyValue& rProp = pPropsVal[n];
942 0 : String sName( rProp.Name );
943 0 : if ( sName == sPropName )
944 : {
945 0 : OUString sURL;
946 0 : if ( rProp.Value >>= sURL )
947 0 : rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
948 0 : break;
949 : }
950 0 : }
951 5 : }
952 : }
953 : #ifdef DB_UTIL
954 : if ( nFoundArgs == nCount )
955 : {
956 : // except for the "special" slots: assure that every argument was convertible
957 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("MacroPlayer: Some properties didn't match to any formal argument for slot: "));
958 : aStr.append(pSlot->pUnoName);
959 : DBG_WARNING( aStr.getStr() );
960 : }
961 : #endif
962 : }
963 :
964 13790 : void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<beans::PropertyValue>& rArgs, const SfxSlot* pSlot )
965 : {
966 13790 : if ( !pSlot )
967 13790 : pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
968 :
969 13790 : if ( !pSlot)
970 3612 : return;
971 :
972 13790 : if ( nSlotId == SID_OPENURL )
973 0 : nSlotId = SID_OPENDOC;
974 13790 : if ( nSlotId == SID_SAVEASURL )
975 0 : nSlotId = SID_SAVEASDOC;
976 :
977 : // find number of properties to avoid permanent reallocations in the sequence
978 13790 : sal_Int32 nProps=0;
979 :
980 : #ifdef DBG_UTIL
981 : // trace number of items and compare with number of properties for debugging purposes
982 : sal_Int32 nItems=0;
983 : #endif
984 :
985 13790 : const SfxType *pType = pSlot->GetType();
986 13790 : if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
987 : {
988 : // slot is a property
989 0 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
990 0 : if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
991 : {
992 0 : sal_uInt16 nSubCount = pType->nAttribs;
993 0 : if ( nSubCount )
994 : // it's a complex property, we want it split into simple types
995 : // so we expect to get as many items as we have (sub) members
996 0 : nProps = nSubCount;
997 : else
998 : // simple property: we expect to get exactly one item
999 0 : nProps++;
1000 : }
1001 : #ifdef DBG_UTIL
1002 : else
1003 : {
1004 : // we will not rely on the "toggle" ability of some property slots
1005 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1006 : "Processing property slot without argument: "));
1007 : aStr.append(static_cast<sal_Int32>(nSlotId));
1008 : OSL_FAIL(aStr.getStr());
1009 : }
1010 : #endif
1011 :
1012 : #ifdef DBG_UTIL
1013 : nItems++;
1014 : #endif
1015 : }
1016 : else
1017 : {
1018 : // slot is a method
1019 13790 : bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
1020 13790 : sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->GetFormalArgumentCount();
1021 275800 : for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1022 : {
1023 : // check every formal argument of the method
1024 262010 : const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1025 :
1026 262010 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1027 262010 : if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
1028 : {
1029 16548 : sal_uInt16 nSubCount = rArg.pType->nAttribs;
1030 16548 : if ( nSubCount )
1031 : // argument has a complex type, we want it split into simple types
1032 : // so for this argument we expect to get as many items as we have (sub) members
1033 0 : nProps += nSubCount;
1034 : else
1035 : // argument of simple type: we expect to get exactly one item for it
1036 16548 : nProps++;
1037 : #ifdef DBG_UTIL
1038 : nItems++;
1039 : #endif
1040 : }
1041 : }
1042 :
1043 : // special treatment for slots that are *not* meant to be recorded as slots (except SaveAs/To)
1044 13790 : if ( bIsMediaDescriptor )
1045 : {
1046 13790 : sal_Int32 nAdditional=0;
1047 13790 : if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL ) == SFX_ITEM_SET )
1048 433 : nAdditional++;
1049 13790 : if ( rSet.GetItemState( SID_INTERACTIONHANDLER ) == SFX_ITEM_SET )
1050 6982 : nAdditional++;
1051 13790 : if ( rSet.GetItemState( SID_DOC_SALVAGE ) == SFX_ITEM_SET )
1052 0 : nAdditional++;
1053 13790 : if ( rSet.GetItemState( SID_PATH ) == SFX_ITEM_SET )
1054 0 : nAdditional++;
1055 13790 : if ( rSet.GetItemState( SID_FILE_DIALOG ) == SFX_ITEM_SET )
1056 0 : nAdditional++;
1057 13790 : if ( rSet.GetItemState( SID_STANDARD_DIR ) == SFX_ITEM_SET )
1058 0 : nAdditional++;
1059 13790 : if ( rSet.GetItemState( SID_BLACK_LIST ) == SFX_ITEM_SET )
1060 0 : nAdditional++;
1061 13790 : if ( rSet.GetItemState( SID_CONTENT ) == SFX_ITEM_SET )
1062 3449 : nAdditional++;
1063 13790 : if ( rSet.GetItemState( SID_INPUTSTREAM ) == SFX_ITEM_SET )
1064 452 : nAdditional++;
1065 13790 : if ( rSet.GetItemState( SID_STREAM ) == SFX_ITEM_SET )
1066 19 : nAdditional++;
1067 13790 : if ( rSet.GetItemState( SID_OUTPUTSTREAM ) == SFX_ITEM_SET )
1068 0 : nAdditional++;
1069 13790 : if ( rSet.GetItemState( SID_TEMPLATE ) == SFX_ITEM_SET )
1070 108 : nAdditional++;
1071 13790 : if ( rSet.GetItemState( SID_OPEN_NEW_VIEW ) == SFX_ITEM_SET )
1072 0 : nAdditional++;
1073 13790 : if ( rSet.GetItemState( SID_FAIL_ON_WARNING ) == SFX_ITEM_SET )
1074 0 : nAdditional++;
1075 13790 : if ( rSet.GetItemState( SID_VIEW_ID ) == SFX_ITEM_SET )
1076 46 : nAdditional++;
1077 13790 : if ( rSet.GetItemState( SID_VIEW_DATA ) == SFX_ITEM_SET )
1078 0 : nAdditional++;
1079 13790 : if ( rSet.GetItemState( SID_FILTER_DATA ) == SFX_ITEM_SET )
1080 0 : nAdditional++;
1081 13790 : if ( rSet.GetItemState( SID_PLUGIN_MODE ) == SFX_ITEM_SET )
1082 0 : nAdditional++;
1083 13790 : if ( rSet.GetItemState( SID_DOC_READONLY ) == SFX_ITEM_SET )
1084 1617 : nAdditional++;
1085 13790 : if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD ) == SFX_ITEM_SET )
1086 0 : nAdditional++;
1087 13790 : if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION ) == SFX_ITEM_SET )
1088 0 : nAdditional++;
1089 13790 : if ( rSet.GetItemState( SID_SELECTION ) == SFX_ITEM_SET )
1090 0 : nAdditional++;
1091 13790 : if ( rSet.GetItemState( SID_CONTENTTYPE ) == SFX_ITEM_SET )
1092 4 : nAdditional++;
1093 13790 : if ( rSet.GetItemState( SID_POSTDATA ) == SFX_ITEM_SET )
1094 0 : nAdditional++;
1095 13790 : if ( rSet.GetItemState( SID_FILLFRAME ) == SFX_ITEM_SET )
1096 0 : nAdditional++;
1097 13790 : if ( rSet.GetItemState( SID_CHARSET ) == SFX_ITEM_SET )
1098 0 : nAdditional++;
1099 13790 : if ( rSet.GetItemState( SID_TARGETNAME ) == SFX_ITEM_SET )
1100 0 : nAdditional++;
1101 13790 : if ( rSet.GetItemState( SID_TEMPLATE_NAME ) == SFX_ITEM_SET )
1102 0 : nAdditional++;
1103 13790 : if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME ) == SFX_ITEM_SET )
1104 0 : nAdditional++;
1105 13790 : if ( rSet.GetItemState( SID_HIDDEN ) == SFX_ITEM_SET )
1106 165 : nAdditional++;
1107 13790 : if ( rSet.GetItemState( SID_MINIMIZED ) == SFX_ITEM_SET )
1108 0 : nAdditional++;
1109 13790 : if ( rSet.GetItemState( SID_PREVIEW ) == SFX_ITEM_SET )
1110 0 : nAdditional++;
1111 13790 : if ( rSet.GetItemState( SID_VIEWONLY ) == SFX_ITEM_SET )
1112 0 : nAdditional++;
1113 13790 : if ( rSet.GetItemState( SID_EDITDOC ) == SFX_ITEM_SET )
1114 0 : nAdditional++;
1115 13790 : if ( rSet.GetItemState( SID_SILENT ) == SFX_ITEM_SET )
1116 0 : nAdditional++;
1117 13790 : if ( rSet.GetItemState( SID_JUMPMARK ) == SFX_ITEM_SET )
1118 0 : nAdditional++;
1119 13790 : if ( rSet.GetItemState( SID_DOCUMENT ) == SFX_ITEM_SET )
1120 0 : nAdditional++;
1121 13790 : if ( rSet.GetItemState( SID_MACROEXECMODE ) == SFX_ITEM_SET )
1122 8215 : nAdditional++;
1123 13790 : if ( rSet.GetItemState( SID_UPDATEDOCMODE ) == SFX_ITEM_SET )
1124 7085 : nAdditional++;
1125 13790 : if ( rSet.GetItemState( SID_REPAIRPACKAGE ) == SFX_ITEM_SET )
1126 0 : nAdditional++;
1127 13790 : if ( rSet.GetItemState( SID_DOCINFO_TITLE ) == SFX_ITEM_SET )
1128 0 : nAdditional++;
1129 13790 : if ( rSet.GetItemState( SID_COMPONENTDATA ) == SFX_ITEM_SET )
1130 17 : nAdditional++;
1131 13790 : if ( rSet.GetItemState( SID_COMPONENTCONTEXT ) == SFX_ITEM_SET )
1132 0 : nAdditional++;
1133 13790 : if ( rSet.GetItemState( SID_DOC_BASEURL ) == SFX_ITEM_SET )
1134 4675 : nAdditional++;
1135 13790 : if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME ) == SFX_ITEM_SET )
1136 0 : nAdditional++;
1137 13790 : if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE ) == SFX_ITEM_SET )
1138 0 : nAdditional++;
1139 13790 : if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SFX_ITEM_SET )
1140 0 : nAdditional++;
1141 13790 : if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO ) == SFX_ITEM_SET )
1142 0 : nAdditional++;
1143 13790 : if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR ) == SFX_ITEM_SET )
1144 0 : nAdditional++;
1145 13790 : if ( rSet.GetItemState( SID_ENCRYPTIONDATA ) == SFX_ITEM_SET )
1146 15 : nAdditional++;
1147 13790 : if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME ) == SFX_ITEM_SET )
1148 0 : nAdditional++;
1149 13790 : if ( rSet.GetItemState( SID_DOC_SERVICE ) == SFX_ITEM_SET )
1150 7061 : nAdditional++;
1151 13790 : if (rSet.HasItem(SID_FILTER_PROVIDER))
1152 0 : ++nAdditional;
1153 :
1154 : // consider additional arguments
1155 13790 : nProps += nAdditional;
1156 : #ifdef DBG_UTIL
1157 : nItems += nAdditional;
1158 : #endif
1159 : }
1160 : }
1161 :
1162 : #ifdef DBG_UTIL
1163 : // now check the itemset: is there any item that is not convertible using the list of formal arguments
1164 : // or the table of additional items?!
1165 : if ( rSet.Count() != nItems )
1166 : {
1167 : // detect unknown item and present error message
1168 : const sal_uInt16 *pRanges = rSet.GetRanges();
1169 : while ( *pRanges )
1170 : {
1171 : for(sal_uInt16 nId = *pRanges++; nId <= *pRanges; ++nId)
1172 : {
1173 : if ( rSet.GetItemState(nId) < SFX_ITEM_SET ) //???
1174 : // not really set
1175 : continue;
1176 :
1177 : if ( !pSlot->IsMode(SFX_SLOT_METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1178 : continue;
1179 :
1180 : bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
1181 : sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
1182 : sal_uInt16 nArg;
1183 : for ( nArg=0; nArg<nFormalArgs; ++nArg )
1184 : {
1185 : const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArg] : pSlot->GetFormalArgument( nArg );
1186 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1187 : if ( nId == nWhich )
1188 : break;
1189 : }
1190 :
1191 : if ( nArg<nFormalArgs )
1192 : continue;
1193 :
1194 : if ( bIsMediaDescriptor )
1195 : {
1196 : if ( nId == SID_DOCFRAME )
1197 : continue;
1198 : if ( nId == SID_PROGRESS_STATUSBAR_CONTROL )
1199 : continue;
1200 : if ( nId == SID_INTERACTIONHANDLER )
1201 : continue;
1202 : if ( nId == SID_VIEW_DATA )
1203 : continue;
1204 : if ( nId == SID_FILTER_DATA )
1205 : continue;
1206 : if ( nId == SID_DOCUMENT )
1207 : continue;
1208 : if ( nId == SID_CONTENT )
1209 : continue;
1210 : if ( nId == SID_INPUTSTREAM )
1211 : continue;
1212 : if ( nId == SID_STREAM )
1213 : continue;
1214 : if ( nId == SID_OUTPUTSTREAM )
1215 : continue;
1216 : if ( nId == SID_POSTDATA )
1217 : continue;
1218 : if ( nId == SID_FILLFRAME )
1219 : continue;
1220 : if ( nId == SID_TEMPLATE )
1221 : continue;
1222 : if ( nId == SID_OPEN_NEW_VIEW )
1223 : continue;
1224 : if ( nId == SID_VIEW_ID )
1225 : continue;
1226 : if ( nId == SID_PLUGIN_MODE )
1227 : continue;
1228 : if ( nId == SID_DOC_READONLY )
1229 : continue;
1230 : if ( nId == SID_DOC_STARTPRESENTATION )
1231 : continue;
1232 : if ( nId == SID_SELECTION )
1233 : continue;
1234 : if ( nId == SID_HIDDEN )
1235 : continue;
1236 : if ( nId == SID_MINIMIZED )
1237 : continue;
1238 : if ( nId == SID_SILENT )
1239 : continue;
1240 : if ( nId == SID_PREVIEW )
1241 : continue;
1242 : if ( nId == SID_VIEWONLY )
1243 : continue;
1244 : if ( nId == SID_EDITDOC )
1245 : continue;
1246 : if ( nId == SID_TARGETNAME )
1247 : continue;
1248 : if ( nId == SID_DOC_SALVAGE )
1249 : continue;
1250 : if ( nId == SID_PATH )
1251 : continue;
1252 : if ( nId == SID_FILE_DIALOG )
1253 : continue;
1254 : if ( nId == SID_STANDARD_DIR )
1255 : continue;
1256 : if ( nId == SID_BLACK_LIST )
1257 : continue;
1258 : if ( nId == SID_CONTENTTYPE )
1259 : continue;
1260 : if ( nId == SID_TEMPLATE_NAME )
1261 : continue;
1262 : if ( nId == SID_TEMPLATE_REGIONNAME )
1263 : continue;
1264 : if ( nId == SID_JUMPMARK )
1265 : continue;
1266 : if ( nId == SID_CHARSET )
1267 : continue;
1268 : if ( nId == SID_MACROEXECMODE )
1269 : continue;
1270 : if ( nId == SID_UPDATEDOCMODE )
1271 : continue;
1272 : if ( nId == SID_REPAIRPACKAGE )
1273 : continue;
1274 : if ( nId == SID_DOCINFO_TITLE )
1275 : continue;
1276 : if ( nId == SID_COMPONENTDATA )
1277 : continue;
1278 : if ( nId == SID_COMPONENTCONTEXT )
1279 : continue;
1280 : if ( nId == SID_DOC_BASEURL )
1281 : continue;
1282 : if ( nId == SID_DOC_HIERARCHICALNAME )
1283 : continue;
1284 : if ( nId == SID_COPY_STREAM_IF_POSSIBLE )
1285 : continue;
1286 : if ( nId == SID_NOAUTOSAVE )
1287 : continue;
1288 : if ( nId == SID_ENCRYPTIONDATA )
1289 : continue;
1290 : if ( nId == SID_DOC_SERVICE )
1291 : continue;
1292 : if (nId == SID_FILTER_PROVIDER)
1293 : continue;
1294 :
1295 : // used only internally
1296 : if ( nId == SID_SAVETO )
1297 : continue;
1298 : if ( nId == SID_SAVEACOPYITEM )
1299 : continue;
1300 : if ( nId == SID_MODIFYPASSWORDINFO )
1301 : continue;
1302 : if ( nId == SID_SUGGESTEDSAVEASDIR )
1303 : continue;
1304 : if ( nId == SID_SUGGESTEDSAVEASNAME )
1305 : continue;
1306 : }
1307 :
1308 : OStringBuffer aDbg(RTL_CONSTASCII_STRINGPARAM(
1309 : "Unknown item detected: "));
1310 : aDbg.append(static_cast<sal_Int32>(nId));
1311 : DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr());
1312 : }
1313 : }
1314 : }
1315 : #endif
1316 :
1317 13790 : if ( !nProps )
1318 3612 : return;
1319 :
1320 : // convert every item into a property
1321 10178 : uno::Sequence<beans::PropertyValue> aSequ(nProps);
1322 10178 : beans::PropertyValue *pValue = aSequ.getArray();
1323 :
1324 10178 : sal_Int32 nActProp=0;
1325 10178 : if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
1326 : {
1327 : // slot is a property
1328 0 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
1329 0 : sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1330 0 : SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1331 0 : if ( pItem ) //???
1332 : {
1333 0 : sal_uInt16 nSubCount = pType->nAttribs;
1334 0 : if ( !nSubCount )
1335 : {
1336 0 : pValue[nActProp].Name = OUString::createFromAscii(pSlot->pUnoName) ;
1337 0 : if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1338 : {
1339 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1340 0 : "Item not convertible: "));
1341 0 : aStr.append(static_cast<sal_Int32>(nSlotId));
1342 0 : OSL_FAIL(aStr.getStr());
1343 : }
1344 : }
1345 : else
1346 : {
1347 : // complex type, add a property value for every member of the struct
1348 0 : for ( sal_uInt16 n=1; n<=nSubCount; ++n )
1349 : {
1350 0 : sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[n-1].nAID;
1351 0 : if ( bConvertTwips )
1352 0 : nSubId |= CONVERT_TWIPS;
1353 :
1354 : DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1355 0 : String aName( OUString::createFromAscii( pSlot->pUnoName ) ) ;
1356 0 : aName += '.';
1357 0 : aName += OUString::createFromAscii( pType->aAttrib[n-1].pName ) ;
1358 0 : pValue[nActProp].Name = aName;
1359 0 : if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1360 : {
1361 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1362 0 : "Sub item "));
1363 : aStr.append(static_cast<sal_Int32>(
1364 0 : pType->aAttrib[n-1].nAID));
1365 : aStr.append(RTL_CONSTASCII_STRINGPARAM(
1366 0 : " not convertible in slot: "));
1367 0 : aStr.append(static_cast<sal_Int32>(nSlotId));
1368 0 : OSL_FAIL( aStr.getStr() );
1369 : }
1370 0 : }
1371 : }
1372 : }
1373 :
1374 0 : rArgs = aSequ;
1375 0 : return;
1376 : }
1377 :
1378 : // slot is a method
1379 10178 : sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1380 101885 : for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1381 : {
1382 91707 : const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1383 91707 : sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1384 91707 : sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1385 91707 : SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1386 91707 : if ( pItem ) //???
1387 : {
1388 16181 : sal_uInt16 nSubCount = rArg.pType->nAttribs;
1389 16181 : if ( !nSubCount )
1390 : {
1391 16181 : pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) ;
1392 16181 : if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1393 : {
1394 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1395 0 : "Item not convertible: "));
1396 0 : aStr.append(static_cast<sal_Int32>(rArg.nSlotId));
1397 0 : OSL_FAIL(aStr.getStr());
1398 : }
1399 : }
1400 : else
1401 : {
1402 : // complex type, add a property value for every member of the struct
1403 0 : for ( sal_uInt16 n = 1; n <= nSubCount; ++n )
1404 : {
1405 0 : sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) rArg.pType->aAttrib[n-1].nAID;
1406 0 : if ( bConvertTwips )
1407 0 : nSubId |= CONVERT_TWIPS;
1408 :
1409 : DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1410 0 : String aName( OUString::createFromAscii( rArg.pName ) ) ;
1411 0 : aName += '.';
1412 0 : aName += OUString::createFromAscii( rArg.pType->aAttrib[n-1].pName ) ;
1413 0 : pValue[nActProp].Name = aName;
1414 0 : if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1415 : {
1416 : OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1417 0 : "Sub item "));
1418 : aStr.append(static_cast<sal_Int32>(
1419 0 : rArg.pType->aAttrib[n-1].nAID));
1420 : aStr.append(RTL_CONSTASCII_STRINGPARAM(
1421 0 : " not convertible in slot: "));
1422 0 : aStr.append(static_cast<sal_Int32>(rArg.nSlotId));
1423 0 : OSL_FAIL(aStr.getStr());
1424 : }
1425 0 : }
1426 : }
1427 : }
1428 : }
1429 :
1430 10178 : if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1431 0 : nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
1432 : nSlotId == SID_SAVEACOPY )
1433 : {
1434 10178 : const SfxPoolItem *pItem=0;
1435 10178 : if ( rSet.GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1436 : {
1437 17 : pValue[nActProp].Name = OUString(sComponentData);
1438 17 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1439 : }
1440 10178 : if ( rSet.GetItemState( SID_COMPONENTCONTEXT, sal_False, &pItem ) == SFX_ITEM_SET )
1441 : {
1442 0 : pValue[nActProp].Name = OUString(sComponentContext);
1443 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1444 : }
1445 10178 : if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, sal_False, &pItem ) == SFX_ITEM_SET )
1446 : {
1447 433 : pValue[nActProp].Name = OUString(sStatusInd);
1448 433 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1449 : }
1450 10178 : if ( rSet.GetItemState( SID_INTERACTIONHANDLER, sal_False, &pItem ) == SFX_ITEM_SET )
1451 : {
1452 6982 : pValue[nActProp].Name = OUString(sInteractionHdl);
1453 6982 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1454 : }
1455 10178 : if ( rSet.GetItemState( SID_VIEW_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1456 : {
1457 0 : pValue[nActProp].Name = OUString(sViewData);
1458 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1459 : }
1460 10178 : if ( rSet.GetItemState( SID_FILTER_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1461 : {
1462 0 : pValue[nActProp].Name = OUString(sFilterData);
1463 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1464 : }
1465 10178 : if ( rSet.GetItemState( SID_DOCUMENT, sal_False, &pItem ) == SFX_ITEM_SET )
1466 : {
1467 0 : pValue[nActProp].Name = OUString(sModel);
1468 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1469 : }
1470 10178 : if ( rSet.GetItemState( SID_CONTENT, sal_False, &pItem ) == SFX_ITEM_SET )
1471 : {
1472 3449 : pValue[nActProp].Name = OUString(sUCBContent);
1473 3449 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1474 : }
1475 10178 : if ( rSet.GetItemState( SID_INPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1476 : {
1477 452 : pValue[nActProp].Name = OUString(sInputStream);
1478 452 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1479 : }
1480 10178 : if ( rSet.GetItemState( SID_STREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1481 : {
1482 19 : pValue[nActProp].Name = OUString(sStream);
1483 19 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1484 : }
1485 10178 : if ( rSet.GetItemState( SID_OUTPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1486 : {
1487 0 : pValue[nActProp].Name = OUString(sOutputStream);
1488 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1489 : }
1490 10178 : if ( rSet.GetItemState( SID_POSTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1491 : {
1492 0 : pValue[nActProp].Name = OUString(sPostData);
1493 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1494 : }
1495 10178 : if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1496 : {
1497 0 : pValue[nActProp].Name = OUString(sFrame);
1498 0 : if ( pItem->ISA( SfxUsrAnyItem ) )
1499 : {
1500 : OSL_FAIL( "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" );
1501 0 : pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue();
1502 : }
1503 0 : else if ( pItem->ISA( SfxUnoFrameItem ) )
1504 0 : pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame();
1505 : else
1506 : OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" );
1507 : }
1508 10178 : if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET )
1509 : {
1510 108 : pValue[nActProp].Name = OUString(sAsTemplate);
1511 108 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1512 : }
1513 10178 : if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1514 : {
1515 0 : pValue[nActProp].Name = OUString(sOpenNewView);
1516 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1517 : }
1518 10178 : if ( rSet.GetItemState( SID_FAIL_ON_WARNING, sal_False, &pItem ) == SFX_ITEM_SET )
1519 : {
1520 0 : pValue[nActProp].Name = OUString(RTL_CONSTASCII_USTRINGPARAM(sFailOnWarning));
1521 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1522 : }
1523 10178 : if ( rSet.GetItemState( SID_VIEW_ID, sal_False, &pItem ) == SFX_ITEM_SET )
1524 : {
1525 46 : pValue[nActProp].Name = OUString(sViewId);
1526 46 : pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1527 : }
1528 10178 : if ( rSet.GetItemState( SID_PLUGIN_MODE, sal_False, &pItem ) == SFX_ITEM_SET )
1529 : {
1530 0 : pValue[nActProp].Name = OUString(sPluginMode);
1531 0 : pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1532 : }
1533 10178 : if ( rSet.GetItemState( SID_DOC_READONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1534 : {
1535 1617 : pValue[nActProp].Name = OUString(sReadOnly);
1536 1617 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1537 : }
1538 10178 : if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD, sal_False, &pItem ) == SFX_ITEM_SET )
1539 : {
1540 0 : pValue[nActProp].Name = OUString(sDdeReconnect);
1541 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1542 : }
1543 10178 : if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, sal_False, &pItem ) == SFX_ITEM_SET )
1544 : {
1545 0 : pValue[nActProp].Name = OUString(sStartPresentation);
1546 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1547 : }
1548 10178 : if ( rSet.GetItemState( SID_SELECTION, sal_False, &pItem ) == SFX_ITEM_SET )
1549 : {
1550 0 : pValue[nActProp].Name = OUString(sSelectionOnly);
1551 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1552 : }
1553 10178 : if ( rSet.GetItemState( SID_HIDDEN, sal_False, &pItem ) == SFX_ITEM_SET )
1554 : {
1555 165 : pValue[nActProp].Name = OUString(sHidden);
1556 165 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1557 : }
1558 10178 : if ( rSet.GetItemState( SID_MINIMIZED, sal_False, &pItem ) == SFX_ITEM_SET )
1559 : {
1560 0 : pValue[nActProp].Name = OUString(sMinimized);
1561 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1562 : }
1563 10178 : if ( rSet.GetItemState( SID_SILENT, sal_False, &pItem ) == SFX_ITEM_SET )
1564 : {
1565 0 : pValue[nActProp].Name = OUString(sSilent);
1566 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1567 : }
1568 10178 : if ( rSet.GetItemState( SID_PREVIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1569 : {
1570 0 : pValue[nActProp].Name = OUString(sPreview);
1571 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1572 : }
1573 10178 : if ( rSet.GetItemState( SID_VIEWONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1574 : {
1575 0 : pValue[nActProp].Name = OUString(sViewOnly);
1576 0 : pValue[nActProp++].Value <<= (sal_Bool) (( ((SfxBoolItem*)pItem)->GetValue() ));
1577 : }
1578 10178 : if ( rSet.GetItemState( SID_EDITDOC, sal_False, &pItem ) == SFX_ITEM_SET )
1579 : {
1580 0 : pValue[nActProp].Name = OUString(sDontEdit);
1581 0 : pValue[nActProp++].Value <<= (sal_Bool) (!( ((SfxBoolItem*)pItem)->GetValue() ));
1582 : }
1583 10178 : if ( rSet.GetItemState( SID_FILE_DIALOG, sal_False, &pItem ) == SFX_ITEM_SET )
1584 : {
1585 0 : pValue[nActProp].Name = OUString(sUseSystemDialog);
1586 0 : pValue[nActProp++].Value <<= (sal_Bool) ( ((SfxBoolItem*)pItem)->GetValue() );
1587 : }
1588 10178 : if ( rSet.GetItemState( SID_STANDARD_DIR, sal_False, &pItem ) == SFX_ITEM_SET )
1589 : {
1590 0 : pValue[nActProp].Name = OUString(sStandardDir);
1591 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1592 : }
1593 10178 : if ( rSet.GetItemState( SID_BLACK_LIST, sal_False, &pItem ) == SFX_ITEM_SET )
1594 : {
1595 0 : pValue[nActProp].Name = OUString(sBlackList);
1596 :
1597 0 : com::sun::star::uno::Sequence< OUString > aList;
1598 0 : ((SfxStringListItem*)pItem)->GetStringList( aList );
1599 0 : pValue[nActProp++].Value <<= aList ;
1600 : }
1601 10178 : if ( rSet.GetItemState( SID_TARGETNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1602 : {
1603 0 : pValue[nActProp].Name = OUString(sFrameName);
1604 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1605 : }
1606 10178 : if ( rSet.GetItemState( SID_DOC_SALVAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1607 : {
1608 0 : pValue[nActProp].Name = OUString(sSalvagedFile);
1609 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1610 : }
1611 10178 : if ( rSet.GetItemState( SID_PATH, sal_False, &pItem ) == SFX_ITEM_SET )
1612 : {
1613 0 : pValue[nActProp].Name = OUString(sFolderName);
1614 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1615 : }
1616 10178 : if ( rSet.GetItemState( SID_CONTENTTYPE, sal_False, &pItem ) == SFX_ITEM_SET )
1617 : {
1618 4 : pValue[nActProp].Name = OUString(sMediaType);
1619 4 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1620 : }
1621 10178 : if ( rSet.GetItemState( SID_TEMPLATE_NAME, sal_False, &pItem ) == SFX_ITEM_SET )
1622 : {
1623 0 : pValue[nActProp].Name = OUString(sTemplateName);
1624 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1625 : }
1626 10178 : if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1627 : {
1628 0 : pValue[nActProp].Name = OUString(sTemplateRegionName);
1629 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1630 : }
1631 10178 : if ( rSet.GetItemState( SID_JUMPMARK, sal_False, &pItem ) == SFX_ITEM_SET )
1632 : {
1633 0 : pValue[nActProp].Name = OUString(sJumpMark);
1634 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1635 : }
1636 :
1637 10178 : if ( rSet.GetItemState( SID_CHARSET, sal_False, &pItem ) == SFX_ITEM_SET )
1638 : {
1639 0 : pValue[nActProp].Name = OUString(sCharacterSet);
1640 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1641 : }
1642 10178 : if ( rSet.GetItemState( SID_MACROEXECMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1643 : {
1644 8215 : pValue[nActProp].Name = OUString(sMacroExecMode);
1645 8215 : pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1646 : }
1647 10178 : if ( rSet.GetItemState( SID_UPDATEDOCMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1648 : {
1649 7085 : pValue[nActProp].Name = OUString(sUpdateDocMode);
1650 7085 : pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1651 : }
1652 10178 : if ( rSet.GetItemState( SID_REPAIRPACKAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1653 : {
1654 0 : pValue[nActProp].Name = OUString(sRepairPackage);
1655 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1656 : }
1657 10178 : if ( rSet.GetItemState( SID_DOCINFO_TITLE, sal_False, &pItem ) == SFX_ITEM_SET )
1658 : {
1659 0 : pValue[nActProp].Name = OUString(sDocumentTitle);
1660 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1661 : }
1662 10178 : if ( rSet.GetItemState( SID_DOC_BASEURL, sal_False, &pItem ) == SFX_ITEM_SET )
1663 : {
1664 4675 : pValue[nActProp].Name = OUString(sDocumentBaseURL);
1665 4675 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1666 : }
1667 10178 : if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1668 : {
1669 0 : pValue[nActProp].Name = OUString(sHierarchicalDocumentName);
1670 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1671 : }
1672 10178 : if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, sal_False, &pItem ) == SFX_ITEM_SET )
1673 : {
1674 0 : pValue[nActProp].Name = OUString(sCopyStreamIfPossible);
1675 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1676 : }
1677 10178 : if ( rSet.GetItemState( SID_NOAUTOSAVE, sal_False, &pItem ) == SFX_ITEM_SET )
1678 : {
1679 0 : pValue[nActProp].Name = OUString(sNoAutoSave);
1680 0 : pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1681 : }
1682 10178 : if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, sal_False, &pItem ) == SFX_ITEM_SET )
1683 : {
1684 0 : pValue[nActProp].Name = OUString(sModifyPasswordInfo);
1685 0 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1686 : }
1687 10178 : if ( rSet.GetItemState( SID_ENCRYPTIONDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1688 : {
1689 15 : pValue[nActProp].Name = OUString(sEncryptionData);
1690 15 : pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1691 : }
1692 10178 : if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, sal_False, &pItem ) == SFX_ITEM_SET )
1693 : {
1694 0 : pValue[nActProp].Name = OUString(sSuggestedSaveAsDir);
1695 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1696 : }
1697 10178 : if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1698 : {
1699 0 : pValue[nActProp].Name = OUString(sSuggestedSaveAsName);
1700 0 : pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1701 : }
1702 10178 : if ( rSet.GetItemState( SID_DOC_SERVICE, sal_False, &pItem ) == SFX_ITEM_SET )
1703 : {
1704 7061 : pValue[nActProp].Name = OUString(sDocumentService);
1705 7061 : pValue[nActProp++].Value <<= OUString(static_cast<const SfxStringItem*>(pItem)->GetValue());
1706 : }
1707 10178 : if (rSet.HasItem(SID_FILTER_PROVIDER, &pItem))
1708 : {
1709 0 : pValue[nActProp].Name = sFilterProvider;
1710 0 : pValue[nActProp++].Value <<= OUString(static_cast<const SfxStringItem*>(pItem)->GetValue());
1711 : }
1712 : }
1713 :
1714 10178 : rArgs = aSequ;
1715 : }
1716 :
1717 85 : SFX_IMPL_XINTERFACE_5( SfxMacroLoader, OWeakObject, frame::XDispatchProvider, frame::XNotifyingDispatch, frame::XDispatch, frame::XSynchronousDispatch,lang::XInitialization )
1718 2 : SFX_IMPL_XTYPEPROVIDER_5( SfxMacroLoader, frame::XDispatchProvider, frame::XNotifyingDispatch, frame::XDispatch, frame::XSynchronousDispatch,lang::XInitialization )
1719 288 : SFX_IMPL_XSERVICEINFO( SfxMacroLoader, PROTOCOLHANDLER_SERVICENAME, "com.sun.star.comp.sfx2.SfxMacroLoader" )
1720 1 : SFX_IMPL_SINGLEFACTORY( SfxMacroLoader )
1721 :
1722 1 : void SAL_CALL SfxMacroLoader::initialize( const uno::Sequence<uno::Any>& aArguments ) throw (uno::Exception, uno::RuntimeException)
1723 : {
1724 1 : Reference < XFrame > xFrame;
1725 1 : if ( aArguments.getLength() )
1726 : {
1727 0 : aArguments[0] >>= xFrame;
1728 0 : m_xFrame = xFrame;
1729 1 : }
1730 1 : }
1731 :
1732 0 : SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
1733 : {
1734 0 : SfxObjectShell* pDocShell = NULL;
1735 0 : Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
1736 0 : if ( xFrame.is() )
1737 : {
1738 0 : SfxFrame* pFrame=0;
1739 0 : for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
1740 : {
1741 0 : if ( pFrame->GetFrameInterface() == xFrame )
1742 0 : break;
1743 : }
1744 :
1745 0 : if ( pFrame )
1746 0 : pDocShell = pFrame->GetCurrentDocument();
1747 : }
1748 :
1749 0 : return pDocShell;
1750 : }
1751 :
1752 : // -----------------------------------------------------------------------
1753 3 : uno::Reference<frame::XDispatch> SAL_CALL SfxMacroLoader::queryDispatch(
1754 : const util::URL& aURL ,
1755 : const OUString& /*sTargetFrameName*/,
1756 : sal_Int32 /*nSearchFlags*/ ) throw( uno::RuntimeException )
1757 : {
1758 3 : uno::Reference<frame::XDispatch> xDispatcher;
1759 3 : if(aURL.Complete.startsWith("macro:"))
1760 3 : xDispatcher = this;
1761 3 : return xDispatcher;
1762 : }
1763 :
1764 : // -----------------------------------------------------------------------
1765 : uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL
1766 1 : SfxMacroLoader::queryDispatches( const uno::Sequence < frame::DispatchDescriptor >& seqDescriptor )
1767 : throw( uno::RuntimeException )
1768 : {
1769 1 : sal_Int32 nCount = seqDescriptor.getLength();
1770 1 : uno::Sequence< uno::Reference<frame::XDispatch> > lDispatcher(nCount);
1771 3 : for( sal_Int32 i=0; i<nCount; ++i )
1772 6 : lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1773 2 : seqDescriptor[i].FrameName,
1774 4 : seqDescriptor[i].SearchFlags );
1775 1 : return lDispatcher;
1776 : }
1777 :
1778 : // -----------------------------------------------------------------------
1779 0 : void SAL_CALL SfxMacroLoader::dispatchWithNotification(
1780 : const util::URL& aURL, const uno::Sequence<beans::PropertyValue>& /*lArgs*/,
1781 : const uno::Reference<frame::XDispatchResultListener>& xListener )
1782 : throw (uno::RuntimeException)
1783 : {
1784 0 : SolarMutexGuard aGuard;
1785 :
1786 0 : uno::Any aAny;
1787 0 : ErrCode nErr = loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1788 0 : if( xListener.is() )
1789 : {
1790 : // always call dispatchFinished(), because we didn't load a document but
1791 : // executed a macro instead!
1792 0 : frame::DispatchResultEvent aEvent;
1793 :
1794 0 : aEvent.Source = static_cast< ::cppu::OWeakObject* >(this);
1795 0 : if( nErr == ERRCODE_NONE )
1796 0 : aEvent.State = frame::DispatchResultState::SUCCESS;
1797 : else
1798 0 : aEvent.State = frame::DispatchResultState::FAILURE;
1799 :
1800 0 : xListener->dispatchFinished( aEvent ) ;
1801 0 : }
1802 0 : }
1803 :
1804 0 : uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue(
1805 : const util::URL& aURL, const uno::Sequence<beans::PropertyValue>& )
1806 : throw (uno::RuntimeException)
1807 : {
1808 0 : uno::Any aRet;
1809 0 : loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() );
1810 0 : return aRet;
1811 : }
1812 :
1813 0 : void SAL_CALL SfxMacroLoader::dispatch(
1814 : const util::URL& aURL, const uno::Sequence<beans::PropertyValue>& /*lArgs*/ )
1815 : throw (uno::RuntimeException)
1816 : {
1817 0 : SolarMutexGuard aGuard;
1818 :
1819 0 : uno::Any aAny;
1820 0 : loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1821 0 : }
1822 :
1823 0 : void SAL_CALL SfxMacroLoader::addStatusListener(
1824 : const uno::Reference< frame::XStatusListener >& ,
1825 : const util::URL& )
1826 : throw (uno::RuntimeException)
1827 : {
1828 : /* TODO
1829 : How we can handle different listener for further coming or currently running dispatch() jobs
1830 : without any inconsistency!
1831 : */
1832 0 : }
1833 :
1834 : // -----------------------------------------------------------------------
1835 0 : void SAL_CALL SfxMacroLoader::removeStatusListener(
1836 : const uno::Reference< frame::XStatusListener >&,
1837 : const util::URL& )
1838 : throw (uno::RuntimeException)
1839 : {
1840 0 : }
1841 :
1842 0 : ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, com::sun::star::uno::Any& rRetval, SfxObjectShell* pSh )
1843 : throw ( uno::RuntimeException )
1844 : {
1845 : #ifdef DISABLE_SCRIPTING
1846 : (void) rURL;
1847 : (void) rRetval;
1848 : (void) pSh;
1849 : return ERRCODE_BASIC_PROC_UNDEFINED;
1850 : #else
1851 0 : SfxObjectShell* pCurrent = pSh;
1852 0 : if ( !pCurrent )
1853 : // all not full qualified names use the BASIC of the given or current document
1854 0 : pCurrent = SfxObjectShell::Current();
1855 :
1856 : // 'macro:///lib.mod.proc(args)' => macro of App-BASIC
1857 : // 'macro://[docname|.]/lib.mod.proc(args)' => macro of current or qualified document
1858 : // 'macro://obj.method(args)' => direct API call, execute it via App-BASIC
1859 0 : String aMacro( rURL );
1860 0 : sal_uInt16 nHashPos = aMacro.Search( '/', 8 );
1861 0 : sal_uInt16 nArgsPos = aMacro.Search( '(' );
1862 0 : BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
1863 0 : BasicManager *pBasMgr = 0;
1864 0 : ErrCode nErr = ERRCODE_NONE;
1865 :
1866 : // should a macro function be executed ( no direct API call)?
1867 0 : if ( STRING_NOTFOUND != nHashPos && nHashPos < nArgsPos )
1868 : {
1869 : // find BasicManager
1870 0 : SfxObjectShell* pDoc = NULL;
1871 0 : String aBasMgrName( INetURLObject::decode(aMacro.Copy( 8, nHashPos-8 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1872 0 : if ( !aBasMgrName.Len() )
1873 0 : pBasMgr = pAppMgr;
1874 0 : else if ( aBasMgrName.EqualsAscii(".") )
1875 : {
1876 : // current/actual document
1877 0 : pDoc = pCurrent;
1878 0 : if (pDoc)
1879 0 : pBasMgr = pDoc->GetBasicManager();
1880 : }
1881 : else
1882 : {
1883 : // full qualified name, find document by name
1884 0 : for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
1885 0 : pObjSh && !pBasMgr;
1886 : pObjSh = SfxObjectShell::GetNext(*pObjSh) )
1887 0 : if ( aBasMgrName == pObjSh->GetTitle(SFX_TITLE_APINAME) )
1888 : {
1889 0 : pDoc = pObjSh;
1890 0 : pBasMgr = pDoc->GetBasicManager();
1891 : }
1892 : }
1893 :
1894 0 : if ( pBasMgr )
1895 : {
1896 0 : const bool bIsAppBasic = ( pBasMgr == pAppMgr );
1897 0 : const bool bIsDocBasic = ( pBasMgr != pAppMgr );
1898 :
1899 0 : if ( pDoc )
1900 : {
1901 : // security check for macros from document basic if an SFX doc is given
1902 0 : if ( !pDoc->AdjustMacroMode( String() ) )
1903 : // check forbids execution
1904 0 : return ERRCODE_IO_ACCESSDENIED;
1905 : }
1906 0 : else if ( pDoc && pDoc->GetMedium() )
1907 : {
1908 0 : pDoc->AdjustMacroMode( String() );
1909 0 : SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
1910 0 : SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False);
1911 0 : if ( pUpdateDocItem && pMacroExecModeItem
1912 0 : && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE
1913 0 : && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE )
1914 0 : return ERRCODE_IO_ACCESSDENIED;
1915 : }
1916 :
1917 : // find BASIC method
1918 0 : String aQualifiedMethod( INetURLObject::decode(aMacro.Copy( nHashPos+1 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1919 0 : String aArgs;
1920 0 : if ( STRING_NOTFOUND != nArgsPos )
1921 : {
1922 : // remove arguments from macro name
1923 0 : aArgs = aQualifiedMethod.Copy( nArgsPos - nHashPos - 1 );
1924 0 : aQualifiedMethod.Erase( nArgsPos - nHashPos - 1 );
1925 : }
1926 :
1927 0 : if ( pBasMgr->HasMacro( OUString(aQualifiedMethod) ) )
1928 : {
1929 0 : Any aOldThisComponent;
1930 0 : const bool bSetDocMacroMode = ( pDoc != NULL ) && bIsDocBasic;
1931 0 : const bool bSetGlobalThisComponent = ( pDoc != NULL ) && bIsAppBasic;
1932 0 : if ( bSetDocMacroMode )
1933 : {
1934 : // mark document: it executes an own macro, so it's in a modal mode
1935 0 : pDoc->SetMacroMode_Impl( sal_True );
1936 : }
1937 :
1938 0 : if ( bSetGlobalThisComponent )
1939 : {
1940 : // document is executed via AppBASIC, adjust ThisComponent variable
1941 0 : aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pDoc->GetModel() ) );
1942 : }
1943 :
1944 : // just to let the shell be alive
1945 0 : SfxObjectShellRef xKeepDocAlive = pDoc;
1946 :
1947 : {
1948 : // attempt to protect the document against the script tampering with its Undo Context
1949 0 : ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
1950 0 : if ( bIsDocBasic )
1951 0 : pUndoGuard.reset( new ::framework::DocumentUndoGuard( pDoc->GetModel() ) );
1952 :
1953 : // execute the method
1954 0 : SbxVariableRef retValRef = new SbxVariable;
1955 0 : nErr = pBasMgr->ExecuteMacro( aQualifiedMethod, aArgs, retValRef );
1956 0 : if ( nErr == ERRCODE_NONE )
1957 0 : rRetval = sbxToUnoValue( retValRef );
1958 : }
1959 :
1960 0 : if ( bSetGlobalThisComponent )
1961 : {
1962 0 : pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent );
1963 : }
1964 :
1965 0 : if ( bSetDocMacroMode )
1966 : {
1967 : // remove flag for modal mode
1968 0 : pDoc->SetMacroMode_Impl( sal_False );
1969 0 : }
1970 : }
1971 : else
1972 0 : nErr = ERRCODE_BASIC_PROC_UNDEFINED;
1973 : }
1974 : else
1975 0 : nErr = ERRCODE_IO_NOTEXISTS;
1976 : }
1977 : else
1978 : {
1979 : // direct API call on a specified object
1980 0 : OUStringBuffer aCall;
1981 0 : aCall.append('[').append(INetURLObject::decode(aMacro.Copy(6), INET_HEX_ESCAPE,
1982 0 : INetURLObject::DECODE_WITH_CHARSET));
1983 0 : aCall.append(']');
1984 0 : pAppMgr->GetLib(0)->Execute(aCall.makeStringAndClear());
1985 0 : nErr = SbxBase::GetError();
1986 : }
1987 :
1988 0 : SbxBase::ResetError();
1989 0 : return nErr;
1990 : #endif
1991 : }
1992 :
1993 : /* XServiceInfo */
1994 2 : OUString SAL_CALL SfxAppDispatchProvider::getImplementationName() throw( css::uno::RuntimeException )
1995 : {
1996 2 : return impl_getStaticImplementationName();
1997 : }
1998 :
1999 : /* XServiceInfo */
2000 0 : sal_Bool SAL_CALL SfxAppDispatchProvider::supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException )
2001 : {
2002 0 : css::uno::Sequence< OUString > seqServiceNames = getSupportedServiceNames();
2003 0 : const OUString* pArray = seqServiceNames.getConstArray();
2004 0 : for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
2005 : {
2006 0 : if ( pArray[nCounter] == sServiceName )
2007 : {
2008 0 : return sal_True;
2009 : }
2010 : }
2011 0 : return sal_False;
2012 : }
2013 :
2014 : /* XServiceInfo */
2015 0 : css::uno::Sequence< OUString > SAL_CALL SfxAppDispatchProvider::getSupportedServiceNames() throw( css::uno::RuntimeException )
2016 : {
2017 0 : return impl_getStaticSupportedServiceNames();
2018 : }
2019 :
2020 : /* Helper for XServiceInfo */
2021 31 : css::uno::Sequence< OUString > SfxAppDispatchProvider::impl_getStaticSupportedServiceNames()
2022 : {
2023 31 : css::uno::Sequence< OUString > seqServiceNames( 2 );
2024 31 : seqServiceNames.getArray()[0] = "com.sun.star.frame.DispatchProvider";
2025 31 : seqServiceNames.getArray()[1] = "com.sun.star.frame.AppDispatchProvider";
2026 31 : return seqServiceNames;
2027 : }
2028 :
2029 : /* Helper for XServiceInfo */
2030 317 : OUString SfxAppDispatchProvider::impl_getStaticImplementationName()
2031 : {
2032 317 : return OUString( "com.sun.star.comp.sfx2.AppDispatchProvider" );
2033 : }
2034 :
2035 : /* Helper for registry */
2036 2175 : css::uno::Reference< css::uno::XInterface > SAL_CALL SfxAppDispatchProvider::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception )
2037 : {
2038 2175 : return css::uno::Reference< css::uno::XInterface >( *new SfxAppDispatchProvider( xServiceManager ) );
2039 : }
2040 :
2041 31 : SFX_IMPL_SINGLEFACTORY( SfxAppDispatchProvider );
2042 :
2043 2174 : void SAL_CALL SfxAppDispatchProvider::initialize( const uno::Sequence<uno::Any>& aArguments ) throw (uno::Exception, uno::RuntimeException)
2044 : {
2045 2174 : Reference < XFrame > xFrame;
2046 2174 : if ( aArguments.getLength() )
2047 : {
2048 2173 : aArguments[0] >>= xFrame;
2049 2173 : m_xFrame = xFrame;
2050 2174 : }
2051 2174 : }
2052 :
2053 2176 : Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch(
2054 : const util::URL& aURL,
2055 : const OUString& /*sTargetFrameName*/,
2056 : FrameSearchFlags /*eSearchFlags*/ ) throw( RuntimeException )
2057 : {
2058 2176 : sal_uInt16 nId( 0 );
2059 2176 : sal_Bool bMasterCommand( sal_False );
2060 2176 : Reference < XDispatch > xDisp;
2061 2176 : const SfxSlot* pSlot = 0;
2062 2176 : SfxDispatcher* pAppDisp = SFX_APP()->GetAppDispatcher_Impl();
2063 4352 : if ( aURL.Protocol.compareToAscii( "slot:" ) == COMPARE_EQUAL ||
2064 2176 : aURL.Protocol.compareToAscii( "commandId:" ) == COMPARE_EQUAL )
2065 : {
2066 0 : nId = (sal_uInt16) aURL.Path.toInt32();
2067 : SfxShell* pShell;
2068 0 : pAppDisp->GetShellAndSlot_Impl( nId, &pShell, &pSlot, sal_True, sal_True );
2069 : }
2070 2176 : else if ( aURL.Protocol.compareToAscii( ".uno:" ) == COMPARE_EQUAL )
2071 : {
2072 : // Support ".uno" commands. Map commands to slotid
2073 2176 : bMasterCommand = SfxOfficeDispatch::IsMasterUnoCommand( aURL );
2074 2176 : if ( bMasterCommand )
2075 0 : pSlot = pAppDisp->GetSlot( SfxOfficeDispatch::GetMasterUnoCommand( aURL ) );
2076 : else
2077 2176 : pSlot = pAppDisp->GetSlot( aURL.Main );
2078 : }
2079 :
2080 2176 : if ( pSlot )
2081 : {
2082 72 : SfxOfficeDispatch* pDispatch = new SfxOfficeDispatch( pAppDisp, pSlot, aURL ) ;
2083 72 : pDispatch->SetFrame(m_xFrame);
2084 72 : pDispatch->SetMasterUnoCommand( bMasterCommand );
2085 72 : xDisp = pDispatch;
2086 : }
2087 :
2088 2176 : return xDisp;
2089 : }
2090 :
2091 1 : Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispatches( const Sequence < DispatchDescriptor >& seqDescriptor )
2092 : throw( RuntimeException )
2093 : {
2094 1 : sal_Int32 nCount = seqDescriptor.getLength();
2095 1 : uno::Sequence< uno::Reference < frame::XDispatch > > lDispatcher(nCount);
2096 3 : for( sal_Int32 i=0; i<nCount; ++i )
2097 6 : lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
2098 2 : seqDescriptor[i].FrameName,
2099 4 : seqDescriptor[i].SearchFlags );
2100 1 : return lDispatcher;
2101 : }
2102 :
2103 0 : Sequence< sal_Int16 > SAL_CALL SfxAppDispatchProvider::getSupportedCommandGroups()
2104 : throw (uno::RuntimeException)
2105 : {
2106 0 : SolarMutexGuard aGuard;
2107 :
2108 0 : std::list< sal_Int16 > aGroupList;
2109 0 : SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2110 :
2111 0 : const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2112 :
2113 : // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2114 0 : for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2115 : {
2116 0 : pAppSlotPool->SeekGroup( i );
2117 0 : const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2118 0 : while ( pSfxSlot )
2119 : {
2120 0 : if ( pSfxSlot->GetMode() & nMode )
2121 : {
2122 0 : sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2123 0 : aGroupList.push_back( nCommandGroup );
2124 0 : break;
2125 : }
2126 0 : pSfxSlot = pAppSlotPool->NextSlot();
2127 : }
2128 : }
2129 :
2130 : uno::Sequence< sal_Int16 > aSeq =
2131 0 : comphelper::containerToSequence< sal_Int16, std::list< sal_Int16 > >( aGroupList );
2132 :
2133 0 : return aSeq;
2134 : }
2135 :
2136 0 : Sequence< frame::DispatchInformation > SAL_CALL SfxAppDispatchProvider::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
2137 : throw (uno::RuntimeException)
2138 : {
2139 0 : std::list< frame::DispatchInformation > aCmdList;
2140 :
2141 0 : SolarMutexGuard aGuard;
2142 0 : SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2143 :
2144 0 : if ( pAppSlotPool )
2145 : {
2146 0 : const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2147 0 : OUString aCmdPrefix( ".uno:" );
2148 :
2149 : // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2150 0 : for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2151 : {
2152 0 : pAppSlotPool->SeekGroup( i );
2153 0 : const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2154 0 : if ( pSfxSlot )
2155 : {
2156 0 : sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2157 0 : if ( nCommandGroup == nCmdGroup )
2158 : {
2159 0 : while ( pSfxSlot )
2160 : {
2161 0 : if ( pSfxSlot->GetMode() & nMode )
2162 : {
2163 0 : frame::DispatchInformation aCmdInfo;
2164 0 : OUStringBuffer aBuf( aCmdPrefix );
2165 0 : aBuf.appendAscii( pSfxSlot->GetUnoName() );
2166 0 : aCmdInfo.Command = aBuf.makeStringAndClear();
2167 0 : aCmdInfo.GroupId = nCommandGroup;
2168 0 : aCmdList.push_back( aCmdInfo );
2169 : }
2170 0 : pSfxSlot = pAppSlotPool->NextSlot();
2171 : }
2172 : }
2173 : }
2174 0 : }
2175 : }
2176 :
2177 : uno::Sequence< frame::DispatchInformation > aSeq =
2178 0 : comphelper::containerToSequence< frame::DispatchInformation, std::list< frame::DispatchInformation > >( aCmdList );
2179 :
2180 0 : return aSeq;
2181 : }
2182 :
2183 : #ifdef TEST_HANDLERS
2184 : #include <cppuhelper/implbase2.hxx>
2185 :
2186 : #include <com/sun/star/awt/XKeyHandler.hpp>
2187 : #include <com/sun/star/awt/XMouseClickHandler.hpp>
2188 :
2189 : class TestKeyHandler: public ::cppu::WeakImplHelper2
2190 : <
2191 : com::sun::star::awt::XKeyHandler,
2192 : com::sun::star::lang::XServiceInfo
2193 : >
2194 : {
2195 : public:
2196 : TestKeyHandler( const com::sun::star::uno::Reference < lang::XMultiServiceFactory >& ){}
2197 :
2198 : SFX_DECL_XSERVICEINFO
2199 : virtual sal_Bool SAL_CALL keyPressed( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException);
2200 : virtual sal_Bool SAL_CALL keyReleased( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException);
2201 : virtual void SAL_CALL disposing( const lang::EventObject& Source)
2202 : throw (uno::RuntimeException);
2203 : };
2204 :
2205 : class TestMouseClickHandler: public ::cppu::WeakImplHelper2
2206 : <
2207 : com::sun::star::awt::XMouseClickHandler,
2208 : com::sun::star::lang::XServiceInfo
2209 : >
2210 : {
2211 : public:
2212 : TestMouseClickHandler( const com::sun::star::uno::Reference < lang::XMultiServiceFactory >& ){}
2213 :
2214 : SFX_DECL_XSERVICEINFO
2215 : virtual sal_Bool SAL_CALL mousePressed( const awt::MouseEvent& e ) throw (uno::RuntimeException);
2216 : virtual sal_Bool SAL_CALL mouseReleased( const awt::MouseEvent& e ) throw (uno::RuntimeException);
2217 : virtual void SAL_CALL disposing( const lang::EventObject& Source)
2218 : throw (uno::RuntimeException);
2219 : };
2220 :
2221 : sal_Bool SAL_CALL TestKeyHandler::keyPressed( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException)
2222 : {
2223 : return sal_False;
2224 : }
2225 :
2226 : sal_Bool SAL_CALL TestKeyHandler::keyReleased( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException)
2227 : {
2228 : return sal_False;
2229 : }
2230 :
2231 : void SAL_CALL TestKeyHandler::disposing( const lang::EventObject& Source) throw (uno::RuntimeException)
2232 : {
2233 : }
2234 :
2235 : sal_Bool SAL_CALL TestMouseClickHandler::mousePressed( const awt::MouseEvent& e ) throw (uno::RuntimeException)
2236 : {
2237 : return sal_False;
2238 : }
2239 :
2240 : sal_Bool SAL_CALL TestMouseClickHandler::mouseReleased( const awt::MouseEvent& e ) throw (uno::RuntimeException)
2241 : {
2242 : return sal_False;
2243 : }
2244 :
2245 : void SAL_CALL TestMouseClickHandler::disposing( const lang::EventObject& Source) throw (uno::RuntimeException)
2246 : {
2247 : }
2248 :
2249 : SFX_IMPL_XSERVICEINFO( TestKeyHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.KeyHandler");
2250 : SFX_IMPL_XSERVICEINFO( TestMouseClickHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.MouseClickHandler");
2251 : SFX_IMPL_SINGLEFACTORY( TestKeyHandler );
2252 : SFX_IMPL_SINGLEFACTORY( TestMouseClickHandler );
2253 : #endif
2254 : // -----------------------------------------------------------------------
2255 :
2256 : extern "C" {
2257 :
2258 284 : SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory(
2259 : const sal_Char* pImplementationName ,
2260 : void* pServiceManager ,
2261 : void* )
2262 : {
2263 : // Set default return value for this operation - if it failed.
2264 284 : void* pReturn = NULL ;
2265 :
2266 284 : if (
2267 284 : ( pImplementationName != NULL ) &&
2268 : ( pServiceManager != NULL )
2269 : )
2270 : {
2271 : // Define variables which are used in following macros.
2272 284 : uno::Reference<uno::XInterface> xFactory;
2273 568 : uno::Reference<lang::XMultiServiceFactory> xServiceManager( reinterpret_cast<lang::XMultiServiceFactory*>( pServiceManager ) ) ;
2274 :
2275 : //=============================================================================
2276 : // Add new macro line to handle new service.
2277 : // !!! ATTENTION !!!
2278 : // Write no ";" at end of line and dont forget "else" ! (see macro)
2279 : //=============================================================================
2280 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxGlobalEvents_Impl )
2281 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl )
2282 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxMacroLoader )
2283 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxAppDispatchProvider )
2284 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxDocTplService )
2285 284 : IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon )
2286 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationScriptLibraryContainer )
2287 284 : IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationDialogLibraryContainer )
2288 : #ifdef TEST_HANDLERS
2289 : IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
2290 : IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler )
2291 : #endif
2292 284 : IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator )
2293 284 : IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject )
2294 284 : IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject )
2295 284 : IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService )
2296 568 : if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
2297 568 : OUString::createFromAscii( pImplementationName ) ) )
2298 : {
2299 130 : xFactory = ::cppu::createSingleComponentFactory(
2300 : ::comp_SfxDocumentMetaData::_create,
2301 : ::comp_SfxDocumentMetaData::_getImplementationName(),
2302 65 : ::comp_SfxDocumentMetaData::_getSupportedServiceNames());
2303 : }
2304 568 : if ( ::comp_CompatWriterDocProps::_getImplementationName().equals(
2305 568 : OUString::createFromAscii( pImplementationName ) ) )
2306 : {
2307 0 : xFactory = ::cppu::createSingleComponentFactory(
2308 : ::comp_CompatWriterDocProps::_create,
2309 : ::comp_CompatWriterDocProps::_getImplementationName(),
2310 0 : ::comp_CompatWriterDocProps::_getSupportedServiceNames());
2311 : }
2312 :
2313 : // Factory is valid - service was found.
2314 :
2315 : // Factory is valid - service was found.
2316 284 : if ( xFactory.is() )
2317 : {
2318 284 : xFactory->acquire();
2319 284 : pReturn = xFactory.get();
2320 284 : }
2321 : }
2322 : // Return with result of this operation.
2323 284 : return pReturn ;
2324 : }
2325 : } // extern "C"
2326 :
2327 : //=========================================================================
2328 :
2329 0 : void SAL_CALL FilterOptionsContinuation::setFilterOptions(
2330 : const uno::Sequence<beans::PropertyValue>& rProps )
2331 : throw (uno::RuntimeException)
2332 : {
2333 0 : rProperties = rProps;
2334 0 : }
2335 :
2336 : uno::Sequence< beans::PropertyValue > SAL_CALL
2337 0 : FilterOptionsContinuation::getFilterOptions()
2338 : throw (uno::RuntimeException)
2339 : {
2340 0 : return rProperties;
2341 : }
2342 :
2343 : //=========================================================================
2344 :
2345 0 : RequestFilterOptions::RequestFilterOptions( uno::Reference< frame::XModel > rModel,
2346 0 : uno::Sequence< beans::PropertyValue > rProperties )
2347 : {
2348 0 : OUString temp;
2349 0 : uno::Reference< uno::XInterface > temp2;
2350 : document::FilterOptionsRequest aOptionsRequest( temp,
2351 : temp2,
2352 : rModel,
2353 0 : rProperties );
2354 :
2355 0 : m_aRequest <<= aOptionsRequest;
2356 :
2357 0 : m_pAbort = new comphelper::OInteractionAbort;
2358 0 : m_pOptions = new FilterOptionsContinuation;
2359 :
2360 0 : m_lContinuations.realloc( 2 );
2361 0 : m_lContinuations[0] = uno::Reference< task::XInteractionContinuation >( m_pAbort );
2362 0 : m_lContinuations[1] = uno::Reference< task::XInteractionContinuation >( m_pOptions );
2363 0 : }
2364 :
2365 0 : uno::Any SAL_CALL RequestFilterOptions::getRequest()
2366 : throw( uno::RuntimeException )
2367 : {
2368 0 : return m_aRequest;
2369 : }
2370 :
2371 : uno::Sequence< uno::Reference< task::XInteractionContinuation > >
2372 0 : SAL_CALL RequestFilterOptions::getContinuations()
2373 : throw( uno::RuntimeException )
2374 : {
2375 0 : return m_lContinuations;
2376 : }
2377 :
2378 : //=========================================================================
2379 0 : class RequestPackageReparation_Impl : public ::cppu::WeakImplHelper1< task::XInteractionRequest >
2380 : {
2381 : uno::Any m_aRequest;
2382 : uno::Sequence< uno::Reference< task::XInteractionContinuation > > m_lContinuations;
2383 : comphelper::OInteractionApprove* m_pApprove;
2384 : comphelper::OInteractionDisapprove* m_pDisapprove;
2385 :
2386 : public:
2387 : RequestPackageReparation_Impl( OUString aName );
2388 : sal_Bool isApproved();
2389 : virtual uno::Any SAL_CALL getRequest() throw( uno::RuntimeException );
2390 : virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations()
2391 : throw( uno::RuntimeException );
2392 : };
2393 :
2394 0 : RequestPackageReparation_Impl::RequestPackageReparation_Impl( OUString aName )
2395 : {
2396 0 : OUString temp;
2397 0 : uno::Reference< uno::XInterface > temp2;
2398 : document::BrokenPackageRequest aBrokenPackageRequest( temp,
2399 : temp2,
2400 0 : aName );
2401 0 : m_aRequest <<= aBrokenPackageRequest;
2402 0 : m_pApprove = new comphelper::OInteractionApprove;
2403 0 : m_pDisapprove = new comphelper::OInteractionDisapprove;
2404 0 : m_lContinuations.realloc( 2 );
2405 0 : m_lContinuations[0] = uno::Reference< task::XInteractionContinuation >( m_pApprove );
2406 0 : m_lContinuations[1] = uno::Reference< task::XInteractionContinuation >( m_pDisapprove );
2407 0 : }
2408 :
2409 0 : sal_Bool RequestPackageReparation_Impl::isApproved()
2410 : {
2411 0 : return m_pApprove->wasSelected();
2412 : }
2413 :
2414 0 : uno::Any SAL_CALL RequestPackageReparation_Impl::getRequest()
2415 : throw( uno::RuntimeException )
2416 : {
2417 0 : return m_aRequest;
2418 : }
2419 :
2420 : uno::Sequence< uno::Reference< task::XInteractionContinuation > >
2421 0 : SAL_CALL RequestPackageReparation_Impl::getContinuations()
2422 : throw( uno::RuntimeException )
2423 : {
2424 0 : return m_lContinuations;
2425 : }
2426 :
2427 0 : RequestPackageReparation::RequestPackageReparation( OUString aName )
2428 : {
2429 0 : pImp = new RequestPackageReparation_Impl( aName );
2430 0 : pImp->acquire();
2431 0 : }
2432 :
2433 0 : RequestPackageReparation::~RequestPackageReparation()
2434 : {
2435 0 : pImp->release();
2436 0 : }
2437 :
2438 0 : sal_Bool RequestPackageReparation::isApproved()
2439 : {
2440 0 : return pImp->isApproved();
2441 : }
2442 :
2443 0 : com::sun::star::uno::Reference < task::XInteractionRequest > RequestPackageReparation::GetRequest()
2444 : {
2445 0 : return com::sun::star::uno::Reference < task::XInteractionRequest >(pImp);
2446 : }
2447 :
2448 : //=========================================================================
2449 0 : class NotifyBrokenPackage_Impl : public ::cppu::WeakImplHelper1< task::XInteractionRequest >
2450 : {
2451 : uno::Any m_aRequest;
2452 : uno::Sequence< uno::Reference< task::XInteractionContinuation > > m_lContinuations;
2453 : comphelper::OInteractionAbort* m_pAbort;
2454 :
2455 : public:
2456 : NotifyBrokenPackage_Impl( OUString aName );
2457 : virtual uno::Any SAL_CALL getRequest() throw( uno::RuntimeException );
2458 : virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations()
2459 : throw( uno::RuntimeException );
2460 : };
2461 :
2462 0 : NotifyBrokenPackage_Impl::NotifyBrokenPackage_Impl( OUString aName )
2463 : {
2464 0 : OUString temp;
2465 0 : uno::Reference< uno::XInterface > temp2;
2466 : document::BrokenPackageRequest aBrokenPackageRequest( temp,
2467 : temp2,
2468 0 : aName );
2469 0 : m_aRequest <<= aBrokenPackageRequest;
2470 0 : m_pAbort = new comphelper::OInteractionAbort;
2471 0 : m_lContinuations.realloc( 1 );
2472 0 : m_lContinuations[0] = uno::Reference< task::XInteractionContinuation >( m_pAbort );
2473 0 : }
2474 :
2475 0 : uno::Any SAL_CALL NotifyBrokenPackage_Impl::getRequest()
2476 : throw( uno::RuntimeException )
2477 : {
2478 0 : return m_aRequest;
2479 : }
2480 :
2481 : uno::Sequence< uno::Reference< task::XInteractionContinuation > >
2482 0 : SAL_CALL NotifyBrokenPackage_Impl::getContinuations()
2483 : throw( uno::RuntimeException )
2484 : {
2485 0 : return m_lContinuations;
2486 : }
2487 :
2488 0 : NotifyBrokenPackage::NotifyBrokenPackage( OUString aName )
2489 : {
2490 0 : pImp = new NotifyBrokenPackage_Impl( aName );
2491 0 : pImp->acquire();
2492 0 : }
2493 :
2494 0 : NotifyBrokenPackage::~NotifyBrokenPackage()
2495 : {
2496 0 : pImp->release();
2497 0 : }
2498 :
2499 0 : com::sun::star::uno::Reference < task::XInteractionRequest > NotifyBrokenPackage::GetRequest()
2500 : {
2501 0 : return com::sun::star::uno::Reference < task::XInteractionRequest >(pImp);
2502 408 : }
2503 :
2504 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|