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