summaryrefslogtreecommitdiff
path: root/svx/source/svdraw
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-02-13 07:46:14 +0000
committerOliver Bolte <obo@openoffice.org>2009-02-13 07:46:14 +0000
commit0162fbb76ca95af2e98ee1445e1eb57e001b2c9e (patch)
tree56c64da7ad401a2f4e4f7f29eabb7806c42e6033 /svx/source/svdraw
parent936accce7a2b1acb62230d174c1e5413baf499e6 (diff)
CWS-TOOLING: integrate CWS aw062
2009-01-27 15:15:53 +0100 aw r266999 : #i97982# corrected small error in ObjectContactOfPageView::isOutputToPDFFile() 2009-01-15 16:02:22 +0100 aw r266378 : #i89872# corrected SdrModel::ImpSetUIUnit to not lose numeric information 2009-01-14 15:16:43 +0100 aw r266309 : #i98072# adde d text suppression for FontworkGallery AutoShapes in ViewContactOfSdrObjCustomShape::createViewIndependentPrimitive2DSequence 2009-01-14 12:35:32 +0100 aw r266283 : #i97878# added TRGetBaseGeometry/TRSetBaseGeometry implementations to SdrMeasureObj 2009-01-14 12:06:47 +0100 aw r266274 : #i97981# corrected the interpretation of bBehaveCompatibleToPaintVersion for line attribute in SdrOle2Primitive2D::createLocalDecomposition 2009-01-14 11:54:07 +0100 aw r266272 : #i97982# added #i97772# to have a correct ChartPrettyPainter output for ChartPrettyPainter 2009-01-14 11:53:13 +0100 aw r266271 : #i97982# added support for ChartPrettyPainter for PDF export 2009-01-13 16:19:19 +0100 aw r266234 : #i96708# adapted RenderBitmapPrimitive2D_self to work with metafile recording and PDF exporting
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r--svx/source/svdraw/svdmodel.cxx116
-rw-r--r--svx/source/svdraw/svdomeas.cxx130
2 files changed, 196 insertions, 50 deletions
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 43f7b841516c..194949474336 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -976,17 +976,19 @@ void SdrModel::SetDefaultTabulator(USHORT nVal)
void SdrModel::ImpSetUIUnit()
{
- if (aUIScale.GetNumerator()==0 || aUIScale.GetDenominator()==0) aUIScale=Fraction(1,1);
- FASTBOOL bMapInch=IsInch(eObjUnit);
- FASTBOOL bMapMetr=IsMetric(eObjUnit);
- FASTBOOL bUIInch=IsInch(eUIUnit);
- FASTBOOL bUIMetr=IsMetric(eUIUnit);
- nUIUnitKomma=0;
- long nMul=1;
- long nDiv=1;
+ if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator())
+ {
+ aUIScale = Fraction(1,1);
+ }
+
+ // set start values
+ nUIUnitKomma = 0;
+ sal_Int64 nMul(1);
+ sal_Int64 nDiv(1);
- // Zunaechst normalisieren auf m bzw. "
- switch (eObjUnit) {
+ // normalize on meters resp. inch
+ switch (eObjUnit)
+ {
case MAP_100TH_MM : nUIUnitKomma+=5; break;
case MAP_10TH_MM : nUIUnitKomma+=4; break;
case MAP_MM : nUIUnitKomma+=3; break;
@@ -1010,7 +1012,8 @@ void SdrModel::ImpSetUIUnit()
// 1 pole = 5 1/2 yd = 198" = 5.029,2mm
// 1 yd = 3 ft = 36" = 914,4mm
// 1 ft = 12 " = 1" = 304,8mm
- switch (eUIUnit) {
+ switch (eUIUnit)
+ {
case FUNIT_NONE : break;
// Metrisch
case FUNIT_100TH_MM: nUIUnitKomma-=5; break;
@@ -1030,48 +1033,61 @@ void SdrModel::ImpSetUIUnit()
case FUNIT_PERCENT: nUIUnitKomma+=2; break;
} // switch
- if (bMapInch && bUIMetr) {
- nUIUnitKomma+=4;
- nMul*=254;
- }
- if (bMapMetr && bUIInch) {
- nUIUnitKomma-=4;
- nDiv*=254;
- }
-
- // Temporaere Fraction zum Kuerzen
- Fraction aTempFract(nMul,nDiv);
- nMul=aTempFract.GetNumerator();
- nDiv=aTempFract.GetDenominator();
- // Nun mit dem eingestellten Masstab verknuepfen
- BigInt nBigMul(nMul);
- BigInt nBigDiv(nDiv);
- BigInt nBig1000(1000);
- nBigMul*=aUIScale.GetDenominator();
- nBigDiv*=aUIScale.GetNumerator();
- while (nBigMul>nBig1000) {
+ // check if mapping is from metric to inch and adapt
+ const bool bMapInch(IsInch(eObjUnit));
+ const bool bUIMetr(IsMetric(eUIUnit));
+
+ if (bMapInch && bUIMetr)
+ {
+ nUIUnitKomma += 4;
+ nMul *= 254;
+ }
+
+ // check if mapping is from inch to metric and adapt
+ const bool bMapMetr(IsMetric(eObjUnit));
+ const bool bUIInch(IsInch(eUIUnit));
+
+ if (bMapMetr && bUIInch)
+ {
+ nUIUnitKomma -= 4;
+ nDiv *= 254;
+ }
+
+ // use temporary fraction for reduction (fallback to 32bit here),
+ // may need to be changed in the future, too
+ if(1 != nMul || 1 != nDiv)
+ {
+ const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv));
+ nMul = aTemp.GetNumerator();
+ nDiv = aTemp.GetDenominator();
+ }
+
+ // #i89872# take Unit of Measurement into account
+ if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator())
+ {
+ // divide by UIScale
+ nMul *= aUIScale.GetDenominator();
+ nDiv *= aUIScale.GetNumerator();
+ }
+
+ // shorten trailing zeroes for dividend
+ while(0 == (nMul % 10))
+ {
nUIUnitKomma--;
- nBigMul/=10;
+ nMul /= 10;
}
- while (nBigDiv>nBig1000) {
+
+ // shorten trailing zeroes for divisor
+ while(0 == (nDiv % 10))
+ {
nUIUnitKomma++;
- nBigDiv/=10;
- }
- nMul=long(nBigMul);
- nDiv=long(nBigDiv);
- switch ((short)nMul) {
- case 10: nMul=1; nUIUnitKomma--; break;
- case 100: nMul=1; nUIUnitKomma-=2; break;
- case 1000: nMul=1; nUIUnitKomma-=3; break;
- } // switch
- switch ((short)nDiv) {
- case 10: nDiv=1; nUIUnitKomma++; break;
- case 100: nDiv=1; nUIUnitKomma+=2; break;
- case 1000: nDiv=1; nUIUnitKomma+=3; break;
- } // switch
- aUIUnitFact=Fraction(nMul,nDiv);
- bUIOnlyKomma=nMul==nDiv;
- TakeUnitStr(eUIUnit,aUIUnitStr);
+ nDiv /= 10;
+ }
+
+ // end preparations, set member values
+ aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
+ bUIOnlyKomma = (nMul == nDiv);
+ TakeUnitStr(eUIUnit, aUIUnitStr);
}
void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 5e61a923a51e..6f97d4051b28 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -71,6 +71,7 @@
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1441,4 +1442,133 @@ USHORT SdrMeasureObj::GetOutlinerViewAnchorMode() const
return (USHORT)eRet;
}
+//////////////////////////////////////////////////////////////////////////////
+// #i97878#
+// TRGetBaseGeometry/TRSetBaseGeometry needs to be based on two positions,
+// same as line geometry in SdrPathObj. Thus needs to be overloaded and
+// implemented since currently it is derived from SdrTextObj which uses
+// a functionality based on SnapRect which is not useful here
+
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+
+sal_Bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
+{
+ // handle the same as a simple line since the definition is based on two points
+ const basegfx::B2DRange aRange(aPt1.X(), aPt1.Y(), aPt2.X(), aPt2.Y());
+ basegfx::B2DTuple aScale(aRange.getRange());
+ basegfx::B2DTuple aTranslate(aRange.getMinimum());
+
+ // position maybe relative to anchorpos, convert
+ if( pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate -= basegfx::B2DTuple(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.setX(ImplTwipsToMM(aTranslate.getX()));
+ aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplTwipsToMM(aScale.getX()));
+ aScale.setY(ImplTwipsToMM(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+
+ // build return value matrix
+ rMatrix.identity();
+
+ if(!basegfx::fTools::equal(aScale.getX(), 1.0) || !basegfx::fTools::equal(aScale.getY(), 1.0))
+ {
+ rMatrix.scale(aScale.getX(), aScale.getY());
+ }
+
+ if(!aTranslate.equalZero())
+ {
+ rMatrix.translate(aTranslate.getX(), aTranslate.getY());
+ }
+
+ return sal_True;
+}
+
+void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
+{
+ // use given transformation to derive the two defining points from unit line
+ basegfx::B2DPoint aPosA(rMatrix * basegfx::B2DPoint(0.0, 0.0));
+ basegfx::B2DPoint aPosB(rMatrix * basegfx::B2DPoint(1.0, 0.0));
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aPosA.setX(ImplMMToTwips(aPosA.getX()));
+ aPosA.setY(ImplMMToTwips(aPosA.getY()));
+ aPosB.setX(ImplMMToTwips(aPosB.getX()));
+ aPosB.setY(ImplMMToTwips(aPosB.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ if( pModel->IsWriter() )
+ {
+ // if anchor is used, make position relative to it
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ const basegfx::B2DVector aAnchorOffset(GetAnchorPos().X(), GetAnchorPos().Y());
+
+ aPosA += aAnchorOffset;
+ aPosB += aAnchorOffset;
+ }
+ }
+
+ // derive new model data
+ const Point aNewPt1(basegfx::fround(aPosA.getX()), basegfx::fround(aPosA.getY()));
+ const Point aNewPt2(basegfx::fround(aPosB.getX()), basegfx::fround(aPosB.getY()));
+
+ if(aNewPt1 != aPt1 || aNewPt2 != aPt2)
+ {
+ // set model values and broadcast
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+
+ aPt1 = aNewPt1;
+ aPt2 = aNewPt2;
+
+ SetTextDirty();
+ ActionChanged();
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
// eof