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