update dev300-m58
[ooovba.git] / sfx2 / source / appl / appuno.cxx
blob5490a4a747ae229dbe5b33d8a6b1d661f7375966
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appuno.cxx,v $
10 * $Revision: 1.131 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
33 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
34 #pragma warning( disable : 4290 )
35 #endif
36 #include <com/sun/star/document/UpdateDocMode.hpp>
38 #include "sal/config.h"
40 #include <sfx2/appuno.hxx>
41 #include "appbaslib.hxx"
43 #include "sfx2/dllapi.h"
45 #include <basic/sbx.hxx>
46 #include <svtools/itempool.hxx>
47 #include <svtools/rectitem.hxx>
48 #include <tools/debug.hxx>
49 #include <tools/wldcrd.hxx>
51 #include <tools/urlobj.hxx>
52 #include <tools/config.hxx>
53 #include <basic/sbxmeth.hxx>
54 #include <basic/sbmeth.hxx>
55 #include <basic/sbxobj.hxx>
56 #include <basic/sberrors.hxx>
57 #include <basic/basmgr.hxx>
58 #ifndef _BASIC_SBUNO_HXX
59 #include <basic/sbuno.hxx>
60 #endif
62 #include <basic/sbxcore.hxx>
63 #include <svtools/ownlist.hxx>
64 #include <svtools/lckbitem.hxx>
65 #include <svtools/stritem.hxx>
66 #include <svtools/slstitm.hxx>
67 #include <svtools/intitem.hxx>
68 #include <svtools/eitem.hxx>
69 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
70 #include <com/sun/star/task/XInteractionHandler.hpp>
71 #include <com/sun/star/io/XInputStream.hpp>
72 #include <com/sun/star/beans/XPropertySet.hpp>
73 #include <com/sun/star/frame/XFrameActionListener.hpp>
74 #include <com/sun/star/frame/XComponentLoader.hpp>
75 #include <com/sun/star/frame/XFrame.hpp>
76 #include <com/sun/star/frame/FrameActionEvent.hpp>
77 #include <com/sun/star/frame/FrameAction.hpp>
78 #include <com/sun/star/container/XContainer.hpp>
79 #include <com/sun/star/container/XIndexContainer.hpp>
80 #include <com/sun/star/container/XNameReplace.hpp>
81 #include <com/sun/star/container/XContainerListener.hpp>
82 #include <com/sun/star/container/XSet.hpp>
83 #include <com/sun/star/container/ContainerEvent.hpp>
84 #include <com/sun/star/container/XIndexReplace.hpp>
85 #include <com/sun/star/container/XNameContainer.hpp>
86 #include <com/sun/star/awt/XTopWindow.hpp>
87 #include <com/sun/star/awt/XWindow.hpp>
88 #include <com/sun/star/awt/PosSize.hpp>
89 #include <com/sun/star/registry/RegistryValueType.hpp>
90 #include <comphelper/processfactory.hxx>
91 #include <com/sun/star/awt/PosSize.hpp>
92 #include <com/sun/star/awt/XButton.hpp>
93 #include <com/sun/star/frame/DispatchResultEvent.hpp>
94 #include <com/sun/star/frame/DispatchResultState.hpp>
95 #include <com/sun/star/frame/XModel.hpp>
96 #include <com/sun/star/document/MacroExecMode.hpp>
97 #include <com/sun/star/ucb/XContent.hpp>
99 #include <tools/cachestr.hxx>
100 #include <osl/mutex.hxx>
101 #include <comphelper/sequence.hxx>
102 #include <rtl/ustrbuf.hxx>
104 using namespace ::com::sun::star;
105 using namespace ::com::sun::star::ucb;
106 using namespace ::com::sun::star::uno;
107 using namespace ::com::sun::star::registry;
108 using namespace ::com::sun::star::frame;
109 using namespace ::com::sun::star::beans;
110 using namespace ::com::sun::star::io;
112 #ifndef GCC
113 #endif
115 #include "sfxtypes.hxx"
116 #include <sfx2/sfxuno.hxx>
117 #include <sfx2/app.hxx>
118 #include <sfx2/sfxsids.hrc>
119 #include <sfx2/msg.hxx>
120 #include <sfx2/msgpool.hxx>
121 #include <sfx2/request.hxx>
122 #include <sfx2/module.hxx>
123 #include <sfx2/fcontnr.hxx>
124 #include "frmload.hxx"
125 #include <sfx2/frame.hxx>
126 #include "sfxbasic.hxx"
127 #include <sfx2/objsh.hxx>
128 #include <sfx2/objuno.hxx>
129 #include <sfx2/unoctitm.hxx>
130 #include <sfx2/dispatch.hxx>
131 #include "doctemplates.hxx"
132 #include "shutdownicon.hxx"
133 #include "objshimp.hxx"
134 #include "fltoptint.hxx"
135 #include <sfx2/docfile.hxx>
136 #include <sfx2/sfxbasecontroller.hxx>
137 #include "brokenpackageint.hxx"
138 #include "eventsupplier.hxx"
139 #include "xpackcreator.hxx"
140 #include "applet.hxx"
141 #include "plugin.hxx"
142 #include "iframe.hxx"
143 #include <ownsubfilterservice.hxx>
144 #include "SfxDocumentMetaData.hxx"
147 #define FRAMELOADER_SERVICENAME "com.sun.star.frame.FrameLoader"
148 #define PROTOCOLHANDLER_SERVICENAME "com.sun.star.frame.ProtocolHandler"
150 static const String sTemplateRegionName = String::CreateFromAscii( "TemplateRegionName" );
151 static const String sTemplateName = String::CreateFromAscii( "TemplateName" );
152 static const String sAsTemplate = String::CreateFromAscii( "AsTemplate" );
153 static const String sOpenNewView = String::CreateFromAscii( "OpenNewView" );
154 static const String sViewId = String::CreateFromAscii( "ViewId" );
155 static const String sPluginMode = String::CreateFromAscii( "PluginMode" );
156 static const String sReadOnly = String::CreateFromAscii( "ReadOnly" );
157 static const String sStartPresentation = String::CreateFromAscii( "StartPresentation" );
158 static const String sFrameName = String::CreateFromAscii( "FrameName" );
159 static const String sMediaType = String::CreateFromAscii( "MediaType" );
160 static const String sPostData = String::CreateFromAscii( "PostData" );
161 static const String sCharacterSet = String::CreateFromAscii( "CharacterSet" );
162 static const String sInputStream = String::CreateFromAscii( "InputStream" );
163 static const String sStream = String::CreateFromAscii( "Stream" );
164 static const String sOutputStream = String::CreateFromAscii( "OutputStream" );
165 static const String sHidden = String::CreateFromAscii( "Hidden" );
166 static const String sPreview = String::CreateFromAscii( "Preview" );
167 static const String sViewOnly = String::CreateFromAscii( "ViewOnly" );
168 static const String sDontEdit = String::CreateFromAscii( "DontEdit" );
169 static const String sSilent = String::CreateFromAscii( "Silent" );
170 static const String sJumpMark = String::CreateFromAscii( "JumpMark" );
171 static const String sFileName = String::CreateFromAscii( "FileName" );
172 static const String sSalvageURL = String::CreateFromAscii( "SalvagedFile" );
173 static const String sStatusInd = String::CreateFromAscii( "StatusIndicator" );
174 static const String sModel = String::CreateFromAscii( "Model" );
175 static const String sFrame = String::CreateFromAscii( "Frame" );
176 static const String sViewData = String::CreateFromAscii( "ViewData" );
177 static const String sFilterData = String::CreateFromAscii( "FilterData" );
178 static const String sSelectionOnly = String::CreateFromAscii( "SelectionOnly" );
179 static const String sFilterFlags = String::CreateFromAscii( "FilterFlags" );
180 static const String sMacroExecMode = String::CreateFromAscii( "MacroExecutionMode" );
181 static const String sUpdateDocMode = String::CreateFromAscii( "UpdateDocMode" );
182 static const String sMinimized = String::CreateFromAscii( "Minimized" );
183 static const String sInteractionHdl = String::CreateFromAscii( "InteractionHandler" );
184 static const String sWindowState = String::CreateFromAscii( "WindowState" );
185 static const String sUCBContent = String::CreateFromAscii( "UCBContent" );
186 static const String sRepairPackage = String::CreateFromAscii( "RepairPackage" );
187 static const String sDocumentTitle = String::CreateFromAscii( "DocumentTitle" );
188 static const String sComponentData = String::CreateFromAscii( "ComponentData" );
189 static const String sComponentContext = String::CreateFromAscii( "ComponentContext" );
190 static const String sDocumentBaseURL = String::CreateFromAscii( "DocumentBaseURL" );
191 static const String sHierarchicalDocumentName = String::CreateFromAscii( "HierarchicalDocumentName" );
192 static const String sCopyStreamIfPossible = String::CreateFromAscii( "CopyStreamIfPossible" );
193 static const String sNoAutoSave = String::CreateFromAscii( "NoAutoSave" );
194 static const String sFolderName = String::CreateFromAscii( "FolderName" );
195 static const String sUseSystemDialog = String::CreateFromAscii( "UseSystemDialog" );
196 static const String sStandardDir = String::CreateFromAscii( "StandardDir" );
197 static const String sBlackList = String::CreateFromAscii( "BlackList" );
199 void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot )
201 if ( !pSlot )
202 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
204 if ( !pSlot )
205 return;
207 if ( nSlotId == SID_OPENURL )
208 nSlotId = SID_OPENDOC;
209 if ( nSlotId == SID_SAVEASURL )
210 nSlotId = SID_SAVEASDOC;
212 sal_Int32 nCount = rArgs.getLength();
213 if ( !nCount )
214 return;
216 const ::com::sun::star::beans::PropertyValue* pPropsVal = rArgs.getConstArray();
217 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
219 // slot is a property
220 const SfxType* pType = pSlot->GetType();
221 SfxPoolItem* pItem = pType->CreateItem();
222 if ( !pItem )
224 #ifdef DBG_UTIL
225 ByteString aStr( "No creator method for item: ");
226 aStr += ByteString::CreateFromInt32( nSlotId );
227 DBG_ERROR( aStr.GetBuffer() );
228 #endif
229 return;
232 USHORT nWhich = rSet.GetPool()->GetWhich(nSlotId);
233 BOOL bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
234 pItem->SetWhich( nWhich );
235 USHORT nSubCount = pType->nAttribs;
237 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[0];
238 String aName = rProp.Name;
239 if ( nCount == 1 && aName.CompareToAscii( pSlot->pUnoName ) == COMPARE_EQUAL )
241 // there is only one parameter and its name matches the name of the property,
242 // so it's either a simple property or a complex property in one single UNO struct
243 if( pItem->PutValue( rProp.Value, bConvertTwips ? CONVERT_TWIPS : 0 ) )
244 // only use successfully converted items
245 rSet.Put( *pItem );
246 #ifdef DBG_UTIL
247 else
249 ByteString aStr( "Property not convertable: ");
250 aStr += pSlot->pUnoName;
251 DBG_ERROR( aStr.GetBuffer() );
253 #endif
255 #ifdef DBG_UTIL
256 else if ( nSubCount == 0 )
258 // for a simple property there can be only one parameter and its name *must* match
259 ByteString aStr( "Property name does not match: ");
260 aStr += ByteString( aName, RTL_TEXTENCODING_UTF8 );
261 DBG_ERROR( aStr.GetBuffer() );
263 #endif
264 else
266 // there is more than one parameter and the property is a complex one
267 #ifdef DBG_UTIL
268 // if the dispatch API is used for UI purposes or from the testtool,
269 // it is possible to skip some or all arguments,
270 // but it indicates an error for macro recording;
271 // so this should be notified as a warning only
272 if ( nCount != nSubCount )
274 ByteString aStr( "MacroPlayer: wrong number of parameters for slot: ");
275 aStr += ByteString::CreateFromInt32( nSlotId );
276 DBG_WARNING( aStr.GetBuffer() );
278 #endif
279 // complex property; collect sub items from the parameter set and reconstruct complex item
280 USHORT nFound=0;
281 for ( sal_uInt16 n=0; n<nCount; n++ )
283 const ::com::sun::star::beans::PropertyValue& rPropValue = pPropsVal[n];
284 USHORT nSub;
285 for ( nSub=0; nSub<nSubCount; nSub++ )
287 // search sub item by name
288 ByteString aStr( pSlot->pUnoName );
289 aStr += '.';
290 aStr += ByteString( pType->aAttrib[nSub].pName );
291 const char* pName = aStr.GetBuffer();
292 if ( rPropValue.Name.compareToAscii( pName ) == COMPARE_EQUAL )
294 BYTE nSubId = (BYTE) (sal_Int8) pType->aAttrib[nSub].nAID;
295 if ( bConvertTwips )
296 nSubId |= CONVERT_TWIPS;
297 if ( pItem->PutValue( rPropValue.Value, nSubId ) )
298 nFound++;
299 #ifdef DBG_UTIL
300 else
302 ByteString aDbgStr( "Property not convertable: ");
303 aDbgStr += pSlot->pUnoName;
304 DBG_ERROR( aDbgStr.GetBuffer() );
306 #endif
307 break;
311 #ifdef DBG_UTIL
312 if ( nSub >= nSubCount )
314 // there was a parameter with a name that didn't match to any of the members
315 ByteString aStr( "Property name does not match: ");
316 aStr += ByteString( String(rPropValue.Name), RTL_TEXTENCODING_UTF8 );
317 DBG_ERROR( aStr.GetBuffer() );
319 #endif
322 // at least one part of the complex item must be present; other parts can have default values
323 if ( nFound > 0 )
324 rSet.Put( *pItem );
327 delete pItem;
329 else if ( nCount )
331 #ifdef DBG_UTIL
332 // detect parameters that don't match to any formal argument or one of its members
333 sal_Int32 nFoundArgs = 0;
334 #endif
335 // slot is a method
336 for ( sal_uInt16 nArgs=0; nArgs<pSlot->nArgDefCount; nArgs++ )
338 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArgs );
339 SfxPoolItem* pItem = rArg.CreateItem();
340 if ( !pItem )
342 #ifdef DBG_UTIL
343 ByteString aStr( "No creator method for argument: ");
344 aStr += rArg.pName;
345 DBG_ERROR( aStr.GetBuffer() );
346 #endif
347 return;
350 USHORT nWhich = rSet.GetPool()->GetWhich(rArg.nSlotId);
351 BOOL bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
352 pItem->SetWhich( nWhich );
353 const SfxType* pType = rArg.pType;
354 USHORT nSubCount = pType->nAttribs;
355 if ( nSubCount == 0 )
357 // "simple" (base type) argument
358 for ( sal_uInt16 n=0; n<nCount; n++ )
360 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
361 String aName = rProp.Name;
362 if ( aName.CompareToAscii(rArg.pName) == COMPARE_EQUAL )
364 #ifdef DBG_UTIL
365 ++nFoundArgs;
366 #endif
367 if( pItem->PutValue( rProp.Value ) )
368 // only use successfully converted items
369 rSet.Put( *pItem );
370 #ifdef DBG_UTIL
371 else
373 ByteString aStr( "Property not convertable: ");
374 aStr += rArg.pName;
375 DBG_ERROR( aStr.GetBuffer() );
377 #endif
378 break;
382 else
384 // complex argument, could be passed in one struct
385 BOOL bAsWholeItem = FALSE;
386 for ( sal_uInt16 n=0; n<nCount; n++ )
388 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
389 String aName = rProp.Name;
390 if ( aName.CompareToAscii(rArg.pName) == COMPARE_EQUAL )
392 bAsWholeItem = TRUE;
393 #ifdef DBG_UTIL
394 ++nFoundArgs;
395 #endif
396 if( pItem->PutValue( rProp.Value ) )
397 // only use successfully converted items
398 rSet.Put( *pItem );
399 #ifdef DBG_UTIL
400 else
402 ByteString aStr( "Property not convertable: ");
403 aStr += rArg.pName;
404 DBG_ERROR( aStr.GetBuffer() );
406 #endif
410 if ( !bAsWholeItem )
412 // complex argument; collect sub items from argument array and reconstruct complex item
413 // only put item if at least one member was found and had the correct type
414 // (is this a good idea?! Should we ask for *all* members?)
415 BOOL bRet = FALSE;
416 for ( sal_uInt16 n=0; n<nCount; n++ )
418 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
419 for ( USHORT nSub=0; nSub<nSubCount; nSub++ )
421 // search sub item by name
422 ByteString aStr( rArg.pName );
423 aStr += '.';
424 aStr += pType->aAttrib[nSub].pName;
425 const char* pName = aStr.GetBuffer();
426 if ( rProp.Name.compareToAscii( pName ) == COMPARE_EQUAL )
428 // at least one member found ...
429 bRet = TRUE;
430 #ifdef DBG_UTIL
431 ++nFoundArgs;
432 #endif
433 BYTE nSubId = (BYTE) (sal_Int8) pType->aAttrib[nSub].nAID;
434 if ( bConvertTwips )
435 nSubId |= CONVERT_TWIPS;
436 if (!pItem->PutValue( rProp.Value, nSubId ) )
438 // ... but it was not convertable
439 bRet = FALSE;
440 #ifdef DBG_UTIL
441 ByteString aDbgStr( "Property not convertable: ");
442 aDbgStr += rArg.pName;
443 DBG_ERROR( aDbgStr.GetBuffer() );
444 #endif
447 break;
452 if ( bRet )
453 // only use successfully converted items
454 rSet.Put( *pItem );
459 delete pItem;
462 // special additional parameters for some slots not seen in the slot definitions
463 // Some of these slots are not considered to be used for macro recording, because they shouldn't be recorded as slots,
464 // but as dispatching or factory or arbitrary URLs to the frame
465 // Some also can use additional arguments that are not recordable (will be changed later,
466 // f.e. "SaveAs" shouldn't support parameters not in the slot definition!)
467 if ( nSlotId == SID_NEWWINDOW )
469 for ( sal_uInt16 n=0; n<nCount; n++ )
471 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
472 String aName = rProp.Name;
473 if ( aName == sFrame )
474 rSet.Put( SfxUnoAnyItem( SID_FILLFRAME, rProp.Value ) );
475 else
476 if ( aName == sHidden )
478 sal_Bool bVal = sal_False;
479 if (rProp.Value >>= bVal)
480 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
484 else if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
485 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
487 for ( sal_uInt16 n=0; n<nCount; n++ )
489 #ifdef DBG_UTIL
490 ++nFoundArgs;
491 #endif
492 const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
493 String aName = rProp.Name;
494 if ( aName == sModel )
495 rSet.Put( SfxUnoAnyItem( SID_DOCUMENT, rProp.Value ) );
496 else if ( aName == sComponentData )
498 rSet.Put( SfxUnoAnyItem( SID_COMPONENTDATA, rProp.Value ) );
500 else if ( aName == sComponentContext )
502 rSet.Put( SfxUnoAnyItem( SID_COMPONENTCONTEXT, rProp.Value ) );
504 else if ( aName == sStatusInd )
506 Reference< ::com::sun::star::task::XStatusIndicator > xVal;
507 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
508 DBG_ASSERT( bOK, "invalid type for StatusIndicator" );
509 if (bOK)
510 rSet.Put( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, rProp.Value ) );
512 else if ( aName == sInteractionHdl )
514 Reference< ::com::sun::star::task::XInteractionHandler > xVal;
515 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
516 DBG_ASSERT( bOK, "invalid type for InteractionHandler" );
517 if (bOK)
518 rSet.Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, rProp.Value ) );
520 else if ( aName == sViewData )
521 rSet.Put( SfxUnoAnyItem( SID_VIEW_DATA, rProp.Value ) );
522 else if ( aName == sFilterData )
523 rSet.Put( SfxUnoAnyItem( SID_FILTER_DATA, rProp.Value ) );
524 else if ( aName == sInputStream )
526 Reference< XInputStream > xVal;
527 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
528 DBG_ASSERT( bOK, "invalid type for InputStream" );
529 if (bOK)
530 rSet.Put( SfxUnoAnyItem( SID_INPUTSTREAM, rProp.Value ) );
532 else if ( aName == sStream )
534 Reference< XInputStream > xVal;
535 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
536 DBG_ASSERT( bOK, "invalid type for Stream" );
537 if (bOK)
538 rSet.Put( SfxUnoAnyItem( SID_STREAM, rProp.Value ) );
540 else if ( aName == sUCBContent )
542 Reference< XContent > xVal;
543 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
544 DBG_ASSERT( bOK, "invalid type for UCBContent" );
545 if (bOK)
546 rSet.Put( SfxUnoAnyItem( SID_CONTENT, rProp.Value ) );
548 else if ( aName == sOutputStream )
550 Reference< XOutputStream > xVal;
551 sal_Bool bOK = ((rProp.Value >>= xVal) && xVal.is());
552 DBG_ASSERT( bOK, "invalid type for OutputStream" );
553 if (bOK)
554 rSet.Put( SfxUnoAnyItem( SID_OUTPUTSTREAM, rProp.Value ) );
556 else if ( aName == sPostData )
558 Reference< XInputStream > xVal;
559 sal_Bool bOK = (rProp.Value >>= xVal);
560 DBG_ASSERT( bOK, "invalid type for PostData" );
561 if (bOK)
562 rSet.Put( SfxUnoAnyItem( SID_POSTDATA, rProp.Value ) );
564 else if ( aName == sFrame )
566 Reference< XFrame > xVal;
567 sal_Bool bOK = (rProp.Value >>= xVal);
568 DBG_ASSERT( bOK, "invalid type for Frame" );
569 if (bOK)
570 rSet.Put( SfxUnoAnyItem( SID_FILLFRAME, rProp.Value ) );
572 else if ( aName == sAsTemplate )
574 sal_Bool bVal = sal_False;
575 sal_Bool bOK = (rProp.Value >>= bVal);
576 DBG_ASSERT( bOK, "invalid type for AsTemplate" );
577 if (bOK)
578 rSet.Put( SfxBoolItem( SID_TEMPLATE, bVal ) );
580 else if ( aName == sOpenNewView )
582 sal_Bool bVal = sal_False;
583 sal_Bool bOK = (rProp.Value >>= bVal);
584 DBG_ASSERT( bOK, "invalid type for OpenNewView" );
585 if (bOK)
586 rSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, bVal ) );
588 else if ( aName == sViewId )
590 sal_Int16 nVal = -1;
591 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
592 DBG_ASSERT( bOK, "invalid type for ViewId" );
593 if (bOK)
594 rSet.Put( SfxUInt16Item( SID_VIEW_ID, nVal ) );
596 else if ( aName == sPluginMode )
598 sal_Int16 nVal = -1;
599 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
600 DBG_ASSERT( bOK, "invalid type for PluginMode" );
601 if (bOK)
602 rSet.Put( SfxUInt16Item( SID_PLUGIN_MODE, nVal ) );
604 else if ( aName == sReadOnly )
606 sal_Bool bVal = sal_False;
607 sal_Bool bOK = (rProp.Value >>= bVal);
608 DBG_ASSERT( bOK, "invalid type for ReadOnly" );
609 if (bOK)
610 rSet.Put( SfxBoolItem( SID_DOC_READONLY, bVal ) );
612 else if ( aName == sStartPresentation )
614 sal_Bool bVal = sal_False;
615 sal_Bool bOK = (rProp.Value >>= bVal);
616 DBG_ASSERT( bOK, "invalid type for StartPresentation" );
617 if (bOK)
618 rSet.Put( SfxBoolItem( SID_DOC_STARTPRESENTATION, bVal ) );
620 else if ( aName == sSelectionOnly )
622 sal_Bool bVal = sal_False;
623 sal_Bool bOK = (rProp.Value >>= bVal);
624 DBG_ASSERT( bOK, "invalid type for SelectionOnly" );
625 if (bOK)
626 rSet.Put( SfxBoolItem( SID_SELECTION, bVal ) );
628 else if ( aName == sHidden )
630 sal_Bool bVal = sal_False;
631 sal_Bool bOK = (rProp.Value >>= bVal);
632 DBG_ASSERT( bOK, "invalid type for Hidden" );
633 if (bOK)
634 rSet.Put( SfxBoolItem( SID_HIDDEN, bVal ) );
636 else if ( aName == sMinimized )
638 sal_Bool bVal = sal_False;
639 sal_Bool bOK = (rProp.Value >>= bVal);
640 DBG_ASSERT( bOK, "invalid type for Minimized" );
641 if (bOK)
642 rSet.Put( SfxBoolItem( SID_MINIMIZED, bVal ) );
644 else if ( aName == sSilent )
646 sal_Bool bVal = sal_False;
647 sal_Bool bOK = (rProp.Value >>= bVal);
648 DBG_ASSERT( bOK, "invalid type for Silent" );
649 if (bOK)
650 rSet.Put( SfxBoolItem( SID_SILENT, bVal ) );
652 else if ( aName == sPreview )
654 sal_Bool bVal = sal_False;
655 sal_Bool bOK = (rProp.Value >>= bVal);
656 DBG_ASSERT( bOK, "invalid type for Preview" );
657 if (bOK)
658 rSet.Put( SfxBoolItem( SID_PREVIEW, bVal ) );
660 else if ( aName == sViewOnly )
662 sal_Bool bVal = sal_False;
663 sal_Bool bOK = (rProp.Value >>= bVal);
664 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
665 if (bOK)
666 rSet.Put( SfxBoolItem( SID_VIEWONLY, bVal ) );
668 else if ( aName == sDontEdit )
670 sal_Bool bVal = sal_False;
671 sal_Bool bOK = (rProp.Value >>= bVal);
672 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
673 if (bOK)
674 rSet.Put( SfxBoolItem( SID_EDITDOC, !bVal ) );
676 else if ( aName == sUseSystemDialog )
678 sal_Bool bVal = sal_False;
679 sal_Bool bOK = (rProp.Value >>= bVal);
680 DBG_ASSERT( bOK, "invalid type for ViewOnly" );
681 if (bOK)
682 rSet.Put( SfxBoolItem( SID_FILE_DIALOG, bVal ) );
684 else if ( aName == sStandardDir )
686 ::rtl::OUString sVal;
687 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
688 DBG_ASSERT( bOK, "invalid type or value for StanadardDir" );
689 if (bOK)
690 rSet.Put( SfxStringItem( SID_STANDARD_DIR, sVal ) );
692 else if ( aName == sBlackList )
694 ::com::sun::star::uno::Sequence< ::rtl::OUString > xVal;
695 sal_Bool bOK = (rProp.Value >>= xVal);
696 DBG_ASSERT( bOK, "invalid type or value for BlackList" );
697 if (bOK)
699 SfxStringListItem stringList(SID_BLACK_LIST);
700 stringList.SetStringList( xVal );
701 rSet.Put( stringList );
704 else if ( aName == sFileName )
706 ::rtl::OUString sVal;
707 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
708 DBG_ASSERT( bOK, "invalid type or value for FileName" );
709 if (bOK)
710 rSet.Put( SfxStringItem( SID_FILE_NAME, sVal ) );
712 else if ( aName == sSalvageURL )
714 ::rtl::OUString sVal;
715 sal_Bool bOK = (rProp.Value >>= sVal);
716 DBG_ASSERT( bOK, "invalid type or value for SalvageURL" );
717 if (bOK)
718 rSet.Put( SfxStringItem( SID_DOC_SALVAGE, sVal ) );
720 else if ( aName == sFolderName )
722 ::rtl::OUString sVal;
723 sal_Bool bOK = (rProp.Value >>= sVal);
724 DBG_ASSERT( bOK, "invalid type or value for SalvageURL" );
725 if (bOK)
726 rSet.Put( SfxStringItem( SID_PATH, sVal ) );
728 else if ( aName == sFrameName )
730 ::rtl::OUString sVal;
731 sal_Bool bOK = (rProp.Value >>= sVal);
732 DBG_ASSERT( bOK, "invalid type for FrameName" );
733 if (bOK && sVal.getLength())
734 rSet.Put( SfxStringItem( SID_TARGETNAME, sVal ) );
736 else if ( aName == sMediaType )
738 ::rtl::OUString sVal;
739 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
740 DBG_ASSERT( bOK, "invalid type or value for MediaType" );
741 if (bOK)
742 rSet.Put( SfxStringItem( SID_CONTENTTYPE, sVal ) );
744 else if ( aName == sWindowState )
746 ::rtl::OUString sVal;
747 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
748 DBG_ASSERT( bOK, "invalid type or value for WindowState" );
749 if (bOK)
750 rSet.Put( SfxStringItem( SID_WIN_POSSIZE, sVal ) );
752 else if ( aName == sTemplateName )
754 ::rtl::OUString sVal;
755 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
756 DBG_ASSERT( bOK, "invalid type or value for TemplateName" );
757 if (bOK)
758 rSet.Put( SfxStringItem( SID_TEMPLATE_NAME, sVal ) );
760 else if ( aName == sTemplateRegionName )
762 ::rtl::OUString sVal;
763 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
764 DBG_ASSERT( bOK, "invalid type or value for TemplateRegionName" );
765 if (bOK)
766 rSet.Put( SfxStringItem( SID_TEMPLATE_REGIONNAME, sVal ) );
768 else if ( aName == sJumpMark )
770 ::rtl::OUString sVal;
771 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
772 DBG_ASSERT( bOK, "invalid type or value for JumpMark" );
773 if (bOK)
774 rSet.Put( SfxStringItem( SID_JUMPMARK, sVal ) );
776 else if ( aName == sCharacterSet )
778 ::rtl::OUString sVal;
779 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
780 DBG_ASSERT( bOK, "invalid type or value for CharacterSet" );
781 if (bOK)
782 rSet.Put( SfxStringItem( SID_CHARSET, sVal ) );
784 else if ( aName == sFilterFlags )
786 ::rtl::OUString sVal;
787 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
788 DBG_ASSERT( bOK, "invalid type or value for FilterFlags" );
789 if (bOK)
790 rSet.Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sVal ) );
792 else if ( aName == sMacroExecMode )
794 sal_Int16 nVal =-1;
795 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
796 DBG_ASSERT( bOK, "invalid type for MacroExecMode" );
797 if (bOK)
798 rSet.Put( SfxUInt16Item( SID_MACROEXECMODE, nVal ) );
800 else if ( aName == sUpdateDocMode )
802 sal_Int16 nVal =-1;
803 sal_Bool bOK = ((rProp.Value >>= nVal) && (nVal != -1));
804 DBG_ASSERT( bOK, "invalid type for UpdateDocMode" );
805 if (bOK)
806 rSet.Put( SfxUInt16Item( SID_UPDATEDOCMODE, nVal ) );
808 else if ( aName == sRepairPackage )
810 sal_Bool bVal = sal_False;
811 sal_Bool bOK = (rProp.Value >>= bVal);
812 DBG_ASSERT( bOK, "invalid type for RepairPackage" );
813 if (bOK)
814 rSet.Put( SfxBoolItem( SID_REPAIRPACKAGE, bVal ) );
816 else if ( aName == sDocumentTitle )
818 ::rtl::OUString sVal;
819 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
820 DBG_ASSERT( bOK, "invalid type or value for DocumentTitle" );
821 if (bOK)
822 rSet.Put( SfxStringItem( SID_DOCINFO_TITLE, sVal ) );
824 else if ( aName == sDocumentBaseURL )
826 ::rtl::OUString sVal;
827 // the base url can be set to empty ( for embedded objects for example )
828 sal_Bool bOK = (rProp.Value >>= sVal);
829 DBG_ASSERT( bOK, "invalid type or value for DocumentBaseURL" );
830 if (bOK)
831 rSet.Put( SfxStringItem( SID_DOC_BASEURL, sVal ) );
833 else if ( aName == sHierarchicalDocumentName )
835 ::rtl::OUString sVal;
836 sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength());
837 DBG_ASSERT( bOK, "invalid type or value for HierarchicalDocumentName" );
838 if (bOK)
839 rSet.Put( SfxStringItem( SID_DOC_HIERARCHICALNAME, sVal ) );
841 else if ( aName == sCopyStreamIfPossible )
843 sal_Bool bVal = sal_False;
844 sal_Bool bOK = (rProp.Value >>= bVal);
845 DBG_ASSERT( bOK, "invalid type for CopyStreamIfPossible" );
846 if (bOK)
847 rSet.Put( SfxBoolItem( SID_COPY_STREAM_IF_POSSIBLE, bVal ) );
849 else if ( aName == sNoAutoSave )
851 sal_Bool bVal = sal_False;
852 sal_Bool bOK = (rProp.Value >>= bVal);
853 DBG_ASSERT( bOK, "invalid type for NoAutoSave" );
854 if (bOK)
855 rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) );
857 #ifdef DBG_UTIL
858 else
859 --nFoundArgs;
860 #endif
863 // --> PB 2007-12-09 #i83757#
864 else
866 // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog"
867 String sSlotName( DEFINE_CONST_UNICODE( "OptionsTreeDialog" ) );
868 String sPropName( DEFINE_CONST_UNICODE( "OptionsPageURL" ) );
869 if ( sSlotName.EqualsAscii( pSlot->pUnoName ) )
871 for ( sal_uInt16 n = 0; n < nCount; ++n )
873 const PropertyValue& rProp = pPropsVal[n];
874 String sName( rProp.Name );
875 if ( sName == sPropName )
877 ::rtl::OUString sURL;
878 if ( rProp.Value >>= sURL )
879 rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) );
880 break;
885 // <--
886 #ifdef DB_UTIL
887 if ( nFoundArgs == nCount )
889 // except for the "special" slots: assure that every argument was convertable
890 ByteString aStr( "MacroPlayer: Some properties didn't match to any formal argument for slot: ");
891 aStr += pSlot->pUnoName;
892 DBG_WARNING( aStr.GetBuffer() );
894 #endif
898 void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, const SfxSlot* pSlot )
900 if ( !pSlot )
901 pSlot = SFX_SLOTPOOL().GetSlot( nSlotId );
903 if ( !pSlot)
904 return;
906 if ( nSlotId == SID_OPENURL )
907 nSlotId = SID_OPENDOC;
908 if ( nSlotId == SID_SAVEASURL )
909 nSlotId = SID_SAVEASDOC;
911 // find number of properties to avoid permanent reallocations in the sequence
912 sal_Int32 nProps=0;
914 #ifdef DBG_UTIL
915 // trace number of items and compare with number of properties for debugging purposes
916 sal_Int32 nItems=0;
917 #endif
919 const SfxType *pType = pSlot->GetType();
920 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
922 // slot is a property
923 USHORT nWhich = rSet.GetPool()->GetWhich(nSlotId);
924 if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
926 USHORT nSubCount = pType->nAttribs;
927 if ( nSubCount )
928 // it's a complex property, we want it split into simple types
929 // so we expect to get as many items as we have (sub) members
930 nProps = nSubCount;
931 else
932 // simple property: we expect to get exactly one item
933 nProps++;
935 #ifdef DBG_UTIL
936 else
938 // we will not rely on the "toggle" ability of some property slots
939 ByteString aStr( "Processing property slot without argument: ");
940 aStr += ByteString::CreateFromInt32( nSlotId );
941 DBG_ERROR( aStr.GetBuffer() );
943 #endif
945 #ifdef DBG_UTIL
946 nItems++;
947 #endif
949 else
951 // slot is a method
952 USHORT nFormalArgs = pSlot->GetFormalArgumentCount();
953 for ( USHORT nArg=0; nArg<nFormalArgs; ++nArg )
955 // check every formal argument of the method
956 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
957 USHORT nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
958 if ( rSet.GetItemState( nWhich ) == SFX_ITEM_SET ) //???
960 USHORT nSubCount = rArg.pType->nAttribs;
961 if ( nSubCount )
962 // argument has a complex type, we want it split into simple types
963 // so for this argument we expect to get as many items as we have (sub) members
964 nProps += nSubCount;
965 else
966 // argument of simple type: we expect to get exactly one item for it
967 nProps++;
968 #ifdef DBG_UTIL
969 nItems++;
970 #endif
974 // special treatment for slots that are *not* meant to be recorded as slots (except SaveAs/To)
975 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
976 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
978 sal_Int32 nAdditional=0;
979 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL ) == SFX_ITEM_SET )
980 nAdditional++;
981 if ( rSet.GetItemState( SID_INTERACTIONHANDLER ) == SFX_ITEM_SET )
982 nAdditional++;
983 if ( rSet.GetItemState( SID_DOC_SALVAGE ) == SFX_ITEM_SET )
984 nAdditional++;
985 if ( rSet.GetItemState( SID_PATH ) == SFX_ITEM_SET )
986 nAdditional++;
987 if ( rSet.GetItemState( SID_FILE_DIALOG ) == SFX_ITEM_SET )
988 nAdditional++;
989 if ( rSet.GetItemState( SID_STANDARD_DIR ) == SFX_ITEM_SET )
990 nAdditional++;
991 if ( rSet.GetItemState( SID_BLACK_LIST ) == SFX_ITEM_SET )
992 nAdditional++;
993 if ( rSet.GetItemState( SID_CONTENT ) == SFX_ITEM_SET )
994 nAdditional++;
995 if ( rSet.GetItemState( SID_INPUTSTREAM ) == SFX_ITEM_SET )
996 nAdditional++;
997 if ( rSet.GetItemState( SID_STREAM ) == SFX_ITEM_SET )
998 nAdditional++;
999 if ( rSet.GetItemState( SID_OUTPUTSTREAM ) == SFX_ITEM_SET )
1000 nAdditional++;
1001 if ( rSet.GetItemState( SID_TEMPLATE ) == SFX_ITEM_SET )
1002 nAdditional++;
1003 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW ) == SFX_ITEM_SET )
1004 nAdditional++;
1005 if ( rSet.GetItemState( SID_VIEW_ID ) == SFX_ITEM_SET )
1006 nAdditional++;
1007 if ( rSet.GetItemState( SID_VIEW_DATA ) == SFX_ITEM_SET )
1008 nAdditional++;
1009 if ( rSet.GetItemState( SID_FILTER_DATA ) == SFX_ITEM_SET )
1010 nAdditional++;
1011 if ( rSet.GetItemState( SID_PLUGIN_MODE ) == SFX_ITEM_SET )
1012 nAdditional++;
1013 if ( rSet.GetItemState( SID_DOC_READONLY ) == SFX_ITEM_SET )
1014 nAdditional++;
1015 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION ) == SFX_ITEM_SET )
1016 nAdditional++;
1017 if ( rSet.GetItemState( SID_SELECTION ) == SFX_ITEM_SET )
1018 nAdditional++;
1019 if ( rSet.GetItemState( SID_CONTENTTYPE ) == SFX_ITEM_SET )
1020 nAdditional++;
1021 if ( rSet.GetItemState( SID_WIN_POSSIZE ) == SFX_ITEM_SET )
1022 nAdditional++;
1023 // if ( rSet.GetItemState( SID_VIEW_POS_SIZE ) == SFX_ITEM_SET )
1024 // nAdditional++;
1025 if ( rSet.GetItemState( SID_POSTDATA ) == SFX_ITEM_SET )
1026 nAdditional++;
1027 if ( rSet.GetItemState( SID_FILLFRAME ) == SFX_ITEM_SET )
1028 nAdditional++;
1029 if ( rSet.GetItemState( SID_CHARSET ) == SFX_ITEM_SET )
1030 nAdditional++;
1031 if ( rSet.GetItemState( SID_TARGETNAME ) == SFX_ITEM_SET )
1032 nAdditional++;
1033 if ( rSet.GetItemState( SID_TEMPLATE_NAME ) == SFX_ITEM_SET )
1034 nAdditional++;
1035 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME ) == SFX_ITEM_SET )
1036 nAdditional++;
1037 if ( rSet.GetItemState( SID_HIDDEN ) == SFX_ITEM_SET )
1038 nAdditional++;
1039 if ( rSet.GetItemState( SID_MINIMIZED ) == SFX_ITEM_SET )
1040 nAdditional++;
1041 if ( rSet.GetItemState( SID_PREVIEW ) == SFX_ITEM_SET )
1042 nAdditional++;
1043 if ( rSet.GetItemState( SID_VIEWONLY ) == SFX_ITEM_SET )
1044 nAdditional++;
1045 if ( rSet.GetItemState( SID_EDITDOC ) == SFX_ITEM_SET )
1046 nAdditional++;
1047 if ( rSet.GetItemState( SID_SILENT ) == SFX_ITEM_SET )
1048 nAdditional++;
1049 if ( rSet.GetItemState( SID_JUMPMARK ) == SFX_ITEM_SET )
1050 nAdditional++;
1051 if ( rSet.GetItemState( SID_DOCUMENT ) == SFX_ITEM_SET )
1052 nAdditional++;
1053 if ( rSet.GetItemState( SID_MACROEXECMODE ) == SFX_ITEM_SET )
1054 nAdditional++;
1055 if ( rSet.GetItemState( SID_UPDATEDOCMODE ) == SFX_ITEM_SET )
1056 nAdditional++;
1057 if ( rSet.GetItemState( SID_REPAIRPACKAGE ) == SFX_ITEM_SET )
1058 nAdditional++;
1059 if ( rSet.GetItemState( SID_DOCINFO_TITLE ) == SFX_ITEM_SET )
1060 nAdditional++;
1061 if ( rSet.GetItemState( SID_COMPONENTDATA ) == SFX_ITEM_SET )
1062 nAdditional++;
1063 if ( rSet.GetItemState( SID_COMPONENTCONTEXT ) == SFX_ITEM_SET )
1064 nAdditional++;
1065 if ( rSet.GetItemState( SID_DOC_BASEURL ) == SFX_ITEM_SET )
1066 nAdditional++;
1067 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME ) == SFX_ITEM_SET )
1068 nAdditional++;
1069 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE ) == SFX_ITEM_SET )
1070 nAdditional++;
1071 if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SFX_ITEM_SET )
1072 nAdditional++;
1074 // consider additional arguments
1075 nProps += nAdditional;
1076 #ifdef DBG_UTIL
1077 nItems += nAdditional;
1078 #endif
1082 #ifdef DBG_UTIL
1083 // now check the itemset: is there any item that is not convertable using the list of formal arguments
1084 // or the table of additional items?!
1085 if ( rSet.Count() != nItems )
1087 // detect unknown item and present error message
1088 const USHORT *pRanges = rSet.GetRanges();
1089 while ( *pRanges )
1091 for(USHORT nId = *pRanges++; nId <= *pRanges; ++nId)
1093 if ( rSet.GetItemState(nId) < SFX_ITEM_SET ) //???
1094 // not really set
1095 continue;
1097 if ( !pSlot->IsMode(SFX_SLOT_METHOD) && nId == rSet.GetPool()->GetWhich( pSlot->GetSlotId() ) )
1098 continue;
1100 USHORT nFormalArgs = pSlot->GetFormalArgumentCount();
1101 USHORT nArg;
1102 for ( nArg=0; nArg<nFormalArgs; ++nArg )
1104 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1105 USHORT nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1106 if ( nId == nWhich )
1107 break;
1110 if ( nArg<nFormalArgs )
1111 continue;
1113 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1114 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
1116 if ( nId == SID_DOCFRAME )
1117 continue;
1118 if ( nId == SID_PROGRESS_STATUSBAR_CONTROL )
1119 continue;
1120 if ( nId == SID_INTERACTIONHANDLER )
1121 continue;
1122 if ( nId == SID_VIEW_DATA )
1123 continue;
1124 if ( nId == SID_FILTER_DATA )
1125 continue;
1126 if ( nId == SID_DOCUMENT )
1127 continue;
1128 if ( nId == SID_CONTENT )
1129 continue;
1130 if ( nId == SID_INPUTSTREAM )
1131 continue;
1132 if ( nId == SID_STREAM )
1133 continue;
1134 if ( nId == SID_OUTPUTSTREAM )
1135 continue;
1136 if ( nId == SID_POSTDATA )
1137 continue;
1138 if ( nId == SID_FILLFRAME )
1139 continue;
1140 if ( nId == SID_TEMPLATE )
1141 continue;
1142 if ( nId == SID_OPEN_NEW_VIEW )
1143 continue;
1144 if ( nId == SID_VIEW_ID )
1145 continue;
1146 if ( nId == SID_PLUGIN_MODE )
1147 continue;
1148 if ( nId == SID_DOC_READONLY )
1149 continue;
1150 if ( nId == SID_DOC_STARTPRESENTATION )
1151 continue;
1152 if ( nId == SID_SELECTION )
1153 continue;
1154 if ( nId == SID_HIDDEN )
1155 continue;
1156 if ( nId == SID_MINIMIZED )
1157 continue;
1158 if ( nId == SID_SILENT )
1159 continue;
1160 if ( nId == SID_PREVIEW )
1161 continue;
1162 if ( nId == SID_VIEWONLY )
1163 continue;
1164 if ( nId == SID_EDITDOC )
1165 continue;
1166 if ( nId == SID_TARGETNAME )
1167 continue;
1168 if ( nId == SID_DOC_SALVAGE )
1169 continue;
1170 if ( nId == SID_PATH )
1171 continue;
1172 if ( nId == SID_FILE_DIALOG )
1173 continue;
1174 if ( nId == SID_STANDARD_DIR )
1175 continue;
1176 if ( nId == SID_BLACK_LIST )
1177 continue;
1178 if ( nId == SID_CONTENTTYPE )
1179 continue;
1180 if ( nId == SID_WIN_POSSIZE )
1181 continue;
1182 if ( nId == SID_TEMPLATE_NAME )
1183 continue;
1184 if ( nId == SID_TEMPLATE_REGIONNAME )
1185 continue;
1186 if ( nId == SID_JUMPMARK )
1187 continue;
1188 if ( nId == SID_CHARSET )
1189 continue;
1190 if ( nId == SID_MACROEXECMODE )
1191 continue;
1192 if ( nId == SID_UPDATEDOCMODE )
1193 continue;
1194 if ( nId == SID_REPAIRPACKAGE )
1195 continue;
1196 if ( nId == SID_DOCINFO_TITLE )
1197 continue;
1198 if ( nId == SID_COMPONENTDATA )
1199 continue;
1200 if ( nId == SID_COMPONENTCONTEXT )
1201 continue;
1202 if ( nId == SID_DOC_BASEURL )
1203 continue;
1204 if ( nId == SID_DOC_HIERARCHICALNAME )
1205 continue;
1206 if ( nId == SID_COPY_STREAM_IF_POSSIBLE )
1207 continue;
1208 if ( nId == SID_NOAUTOSAVE )
1209 continue;
1211 // used only internally
1212 if ( nId == SID_SAVETO )
1213 continue;
1216 ByteString aDbg( "Unknown item detected: ");
1217 aDbg += ByteString::CreateFromInt32( nId );
1218 DBG_ASSERT( nArg<nFormalArgs, aDbg.GetBuffer() );
1222 #endif
1224 if ( !nProps )
1225 return;
1227 // convert every item into a property
1228 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aSequ( nProps );
1229 ::com::sun::star::beans::PropertyValue *pValue = aSequ.getArray();
1231 sal_Int32 nActProp=0;
1232 if ( !pSlot->IsMode(SFX_SLOT_METHOD) )
1234 // slot is a property
1235 USHORT nWhich = rSet.GetPool()->GetWhich(nSlotId);
1236 BOOL bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1237 SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1238 if ( pItem ) //???
1240 USHORT nSubCount = pType->nAttribs;
1241 if ( !nSubCount )
1243 //rPool.FillVariable( *pItem, *pVar, eUserMetric );
1244 pValue[nActProp].Name = String( String::CreateFromAscii( pSlot->pUnoName ) ) ;
1245 if ( !pItem->QueryValue( pValue[nActProp].Value ) )
1247 ByteString aStr( "Item not convertable: ");
1248 aStr += ByteString::CreateFromInt32(nSlotId);
1249 DBG_ERROR( aStr.GetBuffer() );
1252 else
1254 // complex type, add a property value for every member of the struct
1255 for ( USHORT n=1; n<=nSubCount; ++n )
1257 //rPool.FillVariable( *pItem, *pVar, eUserMetric );
1258 BYTE nSubId = (BYTE) (sal_Int8) pType->aAttrib[n-1].nAID;
1259 if ( bConvertTwips )
1260 nSubId |= CONVERT_TWIPS;
1262 DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" );
1263 String aName( String::CreateFromAscii( pSlot->pUnoName ) ) ;
1264 aName += '.';
1265 aName += String( String::CreateFromAscii( pType->aAttrib[n-1].pName ) ) ;
1266 pValue[nActProp].Name = aName;
1267 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1269 ByteString aStr( "Sub item ");
1270 aStr += ByteString::CreateFromInt32( pType->aAttrib[n-1].nAID );
1271 aStr += " not convertable in slot: ";
1272 aStr += ByteString::CreateFromInt32(nSlotId);
1273 DBG_ERROR( aStr.GetBuffer() );
1279 else
1281 // slot is a method
1282 USHORT nFormalArgs = pSlot->GetFormalArgumentCount();
1283 for ( USHORT nArg=0; nArg<nFormalArgs; ++nArg )
1285 const SfxFormalArgument &rArg = pSlot->GetFormalArgument( nArg );
1286 USHORT nWhich = rSet.GetPool()->GetWhich( rArg.nSlotId );
1287 BOOL bConvertTwips = ( rSet.GetPool()->GetMetric( nWhich ) == SFX_MAPUNIT_TWIP );
1288 SFX_ITEMSET_ARG( &rSet, pItem, SfxPoolItem, nWhich, sal_False );
1289 if ( pItem ) //???
1291 USHORT nSubCount = rArg.pType->nAttribs;
1292 if ( !nSubCount )
1294 //rPool.FillVariable( *pItem, *pVar, eUserMetric );
1295 pValue[nActProp].Name = String( String::CreateFromAscii( rArg.pName ) ) ;
1296 if ( !pItem->QueryValue( pValue[nActProp++].Value ) )
1298 ByteString aStr( "Item not convertable: ");
1299 aStr += ByteString::CreateFromInt32(rArg.nSlotId);
1300 DBG_ERROR( aStr.GetBuffer() );
1303 else
1305 // complex type, add a property value for every member of the struct
1306 for ( USHORT n = 1; n <= nSubCount; ++n )
1308 //rPool.FillVariable( rItem, *pVar, eUserMetric );
1309 BYTE nSubId = (BYTE) (sal_Int8) rArg.pType->aAttrib[n-1].nAID;
1310 if ( bConvertTwips )
1311 nSubId |= CONVERT_TWIPS;
1313 DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" );
1314 String aName( String::CreateFromAscii( rArg.pName ) ) ;
1315 aName += '.';
1316 aName += String( String::CreateFromAscii( rArg.pType->aAttrib[n-1].pName ) ) ;
1317 pValue[nActProp].Name = aName;
1318 if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) )
1320 ByteString aStr( "Sub item ");
1321 aStr += ByteString::CreateFromInt32( rArg.pType->aAttrib[n-1].nAID );
1322 aStr += " not convertable in slot: ";
1323 aStr += ByteString::CreateFromInt32(rArg.nSlotId);
1324 DBG_ERROR( aStr.GetBuffer() );
1331 if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
1332 nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF )
1334 const SfxPoolItem *pItem=0;
1335 if ( rSet.GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1337 pValue[nActProp].Name = sComponentData;
1338 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1340 if ( rSet.GetItemState( SID_COMPONENTCONTEXT, sal_False, &pItem ) == SFX_ITEM_SET )
1342 pValue[nActProp].Name = sComponentContext;
1343 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1345 if ( rSet.GetItemState( SID_PROGRESS_STATUSBAR_CONTROL, sal_False, &pItem ) == SFX_ITEM_SET )
1347 pValue[nActProp].Name = sStatusInd;
1348 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1350 if ( rSet.GetItemState( SID_INTERACTIONHANDLER, sal_False, &pItem ) == SFX_ITEM_SET )
1352 pValue[nActProp].Name = sInteractionHdl;
1353 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1355 if ( rSet.GetItemState( SID_VIEW_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1357 pValue[nActProp].Name = sViewData;
1358 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1360 if ( rSet.GetItemState( SID_FILTER_DATA, sal_False, &pItem ) == SFX_ITEM_SET )
1362 pValue[nActProp].Name = sFilterData;
1363 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1365 if ( rSet.GetItemState( SID_DOCUMENT, sal_False, &pItem ) == SFX_ITEM_SET )
1367 pValue[nActProp].Name = sModel;
1368 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1370 if ( rSet.GetItemState( SID_CONTENT, sal_False, &pItem ) == SFX_ITEM_SET )
1372 pValue[nActProp].Name = sUCBContent;
1373 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1375 if ( rSet.GetItemState( SID_INPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1377 pValue[nActProp].Name = sInputStream;
1378 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1380 if ( rSet.GetItemState( SID_STREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1382 pValue[nActProp].Name = sStream;
1383 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1385 if ( rSet.GetItemState( SID_OUTPUTSTREAM, sal_False, &pItem ) == SFX_ITEM_SET )
1387 pValue[nActProp].Name = sOutputStream;
1388 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1390 if ( rSet.GetItemState( SID_POSTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
1392 pValue[nActProp].Name = sPostData;
1393 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1395 if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1397 pValue[nActProp].Name = sFrame;
1398 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1400 if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET )
1402 pValue[nActProp].Name = sAsTemplate;
1403 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1405 if ( rSet.GetItemState( SID_OPEN_NEW_VIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1407 pValue[nActProp].Name = sOpenNewView;
1408 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1410 if ( rSet.GetItemState( SID_VIEW_ID, sal_False, &pItem ) == SFX_ITEM_SET )
1412 pValue[nActProp].Name = sViewId;
1413 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1415 if ( rSet.GetItemState( SID_PLUGIN_MODE, sal_False, &pItem ) == SFX_ITEM_SET )
1417 pValue[nActProp].Name = sPluginMode;
1418 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1420 if ( rSet.GetItemState( SID_DOC_READONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1422 pValue[nActProp].Name = sReadOnly;
1423 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1425 if ( rSet.GetItemState( SID_DOC_STARTPRESENTATION, sal_False, &pItem ) == SFX_ITEM_SET )
1427 pValue[nActProp].Name = sStartPresentation;
1428 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1430 if ( rSet.GetItemState( SID_SELECTION, sal_False, &pItem ) == SFX_ITEM_SET )
1432 pValue[nActProp].Name = sSelectionOnly;
1433 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1435 if ( rSet.GetItemState( SID_HIDDEN, sal_False, &pItem ) == SFX_ITEM_SET )
1437 pValue[nActProp].Name = sHidden;
1438 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1440 if ( rSet.GetItemState( SID_MINIMIZED, sal_False, &pItem ) == SFX_ITEM_SET )
1442 pValue[nActProp].Name = sMinimized;
1443 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1445 if ( rSet.GetItemState( SID_SILENT, sal_False, &pItem ) == SFX_ITEM_SET )
1447 pValue[nActProp].Name = sSilent;
1448 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1450 if ( rSet.GetItemState( SID_PREVIEW, sal_False, &pItem ) == SFX_ITEM_SET )
1452 pValue[nActProp].Name = sPreview;
1453 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1455 if ( rSet.GetItemState( SID_VIEWONLY, sal_False, &pItem ) == SFX_ITEM_SET )
1457 pValue[nActProp].Name = sViewOnly;
1458 pValue[nActProp++].Value <<= (sal_Bool) (( ((SfxBoolItem*)pItem)->GetValue() ));
1460 if ( rSet.GetItemState( SID_EDITDOC, sal_False, &pItem ) == SFX_ITEM_SET )
1462 pValue[nActProp].Name = sDontEdit;
1463 pValue[nActProp++].Value <<= (sal_Bool) (!( ((SfxBoolItem*)pItem)->GetValue() ));
1465 if ( rSet.GetItemState( SID_FILE_DIALOG, sal_False, &pItem ) == SFX_ITEM_SET )
1467 pValue[nActProp].Name = sUseSystemDialog;
1468 pValue[nActProp++].Value <<= (sal_Bool) ( ((SfxBoolItem*)pItem)->GetValue() );
1470 if ( rSet.GetItemState( SID_STANDARD_DIR, sal_False, &pItem ) == SFX_ITEM_SET )
1472 pValue[nActProp].Name = sStandardDir;
1473 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1475 if ( rSet.GetItemState( SID_BLACK_LIST, sal_False, &pItem ) == SFX_ITEM_SET )
1477 pValue[nActProp].Name = sBlackList;
1479 com::sun::star::uno::Sequence< rtl::OUString > aList;
1480 ((SfxStringListItem*)pItem)->GetStringList( aList );
1481 pValue[nActProp++].Value <<= aList ;
1483 if ( rSet.GetItemState( SID_TARGETNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1485 pValue[nActProp].Name = sFrameName;
1486 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1488 if ( rSet.GetItemState( SID_DOC_SALVAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1490 pValue[nActProp].Name = sSalvageURL;
1491 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1493 if ( rSet.GetItemState( SID_PATH, sal_False, &pItem ) == SFX_ITEM_SET )
1495 pValue[nActProp].Name = sFolderName;
1496 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1498 if ( rSet.GetItemState( SID_CONTENTTYPE, sal_False, &pItem ) == SFX_ITEM_SET )
1500 pValue[nActProp].Name = sMediaType;
1501 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1503 if ( rSet.GetItemState( SID_WIN_POSSIZE, sal_False, &pItem ) == SFX_ITEM_SET )
1505 pValue[nActProp].Name = sWindowState;
1506 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1508 if ( rSet.GetItemState( SID_TEMPLATE_NAME, sal_False, &pItem ) == SFX_ITEM_SET )
1510 pValue[nActProp].Name = sTemplateName;
1511 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1513 if ( rSet.GetItemState( SID_TEMPLATE_REGIONNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1515 pValue[nActProp].Name = sTemplateRegionName;
1516 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1518 if ( rSet.GetItemState( SID_JUMPMARK, sal_False, &pItem ) == SFX_ITEM_SET )
1520 pValue[nActProp].Name = sJumpMark;
1521 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1524 SFX_ITEMSET_ARG( &rSet, pRectItem, SfxRectangleItem, SID_VIEW_POS_SIZE, sal_False );
1525 if ( pRectItem )
1527 DBG_ERROR("PosSizeItem not supported yet!");
1530 if ( rSet.GetItemState( SID_CHARSET, sal_False, &pItem ) == SFX_ITEM_SET )
1532 pValue[nActProp].Name = sCharacterSet;
1533 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1535 if ( rSet.GetItemState( SID_MACROEXECMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1537 pValue[nActProp].Name = sMacroExecMode;
1538 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1540 if ( rSet.GetItemState( SID_UPDATEDOCMODE, sal_False, &pItem ) == SFX_ITEM_SET )
1542 pValue[nActProp].Name = sUpdateDocMode;
1543 pValue[nActProp++].Value <<= ( (sal_Int16) ((SfxUInt16Item*)pItem)->GetValue() );
1545 if ( rSet.GetItemState( SID_REPAIRPACKAGE, sal_False, &pItem ) == SFX_ITEM_SET )
1547 pValue[nActProp].Name = sRepairPackage;
1548 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1550 if ( rSet.GetItemState( SID_DOCINFO_TITLE, sal_False, &pItem ) == SFX_ITEM_SET )
1552 pValue[nActProp].Name = sDocumentTitle;
1553 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1555 if ( rSet.GetItemState( SID_DOC_BASEURL, sal_False, &pItem ) == SFX_ITEM_SET )
1557 pValue[nActProp].Name = sDocumentBaseURL;
1558 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1560 if ( rSet.GetItemState( SID_DOC_HIERARCHICALNAME, sal_False, &pItem ) == SFX_ITEM_SET )
1562 pValue[nActProp].Name = sHierarchicalDocumentName;
1563 pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) );
1565 if ( rSet.GetItemState( SID_COPY_STREAM_IF_POSSIBLE, sal_False, &pItem ) == SFX_ITEM_SET )
1567 pValue[nActProp].Name = sCopyStreamIfPossible;
1568 pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
1570 if ( rSet.GetItemState( SID_NOAUTOSAVE, sal_False, &pItem ) == SFX_ITEM_SET )
1572 pValue[nActProp].Name = sNoAutoSave;
1573 pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() );
1579 rArgs = aSequ;
1582 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 )
1583 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 )
1584 SFX_IMPL_XSERVICEINFO( SfxMacroLoader, PROTOCOLHANDLER_SERVICENAME, "com.sun.star.comp.sfx2.SfxMacroLoader" )
1585 SFX_IMPL_SINGLEFACTORY( SfxMacroLoader )
1587 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)
1589 Reference < XFrame > xFrame;
1590 if ( aArguments.getLength() )
1592 aArguments[0] >>= xFrame;
1593 m_xFrame = xFrame;
1597 SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl()
1599 SfxObjectShell* pDocShell = NULL;
1600 Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
1601 if ( xFrame.is() )
1603 SfxFrame* pFrame=0;
1604 for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
1606 if ( pFrame->GetFrameInterface() == xFrame )
1607 break;
1610 if ( pFrame )
1611 pDocShell = pFrame->GetCurrentDocument();
1614 return pDocShell;
1617 // -----------------------------------------------------------------------
1618 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SfxMacroLoader::queryDispatch(
1619 const ::com::sun::star::util::URL& aURL ,
1620 const ::rtl::OUString& /*sTargetFrameName*/,
1621 sal_Int32 /*nSearchFlags*/ ) throw( ::com::sun::star::uno::RuntimeException )
1623 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatcher;
1624 if(aURL.Complete.compareToAscii("macro:",6)==0)
1625 xDispatcher = this;
1626 return xDispatcher;
1629 // -----------------------------------------------------------------------
1630 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > SAL_CALL
1631 SfxMacroLoader::queryDispatches( const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor )
1632 throw( ::com::sun::star::uno::RuntimeException )
1634 sal_Int32 nCount = seqDescriptor.getLength();
1635 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > lDispatcher(nCount);
1636 for( sal_Int32 i=0; i<nCount; ++i )
1637 lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1638 seqDescriptor[i].FrameName,
1639 seqDescriptor[i].SearchFlags );
1640 return lDispatcher;
1643 // -----------------------------------------------------------------------
1644 void SAL_CALL SfxMacroLoader::dispatchWithNotification( const ::com::sun::star::util::URL& aURL ,
1645 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs ,
1646 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& xListener )
1647 throw (::com::sun::star::uno::RuntimeException)
1649 ::vos::OGuard aGuard( Application::GetSolarMutex() );
1651 sal_uInt32 nPropertyCount = lArgs.getLength();
1652 ::rtl::OUString aReferer;
1653 for( sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
1655 if( lArgs[nProperty].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")) )
1657 lArgs[nProperty].Value >>= aReferer;
1658 break;
1662 ::com::sun::star::uno::Any aAny;
1663 ErrCode nErr = loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1664 if( xListener.is() )
1666 // always call dispatchFinished(), because we didn't load a document but
1667 // executed a macro instead!
1668 ::com::sun::star::frame::DispatchResultEvent aEvent;
1670 aEvent.Source = static_cast< ::cppu::OWeakObject* >(this);
1671 if( nErr == ERRCODE_NONE )
1672 aEvent.State = ::com::sun::star::frame::DispatchResultState::SUCCESS;
1673 else
1674 aEvent.State = ::com::sun::star::frame::DispatchResultState::FAILURE;
1676 xListener->dispatchFinished( aEvent ) ;
1680 ::com::sun::star::uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue(
1681 const ::com::sun::star::util::URL& aURL,
1682 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& ) throw (::com::sun::star::uno::RuntimeException)
1684 ::com::sun::star::uno::Any aRet;
1685 /*ErrCode nErr = */loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() );
1686 return aRet;
1689 // -----------------------------------------------------------------------
1690 void SAL_CALL SfxMacroLoader::dispatch( const ::com::sun::star::util::URL& aURL ,
1691 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs )
1692 throw (::com::sun::star::uno::RuntimeException)
1694 ::vos::OGuard aGuard( Application::GetSolarMutex() );
1696 sal_uInt32 nPropertyCount = lArgs.getLength();
1697 ::rtl::OUString aReferer;
1698 for( sal_uInt32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
1700 if( lArgs[nProperty].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")) )
1702 lArgs[nProperty].Value >>= aReferer;
1703 break;
1707 ::com::sun::star::uno::Any aAny;
1708 /*ErrCode nErr = */loadMacro( aURL.Complete, aAny, GetObjectShell_Impl() );
1711 // -----------------------------------------------------------------------
1712 void SAL_CALL SfxMacroLoader::addStatusListener(
1713 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& ,
1714 const ::com::sun::star::util::URL& )
1715 throw (::com::sun::star::uno::RuntimeException)
1717 /* TODO
1718 How we can handle different listener for further coming or currently running dispatch() jobs
1719 without any inconsistency!
1723 // -----------------------------------------------------------------------
1724 void SAL_CALL SfxMacroLoader::removeStatusListener(
1725 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >&,
1726 const ::com::sun::star::util::URL& )
1727 throw (::com::sun::star::uno::RuntimeException)
1731 // -----------------------------------------------------------------------
1732 ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star::uno::Any& rRetval, SfxObjectShell* pSh )
1733 throw ( ::com::sun::star::uno::RuntimeException )
1735 SfxApplication* pApp = SFX_APP();
1736 pApp->EnterBasicCall();
1737 SfxObjectShell* pCurrent = pSh;
1738 if ( !pCurrent )
1739 // all not full qualified names use the BASIC of the given or current document
1740 pCurrent = SfxObjectShell::Current();
1742 // 'macro:///lib.mod.proc(args)' => macro of App-BASIC
1743 // 'macro://[docname|.]/lib.mod.proc(args)' => macro of current or qualified document
1744 // 'macro://obj.method(args)' => direct API call, execute it via App-BASIC
1745 String aMacro( rURL );
1746 sal_uInt16 nHashPos = aMacro.Search( '/', 8 );
1747 sal_uInt16 nArgsPos = aMacro.Search( '(' );
1748 BasicManager *pAppMgr = SFX_APP()->GetBasicManager();
1749 BasicManager *pBasMgr = 0;
1750 ErrCode nErr = ERRCODE_NONE;
1752 // should a macro function be executed ( no direct API call)?
1753 if ( STRING_NOTFOUND != nHashPos && nHashPos < nArgsPos )
1755 // find BasicManager
1756 SfxObjectShell* pDoc = NULL;
1757 String aBasMgrName( INetURLObject::decode(aMacro.Copy( 8, nHashPos-8 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1758 if ( !aBasMgrName.Len() )
1759 pBasMgr = pAppMgr;
1760 else if ( aBasMgrName.EqualsAscii(".") )
1762 // current/actual document
1763 pDoc = pCurrent;
1764 if (pDoc)
1765 pBasMgr = pDoc->GetBasicManager();
1767 else
1769 // full qualified name, find document by name
1770 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
1771 pObjSh && !pBasMgr;
1772 pObjSh = SfxObjectShell::GetNext(*pObjSh) )
1773 if ( aBasMgrName == pObjSh->GetTitle(SFX_TITLE_APINAME) )
1775 pDoc = pObjSh;
1776 pBasMgr = pDoc->GetBasicManager();
1780 if ( pBasMgr )
1782 if ( pSh && pDoc )
1784 // security check for macros from document basic if an SFX context (pSh) is given
1785 if ( !pDoc->AdjustMacroMode( String() ) )
1786 // check forbids execution
1787 return ERRCODE_IO_ACCESSDENIED;
1789 else if ( pSh && pSh->GetMedium() )
1791 pSh->AdjustMacroMode( String() );
1792 SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
1793 SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, sal_False);
1794 if ( pUpdateDocItem && pMacroExecModeItem
1795 && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE
1796 && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE )
1797 return ERRCODE_IO_ACCESSDENIED;
1800 // find BASIC method
1801 String aQualifiedMethod( INetURLObject::decode(aMacro.Copy( nHashPos+1 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
1802 String aArgs;
1803 if ( STRING_NOTFOUND != nArgsPos )
1805 // remove arguments from macro name
1806 aArgs = aQualifiedMethod.Copy( nArgsPos - nHashPos - 1 );
1807 aQualifiedMethod.Erase( nArgsPos - nHashPos - 1 );
1810 SbxMethod *pMethod = SfxQueryMacro( pBasMgr, aQualifiedMethod );
1811 if ( pMethod )
1813 // arguments must be quoted
1814 String aQuotedArgs;
1815 if ( aArgs.Len()<2 || aArgs.GetBuffer()[1] == '\"')
1816 // no args or already quoted args
1817 aQuotedArgs = aArgs;
1818 else
1820 // quote parameters
1821 aArgs.Erase(0,1);
1822 aArgs.Erase( aArgs.Len()-1,1);
1824 aQuotedArgs = '(';
1826 sal_uInt16 nCount = aArgs.GetTokenCount(',');
1827 for ( sal_uInt16 n=0; n<nCount; n++ )
1829 aQuotedArgs += '\"';
1830 aQuotedArgs += aArgs.GetToken( n, ',' );
1831 aQuotedArgs += '\"';
1832 if ( n<nCount-1 )
1833 aQuotedArgs += ',';
1836 aQuotedArgs += ')';
1839 Any aOldThisComponent;
1840 if ( pSh )
1842 if ( pBasMgr != pAppMgr )
1843 // mark document: it executes an own macro, so it's in a modal mode
1844 pSh->SetMacroMode_Impl( TRUE );
1845 if ( pBasMgr == pAppMgr )
1847 // document is executed via AppBASIC, adjust ThisComponent variable
1848 aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( pSh->GetModel() ) );
1852 // add quoted arguments and do the call
1853 String aCall( '[' );
1854 aCall += pMethod->GetName();
1855 aCall += aQuotedArgs;
1856 aCall += ']';
1858 // just to let the shell be alive
1859 SfxObjectShellRef rSh = pSh;
1861 // execute function using its Sbx parent,
1862 //SbxVariable* pRet = pMethod->GetParent()->Execute( aCall );
1863 //rRetval = sbxToUnoValue( pRet );
1865 SbxVariable* pRet = pMethod->GetParent()->Execute( aCall );
1866 if ( pRet )
1868 USHORT nFlags = pRet->GetFlags();
1869 pRet->SetFlag( SBX_READWRITE | SBX_NO_BROADCAST );
1870 rRetval = sbxToUnoValue( pRet );
1871 pRet->SetFlags( nFlags );
1874 nErr = SbxBase::GetError();
1875 if ( ( pBasMgr == pAppMgr ) && pSh )
1877 pAppMgr->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent );
1880 if ( pSh && pSh->GetModel().is() )
1881 // remove flag for modal mode
1882 pSh->SetMacroMode_Impl( FALSE );
1884 else
1885 nErr = ERRCODE_BASIC_PROC_UNDEFINED;
1887 else
1888 nErr = ERRCODE_IO_NOTEXISTS;
1890 else
1892 // direct API call on a specified object
1893 String aCall( '[' );
1894 aCall += String(INetURLObject::decode(aMacro.Copy(6), INET_HEX_ESCAPE,
1895 INetURLObject::DECODE_WITH_CHARSET));
1896 aCall += ']';
1897 pAppMgr->GetLib(0)->Execute( aCall );
1898 nErr = SbxBase::GetError();
1901 pApp->LeaveBasicCall();
1902 SbxBase::ResetError();
1903 return nErr;
1906 SFX_IMPL_XSERVICEINFO( SfxAppDispatchProvider, "com.sun.star.frame.DispatchProvider", "com.sun.star.comp.sfx2.AppDispatchProvider" ) \
1907 SFX_IMPL_SINGLEFACTORY( SfxAppDispatchProvider );
1909 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)
1911 Reference < XFrame > xFrame;
1912 if ( aArguments.getLength() )
1914 aArguments[0] >>= xFrame;
1915 m_xFrame = xFrame;
1919 Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch(
1920 const ::com::sun::star::util::URL& aURL,
1921 const ::rtl::OUString& /*sTargetFrameName*/,
1922 FrameSearchFlags /*eSearchFlags*/ ) throw( RuntimeException )
1924 USHORT nId( 0 );
1925 sal_Bool bMasterCommand( sal_False );
1926 Reference < XDispatch > xDisp;
1927 const SfxSlot* pSlot = 0;
1928 SfxDispatcher* pAppDisp = SFX_APP()->GetAppDispatcher_Impl();
1929 if ( aURL.Protocol.compareToAscii( "slot:" ) == COMPARE_EQUAL ||
1930 aURL.Protocol.compareToAscii( "commandId:" ) == COMPARE_EQUAL )
1932 nId = (USHORT) aURL.Path.toInt32();
1933 SfxShell* pShell;
1934 pAppDisp->GetShellAndSlot_Impl( nId, &pShell, &pSlot, TRUE, TRUE );
1936 else if ( aURL.Protocol.compareToAscii( ".uno:" ) == COMPARE_EQUAL )
1938 // Support ".uno" commands. Map commands to slotid
1939 bMasterCommand = SfxOfficeDispatch::IsMasterUnoCommand( aURL );
1940 if ( bMasterCommand )
1941 pSlot = pAppDisp->GetSlot( SfxOfficeDispatch::GetMasterUnoCommand( aURL ) );
1942 else
1943 pSlot = pAppDisp->GetSlot( aURL.Main );
1946 if ( pSlot )
1948 SfxOfficeDispatch* pDispatch = new SfxOfficeDispatch( pAppDisp, pSlot, aURL ) ;
1949 pDispatch->SetFrame(m_xFrame);
1950 pDispatch->SetMasterUnoCommand( bMasterCommand );
1951 xDisp = pDispatch;
1954 return xDisp;
1957 Sequence< Reference < XDispatch > > SAL_CALL SfxAppDispatchProvider::queryDispatches( const Sequence < DispatchDescriptor >& seqDescriptor )
1958 throw( RuntimeException )
1960 sal_Int32 nCount = seqDescriptor.getLength();
1961 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > > lDispatcher(nCount);
1962 for( sal_Int32 i=0; i<nCount; ++i )
1963 lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
1964 seqDescriptor[i].FrameName,
1965 seqDescriptor[i].SearchFlags );
1966 return lDispatcher;
1969 Sequence< sal_Int16 > SAL_CALL SfxAppDispatchProvider::getSupportedCommandGroups()
1970 throw (::com::sun::star::uno::RuntimeException)
1972 ::vos::OGuard aGuard( Application::GetSolarMutex() );
1974 std::list< sal_Int16 > aGroupList;
1975 SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
1977 const ULONG nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
1979 // Gruppe anw"ahlen ( Gruppe 0 ist intern )
1980 for ( USHORT i=0; i<pAppSlotPool->GetGroupCount(); i++ )
1982 String aName = pAppSlotPool->SeekGroup( i );
1983 const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
1984 while ( pSfxSlot )
1986 if ( pSfxSlot->GetMode() & nMode )
1988 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
1989 aGroupList.push_back( nCommandGroup );
1990 break;
1992 pSfxSlot = pAppSlotPool->NextSlot();
1996 ::com::sun::star::uno::Sequence< sal_Int16 > aSeq =
1997 comphelper::containerToSequence< sal_Int16, std::list< sal_Int16 > >( aGroupList );
1999 return aSeq;
2002 Sequence< ::com::sun::star::frame::DispatchInformation > SAL_CALL SfxAppDispatchProvider::getConfigurableDispatchInformation( sal_Int16 nCmdGroup )
2003 throw (::com::sun::star::uno::RuntimeException)
2005 std::list< ::com::sun::star::frame::DispatchInformation > aCmdList;
2007 ::vos::OGuard aGuard( Application::GetSolarMutex() );
2008 SfxSlotPool* pAppSlotPool = &SFX_APP()->GetAppSlotPool_Impl();
2010 if ( pAppSlotPool )
2012 const ULONG nMode( SFX_SLOT_TOOLBOXCONFIG|SFX_SLOT_ACCELCONFIG|SFX_SLOT_MENUCONFIG );
2013 rtl::OUString aCmdPrefix( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ));
2015 // Gruppe anw"ahlen ( Gruppe 0 ist intern )
2016 for ( USHORT i=0; i<pAppSlotPool->GetGroupCount(); i++ )
2018 String aName = pAppSlotPool->SeekGroup( i );
2019 const SfxSlot* pSfxSlot = pAppSlotPool->FirstSlot();
2020 if ( pSfxSlot )
2022 sal_Int16 nCommandGroup = MapGroupIDToCommandGroup( pSfxSlot->GetGroupId() );
2023 if ( nCommandGroup == nCmdGroup )
2025 while ( pSfxSlot )
2027 if ( pSfxSlot->GetMode() & nMode )
2029 ::com::sun::star::frame::DispatchInformation aCmdInfo;
2030 ::rtl::OUStringBuffer aBuf( aCmdPrefix );
2031 aBuf.appendAscii( pSfxSlot->GetUnoName() );
2032 aCmdInfo.Command = aBuf.makeStringAndClear();
2033 aCmdInfo.GroupId = nCommandGroup;
2034 aCmdList.push_back( aCmdInfo );
2036 pSfxSlot = pAppSlotPool->NextSlot();
2043 ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
2044 comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aCmdList );
2046 return aSeq;
2049 #ifdef TEST_HANDLERS
2050 #include <cppuhelper/implbase2.hxx>
2052 #include <com/sun/star/awt/XKeyHandler.hdl>
2053 #include <com/sun/star/awt/XMouseClickHandler.hdl>
2055 class TestKeyHandler: public ::cppu::WeakImplHelper2
2057 com::sun::star::awt::XKeyHandler,
2058 com::sun::star::lang::XServiceInfo
2061 public:
2062 TestKeyHandler( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& ){}
2064 SFX_DECL_XSERVICEINFO
2065 virtual sal_Bool SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
2066 virtual sal_Bool SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
2067 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source)
2068 throw (::com::sun::star::uno::RuntimeException);
2071 class TestMouseClickHandler: public ::cppu::WeakImplHelper2
2073 com::sun::star::awt::XMouseClickHandler,
2074 com::sun::star::lang::XServiceInfo
2077 public:
2078 TestMouseClickHandler( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& ){}
2080 SFX_DECL_XSERVICEINFO
2081 virtual sal_Bool SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
2082 virtual sal_Bool SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
2083 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source)
2084 throw (::com::sun::star::uno::RuntimeException);
2087 sal_Bool SAL_CALL TestKeyHandler::keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
2089 return sal_False;
2092 sal_Bool SAL_CALL TestKeyHandler::keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
2094 return sal_False;
2097 void SAL_CALL TestKeyHandler::disposing( const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException)
2101 sal_Bool SAL_CALL TestMouseClickHandler::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException)
2103 return sal_False;
2106 sal_Bool SAL_CALL TestMouseClickHandler::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException)
2108 return sal_False;
2111 void SAL_CALL TestMouseClickHandler::disposing( const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException)
2115 SFX_IMPL_XSERVICEINFO( TestKeyHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.KeyHandler");
2116 SFX_IMPL_XSERVICEINFO( TestMouseClickHandler, "com.sun.star.task.Job", "com.sun.star.comp.Office.MouseClickHandler");
2117 SFX_IMPL_SINGLEFACTORY( TestKeyHandler );
2118 SFX_IMPL_SINGLEFACTORY( TestMouseClickHandler );
2119 #endif
2120 // -----------------------------------------------------------------------
2122 extern "C" {
2124 SFX2_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
2125 const sal_Char** ppEnvironmentTypeName ,
2126 uno_Environment** )
2128 *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
2131 SFX2_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo(
2132 void* ,
2133 void* pRegistryKey )
2135 ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pRegistryKey ) ) ;
2137 // register actual implementations and their services
2138 ::rtl::OUString aImpl;
2139 ::rtl::OUString aTempStr;
2140 ::rtl::OUString aKeyStr;
2141 Reference< XRegistryKey > xNewKey;
2142 Reference< XRegistryKey > xLoaderKey;
2144 // PluginObject
2145 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2146 aImpl += ::sfx2::PluginObject::impl_getStaticImplementationName();
2148 aTempStr = aImpl;
2149 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2150 xNewKey = xKey->createKey( aTempStr );
2151 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") );
2153 // AppletObject
2154 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2155 aImpl += ::sfx2::AppletObject::impl_getStaticImplementationName();
2157 aTempStr = aImpl;
2158 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2159 xNewKey = xKey->createKey( aTempStr );
2160 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") );
2162 // IFrameObject
2163 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2164 aImpl += ::sfx2::IFrameObject::impl_getStaticImplementationName();
2166 aTempStr = aImpl;
2167 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2168 xNewKey = xKey->createKey( aTempStr );
2169 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") );
2171 // global app event broadcaster
2172 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2173 aImpl += SfxGlobalEvents_Impl::impl_getStaticImplementationName();
2175 aTempStr = aImpl;
2176 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2177 xNewKey = xKey->createKey( aTempStr );
2178 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster") );
2180 // global app dispatcher
2181 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2182 aImpl += SfxAppDispatchProvider::impl_getStaticImplementationName();
2184 aTempStr = aImpl;
2185 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2186 xNewKey = xKey->createKey( aTempStr );
2187 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.ProtocolHandler") );
2189 // standalone document info
2190 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2191 aImpl += SfxStandaloneDocumentInfoObject::impl_getStaticImplementationName();
2193 aTempStr = aImpl;
2194 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2195 xNewKey = xKey->createKey( aTempStr );
2196 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.document.StandaloneDocumentInfo") );
2198 // frame loader
2199 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2200 aImpl += SfxFrameLoader_Impl::impl_getStaticImplementationName();
2202 aTempStr = aImpl;
2203 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2204 xNewKey = xKey->createKey( aTempStr );
2205 Sequence < ::rtl::OUString > aServices = SfxFrameLoader_Impl::impl_getStaticSupportedServiceNames();
2206 sal_Int32 nCount = aServices.getLength();
2207 for ( sal_Int16 i=0; i<nCount; i++ )
2208 xNewKey->createKey( aServices.getConstArray()[i] );
2210 // macro loader
2211 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2212 aImpl += SfxMacroLoader::impl_getStaticImplementationName();
2214 aTempStr = aImpl;
2215 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2216 xNewKey = xKey->createKey( aTempStr );
2217 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.ProtocolHandler") );
2219 // - sfx document templates
2220 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2221 aImpl += SfxDocTplService::impl_getStaticImplementationName();
2223 aTempStr = aImpl;
2224 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2225 xNewKey = xKey->createKey( aTempStr );
2226 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.DocumentTemplates") );
2228 // quickstart wrapper service
2229 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2230 aImpl += ShutdownIcon::impl_getStaticImplementationName();
2232 aTempStr = aImpl;
2233 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2234 xNewKey = xKey->createKey( aTempStr );
2235 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.office.Quickstart") );
2237 // application script library container service
2238 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2239 aImpl += SfxApplicationScriptLibraryContainer::impl_getStaticImplementationName();
2241 aTempStr = aImpl;
2242 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2243 xNewKey = xKey->createKey( aTempStr );
2244 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.script.ApplicationScriptLibraryContainer") );
2246 // application dialog library container service
2247 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2248 aImpl += SfxApplicationDialogLibraryContainer::impl_getStaticImplementationName();
2250 aTempStr = aImpl;
2251 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2252 xNewKey = xKey->createKey( aTempStr );
2253 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.script.ApplicationDialogLibraryContainer") );
2255 // converter of fs folders to packages
2256 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2257 aImpl += OPackageStructureCreator::impl_getStaticImplementationName();
2259 aTempStr = aImpl;
2260 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2261 xNewKey = xKey->createKey( aTempStr );
2262 Sequence< ::rtl::OUString > rServices = OPackageStructureCreator::impl_getStaticSupportedServiceNames();
2263 for( sal_Int32 ind = 0; ind < rServices.getLength(); ind++ )
2264 xNewKey->createKey( rServices.getConstArray()[ind] );
2266 // subfilter to parse a stream in OASIS format generated by the filter
2267 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2268 aImpl += ::sfx2::OwnSubFilterService::impl_getStaticImplementationName();
2270 aTempStr = aImpl;
2271 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2272 xNewKey = xKey->createKey( aTempStr );
2273 rServices = ::sfx2::OwnSubFilterService::impl_getStaticSupportedServiceNames();
2274 for( sal_Int32 ind = 0; ind < rServices.getLength(); ind++ )
2275 xNewKey->createKey( rServices.getConstArray()[ind] );
2277 // document meta data
2278 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2279 aImpl += comp_SfxDocumentMetaData::_getImplementationName();
2281 aTempStr = aImpl;
2282 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2283 xNewKey = xKey->createKey( aTempStr );
2284 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.document.DocumentProperties") );
2287 // writer compatable document properties
2288 aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2289 aImpl += comp_CompatWriterDocProps::_getImplementationName();
2291 aTempStr = aImpl;
2292 aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2293 xNewKey = xKey->createKey( aTempStr );
2294 xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.writer.DocumentProperties") );
2296 return sal_True;
2299 SFX2_DLLPUBLIC void* SAL_CALL component_getFactory(
2300 const sal_Char* pImplementationName ,
2301 void* pServiceManager ,
2302 void* )
2304 // Set default return value for this operation - if it failed.
2305 void* pReturn = NULL ;
2307 if (
2308 ( pImplementationName != NULL ) &&
2309 ( pServiceManager != NULL )
2312 // Define variables which are used in following macros.
2313 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
2314 xFactory;
2315 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager( reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ) ) ;
2317 //=============================================================================
2318 // Add new macro line to handle new service.
2320 // !!! ATTENTION !!!
2321 // Write no ";" at end of line and dont forget "else" ! (see macro)
2322 //=============================================================================
2323 IF_NAME_CREATECOMPONENTFACTORY( SfxGlobalEvents_Impl )
2324 IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl )
2325 IF_NAME_CREATECOMPONENTFACTORY( SfxMacroLoader )
2326 IF_NAME_CREATECOMPONENTFACTORY( SfxStandaloneDocumentInfoObject )
2327 IF_NAME_CREATECOMPONENTFACTORY( SfxAppDispatchProvider )
2328 IF_NAME_CREATECOMPONENTFACTORY( SfxDocTplService )
2329 IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon )
2330 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationScriptLibraryContainer )
2331 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationDialogLibraryContainer )
2332 #ifdef TEST_HANDLERS
2333 IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
2334 IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler )
2335 #endif
2336 IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator )
2337 if ( ::sfx2::AppletObject::impl_getStaticImplementationName().equals(
2338 ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2340 xFactory = ::sfx2::AppletObject::impl_createFactory();
2342 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject )
2343 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject )
2344 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService )
2345 if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
2346 ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2348 xFactory = ::cppu::createSingleComponentFactory(
2349 ::comp_SfxDocumentMetaData::_create,
2350 ::comp_SfxDocumentMetaData::_getImplementationName(),
2351 ::comp_SfxDocumentMetaData::_getSupportedServiceNames());
2353 if ( ::comp_CompatWriterDocProps::_getImplementationName().equals(
2354 ::rtl::OUString::createFromAscii( pImplementationName ) ) )
2356 xFactory = ::cppu::createSingleComponentFactory(
2357 ::comp_CompatWriterDocProps::_create,
2358 ::comp_CompatWriterDocProps::_getImplementationName(),
2359 ::comp_CompatWriterDocProps::_getSupportedServiceNames());
2362 // Factory is valid - service was found.
2364 // Factory is valid - service was found.
2365 if ( xFactory.is() )
2367 xFactory->acquire();
2368 pReturn = xFactory.get();
2371 // Return with result of this operation.
2372 return pReturn ;
2374 } // extern "C"
2376 //=========================================================================
2378 void SAL_CALL FilterOptionsContinuation::setFilterOptions(
2379 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps )
2380 throw (::com::sun::star::uno::RuntimeException)
2382 rProperties = rProps;
2385 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
2386 FilterOptionsContinuation::getFilterOptions()
2387 throw (::com::sun::star::uno::RuntimeException)
2389 return rProperties;
2392 //=========================================================================
2394 RequestFilterOptions::RequestFilterOptions( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > rModel,
2395 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > rProperties )
2397 ::rtl::OUString temp;
2398 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2399 ::com::sun::star::document::FilterOptionsRequest aOptionsRequest( temp,
2400 temp2,
2401 rModel,
2402 rProperties );
2404 m_aRequest <<= aOptionsRequest;
2406 m_pAbort = new ContinuationAbort;
2407 m_pOptions = new FilterOptionsContinuation;
2409 m_lContinuations.realloc( 2 );
2410 m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
2411 m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pOptions );
2414 ::com::sun::star::uno::Any SAL_CALL RequestFilterOptions::getRequest()
2415 throw( ::com::sun::star::uno::RuntimeException )
2417 return m_aRequest;
2420 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2421 SAL_CALL RequestFilterOptions::getContinuations()
2422 throw( ::com::sun::star::uno::RuntimeException )
2424 return m_lContinuations;
2427 //=========================================================================
2429 RequestPackageReparation::RequestPackageReparation( ::rtl::OUString aName )
2431 ::rtl::OUString temp;
2432 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2433 ::com::sun::star::document::BrokenPackageRequest aBrokenPackageRequest( temp,
2434 temp2,
2435 aName );
2437 m_aRequest <<= aBrokenPackageRequest;
2439 m_pApprove = new ContinuationApprove;
2440 m_pDisapprove = new ContinuationDisapprove;
2442 m_lContinuations.realloc( 2 );
2443 m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pApprove );
2444 m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pDisapprove );
2447 ::com::sun::star::uno::Any SAL_CALL RequestPackageReparation::getRequest()
2448 throw( ::com::sun::star::uno::RuntimeException )
2450 return m_aRequest;
2453 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2454 SAL_CALL RequestPackageReparation::getContinuations()
2455 throw( ::com::sun::star::uno::RuntimeException )
2457 return m_lContinuations;
2460 //=========================================================================
2462 NotifyBrokenPackage::NotifyBrokenPackage( ::rtl::OUString aName )
2464 ::rtl::OUString temp;
2465 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
2466 ::com::sun::star::document::BrokenPackageRequest aBrokenPackageRequest( temp,
2467 temp2,
2468 aName );
2470 m_aRequest <<= aBrokenPackageRequest;
2472 m_pAbort = new ContinuationAbort;
2474 m_lContinuations.realloc( 1 );
2475 m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
2478 ::com::sun::star::uno::Any SAL_CALL NotifyBrokenPackage::getRequest()
2479 throw( ::com::sun::star::uno::RuntimeException )
2481 return m_aRequest;
2484 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
2485 SAL_CALL NotifyBrokenPackage::getContinuations()
2486 throw( ::com::sun::star::uno::RuntimeException )
2488 return m_lContinuations;