Hi LiuTao...

JiaXiang Liu wrote, On 12/04/09 03:19:
> Hello Malte,
> 
> 2009/12/3 Malte Timmermann <[email protected]>
> 
>> Hi LiuTao,
>>
>> you don't need to touch VCL for this, because VCL can't help you with
>> this feature.
>>
>> VCL only sees single text portions, so it can't calculate the correct
>> positions when it comes to complete text lines.
>>
>> This needs to be done in the EditEngine.
>>
>> For TOP and BOTTOM it should be easy.
>>
>> No changes needed in calculation, only in output.
>>
>> In ImpEditEngine::Paint:
>>
>> TOP: Instead of adding nMaxAscent to Y postions, don't manipulate Y and
>> tell VCL to use ALIGN_TOP.
>>
>> BOTTOM: Instead of adding nMaxAscent to Y postions, add line height and
>> tell VCL to use ALIGN_BOTTOM.
>>
>> Please recognize the different manipulations needed for
>> horizontal/vertical writing.
>>
>> CENTER: Can be more complicated, but also might be simple.
>> One solution could be to calculate the font metrics for the portion that
>> you want to draw, handle Y postions like for TOP, but now add
>> (lineheight - textheight) to Y position.
>>
> I have already add codes in In ImpEditEngine::Paint like this:
> 
>     enum TextAlign eTmpAline = ALIGN_BASELINE;
>             SvxFontAlign eFontAlign =
> ((SvxFontAlignItem&)pNode->GetContentAttribs().GetItem( EE_PARA_FONTALIGN
> )).GetFontAlign();
>             if (eFontAlign == SVX_FONT_ALIGN_TOP)
>             {
>                 eTmpAline = ALIGN_TOP;
>             }
>             else if (eFontAlign == SVX_FONT_ALIGN_BOTTOM)
>             {
>                 eTmpAline = ALIGN_BOTTOM;
>             }
>             else if (eFontAlign == SVX_FONT_ALIGN_CENTER)
>             {
>                 eTmpAline = ALIGN_CENTER;

As I said: There is no ALIGN_CENTER in VCL, and your also shouldn't
introduce it, because it makes no sense in that layer.

>             }
>             else
>             {
>                 eTmpAline = ALIGN_BASELINE;
>             }
>         rFont.SetAlign( eTmpAline );
> 
> I think this is what you mean.
> 
> In vcl\source\gdi\outdev3.cxx
> 
>     TextAlign eAlign = maFont.GetAlign();
>     if ( eAlign == ALIGN_BASELINE )
>     {
>         mnTextOffX = 0;
>         mnTextOffY = 0;
>     }
>     else if ( eAlign == ALIGN_TOP )
>     {
>         mnTextOffX = 0;
>         mnTextOffY = +pFontEntry->maMetric.mnAscent + mnEmphasisAscent;
>         if ( pFontEntry->mnOrientation )
>             ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
> pFontEntry->mnOrientation );
>     }
> ...
> ...
> ...

Unfortunately you didn't show how you would implement CENTER here in a
meaningful way. Also, as I said, VCL only gets portions of the text, so
TOP and BOTTOM in VCL can't align your complete text line.

> 
> this is the calculation about ALIGN_BASELINE
> ,ALIGN_TOP,ALIGN_BOTTOM,ALIGN_CENTER(I added this calculation).
> 
> 
> 
> 
>> This should work in Draw/Impress only.
>> Maybe even only in edit mode - it might be that Draw use some special
>> routines for repainting text objects which are not in edit mode (not
>> sure). I also can't say if it would automatically works in presentation
>> mode.
>>
>>
> it is OK in edit mode but it seems can not repaint not in edit mode.you can
> see  the pictures I sent to you.
> It is OK in Outline view but not in normal view. I think that is because
> Outline view is also in edit mode.
> What I want to know is how to repaint it not in edit mode in Impress?

This is somewhere in the drawing layer - not sure where...

But I really don't understand why you completely ignored my hints how to
implement the feature.
- You have to do the calculations in the EditEngine - it will never look
right with different font sizes if you rely on VCL's align mode only.
- Fonts have the metrics like ascent and descent for good reasons. I am
not sure if the VCL team will accept to have ALIGN_CENTER in VCL,
because it doesn't make much sense.

Last but not least: Make sure that ODF covers your new attribute, or
bring a proposal for this to the OASIS TC. Otherwise you can't have
persistence for your new feature w/o having invalid ODF documents.

Malte.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to