1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <fltoptint.hxx>
21 #include <sfx2/brokenpackageint.hxx>
22 #include <sfx2/docfile.hxx>
23 #include <sfx2/frame.hxx>
24 #include <sfx2/msg.hxx>
25 #include <sfx2/msgpool.hxx>
26 #include <sfx2/sfxsids.hrc>
27 #include <sfx2/sfxuno.hxx>
28 #include <sfxslots.hxx>
29 
30 #include <sal/config.h>
31 #include <sal/log.hxx>
32 #include <comphelper/interaction.hxx>
33 #include <osl/diagnose.h>
34 #include <svl/eitem.hxx>
35 #include <svl/intitem.hxx>
36 #include <svl/itempool.hxx>
37 #include <svl/slstitm.hxx>
38 #include <svl/stritem.hxx>
39 #include <tools/debug.hxx>
40 #include <cppuhelper/implbase.hxx>
41 
42 #include <com/sun/star/document/BrokenPackageRequest.hpp>
43 #include <com/sun/star/document/FilterOptionsRequest.hpp>
44 #include <com/sun/star/frame/XFrame.hpp>
45 #include <com/sun/star/frame/XModel.hpp>
46 #include <com/sun/star/io/XInputStream.hpp>
47 #include <com/sun/star/io/XOutputStream.hpp>
48 #include <com/sun/star/task/XInteractionHandler.hpp>
49 #include <com/sun/star/task/XStatusIndicator.hpp>
50 #include <com/sun/star/ucb/XContent.hpp>
51 
52 #include <memory>
53 
54 using namespace ::com::sun::star;
55 using namespace ::com::sun::star::ucb;
56 using namespace ::com::sun::star::uno;
57 using namespace ::com::sun::star::frame;
58 using namespace ::com::sun::star::beans;
59 using namespace ::com::sun::star::io;
60 
61 // needs to be converted to a better data structure
62 SfxFormalArgument const aFormalArgs[] = {
63     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "SuggestedSaveAsName", SID_DEFAULTFILENAME },
64     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "SuggestedSaveAsDir", SID_DEFAULTFILEPATH },
65     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "VersionAuthor", SID_DOCINFO_AUTHOR },
66     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "VersionComment", SID_DOCINFO_COMMENTS },
67     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "DontTerminateEdit", FN_PARAM_1 },
68     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "VersionMajor", SID_DOCINFO_MAJOR },
69     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "FilterOptions", SID_FILE_FILTEROPTIONS },
70     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "FilterName", SID_FILTER_NAME },
71     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Margin1", SID_RULER_MARGIN1 },
72     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Margin2", SID_RULER_MARGIN2 },
73 //    { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "FileName", SID_FILE_NAME },
74     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "URL", SID_FILE_NAME },
75     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "OpenFlags", SID_OPTIONS },
76     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "Overwrite", SID_OVERWRITE },
77     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Password", SID_PASSWORD },
78     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "PasswordInteraction", SID_PASSWORDINTERACTION },
79     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Referer", SID_REFERER },
80     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveTo", SID_SAVETO },
81     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "TemplateName", SID_TEMPLATE_NAME },
82     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "TemplateRegion", SID_TEMPLATE_REGIONNAME },
83 //    { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Region", SID_TEMPLATE_REGIONNAME },
84 //    { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Name", SID_TEMPLATE_NAME },
85     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "Unpacked", SID_UNPACK },
86     { reinterpret_cast<SfxType*>(&aSfxInt16Item_Impl), "Version", SID_VERSION },
87     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveACopy", SID_SAVEACOPYITEM },
88     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoFileSync", SID_NO_FILE_SYNC },
89     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoThumbnail", SID_NO_THUMBNAIL },
90     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoEmbDataSet", SID_NO_EMBEDDED_DS },
91     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "IsRedactMode", SID_IS_REDACT_MODE },
92     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "RedactionStyle", SID_REDACTION_STYLE },
93     { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "AdditionsTag", SID_ADDITIONS_TAG },
94 };
95 
96 sal_uInt16 const nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
97 
98 constexpr OUStringLiteral sTemplateRegionName = u"TemplateRegionName";
99 constexpr OUStringLiteral sTemplateName = u"TemplateName";
100 constexpr OUStringLiteral sAsTemplate = u"AsTemplate";
101 constexpr OUStringLiteral sOpenNewView = u"OpenNewView";
102 constexpr OUStringLiteral sViewId = u"ViewId";
103 constexpr OUStringLiteral sPluginMode = u"PluginMode";
104 constexpr OUStringLiteral sReadOnly = u"ReadOnly";
105 constexpr OUStringLiteral sDdeReconnect = u"DDEReconnect";
106 constexpr OUStringLiteral sStartPresentation = u"StartPresentation";
107 constexpr OUStringLiteral sFrameName = u"FrameName";
108 constexpr OUStringLiteral sMediaType = u"MediaType";
109 constexpr OUStringLiteral sPostData = u"PostData";
110 constexpr OUStringLiteral sCharacterSet = u"CharacterSet";
111 constexpr OUStringLiteral sInputStream = u"InputStream";
112 constexpr OUStringLiteral sStream = u"Stream";
113 constexpr OUStringLiteral sOutputStream = u"OutputStream";
114 constexpr OUStringLiteral sHidden = u"Hidden";
115 constexpr OUStringLiteral sPreview = u"Preview";
116 constexpr OUStringLiteral sViewOnly = u"ViewOnly";
117 constexpr OUStringLiteral sDontEdit = u"DontEdit";
118 constexpr OUStringLiteral sSilent = u"Silent";
119 constexpr OUStringLiteral sJumpMark = u"JumpMark";
120 constexpr OUStringLiteral sSalvagedFile = u"SalvagedFile";
121 constexpr OUStringLiteral sStatusInd = u"StatusIndicator";
122 constexpr OUStringLiteral sModel = u"Model";
123 constexpr OUStringLiteral sFrame = u"Frame";
124 constexpr OUStringLiteral sViewData = u"ViewData";
125 constexpr OUStringLiteral sFilterData = u"FilterData";
126 constexpr OUStringLiteral sSelectionOnly = u"SelectionOnly";
127 constexpr OUStringLiteral sMacroExecMode = u"MacroExecutionMode";
128 constexpr OUStringLiteral sUpdateDocMode = u"UpdateDocMode";
129 constexpr OUStringLiteral sMinimized = u"Minimized";
130 constexpr OUStringLiteral sInteractionHdl = u"InteractionHandler";
131 constexpr OUStringLiteral sUCBContent = u"UCBContent";
132 constexpr OUStringLiteral sRepairPackage = u"RepairPackage";
133 constexpr OUStringLiteral sDocumentTitle = u"DocumentTitle";
134 constexpr OUStringLiteral sComponentData = u"ComponentData";
135 constexpr OUStringLiteral sComponentContext = u"ComponentContext";
136 constexpr OUStringLiteral sDocumentBaseURL = u"DocumentBaseURL";
137 constexpr OUStringLiteral sHierarchicalDocumentName = u"HierarchicalDocumentName";
138 constexpr OUStringLiteral sCopyStreamIfPossible = u"CopyStreamIfPossible";
139 constexpr OUStringLiteral sNoAutoSave = u"NoAutoSave";
140 constexpr OUStringLiteral sFolderName = u"FolderName";
141 constexpr OUStringLiteral sUseSystemDialog = u"UseSystemDialog";
142 constexpr OUStringLiteral sStandardDir = u"StandardDir";
143 constexpr OUStringLiteral sDenyList = u"DenyList";
144 constexpr OUStringLiteral sModifyPasswordInfo = u"ModifyPasswordInfo";
145 constexpr OUStringLiteral sSuggestedSaveAsDir = u"SuggestedSaveAsDir";
146 constexpr OUStringLiteral sSuggestedSaveAsName = u"SuggestedSaveAsName";
147 constexpr OUStringLiteral sEncryptionData = u"EncryptionData";
148 constexpr OUStringLiteral sFailOnWarning = u"FailOnWarning";
149 constexpr OUStringLiteral sDocumentService = u"DocumentService";
150 constexpr OUStringLiteral sFilterProvider = u"FilterProvider";
151 constexpr OUStringLiteral sImageFilter = u"ImageFilter";
152 constexpr OUStringLiteral sLockContentExtraction = u"LockContentExtraction";
153 constexpr OUStringLiteral sLockExport = u"LockExport";
154 constexpr OUStringLiteral sLockPrint = u"LockPrint";
155 constexpr OUStringLiteral sLockSave = u"LockSave";
156 constexpr OUStringLiteral sLockEditDoc = u"LockEditDoc";
157 constexpr OUStringLiteral sReplaceable = u"Replaceable";
158 
isMediaDescriptor(sal_uInt16 nSlotId)159 static bool isMediaDescriptor( sal_uInt16 nSlotId )
160 {
161     return ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC ||
162              nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
163              nSlotId == SID_SAVETO || nSlotId == SID_SAVEACOPY ||
164              nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
165              nSlotId == SID_EXPORTDOCASEPUB || nSlotId == SID_DIRECTEXPORTDOCASEPUB ||
166              nSlotId == SID_REDACTDOC || nSlotId == SID_AUTOREDACTDOC ||
167              nSlotId == SID_SAVEACOPYITEM);
168 }
169 
TransformParameters(sal_uInt16 nSlotId,const uno::Sequence<beans::PropertyValue> & rArgs,SfxAllItemSet & rSet,const SfxSlot * pSlot)170 void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
171 {
172     if ( !pSlot )
173         pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
174 
175     if ( !pSlot )
176         return;
177 
178     if ( nSlotId == SID_OPENURL )
179         nSlotId = SID_OPENDOC;
180 
181     const sal_Int32 nCount = rArgs.getLength();
182     if ( !nCount )
183         return;
184 
185     const beans::PropertyValue* pPropsVal = rArgs.getConstArray();
186     if ( !pSlot->IsMode(SfxSlotMode::METHOD) )
187     {
188         // slot is a property
189         const SfxType* pType = pSlot->GetType();
190         std::unique_ptr<SfxPoolItem> pItem(pType->CreateItem());
191 
192         if ( !pItem )
193         {
194             SAL_WARN( "sfx", "No creator method for item: " << nSlotId );
195             return;
196         }
197 
198         sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
199         bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == MapUnit::MapTwip );
200         pItem->SetWhich( nWhich );
201         sal_uInt16 nSubCount = pType->nAttribs;
202 
203         const beans::PropertyValue& rProp = pPropsVal[0];
204         const OUString& rName = rProp.Name;
205         if ( nCount == 1 && rName == OUString( pSlot->pUnoName, strlen( pSlot->pUnoName ), RTL_TEXTENCODING_UTF8 ) )
206         {
207             // there is only one parameter and its name matches the name of the property,
208             // so it's either a simple property or a complex property in one single UNO struct
209             if( pItem->PutValue( rProp.Value, bConvertTwips ? CONVERT_TWIPS : 0 ) )
210                 // only use successfully converted items
211                 rSet.Put( *pItem );
212             else
213             {
214                 SAL_WARN( "sfx", "Property not convertible: " << pSlot->pUnoName );
215             }
216         }
217 #ifdef DBG_UTIL
218         else if ( nSubCount == 0 )
219         {
220             // for a simple property there can be only one parameter and its name *must* match
221             SAL_WARN("sfx.appl", "Property name does not match: " << rName);
222         }
223 #endif
224         else
225         {
226             // there is more than one parameter and the property is a complex one
227 #ifdef DBG_UTIL
228             // if the dispatch API is used for UI purposes or from the testtool,
229             // it is possible to skip some or all arguments,
230             // but it indicates an error for macro recording;
231             // so this should be notified as a warning only
232             if ( nCount != nSubCount )
233             {
234                 SAL_INFO("sfx.appl", "MacroPlayer: wrong number of parameters for slot: " << nSlotId );
235             }
236 #endif
237             // complex property; collect sub items from the parameter set and reconstruct complex item
238             sal_uInt16 nFound=0;
239             for ( const beans::PropertyValue& rPropValue : rArgs )
240             {
241                 sal_uInt16 nSub;
242                 for ( nSub=0; nSub<nSubCount; nSub++ )
243                 {
244                     // search sub item by name
245                     OString aStr = OString::Concat(pSlot->pUnoName) + "." + pType->aAttrib[nSub].pName;
246                     if ( rPropValue.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
247                     {
248                         sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(pType->aAttrib[nSub].nAID));
249                         if ( bConvertTwips )
250                             nSubId |= CONVERT_TWIPS;
251                         if ( pItem->PutValue( rPropValue.Value, nSubId ) )
252                             nFound++;
253                         else
254                         {
255                             SAL_WARN( "sfx.appl", "Property not convertible: " << pSlot->pUnoName);
256                         }
257                         break;
258                     }
259                 }
260 
261                 // there was a parameter with a name that didn't match to any of the members
262                 SAL_WARN_IF( nSub >= nSubCount, "sfx.appl", "Property name does not match: " << rPropValue.Name );
263             }
264 
265             // at least one part of the complex item must be present; other parts can have default values
266             if ( nFound > 0 )
267                 rSet.Put( *pItem );
268         }
269 
270         return;
271     }
272 
273 #ifdef DBG_UTIL
274     // detect parameters that don't match to any formal argument or one of its members
275     sal_Int32 nFoundArgs = 0;
276 #endif
277     // slot is a method
278     bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
279     sal_uInt16 nMaxArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
280     for ( sal_uInt16 nArgs=0; nArgs<nMaxArgs; nArgs++ )
281     {
282         const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArgs] : pSlot->GetFormalArgument( nArgs );
283         std::unique_ptr<SfxPoolItem> pItem(rArg.CreateItem());
284         if ( !pItem )
285         {
286             SAL_WARN( "sfx", "No creator method for argument: " << rArg.pName );
287             return;
288         }
289 
290         sal_uInt16 nWhich = rSet.GetPool()->GetWhich(rArg.nSlotId);
291         bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == MapUnit::MapTwip );
292         pItem->SetWhich( nWhich );
293         const SfxType* pType = rArg.pType;
294         sal_uInt16 nSubCount = pType->nAttribs;
295         if ( nSubCount == 0 )
296         {
297             // "simple" (base type) argument
298             auto pProp = std::find_if(rArgs.begin(), rArgs.end(),
299                 [&rArg](const beans::PropertyValue& rProp) { return rProp.Name.equalsAscii(rArg.pName); });
300             if (pProp != rArgs.end())
301             {
302 #ifdef DBG_UTIL
303                 ++nFoundArgs;
304 #endif
305                 if( pItem->PutValue( pProp->Value, 0 ) )
306                     // only use successfully converted items
307                     rSet.Put( *pItem );
308                 else
309                 {
310                     SAL_WARN( "sfx", "Property not convertible: " << rArg.pName );
311                 }
312             }
313         }
314         else
315         {
316             // complex argument, could be passed in one struct
317             bool bAsWholeItem = false;
318             for ( const beans::PropertyValue& rProp : rArgs )
319             {
320                 const OUString& rName = rProp.Name;
321                 if ( rName == OUString(rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8) )
322                 {
323                     bAsWholeItem = true;
324 #ifdef DBG_UTIL
325                     ++nFoundArgs;
326 #endif
327                     if( pItem->PutValue( rProp.Value, 0 ) )
328                         // only use successfully converted items
329                         rSet.Put( *pItem );
330                     else
331                     {
332                         SAL_WARN( "sfx", "Property not convertible: " << rArg.pName );
333                     }
334                 }
335             }
336 
337             if ( !bAsWholeItem )
338             {
339                 // complex argument; collect sub items from argument array and reconstruct complex item
340                 // only put item if at least one member was found and had the correct type
341                 // (is this a good idea?! Should we ask for *all* members?)
342                 bool bRet = false;
343                 for ( const beans::PropertyValue& rProp : rArgs )
344                 {
345                     for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
346                     {
347                         // search sub item by name
348                         OString aStr = OString::Concat(rArg.pName) + "." + pType->aAttrib[nSub].pName;
349                         if ( rProp.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
350                         {
351                             // at least one member found ...
352                             bRet = true;
353 #ifdef DBG_UTIL
354                             ++nFoundArgs;
355 #endif
356                             sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(pType->aAttrib[nSub].nAID));
357                             if ( bConvertTwips )
358                                 nSubId |= CONVERT_TWIPS;
359                             if (!pItem->PutValue( rProp.Value, nSubId ) )
360                             {
361                                 // ... but it was not convertible
362                                 bRet = false;
363                                 SAL_WARN( "sfx", "Property not convertible: " << rArg.pName );
364                             }
365 
366                             break;
367                         }
368                     }
369                 }
370 
371                 if ( bRet )
372                     // only use successfully converted items
373                     rSet.Put( *pItem );
374 
375             }
376         }
377     }
378 
379     // special additional parameters for some slots not seen in the slot definitions
380     // Some of these slots are not considered to be used for macro recording, because they shouldn't be recorded as slots,
381     // but as dispatching or factory or arbitrary URLs to the frame
382     // Some also can use additional arguments that are not recordable (will be changed later,
383     // f.e. "SaveAs" shouldn't support parameters not in the slot definition!)
384     if ( nSlotId == SID_NEWWINDOW )
385     {
386         for ( const beans::PropertyValue& rProp : rArgs )
387         {
388             const OUString& rName = rProp.Name;
389             if ( rName == sFrame )
390             {
391                 Reference< XFrame > xFrame;
392                 OSL_VERIFY( rProp.Value >>= xFrame );
393                 rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
394             }
395             else
396             if ( rName == sHidden )
397             {
398                 bool bVal = false;
399                 if (rProp.Value >>= bVal)
400                     rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
401             }
402         }
403     }
404     else if ( bIsMediaDescriptor )
405     {
406         for ( const beans::PropertyValue& rProp : rArgs )
407         {
408 #ifdef DBG_UTIL
409             ++nFoundArgs;
410 #endif
411             const OUString& aName = rProp.Name;
412             if ( aName == sModel )
413                 rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) );
414             else if ( aName == sComponentData )
415             {
416                 rSet.Put( SfxUnoAnyItem( SID_COMPONENTDATA, rProp.Value ) );
417             }
418             else if ( aName == sComponentContext )
419             {
420                 rSet.Put( SfxUnoAnyItem( SID_COMPONENTCONTEXT, rProp.Value ) );
421             }
422             else if ( aName == sStatusInd )
423             {
424                 Reference<task::XStatusIndicator> xVal;
425                 bool bOK = (rProp.Value >>= xVal);
426                 DBG_ASSERT( bOK, "invalid type for StatusIndicator" );
427                 if (bOK && xVal.is())
428                     rSet.Put( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, rProp.Value ) );
429             }
430             else if ( aName == sInteractionHdl )
431             {
432                 Reference<task::XInteractionHandler> xVal;
433                 bool bOK = (rProp.Value >>= xVal);
434                 DBG_ASSERT( bOK, "invalid type for InteractionHandler" );
435                 if (bOK && xVal.is())
436                     rSet.Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, rProp.Value ) );
437             }
438             else if ( aName == sViewData )
439                 rSet.Put( SfxUnoAnyItem( SID_VIEW_DATA, rProp.Value ) );
440             else if ( aName == sFilterData )
441                 rSet.Put( SfxUnoAnyItem( SID_FILTER_DATA, rProp.Value ) );
442             else if ( aName == sInputStream )
443             {
444                 Reference< XInputStream > xVal;
445                 bool bOK = ((rProp.Value >>= xVal) && xVal.is());
446                 DBG_ASSERT( bOK, "invalid type for InputStream" );
447                 if (bOK)
448                     rSet.Put( SfxUnoAnyItem( SID_INPUTSTREAM, rProp.Value ) );
449             }
450             else if ( aName == sStream )
451             {
452                 Reference< XInputStream > xVal;
453                 bool bOK = ((rProp.Value >>= xVal) && xVal.is());
454                 DBG_ASSERT( bOK, "invalid type for Stream" );
455                 if (bOK)
456                     rSet.Put( SfxUnoAnyItem( SID_STREAM, rProp.Value ) );
457             }
458             else if ( aName == sUCBContent )
459             {
460                 Reference< XContent > xVal;
461                 bool bOK = ((rProp.Value >>= xVal) && xVal.is());
462                 DBG_ASSERT( bOK, "invalid type for UCBContent" );
463                 if (bOK)
464                     rSet.Put( SfxUnoAnyItem( SID_CONTENT, rProp.Value ) );
465             }
466             else if ( aName == sOutputStream )
467             {
468                 Reference< XOutputStream > xVal;
469                 bool bOK = ((rProp.Value >>= xVal) && xVal.is());
470                 DBG_ASSERT( bOK, "invalid type for OutputStream" );
471                 if (bOK)
472                     rSet.Put( SfxUnoAnyItem( SID_OUTPUTSTREAM, rProp.Value ) );
473             }
474             else if ( aName == sPostData )
475             {
476                 Reference< XInputStream > xVal;
477                 bool bOK = (rProp.Value >>= xVal);
478                 DBG_ASSERT( bOK, "invalid type for PostData" );
479                 if (bOK)
480                     rSet.Put( SfxUnoAnyItem( SID_POSTDATA, rProp.Value ) );
481             }
482             else if ( aName == sFrame )
483             {
484                 Reference< XFrame > xFrame;
485                 bool bOK = (rProp.Value >>= xFrame);
486                 DBG_ASSERT( bOK, "invalid type for Frame" );
487                 if (bOK)
488                     rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
489             }
490             else if ( aName == sAsTemplate )
491             {
492                 bool bVal = false;
493                 bool bOK = (rProp.Value >>= bVal);
494                 DBG_ASSERT( bOK, "invalid type for AsTemplate" );
495                 if (bOK)
496                     rSet.Put( SfxBoolItem( SID_TEMPLATE, bVal ) );
497             }
498             else if ( aName == sOpenNewView )
499             {
500                 bool bVal = false;
501                 bool bOK = (rProp.Value >>= bVal);
502                 DBG_ASSERT( bOK, "invalid type for OpenNewView" );
503                 if (bOK)
504                     rSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, bVal ) );
505             }
506             else if ( aName == sFailOnWarning )
507             {
508                 bool bVal = false;
509                 bool bOK = (rProp.Value >>= bVal);
510                 DBG_ASSERT( bOK, "invalid type for FailOnWarning" );
511                 if (bOK)
512                     rSet.Put( SfxBoolItem( SID_FAIL_ON_WARNING, bVal ) );
513             }
514             else if ( aName == sViewId )
515             {
516                 sal_Int16 nVal = -1;
517                 bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
518                 DBG_ASSERT( bOK, "invalid type for ViewId" );
519                 if (bOK)
520                     rSet.Put( SfxUInt16Item( SID_VIEW_ID, nVal ) );
521             }
522             else if ( aName == sPluginMode )
523             {
524                 sal_Int16 nVal = -1;
525                 bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
526                 DBG_ASSERT( bOK, "invalid type for PluginMode" );
527                 if (bOK)
528                     rSet.Put( SfxUInt16Item( SID_PLUGIN_MODE, nVal ) );
529             }
530             else if ( aName == sReadOnly )
531             {
532                 bool bVal = false;
533                 bool bOK = (rProp.Value >>= bVal);
534                 DBG_ASSERT( bOK, "invalid type for ReadOnly" );
535                 if (bOK)
536                     rSet.Put( SfxBoolItem( SID_DOC_READONLY, bVal ) );
537             }
538             else if ( aName == sDdeReconnect )
539             {
540                 bool bVal = true;
541                 bool bOK = (rProp.Value >>= bVal);
542                 DBG_ASSERT( bOK, "invalid type for DDEReconnect" );
543                 if (bOK)
544                     rSet.Put( SfxBoolItem( SID_DDE_RECONNECT_ONLOAD, bVal ) );
545             }
546             else if ( aName == sStartPresentation )
547             {
548                 bool bVal = false;
549                 bool bOK = (rProp.Value >>= bVal);
550                 DBG_ASSERT( bOK, "invalid type for StartPresentation" );
551                 if (bOK)
552                     rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, bVal ) );
553             }
554             else if ( aName == sSelectionOnly )
555             {
556                 bool bVal = false;
557                 bool bOK = (rProp.Value >>= bVal);
558                 DBG_ASSERT( bOK, "invalid type for SelectionOnly" );
559                 if (bOK)
560                     rSet.Put( SfxBoolItem( SID_SELECTION, bVal ) );
561             }
562             else if ( aName == sHidden )
563             {
564                 bool bVal = false;
565                 bool bOK = (rProp.Value >>= bVal);
566                 DBG_ASSERT( bOK, "invalid type for Hidden" );
567                 if (bOK)
568                     rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
569             }
570             else if ( aName == sMinimized )
571             {
572                 bool bVal = false;
573                 bool bOK = (rProp.Value >>= bVal);
574                 DBG_ASSERT( bOK, "invalid type for Minimized" );
575                 if (bOK)
576                     rSet.Put( SfxBoolItem( SID_MINIMIZED, bVal ) );
577             }
578             else if ( aName == sSilent )
579             {
580                 bool bVal = false;
581                 bool bOK = (rProp.Value >>= bVal);
582                 DBG_ASSERT( bOK, "invalid type for Silent" );
583                 if (bOK)
584                     rSet.Put( SfxBoolItem( SID_SILENT, bVal ) );
585             }
586             else if ( aName == sPreview )
587             {
588                 bool bVal = false;
589                 bool bOK = (rProp.Value >>= bVal);
590                 DBG_ASSERT( bOK, "invalid type for Preview" );
591                 if (bOK)
592                     rSet.Put( SfxBoolItem( SID_PREVIEW, bVal ) );
593             }
594             else if ( aName == sViewOnly )
595             {
596                 bool bVal = false;
597                 bool bOK = (rProp.Value >>= bVal);
598                 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
599                 if (bOK)
600                     rSet.Put( SfxBoolItem( SID_VIEWONLY, bVal ) );
601             }
602             else if ( aName == sDontEdit )
603             {
604                 bool bVal = false;
605                 bool bOK = (rProp.Value >>= bVal);
606                 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
607                 if (bOK)
608                     rSet.Put( SfxBoolItem( SID_EDITDOC, !bVal ) );
609             }
610             else if ( aName == sUseSystemDialog )
611             {
612                 bool bVal = false;
613                 bool bOK = (rProp.Value >>= bVal);
614                 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
615                 if (bOK)
616                     rSet.Put( SfxBoolItem( SID_FILE_DIALOG, bVal ) );
617             }
618             else if ( aName == sStandardDir )
619             {
620                 OUString sVal;
621                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
622                 DBG_ASSERT( bOK, "invalid type or value for StandardDir" );
623                 if (bOK)
624                     rSet.Put( SfxStringItem( SID_STANDARD_DIR, sVal ) );
625             }
626             else if ( aName == sDenyList )
627             {
628                 uno::Sequence<OUString> xVal;
629                 bool bOK = (rProp.Value >>= xVal);
630                 DBG_ASSERT( bOK, "invalid type or value for DenyList" );
631                 if (bOK)
632                 {
633                     SfxStringListItem stringList(SID_DENY_LIST);
634                     stringList.SetStringList( xVal );
635                     rSet.Put( stringList );
636                 }
637             }
638             else if ( aName == "FileName" )
639             {
640                 OUString sVal;
641                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
642                 DBG_ASSERT( bOK, "invalid type or value for FileName" );
643                 if (bOK)
644                     rSet.Put( SfxStringItem( SID_FILE_NAME, sVal ) );
645             }
646             else if ( aName == sSalvagedFile )
647             {
648                 OUString sVal;
649                 bool bOK = (rProp.Value >>= sVal);
650                 DBG_ASSERT( bOK, "invalid type or value for SalvagedFile" );
651                 if (bOK)
652                     rSet.Put( SfxStringItem( SID_DOC_SALVAGE, sVal ) );
653             }
654             else if ( aName == sFolderName )
655             {
656                 OUString sVal;
657                 bool bOK = (rProp.Value >>= sVal);
658                 DBG_ASSERT( bOK, "invalid type or value for FolderName" );
659                 if (bOK)
660                     rSet.Put( SfxStringItem( SID_PATH, sVal ) );
661             }
662             else if ( aName == sFrameName )
663             {
664                 OUString sVal;
665                 bool bOK = (rProp.Value >>= sVal);
666                 DBG_ASSERT( bOK, "invalid type for FrameName" );
667                 if (bOK && !sVal.isEmpty())
668                     rSet.Put( SfxStringItem( SID_TARGETNAME, sVal ) );
669             }
670             else if ( aName == sMediaType )
671             {
672                 OUString sVal;
673                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
674                 DBG_ASSERT( bOK, "invalid type or value for MediaType" );
675                 if (bOK)
676                     rSet.Put( SfxStringItem( SID_CONTENTTYPE, sVal ) );
677             }
678             else if ( aName == sTemplateName )
679             {
680                 OUString sVal;
681                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
682                 DBG_ASSERT( bOK, "invalid type or value for TemplateName" );
683                 if (bOK)
684                     rSet.Put( SfxStringItem( SID_TEMPLATE_NAME, sVal ) );
685             }
686             else if ( aName == sTemplateRegionName )
687             {
688                 OUString sVal;
689                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
690                 DBG_ASSERT( bOK, "invalid type or value for TemplateRegionName" );
691                 if (bOK)
692                     rSet.Put( SfxStringItem( SID_TEMPLATE_REGIONNAME, sVal ) );
693             }
694             else if ( aName == sJumpMark )
695             {
696                 OUString sVal;
697                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
698                 DBG_ASSERT( bOK, "invalid type or value for JumpMark" );
699                 if (bOK)
700                     rSet.Put( SfxStringItem( SID_JUMPMARK, sVal ) );
701             }
702             else if ( aName == sCharacterSet )
703             {
704                 OUString sVal;
705                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
706                 DBG_ASSERT( bOK, "invalid type or value for CharacterSet" );
707                 if (bOK)
708                     rSet.Put( SfxStringItem( SID_CHARSET, sVal ) );
709             }
710             else if ( aName == "FilterFlags" )
711             {
712                 OUString sVal;
713                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
714                 DBG_ASSERT( bOK, "invalid type or value for FilterFlags" );
715                 if (bOK)
716                     rSet.Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sVal ) );
717             }
718             else if ( aName == sImageFilter )
719             {
720                 OUString sVal;
721                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
722                 DBG_ASSERT( bOK, "invalid type or value for FilterFlags" );
723                 if (bOK)
724                     rSet.Put( SfxStringItem( SID_CONVERT_IMAGES, sVal ) );
725             }
726             else if ( aName == sMacroExecMode )
727             {
728                 sal_Int16 nVal =-1;
729                 bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
730                 DBG_ASSERT( bOK, "invalid type for MacroExecMode" );
731                 if (bOK)
732                     rSet.Put( SfxUInt16Item( SID_MACROEXECMODE, nVal ) );
733             }
734             else if ( aName == sUpdateDocMode )
735             {
736                 sal_Int16 nVal =-1;
737                 bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
738                 DBG_ASSERT( bOK, "invalid type for UpdateDocMode" );
739                 if (bOK)
740                     rSet.Put( SfxUInt16Item( SID_UPDATEDOCMODE, nVal ) );
741             }
742             else if ( aName == sRepairPackage )
743             {
744                 bool bVal = false;
745                 bool bOK = (rProp.Value >>= bVal);
746                 DBG_ASSERT( bOK, "invalid type for RepairPackage" );
747                 if (bOK)
748                     rSet.Put( SfxBoolItem( SID_REPAIRPACKAGE, bVal ) );
749             }
750             else if ( aName == sDocumentTitle )
751             {
752                 OUString sVal;
753                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
754                 DBG_ASSERT( bOK, "invalid type or value for DocumentTitle" );
755                 if (bOK)
756                     rSet.Put( SfxStringItem( SID_DOCINFO_TITLE, sVal ) );
757             }
758             else if ( aName == sDocumentBaseURL )
759             {
760                 OUString sVal;
761                 // the base url can be set to empty ( for embedded objects for example )
762                 bool bOK = (rProp.Value >>= sVal);
763                 DBG_ASSERT( bOK, "invalid type or value for DocumentBaseURL" );
764                 if (bOK)
765                     rSet.Put( SfxStringItem( SID_DOC_BASEURL, sVal ) );
766             }
767             else if ( aName == sHierarchicalDocumentName )
768             {
769                 OUString sVal;
770                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
771                 DBG_ASSERT( bOK, "invalid type or value for HierarchicalDocumentName" );
772                 if (bOK)
773                     rSet.Put( SfxStringItem( SID_DOC_HIERARCHICALNAME, sVal ) );
774             }
775             else if ( aName == sCopyStreamIfPossible )
776             {
777                 bool bVal = false;
778                 bool bOK = (rProp.Value >>= bVal);
779                 DBG_ASSERT( bOK, "invalid type for CopyStreamIfPossible" );
780                 if (bOK)
781                     rSet.Put( SfxBoolItem( SID_COPY_STREAM_IF_POSSIBLE, bVal ) );
782             }
783             else if ( aName == sNoAutoSave )
784             {
785                 bool bVal = false;
786                 bool bOK = (rProp.Value >>= bVal);
787                 DBG_ASSERT( bOK, "invalid type for NoAutoSave" );
788                 if (bOK)
789                     rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) );
790             }
791             else if ( aName == sModifyPasswordInfo )
792             {
793                 rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) );
794             }
795             else if ( aName == sEncryptionData )
796             {
797                 rSet.Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, rProp.Value ) );
798             }
799             else if ( aName == sSuggestedSaveAsDir )
800             {
801                 OUString sVal;
802                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
803                 DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsDir" );
804                 if (bOK)
805                     rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASDIR, sVal ) );
806             }
807             else if ( aName == sSuggestedSaveAsName )
808             {
809                 OUString sVal;
810                 bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
811                 DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsName" );
812                 if (bOK)
813                     rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASNAME, sVal ) );
814             }
815             else if (aName == sDocumentService)
816             {
817                 OUString aVal;
818                 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
819                 if (bOK)
820                     rSet.Put(SfxStringItem(SID_DOC_SERVICE, aVal));
821             }
822             else if (aName == sFilterProvider)
823             {
824                 OUString aVal;
825                 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
826                 if (bOK)
827                     rSet.Put(SfxStringItem(SID_FILTER_PROVIDER, aVal));
828             }
829             else if (aName == sLockContentExtraction)
830             {
831                 bool bVal = false;
832                 bool bOK = (rProp.Value >>= bVal);
833                 DBG_ASSERT( bOK, "invalid type for LockContentExtraction" );
834                 if (bOK)
835                     rSet.Put( SfxBoolItem( SID_LOCK_CONTENT_EXTRACTION, bVal ) );
836             }
837             else if (aName == sLockExport)
838             {
839                 bool bVal = false;
840                 bool bOK = (rProp.Value >>= bVal);
841                 DBG_ASSERT( bOK, "invalid type for LockExport" );
842                 if (bOK)
843                     rSet.Put( SfxBoolItem( SID_LOCK_EXPORT, bVal ) );
844             }
845             else if (aName == sLockPrint)
846             {
847                 bool bVal = false;
848                 bool bOK = (rProp.Value >>= bVal);
849                 DBG_ASSERT( bOK, "invalid type for LockPrint" );
850                 if (bOK)
851                     rSet.Put( SfxBoolItem( SID_LOCK_PRINT, bVal ) );
852             }
853             else if (aName == sLockSave)
854             {
855                 bool bVal = false;
856                 bool bOK = (rProp.Value >>= bVal);
857                 DBG_ASSERT( bOK, "invalid type for LockSave" );
858                 if (bOK)
859                     rSet.Put( SfxBoolItem( SID_LOCK_SAVE, bVal ) );
860             }
861             else if (aName == sLockEditDoc)
862             {
863                 bool bVal = false;
864                 bool bOK = (rProp.Value >>= bVal);
865                 DBG_ASSERT( bOK, "invalid type for LockEditDoc" );
866                 if (bOK)
867                     rSet.Put( SfxBoolItem( SID_LOCK_EDITDOC, bVal ) );
868             }
869             else if (aName == sReplaceable)
870             {
871                 bool bVal = false;
872                 bool bOK = (rProp.Value >>= bVal);
873                 DBG_ASSERT(bOK, "invalid type for Replaceable");
874                 if (bOK)
875                     rSet.Put(SfxBoolItem(SID_REPLACEABLE, bVal));
876             }
877 #ifdef DBG_UTIL
878             else
879                 --nFoundArgs;
880 #endif
881         }
882     }
883     // API to raise options dialog with a specified options ab page (#i83757#)
884     else
885     {
886         // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
887         if ( "OptionsTreeDialog" == OUString( pSlot->pUnoName, strlen(pSlot->pUnoName), RTL_TEXTENCODING_UTF8 ) )
888         {
889             auto pProp = std::find_if(rArgs.begin(), rArgs.end(),
890                 [](const PropertyValue& rProp) { return rProp.Name == "OptionsPageURL"; });
891             if (pProp != rArgs.end())
892             {
893                 OUString sURL;
894                 if ( pProp->Value >>= sURL )
895                     rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
896             }
897         }
898     }
899 #ifdef DBG_UTIL
900     if ( nFoundArgs == nCount )
901     {
902         // except for the "special" slots: assure that every argument was convertible
903         SAL_INFO( "sfx.appl", "MacroPlayer: Some properties didn't match to any formal argument for slot: "<< pSlot->pUnoName );
904     }
905 #endif
906 }
907 
TransformItems(sal_uInt16 nSlotId,const SfxItemSet & rSet,uno::Sequence<beans::PropertyValue> & rArgs,const SfxSlot * pSlot)908 void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<beans::PropertyValue>& rArgs, const SfxSlot* pSlot )
909 {
910     if ( !pSlot )
911         pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
912 
913     if ( !pSlot)
914         return;
915 
916     if ( nSlotId == SID_OPENURL )
917         nSlotId = SID_OPENDOC;
918     if ( nSlotId == SID_SAVEASREMOTE )
919         nSlotId = SID_SAVEASDOC;
920 
921     // find number of properties to avoid permanent reallocations in the sequence
922     sal_Int32 nProps=0;
923 
924 #ifdef DBG_UTIL
925     // trace number of items and compare with number of properties for debugging purposes
926     sal_Int32 nItems=0;
927 #endif
928 
929     const SfxType *pType = pSlot->GetType();
930     if ( !pSlot->IsMode(SfxSlotMode::METHOD) )
931     {
932         // slot is a property
933         sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
934         if ( rSet.GetItemState( nWhich ) == SfxItemState::SET ) //???
935         {
936             sal_uInt16 nSubCount = pType->nAttribs;
937             if ( nSubCount )
938                 // it's a complex property, we want it split into simple types
939                 // so we expect to get as many items as we have (sub) members
940                 nProps = nSubCount;
941             else
942                 // simple property: we expect to get exactly one item
943                 nProps++;
944         }
945         else
946         {
947             // we will not rely on the "toggle" ability of some property slots
948             SAL_WARN( "sfx", "Processing property slot without argument: " << nSlotId );
949         }
950 
951 #ifdef DBG_UTIL
952         nItems++;
953 #endif
954     }
955     else
956     {
957         // slot is a method
958         bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
959         sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->GetFormalArgumentCount();
960         for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
961         {
962             // check every formal argument of the method
963             const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArg] : pSlot->GetFormalArgument( nArg );
964 
965             sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
966             if ( rSet.GetItemState( nWhich ) == SfxItemState::SET ) //???
967             {
968                 sal_uInt16 nSubCount = rArg.pType->nAttribs;
969                 if ( nSubCount )
970                     // argument has a complex type, we want it split into simple types
971                     // so for this argument we expect to get as many items as we have (sub) members
972                     nProps += nSubCount;
973                 else
974                     // argument of simple type: we expect to get exactly one item for it
975                     nProps++;
976 #ifdef DBG_UTIL
977                 nItems++;
978 #endif
979             }
980         }
981 
982         // special treatment for slots that are *not* meant to be recorded as slots (except SaveAs/To)
983         if ( bIsMediaDescriptor )
984         {
985             sal_Int32 nAdditional=0;
986             if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL ) == SfxItemState::SET )
987                 nAdditional++;
988             if ( rSet.GetItemState( SID_INTERACTIONHANDLER ) == SfxItemState::SET )
989                 nAdditional++;
990             if ( rSet.GetItemState( SID_DOC_SALVAGE ) == SfxItemState::SET )
991                 nAdditional++;
992             if ( rSet.GetItemState( SID_PATH ) == SfxItemState::SET )
993                 nAdditional++;
994             if ( rSet.GetItemState( SID_FILE_DIALOG ) == SfxItemState::SET )
995                 nAdditional++;
996             if ( rSet.GetItemState( SID_STANDARD_DIR ) == SfxItemState::SET )
997                 nAdditional++;
998             if ( rSet.GetItemState( SID_DENY_LIST ) == SfxItemState::SET )
999                 nAdditional++;
1000             if ( rSet.GetItemState( SID_CONTENT ) == SfxItemState::SET )
1001                 nAdditional++;
1002             if ( rSet.GetItemState( SID_INPUTSTREAM ) == SfxItemState::SET )
1003                 nAdditional++;
1004             if ( rSet.GetItemState( SID_STREAM ) == SfxItemState::SET )
1005                 nAdditional++;
1006             if ( rSet.GetItemState( SID_OUTPUTSTREAM ) == SfxItemState::SET )
1007                 nAdditional++;
1008             if ( rSet.GetItemState( SID_TEMPLATE ) == SfxItemState::SET )
1009                 nAdditional++;
1010             if ( rSet.GetItemState( SID_OPEN_NEW_VIEW ) == SfxItemState::SET )
1011                 nAdditional++;
1012             if ( rSet.GetItemState( SID_FAIL_ON_WARNING ) == SfxItemState::SET )
1013                 nAdditional++;
1014             if ( rSet.GetItemState( SID_VIEW_ID ) == SfxItemState::SET )
1015                 nAdditional++;
1016             if ( rSet.GetItemState( SID_VIEW_DATA ) == SfxItemState::SET )
1017                 nAdditional++;
1018             if ( rSet.GetItemState( SID_FILTER_DATA ) == SfxItemState::SET )
1019                 nAdditional++;
1020             if ( rSet.GetItemState( SID_PLUGIN_MODE ) == SfxItemState::SET )
1021                 nAdditional++;
1022             if ( rSet.GetItemState( SID_DOC_READONLY ) == SfxItemState::SET )
1023                 nAdditional++;
1024             if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD ) == SfxItemState::SET )
1025                 nAdditional++;
1026             if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION ) == SfxItemState::SET )
1027                 nAdditional++;
1028             if ( rSet.GetItemState( SID_SELECTION ) == SfxItemState::SET )
1029                 nAdditional++;
1030             if ( rSet.GetItemState( SID_CONTENTTYPE ) == SfxItemState::SET )
1031                 nAdditional++;
1032             if ( rSet.GetItemState( SID_POSTDATA ) == SfxItemState::SET )
1033                 nAdditional++;
1034             if ( rSet.GetItemState( SID_FILLFRAME ) == SfxItemState::SET )
1035                 nAdditional++;
1036             if ( rSet.GetItemState( SID_CHARSET ) == SfxItemState::SET )
1037                 nAdditional++;
1038             if ( rSet.GetItemState( SID_TARGETNAME ) == SfxItemState::SET )
1039                 nAdditional++;
1040             if ( rSet.GetItemState( SID_TEMPLATE_NAME ) == SfxItemState::SET )
1041                 nAdditional++;
1042             if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME ) == SfxItemState::SET )
1043                 nAdditional++;
1044             if ( rSet.GetItemState( SID_HIDDEN ) == SfxItemState::SET )
1045                 nAdditional++;
1046             if ( rSet.GetItemState( SID_MINIMIZED ) == SfxItemState::SET )
1047                 nAdditional++;
1048             if ( rSet.GetItemState( SID_PREVIEW ) == SfxItemState::SET )
1049                 nAdditional++;
1050             if ( rSet.GetItemState( SID_VIEWONLY ) == SfxItemState::SET )
1051                 nAdditional++;
1052             if ( rSet.GetItemState( SID_EDITDOC ) == SfxItemState::SET )
1053                 nAdditional++;
1054             if ( rSet.GetItemState( SID_SILENT ) == SfxItemState::SET )
1055                 nAdditional++;
1056             if ( rSet.GetItemState( SID_JUMPMARK ) == SfxItemState::SET )
1057                 nAdditional++;
1058             if ( rSet.GetItemState( SID_DOCUMENT ) == SfxItemState::SET )
1059                 nAdditional++;
1060             if ( rSet.GetItemState( SID_MACROEXECMODE ) == SfxItemState::SET )
1061                 nAdditional++;
1062             if ( rSet.GetItemState( SID_UPDATEDOCMODE ) == SfxItemState::SET )
1063                 nAdditional++;
1064             if ( rSet.GetItemState( SID_REPAIRPACKAGE ) == SfxItemState::SET )
1065                 nAdditional++;
1066             if ( rSet.GetItemState( SID_DOCINFO_TITLE ) == SfxItemState::SET )
1067                 nAdditional++;
1068             if ( rSet.GetItemState( SID_COMPONENTDATA ) == SfxItemState::SET )
1069                 nAdditional++;
1070             if ( rSet.GetItemState( SID_COMPONENTCONTEXT ) == SfxItemState::SET )
1071                 nAdditional++;
1072             if ( rSet.GetItemState( SID_DOC_BASEURL ) == SfxItemState::SET )
1073                 nAdditional++;
1074             if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME ) == SfxItemState::SET )
1075                 nAdditional++;
1076             if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE ) == SfxItemState::SET )
1077                 nAdditional++;
1078             if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SfxItemState::SET )
1079                 nAdditional++;
1080             if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO ) == SfxItemState::SET )
1081                 nAdditional++;
1082             if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR ) == SfxItemState::SET )
1083                 nAdditional++;
1084             if ( rSet.GetItemState( SID_ENCRYPTIONDATA ) == SfxItemState::SET )
1085                 nAdditional++;
1086             if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME ) == SfxItemState::SET )
1087                 nAdditional++;
1088             if ( rSet.GetItemState( SID_DOC_SERVICE ) == SfxItemState::SET )
1089                 nAdditional++;
1090             if (rSet.HasItem(SID_FILTER_PROVIDER))
1091                 ++nAdditional;
1092             if ( rSet.GetItemState( SID_CONVERT_IMAGES ) == SfxItemState::SET )
1093                 nAdditional++;
1094             if ( rSet.GetItemState( SID_LOCK_CONTENT_EXTRACTION ) == SfxItemState::SET )
1095                 nAdditional++;
1096             if ( rSet.GetItemState( SID_LOCK_EXPORT ) == SfxItemState::SET )
1097                 nAdditional++;
1098             if ( rSet.GetItemState( SID_LOCK_PRINT ) == SfxItemState::SET )
1099                 nAdditional++;
1100             if ( rSet.GetItemState( SID_LOCK_SAVE ) == SfxItemState::SET )
1101                 nAdditional++;
1102             if ( rSet.GetItemState( SID_LOCK_EDITDOC ) == SfxItemState::SET )
1103                 nAdditional++;
1104             if (rSet.GetItemState(SID_REPLACEABLE) == SfxItemState::SET)
1105                 nAdditional++;
1106 
1107             // consider additional arguments
1108             nProps += nAdditional;
1109 #ifdef DBG_UTIL
1110             nItems += nAdditional;
1111 #endif
1112         }
1113     }
1114 
1115 #ifdef DBG_UTIL
1116     // now check the itemset: is there any item that is not convertible using the list of formal arguments
1117     // or the table of additional items?!
1118     if ( rSet.Count() != nItems )
1119     {
1120         // detect unknown item and present error message
1121         const sal_uInt16 *pRanges = rSet.GetRanges();
1122         while ( *pRanges )
1123         {
1124             sal_uInt16 nStartWhich = *pRanges++;
1125             sal_uInt16 nEndWhich = *pRanges++;
1126             for(sal_uInt16 nId = nStartWhich; nId <= nEndWhich; ++nId)
1127             {
1128                 if ( rSet.GetItemState(nId) < SfxItemState::SET ) //???
1129                     // not really set
1130                     continue;
1131 
1132                 if ( !pSlot->IsMode(SfxSlotMode::METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1133                     continue;
1134 
1135                 bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
1136                 sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
1137                 sal_uInt16 nArg;
1138                 for ( nArg=0; nArg<nFormalArgs; ++nArg )
1139                 {
1140                     const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArg] : pSlot->GetFormalArgument( nArg );
1141                     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1142                     if ( nId == nWhich )
1143                         break;
1144                 }
1145 
1146                 if ( nArg<nFormalArgs )
1147                     continue;
1148 
1149                 if ( bIsMediaDescriptor )
1150                 {
1151                     if ( nId == SID_DOCFRAME )
1152                         continue;
1153                     if ( nId == SID_PROGRESS_STATUSBAR_CONTROL )
1154                         continue;
1155                     if ( nId == SID_INTERACTIONHANDLER )
1156                         continue;
1157                     if ( nId == SID_VIEW_DATA )
1158                         continue;
1159                     if ( nId == SID_FILTER_DATA )
1160                         continue;
1161                     if ( nId == SID_DOCUMENT )
1162                         continue;
1163                     if ( nId == SID_CONTENT )
1164                         continue;
1165                     if ( nId == SID_INPUTSTREAM )
1166                         continue;
1167                     if ( nId == SID_STREAM )
1168                         continue;
1169                     if ( nId == SID_OUTPUTSTREAM )
1170                         continue;
1171                     if ( nId == SID_POSTDATA )
1172                         continue;
1173                     if ( nId == SID_FILLFRAME )
1174                         continue;
1175                     if ( nId == SID_TEMPLATE )
1176                         continue;
1177                     if ( nId == SID_OPEN_NEW_VIEW )
1178                         continue;
1179                     if ( nId == SID_VIEW_ID )
1180                         continue;
1181                     if ( nId == SID_PLUGIN_MODE )
1182                         continue;
1183                     if ( nId == SID_DOC_READONLY )
1184                         continue;
1185                     if ( nId == SID_DOC_STARTPRESENTATION )
1186                         continue;
1187                     if ( nId == SID_SELECTION )
1188                         continue;
1189                     if ( nId == SID_HIDDEN )
1190                         continue;
1191                     if ( nId == SID_MINIMIZED )
1192                         continue;
1193                     if ( nId == SID_SILENT )
1194                         continue;
1195                     if ( nId == SID_PREVIEW )
1196                         continue;
1197                     if ( nId == SID_VIEWONLY )
1198                         continue;
1199                     if ( nId == SID_EDITDOC )
1200                         continue;
1201                     if ( nId == SID_TARGETNAME )
1202                         continue;
1203                     if ( nId == SID_DOC_SALVAGE )
1204                         continue;
1205                     if ( nId == SID_PATH )
1206                         continue;
1207                     if ( nId == SID_FILE_DIALOG )
1208                         continue;
1209                     if ( nId == SID_STANDARD_DIR )
1210                         continue;
1211                     if ( nId == SID_DENY_LIST )
1212                         continue;
1213                     if ( nId == SID_CONTENTTYPE )
1214                         continue;
1215                     if ( nId == SID_TEMPLATE_NAME )
1216                         continue;
1217                     if ( nId == SID_TEMPLATE_REGIONNAME )
1218                         continue;
1219                     if ( nId == SID_JUMPMARK )
1220                         continue;
1221                     if ( nId == SID_CHARSET )
1222                         continue;
1223                     if ( nId == SID_MACROEXECMODE )
1224                         continue;
1225                     if ( nId == SID_UPDATEDOCMODE )
1226                         continue;
1227                     if ( nId == SID_REPAIRPACKAGE )
1228                         continue;
1229                     if ( nId == SID_DOCINFO_TITLE )
1230                         continue;
1231                     if ( nId == SID_COMPONENTDATA )
1232                         continue;
1233                     if ( nId == SID_COMPONENTCONTEXT )
1234                         continue;
1235                     if ( nId == SID_DOC_BASEURL )
1236                         continue;
1237                     if ( nId == SID_DOC_HIERARCHICALNAME )
1238                         continue;
1239                     if ( nId == SID_COPY_STREAM_IF_POSSIBLE )
1240                         continue;
1241                     if ( nId == SID_NOAUTOSAVE )
1242                         continue;
1243                     if ( nId == SID_ENCRYPTIONDATA )
1244                         continue;
1245                     if ( nId == SID_DOC_SERVICE )
1246                         continue;
1247                     if (nId == SID_FILTER_PROVIDER)
1248                         continue;
1249                     if ( nId == SID_CONVERT_IMAGES )
1250                         continue;
1251 
1252                     // used only internally
1253                     if ( nId == SID_SAVETO )
1254                         continue;
1255                     if ( nId == SID_SAVEACOPYITEM )
1256                         continue;
1257                     if ( nId == SID_MODIFYPASSWORDINFO )
1258                         continue;
1259                     if ( nId == SID_SUGGESTEDSAVEASDIR )
1260                         continue;
1261                     if ( nId == SID_SUGGESTEDSAVEASNAME )
1262                         continue;
1263                     if ( nId == SID_LOCK_CONTENT_EXTRACTION )
1264                         continue;
1265                     if ( nId == SID_LOCK_EXPORT )
1266                         continue;
1267                     if ( nId == SID_LOCK_PRINT )
1268                         continue;
1269                     if ( nId == SID_LOCK_SAVE )
1270                         continue;
1271                     if ( nId == SID_LOCK_EDITDOC )
1272                         continue;
1273                     if (nId == SID_REPLACEABLE)
1274                         continue;
1275                }
1276 
1277                 OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId));
1278                 DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr());
1279             }
1280         }
1281     }
1282 #endif
1283 
1284     if ( !nProps )
1285         return;
1286 
1287     // convert every item into a property
1288     uno::Sequence<beans::PropertyValue> aSequ(nProps);
1289     beans::PropertyValue *pValue = aSequ.getArray();
1290 
1291     sal_Int32 nActProp=0;
1292     if ( !pSlot->IsMode(SfxSlotMode::METHOD) )
1293     {
1294         // slot is a property
1295         sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
1296         bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == MapUnit::MapTwip );
1297         const SfxPoolItem* pItem = rSet.GetItem<SfxPoolItem>(nWhich, false);
1298         if ( pItem ) //???
1299         {
1300             sal_uInt16 nSubCount = pType->nAttribs;
1301             if ( !nSubCount )
1302             {
1303                 pValue[nActProp].Name = OUString::createFromAscii(pSlot->pUnoName) ;
1304                 if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1305                 {
1306                     SAL_WARN( "sfx", "Item not convertible: " << nSlotId );
1307                 }
1308             }
1309             else
1310             {
1311                 // complex type, add a property value for every member of the struct
1312                 for ( sal_uInt16 n=1; n<=nSubCount; ++n )
1313                 {
1314                     sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(pType->aAttrib[n-1].nAID));
1315                     if ( bConvertTwips )
1316                         nSubId |= CONVERT_TWIPS;
1317 
1318                     DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1319                     pValue[nActProp].Name = OUString::createFromAscii( pSlot->pUnoName ) +
1320                         "." +
1321                         OUString::createFromAscii( pType->aAttrib[n-1].pName );
1322                     if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1323                     {
1324                         SAL_WARN( "sfx", "Sub item " << pType->aAttrib[n-1].nAID
1325                                     << " not convertible in slot: " << nSlotId );
1326                     }
1327                 }
1328             }
1329         }
1330 
1331         rArgs = aSequ;
1332         return;
1333     }
1334 
1335     // slot is a method
1336     sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1337     for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1338     {
1339         const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1340         sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1341         bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == MapUnit::MapTwip );
1342         const SfxPoolItem* pItem = rSet.GetItem<SfxPoolItem>(nWhich, false);
1343         if ( pItem ) //???
1344         {
1345             sal_uInt16 nSubCount = rArg.pType->nAttribs;
1346             if ( !nSubCount )
1347             {
1348                 pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) ;
1349                 if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1350                 {
1351                     SAL_WARN( "sfx", "Item not convertible: " << rArg.nSlotId );
1352                 }
1353             }
1354             else
1355             {
1356                 // complex type, add a property value for every member of the struct
1357                 for ( sal_uInt16 n = 1; n <= nSubCount; ++n )
1358                 {
1359                     sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(rArg.pType->aAttrib[n-1].nAID));
1360                     if ( bConvertTwips )
1361                         nSubId |= CONVERT_TWIPS;
1362 
1363                     DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1364                     pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) +
1365                         "." +
1366                         OUString::createFromAscii( rArg.pType->aAttrib[n-1].pName ) ;
1367                     if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1368                     {
1369                         SAL_WARN( "sfx", "Sub item "
1370                                     << rArg.pType->aAttrib[n-1].nAID
1371                                     << " not convertible in slot: "
1372                                     << rArg.nSlotId );
1373                     }
1374                 }
1375             }
1376         }
1377     }
1378 
1379     if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC ||  nSlotId == SID_SAVEDOC ||
1380          nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
1381          nSlotId == SID_EXPORTDOCASEPUB || nSlotId == SID_DIRECTEXPORTDOCASEPUB ||
1382          nSlotId == SID_REDACTDOC || nSlotId == SID_AUTOREDACTDOC || nSlotId == SID_SAVEACOPY )
1383     {
1384         const SfxPoolItem *pItem=nullptr;
1385         if ( rSet.GetItemState( SID_COMPONENTDATA, false, &pItem ) == SfxItemState::SET )
1386         {
1387             pValue[nActProp].Name = sComponentData;
1388             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1389         }
1390         if ( rSet.GetItemState( SID_COMPONENTCONTEXT, false, &pItem ) == SfxItemState::SET )
1391         {
1392             pValue[nActProp].Name = sComponentContext;
1393             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1394         }
1395         if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, false, &pItem ) == SfxItemState::SET )
1396         {
1397             pValue[nActProp].Name = sStatusInd;
1398             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1399         }
1400         if ( rSet.GetItemState( SID_INTERACTIONHANDLER, false, &pItem ) == SfxItemState::SET )
1401         {
1402             pValue[nActProp].Name = sInteractionHdl;
1403             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1404         }
1405         if ( rSet.GetItemState( SID_VIEW_DATA, false, &pItem ) == SfxItemState::SET )
1406         {
1407             pValue[nActProp].Name = sViewData;
1408             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1409         }
1410         if ( rSet.GetItemState( SID_FILTER_DATA, false, &pItem ) == SfxItemState::SET )
1411         {
1412             pValue[nActProp].Name = sFilterData;
1413             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1414         }
1415         if ( rSet.GetItemState( SID_DOCUMENT, false, &pItem ) == SfxItemState::SET )
1416         {
1417             pValue[nActProp].Name = sModel;
1418             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1419         }
1420         if ( rSet.GetItemState( SID_CONTENT, false, &pItem ) == SfxItemState::SET )
1421         {
1422             pValue[nActProp].Name = sUCBContent;
1423             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1424         }
1425         if ( rSet.GetItemState( SID_INPUTSTREAM, false, &pItem ) == SfxItemState::SET )
1426         {
1427             pValue[nActProp].Name = sInputStream;
1428             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1429         }
1430         if ( rSet.GetItemState( SID_STREAM, false, &pItem ) == SfxItemState::SET )
1431         {
1432             pValue[nActProp].Name = sStream;
1433             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1434         }
1435         if ( rSet.GetItemState( SID_OUTPUTSTREAM, false, &pItem ) == SfxItemState::SET )
1436         {
1437             pValue[nActProp].Name = sOutputStream;
1438             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1439         }
1440         if ( rSet.GetItemState( SID_POSTDATA, false, &pItem ) == SfxItemState::SET )
1441         {
1442             pValue[nActProp].Name = sPostData;
1443             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1444         }
1445         if ( rSet.GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET )
1446         {
1447             pValue[nActProp].Name = sFrame;
1448             if ( auto pUsrAnyItem = dynamic_cast< const SfxUnoAnyItem *>( pItem ) )
1449             {
1450                 OSL_FAIL( "TransformItems: transporting an XFrame via an SfxUnoAnyItem is not deprecated!" );
1451                 pValue[nActProp++].Value = pUsrAnyItem->GetValue();
1452             }
1453             else if ( auto pUnoFrameItem = dynamic_cast< const SfxUnoFrameItem *>( pItem ) )
1454                 pValue[nActProp++].Value <<= pUnoFrameItem->GetFrame();
1455             else
1456                 OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" );
1457         }
1458         if ( rSet.GetItemState( SID_TEMPLATE, false, &pItem ) == SfxItemState::SET )
1459         {
1460             pValue[nActProp].Name = sAsTemplate;
1461             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1462         }
1463         if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, false, &pItem ) == SfxItemState::SET )
1464         {
1465             pValue[nActProp].Name = sOpenNewView;
1466             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1467         }
1468         if ( rSet.GetItemState( SID_FAIL_ON_WARNING, false, &pItem ) == SfxItemState::SET )
1469         {
1470             pValue[nActProp].Name = sFailOnWarning;
1471             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1472         }
1473         if ( rSet.GetItemState( SID_VIEW_ID, false, &pItem ) == SfxItemState::SET )
1474         {
1475             pValue[nActProp].Name = sViewId;
1476             pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1477         }
1478         if ( rSet.GetItemState( SID_PLUGIN_MODE, false, &pItem ) == SfxItemState::SET )
1479         {
1480             pValue[nActProp].Name = sPluginMode;
1481             pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1482         }
1483         if ( rSet.GetItemState( SID_DOC_READONLY, false, &pItem ) == SfxItemState::SET )
1484         {
1485             pValue[nActProp].Name = sReadOnly;
1486             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1487         }
1488         if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD, false, &pItem ) == SfxItemState::SET )
1489         {
1490             pValue[nActProp].Name = sDdeReconnect;
1491             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1492         }
1493         if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, false, &pItem ) == SfxItemState::SET )
1494         {
1495             pValue[nActProp].Name = sStartPresentation;
1496             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1497         }
1498         if ( rSet.GetItemState( SID_SELECTION, false, &pItem ) == SfxItemState::SET )
1499         {
1500             pValue[nActProp].Name = sSelectionOnly;
1501             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1502         }
1503         if ( rSet.GetItemState( SID_HIDDEN, false, &pItem ) == SfxItemState::SET )
1504         {
1505             pValue[nActProp].Name = sHidden;
1506             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1507         }
1508         if ( rSet.GetItemState( SID_MINIMIZED, false, &pItem ) == SfxItemState::SET )
1509         {
1510             pValue[nActProp].Name = sMinimized;
1511             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1512         }
1513         if ( rSet.GetItemState( SID_SILENT, false, &pItem ) == SfxItemState::SET )
1514         {
1515             pValue[nActProp].Name = sSilent;
1516             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1517         }
1518         if ( rSet.GetItemState( SID_PREVIEW, false, &pItem ) == SfxItemState::SET )
1519         {
1520             pValue[nActProp].Name = sPreview;
1521             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1522         }
1523         if ( rSet.GetItemState( SID_VIEWONLY, false, &pItem ) == SfxItemState::SET )
1524         {
1525             pValue[nActProp].Name = sViewOnly;
1526             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1527         }
1528         if ( rSet.GetItemState( SID_EDITDOC, false, &pItem ) == SfxItemState::SET )
1529         {
1530             pValue[nActProp].Name = sDontEdit;
1531             pValue[nActProp++].Value <<= !static_cast<const SfxBoolItem*>(pItem)->GetValue();
1532         }
1533         if ( rSet.GetItemState( SID_FILE_DIALOG, false, &pItem ) == SfxItemState::SET )
1534         {
1535             pValue[nActProp].Name = sUseSystemDialog;
1536             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1537         }
1538         if ( rSet.GetItemState( SID_STANDARD_DIR, false, &pItem ) == SfxItemState::SET )
1539         {
1540             pValue[nActProp].Name = sStandardDir;
1541             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1542         }
1543         if ( rSet.GetItemState( SID_DENY_LIST, false, &pItem ) == SfxItemState::SET )
1544         {
1545             pValue[nActProp].Name = sDenyList;
1546 
1547             css::uno::Sequence< OUString > aList;
1548             static_cast<const SfxStringListItem*>(pItem)->GetStringList( aList );
1549             pValue[nActProp++].Value <<= aList ;
1550         }
1551         if ( rSet.GetItemState( SID_TARGETNAME, false, &pItem ) == SfxItemState::SET )
1552         {
1553             pValue[nActProp].Name = sFrameName;
1554             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1555         }
1556         if ( rSet.GetItemState( SID_DOC_SALVAGE, false, &pItem ) == SfxItemState::SET )
1557         {
1558             pValue[nActProp].Name = sSalvagedFile;
1559             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1560         }
1561         if ( rSet.GetItemState( SID_PATH, false, &pItem ) == SfxItemState::SET )
1562         {
1563             pValue[nActProp].Name = sFolderName;
1564             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1565         }
1566         if ( rSet.GetItemState( SID_CONTENTTYPE, false, &pItem ) == SfxItemState::SET )
1567         {
1568             pValue[nActProp].Name = sMediaType;
1569             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1570         }
1571         if ( rSet.GetItemState( SID_TEMPLATE_NAME, false, &pItem ) == SfxItemState::SET )
1572         {
1573             pValue[nActProp].Name = sTemplateName;
1574             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1575         }
1576         if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, false, &pItem ) == SfxItemState::SET )
1577         {
1578             pValue[nActProp].Name = sTemplateRegionName;
1579             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1580         }
1581         if ( rSet.GetItemState( SID_JUMPMARK, false, &pItem ) == SfxItemState::SET )
1582         {
1583             pValue[nActProp].Name = sJumpMark;
1584             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1585         }
1586 
1587         if ( rSet.GetItemState( SID_CHARSET, false, &pItem ) == SfxItemState::SET )
1588         {
1589             pValue[nActProp].Name = sCharacterSet;
1590             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1591         }
1592         if ( rSet.GetItemState( SID_MACROEXECMODE, false, &pItem ) == SfxItemState::SET )
1593         {
1594             pValue[nActProp].Name = sMacroExecMode;
1595             pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1596         }
1597         if ( rSet.GetItemState( SID_UPDATEDOCMODE, false, &pItem ) == SfxItemState::SET )
1598         {
1599             pValue[nActProp].Name = sUpdateDocMode;
1600             pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1601         }
1602         if ( rSet.GetItemState( SID_REPAIRPACKAGE, false, &pItem ) == SfxItemState::SET )
1603         {
1604             pValue[nActProp].Name = sRepairPackage;
1605             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1606         }
1607         if ( rSet.GetItemState( SID_DOCINFO_TITLE, false, &pItem ) == SfxItemState::SET )
1608         {
1609             pValue[nActProp].Name = sDocumentTitle;
1610             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1611         }
1612         if ( rSet.GetItemState( SID_DOC_BASEURL, false, &pItem ) == SfxItemState::SET )
1613         {
1614             pValue[nActProp].Name = sDocumentBaseURL;
1615             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1616         }
1617         if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, false, &pItem ) == SfxItemState::SET )
1618         {
1619             pValue[nActProp].Name = sHierarchicalDocumentName;
1620             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1621         }
1622         if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, false, &pItem ) == SfxItemState::SET )
1623         {
1624             pValue[nActProp].Name = sCopyStreamIfPossible;
1625             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1626         }
1627         if ( rSet.GetItemState( SID_NOAUTOSAVE, false, &pItem ) == SfxItemState::SET )
1628         {
1629             pValue[nActProp].Name = sNoAutoSave;
1630             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1631         }
1632         if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, false, &pItem ) == SfxItemState::SET )
1633         {
1634             pValue[nActProp].Name = sModifyPasswordInfo;
1635             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1636         }
1637         if ( rSet.GetItemState( SID_ENCRYPTIONDATA, false, &pItem ) == SfxItemState::SET )
1638         {
1639             pValue[nActProp].Name = sEncryptionData;
1640             pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1641         }
1642         if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, false, &pItem ) == SfxItemState::SET )
1643         {
1644             pValue[nActProp].Name = sSuggestedSaveAsDir;
1645             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1646         }
1647         if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, false, &pItem ) == SfxItemState::SET )
1648         {
1649             pValue[nActProp].Name = sSuggestedSaveAsName;
1650             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1651         }
1652         if ( rSet.GetItemState( SID_DOC_SERVICE, false, &pItem ) == SfxItemState::SET )
1653         {
1654             pValue[nActProp].Name = sDocumentService;
1655             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1656         }
1657         if (rSet.HasItem(SID_FILTER_PROVIDER, &pItem))
1658         {
1659             pValue[nActProp].Name = sFilterProvider;
1660             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1661         }
1662         if (rSet.HasItem(SID_CONVERT_IMAGES, &pItem))
1663         {
1664             pValue[nActProp].Name = sImageFilter;
1665             pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1666         }
1667         if ( rSet.GetItemState( SID_LOCK_CONTENT_EXTRACTION, false, &pItem ) == SfxItemState::SET )
1668         {
1669             pValue[nActProp].Name = sLockContentExtraction;
1670             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1671         }
1672         if ( rSet.GetItemState( SID_LOCK_EXPORT, false, &pItem ) == SfxItemState::SET )
1673         {
1674             pValue[nActProp].Name = sLockExport;
1675             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1676         }
1677         if ( rSet.GetItemState( SID_LOCK_PRINT, false, &pItem ) == SfxItemState::SET )
1678         {
1679             pValue[nActProp].Name = sLockPrint;
1680             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1681         }
1682         if ( rSet.GetItemState( SID_LOCK_SAVE, false, &pItem ) == SfxItemState::SET )
1683         {
1684             pValue[nActProp].Name = sLockSave;
1685             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1686         }
1687         if ( rSet.GetItemState( SID_LOCK_EDITDOC, false, &pItem ) == SfxItemState::SET )
1688         {
1689             pValue[nActProp].Name = sLockEditDoc;
1690             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1691         }
1692         if (rSet.GetItemState(SID_REPLACEABLE, false, &pItem) == SfxItemState::SET)
1693         {
1694             pValue[nActProp].Name = sReplaceable;
1695             pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1696         }
1697     }
1698 
1699     rArgs = aSequ;
1700 }
1701 
setFilterOptions(const uno::Sequence<beans::PropertyValue> & rProps)1702 void SAL_CALL FilterOptionsContinuation::setFilterOptions(
1703                 const uno::Sequence<beans::PropertyValue>& rProps )
1704 {
1705     rProperties = rProps;
1706 }
1707 
1708 uno::Sequence< beans::PropertyValue > SAL_CALL
getFilterOptions()1709     FilterOptionsContinuation::getFilterOptions()
1710 {
1711     return rProperties;
1712 }
1713 
1714 
RequestFilterOptions(uno::Reference<frame::XModel> const & rModel,const uno::Sequence<beans::PropertyValue> & rProperties)1715 RequestFilterOptions::RequestFilterOptions( uno::Reference< frame::XModel > const & rModel,
1716                               const uno::Sequence< beans::PropertyValue >& rProperties )
1717 {
1718     uno::Reference< uno::XInterface > temp2;
1719     document::FilterOptionsRequest aOptionsRequest( OUString(),
1720                                                     temp2,
1721                                                     rModel,
1722                                                     rProperties );
1723 
1724     m_aRequest <<= aOptionsRequest;
1725 
1726     m_xAbort  = new comphelper::OInteractionAbort;
1727     m_xOptions = new FilterOptionsContinuation;
1728 }
1729 
getRequest()1730 uno::Any SAL_CALL RequestFilterOptions::getRequest()
1731 {
1732     return m_aRequest;
1733 }
1734 
1735 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
getContinuations()1736     SAL_CALL RequestFilterOptions::getContinuations()
1737 {
1738     return { m_xAbort, m_xOptions };
1739 }
1740 
1741 
1742 class RequestPackageReparation_Impl : public ::cppu::WeakImplHelper< task::XInteractionRequest >
1743 {
1744     uno::Any m_aRequest;
1745     rtl::Reference<comphelper::OInteractionApprove> m_xApprove;
1746     rtl::Reference<comphelper::OInteractionDisapprove>  m_xDisapprove;
1747 
1748 public:
1749     explicit RequestPackageReparation_Impl( const OUString& aName );
1750     bool    isApproved() const;
1751     virtual uno::Any SAL_CALL getRequest() override;
1752     virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations() override;
1753 };
1754 
RequestPackageReparation_Impl(const OUString & aName)1755 RequestPackageReparation_Impl::RequestPackageReparation_Impl( const OUString& aName )
1756 {
1757     uno::Reference< uno::XInterface > temp2;
1758     document::BrokenPackageRequest aBrokenPackageRequest( OUString(), temp2, aName );
1759     m_aRequest <<= aBrokenPackageRequest;
1760     m_xApprove = new comphelper::OInteractionApprove;
1761     m_xDisapprove = new comphelper::OInteractionDisapprove;
1762 }
1763 
isApproved() const1764 bool RequestPackageReparation_Impl::isApproved() const
1765 {
1766     return m_xApprove->wasSelected();
1767 }
1768 
getRequest()1769 uno::Any SAL_CALL RequestPackageReparation_Impl::getRequest()
1770 {
1771     return m_aRequest;
1772 }
1773 
1774 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
getContinuations()1775     SAL_CALL RequestPackageReparation_Impl::getContinuations()
1776 {
1777     return { m_xApprove, m_xDisapprove };
1778 }
1779 
RequestPackageReparation(const OUString & aName)1780 RequestPackageReparation::RequestPackageReparation( const OUString& aName )
1781     : mxImpl(new RequestPackageReparation_Impl( aName ))
1782 {
1783 }
1784 
~RequestPackageReparation()1785 RequestPackageReparation::~RequestPackageReparation()
1786 {
1787 }
1788 
isApproved() const1789 bool RequestPackageReparation::isApproved() const
1790 {
1791     return mxImpl->isApproved();
1792 }
1793 
GetRequest() const1794 css::uno::Reference < task::XInteractionRequest > RequestPackageReparation::GetRequest() const
1795 {
1796     return mxImpl;
1797 }
1798 
1799 
1800 class NotifyBrokenPackage_Impl : public ::cppu::WeakImplHelper< task::XInteractionRequest >
1801 {
1802     uno::Any m_aRequest;
1803     rtl::Reference<comphelper::OInteractionAbort>  m_xAbort;
1804 
1805 public:
1806     explicit NotifyBrokenPackage_Impl(const OUString& rName);
1807     virtual uno::Any SAL_CALL getRequest() override;
1808     virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations() override;
1809 };
1810 
NotifyBrokenPackage_Impl(const OUString & aName)1811 NotifyBrokenPackage_Impl::NotifyBrokenPackage_Impl( const OUString& aName )
1812 {
1813     uno::Reference< uno::XInterface > temp2;
1814     document::BrokenPackageRequest aBrokenPackageRequest( OUString(), temp2, aName );
1815     m_aRequest <<= aBrokenPackageRequest;
1816     m_xAbort = new comphelper::OInteractionAbort;
1817 }
1818 
getRequest()1819 uno::Any SAL_CALL NotifyBrokenPackage_Impl::getRequest()
1820 {
1821     return m_aRequest;
1822 }
1823 
1824 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
getContinuations()1825     SAL_CALL NotifyBrokenPackage_Impl::getContinuations()
1826 {
1827     return { m_xAbort };
1828 }
1829 
NotifyBrokenPackage(const OUString & aName)1830 NotifyBrokenPackage::NotifyBrokenPackage( const OUString& aName )
1831     : mxImpl(new NotifyBrokenPackage_Impl( aName ))
1832 {
1833 }
1834 
~NotifyBrokenPackage()1835 NotifyBrokenPackage::~NotifyBrokenPackage()
1836 {
1837 }
1838 
GetRequest() const1839 css::uno::Reference < task::XInteractionRequest > NotifyBrokenPackage::GetRequest() const
1840 {
1841     return mxImpl;
1842 }
1843 
1844 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1845