LibreOffice Module sw (master) 1
swtable.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#ifndef INCLUDED_SW_INC_SWTABLE_HXX
20#define INCLUDED_SW_INC_SWTABLE_HXX
21
22#include <tools/ref.hxx>
23#include "tblenum.hxx"
24#include "swtypes.hxx"
25#include "calbck.hxx"
26#include "swrect.hxx"
27#include "swtblfmt.hxx"
28#include "docary.hxx"
29#include "nodeoffset.hxx"
30
31#include <memory>
32#include <vector>
33#include <algorithm>
35#include <optional>
36
37class SwStartNode;
38class SwFormat;
39class Color;
41class SwTableLine;
42class SwTableBox;
43class SwTableNode;
44class SwTabCols;
45class SwDoc;
46class SwSelBoxes;
47class SwTableCalcPara;
48struct SwPosition;
49class SwNodeIndex;
50class SwNode;
51class SfxPoolItem;
53class SwUndo;
54class SwPaM;
56class SwBoxSelection;
57struct SwSaveRowSpan;
58struct Parm;
59class SwServerObject;
60
61void sw_GetTableBoxColStr( sal_uInt16 nCol, OUString& rNm );
62
64{
65 std::vector<SwTableLine*> m_vLines;
66
67public:
68 typedef std::vector<SwTableLine*>::size_type size_type;
69 typedef std::vector<SwTableLine*>::iterator iterator;
70 typedef std::vector<SwTableLine*>::const_iterator const_iterator;
71
72 // free's any remaining child objects
74
75 bool empty() const { return m_vLines.empty(); }
76 size_type size() const { return m_vLines.size(); }
77 iterator begin() { return m_vLines.begin(); }
78 const_iterator begin() const { return m_vLines.begin(); }
79 iterator end() { return m_vLines.end(); }
80 const_iterator end() const { return m_vLines.end(); }
81 SwTableLine* front() const { return m_vLines.front(); }
82 SwTableLine* back() const { return m_vLines.back(); }
83 void clear() { m_vLines.clear(); }
84 iterator erase( iterator aIt ) { return m_vLines.erase( aIt ); }
85 iterator erase( iterator aFirst, iterator aLast ) { return m_vLines.erase( aFirst, aLast ); }
86 iterator insert( iterator aIt, SwTableLine* pLine ) { return m_vLines.insert( aIt, pLine ); }
87 template<typename TInputIterator>
88 void insert( iterator aIt, TInputIterator aFirst, TInputIterator aLast )
89 {
90 m_vLines.insert( aIt, aFirst, aLast );
91 }
92 void push_back( SwTableLine* pLine ) { m_vLines.push_back( pLine ); }
93 void reserve( size_type nSize ) { m_vLines.reserve( nSize ); }
94 SwTableLine*& operator[]( size_type nPos ) { return m_vLines[ nPos ]; }
95 SwTableLine* operator[]( size_type nPos ) const { return m_vLines[ nPos ]; }
96
97 // return USHRT_MAX if not found, else index of position
98 sal_uInt16 GetPos(const SwTableLine* pBox) const
99 {
100 const_iterator it = std::find(begin(), end(), pBox);
101 return it == end() ? USHRT_MAX : it - begin();
102 }
103};
104
105using SwTableBoxes = std::vector<SwTableBox*>;
106
107// Save content-bearing box-pointers additionally in a sorted array
108// (for calculation in table).
109class SwTableSortBoxes : public o3tl::sorted_vector<SwTableBox*> {};
110
112class SW_DLLPUBLIC SwTable: public SwClient //Client of FrameFormat.
113{
114
115protected:
118 tools::SvRef<SwServerObject> m_xRefObj; // In case DataServer -> pointer is set.
119
120 std::shared_ptr<SwHTMLTableLayout> m_xHTMLLayout;
121
122 // Usually, the table node of a SwTable can be accessed by getting a box
123 // out of m_TabSortContentBoxes, which know their SwStartNode. But in some rare
124 // cases, we need to know the table node of a SwTable, before the table
125 // boxes have been build (SwTableNode::MakeCopy with tables in tables).
127
128 // Should that be adjustable for every table?
130
131 sal_uInt16 m_nGraphicsThatResize; // Count of Grfs that initiate a resize of table
132 // at HTML-import.
133 sal_uInt16 m_nRowsToRepeat; // Number of rows to repeat on every page.
134
137
139 bool m_bNewModel :1; // false: old SubTableModel; true: new RowSpanModel
140
141 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
142
143public:
145 {
146 SEARCH_NONE, // Default: expand to rectangle
147 SEARCH_ROW, // row selection
148 SEARCH_COL // column selection
149 };
150
151
152 explicit SwTable();
153 virtual ~SwTable() override;
154
155 // @@@ public copy ctor, but no copy assignment?
156 SwTable( const SwTable& rTable ); // no copy of the lines !!
157
158 virtual const SwTable* DynCastTable() const override { return this; }
159
160private:
161 // @@@ public copy ctor, but no copy assignment?
162 SwTable & operator= (const SwTable &) = delete;
163 bool OldMerge( SwDoc*, const SwSelBoxes&, SwTableBox*, SwUndoTableMerge* );
164 bool OldSplitRow( SwDoc&, const SwSelBoxes&, sal_uInt16, bool );
165 bool NewMerge( SwDoc*, const SwSelBoxes&, const SwSelBoxes& rMerged,
167 bool NewSplitRow( SwDoc&, const SwSelBoxes&, sal_uInt16, bool );
168 std::optional<SwBoxSelection> CollectBoxSelection( const SwPaM& rPam ) const;
169 void InsertSpannedRow( SwDoc& rDoc, sal_uInt16 nIdx, sal_uInt16 nCnt );
170 bool InsertRow_( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, bool bBehind );
171 bool NewInsertCol( SwDoc&, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, bool );
172 void FindSuperfluousRows_( SwSelBoxes& rBoxes, SwTableLine*, SwTableLine* );
173 void AdjustWidths( const tools::Long nOld, const tools::Long nNew );
174 void NewSetTabCols( Parm &rP, const SwTabCols &rNew, const SwTabCols &rOld,
175 const SwTableBox *pStart, bool bCurRowOnly );
176 void ConvertSubtableBox(sal_uInt16 const nRow, sal_uInt16 const nBox);
177 // Only used for TBL_BOXNAME and TBL_RELBOXNAME for now
178 void UpdateFields(TableFormulaUpdateFlags eFlags);
179 void GatherFormulas(std::vector<SwTableBoxFormula*>& rvFormulas);
180
181public:
182 SwHTMLTableLayout *GetHTMLTableLayout() { return m_xHTMLLayout.get(); }
183 const SwHTMLTableLayout *GetHTMLTableLayout() const { return m_xHTMLLayout.get(); }
184 void SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout> const& r); //Change of property!
185
186 sal_uInt16 IncGrfsThatResize() { return ++m_nGraphicsThatResize; }
187 sal_uInt16 DecGrfsThatResize() { return m_nGraphicsThatResize ? --m_nGraphicsThatResize : 0; }
188
189 void LockModify() { m_bModifyLocked = true; } // Must be used always
190 void UnlockModify() { m_bModifyLocked = false;} // in pairs!
191
192 void SetTableModel( bool bNew ){ m_bNewModel = bNew; }
193 bool IsNewModel() const { return m_bNewModel; }
194
196 const OUString& GetTableStyleName() const { return maTableStyleName; }
197
199 void SetTableStyleName(const OUString& rName) { maTableStyleName = rName; }
200
201 sal_uInt16 GetRowsToRepeat() const { return std::min( o3tl::narrowing<sal_uInt16>(GetTabLines().size()), m_nRowsToRepeat ); }
202 void SetRowsToRepeat( sal_uInt16 nNumOfRows ) { m_nRowsToRepeat = nNumOfRows; }
203
204 bool IsHeadline( const SwTableLine& rLine ) const;
205
206 SwTableLines &GetTabLines() { return m_aLines; }
207 const SwTableLines &GetTabLines() const { return m_aLines; }
208
210 SwTableFormat* GetFrameFormat() const { return const_cast<SwTableFormat*>(static_cast<const SwTableFormat*>(GetRegisteredIn())); }
211
212 void GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart,
213 bool bHidden = false, bool bCurRowOnly = false ) const;
214 void SetTabCols( const SwTabCols &rNew, const SwTabCols &rOld,
215 const SwTableBox *pStart, bool bCurRowOnly );
216
217// The following functions are for new table model only...
218 void CreateSelection( const SwPaM& rPam, SwSelBoxes& rBoxes,
219 const SearchType eSearchType, bool bProtect ) const;
220 void CreateSelection( const SwNode* pStart, const SwNode* pEnd,
221 SwSelBoxes& rBoxes, const SearchType eSearchType, bool bProtect ) const;
222 void ExpandSelection( SwSelBoxes& rBoxes ) const;
223 // When a table is split into two tables, the row spans which overlaps
224 // the split have to be corrected and stored for undo
225 // SwSavRowSpan is the structure needed by Undo to undo the split operation
226 // CleanUpRowSpan corrects the (top of the) second table and delivers the structure
227 // for Undo
228 std::unique_ptr<SwSaveRowSpan> CleanUpTopRowSpan( sal_uInt16 nSplitLine );
229 // RestoreRowSpan is called by Undo to restore the old row span values
230 void RestoreRowSpan( const SwSaveRowSpan& );
231 // CleanUpBottomRowSpan corrects the overhanging row spans at the end of the first table
232 void CleanUpBottomRowSpan( sal_uInt16 nDelLines );
233
234// The following functions are "pseudo-virtual", i.e. they are different for old and new table model
235// It's not allowed to change the table model after the first call of one of these functions.
236
237 bool Merge( SwDoc* pDoc, const SwSelBoxes& rBoxes, const SwSelBoxes& rMerged,
238 SwTableBox* pMergeBox, SwUndoTableMerge* pUndo )
239 {
240 return m_bNewModel ? NewMerge( pDoc, rBoxes, rMerged, pUndo ) :
241 OldMerge( pDoc, rBoxes, pMergeBox, pUndo );
242 }
243 bool SplitRow( SwDoc& rDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt,
244 bool bSameHeight )
245 {
246 return m_bNewModel ? NewSplitRow( rDoc, rBoxes, nCnt, bSameHeight ) :
247 OldSplitRow( rDoc, rBoxes, nCnt, bSameHeight );
248 }
249 bool PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
250 SwSelBoxes& rMerged, SwTableBox** ppMergeBox, SwUndoTableMerge* pUndo );
251 void ExpandColumnSelection( SwSelBoxes& rBoxes, tools::Long &rMin, tools::Long &rMax ) const;
252 void PrepareDeleteCol( tools::Long nMin, tools::Long nMax );
253
254 bool InsertCol( SwDoc&, const SwSelBoxes& rBoxes,
255 sal_uInt16 nCnt, bool bBehind );
256 bool InsertRow( SwDoc*, const SwSelBoxes& rBoxes,
257 sal_uInt16 nCnt, bool bBehind );
258 void PrepareDelBoxes( const SwSelBoxes& rBoxes );
259 bool DeleteSel( SwDoc*, const SwSelBoxes& rBoxes, const SwSelBoxes* pMerged,
260 SwUndo* pUndo, const bool bDelMakeFrames, const bool bCorrBorder );
261 bool SplitCol( SwDoc& rDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt );
262
264 { FindSuperfluousRows_( rBoxes, nullptr, nullptr ); }
265 void CheckRowSpan( SwTableLine* &rpLine, bool bUp ) const;
266
267 SwTableSortBoxes& GetTabSortBoxes() { return m_TabSortContentBoxes; }
268 const SwTableSortBoxes& GetTabSortBoxes() const { return m_TabSortContentBoxes; }
269
270 // Read 1st number and delete it from string (used by GetTableBox and SwTableField).
271
272 // #i80314#
273 // add 3rd parameter in order to control validation check on <rStr>
274 static sal_uInt16 GetBoxNum( OUString& rStr,
275 bool bFirst = false,
276 const bool bPerformValidCheck = false );
277
278 // Search content-bearing box with that name.
279
280 // #i80314#
281 // add 2nd parameter in order to control validation check in called method
282 // <GetBoxNum(..)>
283 const SwTableBox* GetTableBox( const OUString& rName,
284 const bool bPerformValidCheck = false ) const;
285 // Copy selected boxes to another document.
286 bool MakeCopy( SwDoc&, const SwPosition&, const SwSelBoxes&,
287 bool bCpyName = false, const OUString& rStyleName = "" ) const;
288 // Copy table in this
289 bool InsTable( const SwTable& rCpyTable, const SwNodeIndex&,
290 SwUndoTableCpyTable* pUndo );
291 bool InsTable( const SwTable& rCpyTable, const SwSelBoxes&,
292 SwUndoTableCpyTable* pUndo );
293 bool InsNewTable( const SwTable& rCpyTable, const SwSelBoxes&,
294 SwUndoTableCpyTable* pUndo );
295 // Copy headline of table (with content!) into another one.
296 void CopyHeadlineIntoTable( SwTableNode& rTableNd );
297
298 // Get box, whose start index is set on nBoxStt.
299 SwTableBox* GetTableBox( SwNodeOffset nSttIdx );
300 const SwTableBox* GetTableBox( SwNodeOffset nSttIdx ) const
301 { return const_cast<SwTable*>(this)->GetTableBox( nSttIdx ); }
302
303 // Returns true if table contains nestings.
304 bool IsTableComplex() const;
305
306 // Returns true if table or selection is balanced.
307 bool IsTableComplexForChart( std::u16string_view aSel ) const;
308
309 // Search all content-bearing boxes of the base line on which this box stands.
310 // rBoxes as a return value for immediate use.
311 // bToTop = true -> up to base line, false-> else only line of box.
312 static SwSelBoxes& SelLineFromBox( const SwTableBox* pBox,
313 SwSelBoxes& rBoxes, bool bToTop = true );
314
315 // Get information from client.
316 virtual bool GetInfo( SfxPoolItem& ) const override;
317
318 // Search in format for registered table.
319 static SwTable * FindTable( SwFrameFormat const*const pFormat );
320
321 // Clean up structure of subtables a bit:
322 // convert row with 1 box with subtable; box with subtable with 1 row;
323 // by removing the subtable (both recursively)
324 void GCLines();
325
326 // Returns the table node via m_TabSortContentBoxes or pTableNode.
327 SwTableNode* GetTableNode() const;
328 void SetTableNode( SwTableNode* pNode ) { m_pTableNode = pNode; }
329
330 // Data server methods.
331 void SetRefObject( SwServerObject* );
332 const SwServerObject* GetObject() const { return m_xRefObj.get(); }
333 SwServerObject* GetObject() { return m_xRefObj.get(); }
334
335 // Fill data for chart.
336 void UpdateCharts() const;
337
338 TableChgMode GetTableChgMode() const { return m_eTableChgMode; }
339 void SetTableChgMode( TableChgMode eMode ) { m_eTableChgMode = eMode; }
340
341 bool SetColWidth( SwTableBox& rCurrentBox, TableChgWidthHeightType eType,
342 SwTwips nAbsDiff, SwTwips nRelDiff, std::unique_ptr<SwUndo>* ppUndo );
343 bool SetRowHeight( SwTableBox& rCurrentBox, TableChgWidthHeightType eType,
344 SwTwips nAbsDiff, SwTwips nRelDiff, std::unique_ptr<SwUndo>* ppUndo );
345 void RegisterToFormat( SwFormat& rFormat );
346#ifdef DBG_UTIL
347 void CheckConsistency() const;
348#endif
349
350 bool HasLayout() const;
351
352 bool CanConvertSubtables() const;
353 void ConvertSubtables();
354
355 // is it a table deleted completely with change tracking
356 bool IsDeleted() const;
357 // is it a table with a deleted row or cell
358 bool HasDeletedRowOrCell() const;
359 // it doesn't contain box content (except single empty nested tables of the boxes
360 // which could remain after deletion of text content of the selected table)
361 bool IsEmpty() const;
363 { UpdateFields(TBL_BOXNAME); };
365 { UpdateFields(TBL_RELBOXNAME); };
367 { UpdateFields(TBL_BOXPTR); }
368 void Merge(SwTable& rTable, SwHistory* pHistory);
369 void Split(OUString sNewTableName, sal_uInt16 nSplitLine, SwHistory* pHistory);
370
371 void dumpAsXml(xmlTextWriterPtr pWriter) const;
372};
373
375class SW_DLLPUBLIC SwTableLine final : public SwClient // Client of FrameFormat.
376{
380
381public:
382
383 SwTableLine( SwTableLineFormat*, sal_uInt16 nBoxes, SwTableBox *pUp );
384 virtual ~SwTableLine() override;
385
386 SwTableBoxes &GetTabBoxes() { return m_aBoxes; }
387 const SwTableBoxes &GetTabBoxes() const { return m_aBoxes; }
388 sal_uInt16 GetBoxPos(const SwTableBox* pBox) const
389 {
390 SwTableBoxes::const_iterator it = std::find(m_aBoxes.begin(), m_aBoxes.end(), pBox);
391 return it == m_aBoxes.end() ? USHRT_MAX : it - m_aBoxes.begin();
392 }
393
394 SwTableBox *GetUpper() { return m_pUpper; }
395 const SwTableBox *GetUpper() const { return m_pUpper; }
396 void SetUpper( SwTableBox *pNew ) { m_pUpper = pNew; }
397
399 SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
400
401 // Creates an own FrameFormat if more lines depend on it.
402 SwFrameFormat* ClaimFrameFormat();
403 void ChgFrameFormat( SwTableLineFormat* pNewFormat );
404
405 // Search next/previous box with content.
406 SwTableBox* FindNextBox( const SwTable&, const SwTableBox* =nullptr,
407 bool bOvrTableLns=true ) const;
408 SwTableBox* FindPreviousBox( const SwTable&, const SwTableBox* =nullptr,
409 bool bOvrTableLns=true ) const;
410
411 SwTwips GetTableLineHeight( bool& bLayoutAvailable ) const;
412
413 bool hasSoftPageBreak() const;
414
415 // it doesn't contain box content (except single empty nested tables of the boxes
416 // which could remain after deletion of text content of the selected table row)
417 bool IsEmpty() const;
418
419 // Update TextChangesOnly property based on the redlines of the table row.
420 // rRedlinePos: search from this redline index to speed up SwTable::IsDeleted().
421 // bUpdateProperty: don't update HasTextChangesOnly property, if bUpdateProperty = false.
422 // Set rRedlinePos after the last redline index of the table row.
423 // Return with the redline, which associated to the row change (latest deletion
424 // in the case of deleted row, the first insertion in the case of row insertion
425 // or npos, if TextChangesOnly is true, i.e. the table row is not deleted or inserted).
426 // Cache also the type of the redline associated to the changed table row.
427 SwRedlineTable::size_type UpdateTextChangesOnly(
428 SwRedlineTable::size_type& rRedlinePos, bool bUpdateProperty = true) const;
429 // tracked text changes, i.e. a single redline can contain tables
430 // get that redline for the table row, if it exists
431 SwRedlineTable::size_type GetTableRedline() const;
432 // is it a tracked row
433 bool IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted = false) const;
434 // is it a tracked deleted row
435 bool IsDeleted(SwRedlineTable::size_type& rRedlinePos) const;
436 // set/get (if it's possible, cached) redline type
437 RedlineType GetRedlineType() const;
438 void SetRedlineType(RedlineType eType) { m_eRedlineType = eType; }
439};
440
442class SW_DLLPUBLIC SwTableBox final : public SwClient //Client of FrameFormat.
443{
444 friend class SwNodes; // Transpose index.
445 friend void DelBoxNode(SwTableSortBoxes const &); // Delete StartNode* !
446 friend class SwXMLTableContext;
447
448 SwTableBox( const SwTableBox & ) = delete;
449 SwTableBox &operator=( const SwTableBox &) = delete;
450
454
455 std::optional<Color> mxUserColor;
456 std::optional<Color> mxNumFormatColor;
457 sal_Int32 mnRowSpan;
459
462
463 // In case Format contains formulas/values already,
464 // a new one must be created for the new box.
465 static SwTableBoxFormat* CheckBoxFormat( SwTableBoxFormat* );
466
467public:
468
469 SwTableBox( SwTableBoxFormat*, sal_uInt16 nLines, SwTableLine *pUp );
472 virtual ~SwTableBox() override;
473
474 SwTableLines &GetTabLines() { return m_aLines; }
475 const SwTableLines &GetTabLines() const { return m_aLines; }
476
477 SwTableLine *GetUpper() { return m_pUpper; }
478 const SwTableLine *GetUpper() const { return m_pUpper; }
479 void SetUpper( SwTableLine *pNew ) { m_pUpper = pNew; }
480
482 SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
483
485 void SetDirectFormatting(bool bDirect) { mbDirectFormatting = bDirect; }
486
488 bool HasDirectFormatting() const { return mbDirectFormatting; }
489
490 // Creates its own FrameFormat if more boxes depend on it.
491 SwFrameFormat* ClaimFrameFormat();
492 void ChgFrameFormat( SwTableBoxFormat *pNewFormat, bool bNeedToReregister = true );
493
494 void RemoveFromTable();
495 const SwStartNode *GetSttNd() const { return m_pStartNode; }
496 SwNodeOffset GetSttIdx() const;
497 // it doesn't contain box content or if bWithRemainingNestedTable = true,
498 // it contains only an empty nested table as box content (which
499 // could remain after deletion of the text content of the selected box).
500 bool IsEmpty( bool bWithRemainingNestedTable = true ) const;
501
502 // Search next/previous box with content.
503 SwTableBox* FindNextBox( const SwTable&, const SwTableBox*,
504 bool bOvrTableLns=true ) const;
505 SwTableBox* FindPreviousBox( const SwTable&, const SwTableBox* ) const;
506 // Return name of this box. It is determined dynamically and
507 // is calculated from the position in the lines/boxes/table.
508 OUString GetName() const;
509 // Return "value" of box (for calculating in table).
510 double GetValue( SwTableCalcPara& rPara ) const;
511
512 // Computes "coordinates" of a box, used to computed selection
513 // width or height when inserting cols or rows
514 Point GetCoordinates() const;
515
516 bool IsInHeadline( const SwTable* pTable ) const;
517
518 // Contains box contents, that can be formatted as a number?
519 bool HasNumContent( double& rNum, sal_uInt32& rFormatIndex,
520 bool& rIsEmptyTextNd ) const;
521 SwNodeOffset IsValidNumTextNd( bool bCheckAttr = true ) const;
522 // If a table formula is set, test if box contents is congruent with number.
523 // (For Redo of change of NumFormat!).
524 bool IsNumberChanged() const;
525
526 // Is that a formula box or a box with numeric contents (AutoSum)?
527 // What it is indicated by the return value - the WhichId of the attribute.
528 // Empty boxes have the return value USHRT_MAX !!
529 sal_uInt16 IsFormulaOrValueBox() const;
530
531 // Loading of a document requires an actualization of cells with values
532 void ActualiseValueBox();
533
534 // Access on internal data - currently used for the NumFormatter.
535 const std::optional<Color>& GetSaveUserColor() const { return mxUserColor; }
536 const std::optional<Color>& GetSaveNumFormatColor() const { return mxNumFormatColor; }
537 void SetSaveUserColor(std::optional<Color> p ) { mxUserColor = p; }
538 void SetSaveNumFormatColor( std::optional<Color> p ) { mxNumFormatColor = p; }
539
540 sal_Int32 getRowSpan() const { return mnRowSpan; }
541 void setRowSpan( sal_Int32 nNewRowSpan );
542 bool getDummyFlag() const;
543 void setDummyFlag( bool bDummy );
544
545 SwTableBox& FindStartOfRowSpan( const SwTable&, sal_uInt16 nMaxStep = USHRT_MAX );
546 const SwTableBox& FindStartOfRowSpan( const SwTable& rTable,
547 sal_uInt16 nMaxStep = USHRT_MAX ) const
548 { return const_cast<SwTableBox*>(this)->FindStartOfRowSpan( rTable, nMaxStep ); }
549
550 SwTableBox& FindEndOfRowSpan( const SwTable&, sal_uInt16 nMaxStep );
551 const SwTableBox& FindEndOfRowSpan( const SwTable& rTable,
552 sal_uInt16 nMaxStep ) const
553 { return const_cast<SwTableBox*>(this)->FindEndOfRowSpan( rTable, nMaxStep ); }
554 void RegisterToFormat( SwFormat& rFormat ) ;
555 // get redline for the table cell, if it exists
556 SwRedlineTable::size_type GetRedline() const;
557 // get redline type
558 RedlineType GetRedlineType() const;
559};
560
561class SwCellFrame;
563{
564 struct Impl;
565 std::unique_ptr<Impl> m_pImpl;
566
567 const SwCellFrame * getCellFrame() const;
568
571
572public:
573 SwTableCellInfo(const SwTable * pTable);
575
576 bool getNext();
577 SwRect getRect() const;
578 const SwTableBox * getTableBox() const;
579};
580
581#endif // INCLUDED_SW_INC_SWTABLE_HXX
582
583/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwBoxSelection is a small helperclass (structure) to handle selections of cells (boxes) between table...
Definition: swnewtable.cxx:67
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:31
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:120
virtual bool GetInfo(SfxPoolItem &) const
Definition: calbck.hxx:173
Definition: doc.hxx:197
Base class for various Writer styles.
Definition: format.hxx:47
Style of a layout element.
Definition: frmfmt.hxx:72
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
vector_type::size_type size_type
Definition: docary.hxx:223
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
SwTableLine * GetUpper()
Definition: swtable.hxx:477
void SetUpper(SwTableLine *pNew)
Definition: swtable.hxx:479
void SetSaveUserColor(std::optional< Color > p)
Definition: swtable.hxx:537
const SwTableLine * GetUpper() const
Definition: swtable.hxx:478
SwTableBox & operator=(const SwTableBox &)=delete
sal_Int32 getRowSpan() const
Definition: swtable.hxx:540
const SwTableBox & FindStartOfRowSpan(const SwTable &rTable, sal_uInt16 nMaxStep=USHRT_MAX) const
Definition: swtable.hxx:546
const std::optional< Color > & GetSaveUserColor() const
Definition: swtable.hxx:535
SwFrameFormat * GetFrameFormat() const
Definition: swtable.hxx:482
const SwStartNode * m_pStartNode
Definition: swtable.hxx:452
std::optional< Color > mxUserColor
Definition: swtable.hxx:455
void SetSaveNumFormatColor(std::optional< Color > p)
Definition: swtable.hxx:538
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:481
SwTableLines & GetTabLines()
Definition: swtable.hxx:474
void SetDirectFormatting(bool bDirect)
Set that this table box contains formatting that is not set by the table style.
Definition: swtable.hxx:485
bool HasDirectFormatting() const
Do we contain any direct formatting (ie. something not affected by the table style)?
Definition: swtable.hxx:488
const SwTableBox & FindEndOfRowSpan(const SwTable &rTable, sal_uInt16 nMaxStep) const
Definition: swtable.hxx:551
std::optional< Color > mxNumFormatColor
Definition: swtable.hxx:456
bool mbDirectFormatting
Do we contain any direct formatting?
Definition: swtable.hxx:461
bool mbDummyFlag
Definition: swtable.hxx:458
const std::optional< Color > & GetSaveNumFormatColor() const
Definition: swtable.hxx:536
sal_Int32 mnRowSpan
Definition: swtable.hxx:457
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:495
SwTableLine * m_pUpper
Definition: swtable.hxx:453
const SwTableLines & GetTabLines() const
Definition: swtable.hxx:475
SwTableLines m_aLines
Definition: swtable.hxx:451
SwTableBox(const SwTableBox &)=delete
std::unique_ptr< Impl > m_pImpl
Definition: swtable.hxx:564
SwTableCellInfo(SwTableCellInfo const &)=delete
SwTableCellInfo & operator=(SwTableCellInfo const &)=delete
SwTableLine is one table row in the document model.
Definition: swtable.hxx:376
SwTableBoxes m_aBoxes
Definition: swtable.hxx:377
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:398
const SwTableBoxes & GetTabBoxes() const
Definition: swtable.hxx:387
void SetRedlineType(RedlineType eType)
Definition: swtable.hxx:438
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:386
RedlineType m_eRedlineType
Definition: swtable.hxx:379
SwFrameFormat * GetFrameFormat() const
Definition: swtable.hxx:399
sal_uInt16 GetBoxPos(const SwTableBox *pBox) const
Definition: swtable.hxx:388
void SetUpper(SwTableBox *pNew)
Definition: swtable.hxx:396
SwTableBox * m_pUpper
Definition: swtable.hxx:378
SwTableBox * GetUpper()
Definition: swtable.hxx:394
const SwTableBox * GetUpper() const
Definition: swtable.hxx:395
std::vector< SwTableLine * >::const_iterator const_iterator
Definition: swtable.hxx:70
std::vector< SwTableLine * >::iterator iterator
Definition: swtable.hxx:69
size_type size() const
Definition: swtable.hxx:76
SwTableLine * back() const
Definition: swtable.hxx:82
iterator erase(iterator aIt)
Definition: swtable.hxx:84
iterator end()
Definition: swtable.hxx:79
SwTableLine *& operator[](size_type nPos)
Definition: swtable.hxx:94
const_iterator begin() const
Definition: swtable.hxx:78
void clear()
Definition: swtable.hxx:83
SwTableLine * front() const
Definition: swtable.hxx:81
void push_back(SwTableLine *pLine)
Definition: swtable.hxx:92
iterator erase(iterator aFirst, iterator aLast)
Definition: swtable.hxx:85
iterator insert(iterator aIt, SwTableLine *pLine)
Definition: swtable.hxx:86
void reserve(size_type nSize)
Definition: swtable.hxx:93
std::vector< SwTableLine * >::size_type size_type
Definition: swtable.hxx:68
iterator begin()
Definition: swtable.hxx:77
sal_uInt16 GetPos(const SwTableLine *pBox) const
Definition: swtable.hxx:98
void insert(iterator aIt, TInputIterator aFirst, TInputIterator aLast)
Definition: swtable.hxx:88
const_iterator end() const
Definition: swtable.hxx:80
bool empty() const
Definition: swtable.hxx:75
SwTableLine * operator[](size_type nPos) const
Definition: swtable.hxx:95
std::vector< SwTableLine * > m_vLines
Definition: swtable.hxx:65
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SwTableFormat * GetFrameFormat() const
Definition: swtable.hxx:210
const SwHTMLTableLayout * GetHTMLTableLayout() const
Definition: swtable.hxx:183
std::shared_ptr< SwHTMLTableLayout > m_xHTMLLayout
Definition: swtable.hxx:120
virtual const SwTable * DynCastTable() const override
Definition: swtable.hxx:158
void LockModify()
Definition: swtable.hxx:189
SwTableSortBoxes m_TabSortContentBoxes
Definition: swtable.hxx:117
void SetTableModel(bool bNew)
Definition: swtable.hxx:192
OUString maTableStyleName
Name of the table style to be applied on this table.
Definition: swtable.hxx:136
SwServerObject * GetObject()
Definition: swtable.hxx:333
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:196
bool Merge(SwDoc *pDoc, const SwSelBoxes &rBoxes, const SwSelBoxes &rMerged, SwTableBox *pMergeBox, SwUndoTableMerge *pUndo)
Definition: swtable.hxx:237
sal_uInt16 m_nRowsToRepeat
Definition: swtable.hxx:133
const SwServerObject * GetObject() const
Definition: swtable.hxx:332
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Definition: swtable.hxx:202
SwTableNode * m_pTableNode
Definition: swtable.hxx:126
SwTableLines & GetTabLines()
Definition: swtable.hxx:206
void FindSuperfluousRows(SwSelBoxes &rBoxes)
Definition: swtable.hxx:263
void SwitchFormulasToExternalRepresentation()
Definition: swtable.hxx:362
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:209
SwTableLines m_aLines
Definition: swtable.hxx:116
void SetTableStyleName(const OUString &rName)
Set the new table style name for this table.
Definition: swtable.hxx:199
TableChgMode m_eTableChgMode
Definition: swtable.hxx:129
const SwTableLines & GetTabLines() const
Definition: swtable.hxx:207
void SwitchFormulasToInternalRepresentation()
Definition: swtable.hxx:366
void SwitchFormulasToRelativeRepresentation()
Definition: swtable.hxx:364
void SetTableChgMode(TableChgMode eMode)
Definition: swtable.hxx:339
sal_uInt16 DecGrfsThatResize()
Definition: swtable.hxx:187
sal_uInt16 IncGrfsThatResize()
Definition: swtable.hxx:186
void UnlockModify()
Definition: swtable.hxx:190
SwHTMLTableLayout * GetHTMLTableLayout()
Definition: swtable.hxx:182
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:201
@ SEARCH_NONE
Definition: swtable.hxx:146
@ SEARCH_ROW
Definition: swtable.hxx:147
bool m_bNewModel
Definition: swtable.hxx:139
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:267
bool m_bModifyLocked
Definition: swtable.hxx:138
const SwTableBox * GetTableBox(SwNodeOffset nSttIdx) const
Definition: swtable.hxx:300
tools::SvRef< SwServerObject > m_xRefObj
Definition: swtable.hxx:118
bool IsNewModel() const
Definition: swtable.hxx:193
const SwTableSortBoxes & GetTabSortBoxes() const
Definition: swtable.hxx:268
void SetTableNode(SwTableNode *pNode)
Definition: swtable.hxx:328
TableChgMode GetTableChgMode() const
Definition: swtable.hxx:338
bool SplitRow(SwDoc &rDoc, const SwSelBoxes &rBoxes, sal_uInt16 nCnt, bool bSameHeight)
Definition: swtable.hxx:243
sal_uInt16 m_nGraphicsThatResize
Definition: swtable.hxx:131
WriterListener & operator=(WriterListener const &)=delete
T * get() const
RedlineType
struct _xmlTextWriter * xmlTextWriterPtr
virtual OUString GetName() const override
DocumentType eType
TableFormulaUpdateFlags
SwTableFormulaUpdate is sent when the table has to be newly calculated or when a table itself is merg...
Definition: hints.hxx:300
@ TBL_BOXPTR
Definition: hints.hxx:302
@ TBL_BOXNAME
Definition: hints.hxx:301
@ TBL_RELBOXNAME
Definition: hints.hxx:303
Mode eMode
void * p
sal_uInt16 nPos
size
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
const char GetValue[]
Marks a position in the document model.
Definition: pam.hxx:38
This structure is needed by Undo to restore row span attributes when a table has been split into two ...
Definition: tblrwcl.hxx:111
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
void DelBoxNode(SwTableSortBoxes const &rSortCntBoxes)
Definition: swtable.cxx:211
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:105
void sw_GetTableBoxColStr(sal_uInt16 nCol, OUString &rNm)
Definition: swtable.cxx:2146
tools::Long SwTwips
Definition: swtypes.hxx:51
sal_Int32 mnRowSpan
TableChgMode
Definition: tblenum.hxx:48
TableChgWidthHeightType
Definition: tblenum.hxx:27