tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sw / inc / cellfml.hxx
bloba4f6bb2e536641393bd03dd7539d337a8f7824ec
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 #pragma once
22 #include "swdllapi.h"
24 #include <memory>
25 #include <rtl/ustrbuf.hxx>
26 #include <rtl/ustring.hxx>
28 class SwTable;
29 class SwNode;
30 class SwTableSortBoxes;
31 class SwSelBoxes;
32 class SwCalc;
33 class SwTableBox;
34 class SwTableFormulaUpdate;
35 class SwDoc;
36 class SwRootFrame;
38 class SwTableCalcPara
40 const SwTableBox* m_pLastTableBox;
41 sal_uInt16 m_nStackCount, m_nMaxSize;
43 public:
44 SwRootFrame const*const m_pLayout; ///< layout to access text field results
45 std::unique_ptr<SwTableSortBoxes> m_pBoxStack; ///< stack for recognizing recursion
46 SwCalc& m_rCalc; ///< current Calculator
47 const SwTable* m_pTable; ///< current table
49 SwTableCalcPara(SwCalc& rCalculator, const SwTable& rTable, SwRootFrame const* pLayout);
50 ~SwTableCalcPara();
52 bool CalcWithStackOverflow();
53 bool IsStackOverflow() const { return m_nMaxSize == m_nStackCount; }
54 bool IncStackCnt() { return m_nMaxSize == ++m_nStackCount; }
55 void DecStackCnt() { if( m_nStackCount ) --m_nStackCount; }
56 void SetLastTableBox( const SwTableBox* pBox ) { m_pLastTableBox = pBox; }
59 class SW_DLLPUBLIC SwTableFormula
61 typedef void (SwTableFormula::*FnScanFormula)( const SwTable&, OUStringBuffer&,
62 OUString&, OUString*, void* ) const;
64 void BoxNmsToPtr( const SwTable&, OUStringBuffer&, OUString&, OUString*,
65 void* pPara ) const;
66 void PtrToBoxNms( const SwTable&, OUStringBuffer&, OUString&, OUString*,
67 void* pPara ) const;
68 void RelNmsToBoxNms( const SwTable&, OUStringBuffer&, OUString&, OUString*,
69 void* pPara ) const;
70 void RelBoxNmsToPtr( const SwTable&, OUStringBuffer&, OUString&, OUString*,
71 void* pPara ) const;
72 void BoxNmsToRelNm( const SwTable&, OUStringBuffer&, OUString&, OUString*,
73 void* pPara ) const;
74 void MakeFormula_( const SwTable&, OUStringBuffer&, OUString&, OUString*,
75 void* pPara ) const;
76 void GetFormulaBoxes( const SwTable&, OUStringBuffer&, OUString&, OUString*,
77 void* pPara ) const;
78 void HasValidBoxes_( const SwTable&, OUStringBuffer&, OUString&, OUString*,
79 void* pPara ) const;
80 void SplitMergeBoxNm_( const SwTable&, OUStringBuffer&, OUString&, OUString*,
81 void* pPara ) const;
83 static void GetBoxes( const SwTableBox& rStt, const SwTableBox& rEnd,
84 SwSelBoxes& rBoxes );
85 OUString ScanString( FnScanFormula fnFormula, const SwTable& rTable,
86 void*) const;
88 static const SwTable* FindTable( SwDoc& rDoc, std::u16string_view rNm );
90 protected:
91 enum NameType { EXTRNL_NAME, INTRNL_NAME, REL_NAME };
93 OUString m_sFormula; ///< current formula
94 NameType m_eNmType; ///< current display method
95 bool m_bValidValue; ///< true: recalculate formula
97 // find the node in which the formula is located
98 // TextField -> TextNode,
99 // BoxAttribute -> BoxStartNode
100 // !!! every derived class must override this !!!
101 virtual const SwNode* GetNodeOfFormula() const = 0;
103 SwTableFormula( OUString aFormula );
105 OUString MakeFormula( SwTableCalcPara& rCalcPara ) const
107 return ScanString( &SwTableFormula::MakeFormula_,
108 *rCalcPara.m_pTable, &rCalcPara );
112 public:
114 virtual ~SwTableFormula();
116 SwTableFormula(SwTableFormula const &) = default;
117 SwTableFormula(SwTableFormula &&) = default;
118 SwTableFormula & operator =(SwTableFormula const &) = default;
119 SwTableFormula & operator =(SwTableFormula &&) = default;
121 /// create from the internal formula (for CORE) the external formula (for UI)
122 void PtrToBoxNm( const SwTable* pTable );
123 /// create from the external formula the internal
124 void BoxNmToPtr( const SwTable* pTable );
125 /// create from the external/internal formula the relative formula
126 void ToRelBoxNm( const SwTable* pTable );
127 /// gets called before/after merging/splitting of tables
128 void ToSplitMergeBoxNm( SwTableFormulaUpdate& rTableUpd );
130 bool IsIntrnlName() const { return m_eNmType == INTRNL_NAME; }
131 NameType GetNameType() const { return m_eNmType; }
133 bool IsValid() const { return m_bValidValue; }
134 void ChgValid( bool bNew ) { m_bValidValue = bNew; }
136 const OUString& GetFormula() const { return m_sFormula; }
137 void SetFormula( const OUString& rNew )
139 m_sFormula = rNew;
140 m_eNmType = EXTRNL_NAME;
141 m_bValidValue = false;
144 void GetBoxesOfFormula(const SwTable& rTable, SwSelBoxes& rBoxes);
145 // are all boxes valid which this formula relies on?
146 bool HasValidBoxes() const;
147 static sal_uInt16 GetLnPosInTable( const SwTable& rTable, const SwTableBox* pBox );
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */