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;
}
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 );
}
...
...
...
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?
Writer would need an own implementation anyway.
>
> In Calc it only works in cell edit mode. When painting cells, Calc
> normally uses DrawText directly for performance reasons.
> But they use the EditEngine for painting when the content has different
> attributes. So it might also be able to convince Calc to use the
> EditEngine when an other align mode is used.
>
> Last but not least: Please recognize that ODF probably doesn't support
> the attributes that you want to introduce...
>
> I have already add this attributes and it can save and load success.
> HTH,
> Malte.
>
> With Best Regards,
LiuTao
> http://wiki.services.openoffice.org/wiki/Picture1-3
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>