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