You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2013/10/04 19:20:26 UTC
svn commit: r1529226 [4/4] - in /openoffice/branches/alg/aw080/main:
basegfx/inc/basegfx/matrix/ basegfx/source/matrix/ filter/source/msfilter/
offapi/com/sun/star/drawing/ sd/inc/pch/ sd/source/ui/dlg/
sd/source/ui/func/ sd/source/ui/inc/ sd/source/ui...
Modified: openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx?rev=1529226&r1=1529225&r2=1529226&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx (original)
+++ openoffice/branches/alg/aw080/main/svx/source/svdraw/svdoedge.cxx Fri Oct 4 17:20:25 2013
@@ -55,6 +55,10 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
+#define SDRESC_VERT (sdr::glue::Point::ESCAPE_DIRECTION_TOP|sdr::glue::Point::ESCAPE_DIRECTION_BOTTOM)
+#define SDRESC_HORZ (sdr::glue::Point::ESCAPE_DIRECTION_LEFT|sdr::glue::Point::ESCAPE_DIRECTION_RIGHT)
+#define SDRESC_ALL (SDRESC_HORZ|SDRESC_VERT)
+
SdrObjConnection::~SdrObjConnection()
{
}
@@ -68,43 +72,54 @@ void SdrObjConnection::ResetVars()
mbAutoVertex = false;
}
-bool SdrObjConnection::TakeGluePoint(SdrGluePoint& rGP, bool bSetAbsPos) const
+bool SdrObjConnection::TakeGluePoint(sdr::glue::Point& rGP/* TTTT:GLUE, bool bSetAbsPos*/) const
{
- bool bRet=false;
-
- if(mpConnectedSdrObject)
- {
- // Ein Obj muss schon angedockt sein!
- if(mbAutoVertex)
- {
- rGP = mpConnectedSdrObject->GetVertexGluePoint(mnConnectorId);
- bRet = true;
- }
- else
- {
- const SdrGluePointList* pGPL = mpConnectedSdrObject->GetGluePointList();
+ bool bRet(false);
- if(pGPL)
- {
- const sal_uInt32 nNum(pGPL->FindGluePoint(mnConnectorId));
-
- if(SDRGLUEPOINT_NOTFOUND != nNum)
- {
- rGP=(*pGPL)[nNum];
- bRet = true;
- }
- }
- }
- }
+ if(mpConnectedSdrObject)
+ {
+ // Ein Obj muss schon angedockt sein!
+ if(mbAutoVertex)
+ {
+ rGP = mpConnectedSdrObject->GetVertexGluePoint(mnConnectorId);
+ bRet = true;
+ }
+ else
+ {
+ const sdr::glue::List* pGPL = mpConnectedSdrObject->GetGluePointList(false);
- if(bRet && bSetAbsPos)
- {
- const basegfx::B2DPoint aPt(rGP.GetAbsolutePos(sdr::legacy::GetSnapRange(*mpConnectedSdrObject)));
-
- rGP.SetPos(aPt + maObjOfs);
- }
+ if(pGPL)
+ {
+ sdr::glue::Point* pCandidate = pGPL->findByID(mnConnectorId);
+
+ if(pCandidate)
+ {
+ rGP = *pCandidate;
+ bRet = true;
+ }
+
+ // TTTT:GLUE
+ //const sal_uInt32 nNum(pGPL->FindGluePoint(mnConnectorId));
+ //
+ //if(SDRGLUEPOINT_NOTFOUND != nNum)
+ //{
+ // rGP=(*pGPL)[nNum];
+ // bRet = true;
+ //}
+ }
+ }
+ }
+
+ //if(bRet && bSetAbsPos)
+ //{
+ //
+ //
+ // const basegfx::B2DPoint aPt(rGP.GetAbsolutePos(sdr::legacy::GetSnapRange(*mpConnectedSdrObject)));
+ //
+ // rGP.SetPos(aPt + maObjOfs);
+ //}
- return bRet;
+ return bRet;
}
basegfx::B2DPoint& SdrEdgeInfoRec::ImpGetLineVersatzPoint(SdrEdgeLineCode eLineCode)
@@ -120,36 +135,36 @@ basegfx::B2DPoint& SdrEdgeInfoRec::ImpGe
return aMiddleLine;
}
-sal_uInt16 SdrEdgeInfoRec::ImpGetPolyIdx(SdrEdgeLineCode eLineCode, sal_uInt32 nPointCount) const
+sal_uInt32 SdrEdgeInfoRec::ImpGetPolyIdx(SdrEdgeLineCode eLineCode, sal_uInt32 nPointCount) const
{
- switch (eLineCode)
+ switch (eLineCode)
{
- case OBJ1LINE2 : return 1;
- case OBJ1LINE3 : return 2;
- case OBJ2LINE2 : return nPointCount - 3;
- case OBJ2LINE3 : return nPointCount - 4;
- case MIDDLELINE: return nMiddleLine;
- } // switch
- return 0;
+ case OBJ1LINE2 : return 1;
+ case OBJ1LINE3 : return 2;
+ case OBJ2LINE2 : return nPointCount - 3;
+ case OBJ2LINE3 : return nPointCount - 4;
+ case MIDDLELINE: return nMiddleLine;
+ } // switch
+ return 0;
}
bool SdrEdgeInfoRec::ImpIsHorzLine(SdrEdgeLineCode eLineCode, sal_uInt32 nPointCount) const
{
- sal_uInt16 nIdx(ImpGetPolyIdx(eLineCode, nPointCount));
- bool bHorz(0 == nAngle1 || 18000 == nAngle1);
+ sal_uInt32 nIdx(ImpGetPolyIdx(eLineCode, nPointCount));
+ bool bHorz(0 == nAngle1 || 18000 == nAngle1);
if(OBJ2LINE2 == eLineCode || OBJ2LINE3 == eLineCode)
{
- nIdx = nPointCount - nIdx;
- bHorz = (0 == nAngle2 || 18000 == nAngle2);
- }
+ nIdx = nPointCount - nIdx;
+ bHorz = (0 == nAngle2 || 18000 == nAngle2);
+ }
if(1 == (nIdx & 1))
{
bHorz = !bHorz;
}
- return bHorz;
+ return bHorz;
}
void SdrEdgeInfoRec::ImpSetLineVersatz(SdrEdgeLineCode eLineCode, sal_uInt32 nPointCount, long nVal)
@@ -453,53 +468,64 @@ sal_uInt16 SdrEdgeObj::GetObjIdentifier(
return sal_uInt16(OBJ_EDGE);
}
-SdrGluePoint SdrEdgeObj::GetVertexGluePoint(sal_uInt32 nNum) const
+sdr::glue::Point SdrEdgeObj::GetVertexGluePoint(sal_uInt32 nNum) const
{
- basegfx::B2DPoint aPoint(0.0, 0.0);
- const sal_uInt32 nPntAnz(maEdgeTrack.count());
+ //basegfx::B2DPoint aPoint(0.0, 0.0);
+ const sal_uInt32 nPntAnz(maEdgeTrack.count());
basegfx::B2DPoint aOldPoint;
- if(nPntAnz)
- {
- if(2 == nNum && !GetConnectedNode(true))
+ if(nPntAnz)
+ {
+ if(2 == nNum && !GetConnectedNode(true))
{
- aOldPoint = maEdgeTrack.getB2DPoint(0);
+ aOldPoint = maEdgeTrack.getB2DPoint(0);
}
- else if(3 == nNum && !GetConnectedNode(false))
+ else if(3 == nNum && !GetConnectedNode(false))
{
- aOldPoint = maEdgeTrack.getB2DPoint(nPntAnz - 1);
+ aOldPoint = maEdgeTrack.getB2DPoint(nPntAnz - 1);
}
- else
+ else
{
- if(1 == (nPntAnz & 1))
+ if(1 == (nPntAnz & 1))
+ {
+ aOldPoint = maEdgeTrack.getB2DPoint(nPntAnz / 2);
+ }
+ else
{
- aOldPoint = maEdgeTrack.getB2DPoint(nPntAnz / 2);
- }
- else
- {
aOldPoint = (maEdgeTrack.getB2DPoint((nPntAnz/2) - 1) + maEdgeTrack.getB2DPoint(nPntAnz/2)) * 0.5;
- }
- }
-
- aOldPoint -= sdr::legacy::GetSnapRange(*this).getCenter();
+ }
+ }
}
- SdrGluePoint aGP(aOldPoint);
- aGP.SetPercent(false);
-
- return aGP;
-}
+ // TTTT:GLUE
+ //sdr::glue::Point aGP(aOldPoint);
+ //aGP.SetPercent(false);
-const SdrGluePointList* SdrEdgeObj::GetGluePointList() const
-{
- return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671#
+ // need to make absolute position relative. temporarily correct zero sizes for invert
+ basegfx::B2DHomMatrix aTransform(basegfx::tools::guaranteeMinimalScaling(getSdrObjectTransformation()));
+
+ aTransform.invert();
+ aOldPoint = aTransform * aOldPoint;
+
+ return sdr::glue::Point(
+ aOldPoint,
+ sdr::glue::Point::ESCAPE_DIRECTION_SMART,
+ sdr::glue::Point::Alignment_Center,
+ sdr::glue::Point::Alignment_Center,
+ true, // mbRelative
+ false); // mbUserDefined
}
-SdrGluePointList* SdrEdgeObj::ForceGluePointList()
+sdr::glue::List* SdrEdgeObj::GetGluePointList(bool /*bForce*/) const
{
- return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671#
+ return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671#
}
+//sdr::glue::List* SdrEdgeObj::ForceGluePointList()
+//{
+// return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671#
+//}
+
void SdrEdgeObj::ConnectToNode(bool bTail1, SdrObject* pObj)
{
SdrObjConnection& rCon=GetConnection(bTail1);
@@ -542,36 +568,46 @@ SdrObject* SdrEdgeObj::GetConnectedNode(
bool SdrEdgeObj::CheckNodeConnection(bool bTail1) const
{
- bool bRet(false);
- const SdrObjConnection& rCon = GetConnection(bTail1);
- const sal_uInt32 nPtAnz(maEdgeTrack.count());
-
- if(rCon.mpConnectedSdrObject && rCon.mpConnectedSdrObject->getSdrPageFromSdrObject() == getSdrPageFromSdrObject() && nPtAnz)
- {
- const SdrGluePointList* pGPL = rCon.mpConnectedSdrObject->GetGluePointList();
- const sal_uInt32 nConAnz(pGPL ? pGPL->GetCount() : 0);
- const sal_uInt32 nGesAnz(nConAnz + 4);
- const basegfx::B2DPoint aTail(bTail1 ? maEdgeTrack.getB2DPoint(0) : maEdgeTrack.getB2DPoint(nPtAnz - 1));
+ bool bRet(false);
+ const SdrObjConnection& rCon = GetConnection(bTail1);
+ const sal_uInt32 nPtAnz(maEdgeTrack.count());
+
+ if(rCon.mpConnectedSdrObject && rCon.mpConnectedSdrObject->getSdrPageFromSdrObject() == getSdrPageFromSdrObject() && nPtAnz)
+ {
+ const sdr::glue::List* pGPL = rCon.mpConnectedSdrObject->GetGluePointList(false);
+ const sdr::glue::PointVector aGluePointVector(pGPL ? pGPL->getVector() : sdr::glue::PointVector());
+ const sal_uInt32 nConAnz(aGluePointVector.size());
+ const sal_uInt32 nGesAnz(nConAnz + 4);
+ const basegfx::B2DPoint aTail(bTail1 ? maEdgeTrack.getB2DPoint(0) : maEdgeTrack.getB2DPoint(nPtAnz - 1));
for(sal_uInt32 i(0); i < nGesAnz && !bRet; i++)
- {
- if(i < nConAnz)
- {
- // UserDefined
- const basegfx::B2DPoint aGluePos((*pGPL)[i].GetAbsolutePos(sdr::legacy::GetSnapRange(*rCon.mpConnectedSdrObject)));
-
- bRet = (aTail == aGluePos);
- }
- else //if (i<nConAnz+4)
- {
- // Vertex
- const SdrGluePoint aPt(rCon.mpConnectedSdrObject->GetVertexGluePoint(i - nConAnz));
- const basegfx::B2DPoint aGluePos(aPt.GetAbsolutePos(sdr::legacy::GetSnapRange(*rCon.mpConnectedSdrObject)));
+ {
+ if(i < nConAnz)
+ {
+ // UserDefined or CustomShape
+ const sdr::glue::Point* pCandidate = aGluePointVector[i];
+
+ if(pCandidate)
+ {
+ const basegfx::B2DPoint aGluePos(rCon.mpConnectedSdrObject->getSdrObjectTransformation() * pCandidate->getUnitPosition());
+
+ bRet = (aTail == aGluePos);
+ }
+ else
+ {
+ OSL_ENSURE(false, "Got sdr::glue::PointVector with emty entries (!)");
+ }
+ }
+ else //if (i<nConAnz+4)
+ {
+ // Vertex
+ const sdr::glue::Point aPt(rCon.mpConnectedSdrObject->GetVertexGluePoint(i - nConAnz));
+ const basegfx::B2DPoint aGluePos(rCon.mpConnectedSdrObject->getSdrObjectTransformation() * aPt.getUnitPosition());
bRet = (aTail == aGluePos);
- }
- }
- }
+ }
+ }
+ }
return bRet;
}
@@ -690,22 +726,22 @@ sal_uInt16 SdrEdgeObj::ImpCalcEscAngle(S
if (byMitt) nRet|=SDRESC_VERT;
if (bxMitt) nRet|=SDRESC_HORZ;
if (dxl<dxr) { // Links
- if (dyo<dyu) nRet|=SDRESC_LEFT | SDRESC_TOP;
- else nRet|=SDRESC_LEFT | SDRESC_BOTTOM;
+ if (dyo<dyu) nRet|=sdr::glue::Point::ESCAPE_DIRECTION_LEFT | sdr::glue::Point::ESCAPE_DIRECTION_TOP;
+ else nRet|=sdr::glue::Point::ESCAPE_DIRECTION_LEFT | sdr::glue::Point::ESCAPE_DIRECTION_BOTTOM;
} else { // Rechts
- if (dyo<dyu) nRet|=SDRESC_RIGHT | SDRESC_TOP;
- else nRet|=SDRESC_RIGHT | SDRESC_BOTTOM;
+ if (dyo<dyu) nRet|=sdr::glue::Point::ESCAPE_DIRECTION_RIGHT | sdr::glue::Point::ESCAPE_DIRECTION_TOP;
+ else nRet|=sdr::glue::Point::ESCAPE_DIRECTION_RIGHT | sdr::glue::Point::ESCAPE_DIRECTION_BOTTOM;
}
return nRet;
}
if (dx<dy) { // waagerecht
if (bxMitt) return SDRESC_HORZ;
- if (dxl<dxr) return SDRESC_LEFT;
- else return SDRESC_RIGHT;
+ if (dxl<dxr) return sdr::glue::Point::ESCAPE_DIRECTION_LEFT;
+ else return sdr::glue::Point::ESCAPE_DIRECTION_RIGHT;
} else { // senkrecht
if (byMitt) return SDRESC_VERT;
- if (dyo<dyu) return SDRESC_TOP;
- else return SDRESC_BOTTOM;
+ if (dyo<dyu) return sdr::glue::Point::ESCAPE_DIRECTION_TOP;
+ else return sdr::glue::Point::ESCAPE_DIRECTION_BOTTOM;
}
}
@@ -792,7 +828,7 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
basegfx::B2DPoint aPt1(maEdgeTrack.getB2DPoint(0));
basegfx::B2DPoint aPt2(maEdgeTrack.getB2DPoint(nCount - 1));
const basegfx::B2DRange aBaseRange(aPt1, aPt2);
- SdrGluePoint aGP1,aGP2;
+ sdr::glue::Point aGP1,aGP2;
sal_uInt16 nEsc1(SDRESC_ALL);
sal_uInt16 nEsc2(SDRESC_ALL);
basegfx::B2DRange aBoundRange1;
@@ -815,7 +851,7 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
aBoundRange1 = rCon1.mpConnectedSdrObject->getObjectRange(0);
}
- aBoundRange1.transform(basegfx::tools::createTranslateB2DHomMatrix(rCon1.maObjOfs));
+ // TTTT:GLUE aBoundRange1.transform(basegfx::tools::createTranslateB2DHomMatrix(rCon1.maObjOfs));
const sal_Int32 nH(((SdrEdgeNode1HorzDistItem&)rSet.Get(SDRATTR_EDGENODE1HORZDIST)).GetValue());
const sal_Int32 nV(((SdrEdgeNode1VertDistItem&)rSet.Get(SDRATTR_EDGENODE1VERTDIST)).GetValue());
@@ -826,7 +862,7 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
}
else
{
- aBewareRange1 = aBoundRange1 = basegfx::B2DRange(aPt1 + rCon1.maObjOfs);
+ aBewareRange1 = aBoundRange1 = basegfx::B2DRange(aPt1); // TTTT:GLUE + rCon1.maObjOfs);
}
if(bCon2)
@@ -840,7 +876,7 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
aBoundRange2 = rCon2.mpConnectedSdrObject->getObjectRange(0);
}
- aBoundRange2.transform(basegfx::tools::createTranslateB2DHomMatrix(rCon2.maObjOfs));
+ // TTTT:GLUE aBoundRange2.transform(basegfx::tools::createTranslateB2DHomMatrix(rCon2.maObjOfs));
const sal_Int32 nH(((SdrEdgeNode2HorzDistItem&)rSet.Get(SDRATTR_EDGENODE2HORZDIST)).GetValue());
const sal_Int32 nV(((SdrEdgeNode2VertDistItem&)rSet.Get(SDRATTR_EDGENODE2VERTDIST)).GetValue());
@@ -851,7 +887,7 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
}
else
{
- aBewareRange2 = aBoundRange2 = basegfx::B2DRange(aPt2 + rCon2.maObjOfs);
+ aBewareRange2 = aBoundRange2 = basegfx::B2DRange(aPt2); // TTTT:GLUE + rCon2.maObjOfs);
}
sal_uInt32 nBestQual=0xFFFFFFFF;
@@ -897,14 +933,14 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
rCon1.mnConnectorId = nNum1;
}
- if(bCon1 && rCon1.TakeGluePoint(aGP1, true))
+ if(bCon1 && rCon1.TakeGluePoint(aGP1/*TTTT:GLUE, true*/))
{
- aPt1 = aGP1.GetPos();
- nEsc1 = aGP1.GetEscDir();
+ aPt1 = rCon1.mpConnectedSdrObject->getSdrObjectTransformation() * aGP1.getUnitPosition();
+ nEsc1 = aGP1.getEscapeDirections();
- if(SDRESC_SMART == nEsc1)
+ if(sdr::glue::Point::ESCAPE_DIRECTION_SMART == nEsc1)
{
- nEsc1 = ImpCalcEscAngle(rCon1.mpConnectedSdrObject, aPt1 - rCon1.maObjOfs);
+ nEsc1 = ImpCalcEscAngle(rCon1.mpConnectedSdrObject, aPt1); // TTTT:GLUE - rCon1.maObjOfs);
}
}
@@ -915,24 +951,24 @@ basegfx::B2DPolygon SdrEdgeObj::ImpCalcE
rCon2.mnConnectorId = nNum2;
}
- if(bCon2 && rCon2.TakeGluePoint(aGP2, true))
+ if(bCon2 && rCon2.TakeGluePoint(aGP2/*TTTT:GLUE, true*/))
{
- aPt2 = aGP2.GetPos();
- nEsc2 = aGP2.GetEscDir();
+ aPt2 = rCon2.mpConnectedSdrObject->getSdrObjectTransformation() * aGP2.getUnitPosition();
+ nEsc2 = aGP2.getEscapeDirections();
- if(SDRESC_SMART == nEsc2)
+ if(sdr::glue::Point::ESCAPE_DIRECTION_SMART == nEsc2)
{
- nEsc2 = ImpCalcEscAngle(rCon2.mpConnectedSdrObject, aPt2 - rCon2.maObjOfs);
+ nEsc2 = ImpCalcEscAngle(rCon2.mpConnectedSdrObject, aPt2); // TTTT:GLUE - rCon2.maObjOfs);
}
}
for(long nA1(0); nA1 < 36000; nA1 += 9000)
{
- const sal_uInt16 nE1(!nA1 ? SDRESC_RIGHT : 9000 == nA1 ? SDRESC_TOP : 18000 == nA1 ? SDRESC_LEFT : 27000 == nA1 ? SDRESC_BOTTOM : 0);
+ const sal_uInt16 nE1(!nA1 ? sdr::glue::Point::ESCAPE_DIRECTION_RIGHT : 9000 == nA1 ? sdr::glue::Point::ESCAPE_DIRECTION_TOP : 18000 == nA1 ? sdr::glue::Point::ESCAPE_DIRECTION_LEFT : 27000 == nA1 ? sdr::glue::Point::ESCAPE_DIRECTION_BOTTOM : 0);
for(long nA2(0); nA2 < 36000; nA2 += 9000)
{
- const sal_uInt16 nE2(!nA2 ? SDRESC_RIGHT : 9000 == nA2 ? SDRESC_TOP : 18000 == nA2 ? SDRESC_LEFT : 27000 == nA2 ? SDRESC_BOTTOM : 0);
+ const sal_uInt16 nE2(!nA2 ? sdr::glue::Point::ESCAPE_DIRECTION_RIGHT : 9000 == nA2 ? sdr::glue::Point::ESCAPE_DIRECTION_TOP : 18000 == nA2 ? sdr::glue::Point::ESCAPE_DIRECTION_LEFT : 27000 == nA2 ? sdr::glue::Point::ESCAPE_DIRECTION_BOTTOM : 0);
if((nEsc1 & nE1) && (nEsc2 & nE2))
{
@@ -1554,7 +1590,7 @@ basegfx::B2DPolygon ImpOldCalcEdgeTrack(
}
if (bInfo) { // nun die Linienversaetze auf aXP1 anwenden
if (pInfo->nMiddleLine!=0xFFFF) {
- sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(MIDDLELINE,aXP1.GetPointCount());
+ const sal_uInt16 nIdx = (sal_uInt16)pInfo->ImpGetPolyIdx(MIDDLELINE,aXP1.GetPointCount());
if (pInfo->ImpIsHorzLine(MIDDLELINE,aXP1.GetPointCount())) {
aXP1[nIdx].Y()+=pInfo->aMiddleLine.getY();
aXP1[nIdx+1].Y()+=pInfo->aMiddleLine.getY();
@@ -1564,7 +1600,7 @@ basegfx::B2DPolygon ImpOldCalcEdgeTrack(
}
}
if (pInfo->nObj1Lines>=2) {
- sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE2,aXP1.GetPointCount());
+ const sal_uInt16 nIdx = (sal_uInt16)pInfo->ImpGetPolyIdx(OBJ1LINE2,aXP1.GetPointCount());
if (pInfo->ImpIsHorzLine(OBJ1LINE2,aXP1.GetPointCount())) {
aXP1[nIdx].Y()+=pInfo->aObj1Line2.getY();
aXP1[nIdx+1].Y()+=pInfo->aObj1Line2.getY();
@@ -1574,7 +1610,7 @@ basegfx::B2DPolygon ImpOldCalcEdgeTrack(
}
}
if (pInfo->nObj1Lines>=3) {
- sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE3,aXP1.GetPointCount());
+ const sal_uInt16 nIdx = (sal_uInt16)pInfo->ImpGetPolyIdx(OBJ1LINE3,aXP1.GetPointCount());
if (pInfo->ImpIsHorzLine(OBJ1LINE3,aXP1.GetPointCount())) {
aXP1[nIdx].Y()+=pInfo->aObj1Line3.getY();
aXP1[nIdx+1].Y()+=pInfo->aObj1Line3.getY();
@@ -1584,7 +1620,7 @@ basegfx::B2DPolygon ImpOldCalcEdgeTrack(
}
}
if (pInfo->nObj2Lines>=2) {
- sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE2,aXP1.GetPointCount());
+ const sal_uInt16 nIdx = (sal_uInt16)pInfo->ImpGetPolyIdx(OBJ2LINE2,aXP1.GetPointCount());
if (pInfo->ImpIsHorzLine(OBJ2LINE2,aXP1.GetPointCount())) {
aXP1[nIdx].Y()+=pInfo->aObj2Line2.getY();
aXP1[nIdx+1].Y()+=pInfo->aObj2Line2.getY();
@@ -1594,7 +1630,7 @@ basegfx::B2DPolygon ImpOldCalcEdgeTrack(
}
}
if (pInfo->nObj2Lines>=3) {
- sal_uInt16 nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE3,aXP1.GetPointCount());
+ const sal_uInt16 nIdx = (sal_uInt16)pInfo->ImpGetPolyIdx(OBJ2LINE3,aXP1.GetPointCount());
if (pInfo->ImpIsHorzLine(OBJ2LINE3,aXP1.GetPointCount())) {
aXP1[nIdx].Y()+=pInfo->aObj2Line3.getY();
aXP1[nIdx+1].Y()+=pInfo->aObj2Line3.getY();
@@ -2156,15 +2192,16 @@ basegfx::B2DPolygon SdrEdgeObj::ImplAddC
SdrObjConnection aMyCon1(maCon1);
SdrObjConnection aMyCon2(maCon2);
- if (bTail1)
- {
- aMyCon1.maObjOfs *= rDragMethod.getCurrentTransformation();
- }
-
- if (bTail2)
- {
- aMyCon2.maObjOfs *= rDragMethod.getCurrentTransformation();
- }
+ // TTTT:GLUE
+ //if (bTail1)
+ //{
+ // aMyCon1.maObjOfs *= rDragMethod.getCurrentTransformation();
+ //}
+ //
+ //if (bTail2)
+ //{
+ // aMyCon2.maObjOfs *= rDragMethod.getCurrentTransformation();
+ //}
SdrEdgeInfoRec aInfo(maEdgeInfo);
aResult = ImpCalcEdgeTrack(aMyCon1, aMyCon2, &aInfo);
@@ -2283,143 +2320,155 @@ void SdrEdgeObj::FindConnector(
const SdrEdgeObj* pThis,
OutputDevice* pOut)
{
- rCon.ResetVars();
+ rCon.ResetVars();
- if(rSdrView.GetSdrPageView())
- {
- if(!pOut)
- pOut = rSdrView.GetFirstOutputDevice(); // GetWin(0);
+ if(rSdrView.GetSdrPageView())
+ {
+ if(!pOut)
+ pOut = rSdrView.GetFirstOutputDevice(); // GetWin(0);
- if (!pOut)
- return;
+ if (!pOut)
+ return;
const Point aPt(basegfx::fround(rPt.getX()), basegfx::fround(rPt.getY()));
- SdrObjList* pOL = rSdrView.GetSdrPageView()->GetCurrentObjectList();
- const SetOfByte& rVisLayer = rSdrView.GetSdrPageView()->GetVisibleLayers();
- // Sensitiver Bereich der Konnektoren ist doppelt so gross wie die Handles:
- sal_uInt16 nMarkHdSiz = rSdrView.GetMarkHdlSizePixel();
- Size aHalfConSiz(nMarkHdSiz,nMarkHdSiz);
- aHalfConSiz=pOut->PixelToLogic(aHalfConSiz);
- Size aHalfCenterSiz(2*aHalfConSiz.Width(),2*aHalfConSiz.Height());
- Rectangle aMouseRect(aPt,aPt);
- aMouseRect.Left() -=aHalfConSiz.Width();
- aMouseRect.Top() -=aHalfConSiz.Height();
- aMouseRect.Right() +=aHalfConSiz.Width();
- aMouseRect.Bottom()+=aHalfConSiz.Height();
- sal_uInt16 nBoundHitTol=(sal_uInt16)aHalfConSiz.Width()/2; if (nBoundHitTol==0) nBoundHitTol=1;
- sal_uInt32 no=pOL->GetObjCount();
- bool bFnd=false;
- SdrObjConnection aTestCon;
- SdrObjConnection aBestCon;
- bool bTestBoundHit=false;
- //bool bBestBoundHit=false;
-
- while (no>0 && !bFnd)
- {
- // Problem: Gruppenobjekt mit verschiedenen Layern liefert LayerID 0 !!!!
- no--;
- SdrObject* pObj = pOL->GetObj(no);
- if (rVisLayer.IsSet(pObj->GetLayer()) && pObj->IsVisible() && // only visible objects
- (pThis==NULL || pObj != pThis)) // nicht an mich selbst connecten
- {
- Rectangle aObjBound(sdr::legacy::GetBoundRect(*pObj));
- if (aObjBound.IsOver(aMouseRect))
+ SdrObjList* pOL = rSdrView.GetSdrPageView()->GetCurrentObjectList();
+ const SetOfByte& rVisLayer = rSdrView.GetSdrPageView()->GetVisibleLayers();
+ // Sensitiver Bereich der Konnektoren ist doppelt so gross wie die Handles:
+ sal_uInt16 nMarkHdSiz = rSdrView.GetMarkHdlSizePixel();
+ Size aHalfConSiz(nMarkHdSiz,nMarkHdSiz);
+ aHalfConSiz=pOut->PixelToLogic(aHalfConSiz);
+ Size aHalfCenterSiz(2*aHalfConSiz.Width(),2*aHalfConSiz.Height());
+ Rectangle aMouseRect(aPt,aPt);
+ aMouseRect.Left() -=aHalfConSiz.Width();
+ aMouseRect.Top() -=aHalfConSiz.Height();
+ aMouseRect.Right() +=aHalfConSiz.Width();
+ aMouseRect.Bottom()+=aHalfConSiz.Height();
+ sal_uInt16 nBoundHitTol=(sal_uInt16)aHalfConSiz.Width()/2; if (nBoundHitTol==0) nBoundHitTol=1;
+ sal_uInt32 no=pOL->GetObjCount();
+ bool bFnd=false;
+ SdrObjConnection aTestCon;
+ SdrObjConnection aBestCon;
+ bool bTestBoundHit=false;
+ //bool bBestBoundHit=false;
+
+ while (no>0 && !bFnd)
+ {
+ // Problem: Gruppenobjekt mit verschiedenen Layern liefert LayerID 0 !!!!
+ no--;
+ SdrObject* pObj = pOL->GetObj(no);
+ if (rVisLayer.IsSet(pObj->GetLayer()) && pObj->IsVisible() && // only visible objects
+ (pThis==NULL || pObj != pThis)) // nicht an mich selbst connecten
+ {
+ Rectangle aObjBound(sdr::legacy::GetBoundRect(*pObj));
+ if (aObjBound.IsOver(aMouseRect))
{
- aTestCon.ResetVars();
- bTestBoundHit=false;
- const bool bEdge(pObj->IsSdrEdgeObj()); // kein BestCon fuer Edge
- // Die Userdefined Konnektoren haben absolute Prioritaet.
- // Danach kommt Vertex, Corner und Mitte(Best) gleich priorisiert.
- // Zum Schluss kommt noch ein HitTest aufs Obj.
- const SdrGluePointList* pGPL = pObj->GetGluePointList();
- sal_uInt32 nConAnz=pGPL==NULL ? 0 : pGPL->GetCount();
- sal_uInt32 nGesAnz=nConAnz+9;
- bool bUserFnd=false;
- sal_uInt32 nBestDist=0xFFFFFFFF;
- for (sal_uInt32 i=0; i<nGesAnz; i++)
- {
- bool bUser=i<nConAnz;
- bool bVertex=i>=nConAnz+0 && i<nConAnz+4;
- bool bCenter=i==nConAnz+4;
- bool bOk=false;
- Point aConPos;
- sal_uInt32 nConNum=i;
-
- if(bUser)
- {
- const SdrGluePoint& rGP=(*pGPL)[nConNum];
- const basegfx::B2DPoint aPoint(rGP.GetAbsolutePos(sdr::legacy::GetSnapRange(*pObj)));
- aConPos=Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
- nConNum=rGP.GetId();
- bOk=true;
- }
- else if (bVertex && !bUserFnd)
- {
- nConNum=nConNum-nConAnz;
- SdrGluePoint aLocalPt(pObj->GetVertexGluePoint(nConNum));
- const basegfx::B2DPoint aPoint(aLocalPt.GetAbsolutePos(sdr::legacy::GetSnapRange(*pObj)));
- aConPos=Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
- bOk=true;
- }
- else if (bCenter && !bUserFnd && !bEdge)
- {
- // #109007#
- // Suppress default connect at object center
- if(!pThis || !pThis->GetSuppressDefaultConnect())
- {
- // Edges nicht!
- nConNum=0;
- aConPos=aObjBound.Center();
- bOk=true;
- }
- }
- if (bOk && aMouseRect.IsInside(aConPos))
+ aTestCon.ResetVars();
+ bTestBoundHit=false;
+ const bool bEdge(pObj->IsSdrEdgeObj()); // kein BestCon fuer Edge
+ // Die Userdefined Konnektoren haben absolute Prioritaet.
+ // Danach kommt Vertex, Corner und Mitte(Best) gleich priorisiert.
+ // Zum Schluss kommt noch ein HitTest aufs Obj.
+ const sdr::glue::List* pGPL = pObj->GetGluePointList(false);
+ const sdr::glue::PointVector aGluePointVector(pGPL ? pGPL->getVector() : sdr::glue::PointVector());
+ const sal_uInt32 nConAnz(aGluePointVector.size());
+ sal_uInt32 nGesAnz=nConAnz+9;
+ bool bUserFnd=false;
+ sal_uInt32 nBestDist=0xFFFFFFFF;
+ for (sal_uInt32 i=0; i<nGesAnz; i++)
+ {
+ bool bUser=i<nConAnz;
+ bool bVertex=i>=nConAnz+0 && i<nConAnz+4;
+ bool bCenter=i==nConAnz+4;
+ bool bOk=false;
+ Point aConPos;
+ sal_uInt32 nConNum=i;
+
+ if(bUser)
{
- if (bUser) bUserFnd=true;
- bFnd=true;
- sal_uInt32 nDist=(sal_uInt32)Abs(aConPos.X()-aPt.X())+(sal_uInt32)Abs(aConPos.Y()-aPt.Y());
-
+ const sdr::glue::Point* pCandidate = aGluePointVector[nConNum];
+
+ if(pCandidate)
+ {
+ const basegfx::B2DPoint aPoint(pObj->getSdrObjectTransformation() * pCandidate->getUnitPosition());
+
+ aConPos = Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
+ nConNum = pCandidate->getID();
+ bOk = true;
+ }
+ else
+ {
+ OSL_ENSURE(false, "Got sdr::glue::PointVector with empty entries (!)");
+ }
+ }
+ else if (bVertex && !bUserFnd)
+ {
+ nConNum = nConNum - nConAnz;
+
+ const sdr::glue::Point aLocalPt(pObj->GetVertexGluePoint(nConNum));
+ const basegfx::B2DPoint aPoint(pObj->getSdrObjectTransformation() * aLocalPt.getUnitPosition());
+
+ aConPos = Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
+ bOk = true;
+ }
+ else if (bCenter && !bUserFnd && !bEdge)
+ {
+ // #109007#
+ // Suppress default connect at object center
+ if(!pThis || !pThis->GetSuppressDefaultConnect())
+ {
+ // Edges nicht!
+ nConNum=0;
+ aConPos=aObjBound.Center();
+ bOk=true;
+ }
+ }
+ if (bOk && aMouseRect.IsInside(aConPos))
+ {
+ if (bUser) bUserFnd=true;
+ bFnd=true;
+ sal_uInt32 nDist=(sal_uInt32)Abs(aConPos.X()-aPt.X())+(sal_uInt32)Abs(aConPos.Y()-aPt.Y());
+
if (nDist<nBestDist)
{
- nBestDist = nDist;
- aTestCon.mpConnectedSdrObject = pObj;
- aTestCon.mnConnectorId = nConNum;
- aTestCon.mbAutoVertex = bVertex;
- aTestCon.mbBestConnection = false; // bCenter;
- aTestCon.mbBestVertex = bCenter;
- }
- }
- }
- // Falls kein Konnektor getroffen wird nochmal
- // HitTest versucht fuer BestConnector (=bCenter)
- const basegfx::B2DPoint aHitTestPos(aPt.X(), aPt.Y());
- if(!bFnd &&
+ nBestDist = nDist;
+ aTestCon.mpConnectedSdrObject = pObj;
+ aTestCon.mnConnectorId = nConNum;
+ aTestCon.mbAutoVertex = bVertex;
+ aTestCon.mbBestConnection = false; // bCenter;
+ aTestCon.mbBestVertex = bCenter;
+ }
+ }
+ }
+ // Falls kein Konnektor getroffen wird nochmal
+ // HitTest versucht fuer BestConnector (=bCenter)
+ const basegfx::B2DPoint aHitTestPos(aPt.X(), aPt.Y());
+ if(!bFnd &&
!bEdge &&
- SdrObjectPrimitiveHit(*pObj, aHitTestPos, nBoundHitTol, rSdrView, false, 0))
- {
- // #109007#
- // Suppress default connect at object inside bound
- if(!pThis || !pThis->GetSuppressDefaultConnect())
- {
- bFnd = true;
- aTestCon.mpConnectedSdrObject = pObj;
- aTestCon.mbBestConnection = true;
- }
- }
- if (bFnd)
+ SdrObjectPrimitiveHit(*pObj, aHitTestPos, nBoundHitTol, rSdrView, false, 0))
{
- Rectangle aMouseRect2(aPt,aPt);
- aMouseRect.Left() -=nBoundHitTol;
- aMouseRect.Top() -=nBoundHitTol;
- aMouseRect.Right() +=nBoundHitTol;
- aMouseRect.Bottom()+=nBoundHitTol;
- bTestBoundHit=aObjBound.IsOver(aMouseRect2);
- }
- }
- }
- }
+ // #109007#
+ // Suppress default connect at object inside bound
+ if(!pThis || !pThis->GetSuppressDefaultConnect())
+ {
+ bFnd = true;
+ aTestCon.mpConnectedSdrObject = pObj;
+ aTestCon.mbBestConnection = true;
+ }
+ }
+ if (bFnd)
+ {
+ Rectangle aMouseRect2(aPt,aPt);
+ aMouseRect.Left() -=nBoundHitTol;
+ aMouseRect.Top() -=nBoundHitTol;
+ aMouseRect.Right() +=nBoundHitTol;
+ aMouseRect.Bottom()+=nBoundHitTol;
+ bTestBoundHit=aObjBound.IsOver(aMouseRect2);
+ }
+ }
+ }
+ }
- rCon=aTestCon;
+ rCon=aTestCon;
}
}
@@ -2687,37 +2736,41 @@ void SdrEdgeObj::SetTailPoint( bool bTai
}
/** this method is used by the api to set a glue point for a connection
- nId == -1 : The best default point is automaticly choosen
- 0 <= nId <= 3 : One of the default points is choosen
- nId >= 4 : A user defined glue point is choosen
+ nId == -1 : The best default point is automaticly choosen
+ 0 <= nId <= 3 : One of the default points is choosen
+ nId >= 4 : A user defined glue point is choosen
*/
void SdrEdgeObj::setGluePointIndex(bool bTail, sal_Int32 nIndex /* = -1 */ )
{
- SdrObjConnection& rConn1 = GetConnection( bTail );
- rConn1.SetAutoVertex( nIndex >= 0 && nIndex <= 3 );
- rConn1.SetBestConnection( nIndex < 0 );
- rConn1.SetBestVertex( nIndex < 0 );
+ SdrObjConnection& rConn1 = GetConnection( bTail );
+ rConn1.SetAutoVertex( nIndex >= 0 && nIndex <= 3 );
+ rConn1.SetBestConnection( nIndex < 0 );
+ rConn1.SetBestVertex( nIndex < 0 );
- if( nIndex > 3 )
- {
- nIndex -= 3; // SJ: the start api index is 0, whereas the implementation in svx starts from 1
+ if( nIndex > 3 )
+ {
+ // TTTT:GLUE no more; check if this works
+ // nIndex -= 3; // SJ: the start api index is 0, whereas the implementation in svx starts from 1
+ nIndex -= 4; // SJ: the start api index is 0, whereas the implementation in svx starts from 1
- // for user defined glue points we have
- // to get the id for this index first
- const SdrGluePointList* pList = rConn1.GetObject() ? rConn1.GetObject()->GetGluePointList() : NULL;
+ // for user defined glue points we have
+ // to get the id for this index first
+ const sdr::glue::List* pList = rConn1.GetObject() ? rConn1.GetObject()->GetGluePointList(false) : NULL;
- if( pList == NULL || SDRGLUEPOINT_NOTFOUND == pList->FindGluePoint((sal_uInt16)nIndex) )
- return;
- }
- else if( nIndex < 0 )
- {
- nIndex = 0;
- }
+ if(!pList || !pList->findByID(nIndex))
+ {
+ return;
+ }
+ }
+ else if( nIndex < 0 )
+ {
+ nIndex = 0;
+ }
- rConn1.SetConnectorId( (sal_uInt16)nIndex );
+ rConn1.SetConnectorId(nIndex);
- SetChanged();
- ImpRecalcEdgeTrack();
+ SetChanged();
+ ImpRecalcEdgeTrack();
}
/** this method is used by the api to return a glue point id for a connection.
Modified: openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx?rev=1529226&r1=1529225&r2=1529226&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx (original)
+++ openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpntv.cxx Fri Oct 4 17:20:25 2013
@@ -45,7 +45,7 @@
#include <svx/svdmodel.hxx>
#include <svx/svdundo.hxx>
#include <svx/svdview.hxx>
-#include <svx/svdglue.hxx>
+#include <svx/sdrglue.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdattrx.hxx>
@@ -55,7 +55,7 @@
#include <svx/sdr/overlay/overlayobjectlist.hxx>
#include <svx/sdr/overlay/overlayrollingrectangle.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
-#include <svx/svdglue.hxx>
+#include <svx/sdrglue.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdview.hxx>
#include <svl/itemiter.hxx>
@@ -947,44 +947,52 @@ bool SdrPaintView::KeyInput(const KeyEve
void SdrPaintView::GlueInvalidate() const
{
- const sal_uInt32 nWindowCount(PaintWindowCount());
+ const sal_uInt32 nWindowCount(PaintWindowCount());
- for(sal_uInt32 nWinNum(0); nWinNum < nWindowCount; nWinNum++)
- {
- SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum);
+ for(sal_uInt32 nWinNum(0); nWinNum < nWindowCount; nWinNum++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum);
- if(pPaintWindow->OutputToWindow())
- {
- OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
- const basegfx::B2DVector aLogicHalfSevenPix(rOutDev.GetInverseViewTransformation() * basegfx::B2DVector(3.5, 3.5));
+ if(pPaintWindow->OutputToWindow())
+ {
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+ const basegfx::B2DVector aLogicHalfSevenPix(rOutDev.GetInverseViewTransformation() * basegfx::B2DVector(3.5, 3.5));
- if(mpPageView)
- {
- const SdrObjList* pOL = mpPageView->GetCurrentObjectList();
- const sal_uInt32 nObjAnz(pOL->GetObjCount());
-
- for(sal_uInt32 nObjNum(0); nObjNum < nObjAnz; nObjNum++)
- {
- const SdrObject* pObj=pOL->GetObj(nObjNum);
- const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ if(mpPageView)
+ {
+ const SdrObjList* pOL = mpPageView->GetCurrentObjectList();
+ const sal_uInt32 nObjAnz(pOL->GetObjCount());
+
+ for(sal_uInt32 nObjNum(0); nObjNum < nObjAnz; nObjNum++)
+ {
+ const SdrObject* pObj = pOL->GetObj(nObjNum);
+ const sdr::glue::List* pGPL = pObj ? pObj->GetGluePointList(false) : 0;
- if(pGPL && pGPL->GetCount())
- {
- const basegfx::B2DRange aObjectRange(sdr::legacy::GetSnapRange(*pObj));
+ if(pGPL)
+ {
+ const sdr::glue::PointVector aGluePointVecor(pGPL->getVector());
- for(sal_uInt32 a(0); a < pGPL->GetCount(); a++)
- {
- const SdrGluePoint& rCandidate = (*pGPL)[a];
- const basegfx::B2DPoint aPos(rCandidate.GetAbsolutePos(aObjectRange));
- const basegfx::B2DRange aRange(aPos - aLogicHalfSevenPix, aPos + aLogicHalfSevenPix);
+ for(sal_uInt32 a(0); a < aGluePointVecor.size(); a++)
+ {
+ const sdr::glue::Point* pCandidate = aGluePointVecor[a];
- InvalidateOneWin((Window&)rOutDev, aRange);
- }
- }
- }
- }
- }
- }
+ if(pCandidate)
+ {
+ const basegfx::B2DPoint aPos(pObj->getSdrObjectTransformation() * pCandidate->getUnitPosition());
+ const basegfx::B2DRange aRange(aPos - aLogicHalfSevenPix, aPos + aLogicHalfSevenPix);
+
+ InvalidateOneWin((Window&)rOutDev, aRange);
+ }
+ else
+ {
+ OSL_ENSURE(false, "Got sdr::glue::PointVector with empty entries (!)");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
void SdrPaintView::InvalidateAllWin() const
Modified: openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpoev.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpoev.cxx?rev=1529226&r1=1529225&r2=1529226&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpoev.cxx (original)
+++ openoffice/branches/alg/aw080/main/svx/source/svdraw/svdpoev.cxx Fri Oct 4 17:20:25 2013
@@ -682,7 +682,7 @@ void SdrPolyEditView::TransformMarkedPoi
aStr = ImpGetResStr(STR_EditResize);
break;
case SDRREPFUNC_OBJ_ROTATE:
- aStr = ImpGetResStr(STR_EditResize); // no own string for rotate ?!?
+ aStr = ImpGetResStr(STR_EditRotate /*STR_EditResize*/); // TTTT: maybe there is, check // no own string for rotate ?!?
break;
}
Modified: openoffice/branches/alg/aw080/main/svx/source/unodraw/gluepts.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/unodraw/gluepts.cxx?rev=1529226&r1=1529225&r2=1529226&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/source/unodraw/gluepts.cxx (original)
+++ openoffice/branches/alg/aw080/main/svx/source/unodraw/gluepts.cxx Fri Oct 4 17:20:25 2013
@@ -19,21 +19,16 @@
*
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
+
#include <com/sun/star/container/XIdentifierContainer.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
-#ifndef _COM_SUN_STAR_DRAWING_GLUEPOINT2_HDL_
#include <com/sun/star/drawing/GluePoint2.hpp>
-#endif
-
#include <cppuhelper/implbase2.hxx>
-
#include <svx/svdmodel.hxx>
#include <svx/svdobj.hxx>
-#include <svx/svdglue.hxx>
+#include <svx/sdrglue.hxx>
#include <svx/svdpage.hxx>
using namespace ::com::sun::star;
@@ -45,170 +40,42 @@ const sal_uInt16 NON_USER_DEFINED_GLUE_P
class SvxUnoGluePointAccess : public WeakImplHelper2< container::XIndexContainer, container::XIdentifierContainer >
{
private:
- SdrObjectWeakRef mpObject;
+ SdrObjectWeakRef mpObject;
public:
- SvxUnoGluePointAccess( SdrObject* pObject ) throw();
- virtual ~SvxUnoGluePointAccess() throw();
+ SvxUnoGluePointAccess( SdrObject* pObject ) throw();
+ virtual ~SvxUnoGluePointAccess() throw();
- // XIdentifierContainer
+ // XIdentifierContainer
virtual sal_Int32 SAL_CALL insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
virtual void SAL_CALL removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
- // XIdentifierReplace
+ // XIdentifierReplace
virtual void SAL_CALL replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
- // XIdentifierReplace
+ // XIdentifierReplace
virtual uno::Any SAL_CALL getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
virtual uno::Sequence< sal_Int32 > SAL_CALL getIdentifiers( ) throw (uno::RuntimeException);
- /* deprecated */
- // XIndexContainer
+ /* deprecated */
+ // XIndexContainer
virtual void SAL_CALL insertByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
- /* deprecated */
- // XIndexReplace
+ /* deprecated */
+ // XIndexReplace
virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
- /* deprecated */
- // XIndexAccess
+ /* deprecated */
+ // XIndexAccess
virtual sal_Int32 SAL_CALL getCount( ) throw(uno::RuntimeException);
virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
- // XElementAccess
+ // XElementAccess
virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
};
-static void convert( const SdrGluePoint& rSdrGlue, drawing::GluePoint2& rUnoGlue ) throw()
-{
- rUnoGlue.Position.X = basegfx::fround(rSdrGlue.GetPos().getX());
- rUnoGlue.Position.Y = basegfx::fround(rSdrGlue.GetPos().getY());
- rUnoGlue.IsRelative = rSdrGlue.IsPercent();
-
- switch( rSdrGlue.GetAlign() )
- {
- case SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT:
- rUnoGlue.PositionAlignment = drawing::Alignment_TOP_LEFT;
- break;
- case SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP:
- rUnoGlue.PositionAlignment = drawing::Alignment_TOP;
- break;
- case SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT:
- rUnoGlue.PositionAlignment = drawing::Alignment_TOP_RIGHT;
- break;
- case SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER:
- rUnoGlue.PositionAlignment = drawing::Alignment_CENTER;
- break;
- case SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER:
- rUnoGlue.PositionAlignment = drawing::Alignment_RIGHT;
- break;
- case SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM:
- rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_LEFT;
- break;
- case SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM:
- rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM;
- break;
- case SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM:
- rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_RIGHT;
- break;
-// case SDRHORZALIGN_LEFT:
- default:
- rUnoGlue.PositionAlignment = drawing::Alignment_LEFT;
- break;
- }
-
- switch( rSdrGlue.GetEscDir() )
- {
- case SDRESC_LEFT:
- rUnoGlue.Escape = drawing::EscapeDirection_LEFT;
- break;
- case SDRESC_RIGHT:
- rUnoGlue.Escape = drawing::EscapeDirection_RIGHT;
- break;
- case SDRESC_TOP:
- rUnoGlue.Escape = drawing::EscapeDirection_UP;
- break;
- case SDRESC_BOTTOM:
- rUnoGlue.Escape = drawing::EscapeDirection_DOWN;
- break;
- case SDRESC_HORZ:
- rUnoGlue.Escape = drawing::EscapeDirection_HORIZONTAL;
- break;
- case SDRESC_VERT:
- rUnoGlue.Escape = drawing::EscapeDirection_VERTICAL;
- break;
-// case SDRESC_SMART:
- default:
- rUnoGlue.Escape = drawing::EscapeDirection_SMART;
- break;
- }
-}
-
-static void convert( const drawing::GluePoint2& rUnoGlue, SdrGluePoint& rSdrGlue ) throw()
-{
- rSdrGlue.SetPos( basegfx::B2DPoint( rUnoGlue.Position.X, rUnoGlue.Position.Y ) );
- rSdrGlue.SetPercent( rUnoGlue.IsRelative );
-
- switch( rUnoGlue.PositionAlignment )
- {
- case drawing::Alignment_TOP_LEFT:
- rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT );
- break;
- case drawing::Alignment_TOP:
- rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP );
- break;
- case drawing::Alignment_TOP_RIGHT:
- rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT );
- break;
- case drawing::Alignment_CENTER:
- rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER );
- break;
- case drawing::Alignment_RIGHT:
- rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER );
- break;
- case drawing::Alignment_BOTTOM_LEFT:
- rSdrGlue.SetAlign( SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM );
- break;
- case drawing::Alignment_BOTTOM:
- rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM );
- break;
- case drawing::Alignment_BOTTOM_RIGHT:
- rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM );
- break;
-// case SDRHORZALIGN_LEFT:
- default:
- rSdrGlue.SetAlign( SDRHORZALIGN_LEFT );
- break;
- }
- switch( rUnoGlue.Escape )
- {
- case drawing::EscapeDirection_LEFT:
- rSdrGlue.SetEscDir(SDRESC_LEFT);
- break;
- case drawing::EscapeDirection_RIGHT:
- rSdrGlue.SetEscDir(SDRESC_RIGHT);
- break;
- case drawing::EscapeDirection_UP:
- rSdrGlue.SetEscDir(SDRESC_TOP);
- break;
- case drawing::EscapeDirection_DOWN:
- rSdrGlue.SetEscDir(SDRESC_BOTTOM);
- break;
- case drawing::EscapeDirection_HORIZONTAL:
- rSdrGlue.SetEscDir(SDRESC_HORZ);
- break;
- case drawing::EscapeDirection_VERTICAL:
- rSdrGlue.SetEscDir(SDRESC_VERT);
- break;
-// case drawing::EscapeDirection_SMART:
- default:
- rSdrGlue.SetEscDir(SDRESC_SMART);
- break;
- }
-}
-
SvxUnoGluePointAccess::SvxUnoGluePointAccess( SdrObject* pObject ) throw()
: mpObject( pObject )
{
@@ -221,153 +88,228 @@ SvxUnoGluePointAccess::~SvxUnoGluePointA
// XIdentifierContainer
sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
{
- if( mpObject.is() )
- {
- SdrGluePointList* pList = mpObject->ForceGluePointList();
- if( pList )
- {
- // second, insert the new glue point
- drawing::GluePoint2 aUnoGlue;
-
- if( aElement >>= aUnoGlue )
- {
- SdrGluePoint aSdrGlue;
- convert( aUnoGlue, aSdrGlue );
- sal_uInt32 nId = pList->Insert( aSdrGlue );
-
- // only repaint, no objectchange
- mpObject->ActionChanged();
-
- return (sal_Int32)((*pList)[nId].GetId() + NON_USER_DEFINED_GLUE_POINTS) - 1;
- }
-
- throw lang::IllegalArgumentException();
- }
- }
+ if( mpObject.is() )
+ {
+ sdr::glue::List* pList = mpObject->GetGluePointList(true);
+
+ if( pList )
+ {
+ drawing::GluePoint2 aUnoGlue;
+
+ if( aElement >>= aUnoGlue )
+ {
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const sdr::glue::Point aSdrGlue(aUnoGlue, aAbsoluteScale);
+ const sdr::glue::Point& rAdded = pList->add(aSdrGlue);
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
- return -1;
+ return rAdded.getID() + NON_USER_DEFINED_GLUE_POINTS;
+ }
+
+ throw lang::IllegalArgumentException();
+ }
+ }
+
+ return -1;
}
void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
- if( mpObject.is() && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS ))
- {
- const sal_uInt16 nId = (sal_uInt16)(Identifier - NON_USER_DEFINED_GLUE_POINTS) + 1;
-
- SdrGluePointList* pList = const_cast<SdrGluePointList*>(mpObject->GetGluePointList());
- const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
- sal_uInt32 i;
-
- for( i = 0; i < nCount; i++ )
- {
- if( (*pList)[i].GetId() == nId )
- {
- pList->Delete( i );
-
- // only repaint, no objectchange
- mpObject->ActionChanged();
-
- return;
- }
- }
- }
+ if( mpObject.is() && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS ))
+ {
+ const sal_uInt32 nId(Identifier - NON_USER_DEFINED_GLUE_POINTS);
+ sdr::glue::List* pList = mpObject->GetGluePointList(false);
- throw container::NoSuchElementException();
+ if(pList)
+ {
+ const sdr::glue::Point* pCandidate = pList->findByID(nId);
+
+ if(pCandidate)
+ {
+ pList->remove(*pCandidate);
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+
+ return;
+ }
+ }
+
+ // TTTT:GLUE
+ //const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
+ //sal_uInt32 i;
+ //
+ //for( i = 0; i < nCount; i++ )
+ //{
+ // if( (*pList)[i].GetId() == nId )
+ // {
+ // pList->Delete( i );
+ //
+ // // only repaint, no objectchange
+ // mpObject->ActionChanged();
+ //
+ // return;
+ // }
+ //}
+ }
+
+ throw container::NoSuchElementException();
}
// XIdentifierReplace
void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
- if(mpObject.is())
- {
- struct drawing::GluePoint2 aGluePoint;
- if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint))
- throw lang::IllegalArgumentException();
-
- const sal_uInt16 nId = (sal_uInt16)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
-
- SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
- const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
- sal_uInt32 i;
- for( i = 0; i < nCount; i++ )
- {
- if( (*pList)[i].GetId() == nId )
- {
- // change the glue point
- SdrGluePoint& rTempPoint = (*pList)[i];
- convert( aGluePoint, rTempPoint );
-
- // only repaint, no objectchange
- mpObject->ActionChanged();
-
- return;
- }
- }
+ if(mpObject.is())
+ {
+ struct drawing::GluePoint2 aGluePoint;
+
+ if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint))
+ throw lang::IllegalArgumentException();
- throw container::NoSuchElementException();
- }
+ const sal_uInt32 nId(Identifier - NON_USER_DEFINED_GLUE_POINTS);
+ sdr::glue::List* pList = mpObject->GetGluePointList(false);
+
+ if(pList)
+ {
+ sdr::glue::Point* pCandidate = pList->findByID(nId);
+
+ if(pCandidate)
+ {
+ // change the glue point (but start with a new GluePoint)
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const sdr::glue::Point aSdrGlue(aGluePoint, aAbsoluteScale);
+
+ *pCandidate = aSdrGlue;
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+
+ return;
+ }
+ }
+
+ // TTTT:GLUE
+ //const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
+ //sal_uInt32 i;
+ //for( i = 0; i < nCount; i++ )
+ //{
+ // if( (*pList)[i].GetId() == nId )
+ // {
+ // // change the glue point
+ // sdr::glue::Point& rTempPoint = (*pList)[i];
+ // convert( aGluePoint, rTempPoint );
+ //
+ // // only repaint, no objectchange
+ // mpObject->ActionChanged();
+ //
+ // return;
+ // }
+ //}
+
+ throw container::NoSuchElementException();
+ }
}
// XIdentifierAccess
uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
- if(mpObject.is())
- {
- struct drawing::GluePoint2 aGluePoint;
-
- if( Identifier < NON_USER_DEFINED_GLUE_POINTS ) // default glue point?
- {
- SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( Identifier );
- aGluePoint.IsUserDefined = sal_False;
- convert( aTempPoint, aGluePoint );
- return uno::makeAny( aGluePoint );
- }
- else
- {
- const sal_uInt16 nId = (sal_uInt16)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
-
- const SdrGluePointList* pList = mpObject->GetGluePointList();
- const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
-
- for( sal_uInt32 i = 0; i < nCount; i++ )
- {
- const SdrGluePoint& rTempPoint = (*pList)[i];
- if( rTempPoint.GetId() == nId )
- {
- // #i38892#
- if(rTempPoint.IsUserDefined())
- {
- aGluePoint.IsUserDefined = sal_True;
- }
-
- convert( rTempPoint, aGluePoint );
- return uno::makeAny( aGluePoint );
- }
- }
- }
- }
+ if(mpObject.is())
+ {
+ if( Identifier < NON_USER_DEFINED_GLUE_POINTS ) // default glue point?
+ {
+ const sdr::glue::Point aTempPoint(mpObject->GetVertexGluePoint(Identifier));
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const drawing::GluePoint2 aGluePoint(aTempPoint.convertToGluePoint2(aAbsoluteScale));
+
+ return uno::makeAny( aGluePoint );
+ }
+ else
+ {
+ const sal_uInt32 nId(Identifier - NON_USER_DEFINED_GLUE_POINTS);
+ const sdr::glue::List* pList = mpObject->GetGluePointList(false);
+
+ if(pList)
+ {
+ const sdr::glue::Point* pCandidate = pList->findByID(nId);
+
+ if(pCandidate)
+ {
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const drawing::GluePoint2 aGluePoint(pCandidate->convertToGluePoint2(aAbsoluteScale));
+
+ return uno::makeAny( aGluePoint );
+ }
+ }
+
+ // TTTT:GLUE
+ //const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
+ //
+ //for( sal_uInt32 i = 0; i < nCount; i++ )
+ //{
+ // const sdr::glue::Point& rTempPoint = (*pList)[i];
+ // if( rTempPoint.GetId() == nId )
+ // {
+ // // #i38892#
+ // if(rTempPoint.IsUserDefined())
+ // {
+ // aGluePoint.IsUserDefined = sal_True;
+ // }
+ //
+ // convert( rTempPoint, aGluePoint );
+ // return uno::makeAny( aGluePoint );
+ // }
+ //}
+ }
+ }
- throw lang::IndexOutOfBoundsException();
+ throw lang::IndexOutOfBoundsException();
}
uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers() throw (uno::RuntimeException)
{
if( mpObject.is() )
{
- const SdrGluePointList* pList = mpObject->GetGluePointList();
- const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
- sal_uInt32 i;
-
- uno::Sequence< sal_Int32 > aIdSequence( nCount + NON_USER_DEFINED_GLUE_POINTS );
- sal_Int32 *pIdentifier = aIdSequence.getArray();
-
- for( i = 0; i < NON_USER_DEFINED_GLUE_POINTS; i++ )
- *pIdentifier++ = i;
-
- for( i = 0; i < nCount; i++ )
- *pIdentifier++ = ( (*pList)[i].GetId() + NON_USER_DEFINED_GLUE_POINTS ) - 1;
+ const sdr::glue::List* pList = mpObject->GetGluePointList(false);
+ const sdr::glue::PointVector aGluePointVector(pList ? pList->getVector() : sdr::glue::PointVector());
+ uno::Sequence< sal_Int32 > aIdSequence(aGluePointVector.size() + NON_USER_DEFINED_GLUE_POINTS);
+ sal_Int32 *pIdentifier = aIdSequence.getArray();
+ sal_uInt32 i(0);
+
+ for(i = 0; i < NON_USER_DEFINED_GLUE_POINTS; i++)
+ {
+ *pIdentifier++ = i;
+ }
+
+ for(i = 0; i < aGluePointVector.size(); i++)
+ {
+ const sdr::glue::Point* pCandidate = aGluePointVector[i];
+
+ if(pCandidate)
+ {
+ *pIdentifier++ = pCandidate->getID() + NON_USER_DEFINED_GLUE_POINTS;
+ }
+ else
+ {
+ OSL_ENSURE(false, "Got a sdr::glue::PointVector with empty entries (!)");
+ }
+ }
+
+ // TTTT:GLUE
+ //const sal_uInt32 nCount = pList ? pList->GetCount() : 0;
+ //sal_uInt32 i;
+ //
+ //uno::Sequence< sal_Int32 > aIdSequence( nCount + NON_USER_DEFINED_GLUE_POINTS );
+ //sal_Int32 *pIdentifier = aIdSequence.getArray();
+ //
+ //for( i = 0; i < NON_USER_DEFINED_GLUE_POINTS; i++ )
+ // *pIdentifier++ = i;
+ //
+ //for( i = 0; i < nCount; i++ )
+ // *pIdentifier++ = ( (*pList)[i].GetId() + NON_USER_DEFINED_GLUE_POINTS ) - 1;
- return aIdSequence;
+ return aIdSequence;
}
else
{
@@ -379,151 +321,207 @@ uno::Sequence< sal_Int32 > SAL_CALL SvxU
/* deprecated */
// XIndexContainer
-void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& Element )
- throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException,
- lang::WrappedTargetException, uno::RuntimeException)
-{
- if( mpObject.is() )
- {
- SdrGluePointList* pList = mpObject->ForceGluePointList();
- if( pList )
- {
- SdrGluePoint aSdrGlue;
- drawing::GluePoint2 aUnoGlue;
-
- if( Element >>= aUnoGlue )
- {
- convert( aUnoGlue, aSdrGlue );
- pList->Insert( aSdrGlue );
-
- // only repaint, no objectchange
- mpObject->ActionChanged();
-
- return;
- }
-
- throw lang::IllegalArgumentException();
- }
- }
-
- throw lang::IndexOutOfBoundsException();
-}
-
-void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index )
- throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
-{
- if( mpObject.is() )
- {
- SdrGluePointList* pList = mpObject->ForceGluePointList();
- if( pList )
- {
- Index -= 4;
- if( Index >= 0 && Index < (sal_Int32)pList->GetCount() )
- {
- pList->Delete( (sal_uInt32)Index );
-
- // only repaint, no objectchange
- mpObject->ActionChanged();
-
- return;
- }
- }
- }
+void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() )
+ {
+ sdr::glue::List* pList = mpObject->GetGluePointList(true);
+
+ if( pList )
+ {
+ drawing::GluePoint2 aUnoGlue;
+
+ if( Element >>= aUnoGlue )
+ {
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const sdr::glue::Point aSdrGlue(aUnoGlue, aAbsoluteScale);
+
+ pList->add(aSdrGlue);
- throw lang::IndexOutOfBoundsException();
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+
+ return;
+ }
+
+ throw lang::IllegalArgumentException();
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
+void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() )
+ {
+ sdr::glue::List* pList = mpObject->GetGluePointList(true);
+
+ if( pList )
+ {
+ Index -= 4;
+
+ if(Index >= 0)
+ {
+ const sdr::glue::Point* pCandidate = pList->findByID(Index);
+
+ if(pCandidate)
+ {
+ pList->remove(*pCandidate);
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+
+ return;
+ }
+
+ // TTTT:GLUE
+ //{
+ // const sdr::glue::Point* pCandidate = pList->findByID(sal_uInt32 nID) const;
+ //
+ //
+ //
+ // pList->Delete( (sal_uInt32)Index );
+ //
+ // // only repaint, no objectchange
+ // mpObject->ActionChanged();
+ //
+ // return;
+ //}
+ }
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
}
// XIndexReplace
-void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno::Any& Element )
- throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException,
- uno::RuntimeException)
-{
- drawing::GluePoint2 aUnoGlue;
- if(!(Element >>= aUnoGlue))
- throw lang::IllegalArgumentException();
-
- Index -= 4;
- if( mpObject.is() && Index >= 0 )
- {
- SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
- if( pList && Index < (sal_Int32)pList->GetCount() )
- {
- SdrGluePoint& rGlue = (*pList)[(sal_uInt32)Index];
- convert( aUnoGlue, rGlue );
-
- // only repaint, no objectchange
- mpObject->ActionChanged();
- }
- }
+void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ drawing::GluePoint2 aUnoGlue;
+
+ if(!(Element >>= aUnoGlue))
+ throw lang::IllegalArgumentException();
+
+ Index -= 4;
+
+ if( mpObject.is() && Index >= 0 )
+ {
+ const sdr::glue::List* pList = mpObject->GetGluePointList(false);
+ const sdr::glue::PointVector aGluePointVector(pList ? pList->getVector() : sdr::glue::PointVector());
+
+ if(Index < (sal_Int32)aGluePointVector.size())
+ {
+ sdr::glue::Point* pCandidate = aGluePointVector[Index];
+
+ if(pCandidate)
+ {
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const sdr::glue::Point aSdrGlue(aUnoGlue, aAbsoluteScale);
+
+ *pCandidate = aSdrGlue;
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ }
+ else
+ {
+ OSL_ENSURE(false, "Got a sdr::glue::PointVector with empty entries (!)");
+ }
+
+ // TTTT:GLUE
+ //rGlue = (*pList)[(sal_uInt32)Index];
+ //convert( aUnoGlue, rGlue );
+ //
+ //// only repaint, no objectchange
+ //mpObject->ActionChanged();
+ }
+ }
- throw lang::IndexOutOfBoundsException();
+ throw lang::IndexOutOfBoundsException();
}
// XIndexAccess
-sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount()
- throw(uno::RuntimeException)
+sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount() throw(uno::RuntimeException)
+{
+ sal_Int32 nCount = 0;
+
+ if( mpObject.is() )
+ {
+ // each node has a default of 4 glue points
+ // and any number of user defined glue points
+ nCount += 4;
+
+ const sdr::glue::List* pList = mpObject->GetGluePointList(false);
+ const sdr::glue::PointVector aGluePointVector(pList ? pList->getVector() : sdr::glue::PointVector());
+
+ nCount += aGluePointVector.size();
+ }
+
+ return nCount;
+}
+
+uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
{
- sal_Int32 nCount = 0;
- if( mpObject.is() )
- {
- // each node has a default of 4 glue points
- // and any number of user defined glue points
- nCount += 4;
-
- const SdrGluePointList* pList = mpObject->GetGluePointList();
- if( pList )
- nCount += pList->GetCount();
- }
-
- return nCount;
-}
-
-uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index )
- throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
-{
- if(Index >= 0 && mpObject.is())
- {
- struct drawing::GluePoint2 aGluePoint;
-
- if( Index < 4 ) // default glue point?
- {
- SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (sal_uInt32)Index );
- aGluePoint.IsUserDefined = sal_False;
- convert( aTempPoint, aGluePoint );
- uno::Any aAny;
- aAny <<= aGluePoint;
- return aAny;
- }
- else
- {
- Index -= 4;
- const SdrGluePointList* pList = mpObject->GetGluePointList();
- if( pList && Index < (sal_Int32)pList->GetCount() )
- {
- const SdrGluePoint& rTempPoint = (*pList)[(sal_uInt32)Index];
- aGluePoint.IsUserDefined = sal_True;
- convert( rTempPoint, aGluePoint );
- uno::Any aAny;
- aAny <<= aGluePoint;
- return aAny;
- }
- }
- }
+ if(Index >= 0 && mpObject.is())
+ {
+ if( Index < 4 ) // default glue point?
+ {
+ const sdr::glue::Point aTempPoint(mpObject->GetVertexGluePoint(Index));
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const drawing::GluePoint2 aGluePoint(aTempPoint.convertToGluePoint2(aAbsoluteScale));
+ uno::Any aAny;
+
+ aAny <<= aGluePoint;
+ return aAny;
+ }
+ else
+ {
+ Index -= 4;
+ const sdr::glue::List* pList = mpObject->GetGluePointList(false);
+ const sdr::glue::PointVector aGluePointVector(pList ? pList->getVector() : sdr::glue::PointVector());
+
+ if(pList && Index < (sal_Int32)aGluePointVector.size())
+ {
+ const sdr::glue::Point* pCandidate = aGluePointVector[Index];
+
+ if(pCandidate)
+ {
+ const basegfx::B2DVector aAbsoluteScale(basegfx::absolute(mpObject->getSdrObjectScale()));
+ const drawing::GluePoint2 aGluePoint(pCandidate->convertToGluePoint2(aAbsoluteScale));
+ uno::Any aAny;
+
+ aAny <<= aGluePoint;
+ return aAny;
+ }
+ else
+ {
+ OSL_ENSURE(false, "Got a sdr::glue::PointVector with empty entries (!)");
+ }
+
+ // TTTT:GLUE
+ //rTempPoint = (*pList)[(sal_uInt32)Index];
+ //aGluePoint.IsUserDefined = sal_True;
+ //convert( rTempPoint, aGluePoint );
+ //uno::Any aAny;
+ //aAny <<= aGluePoint;
+ //return aAny;
+ }
+ }
+ }
- throw lang::IndexOutOfBoundsException();
+ throw lang::IndexOutOfBoundsException();
}
// XElementAccess
-uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType()
- throw( uno::RuntimeException)
+uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType() throw( uno::RuntimeException)
{
- return ::getCppuType((const struct drawing::GluePoint2*)0);
+ return ::getCppuType((const struct drawing::GluePoint2*)0);
}
-sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements()
- throw( uno::RuntimeException)
+sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements() throw( uno::RuntimeException)
{
- return mpObject.is();
+ return mpObject.is();
}
/**
@@ -531,5 +529,7 @@ sal_Bool SAL_CALL SvxUnoGluePointAccess:
*/
uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject )
{
- return *new SvxUnoGluePointAccess(pObject);
+ return *new SvxUnoGluePointAccess(pObject);
}
+
+// eof
Modified: openoffice/branches/alg/aw080/main/svx/source/unodraw/unoshap2.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/aw080/main/svx/source/unodraw/unoshap2.cxx?rev=1529226&r1=1529225&r2=1529226&view=diff
==============================================================================
--- openoffice/branches/alg/aw080/main/svx/source/unodraw/unoshap2.cxx (original)
+++ openoffice/branches/alg/aw080/main/svx/source/unodraw/unoshap2.cxx Fri Oct 4 17:20:25 2013
@@ -2107,13 +2107,13 @@ void SAL_CALL SvxCustomShape::setPropert
// // #i38892#
// const bool bNeedsMirrorX(((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX);
// const bool bNeedsMirrorY(((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY);
- // boost::scoped_ptr< SdrGluePointList > pListCopy;
+ // boost::scoped_ptr< sdr::glue::List > pListCopy;
//
// if( bNeedsMirrorX || bNeedsMirrorY )
// {
- // const SdrGluePointList* pList = pObject->GetGluePointList();
+ // const sdr::glue::List* pList = pObject->GetGluePointList(false);
// if( pList )
- // pListCopy.reset( new SdrGluePointList(*pList) );
+ // pListCopy.reset( new sdr::glue::List(*pList) );
// }
//
// if ( bNeedsMirrorX )
@@ -2137,7 +2137,7 @@ void SAL_CALL SvxCustomShape::setPropert
//
// if( pListCopy )
// {
- // SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
+ // sdr::glue::List* pNewList = pObject->GetGluePointList(false);
// if(pNewList)
// *pNewList = *pListCopy;
// }