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  SwPaM aCpyPam( aIdx ); //DocStart
716 
717  // If there are table formulas in the area, then display the table first
718  // so that the table formula can calculate a new value first
719  // (individual boxes in the area are retrieved via the layout)
721 
722  SwTableNode *const pSrcNd = aCpyPam.GetNode().GetTableNode();
723  if( !pSrcNd ) // table node ?
724  { // don't skip !!
725  SwContentNode* pCNd = aCpyPam.GetNode().GetContentNode();
726  if( pCNd )
727  aCpyPam.GetPoint()->nContent.Assign( pCNd, 0 );
728  else if( !aCpyPam.Move( fnMoveForward, GoInNode ))
729  aCpyPam.Move( fnMoveBackward, GoInNode );
730  }
731 
732  aCpyPam.SetMark();
733  aCpyPam.Move( fnMoveForward, GoInDoc );
734 
735  bool bRet = true;
736  StartAllAction();
739 
740  // When the clipboard content has been created by a rectangular selection
741  // the pasting is more sophisticated:
742  // every paragraph will be inserted into another position.
743  // The first positions are given by the actual cursor ring,
744  // if there are more text portions to insert than cursor in this ring,
745  // the additional insert positions will be created by moving the last
746  // cursor position into the next line (like pressing the cursor down key)
747  if( rClpDoc.IsColumnSelection() && !IsTableMode() )
748  {
749  // Creation of the list of insert positions
750  std::vector< Insertion > aCopyVector;
751  // The number of text portions of the rectangular selection
752  const sal_uInt32 nSelCount = aCpyPam.GetPoint()->nNode.GetIndex()
753  - aCpyPam.GetMark()->nNode.GetIndex();
754  sal_uInt32 nCount = nSelCount;
755  SwNodeIndex aClpIdx( aIdx );
756  SwPaM* pStartCursor = GetCursor();
757  SwPaM* pCurrCursor = pStartCursor;
758  sal_uInt32 nCursorCount = pStartCursor->GetRingContainer().size();
759  // If the target selection is a multi-selection, often the last and first
760  // cursor of the ring points to identical document positions. Then
761  // we should avoid double insertion of text portions...
762  while( nCursorCount > 1 && *pCurrCursor->GetPoint() ==
763  *(pCurrCursor->GetPrev()->GetPoint()) )
764  {
765  --nCursorCount;
766  pCurrCursor = pCurrCursor->GetNext();
767  pStartCursor = pCurrCursor;
768  }
769  SwPosition aStartPos( *pStartCursor->GetPoint() );
770  SwPosition aInsertPos( aStartPos ); // first insertion position
771  bool bCompletePara = false;
772  sal_uInt16 nMove = 0;
773  while( nCount )
774  {
775  --nCount;
776  OSL_ENSURE( aIdx.GetNode().GetContentNode(), "Who filled the clipboard?!" );
777  if( aIdx.GetNode().GetContentNode() ) // robust
778  {
779  Insertion aInsertion( std::make_shared<SwPaM>( aIdx ),
780  std::make_shared<SwPosition>( aInsertPos ) );
781  ++aIdx;
782  aInsertion.first->SetMark();
783  if( pStartCursor == pCurrCursor->GetNext() )
784  { // Now we have to look for insertion positions...
785  if( !nMove ) // Annotate the last given insert position
786  aStartPos = aInsertPos;
787  SwCursor aCursor( aStartPos, nullptr);
788  // Check if we find another insert position by moving
789  // down the last given position
790  if (aCursor.UpDown(false, ++nMove, nullptr, 0, *GetLayout()))
791  aInsertPos = *aCursor.GetPoint();
792  else // if there is no paragraph we have to create it
793  bCompletePara = nCount > 0;
794  nCursorCount = 0;
795  }
796  else // as long as we find more insert positions in the cursor ring
797  { // we'll take them
798  pCurrCursor = pCurrCursor->GetNext();
799  aInsertPos = *pCurrCursor->GetPoint();
800  --nCursorCount;
801  }
802  // If there are no more paragraphs e.g. at the end of a document,
803  // we insert complete paragraphs instead of text portions
804  if( bCompletePara )
805  aInsertion.first->GetPoint()->nNode = aIdx;
806  else
807  aInsertion.first->GetPoint()->nContent =
808  aInsertion.first->GetContentNode()->Len();
809  aCopyVector.push_back( aInsertion );
810  }
811  // If there are no text portions left but there are some more
812  // cursor positions to fill we have to restart with the first
813  // text portion
814  if( !nCount && nCursorCount )
815  {
816  nCount = std::min( nSelCount, nCursorCount );
817  aIdx = aClpIdx; // Start of clipboard content
818  }
819  }
820  for (auto const& item : aCopyVector)
821  {
822  SwPosition& rInsPos = *item.second;
823  SwPaM& rCopy = *item.first;
824  const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().FindTableBoxStartNode();
825  if( pBoxNd && 2 == pBoxNd->EndOfSectionIndex() - pBoxNd->GetIndex() &&
826  rCopy.GetPoint()->nNode != rCopy.GetMark()->nNode )
827  {
828  // if more than one node will be copied into a cell
829  // the box attributes have to be removed
830  GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
831  }
832  {
833  SwNodeIndex aIndexBefore(rInsPos.nNode);
834  --aIndexBefore;
836  {
837  ++aIndexBefore;
838  SwPaM aPaM(SwPosition(aIndexBefore),
839  SwPosition(rInsPos.nNode));
840  aPaM.GetDoc().MakeUniqueNumRules(aPaM);
841  }
842  }
843  SaveTableBoxContent( &rInsPos );
844  }
845  }
846  else
847  {
848  bool bDelTable = true;
849 
850  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
851  {
852 
853  SwTableNode *const pDestNd(GetDoc()->IsIdxInTable(rPaM.GetPoint()->nNode));
854  if (pSrcNd && nullptr != pDestNd &&
855  // not a forced nested table insertion
856  !bNestedTable &&
857  // are we at the beginning of the cell? (if not, we will insert a nested table)
858  // first paragraph of the cell?
859  rPaM.GetNode().GetIndex() == rPaM.GetNode().FindTableBoxStartNode()->GetIndex()+1 &&
860  // beginning of the paragraph?
861  !rPaM.GetPoint()->nContent.GetIndex())
862  {
863  SwPosition aDestPos( *rPaM.GetPoint() );
864 
865  bool bParkTableCursor = false;
866  const SwStartNode* pSttNd = rPaM.GetNode().FindTableBoxStartNode();
867 
868  // TABLE IN TABLE: copy table in table
869  // search boxes via the layout
870  SwSelBoxes aBoxes;
871  if( IsTableMode() ) // table selection?
872  {
873  GetTableSel( *this, aBoxes );
874  ParkTableCursor();
875  bParkTableCursor = true;
876  }
877  else if( !PamHasSelection(rPaM) && rPaM.GetNext() == &rPaM &&
878  ( !pSrcNd->GetTable().IsTableComplex() ||
879  pDestNd->GetTable().IsNewModel() ) )
880  {
881  // make relative table copy
882  SwTableBox* pBox = pDestNd->GetTable().GetTableBox(
883  pSttNd->GetIndex() );
884  OSL_ENSURE( pBox, "Box is not in this table" );
885  aBoxes.insert( pBox );
886  }
887 
888  SwNodeIndex aNdIdx( *pDestNd->EndOfSectionNode());
889  if( !bParkTableCursor )
890  {
891  // exit first the complete table
892  // ???? what about only table in a frame ?????
893  SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
894  SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
895  // #i59539: Don't remove all redline
896  SwPaM const tmpPaM(*pDestNd, *pDestNd->EndOfSectionNode());
897  ::PaMCorrAbs(tmpPaM, aPos);
898  }
899 
900  bRet = GetDoc()->InsCopyOfTable( aDestPos, aBoxes, &pSrcNd->GetTable() );
901 
902  if( bParkTableCursor )
903  GetCursor();
904  else
905  {
906  // return to the box
907  aNdIdx = *pSttNd;
908  SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
909  SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
910  // #i59539: Don't remove all redline
911  SwNode & rNode(rPaM.GetPoint()->nNode.GetNode());
912  SwContentNode *const pContentNode( rNode.GetContentNode() );
913  SwPaM const tmpPam(rNode, 0,
914  rNode, pContentNode ? pContentNode->Len() : 0);
915  ::PaMCorrAbs(tmpPam, aPos);
916  }
917 
918  break; // exit the "while-loop"
919  }
920  else if( *aCpyPam.GetPoint() == *aCpyPam.GetMark() &&
921  !rClpDoc.GetSpzFrameFormats()->empty() )
922  {
923  // we need a DrawView
924  if( !Imp()->GetDrawView() )
925  MakeDrawView();
926 
927  for ( auto pCpyFormat : *rClpDoc.GetSpzFrameFormats() )
928  {
929  bool bInsWithFormat = true;
930 
931  if( Imp()->GetDrawView()->IsGroupEntered() &&
932  RES_DRAWFRMFMT == pCpyFormat->Which() &&
933  (RndStdIds::FLY_AS_CHAR != pCpyFormat->GetAnchor().GetAnchorId()) )
934  {
935  const SdrObject* pSdrObj = pCpyFormat->FindSdrObject();
936  if( pSdrObj )
937  {
938  SdrObject* pNew = GetDoc()->CloneSdrObj( *pSdrObj,
939  false, false );
940 
941  // Insert object sets any anchor position to 0.
942  // Therefore we calculate the absolute position here
943  // and after the insert the anchor of the object
944  // is set to the anchor of the group object.
945  tools::Rectangle aSnapRect = pNew->GetSnapRect();
946  if( pNew->GetAnchorPos().X() || pNew->GetAnchorPos().Y() )
947  {
948  const Point aPoint( 0, 0 );
949  // OD 2004-04-05 #i26791# - direct drawing object
950  // positioning for group members
951  pNew->NbcSetAnchorPos( aPoint );
952  pNew->NbcSetSnapRect( aSnapRect );
953  }
954 
955  Imp()->GetDrawView()->InsertObjectAtView( pNew, *Imp()->GetPageView() );
956 
957  Point aGrpAnchor( 0, 0 );
959  if ( pList )
960  {
961  SdrObjGroup* pOwner(dynamic_cast< SdrObjGroup* >(pList->getSdrObjectFromSdrObjList()));
962 
963  if(nullptr != pOwner)
964  {
965  aGrpAnchor = pOwner->GetAnchorPos();
966  }
967  }
968 
969  // OD 2004-04-05 #i26791# - direct drawing object
970  // positioning for group members
971  pNew->NbcSetAnchorPos( aGrpAnchor );
972  pNew->SetSnapRect( aSnapRect );
973 
974  bInsWithFormat = false;
975  }
976  }
977 
978  if( bInsWithFormat )
979  {
980  SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() );
981  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
982  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
983  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
984  {
985  SwPosition* pPos = rPaM.GetPoint();
986  // allow shapes (no controls) in header/footer
987  if( RES_DRAWFRMFMT == pCpyFormat->Which() &&
988  GetDoc()->IsInHeaderFooter( pPos->nNode ) )
989  {
990  const SdrObject *pCpyObj = pCpyFormat->FindSdrObject();
991  if (pCpyObj && CheckControlLayer(pCpyObj))
992  continue;
993  }
994  else if (pCpyFormat->Which() == RES_FLYFRMFMT && IsInTextBox(pCpyFormat))
995  {
996  // This is a fly frame which is anchored in a TextBox, ignore it as
997  // it's already copied as part of copying the content of the
998  // TextBox.
999  continue;
1000  }
1001 
1002  // Ignore TextBoxes, they are already handled in sw::DocumentLayoutManager::CopyLayoutFormat().
1003  if (SwTextBoxHelper::isTextBox(pCpyFormat, RES_FLYFRMFMT))
1004  continue;
1005 
1006  aAnchor.SetAnchor( pPos );
1007  }
1008  else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
1009  {
1010  aAnchor.SetPageNum( GetPhyPageNum() );
1011  }
1012  else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
1013  {
1014  Point aPt;
1015  (void)lcl_SetAnchor( *rPaM.GetPoint(), rPaM.GetNode(),
1016  nullptr, aPt, *this, aAnchor, aPt, false );
1017  }
1018 
1019  SwFrameFormat * pNew = GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pCpyFormat, aAnchor, true, true );
1020 
1021  if( pNew )
1022  {
1023  if( RES_FLYFRMFMT == pNew->Which() )
1024  {
1025  const Point aPt( GetCursorDocPos() );
1026  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pNew)->
1027  GetFrame( &aPt );
1028  if( pFlyFrame )
1029  SelectFlyFrame( *pFlyFrame );
1030  // always pick the first FlyFrame only; the others
1031  // were copied to the clipboard via Fly in Fly
1032  break;
1033  }
1034  else
1035  {
1036  OSL_ENSURE( RES_DRAWFRMFMT == pNew->Which(), "New format.");
1037  // #i52780# - drawing object has to be made visible on paste.
1039  SdrObject *pObj = pNew->FindSdrObject();
1040  SwDrawView *pDV = Imp()->GetDrawView();
1041  pDV->MarkObj( pObj, pDV->GetSdrPageView() );
1042  // #i47455# - notify draw frame format
1043  // that position attributes are already set.
1044  if (SwDrawFrameFormat *pDrawFormat = dynamic_cast<SwDrawFrameFormat*>(pNew))
1045  pDrawFormat->PosAttrSet();
1046  }
1047  }
1048  }
1049  }
1050  }
1051  else
1052  {
1053  if( bDelTable && IsTableMode() )
1054  {
1056  bDelTable = false;
1057  }
1058 
1059  SwPosition& rInsPos = *rPaM.GetPoint();
1060  const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().
1061  FindTableBoxStartNode();
1062  if( pBoxNd && 2 == pBoxNd->EndOfSectionIndex() -
1063  pBoxNd->GetIndex() &&
1064  aCpyPam.GetPoint()->nNode != aCpyPam.GetMark()->nNode )
1065  {
1066  // Copy more than 1 node in the current box. But
1067  // then the BoxAttribute should be removed
1068  GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
1069  }
1070 
1071  // **
1072  // ** Update SwDoc::Append, if you change the following code **
1073  // **
1074  {
1075  SwNodeIndex aIndexBefore(rInsPos.nNode);
1076 
1077  --aIndexBefore;
1078 
1080  // Note: aCpyPam is invalid now
1081 
1082  ++aIndexBefore;
1083  SwPaM aPaM(SwPosition(aIndexBefore),
1084  SwPosition(rInsPos.nNode));
1085 
1086  aPaM.GetDoc().MakeUniqueNumRules(aPaM);
1087 
1088  // Update the rsid of each pasted text node.
1089  SwNodes &rDestNodes = GetDoc()->GetNodes();
1090  sal_uLong const nEndIdx = aPaM.End()->nNode.GetIndex();
1091 
1092  for (sal_uLong nIdx = aPaM.Start()->nNode.GetIndex();
1093  nIdx <= nEndIdx; ++nIdx)
1094  {
1095  SwTextNode *const pTextNode = rDestNodes[nIdx]->GetTextNode();
1096  if ( pTextNode )
1097  {
1098  GetDoc()->UpdateParRsid( pTextNode );
1099  }
1100  }
1101  }
1102 
1103  SaveTableBoxContent( &rInsPos );
1104  }
1105  }
1106  }
1107 
1109 
1110  // have new table formulas been inserted?
1111  if( pTableFieldTyp->HasWriterListeners() )
1112  {
1113  // finish old action: table-frames have been created
1114  // a selection can be made now
1115  sal_uInt16 nActCnt;
1116  for( nActCnt = 0; ActionPend(); ++nActCnt )
1117  EndAllAction();
1118 
1119  for( ; nActCnt; --nActCnt )
1120  StartAllAction();
1121  }
1124  EndAllAction();
1125 
1126  return bRet;
1127 }
1128 
1129 void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage)
1130 {
1131  Push();
1132  if(!GotoPage(nStartPage))
1133  {
1135  return;
1136  }
1138  SwPaM aCpyPam( *GetCursor()->GetPoint() );
1139  OUString sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName();
1140  SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, true );
1141  if( pDesc )
1142  rToFill.ChgCurPageDesc( *pDesc );
1143 
1144  if(!GotoPage(nEndPage))
1145  {
1147  return;
1148  }
1149  //if the page starts with a table a paragraph has to be inserted before
1150  SwNode* pTableNode = aCpyPam.GetNode().FindTableNode();
1151  if(pTableNode)
1152  {
1153  //insert a paragraph
1155  SwNodeIndex aTableIdx( *pTableNode, -1 );
1156  SwPosition aBefore(aTableIdx);
1158  {
1159  SwPaM aTmp(aBefore);
1160  aCpyPam = aTmp;
1161  }
1163  }
1164 
1166  aCpyPam.SetMark();
1167  *aCpyPam.GetMark() = *GetCursor()->GetPoint();
1168 
1169  CurrShell aCurr( this );
1170 
1171  StartAllAction();
1173  SetSelection(aCpyPam);
1174  // copy the text of the selection
1175  SwEditShell::Copy(rToFill);
1176 
1177  if(pTableNode)
1178  {
1179  //remove the inserted paragraph
1180  Undo();
1181  //remove the paragraph in the second doc, too
1182  SwNodeIndex aIdx( rToFill.GetDoc()->GetNodes().GetEndOfExtras(), 2 );
1183  SwPaM aPara( aIdx ); //DocStart
1184  rToFill.GetDoc()->getIDocumentContentOperations().DelFullPara(aPara);
1185  }
1186  // now the page bound objects
1187  // additionally copy page bound frames
1188  if( !GetDoc()->GetSpzFrameFormats()->empty() )
1189  {
1190  // create a draw view if necessary
1191  if( !rToFill.Imp()->GetDrawView() )
1192  rToFill.MakeDrawView();
1193 
1194  for ( auto pCpyFormat : *GetDoc()->GetSpzFrameFormats() )
1195  {
1196  SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() );
1197  if ((RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) &&
1198  aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage)
1199  {
1200  aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1);
1201  }
1202  else
1203  continue;
1204  rToFill.GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pCpyFormat, aAnchor, true, true );
1205  }
1206  }
1210  EndAllAction();
1211 }
1212 
1214 
1216 {
1217  OSL_ENSURE( Imp()->HasDrawView(), "GetDrawObjGraphic without DrawView?" );
1218  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1219  bool bConvert = true;
1220  if( rMrkList.GetMarkCount() )
1221  {
1222  if( rMrkList.GetMarkCount() == 1 &&
1223  dynamic_cast< const SwVirtFlyDrawObj* >(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) != nullptr )
1224  {
1225  // select frame
1226  if( CNT_GRF == GetCntType() )
1227  {
1228  const Graphic* pGrf( GetGraphic() );
1229  if ( pGrf )
1230  {
1231  Graphic aGrf( *pGrf );
1232  if( SotClipboardFormatId::GDIMETAFILE == nFormat )
1233  {
1234  if( GraphicType::Bitmap != aGrf.GetType() )
1235  {
1236  rGrf = aGrf;
1237  bConvert = false;
1238  }
1239  else if( GetWin() )
1240  {
1241  Size aSz;
1242  Point aPt;
1243  GetGrfSize( aSz );
1244 
1246  pVirtDev->EnableOutput( false );
1247 
1248  MapMode aTmp( GetWin()->GetMapMode() );
1249  aTmp.SetOrigin( aPt );
1250  pVirtDev->SetMapMode( aTmp );
1251 
1252  GDIMetaFile aMtf;
1253  aMtf.Record( pVirtDev.get() );
1254  aGrf.Draw( pVirtDev, aPt, aSz );
1255  aMtf.Stop();
1256  aMtf.SetPrefMapMode( aTmp );
1257  aMtf.SetPrefSize( aSz );
1258  rGrf = aMtf;
1259  }
1260  }
1261  else if( GraphicType::Bitmap == aGrf.GetType() )
1262  {
1263  rGrf = aGrf;
1264  bConvert = false;
1265  }
1266  else
1267  {
1268  // Not the original size, but the current one.
1269  // Otherwise it could happen that for vector graphics
1270  // many MB's of memory are allocated.
1271  const Size aSz( GetSelectedFlyFrame()->getFramePrintArea().SSize() );
1273 
1274  MapMode aTmp( MapUnit::MapTwip );
1275  pVirtDev->SetMapMode( aTmp );
1276  if( pVirtDev->SetOutputSize( aSz ) )
1277  {
1278  aGrf.Draw( pVirtDev.get(), Point(), aSz );
1279  rGrf = pVirtDev->GetBitmapEx( Point(), aSz );
1280  }
1281  else
1282  {
1283  rGrf = aGrf;
1284  bConvert = false;
1285  }
1286  }
1287  }
1288  }
1289  }
1290  else if( SotClipboardFormatId::GDIMETAFILE == nFormat )
1291  rGrf = Imp()->GetDrawView()->GetMarkedObjMetaFile();
1292  else if( SotClipboardFormatId::BITMAP == nFormat || SotClipboardFormatId::PNG == nFormat )
1293  rGrf = Imp()->GetDrawView()->GetMarkedObjBitmapEx();
1294  }
1295  return bConvert;
1296 }
1297 
1298 // #i50824#
1299 // replace method <lcl_RemoveOleObjsFromSdrModel> by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1301 {
1302  for ( sal_uInt16 nPgNum = 0; nPgNum < _rModel.GetPageCount(); ++nPgNum )
1303  {
1304  // setup object iterator in order to iterate through all objects
1305  // including objects in group objects, but exclusive group objects.
1306  SdrObjListIter aIter(_rModel.GetPage(nPgNum));
1307  while( aIter.IsMore() )
1308  {
1309  SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( aIter.Next() );
1310  if( pOle2Obj )
1311  {
1312  // found an ole2 shape
1313  SdrObjList* pObjList = pOle2Obj->getParentSdrObjListFromSdrObject();
1314 
1315  // get its graphic
1316  Graphic aGraphic;
1317  pOle2Obj->Connect();
1318  const Graphic* pGraphic = pOle2Obj->GetGraphic();
1319  if( pGraphic )
1320  aGraphic = *pGraphic;
1321  pOle2Obj->Disconnect();
1322 
1323  // create new graphic shape with the ole graphic and shape size
1324  SdrGrafObj* pGraphicObj = new SdrGrafObj(
1325  _rModel,
1326  aGraphic,
1327  pOle2Obj->GetCurrentBoundRect());
1328  // apply layer of ole2 shape at graphic shape
1329  pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
1330 
1331  // replace ole2 shape with the new graphic object and delete the ol2 shape
1332  SdrObject* pRemovedObject = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
1333  SdrObject::Free( pRemovedObject );
1334  }
1335  }
1336  }
1337 }
1338 
1339 void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
1340 {
1341  CurrShell aCurr( this );
1342  StartAllAction();
1343  StartUndo();
1344 
1345  std::unique_ptr< FmFormModel > pModel(
1346  new FmFormModel(
1347  nullptr,
1348  GetDoc()->GetDocShell()));
1349 
1350  pModel->GetItemPool().FreezeIdRanges();
1351 
1352  rStrm.Seek(0);
1353 
1354  uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rStrm ) );
1355  SvxDrawingLayerImport( pModel.get(), xInputStream );
1356 
1357  if ( !Imp()->HasDrawView() )
1358  Imp()->MakeDrawView();
1359 
1360  Point aPos( pPt ? *pPt : GetCharRect().Pos() );
1361  SdrView *pView = Imp()->GetDrawView();
1362 
1363  // drop on the existing object: replace object or apply new attributes
1364  if( pModel->GetPageCount() > 0 &&
1365  1 == pModel->GetPage(0)->GetObjCount() &&
1366  1 == pView->GetMarkedObjectList().GetMarkCount() )
1367  {
1368  // replace a marked 'virtual' drawing object
1369  // by its corresponding 'master' drawing object in the mark list.
1371 
1372  SdrObject* pClpObj = pModel->GetPage(0)->GetObj(0);
1373  SdrObject* pOldObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1374 
1375  if( SwPasteSdr::SetAttr == nAction && dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1376  nAction = SwPasteSdr::Replace;
1377 
1378  switch( nAction )
1379  {
1380  case SwPasteSdr::Replace:
1381  {
1382  const SwFrameFormat* pFormat(nullptr);
1383  const SwFrame* pAnchor(nullptr);
1384  if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1385  {
1386  pFormat = FindFrameFormat( pOldObj );
1387 
1388  Point aNullPt;
1389  SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrameFormat*>(pFormat)->GetFrame( &aNullPt );
1390  pAnchor = pFlyFrame ? pFlyFrame->GetAnchorFrame() : nullptr;
1391 
1392  if (!pAnchor || pAnchor->FindFooterOrHeader())
1393  {
1394  // if there is a textframe in the header/footer:
1395  // do not replace but insert
1396  nAction = SwPasteSdr::Insert;
1397  break;
1398  }
1399  }
1400 
1401  SdrObject* pNewObj(pClpObj->CloneSdrObject(pOldObj->getSdrModelFromSdrObject()));
1402  tools::Rectangle aOldObjRect( pOldObj->GetCurrentBoundRect() );
1403  Size aOldObjSize( aOldObjRect.GetSize() );
1404  tools::Rectangle aNewRect( pNewObj->GetCurrentBoundRect() );
1405  Size aNewSize( aNewRect.GetSize() );
1406 
1407  Fraction aScaleWidth( aOldObjSize.Width(), aNewSize.Width() );
1408  Fraction aScaleHeight( aOldObjSize.Height(), aNewSize.Height());
1409  pNewObj->NbcResize( aNewRect.TopLeft(), aScaleWidth, aScaleHeight);
1410 
1411  Point aVec = aOldObjRect.TopLeft() - aNewRect.TopLeft();
1412  pNewObj->NbcMove(Size(aVec.getX(), aVec.getY()));
1413 
1414  if( dynamic_cast<const SdrUnoObj*>( pNewObj) != nullptr )
1415  pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
1416  else if( dynamic_cast<const SdrUnoObj*>( pOldObj) != nullptr )
1417  pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
1418  else
1419  pNewObj->SetLayer( pOldObj->GetLayer() );
1420 
1421  if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1422  {
1423  // store attributes, then set SdrObject
1424  SfxItemSet aFrameSet( mxDoc->GetAttrPool(),
1426  aFrameSet.Set( pFormat->GetAttrSet() );
1427 
1428  Point aNullPt;
1429  if( pAnchor->IsTextFrame() && static_cast<const SwTextFrame*>(pAnchor)->IsFollow() )
1430  {
1431  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnchor);
1432  do {
1433  pTmp = pTmp->FindMaster();
1434  OSL_ENSURE( pTmp, "Where's my Master?" );
1435  } while( pTmp->IsFollow() );
1436  pAnchor = pTmp;
1437  }
1438  if( auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pOldObj))
1439  aNullPt = pCaptionObj->GetTailPos();
1440  else
1441  aNullPt = aOldObjRect.TopLeft();
1442 
1443  Point aNewAnchor = pAnchor->GetFrameAnchorPos( ::HasWrap( pOldObj ) );
1444  // OD 2004-04-05 #i26791# - direct positioning of Writer
1445  // fly frame object for <SwDoc::Insert(..)>
1446  pNewObj->NbcSetRelativePos( aNullPt - aNewAnchor );
1447  pNewObj->NbcSetAnchorPos( aNewAnchor );
1448 
1449  pOldObj->GetOrdNum();
1450 
1451  DelSelectedObj();
1452 
1453  GetDoc()->getIDocumentContentOperations().InsertDrawObj( *GetCursor(), *pNewObj, aFrameSet );
1454  }
1455  else
1456  {
1457  // #i123922# for handling MasterObject and virtual ones correctly, SW
1458  // wants us to call ReplaceObject at the page, but that also
1459  // triggers the same assertion (I tried it), so stay at the view method
1460  pView->ReplaceObjectAtView(pOldObj, *Imp()->GetPageView(), pNewObj);
1461  }
1462  }
1463  break;
1464 
1465  case SwPasteSdr::SetAttr:
1466  {
1467  SfxItemSet aSet( GetAttrPool() );
1468  const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pClpObj);
1469 
1470  if(pSdrGrafObj)
1471  {
1472  SdrObject* pTarget = nullptr;
1473 
1474  if(0 != pView->GetMarkedObjectList().GetMarkCount())
1475  {
1476  // try to get target (if it's at least one, take first)
1477  SdrMark* pMark = pView->GetMarkedObjectList().GetMark(0);
1478 
1479  if(pMark)
1480  {
1481  pTarget = pMark->GetMarkedSdrObj();
1482  }
1483  }
1484 
1485  if(pTarget)
1486  {
1487  // copy ItemSet from target
1488  aSet.Set(pTarget->GetMergedItemSet());
1489  }
1490 
1491  // for SdrGrafObj, use the graphic as fill style argument
1492  const Graphic& rGraphic = pSdrGrafObj->GetGraphic();
1493 
1494  if(GraphicType::NONE != rGraphic.GetType() && GraphicType::Default != rGraphic.GetType())
1495  {
1496  aSet.Put(XFillBitmapItem(OUString(), rGraphic));
1497  aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
1498  }
1499  }
1500  else
1501  {
1502  aSet.Put(pClpObj->GetMergedItemSet());
1503  }
1504 
1505  pView->SetAttributes( aSet );
1506  }
1507  break;
1508 
1509  default:
1510  nAction = SwPasteSdr::Insert;
1511  break;
1512  }
1513  }
1514  else
1515  nAction = SwPasteSdr::Insert;
1516 
1517  if( SwPasteSdr::Insert == nAction )
1518  {
1519  ::sw::DrawUndoGuard drawUndoGuard(GetDoc()->GetIDocumentUndoRedo());
1520 
1521  bool bDesignMode = pView->IsDesignMode();
1522  if( !bDesignMode )
1523  pView->SetDesignMode();
1524 
1525  // #i50824#
1526  // method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1528  pView->Paste(*pModel, aPos, nullptr, SdrInsertFlags::NONE);
1529 
1530  const size_t nCnt = pView->GetMarkedObjectList().GetMarkCount();
1531  if( nCnt )
1532  {
1533  const Point aNull( 0, 0 );
1534  for( size_t i=0; i < nCnt; ++i )
1535  {
1536  SdrObject *pObj = pView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
1537  pObj->ImpSetAnchorPos( aNull );
1538  }
1539 
1540  pView->SetCurrentObj( OBJ_GRUP );
1541  if ( nCnt > 1 )
1542  pView->GroupMarked();
1543  SdrObject *pObj = pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1544  if( dynamic_cast<const SdrUnoObj*>( pObj) != nullptr )
1545  {
1546  pObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
1547  bDesignMode = true;
1548  }
1549  else
1550  pObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
1551  const tools::Rectangle &rSnap = pObj->GetSnapRect();
1552  const Size aDiff( rSnap.GetWidth()/2, rSnap.GetHeight()/2 );
1553  pView->MoveMarkedObj( aDiff );
1554  ImpEndCreate();
1555  if( !bDesignMode )
1556  pView->SetDesignMode( false );
1557  }
1558  }
1559  EndUndo();
1560  EndAllAction();
1561 }
1562 
1563 bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
1564 {
1565  CurrShell aCurr( this );
1566  SdrObject* pObj = nullptr;
1567  SdrView *pView = Imp()->GetDrawView();
1568 
1569  bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount();
1570  if (bRet)
1571  {
1572  pObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1573  bRet = pObj->IsClosedObj() && dynamic_cast<const SdrOle2Obj*>( pObj) == nullptr;
1574  }
1575 
1576  if( bRet && pObj )
1577  {
1578  // #i123922# added code to handle the two cases of SdrGrafObj and a fillable, non-
1579  // OLE object in focus
1580  SdrObject* pResult = pObj;
1581 
1582  if(dynamic_cast< SdrGrafObj* >(pObj))
1583  {
1584  SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
1585 
1586  pNewGrafObj->SetGraphic(rGrf);
1587 
1588  // #i123922# for handling MasterObject and virtual ones correctly, SW
1589  // wants us to call ReplaceObject at the page, but that also
1590  // triggers the same assertion (I tried it), so stay at the view method
1591  pView->ReplaceObjectAtView(pObj, *pView->GetSdrPageView(), pNewGrafObj);
1592 
1593  // set in all cases - the Clone() will have copied an existing link (!)
1594  pNewGrafObj->SetGraphicLink(rURL);
1595 
1596  pResult = pNewGrafObj;
1597  }
1598  else
1599  {
1600  pView->AddUndo(std::make_unique<SdrUndoAttrObj>(*pObj));
1601 
1603 
1604  aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
1605  aSet.Put(XFillBitmapItem(OUString(), rGrf));
1606  pObj->SetMergedItemSetAndBroadcast(aSet);
1607  }
1608 
1609  // we are done; mark the modified/new object
1610  pView->MarkObj(pResult, pView->GetSdrPageView());
1611  }
1612 
1613  return bRet;
1614 }
1615 
1616 /* 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:685
Starts a section of nodes in the document model.
Definition: node.hxx:311
bool GotoPage(sal_uInt16 nPage)
Definition: crsrsh.cxx:1191
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:151
bool AppendTextNode()
Definition: editsh.cxx:205
void Disconnect()
sal_uLong GetIndex() const
Definition: node.hxx:290
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:2858
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:658
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:1129
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:1208
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Definition: doc.hxx:186
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:1213
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:198
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:4240
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
bool IsInHeaderFooter(const SwNodeIndex &rIdx) const
Definition: doclay.cxx:1551
const OUString & GetName() const
Definition: pagedesc.hxx:186
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:2677
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:1072
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:602
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:500
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:2671
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:637
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:2781
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
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:959
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:2241
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:618
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:3515
SdrModel & getSdrModelFromSdrObject() const
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
sal_uInt32 GetOrdNum() const
static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SdrModel &_rModel)
Definition: fecopy.cxx:1300
bool IsNoTextNode() const
Definition: node.hxx:651
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
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:947
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:140
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:464
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:97
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2683
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:680
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
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:895
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:1215
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
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
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:407
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:2280
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
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
const Point & GetAnchorPos() const
Format of a fly content.
Definition: fmtflcnt.hxx:32
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:196
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
SdrObject * getParentSdrObjectFromSdrObject() const
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:363
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:355
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:198
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:4285
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:2136
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:2263
SdrObjList * getParentSdrObjListFromSdrObject() const
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:137
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:2064
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:1284
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:1319
SdrPageView * GetPageView()
Definition: viewimp.hxx:156
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:846
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:206
Base class of the Writer document model elements.
Definition: node.hxx:79
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo