1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appuno.cxx,v $
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 )
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>
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
;
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
)
202 pSlot
= SFX_SLOTPOOL().GetSlot( nSlotId
);
207 if ( nSlotId
== SID_OPENURL
)
208 nSlotId
= SID_OPENDOC
;
209 if ( nSlotId
== SID_SAVEASURL
)
210 nSlotId
= SID_SAVEASDOC
;
212 sal_Int32 nCount
= rArgs
.getLength();
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();
225 ByteString
aStr( "No creator method for item: ");
226 aStr
+= ByteString::CreateFromInt32( nSlotId
);
227 DBG_ERROR( aStr
.GetBuffer() );
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
249 ByteString
aStr( "Property not convertable: ");
250 aStr
+= pSlot
->pUnoName
;
251 DBG_ERROR( aStr
.GetBuffer() );
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() );
266 // there is more than one parameter and the property is a complex one
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() );
279 // complex property; collect sub items from the parameter set and reconstruct complex item
281 for ( sal_uInt16 n
=0; n
<nCount
; n
++ )
283 const ::com::sun::star::beans::PropertyValue
& rPropValue
= pPropsVal
[n
];
285 for ( nSub
=0; nSub
<nSubCount
; nSub
++ )
287 // search sub item by name
288 ByteString
aStr( pSlot
->pUnoName
);
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
;
296 nSubId
|= CONVERT_TWIPS
;
297 if ( pItem
->PutValue( rPropValue
.Value
, nSubId
) )
302 ByteString
aDbgStr( "Property not convertable: ");
303 aDbgStr
+= pSlot
->pUnoName
;
304 DBG_ERROR( aDbgStr
.GetBuffer() );
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() );
322 // at least one part of the complex item must be present; other parts can have default values
332 // detect parameters that don't match to any formal argument or one of its members
333 sal_Int32 nFoundArgs
= 0;
336 for ( sal_uInt16 nArgs
=0; nArgs
<pSlot
->nArgDefCount
; nArgs
++ )
338 const SfxFormalArgument
&rArg
= pSlot
->GetFormalArgument( nArgs
);
339 SfxPoolItem
* pItem
= rArg
.CreateItem();
343 ByteString
aStr( "No creator method for argument: ");
345 DBG_ERROR( aStr
.GetBuffer() );
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
)
367 if( pItem
->PutValue( rProp
.Value
) )
368 // only use successfully converted items
373 ByteString
aStr( "Property not convertable: ");
375 DBG_ERROR( aStr
.GetBuffer() );
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
)
396 if( pItem
->PutValue( rProp
.Value
) )
397 // only use successfully converted items
402 ByteString
aStr( "Property not convertable: ");
404 DBG_ERROR( aStr
.GetBuffer() );
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?)
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
);
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 ...
433 BYTE nSubId
= (BYTE
) (sal_Int8
) pType
->aAttrib
[nSub
].nAID
;
435 nSubId
|= CONVERT_TWIPS
;
436 if (!pItem
->PutValue( rProp
.Value
, nSubId
) )
438 // ... but it was not convertable
441 ByteString
aDbgStr( "Property not convertable: ");
442 aDbgStr
+= rArg
.pName
;
443 DBG_ERROR( aDbgStr
.GetBuffer() );
453 // only use successfully converted items
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
) );
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
++ )
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
586 rSet
.Put( SfxBoolItem( SID_OPEN_NEW_VIEW
, bVal
) );
588 else if ( aName
== sViewId
)
591 sal_Bool bOK
= ((rProp
.Value
>>= nVal
) && (nVal
!= -1));
592 DBG_ASSERT( bOK
, "invalid type for ViewId" );
594 rSet
.Put( SfxUInt16Item( SID_VIEW_ID
, nVal
) );
596 else if ( aName
== sPluginMode
)
599 sal_Bool bOK
= ((rProp
.Value
>>= nVal
) && (nVal
!= -1));
600 DBG_ASSERT( bOK
, "invalid type for PluginMode" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
790 rSet
.Put( SfxStringItem( SID_FILE_FILTEROPTIONS
, sVal
) );
792 else if ( aName
== sMacroExecMode
)
795 sal_Bool bOK
= ((rProp
.Value
>>= nVal
) && (nVal
!= -1));
796 DBG_ASSERT( bOK
, "invalid type for MacroExecMode" );
798 rSet
.Put( SfxUInt16Item( SID_MACROEXECMODE
, nVal
) );
800 else if ( aName
== sUpdateDocMode
)
803 sal_Bool bOK
= ((rProp
.Value
>>= nVal
) && (nVal
!= -1));
804 DBG_ASSERT( bOK
, "invalid type for UpdateDocMode" );
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" );
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" );
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" );
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" );
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" );
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" );
855 rSet
.Put( SfxBoolItem( SID_NOAUTOSAVE
, bVal
) );
863 // --> PB 2007-12-09 #i83757#
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
) );
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() );
898 void TransformItems( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArgs
, const SfxSlot
* pSlot
)
901 pSlot
= SFX_SLOTPOOL().GetSlot( nSlotId
);
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
915 // trace number of items and compare with number of properties for debugging purposes
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
;
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
932 // simple property: we expect to get exactly one item
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() );
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
;
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
966 // argument of simple type: we expect to get exactly one item for it
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
)
981 if ( rSet
.GetItemState( SID_INTERACTIONHANDLER
) == SFX_ITEM_SET
)
983 if ( rSet
.GetItemState( SID_DOC_SALVAGE
) == SFX_ITEM_SET
)
985 if ( rSet
.GetItemState( SID_PATH
) == SFX_ITEM_SET
)
987 if ( rSet
.GetItemState( SID_FILE_DIALOG
) == SFX_ITEM_SET
)
989 if ( rSet
.GetItemState( SID_STANDARD_DIR
) == SFX_ITEM_SET
)
991 if ( rSet
.GetItemState( SID_BLACK_LIST
) == SFX_ITEM_SET
)
993 if ( rSet
.GetItemState( SID_CONTENT
) == SFX_ITEM_SET
)
995 if ( rSet
.GetItemState( SID_INPUTSTREAM
) == SFX_ITEM_SET
)
997 if ( rSet
.GetItemState( SID_STREAM
) == SFX_ITEM_SET
)
999 if ( rSet
.GetItemState( SID_OUTPUTSTREAM
) == SFX_ITEM_SET
)
1001 if ( rSet
.GetItemState( SID_TEMPLATE
) == SFX_ITEM_SET
)
1003 if ( rSet
.GetItemState( SID_OPEN_NEW_VIEW
) == SFX_ITEM_SET
)
1005 if ( rSet
.GetItemState( SID_VIEW_ID
) == SFX_ITEM_SET
)
1007 if ( rSet
.GetItemState( SID_VIEW_DATA
) == SFX_ITEM_SET
)
1009 if ( rSet
.GetItemState( SID_FILTER_DATA
) == SFX_ITEM_SET
)
1011 if ( rSet
.GetItemState( SID_PLUGIN_MODE
) == SFX_ITEM_SET
)
1013 if ( rSet
.GetItemState( SID_DOC_READONLY
) == SFX_ITEM_SET
)
1015 if ( rSet
.GetItemState( SID_DOC_STARTPRESENTATION
) == SFX_ITEM_SET
)
1017 if ( rSet
.GetItemState( SID_SELECTION
) == SFX_ITEM_SET
)
1019 if ( rSet
.GetItemState( SID_CONTENTTYPE
) == SFX_ITEM_SET
)
1021 if ( rSet
.GetItemState( SID_WIN_POSSIZE
) == SFX_ITEM_SET
)
1023 // if ( rSet.GetItemState( SID_VIEW_POS_SIZE ) == SFX_ITEM_SET )
1025 if ( rSet
.GetItemState( SID_POSTDATA
) == SFX_ITEM_SET
)
1027 if ( rSet
.GetItemState( SID_FILLFRAME
) == SFX_ITEM_SET
)
1029 if ( rSet
.GetItemState( SID_CHARSET
) == SFX_ITEM_SET
)
1031 if ( rSet
.GetItemState( SID_TARGETNAME
) == SFX_ITEM_SET
)
1033 if ( rSet
.GetItemState( SID_TEMPLATE_NAME
) == SFX_ITEM_SET
)
1035 if ( rSet
.GetItemState( SID_TEMPLATE_REGIONNAME
) == SFX_ITEM_SET
)
1037 if ( rSet
.GetItemState( SID_HIDDEN
) == SFX_ITEM_SET
)
1039 if ( rSet
.GetItemState( SID_MINIMIZED
) == SFX_ITEM_SET
)
1041 if ( rSet
.GetItemState( SID_PREVIEW
) == SFX_ITEM_SET
)
1043 if ( rSet
.GetItemState( SID_VIEWONLY
) == SFX_ITEM_SET
)
1045 if ( rSet
.GetItemState( SID_EDITDOC
) == SFX_ITEM_SET
)
1047 if ( rSet
.GetItemState( SID_SILENT
) == SFX_ITEM_SET
)
1049 if ( rSet
.GetItemState( SID_JUMPMARK
) == SFX_ITEM_SET
)
1051 if ( rSet
.GetItemState( SID_DOCUMENT
) == SFX_ITEM_SET
)
1053 if ( rSet
.GetItemState( SID_MACROEXECMODE
) == SFX_ITEM_SET
)
1055 if ( rSet
.GetItemState( SID_UPDATEDOCMODE
) == SFX_ITEM_SET
)
1057 if ( rSet
.GetItemState( SID_REPAIRPACKAGE
) == SFX_ITEM_SET
)
1059 if ( rSet
.GetItemState( SID_DOCINFO_TITLE
) == SFX_ITEM_SET
)
1061 if ( rSet
.GetItemState( SID_COMPONENTDATA
) == SFX_ITEM_SET
)
1063 if ( rSet
.GetItemState( SID_COMPONENTCONTEXT
) == SFX_ITEM_SET
)
1065 if ( rSet
.GetItemState( SID_DOC_BASEURL
) == SFX_ITEM_SET
)
1067 if ( rSet
.GetItemState( SID_DOC_HIERARCHICALNAME
) == SFX_ITEM_SET
)
1069 if ( rSet
.GetItemState( SID_COPY_STREAM_IF_POSSIBLE
) == SFX_ITEM_SET
)
1071 if ( rSet
.GetItemState( SID_NOAUTOSAVE
) == SFX_ITEM_SET
)
1074 // consider additional arguments
1075 nProps
+= nAdditional
;
1077 nItems
+= nAdditional
;
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();
1091 for(USHORT nId
= *pRanges
++; nId
<= *pRanges
; ++nId
)
1093 if ( rSet
.GetItemState(nId
) < SFX_ITEM_SET
) //???
1097 if ( !pSlot
->IsMode(SFX_SLOT_METHOD
) && nId
== rSet
.GetPool()->GetWhich( pSlot
->GetSlotId() ) )
1100 USHORT nFormalArgs
= pSlot
->GetFormalArgumentCount();
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
)
1110 if ( nArg
<nFormalArgs
)
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
)
1118 if ( nId
== SID_PROGRESS_STATUSBAR_CONTROL
)
1120 if ( nId
== SID_INTERACTIONHANDLER
)
1122 if ( nId
== SID_VIEW_DATA
)
1124 if ( nId
== SID_FILTER_DATA
)
1126 if ( nId
== SID_DOCUMENT
)
1128 if ( nId
== SID_CONTENT
)
1130 if ( nId
== SID_INPUTSTREAM
)
1132 if ( nId
== SID_STREAM
)
1134 if ( nId
== SID_OUTPUTSTREAM
)
1136 if ( nId
== SID_POSTDATA
)
1138 if ( nId
== SID_FILLFRAME
)
1140 if ( nId
== SID_TEMPLATE
)
1142 if ( nId
== SID_OPEN_NEW_VIEW
)
1144 if ( nId
== SID_VIEW_ID
)
1146 if ( nId
== SID_PLUGIN_MODE
)
1148 if ( nId
== SID_DOC_READONLY
)
1150 if ( nId
== SID_DOC_STARTPRESENTATION
)
1152 if ( nId
== SID_SELECTION
)
1154 if ( nId
== SID_HIDDEN
)
1156 if ( nId
== SID_MINIMIZED
)
1158 if ( nId
== SID_SILENT
)
1160 if ( nId
== SID_PREVIEW
)
1162 if ( nId
== SID_VIEWONLY
)
1164 if ( nId
== SID_EDITDOC
)
1166 if ( nId
== SID_TARGETNAME
)
1168 if ( nId
== SID_DOC_SALVAGE
)
1170 if ( nId
== SID_PATH
)
1172 if ( nId
== SID_FILE_DIALOG
)
1174 if ( nId
== SID_STANDARD_DIR
)
1176 if ( nId
== SID_BLACK_LIST
)
1178 if ( nId
== SID_CONTENTTYPE
)
1180 if ( nId
== SID_WIN_POSSIZE
)
1182 if ( nId
== SID_TEMPLATE_NAME
)
1184 if ( nId
== SID_TEMPLATE_REGIONNAME
)
1186 if ( nId
== SID_JUMPMARK
)
1188 if ( nId
== SID_CHARSET
)
1190 if ( nId
== SID_MACROEXECMODE
)
1192 if ( nId
== SID_UPDATEDOCMODE
)
1194 if ( nId
== SID_REPAIRPACKAGE
)
1196 if ( nId
== SID_DOCINFO_TITLE
)
1198 if ( nId
== SID_COMPONENTDATA
)
1200 if ( nId
== SID_COMPONENTCONTEXT
)
1202 if ( nId
== SID_DOC_BASEURL
)
1204 if ( nId
== SID_DOC_HIERARCHICALNAME
)
1206 if ( nId
== SID_COPY_STREAM_IF_POSSIBLE
)
1208 if ( nId
== SID_NOAUTOSAVE
)
1211 // used only internally
1212 if ( nId
== SID_SAVETO
)
1216 ByteString
aDbg( "Unknown item detected: ");
1217 aDbg
+= ByteString::CreateFromInt32( nId
);
1218 DBG_ASSERT( nArg
<nFormalArgs
, aDbg
.GetBuffer() );
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
);
1240 USHORT nSubCount
= pType
->nAttribs
;
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() );
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
) ) ;
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() );
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
);
1291 USHORT nSubCount
= rArg
.pType
->nAttribs
;
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() );
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
) ) ;
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
);
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() );
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
;
1597 SfxObjectShell
* SfxMacroLoader::GetObjectShell_Impl()
1599 SfxObjectShell
* pDocShell
= NULL
;
1600 Reference
< XFrame
> xFrame( m_xFrame
.get(), UNO_QUERY
);
1604 for ( pFrame
= SfxFrame::GetFirst(); pFrame
; pFrame
= SfxFrame::GetNext( *pFrame
) )
1606 if ( pFrame
->GetFrameInterface() == xFrame
)
1611 pDocShell
= pFrame
->GetCurrentDocument();
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)
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
);
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
;
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
;
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() );
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
;
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
)
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
;
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() )
1760 else if ( aBasMgrName
.EqualsAscii(".") )
1762 // current/actual document
1765 pBasMgr
= pDoc
->GetBasicManager();
1769 // full qualified name, find document by name
1770 for ( SfxObjectShell
*pObjSh
= SfxObjectShell::GetFirst();
1772 pObjSh
= SfxObjectShell::GetNext(*pObjSh
) )
1773 if ( aBasMgrName
== pObjSh
->GetTitle(SFX_TITLE_APINAME
) )
1776 pBasMgr
= pDoc
->GetBasicManager();
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
) );
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
);
1813 // arguments must be quoted
1815 if ( aArgs
.Len()<2 || aArgs
.GetBuffer()[1] == '\"')
1816 // no args or already quoted args
1817 aQuotedArgs
= aArgs
;
1822 aArgs
.Erase( aArgs
.Len()-1,1);
1826 sal_uInt16 nCount
= aArgs
.GetTokenCount(',');
1827 for ( sal_uInt16 n
=0; n
<nCount
; n
++ )
1829 aQuotedArgs
+= '\"';
1830 aQuotedArgs
+= aArgs
.GetToken( n
, ',' );
1831 aQuotedArgs
+= '\"';
1839 Any aOldThisComponent
;
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
;
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
);
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
);
1885 nErr
= ERRCODE_BASIC_PROC_UNDEFINED
;
1888 nErr
= ERRCODE_IO_NOTEXISTS
;
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
));
1897 pAppMgr
->GetLib(0)->Execute( aCall
);
1898 nErr
= SbxBase::GetError();
1901 pApp
->LeaveBasicCall();
1902 SbxBase::ResetError();
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
;
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
)
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();
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
) );
1943 pSlot
= pAppDisp
->GetSlot( aURL
.Main
);
1948 SfxOfficeDispatch
* pDispatch
= new SfxOfficeDispatch( pAppDisp
, pSlot
, aURL
) ;
1949 pDispatch
->SetFrame(m_xFrame
);
1950 pDispatch
->SetMasterUnoCommand( bMasterCommand
);
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
);
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();
1986 if ( pSfxSlot
->GetMode() & nMode
)
1988 sal_Int16 nCommandGroup
= MapGroupIDToCommandGroup( pSfxSlot
->GetGroupId() );
1989 aGroupList
.push_back( nCommandGroup
);
1992 pSfxSlot
= pAppSlotPool
->NextSlot();
1996 ::com::sun::star::uno::Sequence
< sal_Int16
> aSeq
=
1997 comphelper::containerToSequence
< sal_Int16
, std::list
< sal_Int16
> >( aGroupList
);
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();
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();
2022 sal_Int16 nCommandGroup
= MapGroupIDToCommandGroup( pSfxSlot
->GetGroupId() );
2023 if ( nCommandGroup
== nCmdGroup
)
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
);
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
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
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
)
2092 sal_Bool SAL_CALL
TestKeyHandler::keyReleased( const ::com::sun::star::awt::KeyEvent
& aEvent
) throw (::com::sun::star::uno::RuntimeException
)
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
)
2106 sal_Bool SAL_CALL
TestMouseClickHandler::mouseReleased( const ::com::sun::star::awt::MouseEvent
& e
) throw (::com::sun::star::uno::RuntimeException
)
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
);
2120 // -----------------------------------------------------------------------
2124 SFX2_DLLPUBLIC
void SAL_CALL
component_getImplementationEnvironment(
2125 const sal_Char
** ppEnvironmentTypeName
,
2128 *ppEnvironmentTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
2131 SFX2_DLLPUBLIC sal_Bool SAL_CALL
component_writeInfo(
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
;
2145 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2146 aImpl
+= ::sfx2::PluginObject::impl_getStaticImplementationName();
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") );
2155 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2156 aImpl
+= ::sfx2::AppletObject::impl_getStaticImplementationName();
2159 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2160 xNewKey
= xKey
->createKey( aTempStr
);
2161 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") );
2165 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2166 aImpl
+= ::sfx2::IFrameObject::impl_getStaticImplementationName();
2169 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2170 xNewKey
= xKey
->createKey( aTempStr
);
2171 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") );
2173 // global app event broadcaster
2174 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2175 aImpl
+= SfxGlobalEvents_Impl::impl_getStaticImplementationName();
2178 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2179 xNewKey
= xKey
->createKey( aTempStr
);
2180 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster") );
2182 // global app dispatcher
2183 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2184 aImpl
+= SfxAppDispatchProvider::impl_getStaticImplementationName();
2187 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2188 xNewKey
= xKey
->createKey( aTempStr
);
2189 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.ProtocolHandler") );
2191 // standalone document info
2192 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2193 aImpl
+= SfxStandaloneDocumentInfoObject::impl_getStaticImplementationName();
2196 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2197 xNewKey
= xKey
->createKey( aTempStr
);
2198 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.document.StandaloneDocumentInfo") );
2201 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2202 aImpl
+= SfxFrameLoader_Impl::impl_getStaticImplementationName();
2205 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2206 xNewKey
= xKey
->createKey( aTempStr
);
2207 Sequence
< ::rtl::OUString
> aServices
= SfxFrameLoader_Impl::impl_getStaticSupportedServiceNames();
2208 sal_Int32 nCount
= aServices
.getLength();
2209 for ( sal_Int16 i
=0; i
<nCount
; i
++ )
2210 xNewKey
->createKey( aServices
.getConstArray()[i
] );
2213 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2214 aImpl
+= SfxMacroLoader::impl_getStaticImplementationName();
2217 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2218 xNewKey
= xKey
->createKey( aTempStr
);
2219 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.ProtocolHandler") );
2221 // - sfx document templates
2222 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2223 aImpl
+= SfxDocTplService::impl_getStaticImplementationName();
2226 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2227 xNewKey
= xKey
->createKey( aTempStr
);
2228 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.DocumentTemplates") );
2230 // quickstart wrapper service
2231 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2232 aImpl
+= ShutdownIcon::impl_getStaticImplementationName();
2235 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2236 xNewKey
= xKey
->createKey( aTempStr
);
2237 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.office.Quickstart") );
2239 // application script library container service
2240 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2241 aImpl
+= SfxApplicationScriptLibraryContainer::impl_getStaticImplementationName();
2244 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2245 xNewKey
= xKey
->createKey( aTempStr
);
2246 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.script.ApplicationScriptLibraryContainer") );
2248 // application dialog library container service
2249 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2250 aImpl
+= SfxApplicationDialogLibraryContainer::impl_getStaticImplementationName();
2253 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2254 xNewKey
= xKey
->createKey( aTempStr
);
2255 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.script.ApplicationDialogLibraryContainer") );
2257 // converter of fs folders to packages
2258 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2259 aImpl
+= OPackageStructureCreator::impl_getStaticImplementationName();
2262 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2263 xNewKey
= xKey
->createKey( aTempStr
);
2264 Sequence
< ::rtl::OUString
> rServices
= OPackageStructureCreator::impl_getStaticSupportedServiceNames();
2265 for( sal_Int32 ind
= 0; ind
< rServices
.getLength(); ind
++ )
2266 xNewKey
->createKey( rServices
.getConstArray()[ind
] );
2268 // subfilter to parse a stream in OASIS format generated by the filter
2269 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2270 aImpl
+= ::sfx2::OwnSubFilterService::impl_getStaticImplementationName();
2273 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2274 xNewKey
= xKey
->createKey( aTempStr
);
2275 rServices
= ::sfx2::OwnSubFilterService::impl_getStaticSupportedServiceNames();
2276 for( sal_Int32 ind
= 0; ind
< rServices
.getLength(); ind
++ )
2277 xNewKey
->createKey( rServices
.getConstArray()[ind
] );
2279 // document meta data
2280 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2281 aImpl
+= comp_SfxDocumentMetaData::_getImplementationName();
2284 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2285 xNewKey
= xKey
->createKey( aTempStr
);
2286 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.document.DocumentProperties") );
2289 // writer compatable document properties
2290 aImpl
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
2291 aImpl
+= comp_CompatWriterDocProps::_getImplementationName();
2294 aTempStr
+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
2295 xNewKey
= xKey
->createKey( aTempStr
);
2296 xNewKey
->createKey( ::rtl::OUString::createFromAscii("com.sun.star.writer.DocumentProperties") );
2301 SFX2_DLLPUBLIC
void* SAL_CALL
component_getFactory(
2302 const sal_Char
* pImplementationName
,
2303 void* pServiceManager
,
2306 // Set default return value for this operation - if it failed.
2307 void* pReturn
= NULL
;
2310 ( pImplementationName
!= NULL
) &&
2311 ( pServiceManager
!= NULL
)
2314 // Define variables which are used in following macros.
2315 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
2317 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceManager( reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory
* >( pServiceManager
) ) ;
2319 //=============================================================================
2320 // Add new macro line to handle new service.
2322 // !!! ATTENTION !!!
2323 // Write no ";" at end of line and dont forget "else" ! (see macro)
2324 //=============================================================================
2325 IF_NAME_CREATECOMPONENTFACTORY( SfxGlobalEvents_Impl
)
2326 IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl
)
2327 IF_NAME_CREATECOMPONENTFACTORY( SfxMacroLoader
)
2328 IF_NAME_CREATECOMPONENTFACTORY( SfxStandaloneDocumentInfoObject
)
2329 IF_NAME_CREATECOMPONENTFACTORY( SfxAppDispatchProvider
)
2330 IF_NAME_CREATECOMPONENTFACTORY( SfxDocTplService
)
2331 IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon
)
2332 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationScriptLibraryContainer
)
2333 IF_NAME_CREATECOMPONENTFACTORY( SfxApplicationDialogLibraryContainer
)
2334 #ifdef TEST_HANDLERS
2335 IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler
)
2336 IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler
)
2338 IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator
)
2340 if ( ::sfx2::AppletObject::impl_getStaticImplementationName().equals(
2341 ::rtl::OUString::createFromAscii( pImplementationName
) ) )
2343 xFactory
= ::sfx2::AppletObject::impl_createFactory();
2346 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject
)
2347 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject
)
2348 IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService
)
2349 if ( ::comp_SfxDocumentMetaData::_getImplementationName().equals(
2350 ::rtl::OUString::createFromAscii( pImplementationName
) ) )
2352 xFactory
= ::cppu::createSingleComponentFactory(
2353 ::comp_SfxDocumentMetaData::_create
,
2354 ::comp_SfxDocumentMetaData::_getImplementationName(),
2355 ::comp_SfxDocumentMetaData::_getSupportedServiceNames());
2357 if ( ::comp_CompatWriterDocProps::_getImplementationName().equals(
2358 ::rtl::OUString::createFromAscii( pImplementationName
) ) )
2360 xFactory
= ::cppu::createSingleComponentFactory(
2361 ::comp_CompatWriterDocProps::_create
,
2362 ::comp_CompatWriterDocProps::_getImplementationName(),
2363 ::comp_CompatWriterDocProps::_getSupportedServiceNames());
2366 // Factory is valid - service was found.
2368 // Factory is valid - service was found.
2369 if ( xFactory
.is() )
2371 xFactory
->acquire();
2372 pReturn
= xFactory
.get();
2375 // Return with result of this operation.
2380 //=========================================================================
2382 void SAL_CALL
FilterOptionsContinuation::setFilterOptions(
2383 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rProps
)
2384 throw (::com::sun::star::uno::RuntimeException
)
2386 rProperties
= rProps
;
2389 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
2390 FilterOptionsContinuation::getFilterOptions()
2391 throw (::com::sun::star::uno::RuntimeException
)
2396 //=========================================================================
2398 RequestFilterOptions::RequestFilterOptions( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> rModel
,
2399 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> rProperties
)
2401 ::rtl::OUString temp
;
2402 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> temp2
;
2403 ::com::sun::star::document::FilterOptionsRequest
aOptionsRequest( temp
,
2408 m_aRequest
<<= aOptionsRequest
;
2410 m_pAbort
= new ContinuationAbort
;
2411 m_pOptions
= new FilterOptionsContinuation
;
2413 m_lContinuations
.realloc( 2 );
2414 m_lContinuations
[0] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pAbort
);
2415 m_lContinuations
[1] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pOptions
);
2418 ::com::sun::star::uno::Any SAL_CALL
RequestFilterOptions::getRequest()
2419 throw( ::com::sun::star::uno::RuntimeException
)
2424 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >
2425 SAL_CALL
RequestFilterOptions::getContinuations()
2426 throw( ::com::sun::star::uno::RuntimeException
)
2428 return m_lContinuations
;
2431 //=========================================================================
2433 RequestPackageReparation::RequestPackageReparation( ::rtl::OUString aName
)
2435 ::rtl::OUString temp
;
2436 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> temp2
;
2437 ::com::sun::star::document::BrokenPackageRequest
aBrokenPackageRequest( temp
,
2441 m_aRequest
<<= aBrokenPackageRequest
;
2443 m_pApprove
= new ContinuationApprove
;
2444 m_pDisapprove
= new ContinuationDisapprove
;
2446 m_lContinuations
.realloc( 2 );
2447 m_lContinuations
[0] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pApprove
);
2448 m_lContinuations
[1] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pDisapprove
);
2451 ::com::sun::star::uno::Any SAL_CALL
RequestPackageReparation::getRequest()
2452 throw( ::com::sun::star::uno::RuntimeException
)
2457 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >
2458 SAL_CALL
RequestPackageReparation::getContinuations()
2459 throw( ::com::sun::star::uno::RuntimeException
)
2461 return m_lContinuations
;
2464 //=========================================================================
2466 NotifyBrokenPackage::NotifyBrokenPackage( ::rtl::OUString aName
)
2468 ::rtl::OUString temp
;
2469 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> temp2
;
2470 ::com::sun::star::document::BrokenPackageRequest
aBrokenPackageRequest( temp
,
2474 m_aRequest
<<= aBrokenPackageRequest
;
2476 m_pAbort
= new ContinuationAbort
;
2478 m_lContinuations
.realloc( 1 );
2479 m_lContinuations
[0] = ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
>( m_pAbort
);
2482 ::com::sun::star::uno::Any SAL_CALL
NotifyBrokenPackage::getRequest()
2483 throw( ::com::sun::star::uno::RuntimeException
)
2488 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionContinuation
> >
2489 SAL_CALL
NotifyBrokenPackage::getContinuations()
2490 throw( ::com::sun::star::uno::RuntimeException
)
2492 return m_lContinuations
;