Hi Christian,
I add a class PolyPolygonCacheKey what you used to said. It contains the
operator == and operator < and a method getMinPoint to get the minX and minY of
the Poygon.
class PolyPolygonCacheKey
{
public:
PolyPolygonCacheKey( const PolyPolygon& rPolyPoly, const FillStyle& rFillStyle
):maPolyPoly(rPolyPoly),maFillStyle(rFillStyle)
{
}
BOOL operator==( const PolyPolygonCacheKey& rKey ) const;
BOOL operator<( const PolyPolygonCacheKey& rKey ) const;
B2DPoint getMinPoint( const PolyPolygon& rPolyPoly);
private:
PolyPolygon maPolyPoly;
FillStyle maFillStyle;
};
And the getMinPoint() is defined like this:
B2DPoint PolyPolygonCacheKey::getMinPoint(const PolyPolygon& rPolyPoly)
{
sal_uInt32 nB2DPolyPolygonCount = rPolyPoly.getB2DPolyPolygon().count();
B2DPoint maMinPoint;
maMinPoint.setX(rPolyPoly.getB2DPolyPolygon().getB2DPolygon(0).getB2DPoint(0).getX());
maMinPoint.setY(rPolyPoly.getB2DPolyPolygon().getB2DPolygon(0).getB2DPoint(0).getY());
for (int i=0;i<nB2DPolyPolygonCount;i++)
{
sal_uInt32 nB2DPolygonCount =
rPolyPoly.getB2DPolyPolygon().getB2DPolygon(i).count();
for (int j=0; j< nB2DPolygonCount; j++)
{
B2DPoint maPoint;
maPoint.setX(rPolyPoly.getB2DPolyPolygon().getB2DPolygon(i).getB2DPoint(j).getX());
maPoint.setY(rPolyPoly.getB2DPolyPolygon().getB2DPolygon(i).getB2DPoint(j).getY());
if (maMinPoint.getX() > maPoint.getX())
{
maMinPoint.setX(maPoint.getX());
}
if (maMinPoint.getY()>maPoint.getY())
{
maMinPoint.setY(maPoint.getY());
}
}
}
return maMinPoint;
}
In swfwriter.cxx I add a chache in the sal_uInt16 Writer::defineShape( const
PolyPolygon& rPolyPoly, const FillStyle& rFillStyle )
before startTag( TAG_DEFINESHAPE3 );
I add the cods:
PolyPolygon maPolyPolygon = rPolyPoly;
PolyPolygonCacheKey maPolyPolygonFillStyle(rPolyPoly,rFillStyle);
//get the minX and minY
B2DPoint maMinPoint = maPolyPolygonFillStyle.getMinPoint(maPolyPolygon);
Point maMinPoint1(-maMinPoint.getX(),-maMinPoint.getY());
//translate the polygon back to not contains the offset
maPolyPolygon.Translate(maMinPoint1);
PolyPolygonCacheKey maPolyPolygonFillStyle1(maPolyPolygon,rFillStyle);
//find the polygon in the cache, maPolyPolygonCacheMap is defined in class
writer
std::map<PolyPolygonCacheKey, int>::const_iterator
aIter(maPolyPolygonCacheMap.find(maPolyPolygonFillStyle1));
sal_uInt16 nShapeId=0;
if( aIter != maPolyPolygonCacheMap.end() )
{
//if find,return the nShapId
nShapeId = aIter->second;
return nShapeId;
}
else
{
//if not, we create one now
nShapeId = createID();
maPolyPolygonCacheMap[maPolyPolygonFillStyle]=nShapeId;
}
This is my thought in this part, what do you think about it? Is it all right or
not?
I still have some questions about it, as I haven't defined the operator == and
< suitably.
I used to define them like this:
BOOL PolyPolygonCacheKey::operator==( const PolyPolygonCacheKey& rKey ) const
{
DBG_CHKTHIS( PolyPolygonCacheKey, NULL );
DBG_CHKOBJ( &rKey, PolyPolygonCacheKey, NULL );
if ((this->maPolyPoly == rKey.maPolyPoly) && (this->maFillStyle ==
rKey.maFillStyle))
return TRUE;
else
return FALSE;
}
BOOL PolyPolygonCacheKey::operator<( const PolyPolygonCacheKey& rKey ) const
{
DBG_CHKTHIS( PolyPolygonCacheKey, NULL );
DBG_CHKOBJ( &rKey, PolyPolygonCacheKey, NULL );
return !(*this == rKey) && (this->maPolyPoly < rKey.maPolyPoly);
}
But it doesn't work probably. Can you give some suggestions?
Q1: When I track in the codes, I find in Writer::defineShape(const PolyPolygon&
rPolyPoly, const FillStyle& rFillStyle ) , the value of rPolyPoly is a pointer.
When the Polygon is the same (if I export the same word several times),
sometimes the pointer points to the same place, bug sometimes not. I puzzled
about it. And the polygon here containts the offest of the polygon, but it is
true that sometime the pointer in the rPolyPoly points to the same cache, but
sometimes not.
Q2: I read about the format of the flash, we define the shapes of every polygon
, and then define a movieclip to put all the polygons on it. If we define the
polygons without the offset, and how we know the different offset of the same
polygon, and how to define a movieclip which contians the offset of the
polygon? Should I return the offset of each polygon altogether with the id?
I'm sorry that it last such a long time. I am new about it and don't have full
time on it. But I think I am trying my best to it. Thank you for your guides
and look forward to your suggestions sincerely.
Best regards,
Fang
Fang Yaqiong [EMAIL PROTECTED]
2007-06-22
Regards&Thanks!
Tel:010-5157-0010 Ext.6202
Beijing Redflag CH2000 Software Co., Ltd.