xref: /aoo41x/main/sfx2/source/appl/appuno.cxx (revision 5ba24278)
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             if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME ) == SFX_ITEM_SET )
1091                 nAdditional++;
1092 
1093             // consider additional arguments
1094             nProps += nAdditional;
1095 #ifdef DBG_UTIL
1096             nItems += nAdditional;
1097 #endif
1098         }
1099     }
1100 
1101 #ifdef DBG_UTIL
1102     // now check the itemset: is there any item that is not convertable using the list of formal arguments
1103     // or the table of additional items?!
1104     if ( rSet.Count() != nItems )
1105     {
1106         // detect unknown item and present error message
1107         const sal_uInt16 *pRanges = rSet.GetRanges();
1108         while ( *pRanges )
1109         {
1110             for(sal_uInt16 nId = *pRanges++; nId <= *pRanges; ++nId)
1111             {
1112                 if ( rSet.GetItemState(nId) < SFX_ITEM_SET ) //???
1113                     // not really set
1114                     continue;
1115 
1116                 if ( !pSlot->IsMode(SFX_SLOT_METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1117                     continue;
1118 
1119                 sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1120                 sal_uInt16 nArg;
1121                 for ( nArg=0; nArg<nFormalArgs; ++nArg )
1122                 {
1123                     const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1124                     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1125                     if ( nId == nWhich )
1126                         break;
1127                 }
1128 
1129                 if ( nArg<nFormalArgs )
1130                     continue;
1131 
1132                 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC ||  nSlotId == SID_SAVEDOC ||
1133                      nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
1134                 {
1135                     if ( nId == SID_DOCFRAME )
1136                         continue;
1137                     if ( nId == SID_PROGRESS_STATUSBAR_CONTROL )
1138                         continue;
1139                     if ( nId == SID_INTERACTIONHANDLER )
1140                         continue;
1141                     if ( nId == SID_VIEW_DATA )
1142                         continue;
1143                     if ( nId == SID_FILTER_DATA )
1144                         continue;
1145                     if ( nId == SID_DOCUMENT )
1146                         continue;
1147                     if ( nId == SID_CONTENT )
1148                         continue;
1149                     if ( nId == SID_INPUTSTREAM )
1150                         continue;
1151                     if ( nId == SID_STREAM )
1152                         continue;
1153                     if ( nId == SID_OUTPUTSTREAM )
1154                         continue;
1155                     if ( nId == SID_POSTDATA )
1156                         continue;
1157                     if ( nId == SID_FILLFRAME )
1158                         continue;
1159                     if ( nId == SID_TEMPLATE )
1160                         continue;
1161                     if ( nId == SID_OPEN_NEW_VIEW )
1162                         continue;
1163                     if ( nId == SID_VIEW_ID )
1164                         continue;
1165                     if ( nId == SID_PLUGIN_MODE )
1166                         continue;
1167                     if ( nId == SID_DOC_READONLY )
1168                         continue;
1169                     if ( nId == SID_DOC_STARTPRESENTATION )
1170                         continue;
1171                     if ( nId == SID_SELECTION )
1172                         continue;
1173                     if ( nId == SID_HIDDEN )
1174                         continue;
1175                     if ( nId == SID_MINIMIZED )
1176                         continue;
1177                     if ( nId == SID_SILENT )
1178                         continue;
1179                     if ( nId == SID_PREVIEW )
1180                         continue;
1181                     if ( nId == SID_VIEWONLY )
1182                         continue;
1183                     if ( nId == SID_EDITDOC )
1184                         continue;
1185                     if ( nId == SID_TARGETNAME )
1186                         continue;
1187                     if ( nId == SID_DOC_SALVAGE )
1188                         continue;
1189                     if ( nId == SID_PATH )
1190                         continue;
1191                     if ( nId == SID_FILE_DIALOG )
1192                         continue;
1193                     if ( nId == SID_STANDARD_DIR )
1194                         continue;
1195                     if ( nId == SID_BLACK_LIST )
1196                         continue;
1197                     if ( nId == SID_CONTENTTYPE )
1198                         continue;
1199                     if ( nId == SID_TEMPLATE_NAME )
1200                         continue;
1201                     if ( nId == SID_TEMPLATE_REGIONNAME )
1202                         continue;
1203                     if ( nId == SID_JUMPMARK )
1204                         continue;
1205                     if ( nId == SID_CHARSET )
1206                         continue;
1207                     if ( nId == SID_MACROEXECMODE )
1208                         continue;
1209                     if ( nId == SID_UPDATEDOCMODE )
1210                         continue;
1211                     if ( nId == SID_REPAIRPACKAGE )
1212                         continue;
1213                     if ( nId == SID_DOCINFO_TITLE )
1214                         continue;
1215                     if ( nId == SID_COMPONENTDATA )
1216                         continue;
1217                     if ( nId == SID_COMPONENTCONTEXT )
1218                         continue;
1219                     if ( nId == SID_DOC_BASEURL )
1220                         continue;
1221                     if ( nId == SID_DOC_HIERARCHICALNAME )
1222                         continue;
1223                     if ( nId == SID_COPY_STREAM_IF_POSSIBLE )
1224                         continue;
1225                     if ( nId == SID_NOAUTOSAVE )
1226                         continue;
1227                      if ( nId == SID_ENCRYPTIONDATA )
1228                         continue;
1229 
1230                     // used only internally
1231                     if ( nId == SID_SAVETO )
1232                         continue;
1233                      if ( nId == SID_MODIFYPASSWORDINFO )
1234                         continue;
1235                      if ( nId == SID_SUGGESTEDSAVEASDIR )
1236                         continue;
1237                      if ( nId == SID_SUGGESTEDSAVEASNAME )
1238                         continue;
1239                }
1240 
1241                 ByteString aDbg( "Unknown item detected: ");
1242                 aDbg += ByteString::CreateFromInt32( nId );
1243                 DBG_ASSERT( nArg<nFormalArgs, aDbg.GetBuffer() );
1244             }
1245         }
1246     }
1247 #endif
1248 
1249     if ( !nProps )
1250         return;
1251 
1252     // convert every item into a property
1253     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aSequ( nProps );
1254     ::com::sun::star::beans::PropertyValue *pValue = aSequ.getArray();
1255 
1256     sal_Int32 nActProp=0;
1257     if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
1258     {
1259         // slot is a property
1260         sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
1261         sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1262         SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1263         if ( pItem ) //???
1264         {
1265             sal_uInt16 nSubCount = pType->nAttribs;
1266             if ( !nSubCount )
1267             {
1268                 //rPool.FillVariable( *pItem, *pVar, eUserMetric );
1269                 pValue[nActProp].Name = String( String::CreateFromAscii( pSlot->pUnoName ) ) ;
1270                 if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1271                 {
1272                     ByteString aStr( "Item not convertable: ");
1273                     aStr += ByteString::CreateFromInt32(nSlotId);
1274                     DBG_ERROR( aStr.GetBuffer() );
1275                 }
1276             }
1277             else
1278             {
1279                 // complex type, add a property value for every member of the struct
1280                 for ( sal_uInt16 n=1; n<=nSubCount; ++n )
1281                 {
1282                     //rPool.FillVariable( *pItem, *pVar, eUserMetric );
1283                     sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[n-1].nAID;
1284                     if ( bConvertTwips )
1285                         nSubId |= CONVERT_TWIPS;
1286 
1287                     DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1288                     String aName( String::CreateFromAscii( pSlot->pUnoName ) ) ;
1289                     aName += '.';
1290                     aName += String( String::CreateFromAscii( pType->aAttrib[n-1].pName ) ) ;
1291                     pValue[nActProp].Name = aName;
1292                     if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1293                     {
1294                         ByteString aStr( "Sub item ");
1295                         aStr += ByteString::CreateFromInt32( pType->aAttrib[n-1].nAID );
1296                         aStr += " not convertable in slot: ";
1297                         aStr += ByteString::CreateFromInt32(nSlotId);
1298                         DBG_ERROR( aStr.GetBuffer() );
1299                     }
1300                 }
1301             }
1302         }
1303     }
1304     else
1305     {
1306         // slot is a method
1307         sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1308         for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1309         {
1310             const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1311             sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1312             sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1313             SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1314             if ( pItem ) //???
1315             {
1316                 sal_uInt16 nSubCount = rArg.pType->nAttribs;
1317                 if ( !nSubCount )
1318                 {
1319                     //rPool.FillVariable( *pItem, *pVar, eUserMetric );
1320                     pValue[nActProp].Name = String( String::CreateFromAscii( rArg.pName ) ) ;
1321                     if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1322                     {
1323                         ByteString aStr( "Item not convertable: ");
1324                         aStr += ByteString::CreateFromInt32(rArg.nSlotId);
1325                         DBG_ERROR( aStr.GetBuffer() );
1326                     }
1327                 }
1328                 else
1329                 {
1330                     // complex type, add a property value for every member of the struct
1331                     for ( sal_uInt16 n = 1; n <= nSubCount; ++n )
1332                     {
1333                         //rPool.FillVariable( rItem, *pVar, eUserMetric );
1334                         sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) rArg.pType->aAttrib[n-1].nAID;
1335                         if ( bConvertTwips )
1336                             nSubId |= CONVERT_TWIPS;
1337 
1338                         DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1339                         String aName( String::CreateFromAscii( rArg.pName ) ) ;
1340                         aName += '.';
1341                         aName += String( String::CreateFromAscii( rArg.pType->aAttrib[n-1].pName ) ) ;
1342                         pValue[nActProp].Name = aName;
1343                         if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1344                         {
1345                             ByteString aStr( "Sub item ");
1346                             aStr += ByteString::CreateFromInt32( rArg.pType->aAttrib[n-1].nAID );
1347                             aStr += " not convertable in slot: ";
1348                             aStr += ByteString::CreateFromInt32(rArg.nSlotId);
1349                             DBG_ERROR( aStr.GetBuffer() );
1350                         }
1351                     }
1352                 }
1353             }
1354         }
1355 
1356         if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC ||  nSlotId == SID_SAVEDOC ||
1357              nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
1358         {
1359             const SfxPoolItem *pItem=0;
1360             if ( rSet.GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1361             {
1362                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sComponentData));
1363                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1364             }
1365             if ( rSet.GetItemState( SID_COMPONENTCONTEXT, sal_False, &pItem ) == SFX_ITEM_SET )
1366             {
1367                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sComponentContext));
1368                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1369             }
1370             if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, sal_False, &pItem ) == SFX_ITEM_SET )
1371             {
1372                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sStatusInd));
1373                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1374             }
1375             if ( rSet.GetItemState( SID_INTERACTIONHANDLER, sal_False, &pItem ) == SFX_ITEM_SET )
1376             {
1377                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sInteractionHdl));
1378                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1379             }
1380             if ( rSet.GetItemState( SID_VIEW_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1381             {
1382                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sViewData));
1383                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1384             }
1385             if ( rSet.GetItemState( SID_FILTER_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1386             {
1387                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sFilterData));
1388                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1389             }
1390             if ( rSet.GetItemState( SID_DOCUMENT, sal_False, &pItem ) == SFX_ITEM_SET )
1391             {
1392                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sModel));
1393                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1394             }
1395             if ( rSet.GetItemState( SID_CONTENT, sal_False, &pItem ) == SFX_ITEM_SET )
1396             {
1397                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sUCBContent));
1398                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1399             }
1400             if ( rSet.GetItemState( SID_INPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1401             {
1402                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sInputStream));
1403                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1404             }
1405             if ( rSet.GetItemState( SID_STREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1406             {
1407                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sStream));
1408                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1409             }
1410             if ( rSet.GetItemState( SID_OUTPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1411             {
1412                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sOutputStream));
1413                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1414             }
1415             if ( rSet.GetItemState( SID_POSTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1416             {
1417                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sPostData));
1418                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1419             }
1420             if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1421             {
1422                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sFrame));
1423                 if ( pItem->ISA( SfxUsrAnyItem ) )
1424                 {
1425                     OSL_ENSURE( false, "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" );
1426                     pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue();
1427                 }
1428                 else if ( pItem->ISA( SfxUnoFrameItem ) )
1429                     pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame();
1430                 else
1431                     OSL_ENSURE( false, "TransformItems: invalid item type for SID_FILLFRAME!" );
1432             }
1433             if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET )
1434             {
1435                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sAsTemplate));
1436                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1437             }
1438             if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1439             {
1440                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sOpenNewView));
1441                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1442             }
1443             if ( rSet.GetItemState( SID_VIEW_ID, sal_False, &pItem ) == SFX_ITEM_SET )
1444             {
1445                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sViewId));
1446                 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1447             }
1448             if ( rSet.GetItemState( SID_PLUGIN_MODE, sal_False, &pItem ) == SFX_ITEM_SET )
1449             {
1450                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sPluginMode));
1451                 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1452             }
1453             if ( rSet.GetItemState( SID_DOC_READONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1454             {
1455                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sReadOnly));
1456                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1457             }
1458             if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, sal_False, &pItem ) == SFX_ITEM_SET )
1459             {
1460                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sStartPresentation));
1461                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1462             }
1463             if ( rSet.GetItemState( SID_SELECTION, sal_False, &pItem ) == SFX_ITEM_SET )
1464             {
1465                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sSelectionOnly));
1466                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1467             }
1468             if ( rSet.GetItemState( SID_HIDDEN, sal_False, &pItem ) == SFX_ITEM_SET )
1469             {
1470                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sHidden));
1471                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1472             }
1473             if ( rSet.GetItemState( SID_MINIMIZED, sal_False, &pItem ) == SFX_ITEM_SET )
1474             {
1475                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sMinimized));
1476                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1477             }
1478             if ( rSet.GetItemState( SID_SILENT, sal_False, &pItem ) == SFX_ITEM_SET )
1479             {
1480                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sSilent));
1481                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1482             }
1483             if ( rSet.GetItemState( SID_PREVIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1484             {
1485                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sPreview));
1486                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1487             }
1488             if ( rSet.GetItemState( SID_VIEWONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1489             {
1490                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sViewOnly));
1491                 pValue[nActProp++].Value <<= (sal_Bool) (( ((SfxBoolItem*)pItem)->GetValue() ));
1492             }
1493             if ( rSet.GetItemState( SID_EDITDOC, sal_False, &pItem ) == SFX_ITEM_SET )
1494             {
1495                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sDontEdit));
1496                 pValue[nActProp++].Value <<= (sal_Bool) (!( ((SfxBoolItem*)pItem)->GetValue() ));
1497             }
1498             if ( rSet.GetItemState( SID_FILE_DIALOG, sal_False, &pItem ) == SFX_ITEM_SET )
1499             {
1500                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sUseSystemDialog));
1501                 pValue[nActProp++].Value <<= (sal_Bool) ( ((SfxBoolItem*)pItem)->GetValue() );
1502             }
1503             if ( rSet.GetItemState( SID_STANDARD_DIR, sal_False, &pItem ) == SFX_ITEM_SET )
1504             {
1505                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sStandardDir));
1506                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1507             }
1508             if ( rSet.GetItemState( SID_BLACK_LIST, sal_False, &pItem ) == SFX_ITEM_SET )
1509             {
1510                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sBlackList));
1511 
1512                 com::sun::star::uno::Sequence< rtl::OUString > aList;
1513                 ((SfxStringListItem*)pItem)->GetStringList( aList );
1514                 pValue[nActProp++].Value <<= aList ;
1515             }
1516             if ( rSet.GetItemState( SID_TARGETNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1517             {
1518                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sFrameName));
1519                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1520             }
1521             if ( rSet.GetItemState( SID_DOC_SALVAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1522             {
1523                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sSalvagedFile));
1524                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1525             }
1526             if ( rSet.GetItemState( SID_PATH, sal_False, &pItem ) == SFX_ITEM_SET )
1527             {
1528                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sFolderName));
1529                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1530             }
1531             if ( rSet.GetItemState( SID_CONTENTTYPE, sal_False, &pItem ) == SFX_ITEM_SET )
1532             {
1533                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sMediaType));
1534                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue())  );
1535             }
1536             if ( rSet.GetItemState( SID_TEMPLATE_NAME, sal_False, &pItem ) == SFX_ITEM_SET )
1537             {
1538                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sTemplateName));
1539                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue())  );
1540             }
1541             if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1542             {
1543                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sTemplateRegionName));
1544                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue())  );
1545             }
1546             if ( rSet.GetItemState( SID_JUMPMARK, sal_False, &pItem ) == SFX_ITEM_SET )
1547             {
1548                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sJumpMark));
1549                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue())  );
1550             }
1551 
1552             if ( rSet.GetItemState( SID_CHARSET, sal_False, &pItem ) == SFX_ITEM_SET )
1553             {
1554                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sCharacterSet));
1555                 pValue[nActProp++].Value <<= (  ::rtl::OUString(((SfxStringItem*)pItem)->GetValue())  );
1556             }
1557             if ( rSet.GetItemState( SID_MACROEXECMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1558             {
1559                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sMacroExecMode));
1560                 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1561             }
1562             if ( rSet.GetItemState( SID_UPDATEDOCMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1563             {
1564                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sUpdateDocMode));
1565                 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1566             }
1567             if ( rSet.GetItemState( SID_REPAIRPACKAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1568             {
1569                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sRepairPackage));
1570                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1571             }
1572             if ( rSet.GetItemState( SID_DOCINFO_TITLE, sal_False, &pItem ) == SFX_ITEM_SET )
1573             {
1574                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sDocumentTitle));
1575                 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1576             }
1577             if ( rSet.GetItemState( SID_DOC_BASEURL, sal_False, &pItem ) == SFX_ITEM_SET )
1578             {
1579                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sDocumentBaseURL));
1580                 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1581             }
1582             if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1583             {
1584                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sHierarchicalDocumentName));
1585                 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1586             }
1587             if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, sal_False, &pItem ) == SFX_ITEM_SET )
1588             {
1589                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sCopyStreamIfPossible));
1590                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1591             }
1592             if ( rSet.GetItemState( SID_NOAUTOSAVE, sal_False, &pItem ) == SFX_ITEM_SET )
1593             {
1594                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sNoAutoSave));
1595                 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1596             }
1597             if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, sal_False, &pItem ) == SFX_ITEM_SET )
1598             {
1599                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sModifyPasswordInfo));
1600                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1601             }
1602             if ( rSet.GetItemState( SID_ENCRYPTIONDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1603             {
1604                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sEncryptionData));
1605                 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1606             }
1607             if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, sal_False, &pItem ) == SFX_ITEM_SET )
1608             {
1609                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sSuggestedSaveAsDir));
1610                 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1611             }
1612             if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1613             {
1614                 pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sSuggestedSaveAsName));
1615                 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1616             }
1617         }
1618     }
1619 
1620     rArgs = aSequ;
1621 }
1622 
1623 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 )
1624 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  )
1625 SFX_IMPL_XSERVICEINFO( SfxMacroLoader, PROTOCOLHANDLER_SERVICENAME, "com.sun.star.comp.sfx2.SfxMacroLoader" )
1626 SFX_IMPL_SINGLEFACTORY( SfxMacroLoader )
1627 
1628 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)
1629 {
1630     Reference < XFrame > xFrame;
1631     if ( aArguments.getLength() )
1632     {
1633         aArguments[0] >>= xFrame;
1634         m_xFrame = xFrame;
1635     }
1636 }
1637 
1638 SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
1639 {
1640     SfxObjectShell* pDocShell = NULL;
1641     Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
1642     if ( xFrame.is() )
1643     {
1644         SfxFrame* pFrame=0;
1645         for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
1646         {
1647             if ( pFrame->GetFrameInterface() == xFrame )
1648                 break;
1649         }
1650 
1651         if ( pFrame )
1652             pDocShell = pFrame->GetCurrentDocument();
1653     }
1654 
1655     return pDocShell;
1656 }
1657 
1658 // -----------------------------------------------------------------------
1659 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SfxMacroLoader::queryDispatch(
1660     const ::com::sun::star::util::URL&   aURL            ,
1661     const ::rtl::OUString&               /*sTargetFrameName*/,
1662     sal_Int32                            /*nSearchFlags*/    ) throw( ::com::sun::star::uno::RuntimeException )
1663 {
1664     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatcher;
1665     if(aURL.Complete.compareToAscii("macro:",6)==0)
1666         xDispatcher = this;
1667     return xDispatcher;
1668 }
1669 
1670 // -----------------------------------------------------------------------
1671 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > SAL_CALL
1672                 SfxMacroLoader::queryDispatches( const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor )
1673                     throw( ::com::sun::star::uno::RuntimeException )
1674 {
1675     sal_Int32 nCount = seqDescriptor.getLength();
1676     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > lDispatcher(nCount);
1677     for( sal_Int32 i=0; i<nCount; ++i )
1678         lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1679                                               seqDescriptor[i].FrameName,
1680                                               seqDescriptor[i].SearchFlags );
1681     return lDispatcher;
1682 }
1683 
1684 // -----------------------------------------------------------------------
1685 void SAL_CALL SfxMacroLoader::dispatchWithNotification( const ::com::sun::star::util::URL&                                                          aURL      ,
1686                                                         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&            lArgs     ,
1687                                                         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& xListener )
1688               throw (::com::sun::star::uno::RuntimeException)
1689 {
1690     ::vos::OGuard aGuard( Application::GetSolarMutex() );
1691 
1692     sal_uInt32 nPropertyCount = lArgs.getLength();
1693     ::rtl::OUString aReferer;
1694     for( sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
1695     {
1696         if( lArgs[nProperty].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")) )
1697         {
1698             lArgs[nProperty].Value >>= aReferer;
1699             break;
1700         }
1701     }
1702 
1703     ::com::sun::star::uno::Any aAny;
1704     ErrCode nErr = loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1705     if( xListener.is() )
1706     {
1707         // always call dispatchFinished(), because we didn't load a document but
1708         // executed a macro instead!
1709         ::com::sun::star::frame::DispatchResultEvent aEvent;
1710 
1711         aEvent.Source = static_cast< ::cppu::OWeakObject* >(this);
1712         if( nErr == ERRCODE_NONE )
1713             aEvent.State = ::com::sun::star::frame::DispatchResultState::SUCCESS;
1714         else
1715             aEvent.State = ::com::sun::star::frame::DispatchResultState::FAILURE;
1716 
1717         xListener->dispatchFinished( aEvent ) ;
1718     }
1719 }
1720 
1721 ::com::sun::star::uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue(
1722     const ::com::sun::star::util::URL& aURL,
1723     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& ) throw (::com::sun::star::uno::RuntimeException)
1724 {
1725     ::com::sun::star::uno::Any aRet;
1726         /*ErrCode nErr = */loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() );
1727     return aRet;
1728 }
1729 
1730 // -----------------------------------------------------------------------
1731 void SAL_CALL SfxMacroLoader::dispatch( const ::com::sun::star::util::URL&                                               aURL  ,
1732                                         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs )
1733               throw (::com::sun::star::uno::RuntimeException)
1734 {
1735     ::vos::OGuard aGuard( Application::GetSolarMutex() );
1736 
1737     sal_uInt32 nPropertyCount = lArgs.getLength();
1738     ::rtl::OUString aReferer;
1739     for( sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
1740     {
1741         if( lArgs[nProperty].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")) )
1742         {
1743             lArgs[nProperty].Value >>= aReferer;
1744             break;
1745         }
1746     }
1747 
1748     ::com::sun::star::uno::Any aAny;
1749     /*ErrCode nErr = */loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1750 }
1751 
1752 // -----------------------------------------------------------------------
1753 void SAL_CALL SfxMacroLoader::addStatusListener(
1754     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& ,
1755     const ::com::sun::star::util::URL&                                                    )
1756               throw (::com::sun::star::uno::RuntimeException)
1757 {
1758     /* TODO
1759             How we can handle different listener for further coming or currently running dispatch() jobs
1760             without any inconsistency!
1761      */
1762 }
1763 
1764 // -----------------------------------------------------------------------
1765 void SAL_CALL SfxMacroLoader::removeStatusListener(
1766     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >&,
1767     const ::com::sun::star::util::URL&                                                  )
1768         throw (::com::sun::star::uno::RuntimeException)
1769 {
1770 }
1771 
1772 ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star::uno::Any& rRetval, SfxObjectShell* pSh )
1773     throw ( ::com::sun::star::uno::RuntimeException )
1774 {
1775     SfxObjectShell* pCurrent = pSh;
1776     if ( !pCurrent )
1777         // all not full qualified names use the BASIC of the given or current document
1778         pCurrent = SfxObjectShell::Current();
1779 
1780     // 'macro:///lib.mod.proc(args)' => macro of App-BASIC
1781     // 'macro://[docname|.]/lib.mod.proc(args)' => macro of current or qualified document
1782     // 'macro://obj.method(args)' => direct API call, execute it via App-BASIC
1783     String aMacro( rURL );
1784     sal_uInt16 nHashPos = aMacro.Search( '/', 8 );
1785     sal_uInt16 nArgsPos = aMacro.Search( '(' );
1786     BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
1787     BasicManager *pBasMgr = 0;
1788     ErrCode nErr = ERRCODE_NONE;
1789 
1790     // should a macro function be executed ( no direct API call)?
1791     if ( STRING_NOTFOUND != nHashPos && nHashPos < nArgsPos )
1792     {
1793         // find BasicManager
1794         SfxObjectShell* pDoc = NULL;
1795         String aBasMgrName( INetURLObject::decode(aMacro.Copy( 8, nHashPos-8 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1796         if ( !aBasMgrName.Len() )
1797             pBasMgr = pAppMgr;
1798         else if ( aBasMgrName.EqualsAscii(".") )
1799         {
1800             // current/actual document
1801             pDoc = pCurrent;
1802             if (pDoc)
1803                 pBasMgr = pDoc->GetBasicManager();
1804         }
1805         else
1806         {
1807             // full qualified name, find document by name
1808             for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
1809                     pObjSh && !pBasMgr;
1810                     pObjSh = SfxObjectShell::GetNext(*pObjSh) )
1811                 if ( aBasMgrName == pObjSh->GetTitle(SFX_TITLE_APINAME) )
1812                 {
1813                     pDoc = pObjSh;
1814                     pBasMgr = pDoc->GetBasicManager();
1815                 }
1816         }
1817 
1818         if ( pBasMgr )
1819         {
1820             const bool bIsAppBasic = ( pBasMgr == pAppMgr );
1821             const bool bIsDocBasic = ( pBasMgr != pAppMgr );
1822 
1823             if ( pDoc )
1824             {
1825                 // security check for macros from document basic if an SFX doc is given
1826                 if ( !pDoc->AdjustMacroMode( String() ) )
1827                     // check forbids execution
1828                     return ERRCODE_IO_ACCESSDENIED;
1829             }
1830             else if ( pDoc && pDoc->GetMedium() )
1831             {
1832                 pDoc->AdjustMacroMode( String() );
1833                 SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
1834                 SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False);
1835                 if ( pUpdateDocItem && pMacroExecModeItem
1836                   && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE
1837                   && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE )
1838                     return ERRCODE_IO_ACCESSDENIED;
1839             }
1840 
1841             // find BASIC method
1842             String aQualifiedMethod( INetURLObject::decode(aMacro.Copy( nHashPos+1 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1843             String aArgs;
1844             if ( STRING_NOTFOUND != nArgsPos )
1845             {
1846                 // remove arguments from macro name
1847                 aArgs = aQualifiedMethod.Copy( nArgsPos - nHashPos - 1 );
1848                 aQualifiedMethod.Erase( nArgsPos - nHashPos - 1 );
1849             }
1850 
1851             if ( pBasMgr->HasMacro( aQualifiedMethod ) )
1852             {
1853                 Any aOldThisComponent;
1854                 const bool bSetDocMacroMode = ( pDoc != NULL ) && bIsDocBasic;
1855                 const bool bSetGlobalThisComponent = ( pDoc != NULL ) && bIsAppBasic;
1856                 if ( bSetDocMacroMode )
1857                 {
1858                     // mark document: it executes an own macro, so it's in a modal mode
1859                     pDoc->SetMacroMode_Impl( sal_True );
1860                 }
1861 
1862                 if ( bSetGlobalThisComponent )
1863                 {
1864                     // document is executed via AppBASIC, adjust ThisComponent variable
1865                     aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pDoc->GetModel() ) );
1866                 }
1867 
1868                 // just to let the shell be alive
1869                 SfxObjectShellRef xKeepDocAlive = pDoc;
1870 
1871                 {
1872                     // attempt to protect the document against the script tampering with its Undo Context
1873                     ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
1874                     if ( bIsDocBasic )
1875                         pUndoGuard.reset( new ::framework::DocumentUndoGuard( pDoc->GetModel() ) );
1876 
1877                     // execute the method
1878                     SbxVariableRef retValRef = new SbxVariable;
1879                     nErr = pBasMgr->ExecuteMacro( aQualifiedMethod, aArgs, retValRef );
1880                     if ( nErr == ERRCODE_NONE )
1881                         rRetval = sbxToUnoValue( retValRef );
1882                 }
1883 
1884                 if ( bSetGlobalThisComponent )
1885                 {
1886                     pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent );
1887                 }
1888 
1889                 if ( bSetDocMacroMode )
1890                 {
1891                     // remove flag for modal mode
1892                     pDoc->SetMacroMode_Impl( sal_False );
1893                 }
1894             }
1895             else
1896                 nErr = ERRCODE_BASIC_PROC_UNDEFINED;
1897         }
1898         else
1899             nErr = ERRCODE_IO_NOTEXISTS;
1900     }
1901     else
1902     {
1903         // direct API call on a specified object
1904         String aCall( '[' );
1905         aCall += String(INetURLObject::decode(aMacro.Copy(6), INET_HEX_ESCAPE,
1906         INetURLObject::DECODE_WITH_CHARSET));
1907         aCall += ']';
1908         pAppMgr->GetLib(0)->Execute( aCall );
1909         nErr = SbxBase::GetError();
1910     }
1911 
1912     SbxBase::ResetError();
1913     return nErr;
1914 }
1915 
1916 SFX_IMPL_XSERVICEINFO( SfxAppDispatchProvider, "com.sun.star.frame.DispatchProvider", "com.sun.star.comp.sfx2.AppDispatchProvider" )                                                                \
1917 SFX_IMPL_SINGLEFACTORY( SfxAppDispatchProvider );
1918 
1919 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)
1920 {
1921     Reference < XFrame > xFrame;
1922     if ( aArguments.getLength() )
1923     {
1924         aArguments[0] >>= xFrame;
1925         m_xFrame = xFrame;
1926     }
1927 }
1928 
1929 Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch(
1930     const ::com::sun::star::util::URL& aURL,
1931     const ::rtl::OUString& /*sTargetFrameName*/,
1932     FrameSearchFlags /*eSearchFlags*/ ) throw( RuntimeException )
1933 {
1934     sal_uInt16                  nId( 0 );
1935     sal_Bool                bMasterCommand( sal_False );
1936     Reference < XDispatch > xDisp;
1937     const SfxSlot* pSlot = 0;
1938     SfxDispatcher* pAppDisp = SFX_APP()->GetAppDispatcher_Impl();
1939     if ( aURL.Protocol.compareToAscii( "slot:" ) == COMPARE_EQUAL ||
1940          aURL.Protocol.compareToAscii( "commandId:" ) == COMPARE_EQUAL )
1941     {
1942         nId = (sal_uInt16) aURL.Path.toInt32();
1943         SfxShell* pShell;
1944         pAppDisp->GetShellAndSlot_Impl( nId, &pShell, &pSlot, sal_True, sal_True );
1945     }
1946     else if ( aURL.Protocol.compareToAscii( ".uno:" ) == COMPARE_EQUAL )
1947     {
1948         // Support ".uno" commands. Map commands to slotid
1949         bMasterCommand = SfxOfficeDispatch::IsMasterUnoCommand( aURL );
1950         if ( bMasterCommand )
1951             pSlot = pAppDisp->GetSlot( SfxOfficeDispatch::GetMasterUnoCommand( aURL ) );
1952         else
1953             pSlot = pAppDisp->GetSlot( aURL.Main );
1954     }
1955 
1956     if ( pSlot )
1957     {
1958         SfxOfficeDispatch* pDispatch = new SfxOfficeDispatch( pAppDisp, pSlot, aURL ) ;
1959         pDispatch->SetFrame(m_xFrame);
1960         pDispatch->SetMasterUnoCommand( bMasterCommand );
1961         xDisp = pDispatch;
1962     }
1963 
1964     return xDisp;
1965 }
1966 
1967 Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispatches( const Sequence < DispatchDescriptor >& seqDescriptor )
1968 throw( RuntimeException )
1969 {
1970     sal_Int32 nCount = seqDescriptor.getLength();
1971     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > lDispatcher(nCount);
1972     for( sal_Int32 i=0; i<nCount; ++i )
1973         lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1974                                               seqDescriptor[i].FrameName,
1975                                               seqDescriptor[i].SearchFlags );
1976     return lDispatcher;
1977 }
1978 
1979 Sequence< sal_Int16 > SAL_CALL SfxAppDispatchProvider::getSupportedCommandGroups()
1980 throw (::com::sun::star::uno::RuntimeException)
1981 {
1982     ::vos::OGuard aGuard( Application::GetSolarMutex() );
1983 
1984     std::list< sal_Int16 > aGroupList;
1985     SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
1986 
1987     const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
1988 
1989     // Gruppe anw"ahlen ( Gruppe 0 ist intern )
1990     for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
1991     {
1992         String aName = pAppSlotPool->SeekGroup( i );
1993         const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
1994         while ( pSfxSlot )
1995         {
1996             if ( pSfxSlot->GetMode() & nMode )
1997             {
1998                 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
1999                 aGroupList.push_back( nCommandGroup );
2000                 break;
2001             }
2002             pSfxSlot = pAppSlotPool->NextSlot();
2003         }
2004     }
2005 
2006     ::com::sun::star::uno::Sequence< sal_Int16 > aSeq =
2007         comphelper::containerToSequence< sal_Int16, std::list< sal_Int16 > >( aGroupList );
2008 
2009     return aSeq;
2010 }
2011 
2012 Sequence< ::com::sun::star::frame::DispatchInformation > SAL_CALL SfxAppDispatchProvider::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
2013 throw (::com::sun::star::uno::RuntimeException)
2014 {
2015     std::list< ::com::sun::star::frame::DispatchInformation > aCmdList;
2016 
2017     ::vos::OGuard aGuard( Application::GetSolarMutex() );
2018     SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2019 
2020     if ( pAppSlotPool )
2021     {
2022         const sal_uIntPtr   nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2023         rtl::OUString aCmdPrefix( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ));
2024 
2025         // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2026         for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2027         {
2028             String aName = pAppSlotPool->SeekGroup( i );
2029             const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2030             if ( pSfxSlot )
2031             {
2032                 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2033                 if ( nCommandGroup == nCmdGroup )
2034                 {
2035                     while ( pSfxSlot )
2036                     {
2037                         if ( pSfxSlot->GetMode() & nMode )
2038                         {
2039                             ::com::sun::star::frame::DispatchInformation aCmdInfo;
2040                             ::rtl::OUStringBuffer aBuf( aCmdPrefix );
2041                             aBuf.appendAscii( pSfxSlot->GetUnoName() );
2042                             aCmdInfo.Command = aBuf.makeStringAndClear();
2043                             aCmdInfo.GroupId = nCommandGroup;
2044                             aCmdList.push_back( aCmdInfo );
2045                         }
2046                         pSfxSlot = pAppSlotPool->NextSlot();
2047                     }
2048                 }
2049             }
2050         }
2051     }
2052 
2053     ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
2054         comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aCmdList );
2055 
2056     return aSeq;
2057 }
2058 
2059 #ifdef TEST_HANDLERS
2060 #include <cppuhelper/implbase2.hxx>
2061 
2062 #include <com/sun/star/awt/XKeyHandler.hdl>
2063 #include <com/sun/star/awt/XMouseClickHandler.hdl>
2064 
2065 class TestKeyHandler: public ::cppu::WeakImplHelper2
2066 <
2067     com::sun::star::awt::XKeyHandler,
2068     com::sun::star::lang::XServiceInfo
2069 >
2070 {
2071 public:
2072     TestKeyHandler( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& ){}
2073 
2074     SFX_DECL_XSERVICEINFO
2075     virtual sal_Bool SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
2076     virtual sal_Bool SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
2077     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source)
2078         throw (::com::sun::star::uno::RuntimeException);
2079 };
2080 
2081 class TestMouseClickHandler: public ::cppu::WeakImplHelper2
2082 <
2083     com::sun::star::awt::XMouseClickHandler,
2084     com::sun::star::lang::XServiceInfo
2085 >
2086 {
2087 public:
2088     TestMouseClickHandler( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& ){}
2089 
2090     SFX_DECL_XSERVICEINFO
2091     virtual sal_Bool SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
2092     virtual sal_Bool SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
2093     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source)
2094         throw (::com::sun::star::uno::RuntimeException);
2095 };
2096 
2097 sal_Bool SAL_CALL TestKeyHandler::keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
2098 {
2099     return sal_False;
2100 }
2101 
2102 sal_Bool SAL_CALL TestKeyHandler::keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
2103 {
2104     return sal_False;
2105 }
2106 
2107 void SAL_CALL TestKeyHandler::disposing( const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException)
2108 {
2109 }
2110 
2111 sal_Bool SAL_CALL TestMouseClickHandler::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException)
2112 {
2113     return sal_False;
2114 }
2115 
2116 sal_Bool SAL_CALL TestMouseClickHandler::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException)
2117 {
2118     return sal_False;
2119 }
2120 
2121 void SAL_CALL TestMouseClickHandler::disposing( const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException)
2122 {
2123 }
2124 
2125 SFX_IMPL_XSERVICEINFO( TestKeyHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.KeyHandler");
2126 SFX_IMPL_XSERVICEINFO( TestMouseClickHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.MouseClickHandler");
2127 SFX_IMPL_SINGLEFACTORY( TestKeyHandler );
2128 SFX_IMPL_SINGLEFACTORY( TestMouseClickHandler );
2129 #endif
2130 // -----------------------------------------------------------------------
2131 
2132 extern "C" {
2133 
2134 SFX2_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
2135     const sal_Char**  ppEnvironmentTypeName	,
2136     uno_Environment** )
2137 {
2138     *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
2139 }
2140 
2141 SFX2_DLLPUBLIC void* SAL_CALL component_getFactory(
2142     const sal_Char*	pImplementationName	,
2143     void*           pServiceManager		,
2144     void*		                          )
2145 {
2146     // Set default return value for this operation - if it failed.
2147     void* pReturn = NULL ;
2148 
2149     if	(
2150             ( pImplementationName	!=	NULL ) &&
2151             ( pServiceManager		!=	NULL )
2152         )
2153     {
2154         // Define variables which are used in following macros.
2155         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
2156               xFactory;
2157         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >	xServiceManager( reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ) )	;
2158 
2159         //=============================================================================
2160         //  Add new macro line to handle new service.
2161         //
2162         //	!!! ATTENTION !!!
2163         //		Write no ";" at end of line and dont forget "else" ! (see macro)
2164         //=============================================================================
2165         IF_NAME_CREATECOMPONENTFACTORY( SfxGlobalEvents_Impl )
2166         IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl )
2167         IF_NAME_CREATECOMPONENTFACTORY( SfxMacroLoader )
2168         IF_NAME_CREATECOMPONENTFACTORY( SfxStandaloneDocumentInfoObject )
2169         IF_NAME_CREATECOMPONENTFACTORY( SfxAppDispatchProvider )
2170         IF_NAME_CREATECOMPONENTFACTORY( SfxDocTplService )
2171         IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon )
2172         IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationScriptLibraryContainer )
2173         IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationDialogLibraryContainer )
2174 #ifdef TEST_HANDLERS
2175         IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
2176         IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler )
2177 #endif
2178         IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator )
2179         #if 0
2180         if ( ::sfx2::AppletObject::impl_getStaticImplementationName().equals(
2181                  ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2182         {
2183             xFactory = ::sfx2::AppletObject::impl_createFactory();
2184         }
2185         #endif
2186         IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject )
2187         IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject )
2188         IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService )
2189         if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
2190                  ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2191         {
2192             xFactory = ::cppu::createSingleComponentFactory(
2193             ::comp_SfxDocumentMetaData::_create,
2194             ::comp_SfxDocumentMetaData::_getImplementationName(),
2195             ::comp_SfxDocumentMetaData::_getSupportedServiceNames());
2196         }
2197 
2198         // Factory is valid - service was found.
2199         if ( xFactory.is() )
2200         {
2201             xFactory->acquire();
2202             pReturn = xFactory.get();
2203         }
2204     }
2205     // Return with result of this operation.
2206     return pReturn ;
2207 }
2208 } // extern "C"
2209 
2210 //=========================================================================
2211 
2212 void SAL_CALL FilterOptionsContinuation::setFilterOptions(
2213                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps )
2214         throw (::com::sun::star::uno::RuntimeException)
2215 {
2216     rProperties = rProps;
2217 }
2218 
2219 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
2220     FilterOptionsContinuation::getFilterOptions()
2221         throw (::com::sun::star::uno::RuntimeException)
2222 {
2223     return rProperties;
2224 }
2225 
2226 //=========================================================================
2227 
2228 RequestFilterOptions::RequestFilterOptions( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > rModel,
2229                               ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > rProperties )
2230 {
2231     ::rtl::OUString temp;
2232     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2233     ::com::sun::star::document::FilterOptionsRequest aOptionsRequest( temp,
2234                                                                       temp2,
2235                                                                       rModel,
2236                                                                       rProperties );
2237 
2238     m_aRequest <<= aOptionsRequest;
2239 
2240     m_pAbort  = new comphelper::OInteractionAbort;
2241     m_pOptions = new FilterOptionsContinuation;
2242 
2243     m_lContinuations.realloc( 2 );
2244     m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort  );
2245     m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pOptions );
2246 }
2247 
2248 ::com::sun::star::uno::Any SAL_CALL RequestFilterOptions::getRequest()
2249         throw( ::com::sun::star::uno::RuntimeException )
2250 {
2251     return m_aRequest;
2252 }
2253 
2254 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2255     SAL_CALL RequestFilterOptions::getContinuations()
2256         throw( ::com::sun::star::uno::RuntimeException )
2257 {
2258     return m_lContinuations;
2259 }
2260 
2261 //=========================================================================
2262 class RequestPackageReparation_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
2263 {
2264     ::com::sun::star::uno::Any m_aRequest;
2265     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
2266     comphelper::OInteractionApprove* m_pApprove;
2267     comphelper::OInteractionDisapprove*  m_pDisapprove;
2268 
2269 public:
2270     RequestPackageReparation_Impl( ::rtl::OUString aName );
2271     sal_Bool    isApproved();
2272     virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException );
2273     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations()
2274 		throw( ::com::sun::star::uno::RuntimeException );
2275 };
2276 
2277 RequestPackageReparation_Impl::RequestPackageReparation_Impl( ::rtl::OUString aName )
2278 {
2279 	::rtl::OUString temp;
2280 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2281 	::com::sun::star::document::BrokenPackageRequest aBrokenPackageRequest( temp,
2282                                                        				  		temp2,
2283 																	  		aName );
2284    	m_aRequest <<= aBrokenPackageRequest;
2285     m_pApprove = new comphelper::OInteractionApprove;
2286     m_pDisapprove = new comphelper::OInteractionDisapprove;
2287    	m_lContinuations.realloc( 2 );
2288    	m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pApprove );
2289    	m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pDisapprove );
2290 }
2291 
2292 sal_Bool RequestPackageReparation_Impl::isApproved()
2293 {
2294     return m_pApprove->wasSelected();
2295 }
2296 
2297 ::com::sun::star::uno::Any SAL_CALL RequestPackageReparation_Impl::getRequest()
2298 		throw( ::com::sun::star::uno::RuntimeException )
2299 {
2300 	return m_aRequest;
2301 }
2302 
2303 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2304     SAL_CALL RequestPackageReparation_Impl::getContinuations()
2305 		throw( ::com::sun::star::uno::RuntimeException )
2306 {
2307 	return m_lContinuations;
2308 }
2309 
2310 RequestPackageReparation::RequestPackageReparation( ::rtl::OUString aName )
2311 {
2312     pImp = new RequestPackageReparation_Impl( aName );
2313     pImp->acquire();
2314 }
2315 
2316 RequestPackageReparation::~RequestPackageReparation()
2317 {
2318     pImp->release();
2319 }
2320 
2321 sal_Bool RequestPackageReparation::isApproved()
2322 {
2323     return pImp->isApproved();
2324 }
2325 
2326 com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest > RequestPackageReparation::GetRequest()
2327 {
2328     return com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest >(pImp);
2329 }
2330 
2331 //=========================================================================
2332 class NotifyBrokenPackage_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
2333 {
2334     ::com::sun::star::uno::Any m_aRequest;
2335     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
2336     comphelper::OInteractionAbort*  m_pAbort;
2337 
2338 public:
2339     NotifyBrokenPackage_Impl( ::rtl::OUString aName );
2340     sal_Bool    isAborted();
2341     virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException );
2342     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations()
2343 		throw( ::com::sun::star::uno::RuntimeException );
2344 };
2345 
2346 NotifyBrokenPackage_Impl::NotifyBrokenPackage_Impl( ::rtl::OUString aName )
2347 {
2348 	::rtl::OUString temp;
2349 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2350 	::com::sun::star::document::BrokenPackageRequest aBrokenPackageRequest( temp,
2351                                                        				  		temp2,
2352 																	  		aName );
2353    	m_aRequest <<= aBrokenPackageRequest;
2354     m_pAbort  = new comphelper::OInteractionAbort;
2355    	m_lContinuations.realloc( 1 );
2356    	m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort  );
2357 }
2358 
2359 sal_Bool NotifyBrokenPackage_Impl::isAborted()
2360 {
2361     return m_pAbort->wasSelected();
2362 }
2363 
2364 ::com::sun::star::uno::Any SAL_CALL NotifyBrokenPackage_Impl::getRequest()
2365 		throw( ::com::sun::star::uno::RuntimeException )
2366 {
2367 	return m_aRequest;
2368 }
2369 
2370 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2371     SAL_CALL NotifyBrokenPackage_Impl::getContinuations()
2372 		throw( ::com::sun::star::uno::RuntimeException )
2373 {
2374 	return m_lContinuations;
2375 }
2376 
2377 NotifyBrokenPackage::NotifyBrokenPackage( ::rtl::OUString aName )
2378 {
2379     pImp = new NotifyBrokenPackage_Impl( aName );
2380     pImp->acquire();
2381 }
2382 
2383 NotifyBrokenPackage::~NotifyBrokenPackage()
2384 {
2385     pImp->release();
2386 }
2387 
2388 sal_Bool NotifyBrokenPackage::isAborted()
2389 {
2390     return pImp->isAborted();
2391 }
2392 
2393 com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest > NotifyBrokenPackage::GetRequest()
2394 {
2395     return com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest >(pImp);
2396 }
2397 
2398