/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #ifndef INCLUDED_SW_INC_SWTABLE_HXX #define INCLUDED_SW_INC_SWTABLE_HXX
class SwStartNode; class SwFormat; class SwHTMLTableLayout; class SwTableLine; class SwTableBox; class SwTableNode; class SwTabCols; class SwDoc; class SwSelBoxes; class SwTableCalcPara; struct SwPosition; class SwNodeIndex; class SwNode; class SwUndoTableMerge; class SwUndo; class SwPaM; class SwUndoTableCpyTable; class SwBoxSelection; struct SwSaveRowSpan; struct Parm; class SwServerObject; class SwHistory;
// return USHRT_MAX if not found, else index of position
sal_uInt16 GetPos(const SwTableLine* pBox) const
{
const_iterator it = std::find(begin(), end(), pBox); return it == end() ? USHRT_MAX : it - begin();
}
};
using SwTableBoxes = std::vector<SwTableBox*>;
// Save content-bearing box-pointers additionally in a sorted array // (for calculation in table). class SwTableSortBoxes : public o3tl::sorted_vector<SwTableBox*> {};
/// SwTable is one table in the document model, containing rows (which contain cells). class SAL_DLLPUBLIC_RTTI SwTable: public SwClient //Client of FrameFormat.
{
protected:
SwTableLines m_aLines;
SwTableSortBoxes m_TabSortContentBoxes;
tools::SvRef<SwServerObject> m_xRefObj; // In case DataServer -> pointer is set.
std::shared_ptr<SwHTMLTableLayout> m_xHTMLLayout;
// Usually, the table node of a SwTable can be accessed by getting a box // out of m_TabSortContentBoxes, which know their SwStartNode. But in some rare // cases, we need to know the table node of a SwTable, before the table // boxes have been build (SwTableNode::MakeCopy with tables in tables).
SwTableNode* m_pTableNode;
// Should that be adjustable for every table?
TableChgMode m_eTableChgMode;
sal_uInt16 m_nGraphicsThatResize; // Count of Grfs that initiate a resize of table // at HTML-import.
sal_uInt16 m_nRowsToRepeat; // Number of rows to repeat on every page.
/// Name of the table style to be applied on this table.
TableStyleName maTableStyleName;
bool m_bModifyLocked :1; bool m_bNewModel :1; // false: old SubTableModel; true: new RowSpanModel
// The following functions are for new table model only... void CreateSelection( const SwPaM& rPam, SwSelBoxes& rBoxes, const SearchType eSearchType, bool bProtect ) const; void CreateSelection( const SwNode* pStart, const SwNode* pEnd,
SwSelBoxes& rBoxes, const SearchType eSearchType, bool bProtect ) const; void ExpandSelection( SwSelBoxes& rBoxes ) const; // When a table is split into two tables, the row spans which overlaps // the split have to be corrected and stored for undo // SwSavRowSpan is the structure needed by Undo to undo the split operation // CleanUpRowSpan corrects the (top of the) second table and delivers the structure // for Undo
std::unique_ptr<SwSaveRowSpan> CleanUpTopRowSpan( sal_uInt16 nSplitLine ); // RestoreRowSpan is called by Undo to restore the old row span values void RestoreRowSpan( const SwSaveRowSpan& ); // CleanUpBottomRowSpan corrects the overhanging row spans at the end of the first table void CleanUpBottomRowSpan( sal_uInt16 nDelLines );
// The following functions are "pseudo-virtual", i.e. they are different for old and new table model // It's not allowed to change the table model after the first call of one of these functions.
// Returns true if table or selection is balanced. bool IsTableComplexForChart( std::u16string_view aSel ) const;
// Search all content-bearing boxes of the base line on which this box stands. // rBoxes as a return value for immediate use. // bToTop = true -> up to base line, false-> else only line of box.
SW_DLLPUBLIC static SwSelBoxes& SelLineFromBox( const SwTableBox* pBox,
SwSelBoxes& rBoxes, bool bToTop = true );
// Get information from client. virtualbool GetInfo( SwFindNearestNode& ) const override;
// Search in format for registered table.
SW_DLLPUBLIC static SwTable * FindTable( SwFrameFormat const*const pFormat );
// Clean up structure of subtables a bit: // convert row with 1 box with subtable; box with subtable with 1 row; // by removing the subtable (both recursively) void GCLines();
// Returns the table node via m_TabSortContentBoxes or pTableNode.
SW_DLLPUBLIC SwTableNode* GetTableNode() const; void SetTableNode( SwTableNode* pNode ) { m_pTableNode = pNode; }
// is it a table deleted completely with change tracking bool IsDeleted() const; // is it a table with a deleted row or cell
SW_DLLPUBLIC bool HasDeletedRowOrCell() const; // it doesn't contain box content (except single empty nested tables of the boxes // which could remain after deletion of text content of the selected table) bool IsEmpty() const; void SwitchFormulasToExternalRepresentation()
{ UpdateFields(TBL_BOXNAME); }; void SwitchFormulasToRelativeRepresentation()
{ UpdateFields(TBL_RELBOXNAME); }; void SwitchFormulasToInternalRepresentation()
{ UpdateFields(TBL_BOXPTR); } void Merge(const SwTable& rTable, SwHistory* pHistory); void Split(const UIName& sNewTableName, sal_uInt16 nSplitLine, SwHistory* pHistory);
/// SwTableLine is one table row in the document model. class SW_DLLPUBLIC SwTableLine final : public SwClient // Client of FrameFormat.
{
SwTableBoxes m_aBoxes;
SwTableBox *m_pUpper;
RedlineType m_eRedlineType;
// it doesn't contain box content (except single empty nested tables of the boxes // which could remain after deletion of text content of the selected table row) bool IsEmpty() const;
// Update TextChangesOnly property based on the redlines of the table row. // rRedlinePos: search from this redline index to speed up SwTable::IsDeleted(). // bUpdateProperty: don't update HasTextChangesOnly property, if bUpdateProperty = false. // Set rRedlinePos after the last redline index of the table row. // Return with the redline, which associated to the row change (latest deletion // in the case of deleted row, the first insertion in the case of row insertion // or npos, if TextChangesOnly is true, i.e. the table row is not deleted or inserted). // Cache also the type of the redline associated to the changed table row.
SwRedlineTable::size_type UpdateTextChangesOnly(
SwRedlineTable::size_type& rRedlinePos, bool bUpdateProperty = true) const; // tracked text changes, i.e. a single redline can contain tables // get that redline for the table row, if it exists
SwRedlineTable::size_type GetTableRedline() const; // is it a tracked row bool IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted = false) const; // is it a tracked deleted row bool IsDeleted(SwRedlineTable::size_type& rRedlinePos) const; // set/get (if it's possible, cached) redline type
RedlineType GetRedlineType() const; void SetRedlineType(RedlineType eType) { m_eRedlineType = eType; }
/// SwTableBox is one table cell in the document model. class SW_DLLPUBLIC SwTableBox final : public SwClient //Client of FrameFormat.
{ friendclass SwNodes; // Transpose index. friendvoid DelBoxNode(SwTableSortBoxes const &); // Delete StartNode* ! friendclass SwXMLTableContext;
/// Do we contain any direct formatting? bool mbDirectFormatting;
// In case Format contains formulas/values already, // a new one must be created for the new box. static SwTableBoxFormat* CheckBoxFormat( SwTableBoxFormat* );
/// Set that this table box contains formatting that is not set by the table style. void SetDirectFormatting(bool bDirect) { mbDirectFormatting = bDirect; }
/// Do we contain any direct formatting (ie. something not affected by the table style)? bool HasDirectFormatting() const { return mbDirectFormatting; }
// Creates its own FrameFormat if more boxes depend on it.
SwTableBoxFormat* ClaimFrameFormat(); void ChgFrameFormat( SwTableBoxFormat *pNewFormat, bool bNeedToReregister = true );
void RemoveFromTable(); const SwStartNode *GetSttNd() const { return m_pStartNode; }
SwNodeOffset GetSttIdx() const; // it doesn't contain box content or if bWithRemainingNestedTable = true, // it contains only an empty nested table as box content (which // could remain after deletion of the text content of the selected box). bool IsEmpty( bool bWithRemainingNestedTable = true ) const;
// Search next/previous box with content.
SwTableBox* FindNextBox( const SwTable&, const SwTableBox*, bool bOvrTableLns=true ) const;
SwTableBox* FindPreviousBox( const SwTable&, const SwTableBox* ) const; // Return name of this box. It is determined dynamically and // is calculated from the position in the lines/boxes/table.
OUString GetName() const; // Return "value" of box (for calculating in table). double GetValue( SwTableCalcPara& rPara ) const;
// Computes "coordinates" of a box, used to computed selection // width or height when inserting cols or rows
Point GetCoordinates() const;
bool IsInHeadline( const SwTable* pTable ) const;
// Contains box contents, that can be formatted as a number? bool HasNumContent( double& rNum, sal_uInt32& rFormatIndex, bool& rIsEmptyTextNd ) const;
SwNodeOffset IsValidNumTextNd( bool bCheckAttr = true ) const; // If a table formula is set, test if box contents is congruent with number. // (For Redo of change of NumFormat!). bool IsNumberChanged() const;
// Is that a formula box or a box with numeric contents (AutoSum)? // What it is indicated by the return value - the WhichId of the attribute. // Empty boxes have the return value USHRT_MAX !!
sal_uInt16 IsFormulaOrValueBox() const;
// Loading of a document requires an actualization of cells with values void ActualiseValueBox();
// Access on internal data - currently used for the NumFormatter. const std::optional<Color>& GetSaveUserColor() const { return mxUserColor; } const std::optional<Color>& GetSaveNumFormatColor() const { return mxNumFormatColor; } void SetSaveUserColor(std::optional<Color> p ) { mxUserColor = p; } void SetSaveNumFormatColor( std::optional<Color> p ) { mxNumFormatColor = p; }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.