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
113public:
114
115 virtual ~SwTableFormula();
116
117 SwTableFormula(SwTableFormula const &) = default;
119 SwTableFormula & operator =(SwTableFormula const &) = default;
120 SwTableFormula & operator =(SwTableFormula &&) = default;
121
123 void PtrToBoxNm( const SwTable* pTable );
125 void BoxNmToPtr( const SwTable* pTable );
127 void ToRelBoxNm( const SwTable* pTable );
129 void ToSplitMergeBoxNm( SwTableFormulaUpdate& rTableUpd );
130
131 bool IsIntrnlName() const { return m_eNmType == INTRNL_NAME; }
132 NameType GetNameType() const { return m_eNmType; }
133
134 bool IsValid() const { return m_bValidValue; }
135 void ChgValid( bool bNew ) { m_bValidValue = bNew; }
136
137 const OUString& GetFormula() const { return m_sFormula; }
138 void SetFormula( const OUString& rNew )
139 {
140 m_sFormula = rNew;
141 m_eNmType = EXTRNL_NAME;
142 m_bValidValue = false;
143 }
144
145 void GetBoxesOfFormula(const SwTable& rTable, SwSelBoxes& rBoxes);
146 // are all boxes valid which this formula relies on?
147 bool HasValidBoxes() const;
148 static sal_uInt16 GetLnPosInTable( const SwTable& rTable, const SwTableBox* pBox );
149};
150
151#endif
152
153/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: calc.hxx:200
Definition: doc.hxx:197
Base class of the Writer document model elements.
Definition: node.hxx:98
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
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:131
void ChgValid(bool bNew)
Definition: cellfml.hxx:135
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:137
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:132
bool IsValid() const
Definition: cellfml.hxx:134
void SetFormula(const OUString &rNew)
Definition: cellfml.hxx:138
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