Hi Fang,
thanks for the detailed email, much easier to answer to this one.
Fang Yaqiong wrote:
> Hi Christian,
> 1. I found that mpVDev- >GetTextOutline returns the PolyPolygon of the whole
> line in the impress, and I think we should get the PolyPolygon of single
> text. So I define a PolyPolygonVector to store the whole line words'
> PolyPolygon. And I invoke the GetTextOutlines() instead of GetTextOutline()
> as the first parameter of it is a PolyPolyVector.
>
> mpVDev->GetTextOutlines( aPolyPolyVector, rText, 0, 0, (USHORT)nLen, TRUE,
> nWidth, pDXArray );
>
> 2. Because I want to store the PolyPolygon of every single text in the
> PolyPolygonVector, and the aB2DPolyPolyVector stores the single text, so I
> add the code as below in the method GetTextOutlines():
>
> for(; aIt != aB2DPolyPolyVector.end(); ++aIt )
> {
> rResultVector.push_back( *aIt );
> for( unsigned int i = 0; i < aIt->count(); ++i )
> {
> aPolyPolygon = *aItPolyPolyVector;
> aPolyPolygon.Insert( (*aIt).getB2DPolygon( i ) );
> }
> }
>
> Q1: I am not sure whether it can be modfied like this or I should define a
> new method to realize it.
>
GetTextOutlines() already does what you want. Your modified version does
the same, except that it also add all Polygons from all PolyPolygons
(remember,
a PolyPolygon is just a vector of Polygons) to the first PolyPolygon in
the result vector. This way the geometry of the first PolyPolygon is
also doubled each
time. I don't think this is what you want. So you don't need to modify
OutputDevice::GetTextOutlines() as it already returns one PolyPolygon
for each character.
> 3. And now the PolyPolygonVector stores the every single text's PolyPolygon,
> not the whole line text's PolyPolygon. So every PolyPolygon should be
> translated and implemented. I use a loop to realize it.
>
> PolyPolyVector::const_iterator aItPolyPolyVector = aPolyPolyVector.begin();
> PolyPolygon aPolyPoly;
> for(; aItPolyPolyVector != aPolyPolyVector.end(); ++aItPolyPolyVector )
> {
> aPolyPoly = *aItPolyPolyVector;
> aPolyPoly.Translate( rPos );
> Impl_writePolyPolygon( aPolyPoly, sal_True, aTextColor, aTextColor );
> }
>
> Q2: Last IRC meeting, you said it should be a PolyPolyVector instead of just
> a PolyPolygon, so I modfied it like this. Is it right?
>
Yes this part is correct.
> 4. I can add a cache in Writer::defineShape( const PolyPolygon& rPolyPoly,
> const FillStyle& rFillStyle ) as I have said before. But the member varible
> of PolyPolygon is a pointer. (ImplPolyPolygon* mpImplPolyPolygon;)
>
> Q3: If two PolyPolygons exported are the same, will the pointer in
> PolyPolygon point to the same memory? Or will the same PolyPolygons be
> exported to the different memory?
> If they point to the same memory then we can compare the pointer. Then if the
> pointer is the same, it means they are the same PolyPolygon.
>
They can point to different memory. So comparing the pointers of two
PolyPolygon is not enough. But luckily, the PolyPolygon class already
has a operator==, so you can do
if( aPoly1 == aPoly2 ) ... ;
Now for the cache to work, you need to solve one additional problem.
Lets imagine you have the following text in a complex font
"ab" and "ba"
Now we only look at the character "a". Since it is the same geometry in
both cases we should be able to define only one geometry of "a".
But if you compare the PolyPolygons created by GetTextOutlines for the
first "a" and the second "a" you find that the operator== will fail
for them. This is because the translation offset of the first "a" is
(0,0) and the translation offset of the second "a" is (width of "b" +
spacing,0).
Now before comparing two polygons in the cache, you need to transform
them that they always have an origin of (0,0). This can be done
easy by looking at all points and find the smallest x and y component.
Then translate the PolyPolygon by (- min x, - min y).
Of course you must remember that offset as you have to add it later when
that cached PolyPolygon is used.
Regards,
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]