LibreOffice Module sc (master)  1
fmtuno.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_FMTUNO_HXX
21 #define INCLUDED_SC_INC_FMTUNO_HXX
22 
23 #include <vector>
24 
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>
36 
37 #include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
38 #include <com/sun/star/sheet/FormulaToken.hpp>
40 #include <cppuhelper/implbase.hxx>
41 
42 #include "address.hxx"
43 #include "conditio.hxx"
44 
45 class ScDocument;
47 class ScValidationData;
48 
50 {
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
60  formula::FormulaGrammar::Grammar meGrammar1; // grammar used with maExpr1
61  formula::FormulaGrammar::Grammar meGrammar2; // grammar used with maExpr2
63 
64  // Make sure the grammar is initialized for API calls.
66 };
67 
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 >
74 {
75 private:
76  std::vector<rtl::Reference<ScTableConditionalEntry>> maEntries;
77 
78  ScTableConditionalEntry* GetObjectByIndex_Impl(sal_uInt16 nIndex) const;
79  void AddEntry_Impl(const ScCondFormatEntryItem& aEntry);
80 public:
81  ScTableConditionalFormat() = delete;
84  virtual ~ScTableConditionalFormat() override;
85 
86  void FillFormat( ScConditionalFormat& rFormat, ScDocument& rDoc,
87  formula::FormulaGrammar::Grammar eGrammar) const;
88 
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;
93 
94  // XIndexAccess
95  virtual sal_Int32 SAL_CALL getCount() override;
96  virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
97 
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;
102 
103  // XEnumerationAccess
104  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
105  createEnumeration() override;
106 
107  // XElementAccess
108  virtual css::uno::Type SAL_CALL getElementType() override;
109  virtual sal_Bool SAL_CALL hasElements() override;
110 
111  // XUnoTunnel
113 
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;
118 };
119 
120 class ScTableConditionalEntry : public cppu::WeakImplHelper<
121  css::sheet::XSheetCondition2,
122  css::sheet::XSheetConditionalEntry,
123  css::lang::XServiceInfo >
124 {
125 private:
127 
128 public:
129  ScTableConditionalEntry() = delete;
131  virtual ~ScTableConditionalEntry() override;
132 
133  void GetData(ScCondFormatEntryItem& rData) const;
134 
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;
146 
147  // XSheetConditionalEntry
148  virtual OUString SAL_CALL getStyleName() override;
149  virtual void SAL_CALL setStyleName( const OUString& aStyleName ) override;
150 
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;
155 };
156 
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 >
163 {
164 private:
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;
176  OUString aPosString; // formula position as text
177  sal_uInt16 nValMode; // enum ScValidationMode
179  sal_Int16 nShowList;
181  OUString aInputTitle;
182  OUString aInputMessage;
184  sal_uInt16 nErrorStyle; // enum ScValidErrorStyle
185  OUString aErrorTitle;
186  OUString aErrorMessage;
187 
188  void ClearData_Impl();
189 
190 public:
191 
192  ScTableValidationObj() = delete;
193  ScTableValidationObj(const ScDocument& rDoc, sal_uLong nKey,
194  const formula::FormulaGrammar::Grammar eGrammar);
195  virtual ~ScTableValidationObj() override;
196 
197  ScValidationData* CreateValidationData( ScDocument& rDoc,
198  formula::FormulaGrammar::Grammar eGrammar ) const;
199 
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;
211 
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;
218 
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;
234 
235  // XUnoTunnel
237 
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;
242 };
243 
244 #endif
245 
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: fmtuno.cxx:404
formula::FormulaGrammar::Grammar meGrammar1
Definition: fmtuno.hxx:171
SfxItemPropertySet aPropSet
Definition: fmtuno.hxx:165
ScConditionMode nMode
Definition: fmtuno.hxx:166
ScConditionMode meMode
Definition: fmtuno.hxx:62
css::uno::Sequence< css::sheet::FormulaToken > aTokens1
Definition: fmtuno.hxx:173
OUString aPosString
Definition: fmtuno.hxx:176
sal_uIntPtr sal_uLong
void AddEntry_Impl(const ScCondFormatEntryItem &aEntry)
Definition: fmtuno.cxx:237
sal_uInt16 nValMode
Definition: fmtuno.hxx:177
OUString aInputTitle
Definition: fmtuno.hxx:181
#define UNO3_GETIMPLEMENTATION_DECL(classname)
virtual sal_Int32 SAL_CALL getCount() override
Definition: fmtuno.cxx:367
formula::FormulaGrammar::Grammar meGrammar2
Definition: fmtuno.hxx:61
OUString maExprNmsp1
Definition: fmtuno.hxx:169
virtual ~ScTableConditionalFormat() override
Definition: fmtuno.cxx:233
virtual void SAL_CALL addNew(const css::uno::Sequence< css::beans::PropertyValue > &aConditionalEntry) override
Definition: fmtuno.cxx:250
OUString aErrorTitle
Definition: fmtuno.hxx:185
formula::FormulaGrammar::Grammar meGrammar1
Definition: fmtuno.hxx:60
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
ScConditionMode
Definition: conditio.hxx:61
ScAddress aSrcPos
Definition: fmtuno.hxx:175
OUString maExprNmsp1
Definition: fmtuno.hxx:55
OUString aInputMessage
Definition: fmtuno.hxx:182
OUString maExprNmsp2
Definition: fmtuno.hxx:170
std::vector< rtl::Reference< ScTableConditionalEntry > > maEntries
Definition: fmtuno.hxx:76
sal_uInt16 nErrorStyle
Definition: fmtuno.hxx:184
css::uno::Sequence< css::sheet::FormulaToken > aTokens2
Definition: fmtuno.hxx:174
OUString maExprNmsp2
Definition: fmtuno.hxx:56
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: fmtuno.cxx:436
ScTableConditionalEntry * GetObjectByIndex_Impl(sal_uInt16 nIndex) const
Definition: fmtuno.cxx:245
css::uno::Sequence< css::sheet::FormulaToken > maTokens1
Definition: fmtuno.hxx:51
unsigned char sal_Bool
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: fmtuno.cxx:359
formula::FormulaGrammar::Grammar meGrammar2
Definition: fmtuno.hxx:172
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
virtual void SAL_CALL clear() override
Definition: fmtuno.cxx:351
virtual void SAL_CALL removeByIndex(sal_Int32 nIndex) override
Definition: fmtuno.cxx:341
OUString aErrorMessage
Definition: fmtuno.hxx:186
sal_Int16 nShowList
Definition: fmtuno.hxx:179
ScCondFormatEntryItem aData
Definition: fmtuno.hxx:126
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fmtuno.cxx:383
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: fmtuno.cxx:423
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fmtuno.cxx:373
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Sequence< css::sheet::FormulaToken > maTokens2
Definition: fmtuno.hxx:52
void FillFormat(ScConditionalFormat &rFormat, ScDocument &rDoc, formula::FormulaGrammar::Grammar eGrammar) const
Definition: fmtuno.cxx:195
struct _ADOIndex Index
virtual sal_Bool SAL_CALL hasElements() override
Definition: fmtuno.cxx:389
sal_Int16 SCTAB
Definition: types.hxx:23