LibreOffice Module sw (master) 1
cellfml.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_SW_INC_CELLFML_HXX
21#define INCLUDED_SW_INC_CELLFML_HXX
22
23#include "swdllapi.h"
24
25#include <memory>
26#include <rtl/ustrbuf.hxx>
27#include <rtl/ustring.hxx>
28
29class SwTable;
30class SwNode;
32class SwSelBoxes;
33class SwCalc;
34class SwTableBox;
36class SwDoc;
37class SwRootFrame;
38
40{
43
44public:
45 SwRootFrame const*const m_pLayout;
46 std::unique_ptr<SwTableSortBoxes> m_pBoxStack;
49
50 SwTableCalcPara(SwCalc& rCalculator, const SwTable& rTable, SwRootFrame const* pLayout);
52
54 bool IsStackOverflow() const { return m_nMaxSize == m_nStackCount; }
55 bool IncStackCnt() { return m_nMaxSize == ++m_nStackCount; }
57 void SetLastTableBox( const SwTableBox* pBox ) { m_pLastTableBox = pBox; }
58};
59
61{
62typedef void (SwTableFormula::*FnScanFormula)( const SwTable&, OUStringBuffer&,
63 OUString&, OUString*, void* ) const;
64
65 void BoxNmsToPtr( const SwTable&, OUStringBuffer&, OUString&, OUString*,
66 void* pPara ) const;
67 void PtrToBoxNms( const SwTable&, OUStringBuffer&, OUString&, OUString*,
68 void* pPara ) const;
69 void RelNmsToBoxNms( const SwTable&, OUStringBuffer&, OUString&, OUString*,
70 void* pPara ) const;
71 void RelBoxNmsToPtr( const SwTable&, OUStringBuffer&, OUString&, OUString*,
72 void* pPara ) const;
73 void BoxNmsToRelNm( const SwTable&, OUStringBuffer&, OUString&, OUString*,
74 void* pPara ) const;
75 void MakeFormula_( const SwTable&, OUStringBuffer&, OUString&, OUString*,
76 void* pPara ) const;
77 void GetFormulaBoxes( const SwTable&, OUStringBuffer&, OUString&, OUString*,
78 void* pPara ) const;
79 void HasValidBoxes_( const SwTable&, OUStringBuffer&, OUString&, OUString*,
80 void* pPara ) const;
81 void SplitMergeBoxNm_( const SwTable&, OUStringBuffer&, OUString&, OUString*,
82 void* pPara ) const;
83
84 static void GetBoxes( const SwTableBox& rStt, const SwTableBox& rEnd,
85 SwSelBoxes& rBoxes );
86 OUString ScanString( FnScanFormula fnFormula, const SwTable& rTable,
87 void*) const;
88
89 static const SwTable* FindTable( SwDoc& rDoc, std::u16string_view rNm );
90
91protected:
92 enum NameType { EXTRNL_NAME, INTRNL_NAME, REL_NAME };
93
94 OUString m_sFormula;
97
98 // find the node in which the formula is located
99 // TextField -> TextNode,
100 // BoxAttribut -> BoxStartNode
101 // !!! every derived class must override this !!!
102 virtual const SwNode* GetNodeOfFormula() const = 0;
103
104 SwTableFormula( OUString aFormula );
105
106 OUString MakeFormula( SwTableCalcPara& rCalcPara ) const
107 {
108 return ScanString( &SwTableFormula::MakeFormula_,
109 *rCalcPara.m_pTable, &rCalcPara );
110 }
111
112 static sal_uInt16 GetLnPosInTable( const SwTable& rTable, const SwTableBox* pBox );
113
114public:
115
116 virtual ~SwTableFormula();
117
118 SwTableFormula(SwTableFormula const &) = default;
120 SwTableFormula & operator =(SwTableFormula const &) = default;
121 SwTableFormula & operator =(SwTableFormula &&) = default;
122
124 void PtrToBoxNm( const SwTable* pTable );
126 void BoxNmToPtr( const SwTable* pTable );
128 void ToRelBoxNm( const SwTable* pTable );
130 void ToSplitMergeBoxNm( SwTableFormulaUpdate& rTableUpd );
131
132 bool IsIntrnlName() const { return m_eNmType == INTRNL_NAME; }
133 NameType GetNameType() const { return m_eNmType; }
134
135 bool IsValid() const { return m_bValidValue; }
136 void ChgValid( bool bNew ) { m_bValidValue = bNew; }
137
138 const OUString& GetFormula() const { return m_sFormula; }
139 void SetFormula( const OUString& rNew )
140 {
141 m_sFormula = rNew;
142 m_eNmType = EXTRNL_NAME;
143 m_bValidValue = false;
144 }
145
146 void GetBoxesOfFormula(const SwTable& rTable, SwSelBoxes& rBoxes);
147 // are all boxes valid which this formula relies on?
148 bool HasValidBoxes() const;
149};
150
151#endif
152
153/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: calc.hxx:195
Definition: doc.hxx:192
Base class of the Writer document model elements.
Definition: node.hxx:84
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
SwCalc & m_rCalc
current Calculator
Definition: cellfml.hxx:47
sal_uInt16 m_nStackCount
Definition: cellfml.hxx:42
SwTableCalcPara(SwCalc &rCalculator, const SwTable &rTable, SwRootFrame const *pLayout)
Definition: cellfml.cxx:271
void SetLastTableBox(const SwTableBox *pBox)
Definition: cellfml.hxx:57
sal_uInt16 m_nMaxSize
Definition: cellfml.hxx:42
void DecStackCnt()
Definition: cellfml.hxx:56
const SwTableBox * m_pLastTableBox
Definition: cellfml.hxx:41
bool CalcWithStackOverflow()
Definition: cellfml.cxx:287
std::unique_ptr< SwTableSortBoxes > m_pBoxStack
stack for recognizing recursion
Definition: cellfml.hxx:46
const SwTable * m_pTable
current table
Definition: cellfml.hxx:48
bool IsStackOverflow() const
Definition: cellfml.hxx:54
SwRootFrame const *const m_pLayout
layout to access text field results
Definition: cellfml.hxx:45
bool IncStackCnt()
Definition: cellfml.hxx:55
bool IsIntrnlName() const
Definition: cellfml.hxx:132
void ChgValid(bool bNew)
Definition: cellfml.hxx:136
bool m_bValidValue
true: recalculate formula
Definition: cellfml.hxx:96
OUString MakeFormula(SwTableCalcPara &rCalcPara) const
Definition: cellfml.hxx:106
OUString m_sFormula
current formula
Definition: cellfml.hxx:94
SwTableFormula(SwTableFormula &&)=default
const OUString & GetFormula() const
Definition: cellfml.hxx:138
void MakeFormula_(const SwTable &, OUStringBuffer &, OUString &, OUString *, void *pPara) const
Definition: cellfml.cxx:335
NameType m_eNmType
current display method
Definition: cellfml.hxx:95
NameType GetNameType() const
Definition: cellfml.hxx:133
bool IsValid() const
Definition: cellfml.hxx:135
void SetFormula(const OUString &rNew)
Definition: cellfml.hxx:139
virtual const SwNode * GetNodeOfFormula() const =0
SwTableFormula(SwTableFormula const &)=default
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
#define SW_DLLPUBLIC
Definition: swdllapi.h:28