LibreOffice Module sw (master)  1
fecopy.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 <memory>
21 #include <hintids.hxx>
22 
23 #include <vcl/graph.hxx>
24 #include <sot/formats.hxx>
25 #include <svx/xfillit0.hxx>
26 #include <svx/svdocapt.hxx>
27 #include <svx/svdouno.hxx>
28 #include <svx/xbtmpit.hxx>
29 #include <svx/svdpage.hxx>
30 #include <svx/svdogrp.hxx>
31 #include <svx/svdoole2.hxx>
32 #include <svx/fmmodel.hxx>
33 #include <svx/unomodel.hxx>
34 #include <svx/svditer.hxx>
35 #include <svx/svdograf.hxx>
36 #include <tools/stream.hxx>
37 #include <unotools/streamwrap.hxx>
38 #include <osl/diagnose.h>
39 #include <fmtanchr.hxx>
40 #include <fmtcntnt.hxx>
41 #include <fmtornt.hxx>
42 #include <fmtflcnt.hxx>
43 #include <frmfmt.hxx>
44 #include <txtfrm.hxx>
45 #include <txtflcnt.hxx>
46 #include <fesh.hxx>
47 #include <doc.hxx>
48 #include <IDocumentUndoRedo.hxx>
53 #include <rootfrm.hxx>
54 #include <ndtxt.hxx>
55 #include <pam.hxx>
56 #include <tblsel.hxx>
57 #include <swtable.hxx>
58 #include <flyfrm.hxx>
59 #include <pagefrm.hxx>
60 #include <fldbas.hxx>
61 #include <swundo.hxx>
62 #include <viewimp.hxx>
63 #include <dview.hxx>
64 #include <dcontact.hxx>
65 #include <dflyobj.hxx>
66 #include <docsh.hxx>
67 #include <pagedesc.hxx>
68 #include <mvsave.hxx>
69 #include <textboxhelper.hxx>
70 #include <frameformats.hxx>
71 #include <vcl/virdev.hxx>
72 #include <svx/svdundo.hxx>
73 
74 using namespace ::com::sun::star;
75 
76 // Copy for the internal clipboard. Copies all selections to the clipboard.
77 void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText )
78 {
79  rClpDoc.GetIDocumentUndoRedo().DoUndo(false); // always false!
80 
81  // delete content if ClpDocument contains content
82  SwNodeIndex aSttIdx( rClpDoc.GetNodes().GetEndOfExtras(), 2 );
83  SwNodeIndex aEndNdIdx( *aSttIdx.GetNode().EndOfSectionNode() );
84  SwTextNode* pTextNd = aSttIdx.GetNode().GetTextNode();
85  if (!pTextNd || !pTextNd->GetText().isEmpty() ||
86  aSttIdx.GetIndex()+1 != rClpDoc.GetNodes().GetEndOfContent().GetIndex() )
87  {
88  rClpDoc.GetNodes().Delete( aSttIdx,
89  rClpDoc.GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
90  pTextNd = rClpDoc.GetNodes().MakeTextNode( aSttIdx,
91  rClpDoc.GetDfltTextFormatColl() );
92  --aSttIdx;
93  }
94 
95  // also delete surrounding FlyFrames if any
96  for( const auto pFly : *rClpDoc.GetSpzFrameFormats() )
97  {
98  SwFormatAnchor const*const pAnchor = &pFly->GetAnchor();
99  SwPosition const*const pAPos = pAnchor->GetContentAnchor();
100  if (pAPos &&
101  ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
102  (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
103  aSttIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx )
104  {
105  rClpDoc.getIDocumentLayoutAccess().DelLayoutFormat( pFly );
106  }
107  }
108 
109  rClpDoc.GetDocumentFieldsManager().GCFieldTypes(); // delete the FieldTypes
110 
111  // if a string was passed, copy it to the clipboard-
112  // document. Then also the Calculator can use the internal
113  // clipboard
114  if( pNewClpText )
115  {
116  pTextNd->InsertText( *pNewClpText, SwIndex( pTextNd ) );
117  return; // that's it
118  }
119 
122 
123  // do we want to copy a FlyFrame?
124  if( IsFrameSelected() )
125  {
126  // get the FlyFormat
128  SwFrameFormat* pFlyFormat = pFly->GetFormat();
129  SwFormatAnchor aAnchor( pFlyFormat->GetAnchor() );
130 
131  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
132  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
133  (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) ||
134  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
135  {
136  SwPosition aPos( aSttIdx );
137  if ( RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId() )
138  {
139  aPos.nContent.Assign( pTextNd, 0 );
140  }
141  aAnchor.SetAnchor( &aPos );
142  }
143  pFlyFormat = rClpDoc.getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
144 
145  // assure the "RootFormat" is the first element in Spz-Array
146  // (if necessary Flys were copied in Flys)
147  SwFrameFormats& rSpzFrameFormats = *rClpDoc.GetSpzFrameFormats();
148  if( rSpzFrameFormats[ 0 ] != pFlyFormat )
149  {
150 #ifndef NDEBUG
151  bool inserted =
152 #endif
153  rSpzFrameFormats.newDefault( pFlyFormat );
154  assert( !inserted && "Fly not contained in Spz-Array" );
155  }
156 
157  if ( RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId() )
158  {
159  // JP 13.02.99 Bug 61863: if a frameselection is passed to the
160  // clipboard, it should be found at pasting. Therefore
161  // the copied TextAttribut should be removed in the node
162  // otherwise it will be recognised as TextSelektion
163  const SwIndex& rIdx = pFlyFormat->GetAnchor().GetContentAnchor()->nContent;
164  SwTextFlyCnt *const pTextFly = static_cast<SwTextFlyCnt *>(
165  pTextNd->GetTextAttrForCharAt(
166  rIdx.GetIndex(), RES_TXTATR_FLYCNT));
167  if( pTextFly )
168  {
169  const_cast<SwFormatFlyCnt&>(pTextFly->GetFlyCnt()).SetFlyFormat();
170  pTextNd->EraseText( rIdx, 1 );
171  }
172  }
173  }
174  else if ( IsObjSelected() )
175  {
176  SwPosition aPos( aSttIdx, SwIndex( pTextNd, 0 ));
177  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
178  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
179  {
180  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
181 
182  if( Imp()->GetDrawView()->IsGroupEntered() ||
183  ( !pObj->GetUserCall() && pObj->getParentSdrObjectFromSdrObject()) )
184  {
185  SfxItemSet aSet( rClpDoc.GetAttrPool(), aFrameFormatSetRange );
186 
187  SwFormatAnchor aAnchor( RndStdIds::FLY_AT_PARA );
188  aAnchor.SetAnchor( &aPos );
189  aSet.Put( aAnchor );
190 
191  SdrObject *const pNew =
192  rClpDoc.CloneSdrObj( *pObj );
193 
194  SwPaM aTemp(aPos);
195  rClpDoc.getIDocumentContentOperations().InsertDrawObj(aTemp, *pNew, aSet );
196  }
197  else
198  {
199  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
200  SwFrameFormat *pFormat = pContact->GetFormat();
201  SwFormatAnchor aAnchor( pFormat->GetAnchor() );
202  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
203  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
204  (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) ||
205  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
206  {
207  aAnchor.SetAnchor( &aPos );
208  }
209 
210  rClpDoc.getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true );
211  }
212  }
213  }
214  else
215  CopySelToDoc(rClpDoc); // copy the selections
216 
220  rClpDoc.getIDocumentFieldsAccess().UpdateExpFields(nullptr, true);
221 }
222 
223 static const Point &lcl_FindBasePos( const SwFrame *pFrame, const Point &rPt )
224 {
225  const SwFrame *pF = pFrame;
226  while ( pF && !pF->getFrameArea().Contains( rPt ) )
227  {
228  if ( pF->IsContentFrame() )
229  pF = static_cast<const SwContentFrame*>(pF)->GetFollow();
230  else
231  pF = nullptr;
232  }
233  if ( pF )
234  return pF->getFrameArea().Pos();
235  else
236  return pFrame->getFrameArea().Pos();
237 }
238 
239 static bool lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrame const * pFly,
240  const Point& rInsPt, SwFEShell const & rDestShell, SwFormatAnchor& rAnchor,
241  Point& rNewPos, bool bCheckFlyRecur )
242 {
243  bool bRet = true;
244  rAnchor.SetAnchor( &rPos );
245  std::pair<Point, bool> const tmp(rInsPt, false);
246  SwContentFrame *const pTmpFrame = rNd.GetContentNode()->getLayoutFrame(
247  rDestShell.GetLayout(), nullptr, &tmp);
248  SwFlyFrame *pTmpFly = pTmpFrame->FindFlyFrame();
249  if( pTmpFly && bCheckFlyRecur && pFly->IsUpperOf( *pTmpFly ) )
250  {
251  bRet = false;
252  }
253  else if ( RndStdIds::FLY_AT_FLY == rAnchor.GetAnchorId() )
254  {
255  if( pTmpFly )
256  {
257  const SwNodeIndex& rIdx = *pTmpFly->GetFormat()->GetContent().GetContentIdx();
258  SwPosition aPos( rIdx );
259  rAnchor.SetAnchor( &aPos );
260  rNewPos = pTmpFly->getFrameArea().Pos();
261  }
262  else
263  {
264  rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
265  rAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
266  const SwFrame *pPg = pTmpFrame->FindPageFrame();
267  rNewPos = pPg->getFrameArea().Pos();
268  }
269  }
270  else
271  rNewPos = ::lcl_FindBasePos( pTmpFrame, rInsPt );
272  return bRet;
273 }
274 
275 bool SwFEShell::CopyDrawSel( SwFEShell& rDestShell, const Point& rSttPt,
276  const Point& rInsPt, bool bIsMove, bool bSelectInsert )
277 {
278  bool bRet = true;
279 
280  // The list should be copied, because below new objects will be selected
281  const SdrMarkList aMrkList( Imp()->GetDrawView()->GetMarkedObjectList() );
282  const size_t nMarkCount = aMrkList.GetMarkCount();
283  if( !rDestShell.Imp()->GetDrawView() )
284  // should create it now
285  rDestShell.MakeDrawView();
286  else if( bSelectInsert )
287  rDestShell.Imp()->GetDrawView()->UnmarkAll();
288 
289  SdrPageView *pDestPgView = rDestShell.Imp()->GetPageView(),
290  *pSrcPgView = Imp()->GetPageView();
291  SwDrawView *pDestDrwView = rDestShell.Imp()->GetDrawView(),
292  *pSrcDrwView = Imp()->GetDrawView();
293  SwDoc* pDestDoc = rDestShell.GetDoc();
294 
295  Size aSiz( rInsPt.X() - rSttPt.X(), rInsPt.Y() - rSttPt.Y() );
296  for( size_t i = 0; i < nMarkCount; ++i )
297  {
298  SdrObject *pObj = aMrkList.GetMark( i )->GetMarkedSdrObj();
299 
300  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
301  SwFrameFormat *pFormat = pContact->GetFormat();
302  const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
303 
304  bool bInsWithFormat = true;
305 
306  if( pDestDrwView->IsGroupEntered() )
307  {
308  // insert into the group, when it belongs to an entered group
309  // or when the object is not anchored as a character
310  if( pSrcDrwView->IsGroupEntered() ||
311  (RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) )
312 
313  {
314  SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
315  GetDoc() == pDestDoc, false );
316  pNew->NbcMove( aSiz );
317  pDestDrwView->InsertObjectAtView( pNew, *pDestPgView );
318  bInsWithFormat = false;
319  }
320  }
321 
322  if( bInsWithFormat )
323  {
324  SwFormatAnchor aAnchor( rAnchor );
325  Point aNewAnch;
326 
327  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
328  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
329  (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) ||
330  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
331  {
332  if ( this == &rDestShell )
333  {
334  // same shell? Then request the position
335  // from the passed DocumentPosition
336  SwPosition aPos( *GetCursor()->GetPoint() );
337  Point aPt( rInsPt );
338  aPt -= rSttPt - pObj->GetSnapRect().TopLeft();
340  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aState );
341  const SwNode *pNd;
342  if( (pNd = &aPos.nNode.GetNode())->IsNoTextNode() )
343  bRet = false;
344  else
345  bRet = ::lcl_SetAnchor( aPos, *pNd, nullptr, rInsPt,
346  rDestShell, aAnchor, aNewAnch, false );
347  }
348  else
349  {
350  SwPaM *pCursor = rDestShell.GetCursor();
351  if( pCursor->GetNode().IsNoTextNode() )
352  bRet = false;
353  else
354  bRet = ::lcl_SetAnchor( *pCursor->GetPoint(),
355  pCursor->GetNode(), nullptr, rInsPt,
356  rDestShell, aAnchor,
357  aNewAnch, false );
358  }
359  }
360  else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
361  {
362  aAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
363  const SwRootFrame* pTmpRoot = rDestShell.GetLayout();
364  const SwFrame* pPg = pTmpRoot->GetPageAtPos( rInsPt, nullptr, true );
365  if ( pPg )
366  aNewAnch = pPg->getFrameArea().Pos();
367  }
368 
369  if( bRet )
370  {
371  if( pSrcDrwView->IsGroupEntered() ||
372  ( !pObj->GetUserCall() && pObj->getParentSdrObjectFromSdrObject()) )
373  {
374  SfxItemSet aSet( pDestDoc->GetAttrPool(),aFrameFormatSetRange);
375  aSet.Put( aAnchor );
376  SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
377  GetDoc() == pDestDoc );
378  pFormat = pDestDoc->getIDocumentContentOperations().InsertDrawObj( *rDestShell.GetCursor(), *pNew, aSet );
379  }
380  else
381  pFormat = pDestDoc->getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true );
382 
383  // Can be 0, as Draws are not allowed in Headers/Footers
384  if ( pFormat )
385  {
386  // #tdf33692 - drawing object has to be made visible on ctrl+drag copy.
388  SdrObject* pNew = pFormat->FindSdrObject();
389  if ( RndStdIds::FLY_AS_CHAR != aAnchor.GetAnchorId() )
390  {
391  Point aPos( rInsPt );
392  aPos -= aNewAnch;
393  aPos -= rSttPt - pObj->GetSnapRect().TopLeft();
394  // OD 2004-04-05 #i26791# - change attributes instead of
395  // direct positioning
396  pFormat->SetFormatAttr( SwFormatHoriOrient( aPos.getX(), text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
397  pFormat->SetFormatAttr( SwFormatVertOrient( aPos.getY(), text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
398  // #i47455# - notify draw frame format
399  // that position attributes are already set.
400  if (SwDrawFrameFormat *pDrawFormat = dynamic_cast<SwDrawFrameFormat*>(pFormat))
401  pDrawFormat->PosAttrSet();
402  }
404  {
405  SwTextBoxHelper::syncFlyFrameAttr(*pFormat, pFormat->GetAttrSet(), pObj);
406  }
407 
408  if( bSelectInsert )
409  pDestDrwView->MarkObj( pNew, pDestPgView );
410  }
411  }
412  }
413  }
414 
415  if ( bIsMove && bRet )
416  {
417  if( &rDestShell == this )
418  {
419  const SdrMarkList aList( pSrcDrwView->GetMarkedObjectList() );
420  pSrcDrwView->UnmarkAll();
421 
422  for ( size_t i = 0, nMrkCnt = aMrkList.GetMarkCount(); i < nMrkCnt; ++i )
423  {
424  SdrObject *pObj = aMrkList.GetMark( i )->GetMarkedSdrObj();
425  pSrcDrwView->MarkObj( pObj, pSrcPgView );
426  }
427  DelSelectedObj();
428  for ( size_t i = 0, nMrkCnt = aList.GetMarkCount(); i < nMrkCnt; ++i )
429  {
430  SdrObject *pObj = aList.GetMark( i )->GetMarkedSdrObj();
431  pSrcDrwView->MarkObj( pObj, pSrcPgView );
432  }
433  }
434  else
435  DelSelectedObj();
436  }
437 
438  return bRet;
439 }
440 
441 bool SwFEShell::Copy( SwFEShell& rDestShell, const Point& rSttPt,
442  const Point& rInsPt, bool bIsMove, bool bSelectInsert )
443 {
444  bool bRet = false;
445 
446  OSL_ENSURE( this == &rDestShell || !rDestShell.IsObjSelected(),
447  "Dest-Shell cannot be in Obj-Mode" );
448 
449  CurrShell aCurr( &rDestShell );
450 
451  rDestShell.StartAllAction();
453 
454  // Shift references
455  bool bCopyIsMove = mxDoc->IsCopyIsMove();
456  if( bIsMove )
457  // set a flag in Doc, handled in TextNodes
458  mxDoc->SetCopyIsMove( true );
459 
460  RedlineFlags eOldRedlMode = rDestShell.GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
462 
463  // If there are table formulas in the area, then display the table first
464  // so that the table formula can calculate a new value first
465  // (individual boxes in the area are retrieved via the layout)
466  SwFieldType* pTableFieldTyp = rDestShell.GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Table );
467 
468  if( IsFrameSelected() )
469  {
471  SwFrameFormat* pFlyFormat = pFly->GetFormat();
472  SwFormatAnchor aAnchor( pFlyFormat->GetAnchor() );
473  bRet = true;
474  Point aNewAnch;
475 
476  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
477  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
478  (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) ||
479  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
480  {
481  if ( this == &rDestShell )
482  {
483  // same shell? Then request the position
484  // from the passed DocumentPosition
485  SwPosition aPos( *GetCursor()->GetPoint() );
486  Point aPt( rInsPt );
487  aPt -= rSttPt - pFly->getFrameArea().Pos();
489  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aState );
490  const SwNode *pNd;
491  if( (pNd = &aPos.nNode.GetNode())->IsNoTextNode() )
492  bRet = false;
493  else
494  {
495  // do not copy in itself
496  const SwNodeIndex *pTmp = pFlyFormat->GetContent().GetContentIdx();
497  if ( aPos.nNode > *pTmp && aPos.nNode <
498  pTmp->GetNode().EndOfSectionIndex() )
499  {
500  bRet = false;
501  }
502  else
503  bRet = ::lcl_SetAnchor( aPos, *pNd, pFly, rInsPt,
504  rDestShell, aAnchor, aNewAnch, true );
505  }
506  }
507  else
508  {
509  const SwPaM *pCursor = rDestShell.GetCursor();
510  if( pCursor->GetNode().IsNoTextNode() )
511  bRet = false;
512  else
513  bRet = ::lcl_SetAnchor( *pCursor->GetPoint(), pCursor->GetNode(),
514  pFly, rInsPt, rDestShell, aAnchor,
515  aNewAnch, GetDoc() == rDestShell.GetDoc());
516  }
517  }
518  else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
519  {
520  aAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
521  const SwRootFrame* pTmpRoot = rDestShell.GetLayout();
522  const SwFrame* pPg = pTmpRoot->GetPageAtPos( rInsPt, nullptr, true );
523  if ( pPg )
524  aNewAnch = pPg->getFrameArea().Pos();
525  }
526  else {
527  OSL_ENSURE( false, "what anchor is it?" );
528  }
529 
530  if( bRet )
531  {
532  SwFrameFormat *pOldFormat = pFlyFormat;
533  pFlyFormat = rDestShell.GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
534 
535  if ( RndStdIds::FLY_AS_CHAR != aAnchor.GetAnchorId() )
536  {
537  Point aPos( rInsPt );
538  aPos -= aNewAnch;
539  aPos -= rSttPt - pFly->getFrameArea().Pos();
540  pFlyFormat->SetFormatAttr( SwFormatHoriOrient( aPos.getX(),text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
541  pFlyFormat->SetFormatAttr( SwFormatVertOrient( aPos.getY(),text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
542  }
543 
544  const Point aPt( rDestShell.GetCursorDocPos() );
545 
546  if( bIsMove )
548 
549  // only select if it can be shifted/copied in the same shell
550  if( bSelectInsert )
551  {
552  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pFlyFormat)->GetFrame( &aPt );
553  if( pFlyFrame )
554  {
555  //JP 12.05.98: should this be in SelectFlyFrame???
556  rDestShell.Imp()->GetDrawView()->UnmarkAll();
557  rDestShell.SelectFlyFrame( *pFlyFrame );
558  }
559  }
560 
561  if (this != &rDestShell && !rDestShell.HasShellFocus())
562  rDestShell.Imp()->GetDrawView()->hideMarkHandles();
563  }
564  }
565  else if ( IsObjSelected() )
566  bRet = CopyDrawSel( rDestShell, rSttPt, rInsPt, bIsMove, bSelectInsert );
567  else if( IsTableMode() )
568  {
569  // Copy parts from a table: create a table with the same
570  // width as the original and copy the selected boxes.
571  // Sizes will be corrected by percentage.
572 
573  // find boxes via the layout
574  SwSelBoxes aBoxes;
575  GetTableSel( *this, aBoxes );
576  SwTableNode const*const pTableNd(
577  aBoxes.empty() ? nullptr : aBoxes[0]->GetSttNd()->FindTableNode());
578  if (nullptr != pTableNd)
579  {
580  std::unique_ptr<SwPosition> pDstPos;
581  if( this == &rDestShell )
582  {
583  // same shell? Then create new Cursor at the
584  // DocumentPosition passed
585  pDstPos.reset(new SwPosition( *GetCursor()->GetPoint() ));
586  Point aPt( rInsPt );
587  GetLayout()->GetModelPositionForViewPoint( pDstPos.get(), aPt );
588  if( !pDstPos->nNode.GetNode().IsNoTextNode() )
589  bRet = true;
590  }
591  else if( !rDestShell.GetCursor()->GetNode().IsNoTextNode() )
592  {
593  pDstPos.reset(new SwPosition( *rDestShell.GetCursor()->GetPoint() ));
594  bRet = true;
595  }
596 
597  if( bRet )
598  {
599  if( GetDoc() == rDestShell.GetDoc() )
600  ParkTableCursor();
601 
602  bRet = rDestShell.GetDoc()->InsCopyOfTable( *pDstPos, aBoxes,nullptr,
603  bIsMove && this == &rDestShell &&
604  aBoxes.size() == pTableNd->GetTable().
605  GetTabSortBoxes().size(),
606  this != &rDestShell );
607 
608  if( this != &rDestShell )
609  *rDestShell.GetCursor()->GetPoint() = *pDstPos;
610 
611  // create all parked Cursor?
612  if( GetDoc() == rDestShell.GetDoc() )
613  GetCursor();
614 
615  // JP 16.04.99: Bug 64908 - Set InsPos, to assure the parked
616  // Cursor is positioned at the insert position
617  if( this == &rDestShell )
618  GetCursorDocPos() = rInsPt;
619  }
620  }
621  }
622  else
623  {
624  bRet = true;
625  if( this == &rDestShell )
626  {
627  // same shell? then request the position
628  // at the passed document position
629  SwPosition aPos( *GetCursor()->GetPoint() );
630  Point aPt( rInsPt );
631  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
632  bRet = !aPos.nNode.GetNode().IsNoTextNode();
633  }
634  else if( rDestShell.GetCursor()->GetNode().IsNoTextNode() )
635  bRet = false;
636 
637  if( bRet )
638  bRet = SwEditShell::Copy( rDestShell );
639  }
640 
641  rDestShell.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode );
642  mxDoc->SetCopyIsMove( bCopyIsMove );
643 
644  // have new table formulas been inserted?
645  if( pTableFieldTyp->HasWriterListeners() )
646  {
647  // finish old actions: the table frames are created and
648  // a selection can be made
649  sal_uInt16 nActCnt;
650  for( nActCnt = 0; rDestShell.ActionPend(); ++nActCnt )
651  rDestShell.EndAllAction();
652 
653  for( ; nActCnt; --nActCnt )
654  rDestShell.StartAllAction();
655  }
657  rDestShell.GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
658 
659  rDestShell.EndAllAction();
660  return bRet;
661 }
662 
663 // Paste for the internal clipboard. Copy the content of the clipboard
664 // in the document
665 namespace {
666  typedef std::shared_ptr<SwPaM> PaMPtr;
667  typedef std::shared_ptr<SwPosition> PositionPtr;
668  typedef std::pair< PaMPtr, PositionPtr > Insertion;
669 
670  bool PamHasSelection(const SwPaM& rPaM)
671  {
672  return rPaM.HasMark() && *rPaM.GetPoint() != *rPaM.GetMark();
673  }
674 
676  bool IsInTextBox(const SwFrameFormat* pFormat)
677  {
678  const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
679  const SwPosition* pPosition = rAnchor.GetContentAnchor();
680  if (!pPosition)
681  {
682  return false;
683  }
684 
685  const SwStartNode* pFlyNode = pPosition->nNode.GetNode().FindFlyStartNode();
686  if (!pFlyNode)
687  {
688  return false;
689  }
690 
691  for ( const auto& pSpzFormat : *pFormat->GetDoc()->GetSpzFrameFormats() )
692  {
693  if (pSpzFormat->Which() != RES_FLYFRMFMT)
694  {
695  continue;
696  }
697 
698  const SwNodeIndex* pIdx = pSpzFormat->GetContent().GetContentIdx();
699  if (!pIdx || pFlyNode != &pIdx->GetNode())
700  {
701  continue;
702  }
703 
704  return SwTextBoxHelper::isTextBox(pSpzFormat, RES_FLYFRMFMT);
705  }
706 
707  return false;
708  }
709 }
710 
711 namespace {
712  SwFrameFormat* lcl_PasteFlyOrDrawFormat(SwPaM& rPaM, SwFrameFormat* pCpyFormat, SwFEShell& rSh)
713  {
714  auto& rImp = *rSh.Imp();
715  auto& rDoc = *rSh.GetDoc();
716  auto& rDrawView = *rImp.GetDrawView();
717  if(rDrawView.IsGroupEntered() &&
718  RES_DRAWFRMFMT == pCpyFormat->Which() &&
719  (RndStdIds::FLY_AS_CHAR != pCpyFormat->GetAnchor().GetAnchorId()))
720  {
721  const SdrObject* pSdrObj = pCpyFormat->FindSdrObject();
722  if(pSdrObj)
723  {
724  SdrObject* pNew = rDoc.CloneSdrObj(*pSdrObj, false, false);
725  // Insert object sets any anchor position to 0.
726  // Therefore we calculate the absolute position here
727  // and after the insert the anchor of the object
728  // is set to the anchor of the group object.
729  tools::Rectangle aSnapRect = pNew->GetSnapRect();
730  if(pNew->GetAnchorPos().X() || pNew->GetAnchorPos().Y())
731  {
732  const Point aPoint(0, 0);
733  // OD 2004-04-05 #i26791# - direct drawing object
734  // positioning for group members
735  pNew->NbcSetAnchorPos(aPoint);
736  pNew->NbcSetSnapRect(aSnapRect);
737  }
738 
739  rDrawView.InsertObjectAtView(pNew, *rImp.GetPageView());
740 
741  Point aGrpAnchor(0, 0);
743  if(pList)
744  {
745  SdrObjGroup* pOwner(dynamic_cast<SdrObjGroup*>(pList->getSdrObjectFromSdrObjList()));
746 
747  if(nullptr != pOwner)
748  aGrpAnchor = pOwner->GetAnchorPos();
749  }
750 
751  // OD 2004-04-05 #i26791# - direct drawing object
752  // positioning for group members
753  pNew->NbcSetAnchorPos(aGrpAnchor);
754  pNew->SetSnapRect(aSnapRect);
755  return nullptr;
756  }
757  }
758  SwFormatAnchor aAnchor(pCpyFormat->GetAnchor());
759  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
760  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
761  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
762  {
763  SwPosition* pPos = rPaM.GetPoint();
764  // allow shapes (no controls) in header/footer
765  if(RES_DRAWFRMFMT == pCpyFormat->Which() && rDoc.IsInHeaderFooter(pPos->nNode))
766  {
767  const SdrObject *pCpyObj = pCpyFormat->FindSdrObject();
768  if(pCpyObj && CheckControlLayer(pCpyObj))
769  return nullptr;
770  }
771  else if(pCpyFormat->Which() == RES_FLYFRMFMT && IsInTextBox(pCpyFormat))
772  {
773  // This is a fly frame which is anchored in a TextBox, ignore it as
774  // it's already copied as part of copying the content of the
775  // TextBox.
776  return nullptr;
777  }
778  // Ignore TextBoxes, they are already handled in sw::DocumentLayoutManager::CopyLayoutFormat().
780  return nullptr;
781  aAnchor.SetAnchor(pPos);
782  }
783  else if(RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
784  {
785  aAnchor.SetPageNum(rSh.GetPhyPageNum());
786  }
787  else if(RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId())
788  {
789  Point aPt;
790  (void)lcl_SetAnchor(*rPaM.GetPoint(), rPaM.GetNode(), nullptr, aPt, rSh, aAnchor, aPt, false);
791  }
792 
793  SwFrameFormat* pNew = rDoc.getIDocumentLayoutAccess().CopyLayoutFormat(*pCpyFormat, aAnchor, true, true);
794  return pNew;
795  }
796 
797  void lcl_SelectFlyFormat(SwFrameFormat *const pNew, SwFEShell& rSh)
798  {
799  if(!pNew)
800  return;
801  switch(pNew->Which())
802  {
803  case RES_FLYFRMFMT:
804  {
805  assert(dynamic_cast<SwFlyFrameFormat*>(pNew));
806  const Point aPt(rSh.GetCursorDocPos());
807  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pNew)->GetFrame(&aPt);
808  if(pFlyFrame)
809  rSh.SelectFlyFrame(*pFlyFrame);
810  break;
811  }
812  case RES_DRAWFRMFMT:
813  {
814  auto& rDrawView = *rSh.Imp()->GetDrawView();
815  assert(dynamic_cast<SwDrawFrameFormat*>(pNew));
816  SwDrawFrameFormat* pDrawFormat = static_cast<SwDrawFrameFormat*>(pNew);
817  // #i52780# - drawing object has to be made visible on paste.
819  SdrObject* pObj = pDrawFormat->FindSdrObject();
820  rDrawView.MarkObj(pObj, rDrawView.GetSdrPageView());
821  // #i47455# - notify draw frame format
822  // that position attributes are already set.
823  pDrawFormat->PosAttrSet();
824  break;
825  }
826  default:
827  SAL_WARN("sw.core", "unknown fly type");
828  }
829  }
830 }
831 
832 bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable)
833 {
834  CurrShell aCurr( this );
835  // then till end of the nodes array
836  SwNodeIndex aIdx( rClpDoc.GetNodes().GetEndOfExtras(), 2 );
837  // select content section, whatever it may contain
838  SwPaM aCpyPam(aIdx, SwNodeIndex(rClpDoc.GetNodes().GetEndOfContent(), -1));
839  if (SwContentNode *const pAtEnd = aCpyPam.GetNode(true).GetContentNode())
840  {
841  pAtEnd->MakeEndIndex(&aCpyPam.GetPoint()->nContent);
842  }
843 
844  // If there are table formulas in the area, then display the table first
845  // so that the table formula can calculate a new value first
846  // (individual boxes in the area are retrieved via the layout)
848 
849  SwTableNode *const pSrcNd = aCpyPam.GetNode(false).GetTableNode();
850 
851  bool bRet = true;
852  StartAllAction();
855 
856  // When the clipboard content has been created by a rectangular selection
857  // the pasting is more sophisticated:
858  // every paragraph will be inserted into another position.
859  // The first positions are given by the actual cursor ring,
860  // if there are more text portions to insert than cursor in this ring,
861  // the additional insert positions will be created by moving the last
862  // cursor position into the next line (like pressing the cursor down key)
863  if( rClpDoc.IsColumnSelection() && !IsTableMode() )
864  {
865  // Creation of the list of insert positions
866  std::vector< Insertion > aCopyVector;
867  // The number of text portions of the rectangular selection
868  const SwNodeOffset nSelCount = aCpyPam.GetPoint()->nNode.GetIndex()
869  - aCpyPam.GetMark()->nNode.GetIndex();
870  SwNodeOffset nCount = nSelCount;
871  SwNodeIndex aClpIdx( aIdx );
872  SwPaM* pStartCursor = GetCursor();
873  SwPaM* pCurrCursor = pStartCursor;
874  SwNodeOffset nCursorCount( pStartCursor->GetRingContainer().size() );
875  // If the target selection is a multi-selection, often the last and first
876  // cursor of the ring points to identical document positions. Then
877  // we should avoid double insertion of text portions...
878  while( nCursorCount > SwNodeOffset(1) && *pCurrCursor->GetPoint() ==
879  *(pCurrCursor->GetPrev()->GetPoint()) )
880  {
881  --nCursorCount;
882  pCurrCursor = pCurrCursor->GetNext();
883  pStartCursor = pCurrCursor;
884  }
885  SwPosition aStartPos( *pStartCursor->GetPoint() );
886  SwPosition aInsertPos( aStartPos ); // first insertion position
887  bool bCompletePara = false;
888  sal_uInt16 nMove = 0;
889  while( nCount )
890  {
891  --nCount;
892  OSL_ENSURE( aIdx.GetNode().GetContentNode(), "Who filled the clipboard?!" );
893  if( aIdx.GetNode().GetContentNode() ) // robust
894  {
895  Insertion aInsertion( std::make_shared<SwPaM>( aIdx ),
896  std::make_shared<SwPosition>( aInsertPos ) );
897  ++aIdx;
898  aInsertion.first->SetMark();
899  if( pStartCursor == pCurrCursor->GetNext() )
900  { // Now we have to look for insertion positions...
901  if( !nMove ) // Annotate the last given insert position
902  aStartPos = aInsertPos;
903  SwCursor aCursor( aStartPos, nullptr);
904  // Check if we find another insert position by moving
905  // down the last given position
906  if (aCursor.UpDown(false, ++nMove, nullptr, 0, *GetLayout()))
907  aInsertPos = *aCursor.GetPoint();
908  else // if there is no paragraph we have to create it
909  bCompletePara = nCount > SwNodeOffset(0);
910  nCursorCount = SwNodeOffset(0);
911  }
912  else // as long as we find more insert positions in the cursor ring
913  { // we'll take them
914  pCurrCursor = pCurrCursor->GetNext();
915  aInsertPos = *pCurrCursor->GetPoint();
916  --nCursorCount;
917  }
918  // If there are no more paragraphs e.g. at the end of a document,
919  // we insert complete paragraphs instead of text portions
920  if( bCompletePara )
921  aInsertion.first->GetPoint()->nNode = aIdx;
922  else
923  aInsertion.first->GetPoint()->nContent =
924  aInsertion.first->GetContentNode()->Len();
925  aCopyVector.push_back( aInsertion );
926  }
927  // If there are no text portions left but there are some more
928  // cursor positions to fill we have to restart with the first
929  // text portion
930  if( !nCount && nCursorCount )
931  {
932  nCount = min( nSelCount, nCursorCount );
933  aIdx = aClpIdx; // Start of clipboard content
934  }
935  }
936  for (auto const& item : aCopyVector)
937  {
938  SwPosition& rInsPos = *item.second;
939  SwPaM& rCopy = *item.first;
940  const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().FindTableBoxStartNode();
941  if( pBoxNd && SwNodeOffset(2) == pBoxNd->EndOfSectionIndex() - pBoxNd->GetIndex() &&
942  rCopy.GetPoint()->nNode != rCopy.GetMark()->nNode )
943  {
944  // if more than one node will be copied into a cell
945  // the box attributes have to be removed
946  GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
947  }
948  {
949  SwNodeIndex aIndexBefore(rInsPos.nNode);
950  --aIndexBefore;
952  {
953  ++aIndexBefore;
954  SwPaM aPaM(SwPosition(aIndexBefore),
955  SwPosition(rInsPos.nNode));
956  aPaM.GetDoc().MakeUniqueNumRules(aPaM);
957  }
958  }
959  SaveTableBoxContent( &rInsPos );
960  }
961  }
962  else
963  {
964  bool bDelTable = true;
965 
966  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
967  {
968 
969  SwTableNode *const pDestNd(GetDoc()->IsIdxInTable(rPaM.GetPoint()->nNode));
970  if (pSrcNd && nullptr != pDestNd &&
971  // not a forced nested table insertion
972  !bNestedTable &&
973  // Heuristics to allow copying table rows or nesting tables without
974  // using Edit -> Paste Special -> Paste as Nested Table:
975  // Using table cursor, or if the text selection starts in the
976  // first paragraph, or if there is no selection and the text cursor
977  // is there in the first paragraph, overwrite content of the cell(s)
978  // (else insert a nested table later, i.e. if nothing selected and
979  // the cursor is not in the first paragraph, or the selected text
980  // doesn't contain the first paragraph of the cell)
981  rPaM.GetNode().GetIndex() == rPaM.GetNode().FindTableBoxStartNode()->GetIndex() + 1)
982  {
983  SwPosition aDestPos( *rPaM.GetPoint() );
984 
985  bool bParkTableCursor = false;
986  const SwStartNode* pSttNd = rPaM.GetNode().FindTableBoxStartNode();
987 
988  // TABLE IN TABLE: copy table in table
989  // search boxes via the layout
990  SwSelBoxes aBoxes;
991  if( IsTableMode() ) // table selection?
992  {
993  GetTableSel( *this, aBoxes );
994  ParkTableCursor();
995  bParkTableCursor = true;
996  }
997  else if( !PamHasSelection(rPaM) && rPaM.GetNext() == &rPaM &&
998  ( !pSrcNd->GetTable().IsTableComplex() ||
999  pDestNd->GetTable().IsNewModel() ) )
1000  {
1001  // make relative table copy
1002  SwTableBox* pBox = pDestNd->GetTable().GetTableBox(
1003  pSttNd->GetIndex() );
1004  OSL_ENSURE( pBox, "Box is not in this table" );
1005  aBoxes.insert( pBox );
1006  }
1007 
1008  SwNodeIndex aNdIdx( *pDestNd->EndOfSectionNode());
1009  if( !bParkTableCursor )
1010  {
1011  // exit first the complete table
1012  // ???? what about only table in a frame ?????
1013  SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
1014  SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
1015  // #i59539: Don't remove all redline
1016  SwPaM const tmpPaM(*pDestNd, *pDestNd->EndOfSectionNode());
1017  ::PaMCorrAbs(tmpPaM, aPos);
1018  }
1019 
1020  bRet = GetDoc()->InsCopyOfTable( aDestPos, aBoxes, &pSrcNd->GetTable() );
1021 
1022  if( bParkTableCursor )
1023  GetCursor();
1024  else
1025  {
1026  // return to the box
1027  aNdIdx = *pSttNd;
1028  SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
1029  SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
1030  // #i59539: Don't remove all redline
1031  SwNode & rNode(rPaM.GetPoint()->nNode.GetNode());
1032  SwContentNode *const pContentNode( rNode.GetContentNode() );
1033  SwPaM const tmpPam(rNode, 0,
1034  rNode, pContentNode ? pContentNode->Len() : 0);
1035  ::PaMCorrAbs(tmpPam, aPos);
1036  }
1037 
1038  break; // exit the "while-loop"
1039  }
1040  else if(*aCpyPam.GetPoint() == *aCpyPam.GetMark() && !rClpDoc.GetSpzFrameFormats()->empty())
1041  {
1042  // we need a DrawView
1043  if(!Imp()->GetDrawView())
1044  MakeDrawView();
1045  ::std::vector<SwFrameFormat*> inserted;
1046  for (auto const pFlyFormat : *rClpDoc.GetSpzFrameFormats())
1047  {
1048  // if anchored inside other fly, will be copied when copying
1049  // top-level fly, so skip here! (other non-body anchor
1050  // shouldn't happen here)
1051  SwFormatAnchor const& rAnchor(pFlyFormat->GetAnchor());
1052  if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()
1053  || rClpDoc.GetNodes().GetEndOfExtras().GetIndex() < rAnchor.GetContentAnchor()->nNode.GetIndex())
1054  {
1055  inserted.emplace_back(
1056  lcl_PasteFlyOrDrawFormat(rPaM, pFlyFormat, *this));
1057  }
1058  }
1059  for (auto const pFlyFormat : inserted)
1060  {
1061  lcl_SelectFlyFormat(pFlyFormat, *this);
1062  }
1063  }
1064  else
1065  {
1066  if( bDelTable && IsTableMode() )
1067  {
1068  SwEditShell::Delete(false);
1069  bDelTable = false;
1070  }
1071 
1072  SwPosition& rInsPos = *rPaM.GetPoint();
1073  const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().
1074  FindTableBoxStartNode();
1075  if( pBoxNd && SwNodeOffset(2) == pBoxNd->EndOfSectionIndex() -
1076  pBoxNd->GetIndex() &&
1077  aCpyPam.GetPoint()->nNode != aCpyPam.GetMark()->nNode )
1078  {
1079  // Copy more than 1 node in the current box. But
1080  // then the BoxAttribute should be removed
1081  GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
1082  }
1083 
1084  // **
1085  // ** Update SwDoc::Append, if you change the following code **
1086  // **
1087  {
1088  SwNodeIndex aIndexBefore(rInsPos.nNode);
1089 
1090  --aIndexBefore;
1091 
1093  // Note: aCpyPam is invalid now
1094 
1095  ++aIndexBefore;
1096  SwPaM aPaM(SwPosition(aIndexBefore),
1097  SwPosition(rInsPos.nNode));
1098 
1099  aPaM.GetDoc().MakeUniqueNumRules(aPaM);
1100 
1101  // Update the rsid of each pasted text node.
1102  SwNodes &rDestNodes = GetDoc()->GetNodes();
1103  SwNodeOffset const nEndIdx = aPaM.End()->nNode.GetIndex();
1104 
1105  for (SwNodeOffset nIdx = aPaM.Start()->nNode.GetIndex();
1106  nIdx <= nEndIdx; ++nIdx)
1107  {
1108  SwTextNode *const pTextNode = rDestNodes[nIdx]->GetTextNode();
1109  if ( pTextNode )
1110  {
1111  GetDoc()->UpdateParRsid( pTextNode );
1112  }
1113  }
1114  }
1115 
1116  SaveTableBoxContent( &rInsPos );
1117  }
1118  }
1119  }
1120 
1122 
1123  // have new table formulas been inserted?
1124  if( pTableFieldTyp->HasWriterListeners() )
1125  {
1126  // finish old action: table-frames have been created
1127  // a selection can be made now
1128  sal_uInt16 nActCnt;
1129  for( nActCnt = 0; ActionPend(); ++nActCnt )
1130  EndAllAction();
1131 
1132  for( ; nActCnt; --nActCnt )
1133  StartAllAction();
1134  }
1137  EndAllAction();
1138 
1139  return bRet;
1140 }
1141 
1142 void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage)
1143 {
1144  Push();
1145  if(!GotoPage(nStartPage))
1146  {
1148  return;
1149  }
1151  ::std::optional<SwPaM> oSourcePam( *GetCursor()->GetPoint() );
1152  OUString sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName();
1153  SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, true );
1154  if( pDesc )
1155  rToFill.ChgCurPageDesc( *pDesc );
1156 
1157  if(!GotoPage(nEndPage))
1158  {
1160  return;
1161  }
1162  //if the page starts with a table a paragraph has to be inserted before
1163  SwNode *const pTableNode = oSourcePam->GetNode().FindTableNode();
1164  if(pTableNode)
1165  {
1166  //insert a paragraph
1168  SwNodeIndex aTableIdx( *pTableNode, -1 );
1169  SwPosition aBefore(aTableIdx);
1171  {
1172  SwPaM aTmp(aBefore);
1173  *oSourcePam = aTmp;
1174  }
1176  }
1177 
1179  oSourcePam->SetMark();
1180  *oSourcePam->GetMark() = *GetCursor()->GetPoint();
1181 
1182  CurrShell aCurr( this );
1183 
1184  StartAllAction();
1186  SetSelection(*oSourcePam);
1187  // copy the text of the selection
1188  SwEditShell::Copy(rToFill);
1189  oSourcePam.reset(); // delete it because Undo will remove its node!
1190 
1191  if(pTableNode)
1192  {
1193  //remove the inserted paragraph
1194  Undo();
1195  //remove the paragraph in the second doc, too
1196  SwNodeIndex aIdx( rToFill.GetDoc()->GetNodes().GetEndOfExtras(), 2 );
1197  SwPaM aPara( aIdx ); //DocStart
1198  rToFill.GetDoc()->getIDocumentContentOperations().DelFullPara(aPara);
1199  }
1200  // now the page bound objects
1201  // additionally copy page bound frames
1202  if( !GetDoc()->GetSpzFrameFormats()->empty() )
1203  {
1204  // create a draw view if necessary
1205  if( !rToFill.Imp()->GetDrawView() )
1206  rToFill.MakeDrawView();
1207 
1208  for ( auto pCpyFormat : *GetDoc()->GetSpzFrameFormats() )
1209  {
1210  SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() );
1211  if ((RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) &&
1212  aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage)
1213  {
1214  aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1);
1215  }
1216  else
1217  continue;
1218  rToFill.GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pCpyFormat, aAnchor, true, true );
1219  }
1220  }
1224  EndAllAction();
1225 }
1226 
1228 
1230 {
1231  OSL_ENSURE( Imp()->HasDrawView(), "GetDrawObjGraphic without DrawView?" );
1232  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1233  bool bConvert = true;
1234  if( rMrkList.GetMarkCount() )
1235  {
1236  if( rMrkList.GetMarkCount() == 1 &&
1237  dynamic_cast< const SwVirtFlyDrawObj* >(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) != nullptr )
1238  {
1239  // select frame
1240  if( CNT_GRF == GetCntType() )
1241  {
1242  const Graphic* pGrf( GetGraphic() );
1243  if ( pGrf )
1244  {
1245  Graphic aGrf( *pGrf );
1246  if( SotClipboardFormatId::GDIMETAFILE == nFormat )
1247  {
1248  if( GraphicType::Bitmap != aGrf.GetType() )
1249  {
1250  rGrf = aGrf;
1251  bConvert = false;
1252  }
1253  else if( GetWin() )
1254  {
1255  Size aSz;
1256  Point aPt;
1257  GetGrfSize( aSz );
1258 
1260  pVirtDev->EnableOutput( false );
1261 
1262  MapMode aTmp( GetWin()->GetMapMode() );
1263  aTmp.SetOrigin( aPt );
1264  pVirtDev->SetMapMode( aTmp );
1265 
1266  GDIMetaFile aMtf;
1267  aMtf.Record( pVirtDev.get() );
1268  aGrf.Draw(*pVirtDev, aPt, aSz);
1269  aMtf.Stop();
1270  aMtf.SetPrefMapMode( aTmp );
1271  aMtf.SetPrefSize( aSz );
1272  rGrf = aMtf;
1273  }
1274  }
1275  else if( GraphicType::Bitmap == aGrf.GetType() )
1276  {
1277  rGrf = aGrf;
1278  bConvert = false;
1279  }
1280  else
1281  {
1282  // Not the original size, but the current one.
1283  // Otherwise it could happen that for vector graphics
1284  // many MB's of memory are allocated.
1285  const Size aSz( GetSelectedFlyFrame()->getFramePrintArea().SSize() );
1286  ScopedVclPtrInstance< VirtualDevice > pVirtDev(*GetWin()->GetOutDev());
1287 
1288  MapMode aTmp( MapUnit::MapTwip );
1289  pVirtDev->SetMapMode( aTmp );
1290  if( pVirtDev->SetOutputSize( aSz ) )
1291  {
1292  aGrf.Draw(*pVirtDev, Point(), aSz);
1293  rGrf = pVirtDev->GetBitmapEx( Point(), aSz );
1294  }
1295  else
1296  {
1297  rGrf = aGrf;
1298  bConvert = false;
1299  }
1300  }
1301  }
1302  }
1303  }
1304  else if( SotClipboardFormatId::GDIMETAFILE == nFormat )
1305  rGrf = Imp()->GetDrawView()->GetMarkedObjMetaFile();
1306  else if( SotClipboardFormatId::BITMAP == nFormat || SotClipboardFormatId::PNG == nFormat )
1307  rGrf = Imp()->GetDrawView()->GetMarkedObjBitmapEx();
1308  }
1309  return bConvert;
1310 }
1311 
1312 // #i50824#
1313 // replace method <lcl_RemoveOleObjsFromSdrModel> by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1315 {
1316  for ( sal_uInt16 nPgNum = 0; nPgNum < _rModel.GetPageCount(); ++nPgNum )
1317  {
1318  // setup object iterator in order to iterate through all objects
1319  // including objects in group objects, but exclusive group objects.
1320  SdrObjListIter aIter(_rModel.GetPage(nPgNum));
1321  while( aIter.IsMore() )
1322  {
1323  SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( aIter.Next() );
1324  if( pOle2Obj )
1325  {
1326  // found an ole2 shape
1327  SdrObjList* pObjList = pOle2Obj->getParentSdrObjListFromSdrObject();
1328 
1329  // get its graphic
1330  Graphic aGraphic;
1331  pOle2Obj->Connect();
1332  const Graphic* pGraphic = pOle2Obj->GetGraphic();
1333  if( pGraphic )
1334  aGraphic = *pGraphic;
1335  pOle2Obj->Disconnect();
1336 
1337  // create new graphic shape with the ole graphic and shape size
1338  SdrGrafObj* pGraphicObj = new SdrGrafObj(
1339  _rModel,
1340  aGraphic,
1341  pOle2Obj->GetCurrentBoundRect());
1342  // apply layer of ole2 shape at graphic shape
1343  pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
1344 
1345  // replace ole2 shape with the new graphic object and delete the ol2 shape
1346  SdrObject* pRemovedObject = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
1347  SdrObject::Free( pRemovedObject );
1348  }
1349  }
1350  }
1351 }
1352 
1353 void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
1354 {
1355  CurrShell aCurr( this );
1356  StartAllAction();
1357  StartUndo();
1358 
1359  std::unique_ptr< FmFormModel > pModel(
1360  new FmFormModel(
1361  nullptr,
1362  GetDoc()->GetDocShell()));
1363 
1364  pModel->GetItemPool().FreezeIdRanges();
1365 
1366  rStrm.Seek(0);
1367 
1368  uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rStrm ) );
1369  SvxDrawingLayerImport( pModel.get(), xInputStream );
1370 
1371  if ( !Imp()->HasDrawView() )
1372  Imp()->MakeDrawView();
1373 
1374  Point aPos( pPt ? *pPt : GetCharRect().Pos() );
1375  SdrView *pView = Imp()->GetDrawView();
1376 
1377  // drop on the existing object: replace object or apply new attributes
1378  if( pModel->GetPageCount() > 0 &&
1379  1 == pModel->GetPage(0)->GetObjCount() &&
1380  1 == pView->GetMarkedObjectList().GetMarkCount() )
1381  {
1382  // replace a marked 'virtual' drawing object
1383  // by its corresponding 'master' drawing object in the mark list.
1385 
1386  SdrObject* pClpObj = pModel->GetPage(0)->GetObj(0);
1387  SdrObject* pOldObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1388 
1389  if( SwPasteSdr::SetAttr == nAction && dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1390  nAction = SwPasteSdr::Replace;
1391 
1392  switch( nAction )
1393  {
1394  case SwPasteSdr::Replace:
1395  {
1396  const SwFrameFormat* pFormat(nullptr);
1397  const SwFrame* pAnchor(nullptr);
1398  if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1399  {
1400  pFormat = FindFrameFormat( pOldObj );
1401 
1402  Point aNullPt;
1403  SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrameFormat*>(pFormat)->GetFrame( &aNullPt );
1404  pAnchor = pFlyFrame ? pFlyFrame->GetAnchorFrame() : nullptr;
1405 
1406  if (!pAnchor || pAnchor->FindFooterOrHeader())
1407  {
1408  // if there is a textframe in the header/footer:
1409  // do not replace but insert
1410  nAction = SwPasteSdr::Insert;
1411  break;
1412  }
1413  }
1414 
1415  SdrObject* pNewObj(pClpObj->CloneSdrObject(pOldObj->getSdrModelFromSdrObject()));
1416  tools::Rectangle aOldObjRect( pOldObj->GetCurrentBoundRect() );
1417  Size aOldObjSize( aOldObjRect.GetSize() );
1418  tools::Rectangle aNewRect( pNewObj->GetCurrentBoundRect() );
1419  Size aNewSize( aNewRect.GetSize() );
1420 
1421  Fraction aScaleWidth( aOldObjSize.Width(), aNewSize.Width() );
1422  Fraction aScaleHeight( aOldObjSize.Height(), aNewSize.Height());
1423  pNewObj->NbcResize( aNewRect.TopLeft(), aScaleWidth, aScaleHeight);
1424 
1425  Point aVec = aOldObjRect.TopLeft() - aNewRect.TopLeft();
1426  pNewObj->NbcMove(Size(aVec.getX(), aVec.getY()));
1427 
1428  if( dynamic_cast<const SdrUnoObj*>( pNewObj) != nullptr )
1429  pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
1430  else if( dynamic_cast<const SdrUnoObj*>( pOldObj) != nullptr )
1431  pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
1432  else
1433  pNewObj->SetLayer( pOldObj->GetLayer() );
1434 
1435  if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1436  {
1437  // store attributes, then set SdrObject
1438  SfxItemSetFixed<RES_SURROUND, RES_ANCHOR> aFrameSet( mxDoc->GetAttrPool() );
1439  aFrameSet.Set( pFormat->GetAttrSet() );
1440 
1441  Point aNullPt;
1442  if( pAnchor->IsTextFrame() && static_cast<const SwTextFrame*>(pAnchor)->IsFollow() )
1443  {
1444  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnchor);
1445  do {
1446  pTmp = pTmp->FindMaster();
1447  OSL_ENSURE( pTmp, "Where's my Master?" );
1448  } while( pTmp->IsFollow() );
1449  pAnchor = pTmp;
1450  }
1451  if( auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pOldObj))
1452  aNullPt = pCaptionObj->GetTailPos();
1453  else
1454  aNullPt = aOldObjRect.TopLeft();
1455 
1456  Point aNewAnchor = pAnchor->GetFrameAnchorPos( ::HasWrap( pOldObj ) );
1457  // OD 2004-04-05 #i26791# - direct positioning of Writer
1458  // fly frame object for <SwDoc::Insert(..)>
1459  pNewObj->NbcSetRelativePos( aNullPt - aNewAnchor );
1460  pNewObj->NbcSetAnchorPos( aNewAnchor );
1461 
1462  pOldObj->GetOrdNum();
1463 
1464  DelSelectedObj();
1465 
1466  GetDoc()->getIDocumentContentOperations().InsertDrawObj( *GetCursor(), *pNewObj, aFrameSet );
1467  }
1468  else
1469  {
1470  // #i123922# for handling MasterObject and virtual ones correctly, SW
1471  // wants us to call ReplaceObject at the page, but that also
1472  // triggers the same assertion (I tried it), so stay at the view method
1473  pView->ReplaceObjectAtView(pOldObj, *Imp()->GetPageView(), pNewObj);
1474  }
1475  }
1476  break;
1477 
1478  case SwPasteSdr::SetAttr:
1479  {
1480  SfxItemSet aSet( GetAttrPool() );
1481  const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pClpObj);
1482 
1483  if(pSdrGrafObj)
1484  {
1485  SdrObject* pTarget = nullptr;
1486 
1487  if(0 != pView->GetMarkedObjectList().GetMarkCount())
1488  {
1489  // try to get target (if it's at least one, take first)
1490  SdrMark* pMark = pView->GetMarkedObjectList().GetMark(0);
1491 
1492  if(pMark)
1493  {
1494  pTarget = pMark->GetMarkedSdrObj();
1495  }
1496  }
1497 
1498  if(pTarget)
1499  {
1500  // copy ItemSet from target
1501  aSet.Set(pTarget->GetMergedItemSet());
1502  }
1503 
1504  // for SdrGrafObj, use the graphic as fill style argument
1505  const Graphic& rGraphic = pSdrGrafObj->GetGraphic();
1506 
1507  if(GraphicType::NONE != rGraphic.GetType() && GraphicType::Default != rGraphic.GetType())
1508  {
1509  aSet.Put(XFillBitmapItem(OUString(), rGraphic));
1510  aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
1511  }
1512  }
1513  else
1514  {
1515  aSet.Put(pClpObj->GetMergedItemSet());
1516  }
1517 
1518  pView->SetAttributes( aSet );
1519  }
1520  break;
1521 
1522  default:
1523  nAction = SwPasteSdr::Insert;
1524  break;
1525  }
1526  }
1527  else
1528  nAction = SwPasteSdr::Insert;
1529 
1530  if( SwPasteSdr::Insert == nAction )
1531  {
1532  ::sw::DrawUndoGuard drawUndoGuard(GetDoc()->GetIDocumentUndoRedo());
1533 
1534  bool bDesignMode = pView->IsDesignMode();
1535  if( !bDesignMode )
1536  pView->SetDesignMode();
1537 
1538  // #i50824#
1539  // method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1541  pView->Paste(*pModel, aPos, nullptr, SdrInsertFlags::NONE);
1542 
1543  const size_t nCnt = pView->GetMarkedObjectList().GetMarkCount();
1544  if( nCnt )
1545  {
1546  const Point aNull( 0, 0 );
1547  for( size_t i=0; i < nCnt; ++i )
1548  {
1549  SdrObject *pObj = pView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
1550  pObj->ImpSetAnchorPos( aNull );
1551  }
1552 
1553  pView->SetCurrentObj( SdrObjKind::Group );
1554  if ( nCnt > 1 )
1555  pView->GroupMarked();
1556  SdrObject *pObj = pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1557  if( dynamic_cast<const SdrUnoObj*>( pObj) != nullptr )
1558  {
1559  pObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
1560  bDesignMode = true;
1561  }
1562  else
1563  pObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
1564  const tools::Rectangle &rSnap = pObj->GetSnapRect();
1565  const Size aDiff( rSnap.GetWidth()/2, rSnap.GetHeight()/2 );
1566  pView->MoveMarkedObj( aDiff );
1567  ImpEndCreate();
1568  if( !bDesignMode )
1569  pView->SetDesignMode( false );
1570  }
1571  }
1572  EndUndo();
1573  EndAllAction();
1574 }
1575 
1576 bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
1577 {
1578  CurrShell aCurr( this );
1579  SdrObject* pObj = nullptr;
1580  SdrView *pView = Imp()->GetDrawView();
1581 
1582  bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount();
1583  if (bRet)
1584  {
1585  pObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1586  bRet = pObj->IsClosedObj() && dynamic_cast<const SdrOle2Obj*>( pObj) == nullptr;
1587  }
1588 
1589  if( bRet && pObj )
1590  {
1591  // #i123922# added code to handle the two cases of SdrGrafObj and a fillable, non-
1592  // OLE object in focus
1593  SdrObject* pResult = pObj;
1594 
1595  if(dynamic_cast< SdrGrafObj* >(pObj))
1596  {
1597  SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
1598 
1599  pNewGrafObj->SetGraphic(rGrf);
1600 
1601  // #i123922# for handling MasterObject and virtual ones correctly, SW
1602  // wants us to call ReplaceObject at the page, but that also
1603  // triggers the same assertion (I tried it), so stay at the view method
1604  pView->ReplaceObjectAtView(pObj, *pView->GetSdrPageView(), pNewGrafObj);
1605 
1606  // set in all cases - the Clone() will have copied an existing link (!)
1607  pNewGrafObj->SetGraphicLink(rURL);
1608 
1609  pResult = pNewGrafObj;
1610  }
1611  else
1612  {
1613  pView->AddUndo(std::make_unique<SdrUndoAttrObj>(*pObj));
1614 
1616 
1617  aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
1618  aSet.Put(XFillBitmapItem(OUString(), rGrf));
1619  pObj->SetMergedItemSetAndBroadcast(aSet);
1620  }
1621 
1622  // we are done; mark the modified/new object
1623  pView->MarkObj(pResult, pView->GetSdrPageView());
1624  }
1625 
1626  return bRet;
1627 }
1628 
1629 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
bool IsTableComplex() const
Definition: swtable.cxx:1446
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:241
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:602
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:694
Starts a section of nodes in the document model.
Definition: node.hxx:313
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
bool GotoPage(sal_uInt16 nPage)
Definition: crsrsh.cxx:1188
bool Paste(SwDoc &rClpDoc, bool bNestedTable=false)
Definition: fecopy.cxx:832
Base class of the Writer layout elements.
Definition: frame.hxx:314
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:162
bool AppendTextNode()
Definition: editsh.cxx:205
void Disconnect()
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:224
bool IsFollow() const
Definition: flowfrm.hxx:166
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2895
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:689
size_t GetMarkCount() const
Marks a position in the document model.
Definition: pam.hxx:36
bool IsClosedObj() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
SdrView * GetDrawView()
Definition: vnew.cxx:373
const SwPageFrame * GetPageAtPos(const Point &rPt, const Size *pSize=nullptr, bool bExtend=false) const
Point rPt: The point that should be used to find the page Size pSize: If given, we return the (first)...
Definition: findfrm.cxx:627
void SetDesignMode(bool bOn=true)
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1345
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:680
bool UpdateParRsid(SwTextNode *pTextNode, sal_uInt32 nVal=0)
Definition: docfmt.cxx:436
void SaveTableBoxContent(const SwPosition *pPos=nullptr)
Definition: trvltbl.cxx:870
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
bool Set(const SfxItemSet &, bool bDeep=true)
void PastePages(SwFEShell &rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage)
Paste some pages into another doc - used in mailmerge.
Definition: fecopy.cxx:1142
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
static bool lcl_SetAnchor(const SwPosition &rPos, const SwNode &rNd, SwFlyFrame const *pFly, const Point &rInsPt, SwFEShell const &rDestShell, SwFormatAnchor &rAnchor, Point &rNewPos, bool bCheckFlyRecur)
Definition: fecopy.cxx:239
SwNodeIndex nNode
Definition: pam.hxx:38
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions)
bool IsTableMode() const
Definition: crsrsh.hxx:648
SdrObject * CloneSdrObj(const SdrObject &, bool bMoveWithinDoc=false, bool bInsInPage=true)
Definition: doclay.cxx:108
sal_uInt16 char char * pDesc
#define CNT_GRF
Definition: editsh.hxx:130
const SwPosition * GetMark() const
Definition: pam.hxx:210
bool IsDesignMode() const
void Connect()
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1204
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Definition: doc.hxx:187
void SetPrefSize(const Size &rSize)
virtual SwFrameFormat * CopyLayoutFormat(const SwFrameFormat &rSrc, const SwFormatAnchor &rNewAnchor, bool bSetTextFlyAtt, bool bMakeFrames)=0
void PosAttrSet()
Definition: frmfmt.hxx:407
bool HasDrawView() const
Definition: vnew.cxx:358
sal_uInt64 Seek(sal_uInt64 nPos)
bool IsColumnSelection() const
Definition: doc.hxx:966
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
SwNode & GetNode() const
Definition: ndindex.hxx:128
void Draw(OutputDevice &rOutDev, const Point &rDestPt) const
SdrMark * GetMark(size_t nNum) const
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool GetGrfSize(Size &) const
Definition: editsh.cxx:279
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
bool HasShellFocus() const
Definition: crsrsh.hxx:453
comphelper::OInterfaceContainerHelper3< css::text::XPasteListener > & GetPasteListeners()
Definition: fecopy.cxx:1227
static void Free(SdrObject *&_rpObject)
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:277
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
SwLayoutFrame * GetThisFrame(const SwLayoutFrame *pFrame)
Definition: trvlfrm.cxx:1073
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
bool HasWriterListeners() const
Definition: calbck.hxx:202
void EndAllAction()
Definition: edws.cxx:97
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:172
SAL_DLLPRIVATE bool CopyDrawSel(SwFEShell &rDestShell, const Point &rSttPt, const Point &rInsPt, bool bIsMove, bool bSelectInsert)
Methods for copying of draw objects.
Definition: fecopy.cxx:275
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:743
void ClearBoxNumAttrs(const SwNodeIndex &rNode)
Definition: ndtbl.cxx:4259
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
const OUString & GetName() const
Definition: pagedesc.hxx:196
void MakeDrawView()
Definition: viewimp.cxx:237
void ImpSetAnchorPos(const Point &rPnt)
virtual const tools::Rectangle & GetSnapRect() const
void SelectFlyFrame(SwFlyFrame &rFrame)
Definition: fefly1.cxx:238
virtual void LockExpFields()=0
IDocumentContentOperations & getIDocumentContentOperations()
Provides access to the content operations interface.
Definition: viewsh.cxx:2789
virtual void UpdateExpFields(SwTextField *pField, bool bUpdateRefFields)=0
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
SwTableNode * GetTableNode()
Definition: node.hxx:611
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
void Record(OutputDevice *pOutDev)
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
SwIndex nContent
Definition: pam.hxx:39
bool Delete(bool isArtificialSelection=false)
Delete content of all ranges.
Definition: eddel.cxx:126
const SwRect & getFrameArea() const
Definition: frame.hxx:179
const SwTextFormatColl * GetDfltTextFormatColl() const
Definition: doc.hxx:775
check if target position is in fly anchored at source range
int nCount
void SetGraphic(const Graphic &rGrf)
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
bool IsTextFrame() const
Definition: frame.hxx:1234
virtual bool IsExpFieldsLocked() const =0
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
constexpr tools::Long GetWidth() const
const SwTable & GetTable() const
Definition: node.hxx:506
SwPasteSdr
Definition: fesh.hxx:158
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
bool empty() const
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:161
SotClipboardFormatId
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1111
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:121
void UnmarkAll()
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: viewsh.cxx:2783
bool IsUpperOf(const SwFlyFrame &_rLower) const
Definition: flyfrm.hxx:232
size_type size() const
SwPaM * GetNext()
Definition: pam.hxx:265
bool MovePage(SwWhichPage, SwPosPage)
Definition: crsrsh.cxx:634
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
Specific frame formats (frames, DrawObjects).
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:162
SdrObject * GetMarkedSdrObj() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:140
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:617
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
virtual void SetLayer(SdrLayerID nLayer)
Style of a layout element.
Definition: frmfmt.hxx:59
comphelper::OInterfaceContainerHelper3< css::text::XPasteListener > m_aPasteListeners
Definition: fesh.hxx:209
bool ParkTableCursor()
Invalidate cursors.
Definition: crsrsh.cxx:2790
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
bool IsContentFrame() const
Definition: frame.hxx:1230
void MakeUniqueNumRules(const SwPaM &rPaM)
Definition: docnum.cxx:1235
void Copy(SwDoc &rClpDoc, const OUString *pNewClpText=nullptr)
Copy and Paste methods for internal clipboard.
Definition: fecopy.cxx:77
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:149
SwContentFrame * GetLastSub(const SwLayoutFrame *pLayout)
Definition: trvlfrm.cxx:1056
size_t size() const
Definition: ring.hxx:173
const SwPosition * GetPoint() const
Definition: pam.hxx:208
virtual bool CopyRange(SwPaM &rPam, SwPosition &rPos, SwCopyFlags flags) const =0
Copy a selected content range to a position.
GraphicType GetType() const
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
const Graphic & GetGraphic() const
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2248
sal_uInt16 GetPhyPageNum() const
Phy: real page count.
Definition: fews.cxx:335
void hideMarkHandles()
bool ActionPend() const
Definition: viewsh.hxx:196
bool CopySelToDoc(SwDoc &rInsDoc)
For copying via ClipBoard: If table is copied into table, move all cursors away from it...
Definition: edglss.cxx:154
SwContentNode * GetContentNode()
Definition: node.hxx:627
SwNodeOffset GetIndex() const
Definition: node.hxx:292
const SdrMarkList & GetMarkedObjectList() const
FlyAnchors.
Definition: fmtanchr.hxx:34
void SetOrigin(const Point &rOrigin)
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:126
DECL_LISTENERMULTIPLEXER_END void SAL_CALL inserted(::sal_Int32 ID) override
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
SvLinkSource * pOwner
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
Marks a character position inside a document model node.
Definition: index.hxx:33
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3547
void Undo(sal_uInt16 const nCount=1, sal_uInt16 nOffset=0)
Definition: edundo.cxx:96
SdrModel & getSdrModelFromSdrObject() const
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
sal_uInt32 GetOrdNum() const
static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SdrModel &_rModel)
Definition: fecopy.cxx:1314
bool IsNoTextNode() const
Definition: node.hxx:660
Marks a node in the document model.
Definition: ndindex.hxx:30
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1997
ring_container GetRingContainer()
Definition: ring.hxx:240
bool empty() const
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:57
const Graphic * GetGraphic(bool bWait=true) const
Definition: editsh.cxx:239
stay with the cursor inside text
static sal_uInt16 nPgNum
Definition: viewport.cxx:52
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
SwContentFrame * GetFirstSub(const SwLayoutFrame *pLayout)
Definition: trvlfrm.cxx:1051
const SwPosition * Start() const
Definition: pam.hxx:213
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
constexpr Point TopLeft() const
virtual SdrLayerID GetLayer() const
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
SAL_DLLPRIVATE bool ImpEndCreate()
Definition: feshview.cxx:1866
SwPaM * GetPrev()
Definition: pam.hxx:269
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:448
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2795
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
virtual SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet)=0
Insert a DrawObject.
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
void MakeDrawView()
Definition: vnew.cxx:363
static void ReplaceMarkedDrawVirtObjs(SdrMarkView &_rMarkView)
replace marked -objects by its reference object for delete marked objects.
Definition: dview.cxx:914
virtual SdrObject * ReplaceObject(SdrObject *pNewObj, size_t nObjNum)
SwDrawView * GetDrawView()
Definition: viewimp.hxx:161
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
virtual void NbcSetSnapRect(const tools::Rectangle &rRect)
bool InsCopyOfTable(SwPosition &rInsPos, const SwSelBoxes &rBoxes, const SwTable *pCpyTable, bool bCpyName=false, bool bCorrPos=false, const OUString &rStyleName="")
Copies a Table from the same or another Doc into itself We create a new Table or an existing one is f...
Definition: ndtbl.cxx:4304
void GroupMarked()
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:737
bool GetDrawObjGraphic(SotClipboardFormatId nFormat, Graphic &rGrf) const
Get selected DrawObj as graphics (MetaFile/Bitmap).
Definition: fecopy.cxx:1229
vcl::Window * GetWin() const
Definition: viewsh.hxx:338
sal_uInt16 GetCntType() const
Determine form of content. Return Type at CurrentCursor->SPoint.
Definition: edws.cxx:126
virtual void NbcMove(const Size &rSiz)
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
sal_Int32 GetIndex() const
Definition: index.hxx:91
const SfxItemSet & GetMergedItemSet() const
SwNodes & GetNodes()
Definition: doc.hxx:408
const SwPosition * End() const
Definition: pam.hxx:218
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:521
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:418
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while...
Definition: doccorr.cxx:86
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
delete nodes
Definition: nodes.cxx:1085
size_t IsObjSelected() const
Definition: feshview.cxx:1246
void DelSelectedObj()
Definition: feshview.cxx:2379
static const Point & lcl_FindBasePos(const SwFrame *pFrame, const Point &rPt)
Definition: fecopy.cxx:223
bool HasDrawView() const
New Interface for StarView Drawing.
Definition: viewimp.hxx:160
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false, const sal_uInt32 nMaximumQuadraticPixels=500000, const std::optional< Size > &rTargetDPI=std::nullopt) const
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet, SdrObject *pObj)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
const Point & GetAnchorPos() const
Format of a fly content.
Definition: fmtflcnt.hxx:32
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:198
SdrObject * getParentSdrObjectFromSdrObject() const
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
SdrPageView * GetSdrPageView() const
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
bool Copy(SwEditShell &rDestShell)
Copy content of all ranges at current position of cursor to given Shell.
Definition: eddel.cxx:164
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
SwPageDesc * FindPageDescByName(const OUString &rName, bool bGetFromPool=false, size_t *pPos=nullptr)
Definition: fedesc.cxx:131
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:200
virtual void SetSnapRect(const tools::Rectangle &rRect)
SVXCORE_DLLPUBLIC bool SvxDrawingLayerImport(SdrModel *pModel, const css::uno::Reference< css::io::XInputStream > &xInputStream)
reference_type * get() const
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
#define SAL_WARN(area, stream)
const SfxItemPool & GetItemPool() const
virtual void NbcSetAnchorPos(const Point &rPnt)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
bool newDefault(const value_type &x)
Definition: docfmt.cxx:2161
SwDoc & GetDoc() const
Definition: pam.hxx:244
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:185
const SwFrame * GetAnchorFrame() const
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2270
SdrObjList * getParentSdrObjListFromSdrObject() const
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
virtual void UnlockExpFields()=0
virtual void UpdateFields(bool bCloseDB)=0
std::pair< const_iterator, bool > insert(Value &&x)
void ChgCurPageDesc(const SwPageDesc &)
PageDescriptor-interface.
Definition: fedesc.cxx:43
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:160
::sw::DocumentFieldsManager & GetDocumentFieldsManager()
Definition: doc.cxx:367
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool IsNewModel() const
Definition: swtable.hxx:188
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2172
void GCFieldTypes()
Remove all unreferenced field types of a document.
size_t GetCurPageDesc(const bool bCalcFrame=true) const
Definition: fedesc.cxx:167
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
Definition: ssfrm.cxx:293
SdrModel * GetModel() const
virtual void NbcSetRelativePos(const Point &rPnt)
SdrObjUserCall * GetUserCall() const
virtual SdrObject * getSdrObjectFromSdrObjList() const
Point & GetCursorDocPos() const
Definition: crsrsh.hxx:908
bool IsGroupEntered() const
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1300
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:140
bool IsFrameSelected() const
Definition: feshview.cxx:1254
no RedlineFlags
sal_uInt16 GetPageCount() const
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1318
SdrPageView * GetPageView()
Definition: viewimp.hxx:163
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:864
const Graphic * GetGraphic() const
void SetPrefMapMode(const MapMode &rMapMode)
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
Definition: ndtxt.cxx:104
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1586
bool m_bDetectedRangeSegmentation false
constexpr tools::Long GetHeight() const
void MoveMarkedObj(const Size &rSiz, bool bCopy=false)
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:226
Base class of the Writer document model elements.
Definition: node.hxx:81
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo