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