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