diff options
author | Armin Weiss <aw@openoffice.org> | 2001-03-13 11:55:21 +0000 |
---|---|---|
committer | Armin Weiss <aw@openoffice.org> | 2001-03-13 11:55:21 +0000 |
commit | 40c61e9ad1c7f787a33ed657cdb35df988de89ca (patch) | |
tree | 2dda2a51838da6d43282b2b91b1059871e462134 /svx | |
parent | e376910021a92104048230f3eac9becafc7f4ad1 (diff) |
#83259# Changed behaviour of TRSetBaseGeometry/TRGetBaseGeometry to
take MapUnits and AnchorPos into account
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 80 | ||||
-rw-r--r-- | svx/source/svdraw/svdopath.cxx | 102 | ||||
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 68 |
3 files changed, 231 insertions, 19 deletions
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 2f24bf778202..30215ce00e45 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: svdobj.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: aw $ $Date: 2001-02-15 16:11:33 $ + * last change: $Author: aw $ $Date: 2001-03-13 12:55:21 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -130,6 +130,12 @@ using namespace ::com::sun::star; +/*********************************************************************** +* Macros fuer Umrechnung Twips<->100tel mm * +***********************************************************************/ +#define TWIPS_TO_MM(val) ((val * 127 + 36) / 72) +#define MM_TO_TWIPS(val) ((val * 72 + 63) / 127) + //////////////////////////////////////////////////////////////////////////////////////////////////// TYPEINIT0(SdrObjUserCall); @@ -4318,13 +4324,46 @@ BOOL SdrObject::TRGetBaseGeometry(Matrix3D& rMat, XPolyPolygon& rPolyPolygon) co { // any kind of SdrObject, just use SnapRect Rectangle aRectangle(GetSnapRect()); + + // convert to transformation values Vector2D aScale((double)aRectangle.GetWidth(), (double)aRectangle.GetHeight()); Vector2D aTranslate((double)aRectangle.Left(), (double)aRectangle.Top()); + // position maybe relative to anchorpos, convert + if(GetAnchorPos().X() != 0 || GetAnchorPos().Y() != 0) + aTranslate -= Vector2D(GetAnchorPos().X(), GetAnchorPos().Y()); + + // force MapUnit to 100th mm + SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + // postion + aTranslate.X() = TWIPS_TO_MM(aTranslate.X()); + aTranslate.Y() = TWIPS_TO_MM(aTranslate.Y()); + + // size + aScale.X() = TWIPS_TO_MM(aScale.X()); + aScale.Y() = TWIPS_TO_MM(aScale.Y()); + + break; + } + default: + { + DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!"); + } + } + } + // build matrix rMat.Identity(); - rMat.Scale(aScale.X(), aScale.Y()); - rMat.Translate(aTranslate.X(), aTranslate.Y()); + if(aScale.X() != 1.0 || aScale.Y() != 1.0) + rMat.Scale(aScale.X(), aScale.Y()); + if(aTranslate.X() != 0.0 || aTranslate.Y() != 0.0) + rMat.Translate(aTranslate.X(), aTranslate.Y()); return FALSE; } @@ -4339,11 +4378,38 @@ void SdrObject::TRSetBaseGeometry(const Matrix3D& rMat, const XPolyPolygon& rPol double fShear, fRotate; rMat.DecomposeAndCorrect(aScale, fShear, fRotate, aTranslate); + // force metric to pool metric + SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + // position + aTranslate.X() = MM_TO_TWIPS(aTranslate.X()); + aTranslate.Y() = MM_TO_TWIPS(aTranslate.Y()); + + // size + aScale.X() = MM_TO_TWIPS(aScale.X()); + aScale.Y() = MM_TO_TWIPS(aScale.Y()); + + break; + } + default: + { + DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!"); + } + } + } + + // if anchor is used, make position relative to it + if(GetAnchorPos().X() != 0 || GetAnchorPos().Y() != 0) + aTranslate -= Vector2D(GetAnchorPos().X(), GetAnchorPos().Y()); + // build BaseRect Point aPoint(FRound(aTranslate.X()), FRound(aTranslate.Y())); - Rectangle aBaseRect( - aPoint, - Size(FRound(aScale.X()), FRound(aScale.Y()))); + Rectangle aBaseRect(aPoint, Size(FRound(aScale.X()), FRound(aScale.Y()))); // set BaseRect SetSnapRect(aBaseRect); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 8cdffb169500..d7c03383d0fa 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2,9 +2,9 @@ * * $RCSfile: svdopath.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: aw $ $Date: 2001-02-22 12:22:52 $ + * last change: $Author: aw $ $Date: 2001-03-13 12:55:21 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,6 +97,12 @@ #include <vcl/salbtype.hxx> // FRound #endif +/*********************************************************************** +* Macros fuer Umrechnung Twips<->100tel mm * +***********************************************************************/ +#define TWIPS_TO_MM(val) ((val * 127 + 36) / 72) +#define MM_TO_TWIPS(val) ((val * 72 + 63) / 127) + /*************************************************************************/ #define SVDOPATH_INITSIZE 20 @@ -2418,13 +2424,6 @@ FASTBOOL SdrPathObj::NbcDelPoint(USHORT nHdlNum) } } else if (!bPrevIsBez && bNextIsBez) { nDelAnz=3; // Uebergang Kurve nach Linie -#ifdef DBG_UTIL - } else { - ByteString aStr("SdrPathObj::NbcDelPoint(USHORT("); - aStr += nHdlNum; - aStr += ")): Unerlaubt im else-Zweig"; - DBG_ERROR(aStr.GetBuffer()); -#endif } if (nDelAnz!=0) rXPoly.Remove(nDelOfs,nDelAnz); if (bClosed) { // letzten Punkt auf den Ersten setzen @@ -3062,6 +3061,46 @@ BOOL SdrPathObj::TRGetBaseGeometry(Matrix3D& rMat, XPolyPolygon& rPolyPolygon) c // polygon to (0,0) rPolyPolygon.Move(-aRectangle.Left(), -aRectangle.Top()); + // position maybe relative to anchorpos, convert + if(GetAnchorPos().X() != 0 || GetAnchorPos().Y() != 0) + aTranslate -= Vector2D(GetAnchorPos().X(), GetAnchorPos().Y()); + + // force MapUnit to 100th mm + SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + // position + aTranslate.X() = TWIPS_TO_MM(aTranslate.X()); + aTranslate.Y() = TWIPS_TO_MM(aTranslate.Y()); + + // size + aScale.X() = TWIPS_TO_MM(aScale.X()); + aScale.Y() = TWIPS_TO_MM(aScale.Y()); + + // polygon + for(sal_uInt16 a(0); a < rPolyPolygon.Count(); a++) + { + XPolygon& rPoly = rPolyPolygon[a]; + for(sal_uInt16 b(0); b < rPoly.GetPointCount(); b++) + { + rPoly[b].X() = TWIPS_TO_MM(rPoly[b].X()); + rPoly[b].Y() = TWIPS_TO_MM(rPoly[b].Y()); + } + } + + break; + } + default: + { + DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!"); + } + } + } + // build matrix rMat.Identity(); if(aScale.X() != 1.0 || aScale.Y() != 1.0) @@ -3086,14 +3125,57 @@ void SdrPathObj::TRSetBaseGeometry(const Matrix3D& rMat, const XPolyPolygon& rPo double fShear, fRotate; rMat.DecomposeAndCorrect(aScale, fShear, fRotate, aTranslate); + // copy poly + XPolyPolygon aNewPolyPolygon(rPolyPolygon); + // reset object shear and rotations aGeo.nDrehWink = 0; aGeo.RecalcSinCos(); aGeo.nShearWink = 0; aGeo.RecalcTan(); + // force metric to pool metric + SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + // position + aTranslate.X() = MM_TO_TWIPS(aTranslate.X()); + aTranslate.Y() = MM_TO_TWIPS(aTranslate.Y()); + + // size + aScale.X() = MM_TO_TWIPS(aScale.X()); + aScale.Y() = MM_TO_TWIPS(aScale.Y()); + + // polygon + for(sal_uInt16 a(0); a < aNewPolyPolygon.Count(); a++) + { + XPolygon& rPoly = aNewPolyPolygon[a]; + for(sal_uInt16 b(0); b < rPoly.GetPointCount(); b++) + { + rPoly[b].X() = MM_TO_TWIPS(rPoly[b].X()); + rPoly[b].Y() = MM_TO_TWIPS(rPoly[b].Y()); + } + } + + break; + } + default: + { + DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!"); + } + } + } + + // if anchor is used, make position relative to it + if(GetAnchorPos().X() != 0 || GetAnchorPos().Y() != 0) + aTranslate -= Vector2D(GetAnchorPos().X(), GetAnchorPos().Y()); + // set PathPoly - SetPathPoly(rPolyPolygon); + SetPathPoly(aNewPolyPolygon); // shear? if(fShear != 0.0) diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 88691ec713a8..65f0c1fb0195 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: svdotext.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: dl $ $Date: 2001-03-07 10:31:51 $ + * last change: $Author: aw $ $Date: 2001-03-13 12:55:21 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,6 +120,12 @@ #include "xflgrit.hxx" #endif +/*********************************************************************** +* Macros fuer Umrechnung Twips<->100tel mm * +***********************************************************************/ +#define TWIPS_TO_MM(val) ((val * 127 + 36) / 72) +#define MM_TO_TWIPS(val) ((val * 72 + 63) / 127) + //////////////////////////////////////////////////////////////////////////////////////////////////// // // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@ @@ -2141,6 +2147,35 @@ BOOL SdrTextObj::TRGetBaseGeometry(Matrix3D& rMat, XPolyPolygon& rPolyPolygon) c Vector2D aScale((double)aRectangle.GetWidth(), (double)aRectangle.GetHeight()); Vector2D aTranslate((double)aRectangle.Left(), (double)aRectangle.Top()); + // position maybe relative to anchorpos, convert + if(GetAnchorPos().X() != 0 || GetAnchorPos().Y() != 0) + aTranslate -= Vector2D(GetAnchorPos().X(), GetAnchorPos().Y()); + + // force MapUnit to 100th mm + SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + // position + aTranslate.X() = TWIPS_TO_MM(aTranslate.X()); + aTranslate.Y() = TWIPS_TO_MM(aTranslate.Y()); + + // size + aScale.X() = TWIPS_TO_MM(aScale.X()); + aScale.Y() = TWIPS_TO_MM(aScale.Y()); + + break; + } + default: + { + DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!"); + } + } + } + // build matrix rMat.Identity(); if(aScale.X() != 1.0 || aScale.Y() != 1.0) @@ -2171,6 +2206,35 @@ void SdrTextObj::TRSetBaseGeometry(const Matrix3D& rMat, const XPolyPolygon& rPo aGeo.nShearWink = 0; aGeo.RecalcTan(); + // force metric to pool metric + SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + switch(eMapUnit) + { + case SFX_MAPUNIT_TWIP : + { + // position + aTranslate.X() = MM_TO_TWIPS(aTranslate.X()); + aTranslate.Y() = MM_TO_TWIPS(aTranslate.Y()); + + // size + aScale.X() = MM_TO_TWIPS(aScale.X()); + aScale.Y() = MM_TO_TWIPS(aScale.Y()); + + break; + } + default: + { + DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!"); + } + } + } + + // if anchor is used, make position relative to it + if(GetAnchorPos().X() != 0 || GetAnchorPos().Y() != 0) + aTranslate -= Vector2D(GetAnchorPos().X(), GetAnchorPos().Y()); + // build and set BaseRect (use scale) Point aPoint = Point(); Size aSize(FRound(aScale.X()), FRound(aScale.Y())); |