docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / core / inc / tblrwcl.hxx
blobe0255e7717d4094681de26dff9de7cb9cb57ba05
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
22 #include <cstddef>
23 #include <vector>
25 #include <swtypes.hxx>
26 #include <swtable.hxx>
28 namespace editeng { class SvxBorderLine; }
30 class SwDoc;
31 class SwTableNode;
32 class SwTableBoxFormat;
33 class SwHistory;
34 class SwContentNode;
35 class SfxPoolItem;
36 class SwShareBoxFormats;
37 class SwFormatFrameSize;
39 void sw_LineSetHeadCondColl( const SwTableLine* pLine );
41 #if defined DBG_UTIL
42 void CheckTableLayout(const SwTableLines& rLines);
43 SwTwips CheckBoxWidth(const SwTableLines& rLines, const SwFrameFormat& rFrameFormat );
44 #endif
46 void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd,
47 SwTableLine* pLine, SwTableBoxFormat* pBoxFrameFormat,
48 SwTableBox* pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
50 void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* pUndo,
51 bool bCalcNewSize, const bool bCorrBorder,
52 SwShareBoxFormats* pShareFormats = nullptr );
54 /**
55 * Class for SplitTable
56 * Collects the uppermost or lowermost Lines of a Box from a Line in an array.
57 * We also store their positions.
59 * @see implementation in ndtbl.cxx
61 class SwCollectTableLineBoxes
63 std::vector<sal_uInt16> m_aPositionArr;
64 std::vector<SwTableBox*> m_Boxes;
65 SwHistory* m_pHistory;
66 SplitTable_HeadlineOption m_nMode;
67 sal_uInt16 m_nWidth;
68 bool m_bGetFromTop : 1;
69 bool m_bGetValues : 1;
71 public:
72 SwCollectTableLineBoxes( bool bTop, SplitTable_HeadlineOption nMd = SplitTable_HeadlineOption::NONE, SwHistory* pHist=nullptr )
74 m_pHistory( pHist ), m_nMode( nMd ), m_nWidth( 0 ),
75 m_bGetFromTop( bTop ), m_bGetValues( true )
79 void AddBox( const SwTableBox& rBox );
80 const SwTableBox* GetBoxOfPos( const SwTableBox& rBox );
81 void AddToUndoHistory( const SwContentNode& rNd );
83 size_t Count() const { return m_Boxes.size(); }
84 const SwTableBox& GetBox( std::size_t nPos, sal_uInt16* pWidth = nullptr ) const
86 // We need the EndPos of the column here!
87 if( pWidth )
88 *pWidth = (nPos+1 == m_aPositionArr.size()) ? m_nWidth
89 : m_aPositionArr[ nPos+1 ];
90 return *m_Boxes[ nPos ];
93 bool IsGetFromTop() const { return m_bGetFromTop; }
94 bool IsGetValues() const { return m_bGetValues; }
96 SplitTable_HeadlineOption GetMode() const { return m_nMode; }
97 void SetValues( bool bFlag ) { m_bGetValues = false; m_nWidth = 0;
98 m_bGetFromTop = bFlag; }
99 bool Resize( sal_uInt16 nOffset, sal_uInt16 nWidth );
102 void sw_Box_CollectBox( const SwTableBox* pBox, SwCollectTableLineBoxes* pSplPara );
103 bool sw_Line_CollectBox( const SwTableLine*& rpLine, void* pPara );
105 void sw_BoxSetSplitBoxFormats( SwTableBox* pBox, SwCollectTableLineBoxes* pSplPara );
108 * This structure is needed by Undo to restore row span attributes
109 * when a table has been split into two tables
111 struct SwSaveRowSpan
113 sal_uInt16 mnSplitLine; // the line number where the table has been split
114 std::vector< tools::Long > mnRowSpans; // the row span attributes in this line
115 SwSaveRowSpan( SwTableBoxes& rBoxes, sal_uInt16 nSplitLn );
118 struct SwGCLineBorder
120 const SwTableLines* pLines;
121 SwShareBoxFormats* pShareFormats;
122 sal_uInt16 nLinePos;
124 SwGCLineBorder( const SwTable& rTable )
125 : pLines( &rTable.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {}
127 SwGCLineBorder( const SwTableBox& rBox )
128 : pLines( &rBox.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {}
129 bool IsLastLine() const { return nLinePos + 1 >= o3tl::narrowing<sal_uInt16>(pLines->size()); }
132 class SwGCBorder_BoxBrd
134 const editeng::SvxBorderLine* m_pBorderLine;
135 bool m_bAnyBorderFind;
136 public:
137 SwGCBorder_BoxBrd() : m_pBorderLine( nullptr ), m_bAnyBorderFind( false ) {}
139 void SetBorder( const editeng::SvxBorderLine& rBorderLine )
140 { m_pBorderLine = &rBorderLine; m_bAnyBorderFind = false; }
143 * Check whether the left Border is the same as the set one
144 * @returns false if no Border was set
146 bool CheckLeftBorderOfFormat( const SwFrameFormat& rFormat );
148 bool IsAnyBorderFound() const { return m_bAnyBorderFind; }
151 void sw_GC_Line_Border( const SwTableLine* pLine, SwGCLineBorder* pGCPara );
153 class SwShareBoxFormat
155 const SwFrameFormat* m_pOldFormat;
156 std::vector<SwFrameFormat*> m_aNewFormats;
158 public:
159 SwShareBoxFormat( const SwFrameFormat& rFormat )
160 : m_pOldFormat( &rFormat )
163 const SwFrameFormat& GetOldFormat() const { return *m_pOldFormat; }
165 SwFrameFormat* GetFormat( tools::Long nWidth ) const;
166 SwFrameFormat* GetFormat( const SfxPoolItem& rItem ) const;
167 void AddFormat( SwFrameFormat& rFormat );
168 /// @returns true, if we can delete
169 bool RemoveFormat( const SwFrameFormat& rFormat );
172 class SwShareBoxFormats
174 std::vector<SwShareBoxFormat> m_ShareArr;
176 bool Seek_Entry( const SwFrameFormat& rFormat, sal_uInt16* pPos ) const;
178 void ChangeFrameFormat( SwTableBox* pBox, SwTableLine* pLn, SwFrameFormat& rFormat );
180 public:
181 SwShareBoxFormats() {}
182 ~SwShareBoxFormats();
184 SwFrameFormat* GetFormat( const SwFrameFormat& rFormat, tools::Long nWidth ) const;
185 SwFrameFormat* GetFormat( const SwFrameFormat& rFormat, const SfxPoolItem& ) const;
187 void AddFormat( const SwFrameFormat& rOld, SwFrameFormat& rNew );
189 void SetSize( SwTableBox& rBox, const SwFormatFrameSize& rSz );
190 void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem );
191 void SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem );
193 void RemoveFormat( const SwFrameFormat& rFormat );
196 #endif
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */