bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / appl / appuno.cxx
blob50f8ee61369792502e541f9113f26410339075ff
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 #ifdef _MSC_VER
21 #pragma warning( disable : 4290 )
22 #endif
24 #include <sfx2/appuno.hxx>
26 #include "backingcomp.hxx"
27 #include "SfxDocumentMetaData.hxx"
28 #include "appbaslib.hxx"
29 #include "doctemplates.hxx"
30 #include "eventsupplier.hxx"
31 #include "fltoptint.hxx"
32 #include "frmload.hxx"
33 #include "iframe.hxx"
34 #include "objshimp.hxx"
35 #include "plugin.hxx"
36 #include <sfx2/app.hxx>
37 #include <sfx2/brokenpackageint.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <sfx2/dllapi.h>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/fcontnr.hxx>
42 #include <sfx2/frame.hxx>
43 #include <sfx2/module.hxx>
44 #include <sfx2/msg.hxx>
45 #include <sfx2/msgpool.hxx>
46 #include <sfx2/objsh.hxx>
47 #include <sfx2/request.hxx>
48 #include <sfx2/sfxbasecontroller.hxx>
49 #include <sfx2/sfxsids.hrc>
50 #include <sfx2/sfxuno.hxx>
51 #include <sfx2/unoctitm.hxx>
52 #include "sfxslots.hxx"
53 #include "sfxtypes.hxx"
54 #include "shutdownicon.hxx"
55 #include "xpackcreator.hxx"
57 #include <sal/config.h>
58 #include <basic/basmgr.hxx>
59 #include <basic/sberrors.hxx>
60 #include <basic/sbmeth.hxx>
61 #include <basic/sbuno.hxx>
62 #include <basic/sbx.hxx>
63 #include <basic/sbxcore.hxx>
64 #include <basic/sbxmeth.hxx>
65 #include <basic/sbxobj.hxx>
66 #include <comphelper/interaction.hxx>
67 #include <comphelper/processfactory.hxx>
68 #include <comphelper/sequence.hxx>
69 #include <framework/documentundoguard.hxx>
70 #include <osl/mutex.hxx>
71 #include <ownsubfilterservice.hxx>
72 #include <rtl/ustrbuf.hxx>
73 #include <svl/eitem.hxx>
74 #include <svl/intitem.hxx>
75 #include <svl/itempool.hxx>
76 #include <svl/lckbitem.hxx>
77 #include <svl/ownlist.hxx>
78 #include <svl/rectitem.hxx>
79 #include <svl/slstitm.hxx>
80 #include <svl/stritem.hxx>
81 #include <tools/config.hxx>
82 #include <tools/debug.hxx>
83 #include <tools/urlobj.hxx>
85 #include <com/sun/star/awt/PosSize.hpp>
86 #include <com/sun/star/awt/XButton.hpp>
87 #include <com/sun/star/awt/XTopWindow.hpp>
88 #include <com/sun/star/awt/XWindow.hpp>
89 #include <com/sun/star/beans/XPropertySet.hpp>
90 #include <com/sun/star/container/ContainerEvent.hpp>
91 #include <com/sun/star/container/XContainer.hpp>
92 #include <com/sun/star/container/XContainerListener.hpp>
93 #include <com/sun/star/container/XIndexContainer.hpp>
94 #include <com/sun/star/container/XIndexReplace.hpp>
95 #include <com/sun/star/container/XNameContainer.hpp>
96 #include <com/sun/star/container/XNameReplace.hpp>
97 #include <com/sun/star/container/XSet.hpp>
98 #include <com/sun/star/document/MacroExecMode.hpp>
99 #include <com/sun/star/document/UpdateDocMode.hpp>
100 #include <com/sun/star/frame/DispatchResultEvent.hpp>
101 #include <com/sun/star/frame/DispatchResultState.hpp>
102 #include <com/sun/star/frame/FrameAction.hpp>
103 #include <com/sun/star/frame/FrameActionEvent.hpp>
104 #include <com/sun/star/frame/XComponentLoader.hpp>
105 #include <com/sun/star/frame/XFrame.hpp>
106 #include <com/sun/star/frame/XFrameActionListener.hpp>
107 #include <com/sun/star/frame/XModel.hpp>
108 #include <com/sun/star/io/XInputStream.hpp>
109 #include <com/sun/star/registry/RegistryValueType.hpp>
110 #include <com/sun/star/task/XInteractionHandler.hpp>
111 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
112 #include <com/sun/star/ucb/XContent.hpp>
114 #include <cppuhelper/supportsservice.hxx>
116 #include <boost/scoped_ptr.hpp>
118 #define PROTOCOLHANDLER_SERVICENAME "com.sun.star.frame.ProtocolHandler"
120 using namespace ::com::sun::star;
121 using namespace ::com::sun::star::ucb;
122 using namespace ::com::sun::star::uno;
123 using namespace ::com::sun::star::registry;
124 using namespace ::com::sun::star::frame;
125 using namespace ::com::sun::star::beans;
126 using namespace ::com::sun::star::io;
128 // needs to be converted to a better data structure
129 SfxFormalArgument aFormalArgs[] = {
130 SFX_ARGUMENT(SID_DEFAULTFILENAME,"SuggestedSaveAsName",SfxStringItem),
131 SFX_ARGUMENT(SID_DEFAULTFILEPATH,"SuggestedSaveAsDir",SfxStringItem),
132 SFX_ARGUMENT(SID_DOCINFO_AUTHOR,"VersionAuthor",SfxStringItem),
133 SFX_ARGUMENT(SID_DOCINFO_COMMENTS,"VersionComment",SfxStringItem),
134 SFX_ARGUMENT(SID_DOCINFO_MAJOR,"VersionMajor",SfxBoolItem),
135 SFX_ARGUMENT(SID_FILE_FILTEROPTIONS,"FilterOptions",SfxStringItem),
136 SFX_ARGUMENT(SID_FILTER_NAME,"FilterName",SfxStringItem),
137 // SFX_ARGUMENT(SID_FILE_NAME,"FileName",SfxStringItem),
138 SFX_ARGUMENT(SID_FILE_NAME,"URL",SfxStringItem),
139 SFX_ARGUMENT(SID_OPTIONS,"OpenFlags",SfxStringItem),
140 SFX_ARGUMENT(SID_OVERWRITE,"Overwrite",SfxBoolItem),
141 SFX_ARGUMENT(SID_PASSWORD,"Password",SfxStringItem),
142 SFX_ARGUMENT(SID_PASSWORDINTERACTION,"PasswordInteraction",SfxBoolItem),
143 SFX_ARGUMENT(SID_REFERER,"Referer",SfxStringItem),
144 SFX_ARGUMENT(SID_SAVETO,"SaveTo",SfxBoolItem),
145 SFX_ARGUMENT(SID_TEMPLATE_NAME,"TemplateName",SfxStringItem),
146 SFX_ARGUMENT(SID_TEMPLATE_REGIONNAME,"TemplateRegion",SfxStringItem),
147 // SFX_ARGUMENT(SID_TEMPLATE_REGIONNAME,"Region",SfxStringItem),
148 // SFX_ARGUMENT(SID_TEMPLATE_NAME,"Name",SfxStringItem),
149 SFX_ARGUMENT(SID_UNPACK,"Unpacked",SfxBoolItem),
150 SFX_ARGUMENT(SID_VERSION,"Version",SfxInt16Item),
151 SFX_ARGUMENT(SID_SAVEACOPYITEM,"SaveACopy",SfxBoolItem),
154 static sal_uInt16 nMediaArgsCount = sizeof(aFormalArgs) / sizeof (SfxFormalArgument);
156 static char const sTemplateRegionName[] = "TemplateRegionName";
157 static char const sTemplateName[] = "TemplateName";
158 static char const sAsTemplate[] = "AsTemplate";
159 static char const sOpenNewView[] = "OpenNewView";
160 static char const sViewId[] = "ViewId";
161 static char const sPluginMode[] = "PluginMode";
162 static char const sReadOnly[] = "ReadOnly";
163 static char const sDdeReconnect[] = "DDEReconnect";
164 static char const sStartPresentation[] = "StartPresentation";
165 static char const sFrameName[] = "FrameName";
166 static char const sMediaType[] = "MediaType";
167 static char const sPostData[] = "PostData";
168 static char const sCharacterSet[] = "CharacterSet";
169 static char const sInputStream[] = "InputStream";
170 static char const sStream[] = "Stream";
171 static char const sOutputStream[] = "OutputStream";
172 static char const sHidden[] = "Hidden";
173 static char const sPreview[] = "Preview";
174 static char const sViewOnly[] = "ViewOnly";
175 static char const sDontEdit[] = "DontEdit";
176 static char const sSilent[] = "Silent";
177 static char const sJumpMark[] = "JumpMark";
178 static char const sFileName[] = "FileName";
179 static char const sSalvagedFile[] = "SalvagedFile";
180 static char const sStatusInd[] = "StatusIndicator";
181 static char const sModel[] = "Model";
182 static char const sFrame[] = "Frame";
183 static char const sViewData[] = "ViewData";
184 static char const sFilterData[] = "FilterData";
185 static char const sSelectionOnly[] = "SelectionOnly";
186 static char const sFilterFlags[] = "FilterFlags";
187 static char const sMacroExecMode[] = "MacroExecutionMode";
188 static char const sUpdateDocMode[] = "UpdateDocMode";
189 static char const sMinimized[] = "Minimized";
190 static char const sInteractionHdl[] = "InteractionHandler";
191 static char const sUCBContent[] = "UCBContent";
192 static char const sRepairPackage[] = "RepairPackage";
193 static char const sDocumentTitle[] = "DocumentTitle";
194 static char const sComponentData[] = "ComponentData";
195 static char const sComponentContext[] = "ComponentContext";
196 static char const sDocumentBaseURL[] = "DocumentBaseURL";
197 static char const sHierarchicalDocumentName[] = "HierarchicalDocumentName";
198 static char const sCopyStreamIfPossible[] = "CopyStreamIfPossible";
199 static char const sNoAutoSave[] = "NoAutoSave";
200 static char const sFolderName[] = "FolderName";
201 static char const sUseSystemDialog[] = "UseSystemDialog";
202 static char const sStandardDir[] = "StandardDir";
203 static char const sBlackList[] = "BlackList";
204 static char const sModifyPasswordInfo[] = "ModifyPasswordInfo";
205 static char const sSuggestedSaveAsDir[] = "SuggestedSaveAsDir";
206 static char const sSuggestedSaveAsName[] = "SuggestedSaveAsName";
207 static char const sEncryptionData[] = "EncryptionData";
208 static char const sFailOnWarning[] = "FailOnWarning";
209 static char const sDocumentService[] = "DocumentService";
210 static char const sFilterProvider[] = "FilterProvider";
212 static bool isMediaDescriptor( sal_uInt16 nSlotId )
214 return ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC ||
215 nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
216 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF ||
217 nSlotId == SID_DIRECTEXPORTDOCASPDF || nSlotId == SID_SAVEACOPY ||
218 nSlotId == SID_SAVEACOPYITEM);
221 void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
223 if ( !pSlot )
224 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
226 if ( !pSlot )
227 return;
229 if ( nSlotId == SID_OPENURL )
230 nSlotId = SID_OPENDOC;
231 if ( nSlotId == SID_SAVEASURL )
232 nSlotId = SID_SAVEASDOC;
234 sal_Int32 nCount = rArgs.getLength();
235 if ( !nCount )
236 return;
238 const beans::PropertyValue* pPropsVal = rArgs.getConstArray();
239 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
241 // slot is a property
242 const SfxType* pType = pSlot->GetType();
243 boost::scoped_ptr<SfxPoolItem> pItem(pType->CreateItem());
245 if ( !pItem )
247 #ifdef DBG_UTIL
248 OStringBuffer aStr("No creator method for item: ");
249 aStr.append(static_cast<sal_Int32>(nSlotId));
250 OSL_FAIL(aStr.getStr());
251 #endif
252 return;
255 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
256 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
257 pItem->SetWhich( nWhich );
258 sal_uInt16 nSubCount = pType->nAttribs;
260 const beans::PropertyValue& rProp = pPropsVal[0];
261 OUString aName = rProp.Name;
262 if ( nCount == 1 && aName == OUString( pSlot->pUnoName, strlen( pSlot->pUnoName ), RTL_TEXTENCODING_UTF8 ) )
264 // there is only one parameter and its name matches the name of the property,
265 // so it's either a simple property or a complex property in one single UNO struct
266 if( pItem->PutValue( rProp.Value, bConvertTwips ? CONVERT_TWIPS : 0 ) )
267 // only use successfully converted items
268 rSet.Put( *pItem );
269 #ifdef DBG_UTIL
270 else
272 OStringBuffer aStr("Property not convertible: ");
273 aStr.append(pSlot->pUnoName);
274 OSL_FAIL( aStr.getStr() );
276 #endif
278 #ifdef DBG_UTIL
279 else if ( nSubCount == 0 )
281 // for a simple property there can be only one parameter and its name *must* match
282 OUStringBuffer aStr("Property name does not match: ");
283 aStr.append(aName);
284 OSL_FAIL( aStr.getStr() );
286 #endif
287 else
289 // there is more than one parameter and the property is a complex one
290 #ifdef DBG_UTIL
291 // if the dispatch API is used for UI purposes or from the testtool,
292 // it is possible to skip some or all arguments,
293 // but it indicates an error for macro recording;
294 // so this should be notified as a warning only
295 if ( nCount != nSubCount )
297 OStringBuffer aStr("MacroPlayer: wrong number of parameters for slot: ");
298 aStr.append(static_cast<sal_Int32>(nSlotId));
299 DBG_WARNING(aStr.getStr());
301 #endif
302 // complex property; collect sub items from the parameter set and reconstruct complex item
303 sal_uInt16 nFound=0;
304 for ( sal_uInt16 n=0; n<nCount; n++ )
306 const beans::PropertyValue& rPropValue = pPropsVal[n];
307 sal_uInt16 nSub;
308 for ( nSub=0; nSub<nSubCount; nSub++ )
310 // search sub item by name
311 OStringBuffer aStr;
312 aStr.append(pSlot->pUnoName).append('.').append(pType->aAttrib[nSub].pName);
313 if ( rPropValue.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
315 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[nSub].nAID;
316 if ( bConvertTwips )
317 nSubId |= CONVERT_TWIPS;
318 if ( pItem->PutValue( rPropValue.Value, nSubId ) )
319 nFound++;
320 #ifdef DBG_UTIL
321 else
323 OStringBuffer aDbgStr("Property not convertible: ");
324 aDbgStr.append(pSlot->pUnoName);
325 OSL_FAIL( aDbgStr.getStr() );
327 #endif
328 break;
332 #ifdef DBG_UTIL
333 if ( nSub >= nSubCount )
335 // there was a parameter with a name that didn't match to any of the members
336 OStringBuffer aStr("Property name does not match: ");
337 aStr.append(OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8));
338 OSL_FAIL( aStr.getStr() );
340 #endif
343 // at least one part of the complex item must be present; other parts can have default values
344 if ( nFound > 0 )
345 rSet.Put( *pItem );
348 return;
351 OSL_ASSERT(nCount > 0);
353 #ifdef DBG_UTIL
354 // detect parameters that don't match to any formal argument or one of its members
355 sal_Int32 nFoundArgs = 0;
356 #endif
357 // slot is a method
358 bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
359 sal_uInt16 nMaxArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
360 for ( sal_uInt16 nArgs=0; nArgs<nMaxArgs; nArgs++ )
362 const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArgs] : pSlot->GetFormalArgument( nArgs );
363 boost::scoped_ptr<SfxPoolItem> pItem(rArg.CreateItem());
364 if ( !pItem )
366 #ifdef DBG_UTIL
367 OStringBuffer aStr("No creator method for argument: ");
368 aStr.append(rArg.pName);
369 OSL_FAIL( aStr.getStr() );
370 #endif
371 return;
374 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(rArg.nSlotId);
375 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
376 pItem->SetWhich( nWhich );
377 const SfxType* pType = rArg.pType;
378 sal_uInt16 nSubCount = pType->nAttribs;
379 if ( nSubCount == 0 )
381 // "simple" (base type) argument
382 for ( sal_uInt16 n=0; n<nCount; n++ )
384 const beans::PropertyValue& rProp = pPropsVal[n];
385 OUString aName = rProp.Name;
386 if ( aName == OUString( rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8 ) )
388 #ifdef DBG_UTIL
389 ++nFoundArgs;
390 #endif
391 if( pItem->PutValue( rProp.Value ) )
392 // only use successfully converted items
393 rSet.Put( *pItem );
394 #ifdef DBG_UTIL
395 else
397 OStringBuffer aStr("Property not convertible: ");
398 aStr.append(rArg.pName);
399 OSL_FAIL( aStr.getStr() );
401 #endif
402 break;
406 else
408 // complex argument, could be passed in one struct
409 sal_Bool bAsWholeItem = sal_False;
410 for ( sal_uInt16 n=0; n<nCount; n++ )
412 const beans::PropertyValue& rProp = pPropsVal[n];
413 OUString aName = rProp.Name;
414 if ( aName == OUString(rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8) )
416 bAsWholeItem = sal_True;
417 #ifdef DBG_UTIL
418 ++nFoundArgs;
419 #endif
420 if( pItem->PutValue( rProp.Value ) )
421 // only use successfully converted items
422 rSet.Put( *pItem );
423 #ifdef DBG_UTIL
424 else
426 OStringBuffer aStr("Property not convertible: ");
427 aStr.append(rArg.pName);
428 OSL_FAIL( aStr.getStr() );
430 #endif
434 if ( !bAsWholeItem )
436 // complex argument; collect sub items from argument array and reconstruct complex item
437 // only put item if at least one member was found and had the correct type
438 // (is this a good idea?! Should we ask for *all* members?)
439 sal_Bool bRet = sal_False;
440 for ( sal_uInt16 n=0; n<nCount; n++ )
442 const beans::PropertyValue& rProp = pPropsVal[n];
443 for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
445 // search sub item by name
446 OStringBuffer aStr;
447 aStr.append(rArg.pName).append('.').append(pType->aAttrib[nSub].pName);
448 if ( rProp.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
450 // at least one member found ...
451 bRet = sal_True;
452 #ifdef DBG_UTIL
453 ++nFoundArgs;
454 #endif
455 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[nSub].nAID;
456 if ( bConvertTwips )
457 nSubId |= CONVERT_TWIPS;
458 if (!pItem->PutValue( rProp.Value, nSubId ) )
460 // ... but it was not convertible
461 bRet = sal_False;
462 #ifdef DBG_UTIL
463 OStringBuffer aDbgStr("Property not convertible: ");
464 aDbgStr.append(rArg.pName);
465 OSL_FAIL( aDbgStr.getStr() );
466 #endif
469 break;
474 if ( bRet )
475 // only use successfully converted items
476 rSet.Put( *pItem );
482 // special additional parameters for some slots not seen in the slot definitions
483 // Some of these slots are not considered to be used for macro recording, because they shouldn't be recorded as slots,
484 // but as dispatching or factory or arbitrary URLs to the frame
485 // Some also can use additional arguments that are not recordable (will be changed later,
486 // f.e. "SaveAs" shouldn't support parameters not in the slot definition!)
487 if ( nSlotId == SID_NEWWINDOW )
489 for ( sal_uInt16 n=0; n<nCount; n++ )
491 const beans::PropertyValue& rProp = pPropsVal[n];
492 OUString aName = rProp.Name;
493 if ( aName == sFrame )
495 Reference< XFrame > xFrame;
496 OSL_VERIFY( rProp.Value >>= xFrame );
497 rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
499 else
500 if ( aName == sHidden )
502 sal_Bool bVal = sal_False;
503 if (rProp.Value >>= bVal)
504 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
508 else if ( bIsMediaDescriptor )
510 for ( sal_uInt16 n=0; n<nCount; n++ )
512 #ifdef DBG_UTIL
513 ++nFoundArgs;
514 #endif
515 const beans::PropertyValue& rProp = pPropsVal[n];
516 const OUString& aName = rProp.Name;
517 if ( aName == sModel )
518 rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) );
519 else if ( aName == sComponentData )
521 rSet.Put( SfxUnoAnyItem( SID_COMPONENTDATA, rProp.Value ) );
523 else if ( aName == sComponentContext )
525 rSet.Put( SfxUnoAnyItem( SID_COMPONENTCONTEXT, rProp.Value ) );
527 else if ( aName == sStatusInd )
529 Reference<task::XStatusIndicator> xVal;
530 sal_Bool bOK = (rProp.Value >>= xVal);
531 DBG_ASSERT( bOK, "invalid type for StatusIndicator" );
532 if (bOK && xVal.is())
533 rSet.Put( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, rProp.Value ) );
535 else if ( aName == sInteractionHdl )
537 Reference<task::XInteractionHandler> xVal;
538 sal_Bool bOK = (rProp.Value >>= xVal);
539 DBG_ASSERT( bOK, "invalid type for InteractionHandler" );
540 if (bOK && xVal.is())
541 rSet.Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, rProp.Value ) );
543 else if ( aName == sViewData )
544 rSet.Put( SfxUnoAnyItem( SID_VIEW_DATA, rProp.Value ) );
545 else if ( aName == sFilterData )
546 rSet.Put( SfxUnoAnyItem( SID_FILTER_DATA, rProp.Value ) );
547 else if ( aName == sInputStream )
549 Reference< XInputStream > xVal;
550 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
551 DBG_ASSERT( bOK, "invalid type for InputStream" );
552 if (bOK)
553 rSet.Put( SfxUnoAnyItem( SID_INPUTSTREAM, rProp.Value ) );
555 else if ( aName == sStream )
557 Reference< XInputStream > xVal;
558 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
559 DBG_ASSERT( bOK, "invalid type for Stream" );
560 if (bOK)
561 rSet.Put( SfxUnoAnyItem( SID_STREAM, rProp.Value ) );
563 else if ( aName == sUCBContent )
565 Reference< XContent > xVal;
566 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
567 DBG_ASSERT( bOK, "invalid type for UCBContent" );
568 if (bOK)
569 rSet.Put( SfxUnoAnyItem( SID_CONTENT, rProp.Value ) );
571 else if ( aName == sOutputStream )
573 Reference< XOutputStream > xVal;
574 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
575 DBG_ASSERT( bOK, "invalid type for OutputStream" );
576 if (bOK)
577 rSet.Put( SfxUnoAnyItem( SID_OUTPUTSTREAM, rProp.Value ) );
579 else if ( aName == sPostData )
581 Reference< XInputStream > xVal;
582 sal_Bool bOK = (rProp.Value >>= xVal);
583 DBG_ASSERT( bOK, "invalid type for PostData" );
584 if (bOK)
585 rSet.Put( SfxUnoAnyItem( SID_POSTDATA, rProp.Value ) );
587 else if ( aName == sFrame )
589 Reference< XFrame > xFrame;
590 sal_Bool bOK = (rProp.Value >>= xFrame);
591 DBG_ASSERT( bOK, "invalid type for Frame" );
592 if (bOK)
593 rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
595 else if ( aName == sAsTemplate )
597 sal_Bool bVal = sal_False;
598 sal_Bool bOK = (rProp.Value >>= bVal);
599 DBG_ASSERT( bOK, "invalid type for AsTemplate" );
600 if (bOK)
601 rSet.Put( SfxBoolItem( SID_TEMPLATE, bVal ) );
603 else if ( aName == sOpenNewView )
605 sal_Bool bVal = sal_False;
606 sal_Bool bOK = (rProp.Value >>= bVal);
607 DBG_ASSERT( bOK, "invalid type for OpenNewView" );
608 if (bOK)
609 rSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, bVal ) );
611 else if ( aName == sFailOnWarning )
613 sal_Bool bVal = sal_False;
614 sal_Bool bOK = (rProp.Value >>= bVal);
615 DBG_ASSERT( bOK, "invalid type for FailOnWarning" );
616 if (bOK)
617 rSet.Put( SfxBoolItem( SID_FAIL_ON_WARNING, bVal ) );
619 else if ( aName == sViewId )
621 sal_Int16 nVal = -1;
622 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
623 DBG_ASSERT( bOK, "invalid type for ViewId" );
624 if (bOK)
625 rSet.Put( SfxUInt16Item( SID_VIEW_ID, nVal ) );
627 else if ( aName == sPluginMode )
629 sal_Int16 nVal = -1;
630 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
631 DBG_ASSERT( bOK, "invalid type for PluginMode" );
632 if (bOK)
633 rSet.Put( SfxUInt16Item( SID_PLUGIN_MODE, nVal ) );
635 else if ( aName == sReadOnly )
637 sal_Bool bVal = sal_False;
638 sal_Bool bOK = (rProp.Value >>= bVal);
639 DBG_ASSERT( bOK, "invalid type for ReadOnly" );
640 if (bOK)
641 rSet.Put( SfxBoolItem( SID_DOC_READONLY, bVal ) );
643 else if ( aName == sDdeReconnect )
645 sal_Bool bVal = sal_True;
646 sal_Bool bOK = (rProp.Value >>= bVal);
647 DBG_ASSERT( bOK, "invalid type for DDEReconnect" );
648 if (bOK)
649 rSet.Put( SfxBoolItem( SID_DDE_RECONNECT_ONLOAD, bVal ) );
651 else if ( aName == sStartPresentation )
653 sal_Bool bVal = sal_False;
654 sal_Bool bOK = (rProp.Value >>= bVal);
655 DBG_ASSERT( bOK, "invalid type for StartPresentation" );
656 if (bOK)
657 rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, bVal ) );
659 else if ( aName == sSelectionOnly )
661 sal_Bool bVal = sal_False;
662 sal_Bool bOK = (rProp.Value >>= bVal);
663 DBG_ASSERT( bOK, "invalid type for SelectionOnly" );
664 if (bOK)
665 rSet.Put( SfxBoolItem( SID_SELECTION, bVal ) );
667 else if ( aName == sHidden )
669 sal_Bool bVal = sal_False;
670 sal_Bool bOK = (rProp.Value >>= bVal);
671 DBG_ASSERT( bOK, "invalid type for Hidden" );
672 if (bOK)
673 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
675 else if ( aName == sMinimized )
677 sal_Bool bVal = sal_False;
678 sal_Bool bOK = (rProp.Value >>= bVal);
679 DBG_ASSERT( bOK, "invalid type for Minimized" );
680 if (bOK)
681 rSet.Put( SfxBoolItem( SID_MINIMIZED, bVal ) );
683 else if ( aName == sSilent )
685 sal_Bool bVal = sal_False;
686 sal_Bool bOK = (rProp.Value >>= bVal);
687 DBG_ASSERT( bOK, "invalid type for Silent" );
688 if (bOK)
689 rSet.Put( SfxBoolItem( SID_SILENT, bVal ) );
691 else if ( aName == sPreview )
693 sal_Bool bVal = sal_False;
694 sal_Bool bOK = (rProp.Value >>= bVal);
695 DBG_ASSERT( bOK, "invalid type for Preview" );
696 if (bOK)
697 rSet.Put( SfxBoolItem( SID_PREVIEW, bVal ) );
699 else if ( aName == sViewOnly )
701 sal_Bool bVal = sal_False;
702 sal_Bool bOK = (rProp.Value >>= bVal);
703 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
704 if (bOK)
705 rSet.Put( SfxBoolItem( SID_VIEWONLY, bVal ) );
707 else if ( aName == sDontEdit )
709 sal_Bool bVal = sal_False;
710 sal_Bool bOK = (rProp.Value >>= bVal);
711 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
712 if (bOK)
713 rSet.Put( SfxBoolItem( SID_EDITDOC, !bVal ) );
715 else if ( aName == sUseSystemDialog )
717 sal_Bool bVal = sal_False;
718 sal_Bool bOK = (rProp.Value >>= bVal);
719 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
720 if (bOK)
721 rSet.Put( SfxBoolItem( SID_FILE_DIALOG, bVal ) );
723 else if ( aName == sStandardDir )
725 OUString sVal;
726 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
727 DBG_ASSERT( bOK, "invalid type or value for StandardDir" );
728 if (bOK)
729 rSet.Put( SfxStringItem( SID_STANDARD_DIR, sVal ) );
731 else if ( aName == sBlackList )
733 uno::Sequence<OUString> xVal;
734 sal_Bool bOK = (rProp.Value >>= xVal);
735 DBG_ASSERT( bOK, "invalid type or value for BlackList" );
736 if (bOK)
738 SfxStringListItem stringList(SID_BLACK_LIST);
739 stringList.SetStringList( xVal );
740 rSet.Put( stringList );
743 else if ( aName == sFileName )
745 OUString sVal;
746 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
747 DBG_ASSERT( bOK, "invalid type or value for FileName" );
748 if (bOK)
749 rSet.Put( SfxStringItem( SID_FILE_NAME, sVal ) );
751 else if ( aName == sSalvagedFile )
753 OUString sVal;
754 sal_Bool bOK = (rProp.Value >>= sVal);
755 DBG_ASSERT( bOK, "invalid type or value for SalvagedFile" );
756 if (bOK)
757 rSet.Put( SfxStringItem( SID_DOC_SALVAGE, sVal ) );
759 else if ( aName == sFolderName )
761 OUString sVal;
762 sal_Bool bOK = (rProp.Value >>= sVal);
763 DBG_ASSERT( bOK, "invalid type or value for FolderName" );
764 if (bOK)
765 rSet.Put( SfxStringItem( SID_PATH, sVal ) );
767 else if ( aName == sFrameName )
769 OUString sVal;
770 sal_Bool bOK = (rProp.Value >>= sVal);
771 DBG_ASSERT( bOK, "invalid type for FrameName" );
772 if (bOK && !sVal.isEmpty())
773 rSet.Put( SfxStringItem( SID_TARGETNAME, sVal ) );
775 else if ( aName == sMediaType )
777 OUString sVal;
778 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
779 DBG_ASSERT( bOK, "invalid type or value for MediaType" );
780 if (bOK)
781 rSet.Put( SfxStringItem( SID_CONTENTTYPE, sVal ) );
783 else if ( aName == sTemplateName )
785 OUString sVal;
786 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
787 DBG_ASSERT( bOK, "invalid type or value for TemplateName" );
788 if (bOK)
789 rSet.Put( SfxStringItem( SID_TEMPLATE_NAME, sVal ) );
791 else if ( aName == sTemplateRegionName )
793 OUString sVal;
794 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
795 DBG_ASSERT( bOK, "invalid type or value for TemplateRegionName" );
796 if (bOK)
797 rSet.Put( SfxStringItem( SID_TEMPLATE_REGIONNAME, sVal ) );
799 else if ( aName == sJumpMark )
801 OUString sVal;
802 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
803 DBG_ASSERT( bOK, "invalid type or value for JumpMark" );
804 if (bOK)
805 rSet.Put( SfxStringItem( SID_JUMPMARK, sVal ) );
807 else if ( aName == sCharacterSet )
809 OUString sVal;
810 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
811 DBG_ASSERT( bOK, "invalid type or value for CharacterSet" );
812 if (bOK)
813 rSet.Put( SfxStringItem( SID_CHARSET, sVal ) );
815 else if ( aName == sFilterFlags )
817 OUString sVal;
818 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
819 DBG_ASSERT( bOK, "invalid type or value for FilterFlags" );
820 if (bOK)
821 rSet.Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sVal ) );
823 else if ( aName == sMacroExecMode )
825 sal_Int16 nVal =-1;
826 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
827 DBG_ASSERT( bOK, "invalid type for MacroExecMode" );
828 if (bOK)
829 rSet.Put( SfxUInt16Item( SID_MACROEXECMODE, nVal ) );
831 else if ( aName == sUpdateDocMode )
833 sal_Int16 nVal =-1;
834 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
835 DBG_ASSERT( bOK, "invalid type for UpdateDocMode" );
836 if (bOK)
837 rSet.Put( SfxUInt16Item( SID_UPDATEDOCMODE, nVal ) );
839 else if ( aName == sRepairPackage )
841 sal_Bool bVal = sal_False;
842 sal_Bool bOK = (rProp.Value >>= bVal);
843 DBG_ASSERT( bOK, "invalid type for RepairPackage" );
844 if (bOK)
845 rSet.Put( SfxBoolItem( SID_REPAIRPACKAGE, bVal ) );
847 else if ( aName == sDocumentTitle )
849 OUString sVal;
850 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
851 DBG_ASSERT( bOK, "invalid type or value for DocumentTitle" );
852 if (bOK)
853 rSet.Put( SfxStringItem( SID_DOCINFO_TITLE, sVal ) );
855 else if ( aName == sDocumentBaseURL )
857 OUString sVal;
858 // the base url can be set to empty ( for embedded objects for example )
859 sal_Bool bOK = (rProp.Value >>= sVal);
860 DBG_ASSERT( bOK, "invalid type or value for DocumentBaseURL" );
861 if (bOK)
862 rSet.Put( SfxStringItem( SID_DOC_BASEURL, sVal ) );
864 else if ( aName == sHierarchicalDocumentName )
866 OUString sVal;
867 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
868 DBG_ASSERT( bOK, "invalid type or value for HierarchicalDocumentName" );
869 if (bOK)
870 rSet.Put( SfxStringItem( SID_DOC_HIERARCHICALNAME, sVal ) );
872 else if ( aName == sCopyStreamIfPossible )
874 sal_Bool bVal = sal_False;
875 sal_Bool bOK = (rProp.Value >>= bVal);
876 DBG_ASSERT( bOK, "invalid type for CopyStreamIfPossible" );
877 if (bOK)
878 rSet.Put( SfxBoolItem( SID_COPY_STREAM_IF_POSSIBLE, bVal ) );
880 else if ( aName == sNoAutoSave )
882 sal_Bool bVal = sal_False;
883 sal_Bool bOK = (rProp.Value >>= bVal);
884 DBG_ASSERT( bOK, "invalid type for NoAutoSave" );
885 if (bOK)
886 rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) );
888 else if ( aName == sModifyPasswordInfo )
890 rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) );
892 else if ( aName == sEncryptionData )
894 rSet.Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, rProp.Value ) );
896 else if ( aName == sSuggestedSaveAsDir )
898 OUString sVal;
899 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
900 DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsDir" );
901 if (bOK)
902 rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASDIR, sVal ) );
904 else if ( aName == sSuggestedSaveAsName )
906 OUString sVal;
907 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
908 DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsName" );
909 if (bOK)
910 rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASNAME, sVal ) );
912 else if (aName == sDocumentService)
914 OUString aVal;
915 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
916 if (bOK)
917 rSet.Put(SfxStringItem(SID_DOC_SERVICE, aVal));
919 else if (aName == sFilterProvider)
921 OUString aVal;
922 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
923 if (bOK)
924 rSet.Put(SfxStringItem(SID_FILTER_PROVIDER, aVal));
926 #ifdef DBG_UTIL
927 else
928 --nFoundArgs;
929 #endif
932 // API to raise options dialog with a specified options ab page (#i83757#)
933 else
935 // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
936 OUString sSlotName( "OptionsTreeDialog" );
937 OUString sPropName( "OptionsPageURL" );
938 if ( sSlotName == OUString( pSlot->pUnoName, strlen(pSlot->pUnoName), RTL_TEXTENCODING_UTF8 ) )
940 for ( sal_uInt16 n = 0; n < nCount; ++n )
942 const PropertyValue& rProp = pPropsVal[n];
943 OUString sName( rProp.Name );
944 if ( sName == sPropName )
946 OUString sURL;
947 if ( rProp.Value >>= sURL )
948 rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
949 break;
954 #ifdef DB_UTIL
955 if ( nFoundArgs == nCount )
957 // except for the "special" slots: assure that every argument was convertible
958 OStringBuffer aStr("MacroPlayer: Some properties didn't match to any formal argument for slot: ");
959 aStr.append(pSlot->pUnoName);
960 DBG_WARNING( aStr.getStr() );
962 #endif
965 void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<beans::PropertyValue>& rArgs, const SfxSlot* pSlot )
967 if ( !pSlot )
968 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
970 if ( !pSlot)
971 return;
973 if ( nSlotId == SID_OPENURL )
974 nSlotId = SID_OPENDOC;
975 if ( nSlotId == SID_SAVEASURL )
976 nSlotId = SID_SAVEASDOC;
978 // find number of properties to avoid permanent reallocations in the sequence
979 sal_Int32 nProps=0;
981 #ifdef DBG_UTIL
982 // trace number of items and compare with number of properties for debugging purposes
983 sal_Int32 nItems=0;
984 #endif
986 const SfxType *pType = pSlot->GetType();
987 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
989 // slot is a property
990 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
991 if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
993 sal_uInt16 nSubCount = pType->nAttribs;
994 if ( nSubCount )
995 // it's a complex property, we want it split into simple types
996 // so we expect to get as many items as we have (sub) members
997 nProps = nSubCount;
998 else
999 // simple property: we expect to get exactly one item
1000 nProps++;
1002 #ifdef DBG_UTIL
1003 else
1005 // we will not rely on the "toggle" ability of some property slots
1006 OStringBuffer aStr("Processing property slot without argument: ");
1007 aStr.append(static_cast<sal_Int32>(nSlotId));
1008 OSL_FAIL(aStr.getStr());
1010 #endif
1012 #ifdef DBG_UTIL
1013 nItems++;
1014 #endif
1016 else
1018 // slot is a method
1019 bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
1020 sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->GetFormalArgumentCount();
1021 for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1023 // check every formal argument of the method
1024 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1026 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1027 if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
1029 sal_uInt16 nSubCount = rArg.pType->nAttribs;
1030 if ( nSubCount )
1031 // argument has a complex type, we want it split into simple types
1032 // so for this argument we expect to get as many items as we have (sub) members
1033 nProps += nSubCount;
1034 else
1035 // argument of simple type: we expect to get exactly one item for it
1036 nProps++;
1037 #ifdef DBG_UTIL
1038 nItems++;
1039 #endif
1043 // special treatment for slots that are *not* meant to be recorded as slots (except SaveAs/To)
1044 if ( bIsMediaDescriptor )
1046 sal_Int32 nAdditional=0;
1047 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL ) == SFX_ITEM_SET )
1048 nAdditional++;
1049 if ( rSet.GetItemState( SID_INTERACTIONHANDLER ) == SFX_ITEM_SET )
1050 nAdditional++;
1051 if ( rSet.GetItemState( SID_DOC_SALVAGE ) == SFX_ITEM_SET )
1052 nAdditional++;
1053 if ( rSet.GetItemState( SID_PATH ) == SFX_ITEM_SET )
1054 nAdditional++;
1055 if ( rSet.GetItemState( SID_FILE_DIALOG ) == SFX_ITEM_SET )
1056 nAdditional++;
1057 if ( rSet.GetItemState( SID_STANDARD_DIR ) == SFX_ITEM_SET )
1058 nAdditional++;
1059 if ( rSet.GetItemState( SID_BLACK_LIST ) == SFX_ITEM_SET )
1060 nAdditional++;
1061 if ( rSet.GetItemState( SID_CONTENT ) == SFX_ITEM_SET )
1062 nAdditional++;
1063 if ( rSet.GetItemState( SID_INPUTSTREAM ) == SFX_ITEM_SET )
1064 nAdditional++;
1065 if ( rSet.GetItemState( SID_STREAM ) == SFX_ITEM_SET )
1066 nAdditional++;
1067 if ( rSet.GetItemState( SID_OUTPUTSTREAM ) == SFX_ITEM_SET )
1068 nAdditional++;
1069 if ( rSet.GetItemState( SID_TEMPLATE ) == SFX_ITEM_SET )
1070 nAdditional++;
1071 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW ) == SFX_ITEM_SET )
1072 nAdditional++;
1073 if ( rSet.GetItemState( SID_FAIL_ON_WARNING ) == SFX_ITEM_SET )
1074 nAdditional++;
1075 if ( rSet.GetItemState( SID_VIEW_ID ) == SFX_ITEM_SET )
1076 nAdditional++;
1077 if ( rSet.GetItemState( SID_VIEW_DATA ) == SFX_ITEM_SET )
1078 nAdditional++;
1079 if ( rSet.GetItemState( SID_FILTER_DATA ) == SFX_ITEM_SET )
1080 nAdditional++;
1081 if ( rSet.GetItemState( SID_PLUGIN_MODE ) == SFX_ITEM_SET )
1082 nAdditional++;
1083 if ( rSet.GetItemState( SID_DOC_READONLY ) == SFX_ITEM_SET )
1084 nAdditional++;
1085 if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD ) == SFX_ITEM_SET )
1086 nAdditional++;
1087 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION ) == SFX_ITEM_SET )
1088 nAdditional++;
1089 if ( rSet.GetItemState( SID_SELECTION ) == SFX_ITEM_SET )
1090 nAdditional++;
1091 if ( rSet.GetItemState( SID_CONTENTTYPE ) == SFX_ITEM_SET )
1092 nAdditional++;
1093 if ( rSet.GetItemState( SID_POSTDATA ) == SFX_ITEM_SET )
1094 nAdditional++;
1095 if ( rSet.GetItemState( SID_FILLFRAME ) == SFX_ITEM_SET )
1096 nAdditional++;
1097 if ( rSet.GetItemState( SID_CHARSET ) == SFX_ITEM_SET )
1098 nAdditional++;
1099 if ( rSet.GetItemState( SID_TARGETNAME ) == SFX_ITEM_SET )
1100 nAdditional++;
1101 if ( rSet.GetItemState( SID_TEMPLATE_NAME ) == SFX_ITEM_SET )
1102 nAdditional++;
1103 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME ) == SFX_ITEM_SET )
1104 nAdditional++;
1105 if ( rSet.GetItemState( SID_HIDDEN ) == SFX_ITEM_SET )
1106 nAdditional++;
1107 if ( rSet.GetItemState( SID_MINIMIZED ) == SFX_ITEM_SET )
1108 nAdditional++;
1109 if ( rSet.GetItemState( SID_PREVIEW ) == SFX_ITEM_SET )
1110 nAdditional++;
1111 if ( rSet.GetItemState( SID_VIEWONLY ) == SFX_ITEM_SET )
1112 nAdditional++;
1113 if ( rSet.GetItemState( SID_EDITDOC ) == SFX_ITEM_SET )
1114 nAdditional++;
1115 if ( rSet.GetItemState( SID_SILENT ) == SFX_ITEM_SET )
1116 nAdditional++;
1117 if ( rSet.GetItemState( SID_JUMPMARK ) == SFX_ITEM_SET )
1118 nAdditional++;
1119 if ( rSet.GetItemState( SID_DOCUMENT ) == SFX_ITEM_SET )
1120 nAdditional++;
1121 if ( rSet.GetItemState( SID_MACROEXECMODE ) == SFX_ITEM_SET )
1122 nAdditional++;
1123 if ( rSet.GetItemState( SID_UPDATEDOCMODE ) == SFX_ITEM_SET )
1124 nAdditional++;
1125 if ( rSet.GetItemState( SID_REPAIRPACKAGE ) == SFX_ITEM_SET )
1126 nAdditional++;
1127 if ( rSet.GetItemState( SID_DOCINFO_TITLE ) == SFX_ITEM_SET )
1128 nAdditional++;
1129 if ( rSet.GetItemState( SID_COMPONENTDATA ) == SFX_ITEM_SET )
1130 nAdditional++;
1131 if ( rSet.GetItemState( SID_COMPONENTCONTEXT ) == SFX_ITEM_SET )
1132 nAdditional++;
1133 if ( rSet.GetItemState( SID_DOC_BASEURL ) == SFX_ITEM_SET )
1134 nAdditional++;
1135 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME ) == SFX_ITEM_SET )
1136 nAdditional++;
1137 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE ) == SFX_ITEM_SET )
1138 nAdditional++;
1139 if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SFX_ITEM_SET )
1140 nAdditional++;
1141 if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO ) == SFX_ITEM_SET )
1142 nAdditional++;
1143 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR ) == SFX_ITEM_SET )
1144 nAdditional++;
1145 if ( rSet.GetItemState( SID_ENCRYPTIONDATA ) == SFX_ITEM_SET )
1146 nAdditional++;
1147 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME ) == SFX_ITEM_SET )
1148 nAdditional++;
1149 if ( rSet.GetItemState( SID_DOC_SERVICE ) == SFX_ITEM_SET )
1150 nAdditional++;
1151 if (rSet.HasItem(SID_FILTER_PROVIDER))
1152 ++nAdditional;
1154 // consider additional arguments
1155 nProps += nAdditional;
1156 #ifdef DBG_UTIL
1157 nItems += nAdditional;
1158 #endif
1162 #ifdef DBG_UTIL
1163 // now check the itemset: is there any item that is not convertible using the list of formal arguments
1164 // or the table of additional items?!
1165 if ( rSet.Count() != nItems )
1167 // detect unknown item and present error message
1168 const sal_uInt16 *pRanges = rSet.GetRanges();
1169 while ( *pRanges )
1171 for(sal_uInt16 nId = *pRanges++; nId <= *pRanges; ++nId)
1173 if ( rSet.GetItemState(nId) < SFX_ITEM_SET ) //???
1174 // not really set
1175 continue;
1177 if ( !pSlot->IsMode(SFX_SLOT_METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1178 continue;
1180 bool bIsMediaDescriptor = isMediaDescriptor( nSlotId );
1181 sal_uInt16 nFormalArgs = bIsMediaDescriptor ? nMediaArgsCount : pSlot->nArgDefCount;
1182 sal_uInt16 nArg;
1183 for ( nArg=0; nArg<nFormalArgs; ++nArg )
1185 const SfxFormalArgument &rArg = bIsMediaDescriptor ? aFormalArgs[nArg] : pSlot->GetFormalArgument( nArg );
1186 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1187 if ( nId == nWhich )
1188 break;
1191 if ( nArg<nFormalArgs )
1192 continue;
1194 if ( bIsMediaDescriptor )
1196 if ( nId == SID_DOCFRAME )
1197 continue;
1198 if ( nId == SID_PROGRESS_STATUSBAR_CONTROL )
1199 continue;
1200 if ( nId == SID_INTERACTIONHANDLER )
1201 continue;
1202 if ( nId == SID_VIEW_DATA )
1203 continue;
1204 if ( nId == SID_FILTER_DATA )
1205 continue;
1206 if ( nId == SID_DOCUMENT )
1207 continue;
1208 if ( nId == SID_CONTENT )
1209 continue;
1210 if ( nId == SID_INPUTSTREAM )
1211 continue;
1212 if ( nId == SID_STREAM )
1213 continue;
1214 if ( nId == SID_OUTPUTSTREAM )
1215 continue;
1216 if ( nId == SID_POSTDATA )
1217 continue;
1218 if ( nId == SID_FILLFRAME )
1219 continue;
1220 if ( nId == SID_TEMPLATE )
1221 continue;
1222 if ( nId == SID_OPEN_NEW_VIEW )
1223 continue;
1224 if ( nId == SID_VIEW_ID )
1225 continue;
1226 if ( nId == SID_PLUGIN_MODE )
1227 continue;
1228 if ( nId == SID_DOC_READONLY )
1229 continue;
1230 if ( nId == SID_DOC_STARTPRESENTATION )
1231 continue;
1232 if ( nId == SID_SELECTION )
1233 continue;
1234 if ( nId == SID_HIDDEN )
1235 continue;
1236 if ( nId == SID_MINIMIZED )
1237 continue;
1238 if ( nId == SID_SILENT )
1239 continue;
1240 if ( nId == SID_PREVIEW )
1241 continue;
1242 if ( nId == SID_VIEWONLY )
1243 continue;
1244 if ( nId == SID_EDITDOC )
1245 continue;
1246 if ( nId == SID_TARGETNAME )
1247 continue;
1248 if ( nId == SID_DOC_SALVAGE )
1249 continue;
1250 if ( nId == SID_PATH )
1251 continue;
1252 if ( nId == SID_FILE_DIALOG )
1253 continue;
1254 if ( nId == SID_STANDARD_DIR )
1255 continue;
1256 if ( nId == SID_BLACK_LIST )
1257 continue;
1258 if ( nId == SID_CONTENTTYPE )
1259 continue;
1260 if ( nId == SID_TEMPLATE_NAME )
1261 continue;
1262 if ( nId == SID_TEMPLATE_REGIONNAME )
1263 continue;
1264 if ( nId == SID_JUMPMARK )
1265 continue;
1266 if ( nId == SID_CHARSET )
1267 continue;
1268 if ( nId == SID_MACROEXECMODE )
1269 continue;
1270 if ( nId == SID_UPDATEDOCMODE )
1271 continue;
1272 if ( nId == SID_REPAIRPACKAGE )
1273 continue;
1274 if ( nId == SID_DOCINFO_TITLE )
1275 continue;
1276 if ( nId == SID_COMPONENTDATA )
1277 continue;
1278 if ( nId == SID_COMPONENTCONTEXT )
1279 continue;
1280 if ( nId == SID_DOC_BASEURL )
1281 continue;
1282 if ( nId == SID_DOC_HIERARCHICALNAME )
1283 continue;
1284 if ( nId == SID_COPY_STREAM_IF_POSSIBLE )
1285 continue;
1286 if ( nId == SID_NOAUTOSAVE )
1287 continue;
1288 if ( nId == SID_ENCRYPTIONDATA )
1289 continue;
1290 if ( nId == SID_DOC_SERVICE )
1291 continue;
1292 if (nId == SID_FILTER_PROVIDER)
1293 continue;
1295 // used only internally
1296 if ( nId == SID_SAVETO )
1297 continue;
1298 if ( nId == SID_SAVEACOPYITEM )
1299 continue;
1300 if ( nId == SID_MODIFYPASSWORDINFO )
1301 continue;
1302 if ( nId == SID_SUGGESTEDSAVEASDIR )
1303 continue;
1304 if ( nId == SID_SUGGESTEDSAVEASNAME )
1305 continue;
1308 OStringBuffer aDbg("Unknown item detected: ");
1309 aDbg.append(static_cast<sal_Int32>(nId));
1310 DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr());
1314 #endif
1316 if ( !nProps )
1317 return;
1319 // convert every item into a property
1320 uno::Sequence<beans::PropertyValue> aSequ(nProps);
1321 beans::PropertyValue *pValue = aSequ.getArray();
1323 sal_Int32 nActProp=0;
1324 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
1326 // slot is a property
1327 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
1328 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1329 SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1330 if ( pItem ) //???
1332 sal_uInt16 nSubCount = pType->nAttribs;
1333 if ( !nSubCount )
1335 pValue[nActProp].Name = OUString::createFromAscii(pSlot->pUnoName) ;
1336 if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1338 OStringBuffer aStr("Item not convertible: ");
1339 aStr.append(static_cast<sal_Int32>(nSlotId));
1340 OSL_FAIL(aStr.getStr());
1343 else
1345 // complex type, add a property value for every member of the struct
1346 for ( sal_uInt16 n=1; n<=nSubCount; ++n )
1348 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[n-1].nAID;
1349 if ( bConvertTwips )
1350 nSubId |= CONVERT_TWIPS;
1352 DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1353 OUString aName( OUString::createFromAscii( pSlot->pUnoName ) ) ;
1354 aName += ".";
1355 aName += OUString::createFromAscii( pType->aAttrib[n-1].pName ) ;
1356 pValue[nActProp].Name = aName;
1357 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1359 OStringBuffer aStr("Sub item ");
1360 aStr.append(static_cast<sal_Int32>(
1361 pType->aAttrib[n-1].nAID));
1362 aStr.append(" not convertible in slot: ");
1363 aStr.append(static_cast<sal_Int32>(nSlotId));
1364 OSL_FAIL( aStr.getStr() );
1370 rArgs = aSequ;
1371 return;
1374 // slot is a method
1375 sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1376 for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1378 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1379 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1380 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1381 SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1382 if ( pItem ) //???
1384 sal_uInt16 nSubCount = rArg.pType->nAttribs;
1385 if ( !nSubCount )
1387 pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) ;
1388 if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1390 OStringBuffer aStr("Item not convertible: ");
1391 aStr.append(static_cast<sal_Int32>(rArg.nSlotId));
1392 OSL_FAIL(aStr.getStr());
1395 else
1397 // complex type, add a property value for every member of the struct
1398 for ( sal_uInt16 n = 1; n <= nSubCount; ++n )
1400 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) rArg.pType->aAttrib[n-1].nAID;
1401 if ( bConvertTwips )
1402 nSubId |= CONVERT_TWIPS;
1404 DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1405 OUString aName( OUString::createFromAscii( rArg.pName ) ) ;
1406 aName += ".";
1407 aName += OUString::createFromAscii( rArg.pType->aAttrib[n-1].pName ) ;
1408 pValue[nActProp].Name = aName;
1409 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1411 OStringBuffer aStr("Sub item ");
1412 aStr.append(static_cast<sal_Int32>(
1413 rArg.pType->aAttrib[n-1].nAID));
1414 aStr.append(" not convertible in slot: ");
1415 aStr.append(static_cast<sal_Int32>(rArg.nSlotId));
1416 OSL_FAIL(aStr.getStr());
1423 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1424 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
1425 nSlotId == SID_SAVEACOPY )
1427 const SfxPoolItem *pItem=0;
1428 if ( rSet.GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1430 pValue[nActProp].Name = OUString(sComponentData);
1431 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1433 if ( rSet.GetItemState( SID_COMPONENTCONTEXT, sal_False, &pItem ) == SFX_ITEM_SET )
1435 pValue[nActProp].Name = OUString(sComponentContext);
1436 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1438 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, sal_False, &pItem ) == SFX_ITEM_SET )
1440 pValue[nActProp].Name = OUString(sStatusInd);
1441 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1443 if ( rSet.GetItemState( SID_INTERACTIONHANDLER, sal_False, &pItem ) == SFX_ITEM_SET )
1445 pValue[nActProp].Name = OUString(sInteractionHdl);
1446 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1448 if ( rSet.GetItemState( SID_VIEW_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1450 pValue[nActProp].Name = OUString(sViewData);
1451 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1453 if ( rSet.GetItemState( SID_FILTER_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1455 pValue[nActProp].Name = OUString(sFilterData);
1456 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1458 if ( rSet.GetItemState( SID_DOCUMENT, sal_False, &pItem ) == SFX_ITEM_SET )
1460 pValue[nActProp].Name = OUString(sModel);
1461 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1463 if ( rSet.GetItemState( SID_CONTENT, sal_False, &pItem ) == SFX_ITEM_SET )
1465 pValue[nActProp].Name = OUString(sUCBContent);
1466 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1468 if ( rSet.GetItemState( SID_INPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1470 pValue[nActProp].Name = OUString(sInputStream);
1471 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1473 if ( rSet.GetItemState( SID_STREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1475 pValue[nActProp].Name = OUString(sStream);
1476 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1478 if ( rSet.GetItemState( SID_OUTPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1480 pValue[nActProp].Name = OUString(sOutputStream);
1481 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1483 if ( rSet.GetItemState( SID_POSTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1485 pValue[nActProp].Name = OUString(sPostData);
1486 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1488 if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1490 pValue[nActProp].Name = OUString(sFrame);
1491 if ( pItem->ISA( SfxUsrAnyItem ) )
1493 OSL_FAIL( "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" );
1494 pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue();
1496 else if ( pItem->ISA( SfxUnoFrameItem ) )
1497 pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame();
1498 else
1499 OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" );
1501 if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET )
1503 pValue[nActProp].Name = OUString(sAsTemplate);
1504 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1506 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1508 pValue[nActProp].Name = OUString(sOpenNewView);
1509 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1511 if ( rSet.GetItemState( SID_FAIL_ON_WARNING, sal_False, &pItem ) == SFX_ITEM_SET )
1513 pValue[nActProp].Name = OUString(sFailOnWarning);
1514 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1516 if ( rSet.GetItemState( SID_VIEW_ID, sal_False, &pItem ) == SFX_ITEM_SET )
1518 pValue[nActProp].Name = OUString(sViewId);
1519 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1521 if ( rSet.GetItemState( SID_PLUGIN_MODE, sal_False, &pItem ) == SFX_ITEM_SET )
1523 pValue[nActProp].Name = OUString(sPluginMode);
1524 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1526 if ( rSet.GetItemState( SID_DOC_READONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1528 pValue[nActProp].Name = OUString(sReadOnly);
1529 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1531 if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD, sal_False, &pItem ) == SFX_ITEM_SET )
1533 pValue[nActProp].Name = OUString(sDdeReconnect);
1534 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1536 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, sal_False, &pItem ) == SFX_ITEM_SET )
1538 pValue[nActProp].Name = OUString(sStartPresentation);
1539 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1541 if ( rSet.GetItemState( SID_SELECTION, sal_False, &pItem ) == SFX_ITEM_SET )
1543 pValue[nActProp].Name = OUString(sSelectionOnly);
1544 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1546 if ( rSet.GetItemState( SID_HIDDEN, sal_False, &pItem ) == SFX_ITEM_SET )
1548 pValue[nActProp].Name = OUString(sHidden);
1549 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1551 if ( rSet.GetItemState( SID_MINIMIZED, sal_False, &pItem ) == SFX_ITEM_SET )
1553 pValue[nActProp].Name = OUString(sMinimized);
1554 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1556 if ( rSet.GetItemState( SID_SILENT, sal_False, &pItem ) == SFX_ITEM_SET )
1558 pValue[nActProp].Name = OUString(sSilent);
1559 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1561 if ( rSet.GetItemState( SID_PREVIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1563 pValue[nActProp].Name = OUString(sPreview);
1564 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1566 if ( rSet.GetItemState( SID_VIEWONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1568 pValue[nActProp].Name = OUString(sViewOnly);
1569 pValue[nActProp++].Value <<= (sal_Bool) (( ((SfxBoolItem*)pItem)->GetValue() ));
1571 if ( rSet.GetItemState( SID_EDITDOC, sal_False, &pItem ) == SFX_ITEM_SET )
1573 pValue[nActProp].Name = OUString(sDontEdit);
1574 pValue[nActProp++].Value <<= (sal_Bool) (!( ((SfxBoolItem*)pItem)->GetValue() ));
1576 if ( rSet.GetItemState( SID_FILE_DIALOG, sal_False, &pItem ) == SFX_ITEM_SET )
1578 pValue[nActProp].Name = OUString(sUseSystemDialog);
1579 pValue[nActProp++].Value <<= (sal_Bool) ( ((SfxBoolItem*)pItem)->GetValue() );
1581 if ( rSet.GetItemState( SID_STANDARD_DIR, sal_False, &pItem ) == SFX_ITEM_SET )
1583 pValue[nActProp].Name = OUString(sStandardDir);
1584 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1586 if ( rSet.GetItemState( SID_BLACK_LIST, sal_False, &pItem ) == SFX_ITEM_SET )
1588 pValue[nActProp].Name = OUString(sBlackList);
1590 com::sun::star::uno::Sequence< OUString > aList;
1591 ((SfxStringListItem*)pItem)->GetStringList( aList );
1592 pValue[nActProp++].Value <<= aList ;
1594 if ( rSet.GetItemState( SID_TARGETNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1596 pValue[nActProp].Name = OUString(sFrameName);
1597 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1599 if ( rSet.GetItemState( SID_DOC_SALVAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1601 pValue[nActProp].Name = OUString(sSalvagedFile);
1602 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1604 if ( rSet.GetItemState( SID_PATH, sal_False, &pItem ) == SFX_ITEM_SET )
1606 pValue[nActProp].Name = OUString(sFolderName);
1607 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1609 if ( rSet.GetItemState( SID_CONTENTTYPE, sal_False, &pItem ) == SFX_ITEM_SET )
1611 pValue[nActProp].Name = OUString(sMediaType);
1612 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1614 if ( rSet.GetItemState( SID_TEMPLATE_NAME, sal_False, &pItem ) == SFX_ITEM_SET )
1616 pValue[nActProp].Name = OUString(sTemplateName);
1617 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1619 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1621 pValue[nActProp].Name = OUString(sTemplateRegionName);
1622 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1624 if ( rSet.GetItemState( SID_JUMPMARK, sal_False, &pItem ) == SFX_ITEM_SET )
1626 pValue[nActProp].Name = OUString(sJumpMark);
1627 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1630 if ( rSet.GetItemState( SID_CHARSET, sal_False, &pItem ) == SFX_ITEM_SET )
1632 pValue[nActProp].Name = OUString(sCharacterSet);
1633 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1635 if ( rSet.GetItemState( SID_MACROEXECMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1637 pValue[nActProp].Name = OUString(sMacroExecMode);
1638 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1640 if ( rSet.GetItemState( SID_UPDATEDOCMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1642 pValue[nActProp].Name = OUString(sUpdateDocMode);
1643 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1645 if ( rSet.GetItemState( SID_REPAIRPACKAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1647 pValue[nActProp].Name = OUString(sRepairPackage);
1648 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1650 if ( rSet.GetItemState( SID_DOCINFO_TITLE, sal_False, &pItem ) == SFX_ITEM_SET )
1652 pValue[nActProp].Name = OUString(sDocumentTitle);
1653 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1655 if ( rSet.GetItemState( SID_DOC_BASEURL, sal_False, &pItem ) == SFX_ITEM_SET )
1657 pValue[nActProp].Name = OUString(sDocumentBaseURL);
1658 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1660 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1662 pValue[nActProp].Name = OUString(sHierarchicalDocumentName);
1663 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1665 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, sal_False, &pItem ) == SFX_ITEM_SET )
1667 pValue[nActProp].Name = OUString(sCopyStreamIfPossible);
1668 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1670 if ( rSet.GetItemState( SID_NOAUTOSAVE, sal_False, &pItem ) == SFX_ITEM_SET )
1672 pValue[nActProp].Name = OUString(sNoAutoSave);
1673 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1675 if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, sal_False, &pItem ) == SFX_ITEM_SET )
1677 pValue[nActProp].Name = OUString(sModifyPasswordInfo);
1678 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1680 if ( rSet.GetItemState( SID_ENCRYPTIONDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1682 pValue[nActProp].Name = OUString(sEncryptionData);
1683 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1685 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, sal_False, &pItem ) == SFX_ITEM_SET )
1687 pValue[nActProp].Name = OUString(sSuggestedSaveAsDir);
1688 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1690 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1692 pValue[nActProp].Name = OUString(sSuggestedSaveAsName);
1693 pValue[nActProp++].Value <<= ( OUString(((SfxStringItem*)pItem)->GetValue()) );
1695 if ( rSet.GetItemState( SID_DOC_SERVICE, sal_False, &pItem ) == SFX_ITEM_SET )
1697 pValue[nActProp].Name = OUString(sDocumentService);
1698 pValue[nActProp++].Value <<= OUString(static_cast<const SfxStringItem*>(pItem)->GetValue());
1700 if (rSet.HasItem(SID_FILTER_PROVIDER, &pItem))
1702 pValue[nActProp].Name = sFilterProvider;
1703 pValue[nActProp++].Value <<= OUString(static_cast<const SfxStringItem*>(pItem)->GetValue());
1707 rArgs = aSequ;
1710 SFX_IMPL_XSERVICEINFO( SfxMacroLoader, PROTOCOLHANDLER_SERVICENAME, "com.sun.star.comp.sfx2.SfxMacroLoader" )
1711 SFX_IMPL_SINGLEFACTORY( SfxMacroLoader )
1713 void SAL_CALL SfxMacroLoader::initialize( const uno::Sequence<uno::Any>& aArguments ) throw (uno::Exception, uno::RuntimeException)
1715 Reference < XFrame > xFrame;
1716 if ( aArguments.getLength() )
1718 aArguments[0] >>= xFrame;
1719 m_xFrame = xFrame;
1723 SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
1725 SfxObjectShell* pDocShell = NULL;
1726 Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
1727 if ( xFrame.is() )
1729 SfxFrame* pFrame=0;
1730 for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
1732 if ( pFrame->GetFrameInterface() == xFrame )
1733 break;
1736 if ( pFrame )
1737 pDocShell = pFrame->GetCurrentDocument();
1740 return pDocShell;
1743 // -----------------------------------------------------------------------
1744 uno::Reference<frame::XDispatch> SAL_CALL SfxMacroLoader::queryDispatch(
1745 const util::URL& aURL ,
1746 const OUString& /*sTargetFrameName*/,
1747 sal_Int32 /*nSearchFlags*/ ) throw( uno::RuntimeException )
1749 uno::Reference<frame::XDispatch> xDispatcher;
1750 if(aURL.Complete.startsWith("macro:"))
1751 xDispatcher = this;
1752 return xDispatcher;
1755 // -----------------------------------------------------------------------
1756 uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL
1757 SfxMacroLoader::queryDispatches( const uno::Sequence < frame::DispatchDescriptor >& seqDescriptor )
1758 throw( uno::RuntimeException )
1760 sal_Int32 nCount = seqDescriptor.getLength();
1761 uno::Sequence< uno::Reference<frame::XDispatch> > lDispatcher(nCount);
1762 for( sal_Int32 i=0; i<nCount; ++i )
1763 lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1764 seqDescriptor[i].FrameName,
1765 seqDescriptor[i].SearchFlags );
1766 return lDispatcher;
1769 // -----------------------------------------------------------------------
1770 void SAL_CALL SfxMacroLoader::dispatchWithNotification(
1771 const util::URL& aURL, const uno::Sequence<beans::PropertyValue>& /*lArgs*/,
1772 const uno::Reference<frame::XDispatchResultListener>& xListener )
1773 throw (uno::RuntimeException)
1775 SolarMutexGuard aGuard;
1777 uno::Any aAny;
1778 ErrCode nErr = loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1779 if( xListener.is() )
1781 // always call dispatchFinished(), because we didn't load a document but
1782 // executed a macro instead!
1783 frame::DispatchResultEvent aEvent;
1785 aEvent.Source = static_cast< ::cppu::OWeakObject* >(this);
1786 if( nErr == ERRCODE_NONE )
1787 aEvent.State = frame::DispatchResultState::SUCCESS;
1788 else
1789 aEvent.State = frame::DispatchResultState::FAILURE;
1791 xListener->dispatchFinished( aEvent ) ;
1795 uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue(
1796 const util::URL& aURL, const uno::Sequence<beans::PropertyValue>& )
1797 throw (uno::RuntimeException)
1799 uno::Any aRet;
1800 loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() );
1801 return aRet;
1804 void SAL_CALL SfxMacroLoader::dispatch(
1805 const util::URL& aURL, const uno::Sequence<beans::PropertyValue>& /*lArgs*/ )
1806 throw (uno::RuntimeException)
1808 SolarMutexGuard aGuard;
1810 uno::Any aAny;
1811 loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1814 void SAL_CALL SfxMacroLoader::addStatusListener(
1815 const uno::Reference< frame::XStatusListener >& ,
1816 const util::URL& )
1817 throw (uno::RuntimeException)
1819 /* TODO
1820 How we can handle different listener for further coming or currently running dispatch() jobs
1821 without any inconsistency!
1825 // -----------------------------------------------------------------------
1826 void SAL_CALL SfxMacroLoader::removeStatusListener(
1827 const uno::Reference< frame::XStatusListener >&,
1828 const util::URL& )
1829 throw (uno::RuntimeException)
1833 ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, com::sun::star::uno::Any& rRetval, SfxObjectShell* pSh )
1834 throw ( uno::RuntimeException )
1836 #ifdef DISABLE_SCRIPTING
1837 (void) rURL;
1838 (void) rRetval;
1839 (void) pSh;
1840 return ERRCODE_BASIC_PROC_UNDEFINED;
1841 #else
1842 SfxObjectShell* pCurrent = pSh;
1843 if ( !pCurrent )
1844 // all not full qualified names use the BASIC of the given or current document
1845 pCurrent = SfxObjectShell::Current();
1847 // 'macro:///lib.mod.proc(args)' => macro of App-BASIC
1848 // 'macro://[docname|.]/lib.mod.proc(args)' => macro of current or qualified document
1849 // 'macro://obj.method(args)' => direct API call, execute it via App-BASIC
1850 OUString aMacro( rURL );
1851 sal_Int32 nHashPos = aMacro.indexOf( '/', 8 );
1852 sal_Int32 nArgsPos = aMacro.indexOf( '(' );
1853 BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
1854 BasicManager *pBasMgr = 0;
1855 ErrCode nErr = ERRCODE_NONE;
1857 // should a macro function be executed ( no direct API call)?
1858 if ( -1 != nHashPos && ( -1 == nArgsPos || nHashPos < nArgsPos ) )
1860 // find BasicManager
1861 SfxObjectShell* pDoc = NULL;
1862 OUString aBasMgrName( INetURLObject::decode(aMacro.copy( 8, nHashPos-8 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1863 if ( aBasMgrName.isEmpty() )
1864 pBasMgr = pAppMgr;
1865 else if ( aBasMgrName == "." )
1867 // current/actual document
1868 pDoc = pCurrent;
1869 if (pDoc)
1870 pBasMgr = pDoc->GetBasicManager();
1872 else
1874 // full qualified name, find document by name
1875 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
1876 pObjSh && !pBasMgr;
1877 pObjSh = SfxObjectShell::GetNext(*pObjSh) )
1878 if ( aBasMgrName == pObjSh->GetTitle(SFX_TITLE_APINAME) )
1880 pDoc = pObjSh;
1881 pBasMgr = pDoc->GetBasicManager();
1885 if ( pBasMgr )
1887 const bool bIsAppBasic = ( pBasMgr == pAppMgr );
1888 const bool bIsDocBasic = ( pBasMgr != pAppMgr );
1890 if ( pDoc )
1892 // security check for macros from document basic if an SFX doc is given
1893 if ( !pDoc->AdjustMacroMode( OUString() ) )
1894 // check forbids execution
1895 return ERRCODE_IO_ACCESSDENIED;
1897 else if ( pDoc && pDoc->GetMedium() )
1899 pDoc->AdjustMacroMode( OUString() );
1900 SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
1901 SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False);
1902 if ( pUpdateDocItem && pMacroExecModeItem
1903 && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE
1904 && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE )
1905 return ERRCODE_IO_ACCESSDENIED;
1908 // find BASIC method
1909 OUString aQualifiedMethod( INetURLObject::decode(aMacro.copy( nHashPos+1 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1910 OUString aArgs;
1911 if ( -1 != nArgsPos )
1913 // remove arguments from macro name
1914 aArgs = aQualifiedMethod.copy( nArgsPos - nHashPos - 1 );
1915 aQualifiedMethod = aQualifiedMethod.copy( 0, nArgsPos - nHashPos - 1 );
1918 if ( pBasMgr->HasMacro( aQualifiedMethod ) )
1920 Any aOldThisComponent;
1921 const bool bSetDocMacroMode = ( pDoc != NULL ) && bIsDocBasic;
1922 const bool bSetGlobalThisComponent = ( pDoc != NULL ) && bIsAppBasic;
1923 if ( bSetDocMacroMode )
1925 // mark document: it executes an own macro, so it's in a modal mode
1926 pDoc->SetMacroMode_Impl( sal_True );
1929 if ( bSetGlobalThisComponent )
1931 // document is executed via AppBASIC, adjust ThisComponent variable
1932 aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pDoc->GetModel() ) );
1935 // just to let the shell be alive
1936 SfxObjectShellRef xKeepDocAlive = pDoc;
1939 // attempt to protect the document against the script tampering with its Undo Context
1940 ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
1941 if ( bIsDocBasic )
1942 pUndoGuard.reset( new ::framework::DocumentUndoGuard( pDoc->GetModel() ) );
1944 // execute the method
1945 SbxVariableRef retValRef = new SbxVariable;
1946 nErr = pBasMgr->ExecuteMacro( aQualifiedMethod, aArgs, retValRef );
1947 if ( nErr == ERRCODE_NONE )
1948 rRetval = sbxToUnoValue( retValRef );
1951 if ( bSetGlobalThisComponent )
1953 pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent );
1956 if ( bSetDocMacroMode )
1958 // remove flag for modal mode
1959 pDoc->SetMacroMode_Impl( sal_False );
1962 else
1963 nErr = ERRCODE_BASIC_PROC_UNDEFINED;
1965 else
1966 nErr = ERRCODE_IO_NOTEXISTS;
1968 else
1970 // direct API call on a specified object
1971 OUStringBuffer aCall;
1972 aCall.append('[').append(INetURLObject::decode(aMacro.copy(6), INET_HEX_ESCAPE,
1973 INetURLObject::DECODE_WITH_CHARSET));
1974 aCall.append(']');
1975 pAppMgr->GetLib(0)->Execute(aCall.makeStringAndClear());
1976 nErr = SbxBase::GetError();
1979 SbxBase::ResetError();
1980 return nErr;
1981 #endif
1984 /* XServiceInfo */
1985 OUString SAL_CALL SfxAppDispatchProvider::getImplementationName() throw( css::uno::RuntimeException )
1987 return impl_getStaticImplementationName();
1990 /* XServiceInfo */
1991 sal_Bool SAL_CALL SfxAppDispatchProvider::supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException )
1993 return cppu::supportsService(this, sServiceName);
1996 /* XServiceInfo */
1997 css::uno::Sequence< OUString > SAL_CALL SfxAppDispatchProvider::getSupportedServiceNames() throw( css::uno::RuntimeException )
1999 return impl_getStaticSupportedServiceNames();
2002 /* Helper for XServiceInfo */
2003 css::uno::Sequence< OUString > SfxAppDispatchProvider::impl_getStaticSupportedServiceNames()
2005 css::uno::Sequence< OUString > seqServiceNames( 2 );
2006 seqServiceNames.getArray()[0] = "com.sun.star.frame.DispatchProvider";
2007 seqServiceNames.getArray()[1] = "com.sun.star.frame.AppDispatchProvider";
2008 return seqServiceNames;
2011 /* Helper for XServiceInfo */
2012 OUString SfxAppDispatchProvider::impl_getStaticImplementationName()
2014 return OUString( "com.sun.star.comp.sfx2.AppDispatchProvider" );
2017 /* Helper for registry */
2018 css::uno::Reference< css::uno::XInterface > SAL_CALL SfxAppDispatchProvider::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception )
2020 return css::uno::Reference< css::uno::XInterface >( *new SfxAppDispatchProvider( xServiceManager ) );
2023 SFX_IMPL_SINGLEFACTORY( SfxAppDispatchProvider );
2025 void SAL_CALL SfxAppDispatchProvider::initialize( const uno::Sequence<uno::Any>& aArguments ) throw (uno::Exception, uno::RuntimeException)
2027 Reference < XFrame > xFrame;
2028 if ( aArguments.getLength() )
2030 aArguments[0] >>= xFrame;
2031 m_xFrame = xFrame;
2035 Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch(
2036 const util::URL& aURL,
2037 const OUString& /*sTargetFrameName*/,
2038 FrameSearchFlags /*eSearchFlags*/ ) throw( RuntimeException )
2040 sal_uInt16 nId( 0 );
2041 sal_Bool bMasterCommand( sal_False );
2042 Reference < XDispatch > xDisp;
2043 const SfxSlot* pSlot = 0;
2044 SfxDispatcher* pAppDisp = SFX_APP()->GetAppDispatcher_Impl();
2045 if ( aURL.Protocol == "slot:" || aURL.Protocol == "commandId:" )
2047 nId = (sal_uInt16) aURL.Path.toInt32();
2048 SfxShell* pShell;
2049 pAppDisp->GetShellAndSlot_Impl( nId, &pShell, &pSlot, sal_True, sal_True );
2051 else if ( aURL.Protocol == ".uno:" )
2053 // Support ".uno" commands. Map commands to slotid
2054 bMasterCommand = SfxOfficeDispatch::IsMasterUnoCommand( aURL );
2055 if ( bMasterCommand )
2056 pSlot = pAppDisp->GetSlot( SfxOfficeDispatch::GetMasterUnoCommand( aURL ) );
2057 else
2058 pSlot = pAppDisp->GetSlot( aURL.Main );
2061 if ( pSlot )
2063 SfxOfficeDispatch* pDispatch = new SfxOfficeDispatch( pAppDisp, pSlot, aURL ) ;
2064 pDispatch->SetFrame(m_xFrame);
2065 pDispatch->SetMasterUnoCommand( bMasterCommand );
2066 xDisp = pDispatch;
2069 return xDisp;
2072 Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispatches( const Sequence < DispatchDescriptor >& seqDescriptor )
2073 throw( RuntimeException )
2075 sal_Int32 nCount = seqDescriptor.getLength();
2076 uno::Sequence< uno::Reference < frame::XDispatch > > lDispatcher(nCount);
2077 for( sal_Int32 i=0; i<nCount; ++i )
2078 lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
2079 seqDescriptor[i].FrameName,
2080 seqDescriptor[i].SearchFlags );
2081 return lDispatcher;
2084 Sequence< sal_Int16 > SAL_CALL SfxAppDispatchProvider::getSupportedCommandGroups()
2085 throw (uno::RuntimeException)
2087 SolarMutexGuard aGuard;
2089 std::list< sal_Int16 > aGroupList;
2090 SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2092 const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2094 // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2095 for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2097 pAppSlotPool->SeekGroup( i );
2098 const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2099 while ( pSfxSlot )
2101 if ( pSfxSlot->GetMode() & nMode )
2103 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2104 aGroupList.push_back( nCommandGroup );
2105 break;
2107 pSfxSlot = pAppSlotPool->NextSlot();
2111 uno::Sequence< sal_Int16 > aSeq =
2112 comphelper::containerToSequence< sal_Int16, std::list< sal_Int16 > >( aGroupList );
2114 return aSeq;
2117 Sequence< frame::DispatchInformation > SAL_CALL SfxAppDispatchProvider::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
2118 throw (uno::RuntimeException)
2120 std::list< frame::DispatchInformation > aCmdList;
2122 SolarMutexGuard aGuard;
2123 SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2125 if ( pAppSlotPool )
2127 const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2128 OUString aCmdPrefix( ".uno:" );
2130 // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2131 for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2133 pAppSlotPool->SeekGroup( i );
2134 const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2135 if ( pSfxSlot )
2137 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2138 if ( nCommandGroup == nCmdGroup )
2140 while ( pSfxSlot )
2142 if ( pSfxSlot->GetMode() & nMode )
2144 frame::DispatchInformation aCmdInfo;
2145 OUStringBuffer aBuf( aCmdPrefix );
2146 aBuf.appendAscii( pSfxSlot->GetUnoName() );
2147 aCmdInfo.Command = aBuf.makeStringAndClear();
2148 aCmdInfo.GroupId = nCommandGroup;
2149 aCmdList.push_back( aCmdInfo );
2151 pSfxSlot = pAppSlotPool->NextSlot();
2158 uno::Sequence< frame::DispatchInformation > aSeq =
2159 comphelper::containerToSequence< frame::DispatchInformation, std::list< frame::DispatchInformation > >( aCmdList );
2161 return aSeq;
2164 #ifdef TEST_HANDLERS
2165 #include <cppuhelper/implbase2.hxx>
2167 #include <com/sun/star/awt/XKeyHandler.hpp>
2168 #include <com/sun/star/awt/XMouseClickHandler.hpp>
2170 class TestKeyHandler: public ::cppu::WeakImplHelper2
2172 com::sun::star::awt::XKeyHandler,
2173 com::sun::star::lang::XServiceInfo
2176 public:
2177 TestKeyHandler( const com::sun::star::uno::Reference < lang::XMultiServiceFactory >& ){}
2179 SFX_DECL_XSERVICEINFO
2180 virtual sal_Bool SAL_CALL keyPressed( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException);
2181 virtual sal_Bool SAL_CALL keyReleased( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException);
2182 virtual void SAL_CALL disposing( const lang::EventObject& Source)
2183 throw (uno::RuntimeException);
2186 class TestMouseClickHandler: public ::cppu::WeakImplHelper2
2188 com::sun::star::awt::XMouseClickHandler,
2189 com::sun::star::lang::XServiceInfo
2192 public:
2193 TestMouseClickHandler( const com::sun::star::uno::Reference < lang::XMultiServiceFactory >& ){}
2195 SFX_DECL_XSERVICEINFO
2196 virtual sal_Bool SAL_CALL mousePressed( const awt::MouseEvent& e ) throw (uno::RuntimeException);
2197 virtual sal_Bool SAL_CALL mouseReleased( const awt::MouseEvent& e ) throw (uno::RuntimeException);
2198 virtual void SAL_CALL disposing( const lang::EventObject& Source)
2199 throw (uno::RuntimeException);
2202 sal_Bool SAL_CALL TestKeyHandler::keyPressed( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException)
2204 return sal_False;
2207 sal_Bool SAL_CALL TestKeyHandler::keyReleased( const awt::KeyEvent& aEvent ) throw (uno::RuntimeException)
2209 return sal_False;
2212 void SAL_CALL TestKeyHandler::disposing( const lang::EventObject& Source) throw (uno::RuntimeException)
2216 sal_Bool SAL_CALL TestMouseClickHandler::mousePressed( const awt::MouseEvent& e ) throw (uno::RuntimeException)
2218 return sal_False;
2221 sal_Bool SAL_CALL TestMouseClickHandler::mouseReleased( const awt::MouseEvent& e ) throw (uno::RuntimeException)
2223 return sal_False;
2226 void SAL_CALL TestMouseClickHandler::disposing( const lang::EventObject& Source) throw (uno::RuntimeException)
2230 SFX_IMPL_XSERVICEINFO( TestKeyHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.KeyHandler");
2231 SFX_IMPL_XSERVICEINFO( TestMouseClickHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.MouseClickHandler");
2232 SFX_IMPL_SINGLEFACTORY( TestKeyHandler );
2233 SFX_IMPL_SINGLEFACTORY( TestMouseClickHandler );
2234 #endif
2235 // -----------------------------------------------------------------------
2237 extern "C" {
2239 SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory(
2240 const sal_Char* pImplementationName ,
2241 void* pServiceManager ,
2242 void* )
2244 // Set default return value for this operation - if it failed.
2245 void* pReturn = NULL ;
2247 if (
2248 ( pImplementationName != NULL ) &&
2249 ( pServiceManager != NULL )
2252 // Define variables which are used in following macros.
2253 uno::Reference<uno::XInterface> xFactory;
2254 uno::Reference<lang::XMultiServiceFactory> xServiceManager( reinterpret_cast<lang::XMultiServiceFactory*>( pServiceManager ) ) ;
2256 //=============================================================================
2257 // Add new macro line to handle new service.
2258 // !!! ATTENTION !!!
2259 // Write no ";" at end of line and dont forget "else" ! (see macro)
2260 //=============================================================================
2261 IF_NAME_CREATECOMPONENTFACTORY( BackingComp )
2262 IF_NAME_CREATECOMPONENTFACTORY( SfxGlobalEvents_Impl )
2263 IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl )
2264 IF_NAME_CREATECOMPONENTFACTORY( SfxMacroLoader )
2265 IF_NAME_CREATECOMPONENTFACTORY( SfxAppDispatchProvider )
2266 IF_NAME_CREATECOMPONENTFACTORY( SfxDocTplService )
2267 IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon )
2268 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationScriptLibraryContainer )
2269 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationDialogLibraryContainer )
2270 #ifdef TEST_HANDLERS
2271 IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
2272 IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler )
2273 #endif
2274 IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator )
2275 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject )
2276 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject )
2277 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService )
2278 if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
2279 OUString::createFromAscii( pImplementationName ) ) )
2281 xFactory = ::cppu::createSingleComponentFactory(
2282 ::comp_SfxDocumentMetaData::_create,
2283 ::comp_SfxDocumentMetaData::_getImplementationName(),
2284 ::comp_SfxDocumentMetaData::_getSupportedServiceNames());
2286 if ( ::comp_CompatWriterDocProps::_getImplementationName().equals(
2287 OUString::createFromAscii( pImplementationName ) ) )
2289 xFactory = ::cppu::createSingleComponentFactory(
2290 ::comp_CompatWriterDocProps::_create,
2291 ::comp_CompatWriterDocProps::_getImplementationName(),
2292 ::comp_CompatWriterDocProps::_getSupportedServiceNames());
2295 // Factory is valid - service was found.
2297 // Factory is valid - service was found.
2298 if ( xFactory.is() )
2300 xFactory->acquire();
2301 pReturn = xFactory.get();
2304 // Return with result of this operation.
2305 return pReturn ;
2307 } // extern "C"
2309 //=========================================================================
2311 void SAL_CALL FilterOptionsContinuation::setFilterOptions(
2312 const uno::Sequence<beans::PropertyValue>& rProps )
2313 throw (uno::RuntimeException)
2315 rProperties = rProps;
2318 uno::Sequence< beans::PropertyValue > SAL_CALL
2319 FilterOptionsContinuation::getFilterOptions()
2320 throw (uno::RuntimeException)
2322 return rProperties;
2325 //=========================================================================
2327 RequestFilterOptions::RequestFilterOptions( uno::Reference< frame::XModel > rModel,
2328 uno::Sequence< beans::PropertyValue > rProperties )
2330 OUString temp;
2331 uno::Reference< uno::XInterface > temp2;
2332 document::FilterOptionsRequest aOptionsRequest( temp,
2333 temp2,
2334 rModel,
2335 rProperties );
2337 m_aRequest <<= aOptionsRequest;
2339 m_pAbort = new comphelper::OInteractionAbort;
2340 m_pOptions = new FilterOptionsContinuation;
2342 m_lContinuations.realloc( 2 );
2343 m_lContinuations[0] = uno::Reference< task::XInteractionContinuation >( m_pAbort );
2344 m_lContinuations[1] = uno::Reference< task::XInteractionContinuation >( m_pOptions );
2347 uno::Any SAL_CALL RequestFilterOptions::getRequest()
2348 throw( uno::RuntimeException )
2350 return m_aRequest;
2353 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
2354 SAL_CALL RequestFilterOptions::getContinuations()
2355 throw( uno::RuntimeException )
2357 return m_lContinuations;
2360 //=========================================================================
2361 class RequestPackageReparation_Impl : public ::cppu::WeakImplHelper1< task::XInteractionRequest >
2363 uno::Any m_aRequest;
2364 uno::Sequence< uno::Reference< task::XInteractionContinuation > > m_lContinuations;
2365 comphelper::OInteractionApprove* m_pApprove;
2366 comphelper::OInteractionDisapprove* m_pDisapprove;
2368 public:
2369 RequestPackageReparation_Impl( OUString aName );
2370 sal_Bool isApproved();
2371 virtual uno::Any SAL_CALL getRequest() throw( uno::RuntimeException );
2372 virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations()
2373 throw( uno::RuntimeException );
2376 RequestPackageReparation_Impl::RequestPackageReparation_Impl( OUString aName )
2378 OUString temp;
2379 uno::Reference< uno::XInterface > temp2;
2380 document::BrokenPackageRequest aBrokenPackageRequest( temp,
2381 temp2,
2382 aName );
2383 m_aRequest <<= aBrokenPackageRequest;
2384 m_pApprove = new comphelper::OInteractionApprove;
2385 m_pDisapprove = new comphelper::OInteractionDisapprove;
2386 m_lContinuations.realloc( 2 );
2387 m_lContinuations[0] = uno::Reference< task::XInteractionContinuation >( m_pApprove );
2388 m_lContinuations[1] = uno::Reference< task::XInteractionContinuation >( m_pDisapprove );
2391 sal_Bool RequestPackageReparation_Impl::isApproved()
2393 return m_pApprove->wasSelected();
2396 uno::Any SAL_CALL RequestPackageReparation_Impl::getRequest()
2397 throw( uno::RuntimeException )
2399 return m_aRequest;
2402 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
2403 SAL_CALL RequestPackageReparation_Impl::getContinuations()
2404 throw( uno::RuntimeException )
2406 return m_lContinuations;
2409 RequestPackageReparation::RequestPackageReparation( OUString aName )
2411 pImp = new RequestPackageReparation_Impl( aName );
2412 pImp->acquire();
2415 RequestPackageReparation::~RequestPackageReparation()
2417 pImp->release();
2420 sal_Bool RequestPackageReparation::isApproved()
2422 return pImp->isApproved();
2425 com::sun::star::uno::Reference < task::XInteractionRequest > RequestPackageReparation::GetRequest()
2427 return com::sun::star::uno::Reference < task::XInteractionRequest >(pImp);
2430 //=========================================================================
2431 class NotifyBrokenPackage_Impl : public ::cppu::WeakImplHelper1< task::XInteractionRequest >
2433 uno::Any m_aRequest;
2434 uno::Sequence< uno::Reference< task::XInteractionContinuation > > m_lContinuations;
2435 comphelper::OInteractionAbort* m_pAbort;
2437 public:
2438 NotifyBrokenPackage_Impl( OUString aName );
2439 virtual uno::Any SAL_CALL getRequest() throw( uno::RuntimeException );
2440 virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations()
2441 throw( uno::RuntimeException );
2444 NotifyBrokenPackage_Impl::NotifyBrokenPackage_Impl( OUString aName )
2446 OUString temp;
2447 uno::Reference< uno::XInterface > temp2;
2448 document::BrokenPackageRequest aBrokenPackageRequest( temp,
2449 temp2,
2450 aName );
2451 m_aRequest <<= aBrokenPackageRequest;
2452 m_pAbort = new comphelper::OInteractionAbort;
2453 m_lContinuations.realloc( 1 );
2454 m_lContinuations[0] = uno::Reference< task::XInteractionContinuation >( m_pAbort );
2457 uno::Any SAL_CALL NotifyBrokenPackage_Impl::getRequest()
2458 throw( uno::RuntimeException )
2460 return m_aRequest;
2463 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
2464 SAL_CALL NotifyBrokenPackage_Impl::getContinuations()
2465 throw( uno::RuntimeException )
2467 return m_lContinuations;
2470 NotifyBrokenPackage::NotifyBrokenPackage( OUString aName )
2472 pImp = new NotifyBrokenPackage_Impl( aName );
2473 pImp->acquire();
2476 NotifyBrokenPackage::~NotifyBrokenPackage()
2478 pImp->release();
2481 com::sun::star::uno::Reference < task::XInteractionRequest > NotifyBrokenPackage::GetRequest()
2483 return com::sun::star::uno::Reference < task::XInteractionRequest >(pImp);
2486 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */