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