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