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