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