LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sfx2 / source / appl / appuno.cxx
blob17c2304ed10a8f237559501963b2041185ef1b48
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
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>
52 #include <memory>
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;
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 },
96 sal_uInt16 const nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
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";
159 static bool isMediaDescriptor( sal_uInt16 nSlotId )
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);
170 void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
172 if ( !pSlot )
173 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
175 if ( !pSlot )
176 return;
178 if ( nSlotId == SID_OPENURL )
179 nSlotId = SID_OPENDOC;
181 const sal_Int32 nCount = rArgs.getLength();
182 if ( !nCount )
183 return;
185 const beans::PropertyValue* pPropsVal = rArgs.getConstArray();
186 if ( !pSlot->IsMode(SfxSlotMode::METHOD) )
188 // slot is a property
189 const SfxType* pType = pSlot->GetType();
190 std::unique_ptr<SfxPoolItem> pItem(pType->CreateItem());
192 if ( !pItem )
194 SAL_WARN( "sfx", "No creator method for item: " << nSlotId );
195 return;
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;
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 ) )
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
214 SAL_WARN( "sfx", "Property not convertible: " << pSlot->pUnoName );
217 #ifdef DBG_UTIL
218 else if ( nSubCount == 0 )
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);
223 #endif
224 else
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 )
234 SAL_INFO("sfx.appl", "MacroPlayer: wrong number of parameters for slot: " << nSlotId );
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 )
241 sal_uInt16 nSub;
242 for ( nSub=0; nSub<nSubCount; nSub++ )
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()) )
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
255 SAL_WARN( "sfx.appl", "Property not convertible: " << pSlot->pUnoName);
257 break;
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 );
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 );
270 return;
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++ )
282 const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArgs] : pSlot->GetFormalArgument( nArgs );
283 std::unique_ptr<SfxPoolItem> pItem(rArg.CreateItem());
284 if ( !pItem )
286 SAL_WARN( "sfx", "No creator method for argument: " << rArg.pName );
287 return;
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 )
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())
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
310 SAL_WARN( "sfx", "Property not convertible: " << rArg.pName );
314 else
316 // complex argument, could be passed in one struct
317 bool bAsWholeItem = false;
318 for ( const beans::PropertyValue& rProp : rArgs )
320 const OUString& rName = rProp.Name;
321 if ( rName == OUString(rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8) )
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
332 SAL_WARN( "sfx", "Property not convertible: " << rArg.pName );
337 if ( !bAsWholeItem )
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 )
345 for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
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()) )
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 ) )
361 // ... but it was not convertible
362 bRet = false;
363 SAL_WARN( "sfx", "Property not convertible: " << rArg.pName );
366 break;
371 if ( bRet )
372 // only use successfully converted items
373 rSet.Put( *pItem );
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 )
386 for ( const beans::PropertyValue& rProp : rArgs )
388 const OUString& rName = rProp.Name;
389 if ( rName == sFrame )
391 Reference< XFrame > xFrame;
392 OSL_VERIFY( rProp.Value >>= xFrame );
393 rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
395 else
396 if ( rName == sHidden )
398 bool bVal = false;
399 if (rProp.Value >>= bVal)
400 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
404 else if ( bIsMediaDescriptor )
406 for ( const beans::PropertyValue& rProp : rArgs )
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 )
416 rSet.Put( SfxUnoAnyItem( SID_COMPONENTDATA, rProp.Value ) );
418 else if ( aName == sComponentContext )
420 rSet.Put( SfxUnoAnyItem( SID_COMPONENTCONTEXT, rProp.Value ) );
422 else if ( aName == sStatusInd )
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 ) );
430 else if ( aName == sInteractionHdl )
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 ) );
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 )
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 ) );
450 else if ( aName == sStream )
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 ) );
458 else if ( aName == sUCBContent )
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 ) );
466 else if ( aName == sOutputStream )
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 ) );
474 else if ( aName == sPostData )
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 ) );
482 else if ( aName == sFrame )
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 ) );
490 else if ( aName == sAsTemplate )
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 ) );
498 else if ( aName == sOpenNewView )
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 ) );
506 else if ( aName == sFailOnWarning )
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 ) );
514 else if ( aName == sViewId )
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 ) );
522 else if ( aName == sPluginMode )
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 ) );
530 else if ( aName == sReadOnly )
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 ) );
538 else if ( aName == sDdeReconnect )
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 ) );
546 else if ( aName == sStartPresentation )
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 ) );
554 else if ( aName == sSelectionOnly )
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 ) );
562 else if ( aName == sHidden )
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 ) );
570 else if ( aName == sMinimized )
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 ) );
578 else if ( aName == sSilent )
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 ) );
586 else if ( aName == sPreview )
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 ) );
594 else if ( aName == sViewOnly )
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 ) );
602 else if ( aName == sDontEdit )
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 ) );
610 else if ( aName == sUseSystemDialog )
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 ) );
618 else if ( aName == sStandardDir )
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 ) );
626 else if ( aName == sDenyList )
628 uno::Sequence<OUString> xVal;
629 bool bOK = (rProp.Value >>= xVal);
630 DBG_ASSERT( bOK, "invalid type or value for DenyList" );
631 if (bOK)
633 SfxStringListItem stringList(SID_DENY_LIST);
634 stringList.SetStringList( xVal );
635 rSet.Put( stringList );
638 else if ( aName == "FileName" )
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 ) );
646 else if ( aName == sSalvagedFile )
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 ) );
654 else if ( aName == sFolderName )
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 ) );
662 else if ( aName == sFrameName )
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 ) );
670 else if ( aName == sMediaType )
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 ) );
678 else if ( aName == sTemplateName )
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 ) );
686 else if ( aName == sTemplateRegionName )
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 ) );
694 else if ( aName == sJumpMark )
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 ) );
702 else if ( aName == sCharacterSet )
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 ) );
710 else if ( aName == "FilterFlags" )
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 ) );
718 else if ( aName == sImageFilter )
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 ) );
726 else if ( aName == sMacroExecMode )
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 ) );
734 else if ( aName == sUpdateDocMode )
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 ) );
742 else if ( aName == sRepairPackage )
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 ) );
750 else if ( aName == sDocumentTitle )
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 ) );
758 else if ( aName == sDocumentBaseURL )
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 ) );
767 else if ( aName == sHierarchicalDocumentName )
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 ) );
775 else if ( aName == sCopyStreamIfPossible )
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 ) );
783 else if ( aName == sNoAutoSave )
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 ) );
791 else if ( aName == sModifyPasswordInfo )
793 rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) );
795 else if ( aName == sEncryptionData )
797 rSet.Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, rProp.Value ) );
799 else if ( aName == sSuggestedSaveAsDir )
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 ) );
807 else if ( aName == sSuggestedSaveAsName )
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 ) );
815 else if (aName == sDocumentService)
817 OUString aVal;
818 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
819 if (bOK)
820 rSet.Put(SfxStringItem(SID_DOC_SERVICE, aVal));
822 else if (aName == sFilterProvider)
824 OUString aVal;
825 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
826 if (bOK)
827 rSet.Put(SfxStringItem(SID_FILTER_PROVIDER, aVal));
829 else if (aName == sLockContentExtraction)
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 ) );
837 else if (aName == sLockExport)
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 ) );
845 else if (aName == sLockPrint)
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 ) );
853 else if (aName == sLockSave)
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 ) );
861 else if (aName == sLockEditDoc)
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 ) );
869 else if (aName == sReplaceable)
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));
877 #ifdef DBG_UTIL
878 else
879 --nFoundArgs;
880 #endif
883 // API to raise options dialog with a specified options ab page (#i83757#)
884 else
886 // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
887 if ( "OptionsTreeDialog" == OUString( pSlot->pUnoName, strlen(pSlot->pUnoName), RTL_TEXTENCODING_UTF8 ) )
889 auto pProp = std::find_if(rArgs.begin(), rArgs.end(),
890 [](const PropertyValue& rProp) { return rProp.Name == "OptionsPageURL"; });
891 if (pProp != rArgs.end())
893 OUString sURL;
894 if ( pProp->Value >>= sURL )
895 rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
899 #ifdef DBG_UTIL
900 if ( nFoundArgs == nCount )
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 );
905 #endif
908 void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<beans::PropertyValue>& rArgs, const SfxSlot* pSlot )
910 if ( !pSlot )
911 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
913 if ( !pSlot)
914 return;
916 if ( nSlotId == SID_OPENURL )
917 nSlotId = SID_OPENDOC;
918 if ( nSlotId == SID_SAVEASREMOTE )
919 nSlotId = SID_SAVEASDOC;
921 // find number of properties to avoid permanent reallocations in the sequence
922 sal_Int32 nProps=0;
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
929 const SfxType *pType = pSlot->GetType();
930 if ( !pSlot->IsMode(SfxSlotMode::METHOD) )
932 // slot is a property
933 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
934 if ( rSet.GetItemState( nWhich ) == SfxItemState::SET ) //???
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++;
945 else
947 // we will not rely on the "toggle" ability of some property slots
948 SAL_WARN( "sfx", "Processing property slot without argument: " << nSlotId );
951 #ifdef DBG_UTIL
952 nItems++;
953 #endif
955 else
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 )
962 // check every formal argument of the method
963 const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArg] : pSlot->GetFormalArgument( nArg );
965 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
966 if ( rSet.GetItemState( nWhich ) == SfxItemState::SET ) //???
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
982 // special treatment for slots that are *not* meant to be recorded as slots (except SaveAs/To)
983 if ( bIsMediaDescriptor )
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++;
1107 // consider additional arguments
1108 nProps += nAdditional;
1109 #ifdef DBG_UTIL
1110 nItems += nAdditional;
1111 #endif
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 )
1120 // detect unknown item and present error message
1121 for ( auto const & rPair : rSet.GetRanges() )
1123 sal_uInt16 nStartWhich = rPair.first;
1124 sal_uInt16 nEndWhich = rPair.second;
1125 for(sal_uInt16 nId = nStartWhich; nId <= nEndWhich; ++nId)
1127 if ( rSet.GetItemState(nId) < SfxItemState::SET ) //???
1128 // not really set
1129 continue;
1131 if ( !pSlot->IsMode(SfxSlotMode::METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1132 continue;
1134 bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
1135 sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
1136 sal_uInt16 nArg;
1137 for ( nArg=0; nArg<nFormalArgs; ++nArg )
1139 const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArg] : pSlot->GetFormalArgument( nArg );
1140 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1141 if ( nId == nWhich )
1142 break;
1145 if ( nArg<nFormalArgs )
1146 continue;
1148 if ( bIsMediaDescriptor )
1150 if ( nId == SID_DOCFRAME )
1151 continue;
1152 if ( nId == SID_PROGRESS_STATUSBAR_CONTROL )
1153 continue;
1154 if ( nId == SID_INTERACTIONHANDLER )
1155 continue;
1156 if ( nId == SID_VIEW_DATA )
1157 continue;
1158 if ( nId == SID_FILTER_DATA )
1159 continue;
1160 if ( nId == SID_DOCUMENT )
1161 continue;
1162 if ( nId == SID_CONTENT )
1163 continue;
1164 if ( nId == SID_INPUTSTREAM )
1165 continue;
1166 if ( nId == SID_STREAM )
1167 continue;
1168 if ( nId == SID_OUTPUTSTREAM )
1169 continue;
1170 if ( nId == SID_POSTDATA )
1171 continue;
1172 if ( nId == SID_FILLFRAME )
1173 continue;
1174 if ( nId == SID_TEMPLATE )
1175 continue;
1176 if ( nId == SID_OPEN_NEW_VIEW )
1177 continue;
1178 if ( nId == SID_VIEW_ID )
1179 continue;
1180 if ( nId == SID_PLUGIN_MODE )
1181 continue;
1182 if ( nId == SID_DOC_READONLY )
1183 continue;
1184 if ( nId == SID_DOC_STARTPRESENTATION )
1185 continue;
1186 if ( nId == SID_SELECTION )
1187 continue;
1188 if ( nId == SID_HIDDEN )
1189 continue;
1190 if ( nId == SID_MINIMIZED )
1191 continue;
1192 if ( nId == SID_SILENT )
1193 continue;
1194 if ( nId == SID_PREVIEW )
1195 continue;
1196 if ( nId == SID_VIEWONLY )
1197 continue;
1198 if ( nId == SID_EDITDOC )
1199 continue;
1200 if ( nId == SID_TARGETNAME )
1201 continue;
1202 if ( nId == SID_DOC_SALVAGE )
1203 continue;
1204 if ( nId == SID_PATH )
1205 continue;
1206 if ( nId == SID_FILE_DIALOG )
1207 continue;
1208 if ( nId == SID_STANDARD_DIR )
1209 continue;
1210 if ( nId == SID_DENY_LIST )
1211 continue;
1212 if ( nId == SID_CONTENTTYPE )
1213 continue;
1214 if ( nId == SID_TEMPLATE_NAME )
1215 continue;
1216 if ( nId == SID_TEMPLATE_REGIONNAME )
1217 continue;
1218 if ( nId == SID_JUMPMARK )
1219 continue;
1220 if ( nId == SID_CHARSET )
1221 continue;
1222 if ( nId == SID_MACROEXECMODE )
1223 continue;
1224 if ( nId == SID_UPDATEDOCMODE )
1225 continue;
1226 if ( nId == SID_REPAIRPACKAGE )
1227 continue;
1228 if ( nId == SID_DOCINFO_TITLE )
1229 continue;
1230 if ( nId == SID_COMPONENTDATA )
1231 continue;
1232 if ( nId == SID_COMPONENTCONTEXT )
1233 continue;
1234 if ( nId == SID_DOC_BASEURL )
1235 continue;
1236 if ( nId == SID_DOC_HIERARCHICALNAME )
1237 continue;
1238 if ( nId == SID_COPY_STREAM_IF_POSSIBLE )
1239 continue;
1240 if ( nId == SID_NOAUTOSAVE )
1241 continue;
1242 if ( nId == SID_ENCRYPTIONDATA )
1243 continue;
1244 if ( nId == SID_DOC_SERVICE )
1245 continue;
1246 if (nId == SID_FILTER_PROVIDER)
1247 continue;
1248 if ( nId == SID_CONVERT_IMAGES )
1249 continue;
1251 // used only internally
1252 if ( nId == SID_SAVETO )
1253 continue;
1254 if ( nId == SID_SAVEACOPYITEM )
1255 continue;
1256 if ( nId == SID_MODIFYPASSWORDINFO )
1257 continue;
1258 if ( nId == SID_SUGGESTEDSAVEASDIR )
1259 continue;
1260 if ( nId == SID_SUGGESTEDSAVEASNAME )
1261 continue;
1262 if ( nId == SID_LOCK_CONTENT_EXTRACTION )
1263 continue;
1264 if ( nId == SID_LOCK_EXPORT )
1265 continue;
1266 if ( nId == SID_LOCK_PRINT )
1267 continue;
1268 if ( nId == SID_LOCK_SAVE )
1269 continue;
1270 if ( nId == SID_LOCK_EDITDOC )
1271 continue;
1272 if (nId == SID_REPLACEABLE)
1273 continue;
1276 OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId));
1277 DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr());
1281 #endif
1283 if ( !nProps )
1284 return;
1286 // convert every item into a property
1287 uno::Sequence<beans::PropertyValue> aSequ(nProps);
1288 beans::PropertyValue *pValue = aSequ.getArray();
1290 sal_Int32 nActProp=0;
1291 if ( !pSlot->IsMode(SfxSlotMode::METHOD) )
1293 // slot is a property
1294 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
1295 bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == MapUnit::MapTwip );
1296 const SfxPoolItem* pItem = rSet.GetItem<SfxPoolItem>(nWhich, false);
1297 if ( pItem ) //???
1299 sal_uInt16 nSubCount = pType->nAttribs;
1300 if ( !nSubCount )
1302 pValue[nActProp].Name = OUString::createFromAscii(pSlot->pUnoName) ;
1303 if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1305 SAL_WARN( "sfx", "Item not convertible: " << nSlotId );
1308 else
1310 // complex type, add a property value for every member of the struct
1311 for ( sal_uInt16 n=1; n<=nSubCount; ++n )
1313 sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(pType->aAttrib[n-1].nAID));
1314 if ( bConvertTwips )
1315 nSubId |= CONVERT_TWIPS;
1317 DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1318 pValue[nActProp].Name = OUString::createFromAscii( pSlot->pUnoName ) +
1319 "." +
1320 OUString::createFromAscii( pType->aAttrib[n-1].pName );
1321 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1323 SAL_WARN( "sfx", "Sub item " << pType->aAttrib[n-1].nAID
1324 << " not convertible in slot: " << nSlotId );
1330 rArgs = aSequ;
1331 return;
1334 // slot is a method
1335 sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1336 for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1338 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1339 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1340 bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == MapUnit::MapTwip );
1341 const SfxPoolItem* pItem = rSet.GetItem<SfxPoolItem>(nWhich, false);
1342 if ( pItem ) //???
1344 sal_uInt16 nSubCount = rArg.pType->nAttribs;
1345 if ( !nSubCount )
1347 pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) ;
1348 if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1350 SAL_WARN( "sfx", "Item not convertible: " << rArg.nSlotId );
1353 else
1355 // complex type, add a property value for every member of the struct
1356 for ( sal_uInt16 n = 1; n <= nSubCount; ++n )
1358 sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(rArg.pType->aAttrib[n-1].nAID));
1359 if ( bConvertTwips )
1360 nSubId |= CONVERT_TWIPS;
1362 DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1363 pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) +
1364 "." +
1365 OUString::createFromAscii( rArg.pType->aAttrib[n-1].pName ) ;
1366 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1368 SAL_WARN( "sfx", "Sub item "
1369 << rArg.pType->aAttrib[n-1].nAID
1370 << " not convertible in slot: "
1371 << rArg.nSlotId );
1378 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1379 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
1380 nSlotId == SID_EXPORTDOCASEPUB || nSlotId == SID_DIRECTEXPORTDOCASEPUB ||
1381 nSlotId == SID_REDACTDOC || nSlotId == SID_AUTOREDACTDOC || nSlotId == SID_SAVEACOPY )
1383 const SfxPoolItem *pItem=nullptr;
1384 if ( rSet.GetItemState( SID_COMPONENTDATA, false, &pItem ) == SfxItemState::SET )
1386 pValue[nActProp].Name = sComponentData;
1387 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1389 if ( rSet.GetItemState( SID_COMPONENTCONTEXT, false, &pItem ) == SfxItemState::SET )
1391 pValue[nActProp].Name = sComponentContext;
1392 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1394 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, false, &pItem ) == SfxItemState::SET )
1396 pValue[nActProp].Name = sStatusInd;
1397 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1399 if ( rSet.GetItemState( SID_INTERACTIONHANDLER, false, &pItem ) == SfxItemState::SET )
1401 pValue[nActProp].Name = sInteractionHdl;
1402 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1404 if ( rSet.GetItemState( SID_VIEW_DATA, false, &pItem ) == SfxItemState::SET )
1406 pValue[nActProp].Name = sViewData;
1407 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1409 if ( rSet.GetItemState( SID_FILTER_DATA, false, &pItem ) == SfxItemState::SET )
1411 pValue[nActProp].Name = sFilterData;
1412 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1414 if ( rSet.GetItemState( SID_DOCUMENT, false, &pItem ) == SfxItemState::SET )
1416 pValue[nActProp].Name = sModel;
1417 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1419 if ( rSet.GetItemState( SID_CONTENT, false, &pItem ) == SfxItemState::SET )
1421 pValue[nActProp].Name = sUCBContent;
1422 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1424 if ( rSet.GetItemState( SID_INPUTSTREAM, false, &pItem ) == SfxItemState::SET )
1426 pValue[nActProp].Name = sInputStream;
1427 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1429 if ( rSet.GetItemState( SID_STREAM, false, &pItem ) == SfxItemState::SET )
1431 pValue[nActProp].Name = sStream;
1432 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1434 if ( rSet.GetItemState( SID_OUTPUTSTREAM, false, &pItem ) == SfxItemState::SET )
1436 pValue[nActProp].Name = sOutputStream;
1437 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1439 if ( rSet.GetItemState( SID_POSTDATA, false, &pItem ) == SfxItemState::SET )
1441 pValue[nActProp].Name = sPostData;
1442 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1444 if ( rSet.GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET )
1446 pValue[nActProp].Name = sFrame;
1447 if ( auto pUsrAnyItem = dynamic_cast< const SfxUnoAnyItem *>( pItem ) )
1449 OSL_FAIL( "TransformItems: transporting an XFrame via an SfxUnoAnyItem is not deprecated!" );
1450 pValue[nActProp++].Value = pUsrAnyItem->GetValue();
1452 else if ( auto pUnoFrameItem = dynamic_cast< const SfxUnoFrameItem *>( pItem ) )
1453 pValue[nActProp++].Value <<= pUnoFrameItem->GetFrame();
1454 else
1455 OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" );
1457 if ( rSet.GetItemState( SID_TEMPLATE, false, &pItem ) == SfxItemState::SET )
1459 pValue[nActProp].Name = sAsTemplate;
1460 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1462 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, false, &pItem ) == SfxItemState::SET )
1464 pValue[nActProp].Name = sOpenNewView;
1465 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1467 if ( rSet.GetItemState( SID_FAIL_ON_WARNING, false, &pItem ) == SfxItemState::SET )
1469 pValue[nActProp].Name = sFailOnWarning;
1470 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1472 if ( rSet.GetItemState( SID_VIEW_ID, false, &pItem ) == SfxItemState::SET )
1474 pValue[nActProp].Name = sViewId;
1475 pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1477 if ( rSet.GetItemState( SID_PLUGIN_MODE, false, &pItem ) == SfxItemState::SET )
1479 pValue[nActProp].Name = sPluginMode;
1480 pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1482 if ( rSet.GetItemState( SID_DOC_READONLY, false, &pItem ) == SfxItemState::SET )
1484 pValue[nActProp].Name = sReadOnly;
1485 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1487 if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD, false, &pItem ) == SfxItemState::SET )
1489 pValue[nActProp].Name = sDdeReconnect;
1490 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1492 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, false, &pItem ) == SfxItemState::SET )
1494 pValue[nActProp].Name = sStartPresentation;
1495 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1497 if ( rSet.GetItemState( SID_SELECTION, false, &pItem ) == SfxItemState::SET )
1499 pValue[nActProp].Name = sSelectionOnly;
1500 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1502 if ( rSet.GetItemState( SID_HIDDEN, false, &pItem ) == SfxItemState::SET )
1504 pValue[nActProp].Name = sHidden;
1505 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1507 if ( rSet.GetItemState( SID_MINIMIZED, false, &pItem ) == SfxItemState::SET )
1509 pValue[nActProp].Name = sMinimized;
1510 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1512 if ( rSet.GetItemState( SID_SILENT, false, &pItem ) == SfxItemState::SET )
1514 pValue[nActProp].Name = sSilent;
1515 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1517 if ( rSet.GetItemState( SID_PREVIEW, false, &pItem ) == SfxItemState::SET )
1519 pValue[nActProp].Name = sPreview;
1520 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1522 if ( rSet.GetItemState( SID_VIEWONLY, false, &pItem ) == SfxItemState::SET )
1524 pValue[nActProp].Name = sViewOnly;
1525 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1527 if ( rSet.GetItemState( SID_EDITDOC, false, &pItem ) == SfxItemState::SET )
1529 pValue[nActProp].Name = sDontEdit;
1530 pValue[nActProp++].Value <<= !static_cast<const SfxBoolItem*>(pItem)->GetValue();
1532 if ( rSet.GetItemState( SID_FILE_DIALOG, false, &pItem ) == SfxItemState::SET )
1534 pValue[nActProp].Name = sUseSystemDialog;
1535 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1537 if ( rSet.GetItemState( SID_STANDARD_DIR, false, &pItem ) == SfxItemState::SET )
1539 pValue[nActProp].Name = sStandardDir;
1540 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1542 if ( rSet.GetItemState( SID_DENY_LIST, false, &pItem ) == SfxItemState::SET )
1544 pValue[nActProp].Name = sDenyList;
1546 css::uno::Sequence< OUString > aList;
1547 static_cast<const SfxStringListItem*>(pItem)->GetStringList( aList );
1548 pValue[nActProp++].Value <<= aList ;
1550 if ( rSet.GetItemState( SID_TARGETNAME, false, &pItem ) == SfxItemState::SET )
1552 pValue[nActProp].Name = sFrameName;
1553 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1555 if ( rSet.GetItemState( SID_DOC_SALVAGE, false, &pItem ) == SfxItemState::SET )
1557 pValue[nActProp].Name = sSalvagedFile;
1558 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1560 if ( rSet.GetItemState( SID_PATH, false, &pItem ) == SfxItemState::SET )
1562 pValue[nActProp].Name = sFolderName;
1563 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1565 if ( rSet.GetItemState( SID_CONTENTTYPE, false, &pItem ) == SfxItemState::SET )
1567 pValue[nActProp].Name = sMediaType;
1568 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1570 if ( rSet.GetItemState( SID_TEMPLATE_NAME, false, &pItem ) == SfxItemState::SET )
1572 pValue[nActProp].Name = sTemplateName;
1573 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1575 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, false, &pItem ) == SfxItemState::SET )
1577 pValue[nActProp].Name = sTemplateRegionName;
1578 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1580 if ( rSet.GetItemState( SID_JUMPMARK, false, &pItem ) == SfxItemState::SET )
1582 pValue[nActProp].Name = sJumpMark;
1583 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1586 if ( rSet.GetItemState( SID_CHARSET, false, &pItem ) == SfxItemState::SET )
1588 pValue[nActProp].Name = sCharacterSet;
1589 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1591 if ( rSet.GetItemState( SID_MACROEXECMODE, false, &pItem ) == SfxItemState::SET )
1593 pValue[nActProp].Name = sMacroExecMode;
1594 pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1596 if ( rSet.GetItemState( SID_UPDATEDOCMODE, false, &pItem ) == SfxItemState::SET )
1598 pValue[nActProp].Name = sUpdateDocMode;
1599 pValue[nActProp++].Value <<= static_cast<sal_Int16>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
1601 if ( rSet.GetItemState( SID_REPAIRPACKAGE, false, &pItem ) == SfxItemState::SET )
1603 pValue[nActProp].Name = sRepairPackage;
1604 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1606 if ( rSet.GetItemState( SID_DOCINFO_TITLE, false, &pItem ) == SfxItemState::SET )
1608 pValue[nActProp].Name = sDocumentTitle;
1609 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1611 if ( rSet.GetItemState( SID_DOC_BASEURL, false, &pItem ) == SfxItemState::SET )
1613 pValue[nActProp].Name = sDocumentBaseURL;
1614 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1616 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, false, &pItem ) == SfxItemState::SET )
1618 pValue[nActProp].Name = sHierarchicalDocumentName;
1619 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1621 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, false, &pItem ) == SfxItemState::SET )
1623 pValue[nActProp].Name = sCopyStreamIfPossible;
1624 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1626 if ( rSet.GetItemState( SID_NOAUTOSAVE, false, &pItem ) == SfxItemState::SET )
1628 pValue[nActProp].Name = sNoAutoSave;
1629 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1631 if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, false, &pItem ) == SfxItemState::SET )
1633 pValue[nActProp].Name = sModifyPasswordInfo;
1634 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1636 if ( rSet.GetItemState( SID_ENCRYPTIONDATA, false, &pItem ) == SfxItemState::SET )
1638 pValue[nActProp].Name = sEncryptionData;
1639 pValue[nActProp++].Value = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
1641 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, false, &pItem ) == SfxItemState::SET )
1643 pValue[nActProp].Name = sSuggestedSaveAsDir;
1644 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1646 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, false, &pItem ) == SfxItemState::SET )
1648 pValue[nActProp].Name = sSuggestedSaveAsName;
1649 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1651 if ( rSet.GetItemState( SID_DOC_SERVICE, false, &pItem ) == SfxItemState::SET )
1653 pValue[nActProp].Name = sDocumentService;
1654 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1656 if (rSet.HasItem(SID_FILTER_PROVIDER, &pItem))
1658 pValue[nActProp].Name = sFilterProvider;
1659 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1661 if (rSet.HasItem(SID_CONVERT_IMAGES, &pItem))
1663 pValue[nActProp].Name = sImageFilter;
1664 pValue[nActProp++].Value <<= static_cast<const SfxStringItem*>(pItem)->GetValue();
1666 if ( rSet.GetItemState( SID_LOCK_CONTENT_EXTRACTION, false, &pItem ) == SfxItemState::SET )
1668 pValue[nActProp].Name = sLockContentExtraction;
1669 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1671 if ( rSet.GetItemState( SID_LOCK_EXPORT, false, &pItem ) == SfxItemState::SET )
1673 pValue[nActProp].Name = sLockExport;
1674 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1676 if ( rSet.GetItemState( SID_LOCK_PRINT, false, &pItem ) == SfxItemState::SET )
1678 pValue[nActProp].Name = sLockPrint;
1679 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1681 if ( rSet.GetItemState( SID_LOCK_SAVE, false, &pItem ) == SfxItemState::SET )
1683 pValue[nActProp].Name = sLockSave;
1684 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue() ;
1686 if ( rSet.GetItemState( SID_LOCK_EDITDOC, false, &pItem ) == SfxItemState::SET )
1688 pValue[nActProp].Name = sLockEditDoc;
1689 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1691 if (rSet.GetItemState(SID_REPLACEABLE, false, &pItem) == SfxItemState::SET)
1693 pValue[nActProp].Name = sReplaceable;
1694 pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
1698 rArgs = aSequ;
1701 void SAL_CALL FilterOptionsContinuation::setFilterOptions(
1702 const uno::Sequence<beans::PropertyValue>& rProps )
1704 rProperties = rProps;
1707 uno::Sequence< beans::PropertyValue > SAL_CALL
1708 FilterOptionsContinuation::getFilterOptions()
1710 return rProperties;
1714 RequestFilterOptions::RequestFilterOptions( uno::Reference< frame::XModel > const & rModel,
1715 const uno::Sequence< beans::PropertyValue >& rProperties )
1717 uno::Reference< uno::XInterface > temp2;
1718 document::FilterOptionsRequest aOptionsRequest( OUString(),
1719 temp2,
1720 rModel,
1721 rProperties );
1723 m_aRequest <<= aOptionsRequest;
1725 m_xAbort = new comphelper::OInteractionAbort;
1726 m_xOptions = new FilterOptionsContinuation;
1729 uno::Any SAL_CALL RequestFilterOptions::getRequest()
1731 return m_aRequest;
1734 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
1735 SAL_CALL RequestFilterOptions::getContinuations()
1737 return { m_xAbort, m_xOptions };
1741 class RequestPackageReparation_Impl : public ::cppu::WeakImplHelper< task::XInteractionRequest >
1743 uno::Any m_aRequest;
1744 rtl::Reference<comphelper::OInteractionApprove> m_xApprove;
1745 rtl::Reference<comphelper::OInteractionDisapprove> m_xDisapprove;
1747 public:
1748 explicit RequestPackageReparation_Impl( const OUString& aName );
1749 bool isApproved() const;
1750 virtual uno::Any SAL_CALL getRequest() override;
1751 virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations() override;
1754 RequestPackageReparation_Impl::RequestPackageReparation_Impl( const OUString& aName )
1756 uno::Reference< uno::XInterface > temp2;
1757 document::BrokenPackageRequest aBrokenPackageRequest( OUString(), temp2, aName );
1758 m_aRequest <<= aBrokenPackageRequest;
1759 m_xApprove = new comphelper::OInteractionApprove;
1760 m_xDisapprove = new comphelper::OInteractionDisapprove;
1763 bool RequestPackageReparation_Impl::isApproved() const
1765 return m_xApprove->wasSelected();
1768 uno::Any SAL_CALL RequestPackageReparation_Impl::getRequest()
1770 return m_aRequest;
1773 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
1774 SAL_CALL RequestPackageReparation_Impl::getContinuations()
1776 return { m_xApprove, m_xDisapprove };
1779 RequestPackageReparation::RequestPackageReparation( const OUString& aName )
1780 : mxImpl(new RequestPackageReparation_Impl( aName ))
1784 RequestPackageReparation::~RequestPackageReparation()
1788 bool RequestPackageReparation::isApproved() const
1790 return mxImpl->isApproved();
1793 css::uno::Reference < task::XInteractionRequest > RequestPackageReparation::GetRequest() const
1795 return mxImpl;
1799 class NotifyBrokenPackage_Impl : public ::cppu::WeakImplHelper< task::XInteractionRequest >
1801 uno::Any m_aRequest;
1802 rtl::Reference<comphelper::OInteractionAbort> m_xAbort;
1804 public:
1805 explicit NotifyBrokenPackage_Impl(const OUString& rName);
1806 virtual uno::Any SAL_CALL getRequest() override;
1807 virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations() override;
1810 NotifyBrokenPackage_Impl::NotifyBrokenPackage_Impl( const OUString& aName )
1812 uno::Reference< uno::XInterface > temp2;
1813 document::BrokenPackageRequest aBrokenPackageRequest( OUString(), temp2, aName );
1814 m_aRequest <<= aBrokenPackageRequest;
1815 m_xAbort = new comphelper::OInteractionAbort;
1818 uno::Any SAL_CALL NotifyBrokenPackage_Impl::getRequest()
1820 return m_aRequest;
1823 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
1824 SAL_CALL NotifyBrokenPackage_Impl::getContinuations()
1826 return { m_xAbort };
1829 NotifyBrokenPackage::NotifyBrokenPackage( const OUString& aName )
1830 : mxImpl(new NotifyBrokenPackage_Impl( aName ))
1834 NotifyBrokenPackage::~NotifyBrokenPackage()
1838 css::uno::Reference < task::XInteractionRequest > NotifyBrokenPackage::GetRequest() const
1840 return mxImpl;
1843 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */