tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / vba / vbarange.hxx
blobd36eb2562e638058cf7209835356dc183cec1fc0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #pragma once
21 #include <ooo/vba/excel/XRange.hpp>
23 #include <com/sun/star/awt/Point.hpp>
24 #include <com/sun/star/sheet/FillDateMode.hpp>
25 #include <com/sun/star/sheet/FillMode.hpp>
26 #include <com/sun/star/sheet/FillDirection.hpp>
27 #include <rtl/ref.hxx>
28 #include "vbaformat.hxx"
29 #include <address.hxx>
30 #include <formula/grammar.hxx>
32 namespace com::sun::star::sheet { class XSheetCellRangeContainer; }
33 namespace com::sun::star::table { class XCell; }
34 namespace com::sun::star::table { class XCellRange; }
35 namespace com::sun::star::table { struct CellRangeAddress; }
36 namespace com::sun::star::lang { class XServiceInfo; }
37 namespace ooo::vba { class XCollection; }
38 namespace ooo::vba::excel { class XComment; }
39 namespace ooo::vba::excel { class XFont; }
41 class SfxItemSet;
42 class ScCellRangesBase;
43 class ScCellRangeObj;
44 class ScDocShell;
45 class ScDocument;
46 class ScRangeList;
47 class ScVbaRangeAreas;
48 class ScVbaValidation;
50 class ArrayVisitor
52 public:
53 virtual void visitNode( sal_Int32 x, sal_Int32 y, const css::uno::Reference< css::table::XCell >& xCell ) = 0;
54 virtual ~ArrayVisitor(){}
57 class ValueSetter : public ArrayVisitor
59 public:
60 virtual bool processValue( const css::uno::Any& aValue, const css::uno::Reference< css::table::XCell >& xCell ) = 0;
64 class ValueGetter : public ArrayVisitor
67 public:
68 virtual void processValue( const css::uno::Any& aValue ) = 0;
69 virtual const css::uno::Any& getValue() const = 0;
72 typedef ScVbaFormat< ov::excel::XRange > ScVbaRange_BASE;
74 enum class RangeValueType { value, value2 };
76 class ScVbaRange : public ScVbaRange_BASE
78 rtl::Reference< ScVbaRangeAreas > m_Areas;
79 css::uno::Reference< ov::XCollection > m_Borders;
80 css::uno::Reference< css::table::XCellRange > mxRange;
81 css::uno::Reference< css::sheet::XSheetCellRangeContainer > mxRanges;
82 bool mbIsRows;
83 bool mbIsColumns;
84 rtl::Reference< ScVbaValidation > m_xValidation;
85 /// @throws css::uno::RuntimeException
86 double getCalcColWidth(const css::table::CellRangeAddress&);
87 /// @throws css::uno::RuntimeException
88 double getCalcRowHeight(const css::table::CellRangeAddress&);
89 void visitArray( ArrayVisitor& visitor );
91 /// @throws css::uno::RuntimeException
92 css::uno::Reference< ov::excel::XRange > getEntireColumnOrRow( bool bColumn );
94 /// @throws css::uno::RuntimeException
95 void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue );
97 /// @throws css::uno::RuntimeException
98 void ClearContents( sal_Int32 nFlags, bool bFireEvent );
100 /// @throws css::uno::RuntimeException
101 css::uno::Any getValue( ValueGetter& rValueGetter );
102 css::uno::Any DoGetValue( RangeValueType eValueType );
103 /// @throws css::uno::RuntimeException
104 void setValue( const css::uno::Any& aValue, ValueSetter& setter );
106 /// @throws css::uno::RuntimeException
107 css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar );
108 /// @throws css::uno::RuntimeException
109 void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar );
111 /// @throws css::uno::RuntimeException
112 css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex );
113 /// @throws css::uno::RuntimeException
114 ScCellRangeObj* getCellRangeObj( );
115 css::uno::Reference< ov::XCollection >& getBorders();
116 /// @throws css::uno::RuntimeException
117 void groupUnGroup( bool bUnGroup );
118 css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious );
119 /// @throws css::script::BasicErrorException
120 css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue);
121 /// @throws css::uno::RuntimeException
122 css::awt::Point getPosition() const;
124 /** Fires a Worksheet_Change event for this range or range list. */
125 void fireChangeEvent();
127 /// @throws css::uno::RuntimeException
128 ScRange obtainRangeEvenIfRangeListIsEmpty( const ScRangeList& rCellRanges ) const;
130 protected:
131 virtual ScCellRangesBase* getCellRangesBase() override;
132 /// @throws css::uno::RuntimeException
133 SfxItemSet* getCurrentDataSet();
134 public:
135 /// @throws css::lang::IllegalArgumentException
136 ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, bool bIsRows = false, bool bIsColumns = false );
137 /// @throws css::lang::IllegalArgumentException
138 /// @throws css::uno::RuntimeException
139 ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, bool bIsRows = false, bool bIsColumns = false );
140 /// @throws css::lang::IllegalArgumentException
141 /// @throws css::uno::RuntimeException
142 ScVbaRange( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
144 /// @throws css::uno::RuntimeException
145 ScDocument& getScDocument();
146 /// @throws css::uno::RuntimeException
147 ScDocShell* getScDocShell();
149 /** Returns the ScVbaRange implementation object for the passed VBA Range object. */
150 static ScVbaRange* getImplementation( const css::uno::Reference< ov::excel::XRange >& rxRange );
152 /// @throws css::uno::RuntimeException
153 css::uno::Reference< css::frame::XModel > getUnoModel();
154 /// @throws css::uno::RuntimeException
155 static css::uno::Reference< css::frame::XModel > getUnoModel( const css::uno::Reference< ov::excel::XRange >& rxRange );
157 /// @throws css::uno::RuntimeException
158 const ScRangeList& getScRangeList();
159 /// @throws css::uno::RuntimeException
160 static const ScRangeList& getScRangeList( const css::uno::Reference< ov::excel::XRange >& rxRange );
162 virtual ~ScVbaRange() override;
163 virtual css::uno::Reference< ov::XHelperInterface > thisHelperIface() override { return this; }
164 bool isSingleCellRange() const;
166 /// @throws css::uno::RuntimeException
167 static css::uno::Reference< ov::excel::XRange > getRangeObjectForName(
168 const css::uno::Reference< css::uno::XComponentContext >& xContext,
169 const OUString& sRangeName, ScDocShell* pDocSh,
170 formula::FormulaGrammar::AddressConvention eConv );
172 /// @throws css::uno::RuntimeException
173 static css::uno::Reference< ov::excel::XRange > CellsHelper(
174 const ScDocument& rDoc,
175 const css::uno::Reference< ov::XHelperInterface >& xParent,
176 const css::uno::Reference< css::uno::XComponentContext >& xContext,
177 const css::uno::Reference< css::table::XCellRange >& xRange,
178 const css::uno::Any &nRowIndex, const css::uno::Any &nColumnIndex );
180 // Attributes
181 virtual css::uno::Any SAL_CALL getValue() override;
182 virtual css::uno::Any SAL_CALL getValue2() override;
183 virtual void SAL_CALL setValue( const css::uno::Any& aValue ) override;
184 virtual void SAL_CALL setValue2( const css::uno::Any& aValue2 ) override;
185 virtual css::uno::Any SAL_CALL getFormula() override;
186 virtual void SAL_CALL setFormula( const css::uno::Any& rFormula ) override;
187 virtual css::uno::Any SAL_CALL getFormulaArray() override;
188 virtual void SAL_CALL setFormulaArray(const css::uno::Any& rFormula) override;
189 virtual css::uno::Any SAL_CALL getFormulaR1C1() override;
190 virtual void SAL_CALL setFormulaR1C1( const css::uno::Any &rFormula ) override;
191 virtual css::uno::Any SAL_CALL getFormulaLocal() override;
192 virtual void SAL_CALL setFormulaLocal( const css::uno::Any &rFormula ) override;
193 virtual css::uno::Any SAL_CALL getFormulaR1C1Local() override;
194 virtual void SAL_CALL setFormulaR1C1Local( const css::uno::Any &rFormula ) override;
195 virtual ::sal_Int32 SAL_CALL getCount() override;
196 virtual ::sal_Int32 SAL_CALL getRow() override;
197 virtual ::sal_Int32 SAL_CALL getColumn() override;
198 virtual OUString SAL_CALL getText() override;
199 using ScVbaRange_BASE::setNumberFormat;
200 virtual void SAL_CALL setNumberFormat( const css::uno::Any& rNumberFormat ) override;
201 virtual css::uno::Any SAL_CALL getNumberFormat() override;
202 virtual void SAL_CALL setMergeCells( const css::uno::Any& bMerge ) override;
203 virtual css::uno::Any SAL_CALL getMergeCells() override;
204 virtual void SAL_CALL setWrapText( const css::uno::Any& bIsWrapped ) override;
205 virtual css::uno::Any SAL_CALL getWrapText() override;
206 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getEntireRow() override;
207 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getEntireColumn() override;
208 virtual css::uno::Reference< ov::excel::XComment > SAL_CALL getComment() override;
209 virtual css::uno::Any SAL_CALL getHidden() override;
210 virtual void SAL_CALL setHidden( const css::uno::Any& _hidden ) override;
211 virtual css::uno::Any SAL_CALL getColumnWidth() override;
212 virtual void SAL_CALL setColumnWidth( const css::uno::Any& _columnwidth ) override;
213 virtual css::uno::Any SAL_CALL getRowHeight() override;
214 virtual void SAL_CALL setRowHeight( const css::uno::Any& _rowheight ) override;
215 virtual css::uno::Any SAL_CALL getWidth() override;
216 virtual css::uno::Any SAL_CALL getHeight() override;
217 virtual css::uno::Any SAL_CALL getTop() override;
218 virtual css::uno::Any SAL_CALL getLeft() override;
220 virtual css::uno::Reference< ov::excel::XName > SAL_CALL getName() override;
221 virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getWorksheet() override;
222 virtual css::uno::Any SAL_CALL getPageBreak() override;
223 virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) override;
224 virtual css::uno::Reference< ov::excel::XValidation > SAL_CALL getValidation() override;
225 virtual css::uno::Any SAL_CALL getPrefixCharacter() override;
226 virtual css::uno::Any SAL_CALL getShowDetail() override;
227 virtual void SAL_CALL setShowDetail(const css::uno::Any& aShowDetail) override;
228 // Methods
229 virtual css::uno::Reference< ov::excel::XComment > SAL_CALL AddComment( const css::uno::Any& Text ) override;
230 virtual void SAL_CALL Clear() override;
231 virtual void SAL_CALL ClearComments() override;
232 virtual void SAL_CALL ClearContents() override;
233 virtual void SAL_CALL ClearFormats() override;
234 virtual css::uno::Any SAL_CALL HasFormula() override;
235 virtual void SAL_CALL FillLeft() override;
236 virtual void SAL_CALL FillRight() override;
237 virtual void SAL_CALL FillUp() override;
238 virtual void SAL_CALL FillDown() override;
239 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Offset( const css::uno::Any &nRowOffset, const css::uno::Any &nColOffset ) override;
240 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL CurrentRegion() override;
241 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL CurrentArray() override;
242 virtual OUString SAL_CALL Characters( const css::uno::Any& nIndex, const css::uno::Any& nCount ) override;
244 virtual OUString SAL_CALL Address( const css::uno::Any& RowAbsolute, const css::uno::Any& ColumnAbsolute, const css::uno::Any& ReferenceStyle, const css::uno::Any& External, const css::uno::Any& RelativeTo ) override;
246 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any &nRow, const css::uno::Any &nCol ) override;
247 virtual void SAL_CALL Select() override;
248 virtual void SAL_CALL Activate() override;
249 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Rows( const css::uno::Any& nIndex ) override;
250 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns( const css::uno::Any &nIndex ) override;
251 virtual void SAL_CALL Copy( const css::uno::Any& Destination ) override;
252 virtual void SAL_CALL Cut( const css::uno::Any& Destination ) override;
253 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Resize( const css::uno::Any& RowSize, const css::uno::Any& ColumnSize ) override;
254 virtual css::uno::Reference< ov::excel::XFont > SAL_CALL Font() override;
255 virtual css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) override ;
256 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) override;
257 /// @throws css::uno::RuntimeException
258 css::uno::Reference< ov::excel::XRange > Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2, bool bForceUseInpuRangeTab );
259 virtual css::uno::Any SAL_CALL getCellRange( ) override;
260 /// @throws css::uno::RuntimeException
261 static css::uno::Any getCellRange( const css::uno::Reference< ov::excel::XRange >& rxRange );
262 virtual void SAL_CALL PasteSpecial( const css::uno::Any& Paste, const css::uno::Any& Operation, const css::uno::Any& SkipBlanks, const css::uno::Any& Transpose ) override;
263 virtual sal_Bool SAL_CALL Replace( const OUString& What, const OUString& Replacement, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat, const css::uno::Any& ReplaceFormat ) override;
264 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Find( const css::uno::Any& What, const css::uno::Any& After, const css::uno::Any& LookIn, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& SearchDirection, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat ) override;
265 virtual void SAL_CALL Sort( const css::uno::Any& Key1, const css::uno::Any& Order1, const css::uno::Any& Key2, const css::uno::Any& Type, const css::uno::Any& Order2, const css::uno::Any& Key3, const css::uno::Any& Order3, const css::uno::Any& Header, const css::uno::Any& OrderCustom, const css::uno::Any& MatchCase, const css::uno::Any& Orientation, const css::uno::Any& SortMethod, const css::uno::Any& DataOption1, const css::uno::Any& DataOption2, const css::uno::Any& DataOption3 ) override;
266 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL End( ::sal_Int32 Direction ) override;
267 virtual css::uno::Reference< ov::excel::XCharacters > SAL_CALL characters( const css::uno::Any& Start, const css::uno::Any& Length ) override;
268 virtual void SAL_CALL Delete( const css::uno::Any& Shift ) override;
269 virtual css::uno::Any SAL_CALL Areas( const css::uno::Any& ) override;
270 virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& ) override;
271 virtual css::uno::Any SAL_CALL BorderAround( const css::uno::Any& LineStyle,
272 const css::uno::Any& Weight, const css::uno::Any& ColorIndex, const css::uno::Any& Color ) override;
273 virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex ) override;
275 virtual void SAL_CALL AutoFilter( const css::uno::Any& Field, const css::uno::Any& Criteria1, const css::uno::Any& Operator, const css::uno::Any& Criteria2, const css::uno::Any& VisibleDropDown ) override;
276 virtual void SAL_CALL Insert( const css::uno::Any& Shift, const css::uno::Any& CopyOrigin ) override;
277 virtual void SAL_CALL Autofit() override;
278 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 ) override;
279 virtual void SAL_CALL AutoFill( const css::uno::Reference< ov::excel::XRange >& Destination, const css::uno::Any& Type ) override ;
280 void SAL_CALL Calculate( ) override;
281 virtual void SAL_CALL AutoOutline( ) override;
282 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Item( const css::uno::Any& row, const css::uno::Any& column ) override;
283 virtual void SAL_CALL ClearOutline( ) override;
284 virtual void SAL_CALL Ungroup( ) override;
285 virtual void SAL_CALL Group( ) override;
286 virtual void SAL_CALL Merge( const css::uno::Any& Across ) override;
287 virtual void SAL_CALL UnMerge( ) override;
288 virtual css::uno::Any SAL_CALL getStyle() override;
289 virtual void SAL_CALL setStyle( const css::uno::Any& _style ) override;
290 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Next() override;
291 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Previous() override;
292 virtual void SAL_CALL RemoveSubtotal( ) override;
293 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL MergeArea() override;
294 virtual void SAL_CALL Subtotal( ::sal_Int32 GroupBy, ::sal_Int32 Function, const css::uno::Sequence< ::sal_Int32 >& TotalList, const css::uno::Any& Replace, const css::uno::Any& PageBreaks, const css::uno::Any& SummaryBelowData ) override;
295 virtual void SAL_CALL ExportAsFixedFormat(const css::uno::Any& Type, const css::uno::Any& FileName, const css::uno::Any& Quality,
296 const css::uno::Any& IncludeDocProperties, const css::uno::Any& IgnorePrintAreas, const css::uno::Any& From,
297 const css::uno::Any& To, const css::uno::Any& OpenAfterPublish, const css::uno::Any& FixedFormatExtClassPtr) override;
299 // XEnumerationAccess
300 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
301 // XElementAccess
302 virtual css::uno::Type SAL_CALL getElementType() override
304 return cppu::UnoType<ov::excel::XRange>::get();
307 virtual sal_Bool SAL_CALL hasElements() override;
308 // XDefaultMethod
309 OUString SAL_CALL getDefaultMethodName( ) override;
310 // XDefaultProperty
311 OUString SAL_CALL getDefaultPropertyName( ) override { return u"Value"_ustr; }
313 // #TODO completely rewrite ScVbaRange, it's become a hackfest
314 // it needs to be closer to ScCellRangeBase in that the underlying
315 // object model should probably be a ScRangelst.
316 // * would be nice to be able to construct a range from an address only
317 // * or a list of address ( multi-area )
318 // * object should be a lightweight as possible
319 // * we shouldn't need hacks like this below
320 /// @throws css::uno::RuntimeException
321 static css::uno::Reference< ov::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 );
322 static bool getCellRangesForAddress(ScRefFlags &rResFlags, std::u16string_view sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention eConv, char cDelimiter );
323 virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< ov::excel::XRange >& ChangingCell ) override;
324 virtual css::uno::Reference< ov::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) override;
325 // XErrorQuery
326 virtual sal_Bool SAL_CALL hasError( ) override;
327 // XHelperInterface
328 virtual OUString getServiceImplName() override;
329 virtual css::uno::Sequence<OUString> getServiceNames() override;
332 /// @throws css::uno::RuntimeException
333 bool getScRangeListForAddress( const OUString& sName, ScDocShell* pDocSh, const ScRange& refRange,
334 ScRangeList& aCellRanges,
335 formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1 );
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */