LibreOffice Module sw (master)  1
Classes | Macros | Typedefs | Functions
swnewtable.cxx File Reference
#include <swtable.hxx>
#include <tblsel.hxx>
#include <tblrwcl.hxx>
#include <ndtxt.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 <IDocumentLayoutAccess.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 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...
 
struct  RowSpanCheck
 

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 (long &rMin, long &rMax, const SwTableLine &rLine, size_t nCheck, bool bSet)
 lcl_CheckMinMax helps evaluating (horizontal) min/max of boxes More...
 
static long lcl_Box2LeftBorder (const SwTableBox &rBox)
 lcl_Box2LeftBorder(..) delivers the left (logical) border of a table box More...
 
static SwTableBoxlcl_LeftBorder2Box (long nLeft, const SwTableLine *pLine)
 lcl_LeftBorder2Box delivers the box to a given left border More...
 
static void lcl_ChangeRowSpan (const SwTable &rTable, const 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 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, long nMin, 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

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

Typedef Documentation

typedef std::pair< sal_uInt16, sal_uInt16 > SwLineOffset

Definition at line 1201 of file swnewtable.cxx.

typedef std::vector< SwLineOffset > SwLineOffsetArray

Definition at line 1202 of file swnewtable.cxx.

Definition at line 1299 of file swnewtable.cxx.

Function Documentation

static 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 159 of file swnewtable.cxx.

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

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

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 1305 of file swnewtable.cxx.

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

Referenced by SwTable::NewSplitRow().

static void lcl_ChangeRowSpan ( const SwTable rTable,
const 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 254 of file swnewtable.cxx.

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

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

static void lcl_CheckMinMax ( long &  rMin,
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 121 of file swnewtable.cxx.

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

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

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 1156 of file swnewtable.cxx.

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

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

static void lcl_getAllMergedBoxes ( const SwTable rTable,
SwSelBoxes rBoxes,
SwTableBox rBox 
)
static
static 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 605 of file swnewtable.cxx.

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

Referenced by SwTable::NewInsertCol().

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 586 of file swnewtable.cxx.

References SwTableBox::GetFrameFormat(), SwFrame::GetLower(), and SwFrame::InvalidateSize_().

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

static SwTableBox* lcl_LeftBorder2Box ( 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 194 of file swnewtable.cxx.

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

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

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 1367 of file swnewtable.cxx.

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

Referenced by SwTable::InsertRow().

static void lcl_SearchSelBox ( const SwTable rTable,
SwSelBoxes rBoxes,
long  nMin,
long  nMax,
SwTableLine rLine,
bool  bChkProtected,
bool  bColumn 
)
static
static void lcl_SophisticatedFillLineIndices ( SwLineOffsetArray rArr,
const SwTable rTable,
const SwSelBoxes rBoxes,
sal_uInt16  nCnt 
)
static
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 1103 of file swnewtable.cxx.

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

Referenced by SwTable::NewSplitRow().