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& 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  }
403  if( bSelectInsert )
404  pDestDrwView->MarkObj( pNew, pDestPgView );
405  }
406  }
407  }
408  }
409 
410  if ( bIsMove && bRet )
411  {
412  if( &rDestShell == this )
413  {
414  const SdrMarkList aList( pSrcDrwView->GetMarkedObjectList() );
415  pSrcDrwView->UnmarkAll();
416 
417  for ( size_t i = 0, nMrkCnt = aMrkList.GetMarkCount(); i < nMrkCnt; ++i )
418  {
419  SdrObject *pObj = aMrkList.GetMark( i )->GetMarkedSdrObj();
420  pSrcDrwView->MarkObj( pObj, pSrcPgView );
421  }
422  DelSelectedObj();
423  for ( size_t i = 0, nMrkCnt = aList.GetMarkCount(); i < nMrkCnt; ++i )
424  {
425  SdrObject *pObj = aList.GetMark( i )->GetMarkedSdrObj();
426  pSrcDrwView->MarkObj( pObj, pSrcPgView );
427  }
428  }
429  else
430  DelSelectedObj();
431  }
432 
433  return bRet;
434 }
435 
436 bool SwFEShell::Copy( SwFEShell& rDestShell, const Point& rSttPt,
437  const Point& rInsPt, bool bIsMove, bool bSelectInsert )
438 {
439  bool bRet = false;
440 
441  OSL_ENSURE( this == &rDestShell || !rDestShell.IsObjSelected(),
442  "Dest-Shell cannot be in Obj-Mode" );
443 
444  CurrShell aCurr( &rDestShell );
445 
446  rDestShell.StartAllAction();
448 
449  // Shift references
450  bool bCopyIsMove = mxDoc->IsCopyIsMove();
451  if( bIsMove )
452  // set a flag in Doc, handled in TextNodes
453  mxDoc->SetCopyIsMove( true );
454 
455  RedlineFlags eOldRedlMode = rDestShell.GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
457 
458  // If there are table formulas in the area, then display the table first
459  // so that the table formula can calculate a new value first
460  // (individual boxes in the area are retrieved via the layout)
461  SwFieldType* pTableFieldTyp = rDestShell.GetDoc()->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Table );
462 
463  if( IsFrameSelected() )
464  {
466  SwFrameFormat* pFlyFormat = pFly->GetFormat();
467  SwFormatAnchor aAnchor( pFlyFormat->GetAnchor() );
468  bRet = true;
469  Point aNewAnch;
470 
471  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
472  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
473  (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) ||
474  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
475  {
476  if ( this == &rDestShell )
477  {
478  // same shell? Then request the position
479  // from the passed DocumentPosition
480  SwPosition aPos( *GetCursor()->GetPoint() );
481  Point aPt( rInsPt );
482  aPt -= rSttPt - pFly->getFrameArea().Pos();
484  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt, &aState );
485  const SwNode *pNd;
486  if( (pNd = &aPos.nNode.GetNode())->IsNoTextNode() )
487  bRet = false;
488  else
489  {
490  // do not copy in itself
491  const SwNodeIndex *pTmp = pFlyFormat->GetContent().GetContentIdx();
492  if ( aPos.nNode > *pTmp && aPos.nNode <
493  pTmp->GetNode().EndOfSectionIndex() )
494  {
495  bRet = false;
496  }
497  else
498  bRet = ::lcl_SetAnchor( aPos, *pNd, pFly, rInsPt,
499  rDestShell, aAnchor, aNewAnch, true );
500  }
501  }
502  else
503  {
504  const SwPaM *pCursor = rDestShell.GetCursor();
505  if( pCursor->GetNode().IsNoTextNode() )
506  bRet = false;
507  else
508  bRet = ::lcl_SetAnchor( *pCursor->GetPoint(), pCursor->GetNode(),
509  pFly, rInsPt, rDestShell, aAnchor,
510  aNewAnch, GetDoc() == rDestShell.GetDoc());
511  }
512  }
513  else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
514  {
515  aAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) );
516  const SwRootFrame* pTmpRoot = rDestShell.GetLayout();
517  const SwFrame* pPg = pTmpRoot->GetPageAtPos( rInsPt, nullptr, true );
518  if ( pPg )
519  aNewAnch = pPg->getFrameArea().Pos();
520  }
521  else {
522  OSL_ENSURE( false, "what anchor is it?" );
523  }
524 
525  if( bRet )
526  {
527  SwFrameFormat *pOldFormat = pFlyFormat;
528  pFlyFormat = rDestShell.GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pFlyFormat, aAnchor, true, true );
529 
530  if ( RndStdIds::FLY_AS_CHAR != aAnchor.GetAnchorId() )
531  {
532  Point aPos( rInsPt );
533  aPos -= aNewAnch;
534  aPos -= rSttPt - pFly->getFrameArea().Pos();
535  pFlyFormat->SetFormatAttr( SwFormatHoriOrient( aPos.getX(),text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
536  pFlyFormat->SetFormatAttr( SwFormatVertOrient( aPos.getY(),text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
537  }
538 
539  const Point aPt( rDestShell.GetCursorDocPos() );
540 
541  if( bIsMove )
543 
544  // only select if it can be shifted/copied in the same shell
545  if( bSelectInsert )
546  {
547  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pFlyFormat)->GetFrame( &aPt );
548  if( pFlyFrame )
549  {
550  //JP 12.05.98: should this be in SelectFlyFrame???
551  rDestShell.Imp()->GetDrawView()->UnmarkAll();
552  rDestShell.SelectFlyFrame( *pFlyFrame );
553  }
554  }
555 
556  if (this != &rDestShell && !rDestShell.HasShellFocus())
557  rDestShell.Imp()->GetDrawView()->hideMarkHandles();
558  }
559  }
560  else if ( IsObjSelected() )
561  bRet = CopyDrawSel( rDestShell, rSttPt, rInsPt, bIsMove, bSelectInsert );
562  else if( IsTableMode() )
563  {
564  // Copy parts from a table: create a table with the same
565  // width as the original and copy the selected boxes.
566  // Sizes will be corrected by percentage.
567 
568  // find boxes via the layout
569  SwSelBoxes aBoxes;
570  GetTableSel( *this, aBoxes );
571  SwTableNode const*const pTableNd(
572  aBoxes.empty() ? nullptr : aBoxes[0]->GetSttNd()->FindTableNode());
573  if (nullptr != pTableNd)
574  {
575  std::unique_ptr<SwPosition> pDstPos;
576  if( this == &rDestShell )
577  {
578  // same shell? Then create new Cursor at the
579  // DocumentPosition passed
580  pDstPos.reset(new SwPosition( *GetCursor()->GetPoint() ));
581  Point aPt( rInsPt );
582  GetLayout()->GetModelPositionForViewPoint( pDstPos.get(), aPt );
583  if( !pDstPos->nNode.GetNode().IsNoTextNode() )
584  bRet = true;
585  }
586  else if( !rDestShell.GetCursor()->GetNode().IsNoTextNode() )
587  {
588  pDstPos.reset(new SwPosition( *rDestShell.GetCursor()->GetPoint() ));
589  bRet = true;
590  }
591 
592  if( bRet )
593  {
594  if( GetDoc() == rDestShell.GetDoc() )
595  ParkTableCursor();
596 
597  bRet = rDestShell.GetDoc()->InsCopyOfTable( *pDstPos, aBoxes,nullptr,
598  bIsMove && this == &rDestShell &&
599  aBoxes.size() == pTableNd->GetTable().
600  GetTabSortBoxes().size(),
601  this != &rDestShell );
602 
603  if( this != &rDestShell )
604  *rDestShell.GetCursor()->GetPoint() = *pDstPos;
605 
606  // create all parked Cursor?
607  if( GetDoc() == rDestShell.GetDoc() )
608  GetCursor();
609 
610  // JP 16.04.99: Bug 64908 - Set InsPos, to assure the parked
611  // Cursor is positioned at the insert position
612  if( this == &rDestShell )
613  GetCursorDocPos() = rInsPt;
614  }
615  }
616  }
617  else
618  {
619  bRet = true;
620  if( this == &rDestShell )
621  {
622  // same shell? then request the position
623  // at the passed document position
624  SwPosition aPos( *GetCursor()->GetPoint() );
625  Point aPt( rInsPt );
626  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
627  bRet = !aPos.nNode.GetNode().IsNoTextNode();
628  }
629  else if( rDestShell.GetCursor()->GetNode().IsNoTextNode() )
630  bRet = false;
631 
632  if( bRet )
633  bRet = SwEditShell::Copy( rDestShell );
634  }
635 
636  rDestShell.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOldRedlMode );
637  mxDoc->SetCopyIsMove( bCopyIsMove );
638 
639  // have new table formulas been inserted?
640  if( pTableFieldTyp->HasWriterListeners() )
641  {
642  // finish old actions: the table frames are created and
643  // a selection can be made
644  sal_uInt16 nActCnt;
645  for( nActCnt = 0; rDestShell.ActionPend(); ++nActCnt )
646  rDestShell.EndAllAction();
647 
648  for( ; nActCnt; --nActCnt )
649  rDestShell.StartAllAction();
650  }
652  rDestShell.GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
653 
654  rDestShell.EndAllAction();
655  return bRet;
656 }
657 
658 // Paste for the internal clipboard. Copy the content of the clipboard
659 // in the document
660 namespace {
661  typedef std::shared_ptr<SwPaM> PaMPtr;
662  typedef std::shared_ptr<SwPosition> PositionPtr;
663  typedef std::pair< PaMPtr, PositionPtr > Insertion;
664 
665  bool PamHasSelection(const SwPaM& rPaM)
666  {
667  return rPaM.HasMark() && *rPaM.GetPoint() != *rPaM.GetMark();
668  }
669 }
670 
671 bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable)
672 {
673  CurrShell aCurr( this );
674  // then till end of the nodes array
675  SwNodeIndex aIdx( rClpDoc.GetNodes().GetEndOfExtras(), 2 );
676  SwPaM aCpyPam( aIdx ); //DocStart
677 
678  // If there are table formulas in the area, then display the table first
679  // so that the table formula can calculate a new value first
680  // (individual boxes in the area are retrieved via the layout)
682 
683  SwTableNode *const pSrcNd = aCpyPam.GetNode().GetTableNode();
684  if( !pSrcNd ) // table node ?
685  { // don't skip !!
686  SwContentNode* pCNd = aCpyPam.GetNode().GetContentNode();
687  if( pCNd )
688  aCpyPam.GetPoint()->nContent.Assign( pCNd, 0 );
689  else if( !aCpyPam.Move( fnMoveForward, GoInNode ))
690  aCpyPam.Move( fnMoveBackward, GoInNode );
691  }
692 
693  aCpyPam.SetMark();
694  aCpyPam.Move( fnMoveForward, GoInDoc );
695 
696  bool bRet = true;
697  StartAllAction();
700 
701  // When the clipboard content has been created by a rectangular selection
702  // the pasting is more sophisticated:
703  // every paragraph will be inserted into another position.
704  // The first positions are given by the actual cursor ring,
705  // if there are more text portions to insert than cursor in this ring,
706  // the additional insert positions will be created by moving the last
707  // cursor position into the next line (like pressing the cursor down key)
708  if( rClpDoc.IsColumnSelection() && !IsTableMode() )
709  {
710  // Creation of the list of insert positions
711  std::vector< Insertion > aCopyVector;
712  // The number of text portions of the rectangular selection
713  const sal_uInt32 nSelCount = aCpyPam.GetPoint()->nNode.GetIndex()
714  - aCpyPam.GetMark()->nNode.GetIndex();
715  sal_uInt32 nCount = nSelCount;
716  SwNodeIndex aClpIdx( aIdx );
717  SwPaM* pStartCursor = GetCursor();
718  SwPaM* pCurrCursor = pStartCursor;
719  sal_uInt32 nCursorCount = pStartCursor->GetRingContainer().size();
720  // If the target selection is a multi-selection, often the last and first
721  // cursor of the ring points to identical document positions. Then
722  // we should avoid double insertion of text portions...
723  while( nCursorCount > 1 && *pCurrCursor->GetPoint() ==
724  *(pCurrCursor->GetPrev()->GetPoint()) )
725  {
726  --nCursorCount;
727  pCurrCursor = pCurrCursor->GetNext();
728  pStartCursor = pCurrCursor;
729  }
730  SwPosition aStartPos( *pStartCursor->GetPoint() );
731  SwPosition aInsertPos( aStartPos ); // first insertion position
732  bool bCompletePara = false;
733  sal_uInt16 nMove = 0;
734  while( nCount )
735  {
736  --nCount;
737  OSL_ENSURE( aIdx.GetNode().GetContentNode(), "Who filled the clipboard?!" );
738  if( aIdx.GetNode().GetContentNode() ) // robust
739  {
740  Insertion aInsertion( std::make_shared<SwPaM>( aIdx ),
741  std::make_shared<SwPosition>( aInsertPos ) );
742  ++aIdx;
743  aInsertion.first->SetMark();
744  if( pStartCursor == pCurrCursor->GetNext() )
745  { // Now we have to look for insertion positions...
746  if( !nMove ) // Annotate the last given insert position
747  aStartPos = aInsertPos;
748  SwCursor aCursor( aStartPos, nullptr);
749  // Check if we find another insert position by moving
750  // down the last given position
751  if (aCursor.UpDown(false, ++nMove, nullptr, 0, *GetLayout()))
752  aInsertPos = *aCursor.GetPoint();
753  else // if there is no paragraph we have to create it
754  bCompletePara = nCount > 0;
755  nCursorCount = 0;
756  }
757  else // as long as we find more insert positions in the cursor ring
758  { // we'll take them
759  pCurrCursor = pCurrCursor->GetNext();
760  aInsertPos = *pCurrCursor->GetPoint();
761  --nCursorCount;
762  }
763  // If there are no more paragraphs e.g. at the end of a document,
764  // we insert complete paragraphs instead of text portions
765  if( bCompletePara )
766  aInsertion.first->GetPoint()->nNode = aIdx;
767  else
768  aInsertion.first->GetPoint()->nContent =
769  aInsertion.first->GetContentNode()->Len();
770  aCopyVector.push_back( aInsertion );
771  }
772  // If there are no text portions left but there are some more
773  // cursor positions to fill we have to restart with the first
774  // text portion
775  if( !nCount && nCursorCount )
776  {
777  nCount = std::min( nSelCount, nCursorCount );
778  aIdx = aClpIdx; // Start of clipboard content
779  }
780  }
781  for (auto const& item : aCopyVector)
782  {
783  SwPosition& rInsPos = *item.second;
784  SwPaM& rCopy = *item.first;
785  const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().FindTableBoxStartNode();
786  if( pBoxNd && 2 == pBoxNd->EndOfSectionIndex() - pBoxNd->GetIndex() &&
787  rCopy.GetPoint()->nNode != rCopy.GetMark()->nNode )
788  {
789  // if more than one node will be copied into a cell
790  // the box attributes have to be removed
791  GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
792  }
793  {
794  SwNodeIndex aIndexBefore(rInsPos.nNode);
795  --aIndexBefore;
797  {
798  ++aIndexBefore;
799  SwPaM aPaM(SwPosition(aIndexBefore),
800  SwPosition(rInsPos.nNode));
801  aPaM.GetDoc().MakeUniqueNumRules(aPaM);
802  }
803  }
804  SaveTableBoxContent( &rInsPos );
805  }
806  }
807  else
808  {
809  bool bDelTable = true;
810 
811  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
812  {
813 
814  SwTableNode *const pDestNd(GetDoc()->IsIdxInTable(rPaM.GetPoint()->nNode));
815  if (pSrcNd && nullptr != pDestNd &&
816  // not a forced nested table insertion
817  !bNestedTable &&
818  // are we at the beginning of the cell? (if not, we will insert a nested table)
819  // first paragraph of the cell?
820  rPaM.GetNode().GetIndex() == rPaM.GetNode().FindTableBoxStartNode()->GetIndex()+1 &&
821  // beginning of the paragraph?
822  !rPaM.GetPoint()->nContent.GetIndex())
823  {
824  SwPosition aDestPos( *rPaM.GetPoint() );
825 
826  bool bParkTableCursor = false;
827  const SwStartNode* pSttNd = rPaM.GetNode().FindTableBoxStartNode();
828 
829  // TABLE IN TABLE: copy table in table
830  // search boxes via the layout
831  SwSelBoxes aBoxes;
832  if( IsTableMode() ) // table selection?
833  {
834  GetTableSel( *this, aBoxes );
835  ParkTableCursor();
836  bParkTableCursor = true;
837  }
838  else if( !PamHasSelection(rPaM) && rPaM.GetNext() == &rPaM &&
839  ( !pSrcNd->GetTable().IsTableComplex() ||
840  pDestNd->GetTable().IsNewModel() ) )
841  {
842  // make relative table copy
843  SwTableBox* pBox = pDestNd->GetTable().GetTableBox(
844  pSttNd->GetIndex() );
845  OSL_ENSURE( pBox, "Box is not in this table" );
846  aBoxes.insert( pBox );
847  }
848 
849  SwNodeIndex aNdIdx( *pDestNd->EndOfSectionNode());
850  if( !bParkTableCursor )
851  {
852  // exit first the complete table
853  // ???? what about only table in a frame ?????
854  SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
855  SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
856  // #i59539: Don't remove all redline
857  SwPaM const tmpPaM(*pDestNd, *pDestNd->EndOfSectionNode());
858  ::PaMCorrAbs(tmpPaM, aPos);
859  }
860 
861  bRet = GetDoc()->InsCopyOfTable( aDestPos, aBoxes, &pSrcNd->GetTable() );
862 
863  if( bParkTableCursor )
864  GetCursor();
865  else
866  {
867  // return to the box
868  aNdIdx = *pSttNd;
869  SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx );
870  SwPosition aPos( aNdIdx, SwIndex( pCNd, 0 ));
871  // #i59539: Don't remove all redline
872  SwNode & rNode(rPaM.GetPoint()->nNode.GetNode());
873  SwContentNode *const pContentNode( rNode.GetContentNode() );
874  SwPaM const tmpPam(rNode, 0,
875  rNode, pContentNode ? pContentNode->Len() : 0);
876  ::PaMCorrAbs(tmpPam, aPos);
877  }
878 
879  break; // exit the "while-loop"
880  }
881  else if( *aCpyPam.GetPoint() == *aCpyPam.GetMark() &&
882  !rClpDoc.GetSpzFrameFormats()->empty() )
883  {
884  // we need a DrawView
885  if( !Imp()->GetDrawView() )
886  MakeDrawView();
887 
888  for ( auto pCpyFormat : *rClpDoc.GetSpzFrameFormats() )
889  {
890  bool bInsWithFormat = true;
891 
892  if( Imp()->GetDrawView()->IsGroupEntered() &&
893  RES_DRAWFRMFMT == pCpyFormat->Which() &&
894  (RndStdIds::FLY_AS_CHAR != pCpyFormat->GetAnchor().GetAnchorId()) )
895  {
896  const SdrObject* pSdrObj = pCpyFormat->FindSdrObject();
897  if( pSdrObj )
898  {
899  SdrObject* pNew = GetDoc()->CloneSdrObj( *pSdrObj,
900  false, false );
901 
902  // Insert object sets any anchor position to 0.
903  // Therefore we calculate the absolute position here
904  // and after the insert the anchor of the object
905  // is set to the anchor of the group object.
906  tools::Rectangle aSnapRect = pNew->GetSnapRect();
907  if( pNew->GetAnchorPos().X() || pNew->GetAnchorPos().Y() )
908  {
909  const Point aPoint( 0, 0 );
910  // OD 2004-04-05 #i26791# - direct drawing object
911  // positioning for group members
912  pNew->NbcSetAnchorPos( aPoint );
913  pNew->NbcSetSnapRect( aSnapRect );
914  }
915 
916  Imp()->GetDrawView()->InsertObjectAtView( pNew, *Imp()->GetPageView() );
917 
918  Point aGrpAnchor( 0, 0 );
920  if ( pList )
921  {
922  SdrObjGroup* pOwner(dynamic_cast< SdrObjGroup* >(pList->getSdrObjectFromSdrObjList()));
923 
924  if(nullptr != pOwner)
925  {
926  aGrpAnchor = pOwner->GetAnchorPos();
927  }
928  }
929 
930  // OD 2004-04-05 #i26791# - direct drawing object
931  // positioning for group members
932  pNew->NbcSetAnchorPos( aGrpAnchor );
933  pNew->SetSnapRect( aSnapRect );
934 
935  bInsWithFormat = false;
936  }
937  }
938 
939  if( bInsWithFormat )
940  {
941  SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() );
942  if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) ||
943  (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) ||
944  (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId()))
945  {
946  SwPosition* pPos = rPaM.GetPoint();
947  // allow shapes (no controls) in header/footer
948  if( RES_DRAWFRMFMT == pCpyFormat->Which() &&
949  GetDoc()->IsInHeaderFooter( pPos->nNode ) )
950  {
951  const SdrObject *pCpyObj = pCpyFormat->FindSdrObject();
952  if (pCpyObj && CheckControlLayer(pCpyObj))
953  continue;
954  }
955 
956  // Ignore TextBoxes, they are already handled in sw::DocumentLayoutManager::CopyLayoutFormat().
957  if (SwTextBoxHelper::isTextBox(pCpyFormat, RES_FLYFRMFMT))
958  continue;
959 
960  aAnchor.SetAnchor( pPos );
961  }
962  else if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() )
963  {
964  aAnchor.SetPageNum( GetPhyPageNum() );
965  }
966  else if( RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() )
967  {
968  Point aPt;
969  (void)lcl_SetAnchor( *rPaM.GetPoint(), rPaM.GetNode(),
970  nullptr, aPt, *this, aAnchor, aPt, false );
971  }
972 
973  SwFrameFormat * pNew = GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pCpyFormat, aAnchor, true, true );
974 
975  if( pNew )
976  {
977  if( RES_FLYFRMFMT == pNew->Which() )
978  {
979  const Point aPt( GetCursorDocPos() );
980  SwFlyFrame* pFlyFrame = static_cast<SwFlyFrameFormat*>(pNew)->
981  GetFrame( &aPt );
982  if( pFlyFrame )
983  SelectFlyFrame( *pFlyFrame );
984  // always pick the first FlyFrame only; the others
985  // were copied to the clipboard via Fly in Fly
986  break;
987  }
988  else
989  {
990  OSL_ENSURE( RES_DRAWFRMFMT == pNew->Which(), "New format.");
991  // #i52780# - drawing object has to be made visible on paste.
993  SdrObject *pObj = pNew->FindSdrObject();
994  SwDrawView *pDV = Imp()->GetDrawView();
995  pDV->MarkObj( pObj, pDV->GetSdrPageView() );
996  // #i47455# - notify draw frame format
997  // that position attributes are already set.
998  if (SwDrawFrameFormat *pDrawFormat = dynamic_cast<SwDrawFrameFormat*>(pNew))
999  pDrawFormat->PosAttrSet();
1000  }
1001  }
1002  }
1003  }
1004  }
1005  else
1006  {
1007  if( bDelTable && IsTableMode() )
1008  {
1010  bDelTable = false;
1011  }
1012 
1013  SwPosition& rInsPos = *rPaM.GetPoint();
1014  const SwStartNode* pBoxNd = rInsPos.nNode.GetNode().
1015  FindTableBoxStartNode();
1016  if( pBoxNd && 2 == pBoxNd->EndOfSectionIndex() -
1017  pBoxNd->GetIndex() &&
1018  aCpyPam.GetPoint()->nNode != aCpyPam.GetMark()->nNode )
1019  {
1020  // Copy more than 1 node in the current box. But
1021  // then the BoxAttribute should be removed
1022  GetDoc()->ClearBoxNumAttrs( rInsPos.nNode );
1023  }
1024 
1025  // **
1026  // ** Update SwDoc::Append, if you change the following code **
1027  // **
1028  {
1029  SwNodeIndex aIndexBefore(rInsPos.nNode);
1030 
1031  --aIndexBefore;
1032 
1034  // Note: aCpyPam is invalid now
1035 
1036  ++aIndexBefore;
1037  SwPaM aPaM(SwPosition(aIndexBefore),
1038  SwPosition(rInsPos.nNode));
1039 
1040  aPaM.GetDoc().MakeUniqueNumRules(aPaM);
1041 
1042  // Update the rsid of each pasted text node.
1043  SwNodes &rDestNodes = GetDoc()->GetNodes();
1044  sal_uLong const nEndIdx = aPaM.End()->nNode.GetIndex();
1045 
1046  for (sal_uLong nIdx = aPaM.Start()->nNode.GetIndex();
1047  nIdx <= nEndIdx; ++nIdx)
1048  {
1049  SwTextNode *const pTextNode = rDestNodes[nIdx]->GetTextNode();
1050  if ( pTextNode )
1051  {
1052  GetDoc()->UpdateParRsid( pTextNode );
1053  }
1054  }
1055  }
1056 
1057  SaveTableBoxContent( &rInsPos );
1058  }
1059  }
1060  }
1061 
1063 
1064  // have new table formulas been inserted?
1065  if( pTableFieldTyp->HasWriterListeners() )
1066  {
1067  // finish old action: table-frames have been created
1068  // a selection can be made now
1069  sal_uInt16 nActCnt;
1070  for( nActCnt = 0; ActionPend(); ++nActCnt )
1071  EndAllAction();
1072 
1073  for( ; nActCnt; --nActCnt )
1074  StartAllAction();
1075  }
1078  EndAllAction();
1079 
1080  return bRet;
1081 }
1082 
1083 void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt16 nEndPage)
1084 {
1085  Push();
1086  if(!GotoPage(nStartPage))
1087  {
1089  return;
1090  }
1092  SwPaM aCpyPam( *GetCursor()->GetPoint() );
1093  OUString sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName();
1094  SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, true );
1095  if( pDesc )
1096  rToFill.ChgCurPageDesc( *pDesc );
1097 
1098  if(!GotoPage(nEndPage))
1099  {
1101  return;
1102  }
1103  //if the page starts with a table a paragraph has to be inserted before
1104  SwNode* pTableNode = aCpyPam.GetNode().FindTableNode();
1105  if(pTableNode)
1106  {
1107  //insert a paragraph
1109  SwNodeIndex aTableIdx( *pTableNode, -1 );
1110  SwPosition aBefore(aTableIdx);
1112  {
1113  SwPaM aTmp(aBefore);
1114  aCpyPam = aTmp;
1115  }
1117  }
1118 
1120  aCpyPam.SetMark();
1121  *aCpyPam.GetMark() = *GetCursor()->GetPoint();
1122 
1123  CurrShell aCurr( this );
1124 
1125  StartAllAction();
1127  SetSelection(aCpyPam);
1128  // copy the text of the selection
1129  SwEditShell::Copy(rToFill);
1130 
1131  if(pTableNode)
1132  {
1133  //remove the inserted paragraph
1134  Undo();
1135  //remove the paragraph in the second doc, too
1136  SwNodeIndex aIdx( rToFill.GetDoc()->GetNodes().GetEndOfExtras(), 2 );
1137  SwPaM aPara( aIdx ); //DocStart
1138  rToFill.GetDoc()->getIDocumentContentOperations().DelFullPara(aPara);
1139  }
1140  // now the page bound objects
1141  // additionally copy page bound frames
1142  if( !GetDoc()->GetSpzFrameFormats()->empty() )
1143  {
1144  // create a draw view if necessary
1145  if( !rToFill.Imp()->GetDrawView() )
1146  rToFill.MakeDrawView();
1147 
1148  for ( auto pCpyFormat : *GetDoc()->GetSpzFrameFormats() )
1149  {
1150  SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() );
1151  if ((RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) &&
1152  aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage)
1153  {
1154  aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1);
1155  }
1156  else
1157  continue;
1158  rToFill.GetDoc()->getIDocumentLayoutAccess().CopyLayoutFormat( *pCpyFormat, aAnchor, true, true );
1159  }
1160  }
1164  EndAllAction();
1165 }
1166 
1168 
1170 {
1171  OSL_ENSURE( Imp()->HasDrawView(), "GetDrawObjGraphic without DrawView?" );
1172  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1173  bool bConvert = true;
1174  if( rMrkList.GetMarkCount() )
1175  {
1176  if( rMrkList.GetMarkCount() == 1 &&
1177  dynamic_cast< const SwVirtFlyDrawObj* >(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) != nullptr )
1178  {
1179  // select frame
1180  if( CNT_GRF == GetCntType() )
1181  {
1182  const Graphic* pGrf( GetGraphic() );
1183  if ( pGrf )
1184  {
1185  Graphic aGrf( *pGrf );
1186  if( SotClipboardFormatId::GDIMETAFILE == nFormat )
1187  {
1188  if( GraphicType::Bitmap != aGrf.GetType() )
1189  {
1190  rGrf = aGrf;
1191  bConvert = false;
1192  }
1193  else if( GetWin() )
1194  {
1195  Size aSz;
1196  Point aPt;
1197  GetGrfSize( aSz );
1198 
1200  pVirtDev->EnableOutput( false );
1201 
1202  MapMode aTmp( GetWin()->GetMapMode() );
1203  aTmp.SetOrigin( aPt );
1204  pVirtDev->SetMapMode( aTmp );
1205 
1206  GDIMetaFile aMtf;
1207  aMtf.Record( pVirtDev.get() );
1208  aGrf.Draw( pVirtDev, aPt, aSz );
1209  aMtf.Stop();
1210  aMtf.SetPrefMapMode( aTmp );
1211  aMtf.SetPrefSize( aSz );
1212  rGrf = aMtf;
1213  }
1214  }
1215  else if( GraphicType::Bitmap == aGrf.GetType() )
1216  {
1217  rGrf = aGrf;
1218  bConvert = false;
1219  }
1220  else
1221  {
1222  // Not the original size, but the current one.
1223  // Otherwise it could happen that for vector graphics
1224  // many MB's of memory are allocated.
1225  const Size aSz( GetSelectedFlyFrame()->getFramePrintArea().SSize() );
1227 
1228  MapMode aTmp( MapUnit::MapTwip );
1229  pVirtDev->SetMapMode( aTmp );
1230  if( pVirtDev->SetOutputSize( aSz ) )
1231  {
1232  aGrf.Draw( pVirtDev.get(), Point(), aSz );
1233  rGrf = pVirtDev->GetBitmapEx( Point(), aSz );
1234  }
1235  else
1236  {
1237  rGrf = aGrf;
1238  bConvert = false;
1239  }
1240  }
1241  }
1242  }
1243  }
1244  else if( SotClipboardFormatId::GDIMETAFILE == nFormat )
1245  rGrf = Imp()->GetDrawView()->GetMarkedObjMetaFile();
1246  else if( SotClipboardFormatId::BITMAP == nFormat || SotClipboardFormatId::PNG == nFormat )
1247  rGrf = Imp()->GetDrawView()->GetMarkedObjBitmapEx();
1248  }
1249  return bConvert;
1250 }
1251 
1252 // #i50824#
1253 // replace method <lcl_RemoveOleObjsFromSdrModel> by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1255 {
1256  for ( sal_uInt16 nPgNum = 0; nPgNum < _rModel.GetPageCount(); ++nPgNum )
1257  {
1258  // setup object iterator in order to iterate through all objects
1259  // including objects in group objects, but exclusive group objects.
1260  SdrObjListIter aIter(_rModel.GetPage(nPgNum));
1261  while( aIter.IsMore() )
1262  {
1263  SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( aIter.Next() );
1264  if( pOle2Obj )
1265  {
1266  // found an ole2 shape
1267  SdrObjList* pObjList = pOle2Obj->getParentSdrObjListFromSdrObject();
1268 
1269  // get its graphic
1270  Graphic aGraphic;
1271  pOle2Obj->Connect();
1272  const Graphic* pGraphic = pOle2Obj->GetGraphic();
1273  if( pGraphic )
1274  aGraphic = *pGraphic;
1275  pOle2Obj->Disconnect();
1276 
1277  // create new graphic shape with the ole graphic and shape size
1278  SdrGrafObj* pGraphicObj = new SdrGrafObj(
1279  _rModel,
1280  aGraphic,
1281  pOle2Obj->GetCurrentBoundRect());
1282  // apply layer of ole2 shape at graphic shape
1283  pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
1284 
1285  // replace ole2 shape with the new graphic object and delete the ol2 shape
1286  SdrObject* pRemovedObject = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
1287  SdrObject::Free( pRemovedObject );
1288  }
1289  }
1290  }
1291 }
1292 
1293 void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
1294 {
1295  CurrShell aCurr( this );
1296  StartAllAction();
1297  StartUndo();
1298 
1299  std::unique_ptr< FmFormModel > pModel(
1300  new FmFormModel(
1301  nullptr,
1302  GetDoc()->GetDocShell()));
1303 
1304  pModel->GetItemPool().FreezeIdRanges();
1305 
1306  rStrm.Seek(0);
1307 
1308  uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rStrm ) );
1309  SvxDrawingLayerImport( pModel.get(), xInputStream );
1310 
1311  if ( !Imp()->HasDrawView() )
1312  Imp()->MakeDrawView();
1313 
1314  Point aPos( pPt ? *pPt : GetCharRect().Pos() );
1315  SdrView *pView = Imp()->GetDrawView();
1316 
1317  // drop on the existing object: replace object or apply new attributes
1318  if( pModel->GetPageCount() > 0 &&
1319  1 == pModel->GetPage(0)->GetObjCount() &&
1320  1 == pView->GetMarkedObjectList().GetMarkCount() )
1321  {
1322  // replace a marked 'virtual' drawing object
1323  // by its corresponding 'master' drawing object in the mark list.
1325 
1326  SdrObject* pClpObj = pModel->GetPage(0)->GetObj(0);
1327  SdrObject* pOldObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1328 
1329  if( SwPasteSdr::SetAttr == nAction && dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1330  nAction = SwPasteSdr::Replace;
1331 
1332  switch( nAction )
1333  {
1334  case SwPasteSdr::Replace:
1335  {
1336  const SwFrameFormat* pFormat(nullptr);
1337  const SwFrame* pAnchor(nullptr);
1338  if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1339  {
1340  pFormat = FindFrameFormat( pOldObj );
1341 
1342  Point aNullPt;
1343  SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrameFormat*>(pFormat)->GetFrame( &aNullPt );
1344  pAnchor = pFlyFrame ? pFlyFrame->GetAnchorFrame() : nullptr;
1345 
1346  if (!pAnchor || pAnchor->FindFooterOrHeader())
1347  {
1348  // if there is a textframe in the header/footer:
1349  // do not replace but insert
1350  nAction = SwPasteSdr::Insert;
1351  break;
1352  }
1353  }
1354 
1355  SdrObject* pNewObj(pClpObj->CloneSdrObject(pOldObj->getSdrModelFromSdrObject()));
1356  tools::Rectangle aOldObjRect( pOldObj->GetCurrentBoundRect() );
1357  Size aOldObjSize( aOldObjRect.GetSize() );
1358  tools::Rectangle aNewRect( pNewObj->GetCurrentBoundRect() );
1359  Size aNewSize( aNewRect.GetSize() );
1360 
1361  Fraction aScaleWidth( aOldObjSize.Width(), aNewSize.Width() );
1362  Fraction aScaleHeight( aOldObjSize.Height(), aNewSize.Height());
1363  pNewObj->NbcResize( aNewRect.TopLeft(), aScaleWidth, aScaleHeight);
1364 
1365  Point aVec = aOldObjRect.TopLeft() - aNewRect.TopLeft();
1366  pNewObj->NbcMove(Size(aVec.getX(), aVec.getY()));
1367 
1368  if( dynamic_cast<const SdrUnoObj*>( pNewObj) != nullptr )
1369  pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
1370  else if( dynamic_cast<const SdrUnoObj*>( pOldObj) != nullptr )
1371  pNewObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
1372  else
1373  pNewObj->SetLayer( pOldObj->GetLayer() );
1374 
1375  if( dynamic_cast<const SwVirtFlyDrawObj*>( pOldObj) != nullptr )
1376  {
1377  // store attributes, then set SdrObject
1378  SfxItemSet aFrameSet( mxDoc->GetAttrPool(),
1380  aFrameSet.Set( pFormat->GetAttrSet() );
1381 
1382  Point aNullPt;
1383  if( pAnchor->IsTextFrame() && static_cast<const SwTextFrame*>(pAnchor)->IsFollow() )
1384  {
1385  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnchor);
1386  do {
1387  pTmp = pTmp->FindMaster();
1388  OSL_ENSURE( pTmp, "Where's my Master?" );
1389  } while( pTmp->IsFollow() );
1390  pAnchor = pTmp;
1391  }
1392  if( auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pOldObj))
1393  aNullPt = pCaptionObj->GetTailPos();
1394  else
1395  aNullPt = aOldObjRect.TopLeft();
1396 
1397  Point aNewAnchor = pAnchor->GetFrameAnchorPos( ::HasWrap( pOldObj ) );
1398  // OD 2004-04-05 #i26791# - direct positioning of Writer
1399  // fly frame object for <SwDoc::Insert(..)>
1400  pNewObj->NbcSetRelativePos( aNullPt - aNewAnchor );
1401  pNewObj->NbcSetAnchorPos( aNewAnchor );
1402 
1403  pOldObj->GetOrdNum();
1404 
1405  DelSelectedObj();
1406 
1407  GetDoc()->getIDocumentContentOperations().InsertDrawObj( *GetCursor(), *pNewObj, aFrameSet );
1408  }
1409  else
1410  {
1411  // #i123922# for handling MasterObject and virtual ones correctly, SW
1412  // wants us to call ReplaceObject at the page, but that also
1413  // triggers the same assertion (I tried it), so stay at the view method
1414  pView->ReplaceObjectAtView(pOldObj, *Imp()->GetPageView(), pNewObj);
1415  }
1416  }
1417  break;
1418 
1419  case SwPasteSdr::SetAttr:
1420  {
1421  SfxItemSet aSet( GetAttrPool() );
1422  const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pClpObj);
1423 
1424  if(pSdrGrafObj)
1425  {
1426  SdrObject* pTarget = nullptr;
1427 
1428  if(0 != pView->GetMarkedObjectList().GetMarkCount())
1429  {
1430  // try to get target (if it's at least one, take first)
1431  SdrMark* pMark = pView->GetMarkedObjectList().GetMark(0);
1432 
1433  if(pMark)
1434  {
1435  pTarget = pMark->GetMarkedSdrObj();
1436  }
1437  }
1438 
1439  if(pTarget)
1440  {
1441  // copy ItemSet from target
1442  aSet.Set(pTarget->GetMergedItemSet());
1443  }
1444 
1445  // for SdrGrafObj, use the graphic as fill style argument
1446  const Graphic& rGraphic = pSdrGrafObj->GetGraphic();
1447 
1448  if(GraphicType::NONE != rGraphic.GetType() && GraphicType::Default != rGraphic.GetType())
1449  {
1450  aSet.Put(XFillBitmapItem(OUString(), rGraphic));
1451  aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
1452  }
1453  }
1454  else
1455  {
1456  aSet.Put(pClpObj->GetMergedItemSet());
1457  }
1458 
1459  pView->SetAttributes( aSet );
1460  }
1461  break;
1462 
1463  default:
1464  nAction = SwPasteSdr::Insert;
1465  break;
1466  }
1467  }
1468  else
1469  nAction = SwPasteSdr::Insert;
1470 
1471  if( SwPasteSdr::Insert == nAction )
1472  {
1473  ::sw::DrawUndoGuard drawUndoGuard(GetDoc()->GetIDocumentUndoRedo());
1474 
1475  bool bDesignMode = pView->IsDesignMode();
1476  if( !bDesignMode )
1477  pView->SetDesignMode();
1478 
1479  // #i50824#
1480  // method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
1482  pView->Paste(*pModel, aPos, nullptr, SdrInsertFlags::NONE);
1483 
1484  const size_t nCnt = pView->GetMarkedObjectList().GetMarkCount();
1485  if( nCnt )
1486  {
1487  const Point aNull( 0, 0 );
1488  for( size_t i=0; i < nCnt; ++i )
1489  {
1490  SdrObject *pObj = pView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
1491  pObj->ImpSetAnchorPos( aNull );
1492  }
1493 
1494  pView->SetCurrentObj( OBJ_GRUP );
1495  if ( nCnt > 1 )
1496  pView->GroupMarked();
1497  SdrObject *pObj = pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1498  if( dynamic_cast<const SdrUnoObj*>( pObj) != nullptr )
1499  {
1500  pObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetControlsId() );
1501  bDesignMode = true;
1502  }
1503  else
1504  pObj->SetLayer( GetDoc()->getIDocumentDrawModelAccess().GetHeavenId() );
1505  const tools::Rectangle &rSnap = pObj->GetSnapRect();
1506  const Size aDiff( rSnap.GetWidth()/2, rSnap.GetHeight()/2 );
1507  pView->MoveMarkedObj( aDiff );
1508  ImpEndCreate();
1509  if( !bDesignMode )
1510  pView->SetDesignMode( false );
1511  }
1512  }
1513  EndUndo();
1514  EndAllAction();
1515 }
1516 
1517 bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
1518 {
1519  CurrShell aCurr( this );
1520  SdrObject* pObj = nullptr;
1521  SdrView *pView = Imp()->GetDrawView();
1522 
1523  bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount();
1524  if (bRet)
1525  {
1526  pObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
1527  bRet = pObj->IsClosedObj() && dynamic_cast<const SdrOle2Obj*>( pObj) == nullptr;
1528  }
1529 
1530  if( bRet && pObj )
1531  {
1532  // #i123922# added code to handle the two cases of SdrGrafObj and a fillable, non-
1533  // OLE object in focus
1534  SdrObject* pResult = pObj;
1535 
1536  if(dynamic_cast< SdrGrafObj* >(pObj))
1537  {
1538  SdrGrafObj* pNewGrafObj(static_cast<SdrGrafObj*>(pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject())));
1539 
1540  pNewGrafObj->SetGraphic(rGrf);
1541 
1542  // #i123922# for handling MasterObject and virtual ones correctly, SW
1543  // wants us to call ReplaceObject at the page, but that also
1544  // triggers the same assertion (I tried it), so stay at the view method
1545  pView->ReplaceObjectAtView(pObj, *pView->GetSdrPageView(), pNewGrafObj);
1546 
1547  OUString aReferer;
1548  SwDocShell *pDocShell = GetDoc()->GetDocShell();
1549  if (pDocShell->HasName()) {
1550  aReferer = pDocShell->GetMedium()->GetName();
1551  }
1552 
1553  // set in all cases - the Clone() will have copied an existing link (!)
1554  pNewGrafObj->SetGraphicLink(rURL, aReferer, OUString());
1555 
1556  pResult = pNewGrafObj;
1557  }
1558  else
1559  {
1560  pView->AddUndo(std::make_unique<SdrUndoAttrObj>(*pObj));
1561 
1563 
1564  aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
1565  aSet.Put(XFillBitmapItem(OUString(), rGrf));
1566  pObj->SetMergedItemSetAndBroadcast(aSet);
1567  }
1568 
1569  // we are done; mark the modified/new object
1570  pView->MarkObj(pResult, pView->GetSdrPageView());
1571  }
1572 
1573  return bRet;
1574 }
1575 
1576 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Point TopLeft() const
bool IsTableComplex() const
Definition: swtable.cxx:1454
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:690
Starts a section of nodes in the document model.
Definition: node.hxx:311
bool GotoPage(sal_uInt16 nPage)
Definition: crsrsh.cxx:1186
bool Paste(SwDoc &rClpDoc, bool bNestedTable=false)
Definition: fecopy.cxx:671
Base class of the Writer layout elements.
Definition: frame.hxx:297
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:151
bool AppendTextNode()
Definition: editsh.cxx:204
void Disconnect()
sal_uLong GetIndex() const
Definition: node.hxx:290
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
bool IsFollow() const
Definition: flowfrm.hxx:166
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2852
size_t GetMarkCount() const
Marks a position in the document model.
Definition: pam.hxx:35
bool IsClosedObj() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
SdrView * GetDrawView()
Definition: vnew.cxx:375
const SwPageFrame * GetPageAtPos(const Point &rPt, const Size *pSize=nullptr, bool bExtend=false) const
Point rPt: The point that should be used to find the page Size pSize: If given, we return the (first)...
Definition: findfrm.cxx:572
void SetDesignMode(bool bOn=true)
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:189
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1353
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:658
bool UpdateParRsid(SwTextNode *pTextNode, sal_uInt32 nVal=0)
Definition: docfmt.cxx:434
void SaveTableBoxContent(const SwPosition *pPos=nullptr)
Definition: trvltbl.cxx:869
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:1083
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
static bool lcl_SetAnchor(const SwPosition &rPos, const SwNode &rNd, SwFlyFrame const *pFly, const Point &rInsPt, SwFEShell const &rDestShell, SwFormatAnchor &rAnchor, Point &rNewPos, bool bCheckFlyRecur)
Definition: fecopy.cxx:239
SwNodeIndex nNode
Definition: pam.hxx: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:104
sal_uInt16 char char * pDesc
const OUString & GetName() const
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:1192
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Definition: doc.hxx:184
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:1167
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:964
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
tools::Long GetWidth() const
SwNode & GetNode() const
Definition: ndindex.hxx:119
SdrMark * GetMark(size_t nNum) const
void Pos(const Point &rNew)
Definition: swrect.hxx:169
bool GetGrfSize(Size &) const
Definition: editsh.cxx:278
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
bool HasShellFocus() const
Definition: crsrsh.hxx:448
static void Free(SdrObject *&_rpObject)
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:275
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
SwLayoutFrame * GetThisFrame(const SwLayoutFrame *pFrame)
Definition: trvlfrm.cxx:1072
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
bool HasWriterListeners() const
Definition: calbck.hxx:210
void EndAllAction()
Definition: edws.cxx:97
The root element of a Writer document layout.
Definition: rootfrm.hxx:80
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
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:739
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:1550
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:2614
virtual void UpdateExpFields(SwTextField *pField, bool bUpdateRefFields)=0
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1072
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:424
SwTableNode * GetTableNode()
Definition: node.hxx:607
void Record(OutputDevice *pOutDev)
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false) const
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
SwIndex nContent
Definition: pam.hxx:38
const SwRect & getFrameArea() const
Definition: frame.hxx:177
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const SwTextFormatColl * GetDfltTextFormatColl() const
Definition: doc.hxx:773
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:505
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: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:2608
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:632
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:611
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:2763
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:1237
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
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:1055
size_t size() const
Definition: ring.hxx:173
const SwPosition * GetPoint() const
Definition: pam.hxx:207
virtual bool CopyRange(SwPaM &rPam, SwPosition &rPos, SwCopyFlags flags) const =0
Copy a selected content range to a position.
GraphicType GetType() const
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:2236
sal_uInt16 GetPhyPageNum() const
Phy: real page count.
Definition: fews.cxx:334
void hideMarkHandles()
bool ActionPend() const
Definition: viewsh.hxx:196
bool CopySelToDoc(SwDoc &rInsDoc)
For copying via ClipBoard: If table is copied into table, move all cursors away from it...
Definition: edglss.cxx:154
SwContentNode * GetContentNode()
Definition: node.hxx:623
const SdrMarkList & GetMarkedObjectList() const
FlyAnchors.
Definition: fmtanchr.hxx:34
void SetOrigin(const Point &rOrigin)
const SwPageDesc & GetPageDesc(size_t i) const
Definition: fedesc.cxx:125
DECL_LISTENERMULTIPLEXER_END void SAL_CALL inserted(::sal_Int32 ID) override
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
SvLinkSource * pOwner
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
Marks a character position inside a document model node.
Definition: index.hxx:33
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3497
SdrModel & getSdrModelFromSdrObject() const
sal_uInt32 GetOrdNum() const
static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SdrModel &_rModel)
Definition: fecopy.cxx:1254
bool IsNoTextNode() const
Definition: node.hxx:656
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:1962
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:405
SwContentFrame * GetFirstSub(const SwLayoutFrame *pLayout)
Definition: trvlfrm.cxx:1050
const SwPosition * Start() const
Definition: pam.hxx:212
virtual SdrLayerID GetLayer() const
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
SAL_DLLPRIVATE bool ImpEndCreate()
Definition: feshview.cxx:1758
SwPaM * GetPrev()
Definition: pam.hxx:268
bool Delete()
Delete content of all ranges.
Definition: eddel.cxx:125
sal_uInt16 const aFrameFormatSetRange[]
Definition: init.cxx:233
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:460
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:2620
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:685
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
virtual SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet)=0
Insert a DrawObject.
void MakeDrawView()
Definition: vnew.cxx:365
static void ReplaceMarkedDrawVirtObjs(SdrMarkView &_rMarkView)
replace marked -objects by its reference object for delete marked objects.
Definition: dview.cxx:895
virtual SdrObject * ReplaceObject(SdrObject *pNewObj, size_t nObjNum)
SwDrawView * GetDrawView()
Definition: viewimp.hxx:154
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
virtual void NbcSetSnapRect(const tools::Rectangle &rRect)
void SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent=SdrInventor::Default)
void GroupMarked()
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:681
bool GetDrawObjGraphic(SotClipboardFormatId nFormat, Graphic &rGrf) const
Get selected DrawObj as graphics (MetaFile/Bitmap).
Definition: fecopy.cxx:1169
vcl::Window * GetWin() const
Definition: viewsh.hxx:337
sal_uInt16 GetCntType() const
Determine form of content. Return Type at CurrentCursor->SPoint.
Definition: edws.cxx:126
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
virtual void NbcMove(const Size &rSiz)
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
sal_Int32 GetIndex() const
Definition: index.hxx:91
const SfxItemSet & GetMergedItemSet() const
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
SwNodes & GetNodes()
Definition: doc.hxx:403
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:85
size_t IsObjSelected() const
Definition: feshview.cxx:1149
void DelSelectedObj()
Definition: feshview.cxx:2280
static const Point & lcl_FindBasePos(const SwFrame *pFrame, const Point &rPt)
Definition: fecopy.cxx:223
bool HasDrawView() const
New Interface for StarView Drawing.
Definition: viewimp.hxx:153
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
const Point & GetAnchorPos() const
Format of a fly content.
Definition: fmtflcnt.hxx:32
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:196
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
SdrObject * getParentSdrObjectFromSdrObject() const
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:376
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:352
SdrPageView * GetSdrPageView() const
bool Copy(SwEditShell &rDestShell)
Copy content of all ranges at current position of cursor to given Shell.
Definition: eddel.cxx:163
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
SwPageDesc * FindPageDescByName(const OUString &rName, bool bGetFromPool=false, size_t *pPos=nullptr)
Definition: fedesc.cxx:130
tools::Long GetHeight() const
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:4285
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
const SfxItemPool & GetItemPool() const
virtual void NbcSetAnchorPos(const Point &rPnt)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
bool newDefault(const value_type &x)
Definition: docfmt.cxx:2136
SwDoc & GetDoc() const
Definition: pam.hxx:243
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:184
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:475
const SwFrame * GetAnchorFrame() const
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2258
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:367
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool IsNewModel() const
Definition: swtable.hxx:186
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2073
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:899
bool IsGroupEntered() const
void Undo(sal_uInt16 const nCount=1)
Definition: edundo.cxx:97
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1284
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:137
bool IsFrameSelected() const
Definition: feshview.cxx:1157
no RedlineFlags
sal_uInt16 GetPageCount() const
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1315
SdrPageView * GetPageView()
Definition: viewimp.hxx:156
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:844
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:1516
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