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