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