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