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( PrepareHint::FlyFrameAttributesChanged );
891  pCnt = pCnt->GetNextContentFrame();
892  }
893  }
894  if ( bCheckNeighbours && pAct->IsFlyAtContentFrame() )
895  {
896  const SwFormatHoriOrient &rH = pAct->GetFormat()->GetHoriOrient();
897  if ( rH.GetHoriOrient() == aHori &&
898  pAct->getFrameArea().Top() <= aRect.Bottom() &&
899  pAct->getFrameArea().Bottom() >= aRect.Top() )
900  {
901  pAct->InvalidatePos();
903  aFrm.Pos().AdjustY(1 );
904  }
905  }
906  }
907  }
908 }
909 
910 void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj, sal_uInt16 nSlotId)
911 {
912  SdrModel& rModel(rObj.getSdrModelFromSdrObject());
913 
914  if ( !(nSlotId == SID_LINE_ARROW_START ||
915  nSlotId == SID_LINE_ARROW_END ||
916  nSlotId == SID_LINE_ARROWS ||
917  nSlotId == SID_LINE_ARROW_CIRCLE ||
918  nSlotId == SID_LINE_CIRCLE_ARROW ||
919  nSlotId == SID_LINE_ARROW_SQUARE ||
920  nSlotId == SID_LINE_SQUARE_ARROW ||
921  nSlotId == SID_DRAW_MEASURELINE) )
922  return;
923 
924  // set attributes of line start and ends
925 
926  // arrowhead
927  ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) );
928  if( !aArrow.count() )
929  {
930  ::basegfx::B2DPolygon aNewArrow;
931  aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0));
932  aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0));
933  aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0));
934  aNewArrow.setClosed(true);
935  aArrow.append(aNewArrow);
936  }
937 
938  // Circles
939  ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) );
940  if( !aCircle.count() )
941  {
942  ::basegfx::B2DPolygon aNewCircle = ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0);
943  aNewCircle.setClosed(true);
944  aCircle.append(aNewCircle);
945  }
946 
947  // Square
948  ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) );
949  if( !aSquare.count() )
950  {
951  ::basegfx::B2DPolygon aNewSquare;
952  aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0));
953  aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0));
954  aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0));
955  aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0));
956  aNewSquare.setClosed(true);
957  aSquare.append(aNewSquare);
958  }
959 
960  SfxItemSet aSet( rModel.GetItemPool() );
961  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_CIRCLE_ARROW:
1009  {
1010  // circle start
1011  rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
1012  rAttr.Put(XLineStartWidthItem(nWidth));
1013  }
1014  break;
1015 
1016  case SID_LINE_ARROW_SQUARE:
1017  {
1018  // square end
1019  rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
1020  rAttr.Put(XLineEndWidthItem(nWidth));
1021  }
1022  break;
1023 
1024  case SID_LINE_SQUARE_ARROW:
1025  {
1026  // square start
1027  rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
1028  rAttr.Put(XLineStartWidthItem(nWidth));
1029  }
1030  break;
1031  }
1032 
1033 }
1034 
1035 void SwFEShell::SelectionToTop( bool bTop )
1036 {
1037  OSL_ENSURE( Imp()->HasDrawView(), "SelectionToTop without DrawView?" );
1038  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1039  OSL_ENSURE( rMrkList.GetMarkCount(), "No object selected." );
1040 
1041  SwFlyFrame *pFly = ::GetFlyFromMarked( &rMrkList, this );
1042  if ( pFly && pFly->IsFlyInContentFrame() )
1043  return;
1044 
1045  StartAllAction();
1046  if ( bTop )
1047  Imp()->GetDrawView()->PutMarkedToTop();
1048  else
1049  Imp()->GetDrawView()->MovMarkedToTop();
1050  ::lcl_NotifyNeighbours( &rMrkList );
1051  GetDoc()->getIDocumentState().SetModified();
1052  EndAllAction();
1053 }
1054 
1055 void SwFEShell::SelectionToBottom( bool bBottom )
1056 {
1057  OSL_ENSURE( Imp()->HasDrawView(), "SelectionToBottom without DrawView?" );
1058  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1059  OSL_ENSURE( rMrkList.GetMarkCount(), "No object selected." );
1060 
1061  SwFlyFrame *pFly = ::GetFlyFromMarked( &rMrkList, this );
1062  if ( pFly && pFly->IsFlyInContentFrame() )
1063  return;
1064 
1065  StartAllAction();
1066  if ( bBottom )
1067  Imp()->GetDrawView()->PutMarkedToBtm();
1068  else
1069  Imp()->GetDrawView()->MovMarkedToBtm();
1070  ::lcl_NotifyNeighbours( &rMrkList );
1071  GetDoc()->getIDocumentState().SetModified();
1072  EndAllAction();
1073 }
1074 
1075 // Object above/below the document? 2 Controls, 1 Heaven, 0 Hell,
1076 // SDRLAYER_NOTFOUND Ambiguous
1078 {
1079  if ( !Imp()->HasDrawView() )
1080  return SDRLAYER_NOTFOUND;
1081 
1083  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1084  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
1085  {
1086  const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1087  if( !pObj )
1088  continue;
1089  if ( nRet == SDRLAYER_NOTFOUND )
1090  nRet = pObj->GetLayer();
1091  else if ( nRet != pObj->GetLayer() )
1092  {
1093  return SDRLAYER_NOTFOUND;
1094  }
1095  }
1096  return nRet;
1097 }
1098 
1099 // Object above/below the document
1100 // Note: only visible objects can be marked. Thus, objects with invisible
1101 // layer IDs have not to be considered.
1102 // If <SwFEShell> exists, layout exists!!
1104 {
1105  if ( Imp()->HasDrawView() )
1106  {
1107  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1108  const IDocumentDrawModelAccess& rIDDMA = getIDocumentDrawModelAccess();
1109  // correct type of <nControls>
1110  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
1111  {
1112  SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1113  if( !pObj )
1114  continue;
1115  // or group objects containing controls.
1116  // --> #i113730#
1117  // consider that a member of a drawing group has been selected.
1118  const SwContact* pContact = ::GetUserCall( pObj );
1119  OSL_ENSURE( pContact && pContact->GetMaster(), "<SwFEShell::ChangeOpaque(..)> - missing contact or missing master object at contact!" );
1120  const bool bControlObj = ( pContact && pContact->GetMaster() )
1121  ? ::CheckControlLayer( pContact->GetMaster() )
1122  : ::CheckControlLayer( pObj );
1123  if ( !bControlObj && pObj->GetLayer() != nLayerId )
1124  {
1125  pObj->SetLayer( nLayerId );
1126  InvalidateWindows( SwRect( pObj->GetCurrentBoundRect() ) );
1127  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
1128  {
1129  SwFormat *pFormat = pVirtO->GetFlyFrame()->GetFormat();
1130  SvxOpaqueItem aOpa( pFormat->GetOpaque() );
1131  aOpa.SetValue( nLayerId == rIDDMA.GetHellId() );
1132  pFormat->SetFormatAttr( aOpa );
1133  }
1134  }
1135  }
1136  GetDoc()->getIDocumentState().SetModified();
1137  }
1138 }
1139 
1141 {
1142  ChangeOpaque( getIDocumentDrawModelAccess().GetHeavenId() );
1143 }
1144 
1146 {
1147  ChangeOpaque( getIDocumentDrawModelAccess().GetHellId() );
1148 }
1149 
1151 {
1152  if ( IsFrameSelected() || !Imp()->HasDrawView() )
1153  return 0;
1154 
1155  return Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount();
1156 }
1157 
1159 {
1160  if ( !Imp()->HasDrawView() )
1161  return false;
1162  else
1163  return nullptr != ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
1164  const_cast<SwFEShell*>(this) );
1165 }
1166 
1167 bool SwFEShell::IsObjSelected( const SdrObject& rObj ) const
1168 {
1169  if ( IsFrameSelected() || !Imp()->HasDrawView() )
1170  return false;
1171  else
1172  return Imp()->GetDrawView()->IsObjMarked( &rObj );
1173 }
1174 
1176 {
1177  // RotGrfFlyFrame: check if RotationMode is possible
1178  const SdrView *pSdrView = Imp()->GetDrawView();
1179 
1180  if(pSdrView)
1181  {
1182  const SdrMarkList& rList(pSdrView->GetMarkedObjectList());
1183 
1184  if(1 == rList.GetMarkCount())
1185  {
1186  const SwVirtFlyDrawObj* pVirtFlyDraw(dynamic_cast< const SwVirtFlyDrawObj* >(rList.GetMark(0)->GetMarkedSdrObj()));
1187 
1188  if(nullptr != pVirtFlyDraw)
1189  {
1190  return pVirtFlyDraw->ContainsSwGrfNode();
1191  }
1192  }
1193  }
1194 
1195  return false;
1196 }
1197 
1199 {
1200  if (pObj)
1201  {
1202  const SdrMarkList& aMarkList = Imp()->GetDrawView()->GetMarkedObjectList();
1203  if (aMarkList.GetMarkCount() == 0)
1204  {
1205  return true;
1206  }
1207  SdrMark* pM=aMarkList.GetMark(0);
1208  if (pM)
1209  {
1210  SdrObject* pMarkObj = pM->GetMarkedSdrObj();
1211  if (pMarkObj && pMarkObj->getParentSdrObjectFromSdrObject() == pObj->getParentSdrObjectFromSdrObject())
1212  return true;
1213  }
1214  }
1215  return false;
1216 }
1217 
1219 {
1220  // Terminate the TextEditMode. If required (default if the object
1221  // does not contain any more text and does not carry attributes) the object
1222  // is deleted. All other objects marked are preserved.
1223 
1224  OSL_ENSURE( Imp()->HasDrawView() && Imp()->GetDrawView()->IsTextEdit(),
1225  "EndTextEdit a no Object" );
1226 
1227  StartAllAction();
1228  SdrView *pView = Imp()->GetDrawView();
1229  SdrObject *pObj = pView->GetTextEditObject();
1230  SdrObjUserCall* pUserCall;
1231  if( nullptr != ( pUserCall = GetUserCall(pObj) ) )
1232  {
1233  SdrObject *pTmp = static_cast<SwContact*>(pUserCall)->GetMaster();
1234  if( !pTmp )
1235  pTmp = pObj;
1236  pUserCall->Changed( *pTmp, SdrUserCallType::Resize, pTmp->GetLastBoundRect() );
1237  }
1238  if ( !pObj->getParentSdrObjectFromSdrObject() )
1239  {
1240  if ( SdrEndTextEditKind::ShouldBeDeleted == pView->SdrEndTextEdit(true) )
1241  {
1242  if ( pView->GetMarkedObjectList().GetMarkCount() > 1 )
1243  {
1244  SdrMarkList aSave( pView->GetMarkedObjectList() );
1245  aSave.DeleteMark( aSave.FindObject( pObj ) );
1246  if ( aSave.GetMarkCount() )
1247  {
1248  pView->UnmarkAll();
1249  pView->MarkObj( pObj, Imp()->GetPageView() );
1250  }
1251  DelSelectedObj();
1252  for ( size_t i = 0; i < aSave.GetMarkCount(); ++i )
1253  pView->MarkObj( aSave.GetMark( i )->GetMarkedSdrObj(), Imp()->GetPageView() );
1254  }
1255  else
1256  DelSelectedObj();
1257  }
1258  }
1259  else
1260  pView->SdrEndTextEdit();
1261 
1263  SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_LOCK, "rectangle", "EMPTY");
1264 
1265  EndAllAction();
1266 }
1267 
1268 bool SwFEShell::IsInsideSelectedObj( const Point &rPt )
1269 {
1270  if( Imp()->HasDrawView() )
1271  {
1272  SwDrawView *pDView = Imp()->GetDrawView();
1273 
1274  if( pDView->GetMarkedObjectList().GetMarkCount() &&
1275  pDView->IsMarkedObjHit( rPt ) )
1276  {
1277  return true;
1278  }
1279  }
1280  return false;
1281 }
1282 
1283 bool SwFEShell::IsObjSelectable( const Point& rPt )
1284 {
1285  SET_CURR_SHELL(this);
1286  SwDrawView *pDView = Imp()->GetDrawView();
1287  bool bRet = false;
1288  if( pDView )
1289  {
1290  SdrPageView* pPV;
1291  const auto nOld = pDView->GetHitTolerancePixel();
1292  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1293 
1294  bRet = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE) != nullptr;
1295  pDView->SetHitTolerancePixel( nOld );
1296  }
1297  return bRet;
1298 }
1299 
1300 SdrObject* SwFEShell::GetObjAt( const Point& rPt )
1301 {
1302  SdrObject* pRet = nullptr;
1303  SET_CURR_SHELL(this);
1304  SwDrawView *pDView = Imp()->GetDrawView();
1305  if( pDView )
1306  {
1307  SdrPageView* pPV;
1308  const auto nOld = pDView->GetHitTolerancePixel();
1309  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1310 
1311  pRet = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE);
1312  pDView->SetHitTolerancePixel( nOld );
1313  }
1314  return pRet;
1315 }
1316 
1317 // Test if there is an object at that position and if it should be selected.
1319 {
1320  SET_CURR_SHELL(this);
1321  SwDrawView *pDrawView = Imp()->GetDrawView();
1322  bool bRet(false);
1323 
1324  if(pDrawView)
1325  {
1326  SdrPageView* pPV;
1327  const auto nOld(pDrawView->GetHitTolerancePixel());
1328 
1329  pDrawView->SetHitTolerancePixel(pDrawView->GetMarkHdlSizePixel()/2);
1330  SdrObject* pObj = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pPV, SdrSearchOptions::PICKMARKABLE);
1331  pDrawView->SetHitTolerancePixel(nOld);
1332 
1333  if (pObj)
1334  {
1335  bRet = true;
1336  const IDocumentDrawModelAccess& rIDDMA = getIDocumentDrawModelAccess();
1337  // #i89920#
1338  // Do not select object in background which is overlapping this text
1339  // at the given position.
1340  bool bObjInBackground( false );
1341  {
1342  if ( pObj->GetLayer() == rIDDMA.GetHellId() )
1343  {
1344  const SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
1345  const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
1346  const SwFormatSurround& rSurround = rFormat.GetSurround();
1347  if ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH )
1348  {
1349  bObjInBackground = true;
1350  }
1351  }
1352  }
1353  if ( bObjInBackground )
1354  {
1355  const SwPageFrame* pPageFrame = GetLayout()->GetPageAtPos( rPt );
1356  if( pPageFrame )
1357  {
1358  const SwContentFrame* pContentFrame( pPageFrame->ContainsContent() );
1359  while ( pContentFrame )
1360  {
1361  if ( pContentFrame->UnionFrame().IsInside( rPt ) )
1362  {
1363  const SwTextFrame* pTextFrame =
1364  dynamic_cast<const SwTextFrame*>(pContentFrame);
1365  if ( pTextFrame )
1366  {
1367  SwPosition aPos(GetDoc()->GetNodes());
1368  Point aTmpPt( rPt );
1369  if (pTextFrame->GetKeyCursorOfst(&aPos, aTmpPt))
1370  {
1371  SwRect aCursorCharRect;
1372  if (pTextFrame->GetCharRect(aCursorCharRect,
1373  aPos))
1374  {
1375  if ( aCursorCharRect.IsOver( SwRect( pObj->GetLastBoundRect() ) ) )
1376  {
1377  bRet = false;
1378  }
1379  }
1380  }
1381  }
1382  else
1383  {
1384  bRet = false;
1385  }
1386  break;
1387  }
1388 
1389  pContentFrame = pContentFrame->GetNextContentFrame();
1390  }
1391  }
1392  }
1393 
1394  // Don't select header / footer objects in body edition and vice-versa
1395  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1396  if (pContact && !pContact->ObjAnchoredAtPage() )
1397  {
1398  const SwPosition& rPos = pContact->GetContentAnchor();
1399  bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
1400  if (IsHeaderFooterEdit() != bInHdrFtr)
1401  {
1402  bRet = false;
1403  }
1404  }
1405 
1406  if ( bRet )
1407  {
1408  const SdrPage* pPage = rIDDMA.GetDrawModel()->GetPage(0);
1409  for(size_t a = pObj->GetOrdNum()+1; bRet && a < pPage->GetObjCount(); ++a)
1410  {
1411  SdrObject *pCandidate = pPage->GetObj(a);
1412 
1413  SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pCandidate);
1414  if (pDrawObj && pDrawObj->GetCurrentBoundRect().IsInside(rPt))
1415  {
1416  bRet = false;
1417  }
1418  }
1419  }
1420  }
1421  }
1422 
1423  return bRet;
1424 }
1425 
1426 /*
1427  * If an object was selected, we assume its upper-left corner
1428  * otherwise the middle of the current CharRects.
1429  * Does the object include a control or groups,
1430  * which comprise only controls
1431  */
1432 static bool lcl_IsControlGroup( const SdrObject *pObj )
1433 {
1434  bool bRet = false;
1435  if(dynamic_cast<const SdrUnoObj*>( pObj) != nullptr)
1436  bRet = true;
1437  else if( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
1438  {
1439  bRet = true;
1440  const SdrObjList *pLst = pObjGroup->GetSubList();
1441  for ( size_t i = 0; i < pLst->GetObjCount(); ++i )
1442  if( !::lcl_IsControlGroup( pLst->GetObj( i ) ) )
1443  return false;
1444  }
1445  return bRet;
1446 }
1447 
1448 namespace
1449 {
1450  class MarkableObjectsOnly : public svx::ISdrObjectFilter
1451  {
1452  public:
1453  explicit MarkableObjectsOnly( SdrPageView* i_pPV )
1454  :m_pPV( i_pPV )
1455  {
1456  }
1457 
1458  virtual bool includeObject( const SdrObject& i_rObject ) const override
1459  {
1460  return m_pPV && m_pPV->GetView().IsObjMarkable( &i_rObject, m_pPV );
1461  }
1462 
1463  private:
1464  SdrPageView* m_pPV;
1465  };
1466 }
1467 
1468 const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool bFlat, const svx::ISdrObjectFilter* pFilter )
1469 {
1470  if( !Imp()->HasDrawView() )
1471  return nullptr;
1472 
1473  const SdrObject *pBest = nullptr,
1474  *pTop = nullptr;
1475 
1476  const long nTmp = bNext ? LONG_MAX : 0;
1477  Point aBestPos( nTmp, nTmp );
1478  Point aTopPos( nTmp, nTmp );
1479  Point aCurPos;
1480  Point aPos;
1481  bool bNoDraw((GotoObjFlags::DrawAny & eType) == GotoObjFlags::NONE);
1482  bool bNoFly((GotoObjFlags::FlyAny & eType) == GotoObjFlags::NONE);
1483 
1484  if( !bNoFly && bNoDraw )
1485  {
1486  SwFlyFrame *pFly = GetCurrFrame( false )->FindFlyFrame();
1487  if( pFly )
1488  pBest = pFly->GetVirtDrawObj();
1489  }
1490  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1491  SdrPageView* pPV = Imp()->GetDrawView()->GetSdrPageView();
1492 
1493  MarkableObjectsOnly aDefaultFilter( pPV );
1494  if ( !pFilter )
1495  pFilter = &aDefaultFilter;
1496 
1497  if( !pBest || rMrkList.GetMarkCount() == 1 )
1498  {
1499  // Determine starting point
1500  SdrObjList* pList = nullptr;
1501  if ( rMrkList.GetMarkCount() )
1502  {
1503  const SdrObject* pStartObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
1504  if( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pStartObj) )
1505  aPos = pVirtFlyDrawObj->GetFlyFrame()->getFrameArea().Pos();
1506  else
1507  aPos = pStartObj->GetSnapRect().TopLeft();
1508 
1509  // If an object inside a group is selected, we want to
1510  // iterate over the group members.
1511  if ( ! pStartObj->GetUserCall() )
1512  pList = pStartObj->getParentSdrObjListFromSdrObject();
1513  }
1514  else
1515  {
1516  // If no object is selected, we check if we just entered a group.
1517  // In this case we want to iterate over the group members.
1518  aPos = GetCharRect().Center();
1519  const SdrObject* pStartObj = pPV ? pPV->GetCurrentGroup() : nullptr;
1520  if ( dynamic_cast<const SdrObjGroup*>( pStartObj) )
1521  pList = pStartObj->GetSubList();
1522  }
1523 
1524  if ( ! pList )
1525  {
1526  // Here we are if
1527  // A No object has been selected and no group has been entered or
1528  // B An object has been selected and it is not inside a group
1529  pList = getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 );
1530  }
1531 
1532  OSL_ENSURE( pList, "No object list to iterate" );
1533 
1534  SdrObjListIter aObjIter( pList, bFlat ? SdrIterMode::Flat : SdrIterMode::DeepNoGroups );
1535  while ( aObjIter.IsMore() )
1536  {
1537  SdrObject* pObj = aObjIter.Next();
1538  SwVirtFlyDrawObj *pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1539  if( ( bNoFly && pVirtO ) ||
1540  ( bNoDraw && !pVirtO ) ||
1541  // Ignore TextBoxes of draw shapes here, so that
1542  // SwFEShell::SelectObj() won't jump back on this list, meaning
1543  // we never jump to the next draw shape.
1544  (pVirtO && pVirtO->IsTextBox()) ||
1545  ( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) ||
1546  ( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
1547  !pFilter->includeObject( *pObj ) )
1548  continue;
1549  if (pVirtO)
1550  {
1551  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
1552  if( GotoObjFlags::FlyAny != ( GotoObjFlags::FlyAny & eType ) )
1553  {
1554  switch ( eType )
1555  {
1557  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1558  continue;
1559  break;
1560  case GotoObjFlags::FlyGrf:
1561  if ( pFly->Lower() &&
1562  (!pFly->Lower()->IsNoTextFrame() ||
1563  !static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode()))
1564  continue;
1565  break;
1566  case GotoObjFlags::FlyOLE:
1567  if ( pFly->Lower() &&
1568  (!pFly->Lower()->IsNoTextFrame() ||
1569  !static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode()))
1570  continue;
1571  break;
1572  default: break;
1573  }
1574  }
1575  aCurPos = pFly->getFrameArea().Pos();
1576  }
1577  else
1578  aCurPos = pObj->GetSnapRect().TopLeft();
1579 
1580  // Special case if another object is on same Y.
1581  if( aCurPos != aPos && // only when it is not me
1582  aCurPos.getY() == aPos.getY() && // Y positions equal
1583  (bNext? (aCurPos.getX() > aPos.getX()) : // lies next to me
1584  (aCurPos.getX() < aPos.getX())) ) // " reverse
1585  {
1586  aBestPos = Point( nTmp, nTmp );
1587  SdrObjListIter aTmpIter( pList, bFlat ? SdrIterMode::Flat : SdrIterMode::DeepNoGroups );
1588  while ( aTmpIter.IsMore() )
1589  {
1590  SdrObject* pTmpObj = aTmpIter.Next();
1591  pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pTmpObj);
1592  if( ( bNoFly && pVirtO ) || ( bNoDraw && !pVirtO ) )
1593  continue;
1594  if (pVirtO)
1595  {
1596  aCurPos = pVirtO->GetFlyFrame()->getFrameArea().Pos();
1597  }
1598  else
1599  aCurPos = pTmpObj->GetCurrentBoundRect().TopLeft();
1600 
1601  if( aCurPos != aPos && aCurPos.Y() == aPos.Y() &&
1602  (bNext? (aCurPos.getX() > aPos.getX()) : // lies next to me
1603  (aCurPos.getX() < aPos.getX())) && // " reverse
1604  (bNext? (aCurPos.getX() < aBestPos.getX()) : // better as best
1605  (aCurPos.getX() > aBestPos.getX())) ) // " reverse
1606  {
1607  aBestPos = aCurPos;
1608  pBest = pTmpObj;
1609  }
1610  }
1611  break;
1612  }
1613 
1614  if( (
1615  (bNext? (aPos.getY() < aCurPos.getY()) : // only below me
1616  (aPos.getY() > aCurPos.getY())) && // " reverse
1617  (bNext? (aBestPos.getY() > aCurPos.getY()) : // closer below
1618  (aBestPos.getY() < aCurPos.getY()))
1619  ) || // " reverse
1620  (aBestPos.getY() == aCurPos.getY() &&
1621  (bNext? (aBestPos.getX() > aCurPos.getX()) : // further left
1622  (aBestPos.getX() < aCurPos.getX())))) // " reverse
1623 
1624  {
1625  aBestPos = aCurPos;
1626  pBest = pObj;
1627  }
1628 
1629  if( (bNext? (aTopPos.getY() > aCurPos.getY()) : // higher as best
1630  (aTopPos.getY() < aCurPos.getY())) || // " reverse
1631  (aTopPos.getY() == aCurPos.getY() &&
1632  (bNext? (aTopPos.getX() > aCurPos.getX()) : // further left
1633  (aTopPos.getX() < aCurPos.getX())))) // " reverse
1634  {
1635  aTopPos = aCurPos;
1636  pTop = pObj;
1637  }
1638  }
1639  // unfortunately nothing found
1640  if( bNext ? (aBestPos.getX() == LONG_MAX) : (aBestPos.getX() == 0) )
1641  {
1642  pBest = pTop;
1643  SvxSearchDialogWrapper::SetSearchLabel( bNext ? SearchLabel::EndWrapped : SearchLabel::StartWrapped );
1644  }
1645  }
1646 
1647  return pBest;
1648 }
1649 
1650 bool SwFEShell::GotoObj( bool bNext, GotoObjFlags eType )
1651 {
1652  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
1653 
1654  const SdrObject* pBest = GetBestObject( bNext, eType );
1655 
1656  if ( !pBest )
1657  {
1658  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
1659  return false;
1660  }
1661 
1662  const SwVirtFlyDrawObj *pVirtO = dynamic_cast<const SwVirtFlyDrawObj*>(pBest);
1663  if (pVirtO)
1664  {
1665  const SwRect& rFrame = pVirtO->GetFlyFrame()->getFrameArea();
1666  SelectObj( rFrame.Pos(), 0, const_cast<SdrObject*>(pBest) );
1667  if( !ActionPend() )
1668  MakeVisible( rFrame );
1669  }
1670  else
1671  {
1672  SelectObj( Point(), 0, const_cast<SdrObject*>(pBest) );
1673  if( !ActionPend() )
1674  MakeVisible( pBest->GetCurrentBoundRect() );
1675  }
1676  CallChgLnk();
1677  return true;
1678 }
1679 
1680 bool SwFEShell::BeginCreate( sal_uInt16 /*SdrObjKind ?*/ eSdrObjectKind, const Point &rPos )
1681 {
1682  bool bRet = false;
1683 
1684  if ( !Imp()->HasDrawView() )
1685  Imp()->MakeDrawView();
1686 
1687  if ( GetPageNumber( rPos ) )
1688  {
1689  Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind );
1690  if ( eSdrObjectKind == OBJ_CAPTION )
1691  bRet = Imp()->GetDrawView()->BegCreateCaptionObj(
1692  rPos, Size( lMinBorder - MINFLY, lMinBorder - MINFLY ),
1693  GetOut() );
1694  else
1695  bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1696  }
1697  if ( bRet )
1698  {
1699  ::FrameNotify( this, FLY_DRAG_START );
1700  }
1701  return bRet;
1702 }
1703 
1704 bool SwFEShell::BeginCreate( sal_uInt16 /*SdrObjKind ?*/ eSdrObjectKind, SdrInventor eObjInventor,
1705  const Point &rPos )
1706 {
1707  bool bRet = false;
1708 
1709  if ( !Imp()->HasDrawView() )
1710  Imp()->MakeDrawView();
1711 
1712  if ( GetPageNumber( rPos ) )
1713  {
1714  Imp()->GetDrawView()->SetCurrentObj( eSdrObjectKind, eObjInventor );
1715  bRet = Imp()->GetDrawView()->BegCreateObj( rPos, GetOut() );
1716  }
1717  if ( bRet )
1718  ::FrameNotify( this, FLY_DRAG_START );
1719  return bRet;
1720 }
1721 
1722 void SwFEShell::MoveCreate( const Point &rPos )
1723 {
1724  OSL_ENSURE( Imp()->HasDrawView(), "MoveCreate without DrawView?" );
1725  if ( GetPageNumber( rPos ) )
1726  {
1727  ScrollTo( rPos );
1728  Imp()->GetDrawView()->MovCreateObj( rPos );
1729  ::FrameNotify( this );
1730  }
1731 }
1732 
1733 bool SwFEShell::EndCreate( SdrCreateCmd eSdrCreateCmd )
1734 {
1735  // To assure undo-object from the DrawEngine is not stored,
1736  // (we create our own undo-object!), temporarily switch-off Undo
1737  OSL_ENSURE( Imp()->HasDrawView(), "EndCreate without DrawView?" );
1738  if( !Imp()->GetDrawView()->IsGroupEntered() )
1739  {
1740  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
1741  }
1742  bool bCreate = Imp()->GetDrawView()->EndCreateObj( eSdrCreateCmd );
1743  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
1744 
1745  if ( !bCreate )
1746  {
1747  ::FrameNotify( this, FLY_DRAG_END );
1748  return false;
1749  }
1750 
1751  if ( eSdrCreateCmd == SdrCreateCmd::NextPoint )
1752  {
1753  ::FrameNotify( this );
1754  return true;
1755  }
1756  return ImpEndCreate();
1757 }
1758 
1760 {
1761  OSL_ENSURE( Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1,
1762  "New object not selected." );
1763 
1764  SdrObject& rSdrObj = *Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1765 
1766  if( rSdrObj.GetSnapRect().IsEmpty() )
1767  {
1768  // preferably we forget the object, only gives problems
1769  Imp()->GetDrawView()->DeleteMarked();
1770  Imp()->GetDrawView()->UnmarkAll();
1771  ::FrameNotify( this, FLY_DRAG_END );
1772  return false;
1773  }
1774 
1775  if( rSdrObj.getParentSdrObjectFromSdrObject() )
1776  {
1777  Point aTmpPos( rSdrObj.GetSnapRect().TopLeft() );
1778  Point aNewAnchor( rSdrObj.getParentSdrObjectFromSdrObject()->GetAnchorPos() );
1779  // OD 2004-04-05 #i26791# - direct object positioning for group members
1780  rSdrObj.NbcSetRelativePos( aTmpPos - aNewAnchor );
1781  rSdrObj.NbcSetAnchorPos( aNewAnchor );
1782  ::FrameNotify( this );
1783  return true;
1784  }
1785 
1786  LockPaint();
1787  StartAllAction();
1788 
1789  Imp()->GetDrawView()->UnmarkAll();
1790 
1791  const tools::Rectangle &rBound = rSdrObj.GetSnapRect();
1792  Point aPt( rBound.TopRight() );
1793 
1794  // alien identifier should end up on defaults
1795  // duplications possible!!
1796  sal_uInt16 nIdent = SdrInventor::Default == rSdrObj.GetObjInventor()
1797  ? rSdrObj.GetObjIdentifier()
1798  : 0xFFFF;
1799 
1800  // default for controls character bound, otherwise paragraph bound.
1801  SwFormatAnchor aAnch;
1802  const SwFrame *pAnch = nullptr;
1803  bool bCharBound = false;
1804  if( dynamic_cast<const SdrUnoObj*>( &rSdrObj) != nullptr )
1805  {
1806  SwPosition aPos( GetDoc()->GetNodes() );
1808  Point aPoint( aPt.getX(), aPt.getY() + rBound.GetHeight()/2 );
1809  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
1810 
1811  // characterbinding not allowed in readonly-content
1812  if( !aPos.nNode.GetNode().IsProtect() )
1813  {
1814  std::pair<Point, bool> const tmp(aPoint, true);
1815  pAnch = aPos.nNode.GetNode().GetContentNode()->getLayoutFrame(GetLayout(), &aPos, &tmp);
1816  SwRect aTmp;
1817  pAnch->GetCharRect( aTmp, aPos );
1818 
1819  // The crsr should not be too far away
1820  bCharBound = true;
1821  tools::Rectangle aRect( aTmp.SVRect() );
1822  aRect.AdjustLeft( -(MM50*2) );
1823  aRect.AdjustTop( -(MM50*2) );
1824  aRect.AdjustRight(MM50*2 );
1825  aRect.AdjustBottom(MM50*2 );
1826 
1827  if( !aRect.IsOver( rBound ) && !::GetHtmlMode( GetDoc()->GetDocShell() ))
1828  bCharBound = false;
1829 
1830  // anchor in header/footer also not allowed.
1831  if( bCharBound )
1832  bCharBound = !GetDoc()->IsInHeaderFooter( aPos.nNode );
1833 
1834  if( bCharBound )
1835  {
1836  aAnch.SetType( RndStdIds::FLY_AS_CHAR );
1837  aAnch.SetAnchor( &aPos );
1838  }
1839  }
1840  }
1841 
1842  if( !bCharBound )
1843  {
1844  // allow native drawing objects in header/footer.
1845  // Thus, set <bBodyOnly> to <false> for these objects using value
1846  // of <nIdent> - value <0xFFFF> indicates control objects, which aren't
1847  // allowed in header/footer.
1848  //bool bBodyOnly = OBJ_NONE != nIdent;
1849  bool bBodyOnly = 0xFFFF == nIdent;
1850  bool bAtPage = false;
1851  const SwFrame* pPage = nullptr;
1853  Point aPoint( aPt );
1854  SwPosition aPos( GetDoc()->GetNodes() );
1855  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
1856 
1857  // do not set in ReadnOnly-content
1858  if (aPos.nNode.GetNode().IsProtect())
1859  {
1860  // then only page bound. Or should we
1861  // search the next not-readonly position?
1862  bAtPage = true;
1863  }
1864 
1865  SwContentNode* pCNode = aPos.nNode.GetNode().GetContentNode();
1866  std::pair<Point, bool> const tmp(aPoint, false);
1867  pAnch = pCNode ? pCNode->getLayoutFrame(GetLayout(), nullptr, &tmp) : nullptr;
1868  if (!pAnch)
1869  {
1870  // Hidden content. Anchor to the page instead
1871  bAtPage = true;
1872  }
1873 
1874  if( !bAtPage )
1875  {
1876  const SwFlyFrame *pTmp = pAnch->FindFlyFrame();
1877  if( pTmp )
1878  {
1879  const SwFrame* pTmpFrame = pAnch;
1880  SwRect aBound( rBound );
1881  while( pTmp )
1882  {
1883  if( pTmp->getFrameArea().IsInside( aBound ) )
1884  {
1885  if( !bBodyOnly || !pTmp->FindFooterOrHeader() )
1886  pPage = pTmpFrame;
1887  break;
1888  }
1889  pTmp = pTmp->GetAnchorFrame()
1890  ? pTmp->GetAnchorFrame()->FindFlyFrame()
1891  : nullptr;
1892  pTmpFrame = pTmp;
1893  }
1894  }
1895 
1896  if( !pPage )
1897  pPage = pAnch->FindPageFrame();
1898 
1899  // Always via FindAnchor, to assure the frame will be bound
1900  // to the previous. With GetCrsOfst we can also reach the next. THIS IS WRONG.
1901  pAnch = ::FindAnchor( pPage, aPt, bBodyOnly );
1902  if (pAnch->IsTextFrame())
1903  {
1904  std::pair<SwTextNode const*, sal_Int32> const pos(
1905  static_cast<SwTextFrame const*>(pAnch)->MapViewToModel(TextFrameIndex(0)));
1906  aPos.nNode = *pos.first;
1907  }
1908  else
1909  {
1910  aPos.nNode = *static_cast<const SwNoTextFrame*>(pAnch)->GetNode();
1911  }
1912 
1913  // do not set in ReadnOnly-content
1914  if( aPos.nNode.GetNode().IsProtect() )
1915  // then only page bound. Or should we
1916  // search the next not-readonly position?
1917  bAtPage = true;
1918  else
1919  {
1920  aAnch.SetType( RndStdIds::FLY_AT_PARA );
1921  aAnch.SetAnchor( &aPos );
1922  }
1923  }
1924 
1925  if( bAtPage )
1926  {
1927  pPage = pAnch ? pAnch->FindPageFrame() : GetLayout()->GetPageAtPos(aPoint);
1928 
1929  aAnch.SetType( RndStdIds::FLY_AT_PAGE );
1930  aAnch.SetPageNum( pPage->GetPhyPageNum() );
1931  pAnch = pPage; // page becomes an anchor
1932  }
1933  }
1934 
1935  SfxItemSet aSet( GetDoc()->GetAttrPool(), svl::Items<RES_FRM_SIZE, RES_FRM_SIZE,
1936  RES_SURROUND, RES_ANCHOR>{} );
1937  aSet.Put( aAnch );
1938 
1939  // OD 2004-03-30 #i26791# - determine relative object position
1940  SwTwips nXOffset;
1941  SwTwips nYOffset = rBound.Top() - pAnch->getFrameArea().Top();
1942  {
1943  if( pAnch->IsVertical() )
1944  {
1945  nXOffset = nYOffset;
1946  nYOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
1947  }
1948  else if( pAnch->IsRightToLeft() )
1949  nXOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
1950  else
1951  nXOffset = rBound.Left() - pAnch->getFrameArea().Left();
1952  if (pAnch->IsTextFrame())
1953  {
1954  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
1955  if (pTmp->IsFollow())
1956  {
1957  do {
1958  pTmp = pTmp->FindMaster();
1959  OSL_ENSURE(pTmp, "Where's my Master?");
1960  // OD 2004-03-30 #i26791# - correction: add frame area height
1961  // of master frames.
1962  nYOffset += pTmp->IsVertical() ?
1963  pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height();
1964  } while (pTmp->IsFollow());
1965  }
1966 
1967  nYOffset -= pTmp->GetBaseVertOffsetForFly(false);
1968  }
1969  }
1970 
1971  if( OBJ_NONE == nIdent )
1972  {
1973  // For OBJ_NONE a fly is inserted.
1974  const long nWidth = rBound.Right() - rBound.Left();
1975  const long nHeight= rBound.Bottom() - rBound.Top();
1976  aSet.Put( SwFormatFrameSize( SwFrameSize::Minimum, std::max( nWidth, long(MINFLY) ),
1977  std::max( nHeight, long(MINFLY) )));
1978 
1979  SwFormatHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
1980  SwFormatVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
1981  aSet.Put( SwFormatSurround( css::text::WrapTextMode_PARALLEL ) );
1982  aSet.Put( aHori );
1983  aSet.Put( aVert );
1984 
1985  // Quickly store the square
1986  const SwRect aFlyRect( rBound );
1987 
1988  // Throw away generated object, now the fly can nicely
1989  // via the available SS be generated.
1990  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); // see above
1991  // #i52858# - method name changed
1992  SdrPage *pPg = getIDocumentDrawModelAccess().GetOrCreateDrawModel()->GetPage( 0 );
1993  if( !pPg )
1994  {
1995  SdrModel* pTmpSdrModel = getIDocumentDrawModelAccess().GetDrawModel();
1996  pPg = pTmpSdrModel->AllocPage( false );
1997  pTmpSdrModel->InsertPage( pPg );
1998  }
1999  pPg->RecalcObjOrdNums();
2000  SdrObject* pRemovedObject = pPg->RemoveObject( rSdrObj.GetOrdNumDirect() );
2001  SdrObject::Free( pRemovedObject );
2002  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true);
2003 
2004  SwFlyFrame* pFlyFrame;
2005  if( NewFlyFrame( aSet, true ) &&
2006  ::GetHtmlMode( GetDoc()->GetDocShell() ) &&
2007  nullptr != ( pFlyFrame = GetSelectedFlyFrame() ))
2008  {
2009  SfxItemSet aHtmlSet( GetDoc()->GetAttrPool(), svl::Items<RES_VERT_ORIENT, RES_HORI_ORIENT>{} );
2010  // horizontal orientation:
2011  const bool bLeftFrame = aFlyRect.Left() <
2012  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Left(),
2013  bLeftPrt = aFlyRect.Left() + aFlyRect.Width() <
2014  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width()/2;
2015  if( bLeftFrame || bLeftPrt )
2016  {
2017  aHori.SetHoriOrient( text::HoriOrientation::LEFT );
2018  aHori.SetRelationOrient( bLeftFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
2019  }
2020  else
2021  {
2022  const bool bRightFrame = aFlyRect.Left() >
2023  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width();
2024  aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
2025  aHori.SetRelationOrient( bRightFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
2026  }
2027  aHtmlSet.Put( aHori );
2028  aVert.SetVertOrient( text::VertOrientation::TOP );
2029  aVert.SetRelationOrient( text::RelOrientation::PRINT_AREA );
2030  aHtmlSet.Put( aVert );
2031 
2032  GetDoc()->SetAttr( aHtmlSet, *pFlyFrame->GetFormat() );
2033  }
2034  }
2035  else
2036  {
2037  if (rSdrObj.GetName().isEmpty())
2038  {
2039  bool bRestore = GetDoc()->GetIDocumentUndoRedo().DoesDrawUndo();
2040  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
2041  rSdrObj.SetName(GetUniqueShapeName());
2042  GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(bRestore);
2043  }
2044 
2045  Point aRelNullPt;
2046  if( OBJ_CAPTION == nIdent )
2047  aRelNullPt = static_cast<SdrCaptionObj&>(rSdrObj).GetTailPos();
2048  else
2049  aRelNullPt = rBound.TopLeft();
2050 
2051  aSet.Put( aAnch );
2052  aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
2053  // OD 2004-03-30 #i26791# - set horizontal position
2054  SwFormatHoriOrient aHori( nXOffset, text::HoriOrientation::NONE, text::RelOrientation::FRAME );
2055  aSet.Put( aHori );
2056  // OD 2004-03-30 #i26791# - set vertical position
2057  if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
2058  {
2059  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2060  do {
2061  pTmp = pTmp->FindMaster();
2062  assert(pTmp && "Where's my Master?");
2063  nYOffset += pTmp->IsVertical() ?
2064  pTmp->getFramePrintArea().Width() : pTmp->getFramePrintArea().Height();
2065  } while ( pTmp->IsFollow() );
2066  }
2067  SwFormatVertOrient aVert( nYOffset, text::VertOrientation::NONE, text::RelOrientation::FRAME );
2068  aSet.Put( aVert );
2069  SwDrawFrameFormat* pFormat = static_cast<SwDrawFrameFormat*>(getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::DRAW_OBJECT, &aSet ));
2070  // #i36010# - set layout direction of the position
2071  pFormat->SetPositionLayoutDir(
2072  text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
2073  // #i44344#, #i44681# - positioning attributes already set
2074  pFormat->PosAttrSet();
2075  pFormat->SetName(rSdrObj.GetName());
2076 
2077  SwDrawContact *pContact = new SwDrawContact( pFormat, &rSdrObj );
2078  // #i35635#
2079  pContact->MoveObjToVisibleLayer( &rSdrObj );
2080  if( bCharBound )
2081  {
2082  OSL_ENSURE( aAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR, "wrong AnchorType" );
2083  SwTextNode *pNd = aAnch.GetContentAnchor()->nNode.GetNode().GetTextNode();
2084  SwFormatFlyCnt aFormat( pFormat );
2085  pNd->InsertItem(aFormat,
2086  aAnch.GetContentAnchor()->nContent.GetIndex(), 0 );
2088  aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER );
2089  pFormat->SetFormatAttr( aVertical );
2090  }
2091  if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() )
2092  {
2093  const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
2094  do {
2095  pTmp = pTmp->FindMaster();
2096  OSL_ENSURE( pTmp, "Where's my Master?" );
2097  } while( pTmp->IsFollow() );
2098  pAnch = pTmp;
2099  }
2100 
2101  pContact->ConnectToLayout();
2102 
2103  // mark object at frame the object is inserted at.
2104  {
2105  SdrObject* pMarkObj = pContact->GetDrawObjectByAnchorFrame( *pAnch );
2106  if ( pMarkObj )
2107  {
2108  Imp()->GetDrawView()->MarkObj( pMarkObj, Imp()->GetPageView() );
2109  }
2110  else
2111  {
2112  Imp()->GetDrawView()->MarkObj( &rSdrObj, Imp()->GetPageView() );
2113  }
2114  }
2115  }
2116 
2117  GetDoc()->getIDocumentState().SetModified();
2118 
2119  KillPams();
2120  EndAllActionAndCall();
2121  UnlockPaint();
2122  return true;
2123 }
2124 
2126 {
2127  OSL_ENSURE( Imp()->HasDrawView(), "BreakCreate without DrawView?" );
2128  Imp()->GetDrawView()->BrkCreateObj();
2129  ::FrameNotify( this, FLY_DRAG_END );
2130 }
2131 
2133 {
2134  return Imp()->HasDrawView() && Imp()->GetDrawView()->IsCreateObj();
2135 }
2136 
2137 bool SwFEShell::BeginMark( const Point &rPos )
2138 {
2139  if ( !Imp()->HasDrawView() )
2140  Imp()->MakeDrawView();
2141 
2142  if ( GetPageNumber( rPos ) )
2143  {
2144  SwDrawView* pDView = Imp()->GetDrawView();
2145 
2146  if (pDView->HasMarkablePoints())
2147  return pDView->BegMarkPoints( rPos );
2148  else
2149  {
2150  pDView->BegMarkObj( rPos );
2151  return true;
2152  }
2153  }
2154  else
2155  return false;
2156 }
2157 
2158 void SwFEShell::MoveMark( const Point &rPos )
2159 {
2160  OSL_ENSURE( Imp()->HasDrawView(), "MoveMark without DrawView?" );
2161 
2162  if ( GetPageNumber( rPos ) )
2163  {
2164  ScrollTo( rPos );
2165  SwDrawView* pDView = Imp()->GetDrawView();
2166 
2167  if (pDView->IsInsObjPoint())
2168  pDView->MovInsObjPoint( rPos );
2169  else if (pDView->IsMarkPoints())
2170  pDView->MovMarkPoints( rPos );
2171  else
2172  pDView->MovAction( rPos );
2173  }
2174 }
2175 
2177 {
2178  bool bRet = false;
2179  OSL_ENSURE( Imp()->HasDrawView(), "EndMark without DrawView?" );
2180 
2181  if (Imp()->GetDrawView()->IsMarkObj())
2182  {
2183  bRet = Imp()->GetDrawView()->EndMarkObj();
2184 
2185  if ( bRet )
2186  {
2187  bool bShowHdl = false;
2188  SwDrawView* pDView = Imp()->GetDrawView();
2189  // frames are not selected this way, except when
2190  // it is only one frame
2191  SdrMarkList &rMrkList = const_cast<SdrMarkList&>(pDView->GetMarkedObjectList());
2192  SwFlyFrame* pOldSelFly = ::GetFlyFromMarked( &rMrkList, this );
2193 
2194  if ( rMrkList.GetMarkCount() > 1 )
2195  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2196  {
2197  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2198  if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
2199  {
2200  if ( !bShowHdl )
2201  {
2202  bShowHdl = true;
2203  }
2204  rMrkList.DeleteMark( i );
2205  --i; // no exceptions
2206  }
2207  }
2208 
2209  if( bShowHdl )
2210  {
2211  pDView->MarkListHasChanged();
2212  pDView->AdjustMarkHdl();
2213  }
2214 
2215  if ( rMrkList.GetMarkCount() )
2216  ::lcl_GrabCursor(this, pOldSelFly);
2217  else
2218  bRet = false;
2219  }
2220  if ( bRet )
2221  ::FrameNotify( this, FLY_DRAG_START );
2222  }
2223  else
2224  {
2225  if (Imp()->GetDrawView()->IsMarkPoints())
2226  bRet = Imp()->GetDrawView()->EndMarkPoints();
2227  }
2228 
2229  SetChainMarker();
2230  return bRet;
2231 }
2232 
2234 {
2235  RndStdIds nRet = RndStdIds(SHRT_MAX);
2236  if ( Imp()->HasDrawView() )
2237  {
2238  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2239  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2240  {
2241  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2242  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
2243  {
2244  nRet = RndStdIds::UNKNOWN;
2245  break;
2246  }
2247  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2248  RndStdIds nId = pContact->GetFormat()->GetAnchor().GetAnchorId();
2249  if ( nRet == RndStdIds(SHRT_MAX) )
2250  nRet = nId;
2251  else if ( nRet != nId )
2252  {
2253  nRet = RndStdIds::UNKNOWN;
2254  break;
2255  }
2256  }
2257  }
2258  if ( nRet == RndStdIds(SHRT_MAX) )
2259  nRet = RndStdIds::UNKNOWN;
2260  return nRet;
2261 }
2262 
2263 void SwFEShell::ChgAnchor( RndStdIds eAnchorId, bool bSameOnly, bool bPosCorr )
2264 {
2265  OSL_ENSURE( Imp()->HasDrawView(), "ChgAnchor without DrawView?" );
2266  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2267  if( rMrkList.GetMarkCount() &&
2269  {
2270  StartAllAction();
2271 
2272  if( GetDoc()->ChgAnchor( rMrkList, eAnchorId, bSameOnly, bPosCorr ))
2273  Imp()->GetDrawView()->UnmarkAll();
2274 
2275  EndAllAction();
2276 
2277  ::FrameNotify( this );
2278  }
2279 }
2280 
2282 {
2283  OSL_ENSURE( Imp()->HasDrawView(), "DelSelectedObj(), no DrawView available" );
2284  if ( Imp()->HasDrawView() )
2285  {
2286  StartAllAction();
2287  Imp()->GetDrawView()->DeleteMarked();
2288  EndAllAction();
2289  ::FrameNotify( this, FLY_DRAG_END );
2290  }
2291 }
2292 
2293 // For the statusline to request the current conditions
2295 {
2296  tools::Rectangle aRect;
2297  if ( Imp()->HasDrawView() )
2298  {
2299  if ( Imp()->GetDrawView()->IsAction() )
2300  Imp()->GetDrawView()->TakeActionRect( aRect );
2301  else
2302  aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2303  }
2304  return aRect.GetSize();
2305 }
2306 
2308 {
2309  const SdrView *pView = Imp()->GetDrawView();
2310  OSL_ENSURE( pView, "GetAnchorObjDiff without DrawView?" );
2311 
2312  tools::Rectangle aRect;
2313  if ( Imp()->GetDrawView()->IsAction() )
2314  Imp()->GetDrawView()->TakeActionRect( aRect );
2315  else
2316  aRect = Imp()->GetDrawView()->GetAllMarkedRect();
2317 
2318  Point aRet( aRect.TopLeft() );
2319 
2320  if ( IsFrameSelected() )
2321  {
2322  SwFlyFrame *pFly = GetSelectedFlyFrame();
2323  aRet -= pFly->GetAnchorFrame()->getFrameArea().Pos();
2324  }
2325  else
2326  {
2327  const SdrObject *pObj = pView->GetMarkedObjectList().GetMarkCount() == 1 ?
2328  pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() : nullptr;
2329  if ( pObj )
2330  aRet -= pObj->GetAnchorPos();
2331  }
2332 
2333  return aRet;
2334 }
2335 
2337 {
2338  OSL_ENSURE( Imp()->GetDrawView(), "GetObjAbsPos() without DrawView?" );
2339  return Imp()->GetDrawView()->GetDragStat().GetActionRect().TopLeft();
2340 }
2341 
2343 {
2344  if ( IsObjSelected() )
2345  {
2346  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2347  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2348  {
2349  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2350  // consider 'virtual' drawing objects.
2351  // Thus, use corresponding method instead of checking type.
2352  if ( pObj->IsGroupObject() &&
2353  // --> #i38505# No ungroup allowed for 3d objects
2354  !pObj->Is3DObj() &&
2355  RndStdIds::FLY_AS_CHAR != static_cast<SwDrawContact*>(GetUserCall(pObj))->
2356  GetFormat()->GetAnchor().GetAnchorId() )
2357  {
2358  return true;
2359  }
2360  }
2361  }
2362  return false;
2363 }
2364 
2365 namespace
2366 {
2367  bool HasSuitableGroupingAnchor(const SdrObject* pObj)
2368  {
2369  bool bSuitable = true;
2370  SwFrameFormat* pFrameFormat(::FindFrameFormat(const_cast<SdrObject*>(pObj)));
2371  if (!pFrameFormat)
2372  {
2373  OSL_FAIL( "<HasSuitableGroupingAnchor> - missing frame format" );
2374  bSuitable = false;
2375  }
2376  else if (RndStdIds::FLY_AS_CHAR == pFrameFormat->GetAnchor().GetAnchorId())
2377  {
2378  bSuitable = false;
2379  }
2380  return bSuitable;
2381  }
2382 }
2383 
2384 // Change return type.
2385 // Adjustments for drawing objects in header/footer:
2386 // allow group, only if all selected objects are in the same header/footer
2387 // or not in header/footer.
2389 {
2390  bool bIsGroupAllowed = false;
2391  if ( IsObjSelected() > 1 )
2392  {
2393  bIsGroupAllowed = true;
2394  const SdrObject* pUpGroup = nullptr;
2395  const SwFrame* pHeaderFooterFrame = nullptr;
2396  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2397  for ( size_t i = 0; bIsGroupAllowed && i < rMrkList.GetMarkCount(); ++i )
2398  {
2399  const SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2400  if ( i )
2401  bIsGroupAllowed = pObj->getParentSdrObjectFromSdrObject() == pUpGroup;
2402  else
2403  pUpGroup = pObj->getParentSdrObjectFromSdrObject();
2404 
2405  if ( bIsGroupAllowed )
2406  bIsGroupAllowed = HasSuitableGroupingAnchor(pObj);
2407 
2408  // check, if all selected objects are in the
2409  // same header/footer or not in header/footer.
2410  if ( bIsGroupAllowed )
2411  {
2412  const SwFrame* pAnchorFrame = nullptr;
2413  if ( auto pVirtFlyDrawObj = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
2414  {
2415  const SwFlyFrame* pFlyFrame = pVirtFlyDrawObj->GetFlyFrame();
2416  if ( pFlyFrame )
2417  {
2418  pAnchorFrame = pFlyFrame->GetAnchorFrame();
2419  }
2420  }
2421  else
2422  {
2423  SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall( pObj ));
2424  if ( pDrawContact )
2425  {
2426  pAnchorFrame = pDrawContact->GetAnchorFrame( pObj );
2427  }
2428  }
2429  if ( pAnchorFrame )
2430  {
2431  if ( i )
2432  {
2433  bIsGroupAllowed =
2434  ( pAnchorFrame->FindFooterOrHeader() == pHeaderFooterFrame );
2435  }
2436  else
2437  {
2438  pHeaderFooterFrame = pAnchorFrame->FindFooterOrHeader();
2439  }
2440  }
2441  }
2442  }
2443  }
2444 
2445  return bIsGroupAllowed;
2446 }
2447 
2449 {
2450  bool bIsUnGroupAllowed = false;
2451 
2452  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2453  for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i)
2454  {
2455  const SdrObject* pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
2456  bIsUnGroupAllowed = HasSuitableGroupingAnchor(pObj);
2457  if (!bIsUnGroupAllowed)
2458  break;
2459  }
2460 
2461  return bIsUnGroupAllowed;
2462 }
2463 
2464 // The group gets the anchor and the contactobject of the first in the selection
2466 {
2467  if ( IsGroupAllowed() )
2468  {
2469  StartAllAction();
2470  StartUndo( SwUndoId::START );
2471 
2472  GetDoc()->GroupSelection( *Imp()->GetDrawView() );
2473 
2474  EndUndo( SwUndoId::END );
2475  EndAllAction();
2476  }
2477 }
2478 
2479 // The individual objects get a copy of the anchor and the contactobject of the group
2481 {
2482  if ( IsGroupSelected() )
2483  {
2484  StartAllAction();
2485  StartUndo( SwUndoId::START );
2486 
2487  GetDoc()->UnGroupSelection( *Imp()->GetDrawView() );
2488 
2489  EndUndo( SwUndoId::END );
2490  EndAllAction();
2491  }
2492 }
2493 
2494 void SwFEShell::MirrorSelection( bool bHorizontal )
2495 {
2496  SdrView *pView = Imp()->GetDrawView();
2497  if ( IsObjSelected() && pView->IsMirrorAllowed() )
2498  {
2499  if ( bHorizontal )
2500  pView->MirrorAllMarkedHorizontal();
2501  else
2502  pView->MirrorAllMarkedVertical();
2503  }
2504 }
2505 
2506 // jump to named frame (Graphic/OLE)
2507 
2508 bool SwFEShell::GotoFly( const OUString& rName, FlyCntType eType, bool bSelFrame )
2509 {
2510  bool bRet = false;
2511  static SwNodeType const aChkArr[ 4 ] = {
2512  /* FLYCNTTYPE_ALL */ SwNodeType::NONE,
2513  /* FLYCNTTYPE_FRM */ SwNodeType::Text,
2514  /* FLYCNTTYPE_GRF */ SwNodeType::Grf,
2515  /* FLYCNTTYPE_OLE */ SwNodeType::Ole
2516  };
2517 
2518  const SwFlyFrameFormat* pFlyFormat = mxDoc->FindFlyByName( rName, aChkArr[ eType]);
2519  if( pFlyFormat )
2520  {
2521  SET_CURR_SHELL( this );
2522 
2523  SwFlyFrame* pFrame = SwIterator<SwFlyFrame,SwFormat>( *pFlyFormat ).First();
2524  if( pFrame )
2525  {
2526  if( bSelFrame )
2527  {
2528  // first make visible, to get a11y events in proper order
2529  if (!ActionPend())
2530  MakeVisible( pFrame->getFrameArea() );
2531  SelectObj( pFrame->getFrameArea().Pos(), 0, pFrame->GetVirtDrawObj() );
2532  }
2533  else
2534  {
2535  SwContentFrame *pCFrame = pFrame->ContainsContent();
2536  if ( pCFrame )
2537  {
2538  ClearMark();
2539  SwPaM* pCursor = GetCursor();
2540 
2541  if (pCFrame->IsTextFrame())
2542  {
2543  *pCursor->GetPoint() = static_cast<SwTextFrame *>(pCFrame)
2544  ->MapViewToModelPos(TextFrameIndex(0));
2545  }
2546  else
2547  {
2548  assert(pCFrame->IsNoTextFrame());
2549  SwContentNode *const pCNode = static_cast<SwNoTextFrame *>(pCFrame)->GetNode();
2550 
2551  pCursor->GetPoint()->nNode = *pCNode;
2552  pCursor->GetPoint()->nContent.Assign( pCNode, 0 );
2553  }
2554 
2555  SwRect& rChrRect = const_cast<SwRect&>(GetCharRect());
2556  rChrRect = pFrame->getFramePrintArea();
2557  rChrRect.Pos() += pFrame->getFrameArea().Pos();
2558  GetCursorDocPos() = rChrRect.Pos();
2559  }
2560  }
2561  bRet = true;
2562  }
2563  }
2564  return bRet;
2565 }
2566 
2567 size_t SwFEShell::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const
2568 {
2569  return GetDoc()->GetFlyCount(eType, bIgnoreTextBoxes);
2570 }
2571 
2572 const SwFrameFormat* SwFEShell::GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes ) const
2573 {
2574  return GetDoc()->GetFlyNum(nIdx, eType, bIgnoreTextBoxes);
2575 }
2576 
2577 std::vector<SwFrameFormat const*> SwFEShell::GetFlyFrameFormats(
2578  FlyCntType const eType, bool const bIgnoreTextBoxes)
2579 {
2580  return GetDoc()->GetFlyFrameFormats(eType, bIgnoreTextBoxes);
2581 }
2582 
2583 // show the current selected object
2585 {
2586  if ( Imp()->HasDrawView() &&
2587  Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )
2588  {
2589  GetCurrFrame(); // just to trigger formatting in case the selected object is not formatted.
2590  MakeVisible( Imp()->GetDrawView()->GetAllMarkedRect() );
2591  }
2592  else
2594 }
2595 
2596 // how is the selected object protected?
2598 {
2600  const bool bParent(eType & FlyProtectFlags::Parent);
2601  if( Imp()->HasDrawView() )
2602  {
2603  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2604  for( size_t i = rMrkList.GetMarkCount(); i; )
2605  {
2606  SdrObject *pObj = rMrkList.GetMark( --i )->GetMarkedSdrObj();
2607  if( !bParent )
2608  {
2609  nChk |= ( pObj->IsMoveProtect() ? FlyProtectFlags::Pos : FlyProtectFlags::NONE ) |
2611 
2612  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
2613  {
2614  SwFlyFrame *pFly = pVirtO->GetFlyFrame();
2615  if ( (FlyProtectFlags::Content & eType) && pFly->GetFormat()->GetProtect().IsContentProtected() )
2616  nChk |= FlyProtectFlags::Content;
2617 
2618  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
2619  {
2620  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
2621  uno::Reference < embed::XEmbeddedObject > xObj( pNd ? pNd->GetOLEObj().GetOleRef() : nullptr );
2622  if ( xObj.is() )
2623  {
2624  // TODO/LATER: use correct aspect
2625  const bool bNeverResize = (embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ));
2626  if ( ( (FlyProtectFlags::Content & eType) || (FlyProtectFlags::Size & eType) ) && bNeverResize )
2627  {
2628  nChk |= FlyProtectFlags::Size;
2629  nChk |= FlyProtectFlags::Fixed;
2630  }
2631 
2632  // set FlyProtectFlags::Pos if it is a Math object anchored 'as char' and baseline alignment is activated
2633  const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
2634  && RndStdIds::FLY_AS_CHAR == pFly->GetFormat()->GetAnchor().GetAnchorId()
2635  && mxDoc->GetDocumentSettingManager().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT );
2636  if ((FlyProtectFlags::Pos & eType) && bProtectMathPos)
2637  nChk |= FlyProtectFlags::Pos;
2638  }
2639  }
2640  }
2641  nChk &= eType;
2642  if( nChk == eType )
2643  return eType;
2644  }
2645  const SwFrame* pAnch;
2646  if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
2647  pAnch = pVirtO->GetFlyFrame()->GetAnchorFrame();
2648  else
2649  {
2650  SwDrawContact* pTmp = static_cast<SwDrawContact*>(GetUserCall(pObj));
2651  pAnch = pTmp ? pTmp->GetAnchorFrame( pObj ) : nullptr;
2652  }
2653  if( pAnch && pAnch->IsProtected() )
2654  return eType;
2655  }
2656  }
2657  return nChk;
2658 }
2659 
2661 {
2662  if ( !IsObjSelected() )
2663  return false;
2664 
2665  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2666  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2667  {
2668  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2669  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2670  // --> make code robust
2671  OSL_ENSURE( pContact, "<SwFEShell::GetObjAttr(..)> - missing <pContact>." );
2672  if ( pContact )
2673  {
2674  if ( i )
2675  rSet.MergeValues( pContact->GetFormat()->GetAttrSet() );
2676  else
2677  rSet.Put( pContact->GetFormat()->GetAttrSet() );
2678  }
2679  }
2680  return true;
2681 }
2682 
2684 {
2685  SET_CURR_SHELL( this );
2686 
2687  if ( !rSet.Count() )
2688  {
2689  OSL_ENSURE( false, "SetObjAttr, empty set." );
2690  return;
2691  }
2692 
2693  StartAllAction();
2694  StartUndo( SwUndoId::INSATTR );
2695 
2696  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2697  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2698  {
2699  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2700  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
2701  GetDoc()->SetAttr( rSet, *pContact->GetFormat() );
2702  }
2703 
2704  EndUndo( SwUndoId::INSATTR );
2705  EndAllActionAndCall();
2706  GetDoc()->getIDocumentState().SetModified();
2707 }
2708 
2710 {
2711  return Imp()->GetDrawView()->IsAlignPossible();
2712 }
2713 
2715 {
2716  SET_CURR_SHELL( this );
2717 
2718  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
2719  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
2720  {
2721  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2722  if ( !GetUserCall(pObj) )
2723  {
2724  const tools::Rectangle &rBound = pObj->GetSnapRect();
2725  const Point aPt( rBound.TopLeft() );
2726  const SwFrame *pPage = GetLayout()->Lower();
2727  const SwFrame *pLast = pPage;
2728  while ( pPage && !pPage->getFrameArea().IsInside( aPt ) )
2729  {
2730  if ( aPt.Y() > pPage->getFrameArea().Bottom() )
2731  pLast = pPage;
2732  pPage = pPage->GetNext();
2733  }
2734  if ( !pPage )
2735  pPage = pLast;
2736  OSL_ENSURE( pPage, "Page not found." );
2737 
2738  // Alien identifier should roll into the default,
2739  // Duplications are possible!!
2740  sal_uInt16 nIdent =
2741  Imp()->GetDrawView()->GetCurrentObjInventor() == SdrInventor::Default ?
2742  Imp()->GetDrawView()->GetCurrentObjIdentifier() : 0xFFFF;
2743 
2744  SwFormatAnchor aAnch;
2745  {
2746  const SwContentFrame *const pAnch = ::FindAnchor(pPage, aPt, true);
2747  SwPosition aPos( pAnch->IsTextFrame()
2748  ? *static_cast<SwTextFrame const*>(pAnch)->GetTextNodeForParaProps()
2749  : *static_cast<SwNoTextFrame const*>(pAnch)->GetNode() );
2750  aAnch.SetType( RndStdIds::FLY_AT_PARA );
2751  aAnch.SetAnchor( &aPos );
2752  const_cast<SwRect&>(GetCharRect()).Pos() = aPt;
2753  }
2754 
2755  // First the action here, to assure GetCharRect delivers current values.
2756  StartAllAction();
2757 
2758  SfxItemSet aSet( GetAttrPool(), svl::Items<RES_FRM_SIZE, RES_FRM_SIZE,
2759  RES_SURROUND, RES_ANCHOR>{} );
2760  aSet.Put( aAnch );
2761 
2762  Point aRelNullPt;
2763 
2764  if( OBJ_CAPTION == nIdent )
2765  aRelNullPt = static_cast<SdrCaptionObj*>(pObj)->GetTailPos();
2766  else
2767  aRelNullPt = rBound.TopLeft();
2768 
2769  aSet.Put( aAnch );
2770  aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
2771  SwFrameFormat* pFormat = getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::DRAW_OBJECT, &aSet );
2772 
2773  SwDrawContact *pContact = new SwDrawContact(
2774  static_cast<SwDrawFrameFormat*>(pFormat), pObj );
2775 
2776  // #i35635#
2777  pContact->MoveObjToVisibleLayer( pObj );
2778  pContact->ConnectToLayout();
2779 
2780  EndAllAction();
2781  }
2782  }
2783 }
2784 
2786 {
2787  GetDoc()->SetCalcFieldValueHdl(pOutliner);
2788 }
2789 
2791  const Point &rPt ) const
2792 {
2793  rRect.Clear();
2794 
2795  // The source is not allowed to have a follow.
2796  const SwFormatChain &rChain = rSource.GetChain();
2797  if ( rChain.GetNext() )
2799 
2801  if( Imp()->HasDrawView() )
2802  {
2803  SdrPageView* pPView;
2804  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
2805  const auto nOld = pDView->GetHitTolerancePixel();
2806  pDView->SetHitTolerancePixel( 0 );
2807  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
2808  SwVirtFlyDrawObj* pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
2809  if (pDrawObj)
2810  {
2811  SwFlyFrame *pFly = pDrawObj->GetFlyFrame();
2812  rRect = pFly->getFrameArea();
2813 
2814  // Target and source should not be equal and the list
2815  // should not be cyclic
2816  SwFrameFormat *pFormat = pFly->GetFormat();
2817  nRet = GetDoc()->Chainable(rSource, *pFormat);
2818  }
2819  pDView->SetHitTolerancePixel( nOld );
2820  }
2821  return nRet;
2822 }
2823 
2824 void SwFEShell::Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest )
2825 {
2826  GetDoc()->Chain(rSource, rDest);
2827 }
2828 
2829 SwChainRet SwFEShell::Chain( SwFrameFormat &rSource, const Point &rPt )
2830 {
2831  SwRect aDummy;
2832  SwChainRet nErr = Chainable( aDummy, rSource, rPt );
2833  if ( nErr == SwChainRet::OK )
2834  {
2835  StartAllAction();
2836  SdrPageView* pPView;
2837  SwDrawView *pDView = Imp()->GetDrawView();
2838  const auto nOld = pDView->GetHitTolerancePixel();
2839  pDView->SetHitTolerancePixel( 0 );
2840  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
2841  pDView->SetHitTolerancePixel( nOld );
2842  SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
2843 
2844  SwFlyFrameFormat *pFormat = pFly->GetFormat();
2845  GetDoc()->Chain(rSource, *pFormat);
2846  EndAllAction();
2847  SetChainMarker();
2848  }
2849  return nErr;
2850 }
2851 
2853 {
2854  StartAllAction();
2855  GetDoc()->Unchain(rFormat);
2856  EndAllAction();
2857 }
2858 
2860 {
2861  m_pChainFrom.reset();
2862  m_pChainTo.reset();
2863 }
2864 
2866 {
2867  bool bDelFrom = true,
2868  bDelTo = true;
2869  if ( IsFrameSelected() )
2870  {
2871  SwFlyFrame *pFly = GetSelectedFlyFrame();
2872 
2873  if ( pFly->GetPrevLink() )
2874  {
2875  bDelFrom = false;
2876  const SwFrame *pPre = pFly->GetPrevLink();
2877 
2878  Point aStart( pPre->getFrameArea().Right(), pPre->getFrameArea().Bottom());
2879  Point aEnd(pFly->getFrameArea().Pos());
2880 
2881  if (!m_pChainFrom)
2882  {
2883  m_pChainFrom.reset(
2884  new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd ));
2885  }
2886  }
2887  if ( pFly->GetNextLink() )
2888  {
2889  bDelTo = false;
2890  const SwFlyFrame *pNxt = pFly->GetNextLink();
2891 
2892  Point aStart( pFly->getFrameArea().Right(), pFly->getFrameArea().Bottom());
2893  Point aEnd(pNxt->getFrameArea().Pos());
2894 
2895  if (!m_pChainTo)
2896  {
2897  m_pChainTo.reset(
2898  new SdrDropMarkerOverlay( *GetDrawView(), aStart, aEnd ));
2899  }
2900  }
2901  }
2902 
2903  if ( bDelFrom )
2904  {
2905  m_pChainFrom.reset();
2906  }
2907 
2908  if ( bDelTo )
2909  {
2910  m_pChainTo.reset();
2911  }
2912 }
2913 
2914 long SwFEShell::GetSectionWidth( SwFormat const & rFormat ) const
2915 {
2916  SwFrame *pFrame = GetCurrFrame();
2917  // Is the cursor at this moment in a SectionFrame?
2918  if( pFrame && pFrame->IsInSct() )
2919  {
2920  SwSectionFrame* pSect = pFrame->FindSctFrame();
2921  do
2922  {
2923  // Is it the right one?
2924  if( pSect->KnowsFormat( rFormat ) )
2925  return pSect->getFrameArea().Width();
2926  // for nested areas
2927  pSect = pSect->GetUpper()->FindSctFrame();
2928  }
2929  while( pSect );
2930  }
2931  SwIterator<SwSectionFrame,SwFormat> aIter( rFormat );
2932  for ( SwSectionFrame* pSct = aIter.First(); pSct; pSct = aIter.Next() )
2933  {
2934  if( !pSct->IsFollow() )
2935  {
2936  return pSct->getFrameArea().Width();
2937  }
2938  }
2939  return 0;
2940 }
2941 
2942  void SwFEShell::CreateDefaultShape( sal_uInt16 /*SdrObjKind ?*/ eSdrObjectKind, const tools::Rectangle& rRect,
2943  sal_uInt16 nSlotId)
2944 {
2945  SdrView* pDrawView = GetDrawView();
2946  SdrModel* pDrawModel = pDrawView->GetModel();
2948  *pDrawModel,
2949  SdrInventor::Default,
2950  eSdrObjectKind);
2951 
2952  if(pObj)
2953  {
2954  tools::Rectangle aRect(rRect);
2955  if(OBJ_CARC == eSdrObjectKind || OBJ_CCUT == eSdrObjectKind)
2956  {
2957  // force quadratic
2958  if(aRect.GetWidth() > aRect.GetHeight())
2959  {
2960  aRect = tools::Rectangle(
2961  Point(aRect.Left() + ((aRect.GetWidth() - aRect.GetHeight()) / 2), aRect.Top()),
2962  Size(aRect.GetHeight(), aRect.GetHeight()));
2963  }
2964  else
2965  {
2966  aRect = tools::Rectangle(
2967  Point(aRect.Left(), aRect.Top() + ((aRect.GetHeight() - aRect.GetWidth()) / 2)),
2968  Size(aRect.GetWidth(), aRect.GetWidth()));
2969  }
2970  }
2971  pObj->SetLogicRect(aRect);
2972 
2973  Point aStart = aRect.TopLeft();
2974  Point aEnd = aRect.BottomRight();
2975 
2976  if(dynamic_cast<const SdrCircObj*>( pObj) != nullptr)
2977  {
2978  SfxItemSet aAttr(pDrawModel->GetItemPool());
2979  aAttr.Put(makeSdrCircStartAngleItem(9000));
2980  aAttr.Put(makeSdrCircEndAngleItem(0));
2981  pObj->SetMergedItemSet(aAttr);
2982  }
2983  else if(dynamic_cast<const SdrPathObj*>( pObj) != nullptr)
2984  {
2986 
2987  switch(eSdrObjectKind)
2988  {
2989  case OBJ_PATHLINE:
2990  case OBJ_PATHFILL:
2991  {
2992  basegfx::B2DPolygon aInnerPoly;
2993 
2994  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
2995 
2996  const basegfx::B2DPoint aCenterBottom(aRect.Center().getX(), aRect.Bottom());
2997  aInnerPoly.appendBezierSegment(
2998  aCenterBottom,
2999  aCenterBottom,
3000  basegfx::B2DPoint(aRect.Center().getX(), aRect.Center().getY()));
3001 
3002  const basegfx::B2DPoint aCenterTop(aRect.Center().getX(), aRect.Top());
3003  aInnerPoly.appendBezierSegment(
3004  aCenterTop,
3005  aCenterTop,
3006  basegfx::B2DPoint(aRect.Right(), aRect.Top()));
3007 
3008  aInnerPoly.setClosed(true);
3009  aPoly.append(aInnerPoly);
3010  }
3011  break;
3012  case OBJ_FREELINE:
3013  case OBJ_FREEFILL:
3014  {
3015  basegfx::B2DPolygon aInnerPoly;
3016 
3017  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3018 
3019  aInnerPoly.appendBezierSegment(
3020  basegfx::B2DPoint(aRect.Left(), aRect.Top()),
3021  basegfx::B2DPoint(aRect.Center().getX(), aRect.Top()),
3022  basegfx::B2DPoint(aRect.Center().getX(), aRect.Center().getY()));
3023 
3024  aInnerPoly.appendBezierSegment(
3025  basegfx::B2DPoint(aRect.Center().getX(), aRect.Bottom()),
3026  basegfx::B2DPoint(aRect.Right(), aRect.Bottom()),
3027  basegfx::B2DPoint(aRect.Right(), aRect.Top()));
3028 
3029  aInnerPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
3030  aInnerPoly.setClosed(true);
3031  aPoly.append(aInnerPoly);
3032  }
3033  break;
3034  case OBJ_POLY:
3035  case OBJ_PLIN:
3036  {
3037  basegfx::B2DPolygon aInnerPoly;
3038  sal_Int32 nWdt(aRect.GetWidth());
3039  sal_Int32 nHgt(aRect.GetHeight());
3040 
3041  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Bottom()));
3042  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 30) / 100, aRect.Top() + (nHgt * 70) / 100));
3043  aInnerPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top() + (nHgt * 15) / 100));
3044  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 65) / 100, aRect.Top()));
3045  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + nWdt, aRect.Top() + (nHgt * 30) / 100));
3046  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 50) / 100));
3047  aInnerPoly.append(basegfx::B2DPoint(aRect.Left() + (nWdt * 80) / 100, aRect.Top() + (nHgt * 75) / 100));
3048  aInnerPoly.append(basegfx::B2DPoint(aRect.Bottom(), aRect.Right()));
3049 
3050  if(OBJ_PLIN == eSdrObjectKind)
3051  {
3052  aInnerPoly.append(basegfx::B2DPoint(aRect.Center().getX(), aRect.Bottom()));
3053  }
3054  else
3055  {
3056  aInnerPoly.setClosed(true);
3057  }
3058 
3059  aPoly.append(aInnerPoly);
3060  }
3061  break;
3062  case OBJ_LINE :
3063  {
3064  sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
3065  basegfx::B2DPolygon aTempPoly;
3066  aTempPoly.append(basegfx::B2DPoint(aRect.TopLeft().getX(), nYMiddle));
3067  aTempPoly.append(basegfx::B2DPoint(aRect.BottomRight().getX(), nYMiddle));
3068  aPoly.append(aTempPoly);
3069 
3071  SetLineEnds(aAttr, *pObj, nSlotId);
3072  pObj->SetMergedItemSet(aAttr);
3073  }
3074  break;
3075  }
3076 
3077  static_cast<SdrPathObj*>(pObj)->SetPathPoly(aPoly);
3078  }
3079  else if(dynamic_cast<const SdrMeasureObj*>( pObj) != nullptr)
3080  {
3081  sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
3082  static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aStart.X(), nYMiddle), 0);
3083  static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aEnd.X(), nYMiddle), 1);
3084 
3086  SetLineEnds(aAttr, *pObj, nSlotId);
3087  pObj->SetMergedItemSet(aAttr);
3088  }
3089  else if(dynamic_cast<const SdrCaptionObj*>( pObj) != nullptr)
3090  {
3091  bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
3092  SID_DRAW_CAPTION_VERTICAL == nSlotId );
3093  static_cast<SdrTextObj*>(pObj)->SetVerticalWriting(bVerticalText);
3094  if(bVerticalText)
3095  {
3096  SfxItemSet aSet(pObj->GetMergedItemSet());
3099  pObj->SetMergedItemSet(aSet);
3100  }
3101 
3102  static_cast<SdrCaptionObj*>(pObj)->SetLogicRect(aRect);
3103  static_cast<SdrCaptionObj*>(pObj)->SetTailPos(
3104  aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
3105  }
3106  else if(dynamic_cast<const SdrTextObj*>( pObj) != nullptr)
3107  {
3108  SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
3109  pText->SetLogicRect(aRect);
3110 
3111  bool bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotId);
3112  bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nSlotId);
3113 
3114  pText->SetVerticalWriting(bVertical);
3115 
3116  if(bVertical)
3117  {
3118  SfxItemSet aSet(pDrawModel->GetItemPool());
3119  aSet.Put(makeSdrTextAutoGrowWidthItem(true));
3120  aSet.Put(makeSdrTextAutoGrowHeightItem(false));
3123  pText->SetMergedItemSet(aSet);
3124  }
3125 
3126  if(bMarquee)
3127  {
3129  aSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
3130  aSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
3131  aSet.Put( SdrTextAniKindItem( SdrTextAniKind::Slide ) );
3132  aSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) );
3133  aSet.Put( SdrTextAniCountItem( 1 ) );
3134  aSet.Put( SdrTextAniAmountItem( static_cast<sal_Int16>(GetWin()->PixelToLogic(Size(2,1)).Width())) );
3135  pObj->SetMergedItemSetAndBroadcast(aSet);
3136  }
3137  }
3138  SdrPageView* pPageView = pDrawView->GetSdrPageView();
3139  SdrCreateView::SetupObjLayer(pPageView, pDrawView->GetActiveLayer(), pObj);
3140  pDrawView->InsertObjectAtView(pObj, *pPageView);
3141  }
3142  ImpEndCreate();
3143 }
3144 
3155 {
3156  Color aRetColor;
3157 
3158  // check, if a draw view exists
3159  OSL_ENSURE( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackgrd - no draw view!");
3160  if( Imp()->GetDrawView() )
3161  {
3162  // determine list of selected objects
3163  const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3164  // check, if exactly one object is selected.
3165  OSL_ENSURE( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackgrd - no selected object!");
3166  if ( pMrkList->GetMarkCount() == 1)
3167  {
3168  // get selected object
3169  const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3170  // check, if selected object is a shape (drawing object)
3171  OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr, "wrong usage of SwFEShell::GetShapeBackgrd - selected object is not a drawing object!");
3172  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr )
3173  {
3174  // determine page frame of the frame the shape is anchored.
3175  const SwFrame* pAnchorFrame =
3176  static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrame( pSdrObj );
3177  OSL_ENSURE( pAnchorFrame, "inconsistent model - no anchor at shape!");
3178  if ( pAnchorFrame )
3179  {
3180  const SwPageFrame* pPageFrame = pAnchorFrame->FindPageFrame();
3181  OSL_ENSURE( pPageFrame, "inconsistent model - no page!");
3182  if ( pPageFrame )
3183  {
3184  aRetColor = pPageFrame->GetDrawBackgrdColor();
3185  }
3186  }
3187  }
3188  }
3189  }
3190 
3191  return aRetColor;
3192 }
3193 
3203 {
3204  bool bRet = false;
3205 
3206  // check, if a draw view exists
3207  OSL_ENSURE( Imp()->GetDrawView(), "wrong usage of SwFEShell::GetShapeBackgrd - no draw view!");
3208  if( Imp()->GetDrawView() )
3209  {
3210  // determine list of selected objects
3211  const SdrMarkList* pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
3212  // check, if exactly one object is selected.
3213  OSL_ENSURE( pMrkList->GetMarkCount() == 1, "wrong usage of SwFEShell::GetShapeBackgrd - no selected object!");
3214  if ( pMrkList->GetMarkCount() == 1)
3215  {
3216  // get selected object
3217  const SdrObject *pSdrObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
3218  // check, if selected object is a shape (drawing object)
3219  OSL_ENSURE( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr, "wrong usage of SwFEShell::GetShapeBackgrd - selected object is not a drawing object!");
3220  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pSdrObj) == nullptr )
3221  {
3222  // determine page frame of the frame the shape is anchored.
3223  const SwFrame* pAnchorFrame =
3224  static_cast<SwDrawContact*>(GetUserCall(pSdrObj))->GetAnchorFrame( pSdrObj );
3225  OSL_ENSURE( pAnchorFrame, "inconsistent model - no anchor at shape!");
3226  if ( pAnchorFrame )
3227  {
3228  const SwPageFrame* pPageFrame = pAnchorFrame->FindPageFrame();
3229  OSL_ENSURE( pPageFrame, "inconsistent model - no page!");
3230  if ( pPageFrame )
3231  {
3232  bRet = pPageFrame->IsRightToLeft();
3233  }
3234  }
3235  }
3236  }
3237  }
3238 
3239  return bRet;
3240 }
3241 
3243 {
3244  Point aRet(-1, -1);
3245  const SwFrame *pPage = GetLayout()->Lower();
3246  while ( pPage && !pPage->getFrameArea().IsInside( rDocPos ) )
3247  {
3248  pPage = pPage->GetNext();
3249  }
3250  if(pPage)
3251  {
3252  aRet = rDocPos - pPage->getFrameArea().TopLeft();
3253  }
3254  return aRet;
3255 }
3256 
3257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwTwips lMinBorder
Definition: swtypes.hxx:77
static bool lcl_IsControlGroup(const SdrObject *pObj)
Definition: feshview.cxx:1432
Point TopLeft() const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:547
SwRect GetBoundRectOfAnchoredObj(const SdrObject *pObj)
returns the BoundRect inclusive distance of the object.
Definition: dcontact.cxx:154
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:79
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2711
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:297
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:151
SwChainRet Chainable(SwRect &rRect, const SwFrameFormat &rSource, const Point &rPt) const
For Chain always connect Fly specified by format with that hit by point.
Definition: feshview.cxx:2790
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:834
void UnGroupSelection()
The individual objects are selected, but it is possible that there are groups included.
Definition: feshview.cxx:2480
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
long GetWidth() const
void KillPams()
Definition: crsrsh.cxx:1019
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4001
SDRTEXTVERTADJUST_TOP
virtual bool BegDragObj(const Point &rPnt, OutputDevice *pOut, SdrHdl *pHdl, short nMinMov=-3, SdrDragMethod *pForcedMeth=nullptr)
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:195
sal_Int32 nIndex
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
bool IsFollow() const
Definition: flowfrm.hxx:166
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2800
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:2709
void ChgAnchor(RndStdIds eAnchorId, bool bSameOnly=false, bool bPosCorr=true)
frmatr.hxx.
Definition: feshview.cxx:2263
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
bool IsUnGroupAllowed() const
Definition: feshview.cxx:2448
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:816
void SetShiftPressed(bool bShiftPressed)
bool IsInSct() const
Definition: frame.hxx:945
bool IsRotationOfSwGrfNodePossible() const
Definition: feshview.cxx:1175
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:657
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
static SwRectFnCollection aVertical
Definition: newfrm.cxx:115
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
SwNodeIndex nNode
Definition: pam.hxx:37
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
void GroupSelection()
Afterwards the group is selected.
Definition: feshview.cxx:2465
void SetHitTolerancePixel(sal_uInt16 nVal)
void MirrorSelection(bool bHorizontal)
Vertical if FALSE.
Definition: feshview.cxx:2494
long AdjustLeft(long nHorzMoveDelta)
bool AreObjectsMarked() const
void MirrorAllMarkedHorizontal()
SdrTextObj * GetTextEditObject() const
void SelectionToHeaven()
Above document.
Definition: feshview.cxx:1140
#define MINFLY
Definition: swtypes.hxx:65
Size GetObjSize() const
Definition: feshview.cxx:2294
const SwRect & getFramePrintArea() const
Definition: frame.hxx:178
#define CNT_GRF
Definition: editsh.hxx:132
virtual void InsertPage(SdrPage *pPage, sal_uInt16 nPos=0xFFFF)
bool EndDragObj(bool bCopy=false)
void MovInsObjPoint(const Point &rPnt)
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:912
bool IsInsObjPoint() const
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
Check only parents.
SdrObject * GetObj(size_t nNum) const
void CreateDefaultShape(sal_uInt16 eSdrObjectKind, const tools::Rectangle &rRect, sal_uInt16 nSlotId)
Definition: feshview.cxx:2942
void RecalcObjOrdNums()
SwFrame * FindPrev()
Definition: frame.hxx:1133
void CheckUnboundObjects()
Temporary work around for bug.
Definition: feshview.cxx:2714
size_t GetObjCount() const
TElementType * Next()
Definition: calbck.hxx:351
bool KnowsFormat(const SwFormat &rFormat) const
Definition: wsfrm.cxx:330
void Height(long nNew)
Definition: swrect.hxx:191
virtual void MakeSelVisible()
show the current selected "object"
Definition: crsrsh.cxx:3057
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
virtual bool GetCharRect(SwRect &rRect, const SwPosition &rPos, SwCursorMoveState *pCMS=nullptr, bool bAllowFarAway=true) const override
Returns the screen position of rPos.
Definition: frmcrsr.cxx:178
sal_Int16 nId
bool IsInsideSelectedObj(const Point &rPt)
returns enum values
Definition: feshview.cxx:1268
void PosAttrSet()
Definition: frmfmt.hxx:398
void InvalidatePos()
Definition: frame.hxx:1021
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:169
SwFrame * FindNext()
Definition: frame.hxx:1119
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool IsGroupSelected()
Create and destroy group, don't when frame is selected.
Definition: feshview.cxx:2342
OBJ_POLY
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1280
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:2176
void StartCropImage()
Definition: feshview.cxx:677
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
EmbeddedObjectRef * pObject
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
void DeleteMark(size_t nNum)
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
virtual SdrObjList * GetSubList() const
OBJ_PLIN
Value in Var-direction gives minimum (can be exceeded but not be less).
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
SdrObject * GetObjAt(const Point &rPt)
Same as IsObjSelectable(), but return the object as well.
Definition: feshview.cxx:1300
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
bool ContainsSwGrfNode() const
Definition: dflyobj.cxx:357
bool BegMarkPoints(const Point &rPnt, bool bUnmark=false)
const SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false) const
Definition: feshview.cxx:2572
Point GetRelativePagePosition(const Point &rDocPos)
Convert document position into position relative to the current page.
Definition: feshview.cxx:3242
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:1188
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
Definition: feshview.cxx:2577
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:394
long Right() const
void Top(const long nTop)
Definition: swrect.hxx:204
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:782
OUString SvxResId(const char *pId)
Destination and/or source not found.
const SwRect & getFrameArea() const
Definition: frame.hxx:177
SwFlyFrame * GetPrevLink() const
Definition: flyfrm.hxx:172
size_t pos
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:450
int nCount
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2455
bool IsTextFrame() const
Definition: frame.hxx:1212
SdrAngleItem makeSdrCircEndAngleItem(long nAngle)
Point GetAnchorObjDiff() const
Methods for status line.
Definition: feshview.cxx:2307
int SetCursor(const Point &rPt, bool bOnlyText=false, bool bBlock=true)
Definition: crsrsh.cxx:758
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:1089
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:120
void Right(const long nRight)
Definition: swrect.hxx:200
Color GetDrawBackgrdColor() const
SwPageFrame::GetDrawBackgrdColor.
Definition: paintfrm.cxx:7017
void UnmarkAll()
long GetSectionWidth(SwFormat const &rFormat) const
Width of current range for column-dialog.
Definition: feshview.cxx:2914
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:3415
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:208
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:2336
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:1145
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:2508
DocumentType eType
GotoObjFlags
values can be combined via logical or
Definition: fesh.hxx:86
void BreakDrag()
Definition: feshview.cxx:779
void SelectionToBottom(bool bBottom=true)
Definition: feshview.cxx:1055
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Iterate over flys - for Basic-collections.
Definition: feshview.cxx:2567
const OUString & GetName() const
SdrObject * GetMarkedSdrObj() const
Point BottomRight() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
virtual void SetLayer(SdrLayerID nLayer)
bool IsShapeDefaultHoriTextDirR2L() const
Is default horizontal text direction for selected drawing object right-to-left.
Definition: feshview.cxx:3202
OBJ_LINE
Style of a layout element.
Definition: frmfmt.hxx:57
SdrDragMethod * GetDragMethod() const
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1256
SwNodeType
Definition: ndtyp.hxx:28
bool IsContentFrame() const
Definition: frame.hxx:1208
void MirrorAllMarkedVertical()
Only protection that cannot be withdrawn e.g.
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:118
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
uno_Any a
bool GetObjAttr(SfxItemSet &rSet) const
Attention: Ambiguities if multiple selections.
Definition: feshview.cxx:2660
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:56
const SwPosition * GetPoint() const
Definition: pam.hxx:207
virtual sal_uInt16 GetObjIdentifier() const
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
void EndDrag()
Definition: feshview.cxx: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:660
bool IsMarkedObjHit(const Point &rPnt, short nTol=-2) const
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
OBJ_NONE
const SdrObject * GetBestObject(bool bNext, GotoObjFlags eType, bool bFlat=true, const svx::ISdrObjectFilter *pFilter=nullptr)
Definition: feshview.cxx:1468
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool ActionPend() const
Definition: viewsh.hxx:199
TElementType * First()
Definition: calbck.hxx:343
SwContentNode * GetContentNode()
Definition: node.hxx:615
void SelectionHasChanged(SwFEShell *pShell)
Definition: fly.cxx:1770
const SdrMarkList & GetMarkedObjectList() const
sal_uInt16 Count() const
FlyAnchors.
Definition: fmtanchr.hxx:34
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:337
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(MergedPara const &, TextFrameIndex nIndex)
Definition: txtfrm.cxx:1153
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SwLayoutFrame * GetUpper()
Definition: frame.hxx:658
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:90
FlyProtectFlags
values can be combined via logical or
Definition: fesh.hxx:104
SdrHdl * PickHandle(const Point &rPnt) const
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:2388
bool IsGroupObject() const
SwFrame * GetPrev()
Definition: frame.hxx:657
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:2785
void MergeValues(const SfxItemSet &rSet)
void BreakCreate()
Definition: feshview.cxx:2125
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:2158
void SelectionToTop(bool bTop=true)
Move selection upwards or downwards (Z-Order).
Definition: feshview.cxx:1035
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
virtual SdrPage * AllocPage(bool bMasterPage)
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ...
Definition: node.cxx:419
RndStdIds GetAnchorId() const
Anchor type of selected object, RndStdIds::UNKNOWN if ambiguous or in case of frame selection...
Definition: feshview.cxx:2233
A page of the document layout.
Definition: pagefrm.hxx:40
virtual SdrObject * RemoveObject(size_t nObjNum)
#define CNT_TXT
Definition: editsh.hxx:131
stay with the cursor inside text
static void SetSearchLabel(const SearchLabel &rSL)
const tools::Rectangle & GetAllMarkedRect() const
FlyProtectFlags IsSelObjProtected(FlyProtectFlags eType) const
Which Protection is set at selected object?
Definition: feshview.cxx:2597
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:2859
void MovMarkPoints(const Point &rPnt)
virtual SdrLayerID GetHellId() const =0
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1093
virtual SdrLayerID GetLayer() const
static bool LessY(Point const &aPt1, Point const &aPt2, bool bOld)
Definition: feshview.cxx:349
SAL_DLLPRIVATE void ScrollTo(const Point &rPt)
Definition: feshview.cxx:650
SAL_DLLPRIVATE bool ImpEndCreate()
Definition: feshview.cxx:1759
bool ShouldObjectBeSelected(const Point &rPt)
Test if there is a draw object at that position and if it should be selected.
Definition: feshview.cxx:1318
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
#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:1077
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
bool GotoObj(bool bNext, GotoObjFlags eType=GotoObjFlags::DrawAny)
Definition: feshview.cxx:1650
OBJ_FREELINE
virtual const tools::Rectangle & GetLastBoundRect() const
SdrObject * Next()
void Left(const long nLeft)
Definition: swrect.hxx:195
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
OBJ_CARC
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
void MoveCreate(const Point &rPos)
Definition: feshview.cxx:1722
void Bottom(const long nBottom)
Definition: swrect.hxx:209
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:280
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
const SvxOpaqueItem & GetOpaque(bool=true) const
Definition: frmatr.hxx:80
void ScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Definition: edtwin3.cxx:35
#define MM50
Definition: swtypes.hxx:59
OBJ_CCUT
SwDrawView * GetDrawView()
Definition: viewimp.hxx:156
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
virtual SwFrameFormat & GetFrameFormat()=0
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:679
unsigned char sal_uInt8
SdrDragMode
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1692
void Width(long nNew)
Definition: swrect.hxx:187
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:1103
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
bool IsNoTextFrame() const
Definition: frame.hxx:1216
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1715
#define SW_ENTER_GROUP
Definition: fesh.hxx:166
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
sal_uInt16 GetHitTolerancePixel() const
bool IsRightToLeft() const
Definition: frame.hxx:965
void EndTextEdit()
Deletes object if required.
Definition: feshview.cxx:1218
SwFlyFrame * GetNextLink() const
Definition: flyfrm.hxx:173
size_t IsObjSelected() const
Definition: feshview.cxx:1150
bool IsPageFrame() const
Definition: frame.hxx:1156
void DelSelectedObj()
Definition: feshview.cxx:2281
QPRO_FUNC_TYPE nType
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position)...
Definition: feshview.cxx:176
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
bool BeginCreate(sal_uInt16 eSdrObjectKind, const Point &rPos)
Process of creating draw objects.
Definition: feshview.cxx:1680
long Left() const
bool IsScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect)
Definition: edtwin3.cxx:45
void ClearMark()
Definition: crsrsh.cxx:936
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:2683
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
SdrObject * getParentSdrObjectFromSdrObject() const
void SetDragMode(SdrDragMode eSdrDragMode)
Set DragMode (e.g. Rotate), but do nothing when frame is selected.
Definition: feshview.cxx: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:1022
void SetChainMarker()
Definition: feshview.cxx:2865
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
sal_uInt16 GetMarkHdlSizePixel() const
bool IsVertical() const
Definition: frame.hxx:951
bool IsDragObj() const
bool BeginMark(const Point &rPos)
Functions for Rubberbox, ti select Draw-Objects.
Definition: feshview.cxx:2137
bool g_bNoInterrupt
Definition: swmodule.cxx:127
void Unchain(SwFrameFormat &rFormat)
Definition: feshview.cxx:2852
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:761
#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:1198
void Clear()
Definition: swrect.hxx:296
virtual void MakeSelVisible() override
Show current selection (frame / draw object as required).
Definition: feshview.cxx:2584
bool IsObjSelectable(const Point &rPt)
The following two methods return enum SdrHdlKind.
Definition: feshview.cxx:1283
#define SW_LEAVE_FRAME
Definition: fesh.hxx:167
const SwFrame * GetAnchorFrame() const
SdrObjList * getParentSdrObjListFromSdrObject() const
const OUString & GetActiveLayer() const
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:153
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
SdrCreateCmd
SwChainRet Chain(SwFrameFormat &rSource, const Point &rPt)
Definition: feshview.cxx:2829
bool IsOver(const SwRect &rRect) const
Definition: swrect.cxx:123
Source already has a follow.
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:66
bool IsDrawCreate() const
Definition: feshview.cxx:2132
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:1235
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:1158
Point TopRight() const
virtual void SetVerticalWriting(bool bVertical)
OBJ_PATHFILL
virtual bool IsTextBox() const override
Definition: dflyobj.cxx:1290
bool MoveAnchor(SwMove nDir)
Definition: feshview.cxx:357
Point Center() const
bool IsMoveProtect() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:836
sal_Int16 nValue
SDRTEXTVERTADJUST_CENTER
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1478
virtual bool HasMarkablePoints() const
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1625
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1733
FrameTypeFlags GetSelFrameType() const
Definition: feshview.cxx:600
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dflyobj.cxx:557
SwFrame * GetNext()
Definition: frame.hxx:656
SdrObject * GetCurrentGroup() const
Color GetShapeBackgrd() const
SwFEShell::GetShapeBackgrd.
Definition: feshview.cxx:3154