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