1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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 <cppuhelper/implbase.hxx>
41 #include "address.hxx"
42 #include "conditio.hxx"
45 class ScTableConditionalEntry
;
46 class ScValidationData
;
48 struct ScCondFormatEntryItem
50 css::uno::Sequence
< css::sheet::FormulaToken
> maTokens1
;
51 css::uno::Sequence
< css::sheet::FormulaToken
> maTokens2
;
56 OUString maPosStr
; // formula position as text
57 OUString maStyle
; // display name as stored in ScStyleSheet
59 formula::FormulaGrammar::Grammar meGrammar1
; // grammar used with maExpr1
60 formula::FormulaGrammar::Grammar meGrammar2
; // grammar used with maExpr2
61 ScConditionMode meMode
;
63 // Make sure the grammar is initialized for API calls.
64 ScCondFormatEntryItem();
67 class ScTableConditionalFormat
: public cppu::WeakImplHelper
<
68 css::sheet::XSheetConditionalEntries
,
69 css::container::XNameAccess
,
70 css::container::XEnumerationAccess
,
71 css::lang::XUnoTunnel
,
72 css::lang::XServiceInfo
>
75 std::vector
<rtl::Reference
<ScTableConditionalEntry
>> maEntries
;
77 ScTableConditionalEntry
* GetObjectByIndex_Impl(sal_uInt16 nIndex
) const;
78 void AddEntry_Impl(const ScCondFormatEntryItem
& aEntry
);
80 ScTableConditionalFormat() = delete;
81 ScTableConditionalFormat(const ScDocument
* pDoc
, sal_uLong nKey
,
82 SCTAB nTab
, formula::FormulaGrammar::Grammar eGrammar
);
83 virtual ~ScTableConditionalFormat() override
;
85 void FillFormat( ScConditionalFormat
& rFormat
, ScDocument
* pDoc
,
86 formula::FormulaGrammar::Grammar eGrammar
) const;
88 // XSheetConditionalEntries
89 virtual void SAL_CALL
addNew( const css::uno::Sequence
< css::beans::PropertyValue
>& aConditionalEntry
) override
;
90 virtual void SAL_CALL
removeByIndex( sal_Int32 nIndex
) override
;
91 virtual void SAL_CALL
clear() override
;
94 virtual sal_Int32 SAL_CALL
getCount() override
;
95 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
98 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
99 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
100 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
102 // XEnumerationAccess
103 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
104 createEnumeration() override
;
107 virtual css::uno::Type SAL_CALL
getElementType() override
;
108 virtual sal_Bool SAL_CALL
hasElements() override
;
111 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
113 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
114 static ScTableConditionalFormat
* getImplementation(const css::uno::Reference
<css::sheet::XSheetConditionalEntries
>& rObj
);
117 virtual OUString SAL_CALL
getImplementationName() override
;
118 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
119 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
122 class ScTableConditionalEntry
: public cppu::WeakImplHelper
<
123 css::sheet::XSheetCondition2
,
124 css::sheet::XSheetConditionalEntry
,
125 css::lang::XServiceInfo
>
128 ScCondFormatEntryItem aData
;
131 ScTableConditionalEntry() = delete;
132 ScTableConditionalEntry(const ScCondFormatEntryItem
& aItem
);
133 virtual ~ScTableConditionalEntry() override
;
135 void GetData(ScCondFormatEntryItem
& rData
) const;
138 virtual css::sheet::ConditionOperator SAL_CALL
getOperator() override
;
139 virtual sal_Int32 SAL_CALL
getConditionOperator() override
;
140 virtual void SAL_CALL
setOperator( css::sheet::ConditionOperator nOperator
) override
;
141 virtual void SAL_CALL
setConditionOperator( sal_Int32 nOperator
) override
;
142 virtual OUString SAL_CALL
getFormula1() override
;
143 virtual void SAL_CALL
setFormula1( const OUString
& aFormula1
) override
;
144 virtual OUString SAL_CALL
getFormula2() override
;
145 virtual void SAL_CALL
setFormula2( const OUString
& aFormula2
) override
;
146 virtual css::table::CellAddress SAL_CALL
getSourcePosition() override
;
147 virtual void SAL_CALL
setSourcePosition( const css::table::CellAddress
& aSourcePosition
) override
;
149 // XSheetConditionalEntry
150 virtual OUString SAL_CALL
getStyleName() override
;
151 virtual void SAL_CALL
setStyleName( const OUString
& aStyleName
) override
;
154 virtual OUString SAL_CALL
getImplementationName() override
;
155 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
156 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
159 class ScTableValidationObj
: public cppu::WeakImplHelper
<
160 css::sheet::XSheetCondition2
,
161 css::sheet::XMultiFormulaTokens
,
162 css::beans::XPropertySet
,
163 css::lang::XUnoTunnel
,
164 css::lang::XServiceInfo
>
167 SfxItemPropertySet
const aPropSet
;
168 ScConditionMode nMode
;
171 OUString maExprNmsp1
;
172 OUString maExprNmsp2
;
173 formula::FormulaGrammar::Grammar meGrammar1
; // grammar used with aExpr1 and aExpr2
174 formula::FormulaGrammar::Grammar meGrammar2
; // grammar used with aExpr1 and aExpr2
175 css::uno::Sequence
< css::sheet::FormulaToken
> aTokens1
;
176 css::uno::Sequence
< css::sheet::FormulaToken
> aTokens2
;
178 OUString aPosString
; // formula position as text
179 sal_uInt16 nValMode
; // enum ScValidationMode
183 OUString aInputTitle
;
184 OUString aInputMessage
;
186 sal_uInt16 nErrorStyle
; // enum ScValidErrorStyle
187 OUString aErrorTitle
;
188 OUString aErrorMessage
;
190 void ClearData_Impl();
194 ScTableValidationObj() = delete;
195 ScTableValidationObj(const ScDocument
* pDoc
, sal_uLong nKey
,
196 const formula::FormulaGrammar::Grammar eGrammar
);
197 virtual ~ScTableValidationObj() override
;
199 ScValidationData
* CreateValidationData( ScDocument
* pDoc
,
200 formula::FormulaGrammar::Grammar eGrammar
) const;
203 virtual css::sheet::ConditionOperator SAL_CALL
getOperator() override
;
204 virtual sal_Int32 SAL_CALL
getConditionOperator() override
;
205 virtual void SAL_CALL
setOperator( css::sheet::ConditionOperator nOperator
) override
;
206 virtual void SAL_CALL
setConditionOperator( sal_Int32 nOperator
) override
;
207 virtual OUString SAL_CALL
getFormula1() override
;
208 virtual void SAL_CALL
setFormula1( const OUString
& aFormula1
) override
;
209 virtual OUString SAL_CALL
getFormula2() override
;
210 virtual void SAL_CALL
setFormula2( const OUString
& aFormula2
) override
;
211 virtual css::table::CellAddress SAL_CALL
getSourcePosition() override
;
212 virtual void SAL_CALL
setSourcePosition( const css::table::CellAddress
& aSourcePosition
) override
;
214 // XMultiFormulaTokens
215 virtual css::uno::Sequence
< css::sheet::FormulaToken
>
216 SAL_CALL
getTokens( sal_Int32 nIndex
) override
;
217 virtual void SAL_CALL
setTokens( sal_Int32 nIndex
,
218 const css::uno::Sequence
< css::sheet::FormulaToken
>& aTokens
) override
;
219 virtual sal_Int32 SAL_CALL
getCount() override
;
222 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
223 SAL_CALL
getPropertySetInfo() override
;
224 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
225 const css::uno::Any
& aValue
) override
;
226 virtual css::uno::Any SAL_CALL
getPropertyValue(
227 const OUString
& PropertyName
) override
;
228 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
229 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
230 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
231 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
232 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
233 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
234 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
235 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
238 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
240 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
241 static ScTableValidationObj
* getImplementation(const css::uno::Reference
<css::beans::XPropertySet
>& rObj
);
244 virtual OUString SAL_CALL
getImplementationName() override
;
245 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
246 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */