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