xref: /trunk/main/sc/source/ui/vba/vbaworksheet.hxx (revision 7a7771fb4d20b857459c676939e2cc2f4dec9635)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef SC_VBA_WORKSHEET_HXX
24 #define SC_VBA_WORKSHEET_HXX
25 
26 #include <cppuhelper/implbase2.hxx>
27 #include <comphelper/unwrapargs.hxx>
28 
29 #include <com/sun/star/sheet/XSpreadsheet.hpp>
30 #include <com/sun/star/script/XInvocation.hpp>
31 #include <ooo/vba/excel/XWorksheet.hpp>
32 #include <ooo/vba/excel/XComments.hpp>
33 #include <ooo/vba/excel/XRange.hpp>
34 #include <com/sun/star/lang/XEventListener.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
36 #include <com/sun/star/frame/XModel.hpp>
37 #include <ooo/vba/excel/XOutline.hpp>
38 #include <ooo/vba/excel/XPageSetup.hpp>
39 #include <ooo/vba/excel/XHPageBreaks.hpp>
40 #include <ooo/vba/excel/XVPageBreaks.hpp>
41 
42 #include <vbahelper/vbahelperinterface.hxx>
43 #include "address.hxx"
44 
45 namespace ooo { namespace vba { namespace excel {
46     class XChartObjects;
47     class XHyperlinks;
48 } } }
49 
50 class ScVbaSheetObjectsBase;
51 
52 typedef InheritedHelperInterfaceImpl1< ov::excel::XWorksheet >  WorksheetImpl_BASE;
53 
54 class ScVbaWorksheet : public WorksheetImpl_BASE
55 {
56     css::uno::Reference< css::sheet::XSpreadsheet > mxSheet;
57     css::uno::Reference< css::frame::XModel > mxModel;
58     css::uno::Reference< ov::excel::XChartObjects > mxCharts;
59     css::uno::Reference< ov::excel::XHyperlinks > mxHlinks;
60     ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons;
61     bool mbVeryHidden;
62 
63 // MS Excel VBA: Internal helper - gets a worksheet by offset.
64 // Status: internal helper
65     css::uno::Reference< ov::excel::XWorksheet > getSheetAtOffset(SCTAB offset);
66 // MS Excel VBA: Internal helper - gets the entire used range of the sheet.
67 // Status: internal helper
68     css::uno::Reference< ov::excel::XRange > getSheetRange();
69 
70 // MS Excel VBA: Internal helper - gets form controls of the sheet.
71 // Status: internal helper
72     css::uno::Reference< css::container::XNameAccess > getFormControls();
73 // MS Excel VBA: Internal helper - gets a control shape by name.
74 // Status: internal helper
75     css::uno::Any getControlShape( const rtl::OUString& sName );
76 
77 // MS Excel VBA: Internal helper - gets first database range properties.
78 // Status: internal helper
79     css::uno::Reference< css::beans::XPropertySet > getFirstDBRangeProperties();
80 
81 protected:
82 
83 // MS Excel VBA: Protected constructor (internal use only).
84 // Status: internal helper
85     ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent,  const css::uno::Reference< css::uno::XComponentContext >& xContext );
86 public:
87 // MS Excel VBA: Constructor taking a spreadsheet and model.
88 // Status: implemented
89     ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent,
90         const css::uno::Reference< css::uno::XComponentContext >& xContext,
91         const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet,
92         const css::uno::Reference< css::frame::XModel >& xModel )  ;
93 // MS Excel VBA: Constructor taking arguments sequence (for UNO create).
94 // Status: implemented
95     ScVbaWorksheet( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
96 
97 // MS Excel VBA: Destructor.
98 // Status: implemented
99     virtual ~ScVbaWorksheet();
100 
101 // MS Excel VBA: Gets the underlying model object.
102 // Status: implemented
getModel()103     virtual css::uno::Reference< css::frame::XModel > getModel()
104     { return mxModel; }
105 // MS Excel VBA: Gets the underlying spreadsheet object.
106 // Status: implemented
getSheet()107     virtual css::uno::Reference< css::sheet::XSpreadsheet > getSheet()
108     { return mxSheet; }
109 
110     // Attributes
111 // MS Excel VBA: Gets the name of the worksheet.
112 // Status: implemented
113     virtual ::rtl::OUString SAL_CALL getName();
114 // MS Excel VBA: Sets the name of the worksheet.
115 // Status: implemented
116     virtual void SAL_CALL setName( const ::rtl::OUString &rName );
117 // MS Excel VBA: Gets the visibility of the worksheet.
118 // Status: implemented
119     virtual sal_Int32 SAL_CALL getVisible();
120 // MS Excel VBA: Sets the visibility of the worksheet.
121 // Status: implemented
122     virtual void SAL_CALL setVisible( sal_Int32 nVisible );
123 // MS Excel VBA: Gets the standard column width.
124 // Status: implemented
125     virtual ::sal_Int32 SAL_CALL getStandardWidth();
126 // MS Excel VBA: Gets the standard row height.
127 // Status: implemented
128     virtual ::sal_Int32 SAL_CALL getStandardHeight();
129 // MS Excel VBA: Gets whether the worksheet is in protection mode.
130 // Status: implemented
131     virtual ::sal_Bool SAL_CALL getProtectionMode();
132 // MS Excel VBA: Gets whether contents are protected.
133 // Status: implemented
134     virtual ::sal_Bool SAL_CALL getProtectContents();
135 // MS Excel VBA: Gets whether drawing objects are protected.
136 // Status: implemented
137     virtual ::sal_Bool SAL_CALL getProtectDrawingObjects();
138 // MS Excel VBA: Gets whether scenarios are protected.
139 // Status: implemented
140     virtual ::sal_Bool SAL_CALL getProtectScenarios();
141 // MS Excel VBA: Returns the used range of the worksheet.
142 // Status: implemented
143     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getUsedRange() ;
144 // MS Excel VBA: Returns a ChartObject by index.
145 // Status: stubbed - not fully implemented in Calc
146     virtual css::uno::Any SAL_CALL ChartObjects( const css::uno::Any& Index );
147 // MS Excel VBA: Returns the outline for the worksheet.
148 // Status: stubbed - not fully implemented in Calc
149     virtual css::uno::Reference< ov::excel::XOutline > SAL_CALL Outline( );
150 // MS Excel VBA: Returns the page setup for the worksheet.
151 // Status: stubbed - not fully implemented in Calc
152     virtual css::uno::Reference< ov::excel::XPageSetup > SAL_CALL PageSetup( );
153 // MS Excel VBA: Returns a HPageBreaks collection.
154 // Status: stubbed - not fully implemented in Calc
155     virtual css::uno::Any SAL_CALL HPageBreaks( const css::uno::Any& aIndex );
156 // MS Excel VBA: Returns a VPageBreaks collection.
157 // Status: stubbed - not fully implemented in Calc
158     virtual css::uno::Any SAL_CALL VPageBreaks( const css::uno::Any& aIndex );
159 // MS Excel VBA: Returns the next worksheet.
160 // Status: implemented
161     virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getNext();
162 // MS Excel VBA: Returns the previous worksheet.
163 // Status: implemented
164     virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getPrevious();
165 // MS Excel VBA: Returns the index of the worksheet.
166 // Status: implemented
167     virtual sal_Int16 SAL_CALL getIndex();
168 // MS Excel VBA: Gets the selection enabled state for the worksheet.
169 // Status: implemented
170     virtual sal_Int32 SAL_CALL getEnableSelection();
171 // MS Excel VBA: Sets the selection enabled state for the worksheet.
172 // Status: implemented
173     virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection );
174 // MS Excel VBA: Gets whether AutoFilter mode is enabled.
175 // Status: implemented
176     virtual sal_Bool SAL_CALL getAutoFilterMode();
177 // MS Excel VBA: Sets whether AutoFilter mode is enabled.
178 // Status: implemented
179     virtual void SAL_CALL setAutoFilterMode( sal_Bool bAutoFilterMode );
180 
181     // Methods
182 // MS Excel VBA: Activates the worksheet.
183 // Status: implemented
184     virtual void SAL_CALL Activate();
185 // MS Excel VBA: Selects the worksheet.
186 // Status: implemented
187     virtual void SAL_CALL Select();
188 // MS Excel VBA: Returns a Range object representing a cell or range.
189 // Status: implemented
190     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 );
191 // MS Excel VBA: Moves the worksheet to a new location.
192 // Status: implemented
193     virtual void SAL_CALL Move( const css::uno::Any& Before, const css::uno::Any& After ) ;
194 // MS Excel VBA: Copies the worksheet to a new location.
195 // Status: implemented
196     virtual void SAL_CALL Copy( const css::uno::Any& Before, const css::uno::Any& After );
197 // MS Excel VBA: Pastes clipboard contents to the destination.
198 // Status: implemented
199     virtual void SAL_CALL Paste( const css::uno::Any& Destination, const css::uno::Any& Link );
200 // MS Excel VBA: Deletes the worksheet.
201 // Status: implemented
202     virtual void SAL_CALL Delete(  );
203 // MS Excel VBA: Protects the worksheet with a password and options.
204 // Status: implemented - partial (subset of options supported)
205     virtual void SAL_CALL Protect( const css::uno::Any& Password, const css::uno::Any& DrawingObjects, const css::uno::Any& Contents, const css::uno::Any& Scenarios, const css::uno::Any& UserInterfaceOnly );
206 // MS Excel VBA: Removes protection from the worksheet.
207 // Status: implemented
208     virtual void SAL_CALL Unprotect( const css::uno::Any& Password );
209 
210 // MS Excel VBA: Calculates all open workbooks and worksheets.
211 // Status: implemented
212     virtual void SAL_CALL Calculate(  );
213 // MS Excel VBA: Checks spelling of the worksheet text.
214 // Status: implemented
215     virtual void SAL_CALL CheckSpelling( const css::uno::Any& CustomDictionary,const css::uno::Any& IgnoreUppercase,const css::uno::Any& AlwaysSuggest, const css::uno::Any& SpellingLang );
216     // Hacks (?)
217 // MS Excel VBA: Returns a single cell or cell range.
218 // Status: implemented
219     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any &nRow, const css::uno::Any &nCol );
220 // MS Excel VBA: Returns a single row or row range.
221 // Status: implemented
222     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Rows(const css::uno::Any& aIndex );
223 // MS Excel VBA: Returns a single column or column range.
224 // Status: implemented
225     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns(const css::uno::Any& aIndex );
226 
227 // MS Excel VBA: Evaluates an Excel formula expression.
228 // Status: implemented
229     virtual css::uno::Any SAL_CALL Evaluate( const ::rtl::OUString& Name );
230 // MS Excel VBA: Returns a PivotTable by index.
231 // Status: stubbed - not fully implemented in Calc
232     virtual css::uno::Any SAL_CALL PivotTables( const css::uno::Any& Index );
233 // MS Excel VBA: Returns a Comment by index.
234 // Status: implemented
235     virtual css::uno::Any SAL_CALL Comments( const css::uno::Any& Index );
236 // MS Excel VBA: Returns a Hyperlink by index.
237 // Status: implemented
238     virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex );
239 // MS Excel VBA: Returns a Name object by index.
240 // Status: implemented
241     virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex );
242 
243 // MS Excel VBA: Returns an OLEObject by index.
244 // Status: stubbed - not fully implemented in Calc
245     virtual css::uno::Any SAL_CALL OLEObjects( const css::uno::Any& Index );
246 // MS Excel VBA: Returns a Shape object by index.
247 // Status: implemented
248     virtual css::uno::Any SAL_CALL Shapes( const css::uno::Any& aIndex );
249 
250 // MS Excel VBA: Returns Button controls on the worksheet.
251 // Status: not implemented in Calc
252     virtual css::uno::Any SAL_CALL Buttons( const css::uno::Any& rIndex );
253 // MS Excel VBA: Returns CheckBox controls on the worksheet.
254 // Status: not implemented in Calc
255     virtual css::uno::Any SAL_CALL CheckBoxes( const css::uno::Any& rIndex );
256 // MS Excel VBA: Returns DropDown controls on the worksheet.
257 // Status: not implemented in Calc
258     virtual css::uno::Any SAL_CALL DropDowns( const css::uno::Any& rIndex );
259 // MS Excel VBA: Returns GroupBox controls on the worksheet.
260 // Status: not implemented in Calc
261     virtual css::uno::Any SAL_CALL GroupBoxes( const css::uno::Any& rIndex );
262 // MS Excel VBA: Returns Label controls on the worksheet.
263 // Status: not implemented in Calc
264     virtual css::uno::Any SAL_CALL Labels( const css::uno::Any& rIndex );
265 // MS Excel VBA: Returns ListBox controls on the worksheet.
266 // Status: not implemented in Calc
267     virtual css::uno::Any SAL_CALL ListBoxes( const css::uno::Any& rIndex );
268 // MS Excel VBA: Returns OptionButton controls on the worksheet.
269 // Status: not implemented in Calc
270     virtual css::uno::Any SAL_CALL OptionButtons( const css::uno::Any& rIndex );
271 // MS Excel VBA: Returns ScrollBars control objects on the worksheet.
272 // Status: not implemented in Calc
273     virtual css::uno::Any SAL_CALL ScrollBars( const css::uno::Any& rIndex );
274 // MS Excel VBA: Returns Spinners control objects on the worksheet.
275 // Status: not implemented in Calc
276     virtual css::uno::Any SAL_CALL Spinners( const css::uno::Any& rIndex );
277 
278 // MS Excel VBA: Sets whether calculation is enabled on the worksheet.
279 // Status: implemented
280     virtual void SAL_CALL setEnableCalculation( ::sal_Bool EnableCalculation );
281 // MS Excel VBA: Gets whether calculation is enabled on the worksheet.
282 // Status: implemented
283     virtual ::sal_Bool SAL_CALL getEnableCalculation(  );
284 // MS Excel VBA: Displays the data form for entering/editing data.
285 // Status: implemented
286     virtual void SAL_CALL ShowDataForm(  );
287     // XInvocation
288 // MS Excel VBA: Returns introspection access (XInvocation).
289 // Status: implemented
290     virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection(  );
291 // MS Excel VBA: Invokes a method by name (XInvocation).
292 // Status: implemented
293     virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam );
294 // MS Excel VBA: Sets the value of a property by name.
295 // Status: implemented
296     virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue );
297 // MS Excel VBA: Gets the value of a property by name.
298 // Status: implemented
299     virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName );
300 // MS Excel VBA: Indicates if a method exists on this object.
301 // Status: implemented
302     virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName );
303 // MS Excel VBA: Indicates if a property exists on this object.
304 // Status: implemented
305     virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName );
306     // CodeName
307 // MS Excel VBA: Returns the code name of the worksheet.
308 // Status: implemented
309     virtual rtl::OUString SAL_CALL getCodeName();
310 // MS Excel VBA: Returns the sheet ID for this worksheet.
311 // Status: implemented
312     sal_Int16 getSheetID();
313 
314 // MS Excel VBA: Prints the worksheet.
315 // Status: implemented
316     virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, const css::uno::Any& IgnorePrintAreas );
317     // XHelperInterface
318 // MS Excel VBA: Returns the implementation service name for UNO.
319 // Status: implemented
320     virtual rtl::OUString& getServiceImplName();
321 // MS Excel VBA: Returns the list of supported service names for UNO.
322 // Status: implemented
323     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
324 };
325 
326 #endif /* SC_VBA_WORKSHEET_HXX */
327