Bump version to 6.4-15
[LibreOffice.git] / sc / inc / fmtuno.hxx
blobca259517f9dabb4bbf41ba2603b9f8c0f8e2625d
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 .
20 #ifndef INCLUDED_SC_INC_FMTUNO_HXX
21 #define INCLUDED_SC_INC_FMTUNO_HXX
23 #include <vector>
25 #include <formula/grammar.hxx>
26 #include <rtl/ref.hxx>
27 #include <svl/itemprop.hxx>
28 #include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
29 #include <com/sun/star/sheet/XSheetCondition2.hpp>
30 #include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
38 #include <com/sun/star/sheet/FormulaToken.hpp>
39 #include <comphelper/servicehelper.hxx>
40 #include <cppuhelper/implbase.hxx>
42 #include "address.hxx"
43 #include "conditio.hxx"
45 class ScDocument;
46 class ScTableConditionalEntry;
47 class ScValidationData;
49 struct ScCondFormatEntryItem
51 css::uno::Sequence< css::sheet::FormulaToken > maTokens1;
52 css::uno::Sequence< css::sheet::FormulaToken > maTokens2;
53 OUString maExpr1;
54 OUString maExpr2;
55 OUString maExprNmsp1;
56 OUString maExprNmsp2;
57 OUString maPosStr; // formula position as text
58 OUString maStyle; // display name as stored in ScStyleSheet
59 ScAddress maPos;
60 formula::FormulaGrammar::Grammar meGrammar1; // grammar used with maExpr1
61 formula::FormulaGrammar::Grammar meGrammar2; // grammar used with maExpr2
62 ScConditionMode meMode;
64 // Make sure the grammar is initialized for API calls.
65 ScCondFormatEntryItem();
68 class ScTableConditionalFormat final : public cppu::WeakImplHelper<
69 css::sheet::XSheetConditionalEntries,
70 css::container::XNameAccess,
71 css::container::XEnumerationAccess,
72 css::lang::XUnoTunnel,
73 css::lang::XServiceInfo >
75 private:
76 std::vector<rtl::Reference<ScTableConditionalEntry>> maEntries;
78 ScTableConditionalEntry* GetObjectByIndex_Impl(sal_uInt16 nIndex) const;
79 void AddEntry_Impl(const ScCondFormatEntryItem& aEntry);
80 public:
81 ScTableConditionalFormat() = delete;
82 ScTableConditionalFormat(const ScDocument* pDoc, sal_uLong nKey,
83 SCTAB nTab, formula::FormulaGrammar::Grammar eGrammar);
84 virtual ~ScTableConditionalFormat() override;
86 void FillFormat( ScConditionalFormat& rFormat, ScDocument* pDoc,
87 formula::FormulaGrammar::Grammar eGrammar) const;
89 // XSheetConditionalEntries
90 virtual void SAL_CALL addNew( const css::uno::Sequence< css::beans::PropertyValue >& aConditionalEntry ) override;
91 virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override;
92 virtual void SAL_CALL clear() override;
94 // XIndexAccess
95 virtual sal_Int32 SAL_CALL getCount() override;
96 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
98 // XNameAccess
99 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
100 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
101 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
103 // XEnumerationAccess
104 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
105 createEnumeration() override;
107 // XElementAccess
108 virtual css::uno::Type SAL_CALL getElementType() override;
109 virtual sal_Bool SAL_CALL hasElements() override;
111 // XUnoTunnel
112 UNO3_GETIMPLEMENTATION_DECL(ScTableConditionalFormat)
114 // XServiceInfo
115 virtual OUString SAL_CALL getImplementationName() override;
116 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
117 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
120 class ScTableConditionalEntry : public cppu::WeakImplHelper<
121 css::sheet::XSheetCondition2,
122 css::sheet::XSheetConditionalEntry,
123 css::lang::XServiceInfo >
125 private:
126 ScCondFormatEntryItem aData;
128 public:
129 ScTableConditionalEntry() = delete;
130 ScTableConditionalEntry(const ScCondFormatEntryItem& aItem);
131 virtual ~ScTableConditionalEntry() override;
133 void GetData(ScCondFormatEntryItem& rData) const;
135 // XSheetCondition
136 virtual css::sheet::ConditionOperator SAL_CALL getOperator() override;
137 virtual sal_Int32 SAL_CALL getConditionOperator() override;
138 virtual void SAL_CALL setOperator( css::sheet::ConditionOperator nOperator ) override;
139 virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator ) override;
140 virtual OUString SAL_CALL getFormula1() override;
141 virtual void SAL_CALL setFormula1( const OUString& aFormula1 ) override;
142 virtual OUString SAL_CALL getFormula2() override;
143 virtual void SAL_CALL setFormula2( const OUString& aFormula2 ) override;
144 virtual css::table::CellAddress SAL_CALL getSourcePosition() override;
145 virtual void SAL_CALL setSourcePosition( const css::table::CellAddress& aSourcePosition ) override;
147 // XSheetConditionalEntry
148 virtual OUString SAL_CALL getStyleName() override;
149 virtual void SAL_CALL setStyleName( const OUString& aStyleName ) override;
151 // XServiceInfo
152 virtual OUString SAL_CALL getImplementationName() override;
153 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
154 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
157 class ScTableValidationObj final : public cppu::WeakImplHelper<
158 css::sheet::XSheetCondition2,
159 css::sheet::XMultiFormulaTokens,
160 css::beans::XPropertySet,
161 css::lang::XUnoTunnel,
162 css::lang::XServiceInfo >
164 private:
165 SfxItemPropertySet const aPropSet;
166 ScConditionMode nMode;
167 OUString aExpr1;
168 OUString aExpr2;
169 OUString maExprNmsp1;
170 OUString maExprNmsp2;
171 formula::FormulaGrammar::Grammar meGrammar1; // grammar used with aExpr1 and aExpr2
172 formula::FormulaGrammar::Grammar meGrammar2; // grammar used with aExpr1 and aExpr2
173 css::uno::Sequence< css::sheet::FormulaToken > aTokens1;
174 css::uno::Sequence< css::sheet::FormulaToken > aTokens2;
175 ScAddress aSrcPos;
176 OUString aPosString; // formula position as text
177 sal_uInt16 nValMode; // enum ScValidationMode
178 bool bIgnoreBlank;
179 sal_Int16 nShowList;
180 bool bShowInput;
181 OUString aInputTitle;
182 OUString aInputMessage;
183 bool bShowError;
184 sal_uInt16 nErrorStyle; // enum ScValidErrorStyle
185 OUString aErrorTitle;
186 OUString aErrorMessage;
188 void ClearData_Impl();
190 public:
192 ScTableValidationObj() = delete;
193 ScTableValidationObj(const ScDocument* pDoc, sal_uLong nKey,
194 const formula::FormulaGrammar::Grammar eGrammar);
195 virtual ~ScTableValidationObj() override;
197 ScValidationData* CreateValidationData( ScDocument* pDoc,
198 formula::FormulaGrammar::Grammar eGrammar ) const;
200 // XSheetCondition
201 virtual css::sheet::ConditionOperator SAL_CALL getOperator() override;
202 virtual sal_Int32 SAL_CALL getConditionOperator() override;
203 virtual void SAL_CALL setOperator( css::sheet::ConditionOperator nOperator ) override;
204 virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator ) override;
205 virtual OUString SAL_CALL getFormula1() override;
206 virtual void SAL_CALL setFormula1( const OUString& aFormula1 ) override;
207 virtual OUString SAL_CALL getFormula2() override;
208 virtual void SAL_CALL setFormula2( const OUString& aFormula2 ) override;
209 virtual css::table::CellAddress SAL_CALL getSourcePosition() override;
210 virtual void SAL_CALL setSourcePosition( const css::table::CellAddress& aSourcePosition ) override;
212 // XMultiFormulaTokens
213 virtual css::uno::Sequence< css::sheet::FormulaToken >
214 SAL_CALL getTokens( sal_Int32 nIndex ) override;
215 virtual void SAL_CALL setTokens( sal_Int32 nIndex,
216 const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override;
217 virtual sal_Int32 SAL_CALL getCount() override;
219 // XPropertySet
220 virtual css::uno::Reference< css::beans::XPropertySetInfo >
221 SAL_CALL getPropertySetInfo() override;
222 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
223 const css::uno::Any& aValue ) override;
224 virtual css::uno::Any SAL_CALL getPropertyValue(
225 const OUString& PropertyName ) override;
226 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
227 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
228 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
229 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
230 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
231 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
232 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
233 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
235 // XUnoTunnel
236 UNO3_GETIMPLEMENTATION_DECL(ScTableValidationObj)
238 // XServiceInfo
239 virtual OUString SAL_CALL getImplementationName() override;
240 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
241 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
244 #endif
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */