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 <osl/diagnose.h>
23 #include <svl/zforlist.hxx>
24 #include <frmfmt.hxx>
25 #include <doc.hxx>
26 #include <IDocumentUndoRedo.hxx>
32 #include <pam.hxx>
33 #include <swtable.hxx>
34 #include <ndtxt.hxx>
35 #include <tblsel.hxx>
36 #include <poolfmt.hxx>
37 #include <cellatr.hxx>
38 #include <mvsave.hxx>
39 #include <docary.hxx>
40 #include <fmtanchr.hxx>
41 #include <hints.hxx>
42 #include <UndoTable.hxx>
43 #include <fmtfsize.hxx>
44 #include <frameformats.hxx>
45 #include <deque>
46 #include <memory>
47 #include <numeric>
48 
49 static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox,
50  SwTable& rDstTable, SwTableBox* pDstBox,
51  bool bDelContent, SwUndoTableCpyTable* pUndo );
52 
53 // The following type will be used by table copy functions to describe
54 // the structure of tables (or parts of tables).
55 // It's for new table model only.
56 
57 namespace
58 {
59  struct BoxSpanInfo
60  {
61  SwTableBox* mpBox;
62  SwTableBox* mpCopy;
63  sal_uInt16 mnColSpan;
64  bool mbSelected;
65  };
66 
67  typedef std::vector< BoxSpanInfo > BoxStructure;
68  typedef std::vector< BoxStructure > LineStructure;
69  typedef std::deque< sal_uLong > ColumnStructure;
70 
71  struct SubBox
72  {
73  SwTableBox *mpBox;
74  bool mbCovered;
75  };
76 
77  typedef std::vector< SubBox > SubLine;
78  typedef std::vector< SubLine > SubTable;
79 
80  class TableStructure
81  {
82  public:
83  LineStructure maLines;
84  ColumnStructure maCols;
85  sal_uInt16 mnStartCol;
86  sal_uInt16 mnAddLine;
87  void addLine( sal_uInt16 &rLine, const SwTableBoxes&, const SwSelBoxes*,
88  bool bNewModel );
89  void addBox( sal_uInt16 nLine, const SwSelBoxes*, SwTableBox *pBox,
90  sal_uLong &rnB, sal_uInt16 &rnC, ColumnStructure::iterator& rpCl,
91  BoxStructure::iterator& rpSel, bool &rbSel, bool bCover );
92  void incColSpan( sal_uInt16 nLine, sal_uInt16 nCol );
93  explicit TableStructure( const SwTable& rTable );
94  TableStructure( const SwTable& rTable, FndBox_ &rFndBox,
95  const SwSelBoxes& rSelBoxes,
96  LineStructure::size_type nMinSize );
97  LineStructure::size_type getLineCount() const
98  { return maLines.size(); }
99  void moreLines( const SwTable& rTable );
100  void assignBoxes( const TableStructure &rSource );
101  void copyBoxes( const SwTable& rSource, SwTable& rDstTable,
102  SwUndoTableCpyTable* pUndo ) const;
103  };
104 
105  SubTable::iterator insertSubLine( SubTable& rSubTable, SwTableLine& rLine,
106  const SubTable::iterator& pStartLn );
107 
108  SubTable::iterator insertSubBox( SubTable& rSubTable, SwTableBox& rBox,
109  SubTable::iterator pStartLn, const SubTable::iterator& pEndLn )
110  {
111  if( !rBox.GetTabLines().empty() )
112  {
113  SubTable::size_type nSize = static_cast<SubTable::size_type>(std::distance( pStartLn, pEndLn ));
114  if( nSize < rBox.GetTabLines().size() )
115  {
116  SubLine aSubLine;
117  for( const auto& rSubBox : *pStartLn )
118  {
119  SubBox aSub;
120  aSub.mpBox = rSubBox.mpBox;
121  aSub.mbCovered = true;
122  aSubLine.push_back( aSub );
123  }
124  do
125  {
126  rSubTable.insert( pEndLn, aSubLine );
127  } while( ++nSize < rBox.GetTabLines().size() );
128  }
129  for( auto pLine : rBox.GetTabLines() )
130  pStartLn = insertSubLine( rSubTable, *pLine, pStartLn );
131  OSL_ENSURE( pStartLn == pEndLn, "Sub line confusion" );
132  }
133  else
134  {
135  SubBox aSub;
136  aSub.mpBox = &rBox;
137  aSub.mbCovered = false;
138  while( pStartLn != pEndLn )
139  {
140  pStartLn->push_back( aSub );
141  aSub.mbCovered = true;
142  ++pStartLn;
143  }
144  }
145  return pStartLn;
146  }
147 
148  SubTable::iterator insertSubLine( SubTable& rSubTable, SwTableLine& rLine,
149  const SubTable::iterator& pStartLn )
150  {
151  SubTable::iterator pMax = pStartLn;
152  ++pMax;
153  SubTable::difference_type nMax = 1;
154  for( auto pBox : rLine.GetTabBoxes() )
155  {
156  SubTable::iterator pTmp = insertSubBox( rSubTable, *pBox, pStartLn, pMax );
157  SubTable::difference_type nTmp = std::distance( pStartLn, pTmp );
158  if( nTmp > nMax )
159  {
160  pMax = pTmp;
161  nMax = nTmp;
162  }
163  }
164  return pMax;
165  }
166 
167  TableStructure::TableStructure( const SwTable& rTable ) :
168  maLines( rTable.GetTabLines().size() ), mnStartCol(USHRT_MAX),
169  mnAddLine(0)
170  {
171  maCols.push_front(0);
172  sal_uInt16 nCnt = 0;
173  for( auto pLine : rTable.GetTabLines() )
174  addLine( nCnt, pLine->GetTabBoxes(), nullptr, rTable.IsNewModel() );
175  }
176 
177  TableStructure::TableStructure( const SwTable& rTable,
178  FndBox_ &rFndBox, const SwSelBoxes& rSelBoxes,
179  LineStructure::size_type nMinSize )
180  : mnStartCol(USHRT_MAX), mnAddLine(0)
181  {
182  if( rFndBox.GetLines().empty() )
183  return;
184 
185  bool bNoSelection = rSelBoxes.size() < 2;
186  FndLines_t &rFndLines = rFndBox.GetLines();
187  maCols.push_front(0);
188  const SwTableLine* pLine = rFndLines.front()->GetLine();
189  const sal_uInt16 nStartLn = rTable.GetTabLines().GetPos( pLine );
190  SwTableLines::size_type nEndLn = nStartLn;
191  if( rFndLines.size() > 1 )
192  {
193  pLine = rFndLines.back()->GetLine();
194  nEndLn = rTable.GetTabLines().GetPos( pLine );
195  }
196  if( nStartLn < USHRT_MAX && nEndLn < USHRT_MAX )
197  {
198  const SwTableLines &rLines = rTable.GetTabLines();
199  if( bNoSelection && nMinSize > nEndLn - nStartLn + 1 )
200  {
201  SwTableLines::size_type nNewEndLn = nStartLn + nMinSize - 1;
202  if( nNewEndLn >= rLines.size() )
203  {
204  mnAddLine = nNewEndLn - rLines.size() + 1;
205  nNewEndLn = rLines.size() - 1;
206  }
207  while( nEndLn < nNewEndLn )
208  {
209  SwTableLine *pLine2 = rLines[ ++nEndLn ];
210  SwTableBox *pTmpBox = pLine2->GetTabBoxes()[0];
211  FndLine_ *pInsLine = new FndLine_( pLine2, &rFndBox );
212  pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), std::make_unique<FndBox_>(pTmpBox, pInsLine));
213  rFndLines.push_back(std::unique_ptr<FndLine_>(pInsLine));
214  }
215  }
216  maLines.resize( nEndLn - nStartLn + 1 );
217  const SwSelBoxes* pSelBoxes = &rSelBoxes;
218  sal_uInt16 nCnt = 0;
219  for( SwTableLines::size_type nLine = nStartLn; nLine <= nEndLn; ++nLine )
220  {
221  addLine( nCnt, rLines[nLine]->GetTabBoxes(),
222  pSelBoxes, rTable.IsNewModel() );
223  if( bNoSelection )
224  pSelBoxes = nullptr;
225  }
226  }
227  if( bNoSelection && mnStartCol < USHRT_MAX )
228  {
229  sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size()));
230  mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0),
231  [](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; });
232  }
233  else
234  mnStartCol = USHRT_MAX;
235  }
236 
237  void TableStructure::addLine( sal_uInt16 &rLine, const SwTableBoxes& rBoxes,
238  const SwSelBoxes* pSelBoxes, bool bNewModel )
239  {
240  bool bComplex = false;
241  if( !bNewModel )
242  for( SwTableBoxes::size_type nBox = 0; !bComplex && nBox < rBoxes.size(); ++nBox )
243  bComplex = !rBoxes[nBox]->GetTabLines().empty();
244  if( bComplex )
245  {
246  SubTable aSubTable;
247  SubLine aSubLine;
248  aSubTable.push_back( aSubLine );
249  SubTable::iterator pStartLn = aSubTable.begin();
250  SubTable::iterator pEndLn = aSubTable.end();
251  for( auto pBox : rBoxes )
252  insertSubBox( aSubTable, *pBox, pStartLn, pEndLn );
253  SubTable::size_type nSize = aSubTable.size();
254  if( nSize )
255  {
256  maLines.resize( maLines.size() + nSize - 1 );
257  while( pStartLn != pEndLn )
258  {
259  bool bSelected = false;
260  sal_uLong nBorder = 0;
261  sal_uInt16 nCol = 0;
262  maLines[rLine].reserve( pStartLn->size() );
263  BoxStructure::iterator pSel = maLines[rLine].end();
264  ColumnStructure::iterator pCol = maCols.begin();
265  for( const auto& rBox : *pStartLn )
266  {
267  addBox( rLine, pSelBoxes, rBox.mpBox, nBorder, nCol,
268  pCol, pSel, bSelected, rBox.mbCovered );
269  }
270  ++rLine;
271  ++pStartLn;
272  }
273  }
274  }
275  else
276  {
277  bool bSelected = false;
278  sal_uLong nBorder = 0;
279  sal_uInt16 nCol = 0;
280  maLines[rLine].reserve( rBoxes.size() );
281  ColumnStructure::iterator pCol = maCols.begin();
282  BoxStructure::iterator pSel = maLines[rLine].end();
283  for( auto pBox : rBoxes )
284  addBox( rLine, pSelBoxes, pBox, nBorder, nCol,
285  pCol, pSel, bSelected, false );
286  ++rLine;
287  }
288  }
289 
290  void TableStructure::addBox( sal_uInt16 nLine, const SwSelBoxes* pSelBoxes,
291  SwTableBox *pBox, sal_uLong &rnBorder, sal_uInt16 &rnCol,
292  ColumnStructure::iterator& rpCol, BoxStructure::iterator& rpSel,
293  bool &rbSelected, bool bCovered )
294  {
295  BoxSpanInfo aInfo;
296  if( pSelBoxes &&
297  pSelBoxes->end() != pSelBoxes->find( pBox ) )
298  {
299  aInfo.mbSelected = true;
300  if( mnStartCol == USHRT_MAX )
301  {
302  mnStartCol = static_cast<sal_uInt16>(maLines[nLine].size());
303  if( pSelBoxes->size() < 2 )
304  {
305  pSelBoxes = nullptr;
306  aInfo.mbSelected = false;
307  }
308  }
309  }
310  else
311  aInfo.mbSelected = false;
312  rnBorder += pBox->GetFrameFormat()->GetFrameSize().GetWidth();
313  const sal_uInt16 nLeftCol = rnCol;
314  while( rpCol != maCols.end() && *rpCol < rnBorder )
315  {
316  ++rnCol;
317  ++rpCol;
318  }
319  if( rpCol == maCols.end() || *rpCol > rnBorder )
320  {
321  rpCol = maCols.insert( rpCol, rnBorder );
322  incColSpan( nLine, rnCol );
323  }
324  aInfo.mnColSpan = rnCol - nLeftCol;
325  aInfo.mpCopy = nullptr;
326  aInfo.mpBox = bCovered ? nullptr : pBox;
327  maLines[nLine].push_back( aInfo );
328  if( !aInfo.mbSelected )
329  return;
330 
331  if( rbSelected )
332  {
333  while( rpSel != maLines[nLine].end() )
334  {
335  rpSel->mbSelected = true;
336  ++rpSel;
337  }
338  }
339  else
340  {
341  rpSel = maLines[nLine].end();
342  rbSelected = true;
343  }
344  --rpSel;
345  }
346 
347  void TableStructure::moreLines( const SwTable& rTable )
348  {
349  if( !mnAddLine )
350  return;
351 
352  const SwTableLines &rLines = rTable.GetTabLines();
353  const sal_uInt16 nLineCount = rLines.size();
354  if( nLineCount < mnAddLine )
355  mnAddLine = nLineCount;
356  sal_uInt16 nLine = static_cast<sal_uInt16>(maLines.size());
357  maLines.resize( nLine + mnAddLine );
358  while( mnAddLine )
359  {
360  SwTableLine *pLine = rLines[ nLineCount - mnAddLine ];
361  addLine( nLine, pLine->GetTabBoxes(), nullptr, rTable.IsNewModel() );
362  --mnAddLine;
363  }
364  }
365 
366  void TableStructure::incColSpan( sal_uInt16 nLineMax, sal_uInt16 nNewCol )
367  {
368  for( sal_uInt16 nLine = 0; nLine < nLineMax; ++nLine )
369  {
370  BoxStructure::iterator pInfo = maLines[nLine].begin();
371  BoxStructure::iterator pEnd = maLines[nLine].end();
372  tools::Long nCol = pInfo->mnColSpan;
373  while( nNewCol > nCol && ++pInfo != pEnd )
374  nCol += pInfo->mnColSpan;
375  if( pInfo != pEnd )
376  ++(pInfo->mnColSpan);
377  }
378  }
379 
380  void TableStructure::assignBoxes( const TableStructure &rSource )
381  {
382  LineStructure::const_iterator pFirstLine = rSource.maLines.begin();
383  LineStructure::const_iterator pLastLine = rSource.maLines.end();
384  if( pFirstLine == pLastLine )
385  return;
386  LineStructure::const_iterator pCurrLine = pFirstLine;
387  LineStructure::size_type nLineCount = maLines.size();
388  sal_uInt16 nFirstStartCol = 0;
389  {
390  BoxStructure::const_iterator pFirstBox = pFirstLine->begin();
391  if( pFirstBox != pFirstLine->end() && pFirstBox->mpBox &&
392  pFirstBox->mpBox->getDummyFlag() )
393  nFirstStartCol = pFirstBox->mnColSpan;
394  }
395  for( LineStructure::size_type nLine = 0; nLine < nLineCount; ++nLine )
396  {
397  BoxStructure::const_iterator pFirstBox = pCurrLine->begin();
398  BoxStructure::const_iterator pLastBox = pCurrLine->end();
399  sal_uInt16 nCurrStartCol = mnStartCol;
400  if( pFirstBox != pLastBox )
401  {
402  BoxStructure::const_iterator pTmpBox = pLastBox;
403  --pTmpBox;
404  if( pTmpBox->mpBox && pTmpBox->mpBox->getDummyFlag() )
405  --pLastBox;
406  if( pFirstBox != pLastBox && pFirstBox->mpBox &&
407  pFirstBox->mpBox->getDummyFlag() )
408  {
409  if( nCurrStartCol < USHRT_MAX )
410  {
411  if( pFirstBox->mnColSpan > nFirstStartCol )
412  nCurrStartCol += pFirstBox->mnColSpan - nFirstStartCol;
413  }
414  ++pFirstBox;
415  }
416  }
417  if( pFirstBox != pLastBox )
418  {
419  BoxStructure::const_iterator pCurrBox = pFirstBox;
420  BoxStructure &rBox = maLines[nLine];
421  BoxStructure::size_type nBoxCount = rBox.size();
422  sal_uInt16 nCol = 0;
423  for( BoxStructure::size_type nBox = 0; nBox < nBoxCount; ++nBox )
424  {
425  BoxSpanInfo& rInfo = rBox[nBox];
426  nCol += rInfo.mnColSpan;
427  if( rInfo.mbSelected || nCol > nCurrStartCol )
428  {
429  rInfo.mpCopy = pCurrBox->mpBox;
430  if( rInfo.mbSelected && rInfo.mpCopy->getDummyFlag() )
431  {
432  ++pCurrBox;
433  if( pCurrBox == pLastBox )
434  {
435  pCurrBox = pFirstBox;
436  if( pCurrBox->mpBox->getDummyFlag() )
437  ++pCurrBox;
438  }
439  rInfo.mpCopy = pCurrBox->mpBox;
440  }
441  ++pCurrBox;
442  if( pCurrBox == pLastBox )
443  {
444  if( rInfo.mbSelected )
445  pCurrBox = pFirstBox;
446  else
447  {
448  rInfo.mbSelected = rInfo.mpCopy == nullptr;
449  break;
450  }
451  }
452  rInfo.mbSelected = rInfo.mpCopy == nullptr;
453  }
454  }
455  }
456  ++pCurrLine;
457  if( pCurrLine == pLastLine )
458  pCurrLine = pFirstLine;
459  }
460  }
461 
462  void TableStructure::copyBoxes( const SwTable& rSource, SwTable& rDstTable,
463  SwUndoTableCpyTable* pUndo ) const
464  {
465  LineStructure::size_type nLineCount = maLines.size();
466  for( LineStructure::size_type nLine = 0; nLine < nLineCount; ++nLine )
467  {
468  const BoxStructure &rBox = maLines[nLine];
469  BoxStructure::size_type nBoxCount = rBox.size();
470  for( BoxStructure::size_type nBox = 0; nBox < nBoxCount; ++nBox )
471  {
472  const BoxSpanInfo& rInfo = rBox[nBox];
473  if( ( rInfo.mpCopy && !rInfo.mpCopy->getDummyFlag() )
474  || rInfo.mbSelected )
475  {
476  SwTableBox *pBox = rInfo.mpBox;
477  if( pBox && pBox->getRowSpan() > 0 )
478  lcl_CpyBox( rSource, rInfo.mpCopy, rDstTable, pBox,
479  true, pUndo );
480  }
481  }
482  }
483  }
484 }
485 
491 static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox,
492  SwTable& rDstTable, SwTableBox* pDstBox,
493  bool bDelContent, SwUndoTableCpyTable* pUndo )
494 {
495  OSL_ENSURE( ( !pCpyBox || pCpyBox->GetSttNd() ) && pDstBox->GetSttNd(),
496  "No content in this Box" );
497 
498  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
499  SwDoc* pDoc = rDstTable.GetFrameFormat()->GetDoc();
500 
501  // First copy the new content and then delete the old one.
502  // Do not create empty Sections, otherwise they will be deleted!
503  std::unique_ptr< SwNodeRange > pRg( pCpyBox ?
504  new SwNodeRange ( *pCpyBox->GetSttNd(), 1,
505  *pCpyBox->GetSttNd()->EndOfSectionNode() ) : nullptr );
506 
507  SwNodeIndex aInsIdx( *pDstBox->GetSttNd(), bDelContent ? 1 :
508  pDstBox->GetSttNd()->EndOfSectionIndex() -
509  pDstBox->GetSttIdx() );
510 
511  if( pUndo )
512  pUndo->AddBoxBefore( *pDstBox, bDelContent );
513 
514  bool bUndoRedline = pUndo && pDoc->getIDocumentRedlineAccess().IsRedlineOn();
515  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
516 
517  SwNodeIndex aSavePos( aInsIdx, -1 );
518  if (pRg)
519  pCpyDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly(*pRg, aInsIdx, nullptr, false);
520  else
521  pDoc->GetNodes().MakeTextNode( aInsIdx, pDoc->GetDfltTextFormatColl() );
522  ++aSavePos;
523 
524  SwTableLine* pLine = pDstBox->GetUpper();
525  while( pLine->GetUpper() )
526  pLine = pLine->GetUpper()->GetUpper();
527 
528  bool bReplaceColl = true;
529  if( bDelContent && !bUndoRedline )
530  {
531  // Delete the Fly first, then the corresponding Nodes
532  SwNodeIndex aEndNdIdx( *aInsIdx.GetNode().EndOfSectionNode() );
533 
534  // Move Bookmarks
535  {
536  SwPosition aMvPos( aInsIdx );
537  SwContentNode* pCNd = SwNodes::GoPrevious( &aMvPos.nNode );
538  aMvPos.nContent.Assign( pCNd, pCNd->Len() );
539  SwDoc::CorrAbs( aInsIdx, aEndNdIdx, aMvPos );
540  }
541 
542  // If we still have FlyFrames hanging around, delete them too
543  for( const auto pFly : *pDoc->GetSpzFrameFormats() )
544  {
545  SwFormatAnchor const*const pAnchor = &pFly->GetAnchor();
546  SwPosition const*const pAPos = pAnchor->GetContentAnchor();
547  if (pAPos &&
548  ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
549  (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
550  aInsIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx )
551  {
553  }
554  }
555 
556  // If DestBox is a Headline Box and has Table style set, then
557  // DO NOT automatically set the TableHeadline style!
558  if( 1 < rDstTable.GetTabLines().size() &&
559  pLine == rDstTable.GetTabLines().front() )
560  {
561  SwContentNode* pCNd = aInsIdx.GetNode().GetContentNode();
562  if( !pCNd )
563  {
564  SwNodeIndex aTmp( aInsIdx );
565  pCNd = pDoc->GetNodes().GoNext( &aTmp );
566  }
567 
568  if( pCNd &&
570  pCNd->GetFormatColl()->GetPoolFormatId() )
571  bReplaceColl = false;
572  }
573 
574  pDoc->GetNodes().Delete( aInsIdx, aEndNdIdx.GetIndex() - aInsIdx.GetIndex() );
575  }
576 
577  //b6341295: Table copy redlining will be managed by AddBoxAfter()
578  if( pUndo )
579  pUndo->AddBoxAfter( *pDstBox, aInsIdx, bDelContent );
580 
581  // heading
582  SwTextNode *const pTextNd = aSavePos.GetNode().GetTextNode();
583  if( !pTextNd )
584  return;
585 
586  const sal_uInt16 nPoolId = pTextNd->GetTextColl()->GetPoolFormatId();
587  if( bReplaceColl &&
588  (( 1 < rDstTable.GetTabLines().size() &&
589  pLine == rDstTable.GetTabLines().front() )
590  // Is the Table's content still valid?
591  ? RES_POOLCOLL_TABLE == nPoolId
592  : RES_POOLCOLL_TABLE_HDLN == nPoolId ) )
593  {
595  static_cast<sal_uInt16>(
596  RES_POOLCOLL_TABLE == nPoolId
598  : RES_POOLCOLL_TABLE ) );
599  if( pColl ) // Apply style
600  {
601  SwPaM aPam( aSavePos );
602  aPam.SetMark();
603  aPam.Move( fnMoveForward, GoInSection );
604  pDoc->SetTextFormatColl( aPam, pColl );
605  }
606  }
607 
608  // Delete the current Formula/Format/Value values
609  if( SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMAT ) ||
610  SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMULA ) ||
611  SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE ) )
612  {
615  }
616 
617  // Copy the TableBoxAttributes - Formula/Format/Value
618  if( !pCpyBox )
619  return;
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  return;
626 
627  const SfxPoolItem* pItem;
628  SvNumberFormatter* pN = pDoc->GetNumberFormatter( false );
629  if( pN && pN->HasMergeFormatTable() && SfxItemState::SET == aBoxAttrSet.
630  GetItemState( RES_BOXATR_FORMAT, false, &pItem ) )
631  {
632  sal_uLong nOldIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
633  sal_uLong nNewIdx = pN->GetMergeFormatIndex( nOldIdx );
634  if( nNewIdx != nOldIdx )
635  aBoxAttrSet.Put( SwTableBoxNumFormat( nNewIdx ));
636  }
637  pDstBox->ClaimFrameFormat()->SetFormatAttr( aBoxAttrSet );
638 }
639 
640 bool SwTable::InsNewTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
641  SwUndoTableCpyTable* pUndo )
642 {
643  SwDoc* pDoc = GetFrameFormat()->GetDoc();
644  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
645 
646  SwTableNumFormatMerge aTNFM( *pCpyDoc, *pDoc );
647 
648  // Analyze source structure
649  TableStructure aCopyStruct( rCpyTable );
650 
651  // Analyze target structure (from start box) and selected substructure
652  FndBox_ aFndBox( nullptr, nullptr );
653  { // get all boxes/lines
654  FndPara aPara( rSelBoxes, &aFndBox );
655  ForEach_FndLineCopyCol( GetTabLines(), &aPara );
656  }
657  TableStructure aTarget( *this, aFndBox, rSelBoxes, aCopyStruct.getLineCount() );
658 
659  bool bClear = false;
660  if( aTarget.mnAddLine && IsNewModel() )
661  {
662  SwSelBoxes aBoxes;
663  aBoxes.insert( GetTabLines().back()->GetTabBoxes().front() );
664  if( pUndo )
665  pUndo->InsertRow( *this, aBoxes, aTarget.mnAddLine );
666  else
667  InsertRow( pDoc, aBoxes, aTarget.mnAddLine, /*bBehind*/true );
668 
669  aTarget.moreLines( *this );
670  bClear = true;
671  }
672 
673  // Find mapping, if needed extend target table and/or selection
674  aTarget.assignBoxes( aCopyStruct );
675 
676  {
677  // Change table formulas into relative representation
678  SwTableFormulaUpdate aMsgHint( &rCpyTable );
679  aMsgHint.m_eFlags = TBL_RELBOXNAME;
680  pCpyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
681  }
682 
683  // delete frames
684  aFndBox.SetTableLines( *this );
685  if( bClear )
686  aFndBox.ClearLineBehind();
687  aFndBox.DelFrames( *this );
688 
689  // copy boxes
690  aTarget.copyBoxes( rCpyTable, *this, pUndo );
691 
692  // adjust row span attributes accordingly
693 
694  // make frames
695  aFndBox.MakeFrames( *this );
696 
697  return true;
698 }
699 
705 bool SwTable::InsTable( const SwTable& rCpyTable, const SwNodeIndex& rSttBox,
706  SwUndoTableCpyTable* pUndo )
707 {
708  SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>()); // Delete HTML Layout
709 
710  SwDoc* pDoc = GetFrameFormat()->GetDoc();
711 
712  SwTableNode* pTableNd = pDoc->IsIdxInTable( rSttBox );
713 
714  // Find the Box, to which should be copied:
715  SwTableBox* pMyBox = GetTableBox(
716  rSttBox.GetNode().FindTableBoxStartNode()->GetIndex() );
717 
718  OSL_ENSURE( pMyBox, "Index is not in a Box in this Table" );
719 
720  // First delete the Table's Frames
721  FndBox_ aFndBox( nullptr, nullptr );
722  aFndBox.DelFrames( pTableNd->GetTable() );
723 
724  SwDoc* pCpyDoc = rCpyTable.GetFrameFormat()->GetDoc();
725 
726  {
727  // Convert Table formulas to their relative representation
728  SwTableFormulaUpdate aMsgHint( &rCpyTable );
729  aMsgHint.m_eFlags = TBL_RELBOXNAME;
730  pCpyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
731  }
732 
733  SwTableNumFormatMerge aTNFM( *pCpyDoc, *pDoc );
734 
735  bool bDelContent = true;
736  const SwTableBox* pTmp;
737 
738  for( auto pLine : rCpyTable.GetTabLines() )
739  {
740  // Get the first from the CopyLine
741  const SwTableBox* pCpyBox = pLine->GetTabBoxes().front();
742  while( !pCpyBox->GetTabLines().empty() )
743  pCpyBox = pCpyBox->GetTabLines().front()->GetTabBoxes().front();
744 
745  do {
746  // First copy the new content and then delete the old one.
747  // Do not create empty Sections, otherwise they will be deleted!
748  lcl_CpyBox( rCpyTable, pCpyBox, *this, pMyBox, bDelContent, pUndo );
749 
750  pTmp = pCpyBox->FindNextBox( rCpyTable, pCpyBox, false );
751  if( !pTmp )
752  break; // no more Boxes
753  pCpyBox = pTmp;
754 
755  pTmp = pMyBox->FindNextBox( *this, pMyBox, false );
756  if( !pTmp )
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:1454
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:690
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:1225
tools::Long GetWidth() const
static void FndContentLine(const SwTableLine *pLine, SwSelBoxes *pPara)
Definition: tblcpy.cxx:1022
bool InsNewTable(const SwTable &rCpyTable, const SwSelBoxes &, SwUndoTableCpyTable *pUndo)
Definition: tblcpy.cxx:640
const SwTableLine * GetLine() const
Definition: tblsel.hxx:205
sal_uLong GetIndex() const
Definition: node.hxx:290
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:1353
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
sal_uLong GetSttIdx() const
Definition: swtable.cxx:1891
std::string GetValue
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1407
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(150)
SwNodeIndex nNode
Definition: pam.hxx:37
sal_uIntPtr sal_uLong
long Long
sal_Int64 n
Definition: doc.hxx:184
void DelFrames(SwTable &rTable)
Definition: tblsel.cxx:2172
const_iterator find(const Value &x) const
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1301
SwTableLine is one table row in the document model.
Definition: swtable.hxx:350
SwNode & GetNode() const
Definition: ndindex.hxx:119
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
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:202
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:739
size_type size() const
Definition: swtable.hxx:74
void ForEach_FndLineCopyCol(SwTableLines &rLines, FndPara *pFndPara)
This creates a structure mirroring the SwTable structure that contains all rows and non-leaf boxes (a...
Definition: tblsel.cxx:2104
bool GoInSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:948
SwTableLine * back() const
Definition: swtable.hxx:80
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1072
sal_Int32 mnColSpan
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:1072
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:426
const SwTextFormatColl * GetDfltTextFormatColl() const
Definition: doc.hxx:773
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:1953
const SwTable & GetTable() const
Definition: node.hxx:505
bool InsTable(const SwTable &rCpyTable, const SwNodeIndex &, SwUndoTableCpyTable *pUndo)
Copy Table into this Box.
Definition: tblcpy.cxx:705
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:2333
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:260
Table of Contents - heading.
Definition: poolfmt.hxx:341
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:501
void SetTableLines(const SwSelBoxes &rBoxes, const SwTable &rTable)
Definition: tblsel.cxx:2110
bool InsertRow(SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nCnt)
Definition: untbl.cxx:2707
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:206
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:623
FlyAnchors.
Definition: fmtanchr.hxx:34
size
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:398
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:431
const_iterator end() const
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:362
static void FndContentBox(const SwTableBox *pBox, SwSelBoxes *pPara)
Definition: tblcpy.cxx:1011
SwTableLines & GetTabLines()
Definition: swtable.hxx:199
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
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:2574
SwTableLines & GetTabLines()
Definition: swtable.hxx:424
tools::Long const nBorder
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:460
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:685
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:360
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:652
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(149)
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:445
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:167
SwTableNode * IsIdxInTable(const SwNodeIndex &rIdx)
Definition: ndtbl.cxx:212
sal_uInt32 GetMergeFormatIndex(sal_uInt32 nOldFmt) const
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
SwNodes & GetNodes()
Definition: doc.hxx:403
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:392
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:491
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1715
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:368
SwTableBox * FindNextBox(const SwTable &, const SwTableBox *, bool bOvrTableLns=true) const
Definition: tblrwcl.cxx:2301
SwFormatColl * GetFormatColl() const
Definition: node.hxx:455
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:475
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:340
bool IsNewModel() const
Definition: swtable.hxx:186
const int nLineCount
SwTableLine * GetUpper()
Definition: swtable.hxx:427
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1284
sal_uInt16 nPos
void AddBoxAfter(const SwTableBox &rBox, const SwNodeIndex &rIdx, bool bDelContent)
Definition: untbl.cxx:2607
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:844
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
Definition: ndtxt.cxx:105
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:838
tools::Long getRowSpan() const
Definition: swtable.cxx:100