Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / appuno.cxx
blobc97370567e2043b8b096238cb1932b3c4d7e9be6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
30 #pragma warning( disable : 4290 )
31 #endif
32 #include <com/sun/star/document/UpdateDocMode.hpp>
34 #include "sal/config.h"
36 #include <sfx2/appuno.hxx>
37 #include "appbaslib.hxx"
39 #include "sfx2/dllapi.h"
41 #include <basic/sbx.hxx>
42 #include <svl/itempool.hxx>
43 #include <svl/rectitem.hxx>
44 #include <tools/debug.hxx>
46 #include <tools/urlobj.hxx>
47 #include <tools/config.hxx>
48 #include <basic/sbxmeth.hxx>
49 #include <basic/sbmeth.hxx>
50 #include <basic/sbxobj.hxx>
51 #include <basic/sberrors.hxx>
52 #include <basic/basmgr.hxx>
53 #include <basic/sbuno.hxx>
55 #include <basic/sbxcore.hxx>
56 #include <svl/ownlist.hxx>
57 #include <svl/lckbitem.hxx>
58 #include <svl/stritem.hxx>
59 #include <svl/slstitm.hxx>
60 #include <svl/intitem.hxx>
61 #include <svl/eitem.hxx>
62 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
63 #include <com/sun/star/task/XInteractionHandler.hpp>
64 #include <com/sun/star/io/XInputStream.hpp>
65 #include <com/sun/star/beans/XPropertySet.hpp>
66 #include <com/sun/star/frame/XFrameActionListener.hpp>
67 #include <com/sun/star/frame/XComponentLoader.hpp>
68 #include <com/sun/star/frame/XFrame.hpp>
69 #include <com/sun/star/frame/FrameActionEvent.hpp>
70 #include <com/sun/star/frame/FrameAction.hpp>
71 #include <com/sun/star/container/XContainer.hpp>
72 #include <com/sun/star/container/XIndexContainer.hpp>
73 #include <com/sun/star/container/XNameReplace.hpp>
74 #include <com/sun/star/container/XContainerListener.hpp>
75 #include <com/sun/star/container/XSet.hpp>
76 #include <com/sun/star/container/ContainerEvent.hpp>
77 #include <com/sun/star/container/XIndexReplace.hpp>
78 #include <com/sun/star/container/XNameContainer.hpp>
79 #include <com/sun/star/awt/XTopWindow.hpp>
80 #include <com/sun/star/awt/XWindow.hpp>
81 #include <com/sun/star/awt/PosSize.hpp>
82 #include <com/sun/star/registry/RegistryValueType.hpp>
83 #include <comphelper/processfactory.hxx>
84 #include <com/sun/star/awt/XButton.hpp>
85 #include <com/sun/star/frame/DispatchResultEvent.hpp>
86 #include <com/sun/star/frame/DispatchResultState.hpp>
87 #include <com/sun/star/frame/XModel.hpp>
88 #include <com/sun/star/document/MacroExecMode.hpp>
89 #include <com/sun/star/ucb/XContent.hpp>
91 #include <osl/mutex.hxx>
92 #include <comphelper/sequence.hxx>
93 #include <framework/documentundoguard.hxx>
94 #include <rtl/ustrbuf.hxx>
95 #include <comphelper/interaction.hxx>
97 using namespace ::com::sun::star;
98 using namespace ::com::sun::star::ucb;
99 using namespace ::com::sun::star::uno;
100 using namespace ::com::sun::star::registry;
101 using namespace ::com::sun::star::frame;
102 using namespace ::com::sun::star::beans;
103 using namespace ::com::sun::star::io;
105 #include "sfxtypes.hxx"
106 #include <sfx2/sfxuno.hxx>
107 #include <sfx2/app.hxx>
108 #include <sfx2/sfxsids.hrc>
109 #include <sfx2/msg.hxx>
110 #include <sfx2/msgpool.hxx>
111 #include <sfx2/request.hxx>
112 #include <sfx2/module.hxx>
113 #include <sfx2/fcontnr.hxx>
114 #include "frmload.hxx"
115 #include <sfx2/frame.hxx>
116 #include <sfx2/objsh.hxx>
117 #include <sfx2/objuno.hxx>
118 #include <sfx2/unoctitm.hxx>
119 #include <sfx2/dispatch.hxx>
120 #include "doctemplates.hxx"
121 #include "shutdownicon.hxx"
122 #include "objshimp.hxx"
123 #include "fltoptint.hxx"
124 #include <sfx2/docfile.hxx>
125 #include <sfx2/sfxbasecontroller.hxx>
126 #include <sfx2/brokenpackageint.hxx>
127 #include "eventsupplier.hxx"
128 #include "xpackcreator.hxx"
129 #include "plugin.hxx"
130 #include "iframe.hxx"
131 #include <ownsubfilterservice.hxx>
132 #include "SfxDocumentMetaData.hxx"
134 #define PROTOCOLHANDLER_SERVICENAME "com.sun.star.frame.ProtocolHandler"
136 static char const sTemplateRegionName[] = "TemplateRegionName";
137 static char const sTemplateName[] = "TemplateName";
138 static char const sAsTemplate[] = "AsTemplate";
139 static char const sOpenNewView[] = "OpenNewView";
140 static char const sViewId[] = "ViewId";
141 static char const sPluginMode[] = "PluginMode";
142 static char const sReadOnly[] = "ReadOnly";
143 static char const sDdeReconnect[] = "DDEReconnect";
144 static char const sStartPresentation[] = "StartPresentation";
145 static char const sFrameName[] = "FrameName";
146 static char const sMediaType[] = "MediaType";
147 static char const sPostData[] = "PostData";
148 static char const sCharacterSet[] = "CharacterSet";
149 static char const sInputStream[] = "InputStream";
150 static char const sStream[] = "Stream";
151 static char const sOutputStream[] = "OutputStream";
152 static char const sHidden[] = "Hidden";
153 static char const sPreview[] = "Preview";
154 static char const sViewOnly[] = "ViewOnly";
155 static char const sDontEdit[] = "DontEdit";
156 static char const sSilent[] = "Silent";
157 static char const sJumpMark[] = "JumpMark";
158 static char const sFileName[] = "FileName";
159 static char const sSalvagedFile[] = "SalvagedFile";
160 static char const sStatusInd[] = "StatusIndicator";
161 static char const sModel[] = "Model";
162 static char const sFrame[] = "Frame";
163 static char const sViewData[] = "ViewData";
164 static char const sFilterData[] = "FilterData";
165 static char const sSelectionOnly[] = "SelectionOnly";
166 static char const sFilterFlags[] = "FilterFlags";
167 static char const sMacroExecMode[] = "MacroExecutionMode";
168 static char const sUpdateDocMode[] = "UpdateDocMode";
169 static char const sMinimized[] = "Minimized";
170 static char const sInteractionHdl[] = "InteractionHandler";
171 static char const sUCBContent[] = "UCBContent";
172 static char const sRepairPackage[] = "RepairPackage";
173 static char const sDocumentTitle[] = "DocumentTitle";
174 static char const sComponentData[] = "ComponentData";
175 static char const sComponentContext[] = "ComponentContext";
176 static char const sDocumentBaseURL[] = "DocumentBaseURL";
177 static char const sHierarchicalDocumentName[] = "HierarchicalDocumentName";
178 static char const sCopyStreamIfPossible[] = "CopyStreamIfPossible";
179 static char const sNoAutoSave[] = "NoAutoSave";
180 static char const sFolderName[] = "FolderName";
181 static char const sUseSystemDialog[] = "UseSystemDialog";
182 static char const sStandardDir[] = "StandardDir";
183 static char const sBlackList[] = "BlackList";
184 static char const sModifyPasswordInfo[] = "ModifyPasswordInfo";
185 static char const sSuggestedSaveAsDir[] = "SuggestedSaveAsDir";
186 static char const sSuggestedSaveAsName[] = "SuggestedSaveAsName";
187 static char const sEncryptionData[] = "EncryptionData";
188 static char const sDocumentService[] = "DocumentService";
191 void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
193 if ( !pSlot )
194 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
196 if ( !pSlot )
197 return;
199 if ( nSlotId == SID_OPENURL )
200 nSlotId = SID_OPENDOC;
201 if ( nSlotId == SID_SAVEASURL )
202 nSlotId = SID_SAVEASDOC;
204 sal_Int32 nCount = rArgs.getLength();
205 if ( !nCount )
206 return;
208 const ::com::sun::star::beans::PropertyValue* pPropsVal = rArgs.getConstArray();
209 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
211 // slot is a property
212 const SfxType* pType = pSlot->GetType();
213 SfxPoolItem* pItem = pType->CreateItem();
214 if ( !pItem )
216 #ifdef DBG_UTIL
217 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
218 "No creator method for item: "));
219 aStr.append(static_cast<sal_Int32>(nSlotId));
220 OSL_FAIL(aStr.getStr());
221 #endif
222 return;
225 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
226 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
227 pItem->SetWhich( nWhich );
228 sal_uInt16 nSubCount = pType->nAttribs;
230 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[0];
231 String aName = rProp.Name;
232 if ( nCount == 1 && aName.CompareToAscii( pSlot->pUnoName ) == COMPARE_EQUAL )
234 // there is only one parameter and its name matches the name of the property,
235 // so it's either a simple property or a complex property in one single UNO struct
236 if( pItem->PutValue( rProp.Value, bConvertTwips ? CONVERT_TWIPS : 0 ) )
237 // only use successfully converted items
238 rSet.Put( *pItem );
239 #ifdef DBG_UTIL
240 else
242 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property not convertable: "));
243 aStr.append(pSlot->pUnoName);
244 OSL_FAIL( aStr.getStr() );
246 #endif
248 #ifdef DBG_UTIL
249 else if ( nSubCount == 0 )
251 // for a simple property there can be only one parameter and its name *must* match
252 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property name does not match: "));
253 aStr.append(rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8));
254 OSL_FAIL( aStr.getStr() );
256 #endif
257 else
259 // there is more than one parameter and the property is a complex one
260 #ifdef DBG_UTIL
261 // if the dispatch API is used for UI purposes or from the testtool,
262 // it is possible to skip some or all arguments,
263 // but it indicates an error for macro recording;
264 // so this should be notified as a warning only
265 if ( nCount != nSubCount )
267 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
268 "MacroPlayer: wrong number of parameters for slot: "));
269 aStr.append(static_cast<sal_Int32>(nSlotId));
270 DBG_WARNING(aStr.getStr());
272 #endif
273 // complex property; collect sub items from the parameter set and reconstruct complex item
274 sal_uInt16 nFound=0;
275 for ( sal_uInt16 n=0; n<nCount; n++ )
277 const ::com::sun::star::beans::PropertyValue& rPropValue = pPropsVal[n];
278 sal_uInt16 nSub;
279 for ( nSub=0; nSub<nSubCount; nSub++ )
281 // search sub item by name
282 rtl::OStringBuffer aStr;
283 aStr.append(pSlot->pUnoName).append('.').append(pType->aAttrib[nSub].pName);
284 if ( rPropValue.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
286 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[nSub].nAID;
287 if ( bConvertTwips )
288 nSubId |= CONVERT_TWIPS;
289 if ( pItem->PutValue( rPropValue.Value, nSubId ) )
290 nFound++;
291 #ifdef DBG_UTIL
292 else
294 rtl::OStringBuffer aDbgStr(RTL_CONSTASCII_STRINGPARAM("Property not convertable: "));
295 aDbgStr.append(pSlot->pUnoName);
296 OSL_FAIL( aDbgStr.getStr() );
298 #endif
299 break;
303 #ifdef DBG_UTIL
304 if ( nSub >= nSubCount )
306 // there was a parameter with a name that didn't match to any of the members
307 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property name does not match: "));
308 aStr.append(rtl::OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8));
309 OSL_FAIL( aStr.getStr() );
311 #endif
314 // at least one part of the complex item must be present; other parts can have default values
315 if ( nFound > 0 )
316 rSet.Put( *pItem );
319 delete pItem;
321 else if ( nCount )
323 #ifdef DBG_UTIL
324 // detect parameters that don't match to any formal argument or one of its members
325 sal_Int32 nFoundArgs = 0;
326 #endif
327 // slot is a method
328 for ( sal_uInt16 nArgs=0; nArgs<pSlot->nArgDefCount; nArgs++ )
330 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArgs );
331 SfxPoolItem* pItem = rArg.CreateItem();
332 if ( !pItem )
334 #ifdef DBG_UTIL
335 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("No creator method for argument: "));
336 aStr.append(rArg.pName);
337 OSL_FAIL( aStr.getStr() );
338 #endif
339 return;
342 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(rArg.nSlotId);
343 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
344 pItem->SetWhich( nWhich );
345 const SfxType* pType = rArg.pType;
346 sal_uInt16 nSubCount = pType->nAttribs;
347 if ( nSubCount == 0 )
349 // "simple" (base type) argument
350 for ( sal_uInt16 n=0; n<nCount; n++ )
352 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
353 String aName = rProp.Name;
354 if ( aName.CompareToAscii(rArg.pName) == COMPARE_EQUAL )
356 #ifdef DBG_UTIL
357 ++nFoundArgs;
358 #endif
359 if( pItem->PutValue( rProp.Value ) )
360 // only use successfully converted items
361 rSet.Put( *pItem );
362 #ifdef DBG_UTIL
363 else
365 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property not convertable: "));
366 aStr.append(rArg.pName);
367 OSL_FAIL( aStr.getStr() );
369 #endif
370 break;
374 else
376 // complex argument, could be passed in one struct
377 sal_Bool bAsWholeItem = sal_False;
378 for ( sal_uInt16 n=0; n<nCount; n++ )
380 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
381 String aName = rProp.Name;
382 if ( aName.CompareToAscii(rArg.pName) == COMPARE_EQUAL )
384 bAsWholeItem = sal_True;
385 #ifdef DBG_UTIL
386 ++nFoundArgs;
387 #endif
388 if( pItem->PutValue( rProp.Value ) )
389 // only use successfully converted items
390 rSet.Put( *pItem );
391 #ifdef DBG_UTIL
392 else
394 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Property not convertable: "));
395 aStr.append(rArg.pName);
396 OSL_FAIL( aStr.getStr() );
398 #endif
402 if ( !bAsWholeItem )
404 // complex argument; collect sub items from argument array and reconstruct complex item
405 // only put item if at least one member was found and had the correct type
406 // (is this a good idea?! Should we ask for *all* members?)
407 sal_Bool bRet = sal_False;
408 for ( sal_uInt16 n=0; n<nCount; n++ )
410 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
411 for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ )
413 // search sub item by name
414 rtl::OStringBuffer aStr;
415 aStr.append(rArg.pName).append('.').append(pType->aAttrib[nSub].pName);
416 if ( rProp.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) )
418 // at least one member found ...
419 bRet = sal_True;
420 #ifdef DBG_UTIL
421 ++nFoundArgs;
422 #endif
423 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[nSub].nAID;
424 if ( bConvertTwips )
425 nSubId |= CONVERT_TWIPS;
426 if (!pItem->PutValue( rProp.Value, nSubId ) )
428 // ... but it was not convertable
429 bRet = sal_False;
430 #ifdef DBG_UTIL
431 rtl::OStringBuffer aDbgStr(RTL_CONSTASCII_STRINGPARAM("Property not convertable: "));
432 aDbgStr.append(rArg.pName);
433 OSL_FAIL( aDbgStr.getStr() );
434 #endif
437 break;
442 if ( bRet )
443 // only use successfully converted items
444 rSet.Put( *pItem );
449 delete pItem;
452 // special additional parameters for some slots not seen in the slot definitions
453 // Some of these slots are not considered to be used for macro recording, because they shouldn't be recorded as slots,
454 // but as dispatching or factory or arbitrary URLs to the frame
455 // Some also can use additional arguments that are not recordable (will be changed later,
456 // f.e. "SaveAs" shouldn't support parameters not in the slot definition!)
457 if ( nSlotId == SID_NEWWINDOW )
459 for ( sal_uInt16 n=0; n<nCount; n++ )
461 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
462 rtl::OUString aName = rProp.Name;
463 if ( aName == sFrame )
465 Reference< XFrame > xFrame;
466 OSL_VERIFY( rProp.Value >>= xFrame );
467 rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
469 else
470 if ( aName == sHidden )
472 sal_Bool bVal = sal_False;
473 if (rProp.Value >>= bVal)
474 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
478 else if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
479 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
481 for ( sal_uInt16 n=0; n<nCount; n++ )
483 #ifdef DBG_UTIL
484 ++nFoundArgs;
485 #endif
486 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
487 rtl::OUString aName = rProp.Name;
488 if ( aName == sModel )
489 rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) );
490 else if ( aName == sComponentData )
492 rSet.Put( SfxUnoAnyItem( SID_COMPONENTDATA, rProp.Value ) );
494 else if ( aName == sComponentContext )
496 rSet.Put( SfxUnoAnyItem( SID_COMPONENTCONTEXT, rProp.Value ) );
498 else if ( aName == sStatusInd )
500 Reference< ::com::sun::star::task::XStatusIndicator > xVal;
501 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
502 DBG_ASSERT( bOK, "invalid type for StatusIndicator" );
503 if (bOK)
504 rSet.Put( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, rProp.Value ) );
506 else if ( aName == sInteractionHdl )
508 Reference< ::com::sun::star::task::XInteractionHandler > xVal;
509 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
510 DBG_ASSERT( bOK, "invalid type for InteractionHandler" );
511 if (bOK)
512 rSet.Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, rProp.Value ) );
514 else if ( aName == sViewData )
515 rSet.Put( SfxUnoAnyItem( SID_VIEW_DATA, rProp.Value ) );
516 else if ( aName == sFilterData )
517 rSet.Put( SfxUnoAnyItem( SID_FILTER_DATA, rProp.Value ) );
518 else if ( aName == sInputStream )
520 Reference< XInputStream > xVal;
521 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
522 DBG_ASSERT( bOK, "invalid type for InputStream" );
523 if (bOK)
524 rSet.Put( SfxUnoAnyItem( SID_INPUTSTREAM, rProp.Value ) );
526 else if ( aName == sStream )
528 Reference< XInputStream > xVal;
529 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
530 DBG_ASSERT( bOK, "invalid type for Stream" );
531 if (bOK)
532 rSet.Put( SfxUnoAnyItem( SID_STREAM, rProp.Value ) );
534 else if ( aName == sUCBContent )
536 Reference< XContent > xVal;
537 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
538 DBG_ASSERT( bOK, "invalid type for UCBContent" );
539 if (bOK)
540 rSet.Put( SfxUnoAnyItem( SID_CONTENT, rProp.Value ) );
542 else if ( aName == sOutputStream )
544 Reference< XOutputStream > xVal;
545 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
546 DBG_ASSERT( bOK, "invalid type for OutputStream" );
547 if (bOK)
548 rSet.Put( SfxUnoAnyItem( SID_OUTPUTSTREAM, rProp.Value ) );
550 else if ( aName == sPostData )
552 Reference< XInputStream > xVal;
553 sal_Bool bOK = (rProp.Value >>= xVal);
554 DBG_ASSERT( bOK, "invalid type for PostData" );
555 if (bOK)
556 rSet.Put( SfxUnoAnyItem( SID_POSTDATA, rProp.Value ) );
558 else if ( aName == sFrame )
560 Reference< XFrame > xFrame;
561 sal_Bool bOK = (rProp.Value >>= xFrame);
562 DBG_ASSERT( bOK, "invalid type for Frame" );
563 if (bOK)
564 rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
566 else if ( aName == sAsTemplate )
568 sal_Bool bVal = sal_False;
569 sal_Bool bOK = (rProp.Value >>= bVal);
570 DBG_ASSERT( bOK, "invalid type for AsTemplate" );
571 if (bOK)
572 rSet.Put( SfxBoolItem( SID_TEMPLATE, bVal ) );
574 else if ( aName == sOpenNewView )
576 sal_Bool bVal = sal_False;
577 sal_Bool bOK = (rProp.Value >>= bVal);
578 DBG_ASSERT( bOK, "invalid type for OpenNewView" );
579 if (bOK)
580 rSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, bVal ) );
582 else if ( aName == sViewId )
584 sal_Int16 nVal = -1;
585 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
586 DBG_ASSERT( bOK, "invalid type for ViewId" );
587 if (bOK)
588 rSet.Put( SfxUInt16Item( SID_VIEW_ID, nVal ) );
590 else if ( aName == sPluginMode )
592 sal_Int16 nVal = -1;
593 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
594 DBG_ASSERT( bOK, "invalid type for PluginMode" );
595 if (bOK)
596 rSet.Put( SfxUInt16Item( SID_PLUGIN_MODE, nVal ) );
598 else if ( aName == sReadOnly )
600 sal_Bool bVal = sal_False;
601 sal_Bool bOK = (rProp.Value >>= bVal);
602 DBG_ASSERT( bOK, "invalid type for ReadOnly" );
603 if (bOK)
604 rSet.Put( SfxBoolItem( SID_DOC_READONLY, bVal ) );
606 else if ( aName == sDdeReconnect )
608 sal_Bool bVal = sal_True;
609 sal_Bool bOK = (rProp.Value >>= bVal);
610 DBG_ASSERT( bOK, "invalid type for DDEReconnect" );
611 if (bOK)
612 rSet.Put( SfxBoolItem( SID_DDE_RECONNECT_ONLOAD, bVal ) );
614 else if ( aName == sStartPresentation )
616 sal_Bool bVal = sal_False;
617 sal_Bool bOK = (rProp.Value >>= bVal);
618 DBG_ASSERT( bOK, "invalid type for StartPresentation" );
619 if (bOK)
620 rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, bVal ) );
622 else if ( aName == sSelectionOnly )
624 sal_Bool bVal = sal_False;
625 sal_Bool bOK = (rProp.Value >>= bVal);
626 DBG_ASSERT( bOK, "invalid type for SelectionOnly" );
627 if (bOK)
628 rSet.Put( SfxBoolItem( SID_SELECTION, bVal ) );
630 else if ( aName == sHidden )
632 sal_Bool bVal = sal_False;
633 sal_Bool bOK = (rProp.Value >>= bVal);
634 DBG_ASSERT( bOK, "invalid type for Hidden" );
635 if (bOK)
636 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
638 else if ( aName == sMinimized )
640 sal_Bool bVal = sal_False;
641 sal_Bool bOK = (rProp.Value >>= bVal);
642 DBG_ASSERT( bOK, "invalid type for Minimized" );
643 if (bOK)
644 rSet.Put( SfxBoolItem( SID_MINIMIZED, bVal ) );
646 else if ( aName == sSilent )
648 sal_Bool bVal = sal_False;
649 sal_Bool bOK = (rProp.Value >>= bVal);
650 DBG_ASSERT( bOK, "invalid type for Silent" );
651 if (bOK)
652 rSet.Put( SfxBoolItem( SID_SILENT, bVal ) );
654 else if ( aName == sPreview )
656 sal_Bool bVal = sal_False;
657 sal_Bool bOK = (rProp.Value >>= bVal);
658 DBG_ASSERT( bOK, "invalid type for Preview" );
659 if (bOK)
660 rSet.Put( SfxBoolItem( SID_PREVIEW, bVal ) );
662 else if ( aName == sViewOnly )
664 sal_Bool bVal = sal_False;
665 sal_Bool bOK = (rProp.Value >>= bVal);
666 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
667 if (bOK)
668 rSet.Put( SfxBoolItem( SID_VIEWONLY, bVal ) );
670 else if ( aName == sDontEdit )
672 sal_Bool bVal = sal_False;
673 sal_Bool bOK = (rProp.Value >>= bVal);
674 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
675 if (bOK)
676 rSet.Put( SfxBoolItem( SID_EDITDOC, !bVal ) );
678 else if ( aName == sUseSystemDialog )
680 sal_Bool bVal = sal_False;
681 sal_Bool bOK = (rProp.Value >>= bVal);
682 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
683 if (bOK)
684 rSet.Put( SfxBoolItem( SID_FILE_DIALOG, bVal ) );
686 else if ( aName == sStandardDir )
688 ::rtl::OUString sVal;
689 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
690 DBG_ASSERT( bOK, "invalid type or value for StandardDir" );
691 if (bOK)
692 rSet.Put( SfxStringItem( SID_STANDARD_DIR, sVal ) );
694 else if ( aName == sBlackList )
696 ::com::sun::star::uno::Sequence< ::rtl::OUString > xVal;
697 sal_Bool bOK = (rProp.Value >>= xVal);
698 DBG_ASSERT( bOK, "invalid type or value for BlackList" );
699 if (bOK)
701 SfxStringListItem stringList(SID_BLACK_LIST);
702 stringList.SetStringList( xVal );
703 rSet.Put( stringList );
706 else if ( aName == sFileName )
708 ::rtl::OUString sVal;
709 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
710 DBG_ASSERT( bOK, "invalid type or value for FileName" );
711 if (bOK)
712 rSet.Put( SfxStringItem( SID_FILE_NAME, sVal ) );
714 else if ( aName == sSalvagedFile )
716 ::rtl::OUString sVal;
717 sal_Bool bOK = (rProp.Value >>= sVal);
718 DBG_ASSERT( bOK, "invalid type or value for SalvagedFile" );
719 if (bOK)
720 rSet.Put( SfxStringItem( SID_DOC_SALVAGE, sVal ) );
722 else if ( aName == sFolderName )
724 ::rtl::OUString sVal;
725 sal_Bool bOK = (rProp.Value >>= sVal);
726 DBG_ASSERT( bOK, "invalid type or value for FolderName" );
727 if (bOK)
728 rSet.Put( SfxStringItem( SID_PATH, sVal ) );
730 else if ( aName == sFrameName )
732 ::rtl::OUString sVal;
733 sal_Bool bOK = (rProp.Value >>= sVal);
734 DBG_ASSERT( bOK, "invalid type for FrameName" );
735 if (bOK && !sVal.isEmpty())
736 rSet.Put( SfxStringItem( SID_TARGETNAME, sVal ) );
738 else if ( aName == sMediaType )
740 ::rtl::OUString sVal;
741 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
742 DBG_ASSERT( bOK, "invalid type or value for MediaType" );
743 if (bOK)
744 rSet.Put( SfxStringItem( SID_CONTENTTYPE, sVal ) );
746 else if ( aName == sTemplateName )
748 ::rtl::OUString sVal;
749 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
750 DBG_ASSERT( bOK, "invalid type or value for TemplateName" );
751 if (bOK)
752 rSet.Put( SfxStringItem( SID_TEMPLATE_NAME, sVal ) );
754 else if ( aName == sTemplateRegionName )
756 ::rtl::OUString sVal;
757 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
758 DBG_ASSERT( bOK, "invalid type or value for TemplateRegionName" );
759 if (bOK)
760 rSet.Put( SfxStringItem( SID_TEMPLATE_REGIONNAME, sVal ) );
762 else if ( aName == sJumpMark )
764 ::rtl::OUString sVal;
765 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
766 DBG_ASSERT( bOK, "invalid type or value for JumpMark" );
767 if (bOK)
768 rSet.Put( SfxStringItem( SID_JUMPMARK, sVal ) );
770 else if ( aName == sCharacterSet )
772 ::rtl::OUString sVal;
773 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
774 DBG_ASSERT( bOK, "invalid type or value for CharacterSet" );
775 if (bOK)
776 rSet.Put( SfxStringItem( SID_CHARSET, sVal ) );
778 else if ( aName == sFilterFlags )
780 ::rtl::OUString sVal;
781 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
782 DBG_ASSERT( bOK, "invalid type or value for FilterFlags" );
783 if (bOK)
784 rSet.Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sVal ) );
786 else if ( aName == sMacroExecMode )
788 sal_Int16 nVal =-1;
789 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
790 DBG_ASSERT( bOK, "invalid type for MacroExecMode" );
791 if (bOK)
792 rSet.Put( SfxUInt16Item( SID_MACROEXECMODE, nVal ) );
794 else if ( aName == sUpdateDocMode )
796 sal_Int16 nVal =-1;
797 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
798 DBG_ASSERT( bOK, "invalid type for UpdateDocMode" );
799 if (bOK)
800 rSet.Put( SfxUInt16Item( SID_UPDATEDOCMODE, nVal ) );
802 else if ( aName == sRepairPackage )
804 sal_Bool bVal = sal_False;
805 sal_Bool bOK = (rProp.Value >>= bVal);
806 DBG_ASSERT( bOK, "invalid type for RepairPackage" );
807 if (bOK)
808 rSet.Put( SfxBoolItem( SID_REPAIRPACKAGE, bVal ) );
810 else if ( aName == sDocumentTitle )
812 ::rtl::OUString sVal;
813 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
814 DBG_ASSERT( bOK, "invalid type or value for DocumentTitle" );
815 if (bOK)
816 rSet.Put( SfxStringItem( SID_DOCINFO_TITLE, sVal ) );
818 else if ( aName == sDocumentBaseURL )
820 ::rtl::OUString sVal;
821 // the base url can be set to empty ( for embedded objects for example )
822 sal_Bool bOK = (rProp.Value >>= sVal);
823 DBG_ASSERT( bOK, "invalid type or value for DocumentBaseURL" );
824 if (bOK)
825 rSet.Put( SfxStringItem( SID_DOC_BASEURL, sVal ) );
827 else if ( aName == sHierarchicalDocumentName )
829 ::rtl::OUString sVal;
830 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
831 DBG_ASSERT( bOK, "invalid type or value for HierarchicalDocumentName" );
832 if (bOK)
833 rSet.Put( SfxStringItem( SID_DOC_HIERARCHICALNAME, sVal ) );
835 else if ( aName == sCopyStreamIfPossible )
837 sal_Bool bVal = sal_False;
838 sal_Bool bOK = (rProp.Value >>= bVal);
839 DBG_ASSERT( bOK, "invalid type for CopyStreamIfPossible" );
840 if (bOK)
841 rSet.Put( SfxBoolItem( SID_COPY_STREAM_IF_POSSIBLE, bVal ) );
843 else if ( aName == sNoAutoSave )
845 sal_Bool bVal = sal_False;
846 sal_Bool bOK = (rProp.Value >>= bVal);
847 DBG_ASSERT( bOK, "invalid type for NoAutoSave" );
848 if (bOK)
849 rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) );
851 else if ( aName == sModifyPasswordInfo )
853 rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) );
855 else if ( aName == sEncryptionData )
857 rSet.Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, rProp.Value ) );
859 else if ( aName == sSuggestedSaveAsDir )
861 ::rtl::OUString sVal;
862 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
863 DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsDir" );
864 if (bOK)
865 rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASDIR, sVal ) );
867 else if ( aName == sSuggestedSaveAsName )
869 ::rtl::OUString sVal;
870 sal_Bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
871 DBG_ASSERT( bOK, "invalid type or value for SuggestedSaveAsName" );
872 if (bOK)
873 rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASNAME, sVal ) );
875 else if (aName == sDocumentService)
877 rtl::OUString aVal;
878 bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty());
879 if (bOK)
880 rSet.Put(SfxStringItem(SID_DOC_SERVICE, aVal));
882 #ifdef DBG_UTIL
883 else
884 --nFoundArgs;
885 #endif
888 // API to raise options dialog with a specified options ab page (#i83757#)
889 else
891 // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
892 String sSlotName( DEFINE_CONST_UNICODE( "OptionsTreeDialog" ) );
893 String sPropName( DEFINE_CONST_UNICODE( "OptionsPageURL" ) );
894 if ( sSlotName.EqualsAscii( pSlot->pUnoName ) )
896 for ( sal_uInt16 n = 0; n < nCount; ++n )
898 const PropertyValue& rProp = pPropsVal[n];
899 String sName( rProp.Name );
900 if ( sName == sPropName )
902 ::rtl::OUString sURL;
903 if ( rProp.Value >>= sURL )
904 rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
905 break;
910 #ifdef DB_UTIL
911 if ( nFoundArgs == nCount )
913 // except for the "special" slots: assure that every argument was convertable
914 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("MacroPlayer: Some properties didn't match to any formal argument for slot: "));
915 aStr.append(pSlot->pUnoName);
916 DBG_WARNING( aStr.getStr() );
918 #endif
922 void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, const SfxSlot* pSlot )
924 if ( !pSlot )
925 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
927 if ( !pSlot)
928 return;
930 if ( nSlotId == SID_OPENURL )
931 nSlotId = SID_OPENDOC;
932 if ( nSlotId == SID_SAVEASURL )
933 nSlotId = SID_SAVEASDOC;
935 // find number of properties to avoid permanent reallocations in the sequence
936 sal_Int32 nProps=0;
938 #ifdef DBG_UTIL
939 // trace number of items and compare with number of properties for debugging purposes
940 sal_Int32 nItems=0;
941 #endif
943 const SfxType *pType = pSlot->GetType();
944 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
946 // slot is a property
947 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
948 if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
950 sal_uInt16 nSubCount = pType->nAttribs;
951 if ( nSubCount )
952 // it's a complex property, we want it split into simple types
953 // so we expect to get as many items as we have (sub) members
954 nProps = nSubCount;
955 else
956 // simple property: we expect to get exactly one item
957 nProps++;
959 #ifdef DBG_UTIL
960 else
962 // we will not rely on the "toggle" ability of some property slots
963 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
964 "Processing property slot without argument: "));
965 aStr.append(static_cast<sal_Int32>(nSlotId));
966 OSL_FAIL(aStr.getStr());
968 #endif
970 #ifdef DBG_UTIL
971 nItems++;
972 #endif
974 else
976 // slot is a method
977 sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
978 for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
980 // check every formal argument of the method
981 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
982 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
983 if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
985 sal_uInt16 nSubCount = rArg.pType->nAttribs;
986 if ( nSubCount )
987 // argument has a complex type, we want it split into simple types
988 // so for this argument we expect to get as many items as we have (sub) members
989 nProps += nSubCount;
990 else
991 // argument of simple type: we expect to get exactly one item for it
992 nProps++;
993 #ifdef DBG_UTIL
994 nItems++;
995 #endif
999 // special treatment for slots that are *not* meant to be recorded as slots (except SaveAs/To)
1000 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1001 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
1003 sal_Int32 nAdditional=0;
1004 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL ) == SFX_ITEM_SET )
1005 nAdditional++;
1006 if ( rSet.GetItemState( SID_INTERACTIONHANDLER ) == SFX_ITEM_SET )
1007 nAdditional++;
1008 if ( rSet.GetItemState( SID_DOC_SALVAGE ) == SFX_ITEM_SET )
1009 nAdditional++;
1010 if ( rSet.GetItemState( SID_PATH ) == SFX_ITEM_SET )
1011 nAdditional++;
1012 if ( rSet.GetItemState( SID_FILE_DIALOG ) == SFX_ITEM_SET )
1013 nAdditional++;
1014 if ( rSet.GetItemState( SID_STANDARD_DIR ) == SFX_ITEM_SET )
1015 nAdditional++;
1016 if ( rSet.GetItemState( SID_BLACK_LIST ) == SFX_ITEM_SET )
1017 nAdditional++;
1018 if ( rSet.GetItemState( SID_CONTENT ) == SFX_ITEM_SET )
1019 nAdditional++;
1020 if ( rSet.GetItemState( SID_INPUTSTREAM ) == SFX_ITEM_SET )
1021 nAdditional++;
1022 if ( rSet.GetItemState( SID_STREAM ) == SFX_ITEM_SET )
1023 nAdditional++;
1024 if ( rSet.GetItemState( SID_OUTPUTSTREAM ) == SFX_ITEM_SET )
1025 nAdditional++;
1026 if ( rSet.GetItemState( SID_TEMPLATE ) == SFX_ITEM_SET )
1027 nAdditional++;
1028 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW ) == SFX_ITEM_SET )
1029 nAdditional++;
1030 if ( rSet.GetItemState( SID_VIEW_ID ) == SFX_ITEM_SET )
1031 nAdditional++;
1032 if ( rSet.GetItemState( SID_VIEW_DATA ) == SFX_ITEM_SET )
1033 nAdditional++;
1034 if ( rSet.GetItemState( SID_FILTER_DATA ) == SFX_ITEM_SET )
1035 nAdditional++;
1036 if ( rSet.GetItemState( SID_PLUGIN_MODE ) == SFX_ITEM_SET )
1037 nAdditional++;
1038 if ( rSet.GetItemState( SID_DOC_READONLY ) == SFX_ITEM_SET )
1039 nAdditional++;
1040 if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD ) == SFX_ITEM_SET )
1041 nAdditional++;
1042 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION ) == SFX_ITEM_SET )
1043 nAdditional++;
1044 if ( rSet.GetItemState( SID_SELECTION ) == SFX_ITEM_SET )
1045 nAdditional++;
1046 if ( rSet.GetItemState( SID_CONTENTTYPE ) == SFX_ITEM_SET )
1047 nAdditional++;
1048 if ( rSet.GetItemState( SID_POSTDATA ) == SFX_ITEM_SET )
1049 nAdditional++;
1050 if ( rSet.GetItemState( SID_FILLFRAME ) == SFX_ITEM_SET )
1051 nAdditional++;
1052 if ( rSet.GetItemState( SID_CHARSET ) == SFX_ITEM_SET )
1053 nAdditional++;
1054 if ( rSet.GetItemState( SID_TARGETNAME ) == SFX_ITEM_SET )
1055 nAdditional++;
1056 if ( rSet.GetItemState( SID_TEMPLATE_NAME ) == SFX_ITEM_SET )
1057 nAdditional++;
1058 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME ) == SFX_ITEM_SET )
1059 nAdditional++;
1060 if ( rSet.GetItemState( SID_HIDDEN ) == SFX_ITEM_SET )
1061 nAdditional++;
1062 if ( rSet.GetItemState( SID_MINIMIZED ) == SFX_ITEM_SET )
1063 nAdditional++;
1064 if ( rSet.GetItemState( SID_PREVIEW ) == SFX_ITEM_SET )
1065 nAdditional++;
1066 if ( rSet.GetItemState( SID_VIEWONLY ) == SFX_ITEM_SET )
1067 nAdditional++;
1068 if ( rSet.GetItemState( SID_EDITDOC ) == SFX_ITEM_SET )
1069 nAdditional++;
1070 if ( rSet.GetItemState( SID_SILENT ) == SFX_ITEM_SET )
1071 nAdditional++;
1072 if ( rSet.GetItemState( SID_JUMPMARK ) == SFX_ITEM_SET )
1073 nAdditional++;
1074 if ( rSet.GetItemState( SID_DOCUMENT ) == SFX_ITEM_SET )
1075 nAdditional++;
1076 if ( rSet.GetItemState( SID_MACROEXECMODE ) == SFX_ITEM_SET )
1077 nAdditional++;
1078 if ( rSet.GetItemState( SID_UPDATEDOCMODE ) == SFX_ITEM_SET )
1079 nAdditional++;
1080 if ( rSet.GetItemState( SID_REPAIRPACKAGE ) == SFX_ITEM_SET )
1081 nAdditional++;
1082 if ( rSet.GetItemState( SID_DOCINFO_TITLE ) == SFX_ITEM_SET )
1083 nAdditional++;
1084 if ( rSet.GetItemState( SID_COMPONENTDATA ) == SFX_ITEM_SET )
1085 nAdditional++;
1086 if ( rSet.GetItemState( SID_COMPONENTCONTEXT ) == SFX_ITEM_SET )
1087 nAdditional++;
1088 if ( rSet.GetItemState( SID_DOC_BASEURL ) == SFX_ITEM_SET )
1089 nAdditional++;
1090 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME ) == SFX_ITEM_SET )
1091 nAdditional++;
1092 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE ) == SFX_ITEM_SET )
1093 nAdditional++;
1094 if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SFX_ITEM_SET )
1095 nAdditional++;
1096 if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO ) == SFX_ITEM_SET )
1097 nAdditional++;
1098 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR ) == SFX_ITEM_SET )
1099 nAdditional++;
1100 if ( rSet.GetItemState( SID_ENCRYPTIONDATA ) == SFX_ITEM_SET )
1101 nAdditional++;
1102 nAdditional++;
1103 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME ) == SFX_ITEM_SET )
1104 nAdditional++;
1105 if ( rSet.GetItemState( SID_DOC_SERVICE ) == SFX_ITEM_SET )
1106 nAdditional++;
1108 // consider additional arguments
1109 nProps += nAdditional;
1110 #ifdef DBG_UTIL
1111 nItems += nAdditional;
1112 #endif
1116 #ifdef DBG_UTIL
1117 // now check the itemset: is there any item that is not convertable using the list of formal arguments
1118 // or the table of additional items?!
1119 if ( rSet.Count() != nItems )
1121 // detect unknown item and present error message
1122 const sal_uInt16 *pRanges = rSet.GetRanges();
1123 while ( *pRanges )
1125 for(sal_uInt16 nId = *pRanges++; nId <= *pRanges; ++nId)
1127 if ( rSet.GetItemState(nId) < SFX_ITEM_SET ) //???
1128 // not really set
1129 continue;
1131 if ( !pSlot->IsMode(SFX_SLOT_METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1132 continue;
1134 sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1135 sal_uInt16 nArg;
1136 for ( nArg=0; nArg<nFormalArgs; ++nArg )
1138 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1139 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1140 if ( nId == nWhich )
1141 break;
1144 if ( nArg<nFormalArgs )
1145 continue;
1147 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1148 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
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_BLACK_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;
1247 // used only internally
1248 if ( nId == SID_SAVETO )
1249 continue;
1250 if ( nId == SID_MODIFYPASSWORDINFO )
1251 continue;
1252 if ( nId == SID_SUGGESTEDSAVEASDIR )
1253 continue;
1254 if ( nId == SID_SUGGESTEDSAVEASNAME )
1255 continue;
1258 rtl::OStringBuffer aDbg(RTL_CONSTASCII_STRINGPARAM(
1259 "Unknown item detected: "));
1260 aDbg.append(static_cast<sal_Int32>(nId));
1261 DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr());
1265 #endif
1267 if ( !nProps )
1268 return;
1270 // convert every item into a property
1271 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aSequ( nProps );
1272 ::com::sun::star::beans::PropertyValue *pValue = aSequ.getArray();
1274 sal_Int32 nActProp=0;
1275 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
1277 // slot is a property
1278 sal_uInt16 nWhich = rSet.GetPool()->GetWhich(nSlotId);
1279 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1280 SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1281 if ( pItem ) //???
1283 sal_uInt16 nSubCount = pType->nAttribs;
1284 if ( !nSubCount )
1286 pValue[nActProp].Name = String( String::CreateFromAscii( pSlot->pUnoName ) ) ;
1287 if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1289 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1290 "Item not convertable: "));
1291 aStr.append(static_cast<sal_Int32>(nSlotId));
1292 OSL_FAIL(aStr.getStr());
1295 else
1297 // complex type, add a property value for every member of the struct
1298 for ( sal_uInt16 n=1; n<=nSubCount; ++n )
1300 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) pType->aAttrib[n-1].nAID;
1301 if ( bConvertTwips )
1302 nSubId |= CONVERT_TWIPS;
1304 DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1305 String aName( String::CreateFromAscii( pSlot->pUnoName ) ) ;
1306 aName += '.';
1307 aName += String( String::CreateFromAscii( pType->aAttrib[n-1].pName ) ) ;
1308 pValue[nActProp].Name = aName;
1309 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1311 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1312 "Sub item "));
1313 aStr.append(static_cast<sal_Int32>(
1314 pType->aAttrib[n-1].nAID));
1315 aStr.append(RTL_CONSTASCII_STRINGPARAM(
1316 " not convertable in slot: "));
1317 aStr.append(static_cast<sal_Int32>(nSlotId));
1318 OSL_FAIL( aStr.getStr() );
1324 else
1326 // slot is a method
1327 sal_uInt16 nFormalArgs = pSlot->GetFormalArgumentCount();
1328 for ( sal_uInt16 nArg=0; nArg<nFormalArgs; ++nArg )
1330 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1331 sal_uInt16 nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1332 sal_Bool bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1333 SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1334 if ( pItem ) //???
1336 sal_uInt16 nSubCount = rArg.pType->nAttribs;
1337 if ( !nSubCount )
1339 pValue[nActProp].Name = String( String::CreateFromAscii( rArg.pName ) ) ;
1340 if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1342 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1343 "Item not convertable: "));
1344 aStr.append(static_cast<sal_Int32>(rArg.nSlotId));
1345 OSL_FAIL(aStr.getStr());
1348 else
1350 // complex type, add a property value for every member of the struct
1351 for ( sal_uInt16 n = 1; n <= nSubCount; ++n )
1353 sal_uInt8 nSubId = (sal_uInt8) (sal_Int8) rArg.pType->aAttrib[n-1].nAID;
1354 if ( bConvertTwips )
1355 nSubId |= CONVERT_TWIPS;
1357 DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1358 String aName( String::CreateFromAscii( rArg.pName ) ) ;
1359 aName += '.';
1360 aName += String( String::CreateFromAscii( rArg.pType->aAttrib[n-1].pName ) ) ;
1361 pValue[nActProp].Name = aName;
1362 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1364 rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
1365 "Sub item "));
1366 aStr.append(static_cast<sal_Int32>(
1367 rArg.pType->aAttrib[n-1].nAID));
1368 aStr.append(RTL_CONSTASCII_STRINGPARAM(
1369 " not convertable in slot: "));
1370 aStr.append(static_cast<sal_Int32>(rArg.nSlotId));
1371 OSL_FAIL(aStr.getStr());
1378 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1379 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
1381 const SfxPoolItem *pItem=0;
1382 if ( rSet.GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1384 pValue[nActProp].Name = rtl::OUString(sComponentData);
1385 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1387 if ( rSet.GetItemState( SID_COMPONENTCONTEXT, sal_False, &pItem ) == SFX_ITEM_SET )
1389 pValue[nActProp].Name = rtl::OUString(sComponentContext);
1390 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1392 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, sal_False, &pItem ) == SFX_ITEM_SET )
1394 pValue[nActProp].Name = rtl::OUString(sStatusInd);
1395 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1397 if ( rSet.GetItemState( SID_INTERACTIONHANDLER, sal_False, &pItem ) == SFX_ITEM_SET )
1399 pValue[nActProp].Name = rtl::OUString(sInteractionHdl);
1400 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1402 if ( rSet.GetItemState( SID_VIEW_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1404 pValue[nActProp].Name = rtl::OUString(sViewData);
1405 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1407 if ( rSet.GetItemState( SID_FILTER_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1409 pValue[nActProp].Name = rtl::OUString(sFilterData);
1410 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1412 if ( rSet.GetItemState( SID_DOCUMENT, sal_False, &pItem ) == SFX_ITEM_SET )
1414 pValue[nActProp].Name = rtl::OUString(sModel);
1415 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1417 if ( rSet.GetItemState( SID_CONTENT, sal_False, &pItem ) == SFX_ITEM_SET )
1419 pValue[nActProp].Name = rtl::OUString(sUCBContent);
1420 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1422 if ( rSet.GetItemState( SID_INPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1424 pValue[nActProp].Name = rtl::OUString(sInputStream);
1425 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1427 if ( rSet.GetItemState( SID_STREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1429 pValue[nActProp].Name = rtl::OUString(sStream);
1430 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1432 if ( rSet.GetItemState( SID_OUTPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1434 pValue[nActProp].Name = rtl::OUString(sOutputStream);
1435 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1437 if ( rSet.GetItemState( SID_POSTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1439 pValue[nActProp].Name = rtl::OUString(sPostData);
1440 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1442 if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1444 pValue[nActProp].Name = rtl::OUString(sFrame);
1445 if ( pItem->ISA( SfxUsrAnyItem ) )
1447 OSL_FAIL( "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" );
1448 pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue();
1450 else if ( pItem->ISA( SfxUnoFrameItem ) )
1451 pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame();
1452 else
1453 OSL_FAIL( "TransformItems: invalid item type for SID_FILLFRAME!" );
1455 if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET )
1457 pValue[nActProp].Name = rtl::OUString(sAsTemplate);
1458 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1460 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1462 pValue[nActProp].Name = rtl::OUString(sOpenNewView);
1463 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1465 if ( rSet.GetItemState( SID_VIEW_ID, sal_False, &pItem ) == SFX_ITEM_SET )
1467 pValue[nActProp].Name = rtl::OUString(sViewId);
1468 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1470 if ( rSet.GetItemState( SID_PLUGIN_MODE, sal_False, &pItem ) == SFX_ITEM_SET )
1472 pValue[nActProp].Name = rtl::OUString(sPluginMode);
1473 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1475 if ( rSet.GetItemState( SID_DOC_READONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1477 pValue[nActProp].Name = rtl::OUString(sReadOnly);
1478 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1480 if ( rSet.GetItemState( SID_DDE_RECONNECT_ONLOAD, sal_False, &pItem ) == SFX_ITEM_SET )
1482 pValue[nActProp].Name = rtl::OUString(sDdeReconnect);
1483 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1485 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, sal_False, &pItem ) == SFX_ITEM_SET )
1487 pValue[nActProp].Name = rtl::OUString(sStartPresentation);
1488 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1490 if ( rSet.GetItemState( SID_SELECTION, sal_False, &pItem ) == SFX_ITEM_SET )
1492 pValue[nActProp].Name = rtl::OUString(sSelectionOnly);
1493 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1495 if ( rSet.GetItemState( SID_HIDDEN, sal_False, &pItem ) == SFX_ITEM_SET )
1497 pValue[nActProp].Name = rtl::OUString(sHidden);
1498 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1500 if ( rSet.GetItemState( SID_MINIMIZED, sal_False, &pItem ) == SFX_ITEM_SET )
1502 pValue[nActProp].Name = rtl::OUString(sMinimized);
1503 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1505 if ( rSet.GetItemState( SID_SILENT, sal_False, &pItem ) == SFX_ITEM_SET )
1507 pValue[nActProp].Name = rtl::OUString(sSilent);
1508 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1510 if ( rSet.GetItemState( SID_PREVIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1512 pValue[nActProp].Name = rtl::OUString(sPreview);
1513 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1515 if ( rSet.GetItemState( SID_VIEWONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1517 pValue[nActProp].Name = rtl::OUString(sViewOnly);
1518 pValue[nActProp++].Value <<= (sal_Bool) (( ((SfxBoolItem*)pItem)->GetValue() ));
1520 if ( rSet.GetItemState( SID_EDITDOC, sal_False, &pItem ) == SFX_ITEM_SET )
1522 pValue[nActProp].Name = rtl::OUString(sDontEdit);
1523 pValue[nActProp++].Value <<= (sal_Bool) (!( ((SfxBoolItem*)pItem)->GetValue() ));
1525 if ( rSet.GetItemState( SID_FILE_DIALOG, sal_False, &pItem ) == SFX_ITEM_SET )
1527 pValue[nActProp].Name = rtl::OUString(sUseSystemDialog);
1528 pValue[nActProp++].Value <<= (sal_Bool) ( ((SfxBoolItem*)pItem)->GetValue() );
1530 if ( rSet.GetItemState( SID_STANDARD_DIR, sal_False, &pItem ) == SFX_ITEM_SET )
1532 pValue[nActProp].Name = rtl::OUString(sStandardDir);
1533 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1535 if ( rSet.GetItemState( SID_BLACK_LIST, sal_False, &pItem ) == SFX_ITEM_SET )
1537 pValue[nActProp].Name = rtl::OUString(sBlackList);
1539 com::sun::star::uno::Sequence< rtl::OUString > aList;
1540 ((SfxStringListItem*)pItem)->GetStringList( aList );
1541 pValue[nActProp++].Value <<= aList ;
1543 if ( rSet.GetItemState( SID_TARGETNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1545 pValue[nActProp].Name = rtl::OUString(sFrameName);
1546 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1548 if ( rSet.GetItemState( SID_DOC_SALVAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1550 pValue[nActProp].Name = rtl::OUString(sSalvagedFile);
1551 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1553 if ( rSet.GetItemState( SID_PATH, sal_False, &pItem ) == SFX_ITEM_SET )
1555 pValue[nActProp].Name = rtl::OUString(sFolderName);
1556 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1558 if ( rSet.GetItemState( SID_CONTENTTYPE, sal_False, &pItem ) == SFX_ITEM_SET )
1560 pValue[nActProp].Name = rtl::OUString(sMediaType);
1561 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1563 if ( rSet.GetItemState( SID_TEMPLATE_NAME, sal_False, &pItem ) == SFX_ITEM_SET )
1565 pValue[nActProp].Name = rtl::OUString(sTemplateName);
1566 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1568 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1570 pValue[nActProp].Name = rtl::OUString(sTemplateRegionName);
1571 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1573 if ( rSet.GetItemState( SID_JUMPMARK, sal_False, &pItem ) == SFX_ITEM_SET )
1575 pValue[nActProp].Name = rtl::OUString(sJumpMark);
1576 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1579 if ( rSet.GetItemState( SID_CHARSET, sal_False, &pItem ) == SFX_ITEM_SET )
1581 pValue[nActProp].Name = rtl::OUString(sCharacterSet);
1582 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1584 if ( rSet.GetItemState( SID_MACROEXECMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1586 pValue[nActProp].Name = rtl::OUString(sMacroExecMode);
1587 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1589 if ( rSet.GetItemState( SID_UPDATEDOCMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1591 pValue[nActProp].Name = rtl::OUString(sUpdateDocMode);
1592 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1594 if ( rSet.GetItemState( SID_REPAIRPACKAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1596 pValue[nActProp].Name = rtl::OUString(sRepairPackage);
1597 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1599 if ( rSet.GetItemState( SID_DOCINFO_TITLE, sal_False, &pItem ) == SFX_ITEM_SET )
1601 pValue[nActProp].Name = rtl::OUString(sDocumentTitle);
1602 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1604 if ( rSet.GetItemState( SID_DOC_BASEURL, sal_False, &pItem ) == SFX_ITEM_SET )
1606 pValue[nActProp].Name = rtl::OUString(sDocumentBaseURL);
1607 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1609 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1611 pValue[nActProp].Name = rtl::OUString(sHierarchicalDocumentName);
1612 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1614 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, sal_False, &pItem ) == SFX_ITEM_SET )
1616 pValue[nActProp].Name = rtl::OUString(sCopyStreamIfPossible);
1617 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1619 if ( rSet.GetItemState( SID_NOAUTOSAVE, sal_False, &pItem ) == SFX_ITEM_SET )
1621 pValue[nActProp].Name = rtl::OUString(sNoAutoSave);
1622 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1624 if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, sal_False, &pItem ) == SFX_ITEM_SET )
1626 pValue[nActProp].Name = rtl::OUString(sModifyPasswordInfo);
1627 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1629 if ( rSet.GetItemState( SID_ENCRYPTIONDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1631 pValue[nActProp].Name = rtl::OUString(sEncryptionData);
1632 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1634 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASDIR, sal_False, &pItem ) == SFX_ITEM_SET )
1636 pValue[nActProp].Name = rtl::OUString(sSuggestedSaveAsDir);
1637 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1639 if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1641 pValue[nActProp].Name = rtl::OUString(sSuggestedSaveAsName);
1642 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1644 if ( rSet.GetItemState( SID_DOC_SERVICE, sal_False, &pItem ) == SFX_ITEM_SET )
1646 pValue[nActProp].Name = rtl::OUString(sDocumentService);
1647 pValue[nActProp++].Value <<= rtl::OUString(static_cast<const SfxStringItem*>(pItem)->GetValue());
1652 rArgs = aSequ;
1655 SFX_IMPL_XINTERFACE_5( SfxMacroLoader, OWeakObject, ::com::sun::star::frame::XDispatchProvider, ::com::sun::star::frame::XNotifyingDispatch, ::com::sun::star::frame::XDispatch, ::com::sun::star::frame::XSynchronousDispatch,::com::sun::star::lang::XInitialization )
1656 SFX_IMPL_XTYPEPROVIDER_5( SfxMacroLoader, ::com::sun::star::frame::XDispatchProvider, ::com::sun::star::frame::XNotifyingDispatch, ::com::sun::star::frame::XDispatch, ::com::sun::star::frame::XSynchronousDispatch,::com::sun::star::lang::XInitialization )
1657 SFX_IMPL_XSERVICEINFO( SfxMacroLoader, PROTOCOLHANDLER_SERVICENAME, "com.sun.star.comp.sfx2.SfxMacroLoader" )
1658 SFX_IMPL_SINGLEFACTORY( SfxMacroLoader )
1660 void SAL_CALL SfxMacroLoader::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1662 Reference < XFrame > xFrame;
1663 if ( aArguments.getLength() )
1665 aArguments[0] >>= xFrame;
1666 m_xFrame = xFrame;
1670 SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
1672 SfxObjectShell* pDocShell = NULL;
1673 Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
1674 if ( xFrame.is() )
1676 SfxFrame* pFrame=0;
1677 for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
1679 if ( pFrame->GetFrameInterface() == xFrame )
1680 break;
1683 if ( pFrame )
1684 pDocShell = pFrame->GetCurrentDocument();
1687 return pDocShell;
1690 // -----------------------------------------------------------------------
1691 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SfxMacroLoader::queryDispatch(
1692 const ::com::sun::star::util::URL& aURL ,
1693 const ::rtl::OUString& /*sTargetFrameName*/,
1694 sal_Int32 /*nSearchFlags*/ ) throw( ::com::sun::star::uno::RuntimeException )
1696 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatcher;
1697 if(aURL.Complete.compareToAscii("macro:",6)==0)
1698 xDispatcher = this;
1699 return xDispatcher;
1702 // -----------------------------------------------------------------------
1703 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > SAL_CALL
1704 SfxMacroLoader::queryDispatches( const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor )
1705 throw( ::com::sun::star::uno::RuntimeException )
1707 sal_Int32 nCount = seqDescriptor.getLength();
1708 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > lDispatcher(nCount);
1709 for( sal_Int32 i=0; i<nCount; ++i )
1710 lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1711 seqDescriptor[i].FrameName,
1712 seqDescriptor[i].SearchFlags );
1713 return lDispatcher;
1716 // -----------------------------------------------------------------------
1717 void SAL_CALL SfxMacroLoader::dispatchWithNotification( const ::com::sun::star::util::URL& aURL ,
1718 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& /*lArgs*/ ,
1719 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& xListener )
1720 throw (::com::sun::star::uno::RuntimeException)
1722 SolarMutexGuard aGuard;
1724 ::com::sun::star::uno::Any aAny;
1725 ErrCode nErr = loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1726 if( xListener.is() )
1728 // always call dispatchFinished(), because we didn't load a document but
1729 // executed a macro instead!
1730 ::com::sun::star::frame::DispatchResultEvent aEvent;
1732 aEvent.Source = static_cast< ::cppu::OWeakObject* >(this);
1733 if( nErr == ERRCODE_NONE )
1734 aEvent.State = ::com::sun::star::frame::DispatchResultState::SUCCESS;
1735 else
1736 aEvent.State = ::com::sun::star::frame::DispatchResultState::FAILURE;
1738 xListener->dispatchFinished( aEvent ) ;
1742 ::com::sun::star::uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue(
1743 const ::com::sun::star::util::URL& aURL,
1744 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& ) throw (::com::sun::star::uno::RuntimeException)
1746 ::com::sun::star::uno::Any aRet;
1747 /*ErrCode nErr = */loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() );
1748 return aRet;
1751 // -----------------------------------------------------------------------
1752 void SAL_CALL SfxMacroLoader::dispatch( const ::com::sun::star::util::URL& aURL ,
1753 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& /*lArgs*/ )
1754 throw (::com::sun::star::uno::RuntimeException)
1756 SolarMutexGuard aGuard;
1758 ::com::sun::star::uno::Any aAny;
1759 /*ErrCode nErr = */loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1762 // -----------------------------------------------------------------------
1763 void SAL_CALL SfxMacroLoader::addStatusListener(
1764 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& ,
1765 const ::com::sun::star::util::URL& )
1766 throw (::com::sun::star::uno::RuntimeException)
1768 /* TODO
1769 How we can handle different listener for further coming or currently running dispatch() jobs
1770 without any inconsistency!
1774 // -----------------------------------------------------------------------
1775 void SAL_CALL SfxMacroLoader::removeStatusListener(
1776 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >&,
1777 const ::com::sun::star::util::URL& )
1778 throw (::com::sun::star::uno::RuntimeException)
1782 ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star::uno::Any& rRetval, SfxObjectShell* pSh )
1783 throw ( ::com::sun::star::uno::RuntimeException )
1785 #ifdef DISABLE_SCRIPTING
1786 (void) rURL;
1787 (void) rRetval;
1788 (void) pSh;
1789 return ERRCODE_BASIC_PROC_UNDEFINED;
1790 #else
1791 SfxObjectShell* pCurrent = pSh;
1792 if ( !pCurrent )
1793 // all not full qualified names use the BASIC of the given or current document
1794 pCurrent = SfxObjectShell::Current();
1796 // 'macro:///lib.mod.proc(args)' => macro of App-BASIC
1797 // 'macro://[docname|.]/lib.mod.proc(args)' => macro of current or qualified document
1798 // 'macro://obj.method(args)' => direct API call, execute it via App-BASIC
1799 String aMacro( rURL );
1800 sal_uInt16 nHashPos = aMacro.Search( '/', 8 );
1801 sal_uInt16 nArgsPos = aMacro.Search( '(' );
1802 BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
1803 BasicManager *pBasMgr = 0;
1804 ErrCode nErr = ERRCODE_NONE;
1806 // should a macro function be executed ( no direct API call)?
1807 if ( STRING_NOTFOUND != nHashPos && nHashPos < nArgsPos )
1809 // find BasicManager
1810 SfxObjectShell* pDoc = NULL;
1811 String aBasMgrName( INetURLObject::decode(aMacro.Copy( 8, nHashPos-8 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1812 if ( !aBasMgrName.Len() )
1813 pBasMgr = pAppMgr;
1814 else if ( aBasMgrName.EqualsAscii(".") )
1816 // current/actual document
1817 pDoc = pCurrent;
1818 if (pDoc)
1819 pBasMgr = pDoc->GetBasicManager();
1821 else
1823 // full qualified name, find document by name
1824 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
1825 pObjSh && !pBasMgr;
1826 pObjSh = SfxObjectShell::GetNext(*pObjSh) )
1827 if ( aBasMgrName == pObjSh->GetTitle(SFX_TITLE_APINAME) )
1829 pDoc = pObjSh;
1830 pBasMgr = pDoc->GetBasicManager();
1834 if ( pBasMgr )
1836 const bool bIsAppBasic = ( pBasMgr == pAppMgr );
1837 const bool bIsDocBasic = ( pBasMgr != pAppMgr );
1839 if ( pDoc )
1841 // security check for macros from document basic if an SFX doc is given
1842 if ( !pDoc->AdjustMacroMode( String() ) )
1843 // check forbids execution
1844 return ERRCODE_IO_ACCESSDENIED;
1846 else if ( pDoc && pDoc->GetMedium() )
1848 pDoc->AdjustMacroMode( String() );
1849 SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
1850 SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False);
1851 if ( pUpdateDocItem && pMacroExecModeItem
1852 && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE
1853 && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE )
1854 return ERRCODE_IO_ACCESSDENIED;
1857 // find BASIC method
1858 String aQualifiedMethod( INetURLObject::decode(aMacro.Copy( nHashPos+1 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1859 String aArgs;
1860 if ( STRING_NOTFOUND != nArgsPos )
1862 // remove arguments from macro name
1863 aArgs = aQualifiedMethod.Copy( nArgsPos - nHashPos - 1 );
1864 aQualifiedMethod.Erase( nArgsPos - nHashPos - 1 );
1867 if ( pBasMgr->HasMacro( aQualifiedMethod ) )
1869 Any aOldThisComponent;
1870 const bool bSetDocMacroMode = ( pDoc != NULL ) && bIsDocBasic;
1871 const bool bSetGlobalThisComponent = ( pDoc != NULL ) && bIsAppBasic;
1872 if ( bSetDocMacroMode )
1874 // mark document: it executes an own macro, so it's in a modal mode
1875 pDoc->SetMacroMode_Impl( sal_True );
1878 if ( bSetGlobalThisComponent )
1880 // document is executed via AppBASIC, adjust ThisComponent variable
1881 aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pDoc->GetModel() ) );
1884 // just to let the shell be alive
1885 SfxObjectShellRef xKeepDocAlive = pDoc;
1888 // attempt to protect the document against the script tampering with its Undo Context
1889 ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
1890 if ( bIsDocBasic )
1891 pUndoGuard.reset( new ::framework::DocumentUndoGuard( pDoc->GetModel() ) );
1893 // execute the method
1894 SbxVariableRef retValRef = new SbxVariable;
1895 nErr = pBasMgr->ExecuteMacro( aQualifiedMethod, aArgs, retValRef );
1896 if ( nErr == ERRCODE_NONE )
1897 rRetval = sbxToUnoValue( retValRef );
1900 if ( bSetGlobalThisComponent )
1902 pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent );
1905 if ( bSetDocMacroMode )
1907 // remove flag for modal mode
1908 pDoc->SetMacroMode_Impl( sal_False );
1911 else
1912 nErr = ERRCODE_BASIC_PROC_UNDEFINED;
1914 else
1915 nErr = ERRCODE_IO_NOTEXISTS;
1917 else
1919 // direct API call on a specified object
1920 String aCall( '[' );
1921 aCall += String(INetURLObject::decode(aMacro.Copy(6), INET_HEX_ESCAPE,
1922 INetURLObject::DECODE_WITH_CHARSET));
1923 aCall += ']';
1924 pAppMgr->GetLib(0)->Execute( aCall );
1925 nErr = SbxBase::GetError();
1928 SbxBase::ResetError();
1929 return nErr;
1930 #endif
1933 SFX_IMPL_XSERVICEINFO( SfxAppDispatchProvider, "com.sun.star.frame.DispatchProvider", "com.sun.star.comp.sfx2.AppDispatchProvider" ) \
1934 SFX_IMPL_SINGLEFACTORY( SfxAppDispatchProvider );
1936 void SAL_CALL SfxAppDispatchProvider::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1938 Reference < XFrame > xFrame;
1939 if ( aArguments.getLength() )
1941 aArguments[0] >>= xFrame;
1942 m_xFrame = xFrame;
1946 Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch(
1947 const ::com::sun::star::util::URL& aURL,
1948 const ::rtl::OUString& /*sTargetFrameName*/,
1949 FrameSearchFlags /*eSearchFlags*/ ) throw( RuntimeException )
1951 sal_uInt16 nId( 0 );
1952 sal_Bool bMasterCommand( sal_False );
1953 Reference < XDispatch > xDisp;
1954 const SfxSlot* pSlot = 0;
1955 SfxDispatcher* pAppDisp = SFX_APP()->GetAppDispatcher_Impl();
1956 if ( aURL.Protocol.compareToAscii( "slot:" ) == COMPARE_EQUAL ||
1957 aURL.Protocol.compareToAscii( "commandId:" ) == COMPARE_EQUAL )
1959 nId = (sal_uInt16) aURL.Path.toInt32();
1960 SfxShell* pShell;
1961 pAppDisp->GetShellAndSlot_Impl( nId, &pShell, &pSlot, sal_True, sal_True );
1963 else if ( aURL.Protocol.compareToAscii( ".uno:" ) == COMPARE_EQUAL )
1965 // Support ".uno" commands. Map commands to slotid
1966 bMasterCommand = SfxOfficeDispatch::IsMasterUnoCommand( aURL );
1967 if ( bMasterCommand )
1968 pSlot = pAppDisp->GetSlot( SfxOfficeDispatch::GetMasterUnoCommand( aURL ) );
1969 else
1970 pSlot = pAppDisp->GetSlot( aURL.Main );
1973 if ( pSlot )
1975 SfxOfficeDispatch* pDispatch = new SfxOfficeDispatch( pAppDisp, pSlot, aURL ) ;
1976 pDispatch->SetFrame(m_xFrame);
1977 pDispatch->SetMasterUnoCommand( bMasterCommand );
1978 xDisp = pDispatch;
1981 return xDisp;
1984 Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispatches( const Sequence < DispatchDescriptor >& seqDescriptor )
1985 throw( RuntimeException )
1987 sal_Int32 nCount = seqDescriptor.getLength();
1988 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > lDispatcher(nCount);
1989 for( sal_Int32 i=0; i<nCount; ++i )
1990 lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1991 seqDescriptor[i].FrameName,
1992 seqDescriptor[i].SearchFlags );
1993 return lDispatcher;
1996 Sequence< sal_Int16 > SAL_CALL SfxAppDispatchProvider::getSupportedCommandGroups()
1997 throw (::com::sun::star::uno::RuntimeException)
1999 SolarMutexGuard aGuard;
2001 std::list< sal_Int16 > aGroupList;
2002 SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2004 const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2006 // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2007 for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2009 String aName = pAppSlotPool->SeekGroup( i );
2010 const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2011 while ( pSfxSlot )
2013 if ( pSfxSlot->GetMode() & nMode )
2015 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2016 aGroupList.push_back( nCommandGroup );
2017 break;
2019 pSfxSlot = pAppSlotPool->NextSlot();
2023 ::com::sun::star::uno::Sequence< sal_Int16 > aSeq =
2024 comphelper::containerToSequence< sal_Int16, std::list< sal_Int16 > >( aGroupList );
2026 return aSeq;
2029 Sequence< ::com::sun::star::frame::DispatchInformation > SAL_CALL SfxAppDispatchProvider::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
2030 throw (::com::sun::star::uno::RuntimeException)
2032 std::list< ::com::sun::star::frame::DispatchInformation > aCmdList;
2034 SolarMutexGuard aGuard;
2035 SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2037 if ( pAppSlotPool )
2039 const sal_uIntPtr nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2040 rtl::OUString aCmdPrefix( ".uno:" );
2042 // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2043 for ( sal_uInt16 i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2045 String aName = pAppSlotPool->SeekGroup( i );
2046 const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2047 if ( pSfxSlot )
2049 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2050 if ( nCommandGroup == nCmdGroup )
2052 while ( pSfxSlot )
2054 if ( pSfxSlot->GetMode() & nMode )
2056 ::com::sun::star::frame::DispatchInformation aCmdInfo;
2057 ::rtl::OUStringBuffer aBuf( aCmdPrefix );
2058 aBuf.appendAscii( pSfxSlot->GetUnoName() );
2059 aCmdInfo.Command = aBuf.makeStringAndClear();
2060 aCmdInfo.GroupId = nCommandGroup;
2061 aCmdList.push_back( aCmdInfo );
2063 pSfxSlot = pAppSlotPool->NextSlot();
2070 ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
2071 comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aCmdList );
2073 return aSeq;
2076 #ifdef TEST_HANDLERS
2077 #include <cppuhelper/implbase2.hxx>
2079 #include <com/sun/star/awt/XKeyHandler.hdl>
2080 #include <com/sun/star/awt/XMouseClickHandler.hdl>
2082 class TestKeyHandler: public ::cppu::WeakImplHelper2
2084 com::sun::star::awt::XKeyHandler,
2085 com::sun::star::lang::XServiceInfo
2088 public:
2089 TestKeyHandler( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& ){}
2091 SFX_DECL_XSERVICEINFO
2092 virtual sal_Bool SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
2093 virtual sal_Bool SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
2094 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source)
2095 throw (::com::sun::star::uno::RuntimeException);
2098 class TestMouseClickHandler: public ::cppu::WeakImplHelper2
2100 com::sun::star::awt::XMouseClickHandler,
2101 com::sun::star::lang::XServiceInfo
2104 public:
2105 TestMouseClickHandler( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& ){}
2107 SFX_DECL_XSERVICEINFO
2108 virtual sal_Bool SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
2109 virtual sal_Bool SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
2110 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source)
2111 throw (::com::sun::star::uno::RuntimeException);
2114 sal_Bool SAL_CALL TestKeyHandler::keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
2116 return sal_False;
2119 sal_Bool SAL_CALL TestKeyHandler::keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
2121 return sal_False;
2124 void SAL_CALL TestKeyHandler::disposing( const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException)
2128 sal_Bool SAL_CALL TestMouseClickHandler::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException)
2130 return sal_False;
2133 sal_Bool SAL_CALL TestMouseClickHandler::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException)
2135 return sal_False;
2138 void SAL_CALL TestMouseClickHandler::disposing( const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException)
2142 SFX_IMPL_XSERVICEINFO( TestKeyHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.KeyHandler");
2143 SFX_IMPL_XSERVICEINFO( TestMouseClickHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.MouseClickHandler");
2144 SFX_IMPL_SINGLEFACTORY( TestKeyHandler );
2145 SFX_IMPL_SINGLEFACTORY( TestMouseClickHandler );
2146 #endif
2147 // -----------------------------------------------------------------------
2149 extern "C" {
2151 SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory(
2152 const sal_Char* pImplementationName ,
2153 void* pServiceManager ,
2154 void* )
2156 // Set default return value for this operation - if it failed.
2157 void* pReturn = NULL ;
2159 if (
2160 ( pImplementationName != NULL ) &&
2161 ( pServiceManager != NULL )
2164 // Define variables which are used in following macros.
2165 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
2166 xFactory;
2167 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager( reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ) ) ;
2169 //=============================================================================
2170 // Add new macro line to handle new service.
2171 // !!! ATTENTION !!!
2172 // Write no ";" at end of line and dont forget "else" ! (see macro)
2173 //=============================================================================
2174 IF_NAME_CREATECOMPONENTFACTORY( SfxGlobalEvents_Impl )
2175 IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl )
2176 IF_NAME_CREATECOMPONENTFACTORY( SfxMacroLoader )
2177 IF_NAME_CREATECOMPONENTFACTORY( SfxStandaloneDocumentInfoObject )
2178 IF_NAME_CREATECOMPONENTFACTORY( SfxAppDispatchProvider )
2179 IF_NAME_CREATECOMPONENTFACTORY( SfxDocTplService )
2180 IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon )
2181 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationScriptLibraryContainer )
2182 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationDialogLibraryContainer )
2183 #ifdef TEST_HANDLERS
2184 IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
2185 IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler )
2186 #endif
2187 IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator )
2188 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject )
2189 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject )
2190 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService )
2191 if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
2192 ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2194 xFactory = ::cppu::createSingleComponentFactory(
2195 ::comp_SfxDocumentMetaData::_create,
2196 ::comp_SfxDocumentMetaData::_getImplementationName(),
2197 ::comp_SfxDocumentMetaData::_getSupportedServiceNames());
2199 if ( ::comp_CompatWriterDocProps::_getImplementationName().equals(
2200 ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2202 xFactory = ::cppu::createSingleComponentFactory(
2203 ::comp_CompatWriterDocProps::_create,
2204 ::comp_CompatWriterDocProps::_getImplementationName(),
2205 ::comp_CompatWriterDocProps::_getSupportedServiceNames());
2208 // Factory is valid - service was found.
2210 // Factory is valid - service was found.
2211 if ( xFactory.is() )
2213 xFactory->acquire();
2214 pReturn = xFactory.get();
2217 // Return with result of this operation.
2218 return pReturn ;
2220 } // extern "C"
2222 //=========================================================================
2224 void SAL_CALL FilterOptionsContinuation::setFilterOptions(
2225 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps )
2226 throw (::com::sun::star::uno::RuntimeException)
2228 rProperties = rProps;
2231 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
2232 FilterOptionsContinuation::getFilterOptions()
2233 throw (::com::sun::star::uno::RuntimeException)
2235 return rProperties;
2238 //=========================================================================
2240 RequestFilterOptions::RequestFilterOptions( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > rModel,
2241 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > rProperties )
2243 ::rtl::OUString temp;
2244 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2245 ::com::sun::star::document::FilterOptionsRequest aOptionsRequest( temp,
2246 temp2,
2247 rModel,
2248 rProperties );
2250 m_aRequest <<= aOptionsRequest;
2252 m_pAbort = new comphelper::OInteractionAbort;
2253 m_pOptions = new FilterOptionsContinuation;
2255 m_lContinuations.realloc( 2 );
2256 m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
2257 m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pOptions );
2260 ::com::sun::star::uno::Any SAL_CALL RequestFilterOptions::getRequest()
2261 throw( ::com::sun::star::uno::RuntimeException )
2263 return m_aRequest;
2266 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2267 SAL_CALL RequestFilterOptions::getContinuations()
2268 throw( ::com::sun::star::uno::RuntimeException )
2270 return m_lContinuations;
2273 //=========================================================================
2274 class RequestPackageReparation_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
2276 ::com::sun::star::uno::Any m_aRequest;
2277 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
2278 comphelper::OInteractionApprove* m_pApprove;
2279 comphelper::OInteractionDisapprove* m_pDisapprove;
2281 public:
2282 RequestPackageReparation_Impl( ::rtl::OUString aName );
2283 sal_Bool isApproved();
2284 virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException );
2285 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations()
2286 throw( ::com::sun::star::uno::RuntimeException );
2289 RequestPackageReparation_Impl::RequestPackageReparation_Impl( ::rtl::OUString aName )
2291 ::rtl::OUString temp;
2292 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2293 ::com::sun::star::document::BrokenPackageRequest aBrokenPackageRequest( temp,
2294 temp2,
2295 aName );
2296 m_aRequest <<= aBrokenPackageRequest;
2297 m_pApprove = new comphelper::OInteractionApprove;
2298 m_pDisapprove = new comphelper::OInteractionDisapprove;
2299 m_lContinuations.realloc( 2 );
2300 m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pApprove );
2301 m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pDisapprove );
2304 sal_Bool RequestPackageReparation_Impl::isApproved()
2306 return m_pApprove->wasSelected();
2309 ::com::sun::star::uno::Any SAL_CALL RequestPackageReparation_Impl::getRequest()
2310 throw( ::com::sun::star::uno::RuntimeException )
2312 return m_aRequest;
2315 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2316 SAL_CALL RequestPackageReparation_Impl::getContinuations()
2317 throw( ::com::sun::star::uno::RuntimeException )
2319 return m_lContinuations;
2322 RequestPackageReparation::RequestPackageReparation( ::rtl::OUString aName )
2324 pImp = new RequestPackageReparation_Impl( aName );
2325 pImp->acquire();
2328 RequestPackageReparation::~RequestPackageReparation()
2330 pImp->release();
2333 sal_Bool RequestPackageReparation::isApproved()
2335 return pImp->isApproved();
2338 com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest > RequestPackageReparation::GetRequest()
2340 return com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest >(pImp);
2343 //=========================================================================
2344 class NotifyBrokenPackage_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
2346 ::com::sun::star::uno::Any m_aRequest;
2347 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
2348 comphelper::OInteractionAbort* m_pAbort;
2350 public:
2351 NotifyBrokenPackage_Impl( ::rtl::OUString aName );
2352 virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException );
2353 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations()
2354 throw( ::com::sun::star::uno::RuntimeException );
2357 NotifyBrokenPackage_Impl::NotifyBrokenPackage_Impl( ::rtl::OUString aName )
2359 ::rtl::OUString temp;
2360 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2361 ::com::sun::star::document::BrokenPackageRequest aBrokenPackageRequest( temp,
2362 temp2,
2363 aName );
2364 m_aRequest <<= aBrokenPackageRequest;
2365 m_pAbort = new comphelper::OInteractionAbort;
2366 m_lContinuations.realloc( 1 );
2367 m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
2370 ::com::sun::star::uno::Any SAL_CALL NotifyBrokenPackage_Impl::getRequest()
2371 throw( ::com::sun::star::uno::RuntimeException )
2373 return m_aRequest;
2376 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2377 SAL_CALL NotifyBrokenPackage_Impl::getContinuations()
2378 throw( ::com::sun::star::uno::RuntimeException )
2380 return m_lContinuations;
2383 NotifyBrokenPackage::NotifyBrokenPackage( ::rtl::OUString aName )
2385 pImp = new NotifyBrokenPackage_Impl( aName );
2386 pImp->acquire();
2389 NotifyBrokenPackage::~NotifyBrokenPackage()
2391 pImp->release();
2394 com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest > NotifyBrokenPackage::GetRequest()
2396 return com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest >(pImp);
2399 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */