~ubuntu-branches/ubuntu/lucid/openoffice.org-l10n/lucid

« back to all changes in this revision

Viewing changes to ooo-build/patches/vba/vba-automation-put-get-property-improvements.diff

  • Committer: Bazaar Package Importer
  • Author(s): Chris Cheney
  • Date: 2010-01-19 16:00:00 UTC
  • mfrom: (1.1.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100119160000-freeu943fe1z3o76
Tags: 1:3.2.0~rc2-1ubuntu1
* Resynchronise with Debian (r1764). Remaining changes:
  - Add Launchpad integration support.
  - Add Launchpad translations support.
  - Add package openoffice.org-style-human.
  - Add some Ubuntu-specific bitmaps. Adjust broffice diversions for these.
  - Add support for compressing debs with lzma.
  - Add support for shared /usr/share/doc directories.
  - Add support to build l10n as a separate source.
  - Add support to turn off building on sparc.
  - Add Xb-Npp-xxx tags according to "firefox distro add-on suport" spec.
  - Use imagemagick instead of graphicsmagick.
  - openoffice.org-help switch to internal copy of lucene.
  - Disable gnome-vfs support since it is buggy.
  - Switch desktop files from %U to %F for gvfs fuse.
* Resynchronise with ooo-build-3-2 (454ea0d62d4321b54cd5ef870ac99d8d7929c459).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff --git basic/source/classes/sbunoobj.cxx basic/source/classes/sbunoobj.cxx
 
2
index 09858a6..b1935c3 100644
 
3
--- basic/source/classes/sbunoobj.cxx
 
4
+++ basic/source/classes/sbunoobj.cxx
 
5
@@ -63,6 +63,7 @@
 
6
 #include <com/sun/star/script/XInvocationAdapterFactory.hpp>
 
7
 #include <com/sun/star/script/XTypeConverter.hpp>
 
8
 #include <com/sun/star/script/XDefaultProperty.hpp>
 
9
+#include <com/sun/star/script/XDefaultMethod.hpp>
 
10
 #include <com/sun/star/container/XNameAccess.hpp>
 
11
 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
 
12
 #include <com/sun/star/reflection/XIdlArray.hpp>
 
13
@@ -73,7 +74,7 @@
 
14
 #include <com/sun/star/bridge/oleautomation/Date.hpp>
 
15
 #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
 
16
 #include <com/sun/star/bridge/oleautomation/Currency.hpp>
 
17
-
 
18
+#include <com/sun/star/script/XAutomationInvocation.hpp>
 
19
 
 
20
 using com::sun::star::uno::Reference;
 
21
 using namespace com::sun::star::uno;
 
22
@@ -1502,6 +1503,103 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty
 
23
     return aRetVal;
 
24
 }
 
25
 
 
26
+void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOLEAutomation, UINT32 nParamCount )
 
27
+{
 
28
+       AutomationNamedArgsSbxArray* pArgNamesArray = NULL;
 
29
+       if( bOLEAutomation )
 
30
+               pArgNamesArray = PTR_CAST(AutomationNamedArgsSbxArray,pParams);
 
31
+
 
32
+       args.realloc( nParamCount );
 
33
+       Any* pAnyArgs = args.getArray();
 
34
+       bool bBlockConversionToSmallestType = pINST->IsCompatibility();
 
35
+       UINT32 i = 0;   
 
36
+       if( pArgNamesArray )
 
37
+       {
 
38
+               Sequence< ::rtl::OUString >& rNameSeq = pArgNamesArray->getNames();
 
39
+               ::rtl::OUString* pNames = rNameSeq.getArray();
 
40
+               Any aValAny;
 
41
+               for( i = 0 ; i < nParamCount ; i++ )
 
42
+               {
 
43
+                       USHORT iSbx = (USHORT)(i+1);
 
44
+       
 
45
+                       // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen!
 
46
+                       aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ),
 
47
+                       bBlockConversionToSmallestType );
 
48
+       
 
49
+                       ::rtl::OUString aParamName = pNames[iSbx];
 
50
+                       if( aParamName.getLength() )
 
51
+                       {
 
52
+                               oleautomation::NamedArgument aNamedArgument;
 
53
+                               aNamedArgument.Name = aParamName;
 
54
+                               aNamedArgument.Value = aValAny;
 
55
+                               pAnyArgs[i] <<= aNamedArgument;
 
56
+                       }
 
57
+                       else
 
58
+                       {
 
59
+                               pAnyArgs[i] = aValAny;
 
60
+                       }
 
61
+               }
 
62
+       }
 
63
+       else
 
64
+       {
 
65
+               for( i = 0 ; i < nParamCount ; i++ )
 
66
+               {
 
67
+                       // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen!
 
68
+                       pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (USHORT)(i+1) ),
 
69
+                       bBlockConversionToSmallestType );
 
70
+               }
 
71
+       }
 
72
+
 
73
+}
 
74
+enum INVOKETYPE
 
75
+{
 
76
+   GetProp = 0, 
 
77
+   SetProp, 
 
78
+   Func
 
79
+};
 
80
+Any invokeAutomationMethod( const String& Name, Sequence< Any >& args, SbxArray* pParams, UINT32 nParamCount, Reference< XInvocation >& rxInvocation, INVOKETYPE invokeType = Func )
 
81
+{
 
82
+       Sequence< INT16 > OutParamIndex;
 
83
+       Sequence< Any > OutParam;
 
84
+    
 
85
+       Any aRetAny;
 
86
+       switch( invokeType )
 
87
+       {
 
88
+               case Func:
 
89
+                       aRetAny = rxInvocation->invoke( Name, args, OutParamIndex, OutParam );
 
90
+                       break;
 
91
+               case GetProp:
 
92
+                       {
 
93
+                               Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY_THROW );
 
94
+                               aRetAny = xAutoInv->invokeGetProperty( Name, args, OutParamIndex, OutParam );
 
95
+                               break;
 
96
+                       }
 
97
+               case SetProp:
 
98
+                       {
 
99
+                               Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY_THROW );
 
100
+                               aRetAny = xAutoInv->invokePutProperty( Name, args, OutParamIndex, OutParam );
 
101
+                               break;
 
102
+                       }
 
103
+               default:
 
104
+                       break; // should introduce an error here
 
105
+       
 
106
+       }
 
107
+       const INT16* pIndices = OutParamIndex.getConstArray();
 
108
+       UINT32 nLen = OutParamIndex.getLength();
 
109
+       if( nLen )
 
110
+       {
 
111
+               const Any* pNewValues = OutParam.getConstArray();
 
112
+               for( UINT32 j = 0 ; j < nLen ; j++ )
 
113
+               {
 
114
+                       INT16 iTarget = pIndices[ j ];
 
115
+                       if( iTarget >= (INT16)nParamCount )
 
116
+                               break;
 
117
+                       unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pNewValues[ j ] );
 
118
+               }
 
119
+       }
 
120
+    return aRetAny;
 
121
+}
 
122
+
 
123
 // Dbg-Hilfsmethode zum Auslesen der in einem Object implementierten Interfaces
 
124
 String Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, USHORT nRekLevel )
 
125
 {
 
126
@@ -2002,11 +2100,26 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
 
127
                 {
 
128
                     try
 
129
                     {
 
130
-                        // Wert holen
 
131
-                        Any aRetAny = mxInvocation->getValue( pProp->GetName() );
 
132
+                                               UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0;
 
133
+                                               sal_Bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() );
 
134
+                                               Any aRetAny;
 
135
+                                               if ( bCanBeConsideredAMethod && nParamCount )
 
136
+                                               {
 
137
+                                                       // Automation properties have methods, so.. we need to invoke this through
 
138
+                                                       // XInvocation
 
139
+                                                       Sequence<Any> args;
 
140
+                                                       processAutomationParams( pParams, args, true, nParamCount );
 
141
+                                                       aRetAny = invokeAutomationMethod( pProp->GetName(), args, pParams, nParamCount, mxInvocation, GetProp );
 
142
+                                               }       
 
143
+                                               else
 
144
+                                                       // Wert holen
 
145
+                                                       aRetAny = mxInvocation->getValue( pProp->GetName() );
 
146
 
 
147
                         // Wert von Uno nach Sbx uebernehmen
 
148
                         unoToSbxValue( pVar, aRetAny );
 
149
+                                               if( pParams && bCanBeConsideredAMethod )
 
150
+                                                       pVar->SetParameters( NULL );
 
151
+
 
152
                     }
 
153
                     catch( const Exception& )
 
154
                     {
 
155
@@ -2131,52 +2244,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
 
156
                 else if( bInvocation && pParams && mxInvocation.is() )
 
157
                 {
 
158
                     bool bOLEAutomation = true;
 
159
-                    // TODO: bOLEAutomation = xOLEAutomation.is()
 
160
-
 
161
-                    AutomationNamedArgsSbxArray* pArgNamesArray = NULL;
 
162
-                    if( bOLEAutomation )
 
163
-                        pArgNamesArray = PTR_CAST(AutomationNamedArgsSbxArray,pParams);
 
164
-
 
165
-                    args.realloc( nParamCount );
 
166
-                    Any* pAnyArgs = args.getArray();
 
167
-                    bool bBlockConversionToSmallestType = pINST->IsCompatibility();
 
168
-                    if( pArgNamesArray )
 
169
-                    {
 
170
-                        Sequence< ::rtl::OUString >& rNameSeq = pArgNamesArray->getNames();
 
171
-                        ::rtl::OUString* pNames = rNameSeq.getArray();
 
172
-
 
173
-                        Any aValAny;
 
174
-                        for( i = 0 ; i < nParamCount ; i++ )
 
175
-                        {
 
176
-                            USHORT iSbx = (USHORT)(i+1);
 
177
-
 
178
-                            // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen!
 
179
-                            aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ),
 
180
-                                                        bBlockConversionToSmallestType );
 
181
-
 
182
-                            ::rtl::OUString aParamName = pNames[iSbx];
 
183
-                            if( aParamName.getLength() )
 
184
-                            {
 
185
-                                oleautomation::NamedArgument aNamedArgument;
 
186
-                                aNamedArgument.Name = aParamName;
 
187
-                                aNamedArgument.Value = aValAny;
 
188
-                                pAnyArgs[i] <<= aNamedArgument;
 
189
-                            }
 
190
-                            else
 
191
-                            {
 
192
-                                pAnyArgs[i] = aValAny;
 
193
-                            }
 
194
-                        }
 
195
-                    }
 
196
-                    else
 
197
-                    {
 
198
-                        for( i = 0 ; i < nParamCount ; i++ )
 
199
-                        {
 
200
-                            // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen!
 
201
-                            pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (USHORT)(i+1) ),
 
202
-                                                            bBlockConversionToSmallestType );
 
203
-                        }
 
204
-                    }
 
205
+                                       processAutomationParams( pParams, args, bOLEAutomation, nParamCount );
 
206
                 }
 
207
 
 
208
                 // Methode callen
 
209
@@ -2211,26 +2279,8 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
 
210
                     }
 
211
                     else if( bInvocation && mxInvocation.is() )
 
212
                     {
 
213
-                        Sequence< INT16 > OutParamIndex;
 
214
-                        Sequence< Any > OutParam;
 
215
-                        Any aRetAny = mxInvocation->invoke( pMeth->GetName(), args, OutParamIndex, OutParam );
 
216
-
 
217
-                        // Wert von Uno nach Sbx uebernehmen
 
218
+                                               Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation );
 
219
                         unoToSbxValue( pVar, aRetAny );
 
220
-
 
221
-                        const INT16* pIndices = OutParamIndex.getConstArray();
 
222
-                        UINT32 nLen = OutParamIndex.getLength();
 
223
-                        if( nLen )
 
224
-                        {
 
225
-                            const Any* pNewValues = OutParam.getConstArray();
 
226
-                            for( UINT32 j = 0 ; j < nLen ; j++ )
 
227
-                            {
 
228
-                                INT16 iTarget = pIndices[ j ];
 
229
-                                if( iTarget >= (INT16)nParamCount )
 
230
-                                    break;
 
231
-                                unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pNewValues[ j ] );
 
232
-                            }
 
233
-                        }
 
234
                     }
 
235
 
 
236
                     // #55460, Parameter hier weghauen, da das in unoToSbxValue()
 
237
diff --git basic/source/comp/dim.cxx basic/source/comp/dim.cxx
 
238
index b8b6a54..36cca2c 100644
 
239
--- basic/source/comp/dim.cxx
 
240
+++ basic/source/comp/dim.cxx
 
241
@@ -406,7 +406,10 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
 
242
                 aExpr.Gen();
 
243
                 SbiOpcode eOp_ = pDef->IsNew() ? _CREATE : _TCREATE;
 
244
                 aGen.Gen( eOp_, pDef->GetId(), pDef->GetTypeId() );
 
245
-                aGen.Gen( _SET );
 
246
+                               if ( bVBASupportOn )
 
247
+                                       aGen.Gen( _VBASET );
 
248
+                               else    
 
249
+                                       aGen.Gen( _SET );
 
250
             }
 
251
         }
 
252
         else
 
253
diff --git udkapi/com/sun/star/script/XAutomationInvocation.idl udkapi/com/sun/star/script/XAutomationInvocation.idl
 
254
new file mode 100644
 
255
index 0000000..9dcf61b
 
256
--- /dev/null
 
257
+++ udkapi/com/sun/star/script/XAutomationInvocation.idl
 
258
@@ -0,0 +1,51 @@
 
259
+/*************************************************************************
 
260
+ *
 
261
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
262
+ * 
 
263
+ * Copyright 2008 by Sun Microsystems, Inc.
 
264
+ *
 
265
+ * OpenOffice.org - a multi-platform office productivity suite
 
266
+ *
 
267
+ * $RCSfile: XInvocation2.idl,v $
 
268
+ * $Revision: 1.10 $
 
269
+ *
 
270
+ * This file is part of OpenOffice.org.
 
271
+ *
 
272
+ * OpenOffice.org is free software: you can redistribute it and/or modify
 
273
+ * it under the terms of the GNU Lesser General Public License version 3
 
274
+ * only, as published by the Free Software Foundation.
 
275
+ *
 
276
+ * OpenOffice.org is distributed in the hope that it will be useful,
 
277
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
278
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
279
+ * GNU Lesser General Public License version 3 for more details
 
280
+ * (a copy is included in the LICENSE file that accompanied this code).
 
281
+ *
 
282
+ * You should have received a copy of the GNU Lesser General Public License
 
283
+ * version 3 along with OpenOffice.org.  If not, see
 
284
+ * <http://www.openoffice.org/license.html>
 
285
+ * for a copy of the LGPLv3 License.
 
286
+ *
 
287
+ ************************************************************************/
 
288
+#ifndef __com_sun_star_script_XAutomationInvocation_idl__ 
 
289
+#define __com_sun_star_script_XAutomationInvocation_idl__
 
290
 
291
+#ifndef __com_sun_star_script_XInvocation_idl__ 
 
292
+#include <com/sun/star/script/XInvocation.idl> 
 
293
+#endif 
 
294
 
295
 
296
+ module com {  module sun {  module star {  module script {  
 
297
 
298
+interface XAutomationInvocation: com::sun::star::script::XInvocation
 
299
+{ 
 
300
+    any invokeGetProperty(  [in] string aFunctionName, [in] sequence<any> aParams, [out] sequence<short> aOutParamIndex, [out] sequence<any> aOutParam ) raises( com::sun::star::lang::IllegalArgumentException, com::sun::star::script::CannotConvertException, com::sun::star::reflection::InvocationTargetException );
 
301
+    any invokePutProperty(  [in] string aFunctionName, [in] sequence<any> aParams, [out] sequence<short> aOutParamIndex, [out] sequence<any> aOutParam ) raises( com::sun::star::lang::IllegalArgumentException, com::sun::star::script::CannotConvertException, com::sun::star::reflection::InvocationTargetException );
 
302
 
303
+}; 
 
304
 
305
+//============================================================================= 
 
306
 
307
+}; }; }; };  
 
308
 
309
+#endif 
 
310
diff --git udkapi/com/sun/star/script/makefile.mk udkapi/com/sun/star/script/makefile.mk
 
311
index 52a3214..8b8f53a 100644
 
312
--- udkapi/com/sun/star/script/makefile.mk
 
313
+++ udkapi/com/sun/star/script/makefile.mk
 
314
@@ -85,6 +85,7 @@ IDLFILES=\
 
315
     XScriptEventsAttacher.idl\
 
316
     XDefaultMethod.idl\
 
317
     XDefaultProperty.idl\
 
318
+       XAutomationInvocation.idl\
 
319
     ModuleInfo.idl\
 
320
     ModuleType.idl\
 
321
     XErrorQuery.idl\