LibreOffice Module sw (master) 1
Classes | Macros | Typedefs | Functions
swnewtable.cxx File Reference
#include <swtable.hxx>
#include <swcrsr.hxx>
#include <tblsel.hxx>
#include <tblrwcl.hxx>
#include <ndtxt.hxx>
#include <ndole.hxx>
#include <node.hxx>
#include <UndoTable.hxx>
#include <pam.hxx>
#include <frmfmt.hxx>
#include <frmatr.hxx>
#include <cellfrm.hxx>
#include <fmtfsize.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentContentOperations.hxx>
#include <IDocumentFieldsAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <cstdlib>
#include <vector>
#include <set>
#include <list>
#include <memory>
#include <editeng/boxitem.hxx>
#include <editeng/protitem.hxx>
#include <swtblfmt.hxx>
#include <calbck.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
Include dependency graph for swnewtable.cxx:

Go to the source code of this file.

Classes

class  SwBoxSelection
 SwBoxSelection is a small helperclass (structure) to handle selections of cells (boxes) between table functions. More...
 

Macros

#define CHECK_TABLE(t)   (t).CheckConsistency();
 

Typedefs

typedef std::pair< sal_uInt16, sal_uInt16 > SwLineOffset
 
typedef std::vector< SwLineOffsetSwLineOffsetArray
 
typedef std::set< SwTwipsSwSplitLines
 

Functions

static void lcl_CheckMinMax (tools::Long &rMin, tools::Long &rMax, const SwTableLine &rLine, size_t nCheck, bool bSet)
 lcl_CheckMinMax helps evaluating (horizontal) min/max of boxes More...
 
static tools::Long lcl_Box2LeftBorder (const SwTableBox &rBox)
 lcl_Box2LeftBorder(..) delivers the left (logical) border of a table box More...
 
static SwTableBoxlcl_LeftBorder2Box (tools::Long nLeft, const SwTableLine *pLine)
 lcl_LeftBorder2Box delivers the box to a given left border More...
 
static void lcl_ChangeRowSpan (const SwTable &rTable, const tools::Long nDiff, sal_uInt16 nRowIdx, const bool bSingle)
 lcl_ChangeRowSpan corrects row span after insertion/deletion of rows More...
 
static void lcl_InvalidateCellFrame (const SwTableBox &rBox)
 lcl_InvalidateCellFrame(..) invalidates all layout representations of a given cell to initiate a reformatting More...
 
static tools::Long lcl_InsertPosition (SwTable &rTable, std::vector< sal_uInt16 > &rInsPos, const SwSelBoxes &rBoxes, bool bBehind)
 lcl_InsertPosition(..) evaluates the insert positions in every table line, when a selection of cells is given and returns the average cell widths More...
 
static void lcl_getAllMergedBoxes (const SwTable &rTable, SwSelBoxes &rBoxes, SwTableBox &rBox)
 lcl_getAllMergedBoxes(..) collects all overlapped boxes to a given (master) box More...
 
static void lcl_UnMerge (const SwTable &rTable, SwTableBox &rBox, size_t nCnt, bool bSameHeight)
 lcl_UnMerge(..) manipulates the row span attribute of a given master cell and its overlapped cells to split them into several pieces. More...
 
static void lcl_FillSelBoxes (SwSelBoxes &rBoxes, SwTableLine &rLine)
 lcl_FillSelBoxes(..) puts all boxes of a given line into the selection structure More...
 
static void lcl_SophisticatedFillLineIndices (SwLineOffsetArray &rArr, const SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nCnt)
 
static sal_uInt16 lcl_CalculateSplitLineHeights (SwSplitLines &rCurr, SwSplitLines &rNew, const SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nCnt)
 lcl_CalculateSplitLineHeights(..) delivers all y-positions where table rows have to be split to fulfill the requested "split same height" More...
 
static sal_uInt16 lcl_LineIndex (const SwTable &rTable, const SwSelBoxes &rBoxes, bool bBehind)
 lcl_LineIndex(..) delivers the line index of the line behind or above the box selection. More...
 
static void lcl_SearchSelBox (const SwTable &rTable, SwSelBoxes &rBoxes, tools::Long nMin, tools::Long nMax, SwTableLine &rLine, bool bChkProtected, bool bColumn)
 lcl_SearchSelBox(..) adds cells of a given table row to the selection structure if it overlaps with the given x-position range More...
 

Macro Definition Documentation

◆ CHECK_TABLE

#define CHECK_TABLE (   t)    (t).CheckConsistency();

Definition at line 52 of file swnewtable.cxx.

Typedef Documentation

◆ SwLineOffset

typedef std::pair< sal_uInt16, sal_uInt16 > SwLineOffset

Definition at line 1221 of file swnewtable.cxx.

◆ SwLineOffsetArray

typedef std::vector< SwLineOffset > SwLineOffsetArray

Definition at line 1222 of file swnewtable.cxx.

◆ SwSplitLines

Definition at line 1319 of file swnewtable.cxx.

Function Documentation

◆ lcl_Box2LeftBorder()

static tools::Long lcl_Box2LeftBorder ( const SwTableBox rBox)
static

lcl_Box2LeftBorder(..) delivers the left (logical) border of a table box

The left logical border of a table box is the sum of the cell width before this box.

Parameters
rBoxis the requested table box
Returns
is the left logical border (long, even it cannot be negative)

Definition at line 164 of file swnewtable.cxx.

References SwTableBox::GetFrameFormat(), SwFormat::GetFrameSize(), SwTableLine::GetTabBoxes(), SwTableBox::GetUpper(), SvxSizeItem::GetWidth(), and nCount.

Referenced by SwTableBox::FindEndOfRowSpan(), SwTableBox::FindStartOfRowSpan(), lcl_getAllMergedBoxes(), SwTable::PrepareDelBoxes(), and SwTable::RestoreRowSpan().

◆ lcl_CalculateSplitLineHeights()

static sal_uInt16 lcl_CalculateSplitLineHeights ( SwSplitLines rCurr,
SwSplitLines rNew,
const SwTable rTable,
const SwSelBoxes rBoxes,
sal_uInt16  nCnt 
)
static

lcl_CalculateSplitLineHeights(..) delivers all y-positions where table rows have to be split to fulfill the requested "split same height"

Definition at line 1325 of file swnewtable.cxx.

References SwTableLines::GetPos(), SwTableBox::getRowSpan(), SwTable::GetTabLines(), SwTableBox::GetUpper(), i, SwTableLines::insert(), and o3tl::sorted_vector< typename Value, typename Compare, template< typename, typename > class Find, bool >::size().

Referenced by SwTable::NewSplitRow().

◆ lcl_ChangeRowSpan()

static void lcl_ChangeRowSpan ( const SwTable rTable,
const tools::Long  nDiff,
sal_uInt16  nRowIdx,
const bool  bSingle 
)
static

lcl_ChangeRowSpan corrects row span after insertion/deletion of rows

lcl_ChangeRowSpan(..) has to be called after an insertion or deletion of rows to adjust the row spans of previous rows accordingly. If rows are deleted, the previous rows with row spans into the deleted area have to be decremented by the number of overlapped inserted rows. If rows are inserted, the previous rows with row span into the inserted area have to be incremented by the number of inserted rows. For those row spans which ends exactly above the inserted area it has to be decided by the parameter bSingle if they have to be expanded or not.

Parameters
rTablethe table to manipulate (has to be a new model table)
nDiffthe number of rows which has been inserted (nDiff > 0) or deleted (nDiff < 0)
nRowIdxthe index of the first row which has to be checked
bSingletrue if the new inserted row should not extend row spans which ends in the row above this is for rows inserted by UI "insert row" false if all cells of an inserted row has to be overlapped by the previous row this is for rows inserted by "split row" false is also needed for deleted rows

Definition at line 259 of file swnewtable.cxx.

References SwTableLine::GetTabBoxes(), SwTable::GetTabLines(), and SwTableLines::size().

Referenced by SwTable::CleanUpBottomRowSpan(), SwTable::ConvertSubtableBox(), SwTable::InsertRow(), and SwTable::InsertSpannedRow().

◆ lcl_CheckMinMax()

static void lcl_CheckMinMax ( tools::Long rMin,
tools::Long rMax,
const SwTableLine rLine,
size_t  nCheck,
bool  bSet 
)
static

lcl_CheckMinMax helps evaluating (horizontal) min/max of boxes

lcl_CheckMinMax(..) compares the left border and the right border of a given cell with the given range and sets it accordingly.

Parameters
rMinwill be decremented if necessary to the left border of the cell
rMaxwill be incremented if necessary to the right border of the cell
rLinethe row (table line) of the interesting box
nCheckthe index of the box in the table box array of the given row
bSetif bSet is false, rMin and rMax will be manipulated if necessary if bSet is true, rMin and rMax will be set to the left and right border of the box

Definition at line 126 of file swnewtable.cxx.

References SwTableBox::GetFrameFormat(), SwFormat::GetFrameSize(), SwTableLine::GetTabBoxes(), and SvxSizeItem::GetWidth().

Referenced by SwTable::CollectBoxSelection(), SwTable::CreateSelection(), and SwTable::ExpandColumnSelection().

◆ lcl_FillSelBoxes()

static void lcl_FillSelBoxes ( SwSelBoxes rBoxes,
SwTableLine rLine 
)
static

