LibreOffice Module sw (master)  1
dflyobj.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <comphelper/lok.hxx>
22 #include <tools/mapunit.hxx>
23 #include <svx/svdhdl.hxx>
24 #include <svx/svdtrans.hxx>
25 #include <editeng/protitem.hxx>
26 #include <svx/svdpage.hxx>
27 #include <vcl/canvastools.hxx>
28 #include <vcl/gdimtf.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/ptrstyle.hxx>
31 
32 #include <fmtclds.hxx>
33 #include <fmtornt.hxx>
34 #include <fmtfsize.hxx>
35 #include <fmturl.hxx>
36 #include <viewsh.hxx>
37 #include <frmatr.hxx>
38 #include <doc.hxx>
39 #include <IDocumentUndoRedo.hxx>
40 #include <dflyobj.hxx>
41 #include <flyfrm.hxx>
42 #include <frmfmt.hxx>
43 #include <viewopt.hxx>
44 #include <frmtool.hxx>
45 #include <flyfrms.hxx>
46 #include <ndnotxt.hxx>
47 #include <grfatr.hxx>
48 #include <pagefrm.hxx>
49 #include <rootfrm.hxx>
50 #include <textboxhelper.hxx>
51 #include <wrtsh.hxx>
52 #include <ndgrf.hxx>
53 #include <frmmgr.hxx>
54 
59 
60 // AW: For VCOfDrawVirtObj and stuff
64 #include <sw_primitivetypes2d.hxx>
67 #include <notxtfrm.hxx>
68 
69 using namespace ::com::sun::star;
70 
71 static bool bInResize = false;
72 
73 
74 namespace sdr::contact
75 {
76  namespace {
77 
86  class VCOfSwFlyDrawObj : public ViewContactOfSdrObj
87  {
88  protected:
93  virtual drawinglayer::primitive2d::Primitive2DContainer createViewIndependentPrimitive2DSequence() const override;
94 
95  public:
97  explicit VCOfSwFlyDrawObj(SwFlyDrawObj& rObj)
98  : ViewContactOfSdrObj(rObj)
99  {
100  }
101  };
102 
103  }
104 
105  drawinglayer::primitive2d::Primitive2DContainer VCOfSwFlyDrawObj::createViewIndependentPrimitive2DSequence() const
106  {
107  // currently gets not visualized, return empty sequence
109  }
110 
111 } // end of namespace sdr::contact
112 
113 std::unique_ptr<sdr::properties::BaseProperties> SwFlyDrawObj::CreateObjectSpecificProperties()
114 {
115  // create default properties
116  return std::make_unique<sdr::properties::DefaultProperties>(*this);
117 }
118 
119 std::unique_ptr<sdr::contact::ViewContact> SwFlyDrawObj::CreateObjectSpecificViewContact()
120 {
121  // needs an own VC since createViewIndependentPrimitive2DSequence()
122  // is called when RecalcBoundRect() is used
123  return std::make_unique<sdr::contact::VCOfSwFlyDrawObj>(*this);
124 }
125 
127 : SdrObject(rSdrModel),
128  mbIsTextBox(false)
129 {
130 }
131 
133 {
134 }
135 
136 // SwFlyDrawObj - Factory-Methods
138 {
139  return SdrInventor::Swg;
140 }
141 
143 {
144  return SwFlyDrawObjIdentifier;
145 }
146 
147 // TODO: Need own primitive to get the FlyFrame paint working
149 {
150  namespace {
151 
152  class SwVirtFlyDrawObjPrimitive : public BufferedDecompositionPrimitive2D
153  {
154  private:
157 
158  protected:
160  virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
161 
162  public:
163  SwVirtFlyDrawObjPrimitive(
164  const SwVirtFlyDrawObj& rSwVirtFlyDrawObj,
165  const basegfx::B2DRange &rOuterRange)
166  : BufferedDecompositionPrimitive2D(),
167  mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj),
168  maOuterRange(rOuterRange)
169  {
170  }
171 
172  virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
173 
174  virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
175 
176  // override to allow callbacks to wrap_DoPaintObject
177  virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
178 
179  // data read access
180  const SwVirtFlyDrawObj& getSwVirtFlyDrawObj() const { return mrSwVirtFlyDrawObj; }
181  const basegfx::B2DRange& getOuterRange() const { return maOuterRange; }
182 
184  virtual sal_uInt32 getPrimitive2DID() const override;
185  };
186 
187  }
188 } // end of namespace drawinglayer::primitive2d
189 
191 {
192  void SwVirtFlyDrawObjPrimitive::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
193  {
194  if(getOuterRange().isEmpty())
195  return;
196 
197  // currently this SW object has no primitive representation. As long as this is the case,
198  // create invisible geometry to allow correct HitTest and BoundRect calculations for the
199  // object. Use a filled primitive to get 'inside' as default object hit. The special cases from
200  // the old SwVirtFlyDrawObj::CheckHit implementation are handled now in SwDrawView::PickObj;
201  // this removed the 'hack' to get a view from inside model data or to react on null-tolerance
202  // as it was done in the old implementation
203  rContainer.push_back(
205  true,
206  getOuterRange()));
207  }
208 
209  bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const
210  {
211  if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
212  {
213  const SwVirtFlyDrawObjPrimitive& rCompare = static_cast<const SwVirtFlyDrawObjPrimitive&>(rPrimitive);
214 
215  return (&getSwVirtFlyDrawObj() == &rCompare.getSwVirtFlyDrawObj()
216  && getOuterRange() == rCompare.getOuterRange());
217  }
218 
219  return false;
220  }
221 
222  basegfx::B2DRange SwVirtFlyDrawObjPrimitive::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
223  {
224  return getOuterRange();
225  }
226 
227  void SwVirtFlyDrawObjPrimitive::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
228  {
229  // This is the callback to keep the FlyFrame painting in SW alive as long as it
230  // is not changed to primitives. This is the method which will be called by the processors
231  // when they do not know this primitive (and they do not). Inside wrap_DoPaintObject
232  // there needs to be a test that paint is only done during SW repaints (see there).
233  // Using this mechanism guarantees the correct Z-Order of the VirtualObject-based FlyFrames.
234  getSwVirtFlyDrawObj().wrap_DoPaintObject(rViewInformation);
235 
236  // call parent
237  BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
238  }
239 
240  // provide unique ID
242 
243 } // end of namespace drawinglayer::primitive2d
244 
245 // AW: own sdr::contact::ViewContact (VC) sdr::contact::ViewObjectContact (VOC) needed
246 // since offset is defined different from SdrVirtObj's sdr::contact::ViewContactOfVirtObj.
247 // For paint, that offset is used by setting at the OutputDevice; for primitives this is
248 // not possible since we have no OutputDevice, but define the geometry itself.
249 
250 namespace sdr::contact
251 {
252  namespace {
253 
254  class VCOfSwVirtFlyDrawObj : public ViewContactOfVirtObj
255  {
256  protected:
261  virtual drawinglayer::primitive2d::Primitive2DContainer createViewIndependentPrimitive2DSequence() const override;
262 
263  public:
265  explicit VCOfSwVirtFlyDrawObj(SwVirtFlyDrawObj& rObj)
266  : ViewContactOfVirtObj(rObj)
267  {
268  }
269 
271  SwVirtFlyDrawObj& GetSwVirtFlyDrawObj() const
272  {
273  return static_cast<SwVirtFlyDrawObj&>(mrObject);
274  }
275  };
276 
277  }
278 } // end of namespace sdr::contact
279 
280 namespace sdr::contact
281 {
282  drawinglayer::primitive2d::Primitive2DContainer VCOfSwVirtFlyDrawObj::createViewIndependentPrimitive2DSequence() const
283  {
285  const SdrObject& rReferencedObject = GetSwVirtFlyDrawObj().GetReferencedObj();
286 
287  if(dynamic_cast<const SwFlyDrawObj*>( &rReferencedObject) != nullptr)
288  {
289  // create an own specialized primitive which is used as repaint callpoint and HitTest
290  // for HitTest processor (see primitive implementation above)
291  const basegfx::B2DRange aOuterRange(GetSwVirtFlyDrawObj().getOuterBound());
292 
293  if(!aOuterRange.isEmpty())
294  {
296  new drawinglayer::primitive2d::SwVirtFlyDrawObjPrimitive(
297  GetSwVirtFlyDrawObj(),
298  aOuterRange));
299 
300  xRetval = drawinglayer::primitive2d::Primitive2DContainer { xPrimitive };
301  }
302  }
303 
304  return xRetval;
305  }
306 
307 } // end of namespace sdr::contact
308 
310 {
311  basegfx::B2DRange aOuterRange;
312  const SdrObject& rReferencedObject = GetReferencedObj();
313 
314  if(dynamic_cast<const SwFlyDrawObj*>( &rReferencedObject) != nullptr)
315  {
316  const SwFlyFrame* pFlyFrame = GetFlyFrame();
317 
318  if(pFlyFrame)
319  {
320  const tools::Rectangle aOuterRectangle(pFlyFrame->getFrameArea().Pos(), pFlyFrame->getFrameArea().SSize());
321 
322  if(!aOuterRectangle.IsEmpty())
323  {
324  aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Left(), aOuterRectangle.Top()));
325  aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Right(), aOuterRectangle.Bottom()));
326  }
327  }
328  }
329 
330  return aOuterRange;
331 }
332 
334 {
335  basegfx::B2DRange aInnerRange;
336  const SdrObject& rReferencedObject = GetReferencedObj();
337 
338  if(dynamic_cast<const SwFlyDrawObj*>( &rReferencedObject) != nullptr)
339  {
340  const SwFlyFrame* pFlyFrame = GetFlyFrame();
341 
342  if(pFlyFrame)
343  {
344  const tools::Rectangle aInnerRectangle(pFlyFrame->getFrameArea().Pos() + pFlyFrame->getFramePrintArea().Pos(), pFlyFrame->getFramePrintArea().SSize());
345 
346  if(!aInnerRectangle.IsEmpty())
347  {
348  aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Left(), aInnerRectangle.Top()));
349  aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Right(), aInnerRectangle.Bottom()));
350  }
351  }
352  }
353 
354  return aInnerRange;
355 }
356 
358 {
359  // RotGrfFlyFrame: Check if this is a SwGrfNode
360  const SwFlyFrame* pFlyFrame(GetFlyFrame());
361 
362  if(nullptr != pFlyFrame && pFlyFrame->Lower() && pFlyFrame->Lower()->IsNoTextFrame())
363  {
364  const SwNoTextFrame *const pNTF(static_cast<const SwNoTextFrame*>(pFlyFrame->Lower()));
365 
366  const SwGrfNode *const pGrfNd(pNTF->GetNode()->GetGrfNode());
367 
368  return nullptr != pGrfNd;
369  }
370 
371  return false;
372 }
373 
375 {
376  // RotGrfFlyFrame: If true, this SdrObject supports only limited rotation.
377  // This is the case for SwGrfNode instances
378  return ContainsSwGrfNode();
379 }
380 
381 void SwVirtFlyDrawObj::Rotate(const Point& rRef, tools::Long nAngle, double sn, double cs)
382 {
383  if(ContainsSwGrfNode())
384  {
385  // RotGrfFlyFrame: Here is where the positively completed rotate interaction is executed.
386  // Rotation is in 1/100th degree and may be signed (!)
387  nAngle /= 10;
388 
389  while(nAngle < 0)
390  {
391  nAngle += 3600;
392  }
393 
394  SwWrtShell *pShForAngle = nAngle ? dynamic_cast<SwWrtShell*>(GetFlyFrame()->getRootFrame()->GetCurrShell()) : nullptr;
395  if (pShForAngle)
396  {
397  // RotGrfFlyFrame: Add transformation to placeholder object
398  Size aSize;
399  const sal_uInt16 nOldRot(SwVirtFlyDrawObj::getPossibleRotationFromFraphicFrame(aSize));
400  SwFlyFrameAttrMgr aMgr(false, pShForAngle, Frmmgr_Type::NONE, nullptr);
401 
402  aMgr.SetRotation(nOldRot, (nOldRot + static_cast<sal_uInt16>(nAngle)) % 3600, aSize);
403  }
404  }
405  else
406  {
407  // call parent
408  SdrVirtObj::Rotate(rRef, nAngle, sn, cs);
409  }
410 }
411 
412 std::unique_ptr<sdr::contact::ViewContact> SwVirtFlyDrawObj::CreateObjectSpecificViewContact()
413 {
414  // need an own ViewContact (VC) to allow creation of a specialized primitive
415  // for being able to visualize the FlyFrames in primitive renderers
416  return std::make_unique<sdr::contact::VCOfSwVirtFlyDrawObj>(*this);
417 }
418 
420  SdrModel& rSdrModel,
421  SdrObject& rNew,
422  SwFlyFrame* pFly)
423 : SdrVirtObj(rSdrModel, rNew),
424  m_pFlyFrame(pFly)
425 {
427  bMovProt = rP.IsPosProtected();
428  bSizProt = rP.IsSizeProtected();
429 }
430 
432 {
433  if ( getSdrPageFromSdrObject() ) //Withdraw SdrPage the responsibility.
435 }
436 
438 {
439  return GetFlyFrame()->GetFormat();
440 }
442 {
443  return GetFlyFrame()->GetFormat();
444 }
445 
446 // --> OD #i102707#
447 namespace
448 {
449  class RestoreMapMode
450  {
451  public:
452  explicit RestoreMapMode( SwViewShell const * pViewShell )
453  : mbMapModeRestored( false )
454  , mpOutDev( pViewShell->GetOut() )
455  {
456  if ( pViewShell->getPrePostMapMode() == mpOutDev->GetMapMode() )
457  return;
458 
459  mpOutDev->Push(PushFlags::MAPMODE);
460 
461  GDIMetaFile* pMetaFile = mpOutDev->GetConnectMetaFile();
462  if ( pMetaFile &&
463  pMetaFile->IsRecord() && !pMetaFile->IsPause() )
464  {
465  OSL_FAIL( "MapMode restoration during meta file creation is somehow suspect - using <SetRelativeMapMode(..)>, but not sure, if correct." );
466  mpOutDev->SetRelativeMapMode( pViewShell->getPrePostMapMode() );
467  }
468  else
469  {
470  mpOutDev->SetMapMode( pViewShell->getPrePostMapMode() );
471  }
472 
473  mbMapModeRestored = true;
474  };
475 
476  ~RestoreMapMode()
477  {
478  if ( mbMapModeRestored )
479  {
480  mpOutDev->Pop();
481  }
482  };
483 
484  private:
485  bool mbMapModeRestored;
486  VclPtr<OutputDevice> mpOutDev;
487  };
488 }
489 // <--
490 
492  drawinglayer::geometry::ViewInformation2D const& rViewInformation) const
493 {
495 
496  // Only paint when we have a current shell and a DrawingLayer paint is in progress.
497  // This avoids evtl. problems with renderers which do processing stuff,
498  // but no paints. IsPaintInProgress() depends on SW repaint, so, as long
499  // as SW paints self and calls DrawLayer() for Heaven and Hell, this will
500  // be correct
501  if ( !(pShell && pShell->IsDrawingLayerPaintInProgress()) )
502  return;
503 
504  bool bDrawObject(true);
505 
506  if ( !SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(this), pShell ) )
507  {
508  bDrawObject = false;
509  }
510 
511  if ( !bDrawObject )
512  return;
513 
514  // if there's no viewport set, all fly-frames will be painted,
515  // which is slow, wastes memory, and can cause other trouble.
516  (void) rViewInformation; // suppress "unused parameter" warning
519  return;
520 
521  // it is also necessary to restore the VCL MapMode from ViewInformation since e.g.
522  // the VCL PixelRenderer resets it at the used OutputDevice. Unfortunately, this
523  // excludes shears and rotates which are not expressible in MapMode.
524  // OD #i102707#
525  // new helper class to restore MapMode - restoration, only if
526  // needed and consideration of paint for meta file creation .
527  RestoreMapMode aRestoreMapModeIfNeeded( pShell );
528 
529  // paint the FlyFrame (use standard VCL-Paint)
531 }
532 
534 {
535  rInfo.bMoveAllowed =
536  rInfo.bResizeFreeAllowed = rInfo.bResizePropAllowed = true;
537 
538  // RotGrfFlyFrame: Some rotation may be allowed
540 
541  rInfo.bMirrorFreeAllowed = rInfo.bMirror45Allowed =
542  rInfo.bMirror90Allowed = rInfo.bShearAllowed =
543  rInfo.bCanConvToPath = rInfo.bCanConvToPoly =
545 }
546 
547 // SwVirtFlyDrawObj - Size Determination
548 
550 {
551  if ( GetFlyFrame()->getFrameArea().HasArea() )
552  const_cast<SwVirtFlyDrawObj*>(this)->aOutRect = GetFlyFrame()->getFrameArea().SVRect();
553  else
554  const_cast<SwVirtFlyDrawObj*>(this)->aOutRect = tools::Rectangle();
555 }
556 
558 {
559  SetRect();
560  return aOutRect;
561 }
562 
564 {
565  return GetCurrentBoundRect();
566 }
567 
569 {
570  SetRect();
571 }
572 
574 {
575  SetRect();
576 }
577 
579 {
580  SetRect();
581  return aOutRect;
582 }
583 
585 {
587  SetRect();
588  SetChanged();
590  if (pUserCall!=nullptr)
591  pUserCall->Changed(*this, SdrUserCallType::Resize, aTmp);
592 }
593 
595 {
596  SetRect();
597 }
598 
600 {
601  SetRect();
602  return aOutRect;
603 }
604 
606 {
608  SetRect();
609  SetChanged();
611  if (pUserCall!=nullptr)
612  pUserCall->Changed(*this, SdrUserCallType::Resize, aTmp);
613 }
614 
616 {
617  SetRect();
618 }
619 
621 {
622  const tools::Rectangle aSourceRectangle(GetFlyFrame()->getFrameArea().SVRect());
623  const ::basegfx::B2DRange aSourceRange = vcl::unotools::b2DRectangleFromRectangle(aSourceRectangle);
625 
626  aRetval.append(::basegfx::utils::createPolygonFromRect(aSourceRange));
627 
628  return aRetval;
629 }
630 
631 // SwVirtFlyDrawObj::Move() and Resize()
633 {
634  if(GetFlyFrame()->IsFlyFreeFrame() && static_cast< SwFlyFreeFrame* >(GetFlyFrame())->isTransformableSwFrame())
635  {
636  // RotateFlyFrame3: When we have a change and are in transformed state (e.g. rotation used),
637  // we need to fall back to the un-transformed state to keep the old code below
638  // working properly. Restore FrameArea and use aOutRect from old FrameArea.
639  TransformableSwFrame* pTransformableSwFrame(static_cast<SwFlyFreeFrame*>(GetFlyFrame())->getTransformableSwFrame());
640  pTransformableSwFrame->restoreFrameAreas();
642  }
643 
644  aOutRect.Move( rSiz );
645  const Point aOldPos( GetFlyFrame()->getFrameArea().Pos() );
646  const Point aNewPos( aOutRect.TopLeft() );
647  const SwRect aFlyRect( aOutRect );
648 
649  //If the Fly has an automatic align (right or top),
650  //so preserve the automatic.
651  SwFrameFormat *pFormat = GetFlyFrame()->GetFormat();
652  const sal_Int16 eHori = pFormat->GetHoriOrient().GetHoriOrient();
653  const sal_Int16 eVert = pFormat->GetVertOrient().GetVertOrient();
654  const sal_Int16 eRelHori = pFormat->GetHoriOrient().GetRelationOrient();
655  const sal_Int16 eRelVert = pFormat->GetVertOrient().GetRelationOrient();
656  //On paragraph bound Flys starting from the new position a new
657  //anchor must be set. Anchor and the new RelPos is calculated and
658  //placed by the Fly itself.
659  if( GetFlyFrame()->IsFlyAtContentFrame() )
660  {
661  static_cast<SwFlyAtContentFrame*>(GetFlyFrame())->SetAbsPos( aNewPos );
662  }
663  else
664  {
665  const SwFrameFormat *pTmpFormat = GetFormat();
666  const SwFormatVertOrient &rVert = pTmpFormat->GetVertOrient();
667  const SwFormatHoriOrient &rHori = pTmpFormat->GetHoriOrient();
668  tools::Long lXDiff = aNewPos.X() - aOldPos.X();
669  if( rHori.IsPosToggle() && text::HoriOrientation::NONE == eHori &&
671  lXDiff = -lXDiff;
672 
674  text::HoriOrientation::NONE == eHori )
675  lXDiff = -lXDiff;
676 
677  tools::Long lYDiff = aNewPos.Y() - aOldPos.Y();
678  if( GetFlyFrame()->GetAnchorFrame()->IsVertical() )
679  {
680  //lXDiff -= rVert.GetPos();
681  //lYDiff += rHori.GetPos();
682 
683  if ( GetFlyFrame()->GetAnchorFrame()->IsVertLR() )
684  {
685  lXDiff += rVert.GetPos();
686  lXDiff = -lXDiff;
687  }
688  else
689  {
690  lXDiff -= rVert.GetPos();
691  lYDiff += rHori.GetPos();
692  }
693  }
694  else
695  {
696  lXDiff += rHori.GetPos();
697  lYDiff += rVert.GetPos();
698  }
699 
700  if( GetFlyFrame()->GetAnchorFrame()->IsRightToLeft() &&
701  text::HoriOrientation::NONE != eHori )
702  lXDiff = GetFlyFrame()->GetAnchorFrame()->getFrameArea().Width() -
703  aFlyRect.Width() - lXDiff;
704 
705  const Point aTmp( lXDiff, lYDiff );
706  GetFlyFrame()->ChgRelPos( aTmp );
707  }
708 
709  SwAttrSet aSet( pFormat->GetDoc()->GetAttrPool(),
711  SwFormatHoriOrient aHori( pFormat->GetHoriOrient() );
712  SwFormatVertOrient aVert( pFormat->GetVertOrient() );
713  bool bPut = false;
714 
715  if( !GetFlyFrame()->IsFlyLayFrame() &&
716  ::GetHtmlMode(pFormat->GetDoc()->GetDocShell()) )
717  {
718  //In HTML-Mode only automatic aligns are allowed.
719  //Only we can try a snap to left/right respectively left-/right border
720  const SwFrame* pAnch = GetFlyFrame()->GetAnchorFrame();
721  bool bNextLine = false;
722 
723  if( !GetFlyFrame()->IsAutoPos() || text::RelOrientation::PAGE_FRAME != aHori.GetRelationOrient() )
724  {
725  if( text::RelOrientation::CHAR == eRelHori )
726  {
727  aHori.SetHoriOrient( text::HoriOrientation::LEFT );
728  aHori.SetRelationOrient( text::RelOrientation::CHAR );
729  }
730  else
731  {
732  bNextLine = true;
733  //Horizontal Align:
734  const bool bLeftFrame =
735  aFlyRect.Left() < pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Left(),
736  bLeftPrt = aFlyRect.Left() + aFlyRect.Width() <
737  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width()/2;
738  if ( bLeftFrame || bLeftPrt )
739  {
740  aHori.SetHoriOrient( text::HoriOrientation::LEFT );
741  aHori.SetRelationOrient( bLeftFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
742  }
743  else
744  {
745  const bool bRightFrame = aFlyRect.Left() >
746  pAnch->getFrameArea().Left() + pAnch->getFramePrintArea().Width();
747  aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
748  aHori.SetRelationOrient( bRightFrame ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
749  }
750  }
751  aSet.Put( aHori );
752  }
753  //Vertical alignment simply is retained principally,
754  //only on manual align will be switched over.
755  bool bRelChar = text::RelOrientation::CHAR == eRelVert;
756  aVert.SetVertOrient( eVert != text::VertOrientation::NONE ? eVert :
757  GetFlyFrame()->IsFlyInContentFrame() ? text::VertOrientation::CHAR_CENTER :
758  bRelChar && bNextLine ? text::VertOrientation::CHAR_TOP : text::VertOrientation::TOP );
759  if( bRelChar )
760  aVert.SetRelationOrient( text::RelOrientation::CHAR );
761  else
762  aVert.SetRelationOrient( text::RelOrientation::PRINT_AREA );
763  aSet.Put( aVert );
764  bPut = true;
765  }
766 
767  //We want preferably not to lose the automatic alignments.
768  if ( !bPut && bInResize )
769  {
770  if ( text::HoriOrientation::NONE != eHori )
771  {
772  aHori.SetHoriOrient( eHori );
773  aHori.SetRelationOrient( eRelHori );
774  aSet.Put( aHori );
775  bPut = true;
776  }
777  if ( text::VertOrientation::NONE != eVert )
778  {
779  aVert.SetVertOrient( eVert );
780  aVert.SetRelationOrient( eRelVert );
781  aSet.Put( aVert );
782  bPut = true;
783  }
784  }
785  if ( bPut )
786  pFormat->SetFormatAttr( aSet );
787 }
788 
789 
790 void SwVirtFlyDrawObj::NbcCrop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact)
791 {
792  // Get Wrt Shell
793  SwWrtShell *pSh = dynamic_cast<SwWrtShell*>( GetFlyFrame()->getRootFrame()->GetCurrShell() );
794 
795  if (!pSh)
796  {
797  return;
798  }
799 
800  GraphicObject const *pGraphicObject = pSh->GetGraphicObj();
801 
802  if (!pGraphicObject)
803  {
804  return;
805  }
806 
807  // Get graphic object size in 100th of mm
808  const MapMode aMapMode100thmm(MapUnit::Map100thMM);
809  Size aGraphicSize(pGraphicObject->GetPrefSize());
810 
811  if( MapUnit::MapPixel == pGraphicObject->GetPrefMapMode().GetMapUnit() )
812  {
813  aGraphicSize = Application::GetDefaultDevice()->PixelToLogic( aGraphicSize, aMapMode100thmm );
814  }
815  else
816  {
817  aGraphicSize = OutputDevice::LogicToLogic( aGraphicSize, pGraphicObject->GetPrefMapMode(), aMapMode100thmm);
818  }
819 
820  if( aGraphicSize.IsEmpty() )
821  {
822  return ;
823  }
824 
825  const bool bIsTransformableSwFrame(
826  GetFlyFrame()->IsFlyFreeFrame() &&
827  static_cast< SwFlyFreeFrame* >(GetFlyFrame())->isTransformableSwFrame());
828 
829  if(bIsTransformableSwFrame)
830  {
831  // When we have a change and are in transformed state (e.g. rotation used),
832  // we need to fall back to the un-transformed state to keep the old code below
833  // working properly. Restore FrameArea and use aOutRect from old FrameArea.
834  TransformableSwFrame* pTransformableSwFrame(static_cast<SwFlyFreeFrame*>(GetFlyFrame())->getTransformableSwFrame());
835  pTransformableSwFrame->restoreFrameAreas();
837  }
838 
839  // Compute old and new rect. This will give us the deformation to apply to
840  // the object to crop. OldRect is the inner frame, see getFullDragClone()
841  // below where getFramePrintAreaTransformation is used as object geometry for Crop
842  const tools::Rectangle aOldRect(
843  GetFlyFrame()->getFrameArea().TopLeft() + GetFlyFrame()->getFramePrintArea().TopLeft(),
844  GetFlyFrame()->getFramePrintArea().SSize());
845  const tools::Long nOldWidth(aOldRect.GetWidth());
846  const tools::Long nOldHeight(aOldRect.GetHeight());
847 
848  if (!nOldWidth || !nOldHeight)
849  {
850  return;
851  }
852 
853  // rRef is relative to the Crop-Action, si in X/Y-Ranges of [0.0 .. 1.0],
854  // to get the correct absolute position, transform using the old Rect
855  const Point aRef(
856  aOldRect.Left() + basegfx::fround(aOldRect.GetWidth() * rRef.getX()),
857  aOldRect.Top() + basegfx::fround(aOldRect.GetHeight() * rRef.getY()));
858 
859  // apply transformation, use old ResizeRect for now
860  tools::Rectangle aNewRect( aOldRect );
861  ResizeRect(
862  aNewRect,
863  aRef,
864  Fraction(fxFact),
865  Fraction(fyFact));
866 
867  // Get old values for crop in 10th of mm
869  pSh->GetCurAttr( aSet );
870  SwCropGrf aCrop( aSet.Get(RES_GRFATR_CROPGRF) );
871 
872  tools::Rectangle aCropRectangle(
873  convertTwipToMm100(aCrop.GetLeft()),
874  convertTwipToMm100(aCrop.GetTop()),
875  convertTwipToMm100(aCrop.GetRight()),
876  convertTwipToMm100(aCrop.GetBottom()) );
877 
878  // Compute delta to apply
879  double fScaleX = ( aGraphicSize.Width() - aCropRectangle.Left() - aCropRectangle.Right() ) / static_cast<double>(nOldWidth);
880  double fScaleY = ( aGraphicSize.Height() - aCropRectangle.Top() - aCropRectangle.Bottom() ) / static_cast<double>(nOldHeight);
881 
882  sal_Int32 nDiffLeft = aNewRect.Left() - aOldRect.Left();
883  sal_Int32 nDiffTop = aNewRect.Top() - aOldRect.Top();
884  sal_Int32 nDiffRight = aNewRect.Right() - aOldRect.Right();
885  sal_Int32 nDiffBottom = aNewRect.Bottom() - aOldRect.Bottom();
886 
887  // Compute new values in 10th of mm
888  sal_Int32 nLeftCrop = static_cast<sal_Int32>( aCropRectangle.Left() + nDiffLeft * fScaleX );
889  sal_Int32 nTopCrop = static_cast<sal_Int32>( aCropRectangle.Top() + nDiffTop * fScaleY );
890  sal_Int32 nRightCrop = static_cast<sal_Int32>( aCropRectangle.Right() - nDiffRight * fScaleX );
891  sal_Int32 nBottomCrop = static_cast<sal_Int32>( aCropRectangle.Bottom() - nDiffBottom * fScaleY );
892 
893  // Apply values
894  pSh->StartAllAction();
895  // pSh->StartUndo(SwUndoId::START);
896 
897  // Set new crop values in twips
898  aCrop.SetLeft (convertMm100ToTwip(nLeftCrop));
899  aCrop.SetTop (convertMm100ToTwip(nTopCrop));
900  aCrop.SetRight (convertMm100ToTwip(nRightCrop));
901  aCrop.SetBottom(convertMm100ToTwip(nBottomCrop));
902  pSh->SetAttrItem(aCrop);
903 
904  // Set new frame size
905  SwFrameFormat *pFormat = GetFormat();
906  SwFormatFrameSize aSz( pFormat->GetFrameSize() );
907  const tools::Long aNewWidth(aNewRect.GetWidth() + (aOutRect.GetWidth() - aOldRect.GetWidth()));
908  const tools::Long aNewHeight(aNewRect.GetHeight() + (aOutRect.GetHeight() - aOldRect.GetHeight()));
909  aSz.SetWidth(aNewWidth);
910  aSz.SetHeight(aNewHeight);
911  pFormat->GetDoc()->SetAttr( aSz, *pFormat );
912 
913  // add move - to make result look better. Fill with defaults
914  // for the untransformed case
915  Point aNewTopLeft(aNewRect.TopLeft());
916  const Point aOldTopLeft(aOldRect.TopLeft());
917 
918  if(bIsTransformableSwFrame)
919  {
920  // Need to correct the NewTopLeft position in transformed state to make
921  // the interaction look correct. First, extract rotation
922  basegfx::B2DVector aScale, aTranslate;
923  double fRotate, fShearX;
924  GetFlyFrame()->getFrameAreaTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
925 
926  // calc the center of the unchanged object
927  const basegfx::B2DPoint aFormerCenter(
928  GetFlyFrame()->getFrameAreaTransformation() * basegfx::B2DPoint(0.5, 0.5));
929 
930  // define the existing rotation around that former center
931  const basegfx::B2DHomMatrix aRotFormerCenter(
933  aFormerCenter.getX(),
934  aFormerCenter.getY(),
935  fRotate));
936 
937  // use the new center of the unrotated object, rotate it around the
938  // former center
939  const Point aNewCenter(aNewRect.Center());
940  const basegfx::B2DPoint aRotNewCenter(
941  aRotFormerCenter * basegfx::B2DPoint(aNewCenter.X(), aNewCenter.Y()));
942 
943  // Create the new TopLeft of the unrotated, cropped object by creating
944  // as if re-creating the unrotated geometry
945  aNewTopLeft = Point(
946  basegfx::fround(aRotNewCenter.getX() - (0.5 * aNewRect.getWidth())),
947  basegfx::fround(aRotNewCenter.getY() - (0.5 * aNewRect.getHeight())));
948  }
949 
950  // check if we have movement and execute if yes
951  const Size aDeltaMove(
952  aNewTopLeft.X() - aOldTopLeft.X(),
953  aNewTopLeft.Y() - aOldTopLeft.Y());
954 
955  if(0 != aDeltaMove.Width() || 0 != aDeltaMove.Height())
956  {
957  NbcMove(aDeltaMove);
958  }
959 
960  // pSh->EndUndo(SwUndoId::END);
961  pSh->EndAllAction();
962 }
963 
964 void SwVirtFlyDrawObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
965 {
966  const SwFrame* pTmpFrame = GetFlyFrame()->GetAnchorFrame();
967 
968  if( !pTmpFrame )
969  {
970  pTmpFrame = GetFlyFrame();
971  }
972 
973  const bool bVertX(pTmpFrame->IsVertical());
974  const bool bRTL(pTmpFrame->IsRightToLeft());
975  const bool bVertL2RX(pTmpFrame->IsVertLR());
976  const bool bUseRightEdge((bVertX && !bVertL2RX ) || bRTL);
977  const bool bIsTransformableSwFrame(
978  GetFlyFrame()->IsFlyFreeFrame() &&
979  static_cast< SwFlyFreeFrame* >(GetFlyFrame())->isTransformableSwFrame());
980 
981  if(bIsTransformableSwFrame)
982  {
983  // When we have a change in transformed state, we need to fall back to the
984  // state without possible transformations.
985  // In the Resize case to correctly handle the changes, apply to the transformation
986  // and extract the new, untransformed state from that modified transformation
987  basegfx::B2DHomMatrix aNewMat(GetFlyFrame()->getFrameAreaTransformation());
988  const basegfx::B2DPoint aRef(rRef.X(), rRef.Y());
989 
990  // apply state to already valid transformation
991  aNewMat.translate(-aRef.getX(), -aRef.getY());
992  aNewMat.scale(double(xFact), double(yFact));
993  aNewMat.translate(aRef.getX(), aRef.getY());
994 
995  // get center of transformed state
996  const basegfx::B2DPoint aCenter(aNewMat * basegfx::B2DPoint(0.5, 0.5));
997 
998  // decompose to extract scale
999  basegfx::B2DVector aScale, aTranslate;
1000  double fRotate, fShearX;
1001  aNewMat.decompose(aScale, aTranslate, fRotate, fShearX);
1002  const basegfx::B2DVector aAbsScale(basegfx::absolute(aScale));
1003 
1004  // create new modified, but untransformed OutRect
1006  basegfx::fround(aCenter.getX() - (0.5 * aAbsScale.getX())),
1007  basegfx::fround(aCenter.getY() - (0.5 * aAbsScale.getY())),
1008  basegfx::fround(aCenter.getX() + (0.5 * aAbsScale.getX())),
1009  basegfx::fround(aCenter.getY() + (0.5 * aAbsScale.getY())));
1010 
1011  // restore FrameAreas so that actions below not adapted to new
1012  // full transformations take the correct actions
1013  TransformableSwFrame* pTransformableSwFrame(static_cast<SwFlyFreeFrame*>(GetFlyFrame())->getTransformableSwFrame());
1014  pTransformableSwFrame->restoreFrameAreas();
1015  }
1016  else
1017  {
1018  ResizeRect( aOutRect, rRef, xFact, yFact );
1019  }
1020 
1021  // Position may also change, remember old one. This is now already
1022  // the one in the unrotated, old coordinate system
1023  Point aOldPos(bUseRightEdge ? GetFlyFrame()->getFrameArea().TopRight() : GetFlyFrame()->getFrameArea().Pos());
1024 
1025  // get target size in old coordinate system
1026  Size aSz( aOutRect.Right() - aOutRect.Left() + 1, aOutRect.Bottom()- aOutRect.Top() + 1 );
1027 
1028  // compare with restored FrameArea
1029  if( aSz != GetFlyFrame()->getFrameArea().SSize() )
1030  {
1031  //The width of the columns should not be too narrow
1032  if ( GetFlyFrame()->Lower() && GetFlyFrame()->Lower()->IsColumnFrame() )
1033  {
1035  const SwBorderAttrs &rAttrs = *aAccess.Get();
1036  tools::Long nMin = rAttrs.CalcLeftLine()+rAttrs.CalcRightLine();
1037  const SwFormatCol& rCol = rAttrs.GetAttrSet().GetCol();
1038  if ( rCol.GetColumns().size() > 1 )
1039  {
1040  for ( const auto &rC : rCol.GetColumns() )
1041  {
1042  nMin += rC.GetLeft() + rC.GetRight() + MINFLY;
1043  }
1044  nMin -= MINFLY;
1045  }
1046  aSz.setWidth( std::max( aSz.Width(), nMin ) );
1047  }
1048 
1049  SwFrameFormat *pFormat = GetFormat();
1050  const SwFormatFrameSize aOldFrameSz( pFormat->GetFrameSize() );
1051  GetFlyFrame()->ChgSize( aSz );
1052  SwFormatFrameSize aFrameSz( pFormat->GetFrameSize() );
1053 
1054  if ( aFrameSz.GetWidthPercent() || aFrameSz.GetHeightPercent() )
1055  {
1056  tools::Long nRelWidth, nRelHeight;
1057  const SwFrame *pRel = GetFlyFrame()->IsFlyLayFrame() ?
1060  const SwViewShell *pSh = GetFlyFrame()->getRootFrame()->GetCurrShell();
1061 
1062  if ( pSh && pRel->IsBodyFrame() &&
1063  pSh->GetViewOptions()->getBrowseMode() &&
1064  pSh->VisArea().HasArea() )
1065  {
1066  nRelWidth = pSh->GetBrowseWidth();
1067  nRelHeight = pSh->VisArea().Height();
1068  const Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
1069  nRelHeight -= 2*aBorder.Height();
1070  }
1071  else
1072  {
1073  nRelWidth = pRel->getFramePrintArea().Width();
1074  nRelHeight = pRel->getFramePrintArea().Height();
1075  }
1076 
1077  if ( aFrameSz.GetWidthPercent() && aFrameSz.GetWidthPercent() != SwFormatFrameSize::SYNCED &&
1078  aOldFrameSz.GetWidth() != aFrameSz.GetWidth() )
1079  {
1080  aFrameSz.SetWidthPercent( sal_uInt8(aSz.Width() * 100.0 / nRelWidth + 0.5) );
1081  }
1082 
1083  if ( aFrameSz.GetHeightPercent() && aFrameSz.GetHeightPercent() != SwFormatFrameSize::SYNCED &&
1084  aOldFrameSz.GetHeight() != aFrameSz.GetHeight() )
1085  {
1086  aFrameSz.SetHeightPercent( sal_uInt8(aSz.Height() * 100.0 / nRelHeight + 0.5) );
1087  }
1088 
1089  pFormat->GetDoc()->SetAttr( aFrameSz, *pFormat );
1090  }
1091  }
1092 
1093  //Position can also be changed, get new one
1094  const Point aNewPos(bUseRightEdge ? aOutRect.Right() + 1 : aOutRect.Left(), aOutRect.Top());
1095 
1096  if ( aNewPos == aOldPos )
1097  return;
1098 
1099  // Former late change in aOutRect by ChgSize
1100  // is now taken into account directly by calculating
1101  // aNewPos *after* calling ChgSize (see old code).
1102  // Still need to adapt aOutRect since the 'Move' is already applied
1103  // here (see ResizeRect) and it's the same SdrObject
1104  const Size aDeltaMove(
1105  aNewPos.X() - aOldPos.X(),
1106  aNewPos.Y() - aOldPos.Y());
1107  aOutRect.Move(-aDeltaMove.Width(), -aDeltaMove.Height());
1108 
1109  // Now, move as needed (no empty delta which was a hack anyways)
1110  if(bIsTransformableSwFrame)
1111  {
1112  // need to save aOutRect to FrameArea, will be restored to aOutRect in
1113  // SwVirtFlyDrawObj::NbcMove currently for TransformableSwFrames
1115  aFrm.setSwRect(aOutRect);
1116  }
1117 
1118  // keep old hack - not clear what happens here
1119  bInResize = true;
1120  NbcMove(aDeltaMove);
1121  bInResize = false;
1122 }
1123 
1124 void SwVirtFlyDrawObj::Move(const Size& rSiz)
1125 {
1126  NbcMove( rSiz );
1127  SetChanged();
1129 }
1130 
1131 void SwVirtFlyDrawObj::Resize(const Point& rRef,
1132  const Fraction& xFact, const Fraction& yFact, bool /*bUnsetRelative*/)
1133 {
1134  NbcResize( rRef, xFact, yFact );
1135  SetChanged();
1137 }
1138 
1139 void SwVirtFlyDrawObj::Crop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact)
1140 {
1141  NbcCrop( rRef, fxFact, fyFact );
1142  SetChanged();
1144 }
1145 
1146 // RotGrfFlyFrame: Helper to access possible rotation of Graphic contained in FlyFrame
1148 {
1149  sal_uInt16 nRetval(0);
1150  const SwNoTextFrame* pNoTx = dynamic_cast< const SwNoTextFrame* >(GetFlyFrame()->Lower());
1151 
1152  if(pNoTx)
1153  {
1154  SwNoTextNode& rNoTNd = const_cast< SwNoTextNode& >(*static_cast<const SwNoTextNode*>(pNoTx->GetNode()));
1155  SwGrfNode* pGrfNd = rNoTNd.GetGrfNode();
1156 
1157  if(nullptr != pGrfNd)
1158  {
1159  const SwAttrSet& rSet = pGrfNd->GetSwAttrSet();
1160  const SwRotationGrf& rRotation = rSet.GetRotationGrf();
1161 
1162  rSize = rRotation.GetUnrotatedSize();
1163  nRetval = rRotation.GetValue();
1164  }
1165  }
1166 
1167  return nRetval;
1168 }
1169 
1171 {
1172  if(ContainsSwGrfNode())
1173  {
1174  Size aSize;
1176  }
1177  else
1178  {
1179  return SdrVirtObj::GetRotateAngle();
1180  }
1181 }
1182 
1184 {
1185  // call parent
1187 
1188  if(pRetval && GetFlyFrame() && ContainsSwGrfNode())
1189  {
1190  // RotGrfFlyFrame3: get inner bounds/transformation
1191  const basegfx::B2DHomMatrix aTargetTransform(GetFlyFrame()->getFramePrintAreaTransformation());
1192 
1193  pRetval->TRSetBaseGeometry(aTargetTransform, basegfx::B2DPolyPolygon());
1194  }
1195 
1196  return pRetval;
1197 }
1198 
1200 {
1201  // RotGrfFlyFrame: Adapt to possible rotated Graphic contained in FlyFrame
1202  if(!GetFlyFrame()->getFrameArea().HasArea())
1203  return;
1204 
1205  // Use InnerBound, OuterBound (same as GetFlyFrame()->getFrameArea().SVRect())
1206  // may have a distance to InnerBound which needs to be taken into account.
1207  // The Graphic is mapped to InnerBound, as is the rotated Graphic.
1208  const basegfx::B2DRange aTargetRange(getInnerBound());
1209 
1210  if(aTargetRange.isEmpty())
1211  return;
1212 
1213  // RotGrfFlyFrame3: get inner bounds/transformation
1214  const basegfx::B2DHomMatrix aTargetTransform(GetFlyFrame()->getFramePrintAreaTransformation());
1215 
1216  // break up matrix
1217  basegfx::B2DTuple aScale;
1218  basegfx::B2DTuple aTranslate;
1219  double fRotate(0.0);
1220  double fShearX(0.0);
1221  aTargetTransform.decompose(aScale, aTranslate, fRotate, fShearX);
1222  basegfx::B2DPoint aPos;
1223 
1224  aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.0);
1225  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
1226  aPos = aTargetTransform * basegfx::B2DPoint(0.5, 0.0);
1227  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
1228  aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.0);
1229  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
1230  aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.5);
1231  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
1232  aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.5);
1233  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
1234  aPos = aTargetTransform * basegfx::B2DPoint(0.0, 1.0);
1235  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
1236  aPos = aTargetTransform * basegfx::B2DPoint(0.5, 1.0);
1237  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
1238  aPos = aTargetTransform * basegfx::B2DPoint(1.0, 1.0);
1239  rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
1240 }
1241 
1242 // Macro
1243 
1245  const SdrObjMacroHitRec& ) const
1246 {
1247  return PointerStyle::RefHand;
1248 }
1249 
1251 {
1252  const SwFormatURL &rURL = m_pFlyFrame->GetFormat()->GetURL();
1253  return rURL.GetMap() || !rURL.GetURL().isEmpty();
1254 }
1255 
1257 {
1258  const SwFormatURL &rURL = m_pFlyFrame->GetFormat()->GetURL();
1259  if( rURL.GetMap() || !rURL.GetURL().isEmpty() )
1260  {
1261  SwRect aRect;
1262  if ( m_pFlyFrame->Lower() && m_pFlyFrame->Lower()->IsNoTextFrame() )
1263  {
1264  aRect = m_pFlyFrame->getFramePrintArea();
1265  aRect += m_pFlyFrame->getFrameArea().Pos();
1266  }
1267  else
1268  aRect = m_pFlyFrame->getFrameArea();
1269 
1270  if( aRect.IsInside( rRec.aPos ) )
1271  {
1272  aRect.Pos().setX(aRect.Pos().getX() + rRec.nTol);
1273  aRect.Pos().setY(aRect.Pos().getY() + rRec.nTol);
1274  aRect.AddHeight( -(2 * rRec.nTol) );
1275  aRect.AddWidth( -(2 * rRec.nTol) );
1276 
1277  if( aRect.IsInside( rRec.aPos ) )
1278  {
1279  if( !rURL.GetMap() ||
1281  return const_cast<SwVirtFlyDrawObj*>(this);
1282 
1283  return nullptr;
1284  }
1285  }
1286  }
1287  return SdrObject::CheckMacroHit( rRec );
1288 }
1289 
1291 {
1293 }
1294 
1295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:338
Point TopLeft() const
constexpr TypedWhichId< SwCropGrf > RES_GRFATR_CROPGRF(132)
Base class of the Writer layout elements.
Definition: frame.hxx:297
void expand(const B2DTuple &rTuple)
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:195
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2852
const basegfx::B2DRange & getViewport() const
SdrObjUserCall * pUserCall
virtual void addCropHandles(SdrHdlList &rTarget) const override
Definition: dflyobj.cxx:1199
B2DTuple absolute(const B2DTuple &rTup)
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
virtual long GetRotateAngle() const override
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
tools::Long getWidth() const
virtual void get2DDecomposition(Primitive2DDecompositionVisitor &rVisitor, const geometry::ViewInformation2D &rViewInformation) const override
basegfx::B2DRange getInnerBound() const
Definition: dflyobj.cxx:333
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
void setSwRect(const SwRect &rNew)
Definition: frame.hxx:196
#define MINFLY
Definition: swtypes.hxx:65
SwTwips GetPos() const
Definition: fmtornt.hxx:92
long Long
virtual SdrObjectUniquePtr getFullDragClone() const override
Definition: dflyobj.cxx:1183
const SwRect & getFramePrintArea() const
Definition: frame.hxx:178
static SwCache & GetCache()
Definition: frame.hxx:502
void SetRect() const
Definition: dflyobj.cxx:549
double getX() const
sal_uInt16 GetValue() const
double getY() const
tools::Long GetWidth() const
SdrInventor
void Pos(const Point &rNew)
Definition: swrect.hxx:169
RotateFlyFrame3: Helper class when you want to make your SwFrame derivate transformable.
Definition: frame.hxx:233
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
const Size & GetUnrotatedSize() const
Definition: grfatr.hxx:108
bool IsRecord() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
bool IsSizeProtected() const
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3902
static bool bInResize
Definition: dflyobj.cxx:71
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
void EndAllAction()
Definition: edws.cxx:97
virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const
Definition: wsfrm.cxx:122
sal_Int32 GetBrowseWidth() const
Definition: viewsh.cxx:2002
bool ContainsSwGrfNode() const
Definition: dflyobj.cxx:357
const MapMode & getPrePostMapMode() const
Definition: viewsh.hxx:227
static OutputDevice * GetDefaultDevice()
virtual SdrObject * CheckMacroHit(const SdrObjMacroHitRec &rRec) const
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
tools::Long getHeight() const
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
sal_uInt16 CalcLeftLine() const
Definition: frmtool.hxx:511
tools::Long Left() const
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
SdrPage * getSdrPageFromSdrObject() const
void restoreFrameAreas()
Definition: wsfrm.cxx:266
const SwRect & getFrameArea() const
Definition: frame.hxx:177
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool getBrowseMode() const
Definition: viewopt.hxx:461
#define PRIMITIVE2D_ID_SWVIRTFLYDRAWOBJPRIMITIVE2D
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:450
basegfx::B2DRange getOuterBound() const
Definition: dflyobj.cxx:309
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
virtual ~SwFlyDrawObj() override
Definition: dflyobj.cxx:132
tools::Long Bottom() const
void Width(tools::Long nNew)
Definition: swrect.hxx:187
bool OnRightPage() const
Definition: frame.hxx:713
Size GetPrefSize() const
const SdrObject & GetReferencedObj() const
virtual ~SwVirtFlyDrawObj() override
Definition: dflyobj.cxx:431
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:193
virtual bool HasMacro() const override
Definition: dflyobj.cxx:1250
virtual sal_uInt16 GetObjIdentifier() const override
Definition: dflyobj.cxx:142
B2IRange fround(const B2DRange &rRange)
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect)
const SwVirtFlyDrawObj & mrSwVirtFlyDrawObj
Definition: dflyobj.cxx:155
MapMode GetPrefMapMode() const
SwVirtFlyDrawObj(SdrModel &rSdrModel, SdrObject &rNew, SwFlyFrame *pFly)
Definition: dflyobj.cxx:419
bool IsColumnFrame() const
Definition: frame.hxx:1160
virtual PointerStyle GetMacroPointer(const SdrObjMacroHitRec &rRec) const override
Definition: dflyobj.cxx:1244
bool isEmpty() const
virtual void RecalcSnapRect() override
Definition: dflyobj.cxx:573
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:611
void ResizeRect(tools::Rectangle &rRect, const Point &rRef, const Fraction &rxFact, const Fraction &ryFact)
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: dflyobj.cxx:964
Style of a layout element.
Definition: frmfmt.hxx:57
void wrap_DoPaintObject(drawinglayer::geometry::ViewInformation2D const &) const
Definition: dflyobj.cxx:491
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:165
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: dflyobj.cxx:113
const SwColumns & GetColumns() const
Definition: fmtclds.hxx:112
const SwRect & VisArea() const
Definition: viewsh.cxx:560
virtual SdrInventor GetObjInventor() const override
Definition: dflyobj.cxx:137
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: dflyobj.cxx:615
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
SwPageFrame * FindPageFrame()
Definition: frame.hxx:660
tools::Rectangle aOutRect
const SwFrame * Lower() const
Definition: layfrm.hxx:101
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:112
void BroadcastObjectChange() const
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
const sal_uInt16 SwFlyDrawObjIdentifier
Definition: dflyobj.hxx:31
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:337
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: dflyobj.cxx:533
const GraphicObject * GetGraphicObj() const
Definition: editsh.cxx:257
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true) override
Definition: dflyobj.cxx:1131
const SwFormatURL & GetURL(bool=true) const
Definition: fmturl.hxx:78
SwLayoutFrame * GetUpper()
Definition: frame.hxx:658
bool HasArea() const
Definition: swrect.hxx:288
void AddHeight(const tools::Long nAdd)
Definition: swrect.cxx:161
virtual SdrObject * CheckMacroHit(const SdrObjMacroHitRec &rRec) const override
Definition: dflyobj.cxx:1256
void scale(double fX, double fY)
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
sal_uInt32 GetOrdNum() const
const SwAttrSet & GetAttrSet() const
Definition: frmtool.hxx:383
void AddWidth(const tools::Long nAdd)
Definition: swrect.cxx:160
sal_uInt16 getPossibleRotationFromFraphicFrame(Size &rSize) const
Definition: dflyobj.cxx:1147
MapUnit GetMapUnit() const
virtual void NbcCrop(const basegfx::B2DPoint &rRef, double fxFact, double fyFact) override
Definition: dflyobj.cxx:790
const SwRotationGrf & GetRotationGrf(bool=true) const
Definition: grfatr.hxx:284
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
void SSize(const Size &rNew)
Definition: swrect.hxx:178
tools::Long Top() const
virtual SdrObject * RemoveObject(size_t nObjNum)
virtual void Move(const Size &rSiz) override
Definition: dflyobj.cxx:1124
SwBorderAttrs * Get()
Definition: frmtool.cxx:2560
IMapObject * GetIMapObject(const Point &rPoint, const SwFlyFrame *pFly=nullptr) const
Definition: atrfrm.cxx:3491
virtual void Rotate(const Point &rRef, long nAngle, double sn, double cs) override
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
virtual tools::Long GetRotateAngle() const override
Definition: dflyobj.cxx:1170
Point PixelToLogic(const Point &rDevicePt) const
bool IsPause() const
const ImageMap * GetMap() const
Definition: fmturl.hxx:68
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:460
virtual void DoDrawUndo(bool const bDoUndo)=0
Enable/Disable Undo for Drawing objects.
SwFlyFrame * m_pFlyFrame
Definition: dflyobj.hxx:64
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
virtual const tools::Rectangle & GetLogicRect() const override
Definition: dflyobj.cxx:599
ImplPrimitive2DIDBlock(OverlayStaticRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYRECTANGLEPRIMITIVE) OverlayBitmapExPrimitive
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
bool IsPosToggle() const
Definition: fmtornt.hxx:95
const SwContentNode * GetNode() const
Definition: notxtfrm.hxx:66
SwFlyFrame * GetFlyFrame()
Definition: dflyobj.hxx:130
bool bSizProt
bool IsVertLR() const
Definition: frame.hxx:957
constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
tools::Rectangle SVRect() const
Definition: swrect.hxx:280
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
unsigned char sal_uInt8
SwPageFrame * GetPageFrame()
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
SwTwips GetPos() const
Definition: fmtornt.hxx:59
virtual const tools::Rectangle & GetLastBoundRect() const override
Definition: dflyobj.cxx:563
virtual void SetLogicRect(const tools::Rectangle &rRect) override
Definition: dflyobj.cxx:605
B2DHomMatrix createRotateAroundPoint(double fPointX, double fPointY, double fRadiant)
virtual Size ChgSize(const Size &aNewSize) override
Definition: fly.cxx:2101
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
bool IsNoTextFrame() const
Definition: frame.hxx:1216
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
bool bMovProt
bool IsRightToLeft() const
Definition: frame.hxx:965
virtual void Crop(const basegfx::B2DPoint &rRef, double fxFact, double fyFact) override
Definition: dflyobj.cxx:1139
tools::Long Height() const
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: dflyobj.cxx:594
const Size & GetBrowseBorder() const
Definition: viewsh.cxx:1997
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
virtual void Rotate(const Point &rRef, tools::Long nAngle, double sn, double cs) override
Definition: dflyobj.cxx:381
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: dflyobj.cxx:412
void translate(double fX, double fY)
static bool IsPaint(SdrObject *pObj, const SwViewShell *pSh)
Definition: paintfrm.cxx:3796
PointerStyle
virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const override
Definition: dflyobj.cxx:620
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:176
constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:722
SwFlyDrawObj(SdrModel &rSdrModel)
Definition: dflyobj.cxx:126
tools::Long GetHeight() const
virtual const tools::Rectangle & GetSnapRect() const override
Definition: dflyobj.cxx:578
const basegfx::B2DRange maOuterRange
Definition: dflyobj.cxx:156
virtual void RecalcBoundRect() override
Definition: dflyobj.cxx:568
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
bool IsVertical() const
Definition: frame.hxx:951
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: dflyobj.cxx:119
void SetRotation(sal_uInt16 nOld, sal_uInt16 nNew, const Size &rUnrotatedSize)
Definition: frmmgr.cxx:586
const SvxProtectItem & GetProtect(bool=true) const
Definition: frmatr.hxx:82
const SwFrame * GetAnchorFrame() const
virtual SdrObjectUniquePtr getFullDragClone() const override
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:153
virtual bool HasLimitedRotation() const override
Definition: dflyobj.cxx:374
virtual void SetChanged()
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool IsBodyFrame() const
Definition: frame.hxx:1184
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:205
void ChgRelPos(const Point &rAbsPos)
Change the relative position.
Definition: fly.cxx:1103
void Height(tools::Long nNew)
Definition: swrect.hxx:191
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
bool IsDrawingLayerPaintInProgress() const
Definition: viewsh.hxx:239
virtual void NbcMove(const Size &rSiz) override
Definition: dflyobj.cxx:632
virtual void SetSnapRect(const tools::Rectangle &rRect) override
Definition: dflyobj.cxx:584
tools::Long Right() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:659
virtual bool IsTextBox() const override
Definition: dflyobj.cxx:1290
const SwFrameFormat * GetFormat() const
Definition: dflyobj.cxx:437
Point Center() const
void AddHdl(std::unique_ptr< SdrHdl > pHdl)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1315
bool IsPosProtected() const
const OUString & GetURL() const
Definition: fmturl.hxx:66
sal_uInt16 CalcRightLine() const
Definition: frmtool.hxx:517
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: dflyobj.cxx:557
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo