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