lcl_FillSelBoxes(..) puts all boxes of a given line into the selection structure

Definition at line 1176 of file swnewtable.cxx.

References SwTableLine::GetTabBoxes(), i, and o3tl::sorted_vector< typename Value, typename Compare, template< typename, typename > class Find, bool >::insert().

Referenced by SwTable::InsertRow(), and SwTable::InsertSpannedRow().

◆ lcl_getAllMergedBoxes()

static void lcl_getAllMergedBoxes ( const SwTable rTable,
SwSelBoxes rBoxes,
SwTableBox rBox 
)
static

◆ lcl_InsertPosition()

static tools::Long lcl_InsertPosition ( SwTable rTable,
std::vector< sal_uInt16 > &  rInsPos,
const SwSelBoxes rBoxes,
bool  bBehind 
)
static

lcl_InsertPosition(..) evaluates the insert positions in every table line, when a selection of cells is given and returns the average cell widths

Definition at line 610 of file swnewtable.cxx.

References SwTableLine::GetBoxPos(), SwTableLines::GetPos(), SwTable::GetTabLines(), SwTableBox::GetUpper(), nCount, and o3tl::sorted_vector< typename Value, typename Compare, template< typename, typename > class Find, bool >::size().

Referenced by SwTable::NewInsertCol().

◆ lcl_InvalidateCellFrame()

static void lcl_InvalidateCellFrame ( const SwTableBox rBox)
static

lcl_InvalidateCellFrame(..) invalidates all layout representations of a given cell to initiate a reformatting

Definition at line 591 of file swnewtable.cxx.

References SwIterator< TElementType, TSource, eMode >::First(), SwTableBox::GetFrameFormat(), SwFrame::GetLower(), SwFrame::InvalidateSize_(), and SwIterator< TElementType, TSource, eMode >::Next().

Referenced by lcl_UnMerge(), and SwTable::PrepareDelBoxes().

◆ lcl_LeftBorder2Box()

static SwTableBox * lcl_LeftBorder2Box ( tools::Long  nLeft,
const SwTableLine pLine 
)
static

lcl_LeftBorder2Box delivers the box to a given left border

It's used to find the master/follow table boxes in previous/next rows. Don't call this function to check if there is such a box, call it if you know there has to be such box.

Parameters
nLeftthe left border (logical x-value) of the demanded box
rLinethe row (table line) to be scanned
Returns
a pointer to the table box inside the given row with the wished left border

Definition at line 199 of file swnewtable.cxx.

References abs(), SwTableBox::GetFrameFormat(), SwFormat::GetFrameSize(), SwTableLine::GetTabBoxes(), SvxSizeItem::GetWidth(), nCount, and SAL_WARN.

Referenced by SwTableBox::FindEndOfRowSpan(), SwTableBox::FindStartOfRowSpan(), lcl_getAllMergedBoxes(), SwTable::PrepareDelBoxes(), and SwTable::RestoreRowSpan().

◆ lcl_LineIndex()

static sal_uInt16 lcl_LineIndex ( const SwTable rTable,
const SwSelBoxes rBoxes,
bool  bBehind 
)
static

lcl_LineIndex(..) delivers the line index of the line behind or above the box selection.

Definition at line 1387 of file swnewtable.cxx.

References SwTableLines::GetPos(), SwTableBox::getRowSpan(), SwTable::GetTabLines(), i, nPos, and o3tl::sorted_vector< typename Value, typename Compare, template< typename, typename > class Find, bool >::size().

Referenced by SwTable::InsertRow().

◆ lcl_SearchSelBox()

static void lcl_SearchSelBox ( const SwTable rTable,
SwSelBoxes rBoxes,
tools::Long  nMin,
tools::Long  nMax,
SwTableLine rLine,
bool  bChkProtected,
bool  bColumn 
)
static

◆ lcl_SophisticatedFillLineIndices()

static void lcl_SophisticatedFillLineIndices ( SwLineOffsetArray rArr,
const SwTable rTable,
const SwSelBoxes rBoxes,
sal_uInt16  nCnt 
)
static

◆ lcl_UnMerge()

static void lcl_UnMerge ( const SwTable rTable,
SwTableBox rBox,
size_t  nCnt,
bool  bSameHeight 
)
static

lcl_UnMerge(..) manipulates the row span attribute of a given master cell and its overlapped cells to split them into several pieces.

Definition at line 1123 of file swnewtable.cxx.

References SwTableLine::GetFrameFormat(), SwFormat::GetFrameSize(), SvxSizeItem::GetHeight(), i, lcl_getAllMergedBoxes(), lcl_InvalidateCellFrame(), nCount, and o3tl::sorted_vector< typename Value, typename Compare, template< typename, typename > class Find, bool >::size().

Referenced by SwTable::NewSplitRow().