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