LibreOffice Module svx (master)  1
svddrgmt.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 "svddrgm1.hxx"
21 #include <math.h>
22 
23 #include <o3tl/numeric.hxx>
24 #include <vcl/canvastools.hxx>
25 #include <vcl/svapp.hxx>
26 #include <vcl/settings.hxx>
27 #include <vcl/ptrstyle.hxx>
28 #include <svx/xpoly.hxx>
29 #include <svx/svdtrans.hxx>
30 #include <svx/svdundo.hxx>
31 #include <svx/svdmark.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <svx/svddrgv.hxx>
34 #include <svx/svdograf.hxx>
35 #include <svx/strings.hrc>
36 #include <svx/dialmgr.hxx>
37 #include <svx/sdgcpitm.hxx>
38 #include <svx/sdooitm.hxx>
39 #include <svx/sdtagitm.hxx>
44 #include <svx/sdrpagewindow.hxx>
45 #include <svx/sdrpaintwindow.hxx>
52 #include <svx/svditer.hxx>
53 #include <svx/svdopath.hxx>
66 #include <svl/itempool.hxx>
68 #include <comphelper/lok.hxx>
69 #include <map>
70 #include <vector>
71 
72 
74 : mbAddToTransparent(false)
75 {
76 }
77 
79 {
80 }
81 
82 
84 : SdrDragEntry(),
85  maOriginalPolyPolygon(rOriginalPolyPolygon)
86 {
87 }
88 
90 {
91 }
92 
94 {
96 
98  {
100 
101  rDragMethod.applyCurrentTransformationToPolyPolygon(aCopy);
104  const double fStripeLength(SvtOptionsDrawinglayer::GetStripeLength());
105 
106  if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
107  {
109  aColB.invert();
110  }
111 
112  aRetval.resize(2);
114  aCopy,
115  aColA,
116  aColB,
117  fStripeLength);
118 
119  const basegfx::BColor aHilightColor(SvtOptionsDrawinglayer::getHilightColor().getBColor());
120  const double fTransparence(SvtOptionsDrawinglayer::GetTransparentSelectionPercent() * 0.01);
121 
123  aCopy,
124  aHilightColor,
125  fTransparence,
126  3.0,
127  false);
128  }
129 
130  return aRetval;
131 }
132 
133 
135  const SdrObject& rOriginal,
136  bool bModify)
137 : SdrDragEntry(),
138  maOriginal(rOriginal),
139  mbModify(bModify)
140 {
141  // add SdrObject parts to transparent overlay stuff
142  setAddToTransparent(true);
143 }
144 
146 {
147 }
148 
150 {
151  // for the moment, i need to re-create the clone in all cases. I need to figure
152  // out when clone and original have the same class, so that i can use operator=
153  // in those cases
154 
155  mxClone.reset();
156 
157  if(mbModify)
158  {
160 
161  // apply original transformation, implemented at the DragMethods
163  }
164 }
165 
167 {
168  const SdrObject* pSource = &maOriginal;
169 
170  if(mbModify && mxClone)
171  {
172  // choose source for geometry data
173  pSource = mxClone.get();
174  }
175 
176  // use the view-independent primitive representation (without
177  // evtl. GridOffset, that may be applied to the DragEntry individually)
179 }
180 
181 
184 : SdrDragEntry(),
185  maPrimitive2DSequence(rSequence)
186 {
187  // add parts to transparent overlay stuff if necessary
188  setAddToTransparent(true);
189 }
190 
192 {
193 }
194 
196 {
199  rDragMethod.getCurrentTransformation(),
201 
202  return drawinglayer::primitive2d::Primitive2DContainer { aTransformPrimitive2D };
203 }
204 
205 
206 SdrDragEntryPointGlueDrag::SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag)
207 : maPositions(rPositions),
208  mbIsPointDrag(bIsPointDrag)
209 {
210  // add SdrObject parts to transparent overlay stuff
211  setAddToTransparent(true);
212 }
213 
215 {
216 }
217 
219 {
221 
222  if(!maPositions.empty())
223  {
224  basegfx::B2DPolygon aPolygon;
225 
226  for(auto const & a: maPositions)
227  {
228  aPolygon.append(a);
229  }
230 
231  basegfx::B2DPolyPolygon aPolyPolygon(aPolygon);
232 
233  rDragMethod.applyCurrentTransformationToPolyPolygon(aPolyPolygon);
234 
235  const basegfx::B2DPolygon aTransformed(aPolyPolygon.getB2DPolygon(0));
236  std::vector< basegfx::B2DPoint > aTransformedPositions;
237 
238  aTransformedPositions.reserve(aTransformed.count());
239 
240  for(sal_uInt32 a = 0; a < aTransformed.count(); a++)
241  {
242  aTransformedPositions.push_back(aTransformed.getB2DPoint(a));
243  }
244 
245  if(mbIsPointDrag)
246  {
248 
249  if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
250  {
252  }
253 
254  drawinglayer::primitive2d::Primitive2DReference aMarkerArrayPrimitive2D(
255  new drawinglayer::primitive2d::MarkerArrayPrimitive2D(aTransformedPositions,
257 
258  aRetval = drawinglayer::primitive2d::Primitive2DContainer { aMarkerArrayPrimitive2D };
259  }
260  else
261  {
262  drawinglayer::primitive2d::Primitive2DReference aMarkerArrayPrimitive2D(
263  new drawinglayer::primitive2d::MarkerArrayPrimitive2D(aTransformedPositions,
265  aRetval = drawinglayer::primitive2d::Primitive2DContainer { aMarkerArrayPrimitive2D };
266  }
267  }
268 
269  return aRetval;
270 }
271 
272 
274 {
275  // clear entries; creation is on demand
277 }
278 
280 {
282 }
283 
285 {
286  maSdrDragEntries.clear();
287 }
288 
289 void SdrDragMethod::addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew)
290 {
291  assert(pNew);
292  maSdrDragEntries.push_back(std::move(pNew));
293 }
294 
296 {
297  if(!(getSdrDragView().GetSdrPageView() && getSdrDragView().GetSdrPageView()->HasMarkedObjPageView()))
298  return;
299 
301  {
303  }
305  {
307  }
308  else
309  {
311  {
313  }
314  else
315  {
317  }
318  }
319 }
320 
322 {
323  // add full object drag; Clone() at the object has to work
324  // for this
325  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(rOriginal, true/*bModify*/)));
326 }
327 
329  std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject,
330  const sdr::contact::ObjectContact& rObjectContact,
331  sdr::overlay::OverlayManager& rOverlayManager)
332 {
333  // check if we have an OverlayObject
334  if(!pOverlayObject)
335  {
336  return;
337  }
338 
339  // add to OverlayManager
340  rOverlayManager.add(*pOverlayObject);
341 
342  // Add GridOffset for non-linear ViewToDevice transformation (calc)
343  if(rObjectContact.supportsGridOffsets())
344  {
345  const basegfx::B2DRange& rNewRange(pOverlayObject->getBaseRange());
346 
347  if(!rNewRange.isEmpty())
348  {
349  basegfx::B2DVector aOffset(0.0, 0.0);
350  rObjectContact.calculateGridOffsetForB2DRange(aOffset, rNewRange);
351 
352  if(!aOffset.equalZero())
353  {
354  pOverlayObject->setOffset(aOffset);
355  }
356  }
357  }
358 
359  // add to local OverlayObjectList - ownership change (!)
360  maOverlayObjectList.append(std::move(pOverlayObject));
361 }
362 
364 {
365  const size_t nMarkCount(getSdrDragView().GetMarkedObjectCount());
367 
368  if(!pPV)
369  return;
370 
371  for(size_t a = 0; a < nMarkCount; ++a)
372  {
374 
375  if(pM->GetPageView() == pPV)
376  {
377  const SdrObject* pObject = pM->GetMarkedSdrObj();
378 
379  if(pObject)
380  {
381  if(pPV->PageWindowCount())
382  {
383  SdrObjListIter aIter(*pObject);
384 
385  while(aIter.IsMore())
386  {
387  SdrObject* pCandidate = aIter.Next();
388 
389  if(pCandidate)
390  {
391  const bool bSuppressFullDrag(!pCandidate->supportsFullDrag());
392  bool bAddWireframe(bSuppressFullDrag);
393 
394  if(!bAddWireframe && !pCandidate->HasLineStyle())
395  {
396  // add wireframe for objects without outline
397  bAddWireframe = true;
398  }
399 
400  if(!bSuppressFullDrag)
401  {
402  // add full object drag; Clone() at the object has to work
403  // for this
404  createSdrDragEntryForSdrObject(*pCandidate);
405  }
406 
407  if(bAddWireframe)
408  {
409  // when dragging a 50% transparent copy of a filled or not filled object without
410  // outline, this is normally hard to see. Add extra wireframe in that case. This
411  // works nice e.g. with text frames etc.
412  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly())));
413  }
414  }
415  }
416  }
417  }
418  }
419  }
420 }
421 
423 {
424  const size_t nMarkCount(getSdrDragView().GetMarkedObjectCount());
425  bool bNoPolygons(getSdrDragView().IsNoDragXorPolys() || nMarkCount > SdrDragView::GetDragXorPolyLimit());
426  basegfx::B2DPolyPolygon aResult;
427  sal_uInt32 nPointCount(0);
428 
429  for(size_t a = 0; !bNoPolygons && a < nMarkCount; ++a)
430  {
432 
433  if(pM->GetPageView() == getSdrDragView().GetSdrPageView())
434  {
435  const basegfx::B2DPolyPolygon aNewPolyPolygon(pM->GetMarkedSdrObj()->TakeXorPoly());
436 
437  for(auto const& rPolygon : aNewPolyPolygon)
438  {
439  nPointCount += rPolygon.count();
440  }
441 
442  if(nPointCount > SdrDragView::GetDragXorPointLimit())
443  {
444  bNoPolygons = true;
445  }
446 
447  if(!bNoPolygons)
448  {
449  aResult.append(aNewPolyPolygon);
450  }
451  }
452  }
453 
454  if(bNoPolygons)
455  {
456  const tools::Rectangle aR(getSdrDragView().GetSdrPageView()->MarkSnap());
459 
461  }
462 
463  if(aResult.count())
464  {
465  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aResult)));
466  }
467 }
468 
470 {
471  const size_t nMarkCount(getSdrDragView().GetMarkedObjectCount());
472  std::vector< basegfx::B2DPoint > aPositions;
473 
474  for(size_t nm = 0; nm < nMarkCount; ++nm)
475  {
477 
478  if(pM->GetPageView() == getSdrDragView().GetSdrPageView())
479  {
480  const SdrUShortCont& rPts = pM->GetMarkedPoints();
481 
482  if (!rPts.empty())
483  {
484  const SdrObject* pObj = pM->GetMarkedSdrObj();
485  const SdrPathObj* pPath = dynamic_cast< const SdrPathObj* >(pObj);
486 
487  if(pPath)
488  {
489  const basegfx::B2DPolyPolygon& aPathXPP = pPath->GetPathPoly();
490 
491  if(aPathXPP.count())
492  {
493  for(const sal_uInt16 nObjPt : rPts)
494  {
495  sal_uInt32 nPolyNum, nPointNum;
496 
497  if(sdr::PolyPolygonEditor::GetRelativePolyPoint(aPathXPP, nObjPt, nPolyNum, nPointNum))
498  {
499  aPositions.push_back(aPathXPP.getB2DPolygon(nPolyNum).getB2DPoint(nPointNum));
500  }
501  }
502  }
503  }
504  }
505  }
506  }
507 
508  if(!aPositions.empty())
509  {
510  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPointGlueDrag(aPositions, true)));
511  }
512 }
513 
515 {
516  const size_t nMarkCount(getSdrDragView().GetMarkedObjectCount());
517  std::vector< basegfx::B2DPoint > aPositions;
518 
519  for(size_t nm = 0; nm < nMarkCount; ++nm)
520  {
522 
523  if(pM->GetPageView() == getSdrDragView().GetSdrPageView())
524  {
525  const SdrUShortCont& rPts = pM->GetMarkedGluePoints();
526 
527  if (!rPts.empty())
528  {
529  const SdrObject* pObj = pM->GetMarkedSdrObj();
530  const SdrGluePointList* pGPL = pObj->GetGluePointList();
531 
532  if (pGPL)
533  {
534  for(const sal_uInt16 nObjPt : rPts)
535  {
536  const sal_uInt16 nGlueNum(pGPL->FindGluePoint(nObjPt));
537 
538  if(SDRGLUEPOINT_NOTFOUND != nGlueNum)
539  {
540  const Point aPoint((*pGPL)[nGlueNum].GetAbsolutePos(*pObj));
541  aPositions.emplace_back(aPoint.X(), aPoint.Y());
542  }
543  }
544  }
545  }
546  }
547  }
548 
549  if(!aPositions.empty())
550  {
551  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPointGlueDrag(aPositions, false)));
552  }
553 }
554 
555 OUString SdrDragMethod::ImpGetDescriptionStr(const char* pStrCacheID) const
556 {
558  if (IsDraggingPoints()) {
560  } else if (IsDraggingGluePoints()) {
562  }
563  return getSdrDragView().ImpGetDescriptionString(pStrCacheID, nOpt);
564 }
565 
567 {
568  SdrObject* pObj=nullptr;
569  if (getSdrDragView().mpDragHdl!=nullptr) pObj=getSdrDragView().mpDragHdl->GetObj();
570  if (pObj==nullptr) pObj=getSdrDragView().mpMarkedObj;
571  return pObj;
572 }
573 
575 {
576  SdrPageView* pPV=nullptr;
577  if (getSdrDragView().mpDragHdl!=nullptr) pPV=getSdrDragView().mpDragHdl->GetPageView();
578  if (pPV==nullptr) pPV=getSdrDragView().mpMarkedPV;
579  return pPV;
580 }
581 
583 {
584  // the original applies the transformation using TRGetBaseGeometry/TRSetBaseGeometry.
585  // Later this should be the only needed one for linear transforms (not for SdrDragCrook and
586  // SdrDragDistort, those are NOT linear). Currently, this can not yet be used since the
587  // special handling of rotate/mirror due to the not-being-able to handle it in the old
588  // drawinglayer stuff. Text would currently not correctly be mirrored in the preview.
589  basegfx::B2DHomMatrix aObjectTransform;
590  basegfx::B2DPolyPolygon aObjectPolyPolygon;
591  bool bPolyUsed(rTarget.TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon));
592 
593  // apply transform to object transform
594  aObjectTransform *= getCurrentTransformation();
595 
596  if(bPolyUsed)
597  {
598  // do something special since the object size is in the polygon
599  // break up matrix to get the scale
600  const basegfx::utils::B2DHomMatrixBufferedDecompose aTmpDecomp(aObjectTransform);
601 
602  // get polygon's position and size
603  const basegfx::B2DRange aPolyRange(aObjectPolyPolygon.getB2DRange());
604 
605  // get the scaling factors (do not mirror, this is in the object transformation)
606  const double fScaleX(fabs(aTmpDecomp.getScale().getX()) / (basegfx::fTools::equalZero(aPolyRange.getWidth()) ? 1.0 : aPolyRange.getWidth()));
607  const double fScaleY(fabs(aTmpDecomp.getScale().getY()) / (basegfx::fTools::equalZero(aPolyRange.getHeight()) ? 1.0 : aPolyRange.getHeight()));
608 
609  // prepare transform matrix for polygon
610  basegfx::B2DHomMatrix aPolyTransform(
612  -aPolyRange.getMinX(),
613  -aPolyRange.getMinY()));
614  aPolyTransform.scale(fScaleX, fScaleY);
615 
616  // transform the polygon
617  aObjectPolyPolygon.transform(aPolyTransform);
618  }
619 
620  rTarget.TRSetBaseGeometry(getCurrentTransformation() * aObjectTransform, aObjectPolyPolygon);
621 }
622 
624 {
625  // original uses CurrentTransformation
627 }
628 
630 : maSdrDragEntries(),
631  maOverlayObjectList(),
632  mrSdrDragView(rNewView),
633  mbMoveOnly(false),
634  mbSolidDraggingActive(getSdrDragView().IsSolidDragging()),
635  mbShiftPressed(false)
636 {
637  if(mbSolidDraggingActive && Application::GetSettings().GetStyleSettings().GetHighContrastMode())
638  {
639  // fallback to wireframe when high contrast is used
640  mbSolidDraggingActive = false;
641  }
642 }
643 
645 {
647 }
648 
650 {
652 }
653 
655 {
657 }
658 
660 {
661  return basegfx::B2DHomMatrix();
662 }
663 
665 {
666  Hide();
667 }
668 
669 typedef std::map< const SdrObject*, SdrObject* > SdrObjectAndCloneMap;
670 
672  sdr::overlay::OverlayManager& rOverlayManager,
673  const sdr::contact::ObjectContact& rObjectContact)
674 {
675  // We do client-side object manipulation with the Kit API
677  return;
678 
679  // create SdrDragEntries on demand
680  if(maSdrDragEntries.empty())
681  {
683  }
684 
685  // if there are entries, derive OverlayObjects from the entries, including
686  // modification from current interactive state
687  if(!maSdrDragEntries.empty())
688  {
689  // #i54102# SdrDragEntrySdrObject creates clones of SdrObjects as base for creating the needed
690  // primitives, holding the original and the clone. If connectors (Edges) are involved,
691  // the cloned connectors need to be connected to the cloned SdrObjects (after cloning
692  // they are connected to the original SdrObjects). To do so, trigger the preparation
693  // steps for SdrDragEntrySdrObject, save an association of (orig, clone) in a helper
694  // and evtl. remember if it was an edge
695  SdrObjectAndCloneMap aOriginalAndClones;
696  std::vector< SdrEdgeObj* > aEdges;
697 
698  // #i54102# execute prepareCurrentState for all SdrDragEntrySdrObject, register pair of original and
699  // clone, remember edges
700  for(auto const & a: maSdrDragEntries)
701  {
702  SdrDragEntrySdrObject* pSdrDragEntrySdrObject = dynamic_cast< SdrDragEntrySdrObject*>(a.get());
703 
704  if(pSdrDragEntrySdrObject)
705  {
706  pSdrDragEntrySdrObject->prepareCurrentState(*this);
707 
708  SdrEdgeObj* pSdrEdgeObj = dynamic_cast< SdrEdgeObj* >(pSdrDragEntrySdrObject->getClone());
709 
710  if(pSdrEdgeObj)
711  {
712  aEdges.push_back(pSdrEdgeObj);
713  }
714 
715  if(pSdrDragEntrySdrObject->getClone())
716  {
717  aOriginalAndClones[&pSdrDragEntrySdrObject->getOriginal()] = pSdrDragEntrySdrObject->getClone();
718  }
719  }
720  }
721 
722  // #i54102# if there are edges, reconnect their ends to the corresponding clones (if found)
723  for(SdrEdgeObj* pSdrEdgeObj: aEdges)
724  {
725  SdrObject* pConnectedTo = pSdrEdgeObj->GetConnectedNode(true);
726 
727  if(pConnectedTo)
728  {
729  SdrObjectAndCloneMap::iterator aEntry = aOriginalAndClones.find(pConnectedTo);
730 
731  if(aEntry != aOriginalAndClones.end())
732  {
733  pSdrEdgeObj->ConnectToNode(true, aEntry->second);
734  }
735  }
736 
737  pConnectedTo = pSdrEdgeObj->GetConnectedNode(false);
738 
739  if(pConnectedTo)
740  {
741  SdrObjectAndCloneMap::iterator aEntry = aOriginalAndClones.find(pConnectedTo);
742 
743  if(aEntry != aOriginalAndClones.end())
744  {
745  pSdrEdgeObj->ConnectToNode(false, aEntry->second);
746  }
747  }
748  }
749 
750  // collect primitives for visualisation
753 
754  for(auto & pCandidate: maSdrDragEntries)
755  {
756  const drawinglayer::primitive2d::Primitive2DContainer aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this));
757 
758  if(!aCandidateResult.empty())
759  {
760  if(pCandidate->getAddToTransparent())
761  {
762  aResultTransparent.append(aCandidateResult);
763  }
764  else
765  {
766  aResult.append(aCandidateResult);
767  }
768  }
769  }
770 
772  {
774 
775  if(!aConnectorOverlays.empty())
776  {
777  // add connector overlays to transparent part
778  aResultTransparent.append(aConnectorOverlays);
779  }
780  }
781 
782  if(!aResult.empty())
783  {
784  std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(
786  aResult));
787 
789  std::move(pNewOverlayObject),
790  rObjectContact,
791  rOverlayManager);
792  }
793 
794  if(!aResultTransparent.empty())
795  {
796  drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparencePrimitive2D(new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(aResultTransparent, 0.5));
797  aResultTransparent = drawinglayer::primitive2d::Primitive2DContainer { aUnifiedTransparencePrimitive2D };
798 
799  std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(
801  aResultTransparent));
802 
804  std::move(pNewOverlayObject),
805  rObjectContact,
806  rOverlayManager);
807  }
808  }
809 
810  // add DragStripes if necessary (help lines cross the page when dragging)
811  if(!getSdrDragView().IsDragStripes())
812  return;
813 
814  tools::Rectangle aActionRectangle;
815  getSdrDragView().TakeActionRect(aActionRectangle);
816 
817  const basegfx::B2DPoint aTopLeft(aActionRectangle.Left(), aActionRectangle.Top());
818  const basegfx::B2DPoint aBottomRight(aActionRectangle.Right(), aActionRectangle.Bottom());
819  std::unique_ptr<sdr::overlay::OverlayRollingRectangleStriped> pNew(
821  aTopLeft,
822  aBottomRight,
823  true,
824  false));
825 
827  std::move(pNew),
828  rObjectContact,
829  rOverlayManager);
830 }
831 
833 {
835 }
836 
838 {
839  // these conditions are translated from SdrDragView::ImpDrawEdgeXor
840  const SdrMarkList& rMarkedNodes = getSdrDragView().GetEdgesOfMarkedNodes();
841 
842  if(!rMarkedNodes.GetMarkCount())
843  {
844  return false;
845  }
846 
848  {
849  return false;
850  }
851 
852  if(!getMoveOnly() && !(
853  dynamic_cast<const SdrDragMove*>(this) != nullptr || dynamic_cast<const SdrDragResize*>(this) != nullptr ||
854  dynamic_cast<const SdrDragRotate*>(this) != nullptr || dynamic_cast<const SdrDragMirror*>(this) != nullptr ))
855  {
856  return false;
857  }
858 
859  // one more migrated from SdrEdgeObj::NspToggleEdgeXor
860  if( dynamic_cast< const SdrDragObjOwn* >(this) != nullptr || dynamic_cast< const SdrDragMovHdl* >(this) != nullptr )
861  {
862  return false;
863  }
864 
865  return true;
866 }
867 
869 {
871  const bool bDetail(getMoveOnly());
872  const SdrMarkList& rMarkedNodes = getSdrDragView().GetEdgesOfMarkedNodes();
873 
874  for(size_t a = 0; a < rMarkedNodes.GetMarkCount(); ++a)
875  {
876  SdrMark* pEM = rMarkedNodes.GetMark(a);
877 
878  if(pEM && pEM->GetMarkedSdrObj())
879  {
880  SdrEdgeObj* pEdge = dynamic_cast< SdrEdgeObj* >(pEM->GetMarkedSdrObj());
881 
882  if(pEdge)
883  {
884  const basegfx::B2DPolygon aEdgePolygon(pEdge->ImplAddConnectorOverlay(*this, pEM->IsCon1(), pEM->IsCon2(), bDetail));
885 
886  if(aEdgePolygon.count())
887  {
888  // this polygon is a temporary calculated connector path, so it is not possible to fetch
889  // the needed primitives directly from the pEdge object which does not get changed. If full
890  // drag is on, use the SdrObjects ItemSet to create an adequate representation
891  bool bUseSolidDragging(getSolidDraggingActive());
892 
893  if(bUseSolidDragging)
894  {
895  // switch off solid dragging if connector is not visible
896  if(!pEdge->HasLineStyle())
897  {
898  bUseSolidDragging = false;
899  }
900  }
901 
902  if(bUseSolidDragging)
903  {
904  const SfxItemSet& rItemSet = pEdge->GetMergedItemSet();
907 
908  if(!aLine.isDefault())
909  {
912  rItemSet,
913  aLine.getWidth()));
914 
916  aEdgePolygon,
917  aLine,
918  aLineStartEnd));
919  }
920  }
921  else
922  {
925  const double fStripeLength(SvtOptionsDrawinglayer::GetStripeLength());
926 
927  if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
928  {
930  aColB.invert();
931  }
932 
933  drawinglayer::primitive2d::Primitive2DReference aPolyPolygonMarkerPrimitive2D(
935  aEdgePolygon, aColA, aColB, fStripeLength));
936  aRetval.push_back(aPolyPolygonMarkerPrimitive2D);
937  }
938  }
939  }
940  }
941  }
942 
943  return aRetval;
944 }
945 
946 
948 : SdrDragMethod(rNewView)
949 {
950 }
951 
953 {
954  // SdrDragMovHdl does not use the default drags,
955  // but creates nothing
956 }
957 
959 {
960  OUString aStr=SvxResId(STR_DragMethMovHdl);
961  if (getSdrDragView().IsDragWithCopy()) aStr+=SvxResId(STR_EditWithCopy);
962  return aStr;
963 }
964 
966 {
967  if( !GetDragHdl() )
968  return false;
969 
970  DragStat().SetRef1(GetDragHdl()->GetPos());
971  DragStat().SetShown(!DragStat().IsShown());
972  SdrHdlKind eKind=GetDragHdl()->GetKind();
975 
976  if (eKind==SdrHdlKind::MirrorAxis)
977  {
978  if (pH1==nullptr || pH2==nullptr)
979  {
980  OSL_FAIL("SdrDragMovHdl::BeginSdrDrag(): Moving the axis of reflection: reference handles not found.");
981  return false;
982  }
983 
985  }
986  else
987  {
988  Point aPt(GetDragHdl()->GetPos());
990  }
991 
992  return true;
993 }
994 
995 void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt)
996 {
997  Point aPnt(rNoSnapPnt);
998 
999  if ( !(GetDragHdl() && DragStat().CheckMinMoved(rNoSnapPnt)))
1000  return;
1001 
1002  if (GetDragHdl()->GetKind()==SdrHdlKind::MirrorAxis)
1003  {
1006 
1007  if (pH1==nullptr || pH2==nullptr)
1008  return;
1009 
1010  if (!DragStat().IsNoSnap())
1011  {
1012  tools::Long nBestXSnap=0;
1013  tools::Long nBestYSnap=0;
1014  bool bXSnapped=false;
1015  bool bYSnapped=false;
1016  Point aDif(aPnt-DragStat().GetStart());
1017  getSdrDragView().CheckSnap(Ref1()+aDif,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
1018  getSdrDragView().CheckSnap(Ref2()+aDif,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
1019  aPnt.AdjustX(nBestXSnap );
1020  aPnt.AdjustY(nBestYSnap );
1021  }
1022 
1023  if (aPnt!=DragStat().GetNow())
1024  {
1025  Hide();
1026  DragStat().NextMove(aPnt);
1027  Point aDif(DragStat().GetNow()-DragStat().GetStart());
1028  pH1->SetPos(Ref1()+aDif);
1029  pH2->SetPos(Ref2()+aDif);
1030 
1032 
1033  if(pHM)
1034  pHM->Touch();
1035 
1036  Show();
1038  }
1039  }
1040  else
1041  {
1042  if (!DragStat().IsNoSnap()) SnapPos(aPnt);
1043  Degree100 nSA(0);
1044 
1045  if (getSdrDragView().IsAngleSnapEnabled())
1046  nSA=getSdrDragView().GetSnapAngle();
1047 
1048  if (getSdrDragView().IsMirrorAllowed(true,true))
1049  { // limited
1050  if (!getSdrDragView().IsMirrorAllowed()) nSA=4500_deg100;
1051  if (!getSdrDragView().IsMirrorAllowed(true)) nSA=9000_deg100;
1052  }
1053 
1054  if (getSdrDragView().IsOrtho() && nSA!=9000_deg100)
1055  nSA=4500_deg100;
1056 
1057  if (nSA)
1058  { // angle snapping
1060 
1061  if (GetDragHdl()->GetKind()==SdrHdlKind::Ref1)
1062  eRef=SdrHdlKind::Ref2;
1063 
1064  SdrHdl* pH=GetHdlList().GetHdl(eRef);
1065 
1066  if (pH!=nullptr)
1067  {
1068  Point aRef(pH->GetPos());
1069  Degree100 nAngle=NormAngle36000(GetAngle(aPnt-aRef));
1070  Degree100 nNewAngle=nAngle;
1071  nNewAngle+=nSA/2_deg100;
1072  nNewAngle/=nSA;
1073  nNewAngle*=nSA;
1074  nNewAngle=NormAngle36000(nNewAngle);
1075  double a=(nNewAngle-nAngle).get()*F_PI18000;
1076  double nSin=sin(a);
1077  double nCos=cos(a);
1078  RotatePoint(aPnt,aRef,nSin,nCos);
1079 
1080  // eliminate rounding errors for certain values
1081  if (nSA==9000_deg100)
1082  {
1083  if (nNewAngle==0_deg100 || nNewAngle==18000_deg100) aPnt.setY(aRef.Y() );
1084  if (nNewAngle==9000_deg100 || nNewAngle==27000_deg100) aPnt.setX(aRef.X() );
1085  }
1086 
1087  if (nSA==4500_deg100)
1088  OrthoDistance8(aRef,aPnt,true);
1089  }
1090  }
1091 
1092  if (aPnt!=DragStat().GetNow())
1093  {
1094  Hide();
1095  DragStat().NextMove(aPnt);
1096  GetDragHdl()->SetPos(DragStat().GetNow());
1098 
1099  if(pHM)
1100  pHM->Touch();
1101 
1102  Show();
1103  DragStat().SetActionRect(tools::Rectangle(aPnt,aPnt));
1104  }
1105  }
1106 }
1107 
1108 bool SdrDragMovHdl::EndSdrDrag(bool /*bCopy*/)
1109 {
1110  if( GetDragHdl() )
1111  {
1112  switch (GetDragHdl()->GetKind())
1113  {
1114  case SdrHdlKind::Ref1:
1115  Ref1()=DragStat().GetNow();
1116  break;
1117 
1118  case SdrHdlKind::Ref2:
1119  Ref2()=DragStat().GetNow();
1120  break;
1121 
1123  Ref1()+=DragStat().GetNow()-DragStat().GetStart();
1124  Ref2()+=DragStat().GetNow()-DragStat().GetStart();
1125  break;
1126 
1127  default: break;
1128  }
1129  }
1130 
1131  return true;
1132 }
1133 
1135 {
1136  Hide();
1137 
1138  SdrHdl* pHdl = GetDragHdl();
1139  if( pHdl )
1140  pHdl->SetPos(DragStat().GetRef1());
1141 
1143 
1144  if(pHM)
1145  pHM->Touch();
1146 }
1147 
1149 {
1150  const SdrHdl* pHdl = GetDragHdl();
1151 
1152  if (pHdl!=nullptr)
1153  {
1154  return pHdl->GetPointer();
1155  }
1156 
1157  return PointerStyle::RefHand;
1158 }
1159 
1160 
1162 : SdrDragMethod(rNewView)
1163 {
1164  const SdrObject* pObj = GetDragObj();
1165 
1166  if(pObj)
1167  {
1168  // suppress full drag for some object types
1170  }
1171 }
1172 
1174 {
1175 }
1176 
1178 {
1179  if(!mxClone)
1180  return;
1181 
1182  basegfx::B2DPolyPolygon aDragPolyPolygon;
1183  bool bAddWireframe(true);
1184 
1186  {
1188 
1189  if(pPV && pPV->PageWindowCount())
1190  {
1191  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(*mxClone, false)));
1192 
1193  // potentially no wireframe needed, full drag works
1194  bAddWireframe = false;
1195  }
1196  }
1197 
1198  if(!bAddWireframe)
1199  {
1200  // check for extra conditions for wireframe, e.g. no border at
1201  // objects
1202  if(!mxClone->HasLineStyle())
1203  {
1204  bAddWireframe = true;
1205  }
1206  }
1207 
1208  if(bAddWireframe)
1209  {
1210  // use wireframe poly when full drag is off or did not work
1211  aDragPolyPolygon = mxClone->TakeXorPoly();
1212  }
1213 
1214  // add evtl. extra DragPolyPolygon
1215  const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mxClone->getSpecialDragPoly(DragStat()));
1216 
1217  if(aSpecialDragPolyPolygon.count())
1218  {
1219  aDragPolyPolygon.append(aSpecialDragPolyPolygon);
1220  }
1221 
1222  if(aDragPolyPolygon.count())
1223  {
1224  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragPolyPolygon)));
1225  }
1226 }
1227 
1229 {
1230  OUString aStr;
1231  // #i103058# get info string from the clone preferred, the original will
1232  // not be changed. For security, use original as fallback
1233  if(mxClone)
1234  {
1235  aStr = mxClone->getSpecialDragComment(DragStat());
1236  }
1237  else
1238  {
1239  const SdrObject* pObj = GetDragObj();
1240 
1241  if(pObj)
1242  {
1243  aStr = pObj->getSpecialDragComment(DragStat());
1244  }
1245  }
1246  return aStr;
1247 }
1248 
1250 {
1251  if(!mxClone)
1252  {
1253  const SdrObject* pObj = GetDragObj();
1254 
1255  if(pObj && !pObj->IsResizeProtect())
1256  {
1257  if(pObj->beginSpecialDrag(DragStat()))
1258  {
1259  // create initial clone to have a start visualization
1260  mxClone = pObj->getFullDragClone();
1261  mxClone->applySpecialDrag(DragStat());
1262 
1263  return true;
1264  }
1265  }
1266  }
1267 
1268  return false;
1269 }
1270 
1271 void SdrDragObjOwn::MoveSdrDrag(const Point& rNoSnapPnt)
1272 {
1273  const SdrObject* pObj = GetDragObj();
1274 
1275  if (!pObj)
1276  // No object to drag. Bail out.
1277  return;
1278 
1279  Point aPnt(rNoSnapPnt);
1280  SdrPageView* pPV = GetDragPV();
1281 
1282  if (!pPV)
1283  // No page view available. Bail out.
1284  return;
1285 
1286  if(!DragStat().IsNoSnap())
1287  {
1288  SnapPos(aPnt);
1289  }
1290  if(getSdrDragView().IsOrtho())
1291  {
1292  if (DragStat().IsOrtho8Possible())
1293  {
1294  OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
1295  }
1296  else if (DragStat().IsOrtho4Possible())
1297  {
1298  OrthoDistance4(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
1299  }
1300  }
1301 
1302  if (!DragStat().CheckMinMoved(rNoSnapPnt))
1303  // Not moved by the minimum threshold. Nothing to do.
1304  return;
1305 
1306  Hide();
1307  DragStat().NextMove(aPnt);
1308 
1309  // since SdrDragObjOwn currently supports no transformation of
1310  // existing SdrDragEntries but only their recreation, a recreation
1311  // after every move is needed in this mode. Delete existing
1312  // SdrDragEntries here to force their recreation in the following Show().
1314 
1315  // delete current clone (after the last reference to it is deleted above)
1316  mxClone.reset();
1317 
1318  // create a new clone and modify to current drag state
1319  mxClone = pObj->getFullDragClone();
1320  mxClone->applySpecialDrag(DragStat());
1321 
1322  // AutoGrowWidth may change for SdrTextObj due to the automatism used
1323  // with bDisableAutoWidthOnDragging, so not only geometry changes but
1324  // also this (pretty indirect) property change is possible. If it gets
1325  // changed, it needs to be copied to the original since nothing will
1326  // happen when it only changes in the drag clone
1327  const bool bOldAutoGrowWidth(pObj->GetMergedItem(SDRATTR_TEXT_AUTOGROWWIDTH).GetValue());
1328  const bool bNewAutoGrowWidth(mxClone->GetMergedItem(SDRATTR_TEXT_AUTOGROWWIDTH).GetValue());
1329 
1330  if (bOldAutoGrowWidth != bNewAutoGrowWidth)
1331  {
1332  GetDragObj()->SetMergedItem(makeSdrTextAutoGrowWidthItem(bNewAutoGrowWidth));
1333  }
1334 
1335  Show();
1336 }
1337 
1338 bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/)
1339 {
1340  Hide();
1341  std::vector< std::unique_ptr<SdrUndoAction> > vConnectorUndoActions;
1342  bool bRet = false;
1343  SdrObject* pObj = GetDragObj();
1344 
1345  if(pObj)
1346  {
1347  std::unique_ptr<SdrUndoAction> pUndo;
1348  std::unique_ptr<SdrUndoAction> pUndo2;
1349  const bool bUndo = getSdrDragView().IsUndoEnabled();
1350 
1351  if( bUndo )
1352  {
1354  if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() )
1355  {
1357  {
1359 
1360  if (DragStat().IsEndDragChangesGeoAndAttributes())
1361  {
1362  vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj );
1364  }
1365  }
1366  else
1367  {
1368  vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj );
1370  }
1371  }
1372 
1373  if( pUndo )
1374  {
1375  getSdrDragView().BegUndo( pUndo->GetComment() );
1376  }
1377  else
1378  {
1379  getSdrDragView().BegUndo();
1380  }
1381  }
1382 
1383  // Maybe use operator = for setting changed object data (do not change selection in
1384  // view, this will destroy the interactor). This is possible since a clone is now
1385  // directly modified by the modifiers. Only SdrTableObj is adding own UNDOs
1386  // in its SdrTableObj::endSpecialDrag, so currently not possible. OTOH it uses
1387  // a CreateUndoGeoObject(), so maybe setting SetEndDragChangesAttributes is okay. I
1388  // will test this now
1389  tools::Rectangle aBoundRect0;
1390 
1391  if(pObj->GetUserCall())
1392  {
1393  aBoundRect0 = pObj->GetLastBoundRect();
1394  }
1395 
1396  bRet = pObj->applySpecialDrag(DragStat());
1397  if (DragStat().IsEndDragChangesLayout())
1398  {
1399  auto pGeoUndo = dynamic_cast<SdrUndoGeoObj*>(pUndo.get());
1400  if (pGeoUndo)
1401  pGeoUndo->SetSkipChangeLayout(true);
1402  }
1403 
1404  if(bRet)
1405  {
1406  pObj->SetChanged();
1407  pObj->BroadcastObjectChange();
1408  pObj->SendUserCall( SdrUserCallType::Resize, aBoundRect0 );
1409  }
1410 
1411  if(bRet && bUndo )
1412  {
1413  getSdrDragView().AddUndoActions( std::move(vConnectorUndoActions) );
1414 
1415  if ( pUndo )
1416  {
1417  getSdrDragView().AddUndo(std::move(pUndo));
1418  }
1419 
1420  if ( pUndo2 )
1421  {
1422  getSdrDragView().AddUndo(std::move(pUndo2));
1423  }
1424  }
1425 
1426  if( bUndo )
1427  getSdrDragView().EndUndo();
1428  }
1429 
1430  return bRet;
1431 }
1432 
1434 {
1435  const SdrHdl* pHdl=GetDragHdl();
1436 
1437  if (pHdl)
1438  {
1439  return pHdl->GetPointer();
1440  }
1441 
1442  return PointerStyle::Move;
1443 }
1444 
1445 
1447 {
1448  // use the view-independent primitive representation (without
1449  // evtl. GridOffset, that may be applied to the DragEntry individually)
1451  std::unique_ptr<SdrDragEntry>(
1454 
1455 }
1456 
1458 {
1459  rTarget.Move(Size(DragStat().GetDX(), DragStat().GetDY()));
1460 }
1461 
1463  : SdrDragMethod(rNewView)
1464  , nBestXSnap(0)
1465  , nBestYSnap(0)
1466  , bXSnapped(false)
1467  , bYSnapped(false)
1468 {
1469  setMoveOnly(true);
1470 }
1471 
1473 {
1474  OUString aStr = ImpGetDescriptionStr(STR_DragMethMove)
1475  + " (x="
1477  + " y="
1479  + ")";
1480 
1481  if(getSdrDragView().IsDragWithCopy())
1482  {
1483  if(!getSdrDragView().IsInsObjPoint() && !getSdrDragView().IsInsGluePoint())
1484  {
1485  aStr += SvxResId(STR_EditWithCopy);
1486  }
1487  }
1488  return aStr;
1489 }
1490 
1492 {
1494  Show();
1495 
1496  return true;
1497 }
1498 
1500 {
1501  return basegfx::utils::createTranslateB2DHomMatrix(DragStat().GetDX(), DragStat().GetDY());
1502 }
1503 
1504 void SdrDragMove::ImpCheckSnap(const Point& rPt)
1505 {
1506  Point aPt(rPt);
1507  SdrSnap nRet=SnapPos(aPt);
1508  aPt-=rPt;
1509 
1510  if (nRet & SdrSnap::XSNAPPED)
1511  {
1512  if (bXSnapped)
1513  {
1514  if (std::abs(aPt.X())<std::abs(nBestXSnap))
1515  {
1516  nBestXSnap=aPt.X();
1517  }
1518  }
1519  else
1520  {
1521  nBestXSnap=aPt.X();
1522  bXSnapped=true;
1523  }
1524  }
1525 
1526  if (!(nRet & SdrSnap::YSNAPPED))
1527  return;
1528 
1529  if (bYSnapped)
1530  {
1531  if (std::abs(aPt.Y())<std::abs(nBestYSnap))
1532  {
1533  nBestYSnap=aPt.Y();
1534  }
1535  }
1536  else
1537  {
1538  nBestYSnap=aPt.Y();
1539  bYSnapped=true;
1540  }
1541 }
1542 
1543 void SdrDragMove::MoveSdrDrag(const Point& rNoSnapPnt_)
1544 {
1545  nBestXSnap=0;
1546  nBestYSnap=0;
1547  bXSnapped=false;
1548  bYSnapped=false;
1549  Point aNoSnapPnt(rNoSnapPnt_);
1550  const tools::Rectangle& aSR=GetMarkedRect();
1551  tools::Long nMovedx=aNoSnapPnt.X()-DragStat().GetStart().X();
1552  tools::Long nMovedy=aNoSnapPnt.Y()-DragStat().GetStart().Y();
1553  Point aLO(aSR.TopLeft()); aLO.AdjustX(nMovedx ); aLO.AdjustY(nMovedy );
1554  Point aRU(aSR.BottomRight()); aRU.AdjustX(nMovedx ); aRU.AdjustY(nMovedy );
1555  Point aLU(aLO.X(),aRU.Y());
1556  Point aRO(aRU.X(),aLO.Y());
1557  ImpCheckSnap(aLO);
1558 
1559  if (!getSdrDragView().IsMoveSnapOnlyTopLeft())
1560  {
1561  ImpCheckSnap(aRO);
1562  ImpCheckSnap(aLU);
1563  ImpCheckSnap(aRU);
1564  }
1565 
1566  Point aPnt(aNoSnapPnt.X()+nBestXSnap,aNoSnapPnt.Y()+nBestYSnap);
1567  bool bOrtho=getSdrDragView().IsOrtho();
1568 
1569  if (bOrtho)
1570  OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
1571 
1572  if (!DragStat().CheckMinMoved(aNoSnapPnt))
1573  return;
1574 
1575  Point aPt1(aPnt);
1576  tools::Rectangle aLR(getSdrDragView().GetWorkArea());
1577  bool bWorkArea=!aLR.IsEmpty();
1578  bool bDragLimit=IsDragLimit();
1579 
1580  if (bDragLimit || bWorkArea)
1581  {
1583  Point aD(aPt1-DragStat().GetStart());
1584 
1585  if (bDragLimit)
1586  {
1588 
1589  if (bWorkArea)
1590  aLR.Intersection(aR2);
1591  else
1592  aLR=aR2;
1593  }
1594 
1595  if (aSR2.Left()>aLR.Left() || aSR2.Right()<aLR.Right())
1596  { // any space to move to?
1597  aSR2.Move(aD.X(),0);
1598 
1599  if (aSR2.Left()<aLR.Left())
1600  {
1601  aPt1.AdjustX( -(aSR2.Left()-aLR.Left()) );
1602  }
1603  else if (aSR2.Right()>aLR.Right())
1604  {
1605  aPt1.AdjustX( -(aSR2.Right()-aLR.Right()) );
1606  }
1607  }
1608  else
1609  aPt1.setX(DragStat().GetStart().X() ); // no space to move to
1610 
1611  if (aSR2.Top()>aLR.Top() || aSR2.Bottom()<aLR.Bottom())
1612  { // any space to move to?
1613  aSR2.Move(0,aD.Y());
1614 
1615  if (aSR2.Top()<aLR.Top())
1616  {
1617  aPt1.AdjustY( -(aSR2.Top()-aLR.Top()) );
1618  }
1619  else if (aSR2.Bottom()>aLR.Bottom())
1620  {
1621  aPt1.AdjustY( -(aSR2.Bottom()-aLR.Bottom()) );
1622  }
1623  }
1624  else
1625  aPt1.setY(DragStat().GetStart().Y() ); // no space to move to
1626  }
1627 
1629  { // restrict glue points to the BoundRect of the Obj
1630  aPt1-=DragStat().GetStart();
1631  const SdrMarkList& rML=GetMarkedObjectList();
1632  const size_t nMarkCount=rML.GetMarkCount();
1633 
1634  for (size_t nMarkNum=0; nMarkNum<nMarkCount; ++nMarkNum)
1635  {
1636  const SdrMark* pM=rML.GetMark(nMarkNum);
1637  const SdrUShortCont& rPts = pM->GetMarkedGluePoints();
1638 
1639  if (!rPts.empty())
1640  {
1641  const SdrObject* pObj=pM->GetMarkedSdrObj();
1642  const SdrGluePointList* pGPL=pObj->GetGluePointList();
1643  tools::Rectangle aBound(pObj->GetCurrentBoundRect());
1644 
1645  for (sal_uInt16 nId : rPts)
1646  {
1647  sal_uInt16 nGlueNum=pGPL->FindGluePoint(nId);
1648 
1649  if (nGlueNum!=SDRGLUEPOINT_NOTFOUND)
1650  {
1651  Point aPt((*pGPL)[nGlueNum].GetAbsolutePos(*pObj));
1652  aPt+=aPt1; // move by this much
1653  if (aPt.X()<aBound.Left() ) aPt1.AdjustX( -(aPt.X()-aBound.Left()) ) ;
1654  if (aPt.X()>aBound.Right() ) aPt1.AdjustX( -(aPt.X()-aBound.Right()) ) ;
1655  if (aPt.Y()<aBound.Top() ) aPt1.AdjustY( -(aPt.Y()-aBound.Top()) ) ;
1656  if (aPt.Y()>aBound.Bottom()) aPt1.AdjustY( -(aPt.Y()-aBound.Bottom()) );
1657  }
1658  }
1659  }
1660  }
1661 
1662  aPt1+=DragStat().GetStart();
1663  }
1664 
1665  if (bOrtho)
1666  OrthoDistance8(DragStat().GetStart(),aPt1,false);
1667 
1668  if (aPt1!=DragStat().GetNow())
1669  {
1670  Hide();
1671  DragStat().NextMove(aPt1);
1672  tools::Rectangle aAction(GetMarkedRect());
1673  aAction.Move(DragStat().GetDX(),DragStat().GetDY());
1674  DragStat().SetActionRect(aAction);
1675  Show();
1676  }
1677 }
1678 
1679 bool SdrDragMove::EndSdrDrag(bool bCopy)
1680 {
1681  Hide();
1682 
1683  if (getSdrDragView().IsInsObjPoint() || getSdrDragView().IsInsGluePoint())
1684  bCopy=false;
1685 
1686  if (IsDraggingPoints())
1687  {
1688  getSdrDragView().MoveMarkedPoints(Size(DragStat().GetDX(),DragStat().GetDY()));
1689  }
1690  else if (IsDraggingGluePoints())
1691  {
1692  getSdrDragView().MoveMarkedGluePoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy);
1693  }
1694  else
1695  {
1696  getSdrDragView().MoveMarkedObj(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy);
1697  }
1698 
1699  return true;
1700 }
1701 
1703 {
1705  {
1706  return PointerStyle::MovePoint;
1707  }
1708  else
1709  {
1710  return PointerStyle::Move;
1711  }
1712 }
1713 
1714 
1716 : SdrDragMethod(rNewView),
1717  aXFact(1,1),
1718  aYFact(1,1)
1719 {
1720 }
1721 
1723 {
1724  OUString aStr = ImpGetDescriptionStr(STR_DragMethResize);
1725  Fraction aFact1(1,1);
1726  Point aStart(DragStat().GetStart());
1727  Point aRef(DragStat().GetRef1());
1728  sal_Int32 nXDiv(aStart.X() - aRef.X());
1729 
1730  if(!nXDiv)
1731  nXDiv = 1;
1732 
1733  sal_Int32 nYDiv(aStart.Y() - aRef.Y());
1734 
1735  if(!nYDiv)
1736  nYDiv = 1;
1737 
1738  bool bX(aXFact != aFact1 && std::abs(nXDiv) > 1);
1739  bool bY(aYFact != aFact1 && std::abs(nYDiv) > 1);
1740 
1741  if(bX || bY)
1742  {
1743  aStr += " (";
1744 
1745  bool bEqual(aXFact == aYFact);
1746  if(bX)
1747  {
1748  if(!bEqual)
1749  aStr += "x=";
1750 
1752  }
1753 
1754  if(bY && !bEqual)
1755  {
1756  if(bX)
1757  aStr += " ";
1758 
1759  aStr += "y=" + SdrModel::GetPercentString(aYFact);
1760  }
1761 
1762  aStr += ")";
1763  }
1764 
1765  if(getSdrDragView().IsDragWithCopy())
1766  aStr += SvxResId(STR_EditWithCopy);
1767  return aStr;
1768 }
1769 
1771 {
1772  SdrHdlKind eRefHdl=SdrHdlKind::Move;
1773  SdrHdl* pRefHdl=nullptr;
1774 
1775  switch (GetDragHdlKind())
1776  {
1777  case SdrHdlKind::UpperLeft: eRefHdl=SdrHdlKind::LowerRight; break;
1778  case SdrHdlKind::Upper: eRefHdl=SdrHdlKind::Lower; DragStat().SetHorFixed(true); break;
1779  case SdrHdlKind::UpperRight: eRefHdl=SdrHdlKind::LowerLeft; break;
1780  case SdrHdlKind::Left : eRefHdl=SdrHdlKind::Right; DragStat().SetVerFixed(true); break;
1781  case SdrHdlKind::Right: eRefHdl=SdrHdlKind::Left ; DragStat().SetVerFixed(true); break;
1782  case SdrHdlKind::LowerLeft: eRefHdl=SdrHdlKind::UpperRight; break;
1783  case SdrHdlKind::Lower: eRefHdl=SdrHdlKind::Upper; DragStat().SetHorFixed(true); break;
1784  case SdrHdlKind::LowerRight: eRefHdl=SdrHdlKind::UpperLeft; break;
1785  default: break;
1786  }
1787 
1788  if (eRefHdl!=SdrHdlKind::Move)
1789  pRefHdl=GetHdlList().GetHdl(eRefHdl);
1790 
1791  if (pRefHdl!=nullptr && !getSdrDragView().IsResizeAtCenter())
1792  {
1793  DragStat().SetRef1(pRefHdl->GetPos());
1794  }
1795  else
1796  {
1799 
1800  if (pRef1!=nullptr && pRef2!=nullptr)
1801  {
1802  DragStat().SetRef1(tools::Rectangle(pRef1->GetPos(),pRef2->GetPos()).Center());
1803  }
1804  else
1805  {
1807  }
1808  }
1809 
1810  Show();
1811 
1812  return true;
1813 }
1814 
1816 {
1818  -DragStat().GetRef1().X(), -DragStat().GetRef1().Y()));
1819  aRetval.scale(double(aXFact), double(aYFact));
1820  aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y());
1821 
1822  return aRetval;
1823 }
1824 
1825 void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt)
1826 {
1827  Point aPnt(GetSnapPos(rNoSnapPnt));
1828  Point aStart(DragStat().GetStart());
1829  Point aRef(DragStat().GetRef1());
1830  Fraction aMaxFact(0x7FFFFFFF,1);
1831  tools::Rectangle aLR(getSdrDragView().GetWorkArea());
1832  bool bWorkArea=!aLR.IsEmpty();
1833  bool bDragLimit=IsDragLimit();
1834 
1835  if (bDragLimit || bWorkArea)
1836  {
1838 
1839  if (bDragLimit)
1840  {
1842 
1843  if (bWorkArea)
1844  aLR.Intersection(aR2);
1845  else
1846  aLR=aR2;
1847  }
1848 
1849  if (aPnt.X()<aLR.Left())
1850  aPnt.setX(aLR.Left() );
1851  else if (aPnt.X()>aLR.Right())
1852  aPnt.setX(aLR.Right() );
1853 
1854  if (aPnt.Y()<aLR.Top())
1855  aPnt.setY(aLR.Top() );
1856  else if (aPnt.Y()>aLR.Bottom())
1857  aPnt.setY(aLR.Bottom() );
1858 
1859  if (aRef.X()>aSR.Left())
1860  {
1861  Fraction aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left());
1862 
1863  if (aMax<aMaxFact)
1864  aMaxFact=aMax;
1865  }
1866 
1867  if (aRef.X()<aSR.Right())
1868  {
1869  Fraction aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X());
1870 
1871  if (aMax<aMaxFact)
1872  aMaxFact=aMax;
1873  }
1874 
1875  if (aRef.Y()>aSR.Top())
1876  {
1877  Fraction aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top());
1878 
1879  if (aMax<aMaxFact)
1880  aMaxFact=aMax;
1881  }
1882 
1883  if (aRef.Y()<aSR.Bottom())
1884  {
1885  Fraction aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y());
1886 
1887  if (aMax<aMaxFact)
1888  aMaxFact=aMax;
1889  }
1890  }
1891 
1892  tools::Long nXDiv=aStart.X()-aRef.X(); if (nXDiv==0) nXDiv=1;
1893  tools::Long nYDiv=aStart.Y()-aRef.Y(); if (nYDiv==0) nYDiv=1;
1894  tools::Long nXMul=aPnt.X()-aRef.X();
1895  tools::Long nYMul=aPnt.Y()-aRef.Y();
1896 
1897  if (nXDiv<0)
1898  {
1899  nXDiv=-nXDiv;
1900  nXMul=-nXMul;
1901  }
1902 
1903  if (nYDiv<0)
1904  {
1905  nYDiv=-nYDiv;
1906  nYMul=-nYMul;
1907  }
1908 
1909  bool bXNeg=nXMul<0; if (bXNeg) nXMul=-nXMul;
1910  bool bYNeg=nYMul<0; if (bYNeg) nYMul=-nYMul;
1911  bool bOrtho=getSdrDragView().IsOrtho() || !getSdrDragView().IsResizeAllowed();
1912 
1913  if (!DragStat().IsHorFixed() && !DragStat().IsVerFixed())
1914  {
1915  if (std::abs(nXDiv)<=1 || std::abs(nYDiv)<=1)
1916  bOrtho=false;
1917 
1918  if (bOrtho)
1919  {
1920  if ((Fraction(nXMul,nXDiv)>Fraction(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho())
1921  {
1922  nXMul=nYMul;
1923  nXDiv=nYDiv;
1924  }
1925  else
1926  {
1927  nYMul=nXMul;
1928  nYDiv=nXDiv;
1929  }
1930  }
1931  }
1932  else
1933  {
1934  if (bOrtho)
1935  {
1936  if (DragStat().IsHorFixed())
1937  {
1938  bXNeg=false;
1939  nXMul=nYMul;
1940  nXDiv=nYDiv;
1941  }
1942 
1943  if (DragStat().IsVerFixed())
1944  {
1945  bYNeg=false;
1946  nYMul=nXMul;
1947  nYDiv=nXDiv;
1948  }
1949  }
1950  else
1951  {
1952  if (DragStat().IsHorFixed())
1953  {
1954  bXNeg=false;
1955  nXMul=1;
1956  nXDiv=1;
1957  }
1958 
1959  if (DragStat().IsVerFixed())
1960  {
1961  bYNeg=false;
1962  nYMul=1;
1963  nYDiv=1;
1964  }
1965  }
1966  }
1967 
1968  Fraction aNewXFact(nXMul,nXDiv);
1969  Fraction aNewYFact(nYMul,nYDiv);
1970 
1971  if (bOrtho)
1972  {
1973  if (aNewXFact>aMaxFact)
1974  {
1975  aNewXFact=aMaxFact;
1976  aNewYFact=aMaxFact;
1977  }
1978 
1979  if (aNewYFact>aMaxFact)
1980  {
1981  aNewXFact=aMaxFact;
1982  aNewYFact=aMaxFact;
1983  }
1984  }
1985 
1986  if (bXNeg)
1987  aNewXFact=Fraction(-aNewXFact.GetNumerator(),aNewXFact.GetDenominator());
1988 
1989  if (bYNeg)
1990  aNewYFact=Fraction(-aNewYFact.GetNumerator(),aNewYFact.GetDenominator());
1991 
1992  if (DragStat().CheckMinMoved(aPnt))
1993  {
1994  if ((!DragStat().IsHorFixed() && aPnt.X()!=DragStat().GetNow().X()) ||
1995  (!DragStat().IsVerFixed() && aPnt.Y()!=DragStat().GetNow().Y()))
1996  {
1997  Hide();
1998  DragStat().NextMove(aPnt);
1999  aXFact=aNewXFact;
2000  aYFact=aNewYFact;
2001  Show();
2002  }
2003  }
2004 }
2005 
2007 {
2008  rTarget.Resize(DragStat().GetRef1(),aXFact,aYFact);
2009 }
2010 
2012 {
2013  Hide();
2014 
2015  if (IsDraggingPoints())
2016  {
2018  }
2019  else if (IsDraggingGluePoints())
2020  {
2022  }
2023  else
2024  {
2025  getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aXFact,aYFact,bCopy);
2026  }
2027 
2028  return true;
2029 }
2030 
2032 {
2033  const SdrHdl* pHdl=GetDragHdl();
2034 
2035  if (pHdl!=nullptr)
2036  {
2037  return pHdl->GetPointer();
2038  }
2039 
2040  return PointerStyle::Move;
2041 }
2042 
2043 
2045 {
2046  rTarget.Rotate(DragStat().GetRef1(), nAngle, nSin, nCos);
2047 }
2048 
2050 : SdrDragMethod(rNewView),
2051  nSin(0.0),
2052  nCos(1.0),
2053  nAngle0(0),
2054  nAngle(0),
2055  bRight(false)
2056 {
2057 }
2058 
2060 {
2061  OUString aStr = ImpGetDescriptionStr(STR_DragMethRotate) +
2062  " (";
2063  Degree100 nTmpAngle(NormAngle36000(nAngle));
2064 
2065  if(bRight && nAngle)
2066  {
2067  nTmpAngle -= 36000_deg100;
2068  }
2069 
2070  aStr += SdrModel::GetAngleString(nTmpAngle) + ")";
2071 
2072  if(getSdrDragView().IsDragWithCopy())
2073  aStr += SvxResId(STR_EditWithCopy);
2074  return aStr;
2075 }
2076 
2078 {
2080 
2081  if (nullptr != pH)
2082  {
2083  Show();
2084  DragStat().SetRef1(pH->GetPos());
2085  nAngle0=GetAngle(DragStat().GetStart()-DragStat().GetRef1());
2086  return true;
2087  }
2088 
2089  // RotGrfFlyFrame: Support rotation around center *without* Ref1 (normally
2090  // the rotation point)
2091  const tools::Rectangle aLocalMarkRect(getSdrDragView().GetMarkedObjRect());
2092 
2093  if(!aLocalMarkRect.IsEmpty())
2094  {
2095  Show();
2096  DragStat().SetRef1(aLocalMarkRect.Center());
2097  nAngle0=GetAngle(DragStat().GetStart()-DragStat().GetRef1());
2098  return true;
2099  }
2100 
2101  OSL_FAIL("SdrDragRotate::BeginSdrDrag(): No reference point handle found.");
2102  return false;
2103 }
2104 
2106 {
2108  DragStat().GetRef1().X(), DragStat().GetRef1().Y(),
2109  -atan2(nSin, nCos));
2110 }
2111 
2112 void SdrDragRotate::MoveSdrDrag(const Point& rPnt_)
2113 {
2114  Point aPnt(rPnt_);
2115  if (!DragStat().CheckMinMoved(aPnt))
2116  return;
2117 
2118  Degree100 nNewAngle=NormAngle36000(GetAngle(aPnt-DragStat().GetRef1())-nAngle0);
2119  Degree100 nSA(0);
2120 
2121  if (getSdrDragView().IsAngleSnapEnabled())
2122  nSA=getSdrDragView().GetSnapAngle();
2123 
2124  if (!getSdrDragView().IsRotateAllowed())
2125  nSA=9000_deg100;
2126 
2127  if (nSA)
2128  { // angle snapping
2129  nNewAngle += nSA / 2_deg100;
2130  nNewAngle /= nSA;
2131  nNewAngle *= nSA;
2132  }
2133 
2134  nNewAngle=NormAngle18000(nNewAngle);
2135 
2136  if (nAngle==nNewAngle)
2137  return;
2138 
2139  sal_uInt16 nSekt0=GetAngleSector(nAngle);
2140  sal_uInt16 nSekt1=GetAngleSector(nNewAngle);
2141 
2142  if (nSekt0==0 && nSekt1==3)
2143  bRight=true;
2144 
2145  if (nSekt0==3 && nSekt1==0)
2146  bRight=false;
2147 
2148  nAngle=nNewAngle;
2149  double a = nAngle.get() * F_PI18000;
2150  double nSin1=sin(a); // calculate now, so as little time as possible
2151  double nCos1=cos(a); // passes between Hide() and Show()
2152  Hide();
2153  nSin=nSin1;
2154  nCos=nCos1;
2155  DragStat().NextMove(aPnt);
2156  Show();
2157 }
2158 
2160 {
2161  Hide();
2162 
2163  if (nAngle!=0_deg100)
2164  {
2165  if (IsDraggingPoints())
2166  {
2168  }
2169  else if (IsDraggingGluePoints())
2170  {
2172  }
2173  else
2174  {
2175  getSdrDragView().RotateMarkedObj(DragStat().GetRef1(),nAngle,bCopy);
2176  }
2177  }
2178  return true;
2179 }
2180 
2182 {
2183  return PointerStyle::Rotate;
2184 }
2185 
2186 
2187 SdrDragShear::SdrDragShear(SdrDragView& rNewView, bool bSlant1)
2188 : SdrDragMethod(rNewView),
2189  aFact(1,1),
2190  nAngle0(0),
2191  nAngle(0),
2192  nTan(0.0),
2193  bVertical(false),
2194  bResize(false),
2195  bUpSideDown(false),
2196  bSlant(bSlant1)
2197 {
2198 }
2199 
2201 {
2202  OUString aStr = ImpGetDescriptionStr(STR_DragMethShear) +
2203  " (";
2204 
2205  Degree100 nTmpAngle(nAngle);
2206 
2207  if(bUpSideDown)
2208  nTmpAngle += 18000_deg100;
2209 
2210  nTmpAngle = NormAngle18000(nTmpAngle);
2211 
2212  aStr += SdrModel::GetAngleString(nTmpAngle) + ")";
2213 
2214  if(getSdrDragView().IsDragWithCopy())
2215  aStr += SvxResId(STR_EditWithCopy);
2216  return aStr;
2217 }
2218 
2220 {
2221  SdrHdlKind eRefHdl=SdrHdlKind::Move;
2222  SdrHdl* pRefHdl=nullptr;
2223 
2224  switch (GetDragHdlKind())
2225  {
2226  case SdrHdlKind::Upper: eRefHdl=SdrHdlKind::Lower; break;
2227  case SdrHdlKind::Lower: eRefHdl=SdrHdlKind::Upper; break;
2228  case SdrHdlKind::Left : eRefHdl=SdrHdlKind::Right; bVertical=true; break;
2229  case SdrHdlKind::Right: eRefHdl=SdrHdlKind::Left ; bVertical=true; break;
2230  default: break;
2231  }
2232 
2233  if (eRefHdl!=SdrHdlKind::Move)
2234  pRefHdl=GetHdlList().GetHdl(eRefHdl);
2235 
2236  if (pRefHdl!=nullptr)
2237  {
2238  DragStat().SetRef1(pRefHdl->GetPos());
2239  nAngle0=GetAngle(DragStat().GetStart()-DragStat().GetRef1());
2240  }
2241  else
2242  {
2243  OSL_FAIL("SdrDragShear::BeginSdrDrag(): No reference point handle for shearing found.");
2244  return false;
2245  }
2246 
2247  Show();
2248  return true;
2249 }
2250 
2252 {
2254  -DragStat().GetRef1().X(), -DragStat().GetRef1().Y()));
2255 
2256  if (bResize)
2257  {
2258  if (bVertical)
2259  {
2260  aRetval.scale(double(aFact), 1.0);
2261  aRetval.shearY(-nTan);
2262  }
2263  else
2264  {
2265  aRetval.scale(1.0, double(aFact));
2266  aRetval.shearX(-nTan);
2267  }
2268  }
2269 
2270  aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y());
2271 
2272  return aRetval;
2273 }
2274 
2275 void SdrDragShear::MoveSdrDrag(const Point& rPnt)
2276 {
2277  if (!DragStat().CheckMinMoved(rPnt))
2278  return;
2279 
2281  Degree100 nSA(0);
2282 
2283  if (getSdrDragView().IsAngleSnapEnabled())
2284  nSA=getSdrDragView().GetSnapAngle();
2285 
2286  Point aP0(DragStat().GetStart());
2287  Point aPnt(rPnt);
2288  Fraction aNewFract(1,1);
2289 
2290  // if angle snapping not activated, snap to raster (except when using slant)
2291  if (nSA==0_deg100 && !bSlant)
2292  aPnt=GetSnapPos(aPnt);
2293 
2294  if (!bSlant && !bResize)
2295  { // shear, but no resize
2296  if (bVertical)
2297  aPnt.setX(aP0.X() );
2298  else
2299  aPnt.setY(aP0.Y() );
2300  }
2301 
2302  Point aRef(DragStat().GetRef1());
2303  Point aDif(aPnt-aRef);
2304 
2305  Degree100 nNewAngle(0);
2306 
2307  if (bSlant)
2308  {
2309  nNewAngle=NormAngle18000(-(GetAngle(aDif)-nAngle0));
2310 
2311  if (bVertical)
2312  nNewAngle=NormAngle18000(-nNewAngle);
2313  }
2314  else
2315  {
2316  if (bVertical)
2317  nNewAngle=NormAngle18000(GetAngle(aDif));
2318  else
2319  nNewAngle=NormAngle18000(-(GetAngle(aDif)-9000_deg100));
2320 
2321  if (nNewAngle<Degree100(-9000) || nNewAngle>9000_deg100)
2322  nNewAngle=NormAngle18000(nNewAngle+18000_deg100);
2323 
2324  if (bResize)
2325  {
2326  Point aPt2(aPnt);
2327 
2328  if (nSA!=0_deg100)
2329  aPt2=GetSnapPos(aPnt); // snap this one in any case
2330 
2331  if (bVertical)
2332  {
2333  aNewFract=Fraction(aPt2.X()-aRef.X(),aP0.X()-aRef.X());
2334  }
2335  else
2336  {
2337  aNewFract=Fraction(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y());
2338  }
2339  }
2340  }
2341 
2342  bool bNeg=nNewAngle<0_deg100;
2343 
2344  if (bNeg)
2345  nNewAngle=-nNewAngle;
2346 
2347  if (nSA)
2348  { // angle snapping
2349  nNewAngle += nSA / 2_deg100;
2350  nNewAngle /= nSA;
2351  nNewAngle *= nSA;
2352  }
2353 
2354  nNewAngle=NormAngle36000(nNewAngle);
2355  bUpSideDown=nNewAngle>9000_deg100 && nNewAngle<27000_deg100;
2356 
2357  if (bSlant)
2358  { // calculate resize for slant
2359  // when angle snapping is activated, disable 89 degree limit
2360  Degree100 nTmpAngle=nNewAngle;
2361  if (bUpSideDown) nNewAngle -= 18000_deg100;
2362  if (bNeg) nTmpAngle=-nTmpAngle;
2363  bResize=true;
2364  aNewFract = cos(nTmpAngle.get() * F_PI18000);
2365  aFact.ReduceInaccurate(10); // three decimals should be enough
2366  }
2367 
2368  if (nNewAngle > 8900_deg100)
2369  nNewAngle = 8900_deg100;
2370 
2371  if (bNeg)
2372  nNewAngle=-nNewAngle;
2373 
2374  if (nAngle!=nNewAngle || aFact!=aNewFract)
2375  {
2376  nAngle=nNewAngle;
2377  aFact=aNewFract;
2378  double a = nAngle.get() * F_PI18000;
2379  double nTan1=tan(a); // calculate now, so as little time as possible passes between Hide() and Show()
2380  Hide();
2381  nTan=nTan1;
2382  DragStat().NextMove(rPnt);
2383  Show();
2384  }
2385 }
2386 
2388 {
2389  if (bResize)
2390  {
2391  if (bVertical)
2392  {
2393  rTarget.Resize(DragStat().GetRef1(),aFact,Fraction(1,1));
2394  }
2395  else
2396  {
2397  rTarget.Resize(DragStat().GetRef1(),Fraction(1,1),aFact);
2398  }
2399  }
2400 
2401  if (nAngle)
2402  {
2403  rTarget.Shear(DragStat().GetRef1(), nAngle, nTan, bVertical);
2404  }
2405 }
2406 
2408 {
2409  Hide();
2410 
2411  if (bResize && aFact==Fraction(1,1))
2412  bResize=false;
2413 
2414  if (nAngle || bResize)
2415  {
2416  if (nAngle && bResize)
2417  {
2418  OUString aStr = ImpGetDescriptionStr(STR_EditShear);
2419 
2420  if (bCopy)
2421  aStr += SvxResId(STR_EditWithCopy);
2422 
2423  getSdrDragView().BegUndo(aStr);
2424  }
2425 
2426  if (bResize)
2427  {
2428  if (bVertical)
2429  {
2430  getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,Fraction(1,1),bCopy);
2431  }
2432  else
2433  {
2434  getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),Fraction(1,1),aFact,bCopy);
2435  }
2436 
2437  bCopy=false;
2438  }
2439 
2440  if (nAngle)
2441  {
2442  getSdrDragView().ShearMarkedObj(DragStat().GetRef1(),nAngle,bVertical,bCopy);
2443  }
2444 
2445  if (nAngle && bResize)
2446  getSdrDragView().EndUndo();
2447 
2448  return true;
2449  }
2450 
2451  return false;
2452 }
2453 
2455 {
2456  if (bVertical)
2457  return PointerStyle::VShear;
2458  else
2459  return PointerStyle::HShear;
2460 }
2461 
2462 
2464 {
2465  if(bMirrored)
2466  {
2467  rTarget.Mirror(DragStat().GetRef1(), DragStat().GetRef2());
2468  }
2469 }
2470 
2472 : SdrDragMethod(rNewView),
2473  nAngle(0),
2474  bMirrored(false),
2475  bSide0(false)
2476 {
2477 }
2478 
2479 bool SdrDragMirror::ImpCheckSide(const Point& rPnt) const
2480 {
2481  Degree100 nAngle1=GetAngle(rPnt-DragStat().GetRef1());
2482  nAngle1-=nAngle;
2483  nAngle1=NormAngle36000(nAngle1);
2484 
2485  return nAngle1<18000_deg100;
2486 }
2487 
2489 {
2490  OUString aStr;
2491  if (aDif.X()==0)
2492  aStr = ImpGetDescriptionStr(STR_DragMethMirrorHori);
2493  else if (aDif.Y()==0)
2494  aStr = ImpGetDescriptionStr(STR_DragMethMirrorVert);
2495  else if (std::abs(aDif.X()) == std::abs(aDif.Y()))
2496  aStr = ImpGetDescriptionStr(STR_DragMethMirrorDiag);
2497  else
2498  aStr = ImpGetDescriptionStr(STR_DragMethMirrorFree);
2499 
2500  if (getSdrDragView().IsDragWithCopy())
2501  aStr+=SvxResId(STR_EditWithCopy);
2502  return aStr;
2503 }
2504 
2506 {
2509 
2510  if (pH1!=nullptr && pH2!=nullptr)
2511  {
2512  DragStat().SetRef1(pH1->GetPos());
2513  DragStat().SetRef2(pH2->GetPos());
2514  Ref1()=pH1->GetPos();
2515  Ref2()=pH2->GetPos();
2516  aDif=pH2->GetPos()-pH1->GetPos();
2517  bool b90=(aDif.X()==0) || aDif.Y()==0;
2518  bool b45=b90 || (std::abs(aDif.X()) == std::abs(aDif.Y()));
2520 
2521  if (!getSdrDragView().IsMirrorAllowed() && !b45)
2522  return false; // free choice of axis angle not allowed
2523 
2524  if (!getSdrDragView().IsMirrorAllowed() && !b90)
2525  return false; // 45 degrees not allowed either
2526 
2527  bSide0=ImpCheckSide(DragStat().GetStart());
2528  Show();
2529  return true;
2530  }
2531  else
2532  {
2533  OSL_FAIL("SdrDragMirror::BeginSdrDrag(): Axis of reflection not found.");
2534  return false;
2535  }
2536 }
2537 
2539 {
2540  basegfx::B2DHomMatrix aRetval;
2541 
2542  if (bMirrored)
2543  {
2544  const double fDeltaX(DragStat().GetRef2().X() - DragStat().GetRef1().X());
2545  const double fDeltaY(DragStat().GetRef2().Y() - DragStat().GetRef1().Y());
2546  const double fRotation(atan2(fDeltaY, fDeltaX));
2547 
2548  aRetval = basegfx::utils::createTranslateB2DHomMatrix(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y());
2549  aRetval.rotate(-fRotation);
2550  aRetval.scale(1.0, -1.0);
2551  aRetval.rotate(fRotation);
2552  aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y());
2553  }
2554 
2555  return aRetval;
2556 }
2557 
2558 void SdrDragMirror::MoveSdrDrag(const Point& rPnt)
2559 {
2560  if (!DragStat().CheckMinMoved(rPnt))
2561  return;
2562 
2563  bool bNewSide=ImpCheckSide(rPnt);
2564  bool bNewMirrored=bSide0!=bNewSide;
2565 
2566  if (bMirrored!=bNewMirrored)
2567  {
2568  Hide();
2569  bMirrored=bNewMirrored;
2570  DragStat().NextMove(rPnt);
2571  Show();
2572  }
2573 }
2574 
2576 {
2577  Hide();
2578 
2579  if (bMirrored)
2580  {
2581  getSdrDragView().MirrorMarkedObj(DragStat().GetRef1(),DragStat().GetRef2(),bCopy);
2582  }
2583 
2584  return true;
2585 }
2586 
2588 {
2589  return PointerStyle::Mirror;
2590 }
2591 
2592 
2594 : SdrDragMethod(rNewView),
2595  pIAOHandle(nullptr),
2596  bIsGradient(bGrad)
2597 {
2598 }
2599 
2601 {
2602  if(IsGradient())
2603  return ImpGetDescriptionStr(STR_DragMethGradient);
2604  else
2605  return ImpGetDescriptionStr(STR_DragMethTransparence);
2606 }
2607 
2609 {
2610  bool bRetval(false);
2611 
2613 
2614  if(pIAOHandle)
2615  {
2616  // save old values
2619 
2620  // what was hit?
2621  bool bHit(false);
2622  SdrHdlColor* pColHdl = pIAOHandle->GetColorHdl1();
2623 
2624  // init handling flags
2627 
2628  // test first color handle
2629  if(pColHdl)
2630  {
2631  basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y());
2632 
2633  if(pColHdl->getOverlayObjectList().isHitLogic(aPosition))
2634  {
2635  bHit = true;
2638  }
2639  }
2640 
2641  // test second color handle
2642  pColHdl = pIAOHandle->GetColorHdl2();
2643 
2644  if(!bHit && pColHdl)
2645  {
2646  basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y());
2647 
2648  if(pColHdl->getOverlayObjectList().isHitLogic(aPosition))
2649  {
2650  bHit = true;
2652  }
2653  }
2654 
2655  // test gradient handle itself
2656  if(!bHit)
2657  {
2658  basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y());
2659 
2660  if(pIAOHandle->getOverlayObjectList().isHitLogic(aPosition))
2661  {
2662  bHit = true;
2663  }
2664  }
2665 
2666  // everything up and running :o}
2667  bRetval = bHit;
2668  }
2669  else
2670  {
2671  OSL_FAIL("SdrDragGradient::BeginSdrDrag(): IAOGradient not found.");
2672  }
2673 
2674  return bRetval;
2675 }
2676 
2677 void SdrDragGradient::MoveSdrDrag(const Point& rPnt)
2678 {
2679  if(!(pIAOHandle && DragStat().CheckMinMoved(rPnt)))
2680  return;
2681 
2682  DragStat().NextMove(rPnt);
2683 
2684  // Do the Move here!!! DragStat().GetStart()
2685  Point aMoveDiff = rPnt - DragStat().GetStart();
2686 
2688  {
2690  {
2691  pIAOHandle->SetPos(DragStat().GetRef1() + aMoveDiff);
2692  if(pIAOHandle->GetColorHdl1())
2693  pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1() + aMoveDiff);
2694  }
2695  else
2696  {
2697  pIAOHandle->Set2ndPos(DragStat().GetRef2() + aMoveDiff);
2698  if(pIAOHandle->GetColorHdl2())
2699  pIAOHandle->GetColorHdl2()->SetPos(DragStat().GetRef2() + aMoveDiff);
2700  }
2701  }
2702  else
2703  {
2704  pIAOHandle->SetPos(DragStat().GetRef1() + aMoveDiff);
2705  pIAOHandle->Set2ndPos(DragStat().GetRef2() + aMoveDiff);
2706 
2707  if(pIAOHandle->GetColorHdl1())
2708  pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1() + aMoveDiff);
2709 
2710  if(pIAOHandle->GetColorHdl2())
2711  pIAOHandle->GetColorHdl2()->SetPos(DragStat().GetRef2() + aMoveDiff);
2712  }
2713 
2714  // new state
2715  pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), false, false);
2716 }
2717 
2718 bool SdrDragGradient::EndSdrDrag(bool /*bCopy*/)
2719 {
2720  Ref1() = pIAOHandle->GetPos();
2721  Ref2() = pIAOHandle->Get2ndPos();
2722 
2723  // new state
2724  pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), true, true);
2725 
2726  return true;
2727 }
2728 
2730 {
2731  // restore old values
2732  pIAOHandle->SetPos(DragStat().GetRef1());
2733  pIAOHandle->Set2ndPos(DragStat().GetRef2());
2734 
2735  if(pIAOHandle->GetColorHdl1())
2736  pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1());
2737 
2738  if(pIAOHandle->GetColorHdl2())
2739  pIAOHandle->GetColorHdl2()->SetPos(DragStat().GetRef2());
2740 
2741  // new state
2742  pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), true, false);
2743 }
2744 
2746 {
2747  return PointerStyle::RefHand;
2748 }
2749 
2750 
2752 : SdrDragMethod(rNewView),
2753  aFact(1,1),
2754  bContortionAllowed(false),
2755  bNoContortionAllowed(false),
2756  bContortion(false),
2757  bResizeAllowed(false),
2758  bResize(false),
2759  bRotateAllowed(false),
2760  bRotate(false),
2761  bVertical(false),
2762  bValid(false),
2763  bLft(false),
2764  bRgt(false),
2765  bUpr(false),
2766  bLwr(false),
2767  bAtCenter(false),
2768  nAngle(0),
2769  nMarkSize(0),
2771 {
2772 }
2773 
2775 {
2776  OUString aStr = ImpGetDescriptionStr(!bContortion ? STR_DragMethCrook : STR_DragMethCrookContortion);
2777 
2778  if(bValid)
2779  {
2780  aStr += " (";
2781 
2782  sal_Int32 nVal(nAngle);
2783 
2784  if(bAtCenter)
2785  nVal *= 2;
2786 
2787  nVal = std::abs(nVal);
2788  aStr += SdrModel::GetAngleString(Degree100(nVal)) + ")";
2789  }
2790 
2791  if(getSdrDragView().IsDragWithCopy())
2792  aStr += SvxResId(STR_EditWithCopy);
2793  return aStr;
2794 }
2795 
2796 // These defines parametrize the created raster
2797 // for interactions
2798 #define DRAG_CROOK_RASTER_MINIMUM (4)
2799 #define DRAG_CROOK_RASTER_MAXIMUM (15)
2800 #define DRAG_CROOK_RASTER_DISTANCE (30)
2801 
2803 {
2804  basegfx::B2DPolyPolygon aRetval;
2805 
2806  if(rPageView.PageWindowCount())
2807  {
2808  OutputDevice& rOut = rPageView.GetPageWindow(0)->GetPaintWindow().GetOutputDevice();
2809  tools::Rectangle aPixelSize = rOut.LogicToPixel(rMarkRect);
2810  sal_uInt32 nHorDiv(aPixelSize.GetWidth() / DRAG_CROOK_RASTER_DISTANCE);
2811  sal_uInt32 nVerDiv(aPixelSize.GetHeight() / DRAG_CROOK_RASTER_DISTANCE);
2812 
2813  if(nHorDiv > DRAG_CROOK_RASTER_MAXIMUM)
2814  nHorDiv = DRAG_CROOK_RASTER_MAXIMUM;
2815  if(nHorDiv < DRAG_CROOK_RASTER_MINIMUM)
2816  nHorDiv = DRAG_CROOK_RASTER_MINIMUM;
2817 
2818  if(nVerDiv > DRAG_CROOK_RASTER_MAXIMUM)
2819  nVerDiv = DRAG_CROOK_RASTER_MAXIMUM;
2820  if(nVerDiv < DRAG_CROOK_RASTER_MINIMUM)
2821  nVerDiv = DRAG_CROOK_RASTER_MINIMUM;
2822 
2823  const double fXLen(rMarkRect.GetWidth() / static_cast<double>(nHorDiv));
2824  const double fYLen(rMarkRect.GetHeight() / static_cast<double>(nVerDiv));
2825  double fYPos(rMarkRect.Top());
2826  sal_uInt32 a, b;
2827 
2828  for(a = 0; a <= nVerDiv; a++)
2829  {
2830  // horizontal lines
2831  for(b = 0; b < nHorDiv; b++)
2832  {
2833  basegfx::B2DPolygon aHorLineSegment;
2834 
2835  const double fNewX(rMarkRect.Left() + (b * fXLen));
2836  aHorLineSegment.append(basegfx::B2DPoint(fNewX, fYPos));
2837  aHorLineSegment.appendBezierSegment(
2838  basegfx::B2DPoint(fNewX + (fXLen * (1.0 / 3.0)), fYPos),
2839  basegfx::B2DPoint(fNewX + (fXLen * (2.0 / 3.0)), fYPos),
2840  basegfx::B2DPoint(fNewX + fXLen, fYPos));
2841  aRetval.append(aHorLineSegment);
2842  }
2843 
2844  // increments
2845  fYPos += fYLen;
2846  }
2847 
2848  double fXPos(rMarkRect.Left());
2849 
2850  for(a = 0; a <= nHorDiv; a++)
2851  {
2852  // vertical lines
2853  for(b = 0; b < nVerDiv; b++)
2854  {
2855  basegfx::B2DPolygon aVerLineSegment;
2856 
2857  const double fNewY(rMarkRect.Top() + (b * fYLen));
2858  aVerLineSegment.append(basegfx::B2DPoint(fXPos, fNewY));
2859  aVerLineSegment.appendBezierSegment(
2860  basegfx::B2DPoint(fXPos, fNewY + (fYLen * (1.0 / 3.0))),
2861  basegfx::B2DPoint(fXPos, fNewY + (fYLen * (2.0 / 3.0))),
2862  basegfx::B2DPoint(fXPos, fNewY + fYLen));
2863  aRetval.append(aVerLineSegment);
2864  }
2865 
2866  // increments
2867  fXPos += fXLen;
2868  }
2869  }
2870 
2871  return aRetval;
2872 }
2873 
2875 {
2876  // Add extended frame raster first, so it will be behind objects
2877  if(getSdrDragView().GetSdrPageView())
2878  {
2879  const basegfx::B2DPolyPolygon aDragRaster(impCreateDragRaster(*getSdrDragView().GetSdrPageView(), GetMarkedRect()));
2880 
2881  if(aDragRaster.count())
2882  {
2883  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragRaster)));
2884  }
2885  }
2886 
2887  // call parent
2889 }
2890 
2892 {
2897 
2899  {
2905  aStart=DragStat().GetStart();
2906  Show();
2907  return true;
2908  }
2909  else
2910  {
2911  return false;
2912  }
2913 }
2914 
2916 {
2918 
2919  if(!pPV)
2920  return;
2921 
2922  XPolyPolygon aTempPolyPoly(rTarget);
2923 
2924  if (pPV->HasMarkedObjPageView())
2925  {
2926  sal_uInt16 nPolyCount=aTempPolyPoly.Count();
2927 
2928  if (!bContortion && !getSdrDragView().IsNoDragXorPolys())
2929  {
2930  sal_uInt16 n1st=0,nLast=0;
2931  Point aC(aCenter);
2932 
2933  while (n1st<nPolyCount)
2934  {
2935  nLast=n1st;
2936  while (nLast<nPolyCount && aTempPolyPoly[nLast].GetPointCount()!=0) nLast++;
2937  tools::Rectangle aBound(aTempPolyPoly[n1st].GetBoundRect());
2938  sal_uInt16 i;
2939 
2940  for (i=n1st+1; i<nLast; i++)
2941  {
2942  aBound.Union(aTempPolyPoly[n1st].GetBoundRect());
2943  }
2944 
2945  Point aCtr0(aBound.Center());
2946  Point aCtr1(aCtr0);
2947 
2948  if (bResize)
2949  {
2950  Fraction aFact1(1,1);
2951 
2952  if (bVertical)
2953  {
2954  ResizePoint(aCtr1,aC,aFact1,aFact);
2955  }
2956  else
2957  {
2958  ResizePoint(aCtr1,aC,aFact,aFact1);
2959  }
2960  }
2961 
2962  bool bRotOk=false;
2963  double nSin=0,nCos=0;
2964 
2965  if (aRad.X()!=0 && aRad.Y()!=0)
2966  {
2967  bRotOk=bRotate;
2968 
2969  switch (eMode)
2970  {
2971  case SdrCrookMode::Rotate : CrookRotateXPoint (aCtr1,nullptr,nullptr,aC,aRad,nSin,nCos,bVertical); break;
2972  case SdrCrookMode::Slant : CrookSlantXPoint (aCtr1,nullptr,nullptr,aC,aRad,nSin,nCos,bVertical); break;
2973  case SdrCrookMode::Stretch: CrookStretchXPoint(aCtr1,nullptr,nullptr,aC,aRad,nSin,nCos,bVertical,aMarkRect); break;
2974  } // switch
2975  }
2976 
2977  aCtr1-=aCtr0;
2978 
2979  for (i=n1st; i<nLast; i++)
2980  {
2981  if (bRotOk)
2982  {
2983  RotateXPoly(aTempPolyPoly[i],aCtr0,nSin,nCos);
2984  }
2985 
2986  aTempPolyPoly[i].Move(aCtr1.X(),aCtr1.Y());
2987  }
2988 
2989  n1st=nLast+1;
2990  }
2991  }
2992  else
2993  {
2994  sal_uInt16 i,j;
2995 
2996  for (j=0; j<nPolyCount; j++)
2997  {
2998  XPolygon& aPol=aTempPolyPoly[j];
2999  sal_uInt16 nPointCount=aPol.GetPointCount();
3000  i=0;
3001 
3002  while (i<nPointCount)
3003  {
3004  Point* pPnt=&aPol[i];
3005  Point* pC1=nullptr;
3006  Point* pC2=nullptr;
3007 
3008  if (i+1<nPointCount && aPol.IsControl(i))
3009  { // control point on the left
3010  pC1=pPnt;
3011  i++;
3012  pPnt=&aPol[i];
3013  }
3014 
3015  i++;
3016 
3017  if (i<nPointCount && aPol.IsControl(i))
3018  { // control point on the right
3019  pC2=&aPol[i];
3020  i++;
3021  }
3022 
3023  MovCrookPoint(*pPnt,pC1,pC2);
3024  }
3025  }
3026  }
3027  }
3028 
3029  rTarget = aTempPolyPoly.getB2DPolyPolygon();
3030 }
3031 
3032 void SdrDragCrook::MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2)
3033 {
3034  bool bVert=bVertical;
3035  bool bC1=pC1!=nullptr;
3036  bool bC2=pC2!=nullptr;
3037  Point aC(aCenter);
3038 
3039  if (bResize)
3040  {
3041  Fraction aFact1(1,1);
3042 
3043  if (bVert)
3044  {
3045  ResizePoint(rPnt,aC,aFact1,aFact);
3046 
3047  if (bC1)
3048  ResizePoint(*pC1,aC,aFact1,aFact);
3049 
3050  if (bC2)
3051  ResizePoint(*pC2,aC,aFact1,aFact);
3052  }
3053  else
3054  {
3055  ResizePoint(rPnt,aC,aFact,aFact1);
3056 
3057  if (bC1)
3058  ResizePoint(*pC1,aC,aFact,aFact1);
3059 
3060  if (bC2)
3061  ResizePoint(*pC2,aC,aFact,aFact1);
3062  }
3063  }
3064 
3065  if (aRad.X()!=0 && aRad.Y()!=0)
3066  {
3067  double nSin,nCos;
3068 
3069  switch (eMode)
3070  {
3071  case SdrCrookMode::Rotate : CrookRotateXPoint (rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert); break;
3072  case SdrCrookMode::Slant : CrookSlantXPoint (rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert); break;
3073  case SdrCrookMode::Stretch: CrookStretchXPoint(rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert,aMarkRect); break;
3074  } // switch
3075  }
3076 }
3077 
3078 void SdrDragCrook::MoveSdrDrag(const Point& rPnt)
3079 {
3080  if (!DragStat().CheckMinMoved(rPnt))
3081  return;
3082 
3083  bool bNewMoveOnly=getSdrDragView().IsMoveOnlyDragging();
3084  bAtCenter=false;
3086  bool bNewContortion=!bNewMoveOnly && ((bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed);
3087  bResize=!getSdrDragView().IsOrtho() && bResizeAllowed && !bNewMoveOnly;
3088  bool bNewRotate=bRotateAllowed && !bNewContortion && !bNewMoveOnly && eNewMode==SdrCrookMode::Rotate;
3089 
3090  Point aPnt(GetSnapPos(rPnt));
3091 
3092  Point aNewCenter(aMarkCenter.X(),aStart.Y());
3093 
3094  if (bVertical)
3095  {
3096  aNewCenter.setX(aStart.X() );
3097  aNewCenter.setY(aMarkCenter.Y() );
3098  }
3099 
3101  {
3102  switch (GetDragHdlKind())
3103  {
3104  case SdrHdlKind::UpperLeft: aNewCenter.setX(aMarkRect.Right() ); bLft=true; break;
3105  case SdrHdlKind::Upper: aNewCenter.setY(aMarkRect.Bottom() ); bUpr=true; break;
3106  case SdrHdlKind::UpperRight: aNewCenter.setX(aMarkRect.Left() ); bRgt=true; break;
3107  case SdrHdlKind::Left : aNewCenter.setX(aMarkRect.Right() ); bLft=true; break;
3108  case SdrHdlKind::Right: aNewCenter.setX(aMarkRect.Left() ); bRgt=true; break;
3109  case SdrHdlKind::LowerLeft: aNewCenter.setX(aMarkRect.Right() ); bLft=true; break;
3110  case SdrHdlKind::Lower: aNewCenter.setY(aMarkRect.Top() ); bLwr=true; break;
3111  case SdrHdlKind::LowerRight: aNewCenter.setX(aMarkRect.Left() ); bRgt=true; break;
3112  default: bAtCenter=true;
3113  }
3114  }
3115  else
3116  bAtCenter=true;
3117 
3118  Fraction aNewFract(1,1);
3119  tools::Long dx1=aPnt.X()-aNewCenter.X();
3120  tools::Long dy1=aPnt.Y()-aNewCenter.Y();
3121  bValid=bVertical ? dx1!=0 : dy1!=0;
3122 
3123  if (bValid)
3124  {
3125  if (bVertical)
3126  bValid = std::abs(dx1)*100>std::abs(dy1);
3127  else
3128  bValid = std::abs(dy1)*100>std::abs(dx1);
3129  }
3130 
3131  tools::Long nNewRad=0;
3132  nAngle=0_deg100;
3133 
3134  if (bValid)
3135  {
3136  double a=0; // slope of the radius
3137  Degree100 nPntAngle(0);
3138 
3139  if (bVertical)
3140  {
3141  a=static_cast<double>(dy1)/static_cast<double>(dx1); // slope of the radius
3142  nNewRad=(static_cast<tools::Long>(dy1*a)+dx1) /2;
3143  aNewCenter.AdjustX(nNewRad );
3144  nPntAngle=GetAngle(aPnt-aNewCenter);
3145  }
3146  else
3147  {
3148  a=static_cast<double>(dx1)/static_cast<double>(dy1); // slope of the radius
3149  nNewRad=(static_cast<tools::Long>(dx1*a)+dy1) /2;
3150  aNewCenter.AdjustY(nNewRad );
3151  nPntAngle=GetAngle(aPnt-aNewCenter)-9000_deg100;
3152  }
3153 
3154  if (!bAtCenter)
3155  {
3156  if (nNewRad<0)
3157  {
3158  if (bRgt) nPntAngle += 18000_deg100;
3159  if (bLft) nPntAngle = 18000_deg100 - nPntAngle;
3160  if (bLwr) nPntAngle =- nPntAngle;
3161  }
3162  else
3163  {
3164  if (bRgt) nPntAngle = -nPntAngle;
3165  if (bUpr) nPntAngle = 18000_deg100 - nPntAngle;
3166  if (bLwr) nPntAngle += 18000_deg100;
3167  }
3168 
3169  nPntAngle=NormAngle36000(nPntAngle);
3170  }
3171  else
3172  {
3173  if (nNewRad<0) nPntAngle += 18000_deg100;
3174  if (bVertical) nPntAngle = 18000_deg100 - nPntAngle;
3175  nPntAngle = NormAngle18000(nPntAngle);
3176  nPntAngle = abs(nPntAngle);
3177  }
3178 
3179  double nCircumference = 2 * std::abs(nNewRad) * M_PI;
3180 
3181  if (bResize)
3182  {
3183  tools::Long nMul=static_cast<tools::Long>(nCircumference * NormAngle36000(nPntAngle).get() / 36000.0);
3184 
3185  if (bAtCenter)
3186  nMul*=2;
3187 
3188  aNewFract=Fraction(nMul,nMarkSize);
3189  nAngle=nPntAngle;
3190  }
3191  else
3192  {
3193  nAngle = Degree100(static_cast<tools::Long>((nMarkSize*360/nCircumference)*100)/2);
3194 
3195  if (nAngle==0_deg100)
3196  bValid=false;
3197  }
3198  }
3199 
3200  if (nAngle==0_deg100 || nNewRad==0)
3201  bValid=false;
3202 
3203  if (!bValid)
3204  nNewRad=0;
3205 
3206  if (!bValid && bResize)
3207  {
3208  tools::Long nMul=bVertical ? dy1 : dx1;
3209 
3210  if (bLft || bUpr)
3211  nMul=-nMul;
3212 
3213  tools::Long nDiv=nMarkSize;
3214 
3215  if (bAtCenter)
3216  {
3217  nMul*=2;
3218  nMul = std::abs(nMul);
3219  }
3220 
3221  aNewFract=Fraction(nMul,nDiv);
3222  }
3223 
3224  if (aNewCenter==aCenter && bNewContortion==bContortion && aNewFract==aFact &&
3225  bNewMoveOnly == getMoveOnly() && bNewRotate==bRotate && eNewMode==eMode)
3226  return;
3227 
3228  Hide();
3229  setMoveOnly(bNewMoveOnly);
3230  bRotate=bNewRotate;
3231  eMode=eNewMode;
3232  bContortion=bNewContortion;
3233  aCenter=aNewCenter;
3234  aFact=aNewFract;
3235  aRad=Point(nNewRad,nNewRad);
3236  bResize=aFact!=Fraction(1,1) && aFact.GetDenominator()!=0 && aFact.IsValid();
3237  DragStat().NextMove(aPnt);
3238  Show();
3239 }
3240 
3242 {
3243  const bool bDoResize(aFact!=Fraction(1,1));
3244  const bool bDoCrook(aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0);
3245 
3246  if (!(bDoCrook || bDoResize))
3247  return;
3248 
3249  if (bDoResize)
3250  {
3251  Fraction aFact1(1,1);
3252 
3253  if (bContortion)
3254  {
3255  if (bVertical)
3256  {
3257  rTarget.Resize(aCenter,aFact1,aFact);
3258  }
3259  else
3260  {
3261  rTarget.Resize(aCenter,aFact,aFact1);
3262  }
3263  }
3264  else
3265  {
3266  Point aCtr0(rTarget.GetSnapRect().Center());
3267  Point aCtr1(aCtr0);
3268 
3269  if (bVertical)
3270  {
3271  ResizePoint(aCtr1,aCenter,aFact1,aFact);
3272  }
3273  else
3274  {
3275  ResizePoint(aCtr1,aCenter,aFact,aFact1);
3276  }
3277 
3278  Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y());
3279 
3280  rTarget.Move(aSiz);
3281  }
3282  }
3283 
3284  if (bDoCrook)
3285  {
3286  const tools::Rectangle aLocalMarkRect(getSdrDragView().GetMarkedObjRect());
3287  const bool bLocalRotate(!bContortion && eMode == SdrCrookMode::Rotate && getSdrDragView().IsRotateAllowed());
3288 
3289  SdrEditView::ImpCrookObj(&rTarget,aCenter,aRad,eMode,bVertical,!bContortion,bLocalRotate,aLocalMarkRect);
3290  }
3291 }
3292 
3294 {
3295  // use helper derived from old stuff
3296  MovAllPoints(rTarget);
3297 }
3298 
3300 {
3301  Hide();
3302 
3303  if (bResize && aFact==Fraction(1,1))
3304  bResize=false;
3305 
3306  const bool bUndo = getSdrDragView().IsUndoEnabled();
3307 
3308  bool bDoCrook=aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0;
3309 
3310  if (bDoCrook || bResize)
3311  {
3312  if (bResize && bUndo)
3313  {
3314  OUString aStr = ImpGetDescriptionStr(!bContortion?STR_EditCrook:STR_EditCrookContortion);
3315 
3316  if (bCopy)
3317  aStr += SvxResId(STR_EditWithCopy);
3318 
3319  getSdrDragView().BegUndo(aStr);
3320  }
3321 
3322  if (bResize)
3323  {
3324  Fraction aFact1(1,1);
3325 
3326  if (bContortion)
3327  {
3328  if (bVertical)
3329  getSdrDragView().ResizeMarkedObj(aCenter,aFact1,aFact,bCopy);
3330  else
3331  getSdrDragView().ResizeMarkedObj(aCenter,aFact,aFact1,bCopy);
3332  }
3333  else
3334  {
3335  if (bCopy)
3337 
3338  const size_t nMarkCount=getSdrDragView().GetMarkedObjectList().GetMarkCount();
3339 
3340  for (size_t nm=0; nm<nMarkCount; ++nm)
3341  {
3343  SdrObject* pO=pM->GetMarkedSdrObj();
3344  Point aCtr0(pO->GetSnapRect().Center());
3345  Point aCtr1(aCtr0);
3346 
3347  if (bVertical)
3348  ResizePoint(aCtr1,aCenter,aFact1,aFact);
3349  else
3350  ResizePoint(aCtr1,aCenter,aFact,aFact1);
3351 
3352  Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y());
3353  if( bUndo )
3354  AddUndo(getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz));
3355  pO->Move(aSiz);
3356  }
3357  }
3358 
3359  bCopy=false;
3360  }
3361 
3362  if (bDoCrook)
3363  {
3365  }
3366 
3367  if (bResize && bUndo)
3368  getSdrDragView().EndUndo();
3369 
3370  return true;
3371  }
3372 
3373  return false;
3374 }
3375 
3377 {
3378  return PointerStyle::Crook;
3379 }
3380 
3381 
3383 : SdrDragMethod(rNewView),
3384  nPolyPt(0),
3385  bContortionAllowed(false),
3386  bNoContortionAllowed(false),
3387  bContortion(false)
3388 {
3389 }
3390 
3392 {
3393  OUString aStr = ImpGetDescriptionStr(STR_DragMethDistort)
3394  + " (x="
3396  + " y="
3398  + ")";
3399 
3400  if(getSdrDragView().IsDragWithCopy())
3401  aStr += SvxResId(STR_EditWithCopy);
3402  return aStr;
3403 }
3404 
3406 {
3407  // Add extended frame raster first, so it will be behind objects
3408  if(getSdrDragView().GetSdrPageView())
3409  {
3410  const basegfx::B2DPolyPolygon aDragRaster(impCreateDragRaster(*getSdrDragView().GetSdrPageView(), GetMarkedRect()));
3411 
3412  if(aDragRaster.count())
3413  {
3414  addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragRaster)));
3415  }
3416  }
3417 
3418  // call parent
3420 }
3421 
3423 {
3426 
3428  {
3429  SdrHdlKind eKind=GetDragHdlKind();
3430  nPolyPt=0xFFFF;
3431 
3432  if (eKind==SdrHdlKind::UpperLeft) nPolyPt=0;
3433  if (eKind==SdrHdlKind::UpperRight) nPolyPt=1;
3434  if (eKind==SdrHdlKind::LowerRight) nPolyPt=2;
3435  if (eKind==SdrHdlKind::LowerLeft) nPolyPt=3;
3436  if (nPolyPt>3) return false;
3437 
3440  Show();
3441  return true;
3442  }
3443  else
3444  {
3445  return false;
3446  }
3447 }
3448 
3450 {
3451  if (!bContortion)
3452  return;
3453 
3455 
3456  if(pPV && pPV->HasMarkedObjPageView())
3457  {
3458  basegfx::B2DPolyPolygon aDragPolygon(rTarget);
3460  const basegfx::B2DPoint aTopLeft(aDistortedRect[0].X(), aDistortedRect[0].Y());
3461  const basegfx::B2DPoint aTopRight(aDistortedRect[1].X(), aDistortedRect[1].Y());
3462  const basegfx::B2DPoint aBottomLeft(aDistortedRect[3].X(), aDistortedRect[3].Y());
3463  const basegfx::B2DPoint aBottomRight(aDistortedRect[2].X(), aDistortedRect[2].Y());
3464 
3465  aDragPolygon = basegfx::utils::distort(aDragPolygon, aOriginalRange, aTopLeft, aTopRight, aBottomLeft, aBottomRight);
3466  rTarget = aDragPolygon;
3467  }
3468 }
3469 
3470 void SdrDragDistort::MoveSdrDrag(const Point& rPnt)
3471 {
3472  if (!DragStat().CheckMinMoved(rPnt))
3473  return;
3474 
3475  Point aPnt(GetSnapPos(rPnt));
3476 
3477  if (getSdrDragView().IsOrtho())
3478  OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
3479 
3481 
3482  if (bNewContortion!=bContortion || aDistortedRect[nPolyPt]!=aPnt)
3483  {
3484  Hide();
3485  aDistortedRect[nPolyPt]=aPnt;
3486  bContortion=bNewContortion;
3487  DragStat().NextMove(aPnt);
3488  Show();
3489  }
3490 }
3491 
3493 {
3494  Hide();
3495  bool bDoDistort=DragStat().GetDX()!=0 || DragStat().GetDY()!=0;
3496 
3497  if (bDoDistort)
3498  {
3500  return true;
3501  }
3502 
3503  return false;
3504 }
3505 
3507 {
3508  return PointerStyle::RefHand;
3509 }
3510 
3512 {
3513  const bool bDoDistort(DragStat().GetDX()!=0 || DragStat().GetDY()!=0);
3514 
3515  if (bDoDistort)
3516  {
3518  }
3519 }
3520 
3522 {
3523  // use helper derived from old stuff
3524  MovAllPoints(rTarget);
3525 }
3526 
3527 
3529 : SdrDragObjOwn(rNewView)
3530 {
3531  // switch off solid dragging for crop; it just makes no sense since showing
3532  // a 50% transparent object above the original will not be visible
3533  setSolidDraggingActive(false);
3534 }
3535 
3537 {
3538  OUString aStr = ImpGetDescriptionStr(STR_DragMethCrop)
3539  + " (x="
3541  + " y="
3543  + ")";
3544 
3545  if(getSdrDragView().IsDragWithCopy())
3546  aStr += SvxResId(STR_EditWithCopy);
3547  return aStr;
3548 }
3549 
3551 {
3552  // call parent
3553  bool bRetval(SdrDragObjOwn::BeginSdrDrag());
3554 
3555  if(!GetDragHdl())
3556  {
3557  // we need the DragHdl, break if not there
3558  bRetval = false;
3559  }
3560 
3561  return bRetval;
3562 }
3563 
3564 bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
3565 {
3566  Hide();
3567 
3568  if(0 == DragStat().GetDX() && 0 == DragStat().GetDY())
3569  {
3570  // no change, done
3571  return false;
3572  }
3573 
3574  const SdrMarkList& rMarkList = getSdrDragView().GetMarkedObjectList();
3575 
3576  if(1 != rMarkList.GetMarkCount())
3577  {
3578  // Crop only with single Object selected
3579  return false;
3580  }
3581 
3582  // prepare for SdrGrafObj or others. This code has to work with usual
3583  // SdrGrafObj's from Draw/Impress/Calc, but also with SdrObjects from
3584  // Writer. It would be better to handle this in Writer directly, but
3585  // there are currently no easy mechanisms to plug an alternative interaction
3586  // from there
3587  SdrObject* pSdrObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
3588  SdrObjectUniquePtr pFullDragClone;
3589  bool bExternal(false);
3590  SdrObject* pExternalSdrObject(nullptr);
3591 
3592  // RotGrfFlyFrame: Crop decision for DrawingLayer/Writer now
3593  // locally, no two-in-one methods any more
3594  if (nullptr != pSdrObject && dynamic_cast< const SdrGrafObj* >(pSdrObject) == nullptr)
3595  {
3596  // If Writer, get the already offered for interaction SdrGrafObj
3597  // and set up for using that replacement object that contains the
3598  // real transformation. That SdrObject is owned and has to be deleted,
3599  // so use a std::unique_ptr with special handling for the protected
3600  // SDrObject destructor
3601  pFullDragClone = pSdrObject->getFullDragClone();
3602 
3603  if(dynamic_cast< SdrGrafObj* >(pFullDragClone.get()))
3604  {
3605  bExternal = true;
3606  pExternalSdrObject = pSdrObject;
3607  pSdrObject = pFullDragClone.get();
3608  }
3609  }
3610 
3611  // get and check for SdrGrafObj now
3612  SdrGrafObj* pObj = dynamic_cast<SdrGrafObj*>( pSdrObject );
3613 
3614  if(!pObj)
3615  {
3616  return false;
3617  }
3618 
3619  // no undo for external needed, done there
3620  const bool bUndo(!bExternal && getSdrDragView().IsUndoEnabled());
3621 
3622  if(bUndo)
3623  {
3624  OUString aUndoStr = ImpGetDescriptionStr(STR_DragMethCrop);
3625 
3626  getSdrDragView().BegUndo( aUndoStr );
3627  getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
3628  // also need attr undo, the SdrGrafCropItem will be changed
3629  getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
3630  }
3631 
3632  // get the original objects transformation
3633  basegfx::B2DHomMatrix aOriginalMatrix;
3634  basegfx::B2DPolyPolygon aPolyPolygon;
3635  bool bShearCorrected(false);
3636  pObj->TRGetBaseGeometry(aOriginalMatrix, aPolyPolygon);
3637 
3638  { // correct shear, it comes currently mirrored from TRGetBaseGeometry, can be removed with aw080
3639  const basegfx::utils::B2DHomMatrixBufferedDecompose aTmpDecomp(aOriginalMatrix);
3640 
3641  if(!basegfx::fTools::equalZero(aTmpDecomp.getShearX()))
3642  {
3643  bShearCorrected = true;
3645  aTmpDecomp.getScale(),
3646  -aTmpDecomp.getShearX(),
3647  aTmpDecomp.getRotate(),
3648  aTmpDecomp.getTranslate());
3649  }
3650  }
3651 
3652  // generate start point of original drag vector in unit coordinates (the
3653  // vis-a-vis of the drag point)
3654  basegfx::B2DPoint aLocalStart(0.0, 0.0);
3655  bool bOnAxis(false);
3656 
3657  switch(GetDragHdlKind())
3658  {
3659  case SdrHdlKind::UpperLeft: aLocalStart.setX(1.0); aLocalStart.setY(1.0); break;
3660  case SdrHdlKind::Upper: aLocalStart.setX(0.5); aLocalStart.setY(1.0); bOnAxis = true; break;
3661  case SdrHdlKind::UpperRight: aLocalStart.setX(0.0); aLocalStart.setY(1.0); break;
3662  case SdrHdlKind::Left : aLocalStart.setX(1.0); aLocalStart.setY(0.5); bOnAxis = true; break;
3663  case SdrHdlKind::Right: aLocalStart.setX(0.0); aLocalStart.setY(0.5); bOnAxis = true; break;
3664  case SdrHdlKind::LowerLeft: aLocalStart.setX(1.0); aLocalStart.setY(0.0); break;
3665  case SdrHdlKind::Lower: aLocalStart.setX(0.5); aLocalStart.setY(0.0); bOnAxis = true; break;
3666  case SdrHdlKind::LowerRight: aLocalStart.setX(0.0); aLocalStart.setY(0.0); break;
3667  default: break;
3668  }
3669 
3670  // create the current drag position in unit coordinates. To get there,
3671  // transform back the DragPoint to UnitCoordinates
3672  basegfx::B2DHomMatrix aInverse(aOriginalMatrix);
3673  aInverse.invert();
3674  basegfx::B2DPoint aLocalCurrent(aInverse * basegfx::B2DPoint(DragStat().GetNow().X(), DragStat().GetNow().Y()));
3675 
3676  // if one of the edge handles is used, limit to X or Y drag only
3677  if(bOnAxis)
3678  {
3679  if(basegfx::fTools::equal(aLocalStart.getX(), 0.5))
3680  {
3681  aLocalCurrent.setX(aLocalStart.getX());
3682  }
3683  else
3684  {
3685  aLocalCurrent.setY(aLocalStart.getY());
3686  }
3687  }
3688 
3689  // create internal change in unit coordinates
3690  basegfx::B2DHomMatrix aDiscreteChangeMatrix;
3691 
3692  if(!basegfx::fTools::equal(aLocalCurrent.getX(), aLocalStart.getX()))
3693  {
3694  if(aLocalStart.getX() < 0.5)
3695  {
3696  aDiscreteChangeMatrix.scale(aLocalCurrent.getX(), 1.0);
3697  }
3698  else
3699  {
3700  aDiscreteChangeMatrix.scale(1.0 - aLocalCurrent.getX(), 1.0);
3701  aDiscreteChangeMatrix.translate(aLocalCurrent.getX(), 0.0);
3702  }
3703  }
3704 
3705  if(!basegfx::fTools::equal(aLocalCurrent.getY(), aLocalStart.getY()))
3706  {
3707  if(aLocalStart.getY() < 0.5)
3708  {
3709  aDiscreteChangeMatrix.scale(1.0, aLocalCurrent.getY());
3710  }
3711  else
3712  {
3713  aDiscreteChangeMatrix.scale(1.0, 1.0 - aLocalCurrent.getY());
3714  aDiscreteChangeMatrix.translate(0.0, aLocalCurrent.getY());
3715  }
3716  }
3717 
3718  // We now have the whole executed Crop in UnitCoordinates in
3719  // aDiscreteChangeMatrix, go to concrete sizes now.
3720  // Create the unrotated original rectangle and the unrotated modified
3721  // rectangle as Ranges
3722  const basegfx::utils::B2DHomMatrixBufferedDecompose aOriginalMatrixDecomp(aOriginalMatrix);
3723 
3724  // prepare unsheared/unrotated versions of the old and new transformation
3725  const basegfx::B2DHomMatrix aOriginalMatrixNoShearNoRotate(
3727  basegfx::absolute(aOriginalMatrixDecomp.getScale()),
3728  aOriginalMatrixDecomp.getTranslate()));
3729 
3730  // create the ranges for these
3731  basegfx::B2DRange aRangeOriginalNoShearNoRotate(0.0, 0.0, 1.0, 1.0);
3732  basegfx::B2DRange aRangeNewNoShearNoRotate(0.0, 0.0, 1.0, 1.0);
3733  aRangeOriginalNoShearNoRotate.transform(aOriginalMatrixNoShearNoRotate);
3734  aRangeNewNoShearNoRotate.transform(aOriginalMatrixNoShearNoRotate * aDiscreteChangeMatrix);
3735 
3736  if(bExternal)
3737  {
3738  // With aLocalStart point (opposed to dragged point), X scale and Y scale,
3739  // we call crop (virtual method) on pSdrObject which calls VirtFlyDrawObj
3740  // crop. Use aLocalStart unchanged, so being relative to the Crop-Action,
3741  // the called instance knows best how to use it
3742  const double fScaleX(aRangeNewNoShearNoRotate.getWidth() / aRangeOriginalNoShearNoRotate.getWidth());
3743  const double fScaleY(aRangeNewNoShearNoRotate.getHeight() / aRangeOriginalNoShearNoRotate.getHeight());
3744 
3745  pExternalSdrObject->Crop(
3746  aLocalStart,
3747  fScaleX,
3748  fScaleY);
3749  }
3750  else
3751  {
3752  // prepare matrix to apply to object; evtl. back-correct shear
3753  basegfx::B2DHomMatrix aNewObjectMatrix(aOriginalMatrix * aDiscreteChangeMatrix);
3754 
3755  if(bShearCorrected)
3756  {
3757  // back-correct shear
3758  const basegfx::utils::B2DHomMatrixBufferedDecompose aTmpDecomp(aNewObjectMatrix);
3759 
3761  aTmpDecomp.getScale(),
3762  -aTmpDecomp.getShearX(),
3763  aTmpDecomp.getRotate(),
3764  aTmpDecomp.getTranslate());
3765  }
3766 
3767  // apply change to object by applying the unit coordinate change followed
3768  // by the original change
3769  pObj->TRSetBaseGeometry(aNewObjectMatrix, aPolyPolygon);
3770 
3771  // extract the old Rectangle structures
3772  tools::Rectangle aOldRect(
3773  basegfx::fround(aRangeOriginalNoShearNoRotate.getMinX()),
3774  basegfx::fround(aRangeOriginalNoShearNoRotate.getMinY()),
3775  basegfx::fround(aRangeOriginalNoShearNoRotate.getMaxX()),
3776  basegfx::fround(aRangeOriginalNoShearNoRotate.getMaxY()));
3777  tools::Rectangle aNewRect(
3778  basegfx::fround(aRangeNewNoShearNoRotate.getMinX()),
3779  basegfx::fround(aRangeNewNoShearNoRotate.getMinY()),
3780  basegfx::fround(aRangeNewNoShearNoRotate.getMaxX()),
3781  basegfx::fround(aRangeNewNoShearNoRotate.getMaxY()));
3782 
3783  // continue with the old original stuff
3784  if (!aOldRect.GetWidth() || !aOldRect.GetHeight())
3785  {
3786  throw o3tl::divide_by_zero();
3787  }
3788 
3789  if((pObj->GetGraphicType() == GraphicType::NONE) || (pObj->GetGraphicType() == GraphicType::Default))
3790  {
3791  return false;
3792  }
3793 
3794  const GraphicObject& rGraphicObject(pObj->GetGraphicObject());
3795  // tdf#117145 Usually Writer will go the bExternal path (see above), but more correct for
3796  // the future is to use the MapMode from the SdrModel/SfxItemPool if the Writer's current
3797  // special handling should be unified to this path in the future. Usually it *should* be
3798  // MapUnit::Map100thMM, but better do not mix up Units.
3799  // Checked now what SwVirtFlyDrawObj::NbcCrop is doing - it calculates everything forced
3800  // to MapUnit::Map100thMM, but extracts/packs Twips to the used SdrGrafCropItem in Writer.
3801  const MapMode aMapModePool(pObj->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
3802  Size aGraphicSize(rGraphicObject.GetPrefSize());
3803 
3804  if(MapUnit::MapPixel == rGraphicObject.GetPrefMapMode().GetMapUnit())
3805  {
3806  aGraphicSize = Application::GetDefaultDevice()->PixelToLogic(aGraphicSize, aMapModePool);
3807  }
3808  else
3809  {
3810  aGraphicSize = OutputDevice::LogicToLogic(aGraphicSize, rGraphicObject.GetPrefMapMode(), aMapModePool);
3811  }
3812 
3813  if(0 == aGraphicSize.Width() || 0 == aGraphicSize.Height())
3814  {
3815  return false;
3816  }
3817 
3818  const SdrGrafCropItem& rOldCrop = pObj->GetMergedItem(SDRATTR_GRAFCROP);
3819  double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() - rOldCrop.GetRight() ) / static_cast<double>(aOldRect.GetWidth());
3820  double fScaleY = ( aGraphicSize.Height() - rOldCrop.GetTop() - rOldCrop.GetBottom() ) / static_cast<double>(aOldRect.GetHeight());
3821 
3822  sal_Int32 nDiffLeft = aNewRect.Left() - aOldRect.Left();
3823  sal_Int32 nDiffTop = aNewRect.Top() - aOldRect.Top();
3824  sal_Int32 nDiffRight = aNewRect.Right() - aOldRect.Right();
3825  sal_Int32 nDiffBottom = aNewRect.Bottom() - aOldRect.Bottom();
3826 
3827  if(pObj->IsMirrored())
3828  {
3829  // mirrored X or Y, for old stuff, exchange X
3830  // check for aw080
3831  sal_Int32 nTmp(nDiffLeft);
3832  nDiffLeft = -nDiffRight;
3833  nDiffRight = -nTmp;
3834  }
3835 
3836  sal_Int32 nLeftCrop = static_cast<sal_Int32>( rOldCrop.GetLeft() + nDiffLeft * fScaleX );
3837  sal_Int32 nTopCrop = static_cast<sal_Int32>( rOldCrop.GetTop() + nDiffTop * fScaleY );
3838  sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() - nDiffRight * fScaleX );
3839  sal_Int32 nBottomCrop = static_cast<sal_Int32>( rOldCrop.GetBottom() - nDiffBottom * fScaleY );
3840 
3842  SfxItemSet aSet( rPool, svl::Items<SDRATTR_GRAFCROP, SDRATTR_GRAFCROP> );
3843  aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) );
3844  getSdrDragView().SetAttributes( aSet, false );
3845  }
3846 
3847  if(bUndo)
3848  {
3849  getSdrDragView().EndUndo();
3850  }
3851 
3852  return true;
3853 }
3854 
3856 {
3857  return PointerStyle::Crop;
3858 }
3859 
3860 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SdrMarkList & GetMarkedObjectList()
Definition: svddrgmt.hxx:171
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1603
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:2677
tools::Long nMarkSize
Definition: svddrgm1.hxx:163
double getY() const
const SdrUShortCont & GetMarkedGluePoints() const
Definition: svdmark.hxx:115
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
The Xor-Polygon is required by the View to drag the object.
Definition: svdobj.cxx:1129
SdrObjectUniquePtr mxClone
Definition: svddrgmt.hxx:287
void createSdrDragEntries_SolidDrag()
Definition: svddrgmt.cxx:363
SdrObject * getClone()
Definition: svddrgmt.hxx:81
Degree100 nAngle
Definition: svddrgm1.hxx:162
SdrHdlColor * GetColorHdl1() const
Definition: svdhdl.hxx:319
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:2558
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:1679
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:1543
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:2463
void MirrorMarkedObj(const Point &rRef1, const Point &rRef2, bool bCopy=false)
Definition: svdedtv1.cxx:355
static basegfx::B2DPolyPolygon impCreateDragRaster(SdrPageView const &rPageView, const tools::Rectangle &rMarkRect)
Definition: svddrgmt.cxx:2802
SdrHdl * GetDragHdl() const
Definition: svddrgmt.hxx:161
bool DoAddConnectorOverlays()
Definition: svddrgmt.cxx:837
size_t GetMarkCount() const
Definition: svdmark.hxx:180
virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager &rOverlayManager, const sdr::contact::ObjectContact &rObjectContact)
Definition: svddrgmt.cxx:671
void prepareCurrentState(SdrDragMethod &rDragMethod)
Definition: svddrgmt.cxx:149
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:960
bool bYSnapped
Definition: svddrgmt.hxx:235
tools::Long GetDX() const
Definition: svddrag.hxx:158
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true)
Definition: svdobj.cxx:1555
sal_uInt16 Count() const
Definition: _xpoly.cxx:890
void SetPos(const Point &rPnt)
Definition: svdhdl.cxx:342
SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon &rOriginalPolyPolygon)
Definition: svddrgmt.cxx:83
SdrHdlColor * GetColorHdl2() const
Definition: svdhdl.hxx:320
virtual ~SdrDragEntryPointGlueDrag() override
Definition: svddrgmt.cxx:214
double getHeight() const
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint > &rPositions, bool bIsPointDrag)
Definition: svddrgmt.cxx:206
bool IsResizeAllowed(bool bProp=false) const
Definition: svdedtv.cxx:391
virtual OUString getSpecialDragComment(const SdrDragStat &rDrag) const
Definition: svdobj.cxx:1370
const SdrUShortCont & GetMarkedPoints() const
Definition: svdmark.hxx:110
void Set2ndPos(const Point &rPnt)
Definition: svdhdl.cxx:1267
B2DTuple absolute(const B2DTuple &rTup)
SdrDragResize(SdrDragView &rNewView)
Definition: svddrgmt.cxx:1715
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:2718
virtual void TakeActionRect(tools::Rectangle &rRect) const override
Definition: svddrgv.cxx:106
void SetSkipChangeLayout(bool bOn)
Definition: svdundo.hxx:221
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:93
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:2059
void SetVerFixed(bool bOn)
Definition: svddrag.hxx:126
void ResizePoint(Point &rPnt, const Point &rRef, const Fraction &xFract, const Fraction &yFract)
Definition: svdtrans.hxx:106
bool equalZero(const T &rfVal)
tools::Long GetDY() const
Definition: svddrag.hxx:159
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_AUTOGROWWIDTH(SDRATTR_MISC_FIRST+12)
const Point & GetStart() const
Definition: svddrag.hxx:102
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:3550
SdrHdlKind
Definition: svdhdl.hxx:52
static OUString GetAngleString(Degree100 nAngle)
Definition: svdmodel.cxx:1093
Degree100 nAngle
Definition: svddrgm1.hxx:74
B2DPolygon expandToCurve(const B2DPolygon &rCandidate)
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:2011
bool IsUndoEnabled() const
Definition: svdedtv.cxx:1064
long Long
bool CheckMinMoved(const Point &rPnt)
Definition: svddrag.cxx:86
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool IsCon1() const
Definition: svdmark.hxx:85
SdrHdl * mpDragHdl
Definition: svddrgv.hxx:41
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:2575
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:3511
virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon &rTarget)
Definition: svddrgmt.cxx:623
virtual basegfx::B2DHomMatrix getCurrentTransformation() override
Definition: svddrgmt.cxx:2251
static void ImpDistortObj(SdrObject *pO, const tools::Rectangle &rRef, const XPolygon &rDistortedRect, bool bNoContortion)
Definition: svdedtv1.cxx:611
bool IsDraggingPoints() const
Definition: svddrgv.hxx:106
static size_t GetDragXorPointLimit()
Definition: svddrgv.hxx:163
bool IsInserted() const
Definition: svdobj.hxx:741
basegfx::B2DPolyPolygon getB2DPolyPolygon() const
Definition: _xpoly.cxx:935
void RotateMarkedObj(const Point &rRef, Degree100 nAngle, bool bCopy=false)
Definition: svdedtv1.cxx:299
void resetSdrDragEntries()
Definition: svddrgmt.cxx:273
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
void BegUndo()
Definition: svdedtv.hxx:178
sal_Int16 nId
virtual void createSdrDragEntries()
Definition: svddrgmt.cxx:295
SdrHdlGradient * pIAOHandle
Definition: svddrgm1.hxx:121
SdrObject * GetObj() const
Definition: svdhdl.hxx:203
virtual void CancelSdrDrag()
Definition: svddrgmt.cxx:664
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:2006
Changing the geometry of an object.
Definition: svdundo.hxx:204
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:218
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:1825
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:230
std::vector< std::unique_ptr< SdrUndoAction > > CreateConnectorUndo(SdrObject &rO)
Definition: svdedtv1.cxx:150
void append(std::unique_ptr< OverlayObject > pOverlayObject)
SdrDragShear(SdrDragView &rNewView, bool bSlant1)
Definition: svddrgmt.cxx:2187
const Point & GetPos() const
Definition: svdhdl.hxx:197
virtual void createSdrDragEntryForSdrObject(const SdrObject &rOriginal) override
Definition: svddrgmt.cxx:1446
virtual void ConnectToNode(bool bTail1, SdrObject *pObj)
Definition: svdobj.cxx:2347
const GraphicObject & GetGraphicObject(bool bForceSwapIn=false) const
Definition: svdograf.cxx:329
virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix &rMatrix, const basegfx::B2DPolyPolygon &rPolyPolygon) override
Definition: svdotext.cxx:1605
virtual void createSdrDragEntries() override
Definition: svddrgmt.cxx:1177
void EndTextEditAllViews() const
Checks if this or other views have an active text edit, if true, end them.
Definition: svdedtv.cxx:1069
SdrDragCrop(SdrDragView &rNewView)
Definition: svddrgmt.cxx:3528
void shearY(double fSy)
bool IsDraggingGluePoints() const
Definition: svddrgv.hxx:107
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:995
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:3492
Center
GraphicType GetGraphicType() const
Definition: svdograf.cxx:404
EmbeddedObjectRef * pObject
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:1271
double getMaxX() const
void setX(double fX)
basegfx::B2DPolygon ImplAddConnectorOverlay(SdrDragMethod &rDragMethod, bool bTail1, bool bTail2, bool bDetail) const
Definition: svdoedge.cxx:1995
double CrookRotateXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert)
The following methods accept a point of an XPolygon, whereas the neighbouring control points of the a...
Definition: svdtrans.cxx:163
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:2891
SdrDragStat & DragStat()
Definition: svddrgmt.hxx:163
const Color & GetHighlightColor() const
Degree100 nAngle
Definition: svddrgm1.hxx:53
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:251
virtual PointerStyle GetPointer() const
Definition: svdhdl.cxx:952
void ShowDragObj()
Definition: svddrgv.cxx:794
virtual const tools::Rectangle & GetSnapRect() const
Definition: svdobj.cxx:1669
const Point & Get2ndPos() const
Definition: svdhdl.hxx:322
B2DRange getB2DRange() const
SdrDragRotate(SdrDragView &rNewView)
Definition: svddrgmt.cxx:2049
void add(OverlayObject &rOverlayObject)
static OutputDevice * GetDefaultDevice()
void createSdrDragEntries_PolygonDrag()
Definition: svddrgmt.cxx:422
bool equalZero() const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
std::vector< std::unique_ptr< SdrDragEntry > > maSdrDragEntries
Definition: svddrgmt.hxx:118
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:2077
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:2031
SdrCrookMode
Definition: svdsnpv.hxx:83
SdrPageWindow * GetPageWindow(sal_uInt32 nIndex) const
Definition: svdpagv.cxx:83
bool bUpSideDown
Definition: svddrgm1.hxx:78
double getWidth() const
std::map< const SdrObject *, SdrObject * > SdrObjectAndCloneMap
Definition: svddrgmt.cxx:669
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:2112
bool mbSolidDraggingActive
Definition: svddrgmt.hxx:123
Point & Ref2() const
Definition: svddrgmt.hxx:166
bool IsOrtho() const
Definition: svdsnpv.hxx:246
virtual basegfx::B2DHomMatrix getCurrentTransformation()
Definition: svddrgmt.cxx:659
tools::Long Left() const
bool IsMore() const
Definition: svditer.hxx:62
void addSdrDragEntry(std::unique_ptr< SdrDragEntry > pNew)
Definition: svddrgmt.cxx:289
bool bContortionAllowed
Definition: svddrgm1.hxx:148
bool getMoveOnly() const
Definition: svddrgmt.hxx:215
void setSolidDraggingActive(bool bNew)
Definition: svddrgmt.hxx:151
double CrookStretchXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert, const tools::Rectangle &rRefRect)
Definition: svdtrans.cxx:272
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
void SetHorFixed(bool bOn)
Definition: svddrag.hxx:124
SdrDragEntrySdrObject(const SdrObject &rOriginal, bool bModify)
Definition: svddrgmt.cxx:134
B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fShearX, double fRadiant, double fTranslateX, double fTranslateY)
Point aStart
Definition: svddrgm1.hxx:145
bool bResizeAllowed
Definition: svddrgm1.hxx:151
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:2387
void ResizeMarkedPoints(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
Definition: svdpoev.cxx:623
Point GetSnapPos(const Point &rPt) const
Definition: svddrgmt.hxx:172
tools::Rectangle aMarkRect
Definition: svddrgm1.hxx:142
tools::Long Bottom() const
attribute::SdrLineAttribute createNewSdrLineAttribute(const SfxItemSet &rSet)
bool IsMoveFirstHandle() const
Definition: svdhdl.hxx:334
constexpr tools::Long GetWidth() const
virtual void Crop(const basegfx::B2DPoint &rRef, double fxFact, double fyFact)
Definition: svdobj.cxx:1574
void DistortMarkedObj(const tools::Rectangle &rRef, const XPolygon &rDistortedRect, bool bNoContortion, bool bCopy=false)
Definition: svdedtv1.cxx:645
Mode eMode
SdrCrookMode GetCrookMode() const
Definition: svdsnpv.hxx:277
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
Degree100 NormAngle36000(Degree100 deg100)
Normalize angle to -180.00..179.99.
Definition: svdtrans.cxx:409
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:2454
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:3506
void Touch()
Definition: svdhdl.cxx:390
bool IsRotateAllowed(bool b90Deg=false) const
Definition: svdedtv.cxx:399
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
Definition: sdtagitm.hxx:30
Fraction aFact
Definition: svddrgm1.hxx:146
SdrDragMethod(SdrDragView &rNewView)
Definition: svddrgmt.cxx:629
double getMaxY() const
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:1228
void setX(tools::Long x)
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:1433
const tools::Rectangle & GetMarkedRect() const
Definition: svddrgmt.hxx:219
Point & Ref1() const
Definition: svddrgmt.hxx:165
virtual SdrObject * GetConnectedNode(bool bTail1) const
Definition: svdobj.cxx:2355
B2IRange fround(const B2DRange &rRange)
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:195
void EndUndo()
Definition: svdedtv.cxx:303
tools::Rectangle aMarkRect
Definition: svddrgm1.hxx:190
void ImpCheckSnap(const Point &rPt)
Definition: svddrgmt.cxx:1504
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:2587
constexpr bool IsEmpty() const
void shearX(double fSx)
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
virtual ~SdrDragObjOwn() override
Definition: svddrgmt.cxx:1173
virtual ~SdrDragEntry()
Definition: svddrgmt.cxx:78
void SetRef2(const Point &pt)
Definition: svddrag.hxx:110
void clearSdrDragEntries()
Definition: svddrgmt.cxx:284
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:3391
bool IsDragLimit()
Definition: svddrgmt.hxx:169
Degree100 nAngle
Definition: svddrgm1.hxx:98
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:3376
Point BottomRight() const
Everything a View needs to know about a selected object.
Definition: svdmark.hxx:44
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod &rDragMethod) override
Definition: svddrgmt.cxx:166
bool bContortionAllowed
Definition: svddrgm1.hxx:193
SdrDragView & getSdrDragView()
Definition: svddrgmt.hxx:146
void ReduceInaccurate(unsigned nSignificantBits)
sdr::overlay::OverlayObjectList maOverlayObjectList
Definition: svddrgmt.hxx:119
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:3078
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdedtv.hxx:182
bool IsCrookNoContortion() const
Definition: svdsnpv.hxx:273
void ResizeMarkedGluePoints(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bCopy)
Definition: svdglev.cxx:368
OUString SvxResId(std::string_view aId)
Definition: dialmgr.cxx:25
void CopyMarkedObj()
Definition: svdedtv.cxx:907
UNDERLYING_TYPE get() const
virtual const SdrGluePointList * GetGluePointList() const
Definition: svdobj.cxx:2291
static bool GetRelativePolyPoint(const basegfx::B2DPolyPolygon &rPoly, sal_uInt32 nAbsPnt, sal_uInt32 &rPolyNum, sal_uInt32 &rPointNum)
Outputs the relative position ( polygon number and point number in that polygon ) from the absolute p...
void setMoveOnly(bool bNew)
Definition: svddrgmt.hxx:150
void HideDragObj()
Definition: svddrgv.cxx:834
void SetRef1(const Point &pt)
Definition: svddrag.hxx:108
bool HasMarkedObjPageView() const
Definition: svdpagv.hxx:181
Fraction aXFact
Definition: svddrgmt.hxx:261
double nSin
Definition: svddrgm1.hxx:50
int i
void ResizeMarkedObj(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bCopy=false)
Definition: svdedtv1.cxx:217
sal_uInt16 GetStripeLength()
SdrDragMirror(SdrDragView &rNewView)
Definition: svddrgmt.cxx:2471
uno_Any a
#define SDRGLUEPOINT_NOTFOUND
Definition: svdglue.hxx:117
bool equal(T const &rfValA, T const &rfValB)
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:3470
SdrSnap
Definition:
Definition: svdsnpv.hxx:71
SdrSnap SnapPos(Point &rPt) const
Definition: svddrgmt.hxx:173
void rotate(double fRadiant)
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:3536
const B2DPolyPolygon maOriginal
virtual basegfx::B2DHomMatrix getCurrentTransformation() override
Definition: svddrgmt.cxx:1499
virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix &rMatrix, const basegfx::B2DPolyPolygon &rPolyPolygon)
Definition: svdobj.cxx:3003
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:1249
Degree100 GetAngle(const Point &rPnt)
The Y axis points down! The function negates the Y axis, when calculating the angle, such that GetAngle(Point(0,-1))=90 deg.
Definition: svdtrans.cxx:387
bool bXSnapped
Definition: svddrgmt.hxx:234
void BroadcastObjectChange() const
Definition: svdobj.cxx:1011
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
BitmapEx createDefaultCross_3x3(const basegfx::BColor &rBColor)
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:251
SdrPageView * GetPageView() const
Definition: svdmark.hxx:70
SdrDragGradient(SdrDragView &rNewView, bool bGrad=true)
Definition: svddrgmt.cxx:2593
virtual bool supportsFullDrag() const
Definition: svdobj.cxx:1336
SdrObjectUniquePtr mxClone
Definition: svddrgmt.hxx:68
bool bMirrored
Definition: svddrgm1.hxx:99
virtual void CancelSdrDrag() override
Definition: svddrgmt.cxx:1134
#define DRAG_CROOK_RASTER_DISTANCE
Definition: svddrgmt.cxx:2800
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:2488
bool bRotateAllowed
Definition: svddrgm1.hxx:153
void FromIAOToItem(SdrObject *pObj, bool bSetItemOnObject, bool bUndo)
Definition: svdhdl.cxx:1367
bool bVertical
Definition: svddrgm1.hxx:155
static void ImpCrookObj(SdrObject *pO, const Point &rRef, const Point &rRad, SdrCrookMode eMode, bool bVertical, bool bNoContortion, bool bRotate, const tools::Rectangle &rMarkRect)
Definition: svdedtv1.cxx:489
bool IsDraggingGluePoints() const
Definition: svddrgmt.hxx:178
drawinglayer::primitive2d::Primitive2DContainer getViewIndependentPrimitive2DContainer() const
tools::Long nBestXSnap
Definition: svddrgmt.hxx:232
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget)
Definition: svddrgmt.cxx:582
void OrthoDistance8(const Point &rPt0, Point &rPt, bool bBigOrtho)
Definition: svdtrans.cxx:531
void scale(double fX, double fY)
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:279
void transform(const basegfx::B2DHomMatrix &rMatrix)
virtual ~SdrDragMethod()
Definition: svddrgmt.cxx:644
virtual void append(const Primitive2DReference &) override
void NextMove(const Point &rPnt)
Definition: svddrag.cxx:66
virtual void calculateGridOffsetForB2DRange(basegfx::B2DVector &rTarget, const basegfx::B2DRange &rB2DRange) const
const SdrMarkList & GetEdgesOfMarkedNodes() const
Definition: svdmrkv.hxx:266
virtual void createSdrDragEntries() override
Definition: svddrgmt.cxx:2874
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:2608
SdrPageView * GetPageView() const
Definition: svdhdl.hxx:200
virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon &rTarget) override
Definition: svddrgmt.cxx:3293
virtual void Move(const Size &rSiz)
Definition: svdobj.cxx:1538
void SetMergedItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1991
SdrPageView * mpMarkedPV
Definition: svdmrkv.hxx:103
bool bNoContortionAllowed
Definition: svddrgm1.hxx:194
bool IsResizeProtect() const
Definition: svdobj.hxx:749
Degree100 nAngle0
Definition: svddrgm1.hxx:52
virtual void CancelSdrDrag() override
Definition: svddrgmt.cxx:2729
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:3299
bool empty() const
bool IsCrookAtCenter() const
Definition: svddrgv.hxx:194
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
Definition: svdobj.cxx:2016
basegfx::B2DRange getCurrentRange() const
Definition: svddrgmt.cxx:279
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:76
bool getSolidDraggingActive() const
Definition: svddrgmt.hxx:216
Degree100 GetSnapAngle() const
Definition: svdsnpv.hxx:224
tools::Long Top() const
SdrDragMove(SdrDragView &rNewView)
Definition: svddrgmt.cxx:1462
Abstract DrawObject.
Definition: svdobj.hxx:258
XPolygon aDistortedRect
Definition: svddrgm1.hxx:191
Fraction aFact
Definition: svddrgm1.hxx:72
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:3422
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:2219
constexpr TypedWhichId< SdrGrafCropItem > SDRATTR_GRAFCROP(SDRATTR_GRAF_FIRST+9)
virtual void Mirror(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:1594
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
Definition: svdmodel.cxx:1847
attribute::SdrLineStartEndAttribute createNewSdrLineStartEndAttribute(const SfxItemSet &rSet, double fWidth)
#define Y
void CrookMarkedObj(const Point &rRef, const Point &rRad, SdrCrookMode eMode, bool bVertical, bool bNoContortion, bool bCopy=false)
Definition: svdedtv1.cxx:567
bool bContortion
Definition: svddrgm1.hxx:150
void CheckSnap(const Point &rPt, tools::Long &nBestXSnap, tools::Long &nBestYSnap, bool &bXSnapped, bool &bYSnapped) const
Definition: svdsnpv.cxx:412
Point aMarkCenter
Definition: svddrgm1.hxx:143
virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon &rTarget) override
Definition: svddrgmt.cxx:3521
sal_uInt16 FindGluePoint(sal_uInt16 nId) const
Definition: svdglue.cxx:336
constexpr Point TopLeft() const
bool HasLineStyle() const
Definition: svdobj.cxx:3048
virtual std::unique_ptr< SdrUndoAction > CreateUndoGeoObject(SdrObject &rObject)
Definition: svdundo.cxx:1638
SdrObject * mpMarkedObj
Definition: svdmrkv.hxx:102
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
const sdr::overlay::OverlayObjectList & getOverlayObjectList() const
Definition: svdhdl.hxx:191
void MovAllPoints(basegfx::B2DPolyPolygon &rTarget)
Definition: svddrgmt.cxx:3449
void MovCrookPoint(Point &rPnt, Point *pC1, Point *pC2)
Definition: svddrgmt.cxx:3032
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void ShearMarkedObj(const Point &rRef, Degree100 nAngle, bool bVShear=false, bool bCopy=false)
Definition: svdedtv1.cxx:455
void setY(double fY)
const tools::Rectangle & GetDragLimitRect()
Definition: svddrgmt.hxx:170
void RotateMarkedPoints(const Point &rRef, Degree100 nAngle)
Definition: svdpoev.cxx:640
Point aCenter
Definition: svddrgm1.hxx:144
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:2600
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:974
SdrObject * Next()
Definition: svditer.hxx:63
void setAddToTransparent(bool bNew)
Definition: svddrgmt.hxx:38
double nCos
Definition: svddrgm1.hxx:51
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual void createSdrDragEntries() override
Definition: svddrgmt.cxx:952
SdrHdl * GetHdl(size_t nNum) const
Definition: svdhdl.hxx:460
bool ImpCheckSide(const Point &rPnt) const
Definition: svddrgmt.cxx:2479
void RotatePoint(Point &rPnt, const Point &rRef, double sn, double cs)
Definition: svdtrans.hxx:114
void SetActionRect(const tools::Rectangle &rR)
Definition: svddrag.hxx:167
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
double getMinY() const
sal_uInt32 count() const
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:1108
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:3564
double nTan
Definition: svddrgm1.hxx:75
void createSdrDragEntries_GlueDrag()
Definition: svddrgmt.cxx:514
SdrHdlKind GetDragHdlKind() const
Definition: svddrgmt.hxx:162
sal_Int32 GetDenominator() const
basegfx::B2DPolyPolygon maOriginalPolyPolygon
Definition: svddrgmt.hxx:54
virtual basegfx::B2DHomMatrix getCurrentTransformation() override
Definition: svddrgmt.cxx:1815
SdrDragCrook(SdrDragView &rNewView)
Definition: svddrgmt.cxx:2751
tools::Rectangle & Union(const tools::Rectangle &rRect)
bool IsGradient() const
Definition: svddrgm1.hxx:129
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:2407
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:2774
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:958
bool IsControl(sal_uInt16 nPos) const
short path to read the CONTROL flag directly (TODO: better explain what the sense behind this flag is...
Definition: _xpoly.cxx:466
OUString ImpGetDescriptionString(const char *pStrCacheID, ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE) const
Definition: svdmrkv.cxx:2596
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svddrgmt.hxx:168
virtual void createSdrDragEntryForSdrObject(const SdrObject &rOriginal)
Definition: svddrgmt.cxx:321
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:2745
const SdrObject & maOriginal
Definition: svddrgmt.hxx:67
tools::Long nBestYSnap
Definition: svddrgmt.hxx:233
B2DHomMatrix createRotateAroundPoint(double fPointX, double fPointY, double fRadiant)
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:1722
double CrookSlantXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert)
Definition: svdtrans.cxx:217
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1981
virtual basegfx::B2DHomMatrix getCurrentTransformation() override
Definition: svddrgmt.cxx:2105
bool bResize
Definition: svddrgm1.hxx:77
SdrDragDistort(SdrDragView &rNewView)
Definition: svddrgmt.cxx:3382
virtual bool supportsGridOffsets() const
SdrPaintWindow & GetPaintWindow() const
#define F_PI18000
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:2044
SdrDragObjOwn(SdrDragView &rNewView)
Definition: svddrgmt.cxx:1161
#define DRAG_CROOK_RASTER_MINIMUM
Definition: svddrgmt.cxx:2798
void MoveMarkedPoints(const Size &rSiz)
Definition: svdpoev.cxx:606
std::vector< basegfx::B2DPoint > maPositions
Definition: svddrgmt.hxx:104
B2DPoint distort(const B2DPoint &rCandidate, const B2DRange &rOriginal, const B2DPoint &rTopLeft, const B2DPoint &rTopRight, const B2DPoint &rBottomLeft, const B2DPoint &rBottomRight)
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:1148
sal_Int32 GetNumerator() const
void createSdrDragEntries_PointDrag()
Definition: svddrgmt.cxx:469
void AddUndoActions(std::vector< std::unique_ptr< SdrUndoAction > >)
Definition: svdedtv1.cxx:177
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:96
SdrObject * GetDragObj() const
Definition: svddrgmt.cxx:566
static size_t GetDragXorPolyLimit()
Definition: svddrgv.hxx:157
virtual SdrObjectUniquePtr getFullDragClone() const
Definition: svdobj.cxx:1341
Fraction aYFact
Definition: svddrgmt.hxx:262
const Point & GetNow() const
Definition: svddrag.hxx:105
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1347
basegfx::B2DRange getBaseRange() const
static BitmapEx createGluePointBitmap()
Definition: svdhdl.cxx:1073
void translate(double fX, double fY)
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
Definition: svddrgmt.hxx:90
PointerStyle
bool IsCrookAllowed(bool bNoContortion=false) const
Definition: svdedtv.cxx:447
void SetMoveFirstHandle(bool bNew)
Definition: svdhdl.hxx:335
const basegfx::B2DPolyPolygon & GetPathPoly() const
Definition: svdopath.hxx:141
basegfx::BColor getBColor() const
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:1583
ImpGetDescriptionOptions
options for ImpGetDescriptionString()
Definition: svdmrkv.hxx:80
drawinglayer::primitive2d::Primitive2DContainer AddConnectorOverlays()
Definition: svddrgmt.cxx:868
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:299
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll)
Definition: svdedxv.cxx:2131
bool IsMirrored() const
Definition: svdograf.hxx:204
bool bNoContortionAllowed
Definition: svddrgm1.hxx:149
void SetShown(bool bOn)
Definition: svddrag.hxx:116
const SdrObject & getOriginal() const
Definition: svddrgmt.hxx:80
virtual bool applySpecialDrag(SdrDragStat &rDrag)
Definition: svdobj.cxx:1358
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
Degree100 NormAngle18000(Degree100 a)
Definition: svdtrans.cxx:402
Degree100 nAngle0
Definition: svddrgm1.hxx:73
virtual void MoveSdrDrag(const Point &rPnt) override
Definition: svddrgmt.cxx:2275
bool bVertical
Definition: svddrgm1.hxx:76
void RotateXPoly(XPolygon &rPoly, const Point &rRef, double sn, double cs)
Definition: svdtrans.cxx:89
double getX() const
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:3241
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:1491
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:311
double getMinX() const
void destroyOverlayGeometry()
Definition: svddrgmt.cxx:832
OUString GetMetricString(tools::Long nVal, bool bNoUnitChars=false, sal_Int32 nNumDigits=-1) const
Definition: svdmodel.cxx:971
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:1338
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const override
Definition: svdotext.cxx:1570
Degree100 abs(Degree100 x)
virtual ~SdrDragEntrySdrObject() override
Definition: svddrgmt.cxx:145
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:3855
virtual void createSdrDragEntries() override
Definition: svddrgmt.cxx:3405
virtual ~SdrDragEntryPolyPolygon() override
Definition: svddrgmt.cxx:89
static OUString GetPercentString(const Fraction &rVal)
Definition: svdmodel.cxx:1123
SdrMark * GetSdrMarkByIndex(size_t nNum) const
Definition: svdmrkv.hxx:255
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:1702
void RotateMarkedGluePoints(const Point &rRef, Degree100 nAngle, bool bCopy)
Definition: svdglev.cxx:386
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:1770
bool IsValid() const
SdrCrookMode eMode
Definition: svddrgm1.hxx:164
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
bool isHitLogic(const basegfx::B2DPoint &rLogicPosition, double fLogicTolerance=0.0) const
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const
Definition: svdobj.cxx:2976
bool IsCon2() const
Definition: svdmark.hxx:95
SdrDragEntryPrimitive2DSequence(const drawinglayer::primitive2d::Primitive2DContainer &rSequence)
Definition: svddrgmt.cxx:182
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
bool IsVerFixed() const
Definition: svddrag.hxx:125
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:2505
sal_uInt16 GetPointCount() const
Definition: _xpoly.cxx:346
virtual std::unique_ptr< SdrUndoAction > CreateUndoAttrObject(SdrObject &rObject, bool bStyleSheet1=false, bool bSaveText=false)
Definition: svdundo.cxx:1643
void reserve(sal_uInt32 nCount)
virtual ~SdrDragEntryPrimitive2DSequence() override
Definition: svddrgmt.cxx:191
virtual void SetChanged()
Definition: svdobj.cxx:1035
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:1472
virtual OUString GetSdrDragComment() const override
Definition: svddrgmt.cxx:2200
SdrPageView * GetDragPV() const
Definition: svddrgmt.cxx:574
OUString ImpGetDescriptionStr(const char *pStrCacheID) const
Definition: svddrgmt.cxx:555
virtual bool BeginSdrDrag() override
Definition: svddrgmt.cxx:965
virtual basegfx::B2DHomMatrix getCurrentTransformation() override
Definition: svddrgmt.cxx:2538
sal_uInt16 nPolyPt
Definition: svddrgm1.hxx:192
sal_uInt16 GetTransparentSelectionPercent()
bool IsMoveOnlyDragging() const
Definition: svdsnpv.hxx:265
void OrthoDistance4(const Point &rPt0, Point &rPt, bool bBigOrtho)
Definition: svdtrans.cxx:547
SdrModel * GetModel() const
Definition: svdpntv.hxx:260
void SetMoveSingleHandle(bool bNew)
Definition: svdhdl.hxx:333
SdrObjUserCall * GetUserCall() const
Definition: svdobj.hxx:833
#define DRAG_CROOK_RASTER_MAXIMUM
Definition: svddrgmt.cxx:2799
bool IsNoSnap() const
Definition: svddrag.hxx:130
aStr
bool IsDraggingPoints() const
Definition: svddrgmt.hxx:177
OutputDevice & GetOutputDevice() const
void MoveMarkedGluePoints(const Size &rSiz, bool bCopy)
Definition: svdglev.cxx:350
void MovAllPoints(basegfx::B2DPolyPolygon &rTarget)
Definition: svddrgmt.cxx:2915
tools::Long Right() const
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2742
void insertNewlyCreatedOverlayObjectForSdrDragMethod(std::unique_ptr< sdr::overlay::OverlayObject > pOverlayObject, const sdr::contact::ObjectContact &rObjectContact, sdr::overlay::OverlayManager &rOverlayManager)
Definition: svddrgmt.cxx:328
sal_uInt16 GetAngleSector(Degree100 nAngle)
Normalize angle to 0.00..359.99.
Definition: svdtrans.cxx:418
Point Center() const
virtual void applyCurrentTransformationToSdrObject(SdrObject &rTarget) override
Definition: svddrgmt.cxx:1457
virtual bool EndSdrDrag(bool bCopy) override
Definition: svddrgmt.cxx:2159
bool bAtCenter
Definition: svddrgm1.hxx:161
SdrDragMovHdl(SdrDragView &rNewView)
Definition: svddrgmt.cxx:947
SdrHdlKind GetKind() const
Definition: svdhdl.hxx:194
bool IsDistortAllowed(bool bNoContortion=false) const
Definition: svdedtv.cxx:459
Utility class SdrEdgeObj.
Definition: svdoedge.hxx:127
const SdrHdlList & GetHdlList() const
Definition: svddrgmt.hxx:167
sal_uInt32 count() const
bool IsMoveSingleHandle() const
Definition: svdhdl.hxx:332
constexpr tools::Long GetHeight() const
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void MoveMarkedObj(const Size &rSiz, bool bCopy=false)
Definition: svdedtv1.cxx:183
sal_uInt32 PageWindowCount() const
Definition: svdpagv.hxx:93
virtual PointerStyle GetSdrDragPointer() const override
Definition: svddrgmt.cxx:2181
bool IsEndDragChangesAttributes() const
Definition: svddrag.hxx:142