LibreOffice Module sw (master)  1
feshview.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 <hintids.hxx>
21 #include <svx/strings.hrc>
22 #include <svx/sdrobjectfilter.hxx>
23 #include <svx/svddrgmt.hxx>
24 #include <svx/svditer.hxx>
25 #include <svx/svdobj.hxx>
26 #include <svx/svdouno.hxx>
27 #include <svx/svdogrp.hxx>
28 #include <svx/svdocirc.hxx>
29 #include <svx/svdopath.hxx>
30 #include <svx/sxciaitm.hxx>
31 #include <svx/svdocapt.hxx>
32 #include <svx/xlnwtit.hxx>
33 #include <svx/xlnstwit.hxx>
34 #include <svx/xlnedwit.hxx>
35 #include <svx/xlnedit.hxx>
36 #include <svx/xlnstit.hxx>
37 #include <svx/svdomeas.hxx>
38 #include <svx/sdtagitm.hxx>
39 #include <svx/sdtacitm.hxx>
40 #include <svx/sdtaaitm.hxx>
41 #include <editeng/opaqitem.hxx>
42 #include <editeng/protitem.hxx>
43 #include <svx/svdpage.hxx>
44 #include <svx/svdpagv.hxx>
45 #include <svx/dialmgr.hxx>
46 #include <tools/globname.hxx>
47 #include <sot/exchange.hxx>
51 #include <IDocumentState.hxx>
53 #include <drawdoc.hxx>
54 #include <textboxhelper.hxx>
55 #include <frmfmt.hxx>
56 #include <frmatr.hxx>
57 #include <frmtool.hxx>
58 #include <fmtfsize.hxx>
59 #include <fmtanchr.hxx>
60 #include <fmtornt.hxx>
61 #include <fmtsrnd.hxx>
62 #include <fmtcntnt.hxx>
63 #include <fmtflcnt.hxx>
64 #include <fmtcnct.hxx>
65 #include <swmodule.hxx>
66 #include <fesh.hxx>
67 #include <rootfrm.hxx>
68 #include <pagefrm.hxx>
69 #include <sectfrm.hxx>
70 #include <doc.hxx>
71 #include <IDocumentUndoRedo.hxx>
72 #include <dview.hxx>
73 #include <dflyobj.hxx>
74 #include <dcontact.hxx>
75 #include <viewimp.hxx>
76 #include <flyfrm.hxx>
77 #include <pam.hxx>
78 #include <ndole.hxx>
79 #include <ndgrf.hxx>
80 #include <ndtxt.hxx>
81 #include <viewopt.hxx>
82 #include <swundo.hxx>
83 #include <notxtfrm.hxx>
84 #include <txtfrm.hxx>
85 #include <mdiexp.hxx>
86 #include <sortedobjs.hxx>
87 #include <HandleAnchorNodeChg.hxx>
89 #include <comphelper/lok.hxx>
90 #include <sfx2/lokhelper.hxx>
91 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
92 #include <calbck.hxx>
94 #include <svx/svxids.hrc>
95 #include <osl/diagnose.h>
96 
97 #include <com/sun/star/embed/EmbedMisc.hpp>
98 #include <com/sun/star/embed/Aspects.hpp>
99 #include <com/sun/star/embed/XEmbeddedObject.hpp>
100 
101 #include <svx/srchdlg.hxx>
102 
103 #define SCROLLVAL 75
104 
105 using namespace com::sun::star;
106 
111 namespace {
112 
113 ::basegfx::B2DPolyPolygon getPolygon(TranslateId pResId, const SdrModel& rModel)
114 {
116  XLineEndListRef pLineEndList(rModel.GetLineEndList());
117 
118  if( pLineEndList.is() )
119  {
120  OUString aArrowName( SvxResId(pResId) );
121  tools::Long nCount = pLineEndList->Count();
123  for( nIndex = 0; nIndex < nCount; nIndex++ )
124  {
125  const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nIndex);
126  if( pEntry->GetName() == aArrowName )
127  {
128  aRetval = pEntry->GetLineEnd();
129  break;
130  }
131  }
132  }
133 
134  return aRetval;
135 }
136 
137 }
138 
140 {
141  if ( !pLst )
142  pLst = pSh->HasDrawView() ? &pSh->Imp()->GetDrawView()->GetMarkedObjectList():nullptr;
143 
144  if ( pLst && pLst->GetMarkCount() == 1 )
145  {
146  SdrObject *pO = pLst->GetMark( 0 )->GetMarkedSdrObj();
147  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pO))
148  return pVirtO->GetFlyFrame();
149  }
150  return nullptr;
151 }
152 
153 static void lcl_GrabCursor( SwFEShell* pSh, SwFlyFrame* pOldSelFly)
154 {
155  const SwFrameFormat *pFlyFormat = pSh->SelFlyGrabCursor();
156  if( pFlyFormat && !pSh->ActionPend() &&
157  (!pOldSelFly || pOldSelFly->GetFormat() != pFlyFormat) )
158  {
159  // now call set macro if applicable
160  pSh->GetFlyMacroLnk().Call( static_cast<const SwFlyFrameFormat*>(pFlyFormat) );
161  // if a dialog was started inside a macro, then
162  // MouseButtonUp arrives at macro and not to us. Therefore
163  // flag is always set here and will never be switched to
164  // respective Shell !!!!!!!
165 
166  g_bNoInterrupt = false;
167  }
168  else if( !pFlyFormat || RES_DRAWFRMFMT == pFlyFormat->Which() )
169  {
170  // --> assure consistent cursor
171  pSh->KillPams();
172  pSh->ClearMark();
173  pSh->SetCursor( pSh->Imp()->GetDrawView()->GetAllMarkedRect().TopLeft(), true);
174  }
175 }
176 
177 bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj )
178 {
179  SwDrawView *pDView = Imp()->GetDrawView();
180  if(!pDView)
181  return false;
182  CurrShell aCurr( this );
183  StartAction(); // action is necessary to assure only one AttrChgdNotify
184  // (e.g. due to Unmark->MarkListHasChgd) arrives
185 
186  const SdrMarkList &rMrkList = pDView->GetMarkedObjectList();
187  const bool bHadSelection = rMrkList.GetMarkCount();
188  const bool bAddSelect = 0 != (SW_ADD_SELECT & nFlag);
189  const bool bEnterGroup = 0 != (SW_ENTER_GROUP & nFlag);
190  SwFlyFrame* pOldSelFly = nullptr;
191  const Point aOldPos( pDView->GetAllMarkedRect().TopLeft() );
192 
193  if( bHadSelection )
194  {
195  // call Unmark when !bAddSelect or if fly was selected
196  bool bUnmark = !bAddSelect;
197 
198  if ( rMrkList.GetMarkCount() == 1 )
199  {
200  // if fly was selected, deselect it first
201  pOldSelFly = ::GetFlyFromMarked( &rMrkList, this );
202  if ( pOldSelFly )
203  {
204  const sal_uInt16 nType = GetCntType();
205  if( nType != CNT_TXT || (SW_LEAVE_FRAME & nFlag) ||
206  ( pOldSelFly->GetFormat()->GetProtect().IsContentProtected()
207  && !IsReadOnlyAvailable() ))
208  {
209  // If a fly is deselected, which contains graphic, OLE or
210  // otherwise, the cursor should be removed from it.
211  // Similar if a fly with protected content is deselected.
212  // For simplicity we put the cursor next to the upper-left
213  // corner.
214  Point aPt( pOldSelFly->getFrameArea().Pos() );
215  aPt.setX(aPt.getX() - 1);
216  bool bUnLockView = !IsViewLocked();
217  LockView( true );
218  SetCursor( aPt, true );
219  if( bUnLockView )
220  LockView( false );
221  }
222  if ( nType & CNT_GRF &&
223  static_cast<SwNoTextFrame*>(pOldSelFly->Lower())->HasAnimation() )
224  {
225  GetWin()->Invalidate( pOldSelFly->getFrameArea().SVRect() );
226  }
227 
228  // Cancel crop mode
229  if ( SdrDragMode::Crop == GetDragMode() )
230  SetDragMode( SdrDragMode::Move );
231 
232  bUnmark = true;
233  }
234  }
235  if ( bUnmark )
236  {
237  pDView->UnmarkAll();
238  if (pOldSelFly)
239  pOldSelFly->SelectionHasChanged(this);
240  }
241  }
242  else
243  {
244  KillPams();
245  ClearMark();
246  }
247 
248  if ( pObj )
249  {
250  OSL_ENSURE( !bEnterGroup, "SW_ENTER_GROUP is not supported" );
251  pDView->MarkObj( pObj, Imp()->GetPageView() );
252  }
253  else
254  {
255  // tolerance limit of Drawing-SS
256  const auto nHdlSizePixel = Imp()->GetDrawView()->GetMarkHdlSizePixel();
257  const short nMinMove = static_cast<short>(GetOut()->PixelToLogic(Size(nHdlSizePixel/2, 0)).Width());
258  pDView->MarkObj( rPt, nMinMove, bAddSelect, bEnterGroup );
259  }
260 
261  const bool bRet = 0 != rMrkList.GetMarkCount();
262 
263  if ( rMrkList.GetMarkCount() > 1 )
264  {
265  // It sucks if Drawing objects were selected and now
266  // additionally a fly is selected.
267  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
268  {
269  SdrObject *pTmpObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
270  bool bForget = dynamic_cast<const SwVirtFlyDrawObj*>( pTmpObj) != nullptr;
271  if( bForget )
272  {
273  pDView->UnmarkAll();
274  pDView->MarkObj( pTmpObj, Imp()->GetPageView(), bAddSelect, bEnterGroup );
275  break;
276  }
277  }
278  }
279 
280  if ( rMrkList.GetMarkCount() == 1 )
281  {
282  SwFlyFrame *pSelFly = ::GetFlyFromMarked( &rMrkList, this );
283  if (pSelFly)
284  pSelFly->SelectionHasChanged(this);
285  }
286 
287  if (!(nFlag & SW_ALLOW_TEXTBOX))
288  {
289  // If the fly frame is a textbox of a shape, then select the shape instead.
290  for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i)
291  {
292  SdrObject* pObject = rMrkList.GetMark(i)->GetMarkedSdrObj();
293  SwContact* pContact = GetUserCall(pObject);
294  if (!pContact)
295  {
296  continue;
297  }
298 
299  SwFrameFormat* pFormat = pContact->GetFormat();
301  {
302  SdrObject* pShape = pShapeFormat->FindSdrObject();
303  pDView->UnmarkAll();
304  pDView->MarkObj(pShape, Imp()->GetPageView(), bAddSelect, bEnterGroup);
305  break;
306  }
307  }
308  }
309 
310  if ( bRet )
311  {
312  ::lcl_GrabCursor(this, pOldSelFly);
313  if ( GetCntType() & CNT_GRF )
314  {
315  const SwFlyFrame *pTmp = GetFlyFromMarked( &rMrkList, this );
316  OSL_ENSURE( pTmp, "Graphic without Fly" );
317  if ( static_cast<const SwNoTextFrame*>(pTmp->Lower())->HasAnimation() )
318  static_cast<const SwNoTextFrame*>(pTmp->Lower())->StopAnimation( GetOut() );
319  }
320  }
321  else if ( !pOldSelFly && bHadSelection )
322  SetCursor( aOldPos, true);
323 
324  if( bRet || !bHadSelection )
325  CallChgLnk();
326 
327  // update status line
328  ::FrameNotify( this, bRet ? FLY_DRAG_START : FLY_DRAG_END );
329 
330  EndAction();
331  return bRet;
332 }
333 
334 /*
335  * Description: MoveAnchor( nDir ) looked for an another Anchor for
336  * the selected drawing object (or fly frame) in the given direction.
337  * An object "as character" doesn't moves anyway.
338  * A page bounded object could move to the previous/next page with up/down,
339  * an object bounded "at paragraph" moves to the previous/next paragraph, too.
340  * An object bounded "at character" moves to the previous/next paragraph
341  * with up/down and to the previous/next character with left/right.
342  * If the anchor for at paragraph/character bounded objects has vertical or
343  * right_to_left text direction, the directions for up/down/left/right will
344  * interpreted accordingly.
345  * An object bounded "at fly" takes the center of the actual anchor and looks
346  * for the nearest fly frame in the given direction.
347  */
348 
349 static bool LessX( Point const & aPt1, Point const & aPt2, bool bOld )
350 {
351  return aPt1.getX() < aPt2.getX()
352  || ( aPt1.getX() == aPt2.getX()
353  && ( aPt1.getY() < aPt2.getY()
354  || ( aPt1.getY() == aPt2.getY() && bOld ) ) );
355 }
356 static bool LessY( Point const & aPt1, Point const & aPt2, bool bOld )
357 {
358  return aPt1.getY() < aPt2.getY()
359  || ( aPt1.getY() == aPt2.getY()
360  && ( aPt1.getX() < aPt2.getX()
361  || ( aPt1.getX() == aPt2.getX() && bOld ) ) );
362 }
363 
365 {
366  if (!Imp()->GetDrawView())
367  return false;
368  const SdrMarkList& pMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
369  if (1 != pMrkList.GetMarkCount())
370  return false;
371  SwFrame* pOld;
372  SwFlyFrame* pFly = nullptr;
373  SdrObject *pObj = pMrkList.GetMark( 0 )->GetMarkedSdrObj();
374  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
375  {
376  pFly = pVirtO->GetFlyFrame();
377  pOld = pFly->AnchorFrame();
378  }
379  else
380  pOld = static_cast<SwDrawContact*>(GetUserCall(pObj))->GetAnchorFrame( pObj );
381  bool bRet = false;
382  if( pOld )
383  {
384  SwFrame* pNew = pOld;
385  // #i28701#
386  SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
387  SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
388  SwFormatAnchor aAnch( rFormat.GetAnchor() );
389  RndStdIds nAnchorId = aAnch.GetAnchorId();
390  if ( RndStdIds::FLY_AS_CHAR == nAnchorId )
391  return false;
392  if( pOld->IsVertical() )
393  {
394  if( pOld->IsTextFrame() )
395  {
396  switch( nDir ) {
397  case SwMove::UP: nDir = SwMove::LEFT; break;
398  case SwMove::DOWN: nDir = SwMove::RIGHT; break;
399  case SwMove::LEFT: nDir = SwMove::DOWN; break;
400  case SwMove::RIGHT: nDir = SwMove::UP; break;
401  }
402  if( pOld->IsRightToLeft() )
403  {
404  if( nDir == SwMove::LEFT )
405  nDir = SwMove::RIGHT;
406  else if( nDir == SwMove::RIGHT )
407  nDir = SwMove::LEFT;
408  }
409  }
410  }
411  switch ( nAnchorId ) {
412  case RndStdIds::FLY_AT_PAGE:
413  {
414  OSL_ENSURE( pOld->IsPageFrame(), "Wrong anchor, page expected." );
415  if( SwMove::UP == nDir )
416  pNew = pOld->GetPrev();
417  else if( SwMove::DOWN == nDir )
418  pNew = pOld->GetNext();
419  if( pNew && pNew != pOld )
420  {
421  aAnch.SetPageNum( static_cast<SwPageFrame*>(pNew)->GetPhyPageNum() );
422  bRet = true;
423  }
424  break;
425  }
426  case RndStdIds::FLY_AT_CHAR:
427  {
428  OSL_ENSURE(pOld->IsTextFrame(), "Wrong anchor, text frame expected.");
429  if( SwMove::LEFT == nDir || SwMove::RIGHT == nDir )
430  {
431  SwPosition pos = *aAnch.GetContentAnchor();
432  SwTextFrame *const pOldFrame(static_cast<SwTextFrame*>(pOld));
433  TextFrameIndex const nAct(pOldFrame->MapModelToViewPos(pos));
434  if( SwMove::LEFT == nDir )
435  {
436  bRet = true;
437  if( nAct )
438  {
439  pos = pOldFrame->MapViewToModelPos(nAct - TextFrameIndex(1));
440  }
441  else
442  nDir = SwMove::UP;
443  }
444  else
445  {
446  TextFrameIndex const nMax(pOldFrame->GetText().getLength());
447  if( nAct < nMax )
448  {
449  bRet = true;
450  pos = pOldFrame->MapViewToModelPos(nAct + TextFrameIndex(1));
451  }
452  else
453  nDir = SwMove::DOWN;
454  }
455  if( pos != *aAnch.GetContentAnchor())
456  aAnch.SetAnchor( &pos );
457  }
458  [[fallthrough]];
459  }
460  case RndStdIds::FLY_AT_PARA:
461  {
462  OSL_ENSURE(pOld->IsTextFrame(), "Wrong anchor, text frame expected.");
463  if( SwMove::UP == nDir )
464  pNew = pOld->FindPrev();
465  else if( SwMove::DOWN == nDir )
466  pNew = pOld->FindNext();
467  if( pNew && pNew != pOld && pNew->IsContentFrame() )
468  {
469  SwTextFrame *const pNewFrame(static_cast<SwTextFrame*>(pNew));
470  SwPosition const pos = pNewFrame->MapViewToModelPos(
472  (bRet && pNewFrame->GetText().getLength() != 0)
473  ? pNewFrame->GetText().getLength() - 1
474  : 0));
475  aAnch.SetAnchor( &pos );
476  bRet = true;
477  }
478  else if( SwMove::UP == nDir || SwMove::DOWN == nDir )
479  bRet = false;
480  break;
481  }
482  case RndStdIds::FLY_AT_FLY:
483  {
484  OSL_ENSURE( pOld->IsFlyFrame(), "Wrong anchor, fly frame expected.");
485  SwPageFrame* pPage = pOld->FindPageFrame();
486  OSL_ENSURE( pPage, "Where's my page?" );
487  SwFlyFrame* pNewFly = nullptr;
488  if( pPage->GetSortedObjs() )
489  {
490  bool bOld = false;
491  Point aCenter( pOld->getFrameArea().Left() + pOld->getFrameArea().Width()/2,
492  pOld->getFrameArea().Top() + pOld->getFrameArea().Height()/2 );
493  Point aBest;
494  for(SwAnchoredObject* pAnchObj : *pPage->GetSortedObjs())
495  {
496  if( auto pTmp = pAnchObj->DynCastFlyFrame() )
497  {
498  if( pTmp == pOld )
499  bOld = true;
500  else
501  {
502  const SwFlyFrame* pCheck = pFly ? pTmp : nullptr;
503  while( pCheck )
504  {
505  if( pCheck == pFly )
506  break;
507  const SwFrame *pNxt = pCheck->GetAnchorFrame();
508  pCheck = pNxt ? pNxt->FindFlyFrame() : nullptr;
509  }
510  if( pCheck || pTmp->IsProtected() )
511  continue;
512  Point aNew( pTmp->getFrameArea().Left() +
513  pTmp->getFrameArea().Width()/2,
514  pTmp->getFrameArea().Top() +
515  pTmp->getFrameArea().Height()/2 );
516  bool bAccept = false;
517  switch( nDir ) {
518  case SwMove::RIGHT:
519  {
520  bAccept = LessX( aCenter, aNew, bOld )
521  && ( !pNewFly ||
522  LessX( aNew, aBest, false ) );
523  break;
524  }
525  case SwMove::LEFT:
526  {
527  bAccept = LessX( aNew, aCenter, !bOld )
528  && ( !pNewFly ||
529  LessX( aBest, aNew, true ) );
530  break;
531  }
532  case SwMove::UP:
533  {
534  bAccept = LessY( aNew, aCenter, !bOld )
535  && ( !pNewFly ||
536  LessY( aBest, aNew, true ) );
537  break;
538  }
539  case SwMove::DOWN:
540  {
541  bAccept = LessY( aCenter, aNew, bOld )
542  && ( !pNewFly ||
543  LessY( aNew, aBest, false ) );
544  break;
545  }
546  }
547  if( bAccept )
548  {
549  pNewFly = pTmp;
550  aBest = aNew;
551  }
552  }
553  }
554  }
555  }
556 
557  if( pNewFly )
558  {
559  SwPosition aPos( *pNewFly->GetFormat()->
560  GetContent().GetContentIdx());
561  aAnch.SetAnchor( &aPos );
562  bRet = true;
563  }
564  break;
565  }
566  default: break;
567  }
568  if( bRet )
569  {
570  StartAllAction();
571  // --> handle change of anchor node:
572  // if count of the anchor frame also change, the fly frames have to be
573  // re-created. Thus, delete all fly frames except the <this> before the
574  // anchor attribute is change and re-create them afterwards.
575  {
576  std::unique_ptr<SwHandleAnchorNodeChg> pHandleAnchorNodeChg;
577  SwFlyFrameFormat* pFlyFrameFormat( dynamic_cast<SwFlyFrameFormat*>(&rFormat) );
578  if ( pFlyFrameFormat )
579  {
580  pHandleAnchorNodeChg.reset(
581  new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch ));
582  }
583  rFormat.GetDoc()->SetAttr( aAnch, rFormat );
584  }
585  // #i28701# - no call of method
586  // <CheckCharRectAndTopOfLine()> for to-character anchored
587  // Writer fly frame needed. This method call can cause a
588  // format of the anchor frame, which is no longer intended.
589  // Instead clear the anchor character rectangle and
590  // the top of line values for all to-character anchored objects.
591  pAnchoredObj->ClearCharRectAndTopOfLine();
592  EndAllAction();
593  }
594  }
595  return bRet;
596 }
597 
599 {
600  const SdrMarkList* pMarkList = nullptr;
601  if( Imp()->GetDrawView() != nullptr )
602  pMarkList = &Imp()->GetDrawView()->GetMarkedObjectList();
603  return pMarkList;
604 }
605 
607 {
609 
610  // get marked frame list, and check if anything is selected
611  const SdrMarkList* pMarkList = GetMarkList_();
612  if( pMarkList == nullptr || pMarkList->GetMarkCount() == 0 )
613  eType = FrameTypeFlags::NONE;
614  else
615  {
616  // obtain marked item as fly frame; if no fly frame, it must
617  // be a draw object
618  const SwFlyFrame* pFly = ::GetFlyFromMarked(pMarkList, const_cast<SwFEShell*>(this));
619  if ( pFly != nullptr )
620  {
621  if( pFly->IsFlyLayFrame() )
622  eType = FrameTypeFlags::FLY_FREE;
623  else if( pFly->IsFlyAtContentFrame() )
625  else
626  {
627  OSL_ENSURE( pFly->IsFlyInContentFrame(), "New frametype?" );
629  }
630  }
631  else
632  eType = FrameTypeFlags::DRAWOBJ;
633  }
634 
635  return eType;
636 }
637 
638 // does the draw selection contain a control?
640 {
641  bool bRet = false;
642 
643  // basically, copy the mechanism from GetSelFrameType(), but call
644  // CheckControl... if you get a drawing object
645  const SdrMarkList* pMarkList = GetMarkList_();
646  if( pMarkList != nullptr && pMarkList->GetMarkCount() == 1 )
647  {
648  // if we have one marked object, get the SdrObject and check
649  // whether it contains a control
650  const SdrObject* pSdrObject = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
651  bRet = pSdrObject && ::CheckControlLayer( pSdrObject );
652  }
653  return bRet;
654 }
655 
656 void SwFEShell::ScrollTo( const Point &rPt )
657 {
658  const SwRect aRect( rPt, rPt );
659  if ( IsScrollMDI( this, aRect ) &&
660  (!Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() ||
661  Imp()->IsDragPossible( rPt )) )
662  {
663  ScrollMDI( this, aRect, SCROLLVAL, SCROLLVAL );
664  }
665 }
666 
668 {
669  if ( Imp()->HasDrawView() )
670  Imp()->GetDrawView()->SetDragMode( eDragMode );
671 }
672 
674 {
675  SdrDragMode nRet = SdrDragMode(0);
676  if ( Imp()->HasDrawView() )
677  {
678  nRet = Imp()->GetDrawView()->GetDragMode();
679  }
680  return nRet;
681 }
682 
684 {
685  if ( !Imp()->HasDrawView() )
686  {
687  return;
688  }
689  SdrView *pView = Imp()->GetDrawView();
690  if (!pView) return;
691 
692  const SdrMarkList &rMarkList = pView->GetMarkedObjectList();
693  if( 0 == rMarkList.GetMarkCount() ) {
694  // No object selected
695  return;
696  }
697 
698  // If more than a single SwVirtFlyDrawObj is selected, select only the first SwVirtFlyDrawObj
699  if ( rMarkList.GetMarkCount() > 1 )
700  {
701  for ( size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
702  {
703  SdrObject *pTmpObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
704  bool bForget = dynamic_cast<const SwVirtFlyDrawObj*>( pTmpObj) != nullptr;
705  if( bForget )
706  {
707  pView->UnmarkAll();
708  pView->MarkObj( pTmpObj, Imp()->GetPageView() );
709  break;
710  }
711  }
712  }
713 
714  // Activate CROP mode
715  pView->SetEditMode( SdrViewEditMode::Edit );
716  SetDragMode( SdrDragMode::Crop );
717 }
718 
719 void SwFEShell::BeginDrag( const Point* pPt, bool bIsShift)
720 {
721  SdrView *pView = Imp()->GetDrawView();
722  if ( pView && pView->AreObjectsMarked() )
723  {
724  m_pChainFrom.reset();
725  m_pChainTo.reset();
726  SdrHdl* pHdl = pView->PickHandle( *pPt );
727  if (pView->BegDragObj( *pPt, nullptr, pHdl ))
728  pView->GetDragMethod()->SetShiftPressed( bIsShift );
729  ::FrameNotify( this );
730  }
731 }
732 
733 void SwFEShell::Drag( const Point *pPt, bool )
734 {
735  OSL_ENSURE( Imp()->HasDrawView(), "Drag without DrawView?" );
736  if ( HasDrawViewDrag() )
737  {
738  ScrollTo( *pPt );
739  Imp()->GetDrawView()->MovDragObj( *pPt );
740  Imp()->GetDrawView()->ShowDragAnchor();
741  ::FrameNotify( this );
742  }
743 }
744 
746 {
747  OSL_ENSURE( Imp()->HasDrawView(), "EndDrag without DrawView?" );
748  SdrView *pView = Imp()->GetDrawView();
749  if ( !pView->IsDragObj() )
750  return;
751 
752  for(SwViewShell& rSh : GetRingContainer())
753  rSh.StartAction();
754 
755  StartUndo( SwUndoId::START );
756 
757  // #50778# Bug during dragging: In StartAction a HideShowXor is called.
758  // In EndDragObj() this is reversed, for no reason and even wrong.
759  // To restore consistency we should bring up the Xor again.
760 
761  // Reanimation from the hack #50778 to fix bug #97057
762  // May be not the best solution, but the one with lowest risc at the moment.
763  // pView->ShowShownXor( GetOut() );
764 
765  pView->EndDragObj();
766 
767  // DrawUndo on to flyframes are not stored
768  // The flys change the flag.
769  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
770  ChgAnchor( RndStdIds::FLY_AT_PARA, true );
771 
773 
774  for(SwViewShell& rSh : GetRingContainer())
775  {
776  rSh.EndAction();
777  if( auto pCursorShell = dynamic_cast<SwCursorShell *>(&rSh) )
778  pCursorShell->CallChgLnk();
779  }
780 
781  GetDoc()->getIDocumentState().SetModified();
782  ::FrameNotify( this );
783 }
784 
786 {
787  OSL_ENSURE( Imp()->HasDrawView(), "BreakDrag without DrawView?" );
788  if( HasDrawViewDrag() )
789  Imp()->GetDrawView()->BrkDragObj();
790  SetChainMarker();
791 }
792 
793 // If a fly is selected, pulls the crsr in the first ContentFrame
795 {
796  if ( Imp()->HasDrawView() )
797  {
798  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
799  SwFlyFrame *pFly = ::GetFlyFromMarked( &rMrkList, this );
800 
801  if( pFly )
802  {
803  SwContentFrame *pCFrame = pFly->ContainsContent();
804  if ( pCFrame )
805  {
806  // --> assure, that the cursor is consistent.
807  KillPams();
808  ClearMark();
809  SwPaM *pCursor = GetCursor();
810 
811  if (pCFrame->IsTextFrame())
812  {
813  *pCursor->GetPoint() = static_cast<SwTextFrame *>(pCFrame)
814  ->MapViewToModelPos(TextFrameIndex(0));
815  }
816  else
817  {
818  assert(pCFrame->IsNoTextFrame());
819  SwContentNode *const pCNode = static_cast<SwNoTextFrame *>(pCFrame)->GetNode();
820  pCursor->GetPoint()->nNode = *pCNode;
821  pCursor->GetPoint()->nContent.Assign( pCNode, 0 );
822  }
823 
824  SwRect& rChrRect = const_cast<SwRect&>(GetCharRect());
825  rChrRect = pFly->getFramePrintArea();
826  rChrRect.Pos() += pFly->getFrameArea().Pos();
827  GetCursorDocPos() = rChrRect.Pos();
828  }
829  return pFly->GetFormat();
830  }
831  }
832  return nullptr;
833 }
834 
835 // Selection to above/below (Z-Order)
836 static void lcl_NotifyNeighbours( const SdrMarkList *pLst )
837 {
838  // Rules for evasion have changed.
839  // 1. The environment of the fly and everything inside should be notified
840  // 2. The content of the frame itself has to be notified
841  // 3. Frames displaced by the frame have to be notified
842  // 4. Also Drawing objects can displace frames
843  for( size_t j = 0; j < pLst->GetMarkCount(); ++j )
844  {
845  SwPageFrame *pPage;
846  bool bCheckNeighbours = false;
847  sal_Int16 aHori = text::HoriOrientation::NONE;
848  SwRect aRect;
849  SdrObject *pO = pLst->GetMark( j )->GetMarkedSdrObj();
850  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pO))
851  {
852  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
853 
854  const SwFormatHoriOrient &rHori = pFly->GetFormat()->GetHoriOrient();
855  aHori = rHori.GetHoriOrient();
856  if( text::HoriOrientation::NONE != aHori && text::HoriOrientation::CENTER != aHori &&
857  pFly->IsFlyAtContentFrame() )
858  {
859  bCheckNeighbours = true;
860  pFly->InvalidatePos();
862  aFrm.Pos().AdjustY(1 );
863  }
864 
865  pPage = pFly->FindPageFrame();
866  aRect = pFly->getFrameArea();
867  }
868  else
869  {
870  SwFrame* pAnch = static_cast<SwDrawContact*>( GetUserCall(pO) )->GetAnchorFrame( pO );
871  if( !pAnch )
872  continue;
873  pPage = pAnch->FindPageFrame();
874  // #i68520# - naming changed
875  aRect = GetBoundRectOfAnchoredObj( pO );
876  }
877 
878  const size_t nCount = pPage->GetSortedObjs() ? pPage->GetSortedObjs()->size() : 0;
879  for ( size_t i = 0; i < nCount; ++i )
880  {
881  SwAnchoredObject* pAnchoredObj = (*pPage->GetSortedObjs())[i];
882  SwFlyFrame* pAct = pAnchoredObj->DynCastFlyFrame();
883  if ( !pAct )
884  continue;
885 
886  SwRect aTmpCalcPnt( pAct->getFramePrintArea() );
887  aTmpCalcPnt += pAct->getFrameArea().Pos();
888  if ( aRect.Overlaps( aTmpCalcPnt ) )
889  {
890  SwContentFrame *pCnt = pAct->ContainsContent();
891  while ( pCnt )
892  {
893  aTmpCalcPnt = pCnt->getFramePrintArea();
894  aTmpCalcPnt += pCnt->getFrameArea().Pos();
895  if ( aRect.Overlaps( aTmpCalcPnt ) )
896  static_cast<SwFrame*>(pCnt)->Prepare( PrepareHint::FlyFrameAttributesChanged );
897  pCnt = pCnt->GetNextContentFrame();
898  }
899  }
900  if ( bCheckNeighbours && pAct->IsFlyAtContentFrame() )
901  {
902  const SwFormatHoriOrient &rH = pAct->GetFormat()->GetHoriOrient();
903  if ( rH.GetHoriOrient() == aHori &&
904  pAct->getFrameArea().Top() <= aRect.Bottom() &&
905  pAct->getFrameArea().Bottom() >= aRect.Top() )
906  {
907  pAct->InvalidatePos();
909  aFrm.Pos().AdjustY(1 );
910  }
911  }
912  }
913  }
914 }
915 
916 void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj, sal_uInt16 nSlotId)
917 {
918  SdrModel& rModel(rObj.getSdrModelFromSdrObject());
919 
920  if ( !(nSlotId == SID_LINE_ARROW_START ||
921  nSlotId == SID_LINE_ARROW_END ||
922  nSlotId == SID_LINE_ARROWS ||
923  nSlotId == SID_LINE_ARROW_CIRCLE ||
924  nSlotId == SID_LINE_CIRCLE_ARROW ||
925  nSlotId == SID_LINE_ARROW_SQUARE ||
926  nSlotId == SID_LINE_SQUARE_ARROW ||
927  nSlotId == SID_DRAW_MEASURELINE) )
928  return;
929 
930  // set attributes of line start and ends
931 
932  // arrowhead
933  ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) );
934  if( !aArrow.count() )
935  {
936  ::basegfx::B2DPolygon aNewArrow;
937  aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0));
938  aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0));
939  aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0));
940  aNewArrow.setClosed(true);
941  aArrow.append(aNewArrow);
942  }
943 
944  // Circles
945  ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) );
946  if( !aCircle.count() )
947  {
948  ::basegfx::B2DPolygon aNewCircle = ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0);
949  aNewCircle.setClosed(true);
950  aCircle.append(aNewCircle);
951  }
952 
953  // Square
954  ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) );
955  if( !aSquare.count() )
956  {
957  ::basegfx::B2DPolygon aNewSquare;
958  aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0));
959  aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0));
960  aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0));
961  aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0));
962  aNewSquare.setClosed(true);
963  aSquare.append(aNewSquare);
964  }
965 
966  SfxItemSet aSet( rModel.GetItemPool() );
967  tools::Long nWidth = 100; // (1/100th mm)
968 
969  // determine line width and calculate with it the line end width
970  if( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE )
971  {
972  tools::Long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue();
973  if( nValue > 0 )
974  nWidth = nValue * 3;
975  }
976 
977  switch (nSlotId)
978  {
979  case SID_LINE_ARROWS:
980  case SID_DRAW_MEASURELINE:
981  {
982  // connector with arrow ends
983  rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
984  rAttr.Put(XLineStartWidthItem(nWidth));
985  rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
986  rAttr.Put(XLineEndWidthItem(nWidth));
987  }
988  break;
989 
990  case SID_LINE_ARROW_START:
991  case SID_LINE_ARROW_CIRCLE:
992  case SID_LINE_ARROW_SQUARE:
993  {
994  // connector with arrow start
995  rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
996  rAttr.Put(XLineStartWidthItem(nWidth));
997  }
998  break;
999 
1000  case SID_LINE_ARROW_END:
1001  case SID_LINE_CIRCLE_ARROW:
1002  case SID_LINE_SQUARE_ARROW:
1003  {
1004  // connector with arrow end
1005  rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
1006  rAttr.Put(XLineEndWidthItem(nWidth));
1007  }
1008  break;
1009  }
1010 
1011  // and again, for the still missing ends
1012  switch (nSlotId)
1013  {
1014  case SID_LINE_ARROW_CIRCLE:
1015  {
1016  // circle end
1017  rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
1018  rAttr.Put(XLineEndWidthItem(nWidth));
1019  }
1020  break;
1021 
1022  case SID_LINE_CIRCLE_ARROW:
1023  {
1024  // circle start
1025  rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
1026  rAttr.Put(XLineStartWidthItem(nWidth));
1027  }
1028  break;
1029 
1030  case SID_LINE_ARROW_SQUARE:
1031  {
1032  // square end
1033  rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
1034  rAttr.Put(XLineEndWidthItem(nWidth));
1035  }
1036  break;
1037 
1038  case SID_LINE_SQUARE_ARROW:
1039  {
1040  // square start
1041  rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
1042  rAttr.Put(XLineStartWidthItem(nWidth));
1043  }
1044  break;
1045  }
1046 
1047 }
1048 
1049 void SwFEShell::SelectionToTop( bool bTop )
1050 {
1051  OSL_ENSURE( Imp()->HasDrawView(), "SelectionToTop without DrawView?" );
1052  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1053  OSL_ENSURE( rMrkList.GetMarkCount(), "No object selected." );
1054 
1055  SwFlyFrame *pFly = ::GetFlyFromMarked( &rMrkList, this );
1056  if ( pFly && pFly->IsFlyInContentFrame() )
1057  return;
1058 
1059  StartAllAction();
1060  if ( bTop )
1061  Imp()->GetDrawView()->PutMarkedToTop();
1062  else
1063  Imp()->GetDrawView()->MovMarkedToTop();
1064  ::lcl_NotifyNeighbours( &rMrkList );
1065 
1066  // Does the selection contain a textbox?
1067  for (size_t i = 0; i < rMrkList.GetMarkCount(); i++)
1068  if (auto pObj = rMrkList.GetMark(i)->GetMarkedSdrObj())
1069  // Get the textbox-shape
1070  if (auto pFormat = FindFrameFormat(pObj))
1071  {
1072  // If it has not textframe skip...
1073  if (!SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT, pObj))
1074  continue;
1075  // If it has a textframe so it is a textbox, get its page
1076  if (auto pDrwModel
1077  = pFormat->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel())
1078  // Not really understood why everything is on page 0...
1079  // but it is easier to handle sdrobjects, that's true
1080  if (auto pPage = pDrwModel->GetPage(0))
1081  {
1082  // nShift: it means how many layers the pObj have to be shifted up,
1083  // in order not to interfere with other shapes and textboxes.
1084  // Situations:
1085  // - The next shape has textframe: This shape have to shifted with
1086  // two layers.
1087  // - The next shape has not got textframe: This shape have to be
1088  // shifted only one layer up.
1089  // - The next shape is null:
1090  // - This shape is already at heaven: Only the textframe have
1091  // to be adjusted.
1092  sal_uInt32 nShift = 0;
1093  // Get the one level higher object (note: can be nullptr!)
1094  const auto pNextObj = pPage->SetObjectOrdNum(pObj->GetOrdNum() + 1, pObj->GetOrdNum() + 1);
1095  // If there is a higher object (not null)...
1096  if (pNextObj)
1097  {
1098  // One level shift is necessary
1099  nShift++;
1100  // If this object is a textbox, two level increasing needed
1101  // (one for the shape and one for the frame)
1102  if (auto pNextFormat = FindFrameFormat(pNextObj))
1103  if (SwTextBoxHelper::isTextBox(pNextFormat, RES_DRAWFRMFMT, pNextObj)
1104  || SwTextBoxHelper::isTextBox(pNextFormat, RES_FLYFRMFMT))
1105  nShift++;
1106  }
1107  // Set the new z-order.
1108  pPage->SetObjectOrdNum(pObj->GetOrdNum(), pObj->GetOrdNum() + nShift);
1109  }
1110  // The shape is on the right level, correct the layer of the frame
1112  }
1113 
1114  GetDoc()->getIDocumentState().SetModified();
1115  EndAllAction();
1116 }
1117 
1118 void SwFEShell::SelectionToBottom( bool bBottom )
1119 {
1120  OSL_ENSURE( Imp()->HasDrawView(), "SelectionToBottom without DrawView?" );
1121  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1122  OSL_ENSURE( rMrkList.GetMarkCount(), "No object selected." );
1123 
1124  SwFlyFrame *pFly = ::GetFlyFromMarked( &rMrkList, this );
1125  if ( pFly && pFly->IsFlyInContentFrame() )
1126  return;
1127 
1128  StartAllAction();
1129  if ( bBottom )
1130  Imp()->GetDrawView()->PutMarkedToBtm();
1131  else
1132  Imp()->GetDrawView()->MovMarkedToBtm();
1133  ::lcl_NotifyNeighbours( &rMrkList );
1134 
1135  // If the selection has textbox
1136  for(size_t i = 0; i < rMrkList.GetMarkCount(); i++)
1137  if (auto pObj = rMrkList.GetMark(i)->GetMarkedSdrObj())
1138  // Get the shape of the textbox
1139  if (auto pFormat = FindFrameFormat(pObj))
1140  {
1141  // If the shape has not textframes skip.
1142  if (!SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT, pObj))
1143  continue;
1144  // If has, move the shape to correct level with...
1145  if (auto pDrwModel
1146  = pFormat->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel())
1147  if (auto pPage = pDrwModel->GetPage(0))
1148  {
1149  const auto pNextObj = pPage->SetObjectOrdNum(pObj->GetOrdNum() - 1, pObj->GetOrdNum() - 1);
1150  // If there is a lower object (not null)...
1151  if (pNextObj)
1152  {
1153  // If the lower has no textframe, just do nothing, else move by one lower
1154  if (auto pNextFormat = FindFrameFormat(pNextObj))
1155  if (SwTextBoxHelper::isTextBox(pNextFormat, RES_DRAWFRMFMT, pNextObj)
1156  || SwTextBoxHelper::isTextBox(pNextFormat, RES_FLYFRMFMT))
1157  pPage->SetObjectOrdNum(pObj->GetOrdNum(), pObj->GetOrdNum() - 1);
1158  }
1159  }
1160  // And set correct layer for the selected textbox.
1162  }
1163 
1164  GetDoc()->getIDocumentState().SetModified();
1165  EndAllAction();
1166 }
1167 
1168 // Object above/below the document? 2 Controls, 1 Heaven, 0 Hell,
1169 // SDRLAYER_NOTFOUND Ambiguous
1171 {
1172  if ( !Imp()->HasDrawView() )
1173  return SDRLAYER_NOTFOUND;
1174 
1176  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1177  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
1178  {
1179  const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1180  if( !pObj )
1181  continue;
1182  if ( nRet == SDRLAYER_NOTFOUND )
1183  nRet = pObj->GetLayer();
1184  else if ( nRet != pObj->GetLayer() )
1185  {
1186  return SDRLAYER_NOTFOUND;
1187  }
1188  }
1189  return nRet;
1190 }
1191 
1192 // Object above/below the document
1193 // Note: only visible objects can be marked. Thus, objects with invisible
1194 // layer IDs have not to be considered.
1195 // If <SwFEShell> exists, layout exists!!
1197 {
1198  if ( !Imp()->HasDrawView() )
1199  return;
1200 
1201  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1202  const IDocumentDrawModelAccess& rIDDMA = getIDocumentDrawModelAccess();
1203  // correct type of <nControls>
1204  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
1205  {
1206  SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1207  if( !pObj )
1208  continue;
1209  // or group objects containing controls.
1210  // --> #i113730#
1211  // consider that a member of a drawing group has been selected.
1212  const SwContact* pContact = ::GetUserCall( pObj );
1213  OSL_ENSURE( pContact && pContact->GetMaster(), "<SwFEShell::ChangeOpaque(..)> - missing contact or missing master object at contact!" );
1214  const bool bControlObj = ( pContact && pContact->GetMaster() )
1215  ? ::CheckControlLayer( pContact->GetMaster() )
1216  : ::CheckControlLayer( pObj );
1217  if ( !bControlObj && pObj->GetLayer() != nLayerId )
1218  {
1219  pObj->SetLayer( nLayerId );
1220  InvalidateWindows( SwRect( pObj->GetCurrentBoundRect() ) );
1221  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
1222  {
1223  SwFormat *pFormat = pVirtO->GetFlyFrame()->GetFormat();
1224  SvxOpaqueItem aOpa( pFormat->GetOpaque() );
1225  aOpa.SetValue( nLayerId == rIDDMA.GetHellId() );
1226  pFormat->SetFormatAttr( aOpa );
1227  // If pObj has textframe, put its textframe to the right level
1228  if (auto pTextBx = FindFrameFormat(pObj))
1230  }
1231  }
1232  }
1233  GetDoc()->getIDocumentState().SetModified();
1234 }
1235 
1237 {
1238  ChangeOpaque( getIDocumentDrawModelAccess().GetHeavenId() );
1239 }
1240 
1242 {
1243  ChangeOpaque( getIDocumentDrawModelAccess().GetHellId() );
1244 }
1245 
1247 {
1248  if ( IsFrameSelected() || !Imp()->HasDrawView() )
1249  return 0;
1250 
1251  return Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount();
1252 }
1253 
1255 {
1256  if ( !Imp()->HasDrawView() )
1257  return false;
1258  else
1259  return nullptr != ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
1260  const_cast<SwFEShell*>(this) );
1261 }
1262 
1263 bool SwFEShell::IsObjSelected( const SdrObject& rObj ) const
1264 {
1265  if ( IsFrameSelected() || !Imp()->HasDrawView() )
1266  return false;
1267  else
1268  return Imp()->GetDrawView()->IsObjMarked( &rObj );
1269 }
1270 
1272 {
1273  // RotGrfFlyFrame: check if RotationMode is possible
1274  const SdrView *pSdrView = Imp()->GetDrawView();
1275 
1276  if(pSdrView)
1277  {
1278  const SdrMarkList& rList(pSdrView->GetMarkedObjectList());
1279 
1280  if(1 == rList.GetMarkCount())
1281  {
1282  const SwVirtFlyDrawObj* pVirtFlyDraw(dynamic_cast< const SwVirtFlyDrawObj* >(rList.GetMark(0)->GetMarkedSdrObj()));
1283 
1284  if(nullptr != pVirtFlyDraw)
1285  {
1286  return pVirtFlyDraw->ContainsSwGrfNode();
1287  }
1288  }
1289  }
1290 
1291  return false;
1292 }
1293 
1295 {
1296  if (pObj)
1297  {
1298  const SdrMarkList& aMarkList = Imp()->GetDrawView()->GetMarkedObjectList();
1299  if (aMarkList.GetMarkCount() == 0)
1300  {
1301  return true;
1302  }
1303  SdrMark* pM=aMarkList.GetMark(0);
1304  if (pM)
1305  {
1306  SdrObject* pMarkObj = pM->GetMarkedSdrObj();
1307  if (pMarkObj && pMarkObj->getParentSdrObjectFromSdrObject() == pObj->getParentSdrObjectFromSdrObject())
1308  return true;
1309  }
1310  }
1311  return false;
1312 }
1313 
1315 {
1316  // Terminate the TextEditMode. If required (default if the object
1317  // does not contain any more text and does not carry attributes) the object
1318  // is deleted. All other objects marked are preserved.
1319 
1320  OSL_ENSURE( Imp()->HasDrawView() && Imp()->GetDrawView()->IsTextEdit(),
1321  "EndTextEdit a no Object" );
1322 
1323  StartAllAction();
1324  SdrView *pView = Imp()->GetDrawView();
1325  SdrObject *pObj = pView->GetTextEditObject();
1326  SdrObjUserCall* pUserCall = GetUserCall(pObj);
1327  if( nullptr != pUserCall )
1328  {
1329  SdrObject *pTmp = static_cast<SwContact*>(pUserCall)->GetMaster();
1330  if( !pTmp )
1331  pTmp = pObj;
1332  pUserCall->Changed( *pTmp, SdrUserCallType::Resize, pTmp->GetLastBoundRect() );
1333  }
1334  if ( !pObj->getParentSdrObjectFromSdrObject() )
1335  {
1336  if ( SdrEndTextEditKind::ShouldBeDeleted == pView->SdrEndTextEdit(true) )
1337  {
1338  if ( pView->GetMarkedObjectList().GetMarkCount() > 1 )
1339  {
1340  SdrMarkList aSave( pView->GetMarkedObjectList() );
1341  aSave.DeleteMark( aSave.FindObject( pObj ) );
1342  if ( aSave.GetMarkCount() )
1343  {
1344  pView->UnmarkAll();
1345  pView->MarkObj( pObj, Imp()->GetPageView() );
1346  }
1347  DelSelectedObj();
1348  for ( size_t i = 0; i < aSave.GetMarkCount(); ++i )
1349  pView->MarkObj( aSave.GetMark( i )->GetMarkedSdrObj(), Imp()->GetPageView() );
1350  }
1351  else
1352  DelSelectedObj();
1353  }
1354  }
1355  else
1356  pView->SdrEndTextEdit();
1357 
1359  SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_LOCK, "rectangle", "EMPTY");
1360 
1361  EndAllAction();
1362 }
1363 
1364 bool SwFEShell::IsInsideSelectedObj( const Point &rPt )
1365 {
1366  if( Imp()->HasDrawView() )
1367  {
1368  SwDrawView *pDView = Imp()->GetDrawView();
1369 
1370  if( pDView->GetMarkedObjectList().GetMarkCount() &&
1371  pDView->IsMarkedObjHit( rPt ) )
1372  {
1373  return true;
1374  }
1375  }
1376  return false;
1377 }
1378 
1379 bool SwFEShell::IsObjSelectable( const Point& rPt )
1380 {
1381  CurrShell aCurr(this);
1382  SwDrawView *pDView = Imp()->GetDrawView();
1383  bool bRet = false;
1384  if( pDView )
1385  {
1386  SdrPageView* pPV;
1387  const auto nOld = pDView->GetHitTolerancePixel();
1388  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1389 
1390  bRet = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE) != nullptr;
1391  pDView->SetHitTolerancePixel( nOld );
1392  }
1393  return bRet;
1394 }
1395 
1396 SdrObject* SwFEShell::GetObjAt( const Point& rPt )
1397 {
1398  SdrObject* pRet = nullptr;
1399  CurrShell aCurr(this);
1400  SwDrawView *pDView = Imp()->GetDrawView();
1401  if( pDView )
1402  {
1403  SdrPageView* pPV;
1404  const auto nOld = pDView->GetHitTolerancePixel();
1405  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1406 
1407  pRet = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE);
1408  pDView->SetHitTolerancePixel( nOld );
1409  }
1410  return pRet;
1411 }
1412 
1413 // Test if there is an object at that position and if it should be selected.
1415 {
1416  CurrShell aCurr(this);
1417  SwDrawView *pDrawView = Imp()->GetDrawView();
1418  bool bRet(false);
1419 
1420  if(pDrawView)
1421  {
1422  SdrPageView* pPV;
1423  const auto nOld(pDrawView->GetHitTolerancePixel());
1424 
1425  pDrawView->SetHitTolerancePixel(pDrawView->GetMarkHdlSizePixel()/2);
1426  SdrObject* pObj = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE);
1427  pDrawView->SetHitTolerancePixel(nOld);
1428 
1429  if (pObj)
1430  {
1431  bRet = true;
1432  const IDocumentDrawModelAccess& rIDDMA = getIDocumentDrawModelAccess();
1433  // #i89920#
1434  // Do not select object in background which is overlapping this text
1435  // at the given position.
1436  bool bObjInBackground( false );
1437  {
1438  if ( pObj->GetLayer() == rIDDMA.GetHellId() )
1439  {
1440  const SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
1441  const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
1442  const SwFormatSurround& rSurround = rFormat.GetSurround();
1443  if ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH )
1444  {
1445  bObjInBackground = true;
1446  }
1447  }
1448  }
1449  if ( bObjInBackground )
1450  {
1451  const SwPageFrame* pPageFrame = GetLayout()->GetPageAtPos( rPt );
1452  if( pPageFrame )
1453  {
1454  const SwContentFrame* pContentFrame( pPageFrame->ContainsContent() );
1455  while ( pContentFrame )
1456  {
1457  if ( pContentFrame->UnionFrame().Contains( rPt ) )
1458  {
1459  const SwTextFrame* pTextFrame = pContentFrame->DynCastTextFrame();
1460  if ( pTextFrame )
1461  {
1462  SwPosition aPos(GetDoc()->GetNodes());
1463  Point aTmpPt( rPt );
1464  if (pTextFrame->GetKeyCursorOfst(&aPos, aTmpPt))
1465  {
1466  SwRect aCursorCharRect;
1467  if (pTextFrame->GetCharRect(aCursorCharRect,
1468  aPos))
1469  {
1470  if ( aCursorCharRect.Overlaps( SwRect( pObj->GetLastBoundRect() ) ) )
1471  {
1472  bRet = false;
1473  }
1474  }
1475  }
1476  }
1477  else
1478  {
1479  bRet = false;
1480  }
1481  break;
1482  }
1483 
1484  pContentFrame = pContentFrame->GetNextContentFrame();
1485  }
1486  }
1487  }
1488 
1489  // Don't select header / footer objects in body edition and vice-versa
1490  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1491  if (pContact && !pContact->ObjAnchoredAtPage() )
1492  {
1493  const SwPosition& rPos = pContact->GetContentAnchor();
1494  bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
1495  if (IsHeaderFooterEdit() != bInHdrFtr)
1496  {
1497  bRet = false;
1498  }
1499  }
1500 
1501  if ( bRet )
1502  {
1503  const SdrPage* pPage = rIDDMA.GetDrawModel()->GetPage(0);
1504  for(size_t a = pObj->GetOrdNum()+1; bRet && a < pPage->GetObjCount(); ++a)
1505  {
1506  SdrObject *pCandidate = pPage->GetObj(a);
1507 
1508  SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pCandidate);
1509  if (pDrawObj && pDrawObj->GetCurrentBoundRect().Contains(rPt))
1510  {
1511  bRet = false;
1512  }
1513  }
1514  }
1515  }
1516  }
1517 
1518  return bRet;
1519 }
1520 
1521 /*
1522  * If an object was selected, we assume its upper-left corner
1523  * otherwise the middle of the current CharRects.
1524  * Does the object include a control or groups,
1525  * which comprise only controls
1526  */
1527 static bool lcl_IsControlGroup( const SdrObject *pObj )
1528 {
1529  bool bRet = false;
1530  if(dynamic_cast<const SdrUnoObj*>( pObj) != nullptr)
1531  bRet = true;
1532  else if( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
1533  {
1534  bRet = true;
1535  const SdrObjList *pLst = pObjGroup->GetSubList();
1536  for ( size_t i = 0; i < pLst->GetObjCount(); ++i )
1537  if( !::lcl_IsControlGroup( pLst->GetObj( i ) ) )
1538  return false;
1539  }
1540  return bRet;
1541 }
1542 
1543 namespace
1544 {
1545  class MarkableObjectsOnly : public svx::ISdrObjectFilter
1546  {
1547  public:
1548  explicit MarkableObjectsOnly( SdrPageView* i_pPV )
1549  :m_pPV( i_pPV )
1550  {
1551  }
1552 
1553  virtual bool includeObject( const SdrObject& i_rObject ) const override
1554  {
1555  return m_pPV && m_pPV->GetView().IsObjMarkable( &i_rObject, m_pPV );
1556  }
1557 
1558  private:
1559  SdrPageView* m_pPV;
1560  };
1561 }
1562 
1563 const SdrObject* SwFEShell::GetBestObject(bool bNext, GotoObjFlags eType, bool bFlat,
1564  const svx::ISdrObjectFilter* pFilter,
1565  bool* pbWrapped)
1566 {
1567  if (pbWrapped)
1568  *pbWrapped = false;
1569 
1570  if( !Imp()->HasDrawView() )
1571  return nullptr;
1572 
1573  const SdrObject *pBest = nullptr,
1574  *pTop = nullptr;
1575 
1576  const tools::Long nTmp = bNext ? LONG_MAX : 0;
1577  Point aBestPos( nTmp, nTmp );
1578  Point aTopPos( nTmp, nTmp );
1579  Point aCurPos;
1580  Point aPos;
1581  bool bNoDraw((GotoObjFlags::DrawAny & eType) == GotoObjFlags::NONE);
1582  bool bNoFly((GotoObjFlags::FlyAny & eType) == GotoObjFlags::NONE);
1583 
1584  if( !bNoFly && bNoDraw )
1585  {
1586  SwFlyFrame *pFly = GetCurrFrame( false )->FindFlyFrame();
1587  if( pFly )
1588  pBest = pFly->GetVirtDrawObj();
1589  }
1590  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1591  SdrPageView* pPV = Imp()->GetDrawView()->GetSdrPageView();
1592 
1593  MarkableObjectsOnly aDefaultFilter( pPV );
1594  if ( !pFilter )
1595  pFilter = &aDefaultFilter;
1596 
1597  if( !pBest || rMrkList.GetMarkCount() == 1 )
1598  {
1599  // Determine starting point
1600  SdrObjList* pList = nullptr;
1601  if ( rMrkList.GetMarkCount() )
1602  {
1603  const SdrObject* pStartObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
1604  if( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pStartObj) )
1605  aPos = pVirtFlyDrawObj->GetFlyFrame()->getFrameArea().Pos();
1606  else
1607  aPos = pStartObj->GetSnapRect().TopLeft();
1608 
1609  // If an object inside a group is selected, we want to
1610  // iterate over the group members.
1611  if ( ! pStartObj->GetUserCall() )
1612  pList = pStartObj->getParentSdrObjListFromSdrObject();
1613  }
1614  else
1615  {
1616  // If no object is selected, we check if we just entered a group.
1617  // In this case we want to iterate over the group members.
1618  aPos = GetCharRect().Center();
1619  const SdrObject* pStartObj = pPV ? pPV->GetCurrentGroup() : nullptr;
1620  if ( dynamic_cast<const SdrObjGroup*>( pStartObj) )
1621  pList = pStartObj->GetSubList();
1622  }
1623 
1624  if ( ! pList )
1625  {
1626  // Here we are if
1627  // A No object has been selected and no group has been entered or
1628  // B An object has been selected and it is not inside a group
1629  pList = getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 );
1630  }
1631 
1632  OSL_ENSURE( pList, "No object list to iterate" );
1633 
1634  SdrObjListIter aObjIter( pList, bFlat ? SdrIterMode::Flat : SdrIterMode::DeepNoGroups );
1635  while ( aObjIter.IsMore() )
1636  {
1637  SdrObject* pObj = aObjIter.Next();
1638  SwVirtFlyDrawObj *pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1639  if( ( bNoFly && pVirtO ) ||
1640  ( bNoDraw && !pVirtO ) ||
1641  // Ignore TextBoxes of draw shapes here, so that
1642  // SwFEShell::SelectObj() won't jump back on this list, meaning
1643  // we never jump to the next draw shape.
1644  (pVirtO && pVirtO->IsTextBox()) ||
1645  ( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) ||
1646  ( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
1647  !pFilter->includeObject( *pObj ) )
1648  continue;
1649  if (pVirtO)
1650  {
1651  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
1652  if( GotoObjFlags::FlyAny != ( GotoObjFlags::FlyAny & eType ) )
1653  {
1654  switch ( eType )
1655  {
1657  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1658  continue;
1659  break;
1660  case GotoObjFlags::FlyGrf:
1661  if ( pFly->Lower() &&
1662  (!pFly->Lower()->IsNoTextFrame() ||
1663  !static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode()))
1664  continue;
1665  break;
1666  case GotoObjFlags::FlyOLE:
1667  if ( pFly->Lower() &&
1668  (!pFly->Lower()->IsNoTextFrame() ||
1669  !static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode()))
1670  continue;
1671  break;
1672  default: break;
1673  }
1674  }
1675  aCurPos = pFly->getFrameArea().Pos();
1676  }
1677  else
1678  aCurPos = pObj->GetSnapRect().TopLeft();
1679 
1680  // Special case if another object is on same Y.
1681  if( aCurPos != aPos && // only when it is not me
1682  aCurPos.getY() == aPos.getY() && // Y positions equal
1683  (bNext? (aCurPos.getX() > aPos.getX()) : // lies next to me
1684  (aCurPos.getX() < aPos.getX())) ) // " reverse
1685  {
1686  aBestPos = Point( nTmp, nTmp );
1687  SdrObjListIter aTmpIter( pList, bFlat ? SdrIterMode::Flat : SdrIterMode::DeepNoGroups );
1688  while ( aTmpIter.IsMore() )
1689  {
1690  SdrObject* pTmpObj = aTmpIter.Next();
1691  pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pTmpObj);
1692  if( ( bNoFly && pVirtO ) || ( bNoDraw && !pVirtO ) )
1693  continue;
1694  if (pVirtO)
1695  {
1696  aCurPos = pVirtO->GetFlyFrame()->getFrameArea().Pos();
1697  }
1698  else
1699  aCurPos = pTmpObj->GetCurrentBoundRect().TopLeft();
1700 
1701  if( aCurPos != aPos && aCurPos.Y() == aPos.Y() &&
1702  (bNext? (aCurPos.getX() > aPos.getX()) : // lies next to me
1703  (aCurPos.getX() < aPos.getX())) && // " reverse
1704  (bNext? (aCurPos.getX() < aBestPos.getX()) : // better as best
1705  (aCurPos.getX() > aBestPos.getX())) ) // " reverse
1706  {
1707  aBestPos = aCurPos;
1708  pBest = pTmpObj;
1709  }
1710  }
1711  break;
1712  }
1713 
1714  if( (
1715  (bNext? (aPos.getY() < aCurPos.getY()) : // only below me
1716  (aPos.getY() > aCurPos.getY())) && // " reverse
1717  (bNext? (aBestPos.getY() > aCurPos.getY()) : // closer below
1718  (aBestPos.getY() < aCurPos.getY()))
1719  ) || // " reverse
1720  (aBestPos.getY() == aCurPos.getY() &&
1721  (bNext? (aBestPos.getX() > aCurPos.getX()) : // further left
1722  (aBestPos.getX() < aCurPos.getX())))) // " reverse
1723 
1724  {
1725  aBestPos = aCurPos;
1726  pBest = pObj;
1727  }
1728 
1729  if( (bNext? (aTopPos.getY() > aCurPos.getY()) : // higher as best
1730  (aTopPos.getY() < aCurPos.getY())) || // " reverse
1731  (aTopPos.getY() == aCurPos.getY() &&
1732  (bNext? (aTopPos.getX() > aCurPos.getX()) : // further left
1733  (aTopPos.getX() < aCurPos.getX())))) // " reverse
1734  {
1735  aTopPos = aCurPos;
1736  pTop = pObj;
1737  }
1738  }
1739  // unfortunately nothing found
1740  if( bNext ? (aBestPos.getX() == LONG_MAX) : (aBestPos.getX() == 0) )
1741  {
1742  pBest = pTop;
1743  if (pbWrapped && pBest)
1744  *pbWrapped = true;
1745  }
1746  }
1747 
1748  return pBest;
1749 }
1750 
1751 bool SwFEShell::GotoObj( bool bNext, GotoObjFlags eType )
1752 {
1753  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1754 
1755  bool bWrapped(false);
1756  const SdrObject* pBest = GetBestObject(bNext, eType, true, nullptr, &bWrapped);
1757 
1758  if ( !pBest )
1759  {
1760  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1761  return false;
1762  }
1763 
1764  const SwVirtFlyDrawObj *pVirtO = dynamic_cast<const SwVirtFlyDrawObj*>(pBest);
1765  if (pVirtO)
1766  {
1767  const SwRect& rFrame = pVirtO->GetFlyFrame()->getFrameArea();
1768  SelectObj( rFrame.Pos(), 0, const_cast<SdrObject*>(pBest) );
1769  if( !ActionPend() )
1770  MakeVisible( rFrame );
1771  }
1772  else
1773  {
1774  SelectObj( Point(), 0, const_cast<SdrObject*>(pBest) );
1775  if( !ActionPend() )
1776  MakeVisible( SwRect(pBest->GetCurrentBoundRect()) );
1777  }
1778  CallChgLnk();
1779 
1780  if (bWrapped)
1781  SvxSearchDialogWrapper::SetSearchLabel(bNext ? SearchLabel::EndWrapped :
1782  SearchLabel::StartWrapped);
1783 
1784  return true;
1785 }
1786 
1787 bool SwFEShell::BeginCreate( SdrObjKind eSdrObjectKind, const Point &rPos )
1788 {
1789  bool bRet = false;
1790 
1791  if ( !Imp()->HasDrawView() )
1792  Imp()->MakeDrawView();
1793 
1794  if ( GetPageNumber( rPos ) )
1795  {
1796  Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind );
1797  if ( eSdrObjectKind == SdrObjKind::Caption )
1798  bRet = Imp()->GetDrawView()->BegCreateCaptionObj(
1799  rPos, Size( lMinBorder - MINFLY, lMinBorder - MINFLY ),
1800  GetOut() );
1801  else
1802  bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1803  }
1804  if ( bRet )
1805  {
1806  ::FrameNotify( this, FLY_DRAG_START );
1807  }
1808  return bRet;
1809 }
1810 
1811 bool SwFEShell::BeginCreate( SdrObjKind eSdrObjectKind, SdrInventor eObjInventor,
1812  const Point &rPos )
1813 {
1814  bool bRet = false;
1815 
1816  if ( !Imp()->HasDrawView() )
1817  Imp()->MakeDrawView();
1818 
1819  if ( GetPageNumber( rPos ) )
1820  {
1821  Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind, eObjInventor );
1822  bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1823  }
1824  if ( bRet )
1825  ::FrameNotify( this, FLY_DRAG_START );
1826  return bRet;
1827 }
1828 
1829 void SwFEShell::MoveCreate( const Point &rPos )
1830 {
1831  OSL_ENSURE( Imp()->HasDrawView(), "MoveCreate without DrawView?" );
1832  if ( GetPageNumber( rPos ) )
1833  {
1834  ScrollTo( rPos );
1835  Imp()->GetDrawView()->MovCreateObj( rPos );
1836  ::FrameNotify( this );
1837  }
1838 }
1839 
1840 bool SwFEShell::EndCreate( SdrCreateCmd eSdrCreateCmd )
1841 {
1842  // To assure undo-object from the DrawEngine is not stored,
1843  // (we create our own undo-object!), temporarily switch-off Undo
1844  OSL_ENSURE( Imp()->HasDrawView(), "EndCreate without DrawView?" );
1845  if( !Imp()->GetDrawView()->IsGroupEntered() )
1846  {
1847  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
1848  }
1849  bool bCreate = Imp()->GetDrawView()->EndCreateObj( eSdrCreateCmd );
1850  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
1851 
1852  if ( !bCreate )
1853  {
1854  ::FrameNotify( this, FLY_DRAG_END );
1855  return false;
1856  }
1857 
1858  if ( eSdrCreateCmd == SdrCreateCmd::NextPoint )
1859  {
1860  ::FrameNotify( this );
1861  return true;
1862  }
1863  return ImpEndCreate();
1864 }
1865 
1867 {
1868  OSL_ENSURE( Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1,
1869  "New object not selected." );
1870 
1871  SdrObject& rSdrObj = *Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1872 
1873  if( rSdrObj.GetSnapRect().IsEmpty() )
1874  {
1875  // preferably we forget the object, only gives problems
1876  Imp()->GetDrawView()->DeleteMarked();
1877  Imp()->GetDrawView()->UnmarkAll();
1878  ::FrameNotify( this, FLY_DRAG_END );
1879  return false;
1880  }
1881 
1882  if( rSdrObj.getParentSdrObjectFromSdrObject() )
1883  {
1884  Point aTmpPos( rSdrObj.GetSnapRect().TopLeft() );
1885  Point aNewAnchor( rSdrObj.getParentSdrObjectFromSdrObject()->GetAnchorPos() );
1886  // OD 2004-04-05 #i26791# - direct object positioning for group members
1887  rSdrObj.NbcSetRelativePos( aTmpPos - aNewAnchor );
1888  rSdrObj.NbcSetAnchorPos( aNewAnchor );
1889  ::FrameNotify( this );
1890  return true;
1891  }
1892 
1893  LockPaint();
1894  StartAllAction();
1895 
1896  Imp()->GetDrawView()->UnmarkAll();
1897 
1898  const tools::Rectangle &rBound = rSdrObj.GetSnapRect();
1899  Point aPt( rBound.TopRight() );
1900 
1901  // default for controls character bound, otherwise paragraph bound.
1902  SwFormatAnchor aAnch;
1903  const SwFrame *pAnch = nullptr;
1904  bool bCharBound = false;
1905  if( dynamic_cast<const SdrUnoObj*>( &rSdrObj) != nullptr )
1906  {
1907  SwPosition aPos( GetDoc()->GetNodes() );
1909  Point aPoint( aPt.getX(), aPt.getY() + rBound.GetHeight()/2 );
1910  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
1911 
1912  // characterbinding not allowed in readonly-content
1913  if( !aPos.nNode.GetNode().IsProtect() )
1914  {
1915  std::pair<Point, bool> const tmp(aPoint, true);
1916  pAnch = aPos.nNode.GetNode().GetContentNode()->getLayoutFrame(GetLayout(), &aPos, &tmp);
1917  SwRect aTmp;
1918  pAnch->GetCharRect( aTmp, aPos );
1919 
1920  // The crsr should not be too far away
1921  bCharBound = true;
1922  constexpr tools::Long constTwips_1cm = o3tl::toTwips(1, o3tl::Length::cm);
1923  tools::Rectangle aRect( aTmp.SVRect() );
1924  // Extend by 1 cm in each direction
1925  aRect.AdjustLeft(-constTwips_1cm);
1926  aRect.AdjustTop(-constTwips_1cm);
1927  aRect.AdjustRight(constTwips_1cm);
1928  aRect.AdjustBottom(constTwips_1cm);
1929 
1930  if( !aRect.Overlaps( rBound ) && !::GetHtmlMode( GetDoc()->GetDocShell() ))
1931  bCharBound = false;
1932 
1933  // anchor in header/footer also not allowed.
1934  if( bCharBound )
1935  bCharBound = !GetDoc()->IsInHeaderFooter( aPos.nNode );
1936 
1937  if( bCharBound )
1938  {
1939  aAnch.SetType( RndStdIds::FLY_AS_CHAR );
1940  aAnch.SetAnchor( &aPos );
1941  }
1942  }
1943  }
1944 
1945  if( !bCharBound )
1946  {
1947  // allow native drawing objects in header/footer.
1948  // Thus, set <bBodyOnly> to <false> for these objects using value
1949  // of <nIdent> - value <0xFFFF> indicates control objects, which aren't
1950  // allowed in header/footer.
1951  //bool bBodyOnly = OBJ_NONE != nIdent;
1952  bool bBodyOnly = SdrInventor::Default != rSdrObj.GetObjInventor();
1953  bool bAtPage = false;
1954  const SwFrame* pPage = nullptr;
1956  Point aPoint( aPt );
1957  SwPosition aPos( GetDoc()->GetNodes() );
1958  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
1959 
1960  // do not set in ReadnOnly-content
1961  if (aPos.nNode.GetNode().IsProtect())
1962  {
1963  // then only page bound. Or should we
1964  // search the next not-readonly position?
1965  bAtPage = true;
1966  }
1967 
1968  SwContentNode* pCNode = aPos.nNode.GetNode().GetContentNode();
1969  std::pair<Point, bool> const tmp(aPoint, false);
1970  pAnch = pCNode ? pCNode->getLayoutFrame(GetLayout(), nullptr, &tmp) : nullptr;
1971  if (!pAnch)
1972  {
1973  // Hidden content. Anchor to the page instead
1974  bAtPage = true;
1975  }
1976 
1977  if( !bAtPage )
1978  {
1979  const SwFlyFrame *pTmp = pAnch->FindFlyFrame();
1980  if( pTmp )
1981  {
1982  const SwFrame* pTmpFrame = pAnch;
1983  SwRect aBound( rBound );
1984  while( pTmp )
1985  {
1986  if( pTmp->getFrameArea().Contains( aBound ) )
1987  {
1988  if( !bBodyOnly || !pTmp->FindFooterOrHeader() )
1989  pPage = pTmpFrame;
1990  break;
1991  }
1992  pTmp = pTmp->GetAnchorFrame()
1993  ? pTmp->GetAnchorFrame()->FindFlyFrame()
1994  : nullptr;
1995  pTmpFrame = pTmp;
1996  }
1997  }
1998 
1999  if( !pPage )
2000  pPage = pAnch->FindPageFrame();
2001 
2002  // Always via FindAnchor, to assure the frame will be bound
2003  // to the previous. With GetCrsOfst we can also reach the next. THIS IS WRONG.
2004  pAnch = ::FindAnchor( pPage, aPt, bBodyOnly );
2005  if (pAnch->IsTextFrame())
2006  {
2007  std::pair<SwTextNode const*, sal_Int32> const pos(
2008  static_cast<SwTextFrame const*>(pAnch)->MapViewToModel(TextFrameIndex(0)));
2009  aPos.nNode = *pos.first;
2010  }
2011  else
2012  {
2013  aPos.nNode = *static_cast<const SwNoTextFrame*>(pAnch)->GetNode();
2014  }
2015 
2016  // do not set in ReadnOnly-content
2017  if( aPos.nNode.GetNode().IsProtect() )
2018  // then only page bound. Or should we
2019  // search the next not-readonly position?
2020  bAtPage = true;
2021  else
2022  {
2023  aAnch.SetType( RndStdIds::FLY_AT_PARA );
2024  aAnch.SetAnchor( &aPos );
2025  }
2026  }
2027 
2028  if( bAtPage )
2029  {
2030  pPage = pAnch ? pAnch->FindPageFrame() : GetLayout()->GetPageAtPos(aPoint);
2031 
2032  aAnch.SetType( RndStdIds::FLY_AT_PAGE );
2033  aAnch.SetPageNum( pPage->GetPhyPageNum() );
2034  pAnch = pPage; // page becomes an anchor
2035  }
2036  }
2037 
2039  RES_SURROUND, RES_ANCHOR> aSet( GetDoc()->GetAttrPool() );
2040  aSet.Put( aAnch );
2041 
2042  // OD 2004-03-30 #i26791# - determine relative object position
2043  SwTwips nXOffset;
2044  SwTwips nYOffset = rBound.Top() - pAnch->getFrameArea().Top();
2045  {
2046  if( pAnch->IsVertical() )
2047  {
2048  nXOffset = nYOffset;
2049  nYOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
2050  }
2051  else if( pAnch->IsRightToLeft() )
2052  nXOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
2053  else
2054  nXOffset = rBound.Left() - pAnch->getFrameArea().Left();
2055  if (pAnch->IsTextFrame())
2056  {
2057  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2058  if (pTmp->IsFollow())
2059  {
2060  do {
2061  pTmp = pTmp->FindMaster();
2062  OSL_ENSURE(pTmp, "Where's my Master?");
2063  // OD 2004-03-30 #i26791# - correction: add frame area height
2064  // of master frames.
2065  nYOffset += pTmp->IsVertical() ?
2066  pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height();
2067  } while (pTmp->IsFollow());
2068  }
2069 
2070  nYOffset -= pTmp->GetBaseVertOffsetForFly(false);
2071  }
2072  }
2073 
2074  if( SdrInventor::Default == rSdrObj.GetObjInventor() && rSdrObj.GetObjIdentifier() == SdrObjKind::NONE )
2075  {
2076  // For OBJ_NONE a fly is inserted.
2077  const tools::Long nWidth = rBound.Right() - rBound.Left();
2078  const tools::Long nHeight= rBound.Bottom() - rBound.Top();
2079  aSet.Put( SwFormatFrameSize( SwFrameSize::Minimum, std::max( nWidth, tools::Long(MINFLY) ),
2080  std::max( nHeight, tools::Long(MINFLY) )));
2081 
2082  SwFormatHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
2083  SwFormatVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
2084  aSet.Put( SwFormatSurround( css::text::WrapTextMode_PARALLEL ) );
2085  aSet.Put( aHori );
2086  aSet.Put( aVert );
2087 
2088  // Quickly store the square
2089  const SwRect aFlyRect( rBound );
2090 
2091  // Throw away generated object, now the fly can nicely
2092  // via the available SS be generated.
2093  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); // see above
2094  // #i52858# - method name changed
2095  SdrPage *pPg = getIDocumentDrawModelAccess().GetOrCreateDrawModel()->GetPage( 0 );
2096  if( !pPg )
2097  {
2098  SdrModel* pTmpSdrModel = getIDocumentDrawModelAccess().GetDrawModel();
2099  auto pNewPage = pTmpSdrModel->AllocPage( false );
2100  pTmpSdrModel->InsertPage( pNewPage.get() );
2101  pPg = pNewPage.get();
2102  }
2103  pPg->RecalcObjOrdNums();
2104  SdrObject* pRemovedObject = pPg->RemoveObject( rSdrObj.GetOrdNumDirect() );
2105  SdrObject::Free( pRemovedObject );
2106  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
2107 
2108  SwFlyFrame* pFlyFrame;
2109  if( NewFlyFrame( aSet, true ) &&
2110  ::GetHtmlMode( GetDoc()->GetDocShell() ) &&
2111  nullptr != ( pFlyFrame = GetSelectedFlyFrame() ))
2112  {
2113  SfxItemSetFixed<RES_VERT_ORIENT, RES_HORI_ORIENT> aHtmlSet( GetDoc()->GetAttrPool() );
2114  // horizontal orientation:
2115  const bool bLeftFrame = aFlyRect.Left() <
2116  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Left(),
2117  bLeftPrt = aFlyRect.Left() + aFlyRect.Width() <
2118  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width()/2;
2119  if( bLeftFrame || bLeftPrt )
2120  {
2121  aHori.SetHoriOrient( text::HoriOrientation::LEFT );
2122  aHori.SetRelationOrient( bLeftFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
2123  }
2124  else
2125  {
2126  const bool bRightFrame = aFlyRect.Left() >
2127  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width();
2128  aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
2129  aHori.SetRelationOrient( bRightFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
2130  }
2131  aHtmlSet.Put( aHori );
2132  aVert.SetVertOrient( text::VertOrientation::TOP );
2133  aVert.SetRelationOrient( text::RelOrientation::PRINT_AREA );
2134  aHtmlSet.Put( aVert );
2135 
2136  GetDoc()->SetAttr( aHtmlSet, *pFlyFrame->GetFormat() );
2137  }
2138  }
2139  else
2140  {
2141  if (rSdrObj.GetName().isEmpty())
2142  {
2143  bool bRestore = GetDoc()->GetIDocumentUndoRedo().DoesDrawUndo();
2144  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
2145  rSdrObj.MakeNameUnique();
2146  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(bRestore);
2147  }
2148 
2149  aSet.Put( aAnch );
2150  aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
2151  // OD 2004-03-30 #i26791# - set horizontal position
2152  SwFormatHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
2153  aSet.Put( aHori );
2154  // OD 2004-03-30 #i26791# - set vertical position
2155  if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
2156  {
2157  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2158  do {
2159  pTmp = pTmp->FindMaster();
2160  assert(pTmp && "Where's my Master?");
2161  nYOffset += pTmp->IsVertical() ?
2162  pTmp->getFramePrintArea().Width() : pTmp->getFramePrintArea().Height();
2163  } while ( pTmp->IsFollow() );
2164  }
2165  SwFormatVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
2166  aSet.Put( aVert );
2167  SwDrawFrameFormat* pFormat = static_cast<SwDrawFrameFormat*>(getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::DRAW_OBJECT, &aSet ));
2168  // #i36010# - set layout direction of the position
2169  pFormat->SetPositionLayoutDir(
2170  text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
2171  // #i44344#, #i44681# - positioning attributes already set
2172  pFormat->PosAttrSet();
2173  pFormat->SetName(rSdrObj.GetName());
2174 
2175  SwDrawContact *pContact = new SwDrawContact( pFormat, &rSdrObj );
2176  // #i35635#
2177  pContact->MoveObjToVisibleLayer( &rSdrObj );
2178  if( bCharBound )
2179  {
2180  OSL_ENSURE( aAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR, "wrong AnchorType" );
2181  SwTextNode *pNd = aAnch.GetContentAnchor()->nNode.GetNode().GetTextNode();
2182  SwFormatFlyCnt aFormat( pFormat );
2183  pNd->InsertItem(aFormat,
2184  aAnch.GetContentAnchor()->nContent.GetIndex(), 0 );
2186  aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER );
2187  pFormat->SetFormatAttr( aVertical );
2188  }
2189  if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
2190  {
2191  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2192  do {
2193  pTmp = pTmp->FindMaster();
2194  OSL_ENSURE( pTmp, "Where's my Master?" );
2195  } while( pTmp->IsFollow() );
2196  pAnch = pTmp;
2197  }
2198 
2199  pContact->ConnectToLayout();
2200 
2201  // mark object at frame the object is inserted at.
2202  {
2203  SdrObject* pMarkObj = pContact->GetDrawObjectByAnchorFrame( *pAnch );
2204  if ( pMarkObj )
2205  {
2206  Imp()->GetDrawView()->MarkObj( pMarkObj, Imp()->GetPageView() );
2207  }
2208  else
2209  {
2210  Imp()->GetDrawView()->MarkObj( &rSdrObj, Imp()->GetPageView() );
2211  }
2212  }
2213  }
2214 
2215  GetDoc()->getIDocumentState().SetModified();
2216 
2217  KillPams();
2218  EndAllActionAndCall();
2219  UnlockPaint();
2220  return true;
2221 }
2222 
2224 {
2225  OSL_ENSURE( Imp()->HasDrawView(), "BreakCreate without DrawView?" );
2226  Imp()->GetDrawView()->BrkCreateObj();
2227  ::FrameNotify( this, FLY_DRAG_END );
2228 }
2229 
2231 {
2232  return Imp()->HasDrawView() && Imp()->GetDrawView()->IsCreateObj();
2233 }
2234 
2235 bool SwFEShell::BeginMark( const Point &rPos )
2236 {
2237  if ( !Imp()->HasDrawView() )
2238  Imp()->MakeDrawView();
2239 
2240  if ( GetPageNumber( rPos ) )
2241  {
2242  SwDrawView* pDView = Imp()->GetDrawView();
2243 
2244  if (pDView->HasMarkablePoints())
2245  return pDView->BegMarkPoints( rPos );
2246  else
2247  {
2248  pDView->BegMarkObj( rPos );
2249  return true;
2250  }
2251  }
2252  else
2253  return false;
2254 }
2255 
2256 void SwFEShell::MoveMark( const Point &rPos )
2257 {
2258  OSL_ENSURE( Imp()->HasDrawView(), "MoveMark without DrawView?" );
2259 
2260  if ( GetPageNumber( rPos ) )
2261  {
2262  ScrollTo( rPos );
2263  SwDrawView* pDView = Imp()->GetDrawView();
2264 
2265  if (pDView->IsInsObjPoint())
2266  pDView->MovInsObjPoint( rPos );
2267  else if (pDView->IsMarkPoints())
2268  pDView->MovMarkPoints( rPos );
2269  else
2270  pDView->MovAction( rPos );
2271  }
2272 }
2273 
2275 {
2276  bool bRet = false;
2277  OSL_ENSURE( Imp()->HasDrawView(), "EndMark without DrawView?" );
2278 
2279  if (Imp()->GetDrawView()->IsMarkObj())
2280  {
2281  bRet = Imp()->GetDrawView()->EndMarkObj();
2282 
2283  if ( bRet )
2284  {
2285  bool bShowHdl = false;
2286  SwDrawView* pDView = Imp()->GetDrawView();
2287  // frames are not selected this way, except when
2288  // it is only one frame
2289  SdrMarkList &rMrkList = const_cast<SdrMarkList&>(pDView->GetMarkedObjectList());
2290  SwFlyFrame* pOldSelFly = ::GetFlyFromMarked( &rMrkList, this );
2291 
2292  if ( rMrkList.GetMarkCount() > 1 )
2293  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2294  {
2295  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2296  if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
2297  {
2298  if ( !bShowHdl )
2299  {
2300  bShowHdl = true;
2301  }
2302  rMrkList.DeleteMark( i );
2303  --i; // no exceptions
2304  }
2305  }
2306 
2307  if( bShowHdl )
2308  {
2309  pDView->MarkListHasChanged();
2310  pDView->AdjustMarkHdl();
2311  }
2312 
2313  if ( rMrkList.GetMarkCount() )
2314  ::lcl_GrabCursor(this, pOldSelFly);
2315  else
2316  bRet = false;
2317  }
2318  if ( bRet )
2319  ::FrameNotify( this, FLY_DRAG_START );
2320  }
2321  else
2322  {
2323  if (Imp()->GetDrawView()->IsMarkPoints())
2324  bRet = Imp()->GetDrawView()->EndMarkPoints();
2325  }
2326 
2327  SetChainMarker();
2328  return bRet;
2329 }
2330 
2332 {
2333  RndStdIds nRet = RndStdIds(SHRT_MAX);
2334  if ( Imp()->HasDrawView() )
2335  {
2336  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2337  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2338  {
2339  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2340  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
2341  {
2342  nRet = RndStdIds::UNKNOWN;
2343  break;
2344  }
2345  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2346  RndStdIds nId = pContact->GetFormat()->GetAnchor().GetAnchorId();
2347  if ( nRet == RndStdIds(SHRT_MAX) )
2348  nRet = nId;
2349  else if ( nRet != nId )
2350  {
2351  nRet = RndStdIds::UNKNOWN;
2352  break;
2353  }
2354  }
2355  }
2356  if ( nRet == RndStdIds(SHRT_MAX) )
2357  nRet = RndStdIds::UNKNOWN;
2358  return nRet;
2359 }
2360 
2361 void SwFEShell::ChgAnchor( RndStdIds eAnchorId, bool bSameOnly, bool bPosCorr )
2362 {
2363  OSL_ENSURE( Imp()->HasDrawView(), "ChgAnchor without DrawView?" );
2364  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2365  if( rMrkList.GetMarkCount() &&
2367  {
2368  StartAllAction();
2369 
2370  if( GetDoc()->ChgAnchor( rMrkList, eAnchorId, bSameOnly, bPosCorr ))
2371  Imp()->GetDrawView()->UnmarkAll();
2372 
2373  EndAllAction();
2374 
2375  ::FrameNotify( this );
2376  }
2377 }
2378 
2380 {
2381  OSL_ENSURE( Imp()->HasDrawView(), "DelSelectedObj(), no DrawView available" );
2382  if ( Imp()->HasDrawView() )
2383  {
2384  StartAllAction();
2385  Imp()->GetDrawView()->DeleteMarked();
2386  EndAllAction();
2387  ::FrameNotify( this, FLY_DRAG_END );
2388  }
2389 }
2390 
2391 // For the statusline to request the current conditions
2393 {
2394  tools::Rectangle aRect;
2395  if ( Imp()->HasDrawView() )
2396  {
2397  if ( Imp()->GetDrawView()->IsAction() )
2398  Imp()->GetDrawView()->TakeActionRect( aRect );
2399  else
2400  aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2401  }
2402  return aRect.GetSize();
2403 }
2404 
2406 {
2407  const SdrView *pView = Imp()->GetDrawView();
2408  OSL_ENSURE( pView, "GetAnchorObjDiff without DrawView?" );
2409 
2410  tools::Rectangle aRect;
2411  if ( Imp()->GetDrawView()->IsAction() )
2412  Imp()->GetDrawView()->TakeActionRect( aRect );
2413  else
2414  aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2415 
2416  Point aRet( aRect.TopLeft() );
2417 
2418  if ( IsFrameSelected() )
2419  {
2420  SwFlyFrame *pFly = GetSelectedFlyFrame();
2421  aRet -= pFly->GetAnchorFrame()->getFrameArea().Pos();
2422  }
2423  else
2424  {
2425  const SdrObject *pObj = pView->GetMarkedObjectList().GetMarkCount() == 1 ?
2426  pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() : nullptr;
2427  if ( pObj )
2428  aRet -= pObj->GetAnchorPos();
2429  }
2430 
2431  return aRet;
2432 }
2433 
2435 {
2436  OSL_ENSURE( Imp()->GetDrawView(), "GetObjAbsPos() without DrawView?" );
2437  return Imp()->GetDrawView()->GetDragStat().GetActionRect().TopLeft();
2438 }
2439 
2440 bool SwFEShell::IsGroupSelected(bool bAllowDiagams)
2441 {
2442  if ( IsObjSelected() )
2443  {
2444  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2445  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2446  {
2447  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2448  // consider 'virtual' drawing objects.
2449  // Thus, use corresponding method instead of checking type.
2450  if ( pObj->IsGroupObject() &&
2451  // --> #i38505# No ungroup allowed for 3d objects
2452  !pObj->Is3DObj() &&
2453  RndStdIds::FLY_AS_CHAR != static_cast<SwDrawContact*>(GetUserCall(pObj))->
2454  GetFormat()->GetAnchor().GetAnchorId() )
2455  {
2456  if(!bAllowDiagams)
2457  {
2458  // Don't allow enter Diagrams
2459  auto* pGroup(dynamic_cast<SdrObjGroup*>(pObj));
2460  if(nullptr != pGroup && pGroup->isDiagram())
2461  {
2462  return false;
2463  }
2464  }
2465 
2466  return true;
2467  }
2468  }
2469  }
2470  return false;
2471 }
2472 
2473 namespace
2474 {
2475  bool HasSuitableGroupingAnchor(const SdrObject* pObj)
2476  {
2477  bool bSuitable = true;
2478  SwFrameFormat* pFrameFormat(::FindFrameFormat(const_cast<SdrObject*>(pObj)));
2479  if (!pFrameFormat)
2480  {
2481  OSL_FAIL( "<HasSuitableGroupingAnchor> - missing frame format" );
2482  bSuitable = false;
2483  }
2484  else if (RndStdIds::FLY_AS_CHAR == pFrameFormat->GetAnchor().GetAnchorId())
2485  {
2486  bSuitable = false;
2487  }
2488  return bSuitable;
2489  }
2490 }
2491 
2492 // Change return type.
2493 // Adjustments for drawing objects in header/footer:
2494 // allow group, only if all selected objects are in the same header/footer
2495 // or not in header/footer.
2497 {
2498  bool bIsGroupAllowed = false;
2499  if ( IsObjSelected() > 1 )
2500  {
2501  bIsGroupAllowed = true;
2502  const SdrObject* pUpGroup = nullptr;
2503  const SwFrame* pHeaderFooterFrame = nullptr;
2504  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2505  for ( size_t i = 0; bIsGroupAllowed && i < rMrkList.GetMarkCount(); ++i )
2506  {
2507  const SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2508  if ( i )
2509  bIsGroupAllowed = pObj->getParentSdrObjectFromSdrObject() == pUpGroup;
2510  else
2511  pUpGroup = pObj->getParentSdrObjectFromSdrObject();
2512 
2513  if ( bIsGroupAllowed )
2514  bIsGroupAllowed = HasSuitableGroupingAnchor(pObj);
2515 
2516  // check, if all selected objects are in the
2517  // same header/footer or not in header/footer.
2518  if ( bIsGroupAllowed )
2519  {
2520  const SwFrame* pAnchorFrame = nullptr;
2521  if ( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
2522  {
2523  const SwFlyFrame* pFlyFrame = pVirtFlyDrawObj->GetFlyFrame();
2524  if ( pFlyFrame )
2525  {
2526  pAnchorFrame = pFlyFrame->GetAnchorFrame();
2527  }
2528  }
2529  else
2530  {
2531  SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
2532  if ( pDrawContact )
2533  {
2534  pAnchorFrame = pDrawContact->GetAnchorFrame( pObj );
2535  }
2536  }
2537  if ( pAnchorFrame )
2538  {
2539  if ( i )
2540  {
2541  bIsGroupAllowed =
2542  ( pAnchorFrame->FindFooterOrHeader() == pHeaderFooterFrame );
2543  }
2544  else
2545  {
2546  pHeaderFooterFrame = pAnchorFrame->FindFooterOrHeader();
2547  }
2548  }
2549  }
2550  }
2551  }
2552 
2553  return bIsGroupAllowed;
2554 }
2555 
2557 {
2558  bool bIsUnGroupAllowed = false;
2559 
2560  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2561  for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i)
2562  {
2563  const SdrObject* pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
2564  bIsUnGroupAllowed = HasSuitableGroupingAnchor(pObj);
2565  if (!bIsUnGroupAllowed)
2566  break;
2567  }
2568 
2569  return bIsUnGroupAllowed;
2570 }
2571 
2572 // The group gets the anchor and the contactobject of the first in the selection
2574 {
2575  if ( IsGroupAllowed() )
2576  {
2577  StartAllAction();
2578  StartUndo( SwUndoId::START );
2579 
2580  GetDoc()->GroupSelection( *Imp()->GetDrawView() );
2581 
2583  EndAllAction();
2584  }
2585 }
2586 
2587 // The individual objects get a copy of the anchor and the contactobject of the group
2589 {
2590  if ( IsGroupSelected(true) )
2591  {
2592  StartAllAction();
2593  StartUndo( SwUndoId::START );
2594 
2595  GetDoc()->UnGroupSelection( *Imp()->GetDrawView() );
2596 
2598  EndAllAction();
2599  }
2600 }
2601 
2602 void SwFEShell::MirrorSelection( bool bHorizontal )
2603 {
2604  SdrView *pView = Imp()->GetDrawView();
2605  if ( IsObjSelected() && pView->IsMirrorAllowed() )
2606  {
2607  if ( bHorizontal )
2608  pView->MirrorAllMarkedHorizontal();
2609  else
2610  pView->MirrorAllMarkedVertical();
2611  }
2612 }
2613 
2614 // jump to named frame (Graphic/OLE)
2615 
2616 bool SwFEShell::GotoFly( const OUString& rName, FlyCntType eType, bool bSelFrame )
2617 {
2618  bool bRet = false;
2619  static SwNodeType const aChkArr[ 4 ] = {
2620  /* FLYCNTTYPE_ALL */ SwNodeType::NONE,
2621  /* FLYCNTTYPE_FRM */ SwNodeType::Text,
2622  /* FLYCNTTYPE_GRF */ SwNodeType::Grf,
2623  /* FLYCNTTYPE_OLE */ SwNodeType::Ole
2624  };
2625 
2626  const SwFlyFrameFormat* pFlyFormat = mxDoc->FindFlyByName( rName, aChkArr[ eType]);
2627  if( pFlyFormat )
2628  {
2629  CurrShell aCurr( this );
2630 
2631  SwFlyFrame* pFrame = SwIterator<SwFlyFrame,SwFormat>( *pFlyFormat ).First();
2632  if( pFrame )
2633  {
2634  if( bSelFrame )
2635  {
2636  // first make visible, to get a11y events in proper order
2637  if (!ActionPend())
2638  MakeVisible( pFrame->getFrameArea() );
2639  SelectObj( pFrame->getFrameArea().Pos(), 0, pFrame->GetVirtDrawObj() );
2640  }
2641  else
2642  {
2643  SwContentFrame *pCFrame = pFrame->ContainsContent();
2644  if ( pCFrame )
2645  {
2646  ClearMark();
2647  SwPaM* pCursor = GetCursor();
2648 
2649  if (pCFrame->IsTextFrame())
2650  {
2651  *pCursor->GetPoint() = static_cast<SwTextFrame *>(pCFrame)
2652  ->MapViewToModelPos(TextFrameIndex(0));
2653  }
2654  else
2655  {
2656  assert(pCFrame->IsNoTextFrame());
2657  SwContentNode *const pCNode = static_cast<SwNoTextFrame *>(pCFrame)->GetNode();
2658 
2659  pCursor->GetPoint()->nNode = *pCNode;
2660  pCursor->GetPoint()->nContent.Assign( pCNode, 0 );
2661  }
2662 
2663  SwRect& rChrRect = const_cast<SwRect&>(GetCharRect());
2664  rChrRect = pFrame->getFramePrintArea();
2665  rChrRect.Pos() += pFrame->getFrameArea().Pos();
2666  GetCursorDocPos() = rChrRect.Pos();
2667  }
2668  }
2669  bRet = true;
2670  }
2671  }
2672  return bRet;
2673 }
2674 
2675 size_t SwFEShell::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const
2676 {
2677  return GetDoc()->GetFlyCount(eType, bIgnoreTextBoxes);
2678 }
2679 
2680 const SwFrameFormat* SwFEShell::GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes ) const
2681 {
2682  return GetDoc()->GetFlyNum(nIdx, eType, bIgnoreTextBoxes);
2683 }
2684 
2685 std::vector<SwFrameFormat const*> SwFEShell::GetFlyFrameFormats(
2686  FlyCntType const eType, bool const bIgnoreTextBoxes)
2687 {
2688  return GetDoc()->GetFlyFrameFormats(eType, bIgnoreTextBoxes);
2689 }
2690 
2691 // show the current selected object
2693 {
2694  if ( Imp()->HasDrawView() &&
2695  Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )
2696  {
2697  GetCurrFrame(); // just to trigger formatting in case the selected object is not formatted.
2698  MakeVisible( SwRect(Imp()->GetDrawView()->GetAllMarkedRect()) );
2699  }
2700  else
2702 }
2703 
2704 // how is the selected object protected?
2706 {
2708  const bool bParent(eType & FlyProtectFlags::Parent);
2709  if( Imp()->HasDrawView() )
2710  {
2711  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2712  for( size_t i = rMrkList.GetMarkCount(); i; )
2713  {
2714  SdrObject *pObj = rMrkList.GetMark( --i )->GetMarkedSdrObj();
2715  if (!pObj)
2716  {
2717  continue;
2718  }
2719 
2720  if( !bParent )
2721  {
2722  nChk |= ( pObj->IsMoveProtect() ? FlyProtectFlags::Pos : FlyProtectFlags::NONE ) |
2724 
2725  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
2726  {
2727  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
2728  if ( (FlyProtectFlags::Content & eType) && pFly->GetFormat()->GetProtect().IsContentProtected() )
2729  nChk |= FlyProtectFlags::Content;
2730 
2731  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
2732  {
2733  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
2734  uno::Reference < embed::XEmbeddedObject > xObj( pNd ? pNd->GetOLEObj().GetOleRef() : nullptr );
2735  if ( xObj.is() )
2736  {
2737  // TODO/LATER: use correct aspect
2738  const bool bNeverResize = (embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ));
2739  if ( ( (FlyProtectFlags::Content & eType) || (FlyProtectFlags::Size & eType) ) && bNeverResize )
2740  {
2741  nChk |= FlyProtectFlags::Size;
2742  nChk |= FlyProtectFlags::Fixed;
2743  }
2744 
2745  // set FlyProtectFlags::Pos if it is a Math object anchored 'as char' and baseline alignment is activated
2746  const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
2747  && RndStdIds::FLY_AS_CHAR == pFly->GetFormat()->GetAnchor().GetAnchorId()
2748  && mxDoc->GetDocumentSettingManager().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT );
2749  if ((FlyProtectFlags::Pos & eType) && bProtectMathPos)
2750  nChk |= FlyProtectFlags::Pos;
2751  }
2752  }
2753  }
2754  nChk &= eType;
2755  if( nChk == eType )
2756  return eType;
2757  }
2758  const SwFrame* pAnch;
2759  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
2760  pAnch = pVirtO->GetFlyFrame()->GetAnchorFrame();
2761  else
2762  {
2763  SwDrawContact* pTmp = static_cast<SwDrawContact*>(GetUserCall(pObj));
2764  pAnch = pTmp ? pTmp->GetAnchorFrame( pObj ) : nullptr;
2765  }
2766  if( pAnch && pAnch->IsProtected() )
2767  return eType;
2768  }
2769  }
2770  return nChk;
2771 }
2772 
2774 {
2775  if ( !IsObjSelected() )
2776  return false;
2777 
2778  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2779  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2780  {
2781  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2782  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2783  // --> make code robust
2784  OSL_ENSURE( pContact, "<SwFEShell::GetObjAttr(..)> - missing <pContact>." );
2785  if ( pContact )
2786  {
2787  if ( i )
2788  rSet.MergeValues( pContact->GetFormat()->GetAttrSet() );
2789  else
2790  rSet.Put( pContact->GetFormat()->GetAttrSet() );
2791  }
2792  }
2793  return true;
2794 }
2795 
2797 {
2798  CurrShell aCurr( this );
2799 
2800  if ( !rSet.Count() )
2801  {
2802  OSL_ENSURE( false, "SetObjAttr, empty set." );
2803  return;
2804  }
2805 
2806  StartAllAction();
2807  StartUndo( SwUndoId::INSATTR );
2808 
2809  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2810  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2811  {
2812  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2813  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2814  GetDoc()->SetAttr( rSet, *pContact->GetFormat() );
2815  }
2816 
2818  EndAllActionAndCall();
2819  GetDoc()->getIDocumentState().SetModified();
2820 }
2821 
2823 {
2824  return Imp()->GetDrawView()->IsAlignPossible();
2825 }
2826 
2828 {
2829  CurrShell aCurr( this );
2830 
2831  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2832  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2833  {
2834  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2835  if ( !GetUserCall(pObj) )
2836  {
2837  const tools::Rectangle &rBound = pObj->GetSnapRect();
2838  const Point aPt( rBound.TopLeft() );
2839  const SwFrame *pPage = GetLayout()->Lower();
2840  const SwFrame *pLast = pPage;
2841  while ( pPage && !pPage->getFrameArea().Contains( aPt ) )
2842  {
2843  if ( aPt.Y() > pPage->getFrameArea().Bottom() )
2844  pLast = pPage;
2845  pPage = pPage->GetNext();
2846  }
2847  if ( !pPage )
2848  pPage = pLast;
2849  OSL_ENSURE( pPage, "Page not found." );
2850 
2851  SwFormatAnchor aAnch;
2852  {
2853  const SwContentFrame *const pAnch = ::FindAnchor(pPage, aPt, true);
2854  SwPosition aPos( pAnch->IsTextFrame()
2855  ? *static_cast<SwTextFrame const*>(pAnch)->GetTextNodeForParaProps()
2856  : *static_cast<SwNoTextFrame const*>(pAnch)->GetNode() );
2857  aAnch.SetType( RndStdIds::FLY_AT_PARA );
2858  aAnch.SetAnchor( &aPos );
2859  const_cast<SwRect&>(GetCharRect()).Pos() = aPt;
2860  }
2861 
2862  // First the action here, to assure GetCharRect delivers current values.
2863  StartAllAction();
2864 
2866  RES_SURROUND, RES_ANCHOR> aSet( GetAttrPool() );
2867  aSet.Put( aAnch );
2868  aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
2869  SwFrameFormat* pFormat = getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::DRAW_OBJECT, &aSet );
2870 
2871  SwDrawContact *pContact = new SwDrawContact(
2872  static_cast<SwDrawFrameFormat*>(pFormat), pObj );
2873 
2874  // #i35635#
2875  pContact->MoveObjToVisibleLayer( pObj );
2876  pContact->ConnectToLayout();
2877 
2878  EndAllAction();
2879  }
2880  }
2881 }
2882 
2884 {
2885  GetDoc()->SetCalcFieldValueHdl(pOutliner);
2886 }
2887 
2889  const Point &rPt ) const
2890 {
2891  rRect.Clear();
2892 
2893  // The source is not allowed to have a follow.
2894  const SwFormatChain &rChain = rSource.GetChain();
2895  if ( rChain.GetNext() )
2897 
2899  if( Imp()->HasDrawView() )
2900  {
2901  SdrPageView* pPView;
2902  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
2903  const auto nOld = pDView->GetHitTolerancePixel();
2904  pDView->SetHitTolerancePixel( 0 );
2905  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
2906  SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
2907  if (pDrawObj)
2908  {
2909  SwFlyFrame *pFly = pDrawObj->GetFlyFrame();
2910  rRect = pFly->getFrameArea();
2911 
2912  // Target and source should not be equal and the list
2913  // should not be cyclic
2914  SwFrameFormat *pFormat = pFly->GetFormat();
2915  nRet = GetDoc()->Chainable(rSource, *pFormat);
2916  }
2917  pDView->SetHitTolerancePixel( nOld );
2918  }
2919  return nRet;
2920 }
2921 
2922 void SwFEShell::Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest )
2923 {
2924  GetDoc()->Chain(rSource, rDest);
2925 }
2926 
2927 SwChainRet SwFEShell::Chain( SwFrameFormat &rSource, const Point &rPt )
2928 {
2929  SwRect aDummy;
2930  SwChainRet nErr = Chainable( aDummy, rSource, rPt );
2931  if ( nErr == SwChainRet::OK )
2932  {
2933  StartAllAction();
2934  SdrPageView* pPView;
2935  SwDrawView *pDView = Imp()->GetDrawView();
2936  const auto nOld = pDView->GetHitTolerancePixel();
2937  pDView->SetHitTolerancePixel( 0 );
2938  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
2939  pDView->SetHitTolerancePixel( nOld );
2940  SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
2941 
2942  SwFlyFrameFormat *pFormat = pFly->GetFormat();
2943  GetDoc()->Chain(rSource, *pFormat);
2944  EndAllAction();
2945  SetChainMarker();
2946  }
2947  return nErr;
2948 }
2949 
2951 {
2952  StartAllAction();
2953  GetDoc()->Unchain(rFormat);
2954  EndAllAction();
2955 }
2956 
2958 {
2959  m_pChainFrom.reset();
2960  m_pChainTo.reset();
2961 }
2962 
2964 {
2965  bool bDelFrom = true,
2966  bDelTo = true;
2967  if ( IsFrameSelected() )
2968  {
2969  SwFlyFrame *pFly = GetSelectedFlyFrame();
2970 
2971  if ( pFly->GetPrevLink() )
2972  {
2973  bDelFrom = false;
2974  const SwFrame *pPre = pFly->GetPrevLink();
2975 
2976  Point aStart( pPre->getFrameArea().Right(), pPre->getFrameArea().Bottom());
2977  Point aEnd(pFly->getFrameArea().Pos());
2978 
2979  if (!m_pChainFrom)
2980  {
2981  m_pChainFrom.reset(
2982  new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd ));
2983  }
2984  }
2985  if ( pFly->GetNextLink() )
2986  {
2987  bDelTo = false;
2988  const SwFlyFrame *pNxt = pFly->GetNextLink();
2989 
2990  Point aStart( pFly->getFrameArea().Right(), pFly->getFrameArea().Bottom());
2991  Point aEnd(pNxt->getFrameArea().Pos());
2992 
2993  if (!m_pChainTo)
2994  {
2995  m_pChainTo.reset(
2996  new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd ));
2997  }
2998  }
2999  }
3000 
3001  if ( bDelFrom )
3002  {
3003  m_pChainFrom.reset();
3004  }
3005 
3006  if ( bDelTo )
3007  {
3008  m_pChainTo.reset();
3009  }
3010 }
3011 
3013 {
3014  SwFrame *pFrame = GetCurrFrame();
3015  // Is the cursor at this moment in a SectionFrame?
3016  if( pFrame && pFrame->IsInSct() )
3017  {
3018  SwSectionFrame* pSect = pFrame->FindSctFrame();
3019  do
3020  {
3021  // Is it the right one?
3022  if( pSect->KnowsFormat( rFormat ) )
3023  return pSect->getFrameArea().Width();
3024  // for nested areas
3025  pSect = pSect->GetUpper()->FindSctFrame();
3026  }
3027  while( pSect );
3028  }
3029  SwIterator<SwSectionFrame,SwFormat> aIter( rFormat );
3030  for ( SwSectionFrame* pSct = aIter.First(); pSct; pSct = aIter.Next() )
3031  {
3032  if( !pSct->IsFollow() )
3033  {
3034  return pSct->getFrameArea().Width();
3035  }
3036  }
3037  return 0;
3038 }
3039 
3040 void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rectangle& rRect,
3041  sal_uInt16 nSlotId)
3042 {
3043  SdrView* pDrawView = GetDrawView();
3044  SdrModel* pDrawModel = pDrawView->GetModel();
3046  *pDrawModel,
3047  SdrInventor::Default,
3048  eSdrObjectKind);
3049 
3050  if(pObj)
3051  {
3052  tools::Rectangle aRect(rRect);
3053  if(SdrObjKind::CircleArc == eSdrObjectKind || SdrObjKind::CircleCut == eSdrObjectKind)
3054  {
3055  // force quadratic
3056  if(aRect.GetWidth() > aRect.GetHeight())
3057  {
3058  aRect = tools::Rectangle(
3059  Point(aRect.Left() + ((aRect.GetWidth() - aRect.GetHeight()) / 2), aRect.Top()),
3060  Size(aRect.GetHeight(), aRect.GetHeight()));
3061  }
3062  else
3063  {
3064  aRect = tools::Rectangle(
3065  Point(aRect.Left(), aRect.Top() + ((aRect.GetHeight() - aRect.GetWidth()) / 2)),
3066  Size(aRect.GetWidth(), aRect.GetWidth()));
3067  }
3068  }
3069  pObj->SetLogicRect(aRect);
3070 
3071  Point aStart = aRect.TopLeft();
3072  Point aEnd = aRect.BottomRight();
3073 
3074  if(dynamic_cast<const SdrCircObj*>( pObj) != nullptr)
3075  {
3076  SfxItemSet aAttr(pDrawModel->GetItemPool());
3077  aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
3078  aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
3079  pObj->SetMergedItemSet(aAttr);
3080  }
3081  else if(auto pPathObj = dynamic_cast<SdrPathObj*>( pObj))
3082  {
3084 
3085  switch(eSdrObjectKind)
3086  {
3087  case SdrObjKind::PathLine:
3088  case SdrObjKind::PathFill:
3089  {
3090  basegfx::B2DPolygon aInnerPoly;
3091 
3092  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3093 
3094  const basegfx::B2DPoint aCenterBottom(aRect.Center().getX(), aRect.Bottom());
3095  aInnerPoly.appendBezierSegment(
3096  aCenterBottom,
3097  aCenterBottom,
3098  basegfx::B2DPoint(aRect.Center().getX(), aRect.Center().getY()));
3099 
3100  const basegfx::B2DPoint aCenterTop(aRect.Center().getX(), aRect.Top());
3101  aInnerPoly.appendBezierSegment(
3102  aCenterTop,
3103  aCenterTop,
3104  basegfx::B2DPoint(aRect.Right(), aRect.Top()));
3105 
3106  aInnerPoly.setClosed(true);
3107  aPoly.append(aInnerPoly);
3108  }
3109  break;
3110  case SdrObjKind::FreehandLine:
3111  case SdrObjKind::FreehandFill:
3112  {
3113  basegfx::B2DPolygon aInnerPoly;
3114 
3115  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3116 
3117  aInnerPoly.appendBezierSegment(
3118  basegfx::B2DPoint(aRect.Left(), aRect.Top()),
3119  basegfx::B2DPoint(aRect.Center().getX(), aRect.Top()),
3120  basegfx::B2DPoint(aRect.Center().getX(), aRect.Center().getY()));
3121 
3122  aInnerPoly.appendBezierSegment(
3123  basegfx::B2DPoint(aRect.Center().getX(), aRect.Bottom()),
3124  basegfx::B2DPoint(aRect.Right(), aRect.Bottom()),
3125  basegfx::B2DPoint(aRect.Right(), aRect.Top()));
3126 
3127  aInnerPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
3128  aInnerPoly.setClosed(true);
3129  aPoly.append(aInnerPoly);
3130  }
3131  break;
3132  case SdrObjKind::Polygon:
3133  case SdrObjKind::PolyLine:
3134  {
3135  basegfx::B2DPolygon aInnerPoly;
3136  sal_Int32 nWdt(aRect.GetWidth());
3137  sal_Int32 nHgt(aRect.GetHeight());
3138 
3139  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3140  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 30) / 100, aRect.Top() + (nHgt * 70) / 100));
3141  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top() + (nHgt * 15) / 100));
3142  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 65) / 100, aRect.Top()));
3143  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + nWdt, aRect.Top() + (nHgt * 30) / 100));
3144  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 50) / 100));
3145  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 75) / 100));
3146  aInnerPoly.append(basegfx::B2DPoint(aRect.Bottom(), aRect.Right()));
3147 
3148  if(SdrObjKind::PolyLine == eSdrObjectKind)
3149  {
3150  aInnerPoly.append(basegfx::B2DPoint(aRect.Center().getX(), aRect.Bottom()));
3151  }
3152  else
3153  {
3154  aInnerPoly.setClosed(true);
3155  }
3156 
3157  aPoly.append(aInnerPoly);
3158  }
3159  break;
3160  case SdrObjKind::Line :
3161  {
3162  sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
3163  basegfx::B2DPolygon aTempPoly;
3164  aTempPoly.append(basegfx::B2DPoint(aRect.TopLeft().getX(), nYMiddle));
3165  aTempPoly.append(basegfx::B2DPoint(aRect.BottomRight().getX(), nYMiddle));
3166  aPoly.append(aTempPoly);
3167 
3169  SetLineEnds(aAttr, *pObj, nSlotId);
3170  pObj->SetMergedItemSet(aAttr);
3171  }
3172  break;
3173  default:
3174  break;
3175  }
3176 
3177  pPathObj->SetPathPoly(aPoly);
3178  }
3179  else if(auto pMeasureObj = dynamic_cast<SdrMeasureObj*>( pObj))
3180  {
3181  sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
3182  pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
3183  pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1);
3184 
3186  SetLineEnds(aAttr, *pObj, nSlotId);
3187  pObj->SetMergedItemSet(aAttr);
3188  }
3189  else if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj))
3190  {
3191  bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
3192  SID_DRAW_CAPTION_VERTICAL == nSlotId );
3193  pCaptionObj->SetVerticalWriting(bVerticalText);
3194  if(bVerticalText)
3195  {
3196  SfxItemSet aSet(pObj->GetMergedItemSet());
3199  pObj->SetMergedItemSet(aSet);
3200  }
3201 
3202  pCaptionObj->SetLogicRect(aRect);
3203  pCaptionObj->SetTailPos(
3204  aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
3205  }
3206  else if(auto pText = dynamic_cast<SdrTextObj*>( pObj))
3207  {
3208  pText->SetLogicRect(aRect);
3209 
3210  bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotId);
3211  bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nSlotId);
3212 
3213  pText->SetVerticalWriting(bVertical);
3214 
3215  if(bVertical)
3216  {
3217  SfxItemSet aSet(pDrawModel->GetItemPool());
3218  aSet.Put(makeSdrTextAutoGrowWidthItem(true));
3219  aSet.Put(makeSdrTextAutoGrowHeightItem(false));
3222  pText->SetMergedItemSet(aSet);
3223  }
3224 
3225  if(bMarquee)
3226  {
3228  aSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
3229  aSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
3230  aSet.Put( SdrTextAniKindItem( SdrTextAniKind::Slide ) );
3231  aSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) );
3232  aSet.Put( SdrTextAniCountItem( 1 ) );
3233  aSet.Put( SdrTextAniAmountItem( static_cast<sal_Int16>(GetWin()->PixelToLogic(Size(2,1)).Width())) );
3234  pObj->SetMergedItemSetAndBroadcast(aSet);
3235  }
3236  }
3237  SdrPageView* pPageView = pDrawView->GetSdrPageView();
3238  SdrCreateView::SetupObjLayer(pPageView, pDrawView->GetActiveLayer(), pObj);
3239  // switch undo off or this combined with ImpEndCreate will cause two undos
3240  // see comment made in SwFEShell::EndCreate (we create our own undo-object!)
3241  const bool bUndo(GetDoc()->GetIDocumentUndoRedo().DoesUndo());
3242  GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
3243  pDrawView->InsertObjectAtView(pObj, *pPageView);
3244  GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo);
3245  }
3246  ImpEndCreate();
3247 }
3248 
3259 {
3260  Color aRetColor;
3261 
3262  // check, if a draw view exists
3263  OSL_ENSURE( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackground - no draw view!");
3264  if( Imp()->GetDrawView() )
3265  {
3266  // determine list of selected objects
3267  const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3268  // check, if exactly one object is selected.
3269  OSL_ENSURE( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackground - no selected object!");
3270  if ( pMrkList->GetMarkCount() == 1)
3271  {
3272  // get selected object
3273  const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3274  // check, if selected object is a shape (drawing object)
3275  OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr, "wrong usage of SwFEShell::GetShapeBackground - selected object is not a drawing object!");
3276  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr )
3277  {
3278  // determine page frame of the frame the shape is anchored.
3279  const SwFrame* pAnchorFrame =
3280  static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrame( pSdrObj );
3281  OSL_ENSURE( pAnchorFrame, "inconsistent model - no anchor at shape!");
3282  if ( pAnchorFrame )
3283  {
3284  const SwPageFrame* pPageFrame = pAnchorFrame->FindPageFrame();
3285  OSL_ENSURE( pPageFrame, "inconsistent model - no page!");
3286  if ( pPageFrame )
3287  {
3288  aRetColor = pPageFrame->GetDrawBackgroundColor();
3289  }
3290  }
3291  }
3292  }
3293  }
3294 
3295  return aRetColor;
3296 }
3297 
3307 {
3308  bool bRet = false;
3309 
3310  // check, if a draw view exists
3311  OSL_ENSURE( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackground - no draw view!");
3312  if( Imp()->GetDrawView() )
3313  {
3314  // determine list of selected objects
3315  const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3316  // check, if exactly one object is selected.
3317  OSL_ENSURE( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackground - no selected object!");
3318  if ( pMrkList->GetMarkCount() == 1)
3319  {
3320  // get selected object
3321  const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3322  // check, if selected object is a shape (drawing object)
3323  OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr, "wrong usage of SwFEShell::GetShapeBackground - selected object is not a drawing object!");
3324  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr )
3325  {
3326  // determine page frame of the frame the shape is anchored.
3327  const SwFrame* pAnchorFrame =
3328  static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrame( pSdrObj );
3329  OSL_ENSURE( pAnchorFrame, "inconsistent model - no anchor at shape!");
3330  if ( pAnchorFrame )
3331  {
3332  const SwPageFrame* pPageFrame = pAnchorFrame->FindPageFrame();
3333  OSL_ENSURE( pPageFrame, "inconsistent model - no page!");
3334  if ( pPageFrame )
3335  {
3336  bRet = pPageFrame->IsRightToLeft();
3337  }
3338  }
3339  }
3340  }
3341  }
3342 
3343  return bRet;
3344 }
3345 
3347 {
3348  Point aRet(-1, -1);
3349  const SwFrame *pPage = GetLayout()->Lower();
3350  while ( pPage && !pPage->getFrameArea().Contains( rDocPos ) )
3351  {
3352  pPage = pPage->GetNext();
3353  }
3354  if(pPage)
3355  {
3356  aRet = rDocPos - pPage->getFrameArea().TopLeft();
3357  }
3358  return aRet;
3359 }
3360 
3361 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
static bool lcl_IsControlGroup(const SdrObject *pObj)
Definition: feshview.cxx:1527
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:602
SwRect GetBoundRectOfAnchoredObj(const SdrObject *pObj)
returns the BoundRect inclusive distance of the object.
Definition: dcontact.cxx:155
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:78
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2799
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:314
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
SwChainRet Chainable(SwRect &rRect, const SwFrameFormat &rSource, const Point &rPt) const
For Chain always connect Fly specified by format with that hit by point.
Definition: feshview.cxx:2888
SAL_DLLPRIVATE const SdrMarkList * GetMarkList_() const
Get list of marked SdrObjects; helper method for GetSelFrameType, IsSelContainsControl.
Definition: feshview.cxx:598
SdrObject * GetDrawObjectByAnchorFrame(const SwFrame &_rAnchorFrame)
get drawing object ('master' or 'virtual') by frame.
Definition: dcontact.cxx:856
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
void UnGroupSelection()
The individual objects are selected, but it is possible that there are groups included.
Definition: feshview.cxx:2588
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
void KillPams()
Definition: crsrsh.cxx:1022
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4027
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
SDRTEXTVERTADJUST_TOP
virtual bool BegDragObj(const Point &rPnt, OutputDevice *pOut, SdrHdl *pHdl, short nMinMov=-3, SdrDragMethod *pForcedMeth=nullptr)
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:217
sal_Int32 nIndex
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
bool IsFollow() const
Definition: flowfrm.hxx:166
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2893
SwMove
Definition: fesh.hxx:172
size_t GetMarkCount() const
Marks a position in the document model.
Definition: pam.hxx:36
virtual const tools::Rectangle & GetCurrentBoundRect() const
bool IsAlignPossible() const
Definition: feshview.cxx:2822
void ChgAnchor(RndStdIds eAnchorId, bool bSameOnly=false, bool bPosCorr=true)
frmatr.hxx.
Definition: feshview.cxx:2361
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
bool IsUnGroupAllowed() const
Definition: feshview.cxx:2556
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:115
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:821
SwTextFrame * DynCastTextFrame()
Definition: findfrm.cxx:1895
void SetShiftPressed(bool bShiftPressed)
bool IsInSct() const
Definition: frame.hxx:967
bool IsRotationOfSwGrfNodePossible() const
Definition: feshview.cxx:1271
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:680
constexpr auto toTwips(N number, Length from)
virtual rtl::Reference< SdrPage > AllocPage(bool bMasterPage)
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:164
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:115
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
constexpr tools::Long Left() const
static SwRectFnCollection aVertical
Definition: newfrm.cxx:116
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
SwNodeIndex nNode
Definition: pam.hxx:38
Color GetDrawBackgroundColor() const
SwPageFrame::GetDrawBackgroundColor.
Definition: paintfrm.cxx:7234
bool Contains(const Point &rPOINT) const
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
void GroupSelection()
Afterwards the group is selected.
Definition: feshview.cxx:2573
void SetHitTolerancePixel(sal_uInt16 nVal)
void MirrorSelection(bool bHorizontal)
Vertical if FALSE.
Definition: feshview.cxx:2602
bool AreObjectsMarked() const
void MirrorAllMarkedHorizontal()
SdrTextObj * GetTextEditObject() const
void SelectionToHeaven()
Above document.
Definition: feshview.cxx:1236
#define MINFLY
Definition: swtypes.hxx:61
long Long
Size GetObjSize() const
Definition: feshview.cxx:2392
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
#define CNT_GRF
Definition: editsh.hxx:130
virtual void InsertPage(SdrPage *pPage, sal_uInt16 nPos=0xFFFF)
bool EndDragObj(bool bCopy=false)
void MovInsObjPoint(const Point &rPnt)
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:939
bool IsInsObjPoint() const
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1210
Check only parents.
SdrObject * GetObj(size_t nNum) const
void RecalcObjOrdNums()
SwFrame * FindPrev()
Definition: frame.hxx:1155
void CheckUnboundObjects()
Temporary work around for bug.
Definition: feshview.cxx:2827
size_t GetObjCount() const
TElementType * Next()
Definition: calbck.hxx:364
Color GetShapeBackground() const
SwFEShell::GetShapeBackground.
Definition: feshview.cxx:3258
bool KnowsFormat(const SwFormat &rFormat) const
Definition: wsfrm.cxx:331
virtual void MakeSelVisible()
show the current selected "object"
Definition: crsrsh.cxx:3084
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
virtual bool GetCharRect(SwRect &rRect, const SwPosition &rPos, SwCursorMoveState *pCMS=nullptr, bool bAllowFarAway=true) const override
Returns the view rectangle for the rPos model position.
Definition: frmcrsr.cxx:178
sal_Int16 nId
bool IsInsideSelectedObj(const Point &rPt)
returns enum values
Definition: feshview.cxx:1364
void PosAttrSet()
Definition: frmfmt.hxx:407
void InvalidatePos()
Definition: frame.hxx:1043
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
bool HasDrawView() const
Definition: vnew.cxx:358
SwNode & GetNode() const
Definition: ndindex.hxx:119
SdrInventor
SdrMark * GetMark(size_t nNum) const
void Pos(const Point &rNew)
Definition: swrect.hxx:171
SwFrame * FindNext()
Definition: frame.hxx:1141
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1296
static void Free(SdrObject *&_rpObject)
virtual SdrObjKind GetObjIdentifier() const
void ClearCharRectAndTopOfLine()
reset members and
bool EndMark()
Definition: feshview.cxx:2274
void StartCropImage()
Definition: feshview.cxx:683
EmbeddedObjectRef * pObject
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:172
void DeleteMark(size_t nNum)
virtual SdrObjList * GetSubList() const
Value in Var-direction gives minimum (can be exceeded but not be less).
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
SdrObject * GetObjAt(const Point &rPt)
Same as IsObjSelectable(), but return the object as well.
Definition: feshview.cxx:1396
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
bool ContainsSwGrfNode() const
Definition: dflyobj.cxx:357
bool BegMarkPoints(const Point &rPnt, bool bUnmark=false)
const SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false) const
Definition: feshview.cxx:2680
Point GetRelativePagePosition(const Point &rDocPos)
Convert document position into position relative to the current page.
Definition: feshview.cxx:3346
virtual const tools::Rectangle & GetSnapRect() const
SdrObjKind
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:218
Point TopLeft() const
Definition: swrect.hxx:254
void BeginDrag(const Point *pPt, bool bProp)
Definition: feshview.cxx:719
static void lcl_GrabCursor(SwFEShell *pSh, SwFlyFrame *pOldSelFly)
Definition: feshview.cxx:153
bool IsFlyFrame() const
Definition: frame.hxx:1210
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
Definition: feshview.cxx:2685
wrapper class for the positioning of Writer fly frames and drawing objects
virtual void MovAction(const Point &rPnt) override
static void SetupObjLayer(const SdrPageView *pPageView, const OUString &aActiveLayer, SdrObject *pObj)
bool GetKeyCursorOfst(SwPosition *pPos, const Point &rPoint) const
Makes sure that the Frame is not switched (e.g.
Definition: txtfrm.hxx:403
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
bool IsMore() const
SwIndex nContent
Definition: pam.hxx:39
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:804
Destination and/or source not found.
const SwRect & getFrameArea() const
Definition: frame.hxx:179
SwFlyFrame * GetPrevLink() const
Definition: flyfrm.hxx:194
size_t pos
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:452
tools::Long GetSectionWidth(SwFormat const &rFormat) const
Width of current range for column-dialog.
Definition: feshview.cxx:3012
int nCount
OUString SvxResId(TranslateId aId)
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2560
bool IsTextFrame() const
Definition: frame.hxx:1234
Point GetAnchorObjDiff() const
Methods for status line.
Definition: feshview.cxx:2405
void MakeNameUnique()
constexpr tools::Long GetWidth() const
void Width(tools::Long nNew)
Definition: swrect.hxx:189
int SetCursor(const Point &rPt, bool bOnlyText=false, bool bBlock=true)
Definition: crsrsh.cxx:761
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
static void SetLineEnds(SfxItemSet &rAttr, SdrObject const &rObj, sal_uInt16 nSlotId)
Definition: feshview.cxx:916
XLineEndListRef GetLineEndList() const
void SetEditMode(SdrViewEditMode eMode)
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1111
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:121
void UnmarkAll()
static sal_uInt16 IsMath(const SvGlobalName &rName)
bool BeginCreate(SdrObjKind eSdrObjectKind, const Point &rPos)
Process of creating draw objects.
Definition: feshview.cxx:1787
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:215
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir) override
Definition: atrfrm.cxx:3484
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:210
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect)
SwFrame * AnchorFrame()
const Link< const SwFlyFrameFormat *, void > & GetFlyMacroLnk() const
Definition: crsrsh.hxx:485
Point GetObjAbsPos() const
Definition: feshview.cxx:2434
sal_uInt32 GetOrdNumDirect() const
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
void SelectionToHell()
Below document.
Definition: feshview.cxx:1241
constexpr bool IsEmpty() const
Base class for various Writer styles.
Definition: format.hxx:46
bool GotoFly(const OUString &rName, FlyCntType eType, bool bSelFrame)
Jump to named Fly (graphic/OLE).
Definition: feshview.cxx:2616
DocumentType eType
GotoObjFlags
values can be combined via logical or
Definition: fesh.hxx:87
void BreakDrag()
Definition: feshview.cxx:785
void SelectionToBottom(bool bBottom=true)
Definition: feshview.cxx:1118
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Iterate over flys - for Basic-collections.
Definition: feshview.cxx:2675
const OUString & GetName() const
SdrObject * GetMarkedSdrObj() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
virtual void SetLayer(SdrLayerID nLayer)
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:2830
bool IsShapeDefaultHoriTextDirR2L() const
Is default horizontal text direction for selected drawing object right-to-left.
Definition: feshview.cxx:3306
Style of a layout element.
Definition: frmfmt.hxx:59
SdrDragMethod * GetDragMethod() const
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1270
SwNodeType
Definition: ndtyp.hxx:28
bool IsContentFrame() const
Definition: frame.hxx:1230
void MirrorAllMarkedVertical()
Only protection that cannot be withdrawn e.g.
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:132
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
uno_Any a
bool GetObjAttr(SfxItemSet &rSet) const
Attention: Ambiguities if multiple selections.
Definition: feshview.cxx:2773
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:56
const SwPosition * GetPoint() const
Definition: pam.hxx:208
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
void EndDrag()
Definition: feshview.cxx:745
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
size_t size() const
Definition: sortedobjs.cxx:43
FlyCntType
Definition: flyenum.hxx:23
bool IsSelContainsControl() const
check whether selected frame contains a control; companion method to GetSelFrameType, used for preventing drag&drop of controls into header
Definition: feshview.cxx:639
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
bool IsMarkedObjHit(const Point &rPnt, short nTol=-2) const
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool ActionPend() const
Definition: viewsh.hxx:196
TElementType * First()
Definition: calbck.hxx:356
SwContentNode * GetContentNode()
Definition: node.hxx:625
void SelectionHasChanged(SwFEShell *pShell)
Definition: fly.cxx:1842
const SdrMarkList & GetMarkedObjectList() const
sal_uInt16 Count() const
FlyAnchors.
Definition: fmtanchr.hxx:34
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:63
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(MergedPara const &, TextFrameIndex nIndex)
Definition: txtfrm.cxx:1167
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual const SwFlyFrame * DynCastFlyFrame() const
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
constexpr tools::Long Right() const
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:90
FlyProtectFlags
values can be combined via logical or
Definition: fesh.hxx:105
SdrHdl * PickHandle(const Point &rPnt) const
SdrModel & getSdrModelFromSdrObject() const
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
sal_uInt32 GetOrdNum() const
bool IsGroupSelected(bool bAllowDiagams)
Create and destroy group, don't when frame is selected.
Definition: feshview.cxx:2440
bool ObjAnchoredAtPage() const
Definition: dcontact.hxx:146
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
constexpr tools::Long Top() const
bool IsGroupAllowed() const
Definition: feshview.cxx:2496
bool IsGroupObject() const
SwFrame * GetPrev()
Definition: frame.hxx:677
bool IsContentProtected() const
void BegMarkObj(const Point &rPnt, bool bUnmark=false)
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
virtual void SetLogicRect(const tools::Rectangle &rRect)
void CreateDefaultShape(SdrObjKind eSdrObjectKind, const tools::Rectangle &rRect, sal_uInt16 nSlotId)
Definition: feshview.cxx:3040
#define SW_ADD_SELECT
Definition: fesh.hxx:166
bool IsResizeProtect() const
constexpr SdrLayerID SDRLAYER_NOTFOUND(-1)
SdrDragMode GetDragMode() const
Definition: feshview.cxx:673
void SetCalcFieldValueHdl(Outliner *pOutliner)
Definition: feshview.cxx:2883
void MergeValues(const SfxItemSet &rSet)
void BreakCreate()
Definition: feshview.cxx:2223
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
void MoveMark(const Point &rPos)
Definition: feshview.cxx:2256
void SelectionToTop(bool bTop=true)
Move selection upwards or downwards (Z-Order).
Definition: feshview.cxx:1049
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ...
Definition: node.cxx:427
RndStdIds GetAnchorId() const
Anchor type of selected object, RndStdIds::UNKNOWN if ambiguous or in case of frame selection...
Definition: feshview.cxx:2331
A page of the document layout.
Definition: pagefrm.hxx:57
virtual SdrObject * RemoveObject(size_t nObjNum)
#define CNT_TXT
Definition: editsh.hxx:129
SdrAngleItem makeSdrCircStartAngleItem(Degree100 nAngle)
stay with the cursor inside text
static void SetSearchLabel(const SearchLabel &rSL)
const tools::Rectangle & GetAllMarkedRect() const
tools::Long SwTwips
Definition: swtypes.hxx:51
FlyProtectFlags IsSelObjProtected(FlyProtectFlags eType) const
Which Protection is set at selected object?
Definition: feshview.cxx:2705
const long LONG_MAX
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
virtual const SdrObject * GetMaster() const =0
virtual SdrInventor GetObjInventor() const
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
void HideChainMarker()
Definition: feshview.cxx:2957
constexpr Point Center() const
void MovMarkPoints(const Point &rPnt)
constexpr Point TopLeft() const
virtual SdrLayerID GetHellId() const =0
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1115
virtual SdrLayerID GetLayer() const
static bool LessY(Point const &aPt1, Point const &aPt2, bool bOld)
Definition: feshview.cxx:356
SAL_DLLPRIVATE void ScrollTo(const Point &rPt)
Definition: feshview.cxx:656
constexpr tools::Long Bottom() const
SAL_DLLPRIVATE bool ImpEndCreate()
Definition: feshview.cxx:1866
bool ShouldObjectBeSelected(const Point &rPt)
Test if there is a draw object at that position and if it should be selected.
Definition: feshview.cxx:1414
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:448
#define SCROLLVAL
Definition: feshview.cxx:103
const basegfx::B2DPolyPolygon & GetLineEnd() const
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
SDRTEXTHORZADJUST_RIGHT
SdrLayerID GetLayerId() const
1 Heaven, 0 Hell, SDRLAYER_NOTFOUND Ambiguous.
Definition: feshview.cxx:1170
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
bool GotoObj(bool bNext, GotoObjFlags eType=GotoObjFlags::DrawAny)
Definition: feshview.cxx:1751
virtual const tools::Rectangle & GetLastBoundRect() const
SdrObject * Next()
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void MoveCreate(const Point &rPos)
Definition: feshview.cxx:1829
void setClosed(bool bNew)
constexpr Size GetSize() const
SwFlyFrame * GetFlyFrame()
Definition: dflyobj.hxx:128
bool IsMarkPoints() const
void Drag(const Point *pPt, bool bProp)
Definition: feshview.cxx:733
bool IsMirrorAllowed(bool b45Deg=false, bool b90Deg=false) const
sal_uInt32 count() const
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
const SvxOpaqueItem & GetOpaque(bool=true) const
Definition: frmatr.hxx:80
void ScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Definition: edtwin3.cxx:35
SwDrawView * GetDrawView()
Definition: viewimp.hxx:161
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
virtual SwFrameFormat & GetFrameFormat()=0
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:737
unsigned char sal_uInt8
SdrDragMode
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1695
SwFlyFrame * GetFlyFromMarked(const SdrMarkList *pLst, SwViewShell *pSh)
Definition: feshview.cxx:139
static bool LessX(Point const &aPt1, Point const &aPt2, bool bOld)
Definition: feshview.cxx:349
const SfxItemSet & GetMergedItemSet() const
SAL_DLLPRIVATE void ChangeOpaque(SdrLayerID nLayerId)
Definition: feshview.cxx:1196
constexpr Point TopRight() const
bool IsNoTextFrame() const
Definition: frame.hxx:1238
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1787
#define SW_ENTER_GROUP
Definition: fesh.hxx:167
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
sal_uInt16 GetHitTolerancePixel() const
bool IsRightToLeft() const
Definition: frame.hxx:987
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void EndTextEdit()
Deletes object if required.
Definition: feshview.cxx:1314
SwFlyFrame * GetNextLink() const
Definition: flyfrm.hxx:195
size_t IsObjSelected() const
Definition: feshview.cxx:1246
bool IsPageFrame() const
Definition: frame.hxx:1178
void DelSelectedObj()
Definition: feshview.cxx:2379
QPRO_FUNC_TYPE nType
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position)...
Definition: feshview.cxx:177
bool IsScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:45
void ClearMark()
Definition: crsrsh.cxx:939
const SwFrameFormat * SelFlyGrabCursor()
If a fly is selected, it draws cursor into the first ContentFrame.
Definition: feshview.cxx:794
const Point & GetAnchorPos() const
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:57
Format of a fly content.
Definition: fmtflcnt.hxx:32
void SetObjAttr(const SfxItemSet &rSet)
Definition: feshview.cxx:2796
SdrObject * getParentSdrObjectFromSdrObject() const
void SetDragMode(SdrDragMode eSdrDragMode)
Set DragMode (e.g. Rotate), but do nothing when frame is selected.
Definition: feshview.cxx:667
SdrPageView * GetSdrPageView() const
constexpr Point BottomRight() const
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBody=false)
search an anchor for paragraph bound frames starting from pOldAnch
Definition: flycnt.cxx:1063
void SetChainMarker()
Definition: feshview.cxx:2963
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
sal_uInt16 GetMarkHdlSizePixel() const
bool IsVertical() const
Definition: frame.hxx:973
bool IsDragObj() const
bool BeginMark(const Point &rPos)
Functions for Rubberbox, it selects Draw-Objects.
Definition: feshview.cxx:2235
bool g_bNoInterrupt
Definition: swmodule.cxx:114
void Unchain(SwFrameFormat &rFormat)
Definition: feshview.cxx:2950
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
RndStdIds
const SfxItemPool & GetItemPool() const
virtual void NbcSetAnchorPos(const Point &rPnt)
virtual bool includeObject(const SdrObject &i_rObject) const =0
const SvxProtectItem & GetProtect(bool=true) const
Definition: frmatr.hxx:82
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
virtual void MarkListHasChanged() override
Definition: dview.cxx:775
constexpr SwTwips lMinBorder
Definition: swtypes.hxx:74
#define SW_ALLOW_TEXTBOX
Allow SwFEShell::SelectObj() to select the TextBox of a shape.
Definition: fesh.hxx:170
bool IsObjSameLevelWithMarked(const SdrObject *pObj) const
Definition: feshview.cxx:1294
void Clear()
Definition: swrect.hxx:308
virtual void MakeSelVisible() override
Show current selection (frame / draw object as required).
Definition: feshview.cxx:2692
bool IsObjSelectable(const Point &rPt)
The following two methods return enum SdrHdlKind.
Definition: feshview.cxx:1379
#define SW_LEAVE_FRAME
Definition: fesh.hxx:168
const SwFrame * GetAnchorFrame() const
static bool DoTextBoxZOrderCorrection(SwFrameFormat *pShape, const SdrObject *pObj)
SdrObjList * getParentSdrObjListFromSdrObject() const
const OUString & GetActiveLayer() const
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:154
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
SdrCreateCmd
SdrAngleItem makeSdrCircEndAngleItem(Degree100 nAngle)
SwChainRet Chain(SwFrameFormat &rSource, const Point &rPt)
Definition: feshview.cxx:2927
Source already has a follow.
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:70
bool IsDrawCreate() const
Definition: feshview.cxx:2230
static void lcl_NotifyNeighbours(const SdrMarkList *pLst)
Definition: feshview.cxx:836
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
sal_uInt16 getHitTolLog() const
void Height(tools::Long nNew)
Definition: swrect.hxx:193
SdrModel * GetModel() const
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1249
virtual void NbcSetRelativePos(const Point &rPnt)
SdrObjUserCall * GetUserCall() const
const SwPosition & GetContentAnchor() const
Definition: dcontact.hxx:152
bool Is3DObj() const
bool Overlaps(const SwRect &rRect) const
Definition: swrect.hxx:374
const OUString & GetName() const
SwChainRet
Definition: flyenum.hxx:33
bool IsFrameSelected() const
Definition: feshview.cxx:1254
virtual bool IsTextBox() const override
Definition: dflyobj.cxx:1290
bool MoveAnchor(SwMove nDir)
Definition: feshview.cxx:364
bool IsMoveProtect() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:864
sal_Int16 nValue
SDRTEXTVERTADJUST_CENTER
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1585
virtual bool HasMarkablePoints() const
const SdrObject * GetBestObject(bool bNext, GotoObjFlags eType, bool bFlat=true, const svx::ISdrObjectFilter *pFilter=nullptr, bool *pbWrapped=nullptr)
Definition: feshview.cxx:1563
constexpr tools::Long GetHeight() const
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1628
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1840
FrameTypeFlags GetSelFrameType() const
Definition: feshview.cxx:606
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dflyobj.cxx:557
SwFrame * GetNext()
Definition: frame.hxx:676
SdrObject * GetCurrentGroup() const