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