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