LibreOffice Module sw (master)  1
dcontact.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 <memory>
21 #include <hintids.hxx>
22 #include <svx/svdpage.hxx>
23 #include <svx/svditer.hxx>
24 #include <svx/svdogrp.hxx>
25 #include <svx/svdotext.hxx>
26 #include <svx/svdmodel.hxx>
27 #include <svx/svdviter.hxx>
28 #include <svx/svdview.hxx>
31 #include <drawdoc.hxx>
32 #include <fmtornt.hxx>
33 #include <viewimp.hxx>
34 #include <fmtsrnd.hxx>
35 #include <fmtanchr.hxx>
36 #include <node.hxx>
37 #include <fmtcntnt.hxx>
38 #include <fmtfsize.hxx>
39 #include <pam.hxx>
40 #include <pagefrm.hxx>
41 #include <rootfrm.hxx>
42 #include <frmtool.hxx>
43 #include <flyfrm.hxx>
44 #include <textboxhelper.hxx>
45 #include <frmfmt.hxx>
46 #include <fmtfollowtextflow.hxx>
47 #include <dflyobj.hxx>
48 #include <dcontact.hxx>
49 #include <unodraw.hxx>
52 #include <IDocumentState.hxx>
53 #include <IDocumentUndoRedo.hxx>
54 #include <doc.hxx>
55 #include <hints.hxx>
56 #include <txtfrm.hxx>
57 #include <frameformats.hxx>
58 #include <sortedobjs.hxx>
65 #include <com/sun/star/text/WritingMode2.hpp>
66 #include <calbck.hxx>
67 #include <algorithm>
68 #include <txtfly.hxx>
69 #include <sal/log.hxx>
70 
71 using namespace ::com::sun::star;
72 
73 namespace
74 {
76  struct VirtObjAnchoredAtFramePred
77  {
78  const SwFrame* m_pAnchorFrame;
79 
80  // #i26791# - compare with master frame
81  static const SwFrame* FindFrame(const SwFrame* pFrame)
82  {
83  if(!pFrame || !pFrame->IsContentFrame())
84  return pFrame;
85  auto pContentFrame = static_cast<const SwContentFrame*>(pFrame);
86  while(pContentFrame->IsFollow())
87  pContentFrame = pContentFrame->FindMaster();
88  return pContentFrame;
89  }
90 
91  VirtObjAnchoredAtFramePred(const SwFrame* pAnchorFrame)
92  : m_pAnchorFrame(FindFrame(pAnchorFrame))
93  {}
94 
95  bool operator()(const SwDrawVirtObjPtr& rpDrawVirtObj)
96  {
97  return FindFrame(rpDrawVirtObj->GetAnchorFrame()) == m_pAnchorFrame;
98  }
99  };
100 }
101 
102 void setContextWritingMode(SdrObject* pObj, SwFrame const * pAnchor)
103 {
104  if(!pObj || !pAnchor)
105  return;
106  short nWritingDirection =
107  pAnchor->IsVertical() ? text::WritingMode2::TB_RL :
108  pAnchor->IsRightToLeft() ? text::WritingMode2::RL_TB :
109  text::WritingMode2::LR_TB;
110  pObj->SetContextWritingMode(nWritingDirection);
111 }
112 
113 
121 {
122  SwFrameFormat* pRetval = nullptr;
123 
124  if (SwVirtFlyDrawObj* pFlyDrawObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
125  {
126  pRetval = pFlyDrawObj->GetFormat();
127  }
128  else
129  {
130  SwContact* pContact = GetUserCall(pObj);
131  if ( pContact )
132  {
133  pRetval = pContact->GetFormat();
134  }
135  }
136  return pRetval;
137 }
138 
139 bool HasWrap( const SdrObject* pObj )
140 {
141  if ( pObj )
142  {
143  const SwFrameFormat* pFormat = ::FindFrameFormat( pObj );
144  if ( pFormat )
145  {
146  return css::text::WrapTextMode_THROUGH != pFormat->GetSurround().GetSurround();
147  }
148  }
149 
150  return false;
151 }
152 
155 {
156  SwRect aRet( pObj->GetCurrentBoundRect() );
157  // #i68520# - call cache of <SwAnchoredObject>
158  SwContact* pContact( GetUserCall( pObj ) );
159  if ( pContact )
160  {
161  const SwAnchoredObject* pAnchoredObj( pContact->GetAnchoredObj( pObj ) );
162  if ( pAnchoredObj )
163  {
164  aRet = pAnchoredObj->GetObjRectWithSpaces();
165  }
166  }
167  return aRet;
168 }
169 
172 {
173  SdrObject *pTmp;
174  while ( !pObj->GetUserCall() && nullptr != (pTmp = pObj->getParentSdrObjectFromSdrObject()) )
175  pObj = pTmp;
176  assert((!pObj->GetUserCall() || nullptr != dynamic_cast<const SwContact*>(pObj->GetUserCall())) &&
177  "<::GetUserCall(..)> - wrong type of found object user call." );
178  return static_cast<SwContact*>(pObj->GetUserCall());
179 }
180 
182 bool IsMarqueeTextObj( const SdrObject& rObj )
183 {
184  if (SdrInventor::Default != rObj.GetObjInventor() ||
185  SdrObjKind::Text != rObj.GetObjIdentifier())
186  return false;
187  SdrTextAniKind eTKind = static_cast<const SdrTextObj&>(rObj).GetTextAniKind();
188  return ( SdrTextAniKind::Scroll == eTKind
189  || SdrTextAniKind::Alternate == eTKind || SdrTextAniKind::Slide == eTKind );
190 }
191 
193  SwClient( pToRegisterIn ),
194  mbInDTOR( false )
195 {}
196 
198 {
199  SetInDTOR();
200 }
201 
202 
204 {
205  mbInDTOR = true;
206 }
207 
210 {
211  // #i46297# - notify background about the arriving of
212  // the object and invalidate its position.
213  const bool bNotify( !GetFormat()->getIDocumentDrawModelAccess().IsVisibleLayerId( _pDrawObj->GetLayer() ) );
214 
215  MoveObjToLayer( true, _pDrawObj );
216 
217  // #i46297#
218  if ( !bNotify )
219  return;
220 
221  SwAnchoredObject* pAnchoredObj = GetAnchoredObj( _pDrawObj );
222  assert(pAnchoredObj);
223  ::setContextWritingMode( _pDrawObj, pAnchoredObj->GetAnchorFrameContainingAnchPos() );
224  // Note: as-character anchored objects aren't registered at a page frame and
225  // a notification of its background isn't needed.
226  if ( pAnchoredObj->GetPageFrame() )
227  {
228  ::Notify_Background( _pDrawObj, pAnchoredObj->GetPageFrame(),
229  pAnchoredObj->GetObjRect(), PrepareHint::FlyFrameArrive, true );
230  }
231 
232  pAnchoredObj->InvalidateObjPos();
233 }
234 
237 {
238  // #i46297# - notify background about the leaving of the object.
239  const bool bNotify( GetFormat()->getIDocumentDrawModelAccess().IsVisibleLayerId( _pDrawObj->GetLayer() ) );
240 
241  MoveObjToLayer( false, _pDrawObj );
242 
243  // #i46297#
244  if ( bNotify )
245  {
246  SwAnchoredObject* pAnchoredObj = GetAnchoredObj( _pDrawObj );
247  assert(pAnchoredObj);
248  // Note: as-character anchored objects aren't registered at a page frame and
249  // a notification of its background isn't needed.
250  if (pAnchoredObj->GetPageFrame())
251  {
252  ::Notify_Background( _pDrawObj, pAnchoredObj->GetPageFrame(),
253  pAnchoredObj->GetObjRect(), PrepareHint::FlyFrameLeave, true );
254  }
255  }
256 }
257 
263 void SwContact::MoveObjToLayer( const bool _bToVisible,
264  SdrObject* _pDrawObj )
265 {
266  if ( !_pDrawObj )
267  {
268  OSL_FAIL( "SwDrawContact::MoveObjToLayer(..) - no drawing object!" );
269  return;
270  }
271 
272  if ( !GetRegisteredIn() )
273  {
274  OSL_FAIL( "SwDrawContact::MoveObjToLayer(..) - no drawing frame format!" );
275  return;
276  }
277 
278  const IDocumentDrawModelAccess& rIDDMA = static_cast<SwFrameFormat*>(GetRegisteredInNonConst())->getIDocumentDrawModelAccess();
279 
280  SdrLayerID nToHellLayerId =
281  _bToVisible ? rIDDMA.GetHellId() : rIDDMA.GetInvisibleHellId();
282  SdrLayerID nToHeavenLayerId =
283  _bToVisible ? rIDDMA.GetHeavenId() : rIDDMA.GetInvisibleHeavenId();
284  SdrLayerID nToControlLayerId =
285  _bToVisible ? rIDDMA.GetControlsId() : rIDDMA.GetInvisibleControlsId();
286  SdrLayerID nFromHellLayerId =
287  _bToVisible ? rIDDMA.GetInvisibleHellId() : rIDDMA.GetHellId();
288  SdrLayerID nFromHeavenLayerId =
289  _bToVisible ? rIDDMA.GetInvisibleHeavenId() : rIDDMA.GetHeavenId();
290  SdrLayerID nFromControlLayerId =
291  _bToVisible ? rIDDMA.GetInvisibleControlsId() : rIDDMA.GetControlsId();
292 
293  if ( dynamic_cast<const SdrObjGroup*>( _pDrawObj) != nullptr )
294  {
295  // determine layer for group object
296  {
297  // proposed layer of a group object is the hell layer
298  SdrLayerID nNewLayerId = nToHellLayerId;
299  if ( ::CheckControlLayer( _pDrawObj ) )
300  {
301  // it has to be the control layer, if one of the member
302  // is a control
303  nNewLayerId = nToControlLayerId;
304  }
305  else if ( _pDrawObj->GetLayer() == rIDDMA.GetHeavenId() ||
306  _pDrawObj->GetLayer() == rIDDMA.GetInvisibleHeavenId() )
307  {
308  // it has to be the heaven layer, if method <GetLayer()> reveals
309  // a heaven layer
310  nNewLayerId = nToHeavenLayerId;
311  }
312  // set layer at group object, but do *not* broadcast and
313  // no propagation to the members.
314  // Thus, call <NbcSetLayer(..)> at super class
315  _pDrawObj->SdrObject::NbcSetLayer( nNewLayerId );
316  }
317 
318  // call method recursively for group object members
319  const SdrObjList* pLst =
320  static_cast<SdrObjGroup*>(_pDrawObj)->GetSubList();
321  if ( pLst )
322  {
323  for ( size_t i = 0; i < pLst->GetObjCount(); ++i )
324  {
325  MoveObjToLayer( _bToVisible, pLst->GetObj( i ) );
326  }
327  }
328  }
329  else
330  {
331  const SdrLayerID nLayerIdOfObj = _pDrawObj->GetLayer();
332  if ( nLayerIdOfObj == nFromHellLayerId )
333  {
334  _pDrawObj->SetLayer( nToHellLayerId );
335  }
336  else if ( nLayerIdOfObj == nFromHeavenLayerId )
337  {
338  _pDrawObj->SetLayer( nToHeavenLayerId );
339  }
340  else if ( nLayerIdOfObj == nFromControlLayerId )
341  {
342  _pDrawObj->SetLayer( nToControlLayerId );
343  }
344  }
345 }
346 
348 sal_uInt32 SwContact::GetMinOrdNum() const
349 {
350  sal_uInt32 nMinOrdNum( SAL_MAX_UINT32 );
351 
352  std::vector< SwAnchoredObject* > aObjs;
353  GetAnchoredObjs( aObjs );
354 
355  while ( !aObjs.empty() )
356  {
357  sal_uInt32 nTmpOrdNum = aObjs.back()->GetDrawObj()->GetOrdNum();
358 
359  if ( nTmpOrdNum < nMinOrdNum )
360  {
361  nMinOrdNum = nTmpOrdNum;
362  }
363 
364  aObjs.pop_back();
365  }
366 
367  OSL_ENSURE( nMinOrdNum != SAL_MAX_UINT32,
368  "<SwContact::GetMinOrdNum()> - no order number found." );
369  return nMinOrdNum;
370 }
371 
373 sal_uInt32 SwContact::GetMaxOrdNum() const
374 {
375  sal_uInt32 nMaxOrdNum( 0 );
376 
377  std::vector< SwAnchoredObject* > aObjs;
378  GetAnchoredObjs( aObjs );
379 
380  while ( !aObjs.empty() )
381  {
382  sal_uInt32 nTmpOrdNum = aObjs.back()->GetDrawObj()->GetOrdNum();
383 
384  if ( nTmpOrdNum > nMaxOrdNum )
385  {
386  nMaxOrdNum = nTmpOrdNum;
387  }
388 
389  aObjs.pop_back();
390  }
391 
392  return nMaxOrdNum;
393 }
394 
395 namespace
396 {
397  Point lcl_GetWW8Pos(SwAnchoredObject const * pAnchoredObj, const bool bFollowTextFlow, sw::WW8AnchorConv& reConv)
398  {
399  switch(reConv)
400  {
402  {
403  bool bRelToTableCell(false);
404  Point aPos(pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell));
405  if(bRelToTableCell)
407  return aPos;
408  }
410  return pAnchoredObj->GetRelPosToAnchorFrame();
412  return pAnchoredObj->GetRelPosToChar();
414  return pAnchoredObj->GetRelPosToLine();
415  default: ;
416  }
417  return Point();
418  }
419 }
420 void SwContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
421 {
422  // this does not call SwClient::SwClientNotify and thus doesn't handle RES_OBJECTDYING as usual. Is this intentional?
423  if (auto pFindSdrObjectHint = dynamic_cast<const sw::FindSdrObjectHint*>(&rHint))
424  {
425  if(!pFindSdrObjectHint->m_rpObject)
426  pFindSdrObjectHint->m_rpObject = GetMaster();
427  }
428  else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint))
429  {
430  // determine anchored object
431  SwAnchoredObject* pAnchoredObj(nullptr);
432  {
433  std::vector<SwAnchoredObject*> aAnchoredObjs;
434  GetAnchoredObjs(aAnchoredObjs);
435  if(!aAnchoredObjs.empty())
436  pAnchoredObj = aAnchoredObjs.front();
437  }
438  // no anchored object found. Thus, the needed layout information can't
439  // be determined. --> no conversion
440  if(!pAnchoredObj)
441  return;
442  // no conversion for anchored drawing object, which aren't attached to an
443  // anchor frame.
444  // This is the case for drawing objects, which are anchored inside a page
445  // header/footer of an *unused* page style.
446  if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame())
447  return;
448  const bool bFollowTextFlow = static_cast<const SwFrameFormat&>(rMod).GetFollowTextFlow().GetValue();
449  sw::WW8AnchorConvResult& rResult(pWW8AnchorConvHint->m_rResult);
450  // No distinction between layout directions, because of missing
451  // information about WW8 in vertical layout.
452  rResult.m_aPos.setX(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eHoriConv).getX());
453  rResult.m_aPos.setY(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eVertConv).getY());
454  rResult.m_bConverted = true;
455  }
456 }
457 
458 
460  SwFlyFrameFormat *pToRegisterIn,
461  SdrModel& rTargetModel)
462 : SwContact(pToRegisterIn),
463  mpMasterObj(new SwFlyDrawObj(rTargetModel))
464 {
465  // #i26791# - class <SwFlyDrawContact> contains the 'master'
466  // drawing object of type <SwFlyDrawObj> on its own.
467  mpMasterObj->SetOrdNum( 0xFFFFFFFE );
468  mpMasterObj->SetUserCall( this );
469 }
470 
472 {
473  if ( mpMasterObj )
474  {
475  mpMasterObj->SetUserCall( nullptr );
476  if ( mpMasterObj->getSdrPageFromSdrObject() )
477  mpMasterObj->getSdrPageFromSdrObject()->RemoveObject( mpMasterObj->GetOrdNum() );
478  }
479 }
480 
482  SwFrame const& rAnchorFrame)
483 {
484  // maintain invariant that a shape's textbox immediately follows the shape
485  // also for the multiple SdrVirtObj created for shapes in header/footer
486  if (SwFrameFormat const*const pDrawFormat =
488  {
489  // assume that the draw SdrVirtObj is always created before the flyframe one
490  if (SwSortedObjs const*const pObjs = rAnchorFrame.GetDrawObjs())
491  {
492  for (SwAnchoredObject const*const pAnchoredObj : *pObjs)
493  {
494  if (&pAnchoredObj->GetFrameFormat() == pDrawFormat)
495  {
496  return pAnchoredObj->GetDrawObj()->GetOrdNum() + 1;
497  }
498  }
499  }
500  // if called from AppendObjs(), this is a problem; if called from lcl_SetFlyFrameAttr() it's not
501  SAL_INFO("sw", "GetOrdNumForNewRef: cannot find SdrObject for text box's shape");
502  }
503  // search for another Writer fly frame registered at same frame format
505  const SwFlyFrame* pFlyFrame(nullptr);
506  for(pFlyFrame = aIter.First(); pFlyFrame; pFlyFrame = aIter.Next())
507  {
508  if(pFlyFrame != pFly)
509  break;
510  }
511 
512  if(pFlyFrame)
513  {
514  // another Writer fly frame found. Take its order number
515  return pFlyFrame->GetVirtDrawObj()->GetOrdNum();
516  }
517  // no other Writer fly frame found. Take order number of 'master' object
518  // #i35748# - use method <GetOrdNumDirect()> instead
519  // of method <GetOrdNum()> to avoid a recalculation of the order number,
520  // which isn't intended.
521  return GetMaster()->GetOrdNumDirect();
522 }
523 
525  SwFlyFrameFormat* pFormat, SwFrame const& rAnchorFrame)
526 {
527  // Find ContactObject from the Format. If there's already one, we just
528  // need to create a new Ref, else we create the Contact now.
529 
531  SwFlyDrawContact* pContact = pFormat->GetOrCreateContact();
532  SwVirtFlyDrawObj* pDrawObj(
533  new SwVirtFlyDrawObj(
534  pContact->GetMaster()->getSdrModelFromSdrObject(),
535  *pContact->GetMaster(),
536  pFly));
537  pDrawObj->SetUserCall(pContact);
538 
539  // The Reader creates the Masters and inserts them into the Page in
540  // order to transport the z-order.
541  // After creating the first Reference the Masters are removed from the
542  // List and are not important anymore.
543  SdrPage* pPg = pContact->GetMaster()->getSdrPageFromSdrObject();
544  if(nullptr != pPg)
545  {
546  const size_t nOrdNum = pContact->GetMaster()->GetOrdNum();
547  pPg->ReplaceObject(pDrawObj, nOrdNum);
548  }
549  // #i27030# - insert new <SwVirtFlyDrawObj> instance
550  // into drawing page with correct order number
551  else
552  rIDDMA.GetDrawModel()->GetPage(0)->InsertObject(pDrawObj, pContact->GetOrdNumForNewRef(pFly, rAnchorFrame));
553  // #i38889# - assure, that new <SwVirtFlyDrawObj> instance
554  // is in a visible layer.
555  pContact->MoveObjToVisibleLayer(pDrawObj);
556  return pDrawObj;
557 }
558 
559 // #i26791#
561 {
562  assert(pSdrObj);
563  assert(dynamic_cast<const SwVirtFlyDrawObj*>(pSdrObj) != nullptr);
564  assert(GetUserCall(pSdrObj) == this &&
565  "<SwFlyDrawContact::GetAnchoredObj(..)> - provided object doesn't belong to this contact");
566 
567  const SwAnchoredObject *const pRetAnchoredObj =
568  static_cast<const SwVirtFlyDrawObj*>(pSdrObj)->GetFlyFrame();
569 
570  return pRetAnchoredObj;
571 }
572 
574 {
575  return const_cast<SwAnchoredObject *>(const_cast<SwFlyDrawContact const*>(this)->GetAnchoredObj(pSdrObj));
576 }
577 
579 {
580  return mpMasterObj.get();
581 }
582 
589 {
590  assert(dynamic_cast<const SwVirtFlyDrawObj*>(_pDrawObj) != nullptr);
591 
592  if ( GetFormat()->getIDocumentDrawModelAccess().IsVisibleLayerId( _pDrawObj->GetLayer() ) )
593  {
594  // nothing to do
595  return;
596  }
597 
598  SwFlyFrame* pFlyFrame = static_cast<SwVirtFlyDrawObj*>(_pDrawObj)->GetFlyFrame();
599 
600  // #i44464# - consider, that Writer fly frame content
601  // already exists - (e.g. WW8 document is inserted into an existing document).
602  if ( !pFlyFrame->Lower() )
603  {
604  pFlyFrame->InsertColumns();
605  pFlyFrame->Chain( pFlyFrame->AnchorFrame() );
606  pFlyFrame->InsertCnt();
607  }
608  if ( pFlyFrame->GetDrawObjs() )
609  {
610  for (SwAnchoredObject* i : *pFlyFrame->GetDrawObjs())
611  {
612  // #i28701# - consider type of objects in sorted object list.
613  SdrObject* pObj = i->DrawObj();
614  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
615  pContact->MoveObjToVisibleLayer( pObj );
616  }
617  }
618 
619  // make fly frame visible
621 }
622 
629 {
630  assert(dynamic_cast<const SwVirtFlyDrawObj*>(_pDrawObj) != nullptr);
631 
632  if ( !GetFormat()->getIDocumentDrawModelAccess().IsVisibleLayerId( _pDrawObj->GetLayer() ) )
633  {
634  // nothing to do
635  return;
636  }
637 
638  SwFlyFrame* pFlyFrame = static_cast<SwVirtFlyDrawObj*>(_pDrawObj)->GetFlyFrame();
639 
640  pFlyFrame->Unchain();
641  pFlyFrame->DeleteCnt();
642  if ( pFlyFrame->GetDrawObjs() )
643  {
644  for (SwAnchoredObject* i : *pFlyFrame->GetDrawObjs())
645  {
646  // #i28701# - consider type of objects in sorted object list.
647  SdrObject* pObj = i->DrawObj();
648  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
649  pContact->MoveObjToInvisibleLayer( pObj );
650  }
651  }
652 
653  // make fly frame invisible
655 }
656 
658 void SwFlyDrawContact::GetAnchoredObjs( std::vector<SwAnchoredObject*>& _roAnchoredObjs ) const
659 {
660  const SwFrameFormat* pFormat = GetFormat();
661  SwFlyFrame::GetAnchoredObjects( _roAnchoredObjs, *pFormat );
662 }
663 void SwFlyDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
664 {
665  SwContact::SwClientNotify(rMod, rHint);
666  if(auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
667  {
668  // #i11176#
669  // This also needs to work when no layout exists. Thus, for
670  // FlyFrames an alternative method is used now in that case.
671  auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
672  if (pFormat && pFormat->Which() == RES_FLYFRMFMT && !pFormat->getIDocumentLayoutAccess().GetCurrentViewShell())
673  pGetZOrdnerHint->m_rnZOrder = GetMaster()->GetOrdNum();
674  }
675 }
676 
677 // SwDrawContact
678 
679 bool CheckControlLayer( const SdrObject *pObj )
680 {
681  if ( SdrInventor::FmForm == pObj->GetObjInventor() )
682  return true;
683  if (const SdrObjGroup *pObjGroup = dynamic_cast<const SdrObjGroup*>(pObj))
684  {
685  const SdrObjList *pLst = pObjGroup->GetSubList();
686  for ( size_t i = 0; i < pLst->GetObjCount(); ++i )
687  {
688  if ( ::CheckControlLayer( pLst->GetObj( i ) ) )
689  {
690  // #i18447# - return correct value ;-)
691  return true;
692  }
693  }
694  }
695  return false;
696 }
697 
699  SwContact( pToRegisterIn ),
700  mbMasterObjCleared( false ),
701  mbDisconnectInProgress( false ),
702  mbUserCallActive( false ),
703  // Note: value of <meEventTypeOfCurrentUserCall> isn't of relevance, because
704  // <mbUserCallActive> is false.
705  meEventTypeOfCurrentUserCall( SdrUserCallType::MoveOnly )
706 {
707  // --> #i33909# - assure, that drawing object is inserted
708  // in the drawing page.
709  if ( !pObj->IsInserted() )
710  {
711  pToRegisterIn->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0)->
712  InsertObject( pObj, pObj->GetOrdNumDirect() );
713  }
714 
715  // Controls have to be always in the Control-Layer. This is also true for
716  // group objects, if they contain controls.
717  if ( ::CheckControlLayer( pObj ) )
718  {
719  // set layer of object to corresponding invisible layer.
720  pObj->SetLayer( pToRegisterIn->getIDocumentDrawModelAccess().GetInvisibleControlsId() );
721  }
722 
723  // #i26791#
724  pObj->SetUserCall( this );
725  maAnchoredDrawObj.SetDrawObj( *pObj );
726 
727  // if there already exists an SwXShape for the object, ensure it knows about us, and the SdrObject
728  // #i99056#
730 }
731 
733 {
734  SetInDTOR();
735 
737 
738  // remove 'master' from drawing page
740 
741  // remove and destroy 'virtual' drawing objects.
743 
744  if ( !mbMasterObjCleared )
745  {
746  SdrObject* pObject = const_cast< SdrObject* >( maAnchoredDrawObj.GetDrawObj() );
747  SdrObject::Free( pObject );
748  }
749 }
750 
751 void SwDrawContact::GetTextObjectsFromFormat(std::list<SdrTextObj*>& o_rTextObjects, SwDoc& rDoc)
752 {
753  for(auto& rpFly : *rDoc.GetSpzFrameFormats())
754  {
755  if(dynamic_cast<const SwDrawFrameFormat*>(rpFly))
756  rpFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects));
757  }
758 }
759 
760 // #i26791#
762 {
763  // handle default parameter value
764  if (!pSdrObj)
765  {
766  pSdrObj = GetMaster();
767  }
768 
769  assert(pSdrObj);
770  assert(dynamic_cast<const SwDrawVirtObj*>(pSdrObj) != nullptr ||
771  dynamic_cast<const SdrVirtObj*>(pSdrObj) == nullptr);
772  assert((GetUserCall(pSdrObj) == this ||
773  pSdrObj == GetMaster()) &&
774  "<SwDrawContact::GetAnchoredObj(..)> - provided object doesn't belongs to this contact" );
775 
776  const SwAnchoredObject* pRetAnchoredObj = nullptr;
777 
778  if (auto pVirtObj = dynamic_cast<const SwDrawVirtObj*>(pSdrObj))
779  {
780  pRetAnchoredObj = &(pVirtObj->GetAnchoredObj());
781  }
782  else
783  {
784  assert(dynamic_cast<const SdrVirtObj*>(pSdrObj) == nullptr);
785  pRetAnchoredObj = &maAnchoredDrawObj;
786  }
787 
788  return pRetAnchoredObj;
789 }
790 
792 {
793  return const_cast<SwAnchoredObject*>(const_cast<SwDrawContact const*>(this)->GetAnchoredObj(pSdrObj));
794 }
795 
797 {
798  return !mbMasterObjCleared
800  : nullptr;
801 }
802 
803 const SwFrame* SwDrawContact::GetAnchorFrame( const SdrObject* _pDrawObj ) const
804 {
805  const SwFrame* pAnchorFrame = nullptr;
806  if ( !_pDrawObj ||
807  _pDrawObj == GetMaster() ||
808  ( !_pDrawObj->GetUserCall() &&
809  GetUserCall( _pDrawObj ) == this ) )
810  {
811  pAnchorFrame = maAnchoredDrawObj.GetAnchorFrame();
812  }
813  else
814  {
815  assert(dynamic_cast<SwDrawVirtObj const*>(_pDrawObj) != nullptr);
816  pAnchorFrame = static_cast<const SwDrawVirtObj*>(_pDrawObj)->GetAnchorFrame();
817  }
818 
819  return pAnchorFrame;
820 }
821 
823 {
824  return const_cast<SwFrame *>(const_cast<SwDrawContact const*>(this)->GetAnchorFrame(pDrawObj));
825 }
826 
830 {
831  maDrawVirtObjs.push_back(
833  new SwDrawVirtObj(
834  GetMaster()->getSdrModelFromSdrObject(),
835  *GetMaster(),
836  *this)));
837  maDrawVirtObjs.back()->AddToDrawingPage(rAnchorFrame);
838  return maDrawVirtObjs.back().get();
839 }
840 
843 {
844  for(auto& rpDrawVirtObj : maDrawVirtObjs)
845  {
846  // remove and destroy 'virtual object'
847  rpDrawVirtObj->RemoveFromWriterLayout();
848  rpDrawVirtObj->RemoveFromDrawingPage();
849  }
850  maDrawVirtObjs.clear();
851 }
852 
853 
856 {
857  SdrObject* pRetDrawObj = nullptr;
858 
859  // #i26791# - compare master frames instead of direct frames
860  const SwFrame* pProposedAnchorFrame = &_rAnchorFrame;
861  if ( pProposedAnchorFrame->IsContentFrame() )
862  {
863  const SwContentFrame* pTmpFrame =
864  static_cast<const SwContentFrame*>( pProposedAnchorFrame );
865  while ( pTmpFrame->IsFollow() )
866  {
867  pTmpFrame = pTmpFrame->FindMaster();
868  }
869  pProposedAnchorFrame = pTmpFrame;
870  }
871 
872  const SwFrame* pMasterObjAnchorFrame = GetAnchorFrame();
873  if ( pMasterObjAnchorFrame && pMasterObjAnchorFrame->IsContentFrame() )
874  {
875  const SwContentFrame* pTmpFrame =
876  static_cast<const SwContentFrame*>( pMasterObjAnchorFrame );
877  while ( pTmpFrame->IsFollow() )
878  {
879  pTmpFrame = pTmpFrame->FindMaster();
880  }
881  pMasterObjAnchorFrame = pTmpFrame;
882  }
883 
884  if ( pMasterObjAnchorFrame && pMasterObjAnchorFrame == pProposedAnchorFrame )
885  {
886  pRetDrawObj = GetMaster();
887  }
888  else
889  {
890  const auto ppFoundVirtObj(std::find_if(maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
891  VirtObjAnchoredAtFramePred(pProposedAnchorFrame)));
892  if(ppFoundVirtObj != maDrawVirtObjs.end())
893  pRetDrawObj = ppFoundVirtObj->get();
894  }
895 
896  return pRetDrawObj;
897 }
898 
900 {
901  for(const auto& rpDrawVirtObj : maDrawVirtObjs)
902  {
903  SwDrawVirtObj* pDrawVirtObj(rpDrawVirtObj.get());
904  if ( pDrawVirtObj->GetAnchorFrame() )
905  {
906  // #i34640# - determine correct page frame
907  SwPageFrame* pPage = pDrawVirtObj->AnchoredObj().FindPageFrameOfAnchor();
908  if( pOldBoundRect && pPage )
909  {
910  SwRect aOldRect( *pOldBoundRect );
911  aOldRect.Pos() += pDrawVirtObj->GetOffset();
912  if( aOldRect.HasArea() )
913  ::Notify_Background( pDrawVirtObj, pPage,
914  aOldRect, PrepareHint::FlyFrameLeave,true);
915  }
916  // #i34640# - include spacing for wrapping
917  SwRect aRect( pDrawVirtObj->GetAnchoredObj().GetObjRectWithSpaces() );
918  if (aRect.HasArea() && pPage)
919  {
920  SwPageFrame* pPg = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aRect, pPage )));
921  if ( pPg )
922  ::Notify_Background( pDrawVirtObj, pPg, aRect,
924  }
925  ::ClrContourCache( pDrawVirtObj );
926  }
927  }
928 }
929 
931 static void lcl_NotifyBackgroundOfObj( SwDrawContact const & _rDrawContact,
932  const SdrObject& _rObj,
933  const tools::Rectangle* _pOldObjRect )
934 {
935  // #i34640#
936  SwAnchoredObject* pAnchoredObj =
937  const_cast<SwAnchoredObject*>(_rDrawContact.GetAnchoredObj( &_rObj ));
938  if ( !(pAnchoredObj && pAnchoredObj->GetAnchorFrame()) )
939  return;
940 
941  // #i34640# - determine correct page frame
942  SwPageFrame* pPageFrame = pAnchoredObj->FindPageFrameOfAnchor();
943  if( _pOldObjRect && pPageFrame )
944  {
945  SwRect aOldRect( *_pOldObjRect );
946  if( aOldRect.HasArea() )
947  {
948  // #i34640# - determine correct page frame
949  SwPageFrame* pOldPageFrame = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aOldRect, pPageFrame )));
950  ::Notify_Background( &_rObj, pOldPageFrame, aOldRect,
952  }
953  }
954  // #i34640# - include spacing for wrapping
955  SwRect aNewRect( pAnchoredObj->GetObjRectWithSpaces() );
956  if( aNewRect.HasArea() && pPageFrame )
957  {
958  pPageFrame = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aNewRect, pPageFrame )));
959  ::Notify_Background( &_rObj, pPageFrame, aNewRect,
961  }
962  ClrContourCache( &_rObj );
963 }
964 
966  SdrUserCallType eType,
967  const tools::Rectangle& rOldBoundRect )
968 {
969  // #i26791# - no event handling, if existing <SwViewShell>
970  // is in construction
971  SwDoc* pDoc = GetFormat()->GetDoc();
974  {
975  return;
976  }
977 
978  // #i44339#
979  // no event handling, if document is in destruction.
980  // Exception: It's the SdrUserCallType::Delete event
981  if ( pDoc->IsInDtor() && eType != SdrUserCallType::Delete )
982  {
983  return;
984  }
985 
986  //Put on Action, but not if presently anywhere an action runs.
987  bool bHasActions(true);
989  if ( pTmpRoot && pTmpRoot->IsCallbackActionEnabled() )
990  {
992  if ( pSh )
993  {
994  for(SwViewShell& rShell : pSh->GetRingContainer() )
995  {
996  if ( rShell.Imp()->IsAction() || rShell.Imp()->IsIdleAction() )
997  {
998  bHasActions = true;
999  break;
1000  }
1001  bHasActions = false;
1002  }
1003  }
1004  if(!bHasActions)
1005  pTmpRoot->StartAllAction();
1006  }
1007  SdrObjUserCall::Changed( rObj, eType, rOldBoundRect );
1008  Changed_( rObj, eType, &rOldBoundRect ); //Attention, possibly suicidal!
1009 
1010  if(!bHasActions)
1011  pTmpRoot->EndAllAction();
1012 }
1013 
1017 {
1018  private:
1022 
1023  public:
1025  SdrUserCallType _eEventType )
1026  : mpDrawContact( _pDrawContact ),
1027  mbParentUserCallActive( _pDrawContact->mbUserCallActive ),
1028  meParentUserCallEventType( _pDrawContact->meEventTypeOfCurrentUserCall )
1029  {
1030  mpDrawContact->mbUserCallActive = true;
1031  mpDrawContact->meEventTypeOfCurrentUserCall = _eEventType;
1032  }
1033 
1035  {
1036  if ( mpDrawContact )
1037  {
1038  mpDrawContact->mbUserCallActive = mbParentUserCallActive;
1040  }
1041  }
1042 
1044  {
1045  mpDrawContact = nullptr;
1046  }
1047 
1048  bool IsNestedUserCall() const
1049  {
1050  return mbParentUserCallActive;
1051  }
1052 
1054  {
1055  if ( !IsNestedUserCall() )
1056  return;
1057 
1058  bool bTmpAssert( true );
1059  // Currently its known, that a nested event SdrUserCallType::Resize
1060  // could occur during parent user call SdrUserCallType::Inserted,
1061  // SdrUserCallType::Delete and SdrUserCallType::Resize for edge objects.
1062  // Also possible are nested SdrUserCallType::ChildResize events for
1063  // edge objects
1064  // Thus, assert all other combinations
1065  if ( ( meParentUserCallEventType == SdrUserCallType::Inserted ||
1066  meParentUserCallEventType == SdrUserCallType::Delete ||
1067  meParentUserCallEventType == SdrUserCallType::Resize ) &&
1068  mpDrawContact->meEventTypeOfCurrentUserCall == SdrUserCallType::Resize )
1069  {
1070  bTmpAssert = false;
1071  }
1072  else if ( meParentUserCallEventType == SdrUserCallType::ChildResize &&
1073  mpDrawContact->meEventTypeOfCurrentUserCall == SdrUserCallType::ChildResize )
1074  {
1075  bTmpAssert = false;
1076  }
1077 
1078  if ( bTmpAssert )
1079  {
1080  OSL_FAIL( "<SwDrawContact::Changed_(..)> - unknown nested <UserCall> event. This is serious." );
1081  }
1082  }
1083 };
1084 
1087 {
1089  {
1090  // Just notify the textbox that the size has changed, the actual object size is not interesting.
1092  SwFormatFrameSize aSize;
1093  aResizeSet.Put(aSize);
1094  SwTextBoxHelper::syncFlyFrameAttr(*pFormat, aResizeSet, pFormat->FindRealSdrObject());
1095  }
1096 }
1097 
1098 // !!!ATTENTION!!! The object may commit suicide!!!
1099 
1101  SdrUserCallType eType,
1102  const tools::Rectangle* pOldBoundRect )
1103 {
1104  // suppress handling of nested <SdrObjUserCall> events
1105  NestedUserCallHdl aNestedUserCallHdl( this, eType );
1106  if ( aNestedUserCallHdl.IsNestedUserCall() )
1107  {
1108  aNestedUserCallHdl.AssertNestedUserCall();
1109  return;
1110  }
1111  // do *not* notify, if document is destructing
1112  // #i35912# - do *not* notify for as-character anchored
1113  // drawing objects.
1114  // #i35007#
1115  // improvement: determine as-character anchored object flag only once.
1116  const bool bAnchoredAsChar = ObjAnchoredAsChar();
1117  const bool bNotify = !(GetFormat()->GetDoc()->IsInDtor()) &&
1118  ( css::text::WrapTextMode_THROUGH != GetFormat()->GetSurround().GetSurround() ) &&
1119  !bAnchoredAsChar;
1120  switch( eType )
1121  {
1122  case SdrUserCallType::Delete:
1123  {
1124  if ( bNotify )
1125  {
1126  lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1127  // --> #i36181# - background of 'virtual'
1128  // drawing objects have also been notified.
1129  NotifyBackgroundOfAllVirtObjs( pOldBoundRect );
1130  }
1131  DisconnectFromLayout( false );
1132  mbMasterObjCleared = true;
1133  delete this;
1134  // --> #i65784# Prevent memory corruption
1135  aNestedUserCallHdl.DrawContactDeleted();
1136  break;
1137  }
1138  case SdrUserCallType::Inserted:
1139  {
1140  if ( mbDisconnectInProgress )
1141  {
1142  OSL_FAIL( "<SwDrawContact::Changed_(..)> - Insert event during disconnection from layout is invalid." );
1143  }
1144  else
1145  {
1146  ConnectToLayout();
1147  if ( bNotify )
1148  {
1149  lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1150  }
1151  }
1152  break;
1153  }
1154  case SdrUserCallType::Removed:
1155  {
1156  if ( bNotify )
1157  {
1158  lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1159  }
1160  DisconnectFromLayout( false );
1161  break;
1162  }
1163  case SdrUserCallType::ChildInserted :
1164  case SdrUserCallType::ChildRemoved :
1165  {
1166  // --> #i113730#
1167  // force layer of controls for group objects containing control objects
1168  if(dynamic_cast< SdrObjGroup* >(maAnchoredDrawObj.DrawObj()))
1169  {
1171  {
1172  const IDocumentDrawModelAccess& rIDDMA = static_cast<SwFrameFormat*>(GetRegisteredInNonConst())->getIDocumentDrawModelAccess();
1173  const SdrLayerID aCurrentLayer(maAnchoredDrawObj.DrawObj()->GetLayer());
1174  const SdrLayerID aControlLayerID(rIDDMA.GetControlsId());
1175  const SdrLayerID aInvisibleControlLayerID(rIDDMA.GetInvisibleControlsId());
1176 
1177  if(aCurrentLayer != aControlLayerID && aCurrentLayer != aInvisibleControlLayerID)
1178  {
1179  if ( aCurrentLayer == rIDDMA.GetInvisibleHellId() ||
1180  aCurrentLayer == rIDDMA.GetInvisibleHeavenId() )
1181  {
1182  maAnchoredDrawObj.DrawObj()->SetLayer(aInvisibleControlLayerID);
1183  }
1184  else
1185  {
1186  maAnchoredDrawObj.DrawObj()->SetLayer(aControlLayerID);
1187  }
1188  }
1189  }
1190  }
1191  [[fallthrough]];
1192  }
1193  case SdrUserCallType::MoveOnly:
1194  case SdrUserCallType::Resize:
1195  case SdrUserCallType::ChildMoveOnly :
1196  case SdrUserCallType::ChildResize :
1197  case SdrUserCallType::ChildChangeAttr :
1198  case SdrUserCallType::ChildDelete :
1199  {
1200  // #i31698# - improvement
1201  // get instance <SwAnchoredDrawObject> only once
1202  const SwAnchoredDrawObject* pAnchoredDrawObj =
1203  static_cast<const SwAnchoredDrawObject*>( GetAnchoredObj( &rObj ) );
1204 
1205  /* protect against NULL pointer dereferencing */
1206  if(!pAnchoredDrawObj)
1207  {
1208  break;
1209  }
1210 
1211  // #i26791# - adjust positioning and alignment attributes,
1212  // if positioning of drawing object isn't in progress.
1213  // #i53320# - no adjust of positioning attributes,
1214  // if drawing object isn't positioned.
1215  if ( !pAnchoredDrawObj->IsPositioningInProgress() &&
1216  !pAnchoredDrawObj->NotYetPositioned() )
1217  {
1218  // #i34748# - If no last object rectangle is
1219  // provided by the anchored object, use parameter <pOldBoundRect>.
1220  const tools::Rectangle& aOldObjRect = pAnchoredDrawObj->GetLastObjRect()
1221  ? *(pAnchoredDrawObj->GetLastObjRect())
1222  : *pOldBoundRect;
1223  // #i79400#
1224  // always invalidate object rectangle inclusive spaces
1225  pAnchoredDrawObj->InvalidateObjRectWithSpaces();
1226  // #i41324# - notify background before
1227  // adjusting position
1228  if ( bNotify )
1229  {
1230  // #i31573# - correction
1231  // background of given drawing object.
1232  lcl_NotifyBackgroundOfObj( *this, rObj, &aOldObjRect );
1233  }
1234  // #i31698# - determine layout direction
1235  // via draw frame format.
1236  SwFrameFormat::tLayoutDir eLayoutDir =
1237  pAnchoredDrawObj->GetFrameFormat().GetLayoutDir();
1238  // use geometry of drawing object
1239  tools::Rectangle aObjRect( rObj.GetSnapRect() );
1240  // If drawing object is a member of a group, the adjustment
1241  // of the positioning and the alignment attributes has to
1242  // be done for the top group object.
1243  if ( rObj.getParentSdrObjectFromSdrObject() )
1244  {
1245  const SdrObject* pGroupObj = rObj.getParentSdrObjectFromSdrObject();
1246  while ( pGroupObj->getParentSdrObjectFromSdrObject() )
1247  {
1248  pGroupObj = pGroupObj->getParentSdrObjectFromSdrObject();
1249  }
1250  // use geometry of drawing object
1251  aObjRect = pGroupObj->GetSnapRect();
1252 
1255 
1256  }
1257  SwTwips nXPosDiff(0);
1258  SwTwips nYPosDiff(0);
1259  switch ( eLayoutDir )
1260  {
1262  {
1263  nXPosDiff = aObjRect.Left() - aOldObjRect.Left();
1264  nYPosDiff = aObjRect.Top() - aOldObjRect.Top();
1265  }
1266  break;
1268  {
1269  nXPosDiff = aOldObjRect.Right() - aObjRect.Right();
1270  nYPosDiff = aObjRect.Top() - aOldObjRect.Top();
1271  }
1272  break;
1274  {
1275  nXPosDiff = aObjRect.Top() - aOldObjRect.Top();
1276  nYPosDiff = aOldObjRect.Right() - aObjRect.Right();
1277  }
1278  break;
1279  default:
1280  {
1281  assert(!"<SwDrawContact::Changed_(..)> - unsupported layout direction");
1282  }
1283  }
1284  SfxItemSetFixed<RES_VERT_ORIENT, RES_HORI_ORIENT> aSet( GetFormat()->GetDoc()->GetAttrPool() );
1285  const SwFormatVertOrient& rVert = GetFormat()->GetVertOrient();
1286  if ( nYPosDiff != 0 )
1287  {
1288  if ( rVert.GetRelationOrient() == text::RelOrientation::CHAR ||
1289  rVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
1290  {
1291  nYPosDiff = -nYPosDiff;
1292  }
1293  aSet.Put( SwFormatVertOrient( rVert.GetPos()+nYPosDiff,
1295  rVert.GetRelationOrient() ) );
1296  }
1297 
1298  const SwFormatHoriOrient& rHori = GetFormat()->GetHoriOrient();
1299  if ( !bAnchoredAsChar && nXPosDiff != 0 )
1300  {
1301  aSet.Put( SwFormatHoriOrient( rHori.GetPos()+nXPosDiff,
1303  rHori.GetRelationOrient() ) );
1304  }
1305 
1306  if ( nYPosDiff ||
1307  ( !bAnchoredAsChar && nXPosDiff != 0 ) )
1308  {
1309  GetFormat()->GetDoc()->SetFlyFrameAttr( *(GetFormat()), aSet );
1310  // keep new object rectangle, to avoid multiple
1311  // changes of the attributes by multiple event from
1312  // the drawing layer - e.g. group objects and its members
1313  // #i34748# - use new method
1314  // <SwAnchoredDrawObject::SetLastObjRect(..)>.
1315  const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)
1316  ->SetLastObjRect( aObjRect );
1317  }
1318  else if ( aObjRect.GetSize() != aOldObjRect.GetSize() )
1319  {
1320  InvalidateObjs_();
1321  // #i35007# - notify anchor frame
1322  // of as-character anchored object
1323  if ( bAnchoredAsChar )
1324  {
1325  SwFrame* pAnchorFrame = const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)->AnchorFrame();
1326  if(pAnchorFrame)
1327  {
1329  }
1330  }
1331 
1333  }
1334  else if (eType == SdrUserCallType::Resize)
1335  // Even if the bounding box of the shape didn't change,
1336  // notify about the size change, as an adjustment change
1337  // may affect the size of the underlying textbox.
1339  }
1340 
1341  // tdf#135198: keep text box together with its shape
1342  const SwPageFrame* rPageFrame = pAnchoredDrawObj->GetPageFrame();
1343  if (rPageFrame && rPageFrame->isFrameAreaPositionValid() && !rObj.getChildrenOfSdrObject())
1344  {
1345  SwDoc* const pDoc = GetFormat()->GetDoc();
1346 
1347  // avoid Undo creation
1348  ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
1349 
1350  // hide any artificial "changes" made by synchronizing the textbox position
1351  const bool bEnableSetModified = pDoc->getIDocumentState().IsEnableSetModified();
1352  pDoc->getIDocumentState().SetEnableSetModified(false);
1353 
1355  aSyncSet( pDoc->GetAttrPool() );
1356  aSyncSet.Put(GetFormat()->GetHoriOrient());
1357  bool bRelToTableCell(false);
1358  aSyncSet.Put(SwFormatVertOrient(pAnchoredDrawObj->GetRelPosToPageFrame(false, bRelToTableCell).getY(),
1360  text::RelOrientation::PAGE_FRAME));
1361  aSyncSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, rPageFrame->GetPhyPageNum()));
1362 
1363  auto pSdrObj = const_cast<SdrObject*>(&rObj);
1364  if (pSdrObj != GetFormat()->FindRealSdrObject())
1365  {
1367 
1368  aSet.Put(aSyncSet);
1369  aSet.Put(pSdrObj->GetMergedItem(RES_FRM_SIZE));
1370  SwTextBoxHelper::syncFlyFrameAttr(*GetFormat(), aSet, pSdrObj);
1372  }
1373  else
1374  SwTextBoxHelper::syncFlyFrameAttr(*GetFormat(), aSyncSet, GetFormat()->FindRealSdrObject());
1375 
1376  pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
1377  }
1378  }
1379  break;
1380  case SdrUserCallType::ChangeAttr:
1381  if ( bNotify )
1382  {
1383  lcl_NotifyBackgroundOfObj( *this, rObj, pOldBoundRect );
1384  }
1385  break;
1386  default:
1387  break;
1388  }
1389 }
1390 
1391 namespace
1392 {
1393  const SwFormatAnchor* lcl_getAnchorFormat( const SfxPoolItem& _rItem )
1394  {
1395  sal_uInt16 nWhich = _rItem.Which();
1396  const SwFormatAnchor* pAnchorFormat = nullptr;
1397  if ( RES_ATTRSET_CHG == nWhich )
1398  {
1399  static_cast<const SwAttrSetChg&>(_rItem).GetChgSet()->
1400  GetItemState( RES_ANCHOR, false, reinterpret_cast<const SfxPoolItem**>(&pAnchorFormat) );
1401  }
1402  else if ( RES_ANCHOR == nWhich )
1403  {
1404  pAnchorFormat = &static_cast<const SwFormatAnchor&>(_rItem);
1405  }
1406  return pAnchorFormat;
1407  }
1408 }
1409 
1410 void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
1411 {
1412  SwClient::SwClientNotify(rMod, rHint); // needed as SwContact::SwClientNotify doesn't explicitly call SwClient::SwClientNotify
1413  SwContact::SwClientNotify(rMod, rHint);
1414  if (rHint.GetId() == SfxHintId::SwLegacyModify)
1415  {
1416  auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
1417  SAL_WARN_IF(mbDisconnectInProgress, "sw.core", "<SwDrawContact::Modify(..)> called during disconnection.");
1418 
1419  const SfxPoolItem* pNew = pLegacyHint->m_pNew;
1420  sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
1421  if(const SwFormatAnchor* pNewAnchorFormat = pNew ? lcl_getAnchorFormat(*pNew) : nullptr)
1422  {
1423  // Do not respond to a Reset Anchor!
1424  if(GetFormat()->GetAttrSet().GetItemState(RES_ANCHOR, false) == SfxItemState::SET)
1425  {
1426  // no connect to layout during disconnection
1428  {
1429  // determine old object rectangle of 'master' drawing object
1430  // for notification
1431  const tools::Rectangle* pOldRect = nullptr;
1432  tools::Rectangle aOldRect;
1433  if(GetAnchorFrame())
1434  {
1435  // --> #i36181# - include spacing in object
1436  // rectangle for notification.
1438  pOldRect = &aOldRect;
1439  }
1440  // re-connect to layout due to anchor format change
1441  ConnectToLayout(pNewAnchorFormat);
1442  // notify background of drawing objects
1443  lcl_NotifyBackgroundOfObj(*this, *GetMaster(), pOldRect);
1445 
1446  const SwFormatAnchor* pOldAnchorFormat = pLegacyHint->m_pOld ? lcl_getAnchorFormat(*pLegacyHint->m_pOld) : nullptr;
1447  if(!pOldAnchorFormat || (pOldAnchorFormat->GetAnchorId() != pNewAnchorFormat->GetAnchorId()))
1448  {
1450  {
1451  // --> #i102752#
1452  // assure that a ShapePropertyChangeNotifier exists
1454  }
1455  else
1456  SAL_WARN("sw.core", "SwDrawContact::Modify: no draw object here?");
1457  }
1458  }
1459  }
1460  else
1462  }
1463  else if (nWhich == RES_REMOVE_UNO_OBJECT)
1464  {} // nothing to do
1465  // --> #i62875# - no further notification, if not connected to Writer layout
1466  else if ( maAnchoredDrawObj.GetAnchorFrame() &&
1468  {
1469  bool bUpdateSortedObjsList(false);
1470  switch(nWhich)
1471  {
1472  case RES_UL_SPACE:
1473  case RES_LR_SPACE:
1474  case RES_HORI_ORIENT:
1475  case RES_VERT_ORIENT:
1476  case RES_FOLLOW_TEXT_FLOW: // #i28701# - add attribute 'Follow text flow'
1477  break;
1478  case RES_SURROUND:
1479  case RES_OPAQUE:
1481  // --> #i28701# - on change of wrapping style, hell|heaven layer,
1482  // or wrapping style influence an update of the <SwSortedObjs> list,
1483  // the drawing object is registered in, has to be performed. This is triggered
1484  // by the 1st parameter of method call <InvalidateObjs_(..)>.
1485  bUpdateSortedObjsList = true;
1486  break;
1487  case RES_ATTRSET_CHG: // #i35443#
1488  {
1489  auto pChgSet = static_cast<const SwAttrSetChg*>(pNew)->GetChgSet();
1490  if(pChgSet->GetItemState(RES_SURROUND, false) == SfxItemState::SET ||
1491  pChgSet->GetItemState(RES_OPAQUE, false) == SfxItemState::SET ||
1492  pChgSet->GetItemState(RES_WRAP_INFLUENCE_ON_OBJPOS, false) == SfxItemState::SET)
1493  bUpdateSortedObjsList = true;
1494  }
1495  break;
1496  default:
1497  assert(!"<SwDraw Contact::Modify(..)> - unhandled attribute?");
1498  }
1499  lcl_NotifyBackgroundOfObj(*this, *GetMaster(), nullptr);
1501  InvalidateObjs_(bUpdateSortedObjsList);
1502  }
1503 
1504  // #i51474#
1506  }
1507  else if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
1508  {
1509  switch(pDrawFrameFormatHint->m_eId)
1510  {
1512  delete this;
1513  break;
1516  break;
1519  // #i40845# - follow-up of #i35635#
1520  // move object to visible layer
1522  // tdf#135661 InsertMasterIntoDrawPage may have created a new
1523  // SwXShape with null m_pFormat; fix that
1525  break;
1528  break;
1532  break;
1534  ConnectToLayout();
1535  break;
1538  break;
1539  default:
1540  ;
1541  }
1542  }
1543  else if (auto pCheckDrawFrameFormatLayerHint = dynamic_cast<const sw::CheckDrawFrameFormatLayerHint*>(&rHint))
1544  {
1545  *(pCheckDrawFrameFormatLayerHint->m_bCheckControlLayer) |= (GetMaster() && CheckControlLayer(GetMaster()));
1546  }
1547  else if (auto pContactChangedHint = dynamic_cast<const sw::ContactChangedHint*>(&rHint))
1548  {
1549  if(!*pContactChangedHint->m_ppObject)
1550  *pContactChangedHint->m_ppObject = GetMaster();
1551  auto pObject = *pContactChangedHint->m_ppObject;
1552  Changed(*pObject, SdrUserCallType::Delete, pObject->GetLastBoundRect());
1553  }
1554  else if (auto pDrawFormatLayoutCopyHint = dynamic_cast<const sw::DrawFormatLayoutCopyHint*>(&rHint))
1555  {
1556  const SwDrawFrameFormat& rFormat = static_cast<const SwDrawFrameFormat&>(rMod);
1557  new SwDrawContact(
1558  &pDrawFormatLayoutCopyHint->m_rDestFormat,
1559  pDrawFormatLayoutCopyHint->m_rDestDoc.CloneSdrObj(
1560  *GetMaster(),
1561  pDrawFormatLayoutCopyHint->m_rDestDoc.IsCopyIsMove() && &pDrawFormatLayoutCopyHint->m_rDestDoc == rFormat.GetDoc()));
1562  // #i49730# - notify draw frame format that position attributes are
1563  // already set, if the position attributes are already set at the
1564  // source draw frame format.
1565  if(rFormat.IsPosAttrSet())
1566  pDrawFormatLayoutCopyHint->m_rDestFormat.PosAttrSet();
1567  }
1568  else if (auto pRestoreFlyAnchorHint = dynamic_cast<const sw::RestoreFlyAnchorHint*>(&rHint))
1569  {
1570  SdrObject* pObj = GetMaster();
1571  if(GetAnchorFrame() && !pObj->IsInserted())
1572  {
1573  auto pDrawModel = const_cast<SwDrawFrameFormat&>(static_cast<const SwDrawFrameFormat&>(rMod)).GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
1574  assert(pDrawModel);
1575  pDrawModel->GetPage(0)->InsertObject(pObj);
1576  }
1577  pObj->SetRelativePos(pRestoreFlyAnchorHint->m_aPos);
1578  }
1579  else if (auto pCreatePortionHint = dynamic_cast<const sw::CreatePortionHint*>(&rHint))
1580  {
1581  if(*pCreatePortionHint->m_ppContact)
1582  return;
1583  *pCreatePortionHint->m_ppContact = this; // This is kind of ridiculous: the FrameFormat doesn't even hold a pointer to the contact itself, but here we are leaking it out randomly
1584  if(!GetAnchorFrame())
1585  {
1586  // No direct positioning needed any more
1587  ConnectToLayout();
1588  // Move object to visible layer
1590  }
1591  }
1592  else if (auto pCollectTextObjectsHint = dynamic_cast<const sw::CollectTextObjectsHint*>(&rHint))
1593  {
1594  auto pSdrO = GetMaster();
1595  if(!pSdrO)
1596  return;
1597  if(dynamic_cast<const SdrObjGroup*>(pSdrO))
1598  {
1599  SdrObjListIter aListIter(*pSdrO, SdrIterMode::DeepNoGroups);
1600  //iterate inside of a grouped object
1601  while(aListIter.IsMore())
1602  {
1603  SdrObject* pSdrOElement = aListIter.Next();
1604  auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrOElement));
1605  if(pTextObj && pTextObj->HasText())
1606  pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
1607  }
1608  }
1609  else if(auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrO)))
1610  {
1611  if(pTextObj->HasText())
1612  pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj);
1613  }
1614  }
1615  else if (auto pGetZOrdnerHint = dynamic_cast<const sw::GetZOrderHint*>(&rHint))
1616  {
1617  auto pFormat(dynamic_cast<const SwFrameFormat*>(&rMod));
1618  if(pFormat->Which() == RES_DRAWFRMFMT)
1619  pGetZOrdnerHint->m_rnZOrder = GetMaster()->GetOrdNum();
1620  }
1621  else if (auto pConnectedHint = dynamic_cast<const sw::GetObjectConnectedHint*>(&rHint))
1622  {
1623  pConnectedHint->m_risConnected |= (GetAnchorFrame() != nullptr);
1624  }
1625 }
1626 
1627 // #i26791#
1628 // #i28701# - added parameter <_bUpdateSortedObjsList>
1629 void SwDrawContact::InvalidateObjs_( const bool _bUpdateSortedObjsList )
1630 {
1631  for(const auto& rpDrawVirtObj : maDrawVirtObjs)
1632  // invalidate position of existing 'virtual' drawing objects
1633  {
1634  SwDrawVirtObj* pDrawVirtObj(rpDrawVirtObj.get());
1635  // #i33313# - invalidation only for connected
1636  // 'virtual' drawing objects
1637  if ( pDrawVirtObj->IsConnected() )
1638  {
1639  pDrawVirtObj->AnchoredObj().InvalidateObjPos();
1640  // #i28701#
1641  if ( _bUpdateSortedObjsList )
1642  {
1643  pDrawVirtObj->AnchoredObj().UpdateObjInSortedList();
1644  }
1645  }
1646  }
1647 
1648  // invalidate position of 'master' drawing object
1649  SwAnchoredObject* pAnchoredObj = GetAnchoredObj( nullptr );
1650  pAnchoredObj->InvalidateObjPos();
1651  // #i28701#
1652  if ( _bUpdateSortedObjsList )
1653  {
1654  pAnchoredObj->UpdateObjInSortedList();
1655  }
1656 }
1657 
1658 void SwDrawContact::DisconnectFromLayout( bool _bMoveMasterToInvisibleLayer )
1659 {
1660  mbDisconnectInProgress = true;
1661 
1662  // --> #i36181# - notify background of drawing object
1663  if ( _bMoveMasterToInvisibleLayer &&
1664  !(GetFormat()->GetDoc()->IsInDtor()) &&
1665  GetAnchorFrame() && !GetAnchorFrame()->IsInDtor() )
1666  {
1668  lcl_NotifyBackgroundOfObj( *this, *GetMaster(), &aOldRect );
1669  NotifyBackgroundOfAllVirtObjs( &aOldRect );
1670  }
1671 
1672  // remove 'virtual' drawing objects from writer
1673  // layout and from drawing page
1674  for(auto& rpVirtDrawObj : maDrawVirtObjs)
1675  {
1676  rpVirtDrawObj->RemoveFromWriterLayout();
1677  rpVirtDrawObj->RemoveFromDrawingPage();
1678  }
1679 
1681  {
1683  }
1684 
1685  if ( _bMoveMasterToInvisibleLayer && GetMaster() && GetMaster()->IsInserted() )
1686  {
1687  SdrViewIter aIter( GetMaster() );
1688  for( SdrView* pView = aIter.FirstView(); pView;
1689  pView = aIter.NextView() )
1690  {
1691  pView->MarkObj( GetMaster(), pView->GetSdrPageView(), true );
1692  }
1693 
1694  // Instead of removing 'master' object from drawing page, move the
1695  // 'master' drawing object into the corresponding invisible layer.
1696  {
1697  //static_cast<SwFrameFormat*>(GetRegisteredIn())->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)->
1698  // RemoveObject( GetMaster()->GetOrdNum() );
1699  // #i18447# - in order to consider group object correct
1700  // use new method <SwDrawContact::MoveObjToInvisibleLayer(..)>
1702  }
1703  }
1704 
1705  mbDisconnectInProgress = false;
1706 }
1707 
1710 {
1711  if ( GetMaster() )
1712  {
1713  GetMaster()->SetUserCall( nullptr );
1714  if ( GetMaster()->IsInserted() )
1715  {
1716  static_cast<SwFrameFormat*>(GetRegisteredIn())->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0)->
1717  RemoveObject( GetMaster()->GetOrdNum() );
1718  }
1719  }
1720 }
1721 
1722 // disconnect for a dedicated drawing object - could be 'master' or 'virtual'.
1723 // a 'master' drawing object will disconnect a 'virtual' drawing object
1724 // in order to take its place.
1725 // #i19919# - no special case, if drawing object isn't in
1726 // page header/footer, in order to get drawing objects in repeating table headers
1727 // also working.
1729 {
1730  if ( auto pSwDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( _pDrawObj) )
1731  {
1732  pSwDrawVirtObj->RemoveFromWriterLayout();
1733  pSwDrawVirtObj->RemoveFromDrawingPage();
1734  }
1735  else
1736  {
1737  const auto ppVirtDrawObj(std::find_if(maDrawVirtObjs.begin(), maDrawVirtObjs.end(),
1738  [] (const SwDrawVirtObjPtr& pObj) { return pObj->IsConnected(); }));
1739 
1740  if(ppVirtDrawObj != maDrawVirtObjs.end())
1741  {
1742  // replace found 'virtual' drawing object by 'master' drawing
1743  // object and disconnect the 'virtual' one
1744  SwDrawVirtObj* pDrawVirtObj(ppVirtDrawObj->get());
1745  SwFrame* pNewAnchorFrameOfMaster = pDrawVirtObj->AnchorFrame();
1746  // disconnect 'virtual' drawing object
1747  pDrawVirtObj->RemoveFromWriterLayout();
1748  pDrawVirtObj->RemoveFromDrawingPage();
1749  // disconnect 'master' drawing object from current frame
1751  // re-connect 'master' drawing object to frame of found 'virtual'
1752  // drawing object.
1753  pNewAnchorFrameOfMaster->AppendDrawObj( maAnchoredDrawObj );
1754  }
1755  else
1756  {
1757  // no connected 'virtual' drawing object found. Thus, disconnect
1758  // completely from layout.
1760  }
1761  }
1762 }
1763 
1764 static SwTextFrame* lcl_GetFlyInContentAnchor( SwTextFrame* _pProposedAnchorFrame,
1765  SwPosition const& rAnchorPos)
1766 {
1767  SwTextFrame* pAct = _pProposedAnchorFrame;
1768  SwTextFrame* pTmp;
1769  TextFrameIndex const nTextOffset(_pProposedAnchorFrame->MapModelToViewPos(rAnchorPos));
1770  do
1771  {
1772  pTmp = pAct;
1773  pAct = pTmp->GetFollow();
1774  }
1775  while (pAct && nTextOffset >= pAct->GetOffset());
1776  return pTmp;
1777 }
1778 
1780 {
1781  // *no* connect to layout during disconnection from layout.
1782  if ( mbDisconnectInProgress )
1783  {
1784  OSL_FAIL( "<SwDrawContact::ConnectToLayout(..)> called during disconnection.");
1785  return;
1786  }
1787 
1788  // --> #i33909# - *no* connect to layout, if 'master' drawing
1789  // object isn't inserted in the drawing page
1790  if ( !GetMaster()->IsInserted() )
1791  {
1792  OSL_FAIL( "<SwDrawContact::ConnectToLayout(..)> - master drawing object not inserted -> no connect to layout. Please inform od@openoffice.org" );
1793  return;
1794  }
1795 
1796  SwFrameFormat* pDrawFrameFormat = static_cast<SwFrameFormat*>(GetRegisteredIn());
1797 
1798  if( !pDrawFrameFormat->getIDocumentLayoutAccess().GetCurrentViewShell() )
1799  return;
1800 
1801  // remove 'virtual' drawing objects from writer
1802  // layout and from drawing page, and remove 'master' drawing object from
1803  // writer layout - 'master' object will remain in drawing page.
1804  DisconnectFromLayout( false );
1805 
1806  if ( !pAnch )
1807  {
1808  pAnch = &(pDrawFrameFormat->GetAnchor());
1809  }
1810 
1811  switch ( pAnch->GetAnchorId() )
1812  {
1813  case RndStdIds::FLY_AT_PAGE:
1814  {
1815  sal_uInt16 nPgNum = pAnch->GetPageNum();
1816  SwViewShell *pShell = pDrawFrameFormat->getIDocumentLayoutAccess().GetCurrentViewShell();
1817  if( !pShell )
1818  break;
1819  SwRootFrame* pRoot = pShell->GetLayout();
1820  SwPageFrame *pPage = static_cast<SwPageFrame*>(pRoot->Lower());
1821 
1822  for ( sal_uInt16 i = 1; i < nPgNum && pPage; ++i )
1823  {
1824  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
1825  }
1826 
1827  if ( pPage )
1828  {
1829  pPage->AppendDrawObj( maAnchoredDrawObj );
1830  }
1831  else
1832  //Looks stupid but is allowed (compare SwFEShell::SetPageObjsNewPage)
1833  pRoot->SetAssertFlyPages();
1834  }
1835  break;
1836 
1837  case RndStdIds::FLY_AT_CHAR:
1838  case RndStdIds::FLY_AT_PARA:
1839  case RndStdIds::FLY_AT_FLY:
1840  case RndStdIds::FLY_AS_CHAR:
1841  {
1842  if ( pAnch->GetAnchorId() == RndStdIds::FLY_AS_CHAR )
1843  {
1845  }
1846  // support drawing objects in header/footer,
1847  // but not control objects:
1848  // anchor at first found frame the 'master' object and
1849  // at the following frames 'virtual' drawing objects.
1850  // Note: method is similar to <SwFlyFrameFormat::MakeFrames(..)>
1851  sw::BroadcastingModify *pModify = nullptr;
1852  if( pAnch->GetContentAnchor() )
1853  {
1854  if ( pAnch->GetAnchorId() == RndStdIds::FLY_AT_FLY )
1855  {
1856  SwNodeIndex aIdx( pAnch->GetContentAnchor()->nNode );
1857  SwContentNode* pCNd = pDrawFrameFormat->GetDoc()->GetNodes().GoNext( &aIdx );
1859  pModify = pCNd;
1860  else
1861  {
1862  const SwNodeIndex& rIdx = pAnch->GetContentAnchor()->nNode;
1863  SwFrameFormats& rFormats = *(pDrawFrameFormat->GetDoc()->GetSpzFrameFormats());
1864  for( auto pFlyFormat : rFormats )
1865  {
1866  if( pFlyFormat->GetContent().GetContentIdx() &&
1867  rIdx == *(pFlyFormat->GetContent().GetContentIdx()) )
1868  {
1869  pModify = pFlyFormat;
1870  break;
1871  }
1872  }
1873  }
1874  }
1875  else
1876  {
1877  pModify = pAnch->GetContentAnchor()->nNode.GetNode().GetContentNode();
1878  }
1879  }
1880 
1881  // #i29199# - It is possible, that
1882  // the anchor doesn't exist - E.g., reordering the
1883  // sub-documents in a master document.
1884  // Note: The anchor will be inserted later.
1885  if ( !pModify )
1886  {
1887  // break to end of the current switch case.
1888  break;
1889  }
1890 
1892  SwFrame* pAnchorFrameOfMaster = nullptr;
1893  for( SwFrame *pFrame = aIter.First(); pFrame; pFrame = aIter.Next() )
1894  {
1895  // append drawing object, if
1896  // (1) proposed anchor frame isn't a follow and...
1897  const bool bFollow = pFrame->IsContentFrame() && static_cast<SwContentFrame*>(pFrame)->IsFollow();
1898  if (bFollow)
1899  continue;
1900 
1901  // (2) drawing object isn't a control object to be anchored
1902  // in header/footer.
1903  const bool bControlInHF = ::CheckControlLayer(GetMaster()) && pFrame->FindFooterOrHeader();
1904  // tdf#129542 but make an exception for control objects so they can get added to just the first frame,
1905  // the Master Anchor Frame and not the others
1906  if (bControlInHF && pAnchorFrameOfMaster)
1907  continue;
1908 
1909  bool bAdd;
1910  if (RndStdIds::FLY_AT_FLY == pAnch->GetAnchorId())
1911  bAdd = true;
1912  else
1913  {
1914  assert(pFrame->IsTextFrame());
1915  bAdd = IsAnchoredObjShown(*static_cast<SwTextFrame*>(pFrame), *pAnch);
1916  }
1917 
1918  if( bAdd )
1919  {
1920  if ( RndStdIds::FLY_AT_FLY == pAnch->GetAnchorId() && !pFrame->IsFlyFrame() )
1921  {
1922  pFrame = pFrame->FindFlyFrame();
1923  assert(pFrame);
1924  }
1925 
1926  // find correct follow for as character anchored objects
1927  if ((pAnch->GetAnchorId() == RndStdIds::FLY_AS_CHAR) &&
1928  pFrame->IsTextFrame() )
1929  {
1930  pFrame = lcl_GetFlyInContentAnchor(
1931  static_cast<SwTextFrame*>(pFrame),
1932  *pAnch->GetContentAnchor());
1933  }
1934 
1935  if ( !pAnchorFrameOfMaster )
1936  {
1937  // append 'master' drawing object
1938  pAnchorFrameOfMaster = pFrame;
1939  pFrame->AppendDrawObj( maAnchoredDrawObj );
1940  }
1941  else
1942  {
1943  // append 'virtual' drawing object
1944  SwDrawVirtObj* pDrawVirtObj = AddVirtObj(*pFrame);
1945  if ( pAnch->GetAnchorId() == RndStdIds::FLY_AS_CHAR )
1946  {
1947  ClrContourCache( pDrawVirtObj );
1948  }
1949  pFrame->AppendDrawObj( pDrawVirtObj->AnchoredObj() );
1950 
1951  pDrawVirtObj->ActionChanged();
1952  }
1953 
1954  if ( pAnch->GetAnchorId() == RndStdIds::FLY_AS_CHAR )
1955  {
1956  pFrame->InvalidatePrt();
1957  }
1958  }
1959  }
1960  }
1961  break;
1962  default:
1963  assert(!"Unknown Anchor.");
1964  break;
1965  }
1966  if ( GetAnchorFrame() )
1967  {
1969  // #i26791# - invalidate objects instead of direct positioning
1970  InvalidateObjs_();
1971  }
1972 }
1973 
1976 {
1977  if ( !GetMaster()->IsInserted() )
1978  {
1980  ->InsertObject( GetMaster(), GetMaster()->GetOrdNumDirect() );
1981  }
1982  GetMaster()->SetUserCall( this );
1983 }
1984 
1986 {
1987  // --> #i28701# - use method <GetPageFrame()>
1988  SwPageFrame* pPg = GetPageFrame();
1989  if ( !pPg && GetAnchorFrame() )
1990  pPg = GetAnchorFrame()->FindPageFrame();
1991  if ( pPg )
1992  pPg = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( rRect, pPg )));
1993  return pPg;
1994 }
1995 
1997 {
1998  if ( mbDisconnectInProgress )
1999  {
2000  OSL_FAIL( "<SwDrawContact::ChkPage()> called during disconnection." );
2001  return;
2002  }
2003 
2004  // --> #i28701#
2007  ? GetPageFrame()
2008  : FindPage( SwRect(GetMaster()->GetCurrentBoundRect()) );
2009  if ( GetPageFrame() == pPg )
2010  return;
2011 
2012  // if drawing object is anchor in header/footer a change of the page
2013  // is a dramatic change. Thus, completely re-connect to the layout
2016  {
2017  ConnectToLayout();
2018  }
2019  else
2020  {
2021  // --> #i28701# - use methods <GetPageFrame()> and <SetPageFrame>
2022  if ( GetPageFrame() )
2026  }
2027 }
2028 
2029 // Important note:
2030 // method is called by method <SwDPage::ReplaceObject(..)>, which called its
2031 // corresponding superclass method <FmFormPage::ReplaceObject(..)>.
2032 // Note: 'master' drawing object *has* to be connected to layout triggered
2033 // by the caller of this, if method is called.
2035 {
2036  DisconnectFromLayout( false );
2037  // consider 'virtual' drawing objects
2039 
2040  GetMaster()->SetUserCall( nullptr );
2041  if(pNewMaster)
2042  maAnchoredDrawObj.SetDrawObj(*pNewMaster);
2043  else
2044  mbMasterObjCleared = true;
2045  GetMaster()->SetUserCall( this );
2046 
2047  InvalidateObjs_();
2048 }
2049 
2051 void SwDrawContact::GetAnchoredObjs(std::vector<SwAnchoredObject*>& o_rAnchoredObjs) const
2052 {
2053  o_rAnchoredObjs.push_back(const_cast<SwAnchoredDrawObject*>(&maAnchoredDrawObj));
2054 
2055  for(auto& rpDrawVirtObj : maDrawVirtObjs)
2056  o_rAnchoredObjs.push_back(&rpDrawVirtObj->AnchoredObj());
2057 }
2058 
2059 // AW: own sdr::contact::ViewContact (VC) sdr::contact::ViewObjectContact (VOC) needed
2060 // since offset is defined different from SdrVirtObj's sdr::contact::ViewContactOfVirtObj.
2061 // For paint, that offset is used by setting at the OutputDevice; for primitives this is
2062 // not possible since we have no OutputDevice, but define the geometry itself.
2063 
2064 namespace sdr::contact
2065 {
2066  namespace {
2067 
2068  class VOCOfDrawVirtObj : public ViewObjectContactOfSdrObj
2069  {
2070  protected:
2079  virtual void createPrimitive2DSequence(const DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const override;
2080 
2081  public:
2082  VOCOfDrawVirtObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
2083  : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
2084  {
2085  }
2086  };
2087 
2088  class VCOfDrawVirtObj : public ViewContactOfVirtObj
2089  {
2090  protected:
2096  virtual ViewObjectContact& CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) override;
2097 
2098  public:
2100  explicit VCOfDrawVirtObj(SwDrawVirtObj& rObj)
2101  : ViewContactOfVirtObj(rObj)
2102  {
2103  }
2104 
2106  SwDrawVirtObj& GetSwDrawVirtObj() const
2107  {
2108  return static_cast<SwDrawVirtObj&>(mrObject);
2109  }
2110  };
2111 
2112  }
2113 } // end of namespace sdr::contact
2114 
2115 namespace sdr::contact
2116 {
2118  static void impAddPrimitivesFromGroup(const ViewObjectContact& rVOC, const basegfx::B2DHomMatrix& rOffsetMatrix, const DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DContainer& rxTarget)
2119  {
2120  const sal_uInt32 nSubHierarchyCount(rVOC.GetViewContact().GetObjectCount());
2121 
2122  for(sal_uInt32 a(0); a < nSubHierarchyCount; a++)
2123  {
2125 
2126  if(rCandidate.GetViewContact().GetObjectCount())
2127  {
2128  // is a group object itself, call recursively
2129  impAddPrimitivesFromGroup(rCandidate, rOffsetMatrix, rDisplayInfo, rxTarget);
2130  }
2131  else
2132  {
2133  // single object, add primitives; check model-view visibility
2134  if(rCandidate.isPrimitiveVisible(rDisplayInfo))
2135  {
2136  drawinglayer::primitive2d::Primitive2DContainer aNewSequence(rCandidate.getPrimitive2DSequence(rDisplayInfo));
2137 
2138  if(!aNewSequence.empty())
2139  {
2140  // get ranges
2141  const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(rCandidate.GetObjectContact().getViewInformation2D());
2142  const basegfx::B2DRange& aViewRange(rViewInformation2D.getViewport());
2143  basegfx::B2DRange aObjectRange(rCandidate.getObjectRange());
2144 
2145  // correct with virtual object's offset
2146  aObjectRange.transform(rOffsetMatrix);
2147 
2148  // check geometrical visibility (with offset)
2149  if(!aViewRange.overlaps(aObjectRange))
2150  {
2151  // not visible, release
2152  aNewSequence.clear();
2153  }
2154  }
2155 
2156  if(!aNewSequence.empty())
2157  {
2158  rxTarget.append(aNewSequence);
2159  }
2160  }
2161  }
2162  }
2163  }
2164 
2165  void VOCOfDrawVirtObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const
2166  {
2167  // tdf#91260 have already checked top-level one is on the right page
2168  assert(isPrimitiveVisible(rDisplayInfo));
2169  // nasty corner case: override to clear page frame to disable the
2170  // sub-objects' anchor check, because their anchor is always on
2171  // the first page that the page style is applied to
2172  DisplayInfo aDisplayInfo(rDisplayInfo);
2173  aDisplayInfo.SetWriterPageFrame(basegfx::B2IRectangle());
2174  const VCOfDrawVirtObj& rVC = static_cast< const VCOfDrawVirtObj& >(GetViewContact());
2175  const SdrObject& rReferencedObject = rVC.GetSwDrawVirtObj().GetReferencedObj();
2177 
2178  // create offset transformation
2179  basegfx::B2DHomMatrix aOffsetMatrix;
2180  const Point aLocalOffset(rVC.GetSwDrawVirtObj().GetOffset());
2181 
2182  if(aLocalOffset.X() || aLocalOffset.Y())
2183  {
2184  aOffsetMatrix.set(0, 2, aLocalOffset.X());
2185  aOffsetMatrix.set(1, 2, aLocalOffset.Y());
2186  }
2187 
2188  if(dynamic_cast<const SdrObjGroup*>( &rReferencedObject) != nullptr)
2189  {
2190  // group object. Since the VOC/OC/VC hierarchy does not represent the
2191  // hierarchy virtual objects when they have group objects
2192  // (ViewContactOfVirtObj::GetObjectCount() returns null for that purpose)
2193  // to avoid multiple usages of VOCs (which would not work), the primitives
2194  // for the sub-hierarchy need to be collected here
2195 
2196  // Get the VOC of the referenced object (the Group) and fetch primitives from it
2197  const ViewObjectContact& rVOCOfRefObj = rReferencedObject.GetViewContact().GetViewObjectContact(GetObjectContact());
2198  impAddPrimitivesFromGroup(rVOCOfRefObj, aOffsetMatrix, aDisplayInfo, xRetval);
2199  }
2200  else
2201  {
2202  // single object, use method from referenced object to get the Primitive2DSequence
2203  rReferencedObject.GetViewContact().getViewIndependentPrimitive2DContainer(xRetval);
2204  }
2205 
2206  if(!xRetval.empty())
2207  {
2208  // create transform primitive
2210  xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReference };
2211  }
2212 
2213  rVisitor.visit(xRetval);
2214  }
2215 
2216  ViewObjectContact& VCOfDrawVirtObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
2217  {
2218  return *(new VOCOfDrawVirtObj(rObjectContact, *this));
2219  }
2220 
2221 } // end of namespace sdr::contact
2222 
2224 std::unique_ptr<sdr::contact::ViewContact> SwDrawVirtObj::CreateObjectSpecificViewContact()
2225 {
2226  return std::make_unique<sdr::contact::VCOfDrawVirtObj>(*this);
2227 }
2228 
2230  SdrModel& rSdrModel,
2231  SdrObject& _rNewObj,
2232  SwDrawContact& _rDrawContact)
2233 : SdrVirtObj(rSdrModel, _rNewObj ),
2234  mrDrawContact(_rDrawContact)
2235 {
2236  // #i26791#
2237  maAnchoredDrawObj.SetDrawObj( *this );
2238 
2239  // #i35635# - set initial position out of sight
2240  NbcMove( Size( -16000, -16000 ) );
2241 }
2242 
2244  SdrModel& rSdrModel,
2245  SwDrawVirtObj const & rSource)
2246 : SdrVirtObj(rSdrModel, rSource),
2247  mrDrawContact(rSource.mrDrawContact)
2248 {
2249  // #i26791#
2250  maAnchoredDrawObj.SetDrawObj( *this );
2251 
2252  // #i35635# - set initial position out of sight
2253  NbcMove( Size( -16000, -16000 ) );
2254 
2255  // Note: Members <maAnchoredDrawObj> and <mrDrawContact>
2256  // haven't to be considered.
2257 }
2258 
2260 {
2261 }
2262 
2264 {
2265  return new SwDrawVirtObj(rTargetModel, *this);
2266 }
2267 
2269 {
2270  // #i26791# - use new member <maAnchoredDrawObj>
2272 }
2273 
2275 {
2276  // #i26791# - use new member <maAnchoredDrawObj>
2277  return maAnchoredDrawObj.AnchorFrame();
2278 }
2279 
2281 {
2282  // remove contact object from frame for 'virtual' drawing object
2283  // #i26791# - use new member <maAnchoredDrawObj>
2285  {
2287  }
2288 }
2289 
2290 void SwDrawVirtObj::AddToDrawingPage(SwFrame const& rAnchorFrame)
2291 {
2292  // determine 'master'
2293  SdrObject* pOrgMasterSdrObj = mrDrawContact.GetMaster();
2294 
2295  // insert 'virtual' drawing object into page, set layer and user call.
2296  SdrPage* pDrawPg = pOrgMasterSdrObj->getSdrPageFromSdrObject();
2297  // default: insert before master object
2298  auto nOrdNum(GetReferencedObj().GetOrdNum());
2299 
2300  // maintain invariant that a shape's textbox immediately follows the shape
2301  // also for the multiple SdrDrawVirtObj created for shapes in header/footer
2302  if (SwFrameFormat const*const pFlyFormat =
2304  {
2305  // this is for the case when the flyframe SdrVirtObj is created before the draw one
2306  if (SwSortedObjs const*const pObjs = rAnchorFrame.GetDrawObjs())
2307  {
2308  for (SwAnchoredObject const*const pAnchoredObj : *pObjs)
2309  {
2310  if (&pAnchoredObj->GetFrameFormat() == pFlyFormat)
2311  {
2312  assert(dynamic_cast<SwFlyFrame const*>(pAnchoredObj));
2313  nOrdNum = pAnchoredObj->GetDrawObj()->GetOrdNum();
2314  // the master SdrObj should have the highest index
2315  assert(nOrdNum < GetReferencedObj().GetOrdNum());
2316  break;
2317  }
2318  }
2319  }
2320  // this happens on initial insertion, the draw object is created first
2321  SAL_INFO_IF(GetReferencedObj().GetOrdNum() == nOrdNum, "sw", "AddToDrawingPage: cannot find SdrObject for text box's shape");
2322  }
2323 
2324  // #i27030# - apply order number of referenced object
2325  if ( nullptr != pDrawPg )
2326  {
2327  // #i27030# - apply order number of referenced object
2328  pDrawPg->InsertObject(this, nOrdNum);
2329  }
2330  else
2331  {
2332  pDrawPg = getSdrPageFromSdrObject();
2333  if ( pDrawPg )
2334  {
2335  pDrawPg->SetObjectOrdNum(GetOrdNumDirect(), nOrdNum);
2336  }
2337  else
2338  {
2339  SetOrdNum(nOrdNum);
2340  }
2341  }
2343 }
2344 
2346 {
2347  SetUserCall( nullptr );
2348  if ( getSdrPageFromSdrObject() )
2349  {
2351  }
2352 }
2353 
2356 {
2357  bool bRetVal = GetAnchorFrame() &&
2359 
2360  return bRetVal;
2361 }
2362 
2363 void SwDrawVirtObj::NbcSetAnchorPos(const Point& rPnt)
2364 {
2366 }
2367 
2368 // #i97197#
2369 // the methods relevant for positioning
2370 
2372 {
2373  if(m_aOutRect.IsEmpty())
2374  {
2375  const_cast<SwDrawVirtObj*>(this)->RecalcBoundRect();
2376  }
2377 
2378  return m_aOutRect;
2379 }
2380 
2382 {
2383  return m_aOutRect;
2384 }
2385 
2387 {
2388  // do NOT use IsEmpty() here, there is already a useful offset
2389  // in the position
2390  if(m_aOutRect == tools::Rectangle())
2391  {
2392  return Point();
2393  }
2394  else
2395  {
2397  }
2398 }
2399 
2401 {
2402  // do nothing to not lose model information in aOutRect
2403 }
2404 
2406 {
2407  // #i26791# - switch order of calling <GetOffset()> and
2408  // <ReferencedObj().GetCurrentBoundRect()>, because <GetOffset()> calculates
2409  // its value by the 'BoundRect' of the referenced object.
2410 
2411  const Point aOffset(GetOffset());
2413 }
2414 
2416 {
2419 
2420  return aRetval;
2421 }
2422 
2424 {
2427 
2428  return aRetval;
2429 }
2430 
2432 {
2433  SdrHdlList tmpList(nullptr);
2434  rRefObj.AddToHdlList(tmpList);
2435 
2436  size_t cnt = tmpList.GetHdlCount();
2437  for(size_t i=0; i < cnt; ++i)
2438  {
2439  SdrHdl* pHdl = tmpList.GetHdl(i);
2440  Point aP(pHdl->GetPos() + GetOffset());
2441  pHdl->SetPos(aP);
2442  }
2443  tmpList.MoveTo(rHdlList);
2444 }
2445 
2446 void SwDrawVirtObj::NbcMove(const Size& rSiz)
2447 {
2448  SdrObject::NbcMove( rSiz );
2449 }
2450 
2451 void SwDrawVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
2452 {
2453  rRefObj.NbcResize(rRef - GetOffset(), xFact, yFact);
2455 }
2456 
2457 void SwDrawVirtObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
2458 {
2459  rRefObj.NbcRotate(rRef - GetOffset(), nAngle, sn, cs);
2461 }
2462 
2463 void SwDrawVirtObj::NbcMirror(const Point& rRef1, const Point& rRef2)
2464 {
2465  rRefObj.NbcMirror(rRef1 - GetOffset(), rRef2 - GetOffset());
2467 }
2468 
2469 void SwDrawVirtObj::NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear)
2470 {
2471  rRefObj.NbcShear(rRef - GetOffset(), nAngle, tn, bVShear);
2473 }
2474 
2475 void SwDrawVirtObj::Move(const Size& rSiz)
2476 {
2477  SdrObject::Move( rSiz );
2478 }
2479 
2480 void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
2481 {
2482  if(xFact.GetNumerator() != xFact.GetDenominator() || yFact.GetNumerator() != yFact.GetDenominator())
2483  {
2484  tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
2485  rRefObj.Resize(rRef - GetOffset(), xFact, yFact, bUnsetRelative);
2487  SendUserCall(SdrUserCallType::Resize, aBoundRect0);
2488  }
2489 }
2490 
2491 void SwDrawVirtObj::Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
2492 {
2493  if(nAngle)
2494  {
2495  tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
2496  rRefObj.Rotate(rRef - GetOffset(), nAngle, sn, cs);
2498  SendUserCall(SdrUserCallType::Resize, aBoundRect0);
2499  }
2500 }
2501 
2502 void SwDrawVirtObj::Mirror(const Point& rRef1, const Point& rRef2)
2503 {
2504  tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
2505  rRefObj.Mirror(rRef1 - GetOffset(), rRef2 - GetOffset());
2507  SendUserCall(SdrUserCallType::Resize, aBoundRect0);
2508 }
2509 
2510 void SwDrawVirtObj::Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear)
2511 {
2512  if(nAngle)
2513  {
2514  tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
2515  rRefObj.Shear(rRef - GetOffset(), nAngle, tn, bVShear);
2517  SendUserCall(SdrUserCallType::Resize, aBoundRect0);
2518  }
2519 }
2520 
2522 {
2524  aSnapRect += GetOffset();
2525 }
2526 
2528 {
2529  const_cast<SwDrawVirtObj*>(this)->aSnapRect = rRefObj.GetSnapRect();
2530  const_cast<SwDrawVirtObj*>(this)->aSnapRect += GetOffset();
2531 
2532  return aSnapRect;
2533 }
2534 
2536 {
2537  tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
2538  tools::Rectangle aR(rRect);
2539  aR -= GetOffset();
2540  rRefObj.SetSnapRect(aR);
2542  SendUserCall(SdrUserCallType::Resize, aBoundRect0);
2543 }
2544 
2546 {
2547  tools::Rectangle aR(rRect);
2548  aR -= GetOffset();
2550  rRefObj.NbcSetSnapRect(aR);
2551 }
2552 
2554 {
2555  const_cast<SwDrawVirtObj*>(this)->aSnapRect = rRefObj.GetLogicRect();
2556  const_cast<SwDrawVirtObj*>(this)->aSnapRect += GetOffset();
2557 
2558  return aSnapRect;
2559 }
2560 
2562 {
2563  tools::Rectangle aBoundRect0; if(m_pUserCall) aBoundRect0 = GetLastBoundRect();
2564  tools::Rectangle aR(rRect);
2565  aR -= GetOffset();
2566  rRefObj.SetLogicRect(aR);
2568  SendUserCall(SdrUserCallType::Resize, aBoundRect0);
2569 }
2570 
2572 {
2573  tools::Rectangle aR(rRect);
2574  aR -= GetOffset();
2577 }
2578 
2580 {
2581  Point aP(rRefObj.GetSnapPoint(i));
2582  aP += GetOffset();
2583 
2584  return aP;
2585 }
2586 
2587 Point SwDrawVirtObj::GetPoint(sal_uInt32 i) const
2588 {
2589  return rRefObj.GetPoint(i) + GetOffset();
2590 }
2591 
2592 void SwDrawVirtObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
2593 {
2594  Point aP(rPnt);
2595  aP -= GetOffset();
2596  rRefObj.SetPoint(aP, i);
2598 }
2599 
2601 {
2602  return rRefObj.HasTextEdit();
2603 }
2604 
2605 // override 'layer' methods for 'virtual' drawing object to assure
2606 // that layer of 'virtual' object is the layer of the referenced object.
2608 {
2609  return GetReferencedObj().GetLayer();
2610 }
2611 
2613 {
2614  ReferencedObj().NbcSetLayer( nLayer );
2616 }
2617 
2619 {
2620  ReferencedObj().SetLayer( nLayer );
2622 }
2623 
2624 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
void RemoveAllVirtObjs()
remove 'virtual' drawing objects and destroy them.
Definition: dcontact.cxx:842
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:580
sal_uInt32 GetMaxOrdNum() const
get maximum order number of anchored objects handled by with contact
Definition: dcontact.cxx:373
virtual bool HasTextEdit() const
SwFrame * AnchorFrame()
Definition: dcontact.cxx:2274
virtual void MakeObjPos()=0
method to determine position for the object and set the position at the object
SwRect GetBoundRectOfAnchoredObj(const SdrObject *pObj)
returns the BoundRect inclusive distance of the object.
Definition: dcontact.cxx:154
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2782
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
void ChangeMasterObject(SdrObject *pNewMaster)
Moves all SW-connections to new Master)
Definition: dcontact.cxx:2034
Base class of the Writer layout elements.
Definition: frame.hxx:315
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
SdrObject * GetDrawObjectByAnchorFrame(const SwFrame &_rAnchorFrame)
get drawing object ('master' or 'virtual') by frame.
Definition: dcontact.cxx:855
virtual SwRect GetObjRect() const =0
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
void InsertCnt()
Definition: fly.cxx:210
SwFlyDrawObjPtr mpMasterObj
Definition: dcontact.hxx:180
SwFlyDrawContact * GetOrCreateContact()
Definition: atrfrm.cxx:2924
SwDrawContact(const SwDrawContact &)=delete
void ChkPage()
Definition: dcontact.cxx:1996
bool IsFollow() const
Definition: flowfrm.hxx:166
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: dcontact.cxx:2510
WW8AnchorConv
Definition: frmfmt.hxx:298
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:565
SwAnchoredDrawObject maAnchoredDrawObj
anchored drawing object instance for the 'virtual' drawing object
Definition: dcontact.hxx:218
SdrObject & ReferencedObj()
Marks a position in the document model.
Definition: pam.hxx:36
class for the positioning of drawing objects
virtual const tools::Rectangle & GetCurrentBoundRect() const
tools::Rectangle aSnapRect
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true)
void SetPos(const Point &rPnt)
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
SwDrawContact * mpDrawContact
Definition: dcontact.cxx:1019
virtual SwDrawVirtObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: dcontact.cxx:2263
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:679
void InsertColumns()
Definition: fly.cxx:230
void SetPoint(const Point &rPnt, sal_uInt32 i)
void DisconnectFromLayout(bool _bMoveMasterToInvisibleLayer=true)
Definition: dcontact.cxx:1658
virtual const SwRootFrame * GetCurrentLayout() const =0
std::unique_ptr< SwDrawVirtObj, SdrObjectFreeOp > SwDrawVirtObjPtr
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:305
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj) override
override methods to control Writer fly frames, which are linked, and to assure that all objects ancho...
Definition: dcontact.cxx:588
virtual SdrObjList * getChildrenOfSdrObject() const
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
constexpr tools::Long Left() const
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
SwNodeIndex nNode
Definition: pam.hxx:38
virtual ~SwContact() override
Definition: dcontact.cxx:197
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:597
virtual SdrLayerID GetInvisibleControlsId() const =0
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
const SwFrame * FindPage(const SwRect &rRect, const SwFrame *pPage)
Definition: frmtool.cxx:3716
SwTwips GetPos() const
Definition: fmtornt.hxx:92
#define SAL_INFO_IF(condition, area, stream)
static void lcl_NotifyBackgroundOfObj(SwDrawContact const &_rDrawContact, const SdrObject &_rObj, const tools::Rectangle *_pOldObjRect)
local method to notify the background for a drawing object - #i26791#
Definition: dcontact.cxx:931
bool mbMasterObjCleared
boolean indicating set 'master' drawing object has been cleared.
Definition: dcontact.hxx:319
helper class for method for handling nested events ...
Definition: dcontact.cxx:1016
virtual SdrLayerID GetHeavenId() const =0
SdrUserCallType
bool IsAnchoredObjShown(SwTextFrame const &rFrame, SwFormatAnchor const &rAnchor)
Definition: frmtool.cxx:1318
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: dcontact.cxx:2491
void RemoveDrawObjFromPage(SwAnchoredObject &_rToRemoveObj)
Definition: flylay.cxx:1078
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
virtual ~SwDrawVirtObj() override
Definition: dcontact.cxx:2259
SdrObject * GetObj(size_t nNum) const
bool IsInserted() const
Definition: doc.hxx:188
SwContact(SwFrameFormat *pToRegisterIn)
For reader. Only the connection is created.
Definition: dcontact.cxx:192
virtual SdrLayerID GetControlsId() const =0
size_t GetObjCount() const
TElementType * Next()
Definition: calbck.hxx:365
SwDrawVirtObj(SdrModel &rSdrModel, SdrObject &_rNewObj, SwDrawContact &_rDrawContact)
Definition: dcontact.cxx:2229
virtual ~SwDrawContact() override
Definition: dcontact.cxx:732
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: dcontact.cxx:2431
ViewObjectContact & GetViewObjectContact(ObjectContact &rObjectContact)
SwNode & GetNode() const
Definition: ndindex.hxx:121
void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: dcontact.cxx:663
bool IsPosAttrSet() const
Definition: frmfmt.hxx:400
constexpr TypedWhichId< SvxOpaqueItem > RES_OPAQUE(99)
virtual void Move(const Size &rSiz) override
Definition: dcontact.cxx:2475
void Pos(const Point &rNew)
Definition: swrect.hxx:171
SdrUserCallType meEventTypeOfCurrentUserCall
event type, which is handled for .
Definition: dcontact.hxx:330
tools::Rectangle m_aOutRect
virtual void NbcMove(const Size &rSiz) override
Definition: dcontact.cxx:2446
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
const Point & GetPos() const
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:121
virtual void AddToHdlList(SdrHdlList &rHdlList) const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
Point GetRelPosToChar() const
method to determine position of anchored object relative to anchor character
static void Free(SdrObject *&_rpObject)
virtual SdrObjKind GetObjIdentifier() const
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
static void GetTextObjectsFromFormat(std::list< SdrTextObj * > &, SwDoc &)
get data collection of anchored objects, handled by with contact
Definition: dcontact.cxx:751
SwDrawContact & mrDrawContact
writer-drawing contact object the 'virtual' drawing object is controlled by.
Definition: dcontact.hxx:223
void Notify_Background(const SdrObject *pObj, SwPageFrame *pPage, const SwRect &rRect, const PrepareHint eHint, const bool bInva)
Definition: frmtool.cxx:3377
EmbeddedObjectRef * pObject
void Chain(SwFrame *_pAnchor)
Definition: fly.cxx:179
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
void DeleteCnt()
Definition: fly.cxx:317
virtual bool HasTextEdit() const override
Definition: dcontact.cxx:2600
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:744
SfxHintId GetId() const
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
void MoveObjToLayer(const bool _bToVisible, SdrObject *_pDrawObj)
method to move object to visible/invisible layer
Definition: dcontact.cxx:263
sdr::contact::ViewContact & GetViewContact() const
void DrawContactDeleted()
Definition: dcontact.cxx:1043
SdrTextAniKind
drawinglayer::primitive2d::Primitive2DContainer const & getPrimitive2DSequence(const DisplayInfo &rDisplayInfo) const
virtual Point GetOffset() const override
access to offset
Definition: dcontact.cxx:2386
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
virtual const tools::Rectangle & GetSnapRect() const
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
SdrView * NextView()
#define SAL_MAX_UINT32
void SetDrawObj(SdrObject &_rDrawObj)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
bool IsFlyFrame() const
Definition: frame.hxx:1211
wrapper class for the positioning of Writer fly frames and drawing objects
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
void RemoveDrawObj(SwAnchoredObject &_rToRemoveObj)
Definition: fly.cxx:2318
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
bool IsMore() const
SdrPage * getSdrPageFromSdrObject() const
const SwFrame * GetAnchorFrame(const SdrObject *_pDrawObj=nullptr) const
Definition: dcontact.cxx:803
void NotifyBackgroundOfAllVirtObjs(const tools::Rectangle *pOldBoundRect)
Definition: dcontact.cxx:899
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: dcontact.cxx:1410
Point GetRelPosToPageFrame(const bool _bFollowTextFlow, bool &_obRelToTableCell) const
method to determine position of anchored object relative to page frame
virtual Point GetSnapPoint(sal_uInt32 i) const
WW8AnchorConv m_eVertConv
Definition: frmfmt.hxx:310
virtual const tools::Rectangle & GetLogicRect() const override
Definition: dcontact.cxx:2553
SdrObject & rRefObj
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: dcontact.cxx:420
bool IsTextFrame() const
Definition: frame.hxx:1235
bool mbUserCallActive
Needed data for handling of nested events in method ...
Definition: dcontact.hxx:327
const SdrObject & GetReferencedObj() const
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
sal_uInt32 GetMinOrdNum() const
get minimum order number of anchored objects handled by with contact
Definition: dcontact.cxx:348
bool mbParentUserCallActive
Definition: dcontact.cxx:1020
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1112
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:120
void AssertNestedUserCall()
Definition: dcontact.cxx:1053
SdrObject * DrawObj()
virtual bool IsEnableSetModified() const =0
virtual void GetAnchoredObjs(std::vector< SwAnchoredObject * > &_roAnchoredObjs) const override
get data collection of anchored objects handled by with contact
Definition: dcontact.cxx:658
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: dcontact.cxx:2463
constexpr TypedWhichId< SwFormatWrapInfluenceOnObjPos > RES_WRAP_INFLUENCE_ON_OBJPOS(125)
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:209
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect)
bool IsInConstructor() const
Definition: viewsh.hxx:556
SwFrame * AnchorFrame()
SwDrawVirtObj * AddVirtObj(SwFrame const &rAnchorFrame)
add a 'virtual' drawing object to drawing page.
Definition: dcontact.cxx:829
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself=false, bool bRecursive=true)
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:856
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:439
sal_uInt32 GetOrdNumDirect() const
Specific frame formats (frames, DrawObjects).
bool mbInDTOR
boolean, indicating destruction of contact object important note: boolean has to be set at the beginn...
Definition: dcontact.hxx:71
constexpr bool IsEmpty() const
virtual SdrLayerID GetInvisibleHellId() const =0
ObjectContact & GetObjectContact() const
ContactObject for connection between frames (or their formats respectively) in SwClient and the drawo...
Definition: dcontact.hxx:175
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
AW: Need own sdr::contact::ViewContact since AnchorPos from parent is not used but something own (top...
Definition: dcontact.cxx:2224
bool IsMarqueeTextObj(const SdrObject &rObj)
Returns true if the SrdObject is a Marquee-Object (scrolling text)
Definition: dcontact.cxx:182
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: dcontact.cxx:2469
static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat *, SdrObject *), SwFrameFormat *pFormat, SdrObject *pObj)
Calls the method given by pFunc with every textboxes of the group given by pFormat.
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:139
virtual void SetLayer(SdrLayerID nLayer)
Style of a layout element.
Definition: frmfmt.hxx:59
Point GetRelPosToLine() const
method to determine position of anchored object relative to top of line
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1268
bool IsContentFrame() const
Definition: frame.hxx:1231
void InsertMasterIntoDrawPage()
method to insert 'master' drawing object into drawing page
Definition: dcontact.cxx:1975
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dcontact.cxx:2371
void append(const Primitive2DReference &)
const SdrObject * GetDrawObj() const
void InvalidatePrt()
Definition: frame.hxx:1037
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2571
uno_Any a
virtual SdrLayerID GetLayer() const override
Definition: dcontact.cxx:2607
void MoveTo(SdrHdlList &rOther)
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:278
static void GetAnchoredObjects(std::vector< SwAnchoredObject * > &, const SwFormat &rFormat)
Definition: fly.cxx:2869
const drawinglayer::geometry::ViewInformation2D & getViewInformation2D() const
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: format.cxx:720
virtual SwFrameFormat::tLayoutDir GetLayoutDir() const
Definition: atrfrm.cxx:2841
virtual void visit(const Primitive2DReference &)=0
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
virtual void NbcMirror(const Point &rRef1, const Point &rRef2)
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
SwPageFrame * FindPageFrame()
Definition: frame.hxx:681
virtual void SetBoundRectDirty() override
Definition: dcontact.cxx:2400
void AppendDrawObjToPage(SwAnchoredObject &_rNewObj)
Definition: flylay.cxx:1029
const SwFrame * Lower() const
Definition: layfrm.hxx:101
TElementType * First()
Definition: calbck.hxx:357
SwContentNode * GetContentNode()
Definition: node.hxx:619
FlyAnchors.
Definition: fmtanchr.hxx:34
const SdrPage * GetPage(sal_uInt16 nPgNum) const
void ActionChanged() const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
static void impAddPrimitivesFromGroup(const ViewObjectContact &rVOC, const basegfx::B2DHomMatrix &rOffsetMatrix, const DisplayInfo &rDisplayInfo, drawinglayer::primitive2d::Primitive2DContainer &rxTarget)
recursively collect primitive data from given VOC with given offset
Definition: dcontact.cxx:2118
bool HasArea() const
Definition: swrect.hxx:300
constexpr tools::Long Right() const
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
const SwRect & GetObjRectWithSpaces() const
method to determine object area inclusive its spacing
virtual basegfx::B2DPolyPolygon TakeContour() const
void UpdateObjInSortedList()
method to update anchored object in the lists
static bool syncTextBoxSize(SwFrameFormat *pShape, SdrObject *pObj)
Sets the correct size of textframe depending on the given SdrObject.
SdrModel & getSdrModelFromSdrObject() const
SdrObjUserCall * m_pUserCall
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 GetOrdNum() const
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
constexpr tools::Long Top() const
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:352
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const
SwFlyDrawContact(SwFlyFrameFormat *pToRegisterIn, SdrModel &rTargetModel)
Creates DrawObject and registers it with the Model.
Definition: dcontact.cxx:459
virtual void SetLogicRect(const tools::Rectangle &rRect)
Marks a node in the document model.
Definition: ndindex.hxx:32
virtual void Move(const Size &rSiz)
bool isFrameAreaPositionValid() const
Definition: frame.hxx:167
ring_container GetRingContainer()
Definition: ring.hxx:240
void InvalidateObjs_(const bool _bUpdateSortedObjsList=false)
Definition: dcontact.cxx:1629
virtual void InvalidateObjPos()=0
method to invalidate position of the anchored object
virtual void SetRelativePos(const Point &rPnt)
void SetUserCall(SdrObjUserCall *pUser)
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
virtual const tools::Rectangle & GetLastBoundRect() const override
Definition: dcontact.cxx:2381
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:560
static bool changeAnchor(SwFrameFormat *pShape, SdrObject *pObj)
Sets the anchor of the associated textframe of the given shape, and returns true on success...
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
A page of the document layout.
Definition: pagefrm.hxx:57
virtual SdrObject * RemoveObject(size_t nObjNum)
void notifyShapePropertyChange(const svx::ShapeProperty _eProperty) const
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:558
void Changed_(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle *pOldBoundRect)
Used by Changed() and by UndoDraw.
Definition: dcontact.cxx:1100
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
virtual void Mirror(const Point &rRef1, const Point &rRef2)
tools::Long SwTwips
Definition: swtypes.hxx:52
static sal_uInt16 nPgNum
Definition: viewport.cxx:52
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
#define Y
virtual const SdrObject * GetMaster() const =0
virtual SdrInventor GetObjInventor() const
constexpr Point TopLeft() const
virtual SdrLayerID GetHellId() const =0
virtual SdrLayerID GetLayer() const
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2545
void AddToDrawingPage(SwFrame const &rAnchorFrame)
connection to drawing layer
Definition: dcontact.cxx:2290
virtual void RecalcBoundRect() override
All overridden methods which need to use the offset.
Definition: dcontact.cxx:2405
virtual void RecalcSnapRect() override
Definition: dcontact.cxx:2521
static void AddExistingShapeToFormat(SdrObject const &_rObj)
Definition: unodraw.cxx:918
std::optional< tools::Rectangle > const & GetLastObjRect() const
virtual void SetLogicRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2561
virtual sal_uInt32 GetObjectCount() const
SdrObject * Next()
size_t GetHdlCount() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SdrHdl * GetHdl(size_t nNum) const
constexpr Size GetSize() const
virtual Point GetSnapPoint(sal_uInt32 i) const override
Definition: dcontact.cxx:2579
virtual SwFrameFormat & GetFrameFormat() override
virtual void SetLayer(SdrLayerID nLayer) override
Definition: dcontact.cxx:2618
void getViewIndependentPrimitive2DContainer(drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
sal_Int32 GetDenominator() const
virtual SdrObject * ReplaceObject(SdrObject *pNewObj, size_t nObjNum)
virtual const tools::Rectangle & GetSnapRect() const override
Definition: dcontact.cxx:2527
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
virtual void NbcSetSnapRect(const tools::Rectangle &rRect)
virtual SwFrameFormat & GetFrameFormat()=0
SwPageFrame * FindPageFrameOfAnchor()
method to determine the page frame, on which the 'anchor' of the given anchored object is...
#define SAL_WARN_IF(condition, area, stream)
virtual SdrLayerID GetInvisibleHeavenId() const =0
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:738
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
SwPageFrame * GetPageFrame()
virtual void NbcSetLogicRect(const tools::Rectangle &rRect)
void ClrContourCache(const SdrObject *pObj)
Definition: txtfly.cxx:134
void SetOrdNum(sal_uInt32 nNum)
SwTwips GetPos() const
Definition: fmtornt.hxx:59
virtual void Mirror(const Point &rRef1, const Point &rRef2) override
Definition: dcontact.cxx:2502
sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame *pFly, SwFrame const &rAnchorFrame)
Definition: dcontact.cxx:481
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:761
void SetInDTOR()
Definition: dcontact.cxx:203
virtual void NbcMove(const Size &rSiz)
void SetPageFrame(SwPageFrame *_pNewPageFrame)
#define SAL_INFO(area, stream)
virtual void NbcSetLayer(SdrLayerID nLayer) override
Definition: dcontact.cxx:2612
Point GetRelPosToAnchorFrame() const
method to determine position of anchored object relative to anchor frame
void DisconnectObjFromLayout(SdrObject *_pDrawObj)
disconnect for a dedicated drawing object - could be 'master' or 'virtual'.
Definition: dcontact.cxx:1728
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1779
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect) override
Virtual methods of SdrObjUserCall.
Definition: dcontact.cxx:965
static SwVirtFlyDrawObj * CreateNewRef(SwFlyFrame *pFly, SwFlyFrameFormat *pFormat, SwFrame const &rAnchorFrame)
Definition: dcontact.cxx:524
const SwPageFrame * GetPageFrame() const
Definition: dcontact.hxx:359
void RemoveFromDrawingPage()
Definition: dcontact.cxx:2345
SwNodes & GetNodes()
Definition: doc.hxx:409
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:212
bool IsRightToLeft() const
Definition: frame.hxx:988
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:165
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true) override
Definition: dcontact.cxx:2480
void InvalidateObjRectWithSpaces() const
bool IsPageFrame() const
Definition: frame.hxx:1179
bool ObjAnchoredAsChar() const
Definition: dcontact.hxx:150
sal_Int32 GetNumerator() const
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: dcontact.cxx:2451
void RemoveMasterFromDrawPage()
method to remove 'master' drawing object from drawing page.
Definition: dcontact.cxx:1709
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
std::vector< SwDrawVirtObjPtr > maDrawVirtObjs
container for 'virtual' drawing object supporting drawing objects in headers/footers.
Definition: dcontact.hxx:315
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet, SdrObject *pObj)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
void Unchain()
Definition: fly.cxx:309
virtual void GetAnchoredObjs(std::vector< SwAnchoredObject * > &_roAnchoredObjs) const =0
get data collection of anchored objects, handled by with contact
virtual void MoveObjToInvisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding invisible layer
Definition: dcontact.cxx:236
virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override
Definition: dcontact.cxx:2415
virtual ViewContact & GetViewContact(sal_uInt32 nIndex) const
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
SdrObject * getParentSdrObjectFromSdrObject() const
void AppendDrawObj(SwAnchoredObject &_rNewObj)
Definition: fly.cxx:2237
virtual ::basegfx::B2DPolyPolygon TakeContour() const override
Definition: dcontact.cxx:2423
void RemoveFromWriterLayout()
Definition: dcontact.cxx:2280
SdrUserCallType meParentUserCallEventType
Definition: dcontact.cxx:1021
void setContextWritingMode(SdrObject *pObj, SwFrame const *pAnchor)
Definition: dcontact.cxx:102
ViewContact & GetViewContact() const
virtual void SetSnapRect(const tools::Rectangle &rRect)
bool IsVertical() const
Definition: frame.hxx:974
virtual void SetEnableSetModified(bool bEnableSetModified)=0
bool IsInDtor() const
Definition: doc.hxx:404
const SwFrame * GetAnchorFrame() const
Definition: dcontact.cxx:2268
SwModify * GetRegisteredInNonConst() const
Definition: calbck.hxx:147
#define SAL_WARN(area, stream)
virtual void NbcSetAnchorPos(const Point &rPnt)
bool IsNestedUserCall() const
Definition: dcontact.cxx:1048
virtual SdrObject * SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
virtual void SetContextWritingMode(const sal_Int16 _nContextWritingMode)
virtual void SetSnapRect(const tools::Rectangle &rRect) override
Definition: dcontact.cxx:2535
virtual const tools::Rectangle & GetLogicRect() const
NestedUserCallHdl(SwDrawContact *_pDrawContact, SdrUserCallType _eEventType)
Definition: dcontact.cxx:1024
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1895
virtual void NbcSetAnchorPos(const Point &rPnt) override
Definition: dcontact.cxx:2363
SwAnchoredDrawObject maAnchoredDrawObj
anchored drawing object instance for the 'master' drawing object
Definition: dcontact.hxx:312
bool mbDisconnectInProgress
internal flag to indicate that disconnect from layout is in progress
Definition: dcontact.hxx:323
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: dcontact.cxx:2457
virtual ~SwFlyDrawContact() override
Definition: dcontact.cxx:471
const SwFrame * GetAnchorFrame() const
void ResetLayoutProcessBools()
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
virtual void MoveObjToInvisibleLayer(SdrObject *_pDrawObj) override
Definition: dcontact.cxx:628
constexpr TypedWhichId< SwFormatFollowTextFlow > RES_FOLLOW_TEXT_FLOW(123)
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1907
WW8AnchorConv m_eHoriConv
Definition: frmfmt.hxx:309
virtual void NbcSetPoint(const Point &rPnt, sal_uInt32 i) override
Definition: dcontact.cxx:2592
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2166
bool IsPositioningInProgress() const
is positioning of anchored object in progress
class for collecting anchored objects
Definition: sortedobjs.hxx:48
virtual void GetAnchoredObjs(std::vector< SwAnchoredObject * > &_roAnchoredObjs) const override
get data collection of anchored objects, handled by with contact
Definition: dcontact.cxx:2051
virtual Point GetPoint(sal_uInt32 i) const
SdrView * FirstView()
static SwTextFrame * lcl_GetFlyInContentAnchor(SwTextFrame *_pProposedAnchorFrame, SwPosition const &rAnchorPos)
Definition: dcontact.cxx:1764
SdrObjUserCall * GetUserCall() const
virtual Point GetPoint(sal_uInt32 i) const override
Definition: dcontact.cxx:2587
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1300
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
sal_uInt16 Which() const
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
SdrObject * FindRealSdrObject()
Definition: atrfrm.cxx:2773
SwAnchoredObject & AnchoredObj()
Definition: dcontact.hxx:248
bool IsCallbackActionEnabled() const
Definition: rootfrm.hxx:388
const basegfx::B2DRange & getObjectRange() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1319
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:718
static void lcl_textBoxSizeNotify(SwFrameFormat *pFormat)
Notify the format's textbox that it should reconsider its position / size.
Definition: dcontact.cxx:1086
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
Definition: dcontact.cxx:2355
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:194
virtual void NbcSetLayer(SdrLayerID nLayer)
SwPageFrame * FindPage(const SwRect &rRect)
Definition: dcontact.cxx:1985