LibreOffice Module sw (master)  1
tblcpy.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <hintids.hxx>
21 
22 #include <svl/zforlist.hxx>
23 #include <frmfmt.hxx>
24 #include <doc.hxx>
25 #include <IDocumentUndoRedo.hxx>
31 #include <cntfrm.hxx>
32 #include <pam.hxx>
33 #include <swtable.hxx>
34 #include <ndtxt.hxx>
35 #include <fldbas.hxx>
36 #include <tblsel.hxx>
37 #include <tabfrm.hxx>
38 #include <poolfmt.hxx>
39 #include <cellatr.hxx>
40 #include <mvsave.hxx>
41 #include <docary.hxx>
42 #include <fmtanchr.hxx>
43 #include <hints.hxx>
44 #include <UndoTable.hxx>
45 #include <redline.hxx>
46 #include <fmtfsize.hxx>
47 #include <deque>
48 #include <memory>
49 #include <numeric>
50 
51 static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox,
52  SwTable& rDstTable, SwTableBox* pDstBox,
53  bool bDelContent, SwUndoTableCpyTable* pUndo );
54 
55 // The following type will be used by table copy functions to describe
56 // the structure of tables (or parts of tables).
57 // It's for new table model only.
58 
59 namespace
60 {
61  struct BoxSpanInfo
62  {
63  SwTableBox* mpBox;
64  SwTableBox* mpCopy;
65  sal_uInt16 mnColSpan;
66  bool mbSelected;
67  };
68 
69  typedef std::vector< BoxSpanInfo > BoxStructure;
70  typedef std::vector< BoxStructure > LineStructure;
71  typedef std::deque< sal_uLong > ColumnStructure;
72 
73  struct SubBox
74  {
75  SwTableBox *mpBox;
76  bool mbCovered;
77  };
78 
79  typedef std::vector< SubBox > SubLine;
80  typedef std::vector< SubLine > SubTable;
81 
82  class TableStructure
83  {
84  public:
85  LineStructure maLines;
86  ColumnStructure maCols;
87  sal_uInt16 mnStartCol;
88  sal_uInt16 mnAddLine;
89  void addLine( sal_uInt16 &rLine, const SwTableBoxes&, const SwSelBoxes*,
90  bool bNewModel );
91  void addBox( sal_uInt16 nLine, const SwSelBoxes*, SwTableBox *pBox,
92  sal_uLong &rnB, sal_uInt16 &rnC, ColumnStructure::iterator& rpCl,
93  BoxStructure::iterator& rpSel, bool &rbSel, bool bCover );
94  void incColSpan( sal_uInt16 nLine, sal_uInt16 nCol );
95  explicit TableStructure( const SwTable& rTable );
96  TableStructure( const SwTable& rTable, FndBox_ &rFndBox,
97  const SwSelBoxes& rSelBoxes,
98  LineStructure::size_type nMinSize );
99  LineStructure::size_type getLineCount() const
100  { return maLines.size(); }
101  void moreLines( const SwTable& rTable );
102  void assignBoxes( const TableStructure &rSource );
103  void copyBoxes( const SwTable& rSource, SwTable& rDstTable,
104  SwUndoTableCpyTable* pUndo ) const;
105  };
106 
107  SubTable::iterator insertSubLine( SubTable& rSubTable, SwTableLine& rLine,
108  const SubTable::iterator& pStartLn );
109 
110  SubTable::iterator insertSubBox( SubTable& rSubTable, SwTableBox& rBox,
111  SubTable::iterator pStartLn, const SubTable::iterator& pEndLn )
112  {
113  if( !rBox.GetTabLines().empty() )
114  {
115  SubTable::size_type nSize = static_cast<SubTable::size_type>(std::distance( pStartLn, pEndLn ));
116  if( nSize < rBox.GetTabLines().size() )
117  {
118  SubLine aSubLine;
119  for( const auto& rSubBox : *pStartLn )
120  {
121  SubBox aSub;
122  aSub.mpBox = rSubBox.mpBox;
123  aSub.mbCovered = true;
124  aSubLine.push_back( aSub );
125  }
126  do
127  {
128  rSubTable.insert( pEndLn, aSubLine );
129  } while( ++nSize < rBox.GetTabLines().size() );
130  }
131  for( auto pLine : rBox.GetTabLines() )
132  pStartLn = insertSubLine( rSubTable, *pLine, pStartLn );
133  OSL_ENSURE( pStartLn == pEndLn, "Sub line confusion" );
134  }
135  else
136  {
137  SubBox aSub;
138  aSub.mpBox = &rBox;
139  aSub.mbCovered = false;
140  while( pStartLn != pEndLn )
141  {
142  pStartLn->push_back( aSub );
143  aSub.mbCovered = true;
144  ++pStartLn;
145  }
146  }
147  return pStartLn;
148  }
149 
150  SubTable::iterator insertSubLine( SubTable& rSubTable, SwTableLine& rLine,
151  const SubTable::iterator& pStartLn )
152  {
153  SubTable::iterator pMax = pStartLn;
154  ++pMax;
155  SubTable::difference_type nMax = 1;
156  for( auto pBox : rLine.GetTabBoxes() )
157  {
158  SubTable::iterator pTmp = insertSubBox( rSubTable, *pBox, pStartLn, pMax );
159  SubTable::difference_type nTmp = std::distance( pStartLn, pTmp );
160  if( nTmp > nMax )
161  {
162  pMax = pTmp;
163  nMax = nTmp;
164  }
165  }
166  return pMax;
167  }
168 
169  TableStructure::TableStructure( const SwTable& rTable ) :
170  maLines( rTable.GetTabLines().size() ), mnStartCol(USHRT_MAX),
171  mnAddLine(0)
172  {
173  maCols.push_front(0);
174  sal_uInt16 nCnt = 0;
175  for( auto pLine : rTable.GetTabLines() )
176  addLine( nCnt, pLine->GetTabBoxes(), nullptr, rTable.IsNewModel() );
177  }
178 
179  TableStructure::TableStructure( const SwTable& rTable,
180  FndBox_ &rFndBox, const SwSelBoxes& rSelBoxes,
181  LineStructure::size_type nMinSize )
182  : mnStartCol(USHRT_MAX), mnAddLine(0)
183  {
184  if( !rFndBox.GetLines().empty() )
185  {
186  bool bNoSelection = rSelBoxes.size() < 2;
187  FndLines_t &rFndLines = rFndBox.GetLines();
188  maCols.push_front(0);
189  const SwTableLine* pLine = rFndLines.front()->GetLine();
190  const sal_uInt16 nStartLn = rTable.GetTabLines().GetPos( pLine );
191  SwTableLines::size_type nEndLn = nStartLn;
192  if( rFndLines.size() > 1 )
193  {
194  pLine = rFndLines.back()->GetLine();
195  nEndLn = rTable.GetTabLines().GetPos( pLine );
196  }
197  if( nStartLn < USHRT_MAX && nEndLn < USHRT_MAX )
198  {
199  const SwTableLines &rLines = rTable.GetTabLines();
200  if( bNoSelection && nMinSize > nEndLn - nStartLn + 1 )
201  {
202  SwTableLines::size_type nNewEndLn = nStartLn + nMinSize - 1;
203  if( nNewEndLn >= rLines.size() )
204  {
205  mnAddLine = nNewEndLn - rLines.size() + 1;
206  nNewEndLn = rLines.size() - 1;
207  }
208  while( nEndLn < nNewEndLn )
209  {
210  SwTableLine *pLine2 = rLines[ ++nEndLn ];
211  SwTableBox *pTmpBox = pLine2->GetTabBoxes()[0];
212  FndLine_ *pInsLine = new FndLine_( pLine2, &rFndBox );
213  pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), std::make_unique<FndBox_>(pTmpBox, pInsLine));
214  rFndLines.push_back(std::unique_ptr<FndLine_>(pInsLine));
215  }
216  }
217  maLines.resize( nEndLn - nStartLn + 1 );
218  const SwSelBoxes* pSelBoxes = &rSelBoxes;
219  sal_uInt16 nCnt = 0;
220  for( SwTableLines::size_type nLine = nStartLn; nLine <= nEndLn; ++nLine )
221  {
222  addLine( nCnt, rLines[nLine]->GetTabBoxes(),
223  pSelBoxes, rTable.IsNewModel() );
224  if( bNoSelection )
225  pSelBoxes = nullptr;
226  }
227  }
228  if( bNoSelection && mnStartCol < USHRT_MAX )
229  {
230  sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size()));
231  mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0),
232  [](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; });
233  }
234  else
235  mnStartCol = USHRT_MAX;
236  }
237  }
238 
239  void TableStructure::addLine( sal_uInt16 &rLine, const SwTableBoxes& rBoxes,
240  const SwSelBoxes* pSelBoxes, bool bNewModel )
241  {
242  bool bComplex = false;
243  if( !bNewModel )
244  for( SwTableBoxes::size_type nBox = 0; !bComplex && nBox < rBoxes.size(); ++nBox )
245  bComplex = !rBoxes[nBox]->GetTabLines().empty();
246  if( bComplex )
247  {
248  SubTable aSubTable;
249  SubLine aSubLine;
250  aSubTable.push_back( aSubLine );
251  SubTable::iterator pStartLn = aSubTable.begin();
252  SubTable::iterator pEndLn = aSubTable.end();
253  for( auto pBox : rBoxes )
254  insertSubBox( aSubTable, *pBox, pStartLn, pEndLn );
255  SubTable::size_type nSize = aSubTable.size();
256  if( nSize )
257  {
258  maLines.resize( maLines.size() + nSize - 1 );
259  while( pStartLn != pEndLn )
260  {
261  bool bSelected = false;
262  sal_uLong nBorder = 0;
263  sal_uInt16 nCol = 0;
264  maLines[rLine].reserve( pStartLn->size() );
265  BoxStructure::iterator pSel = maLines[rLine].end();
266  ColumnStructure::iterator pCol = maCols.begin();
267  for( const auto& rBox : *pStartLn )
268  {
269  addBox( rLine, pSelBoxes, rBox.mpBox, nBorder, nCol,
270  pCol, pSel, bSelected, rBox.mbCovered );
271  }
272  ++rLine;
273  ++pStartLn;
274  }
275  }
276  }
277  else
278  {
279  bool bSelected = false;
280  sal_uLong nBorder = 0;
281  sal_uInt16 nCol = 0;
282  maLines[rLine].reserve( rBoxes.size() );
283  ColumnStructure::iterator pCol = maCols.begin();
284  BoxStructure::iterator pSel = maLines[rLine].end();
285  for( auto pBox : rBoxes )
286  addBox( rLine, pSelBoxes, pBox, nBorder, nCol,
287  pCol, pSel, bSelected, false );
288  ++rLine;
289  }
290  }
291 
292  void TableStructure::addBox( sal_uInt16 nLine, const SwSelBoxes* pSelBoxes,
293  SwTableBox *pBox, sal_uLong &rnBorder, sal_uInt16 &rnCol,
294  ColumnStructure::iterator& rpCol, BoxStructure::iterator& rpSel,
295  bool &rbSelected, bool bCovered )
296  {
297  BoxSpanInfo aInfo;
298  if( pSelBoxes &&
299  pSelBoxes->end() != pSelBoxes->find( pBox ) )
300  {
301  aInfo.mbSelected = true;
302  if( mnStartCol == USHRT_MAX )
303  {
304  mnStartCol = static_cast<sal_uInt16>(maLines[nLine].size());
305  if( pSelBoxes->size() < 2 )
306  {
307  pSelBoxes = nullptr;
308  aInfo.mbSelected = false;
309  }
310  }
311  }
312  else
313  aInfo.mbSelected = false;
314  rnBorder += pBox->GetFrameFormat()->GetFrameSize().GetWidth();
315  const sal_uInt16 nLeftCol = rnCol;
316  while( rpCol != maCols.end() && *rpCol < rnBorder )
317  {
318  ++rnCol;
319  ++rpCol;
320  }
321  if( rpCol == maCols.end() || *rpCol > rnBorder )
322  {
323  rpCol = maCols.insert( rpCol, rnBorder );
324  incColSpan( nLine, rnCol );
325  }
326  aInfo.mnColSpan = rnCol - nLeftCol;
327  aInfo.mpCopy = nullptr;
328  aInfo.mpBox = bCovered ? nullptr : pBox;
329  maLines[nLine].push_back( aInfo );
330  if( aInfo.mbSelected )
331  {
332  if( rbSelected )
333  {
334  while( rpSel != maLines[nLine].end() )
335  {
336  rpSel->mbSelected = true;
337  ++rpSel;
338  }
339  }
340  else
341  {
342  rpSel = maLines[nLine].end();
343  rbSelected = true;
344  }
345  --rpSel;
346  }
347  }
348 
349  void TableStructure::moreLines( const SwTable& rTable )
350  {
351  if( mnAddLine )
352  {
353  const SwTableLines &rLines = rTable.GetTabLines();
354  const sal_uInt16 nLineCount = rLines.size();
355  if( nLineCount < mnAddLine )
356  mnAddLine = nLineCount;
357  sal_uInt16 nLine = static_cast<sal_uInt16>(maLines.size());
358  maLines.resize( nLine + mnAddLine );
359  while( mnAddLine )
360  {
361  SwTableLine *pLine = rLines[ nLineCount - mnAddLine ];
362  addLine( nLine, pLine->GetTabBoxes(), nullptr, rTable.IsNewModel() );
363  --mnAddLine;
364  }
365  }
366  }
367 
368  void TableStructure::incColSpan( sal_uInt16 nLineMax, sal_uInt16 nNewCol )
369  {
370  for( sal_uInt16 nLine = 0; nLine < nLineMax; ++nLine )
371  {
372  BoxStructure::iterator pInfo = maLines[nLine].begin();
373  BoxStructure::iterator pEnd = maLines[nLine].end();
374  long nCol = pInfo->mnColSpan;
375  while( nNewCol > nCol && ++pInfo != pEnd )
376  nCol += pInfo->mnColSpan;
377  if( pInfo != pEnd )
378  ++(pInfo->mnColSpan);
379  }
380  }
381 
382  void TableStructure::assignBoxes( const TableStructure &rSource )
383  {
384  LineStructure::const_iterator pFirstLine = rSource.maLines.begin();
385  LineStructure::const_iterator pLastLine = rSource.maLines.end();
386  if( pFirstLine == pLastLine )
387  return;
388  LineStructure::const_iterator pCurrLine = pFirstLine;
389  LineStructure::size_type nLineCount = maLines.size();
390  sal_uInt16 nFirstStartCol = 0;
391  {
392  BoxStructure::const_iterator pFirstBox = pFirstLine->begin();
393  if( pFirstBox != pFirstLine->end() && pFirstBox->mpBox &&
394  pFirstBox->mpBox->getDummyFlag() )
395  nFirstStartCol = pFirstBox->mnColSpan;
396  }
397  for( LineStructure::size_type nLine = 0; nLine < nLineCount; ++nLine )
398  {
399  BoxStructure::const_iterator pFirstBox = pCurrLine->begin();
400  BoxStructure::const_iterator pLastBox = pCurrLine->end();
401  sal_uInt16 nCurrStartCol = mnStartCol;
402  if( pFirstBox != pLastBox )
403  {
404  BoxStructure::const_iterator pTmpBox = pLastBox;
405  --pTmpBox;
406  if( pTmpBox->mpBox && pTmpBox->mpBox->getDummyFlag() )
407  --pLastBox;
408  if( pFirstBox != pLastBox && pFirstBox->mpBox &&
409  pFirstBox->mpBox->getDummyFlag() )
410  {
411  if( nCurrStartCol < USHRT_MAX )
412  {
413  if( pFirstBox->mnColSpan > nFirstStartCol )
414  nCurrStartCol += pFirstBox->mnColSpan - nFirstStartCol;
415  }
416  ++pFirstBox;
417  }
418  }
419  if( pFirstBox != pLastBox )
420  {
421  BoxStructure::const_iterator pCurrBox = pFirstBox;
422  BoxStructure &rBox = maLines[nLine];
423  BoxStructure::size_type nBoxCount = rBox.size();
424  sal_uInt16 nCol = 0;
425  for( BoxStructure::size_type nBox = 0; nBox < nBoxCount; ++nBox )
426  {
427  BoxSpanInfo& rInfo = rBox[nBox];
428  nCol += rInfo.mnColSpan;
429  if( rInfo.mbSelected || nCol > nCurrStartCol )
430  {
431  rInfo.mpCopy = pCurrBox->mpBox;
432  if( rInfo.mbSelected && rInfo.mpCopy->getDummyFlag() )
433  {
434  ++pCurrBox;
435  if( pCurrBox == pLastBox )
436  {
437  pCurrBox = pFirstBox;
438  if( pCurrBox->mpBox->getDummyFlag() )
439  ++pCurrBox;
440  }
441  rInfo.mpCopy = pCurrBox->mpBox;
442  }
443  ++pCurrBox;
444  if( pCurrBox == pLastBox )
445  {
446  if( rInfo.mbSelected )
447  pCurrBox = pFirstBox;
448  else
449  {
450  rInfo.mbSelected = rInfo.mpCopy == nullptr;
451  break;
452  }
453  }
454  rInfo.mbSelected = rInfo.mpCopy == nullptr;
455  }
456  }
457  }
458  ++pCurrLine;
459  if( pCurrLine == pLastLine )
460  pCurrLine = pFirstLine;
461  }
462  }
463 
464  void TableStructure::copyBoxes( const SwTable& rSource, SwTable& rDstTable,
465  SwUndoTableCpyTable* pUndo ) const
466  {
467  LineStructure::size_type nLineCount = maLines.size();
468  for( LineStructure::size_type nLine = 0; nLine < nLineCount; ++nLine )
469  {
470  const BoxStructure &rBox = maLines[nLine];
471  BoxStructure::size_type nBoxCount = rBox.size();
472  for( BoxStructure::size_type nBox = 0; nBox < nBoxCount; ++nBox )
473  {
474  const BoxSpanInfo& rInfo = rBox[nBox];
475  if( ( rInfo.mpCopy && !rInfo.mpCopy->getDummyFlag() )
476  || rInfo.mbSelected )
477  {
478  SwTableBox *pBox = rInfo.mpBox;
479  if( pBox && pBox->getRowSpan() > 0 )
480  lcl_CpyBox( rSource, rInfo.mpCopy, rDstTable, pBox,
481  true, pUndo );
482  }
483  }
484  }
485  }
486 }
487 
493 static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox,
494  SwTable& rDstTable, SwTableBox* pDstBox,
495  bool bDelContent, SwUndoTableCpyTable* pUndo )
496 {
497  OSL_ENSURE( ( !pCpyBox || pCpyBox->GetSttNd() ) && pDstBox->GetSttNd(),
498  "No content in this Box" );
499 
500  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
501  SwDoc* pDoc = rDstTable.GetFrameFormat()->GetDoc();
502 
503  // First copy the new content and then delete the old one.
504  // Do not create empty Sections, otherwise they will be deleted!
505  std::unique_ptr< SwNodeRange > pRg( pCpyBox ?
506  new SwNodeRange ( *pCpyBox->GetSttNd(), 1,
507  *pCpyBox->GetSttNd()->EndOfSectionNode() ) : nullptr );
508 
509  SwNodeIndex aInsIdx( *pDstBox->GetSttNd(), bDelContent ? 1 :
510  pDstBox->GetSttNd()->EndOfSectionIndex() -
511  pDstBox->GetSttIdx() );
512 
513  if( pUndo )
514  pUndo->AddBoxBefore( *pDstBox, bDelContent );
515 
516  bool bUndoRedline = pUndo && pDoc->getIDocumentRedlineAccess().IsRedlineOn();
517  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
518 
519  SwNodeIndex aSavePos( aInsIdx, -1 );
520  if (pRg)
521  pCpyDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly(*pRg, aInsIdx, nullptr, false);
522  else
523  pDoc->GetNodes().MakeTextNode( aInsIdx, pDoc->GetDfltTextFormatColl() );
524  ++aSavePos;
525 
526  SwTableLine* pLine = pDstBox->GetUpper();
527  while( pLine->GetUpper() )
528  pLine = pLine->GetUpper()->GetUpper();
529 
530  bool bReplaceColl = true;
531  if( bDelContent && !bUndoRedline )
532  {
533  // Delete the Fly first, then the corresponding Nodes
534  SwNodeIndex aEndNdIdx( *aInsIdx.GetNode().EndOfSectionNode() );
535 
536  // Move Bookmarks
537  {
538  SwPosition aMvPos( aInsIdx );
539  SwContentNode* pCNd = SwNodes::GoPrevious( &aMvPos.nNode );
540  aMvPos.nContent.Assign( pCNd, pCNd->Len() );
541  SwDoc::CorrAbs( aInsIdx, aEndNdIdx, aMvPos );
542  }
543 
544  // If we still have FlyFrames hanging around, delete them too
545  for( const auto pFly : *pDoc->GetSpzFrameFormats() )
546  {
547  SwFormatAnchor const*const pAnchor = &pFly->GetAnchor();
548  SwPosition const*const pAPos = pAnchor->GetContentAnchor();
549  if (pAPos &&
550  ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
551  (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
552  aInsIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx )
553  {
555  }
556  }
557 
558  // If DestBox is a Headline Box and has Table style set, then
559  // DO NOT automatically set the TableHeadline style!
560  if( 1 < rDstTable.GetTabLines().size() &&
561  pLine == rDstTable.GetTabLines().front() )
562  {
563  SwContentNode* pCNd = aInsIdx.GetNode().GetContentNode();
564  if( !pCNd )
565  {
566  SwNodeIndex aTmp( aInsIdx );
567  pCNd = pDoc->GetNodes().GoNext( &aTmp );
568  }
569 
570  if( pCNd &&
572  pCNd->GetFormatColl()->GetPoolFormatId() )
573  bReplaceColl = false;
574  }
575 
576  pDoc->GetNodes().Delete( aInsIdx, aEndNdIdx.GetIndex() - aInsIdx.GetIndex() );
577  }
578 
579  //b6341295: Table copy redlining will be managed by AddBoxAfter()
580  if( pUndo )
581  pUndo->AddBoxAfter( *pDstBox, aInsIdx, bDelContent );
582 
583  // heading
584  SwTextNode *const pTextNd = aSavePos.GetNode().GetTextNode();
585  if( pTextNd )
586  {
587  const sal_uInt16 nPoolId = pTextNd->GetTextColl()->GetPoolFormatId();
588  if( bReplaceColl &&
589  (( 1 < rDstTable.GetTabLines().size() &&
590  pLine == rDstTable.GetTabLines().front() )
591  // Is the Table's content still valid?
592  ? RES_POOLCOLL_TABLE == nPoolId
593  : RES_POOLCOLL_TABLE_HDLN == nPoolId ) )
594  {
596  static_cast<sal_uInt16>(
597  RES_POOLCOLL_TABLE == nPoolId
599  : RES_POOLCOLL_TABLE ) );
600  if( pColl ) // Apply style
601  {
602  SwPaM aPam( aSavePos );
603  aPam.SetMark();
604  aPam.Move( fnMoveForward, GoInSection );
605  pDoc->SetTextFormatColl( aPam, pColl );
606  }
607  }
608 
609  // Delete the current Formula/Format/Value values
610  if( SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMAT ) ||
611  SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMULA ) ||
612  SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE ) )
613  {
616  }
617 
618  // Copy the TableBoxAttributes - Formula/Format/Value
619  if( pCpyBox )
620  {
621  SfxItemSet aBoxAttrSet( pCpyDoc->GetAttrPool(), svl::Items<RES_BOXATR_FORMAT,
622  RES_BOXATR_VALUE>{} );
623  aBoxAttrSet.Put( pCpyBox->GetFrameFormat()->GetAttrSet() );
624  if( aBoxAttrSet.Count() )
625  {
626  const SfxPoolItem* pItem;
627  SvNumberFormatter* pN = pDoc->GetNumberFormatter( false );
628  if( pN && pN->HasMergeFormatTable() && SfxItemState::SET == aBoxAttrSet.
629  GetItemState( RES_BOXATR_FORMAT, false, &pItem ) )
630  {
631  sal_uLong nOldIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
632  sal_uLong nNewIdx = pN->GetMergeFormatIndex( nOldIdx );
633  if( nNewIdx != nOldIdx )
634  aBoxAttrSet.Put( SwTableBoxNumFormat( nNewIdx ));
635  }
636  pDstBox->ClaimFrameFormat()->SetFormatAttr( aBoxAttrSet );
637  }
638  }
639  }
640 }
641 
642 bool SwTable::InsNewTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
643  SwUndoTableCpyTable* pUndo )
644 {
645  SwDoc* pDoc = GetFrameFormat()->GetDoc();
646  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
647 
648  SwTableNumFormatMerge aTNFM( *pCpyDoc, *pDoc );
649 
650  // Analyze source structure
651  TableStructure aCopyStruct( rCpyTable );
652 
653  // Analyze target structure (from start box) and selected substructure
654  FndBox_ aFndBox( nullptr, nullptr );
655  { // get all boxes/lines
656  FndPara aPara( rSelBoxes, &aFndBox );
657  ForEach_FndLineCopyCol( GetTabLines(), &aPara );
658  }
659  TableStructure aTarget( *this, aFndBox, rSelBoxes, aCopyStruct.getLineCount() );
660 
661  bool bClear = false;
662  if( aTarget.mnAddLine && IsNewModel() )
663  {
664  SwSelBoxes aBoxes;
665  aBoxes.insert( GetTabLines().back()->GetTabBoxes().front() );
666  if( pUndo )
667  pUndo->InsertRow( *this, aBoxes, aTarget.mnAddLine );
668  else
669  InsertRow( pDoc, aBoxes, aTarget.mnAddLine, /*bBehind*/true );
670 
671  aTarget.moreLines( *this );
672  bClear = true;
673  }
674 
675  // Find mapping, if needed extend target table and/or selection
676  aTarget.assignBoxes( aCopyStruct );
677 
678  {
679  // Change table formulas into relative representation
680  SwTableFormulaUpdate aMsgHint( &rCpyTable );
681  aMsgHint.m_eFlags = TBL_RELBOXNAME;
682  pCpyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
683  }
684 
685  // delete frames
686  aFndBox.SetTableLines( *this );
687  if( bClear )
688  aFndBox.ClearLineBehind();
689  aFndBox.DelFrames( *this );
690 
691  // copy boxes
692  aTarget.copyBoxes( rCpyTable, *this, pUndo );
693 
694  // adjust row span attributes accordingly
695 
696  // make frames
697  aFndBox.MakeFrames( *this );
698 
699  return true;
700 }
701 
707 bool SwTable::InsTable( const SwTable& rCpyTable, const SwNodeIndex& rSttBox,
708  SwUndoTableCpyTable* pUndo )
709 {
710  SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>()); // Delete HTML Layout
711 
712  SwDoc* pDoc = GetFrameFormat()->GetDoc();
713 
714  SwTableNode* pTableNd = pDoc->IsIdxInTable( rSttBox );
715 
716  // Find the Box, to which should be copied:
717  SwTableBox* pMyBox = GetTableBox(
718  rSttBox.GetNode().FindTableBoxStartNode()->GetIndex() );
719 
720  OSL_ENSURE( pMyBox, "Index is not in a Box in this Table" );
721 
722  // First delete the Table's Frames
723  FndBox_ aFndBox( nullptr, nullptr );
724  aFndBox.DelFrames( pTableNd->GetTable() );
725 
726  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
727 
728  {
729  // Convert Table formulas to their relative representation
730  SwTableFormulaUpdate aMsgHint( &rCpyTable );
731  aMsgHint.m_eFlags = TBL_RELBOXNAME;
732  pCpyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
733  }
734 
735  SwTableNumFormatMerge aTNFM( *pCpyDoc, *pDoc );
736 
737  bool bDelContent = true;
738  const SwTableBox* pTmp;
739 
740  for( auto pLine : rCpyTable.GetTabLines() )
741  {
742  // Get the first from the CopyLine
743  const SwTableBox* pCpyBox = pLine->GetTabBoxes().front();
744  while( !pCpyBox->GetTabLines().empty() )
745  pCpyBox = pCpyBox->GetTabLines().front()->GetTabBoxes().front();
746 
747  do {
748  // First copy the new content and then delete the old one.
749  // Do not create empty Sections, otherwise they will be deleted!
750  lcl_CpyBox( rCpyTable, pCpyBox, *this, pMyBox, bDelContent, pUndo );
751 
752  if( nullptr == (pTmp = pCpyBox->FindNextBox( rCpyTable, pCpyBox, false )))
753  break; // no more Boxes
754  pCpyBox = pTmp;
755 
756  if( nullptr == ( pTmp = pMyBox->FindNextBox( *this, pMyBox, false )))
757  bDelContent = false; // No space left?
758  else
759  pMyBox = const_cast<SwTableBox*>(pTmp);
760 
761  } while( true );
762 
763  // Find the topmost Line
764  SwTableLine* pNxtLine = pMyBox->GetUpper();
765  while( pNxtLine->GetUpper() )
766  pNxtLine = pNxtLine->GetUpper()->GetUpper();
767  const SwTableLines::size_type nPos = GetTabLines().GetPos( pNxtLine ) + 1;
768  // Is there a next?
769  if( nPos >= GetTabLines().size() )
770  bDelContent = false; // there is none, all goes into the last Box
771  else
772  {
773  // Find the next Box with content
774  pNxtLine = GetTabLines()[ nPos ];
775  pMyBox = pNxtLine->GetTabBoxes().front();
776  while( !pMyBox->GetTabLines().empty() )
777  pMyBox = pMyBox->GetTabLines().front()->GetTabBoxes().front();
778  bDelContent = true;
779  }
780  }
781 
782  aFndBox.MakeFrames( pTableNd->GetTable() ); // Create the Frames anew
783  return true;
784 }
785 
786 bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
787  SwUndoTableCpyTable* pUndo )
788 {
789  OSL_ENSURE( !rSelBoxes.empty(), "Missing selection" );
790 
791  SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>()); // Delete HTML Layout
792 
793  if( IsNewModel() || rCpyTable.IsNewModel() )
794  return InsNewTable( rCpyTable, rSelBoxes, pUndo );
795 
796  OSL_ENSURE( !rCpyTable.IsTableComplex(), "Table too complex" );
797 
798  SwDoc* pDoc = GetFrameFormat()->GetDoc();
799  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
800 
801  SwTableNumFormatMerge aTNFM( *pCpyDoc, *pDoc );
802 
803  FndLine_ *pFLine;
804  FndBox_ aFndBox( nullptr, nullptr );
805  // Find all Boxes/Lines
806  {
807  FndPara aPara( rSelBoxes, &aFndBox );
808  ForEach_FndLineCopyCol( GetTabLines(), &aPara );
809  }
810 
811  // Special case: If a Box is located in a Table, copy it to all selected
812  // Boxes!
813  if( 1 != rCpyTable.GetTabSortBoxes().size() )
814  {
815  FndBox_* pFndBox;
816 
817  const FndLines_t::size_type nFndCnt = aFndBox.GetLines().size();
818  if( !nFndCnt )
819  return false;
820 
821  // Check if we have enough space for all Lines and Boxes
822  SwTableLines::size_type nTstLns = 0;
823  pFLine = aFndBox.GetLines().front().get();
824  sal_uInt16 nSttLine = GetTabLines().GetPos( pFLine->GetLine() );
825  // Do we have as many rows, actually?
826  if( 1 == nFndCnt )
827  {
828  // Is there still enough space in the Table?
829  if( (GetTabLines().size() - nSttLine ) <
830  rCpyTable.GetTabLines().size() )
831  {
832  // If we don't have enough Lines, then see if we can insert
833  // new ones to reach our goal. But only if the SSelection
834  // contains a Box!
835  if( 1 < rSelBoxes.size() )
836  return false;
837 
838  const sal_uInt16 nNewLns = rCpyTable.GetTabLines().size() -
839  (GetTabLines().size() - nSttLine );
840 
841  // See if the Box count is high enough for the Lines
842  SwTableLine* pLastLn = GetTabLines().back();
843 
844  SwTableBox* pSttBox = pFLine->GetBoxes()[0]->GetBox();
845  const SwTableBoxes::size_type nSttBox = pFLine->GetLine()->GetBoxPos( pSttBox );
846  for( SwTableLines::size_type n = rCpyTable.GetTabLines().size() - nNewLns;
847  n < rCpyTable.GetTabLines().size(); ++n )
848  {
849  SwTableLine* pCpyLn = rCpyTable.GetTabLines()[ n ];
850 
851  if( pLastLn->GetTabBoxes().size() < nSttBox ||
852  ( pLastLn->GetTabBoxes().size() - nSttBox ) <
853  pCpyLn->GetTabBoxes().size() )
854  return false;
855 
856  // Test for nesting
857  for( SwTableBoxes::size_type nBx = 0; nBx < pCpyLn->GetTabBoxes().size(); ++nBx )
858  if( !pLastLn->GetTabBoxes()[ nSttBox + nBx ]->GetSttNd() )
859  return false;
860  }
861  // We have enough space for the to-be-copied, so insert new
862  // rows accordingly.
863  SwTableBox* pInsBox = pLastLn->GetTabBoxes()[ nSttBox ];
864  OSL_ENSURE( pInsBox && pInsBox->GetSttNd(),
865  "no ContentBox or it's not in this Table" );
866  SwSelBoxes aBoxes;
867 
868  if( pUndo
869  ? !pUndo->InsertRow( *this, SelLineFromBox( pInsBox,
870  aBoxes ), nNewLns )
871  : !InsertRow( pDoc, SelLineFromBox( pInsBox,
872  aBoxes ), nNewLns, /*bBehind*/true ) )
873  return false;
874  }
875 
876  nTstLns = rCpyTable.GetTabLines().size(); // copy this many
877  }
878  else if( 0 == (nFndCnt % rCpyTable.GetTabLines().size()) )
879  nTstLns = nFndCnt;
880  else
881  return false; // not enough space for the rows
882 
883  for( SwTableLines::size_type nLn = 0; nLn < nTstLns; ++nLn )
884  {
885  // We have enough rows, so check the Boxes per row
886  pFLine = aFndBox.GetLines()[ nLn % nFndCnt ].get();
887  SwTableLine* pLine = pFLine->GetLine();
888  SwTableBox* pSttBox = pFLine->GetBoxes()[0]->GetBox();
889  const SwTableBoxes::size_type nSttBox = pLine->GetBoxPos( pSttBox );
890  std::unique_ptr<FndLine_> pInsFLine;
891  if( nLn >= nFndCnt )
892  {
893  // We have more rows in the ClipBoard than we have selected
894  pInsFLine.reset(new FndLine_( GetTabLines()[ nSttLine + nLn ],
895  &aFndBox ));
896  pLine = pInsFLine->GetLine();
897  }
898  SwTableLine* pCpyLn = rCpyTable.GetTabLines()[ nLn %
899  rCpyTable.GetTabLines().size() ];
900 
901  // Selected too few rows?
902  if( pInsFLine )
903  {
904  // We insert a new row into the FndBox
905  if( pLine->GetTabBoxes().size() < nSttBox ||
906  pLine->GetTabBoxes().size() - nSttBox < pFLine->GetBoxes().size() )
907  {
908  return false;
909  }
910 
911  // Test for nesting
912  for (FndBoxes_t::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx)
913  {
914  SwTableBox *pTmpBox = pLine->GetTabBoxes()[ nSttBox + nBx ];
915  if( !pTmpBox->GetSttNd() )
916  {
917  return false;
918  }
919  // if Ok, insert the Box into the FndLine
920  pFndBox = new FndBox_( pTmpBox, pInsFLine.get() );
921  pInsFLine->GetBoxes().insert( pInsFLine->GetBoxes().begin() + nBx,
922  std::unique_ptr<FndBox_>(pFndBox));
923  }
924  aFndBox.GetLines().insert( aFndBox.GetLines().begin() + nLn, std::move(pInsFLine));
925  }
926  else if( pFLine->GetBoxes().size() == 1 )
927  {
928  if( pLine->GetTabBoxes().size() < nSttBox ||
929  ( pLine->GetTabBoxes().size() - nSttBox ) <
930  pCpyLn->GetTabBoxes().size() )
931  return false;
932 
933  // Test for nesting
934  for( SwTableBoxes::size_type nBx = 0; nBx < pCpyLn->GetTabBoxes().size(); ++nBx )
935  {
936  SwTableBox *pTmpBox = pLine->GetTabBoxes()[ nSttBox + nBx ];
937  if( !pTmpBox->GetSttNd() )
938  return false;
939  // if Ok, insert the Box into the FndLine
940  if( nBx == pFLine->GetBoxes().size() )
941  {
942  pFndBox = new FndBox_( pTmpBox, pFLine );
943  pFLine->GetBoxes().insert(pFLine->GetBoxes().begin() + nBx,
944  std::unique_ptr<FndBox_>(pFndBox));
945  }
946  }
947  }
948  else
949  {
950  // Match the selected Boxes with the ones in the Clipboard
951  // (n times)
952  if( 0 != ( pFLine->GetBoxes().size() %
953  pCpyLn->GetTabBoxes().size() ))
954  return false;
955 
956  // Test for nesting
957  for (auto &rpBox : pFLine->GetBoxes())
958  {
959  if (!rpBox->GetBox()->GetSttNd())
960  return false;
961  }
962  }
963  }
964 
965  if( aFndBox.GetLines().empty() )
966  return false;
967  }
968 
969  {
970  // Convert Table formulas to their relative representation
971  SwTableFormulaUpdate aMsgHint( &rCpyTable );
972  aMsgHint.m_eFlags = TBL_RELBOXNAME;
973  pCpyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
974  }
975 
976  // Delete the Frames
977  aFndBox.SetTableLines( *this );
978  //Not dispose accessible table
979  aFndBox.DelFrames( *this );
980 
981  if( 1 == rCpyTable.GetTabSortBoxes().size() )
982  {
983  SwTableBox *pTmpBx = rCpyTable.GetTabSortBoxes()[0];
984  for (size_t n = 0; n < rSelBoxes.size(); ++n)
985  {
986  lcl_CpyBox( rCpyTable, pTmpBx, *this,
987  rSelBoxes[n], true, pUndo );
988  }
989  }
990  else
991  for (FndLines_t::size_type nLn = 0; nLn < aFndBox.GetLines().size(); ++nLn)
992  {
993  pFLine = aFndBox.GetLines()[ nLn ].get();
994  SwTableLine* pCpyLn = rCpyTable.GetTabLines()[
995  nLn % rCpyTable.GetTabLines().size() ];
996  for (FndBoxes_t::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx)
997  {
998  // Copy the pCpyBox into pMyBox
999  lcl_CpyBox( rCpyTable, pCpyLn->GetTabBoxes()[
1000  nBx % pCpyLn->GetTabBoxes().size() ],
1001  *this, pFLine->GetBoxes()[nBx]->GetBox(), true, pUndo );
1002  }
1003  }
1004 
1005  aFndBox.MakeFrames( *this );
1006  return true;
1007 }
1008 
1009 static void FndContentLine( const SwTableLine* pLine, SwSelBoxes* pPara );
1010 
1011 static void FndContentBox( const SwTableBox* pBox, SwSelBoxes* pPara )
1012 {
1013  if( !pBox->GetTabLines().empty() )
1014  {
1015  for( const SwTableLine* pLine : pBox->GetTabLines() )
1016  FndContentLine( pLine, pPara );
1017  }
1018  else
1019  pPara->insert( const_cast<SwTableBox*>(pBox) );
1020 }
1021 
1022 static void FndContentLine( const SwTableLine* pLine, SwSelBoxes* pPara )
1023 {
1024  for( const SwTableBox* pBox : pLine->GetTabBoxes() )
1025  FndContentBox(pBox, pPara );
1026 }
1027 
1028 // Find all Boxes with content in this Box
1030  SwSelBoxes& rBoxes, bool bToTop )
1031 {
1032  SwTableLine* pLine = const_cast<SwTableLine*>(pBox->GetUpper());
1033  if( bToTop )
1034  while( pLine->GetUpper() )
1035  pLine = pLine->GetUpper()->GetUpper();
1036 
1037  // Delete all old ones
1038  rBoxes.clear();
1039  for( const auto& rpBox : pLine->GetTabBoxes() )
1040  FndContentBox(rpBox, &rBoxes );
1041  return rBoxes;
1042 }
1043 
1044 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsTableComplex() const
Definition: swtable.cxx:1445
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
std::vector< SwTableLine * >::size_type size_type
Definition: swtable.hxx:66
const FndLines_t & GetLines() const
Definition: tblsel.hxx:173
virtual sal_Int32 Len() const
Definition: node.cxx:1181
static void FndContentLine(const SwTableLine *pLine, SwSelBoxes *pPara)
Definition: tblcpy.cxx:1022
bool InsNewTable(const SwTable &rCpyTable, const SwSelBoxes &, SwUndoTableCpyTable *pUndo)
Definition: tblcpy.cxx:642
const SwTableLine * GetLine() const
Definition: tblsel.hxx:205
sal_uLong GetIndex() const
Definition: node.hxx:282
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1344
sal_uLong GetSttIdx() const
Definition: swtable.cxx:1880
std::string GetValue
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1400
SwNodeIndex nNode
Definition: pam.hxx:37
long GetWidth() const
sal_uIntPtr sal_uLong
Definition: doc.hxx:185
void DelFrames(SwTable &rTable)
Definition: tblsel.cxx:2160
const_iterator find(const Value &x) const
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1290
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
SwNode & GetNode() const
Definition: ndindex.hxx:118
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:176
iterator begin()
Definition: swtable.hxx:75
bool InsertRow(SwDoc *, const SwSelBoxes &rBoxes, sal_uInt16 nCnt, bool bBehind)
SwTable::InsertRow(..) inserts one or more rows before or behind the selected boxes.
SwTableLine * front() const
Definition: swtable.hxx:79
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:737
size_type size() const
Definition: swtable.hxx:74
void ForEach_FndLineCopyCol(SwTableLines &rLines, FndPara *pFndPara)
Definition: tblsel.cxx:2092
bool GoInSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:886
SwTableLine * back() const
Definition: swtable.hxx:80
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:389
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1063
SwIndex nContent
Definition: pam.hxx:38
enumrange< T >::Iterator begin(enumrange< T >)
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter .
Definition: docfmt.cxx:1096
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:458
const SwTextFormatColl * GetDfltTextFormatColl() const
Definition: doc.hxx:772
static bool IsRedlineOn(const RedlineFlags eM)
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
const FndBoxes_t & GetBoxes() const
Definition: tblsel.hxx:203
void SetHTMLTableLayout(std::shared_ptr< SwHTMLTableLayout > const &r)
Definition: swtable.cxx:1942
const SwTable & GetTable() const
Definition: node.hxx:497
bool InsTable(const SwTable &rCpyTable, const SwNodeIndex &, SwUndoTableCpyTable *pUndo)
Copy Table into this Box.
Definition: tblcpy.cxx:707
size_type size() const
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:143
void MakeFrames(SwTable &rTable)
Definition: tblsel.cxx:2321
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:259
Table of Contents - heading.
Definition: poolfmt.hxx:342
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:481
void SetTableLines(const SwSelBoxes &rBoxes, const SwTable &rTable)
Definition: tblsel.cxx:2098
bool InsertRow(SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nCnt)
Definition: untbl.cxx:2701
static SwSelBoxes & SelLineFromBox(const SwTableBox *pBox, SwSelBoxes &rBoxes, bool bToTop=true)
Definition: tblcpy.cxx:1029
bool empty() const
Definition: swtable.hxx:73
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
void ClearLineBehind()
Definition: tblsel.hxx:189
SwContentNode * GetContentNode()
Definition: node.hxx:615
FlyAnchors.
Definition: fmtanchr.hxx:34
long const nBorder
size
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:396
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:425
const_iterator end() const
#define RES_BOXATR_VALUE
Definition: hintids.hxx:263
bool HasMergeFormatTable() const
bool empty() const
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
sal_uInt16 GetBoxPos(const SwTableBox *pBox) const
Definition: swtable.hxx:356
static void FndContentBox(const SwTableBox *pBox, SwSelBoxes *pPara)
Definition: tblcpy.cxx:1011
SwTableLines & GetTabLines()
Definition: swtable.hxx:198
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:437
enumrange< T >::Iterator end(enumrange< T >)
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
void AddBoxBefore(const SwTableBox &rBox, bool bDelContent)
Definition: untbl.cxx:2568
SwTableLines & GetTabLines()
Definition: swtable.hxx:418
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:354
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:650
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:439
long getRowSpan() const
Definition: swtable.cxx:102
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:168
SwTableNode * IsIdxInTable(const SwNodeIndex &rIdx)
Definition: ndtbl.cxx:216
sal_uInt32 GetMergeFormatIndex(sal_uInt32 nOldFmt) const
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
SwNodes & GetNodes()
Definition: doc.hxx:402
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
static void lcl_CpyBox(const SwTable &rCpyTable, const SwTableBox *pCpyBox, SwTable &rDstTable, SwTableBox *pDstBox, bool bDelContent, SwUndoTableCpyTable *pUndo)
Copy Table into this Box.
Definition: tblcpy.cxx:493
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1706
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:196
std::vector< std::unique_ptr< FndLine_ > > FndLines_t
Definition: tblsel.hxx:155
SwTableBox * GetUpper()
Definition: swtable.hxx:362
SwTableBox * FindNextBox(const SwTable &, const SwTableBox *, bool bOvrTableLns=true) const
Definition: tblrwcl.cxx:2281
SwFormatColl * GetFormatColl() const
Definition: node.hxx:447
sal_uInt16 GetPos(const SwTableLine *pBox) const
Definition: swtable.hxx:96
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:455
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
TableFormulaUpdateFlags m_eFlags
Definition: hints.hxx:208
std::pair< const_iterator, bool > insert(Value &&x)
Subgroup table.
Definition: poolfmt.hxx:341
bool IsNewModel() const
Definition: swtable.hxx:185
const int nLineCount
SwTableLine * GetUpper()
Definition: swtable.hxx:421
sal_Int32 nPos
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1273
#define RES_BOXATR_FORMAT
Definition: hintids.hxx:261
void AddBoxAfter(const SwTableBox &rBox, const SwNodeIndex &rIdx, bool bDelContent)
Definition: untbl.cxx:2601
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
Definition: ndtxt.cxx:114
#define RES_BOXATR_FORMULA
Definition: hintids.hxx:262
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:837