Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _TBLRWCL_HXX
29 : : #define _TBLRWCL_HXX
30 : : #include <cstddef>
31 : : #include <vector>
32 : : #include <swtypes.hxx>
33 : : #include <tblsel.hxx>
34 : : #include <swtable.hxx>
35 : :
36 : : namespace editeng { class SvxBorderLine; }
37 : :
38 : : class SwDoc;
39 : : class SwTableNode;
40 : : class SwTableLine;
41 : : class SwTableBox;
42 : : class SwTableBoxFmt;
43 : : class SwHistory;
44 : : class SwCntntNode;
45 : : class SfxPoolItem;
46 : : class SwShareBoxFmts;
47 : : class SwFmtFrmSize;
48 : : struct _CpyPara;
49 : : struct _InsULPara;
50 : :
51 : : void lcl_LineSetHeadCondColl( const SwTableLine* pLine );
52 : :
53 : :
54 : : #ifdef DBG_UTIL
55 : : void _CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize );
56 : : #endif
57 : :
58 : : void _InsTblBox( SwDoc* pDoc, SwTableNode* pTblNd,
59 : : SwTableLine* pLine, SwTableBoxFmt* pBoxFrmFmt,
60 : : SwTableBox* pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
61 : :
62 : : SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0,
63 : : sal_Bool bCalcNewSize = sal_True, const sal_Bool bCorrBorder = sal_True,
64 : : SwShareBoxFmts* pShareFmts = 0 );
65 : :
66 : : // Klasse fuers SplitTable
67 : : // sammelt von einer Line die Boxen aller obersten oder untersten Lines
68 : : // in einem Array. Zusaetzlich werden die Positionen vermerkt.
69 : : // ( die Implementierung steht im ndtbl.cxx)
70 : :
71 : 0 : class SwCollectTblLineBoxes
72 : : {
73 : : std::vector<sal_uInt16> aPosArr;
74 : : std::vector<SwTableBox*> m_Boxes;
75 : : SwHistory* pHst;
76 : : sal_uInt16 nMode, nWidth;
77 : : sal_Bool bGetFromTop : 1;
78 : : sal_Bool bGetValues : 1;
79 : :
80 : : public:
81 : 0 : SwCollectTblLineBoxes( sal_Bool bTop, sal_uInt16 nMd = 0, SwHistory* pHist=0 )
82 : : :
83 : : pHst( pHist ), nMode( nMd ), nWidth( 0 ),
84 [ # # ]: 0 : bGetFromTop( bTop ), bGetValues( sal_True )
85 : :
86 : 0 : {}
87 : :
88 : : void AddBox( const SwTableBox& rBox );
89 : : const SwTableBox* GetBoxOfPos( const SwTableBox& rBox );
90 : : void AddToUndoHistory( const SwCntntNode& rNd );
91 : :
92 : 0 : size_t Count() const { return m_Boxes.size(); }
93 : 0 : const SwTableBox& GetBox( std::size_t nPos, sal_uInt16* pWidth = 0 ) const
94 : : {
95 : : // hier wird die EndPos der Spalte benoetigt!
96 [ # # ]: 0 : if( pWidth )
97 : 0 : *pWidth = (nPos+1 == aPosArr.size()) ? nWidth
98 [ # # ]: 0 : : aPosArr[ nPos+1 ];
99 : 0 : return *m_Boxes[ nPos ];
100 : : }
101 : :
102 : 0 : sal_Bool IsGetFromTop() const { return bGetFromTop; }
103 : 0 : sal_Bool IsGetValues() const { return bGetValues; }
104 : :
105 : 0 : sal_uInt16 GetMode() const { return nMode; }
106 : 0 : void SetValues( sal_Bool bFlag ) { bGetValues = sal_False; nWidth = 0;
107 : 0 : bGetFromTop = bFlag; }
108 : : sal_Bool Resize( sal_uInt16 nOffset, sal_uInt16 nWidth );
109 : : };
110 : :
111 : : void lcl_Box_CollectBox( const SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara );
112 : : sal_Bool lcl_Line_CollectBox( const SwTableLine*& rpLine, void* pPara );
113 : :
114 : : void lcl_BoxSetSplitBoxFmts( SwTableBox* pBox, SwCollectTblLineBoxes* pSplPara );
115 : :
116 : : // This structure is needed by Undo to restore row span attributes
117 : : // when a table has been splitted into two tables
118 : 0 : struct SwSaveRowSpan
119 : : {
120 : : sal_uInt16 mnSplitLine; // the line number where the table has been splitted
121 : : std::vector< long > mnRowSpans; // the row span attributes in this line
122 : : SwSaveRowSpan( SwTableBoxes& rBoxes, sal_uInt16 nSplitLn );
123 : : };
124 : :
125 : : struct _SwGCLineBorder
126 : : {
127 : : const SwTableLines* pLines;
128 : : SwShareBoxFmts* pShareFmts;
129 : : sal_uInt16 nLinePos;
130 : :
131 : 0 : _SwGCLineBorder( const SwTable& rTable )
132 : 0 : : pLines( &rTable.GetTabLines() ), pShareFmts(0), nLinePos( 0 ) {}
133 : :
134 : 0 : _SwGCLineBorder( const SwTableBox& rBox )
135 : 0 : : pLines( &rBox.GetTabLines() ), pShareFmts(0), nLinePos( 0 ) {}
136 : 0 : sal_Bool IsLastLine() const { return nLinePos + 1 >= (sal_uInt16)pLines->size(); }
137 : : };
138 : :
139 : : class _SwGCBorder_BoxBrd
140 : : {
141 : : const editeng::SvxBorderLine* pBrdLn;
142 : : sal_Bool bAnyBorderFnd;
143 : : public:
144 : 0 : _SwGCBorder_BoxBrd() : pBrdLn( 0 ), bAnyBorderFnd( sal_False ) {}
145 : :
146 : 0 : void SetBorder( const editeng::SvxBorderLine& rBorderLine )
147 : 0 : { pBrdLn = &rBorderLine; bAnyBorderFnd = sal_False; }
148 : :
149 : : // checke, ob die linke Border dieselbe wie die gesetzte ist
150 : : // returnt sal_False falls gar keine Border gesetzt ist
151 : : sal_Bool CheckLeftBorderOfFormat( const SwFrmFmt& rFmt );
152 : :
153 : 0 : sal_Bool IsAnyBorderFound() const { return bAnyBorderFnd; }
154 : : };
155 : :
156 : : void lcl_GC_Line_Border( const SwTableLine* pLine, _SwGCLineBorder* pGCPara );
157 : :
158 : :
159 : 375 : class SwShareBoxFmt
160 : : {
161 : : const SwFrmFmt* pOldFmt;
162 : : std::vector<SwFrmFmt*> aNewFmts;
163 : :
164 : : public:
165 : 375 : SwShareBoxFmt( const SwFrmFmt& rFmt )
166 : 375 : : pOldFmt( &rFmt )
167 : 375 : {}
168 : :
169 : 1278 : const SwFrmFmt& GetOldFormat() const { return *pOldFmt; }
170 : :
171 : : SwFrmFmt* GetFormat( long nWidth ) const;
172 : : SwFrmFmt* GetFormat( const SfxPoolItem& rItem ) const;
173 : : void AddFormat( SwFrmFmt& rFmt );
174 : : // returnt sal_True, wenn geloescht werden kann
175 : : bool RemoveFormat( const SwFrmFmt& rFmt );
176 : : };
177 : :
178 : :
179 : : typedef boost::ptr_vector<SwShareBoxFmt> _SwShareBoxFmts;
180 : :
181 : : class SwShareBoxFmts
182 : : {
183 : : _SwShareBoxFmts aShareArr;
184 : : sal_Bool Seek_Entry( const SwFrmFmt& rFmt, sal_uInt16* pPos ) const;
185 : :
186 : : void ChangeFrmFmt( SwTableBox* pBox, SwTableLine* pLn, SwFrmFmt& rFmt );
187 : :
188 : : public:
189 : 193 : SwShareBoxFmts() {}
190 : : ~SwShareBoxFmts();
191 : :
192 : : SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, long nWidth ) const;
193 : : SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, const SfxPoolItem& ) const;
194 : :
195 : : void AddFormat( const SwFrmFmt& rOld, SwFrmFmt& rNew );
196 : :
197 : : void SetSize( SwTableBox& rBox, const SwFmtFrmSize& rSz );
198 : : void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem );
199 : : void SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem );
200 : :
201 : : void RemoveFormat( const SwFrmFmt& rFmt );
202 : : };
203 : :
204 : :
205 : :
206 : : #endif
207 : :
208 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|