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