1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_TBLRWCL_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_TBLRWCL_HXX
25 #include <swtypes.hxx>
26 #include <swtable.hxx>
28 namespace editeng
{ class SvxBorderLine
; }
32 class SwTableBoxFormat
;
36 class SwShareBoxFormats
;
37 class SwFormatFrameSize
;
39 void sw_LineSetHeadCondColl( const SwTableLine
* pLine
);
42 void CheckBoxWidth( const SwTableLine
& rLine
, SwTwips nSize
);
45 void InsTableBox( SwDoc
& rDoc
, SwTableNode
* pTableNd
,
46 SwTableLine
* pLine
, SwTableBoxFormat
* pBoxFrameFormat
,
47 SwTableBox
* pBox
, sal_uInt16 nInsPos
, sal_uInt16 nCnt
= 1 );
49 void DeleteBox_( SwTable
& rTable
, SwTableBox
* pBox
, SwUndo
* pUndo
,
50 bool bCalcNewSize
, const bool bCorrBorder
,
51 SwShareBoxFormats
* pShareFormats
= nullptr );
54 * Class for SplitTable
55 * Collects the uppermost or lowermost Lines of a Box from a Line in an array.
56 * We also store their positions.
58 * @see implementation in ndtbl.cxx
60 class SwCollectTableLineBoxes
62 std::vector
<sal_uInt16
> m_aPositionArr
;
63 std::vector
<SwTableBox
*> m_Boxes
;
64 SwHistory
* m_pHistory
;
65 SplitTable_HeadlineOption m_nMode
;
67 bool m_bGetFromTop
: 1;
68 bool m_bGetValues
: 1;
71 SwCollectTableLineBoxes( bool bTop
, SplitTable_HeadlineOption nMd
= SplitTable_HeadlineOption::NONE
, SwHistory
* pHist
=nullptr )
73 m_pHistory( pHist
), m_nMode( nMd
), m_nWidth( 0 ),
74 m_bGetFromTop( bTop
), m_bGetValues( true )
78 void AddBox( const SwTableBox
& rBox
);
79 const SwTableBox
* GetBoxOfPos( const SwTableBox
& rBox
);
80 void AddToUndoHistory( const SwContentNode
& rNd
);
82 size_t Count() const { return m_Boxes
.size(); }
83 const SwTableBox
& GetBox( std::size_t nPos
, sal_uInt16
* pWidth
= nullptr ) const
85 // We need the EndPos of the column here!
87 *pWidth
= (nPos
+1 == m_aPositionArr
.size()) ? m_nWidth
88 : m_aPositionArr
[ nPos
+1 ];
89 return *m_Boxes
[ nPos
];
92 bool IsGetFromTop() const { return m_bGetFromTop
; }
93 bool IsGetValues() const { return m_bGetValues
; }
95 SplitTable_HeadlineOption
GetMode() const { return m_nMode
; }
96 void SetValues( bool bFlag
) { m_bGetValues
= false; m_nWidth
= 0;
97 m_bGetFromTop
= bFlag
; }
98 bool Resize( sal_uInt16 nOffset
, sal_uInt16 nWidth
);
101 void sw_Box_CollectBox( const SwTableBox
* pBox
, SwCollectTableLineBoxes
* pSplPara
);
102 bool sw_Line_CollectBox( const SwTableLine
*& rpLine
, void* pPara
);
104 void sw_BoxSetSplitBoxFormats( SwTableBox
* pBox
, SwCollectTableLineBoxes
* pSplPara
);
107 * This structure is needed by Undo to restore row span attributes
108 * when a table has been split into two tables
112 sal_uInt16 mnSplitLine
; // the line number where the table has been split
113 std::vector
< tools::Long
> mnRowSpans
; // the row span attributes in this line
114 SwSaveRowSpan( SwTableBoxes
& rBoxes
, sal_uInt16 nSplitLn
);
117 struct SwGCLineBorder
119 const SwTableLines
* pLines
;
120 SwShareBoxFormats
* pShareFormats
;
123 SwGCLineBorder( const SwTable
& rTable
)
124 : pLines( &rTable
.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {}
126 SwGCLineBorder( const SwTableBox
& rBox
)
127 : pLines( &rBox
.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {}
128 bool IsLastLine() const { return nLinePos
+ 1 >= o3tl::narrowing
<sal_uInt16
>(pLines
->size()); }
131 class SwGCBorder_BoxBrd
133 const editeng::SvxBorderLine
* m_pBorderLine
;
134 bool m_bAnyBorderFind
;
136 SwGCBorder_BoxBrd() : m_pBorderLine( nullptr ), m_bAnyBorderFind( false ) {}
138 void SetBorder( const editeng::SvxBorderLine
& rBorderLine
)
139 { m_pBorderLine
= &rBorderLine
; m_bAnyBorderFind
= false; }
142 * Check whether the left Border is the same as the set one
143 * @returns false if no Border was set
145 bool CheckLeftBorderOfFormat( const SwFrameFormat
& rFormat
);
147 bool IsAnyBorderFound() const { return m_bAnyBorderFind
; }
150 void sw_GC_Line_Border( const SwTableLine
* pLine
, SwGCLineBorder
* pGCPara
);
152 class SwShareBoxFormat
154 const SwFrameFormat
* m_pOldFormat
;
155 std::vector
<SwFrameFormat
*> m_aNewFormats
;
158 SwShareBoxFormat( const SwFrameFormat
& rFormat
)
159 : m_pOldFormat( &rFormat
)
162 const SwFrameFormat
& GetOldFormat() const { return *m_pOldFormat
; }
164 SwFrameFormat
* GetFormat( tools::Long nWidth
) const;
165 SwFrameFormat
* GetFormat( const SfxPoolItem
& rItem
) const;
166 void AddFormat( SwFrameFormat
& rFormat
);
167 /// @returns true, if we can delete
168 bool RemoveFormat( const SwFrameFormat
& rFormat
);
171 class SwShareBoxFormats
173 std::vector
<SwShareBoxFormat
> m_ShareArr
;
175 bool Seek_Entry( const SwFrameFormat
& rFormat
, sal_uInt16
* pPos
) const;
177 void ChangeFrameFormat( SwTableBox
* pBox
, SwTableLine
* pLn
, SwFrameFormat
& rFormat
);
180 SwShareBoxFormats() {}
181 ~SwShareBoxFormats();
183 SwFrameFormat
* GetFormat( const SwFrameFormat
& rFormat
, tools::Long nWidth
) const;
184 SwFrameFormat
* GetFormat( const SwFrameFormat
& rFormat
, const SfxPoolItem
& ) const;
186 void AddFormat( const SwFrameFormat
& rOld
, SwFrameFormat
& rNew
);
188 void SetSize( SwTableBox
& rBox
, const SwFormatFrameSize
& rSz
);
189 void SetAttr( SwTableBox
& rBox
, const SfxPoolItem
& rItem
);
190 void SetAttr( SwTableLine
& rLine
, const SfxPoolItem
& rItem
);
192 void RemoveFormat( const SwFrameFormat
& rFormat
);
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */