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(const char* 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 = dynamic_cast<SwFlyFrame*>( pAnchObj) )
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 = dynamic_cast<SwFlyFrame*>(pAnchoredObj);
877  if ( !pAct )
878  continue;
879 
880  SwRect aTmpCalcPnt( pAct->getFramePrintArea() );
881  aTmpCalcPnt += pAct->getFrameArea().Pos();
882  if ( aRect.IsOver( aTmpCalcPnt ) )
883  {
884  SwContentFrame *pCnt = pAct->ContainsContent();
885  while ( pCnt )
886  {
887  aTmpCalcPnt = pCnt->getFramePrintArea();
888  aTmpCalcPnt += pCnt->getFrameArea().Pos();
889  if ( aRect.IsOver( 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().IsInside( rPt ) )
1452  {
1453  const SwTextFrame* pTextFrame =
1454  dynamic_cast<const SwTextFrame*>(pContentFrame);
1455  if ( pTextFrame )
1456  {
1457  SwPosition aPos(GetDoc()->GetNodes());
1458  Point aTmpPt( rPt );
1459  if (pTextFrame->GetKeyCursorOfst(&aPos, aTmpPt))
1460  {
1461  SwRect aCursorCharRect;
1462  if (pTextFrame->GetCharRect(aCursorCharRect,
1463  aPos))
1464  {
1465  if ( aCursorCharRect.IsOver( SwRect( pObj->GetLastBoundRect() ) ) )
1466  {
1467  bRet = false;
1468  }
1469  }
1470  }
1471  }
1472  else
1473  {
1474  bRet = false;
1475  }
1476  break;
1477  }
1478 
1479  pContentFrame = pContentFrame->GetNextContentFrame();
1480  }
1481  }
1482  }
1483 
1484  // Don't select header / footer objects in body edition and vice-versa
1485  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1486  if (pContact && !pContact->ObjAnchoredAtPage() )
1487  {
1488  const SwPosition& rPos = pContact->GetContentAnchor();
1489  bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
1490  if (IsHeaderFooterEdit() != bInHdrFtr)
1491  {
1492  bRet = false;
1493  }
1494  }
1495 
1496  if ( bRet )
1497  {
1498  const SdrPage* pPage = rIDDMA.GetDrawModel()->GetPage(0);
1499  for(size_t a = pObj->GetOrdNum()+1; bRet && a < pPage->GetObjCount(); ++a)
1500  {
1501  SdrObject *pCandidate = pPage->GetObj(a);
1502 
1503  SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pCandidate);
1504  if (pDrawObj && pDrawObj->GetCurrentBoundRect().IsInside(rPt))
1505  {
1506  bRet = false;
1507  }
1508  }
1509  }
1510  }
1511  }
1512 
1513  return bRet;
1514 }
1515 
1516 /*
1517  * If an object was selected, we assume its upper-left corner
1518  * otherwise the middle of the current CharRects.
1519  * Does the object include a control or groups,
1520  * which comprise only controls
1521  */
1522 static bool lcl_IsControlGroup( const SdrObject *pObj )
1523 {
1524  bool bRet = false;
1525  if(dynamic_cast<const SdrUnoObj*>( pObj) != nullptr)
1526  bRet = true;
1527  else if( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
1528  {
1529  bRet = true;
1530  const SdrObjList *pLst = pObjGroup->GetSubList();
1531  for ( size_t i = 0; i < pLst->GetObjCount(); ++i )
1532  if( !::lcl_IsControlGroup( pLst->GetObj( i ) ) )
1533  return false;
1534  }
1535  return bRet;
1536 }
1537 
1538 namespace
1539 {
1540  class MarkableObjectsOnly : public svx::ISdrObjectFilter
1541  {
1542  public:
1543  explicit MarkableObjectsOnly( SdrPageView* i_pPV )
1544  :m_pPV( i_pPV )
1545  {
1546  }
1547 
1548  virtual bool includeObject( const SdrObject& i_rObject ) const override
1549  {
1550  return m_pPV && m_pPV->GetView().IsObjMarkable( &i_rObject, m_pPV );
1551  }
1552 
1553  private:
1554  SdrPageView* m_pPV;
1555  };
1556 }
1557 
1558 const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool bFlat, const svx::ISdrObjectFilter* pFilter )
1559 {
1560  if( !Imp()->HasDrawView() )
1561  return nullptr;
1562 
1563  const SdrObject *pBest = nullptr,
1564  *pTop = nullptr;
1565 
1566  const tools::Long nTmp = bNext ? LONG_MAX : 0;
1567  Point aBestPos( nTmp, nTmp );
1568  Point aTopPos( nTmp, nTmp );
1569  Point aCurPos;
1570  Point aPos;
1571  bool bNoDraw((GotoObjFlags::DrawAny & eType) == GotoObjFlags::NONE);
1572  bool bNoFly((GotoObjFlags::FlyAny & eType) == GotoObjFlags::NONE);
1573 
1574  if( !bNoFly && bNoDraw )
1575  {
1576  SwFlyFrame *pFly = GetCurrFrame( false )->FindFlyFrame();
1577  if( pFly )
1578  pBest = pFly->GetVirtDrawObj();
1579  }
1580  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1581  SdrPageView* pPV = Imp()->GetDrawView()->GetSdrPageView();
1582 
1583  MarkableObjectsOnly aDefaultFilter( pPV );
1584  if ( !pFilter )
1585  pFilter = &aDefaultFilter;
1586 
1587  if( !pBest || rMrkList.GetMarkCount() == 1 )
1588  {
1589  // Determine starting point
1590  SdrObjList* pList = nullptr;
1591  if ( rMrkList.GetMarkCount() )
1592  {
1593  const SdrObject* pStartObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
1594  if( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pStartObj) )
1595  aPos = pVirtFlyDrawObj->GetFlyFrame()->getFrameArea().Pos();
1596  else
1597  aPos = pStartObj->GetSnapRect().TopLeft();
1598 
1599  // If an object inside a group is selected, we want to
1600  // iterate over the group members.
1601  if ( ! pStartObj->GetUserCall() )
1602  pList = pStartObj->getParentSdrObjListFromSdrObject();
1603  }
1604  else
1605  {
1606  // If no object is selected, we check if we just entered a group.
1607  // In this case we want to iterate over the group members.
1608  aPos = GetCharRect().Center();
1609  const SdrObject* pStartObj = pPV ? pPV->GetCurrentGroup() : nullptr;
1610  if ( dynamic_cast<const SdrObjGroup*>( pStartObj) )
1611  pList = pStartObj->GetSubList();
1612  }
1613 
1614  if ( ! pList )
1615  {
1616  // Here we are if
1617  // A No object has been selected and no group has been entered or
1618  // B An object has been selected and it is not inside a group
1619  pList = getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 );
1620  }
1621 
1622  OSL_ENSURE( pList, "No object list to iterate" );
1623 
1624  SdrObjListIter aObjIter( pList, bFlat ? SdrIterMode::Flat : SdrIterMode::DeepNoGroups );
1625  while ( aObjIter.IsMore() )
1626  {
1627  SdrObject* pObj = aObjIter.Next();
1628  SwVirtFlyDrawObj *pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1629  if( ( bNoFly && pVirtO ) ||
1630  ( bNoDraw && !pVirtO ) ||
1631  // Ignore TextBoxes of draw shapes here, so that
1632  // SwFEShell::SelectObj() won't jump back on this list, meaning
1633  // we never jump to the next draw shape.
1634  (pVirtO && pVirtO->IsTextBox()) ||
1635  ( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) ||
1636  ( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
1637  !pFilter->includeObject( *pObj ) )
1638  continue;
1639  if (pVirtO)
1640  {
1641  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
1642  if( GotoObjFlags::FlyAny != ( GotoObjFlags::FlyAny & eType ) )
1643  {
1644  switch ( eType )
1645  {
1647  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1648  continue;
1649  break;
1650  case GotoObjFlags::FlyGrf:
1651  if ( pFly->Lower() &&
1652  (!pFly->Lower()->IsNoTextFrame() ||
1653  !static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode()))
1654  continue;
1655  break;
1656  case GotoObjFlags::FlyOLE:
1657  if ( pFly->Lower() &&
1658  (!pFly->Lower()->IsNoTextFrame() ||
1659  !static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode()))
1660  continue;
1661  break;
1662  default: break;
1663  }
1664  }
1665  aCurPos = pFly->getFrameArea().Pos();
1666  }
1667  else
1668  aCurPos = pObj->GetSnapRect().TopLeft();
1669 
1670  // Special case if another object is on same Y.
1671  if( aCurPos != aPos && // only when it is not me
1672  aCurPos.getY() == aPos.getY() && // Y positions equal
1673  (bNext? (aCurPos.getX() > aPos.getX()) : // lies next to me
1674  (aCurPos.getX() < aPos.getX())) ) // " reverse
1675  {
1676  aBestPos = Point( nTmp, nTmp );
1677  SdrObjListIter aTmpIter( pList, bFlat ? SdrIterMode::Flat : SdrIterMode::DeepNoGroups );
1678  while ( aTmpIter.IsMore() )
1679  {
1680  SdrObject* pTmpObj = aTmpIter.Next();
1681  pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pTmpObj);
1682  if( ( bNoFly && pVirtO ) || ( bNoDraw && !pVirtO ) )
1683  continue;
1684  if (pVirtO)
1685  {
1686  aCurPos = pVirtO->GetFlyFrame()->getFrameArea().Pos();
1687  }
1688  else
1689  aCurPos = pTmpObj->GetCurrentBoundRect().TopLeft();
1690 
1691  if( aCurPos != aPos && aCurPos.Y() == aPos.Y() &&
1692  (bNext? (aCurPos.getX() > aPos.getX()) : // lies next to me
1693  (aCurPos.getX() < aPos.getX())) && // " reverse
1694  (bNext? (aCurPos.getX() < aBestPos.getX()) : // better as best
1695  (aCurPos.getX() > aBestPos.getX())) ) // " reverse
1696  {
1697  aBestPos = aCurPos;
1698  pBest = pTmpObj;
1699  }
1700  }
1701  break;
1702  }
1703 
1704  if( (
1705  (bNext? (aPos.getY() < aCurPos.getY()) : // only below me
1706  (aPos.getY() > aCurPos.getY())) && // " reverse
1707  (bNext? (aBestPos.getY() > aCurPos.getY()) : // closer below
1708  (aBestPos.getY() < aCurPos.getY()))
1709  ) || // " reverse
1710  (aBestPos.getY() == aCurPos.getY() &&
1711  (bNext? (aBestPos.getX() > aCurPos.getX()) : // further left
1712  (aBestPos.getX() < aCurPos.getX())))) // " reverse
1713 
1714  {
1715  aBestPos = aCurPos;
1716  pBest = pObj;
1717  }
1718 
1719  if( (bNext? (aTopPos.getY() > aCurPos.getY()) : // higher as best
1720  (aTopPos.getY() < aCurPos.getY())) || // " reverse
1721  (aTopPos.getY() == aCurPos.getY() &&
1722  (bNext? (aTopPos.getX() > aCurPos.getX()) : // further left
1723  (aTopPos.getX() < aCurPos.getX())))) // " reverse
1724  {
1725  aTopPos = aCurPos;
1726  pTop = pObj;
1727  }
1728  }
1729  // unfortunately nothing found
1730  if( bNext ? (aBestPos.getX() == LONG_MAX) : (aBestPos.getX() == 0) )
1731  {
1732  pBest = pTop;
1733  SvxSearchDialogWrapper::SetSearchLabel( bNext ? SearchLabel::EndWrapped : SearchLabel::StartWrapped );
1734  }
1735  }
1736 
1737  return pBest;
1738 }
1739 
1740 bool SwFEShell::GotoObj( bool bNext, GotoObjFlags eType )
1741 {
1742  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1743 
1744  const SdrObject* pBest = GetBestObject( bNext, eType );
1745 
1746  if ( !pBest )
1747  {
1748  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1749  return false;
1750  }
1751 
1752  const SwVirtFlyDrawObj *pVirtO = dynamic_cast<const SwVirtFlyDrawObj*>(pBest);
1753  if (pVirtO)
1754  {
1755  const SwRect& rFrame = pVirtO->GetFlyFrame()->getFrameArea();
1756  SelectObj( rFrame.Pos(), 0, const_cast<SdrObject*>(pBest) );
1757  if( !ActionPend() )
1758  MakeVisible( rFrame );
1759  }
1760  else
1761  {
1762  SelectObj( Point(), 0, const_cast<SdrObject*>(pBest) );
1763  if( !ActionPend() )
1764  MakeVisible( SwRect(pBest->GetCurrentBoundRect()) );
1765  }
1766  CallChgLnk();
1767  return true;
1768 }
1769 
1770 bool SwFEShell::BeginCreate( SdrObjKind eSdrObjectKind, const Point &rPos )
1771 {
1772  bool bRet = false;
1773 
1774  if ( !Imp()->HasDrawView() )
1775  Imp()->MakeDrawView();
1776 
1777  if ( GetPageNumber( rPos ) )
1778  {
1779  Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind );
1780  if ( eSdrObjectKind == OBJ_CAPTION )
1781  bRet = Imp()->GetDrawView()->BegCreateCaptionObj(
1782  rPos, Size( lMinBorder - MINFLY, lMinBorder - MINFLY ),
1783  GetOut() );
1784  else
1785  bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1786  }
1787  if ( bRet )
1788  {
1789  ::FrameNotify( this, FLY_DRAG_START );
1790  }
1791  return bRet;
1792 }
1793 
1794 bool SwFEShell::BeginCreate( SdrObjKind eSdrObjectKind, SdrInventor eObjInventor,
1795  const Point &rPos )
1796 {
1797  bool bRet = false;
1798 
1799  if ( !Imp()->HasDrawView() )
1800  Imp()->MakeDrawView();
1801 
1802  if ( GetPageNumber( rPos ) )
1803  {
1804  Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind, eObjInventor );
1805  bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1806  }
1807  if ( bRet )
1808  ::FrameNotify( this, FLY_DRAG_START );
1809  return bRet;
1810 }
1811 
1812 void SwFEShell::MoveCreate( const Point &rPos )
1813 {
1814  OSL_ENSURE( Imp()->HasDrawView(), "MoveCreate without DrawView?" );
1815  if ( GetPageNumber( rPos ) )
1816  {
1817  ScrollTo( rPos );
1818  Imp()->GetDrawView()->MovCreateObj( rPos );
1819  ::FrameNotify( this );
1820  }
1821 }
1822 
1823 bool SwFEShell::EndCreate( SdrCreateCmd eSdrCreateCmd )
1824 {
1825  // To assure undo-object from the DrawEngine is not stored,
1826  // (we create our own undo-object!), temporarily switch-off Undo
1827  OSL_ENSURE( Imp()->HasDrawView(), "EndCreate without DrawView?" );
1828  if( !Imp()->GetDrawView()->IsGroupEntered() )
1829  {
1830  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
1831  }
1832  bool bCreate = Imp()->GetDrawView()->EndCreateObj( eSdrCreateCmd );
1833  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
1834 
1835  if ( !bCreate )
1836  {
1837  ::FrameNotify( this, FLY_DRAG_END );
1838  return false;
1839  }
1840 
1841  if ( eSdrCreateCmd == SdrCreateCmd::NextPoint )
1842  {
1843  ::FrameNotify( this );
1844  return true;
1845  }
1846  return ImpEndCreate();
1847 }
1848 
1850 {
1851  OSL_ENSURE( Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1,
1852  "New object not selected." );
1853 
1854  SdrObject& rSdrObj = *Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1855 
1856  if( rSdrObj.GetSnapRect().IsEmpty() )
1857  {
1858  // preferably we forget the object, only gives problems
1859  Imp()->GetDrawView()->DeleteMarked();
1860  Imp()->GetDrawView()->UnmarkAll();
1861  ::FrameNotify( this, FLY_DRAG_END );
1862  return false;
1863  }
1864 
1865  if( rSdrObj.getParentSdrObjectFromSdrObject() )
1866  {
1867  Point aTmpPos( rSdrObj.GetSnapRect().TopLeft() );
1868  Point aNewAnchor( rSdrObj.getParentSdrObjectFromSdrObject()->GetAnchorPos() );
1869  // OD 2004-04-05 #i26791# - direct object positioning for group members
1870  rSdrObj.NbcSetRelativePos( aTmpPos - aNewAnchor );
1871  rSdrObj.NbcSetAnchorPos( aNewAnchor );
1872  ::FrameNotify( this );
1873  return true;
1874  }
1875 
1876  LockPaint();
1877  StartAllAction();
1878 
1879  Imp()->GetDrawView()->UnmarkAll();
1880 
1881  const tools::Rectangle &rBound = rSdrObj.GetSnapRect();
1882  Point aPt( rBound.TopRight() );
1883 
1884  // alien identifier should end up on defaults
1885  // duplications possible!!
1886  sal_uInt16 nIdent = SdrInventor::Default == rSdrObj.GetObjInventor()
1887  ? rSdrObj.GetObjIdentifier()
1888  : 0xFFFF;
1889 
1890  // default for controls character bound, otherwise paragraph bound.
1891  SwFormatAnchor aAnch;
1892  const SwFrame *pAnch = nullptr;
1893  bool bCharBound = false;
1894  if( dynamic_cast<const SdrUnoObj*>( &rSdrObj) != nullptr )
1895  {
1896  SwPosition aPos( GetDoc()->GetNodes() );
1898  Point aPoint( aPt.getX(), aPt.getY() + rBound.GetHeight()/2 );
1899  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
1900 
1901  // characterbinding not allowed in readonly-content
1902  if( !aPos.nNode.GetNode().IsProtect() )
1903  {
1904  std::pair<Point, bool> const tmp(aPoint, true);
1905  pAnch = aPos.nNode.GetNode().GetContentNode()->getLayoutFrame(GetLayout(), &aPos, &tmp);
1906  SwRect aTmp;
1907  pAnch->GetCharRect( aTmp, aPos );
1908 
1909  // The crsr should not be too far away
1910  bCharBound = true;
1911  tools::Rectangle aRect( aTmp.SVRect() );
1912  aRect.AdjustLeft( -(MM50*2) );
1913  aRect.AdjustTop( -(MM50*2) );
1914  aRect.AdjustRight(MM50*2 );
1915  aRect.AdjustBottom(MM50*2 );
1916 
1917  if( !aRect.IsOver( rBound ) && !::GetHtmlMode( GetDoc()->GetDocShell() ))
1918  bCharBound = false;
1919 
1920  // anchor in header/footer also not allowed.
1921  if( bCharBound )
1922  bCharBound = !GetDoc()->IsInHeaderFooter( aPos.nNode );
1923 
1924  if( bCharBound )
1925  {
1926  aAnch.SetType( RndStdIds::FLY_AS_CHAR );
1927  aAnch.SetAnchor( &aPos );
1928  }
1929  }
1930  }
1931 
1932  if( !bCharBound )
1933  {
1934  // allow native drawing objects in header/footer.
1935  // Thus, set <bBodyOnly> to <false> for these objects using value
1936  // of <nIdent> - value <0xFFFF> indicates control objects, which aren't
1937  // allowed in header/footer.
1938  //bool bBodyOnly = OBJ_NONE != nIdent;
1939  bool bBodyOnly = 0xFFFF == nIdent;
1940  bool bAtPage = false;
1941  const SwFrame* pPage = nullptr;
1943  Point aPoint( aPt );
1944  SwPosition aPos( GetDoc()->GetNodes() );
1945  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
1946 
1947  // do not set in ReadnOnly-content
1948  if (aPos.nNode.GetNode().IsProtect())
1949  {
1950  // then only page bound. Or should we
1951  // search the next not-readonly position?
1952  bAtPage = true;
1953  }
1954 
1955  SwContentNode* pCNode = aPos.nNode.GetNode().GetContentNode();
1956  std::pair<Point, bool> const tmp(aPoint, false);
1957  pAnch = pCNode ? pCNode->getLayoutFrame(GetLayout(), nullptr, &tmp) : nullptr;
1958  if (!pAnch)
1959  {
1960  // Hidden content. Anchor to the page instead
1961  bAtPage = true;
1962  }
1963 
1964  if( !bAtPage )
1965  {
1966  const SwFlyFrame *pTmp = pAnch->FindFlyFrame();
1967  if( pTmp )
1968  {
1969  const SwFrame* pTmpFrame = pAnch;
1970  SwRect aBound( rBound );
1971  while( pTmp )
1972  {
1973  if( pTmp->getFrameArea().IsInside( aBound ) )
1974  {
1975  if( !bBodyOnly || !pTmp->FindFooterOrHeader() )
1976  pPage = pTmpFrame;
1977  break;
1978  }
1979  pTmp = pTmp->GetAnchorFrame()
1980  ? pTmp->GetAnchorFrame()->FindFlyFrame()
1981  : nullptr;
1982  pTmpFrame = pTmp;
1983  }
1984  }
1985 
1986  if( !pPage )
1987  pPage = pAnch->FindPageFrame();
1988 
1989  // Always via FindAnchor, to assure the frame will be bound
1990  // to the previous. With GetCrsOfst we can also reach the next. THIS IS WRONG.
1991  pAnch = ::FindAnchor( pPage, aPt, bBodyOnly );
1992  if (pAnch->IsTextFrame())
1993  {
1994  std::pair<SwTextNode const*, sal_Int32> const pos(
1995  static_cast<SwTextFrame const*>(pAnch)->MapViewToModel(TextFrameIndex(0)));
1996  aPos.nNode = *pos.first;
1997  }
1998  else
1999  {
2000  aPos.nNode = *static_cast<const SwNoTextFrame*>(pAnch)->GetNode();
2001  }
2002 
2003  // do not set in ReadnOnly-content
2004  if( aPos.nNode.GetNode().IsProtect() )
2005  // then only page bound. Or should we
2006  // search the next not-readonly position?
2007  bAtPage = true;
2008  else
2009  {
2010  aAnch.SetType( RndStdIds::FLY_AT_PARA );
2011  aAnch.SetAnchor( &aPos );
2012  }
2013  }
2014 
2015  if( bAtPage )
2016  {
2017  pPage = pAnch ? pAnch->FindPageFrame() : GetLayout()->GetPageAtPos(aPoint);
2018 
2019  aAnch.SetType( RndStdIds::FLY_AT_PAGE );
2020  aAnch.SetPageNum( pPage->GetPhyPageNum() );
2021  pAnch = pPage; // page becomes an anchor
2022  }
2023  }
2024 
2025  SfxItemSet aSet( GetDoc()->GetAttrPool(), svl::Items<RES_FRM_SIZE, RES_FRM_SIZE,
2027  aSet.Put( aAnch );
2028 
2029  // OD 2004-03-30 #i26791# - determine relative object position
2030  SwTwips nXOffset;
2031  SwTwips nYOffset = rBound.Top() - pAnch->getFrameArea().Top();
2032  {
2033  if( pAnch->IsVertical() )
2034  {
2035  nXOffset = nYOffset;
2036  nYOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
2037  }
2038  else if( pAnch->IsRightToLeft() )
2039  nXOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
2040  else
2041  nXOffset = rBound.Left() - pAnch->getFrameArea().Left();
2042  if (pAnch->IsTextFrame())
2043  {
2044  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2045  if (pTmp->IsFollow())
2046  {
2047  do {
2048  pTmp = pTmp->FindMaster();
2049  OSL_ENSURE(pTmp, "Where's my Master?");
2050  // OD 2004-03-30 #i26791# - correction: add frame area height
2051  // of master frames.
2052  nYOffset += pTmp->IsVertical() ?
2053  pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height();
2054  } while (pTmp->IsFollow());
2055  }
2056 
2057  nYOffset -= pTmp->GetBaseVertOffsetForFly(false);
2058  }
2059  }
2060 
2061  if( OBJ_NONE == nIdent )
2062  {
2063  // For OBJ_NONE a fly is inserted.
2064  const tools::Long nWidth = rBound.Right() - rBound.Left();
2065  const tools::Long nHeight= rBound.Bottom() - rBound.Top();
2066  aSet.Put( SwFormatFrameSize( SwFrameSize::Minimum, std::max( nWidth, tools::Long(MINFLY) ),
2067  std::max( nHeight, tools::Long(MINFLY) )));
2068 
2069  SwFormatHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
2070  SwFormatVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
2071  aSet.Put( SwFormatSurround( css::text::WrapTextMode_PARALLEL ) );
2072  aSet.Put( aHori );
2073  aSet.Put( aVert );
2074 
2075  // Quickly store the square
2076  const SwRect aFlyRect( rBound );
2077 
2078  // Throw away generated object, now the fly can nicely
2079  // via the available SS be generated.
2080  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); // see above
2081  // #i52858# - method name changed
2082  SdrPage *pPg = getIDocumentDrawModelAccess().GetOrCreateDrawModel()->GetPage( 0 );
2083  if( !pPg )
2084  {
2085  SdrModel* pTmpSdrModel = getIDocumentDrawModelAccess().GetDrawModel();
2086  auto pNewPage = pTmpSdrModel->AllocPage( false );
2087  pTmpSdrModel->InsertPage( pNewPage.get() );
2088  pPg = pNewPage.get();
2089  }
2090  pPg->RecalcObjOrdNums();
2091  SdrObject* pRemovedObject = pPg->RemoveObject( rSdrObj.GetOrdNumDirect() );
2092  SdrObject::Free( pRemovedObject );
2093  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
2094 
2095  SwFlyFrame* pFlyFrame;
2096  if( NewFlyFrame( aSet, true ) &&
2097  ::GetHtmlMode( GetDoc()->GetDocShell() ) &&
2098  nullptr != ( pFlyFrame = GetSelectedFlyFrame() ))
2099  {
2100  SfxItemSet aHtmlSet( GetDoc()->GetAttrPool(), svl::Items<RES_VERT_ORIENT, RES_HORI_ORIENT> );
2101  // horizontal orientation:
2102  const bool bLeftFrame = aFlyRect.Left() <
2103  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Left(),
2104  bLeftPrt = aFlyRect.Left() + aFlyRect.Width() <
2105  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width()/2;
2106  if( bLeftFrame || bLeftPrt )
2107  {
2108  aHori.SetHoriOrient( text::HoriOrientation::LEFT );
2109  aHori.SetRelationOrient( bLeftFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
2110  }
2111  else
2112  {
2113  const bool bRightFrame = aFlyRect.Left() >
2114  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width();
2115  aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
2116  aHori.SetRelationOrient( bRightFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
2117  }
2118  aHtmlSet.Put( aHori );
2119  aVert.SetVertOrient( text::VertOrientation::TOP );
2120  aVert.SetRelationOrient( text::RelOrientation::PRINT_AREA );
2121  aHtmlSet.Put( aVert );
2122 
2123  GetDoc()->SetAttr( aHtmlSet, *pFlyFrame->GetFormat() );
2124  }
2125  }
2126  else
2127  {
2128  if (rSdrObj.GetName().isEmpty())
2129  {
2130  bool bRestore = GetDoc()->GetIDocumentUndoRedo().DoesDrawUndo();
2131  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
2132  rSdrObj.MakeNameUnique();
2133  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(bRestore);
2134  }
2135 
2136  aSet.Put( aAnch );
2137  aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
2138  // OD 2004-03-30 #i26791# - set horizontal position
2139  SwFormatHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
2140  aSet.Put( aHori );
2141  // OD 2004-03-30 #i26791# - set vertical position
2142  if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
2143  {
2144  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2145  do {
2146  pTmp = pTmp->FindMaster();
2147  assert(pTmp && "Where's my Master?");
2148  nYOffset += pTmp->IsVertical() ?
2149  pTmp->getFramePrintArea().Width() : pTmp->getFramePrintArea().Height();
2150  } while ( pTmp->IsFollow() );
2151  }
2152  SwFormatVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
2153  aSet.Put( aVert );
2154  SwDrawFrameFormat* pFormat = static_cast<SwDrawFrameFormat*>(getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::DRAW_OBJECT, &aSet ));
2155  // #i36010# - set layout direction of the position
2156  pFormat->SetPositionLayoutDir(
2157  text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
2158  // #i44344#, #i44681# - positioning attributes already set
2159  pFormat->PosAttrSet();
2160  pFormat->SetName(rSdrObj.GetName());
2161 
2162  SwDrawContact *pContact = new SwDrawContact( pFormat, &rSdrObj );
2163  // #i35635#
2164  pContact->MoveObjToVisibleLayer( &rSdrObj );
2165  if( bCharBound )
2166  {
2167  OSL_ENSURE( aAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR, "wrong AnchorType" );
2168  SwTextNode *pNd = aAnch.GetContentAnchor()->nNode.GetNode().GetTextNode();
2169  SwFormatFlyCnt aFormat( pFormat );
2170  pNd->InsertItem(aFormat,
2171  aAnch.GetContentAnchor()->nContent.GetIndex(), 0 );
2173  aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER );
2174  pFormat->SetFormatAttr( aVertical );
2175  }
2176  if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
2177  {
2178  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2179  do {
2180  pTmp = pTmp->FindMaster();
2181  OSL_ENSURE( pTmp, "Where's my Master?" );
2182  } while( pTmp->IsFollow() );
2183  pAnch = pTmp;
2184  }
2185 
2186  pContact->ConnectToLayout();
2187 
2188  // mark object at frame the object is inserted at.
2189  {
2190  SdrObject* pMarkObj = pContact->GetDrawObjectByAnchorFrame( *pAnch );
2191  if ( pMarkObj )
2192  {
2193  Imp()->GetDrawView()->MarkObj( pMarkObj, Imp()->GetPageView() );
2194  }
2195  else
2196  {
2197  Imp()->GetDrawView()->MarkObj( &rSdrObj, Imp()->GetPageView() );
2198  }
2199  }
2200  }
2201 
2202  GetDoc()->getIDocumentState().SetModified();
2203 
2204  KillPams();
2205  EndAllActionAndCall();
2206  UnlockPaint();
2207  return true;
2208 }
2209 
2211 {
2212  OSL_ENSURE( Imp()->HasDrawView(), "BreakCreate without DrawView?" );
2213  Imp()->GetDrawView()->BrkCreateObj();
2214  ::FrameNotify( this, FLY_DRAG_END );
2215 }
2216 
2218 {
2219  return Imp()->HasDrawView() && Imp()->GetDrawView()->IsCreateObj();
2220 }
2221 
2222 bool SwFEShell::BeginMark( const Point &rPos )
2223 {
2224  if ( !Imp()->HasDrawView() )
2225  Imp()->MakeDrawView();
2226 
2227  if ( GetPageNumber( rPos ) )
2228  {
2229  SwDrawView* pDView = Imp()->GetDrawView();
2230 
2231  if (pDView->HasMarkablePoints())
2232  return pDView->BegMarkPoints( rPos );
2233  else
2234  {
2235  pDView->BegMarkObj( rPos );
2236  return true;
2237  }
2238  }
2239  else
2240  return false;
2241 }
2242 
2243 void SwFEShell::MoveMark( const Point &rPos )
2244 {
2245  OSL_ENSURE( Imp()->HasDrawView(), "MoveMark without DrawView?" );
2246 
2247  if ( GetPageNumber( rPos ) )
2248  {
2249  ScrollTo( rPos );
2250  SwDrawView* pDView = Imp()->GetDrawView();
2251 
2252  if (pDView->IsInsObjPoint())
2253  pDView->MovInsObjPoint( rPos );
2254  else if (pDView->IsMarkPoints())
2255  pDView->MovMarkPoints( rPos );
2256  else
2257  pDView->MovAction( rPos );
2258  }
2259 }
2260 
2262 {
2263  bool bRet = false;
2264  OSL_ENSURE( Imp()->HasDrawView(), "EndMark without DrawView?" );
2265 
2266  if (Imp()->GetDrawView()->IsMarkObj())
2267  {
2268  bRet = Imp()->GetDrawView()->EndMarkObj();
2269 
2270  if ( bRet )
2271  {
2272  bool bShowHdl = false;
2273  SwDrawView* pDView = Imp()->GetDrawView();
2274  // frames are not selected this way, except when
2275  // it is only one frame
2276  SdrMarkList &rMrkList = const_cast<SdrMarkList&>(pDView->GetMarkedObjectList());
2277  SwFlyFrame* pOldSelFly = ::GetFlyFromMarked( &rMrkList, this );
2278 
2279  if ( rMrkList.GetMarkCount() > 1 )
2280  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2281  {
2282  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2283  if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
2284  {
2285  if ( !bShowHdl )
2286  {
2287  bShowHdl = true;
2288  }
2289  rMrkList.DeleteMark( i );
2290  --i; // no exceptions
2291  }
2292  }
2293 
2294  if( bShowHdl )
2295  {
2296  pDView->MarkListHasChanged();
2297  pDView->AdjustMarkHdl();
2298  }
2299 
2300  if ( rMrkList.GetMarkCount() )
2301  ::lcl_GrabCursor(this, pOldSelFly);
2302  else
2303  bRet = false;
2304  }
2305  if ( bRet )
2306  ::FrameNotify( this, FLY_DRAG_START );
2307  }
2308  else
2309  {
2310  if (Imp()->GetDrawView()->IsMarkPoints())
2311  bRet = Imp()->GetDrawView()->EndMarkPoints();
2312  }
2313 
2314  SetChainMarker();
2315  return bRet;
2316 }
2317 
2319 {
2320  RndStdIds nRet = RndStdIds(SHRT_MAX);
2321  if ( Imp()->HasDrawView() )
2322  {
2323  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2324  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2325  {
2326  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2327  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
2328  {
2329  nRet = RndStdIds::UNKNOWN;
2330  break;
2331  }
2332  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2333  RndStdIds nId = pContact->GetFormat()->GetAnchor().GetAnchorId();
2334  if ( nRet == RndStdIds(SHRT_MAX) )
2335  nRet = nId;
2336  else if ( nRet != nId )
2337  {
2338  nRet = RndStdIds::UNKNOWN;
2339  break;
2340  }
2341  }
2342  }
2343  if ( nRet == RndStdIds(SHRT_MAX) )
2344  nRet = RndStdIds::UNKNOWN;
2345  return nRet;
2346 }
2347 
2348 void SwFEShell::ChgAnchor( RndStdIds eAnchorId, bool bSameOnly, bool bPosCorr )
2349 {
2350  OSL_ENSURE( Imp()->HasDrawView(), "ChgAnchor without DrawView?" );
2351  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2352  if( rMrkList.GetMarkCount() &&
2354  {
2355  StartAllAction();
2356 
2357  if( GetDoc()->ChgAnchor( rMrkList, eAnchorId, bSameOnly, bPosCorr ))
2358  Imp()->GetDrawView()->UnmarkAll();
2359 
2360  EndAllAction();
2361 
2362  ::FrameNotify( this );
2363  }
2364 }
2365 
2367 {
2368  OSL_ENSURE( Imp()->HasDrawView(), "DelSelectedObj(), no DrawView available" );
2369  if ( Imp()->HasDrawView() )
2370  {
2371  StartAllAction();
2372  Imp()->GetDrawView()->DeleteMarked();
2373  EndAllAction();
2374  ::FrameNotify( this, FLY_DRAG_END );
2375  }
2376 }
2377 
2378 // For the statusline to request the current conditions
2380 {
2381  tools::Rectangle aRect;
2382  if ( Imp()->HasDrawView() )
2383  {
2384  if ( Imp()->GetDrawView()->IsAction() )
2385  Imp()->GetDrawView()->TakeActionRect( aRect );
2386  else
2387  aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2388  }
2389  return aRect.GetSize();
2390 }
2391 
2393 {
2394  const SdrView *pView = Imp()->GetDrawView();
2395  OSL_ENSURE( pView, "GetAnchorObjDiff without DrawView?" );
2396 
2397  tools::Rectangle aRect;
2398  if ( Imp()->GetDrawView()->IsAction() )
2399  Imp()->GetDrawView()->TakeActionRect( aRect );
2400  else
2401  aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2402 
2403  Point aRet( aRect.TopLeft() );
2404 
2405  if ( IsFrameSelected() )
2406  {
2407  SwFlyFrame *pFly = GetSelectedFlyFrame();
2408  aRet -= pFly->GetAnchorFrame()->getFrameArea().Pos();
2409  }
2410  else
2411  {
2412  const SdrObject *pObj = pView->GetMarkedObjectList().GetMarkCount() == 1 ?
2413  pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() : nullptr;
2414  if ( pObj )
2415  aRet -= pObj->GetAnchorPos();
2416  }
2417 
2418  return aRet;
2419 }
2420 
2422 {
2423  OSL_ENSURE( Imp()->GetDrawView(), "GetObjAbsPos() without DrawView?" );
2424  return Imp()->GetDrawView()->GetDragStat().GetActionRect().TopLeft();
2425 }
2426 
2428 {
2429  if ( IsObjSelected() )
2430  {
2431  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2432  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2433  {
2434  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2435  // consider 'virtual' drawing objects.
2436  // Thus, use corresponding method instead of checking type.
2437  if ( pObj->IsGroupObject() &&
2438  // --> #i38505# No ungroup allowed for 3d objects
2439  !pObj->Is3DObj() &&
2440  RndStdIds::FLY_AS_CHAR != static_cast<SwDrawContact*>(GetUserCall(pObj))->
2441  GetFormat()->GetAnchor().GetAnchorId() )
2442  {
2443  return true;
2444  }
2445  }
2446  }
2447  return false;
2448 }
2449 
2450 namespace
2451 {
2452  bool HasSuitableGroupingAnchor(const SdrObject* pObj)
2453  {
2454  bool bSuitable = true;
2455  SwFrameFormat* pFrameFormat(::FindFrameFormat(const_cast<SdrObject*>(pObj)));
2456  if (!pFrameFormat)
2457  {
2458  OSL_FAIL( "<HasSuitableGroupingAnchor> - missing frame format" );
2459  bSuitable = false;
2460  }
2461  else if (RndStdIds::FLY_AS_CHAR == pFrameFormat->GetAnchor().GetAnchorId())
2462  {
2463  bSuitable = false;
2464  }
2465  return bSuitable;
2466  }
2467 }
2468 
2469 // Change return type.
2470 // Adjustments for drawing objects in header/footer:
2471 // allow group, only if all selected objects are in the same header/footer
2472 // or not in header/footer.
2474 {
2475  bool bIsGroupAllowed = false;
2476  if ( IsObjSelected() > 1 )
2477  {
2478  bIsGroupAllowed = true;
2479  const SdrObject* pUpGroup = nullptr;
2480  const SwFrame* pHeaderFooterFrame = nullptr;
2481  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2482  for ( size_t i = 0; bIsGroupAllowed && i < rMrkList.GetMarkCount(); ++i )
2483  {
2484  const SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2485  if ( i )
2486  bIsGroupAllowed = pObj->getParentSdrObjectFromSdrObject() == pUpGroup;
2487  else
2488  pUpGroup = pObj->getParentSdrObjectFromSdrObject();
2489 
2490  if ( bIsGroupAllowed )
2491  bIsGroupAllowed = HasSuitableGroupingAnchor(pObj);
2492 
2493  // check, if all selected objects are in the
2494  // same header/footer or not in header/footer.
2495  if ( bIsGroupAllowed )
2496  {
2497  const SwFrame* pAnchorFrame = nullptr;
2498  if ( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
2499  {
2500  const SwFlyFrame* pFlyFrame = pVirtFlyDrawObj->GetFlyFrame();
2501  if ( pFlyFrame )
2502  {
2503  pAnchorFrame = pFlyFrame->GetAnchorFrame();
2504  }
2505  }
2506  else
2507  {
2508  SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
2509  if ( pDrawContact )
2510  {
2511  pAnchorFrame = pDrawContact->GetAnchorFrame( pObj );
2512  }
2513  }
2514  if ( pAnchorFrame )
2515  {
2516  if ( i )
2517  {
2518  bIsGroupAllowed =
2519  ( pAnchorFrame->FindFooterOrHeader() == pHeaderFooterFrame );
2520  }
2521  else
2522  {
2523  pHeaderFooterFrame = pAnchorFrame->FindFooterOrHeader();
2524  }
2525  }
2526  }
2527  }
2528  }
2529 
2530  return bIsGroupAllowed;
2531 }
2532 
2534 {
2535  bool bIsUnGroupAllowed = false;
2536 
2537  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2538  for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i)
2539  {
2540  const SdrObject* pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
2541  bIsUnGroupAllowed = HasSuitableGroupingAnchor(pObj);
2542  if (!bIsUnGroupAllowed)
2543  break;
2544  }
2545 
2546  return bIsUnGroupAllowed;
2547 }
2548 
2549 // The group gets the anchor and the contactobject of the first in the selection
2551 {
2552  if ( IsGroupAllowed() )
2553  {
2554  StartAllAction();
2555  StartUndo( SwUndoId::START );
2556 
2557  GetDoc()->GroupSelection( *Imp()->GetDrawView() );
2558 
2560  EndAllAction();
2561  }
2562 }
2563 
2564 // The individual objects get a copy of the anchor and the contactobject of the group
2566 {
2567  if ( IsGroupSelected() )
2568  {
2569  StartAllAction();
2570  StartUndo( SwUndoId::START );
2571 
2572  GetDoc()->UnGroupSelection( *Imp()->GetDrawView() );
2573 
2575  EndAllAction();
2576  }
2577 }
2578 
2579 void SwFEShell::MirrorSelection( bool bHorizontal )
2580 {
2581  SdrView *pView = Imp()->GetDrawView();
2582  if ( IsObjSelected() && pView->IsMirrorAllowed() )
2583  {
2584  if ( bHorizontal )
2585  pView->MirrorAllMarkedHorizontal();
2586  else
2587  pView->MirrorAllMarkedVertical();
2588  }
2589 }
2590 
2591 // jump to named frame (Graphic/OLE)
2592 
2593 bool SwFEShell::GotoFly( const OUString& rName, FlyCntType eType, bool bSelFrame )
2594 {
2595  bool bRet = false;
2596  static SwNodeType const aChkArr[ 4 ] = {
2597  /* FLYCNTTYPE_ALL */ SwNodeType::NONE,
2598  /* FLYCNTTYPE_FRM */ SwNodeType::Text,
2599  /* FLYCNTTYPE_GRF */ SwNodeType::Grf,
2600  /* FLYCNTTYPE_OLE */ SwNodeType::Ole
2601  };
2602 
2603  const SwFlyFrameFormat* pFlyFormat = mxDoc->FindFlyByName( rName, aChkArr[ eType]);
2604  if( pFlyFormat )
2605  {
2606  CurrShell aCurr( this );
2607 
2608  SwFlyFrame* pFrame = SwIterator<SwFlyFrame,SwFormat>( *pFlyFormat ).First();
2609  if( pFrame )
2610  {
2611  if( bSelFrame )
2612  {
2613  // first make visible, to get a11y events in proper order
2614  if (!ActionPend())
2615  MakeVisible( pFrame->getFrameArea() );
2616  SelectObj( pFrame->getFrameArea().Pos(), 0, pFrame->GetVirtDrawObj() );
2617  }
2618  else
2619  {
2620  SwContentFrame *pCFrame = pFrame->ContainsContent();
2621  if ( pCFrame )
2622  {
2623  ClearMark();
2624  SwPaM* pCursor = GetCursor();
2625 
2626  if (pCFrame->IsTextFrame())
2627  {
2628  *pCursor->GetPoint() = static_cast<SwTextFrame *>(pCFrame)
2629  ->MapViewToModelPos(TextFrameIndex(0));
2630  }
2631  else
2632  {
2633  assert(pCFrame->IsNoTextFrame());
2634  SwContentNode *const pCNode = static_cast<SwNoTextFrame *>(pCFrame)->GetNode();
2635 
2636  pCursor->GetPoint()->nNode = *pCNode;
2637  pCursor->GetPoint()->nContent.Assign( pCNode, 0 );
2638  }
2639 
2640  SwRect& rChrRect = const_cast<SwRect&>(GetCharRect());
2641  rChrRect = pFrame->getFramePrintArea();
2642  rChrRect.Pos() += pFrame->getFrameArea().Pos();
2643  GetCursorDocPos() = rChrRect.Pos();
2644  }
2645  }
2646  bRet = true;
2647  }
2648  }
2649  return bRet;
2650 }
2651 
2652 size_t SwFEShell::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const
2653 {
2654  return GetDoc()->GetFlyCount(eType, bIgnoreTextBoxes);
2655 }
2656 
2657 const SwFrameFormat* SwFEShell::GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes ) const
2658 {
2659  return GetDoc()->GetFlyNum(nIdx, eType, bIgnoreTextBoxes);
2660 }
2661 
2662 std::vector<SwFrameFormat const*> SwFEShell::GetFlyFrameFormats(
2663  FlyCntType const eType, bool const bIgnoreTextBoxes)
2664 {
2665  return GetDoc()->GetFlyFrameFormats(eType, bIgnoreTextBoxes);
2666 }
2667 
2668 // show the current selected object
2670 {
2671  if ( Imp()->HasDrawView() &&
2672  Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )
2673  {
2674  GetCurrFrame(); // just to trigger formatting in case the selected object is not formatted.
2675  MakeVisible( SwRect(Imp()->GetDrawView()->GetAllMarkedRect()) );
2676  }
2677  else
2679 }
2680 
2681 // how is the selected object protected?
2683 {
2685  const bool bParent(eType & FlyProtectFlags::Parent);
2686  if( Imp()->HasDrawView() )
2687  {
2688  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2689  for( size_t i = rMrkList.GetMarkCount(); i; )
2690  {
2691  SdrObject *pObj = rMrkList.GetMark( --i )->GetMarkedSdrObj();
2692  if( !bParent )
2693  {
2694  nChk |= ( pObj->IsMoveProtect() ? FlyProtectFlags::Pos : FlyProtectFlags::NONE ) |
2696 
2697  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
2698  {
2699  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
2700  if ( (FlyProtectFlags::Content & eType) && pFly->GetFormat()->GetProtect().IsContentProtected() )
2701  nChk |= FlyProtectFlags::Content;
2702 
2703  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
2704  {
2705  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
2706  uno::Reference < embed::XEmbeddedObject > xObj( pNd ? pNd->GetOLEObj().GetOleRef() : nullptr );
2707  if ( xObj.is() )
2708  {
2709  // TODO/LATER: use correct aspect
2710  const bool bNeverResize = (embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ));
2711  if ( ( (FlyProtectFlags::Content & eType) || (FlyProtectFlags::Size & eType) ) && bNeverResize )
2712  {
2713  nChk |= FlyProtectFlags::Size;
2714  nChk |= FlyProtectFlags::Fixed;
2715  }
2716 
2717  // set FlyProtectFlags::Pos if it is a Math object anchored 'as char' and baseline alignment is activated
2718  const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
2719  && RndStdIds::FLY_AS_CHAR == pFly->GetFormat()->GetAnchor().GetAnchorId()
2720  && mxDoc->GetDocumentSettingManager().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT );
2721  if ((FlyProtectFlags::Pos & eType) && bProtectMathPos)
2722  nChk |= FlyProtectFlags::Pos;
2723  }
2724  }
2725  }
2726  nChk &= eType;
2727  if( nChk == eType )
2728  return eType;
2729  }
2730  const SwFrame* pAnch;
2731  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
2732  pAnch = pVirtO->GetFlyFrame()->GetAnchorFrame();
2733  else
2734  {
2735  SwDrawContact* pTmp = static_cast<SwDrawContact*>(GetUserCall(pObj));
2736  pAnch = pTmp ? pTmp->GetAnchorFrame( pObj ) : nullptr;
2737  }
2738  if( pAnch && pAnch->IsProtected() )
2739  return eType;
2740  }
2741  }
2742  return nChk;
2743 }
2744 
2746 {
2747  if ( !IsObjSelected() )
2748  return false;
2749 
2750  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2751  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2752  {
2753  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2754  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2755  // --> make code robust
2756  OSL_ENSURE( pContact, "<SwFEShell::GetObjAttr(..)> - missing <pContact>." );
2757  if ( pContact )
2758  {
2759  if ( i )
2760  rSet.MergeValues( pContact->GetFormat()->GetAttrSet() );
2761  else
2762  rSet.Put( pContact->GetFormat()->GetAttrSet() );
2763  }
2764  }
2765  return true;
2766 }
2767 
2769 {
2770  CurrShell aCurr( this );
2771 
2772  if ( !rSet.Count() )
2773  {
2774  OSL_ENSURE( false, "SetObjAttr, empty set." );
2775  return;
2776  }
2777 
2778  StartAllAction();
2779  StartUndo( SwUndoId::INSATTR );
2780 
2781  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2782  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2783  {
2784  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2785  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2786  GetDoc()->SetAttr( rSet, *pContact->GetFormat() );
2787  }
2788 
2790  EndAllActionAndCall();
2791  GetDoc()->getIDocumentState().SetModified();
2792 }
2793 
2795 {
2796  return Imp()->GetDrawView()->IsAlignPossible();
2797 }
2798 
2800 {
2801  CurrShell aCurr( this );
2802 
2803  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2804  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2805  {
2806  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2807  if ( !GetUserCall(pObj) )
2808  {
2809  const tools::Rectangle &rBound = pObj->GetSnapRect();
2810  const Point aPt( rBound.TopLeft() );
2811  const SwFrame *pPage = GetLayout()->Lower();
2812  const SwFrame *pLast = pPage;
2813  while ( pPage && !pPage->getFrameArea().IsInside( aPt ) )
2814  {
2815  if ( aPt.Y() > pPage->getFrameArea().Bottom() )
2816  pLast = pPage;
2817  pPage = pPage->GetNext();
2818  }
2819  if ( !pPage )
2820  pPage = pLast;
2821  OSL_ENSURE( pPage, "Page not found." );
2822 
2823  SwFormatAnchor aAnch;
2824  {
2825  const SwContentFrame *const pAnch = ::FindAnchor(pPage, aPt, true);
2826  SwPosition aPos( pAnch->IsTextFrame()
2827  ? *static_cast<SwTextFrame const*>(pAnch)->GetTextNodeForParaProps()
2828  : *static_cast<SwNoTextFrame const*>(pAnch)->GetNode() );
2829  aAnch.SetType( RndStdIds::FLY_AT_PARA );
2830  aAnch.SetAnchor( &aPos );
2831  const_cast<SwRect&>(GetCharRect()).Pos() = aPt;
2832  }
2833 
2834  // First the action here, to assure GetCharRect delivers current values.
2835  StartAllAction();
2836 
2837  SfxItemSet aSet( GetAttrPool(), svl::Items<RES_FRM_SIZE, RES_FRM_SIZE,
2839  aSet.Put( aAnch );
2840  aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
2841  SwFrameFormat* pFormat = getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::DRAW_OBJECT, &aSet );
2842 
2843  SwDrawContact *pContact = new SwDrawContact(
2844  static_cast<SwDrawFrameFormat*>(pFormat), pObj );
2845 
2846  // #i35635#
2847  pContact->MoveObjToVisibleLayer( pObj );
2848  pContact->ConnectToLayout();
2849 
2850  EndAllAction();
2851  }
2852  }
2853 }
2854 
2856 {
2857  GetDoc()->SetCalcFieldValueHdl(pOutliner);
2858 }
2859 
2861  const Point &rPt ) const
2862 {
2863  rRect.Clear();
2864 
2865  // The source is not allowed to have a follow.
2866  const SwFormatChain &rChain = rSource.GetChain();
2867  if ( rChain.GetNext() )
2869 
2871  if( Imp()->HasDrawView() )
2872  {
2873  SdrPageView* pPView;
2874  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
2875  const auto nOld = pDView->GetHitTolerancePixel();
2876  pDView->SetHitTolerancePixel( 0 );
2877  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
2878  SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
2879  if (pDrawObj)
2880  {
2881  SwFlyFrame *pFly = pDrawObj->GetFlyFrame();
2882  rRect = pFly->getFrameArea();
2883 
2884  // Target and source should not be equal and the list
2885  // should not be cyclic
2886  SwFrameFormat *pFormat = pFly->GetFormat();
2887  nRet = GetDoc()->Chainable(rSource, *pFormat);
2888  }
2889  pDView->SetHitTolerancePixel( nOld );
2890  }
2891  return nRet;
2892 }
2893 
2894 void SwFEShell::Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest )
2895 {
2896  GetDoc()->Chain(rSource, rDest);
2897 }
2898 
2899 SwChainRet SwFEShell::Chain( SwFrameFormat &rSource, const Point &rPt )
2900 {
2901  SwRect aDummy;
2902  SwChainRet nErr = Chainable( aDummy, rSource, rPt );
2903  if ( nErr == SwChainRet::OK )
2904  {
2905  StartAllAction();
2906  SdrPageView* pPView;
2907  SwDrawView *pDView = Imp()->GetDrawView();
2908  const auto nOld = pDView->GetHitTolerancePixel();
2909  pDView->SetHitTolerancePixel( 0 );
2910  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
2911  pDView->SetHitTolerancePixel( nOld );
2912  SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
2913 
2914  SwFlyFrameFormat *pFormat = pFly->GetFormat();
2915  GetDoc()->Chain(rSource, *pFormat);
2916  EndAllAction();
2917  SetChainMarker();
2918  }
2919  return nErr;
2920 }
2921 
2923 {
2924  StartAllAction();
2925  GetDoc()->Unchain(rFormat);
2926  EndAllAction();
2927 }
2928 
2930 {
2931  m_pChainFrom.reset();
2932  m_pChainTo.reset();
2933 }
2934 
2936 {
2937  bool bDelFrom = true,
2938  bDelTo = true;
2939  if ( IsFrameSelected() )
2940  {
2941  SwFlyFrame *pFly = GetSelectedFlyFrame();
2942 
2943  if ( pFly->GetPrevLink() )
2944  {
2945  bDelFrom = false;
2946  const SwFrame *pPre = pFly->GetPrevLink();
2947 
2948  Point aStart( pPre->getFrameArea().Right(), pPre->getFrameArea().Bottom());
2949  Point aEnd(pFly->getFrameArea().Pos());
2950 
2951  if (!m_pChainFrom)
2952  {
2953  m_pChainFrom.reset(
2954  new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd ));
2955  }
2956  }
2957  if ( pFly->GetNextLink() )
2958  {
2959  bDelTo = false;
2960  const SwFlyFrame *pNxt = pFly->GetNextLink();
2961 
2962  Point aStart( pFly->getFrameArea().Right(), pFly->getFrameArea().Bottom());
2963  Point aEnd(pNxt->getFrameArea().Pos());
2964 
2965  if (!m_pChainTo)
2966  {
2967  m_pChainTo.reset(
2968  new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd ));
2969  }
2970  }
2971  }
2972 
2973  if ( bDelFrom )
2974  {
2975  m_pChainFrom.reset();
2976  }
2977 
2978  if ( bDelTo )
2979  {
2980  m_pChainTo.reset();
2981  }
2982 }
2983 
2985 {
2986  SwFrame *pFrame = GetCurrFrame();
2987  // Is the cursor at this moment in a SectionFrame?
2988  if( pFrame && pFrame->IsInSct() )
2989  {
2990  SwSectionFrame* pSect = pFrame->FindSctFrame();
2991  do
2992  {
2993  // Is it the right one?
2994  if( pSect->KnowsFormat( rFormat ) )
2995  return pSect->getFrameArea().Width();
2996  // for nested areas
2997  pSect = pSect->GetUpper()->FindSctFrame();
2998  }
2999  while( pSect );
3000  }
3001  SwIterator<SwSectionFrame,SwFormat> aIter( rFormat );
3002  for ( SwSectionFrame* pSct = aIter.First(); pSct; pSct = aIter.Next() )
3003  {
3004  if( !pSct->IsFollow() )
3005  {
3006  return pSct->getFrameArea().Width();
3007  }
3008  }
3009  return 0;
3010 }
3011 
3012 void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rectangle& rRect,
3013  sal_uInt16 nSlotId)
3014 {
3015  SdrView* pDrawView = GetDrawView();
3016  SdrModel* pDrawModel = pDrawView->GetModel();
3018  *pDrawModel,
3019  SdrInventor::Default,
3020  eSdrObjectKind);
3021 
3022  if(pObj)
3023  {
3024  tools::Rectangle aRect(rRect);
3025  if(OBJ_CARC == eSdrObjectKind || OBJ_CCUT == eSdrObjectKind)
3026  {
3027  // force quadratic
3028  if(aRect.GetWidth() > aRect.GetHeight())
3029  {
3030  aRect = tools::Rectangle(
3031  Point(aRect.Left() + ((aRect.GetWidth() - aRect.GetHeight()) / 2), aRect.Top()),
3032  Size(aRect.GetHeight(), aRect.GetHeight()));
3033  }
3034  else
3035  {
3036  aRect = tools::Rectangle(
3037  Point(aRect.Left(), aRect.Top() + ((aRect.GetHeight() - aRect.GetWidth()) / 2)),
3038  Size(aRect.GetWidth(), aRect.GetWidth()));
3039  }
3040  }
3041  pObj->SetLogicRect(aRect);
3042 
3043  Point aStart = aRect.TopLeft();
3044  Point aEnd = aRect.BottomRight();
3045 
3046  if(dynamic_cast<const SdrCircObj*>( pObj) != nullptr)
3047  {
3048  SfxItemSet aAttr(pDrawModel->GetItemPool());
3049  aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
3050  aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
3051  pObj->SetMergedItemSet(aAttr);
3052  }
3053  else if(auto pPathObj = dynamic_cast<SdrPathObj*>( pObj))
3054  {
3056 
3057  switch(eSdrObjectKind)
3058  {
3059  case OBJ_PATHLINE:
3060  case OBJ_PATHFILL:
3061  {
3062  basegfx::B2DPolygon aInnerPoly;
3063 
3064  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3065 
3066  const basegfx::B2DPoint aCenterBottom(aRect.Center().getX(), aRect.Bottom());
3067  aInnerPoly.appendBezierSegment(
3068  aCenterBottom,
3069  aCenterBottom,
3070  basegfx::B2DPoint(aRect.Center().getX(), aRect.Center().getY()));
3071 
3072  const basegfx::B2DPoint aCenterTop(aRect.Center().getX(), aRect.Top());
3073  aInnerPoly.appendBezierSegment(
3074  aCenterTop,
3075  aCenterTop,
3076  basegfx::B2DPoint(aRect.Right(), aRect.Top()));
3077 
3078  aInnerPoly.setClosed(true);
3079  aPoly.append(aInnerPoly);
3080  }
3081  break;
3082  case OBJ_FREELINE:
3083  case OBJ_FREEFILL:
3084  {
3085  basegfx::B2DPolygon aInnerPoly;
3086 
3087  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3088 
3089  aInnerPoly.appendBezierSegment(
3090  basegfx::B2DPoint(aRect.Left(), aRect.Top()),
3091  basegfx::B2DPoint(aRect.Center().getX(), aRect.Top()),
3092  basegfx::B2DPoint(aRect.Center().getX(), aRect.Center().getY()));
3093 
3094  aInnerPoly.appendBezierSegment(
3095  basegfx::B2DPoint(aRect.Center().getX(), aRect.Bottom()),
3096  basegfx::B2DPoint(aRect.Right(), aRect.Bottom()),
3097  basegfx::B2DPoint(aRect.Right(), aRect.Top()));
3098 
3099  aInnerPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
3100  aInnerPoly.setClosed(true);
3101  aPoly.append(aInnerPoly);
3102  }
3103  break;
3104  case OBJ_POLY:
3105  case OBJ_PLIN:
3106  {
3107  basegfx::B2DPolygon aInnerPoly;
3108  sal_Int32 nWdt(aRect.GetWidth());
3109  sal_Int32 nHgt(aRect.GetHeight());
3110 
3111  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3112  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 30) / 100, aRect.Top() + (nHgt * 70) / 100));
3113  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top() + (nHgt * 15) / 100));
3114  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 65) / 100, aRect.Top()));
3115  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + nWdt, aRect.Top() + (nHgt * 30) / 100));
3116  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 50) / 100));
3117  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 75) / 100));
3118  aInnerPoly.append(basegfx::B2DPoint(aRect.Bottom(), aRect.Right()));
3119 
3120  if(OBJ_PLIN == eSdrObjectKind)
3121  {
3122  aInnerPoly.append(basegfx::B2DPoint(aRect.Center().getX(), aRect.Bottom()));
3123  }
3124  else
3125  {
3126  aInnerPoly.setClosed(true);
3127  }
3128 
3129  aPoly.append(aInnerPoly);
3130  }
3131  break;
3132  case OBJ_LINE :
3133  {
3134  sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
3135  basegfx::B2DPolygon aTempPoly;
3136  aTempPoly.append(basegfx::B2DPoint(aRect.TopLeft().getX(), nYMiddle));
3137  aTempPoly.append(basegfx::B2DPoint(aRect.BottomRight().getX(), nYMiddle));
3138  aPoly.append(aTempPoly);
3139 
3141  SetLineEnds(aAttr, *pObj, nSlotId);
3142  pObj->SetMergedItemSet(aAttr);
3143  }
3144  break;
3145  default:
3146  break;
3147  }
3148 
3149  pPathObj->SetPathPoly(aPoly);
3150  }
3151  else if(auto pMeasureObj = dynamic_cast<SdrMeasureObj*>( pObj))
3152  {
3153  sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
3154  pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
3155  pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1);
3156 
3158  SetLineEnds(aAttr, *pObj, nSlotId);
3159  pObj->SetMergedItemSet(aAttr);
3160  }
3161  else if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj))
3162  {
3163  bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
3164  SID_DRAW_CAPTION_VERTICAL == nSlotId );
3165  pCaptionObj->SetVerticalWriting(bVerticalText);
3166  if(bVerticalText)
3167  {
3168  SfxItemSet aSet(pObj->GetMergedItemSet());
3171  pObj->SetMergedItemSet(aSet);
3172  }
3173 
3174  pCaptionObj->SetLogicRect(aRect);
3175  pCaptionObj->SetTailPos(
3176  aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
3177  }
3178  else if(auto pText = dynamic_cast<SdrTextObj*>( pObj))
3179  {
3180  pText->SetLogicRect(aRect);
3181 
3182  bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotId);
3183  bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nSlotId);
3184 
3185  pText->SetVerticalWriting(bVertical);
3186 
3187  if(bVertical)
3188  {
3189  SfxItemSet aSet(pDrawModel->GetItemPool());
3190  aSet.Put(makeSdrTextAutoGrowWidthItem(true));
3191  aSet.Put(makeSdrTextAutoGrowHeightItem(false));
3194  pText->SetMergedItemSet(aSet);
3195  }
3196 
3197  if(bMarquee)
3198  {
3199  SfxItemSet aSet(pDrawModel->GetItemPool(), svl::Items<SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST>);
3200  aSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
3201  aSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
3202  aSet.Put( SdrTextAniKindItem( SdrTextAniKind::Slide ) );
3203  aSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) );
3204  aSet.Put( SdrTextAniCountItem( 1 ) );
3205  aSet.Put( SdrTextAniAmountItem( static_cast<sal_Int16>(GetWin()->PixelToLogic(Size(2,1)).Width())) );
3206  pObj->SetMergedItemSetAndBroadcast(aSet);
3207  }
3208  }
3209  SdrPageView* pPageView = pDrawView->GetSdrPageView();
3210  SdrCreateView::SetupObjLayer(pPageView, pDrawView->GetActiveLayer(), pObj);
3211  // switch undo off or this combined with ImpEndCreate will cause two undos
3212  // see comment made in SwFEShell::EndCreate (we create our own undo-object!)
3213  const bool bUndo(GetDoc()->GetIDocumentUndoRedo().DoesUndo());
3214  GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
3215  pDrawView->InsertObjectAtView(pObj, *pPageView);
3216  GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo);
3217  }
3218  ImpEndCreate();
3219 }
3220 
3231 {
3232  Color aRetColor;
3233 
3234  // check, if a draw view exists
3235  OSL_ENSURE( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackground - no draw view!");
3236  if( Imp()->GetDrawView() )
3237  {
3238  // determine list of selected objects
3239  const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3240  // check, if exactly one object is selected.
3241  OSL_ENSURE( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackground - no selected object!");
3242  if ( pMrkList->GetMarkCount() == 1)
3243  {
3244  // get selected object
3245  const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3246  // check, if selected object is a shape (drawing object)
3247  OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr, "wrong usage of SwFEShell::GetShapeBackground - selected object is not a drawing object!");
3248  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr )
3249  {
3250  // determine page frame of the frame the shape is anchored.
3251  const SwFrame* pAnchorFrame =
3252  static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrame( pSdrObj );
3253  OSL_ENSURE( pAnchorFrame, "inconsistent model - no anchor at shape!");
3254  if ( pAnchorFrame )
3255  {
3256  const SwPageFrame* pPageFrame = pAnchorFrame->FindPageFrame();
3257  OSL_ENSURE( pPageFrame, "inconsistent model - no page!");
3258  if ( pPageFrame )
3259  {
3260  aRetColor = pPageFrame->GetDrawBackgroundColor();
3261  }
3262  }
3263  }
3264  }
3265  }
3266 
3267  return aRetColor;
3268 }
3269 
3279 {
3280  bool bRet = false;
3281 
3282  // check, if a draw view exists
3283  OSL_ENSURE( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackground - no draw view!");
3284  if( Imp()->GetDrawView() )
3285  {
3286  // determine list of selected objects
3287  const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3288  // check, if exactly one object is selected.
3289  OSL_ENSURE( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackground - no selected object!");
3290  if ( pMrkList->GetMarkCount() == 1)
3291  {
3292  // get selected object
3293  const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3294  // check, if selected object is a shape (drawing object)
3295  OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr, "wrong usage of SwFEShell::GetShapeBackground - selected object is not a drawing object!");
3296  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr )
3297  {
3298  // determine page frame of the frame the shape is anchored.
3299  const SwFrame* pAnchorFrame =
3300  static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrame( pSdrObj );
3301  OSL_ENSURE( pAnchorFrame, "inconsistent model - no anchor at shape!");
3302  if ( pAnchorFrame )
3303  {
3304  const SwPageFrame* pPageFrame = pAnchorFrame->FindPageFrame();
3305  OSL_ENSURE( pPageFrame, "inconsistent model - no page!");
3306  if ( pPageFrame )
3307  {
3308  bRet = pPageFrame->IsRightToLeft();
3309  }
3310  }
3311  }
3312  }
3313  }
3314 
3315  return bRet;
3316 }
3317 
3319 {
3320  Point aRet(-1, -1);
3321  const SwFrame *pPage = GetLayout()->Lower();
3322  while ( pPage && !pPage->getFrameArea().IsInside( rDocPos ) )
3323  {
3324  pPage = pPage->GetNext();
3325  }
3326  if(pPage)
3327  {
3328  aRet = rDocPos - pPage->getFrameArea().TopLeft();
3329  }
3330  return aRet;
3331 }
3332 
3333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool lcl_IsControlGroup(const SdrObject *pObj)
Definition: feshview.cxx:1522
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:548
SwRect GetBoundRectOfAnchoredObj(const SdrObject *pObj)
returns the BoundRect inclusive distance of the object.
Definition: dcontact.cxx:154
constexpr tools::Long MM50
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:78
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2783
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:313
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:2860
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:856
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
void UnGroupSelection()
The individual objects are selected, but it is possible that there are groups included.
Definition: feshview.cxx:2565
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
void KillPams()
Definition: crsrsh.cxx:1022
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4017
void Right(const tools::Long nRight)
Definition: swrect.hxx:199
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:2877
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:2794
void ChgAnchor(RndStdIds eAnchorId, bool bSameOnly=false, bool bPosCorr=true)
frmatr.hxx.
Definition: feshview.cxx:2348
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
bool IsUnGroupAllowed() const
Definition: feshview.cxx:2533
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
static bool isTextBoxShapeHasValidTextFrame(SwFrameFormat *pShape)
Returns true if the given shape has a valid textframe.
void SetShiftPressed(bool bShiftPressed)
bool IsInSct() const
Definition: frame.hxx:964
bool IsRotationOfSwGrfNodePossible() const
Definition: feshview.cxx:1265
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:679
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
static constexpr auto Items
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:194
SwNodeIndex nNode
Definition: pam.hxx:37
Color GetDrawBackgroundColor() const
SwPageFrame::GetDrawBackgroundColor.
Definition: paintfrm.cxx:7105
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
void GroupSelection()
Afterwards the group is selected.
Definition: feshview.cxx:2550
void SetHitTolerancePixel(sal_uInt16 nVal)
void MirrorSelection(bool bHorizontal)
Vertical if FALSE.
Definition: feshview.cxx:2579
bool AreObjectsMarked() const
void MirrorAllMarkedHorizontal()
SdrTextObj * GetTextEditObject() const
void SelectionToHeaven()
Above document.
Definition: feshview.cxx:1230
#define MINFLY
Definition: swtypes.hxx:60
long Long
Size GetObjSize() const
Definition: feshview.cxx:2379
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
#define CNT_GRF
Definition: editsh.hxx:130
virtual void InsertPage(SdrPage *pPage, sal_uInt16 nPos=0xFFFF)
static bool DoTextBoxZOrderCorrection(SwFrameFormat *pShape)
bool EndDragObj(bool bCopy=false)
OBJ_LINE
void MovInsObjPoint(const Point &rPnt)
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:915
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:1152
void CheckUnboundObjects()
Temporary work around for bug.
Definition: feshview.cxx:2799
size_t GetObjCount() const
OBJ_POLY
TElementType * Next()
Definition: calbck.hxx:333
Color GetShapeBackground() const
SwFEShell::GetShapeBackground.
Definition: feshview.cxx:3230
bool KnowsFormat(const SwFormat &rFormat) const
Definition: wsfrm.cxx:333
virtual void MakeSelVisible()
show the current selected "object"
Definition: crsrsh.cxx:3080
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:399
void InvalidatePos()
Definition: frame.hxx:1040
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
bool HasDrawView() const
Definition: vnew.cxx:361
OBJ_CARC
SwNode & GetNode() const
Definition: ndindex.hxx:119
SdrInventor
SdrMark * GetMark(size_t nNum) const
void Pos(const Point &rNew)
Definition: swrect.hxx:168
SwFrame * FindNext()
Definition: frame.hxx:1138
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:2427
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1295
static void Free(SdrObject *&_rpObject)
virtual SdrObjKind GetObjIdentifier() const
void ClearCharRectAndTopOfLine()
reset members and
bool EndMark()
Definition: feshview.cxx:2261
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)
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
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:360
bool BegMarkPoints(const Point &rPnt, bool bUnmark=false)
const SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false) const
Definition: feshview.cxx:2657
Point GetRelativePagePosition(const Point &rDocPos)
Convert document position into position relative to the current page.
Definition: feshview.cxx:3318
virtual const tools::Rectangle & GetSnapRect() const
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:218
Point TopLeft() const
Definition: swrect.cxx:174
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:1207
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
Definition: feshview.cxx:2662
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
tools::Long Left() const
bool IsMore() const
SwIndex nContent
Definition: pam.hxx:38
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:804
Destination and/or source not found.
const SwRect & getFrameArea() const
Definition: frame.hxx:178
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:451
tools::Long GetSectionWidth(SwFormat const &rFormat) const
Width of current range for column-dialog.
Definition: feshview.cxx:2984
int nCount
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
tools::Long Bottom() const
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2560
bool IsTextFrame() const
Definition: frame.hxx:1231
Point GetAnchorObjDiff() const
Methods for status line.
Definition: feshview.cxx:2392
void MakeNameUnique()
constexpr tools::Long GetWidth() const
void Width(tools::Long nNew)
Definition: swrect.hxx:186
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
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
constexpr SdrLayerID SDRLAYER_NOTFOUND(0xff)
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1108
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:1770
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:215
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir) override
Definition: atrfrm.cxx:3508
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:2421
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:2593
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:2652
const OUString & GetName() const
SdrObject * GetMarkedSdrObj() const
Point BottomRight() 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:2770
bool IsShapeDefaultHoriTextDirR2L() const
Is default horizontal text direction for selected drawing object right-to-left.
Definition: feshview.cxx:3278
OUString SvxResId(std::string_view aId)
OBJ_PATHFILL
Style of a layout element.
Definition: frmfmt.hxx:58
SdrDragMethod * GetDragMethod() const
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1269
SwNodeType
Definition: ndtyp.hxx:28
bool IsContentFrame() const
Definition: frame.hxx:1227
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:2745
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:679
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:1558
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool ActionPend() const
Definition: viewsh.hxx:196
TElementType * First()
Definition: calbck.hxx:325
OBJ_CAPTION
SwContentNode * GetContentNode()
Definition: node.hxx:616
void SelectionHasChanged(SwFEShell *pShell)
Definition: fly.cxx:1832
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:1166
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SwLayoutFrame * GetUpper()
Definition: frame.hxx:677
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
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
bool IsGroupAllowed() const
Definition: feshview.cxx:2473
bool IsGroupObject() const
SwFrame * GetPrev()
Definition: frame.hxx:676
bool IsContentProtected() const
void BegMarkObj(const Point &rPnt, bool bUnmark=false)
bool IsInside(const Point &rPOINT) const
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:3012
#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:2855
void MergeValues(const SfxItemSet &rSet)
void BreakCreate()
Definition: feshview.cxx:2210
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:2243
void SelectionToTop(bool bTop=true)
Move selection upwards or downwards (Z-Order).
Definition: feshview.cxx:1043
tools::Long Top() const
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:2318
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:50
FlyProtectFlags IsSelObjProtected(FlyProtectFlags eType) const
Which Protection is set at selected object?
Definition: feshview.cxx:2682
OUString GetName() const
const long LONG_MAX
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
virtual const SdrObject * GetMaster() const =0
virtual SdrInventor GetObjInventor() const
void HideChainMarker()
Definition: feshview.cxx:2929
void MovMarkPoints(const Point &rPnt)
constexpr Point TopLeft() const
virtual SdrLayerID GetHellId() const =0
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1112
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
SAL_DLLPRIVATE bool ImpEndCreate()
Definition: feshview.cxx:1849
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:1740
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:208
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void MoveCreate(const Point &rPos)
Definition: feshview.cxx:1812
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:279
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:154
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
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
constexpr Point TopRight() const
bool IsNoTextFrame() const
Definition: frame.hxx:1235
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1765
#define SW_ENTER_GROUP
Definition: fesh.hxx:166
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
sal_uInt16 GetHitTolerancePixel() const
bool IsRightToLeft() const
Definition: frame.hxx:984
void Top(const tools::Long nTop)
Definition: swrect.hxx:203
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:1175
void DelSelectedObj()
Definition: feshview.cxx:2366
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:2768
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
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:1056
void SetChainMarker()
Definition: feshview.cxx:2935
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
sal_uInt16 GetMarkHdlSizePixel() const
OBJ_PATHLINE
bool IsVertical() const
Definition: frame.hxx:970
bool IsDragObj() const
bool BeginMark(const Point &rPos)
Functions for Rubberbox, it selects Draw-Objects.
Definition: feshview.cxx:2222
bool g_bNoInterrupt
Definition: swmodule.cxx:115
void Unchain(SwFrameFormat &rFormat)
Definition: feshview.cxx:2922
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:759
constexpr SwTwips lMinBorder
Definition: swtypes.hxx:72
#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:295
virtual void MakeSelVisible() override
Show current selection (frame / draw object as required).
Definition: feshview.cxx:2669
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
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:2899
bool IsOver(const SwRect &rRect) const
Definition: swrect.cxx:123
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:2217
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:190
SdrModel * GetModel() const
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1248
virtual void NbcSetRelativePos(const Point &rPnt)
SdrObjUserCall * GetUserCall() const
const SwPosition & GetContentAnchor() const
Definition: dcontact.hxx:152
bool Is3DObj() const
SwChainRet
Definition: flyenum.hxx:33
bool IsFrameSelected() const
Definition: feshview.cxx:1248
tools::Long Right() const
virtual bool IsTextBox() const override
Definition: dflyobj.cxx:1293
bool MoveAnchor(SwMove nDir)
Definition: feshview.cxx:358
Point Center() const
bool IsMoveProtect() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:850
sal_Int16 nValue
SDRTEXTVERTADJUST_CENTER
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1583
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:1823
FrameTypeFlags GetSelFrameType() const
Definition: feshview.cxx:600
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dflyobj.cxx:560
SwFrame * GetNext()
Definition: frame.hxx:675
SdrObject * GetCurrentGroup() const