Questions about Text Align feature.

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Questions about Text Align feature.

JiaXiang Liu
Hello all,

 I want to ask you some questons. I am developing a new feature called
"text-align" recently. this feature is like this:
    it can set text align in 4 ways: 1.TOP,2.CENTER,3.BASELINE,4.BOTTOM in
Impress module. Then it can be set in SW and SC modules.
I implement it like this:
                 1.define a menu item ;
                 2.define slot_ID;
                 3.define a SvxTextAlignItem like  SvxAdjustItem.
                 4. for example. I add these code:
case SID_TEXT_ALIGN_TOP:
{
       aNewAttr.Put( SvxTextAlignItem( SVX_TEXTALIGN_TOP, EE_TEXT_ALIGN ) );
}
like this code:
case SID_ATTR_PARA_ADJUST_LEFT,:
{
    aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
}
                  5. after that I think it should do calculate and paint.I
found some code in vcl like this:
    // calculate text offset depending on TextAlignment
    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 );
    }
    //---liutao---modify---091109---15:31---start---//
    //else // eAlign == ALIGN_BOTTOM
    //{
    //    mnTextOffX = 0;
    //    mnTextOffY = -pFontEntry->maMetric.mnDescent + mnEmphasisDescent;
    //    if ( pFontEntry->mnOrientation )
    //        ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
pFontEntry->mnOrientation );
    //}
    else if (eAlign == ALIGN_BOTTOM)
    {
        mnTextOffX = 0;
        mnTextOffY = -pFontEntry->maMetric.mnDescent + mnEmphasisDescent;
        if ( pFontEntry->mnOrientation )
            ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
pFontEntry->mnOrientation );
    }
    else //(eAlign == ALIGN_CENTER)
    {
        mnTextOffX = 0;
        mnTextOffY = -pFontEntry->maMetric.mnDescent + mnEmphasisDescent;
        if ( pFontEntry->mnOrientation )
            ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
pFontEntry->mnOrientation );
    }
//---liutao---modify---091109---15:31---end---//
I did some modify.
I think the calculation is done by someone else. so it become easy to
implement this feature.
my question is this:
1.how to call this calculation function?
             I add some code like this in the createfont function in
editdoc.cxx file:
//---liutao---modify---091109---15:39---start---//
    rFont.SetAlign( ALIGN_BASELINE );
    //enum TextAlign at = ALIGN_BASELINE;
    //if ( bSearchInParent || ( rSet.GetItemState( EE_PARA_ALIGN ) ==
SFX_ITEM_ON ) )
    //{
    //    SvxTextAlignItem svAD = (const SvxTextAlignItem&)rSet.Get(
EE_PARA_ALIGN );
    //    if (svAD.GetTextAlign() == SVX_TEXTALIGN_TOP)
    //    {
    //        at = ALIGN_TOP;
    //    }
    //    else if (svAD.GetTextAlign() == SVX_TEXTALIGN_BOTTOM)
    //    {
    //        at = ALIGN_BOTTOM;
    //    }
    //    else if (svAD.GetTextAlign() == SVX_TEXTALIGN_CENTER)
    //    {
    //        at = ALIGN_CENTER;
    //    }
    //    else
    //    {
    //        at = ALIGN_BASELINE;
    //    }
    //}
    //rFont.SetAlign(at);
//---liutao---modify---091109---15:39---end---//
these code can change the position of the words. for example,after I add
these code and implement it. the phenomena is like this:
1.1.create a new Impress document
1.2.select a layout and input some words in a Editbox. these words should
have different size.
1.3.implement this new feature(align top)
1.4.result:
these words are down to the bottom line. I can only see only a little "head"
of these words . (PIC1) BUT  I think it is aligned top.(PIC2)
after I exit the edit status. it will be dispalied as original.(PIC3)(if we
set para align left in edit status and exit edit status,it will not
dispalied as original.)
2. what is the function mean "void CreateFont( SvxFont& rFont, const
SfxItemSet& rSet, bool bSearchInParent, short nScriptType )" in editdoc.cxx
file.It has no class.
3. what is the arithmetic mean in vcl module:
    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 );
    }
for example:what is the mean of" mnTextOffX = 0;" and what is the mean of "
mnTextOffY = +pFontEntry->maMetric.mnAscent + mnEmphasisAscent;
        if ( pFontEntry->mnOrientation )
            ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
pFontEntry->mnOrientation );"
4.if I should define  a new class EditCharAttribAlign like
EditCharAttribShadow to implement this feature?I added this class but
unfortunately I don't know how to use it. and seems it should be defined.
EditCharAttribShadow::EditCharAttribShadow( const SvxShadowedItem& rAttr,
USHORT _nStart, USHORT _nEnd )
    : EditCharAttrib( rAttr, _nStart, _nEnd )
{
    DBG_ASSERT( rAttr.Which() == EE_CHAR_SHADOW, "Kein Shadowattribut!" );
}
void EditCharAttribShadow::SetFont( SvxFont& rFont, OutputDevice* )
{
    rFont.SetShadow( (BOOL)((const SvxShadowedItem*)GetItem())->GetValue()
);
}
// -------------------------------------------------------------------------
//---liutao---add---091109---15:18---start---//
// -------------------------------------------------------------------------
// class EditCharAttribShadow
// -------------------------------------------------------------------------
//EditCharAttribAlign::EditCharAttribAlign( const SvxTextAlignItem& rAttr,
USHORT _nStart, USHORT _nEnd )
//    : EditCharAttrib( rAttr, _nStart, _nEnd )
//{
//    DBG_ASSERT( rAttr.Which() == EE_PARA_ALIGN, "Paragraph Textalign!" );
//}
//
//void EditCharAttribAlign::SetFont( SvxFont& rFont, OutputDevice* )
//{
//    rFont.SetAlign((TextAlign)((const
SvxTextAlignItem*)GetItem())->GetEnumValue() );
//}
Please look at the PIC1 TO PIC 3:

http://wiki.services.openoffice.org/wiki/Picture1-3

I wish you can give me explanation .wish your reply.
With Best Regards,
LiuTao
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
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.

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.

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...

HTH,
Malte.



JiaXiang Liu wrote, On 12/03/09 02:14:

> Hello all,
>
>  I want to ask you some questons. I am developing a new feature called
> "text-align" recently. this feature is like this:
>     it can set text align in 4 ways: 1.TOP,2.CENTER,3.BASELINE,4.BOTTOM in
> Impress module. Then it can be set in SW and SC modules.
> I implement it like this:
>                  1.define a menu item ;
>                  2.define slot_ID;
>                  3.define a SvxTextAlignItem like  SvxAdjustItem.
>                  4. for example. I add these code:
> case SID_TEXT_ALIGN_TOP:
> {
>        aNewAttr.Put( SvxTextAlignItem( SVX_TEXTALIGN_TOP, EE_TEXT_ALIGN ) );
> }
> like this code:
> case SID_ATTR_PARA_ADJUST_LEFT,:
> {
>     aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
> }
>                   5. after that I think it should do calculate and paint.I
> found some code in vcl like this:
>     // calculate text offset depending on TextAlignment
>     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 );
>     }
>     //---liutao---modify---091109---15:31---start---//
>     //else // eAlign == ALIGN_BOTTOM
>     //{
>     //    mnTextOffX = 0;
>     //    mnTextOffY = -pFontEntry->maMetric.mnDescent + mnEmphasisDescent;
>     //    if ( pFontEntry->mnOrientation )
>     //        ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
> pFontEntry->mnOrientation );
>     //}
>     else if (eAlign == ALIGN_BOTTOM)
>     {
>         mnTextOffX = 0;
>         mnTextOffY = -pFontEntry->maMetric.mnDescent + mnEmphasisDescent;
>         if ( pFontEntry->mnOrientation )
>             ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
> pFontEntry->mnOrientation );
>     }
>     else //(eAlign == ALIGN_CENTER)
>     {
>         mnTextOffX = 0;
>         mnTextOffY = -pFontEntry->maMetric.mnDescent + mnEmphasisDescent;
>         if ( pFontEntry->mnOrientation )
>             ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
> pFontEntry->mnOrientation );
>     }
> //---liutao---modify---091109---15:31---end---//
> I did some modify.
> I think the calculation is done by someone else. so it become easy to
> implement this feature.
> my question is this:
> 1.how to call this calculation function?
>              I add some code like this in the createfont function in
> editdoc.cxx file:
> //---liutao---modify---091109---15:39---start---//
>     rFont.SetAlign( ALIGN_BASELINE );
>     //enum TextAlign at = ALIGN_BASELINE;
>     //if ( bSearchInParent || ( rSet.GetItemState( EE_PARA_ALIGN ) ==
> SFX_ITEM_ON ) )
>     //{
>     //    SvxTextAlignItem svAD = (const SvxTextAlignItem&)rSet.Get(
> EE_PARA_ALIGN );
>     //    if (svAD.GetTextAlign() == SVX_TEXTALIGN_TOP)
>     //    {
>     //        at = ALIGN_TOP;
>     //    }
>     //    else if (svAD.GetTextAlign() == SVX_TEXTALIGN_BOTTOM)
>     //    {
>     //        at = ALIGN_BOTTOM;
>     //    }
>     //    else if (svAD.GetTextAlign() == SVX_TEXTALIGN_CENTER)
>     //    {
>     //        at = ALIGN_CENTER;
>     //    }
>     //    else
>     //    {
>     //        at = ALIGN_BASELINE;
>     //    }
>     //}
>     //rFont.SetAlign(at);
> //---liutao---modify---091109---15:39---end---//
> these code can change the position of the words. for example,after I add
> these code and implement it. the phenomena is like this:
> 1.1.create a new Impress document
> 1.2.select a layout and input some words in a Editbox. these words should
> have different size.
> 1.3.implement this new feature(align top)
> 1.4.result:
> these words are down to the bottom line. I can only see only a little "head"
> of these words . (PIC1) BUT  I think it is aligned top.(PIC2)
> after I exit the edit status. it will be dispalied as original.(PIC3)(if we
> set para align left in edit status and exit edit status,it will not
> dispalied as original.)
> 2. what is the function mean "void CreateFont( SvxFont& rFont, const
> SfxItemSet& rSet, bool bSearchInParent, short nScriptType )" in editdoc.cxx
> file.It has no class.
> 3. what is the arithmetic mean in vcl module:
>     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 );
>     }
> for example:what is the mean of" mnTextOffX = 0;" and what is the mean of "
> mnTextOffY = +pFontEntry->maMetric.mnAscent + mnEmphasisAscent;
>         if ( pFontEntry->mnOrientation )
>             ImplRotatePos( 0, 0, mnTextOffX, mnTextOffY,
> pFontEntry->mnOrientation );"
> 4.if I should define  a new class EditCharAttribAlign like
> EditCharAttribShadow to implement this feature?I added this class but
> unfortunately I don't know how to use it. and seems it should be defined.
> EditCharAttribShadow::EditCharAttribShadow( const SvxShadowedItem& rAttr,
> USHORT _nStart, USHORT _nEnd )
>     : EditCharAttrib( rAttr, _nStart, _nEnd )
> {
>     DBG_ASSERT( rAttr.Which() == EE_CHAR_SHADOW, "Kein Shadowattribut!" );
> }
> void EditCharAttribShadow::SetFont( SvxFont& rFont, OutputDevice* )
> {
>     rFont.SetShadow( (BOOL)((const SvxShadowedItem*)GetItem())->GetValue()
> );
> }
> // -------------------------------------------------------------------------
> //---liutao---add---091109---15:18---start---//
> // -------------------------------------------------------------------------
> // class EditCharAttribShadow
> // -------------------------------------------------------------------------
> //EditCharAttribAlign::EditCharAttribAlign( const SvxTextAlignItem& rAttr,
> USHORT _nStart, USHORT _nEnd )
> //    : EditCharAttrib( rAttr, _nStart, _nEnd )
> //{
> //    DBG_ASSERT( rAttr.Which() == EE_PARA_ALIGN, "Paragraph Textalign!" );
> //}
> //
> //void EditCharAttribAlign::SetFont( SvxFont& rFont, OutputDevice* )
> //{
> //    rFont.SetAlign((TextAlign)((const
> SvxTextAlignItem*)GetItem())->GetEnumValue() );
> //}
> Please look at the PIC1 TO PIC 3:
>
> http://wiki.services.openoffice.org/wiki/Picture1-3
>
> I wish you can give me explanation .wish your reply.
> With Best Regards,
> LiuTao
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hello Malte,

2009/12/3 Malte Timmermann <[hidden email]>

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
Hi LiuTao...

JiaXiang Liu wrote, On 12/04/09 03:19:

> Hello Malte,
>
> 2009/12/3 Malte Timmermann <[hidden email]>
>
>> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hello Malte,

Thank you for your anwser first!

2009/12/4 Malte Timmermann <[hidden email]>

> Hi LiuTao...
>
> JiaXiang Liu wrote, On 12/04/09 03:19:
> > Hello Malte,
> >
> > 2009/12/3 Malte Timmermann <[hidden email]>
> >
> >> 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.
>
> Oh,I just add a caculate CENTER  like this:

+    else if (eAlign == ALIGN_CENTER)
+    {
+        mnTextOffX = 0;
+        mnTextOffY = (pFontEntry->maMetric.mnAscent -
pFontEntry->maMetric.mnDescent)/2 + (mnEmphasisAscent +
mnEmphasisDescent)/2;
+        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?
>
> This is somewhere in the drawing layer - not sure where...
>
> This is my puzzle.I want to know how to set the text displayed OK in no
edit mode.
the different view in edit and no edit is my bigest problem.  :-(

> 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.
>
> Yes,I did not ignore your hints how to implement the feature.
I do the calculations in the EditEngine like this:
+                                            TextAlign eAlign =
aTmpFont.GetAlign();
+                                            if ( eAlign == ALIGN_CENTER )
+                                            {
+                                                aRealOutPos.Y() +=
-pLine->GetHeight() * 2/5;// + pLine->GetMaxAscent();
+                                            }
+                                            else if ( eAlign == ALIGN_TOP )
+                                            {
+                                                aRealOutPos.Y() +=
-pLine->GetHeight() * 4/5;// + pLine->GetMaxAscent();
+                                            }
+                                            else if( eAlign ==
ALIGN_BOTTOM)
+                                            {
+                                                aRealOutPos.Y() +=
pLine->GetHeight() * 1/5;// + pLine->GetMaxAscent();
+                                            }

It can dispaly correctly in edit mode but not in unedit mode.

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.
>
> OK,Thank you.how to bring a proposal to the OASIS TC? Are there somebody in
OpenOffice team do this feature?


> Malte.
>
>
With Best Regards,
LiuTao

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
Hi LiuTao,

JiaXiang Liu wrote, On 12/04/09 09:36:

> Hello Malte,
>
> Thank you for your anwser first!
>
> 2009/12/4 Malte Timmermann <[hidden email]>
>
>> Hi LiuTao...
>>
>> JiaXiang Liu wrote, On 12/04/09 03:19:
>>> Hello Malte,
>>>
>>> 2009/12/3 Malte Timmermann <[hidden email]>
>>>
>>>> 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.
>>
>> Oh,I just add a caculate CENTER  like this:
>
> +    else if (eAlign == ALIGN_CENTER)
> +    {
> +        mnTextOffX = 0;
> +        mnTextOffY = (pFontEntry->maMetric.mnAscent -
> pFontEntry->maMetric.mnDescent)/2 + (mnEmphasisAscent +
> mnEmphasisDescent)/2;
> +        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?
>> This is somewhere in the drawing layer - not sure where...
>>
>> This is my puzzle.I want to know how to set the text displayed OK in no
> edit mode.
> the different view in edit and no edit is my bigest problem.  :-(
>
>> 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.
>>
>> Yes,I did not ignore your hints how to implement the feature.
> I do the calculations in the EditEngine like this:
> +                                            TextAlign eAlign =
> aTmpFont.GetAlign();
> +                                            if ( eAlign == ALIGN_CENTER )
> +                                            {
> +                                                aRealOutPos.Y() +=
> -pLine->GetHeight() * 2/5;// + pLine->GetMaxAscent();
> +                                            }
> +                                            else if ( eAlign == ALIGN_TOP )
> +                                            {
> +                                                aRealOutPos.Y() +=
> -pLine->GetHeight() * 4/5;// + pLine->GetMaxAscent();
> +                                            }
> +                                            else if( eAlign ==
> ALIGN_BOTTOM)
> +                                            {
> +                                                aRealOutPos.Y() +=
> pLine->GetHeight() * 1/5;// + pLine->GetMaxAscent();
> +                                            }

Not sure what this random multiplications are good for. Try-and-error
until one example looked good?
I didn't try it, but the calculations I suggested look much more logical
to me...
And again - please note that you also need to take vertical writing mode
into consideration. Not sure if the feature makes sense in vertical
writing. If so, adjust calculations accordingly. If not, make sure to
not do the calculations in vertical writing mode.

>
> It can dispaly correctly in edit mode but not in unedit mode.
>
> 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.
>>
> OK,Thank you.how to bring a proposal to the OASIS TC? Are there somebody in
> OpenOffice team do this feature?

Well, it seems CS2C is working on OOo features, so C2SC should become an
OASIS member, and someone of you (maybe you?) should join the OASIS ODF
TC. Submitting suggestions to OASIS TCs always needs to be done directly
from the people who want to have something. This has something to do
with intellectually property stuff.

Malte.

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hello Malte,

Thank you for your answer.

What I puzzled now is:

Why I can not set the new attribute in no edit mode?

This is the* biggest problem* now and I want to solve it. Can you help
me?you said it may be the drawing layer.but I can not do anything about
that.

Do you know Are there somebody in OpenOffice team is developing or will
develop this feature?

2009/12/4 Malte Timmermann <[hidden email]>

> Hi LiuTao,
>
> JiaXiang Liu wrote, On 12/04/09 09:36:
> > Hello Malte,
> >
> > Thank you for your anwser first!
> >
> > 2009/12/4 Malte Timmermann <[hidden email]>
> >
> >> Hi LiuTao...
> >>
> >> JiaXiang Liu wrote, On 12/04/09 03:19:
> >>> Hello Malte,
> >>>
> >>> 2009/12/3 Malte Timmermann <[hidden email]>
> >>>
> >>>> 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.
> >>
> >> Oh,I just add a caculate CENTER  like this:
> >
> > +    else if (eAlign == ALIGN_CENTER)
> > +    {
> > +        mnTextOffX = 0;
> > +        mnTextOffY = (pFontEntry->maMetric.mnAscent -
> > pFontEntry->maMetric.mnDescent)/2 + (mnEmphasisAscent +
> > mnEmphasisDescent)/2;
> > +        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?
> >> This is somewhere in the drawing layer - not sure where...
> >>
> >> This is my puzzle.I want to know how to set the text displayed OK in no
> > edit mode.
> > the different view in edit and no edit is my bigest problem.  :-(
> >
> >> 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.
> >>
> >> Yes,I did not ignore your hints how to implement the feature.
> > I do the calculations in the EditEngine like this:
> > +                                            TextAlign eAlign =
> > aTmpFont.GetAlign();
> > +                                            if ( eAlign == ALIGN_CENTER
> )
> > +                                            {
> > +                                                aRealOutPos.Y() +=
> > -pLine->GetHeight() * 2/5;// + pLine->GetMaxAscent();
> > +                                            }
> > +                                            else if ( eAlign ==
> ALIGN_TOP )
> > +                                            {
> > +                                                aRealOutPos.Y() +=
> > -pLine->GetHeight() * 4/5;// + pLine->GetMaxAscent();
> > +                                            }
> > +                                            else if( eAlign ==
> > ALIGN_BOTTOM)
> > +                                            {
> > +                                                aRealOutPos.Y() +=
> > pLine->GetHeight() * 1/5;// + pLine->GetMaxAscent();
> > +                                            }
>
> Not sure what this random multiplications are good for. Try-and-error
> until one example looked good?
> I didn't try it, but the calculations I suggested look much more logical
> to me...
> And again - please note that you also need to take vertical writing mode
> into consideration. Not sure if the feature makes sense in vertical
> writing. If so, adjust calculations accordingly. If not, make sure to
> not do the calculations in vertical writing mode.
>
>
yes,I already add a if sentence to implement the vertical writing mode.
It is OK for me.



> >
> > It can dispaly correctly in edit mode but not in unedit mode.
> >
> > 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.
> >>
> > OK,Thank you.how to bring a proposal to the OASIS TC? Are there somebody
> in
> > OpenOffice team do this feature?
>
> Well, it seems CS2C is working on OOo features, so C2SC should become an
> OASIS member, and someone of you (maybe you?) should join the OASIS ODF
> TC. Submitting suggestions to OASIS TCs always needs to be done directly
> from the people who want to have something. This has something to do
> with intellectually property stuff.
>
>
I will ask someone else about this. I just join CS2C 2 month and do not know
many things .


> Malte.
>
>
With Best Regards,
LiuTao

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
Hi LiuTao,

JiaXiang Liu wrote, On 12/04/09 10:30:
> Hello Malte,
>
> Thank you for your answer.
>
> What I puzzled now is:
>
> Why I can not set the new attribute in no edit mode?

For redrawing the content, the metrics calculated from the EditEngine
are cached somewhere, and the drawing layer uses DrawText() directly,
probably also with ALIGN_BASELINE.

>
> This is the* biggest problem* now and I want to solve it. Can you help
> me?you said it may be the drawing layer.but I can not do anything about
> that.

Armin should know more about this...

You might figure out by setting a break point in outliner.cxx
aDrawPortionHdl.Call(...). Then you will at least be able to see how the
information is collected. You need to record the information about the
currently used alignment, and also use that information at the place
where the drawtext() is done.

>
> Do you know Are there somebody in OpenOffice team is developing or will
> develop this feature?

Don't know / think so.

Malte.

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hello Malte,

Thank you very much for the information.

It is too late today fo me.

I will test in Monday morning. if it is not ok, I will also ask Armin for
this.

Have a nice weekend.

With Best Regards,

LiuTao

2009/12/4 Malte Timmermann <[hidden email]>

> Hi LiuTao,
>
> JiaXiang Liu wrote, On 12/04/09 10:30:
> > Hello Malte,
> >
> > Thank you for your answer.
> >
> > What I puzzled now is:
> >
> > Why I can not set the new attribute in no edit mode?
>
> For redrawing the content, the metrics calculated from the EditEngine
> are cached somewhere, and the drawing layer uses DrawText() directly,
> probably also with ALIGN_BASELINE.
>
> >
> > This is the* biggest problem* now and I want to solve it. Can you help
> > me?you said it may be the drawing layer.but I can not do anything about
> > that.
>
> Armin should know more about this...
>
> You might figure out by setting a break point in outliner.cxx
> aDrawPortionHdl.Call(...). Then you will at least be able to see how the
> information is collected. You need to record the information about the
> currently used alignment, and also use that information at the place
> where the drawtext() is done.
>
> >
> > Do you know Are there somebody in OpenOffice team is developing or will
> > develop this feature?
>
> Don't know / think so.
>
> Malte.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hello Malte,Armin

@Malte

I test that.It is so difficult.

I setted a break point in outliner.cxx
aDrawPortionHdl.Call(...).
Then I find the many information is collected but not alignment.

How to record the information about the currently used alignment?
If I should add a Parameter in this area ?

 DrawPortionInfo aInfo( rStartPos, rText, nTextStart, nTextLen, rFont,
nPara, nIndex, pDXArray, pWrongSpellVector,
            pFieldData, pLocale, rOverlineColor, rTextLineColor,
nRightToLeft, bEndOfLine, bEndOfParagraph, bEndOfBullet);

BTW,
aDrawPortionHdl.Call(...).  is called by
void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point
aStartPos, sal_Bool bStripOnly, short nOrientation )

and the pOutDev saved the alignment.

This area is also not save paragraph adjust.I am so puzzled.


@Armin

Malte told me that you maybe know that I want to know. :-)

the question is :
I am developing a new feature called "fontalign" It can set the text align
top,center,baseline and bottom.
In Impress,Create a new document, input some words in a text box in normal
view.
I can set the alignment successful in edit mode.
but it can not store the setting when left the edit mode.
It is OK in outline view,bucause in outline view it is also in edit mode.

I wish you can help me to solve this problem. Thank you.

With Best Regards,
LiuTao


2009/12/4 JiaXiang Liu <[hidden email]>

> Hello Malte,
>
> Thank you very much for the information.
>
> It is too late today fo me.
>
> I will test in Monday morning. if it is not ok, I will also ask Armin for
> this.
>
> Have a nice weekend.
>
> With Best Regards,
>
> LiuTao
>
> 2009/12/4 Malte Timmermann <[hidden email]>
>
>> Hi LiuTao,
>>
>>
>> JiaXiang Liu wrote, On 12/04/09 10:30:
>> > Hello Malte,
>> >
>> > Thank you for your answer.
>> >
>> > What I puzzled now is:
>> >
>> > Why I can not set the new attribute in no edit mode?
>>
>> For redrawing the content, the metrics calculated from the EditEngine
>> are cached somewhere, and the drawing layer uses DrawText() directly,
>> probably also with ALIGN_BASELINE.
>>
>> >
>> > This is the* biggest problem* now and I want to solve it. Can you help
>> > me?you said it may be the drawing layer.but I can not do anything about
>> > that.
>>
>> Armin should know more about this...
>>
>> You might figure out by setting a break point in outliner.cxx
>> aDrawPortionHdl.Call(...). Then you will at least be able to see how the
>> information is collected. You need to record the information about the
>> currently used alignment, and also use that information at the place
>> where the drawtext() is done.
>>
>> >
>> > Do you know Are there somebody in OpenOffice team is developing or will
>> > develop this feature?
>>
>> Don't know / think so.
>>
>> Malte.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
Hi LiuTao,

the text alignment should already be part of rFont in the portion info,
but probably the drawing layer will later reset it to baseline.

You cc'ed the wrong Armin - it's [hidden email].

Malte.


JiaXiang Liu wrote, On 12/07/09 08:40:

> Hello Malte,Armin
>
> @Malte
>
> I test that.It is so difficult.
>
> I setted a break point in outliner.cxx
> aDrawPortionHdl.Call(...).
> Then I find the many information is collected but not alignment.
>
> How to record the information about the currently used alignment?
> If I should add a Parameter in this area ?
>
>  DrawPortionInfo aInfo( rStartPos, rText, nTextStart, nTextLen, rFont,
> nPara, nIndex, pDXArray, pWrongSpellVector,
>             pFieldData, pLocale, rOverlineColor, rTextLineColor,
> nRightToLeft, bEndOfLine, bEndOfParagraph, bEndOfBullet);
>
> BTW,
> aDrawPortionHdl.Call(...).  is called by
> void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point
> aStartPos, sal_Bool bStripOnly, short nOrientation )
>
> and the pOutDev saved the alignment.
>
> This area is also not save paragraph adjust.I am so puzzled.
>
>
> @Armin
>
> Malte told me that you maybe know that I want to know. :-)
>
> the question is :
> I am developing a new feature called "fontalign" It can set the text align
> top,center,baseline and bottom.
> In Impress,Create a new document, input some words in a text box in normal
> view.
> I can set the alignment successful in edit mode.
> but it can not store the setting when left the edit mode.
> It is OK in outline view,bucause in outline view it is also in edit mode.
>
> I wish you can help me to solve this problem. Thank you.
>
> With Best Regards,
> LiuTao
>
>
> 2009/12/4 JiaXiang Liu <[hidden email]>
>
>> Hello Malte,
>>
>> Thank you very much for the information.
>>
>> It is too late today fo me.
>>
>> I will test in Monday morning. if it is not ok, I will also ask Armin for
>> this.
>>
>> Have a nice weekend.
>>
>> With Best Regards,
>>
>> LiuTao
>>
>> 2009/12/4 Malte Timmermann <[hidden email]>
>>
>>> Hi LiuTao,
>>>
>>>
>>> JiaXiang Liu wrote, On 12/04/09 10:30:
>>>> Hello Malte,
>>>>
>>>> Thank you for your answer.
>>>>
>>>> What I puzzled now is:
>>>>
>>>> Why I can not set the new attribute in no edit mode?
>>> For redrawing the content, the metrics calculated from the EditEngine
>>> are cached somewhere, and the drawing layer uses DrawText() directly,
>>> probably also with ALIGN_BASELINE.
>>>
>>>> This is the* biggest problem* now and I want to solve it. Can you help
>>>> me?you said it may be the drawing layer.but I can not do anything about
>>>> that.
>>> Armin should know more about this...
>>>
>>> You might figure out by setting a break point in outliner.cxx
>>> aDrawPortionHdl.Call(...). Then you will at least be able to see how the
>>> information is collected. You need to record the information about the
>>> currently used alignment, and also use that information at the place
>>> where the drawtext() is done.
>>>
>>>> Do you know Are there somebody in OpenOffice team is developing or will
>>>> develop this feature?
>>> Don't know / think so.
>>>
>>> Malte.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
In reply to this post by JiaXiang Liu
Hello all,

2009/12/8 Malte Timmermann <[hidden email]>

> I didn't review the patch, but just took a quick look.
>
> FontAlign is probably the wrong wording here at all.
>
What you want to achieve is alignment of a text line.
> You should probably better call it TextLineAlignment or something like
> that.
>
>
OK,I will modify it.

> Again - all calculations need to be dome in some upper layer, eg.
> EditEngine. Assuming that we really talk about text lign alignment,
> there is no need/reason to add a new enum in VCL.
>

I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to care
it. assume it is no use.

>
> As I said, do the implementation in impedit3.cxx.
> Instead of the suggestion in my first email, don't use ALIGN_TOP/BOTTOM
> at all, but use the font metrics to calculate the correct position so
> that the normal output with ALIGN_BASELINE works.
>
>
I want to know where(which function?) can I use the font metrics to
calculate the correct position? and
how to use the font metrics to calculate?why do not use
ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
I think it should be called by some functions.

Just like in editmode. in the function implEditEngine::print(...).this
function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
but it is in editmode.
my problem is : I can not set Align in non-edit mode.




> Then all the rest in the drawing layer should work automatically.
>
> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one, and
> insert the new ID at the beginning, you don't have to manipulate the
> Version Maps, IIRC.
>
> The SvxFontAlignItem itself looks strange to me: Its bad design to use 4
> bool values instead of an enum, if only one value can be true, and
> exactly one value needs to be true.
>
>
I will improve.

> Malte.
>
> JiaXiang Liu wrote, On 12/08/09 12:07:
> > Hello All,
> >
> >
> >
> > 2009/12/8 Armin Le Grand <[hidden email]
> > <mailto:[hidden email]>>
> >
> >     JiaXiang Liu schrieb:
> >
> >         Hi All,
> >
> >         2009/12/7 Malte Timmermann <[hidden email]
> >         <mailto:[hidden email]>
> >         <mailto:[hidden email] <mailto:
> [hidden email]>>>
> >
> >            Hi LiuTao,
> >
>  >            given Armins explanation about the text primitive stuff, it
> >         seems it
> >            would be much easier to do the transformation to baseline in
> >            impedit3.cxx instead of manipulating the font alignment.
> >
> >         you mean I can only modify the impedit3.cxx to implement?
> >
> >     I do not know impedit3.cxx, but i would do the adaption (as
> >     described) in impTextBreakupHandler::impCreateTextPortionPrimitive.
> >     Nonetheless, even for pure VCL usage it is not sure if all usages
> >     can use the baseline when it is used. It looks like it was not used
> >     in editengine up to now, but maybe in SW. HDU should know.
> >
> >
> > yes,I have tryed so many times but have no result.I think it is not so
> > much difficult,just like to set the paragraph adjust left.when we set it
> > in edit mode it is ok , when in non-edit mode it is still ok.I guess if
> > there are some message should be transfered.
> >
> >
> >
> >
> >            Then it would probably also work out-of-the-box in non-edit
> mode.
> >
> >         Still don't know how to do that. :-(
> >
> >     As described: You have a StartPosition (rInfo.mrStartPos) that
> >     defines where to draw the text. You have the TextAlign. If TextAlign
> >     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of course)
> >     as if it is ALIGN_BASELINE. This means to add offsets vertically for
> >     horizontal text and probably vice-versa. The offsets depend on
> >     FontInfo information which You get with the VCL Font and an
> >     OutputDevice.
> >
> >
> > the font align is not a attribute of font.so it is painted in edit mode
> > in impleditengine::paint(...)
> > how to draw the alignment is in VCL.(function setalign)
> > I guess if there have a function called like : noeditview::paint(...) to
> > call the VCL to draw the alignment?
> >
> >
> > @Herbert
> >
> > Hello , Armin said you maybe know this.I wish you can help me....
> >
> >
> >            Malte.
> >
> >            Armin Le Grand wrote, On 12/07/09 12:33:
> >            > JiaXiang Liu schrieb:
> >            >> Hello Malte,Armin,
> >            >>
> >            >> Just Forward the email:
> >            >>
> >            >> 2009/12/7 JiaXiang Liu <[hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email] <mailto:[hidden email]>>
> >            >> <mailto:[hidden email]
> >         <mailto:[hidden email]> <mailto:[hidden email]
> >         <mailto:[hidden email]>>>>
> >
> >            >>
> >            >> Hello Malte,Armin
> >            >>
> >            >> @Malte
> >            >>
> >            >> I test that.It is so difficult.
> >            >>
> >            >> I setted a break point in outliner.cxx
> >            >> aDrawPortionHdl.Call(...).
> >            >> Then I find the many information is collected but not
> >         alignment.
> >            >>
> >            >> How to record the information about the currently used
> >         alignment?
> >            >> If I should add a Parameter in this area ?
> >            >>
> >            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
> nTextLen,
> >            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
> >            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
> >            >> nRightToLeft, bEndOfLine, bEndOfParagraph, bEndOfBullet);
> >            >>
> >            >> BTW,
> >            >> aDrawPortionHdl.Call(...). is called by
> >            >> void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle
> >            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
> >            nOrientation )
> >            >>
> >            >> and the pOutDev saved the alignment.
> >            >>
> >            >> This area is also not save paragraph adjust.I am so
> puzzled.
> >            >>
> >            >>
> >            >> @Armin
> >            >>
> >            >> Malte told me that you maybe know that I want to know. :-)
> >            >>
> >            > Maybe; i am responsible for DrawingLayer, not for Text
> engines;
> >            i just
> >            > have to work with TextEngines since no one really is
> >         responsible for
> >            > them currently; and Yes, they are somewhat complicated and
> >         grown
> >            code.
> >            > Malte once was responsible for them, thus in relation to
> >            > EditEngine/Outliner he may know more than me. I can help
> with
> >            > DrawingLayer and usage of TextParameters in prmitives,
> though.
> >            >>
> >            >> the question is :
> >            >> I am developing a new feature called "fontalign" It can
> >         set the
> >            >> text align top,center,baseline and bottom.
> >            >> In Impress,Create a new document, input some words in a
> >         text box
> >            >> in normal view.
> >            >> I can set the alignment successful in edit mode.
> >            >>
> >            > Is this already possible in the working/current code?
> >            > If Yes, where can i change those settings?
> >            >
> >            > If no (and it's a completely new feature) it has to be
> >            implemented not
> >            > only inside EditEngine/Outliner, evtl. new items there (not
> >         sure if
> >            > holding font alignment at the font itself is sufficient in
> all
> >            > situations) and in Paint/export/callbacks, but also in text
> >            primities,
> >            > their decompositions, exports and paintings.
> >            > I will set HDU on CC, he may now if holding alignment at the
> >            font will
> >            > be enough (if You use that currently).
> >            >
> >            >> but it can not store the setting when left the edit mode.
> >            >> It is OK in outline view,bucause in outline view it is also
> in
> >            >> edit mode.
> >            >>
> >            > That's right, that new feature has to be represented in
> >            TextPrimitives
> >            > and used by renderers for it.
> >            >
> >            > In short: DrawPortionInfo is the class which
> >         EditEngine/Outliner
> >            uses in
> >            > callback mode to export it's data (You already located
> >         that). The
> >            > FontAlignment info will be (i guess) at the
> >         DrawPortionInfo::mrFont
> >            > member which is also a 'Font' (the VCL class).
> >            >
> >
> >         yes,it can use the 'Font'(VCL class) member function like:
> >         (mrFont).SetAlign(ALIGN_TOP/../../..)
> >
> >            > Primitives do not use a Font class (they are designed to be
> >            transported
> >            > over an API later), so they use
> >            > drawinglayer::primitive2d::FontAttributes where the font is
> >            described
> >            > using FamilyName/StyleName/Weight and others. There is no
> >         alignment
> >            > currently since it was not used yet. FontAttributes is then
> >         used in
> >            > TextSimplePortionPrimitive2D. At render time, the helper
> >            > getVclFontFromFontAttributes is used to re-create a VCL Font
> >            from the
> >            > FontAttributes, but this is only ONE way to use/render text
> >         in the
> >            > future with primitives; to use VCL again. This will
> >         probably change.
> >            >
> >            > The point is that currently, font alignment is not part of
> >            > FontAttributes and is not transported. As can be seen in
> >            > getVclFontFromFontAttributes, ALIGN_BASELINE is assumed. I
> >         would
> >            not add
> >            > a font alignment to FontAttributes to keep it minimal (and
> >         it is not
> >            > necessary). The TextSimplePortionPrimitive2D (and it's
> >            derivates) are
> >            > low-level text portion holders and also have a implicit
> >         TextPosition
> >            > (part of the TextTransform), thus it would be best to adapt
> the
> >            implicit
> >            > TextStart position inside
> >            > impTextBreakupHandler::impCreateTextPortionPrimitive to
> >         always use
> >            > ALIGN_BASELINE.
> >            >
> >            > This is always possible using the FontInfo class and the
> >         offsets
> >            of the
> >            > font (bbaseline, height, etc...). This can be done in
> >            > impTextBreakupHandler::impCreateTextPortionPrimitive, see
> >         'apply
> >            local
> >            > offset'. rInfo.mrStartPos.Y() would need to be
> >         expanded/adapted when
> >            > text alignment is != ALIGN_BASELINE.
> >            >
> >
> >         If that means I would modify something in this area and do some
> >         expand?but how?
> >         Still puzzled about that.
> >
> >         Wish you can give me more hint to modify and implement the
> >         feature. :-)
> >
> >         I attach a patch.
> >         The Patch is what I have done,It did not contain XMLOFF
> >         module,outline view and vertical mode.
> >         I have implemented that. only have the non-edit mode problem.
> >
> >            > HTH!
> >            >
> >            >> I wish you can help me to solve this problem. Thank you.
> >            >>
> >            >> With Best Regards,
> >            >> LiuTao
> >            >>
> >            >>
> >            >> 2009/12/4 JiaXiang Liu <[hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email] <mailto:[hidden email]>>
> >            >> <mailto:[hidden email]
> >         <mailto:[hidden email]> <mailto:[hidden email]
>  >         <mailto:[hidden email]>>>>
> >
> >            >>
> >            >> Hello Malte,
> >            >>
> >            >> Thank you very much for the information.
> >            >>
> >            >> It is too late today fo me.
> >            >>
> >            >> I will test in Monday morning. if it is not ok, I will also
> >            >> ask Armin for this.
> >            >>
> >            >> Have a nice weekend.
> >            >>
> >            >> With Best Regards,
> >            >>
> >            >> LiuTao
> >            >>
> >            >> 2009/12/4 Malte Timmermann <[hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email]
> >         <mailto:[hidden email]>>
> >            >> <mailto:[hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email]
> >         <mailto:[hidden email]>>>>
> >            >>
> >            >> Hi LiuTao,
> >            >>
> >            >>
> >            >> JiaXiang Liu wrote, On 12/04/09 10:30:
> >            >> > Hello Malte,
> >            >> >
> >            >> > Thank you for your answer.
> >            >> >
> >            >> > What I puzzled now is:
> >            >> >
> >            >> > Why I can not set the new attribute in no edit mode?
> >            >>
> >            >> For redrawing the content, the metrics calculated from the
> >            >> EditEngine
> >            >> are cached somewhere, and the drawing layer uses
> >            >> DrawText() directly,
> >            >> probably also with ALIGN_BASELINE.
> >            >>
> >            >> >
> >            >> > This is the* biggest problem* now and I want to solve
> >            >> it. Can you help
> >            >> > me?you said it may be the drawing layer.but I can not do
> >            >> anything about
> >            >> > that.
> >            >>
> >            >> Armin should know more about this...
> >            >>
> >            >> You might figure out by setting a break point in
> outliner.cxx
> >            >> aDrawPortionHdl.Call(...). Then you will at least be able
> >            >> to see how the
> >            >> information is collected. You need to record the
> >            >> information about the
> >            >> currently used alignment, and also use that information at
> >            >> the place
> >            >> where the drawtext() is done.
> >            >>
> >            >> >
> >            >> > Do you know Are there somebody in OpenOffice team is
> >            >> developing or will
> >            >> > develop this feature?
> >            >>
> >            >> Don't know / think so.
> >            >>
> >            >> Malte.
> >            >>
> >            >>
> >
> >
>  ---------------------------------------------------------------------
> >            >> To unsubscribe, e-mail: [hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email]
> >         <mailto:[hidden email]>>
> >            >> <mailto:[hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email]
> >         <mailto:[hidden email]>>>
> >            >> For additional commands, e-mail:
> >            >> [hidden email]
> >         <mailto:[hidden email]>
> >         <mailto:[hidden email]
> >         <mailto:[hidden email]>>
> >            >> <mailto:[hidden email]
> >         <mailto:[hidden email]>
> >            <mailto:[hidden email]
> >         <mailto:[hidden email]>>>
> >            >>
> >            >>
> >            >>
> >            >>
> >            >
> >
> >         With Best Regards,
> >
> >         LiuTao
> >
> >
> >
> >
> >     --
> >     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
> >     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
> >     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
> >     Vorsitzender des Aufsichtsrates: Martin Häring
> >
> >     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
> >     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what You
> >     can do for ooO!
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann


JiaXiang Liu wrote, On 12/09/09 10:24:

> Hello all,
>
> 2009/12/8 Malte Timmermann <[hidden email]>
>
>> I didn't review the patch, but just took a quick look.
>>
>> FontAlign is probably the wrong wording here at all.
>>
>> What you want to achieve is alignment of a text line.
>> You should probably better call it TextLineAlignment or something like
>> that.
>>
>>
> OK,I will modify it.
>
>> Again - all calculations need to be dome in some upper layer, eg.
>> EditEngine. Assuming that we really talk about text lign alignment,
>> there is no need/reason to add a new enum in VCL.
>>
>
> I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to care
> it. assume it is no use.

If it is of no use, it shouldn't be introduced. No one will accept to
have it in VCL then.

>
>> As I said, do the implementation in impedit3.cxx.
>> Instead of the suggestion in my first email, don't use ALIGN_TOP/BOTTOM
>> at all, but use the font metrics to calculate the correct position so
>> that the normal output with ALIGN_BASELINE works.
>>
>>
> I want to know where(which function?) can I use the font metrics to
> calculate the correct position? and
> how to use the font metrics to calculate?

Look in impedit3.cxx, CreateLines. There you can see how the Ascent and
Descent from the FormatterFontMetric is used.

Since your alignment doesn't influent the line calculation, you don't
need to use the new attr in CreateLines(), but only in Paint().
In Paint, the x/y position is calculated, and the DrawText with
Align_Baseline is used.

> why do not use
> ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
> I think it should be called by some functions.

Because you have to adjust x/y in Paint() anyway.
TOP and BOTTOM could help you to not do ascent/descent calculations
yourself, but for CENTER you have to do it anyway.
If you adjust x/y for all cases (top/bottom/center/baseline) to
BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
automatically. Edit Mode as well as repaint mode.

Malte.

>
> Just like in editmode. in the function implEditEngine::print(...).this
> function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
> but it is in editmode.
> my problem is : I can not set Align in non-edit mode.


>
>
>
>
>> Then all the rest in the drawing layer should work automatically.
>>
>> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one, and
>> insert the new ID at the beginning, you don't have to manipulate the
>> Version Maps, IIRC.
>>
>> The SvxFontAlignItem itself looks strange to me: Its bad design to use 4
>> bool values instead of an enum, if only one value can be true, and
>> exactly one value needs to be true.
>>
>>
> I will improve.
>
>> Malte.
>>
>> JiaXiang Liu wrote, On 12/08/09 12:07:
>>> Hello All,
>>>
>>>
>>>
>>> 2009/12/8 Armin Le Grand <[hidden email]
>>> <mailto:[hidden email]>>
>>>
>>>     JiaXiang Liu schrieb:
>>>
>>>         Hi All,
>>>
>>>         2009/12/7 Malte Timmermann <[hidden email]
>>>         <mailto:[hidden email]>
>>>         <mailto:[hidden email] <mailto:
>> [hidden email]>>>
>>>            Hi LiuTao,
>>>
>>  >            given Armins explanation about the text primitive stuff, it
>>>         seems it
>>>            would be much easier to do the transformation to baseline in
>>>            impedit3.cxx instead of manipulating the font alignment.
>>>
>>>         you mean I can only modify the impedit3.cxx to implement?
>>>
>>>     I do not know impedit3.cxx, but i would do the adaption (as
>>>     described) in impTextBreakupHandler::impCreateTextPortionPrimitive.
>>>     Nonetheless, even for pure VCL usage it is not sure if all usages
>>>     can use the baseline when it is used. It looks like it was not used
>>>     in editengine up to now, but maybe in SW. HDU should know.
>>>
>>>
>>> yes,I have tryed so many times but have no result.I think it is not so
>>> much difficult,just like to set the paragraph adjust left.when we set it
>>> in edit mode it is ok , when in non-edit mode it is still ok.I guess if
>>> there are some message should be transfered.
>>>
>>>
>>>
>>>
>>>            Then it would probably also work out-of-the-box in non-edit
>> mode.
>>>         Still don't know how to do that. :-(
>>>
>>>     As described: You have a StartPosition (rInfo.mrStartPos) that
>>>     defines where to draw the text. You have the TextAlign. If TextAlign
>>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of course)
>>>     as if it is ALIGN_BASELINE. This means to add offsets vertically for
>>>     horizontal text and probably vice-versa. The offsets depend on
>>>     FontInfo information which You get with the VCL Font and an
>>>     OutputDevice.
>>>
>>>
>>> the font align is not a attribute of font.so it is painted in edit mode
>>> in impleditengine::paint(...)
>>> how to draw the alignment is in VCL.(function setalign)
>>> I guess if there have a function called like : noeditview::paint(...) to
>>> call the VCL to draw the alignment?
>>>
>>>
>>> @Herbert
>>>
>>> Hello , Armin said you maybe know this.I wish you can help me....
>>>
>>>
>>>            Malte.
>>>
>>>            Armin Le Grand wrote, On 12/07/09 12:33:
>>>            > JiaXiang Liu schrieb:
>>>            >> Hello Malte,Armin,
>>>            >>
>>>            >> Just Forward the email:
>>>            >>
>>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email] <mailto:[hidden email]>>
>>>            >> <mailto:[hidden email]
>>>         <mailto:[hidden email]> <mailto:[hidden email]
>>>         <mailto:[hidden email]>>>>
>>>
>>>            >>
>>>            >> Hello Malte,Armin
>>>            >>
>>>            >> @Malte
>>>            >>
>>>            >> I test that.It is so difficult.
>>>            >>
>>>            >> I setted a break point in outliner.cxx
>>>            >> aDrawPortionHdl.Call(...).
>>>            >> Then I find the many information is collected but not
>>>         alignment.
>>>            >>
>>>            >> How to record the information about the currently used
>>>         alignment?
>>>            >> If I should add a Parameter in this area ?
>>>            >>
>>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
>> nTextLen,
>>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
>>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
>>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph, bEndOfBullet);
>>>            >>
>>>            >> BTW,
>>>            >> aDrawPortionHdl.Call(...). is called by
>>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle
>>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
>>>            nOrientation )
>>>            >>
>>>            >> and the pOutDev saved the alignment.
>>>            >>
>>>            >> This area is also not save paragraph adjust.I am so
>> puzzled.
>>>            >>
>>>            >>
>>>            >> @Armin
>>>            >>
>>>            >> Malte told me that you maybe know that I want to know. :-)
>>>            >>
>>>            > Maybe; i am responsible for DrawingLayer, not for Text
>> engines;
>>>            i just
>>>            > have to work with TextEngines since no one really is
>>>         responsible for
>>>            > them currently; and Yes, they are somewhat complicated and
>>>         grown
>>>            code.
>>>            > Malte once was responsible for them, thus in relation to
>>>            > EditEngine/Outliner he may know more than me. I can help
>> with
>>>            > DrawingLayer and usage of TextParameters in prmitives,
>> though.
>>>            >>
>>>            >> the question is :
>>>            >> I am developing a new feature called "fontalign" It can
>>>         set the
>>>            >> text align top,center,baseline and bottom.
>>>            >> In Impress,Create a new document, input some words in a
>>>         text box
>>>            >> in normal view.
>>>            >> I can set the alignment successful in edit mode.
>>>            >>
>>>            > Is this already possible in the working/current code?
>>>            > If Yes, where can i change those settings?
>>>            >
>>>            > If no (and it's a completely new feature) it has to be
>>>            implemented not
>>>            > only inside EditEngine/Outliner, evtl. new items there (not
>>>         sure if
>>>            > holding font alignment at the font itself is sufficient in
>> all
>>>            > situations) and in Paint/export/callbacks, but also in text
>>>            primities,
>>>            > their decompositions, exports and paintings.
>>>            > I will set HDU on CC, he may now if holding alignment at the
>>>            font will
>>>            > be enough (if You use that currently).
>>>            >
>>>            >> but it can not store the setting when left the edit mode.
>>>            >> It is OK in outline view,bucause in outline view it is also
>> in
>>>            >> edit mode.
>>>            >>
>>>            > That's right, that new feature has to be represented in
>>>            TextPrimitives
>>>            > and used by renderers for it.
>>>            >
>>>            > In short: DrawPortionInfo is the class which
>>>         EditEngine/Outliner
>>>            uses in
>>>            > callback mode to export it's data (You already located
>>>         that). The
>>>            > FontAlignment info will be (i guess) at the
>>>         DrawPortionInfo::mrFont
>>>            > member which is also a 'Font' (the VCL class).
>>>            >
>>>
>>>         yes,it can use the 'Font'(VCL class) member function like:
>>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
>>>
>>>            > Primitives do not use a Font class (they are designed to be
>>>            transported
>>>            > over an API later), so they use
>>>            > drawinglayer::primitive2d::FontAttributes where the font is
>>>            described
>>>            > using FamilyName/StyleName/Weight and others. There is no
>>>         alignment
>>>            > currently since it was not used yet. FontAttributes is then
>>>         used in
>>>            > TextSimplePortionPrimitive2D. At render time, the helper
>>>            > getVclFontFromFontAttributes is used to re-create a VCL Font
>>>            from the
>>>            > FontAttributes, but this is only ONE way to use/render text
>>>         in the
>>>            > future with primitives; to use VCL again. This will
>>>         probably change.
>>>            >
>>>            > The point is that currently, font alignment is not part of
>>>            > FontAttributes and is not transported. As can be seen in
>>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is assumed. I
>>>         would
>>>            not add
>>>            > a font alignment to FontAttributes to keep it minimal (and
>>>         it is not
>>>            > necessary). The TextSimplePortionPrimitive2D (and it's
>>>            derivates) are
>>>            > low-level text portion holders and also have a implicit
>>>         TextPosition
>>>            > (part of the TextTransform), thus it would be best to adapt
>> the
>>>            implicit
>>>            > TextStart position inside
>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive to
>>>         always use
>>>            > ALIGN_BASELINE.
>>>            >
>>>            > This is always possible using the FontInfo class and the
>>>         offsets
>>>            of the
>>>            > font (bbaseline, height, etc...). This can be done in
>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive, see
>>>         'apply
>>>            local
>>>            > offset'. rInfo.mrStartPos.Y() would need to be
>>>         expanded/adapted when
>>>            > text alignment is != ALIGN_BASELINE.
>>>            >
>>>
>>>         If that means I would modify something in this area and do some
>>>         expand?but how?
>>>         Still puzzled about that.
>>>
>>>         Wish you can give me more hint to modify and implement the
>>>         feature. :-)
>>>
>>>         I attach a patch.
>>>         The Patch is what I have done,It did not contain XMLOFF
>>>         module,outline view and vertical mode.
>>>         I have implemented that. only have the non-edit mode problem.
>>>
>>>            > HTH!
>>>            >
>>>            >> I wish you can help me to solve this problem. Thank you.
>>>            >>
>>>            >> With Best Regards,
>>>            >> LiuTao
>>>            >>
>>>            >>
>>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email] <mailto:[hidden email]>>
>>>            >> <mailto:[hidden email]
>>>         <mailto:[hidden email]> <mailto:[hidden email]
>>  >         <mailto:[hidden email]>>>>
>>>            >>
>>>            >> Hello Malte,
>>>            >>
>>>            >> Thank you very much for the information.
>>>            >>
>>>            >> It is too late today fo me.
>>>            >>
>>>            >> I will test in Monday morning. if it is not ok, I will also
>>>            >> ask Armin for this.
>>>            >>
>>>            >> Have a nice weekend.
>>>            >>
>>>            >> With Best Regards,
>>>            >>
>>>            >> LiuTao
>>>            >>
>>>            >> 2009/12/4 Malte Timmermann <[hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email]
>>>         <mailto:[hidden email]>>
>>>            >> <mailto:[hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email]
>>>         <mailto:[hidden email]>>>>
>>>            >>
>>>            >> Hi LiuTao,
>>>            >>
>>>            >>
>>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
>>>            >> > Hello Malte,
>>>            >> >
>>>            >> > Thank you for your answer.
>>>            >> >
>>>            >> > What I puzzled now is:
>>>            >> >
>>>            >> > Why I can not set the new attribute in no edit mode?
>>>            >>
>>>            >> For redrawing the content, the metrics calculated from the
>>>            >> EditEngine
>>>            >> are cached somewhere, and the drawing layer uses
>>>            >> DrawText() directly,
>>>            >> probably also with ALIGN_BASELINE.
>>>            >>
>>>            >> >
>>>            >> > This is the* biggest problem* now and I want to solve
>>>            >> it. Can you help
>>>            >> > me?you said it may be the drawing layer.but I can not do
>>>            >> anything about
>>>            >> > that.
>>>            >>
>>>            >> Armin should know more about this...
>>>            >>
>>>            >> You might figure out by setting a break point in
>> outliner.cxx
>>>            >> aDrawPortionHdl.Call(...). Then you will at least be able
>>>            >> to see how the
>>>            >> information is collected. You need to record the
>>>            >> information about the
>>>            >> currently used alignment, and also use that information at
>>>            >> the place
>>>            >> where the drawtext() is done.
>>>            >>
>>>            >> >
>>>            >> > Do you know Are there somebody in OpenOffice team is
>>>            >> developing or will
>>>            >> > develop this feature?
>>>            >>
>>>            >> Don't know / think so.
>>>            >>
>>>            >> Malte.
>>>            >>
>>>            >>
>>>
>>>
>>  ---------------------------------------------------------------------
>>>            >> To unsubscribe, e-mail: [hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email]
>>>         <mailto:[hidden email]>>
>>>            >> <mailto:[hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email]
>>>         <mailto:[hidden email]>>>
>>>            >> For additional commands, e-mail:
>>>            >> [hidden email]
>>>         <mailto:[hidden email]>
>>>         <mailto:[hidden email]
>>>         <mailto:[hidden email]>>
>>>            >> <mailto:[hidden email]
>>>         <mailto:[hidden email]>
>>>            <mailto:[hidden email]
>>>         <mailto:[hidden email]>>>
>>>            >>
>>>            >>
>>>            >>
>>>            >>
>>>            >
>>>
>>>         With Best Regards,
>>>
>>>         LiuTao
>>>
>>>
>>>
>>>
>>>     --
>>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
>>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
>>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
>>>     Vorsitzender des Aufsichtsrates: Martin Häring
>>>
>>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
>>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what You
>>>     can do for ooO!
>>>
>>>
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hi all

2009/12/9 Malte Timmermann <[hidden email]>

>
>
> JiaXiang Liu wrote, On 12/09/09 10:24:
> > Hello all,
> >
> > 2009/12/8 Malte Timmermann <[hidden email]>
> >
> >> I didn't review the patch, but just took a quick look.
> >>
> >> FontAlign is probably the wrong wording here at all.
> >>
> >> What you want to achieve is alignment of a text line.
> >> You should probably better call it TextLineAlignment or something like
> >> that.
> >>
> >>
> > OK,I will modify it.
> >
> >> Again - all calculations need to be dome in some upper layer, eg.
> >> EditEngine. Assuming that we really talk about text lign alignment,
> >> there is no need/reason to add a new enum in VCL.
> >>
> >
> > I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to care
> > it. assume it is no use.
>
> If it is of no use, it shouldn't be introduced. No one will accept to
> have it in VCL then.
>
> >
> >> As I said, do the implementation in impedit3.cxx.
> >> Instead of the suggestion in my first email, don't use ALIGN_TOP/BOTTOM
> >> at all, but use the font metrics to calculate the correct position so
> >> that the normal output with ALIGN_BASELINE works.
> >>
> >>
> > I want to know where(which function?) can I use the font metrics to
> > calculate the correct position? and
> > how to use the font metrics to calculate?
>
> Look in impedit3.cxx, CreateLines. There you can see how the Ascent and
> Descent from the FormatterFontMetric is used.
>
> Since your alignment doesn't influent the line calculation, you don't
> need to use the new attr in CreateLines(), but only in Paint().
> In Paint, the x/y position is calculated, and the DrawText with
> Align_Baseline is used.
>
> > why do not use
> > ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
> > I think it should be called by some functions.
>
> Because you have to adjust x/y in Paint() anyway.
> TOP and BOTTOM could help you to not do ascent/descent calculations
> yourself, but for CENTER you have to do it anyway.
> If you adjust x/y for all cases (top/bottom/center/baseline) to
> BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
> automatically. Edit Mode as well as repaint mode.
>
>

what your mean about adjust x/y for all cases (top/bottom/center/baseline)
to
BASELINE?

do you mean that I should add some code in paint(...) function like this:

     TextAlign eAlign = aTmpFont.GetAlign();
     if ( eAlign == ALIGN_TOP )
     {
      aRealOutPos.Y() =......
      aRealOutPos.X() =....
     }
     if ( eAlign == ALIGN_BOTTOM )
     {
      aRealOutPos.Y() =......
      aRealOutPos.X() =....
     }
     if ( eAlign == ALIGN_BASELINE )
     {
      aRealOutPos.Y() =......
      aRealOutPos.X() =....
     }

but I think this is still works in edit mode.but not in non-edit mode.

so puzzled.I am afraid I will crash. ;-)

> Malte.
>
> >
> > Just like in editmode. in the function implEditEngine::print(...).this
> > function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
> > but it is in editmode.
> > my problem is : I can not set Align in non-edit mode.
>
>
> >
> >
> >
> >
> >> Then all the rest in the drawing layer should work automatically.
> >>
> >> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one, and
> >> insert the new ID at the beginning, you don't have to manipulate the
> >> Version Maps, IIRC.
> >>
> >> The SvxFontAlignItem itself looks strange to me: Its bad design to use 4
> >> bool values instead of an enum, if only one value can be true, and
> >> exactly one value needs to be true.
> >>
> >>
> > I will improve.
> >
> >> Malte.
> >>
> >> JiaXiang Liu wrote, On 12/08/09 12:07:
> >>> Hello All,
> >>>
> >>>
> >>>
> >>> 2009/12/8 Armin Le Grand <[hidden email]
> >>> <mailto:[hidden email]>>
> >>>
> >>>     JiaXiang Liu schrieb:
> >>>
> >>>         Hi All,
> >>>
> >>>         2009/12/7 Malte Timmermann <[hidden email]
> >>>         <mailto:[hidden email]>
> >>>         <mailto:[hidden email] <mailto:
> >> [hidden email]>>>
> >>>            Hi LiuTao,
> >>>
> >>  >            given Armins explanation about the text primitive stuff,
> it
> >>>         seems it
> >>>            would be much easier to do the transformation to baseline in
> >>>            impedit3.cxx instead of manipulating the font alignment.
> >>>
> >>>         you mean I can only modify the impedit3.cxx to implement?
> >>>
> >>>     I do not know impedit3.cxx, but i would do the adaption (as
> >>>     described) in impTextBreakupHandler::impCreateTextPortionPrimitive.
> >>>     Nonetheless, even for pure VCL usage it is not sure if all usages
> >>>     can use the baseline when it is used. It looks like it was not used
> >>>     in editengine up to now, but maybe in SW. HDU should know.
> >>>
> >>>
> >>> yes,I have tryed so many times but have no result.I think it is not so
> >>> much difficult,just like to set the paragraph adjust left.when we set
> it
> >>> in edit mode it is ok , when in non-edit mode it is still ok.I guess if
> >>> there are some message should be transfered.
> >>>
> >>>
> >>>
> >>>
> >>>            Then it would probably also work out-of-the-box in non-edit
> >> mode.
> >>>         Still don't know how to do that. :-(
> >>>
> >>>     As described: You have a StartPosition (rInfo.mrStartPos) that
> >>>     defines where to draw the text. You have the TextAlign. If
> TextAlign
> >>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of
> course)
> >>>     as if it is ALIGN_BASELINE. This means to add offsets vertically
> for
> >>>     horizontal text and probably vice-versa. The offsets depend on
> >>>     FontInfo information which You get with the VCL Font and an
> >>>     OutputDevice.
> >>>
> >>>
> >>> the font align is not a attribute of font.so it is painted in edit mode
> >>> in impleditengine::paint(...)
> >>> how to draw the alignment is in VCL.(function setalign)
> >>> I guess if there have a function called like : noeditview::paint(...)
> to
> >>> call the VCL to draw the alignment?
> >>>
> >>>
> >>> @Herbert
> >>>
> >>> Hello , Armin said you maybe know this.I wish you can help me....
> >>>
> >>>
> >>>            Malte.
> >>>
> >>>            Armin Le Grand wrote, On 12/07/09 12:33:
> >>>            > JiaXiang Liu schrieb:
> >>>            >> Hello Malte,Armin,
> >>>            >>
> >>>            >> Just Forward the email:
> >>>            >>
> >>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email] <mailto:[hidden email]
> >>
> >>>            >> <mailto:[hidden email]
> >>>         <mailto:[hidden email]> <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>>>
> >>>
> >>>            >>
> >>>            >> Hello Malte,Armin
> >>>            >>
> >>>            >> @Malte
> >>>            >>
> >>>            >> I test that.It is so difficult.
> >>>            >>
> >>>            >> I setted a break point in outliner.cxx
> >>>            >> aDrawPortionHdl.Call(...).
> >>>            >> Then I find the many information is collected but not
> >>>         alignment.
> >>>            >>
> >>>            >> How to record the information about the currently used
> >>>         alignment?
> >>>            >> If I should add a Parameter in this area ?
> >>>            >>
> >>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
> >> nTextLen,
> >>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
> >>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
> >>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph, bEndOfBullet);
> >>>            >>
> >>>            >> BTW,
> >>>            >> aDrawPortionHdl.Call(...). is called by
> >>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev,
> Rectangle
> >>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
> >>>            nOrientation )
> >>>            >>
> >>>            >> and the pOutDev saved the alignment.
> >>>            >>
> >>>            >> This area is also not save paragraph adjust.I am so
> >> puzzled.
> >>>            >>
> >>>            >>
> >>>            >> @Armin
> >>>            >>
> >>>            >> Malte told me that you maybe know that I want to know.
> :-)
> >>>            >>
> >>>            > Maybe; i am responsible for DrawingLayer, not for Text
> >> engines;
> >>>            i just
> >>>            > have to work with TextEngines since no one really is
> >>>         responsible for
> >>>            > them currently; and Yes, they are somewhat complicated and
> >>>         grown
> >>>            code.
> >>>            > Malte once was responsible for them, thus in relation to
> >>>            > EditEngine/Outliner he may know more than me. I can help
> >> with
> >>>            > DrawingLayer and usage of TextParameters in prmitives,
> >> though.
> >>>            >>
> >>>            >> the question is :
> >>>            >> I am developing a new feature called "fontalign" It can
> >>>         set the
> >>>            >> text align top,center,baseline and bottom.
> >>>            >> In Impress,Create a new document, input some words in a
> >>>         text box
> >>>            >> in normal view.
> >>>            >> I can set the alignment successful in edit mode.
> >>>            >>
> >>>            > Is this already possible in the working/current code?
> >>>            > If Yes, where can i change those settings?
> >>>            >
> >>>            > If no (and it's a completely new feature) it has to be
> >>>            implemented not
> >>>            > only inside EditEngine/Outliner, evtl. new items there
> (not
> >>>         sure if
> >>>            > holding font alignment at the font itself is sufficient in
> >> all
> >>>            > situations) and in Paint/export/callbacks, but also in
> text
> >>>            primities,
> >>>            > their decompositions, exports and paintings.
> >>>            > I will set HDU on CC, he may now if holding alignment at
> the
> >>>            font will
> >>>            > be enough (if You use that currently).
> >>>            >
> >>>            >> but it can not store the setting when left the edit mode.
> >>>            >> It is OK in outline view,bucause in outline view it is
> also
> >> in
> >>>            >> edit mode.
> >>>            >>
> >>>            > That's right, that new feature has to be represented in
> >>>            TextPrimitives
> >>>            > and used by renderers for it.
> >>>            >
> >>>            > In short: DrawPortionInfo is the class which
> >>>         EditEngine/Outliner
> >>>            uses in
> >>>            > callback mode to export it's data (You already located
> >>>         that). The
> >>>            > FontAlignment info will be (i guess) at the
> >>>         DrawPortionInfo::mrFont
> >>>            > member which is also a 'Font' (the VCL class).
> >>>            >
> >>>
> >>>         yes,it can use the 'Font'(VCL class) member function like:
> >>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
> >>>
> >>>            > Primitives do not use a Font class (they are designed to
> be
> >>>            transported
> >>>            > over an API later), so they use
> >>>            > drawinglayer::primitive2d::FontAttributes where the font
> is
> >>>            described
> >>>            > using FamilyName/StyleName/Weight and others. There is no
> >>>         alignment
> >>>            > currently since it was not used yet. FontAttributes is
> then
> >>>         used in
> >>>            > TextSimplePortionPrimitive2D. At render time, the helper
> >>>            > getVclFontFromFontAttributes is used to re-create a VCL
> Font
> >>>            from the
> >>>            > FontAttributes, but this is only ONE way to use/render
> text
> >>>         in the
> >>>            > future with primitives; to use VCL again. This will
> >>>         probably change.
> >>>            >
> >>>            > The point is that currently, font alignment is not part of
> >>>            > FontAttributes and is not transported. As can be seen in
> >>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is assumed. I
> >>>         would
> >>>            not add
> >>>            > a font alignment to FontAttributes to keep it minimal (and
> >>>         it is not
> >>>            > necessary). The TextSimplePortionPrimitive2D (and it's
> >>>            derivates) are
> >>>            > low-level text portion holders and also have a implicit
> >>>         TextPosition
> >>>            > (part of the TextTransform), thus it would be best to
> adapt
> >> the
> >>>            implicit
> >>>            > TextStart position inside
> >>>            > impTextBreakupHandler::impCreateTextPortionPrimitive to
> >>>         always use
> >>>            > ALIGN_BASELINE.
> >>>            >
> >>>            > This is always possible using the FontInfo class and the
> >>>         offsets
> >>>            of the
> >>>            > font (bbaseline, height, etc...). This can be done in
> >>>            > impTextBreakupHandler::impCreateTextPortionPrimitive, see
> >>>         'apply
> >>>            local
> >>>            > offset'. rInfo.mrStartPos.Y() would need to be
> >>>         expanded/adapted when
> >>>            > text alignment is != ALIGN_BASELINE.
> >>>            >
> >>>
> >>>         If that means I would modify something in this area and do some
> >>>         expand?but how?
> >>>         Still puzzled about that.
> >>>
> >>>         Wish you can give me more hint to modify and implement the
> >>>         feature. :-)
> >>>
> >>>         I attach a patch.
> >>>         The Patch is what I have done,It did not contain XMLOFF
> >>>         module,outline view and vertical mode.
> >>>         I have implemented that. only have the non-edit mode problem.
> >>>
> >>>            > HTH!
> >>>            >
> >>>            >> I wish you can help me to solve this problem. Thank you.
> >>>            >>
> >>>            >> With Best Regards,
> >>>            >> LiuTao
> >>>            >>
> >>>            >>
> >>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email] <mailto:[hidden email]
> >>
> >>>            >> <mailto:[hidden email]
> >>>         <mailto:[hidden email]> <mailto:[hidden email]
> >>  >         <mailto:[hidden email]>>>>
> >>>            >>
> >>>            >> Hello Malte,
> >>>            >>
> >>>            >> Thank you very much for the information.
> >>>            >>
> >>>            >> It is too late today fo me.
> >>>            >>
> >>>            >> I will test in Monday morning. if it is not ok, I will
> also
> >>>            >> ask Armin for this.
> >>>            >>
> >>>            >> Have a nice weekend.
> >>>            >>
> >>>            >> With Best Regards,
> >>>            >>
> >>>            >> LiuTao
> >>>            >>
> >>>            >> 2009/12/4 Malte Timmermann <[hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>
> >>>            >> <mailto:[hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>>>
> >>>            >>
> >>>            >> Hi LiuTao,
> >>>            >>
> >>>            >>
> >>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
> >>>            >> > Hello Malte,
> >>>            >> >
> >>>            >> > Thank you for your answer.
> >>>            >> >
> >>>            >> > What I puzzled now is:
> >>>            >> >
> >>>            >> > Why I can not set the new attribute in no edit mode?
> >>>            >>
> >>>            >> For redrawing the content, the metrics calculated from
> the
> >>>            >> EditEngine
> >>>            >> are cached somewhere, and the drawing layer uses
> >>>            >> DrawText() directly,
> >>>            >> probably also with ALIGN_BASELINE.
> >>>            >>
> >>>            >> >
> >>>            >> > This is the* biggest problem* now and I want to solve
> >>>            >> it. Can you help
> >>>            >> > me?you said it may be the drawing layer.but I can not
> do
> >>>            >> anything about
> >>>            >> > that.
> >>>            >>
> >>>            >> Armin should know more about this...
> >>>            >>
> >>>            >> You might figure out by setting a break point in
> >> outliner.cxx
> >>>            >> aDrawPortionHdl.Call(...). Then you will at least be able
> >>>            >> to see how the
> >>>            >> information is collected. You need to record the
> >>>            >> information about the
> >>>            >> currently used alignment, and also use that information
> at
> >>>            >> the place
> >>>            >> where the drawtext() is done.
> >>>            >>
> >>>            >> >
> >>>            >> > Do you know Are there somebody in OpenOffice team is
> >>>            >> developing or will
> >>>            >> > develop this feature?
> >>>            >>
> >>>            >> Don't know / think so.
> >>>            >>
> >>>            >> Malte.
> >>>            >>
> >>>            >>
> >>>
> >>>
> >>  ---------------------------------------------------------------------
> >>>            >> To unsubscribe, e-mail:
> [hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>
> >>>            >> <mailto:[hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>>
> >>>            >> For additional commands, e-mail:
> >>>            >> [hidden email]
> >>>         <mailto:[hidden email]>
> >>>         <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>
> >>>            >> <mailto:[hidden email]
> >>>         <mailto:[hidden email]>
> >>>            <mailto:[hidden email]
> >>>         <mailto:[hidden email]>>>
> >>>            >>
> >>>            >>
> >>>            >>
> >>>            >>
> >>>            >
> >>>
> >>>         With Best Regards,
> >>>
> >>>         LiuTao
> >>>
> >>>
> >>>
> >>>
> >>>     --
> >>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
> >>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
> >>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
> >>>     Vorsitzender des Aufsichtsrates: Martin Häring
> >>>
> >>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
> >>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what You
> >>>     can do for ooO!
> >>>
> >>>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
>  For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann


JiaXiang Liu wrote, On 12/09/09 12:10:

> Hi all
>
> 2009/12/9 Malte Timmermann <[hidden email]>
>
>>
>> JiaXiang Liu wrote, On 12/09/09 10:24:
>>> Hello all,
>>>
>>> 2009/12/8 Malte Timmermann <[hidden email]>
>>>
>>>> I didn't review the patch, but just took a quick look.
>>>>
>>>> FontAlign is probably the wrong wording here at all.
>>>>
>>>> What you want to achieve is alignment of a text line.
>>>> You should probably better call it TextLineAlignment or something like
>>>> that.
>>>>
>>>>
>>> OK,I will modify it.
>>>
>>>> Again - all calculations need to be dome in some upper layer, eg.
>>>> EditEngine. Assuming that we really talk about text lign alignment,
>>>> there is no need/reason to add a new enum in VCL.
>>>>
>>> I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to care
>>> it. assume it is no use.
>> If it is of no use, it shouldn't be introduced. No one will accept to
>> have it in VCL then.
>>
>>>> As I said, do the implementation in impedit3.cxx.
>>>> Instead of the suggestion in my first email, don't use ALIGN_TOP/BOTTOM
>>>> at all, but use the font metrics to calculate the correct position so
>>>> that the normal output with ALIGN_BASELINE works.
>>>>
>>>>
>>> I want to know where(which function?) can I use the font metrics to
>>> calculate the correct position? and
>>> how to use the font metrics to calculate?
>> Look in impedit3.cxx, CreateLines. There you can see how the Ascent and
>> Descent from the FormatterFontMetric is used.
>>
>> Since your alignment doesn't influent the line calculation, you don't
>> need to use the new attr in CreateLines(), but only in Paint().
>> In Paint, the x/y position is calculated, and the DrawText with
>> Align_Baseline is used.
>>
>>> why do not use
>>> ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
>>> I think it should be called by some functions.
>> Because you have to adjust x/y in Paint() anyway.
>> TOP and BOTTOM could help you to not do ascent/descent calculations
>> yourself, but for CENTER you have to do it anyway.
>> If you adjust x/y for all cases (top/bottom/center/baseline) to
>> BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
>> automatically. Edit Mode as well as repaint mode.
>>
>>
>
> what your mean about adjust x/y for all cases (top/bottom/center/baseline)
> to
> BASELINE?
>
> do you mean that I should add some code in paint(...) function like this:
>
>      TextAlign eAlign = aTmpFont.GetAlign();
>      if ( eAlign == ALIGN_TOP )
>      {
>       aRealOutPos.Y() =......
>       aRealOutPos.X() =....
>      }
>      if ( eAlign == ALIGN_BOTTOM )
>      {
>       aRealOutPos.Y() =......
>       aRealOutPos.X() =....
>      }
>      if ( eAlign == ALIGN_BASELINE )
>      {
>       aRealOutPos.Y() =......
>       aRealOutPos.X() =....
>      }
>

First - use the current para attr, not GetAlign from the Font, because
you shouldn't manipulate the alignment from the font anymore.

Then look at the loop for ( nLine < nLines ), first switch statement
covering text/field/hypenator. There you can manipulate y (or x in
vertical writing mode). aTmpPos, not aRealOutPos.

Malte.

> but I think this is still works in edit mode.but not in non-edit mode.
>
> so puzzled.I am afraid I will crash. ;-)
>
>> Malte.
>>
>>> Just like in editmode. in the function implEditEngine::print(...).this
>>> function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
>>> but it is in editmode.
>>> my problem is : I can not set Align in non-edit mode.
>>
>>>
>>>
>>>
>>>> Then all the rest in the drawing layer should work automatically.
>>>>
>>>> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one, and
>>>> insert the new ID at the beginning, you don't have to manipulate the
>>>> Version Maps, IIRC.
>>>>
>>>> The SvxFontAlignItem itself looks strange to me: Its bad design to use 4
>>>> bool values instead of an enum, if only one value can be true, and
>>>> exactly one value needs to be true.
>>>>
>>>>
>>> I will improve.
>>>
>>>> Malte.
>>>>
>>>> JiaXiang Liu wrote, On 12/08/09 12:07:
>>>>> Hello All,
>>>>>
>>>>>
>>>>>
>>>>> 2009/12/8 Armin Le Grand <[hidden email]
>>>>> <mailto:[hidden email]>>
>>>>>
>>>>>     JiaXiang Liu schrieb:
>>>>>
>>>>>         Hi All,
>>>>>
>>>>>         2009/12/7 Malte Timmermann <[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>         <mailto:[hidden email] <mailto:
>>>> [hidden email]>>>
>>>>>            Hi LiuTao,
>>>>>
>>>>  >            given Armins explanation about the text primitive stuff,
>> it
>>>>>         seems it
>>>>>            would be much easier to do the transformation to baseline in
>>>>>            impedit3.cxx instead of manipulating the font alignment.
>>>>>
>>>>>         you mean I can only modify the impedit3.cxx to implement?
>>>>>
>>>>>     I do not know impedit3.cxx, but i would do the adaption (as
>>>>>     described) in impTextBreakupHandler::impCreateTextPortionPrimitive.
>>>>>     Nonetheless, even for pure VCL usage it is not sure if all usages
>>>>>     can use the baseline when it is used. It looks like it was not used
>>>>>     in editengine up to now, but maybe in SW. HDU should know.
>>>>>
>>>>>
>>>>> yes,I have tryed so many times but have no result.I think it is not so
>>>>> much difficult,just like to set the paragraph adjust left.when we set
>> it
>>>>> in edit mode it is ok , when in non-edit mode it is still ok.I guess if
>>>>> there are some message should be transfered.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            Then it would probably also work out-of-the-box in non-edit
>>>> mode.
>>>>>         Still don't know how to do that. :-(
>>>>>
>>>>>     As described: You have a StartPosition (rInfo.mrStartPos) that
>>>>>     defines where to draw the text. You have the TextAlign. If
>> TextAlign
>>>>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of
>> course)
>>>>>     as if it is ALIGN_BASELINE. This means to add offsets vertically
>> for
>>>>>     horizontal text and probably vice-versa. The offsets depend on
>>>>>     FontInfo information which You get with the VCL Font and an
>>>>>     OutputDevice.
>>>>>
>>>>>
>>>>> the font align is not a attribute of font.so it is painted in edit mode
>>>>> in impleditengine::paint(...)
>>>>> how to draw the alignment is in VCL.(function setalign)
>>>>> I guess if there have a function called like : noeditview::paint(...)
>> to
>>>>> call the VCL to draw the alignment?
>>>>>
>>>>>
>>>>> @Herbert
>>>>>
>>>>> Hello , Armin said you maybe know this.I wish you can help me....
>>>>>
>>>>>
>>>>>            Malte.
>>>>>
>>>>>            Armin Le Grand wrote, On 12/07/09 12:33:
>>>>>            > JiaXiang Liu schrieb:
>>>>>            >> Hello Malte,Armin,
>>>>>            >>
>>>>>            >> Just Forward the email:
>>>>>            >>
>>>>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email] <mailto:[hidden email]
>>>>>            >> <mailto:[hidden email]
>>>>>         <mailto:[hidden email]> <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>>>
>>>>>
>>>>>            >>
>>>>>            >> Hello Malte,Armin
>>>>>            >>
>>>>>            >> @Malte
>>>>>            >>
>>>>>            >> I test that.It is so difficult.
>>>>>            >>
>>>>>            >> I setted a break point in outliner.cxx
>>>>>            >> aDrawPortionHdl.Call(...).
>>>>>            >> Then I find the many information is collected but not
>>>>>         alignment.
>>>>>            >>
>>>>>            >> How to record the information about the currently used
>>>>>         alignment?
>>>>>            >> If I should add a Parameter in this area ?
>>>>>            >>
>>>>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
>>>> nTextLen,
>>>>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
>>>>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
>>>>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph, bEndOfBullet);
>>>>>            >>
>>>>>            >> BTW,
>>>>>            >> aDrawPortionHdl.Call(...). is called by
>>>>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev,
>> Rectangle
>>>>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
>>>>>            nOrientation )
>>>>>            >>
>>>>>            >> and the pOutDev saved the alignment.
>>>>>            >>
>>>>>            >> This area is also not save paragraph adjust.I am so
>>>> puzzled.
>>>>>            >>
>>>>>            >>
>>>>>            >> @Armin
>>>>>            >>
>>>>>            >> Malte told me that you maybe know that I want to know.
>> :-)
>>>>>            >>
>>>>>            > Maybe; i am responsible for DrawingLayer, not for Text
>>>> engines;
>>>>>            i just
>>>>>            > have to work with TextEngines since no one really is
>>>>>         responsible for
>>>>>            > them currently; and Yes, they are somewhat complicated and
>>>>>         grown
>>>>>            code.
>>>>>            > Malte once was responsible for them, thus in relation to
>>>>>            > EditEngine/Outliner he may know more than me. I can help
>>>> with
>>>>>            > DrawingLayer and usage of TextParameters in prmitives,
>>>> though.
>>>>>            >>
>>>>>            >> the question is :
>>>>>            >> I am developing a new feature called "fontalign" It can
>>>>>         set the
>>>>>            >> text align top,center,baseline and bottom.
>>>>>            >> In Impress,Create a new document, input some words in a
>>>>>         text box
>>>>>            >> in normal view.
>>>>>            >> I can set the alignment successful in edit mode.
>>>>>            >>
>>>>>            > Is this already possible in the working/current code?
>>>>>            > If Yes, where can i change those settings?
>>>>>            >
>>>>>            > If no (and it's a completely new feature) it has to be
>>>>>            implemented not
>>>>>            > only inside EditEngine/Outliner, evtl. new items there
>> (not
>>>>>         sure if
>>>>>            > holding font alignment at the font itself is sufficient in
>>>> all
>>>>>            > situations) and in Paint/export/callbacks, but also in
>> text
>>>>>            primities,
>>>>>            > their decompositions, exports and paintings.
>>>>>            > I will set HDU on CC, he may now if holding alignment at
>> the
>>>>>            font will
>>>>>            > be enough (if You use that currently).
>>>>>            >
>>>>>            >> but it can not store the setting when left the edit mode.
>>>>>            >> It is OK in outline view,bucause in outline view it is
>> also
>>>> in
>>>>>            >> edit mode.
>>>>>            >>
>>>>>            > That's right, that new feature has to be represented in
>>>>>            TextPrimitives
>>>>>            > and used by renderers for it.
>>>>>            >
>>>>>            > In short: DrawPortionInfo is the class which
>>>>>         EditEngine/Outliner
>>>>>            uses in
>>>>>            > callback mode to export it's data (You already located
>>>>>         that). The
>>>>>            > FontAlignment info will be (i guess) at the
>>>>>         DrawPortionInfo::mrFont
>>>>>            > member which is also a 'Font' (the VCL class).
>>>>>            >
>>>>>
>>>>>         yes,it can use the 'Font'(VCL class) member function like:
>>>>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
>>>>>
>>>>>            > Primitives do not use a Font class (they are designed to
>> be
>>>>>            transported
>>>>>            > over an API later), so they use
>>>>>            > drawinglayer::primitive2d::FontAttributes where the font
>> is
>>>>>            described
>>>>>            > using FamilyName/StyleName/Weight and others. There is no
>>>>>         alignment
>>>>>            > currently since it was not used yet. FontAttributes is
>> then
>>>>>         used in
>>>>>            > TextSimplePortionPrimitive2D. At render time, the helper
>>>>>            > getVclFontFromFontAttributes is used to re-create a VCL
>> Font
>>>>>            from the
>>>>>            > FontAttributes, but this is only ONE way to use/render
>> text
>>>>>         in the
>>>>>            > future with primitives; to use VCL again. This will
>>>>>         probably change.
>>>>>            >
>>>>>            > The point is that currently, font alignment is not part of
>>>>>            > FontAttributes and is not transported. As can be seen in
>>>>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is assumed. I
>>>>>         would
>>>>>            not add
>>>>>            > a font alignment to FontAttributes to keep it minimal (and
>>>>>         it is not
>>>>>            > necessary). The TextSimplePortionPrimitive2D (and it's
>>>>>            derivates) are
>>>>>            > low-level text portion holders and also have a implicit
>>>>>         TextPosition
>>>>>            > (part of the TextTransform), thus it would be best to
>> adapt
>>>> the
>>>>>            implicit
>>>>>            > TextStart position inside
>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive to
>>>>>         always use
>>>>>            > ALIGN_BASELINE.
>>>>>            >
>>>>>            > This is always possible using the FontInfo class and the
>>>>>         offsets
>>>>>            of the
>>>>>            > font (bbaseline, height, etc...). This can be done in
>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive, see
>>>>>         'apply
>>>>>            local
>>>>>            > offset'. rInfo.mrStartPos.Y() would need to be
>>>>>         expanded/adapted when
>>>>>            > text alignment is != ALIGN_BASELINE.
>>>>>            >
>>>>>
>>>>>         If that means I would modify something in this area and do some
>>>>>         expand?but how?
>>>>>         Still puzzled about that.
>>>>>
>>>>>         Wish you can give me more hint to modify and implement the
>>>>>         feature. :-)
>>>>>
>>>>>         I attach a patch.
>>>>>         The Patch is what I have done,It did not contain XMLOFF
>>>>>         module,outline view and vertical mode.
>>>>>         I have implemented that. only have the non-edit mode problem.
>>>>>
>>>>>            > HTH!
>>>>>            >
>>>>>            >> I wish you can help me to solve this problem. Thank you.
>>>>>            >>
>>>>>            >> With Best Regards,
>>>>>            >> LiuTao
>>>>>            >>
>>>>>            >>
>>>>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email] <mailto:[hidden email]
>>>>>            >> <mailto:[hidden email]
>>>>>         <mailto:[hidden email]> <mailto:[hidden email]
>>>>  >         <mailto:[hidden email]>>>>
>>>>>            >>
>>>>>            >> Hello Malte,
>>>>>            >>
>>>>>            >> Thank you very much for the information.
>>>>>            >>
>>>>>            >> It is too late today fo me.
>>>>>            >>
>>>>>            >> I will test in Monday morning. if it is not ok, I will
>> also
>>>>>            >> ask Armin for this.
>>>>>            >>
>>>>>            >> Have a nice weekend.
>>>>>            >>
>>>>>            >> With Best Regards,
>>>>>            >>
>>>>>            >> LiuTao
>>>>>            >>
>>>>>            >> 2009/12/4 Malte Timmermann <[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>
>>>>>            >> <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>>>
>>>>>            >>
>>>>>            >> Hi LiuTao,
>>>>>            >>
>>>>>            >>
>>>>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
>>>>>            >> > Hello Malte,
>>>>>            >> >
>>>>>            >> > Thank you for your answer.
>>>>>            >> >
>>>>>            >> > What I puzzled now is:
>>>>>            >> >
>>>>>            >> > Why I can not set the new attribute in no edit mode?
>>>>>            >>
>>>>>            >> For redrawing the content, the metrics calculated from
>> the
>>>>>            >> EditEngine
>>>>>            >> are cached somewhere, and the drawing layer uses
>>>>>            >> DrawText() directly,
>>>>>            >> probably also with ALIGN_BASELINE.
>>>>>            >>
>>>>>            >> >
>>>>>            >> > This is the* biggest problem* now and I want to solve
>>>>>            >> it. Can you help
>>>>>            >> > me?you said it may be the drawing layer.but I can not
>> do
>>>>>            >> anything about
>>>>>            >> > that.
>>>>>            >>
>>>>>            >> Armin should know more about this...
>>>>>            >>
>>>>>            >> You might figure out by setting a break point in
>>>> outliner.cxx
>>>>>            >> aDrawPortionHdl.Call(...). Then you will at least be able
>>>>>            >> to see how the
>>>>>            >> information is collected. You need to record the
>>>>>            >> information about the
>>>>>            >> currently used alignment, and also use that information
>> at
>>>>>            >> the place
>>>>>            >> where the drawtext() is done.
>>>>>            >>
>>>>>            >> >
>>>>>            >> > Do you know Are there somebody in OpenOffice team is
>>>>>            >> developing or will
>>>>>            >> > develop this feature?
>>>>>            >>
>>>>>            >> Don't know / think so.
>>>>>            >>
>>>>>            >> Malte.
>>>>>            >>
>>>>>            >>
>>>>>
>>>>>
>>>>  ---------------------------------------------------------------------
>>>>>            >> To unsubscribe, e-mail:
>> [hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>
>>>>>            >> <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>>
>>>>>            >> For additional commands, e-mail:
>>>>>            >> [hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>         <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>
>>>>>            >> <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>
>>>>>            <mailto:[hidden email]
>>>>>         <mailto:[hidden email]>>>
>>>>>            >>
>>>>>            >>
>>>>>            >>
>>>>>            >>
>>>>>            >
>>>>>
>>>>>         With Best Regards,
>>>>>
>>>>>         LiuTao
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     --
>>>>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
>>>>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
>>>>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
>>>>>     Vorsitzender des Aufsichtsrates: Martin Häring
>>>>>
>>>>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
>>>>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what You
>>>>>     can do for ooO!
>>>>>
>>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>>  For additional commands, e-mail: [hidden email]
>>
>>
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
2009/12/9 Malte Timmermann <[hidden email]>

>
>
> JiaXiang Liu wrote, On 12/09/09 12:10:
>  > Hi all
> >
> > 2009/12/9 Malte Timmermann <[hidden email]>
> >
> >>
> >> JiaXiang Liu wrote, On 12/09/09 10:24:
> >>> Hello all,
> >>>
> >>> 2009/12/8 Malte Timmermann <[hidden email]>
> >>>
> >>>> I didn't review the patch, but just took a quick look.
> >>>>
> >>>> FontAlign is probably the wrong wording here at all.
> >>>>
> >>>> What you want to achieve is alignment of a text line.
> >>>> You should probably better call it TextLineAlignment or something like
> >>>> that.
> >>>>
> >>>>
> >>> OK,I will modify it.
> >>>
> >>>> Again - all calculations need to be dome in some upper layer, eg.
> >>>> EditEngine. Assuming that we really talk about text lign alignment,
> >>>> there is no need/reason to add a new enum in VCL.
> >>>>
> >>> I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to
> care
> >>> it. assume it is no use.
> >> If it is of no use, it shouldn't be introduced. No one will accept to
> >> have it in VCL then.
> >>
> >>>> As I said, do the implementation in impedit3.cxx.
> >>>> Instead of the suggestion in my first email, don't use
> ALIGN_TOP/BOTTOM
> >>>> at all, but use the font metrics to calculate the correct position so
> >>>> that the normal output with ALIGN_BASELINE works.
> >>>>
> >>>>
> >>> I want to know where(which function?) can I use the font metrics to
> >>> calculate the correct position? and
> >>> how to use the font metrics to calculate?
> >> Look in impedit3.cxx, CreateLines. There you can see how the Ascent and
> >> Descent from the FormatterFontMetric is used.
> >>
> >> Since your alignment doesn't influent the line calculation, you don't
> >> need to use the new attr in CreateLines(), but only in Paint().
> >> In Paint, the x/y position is calculated, and the DrawText with
> >> Align_Baseline is used.
> >>
> >>> why do not use
> >>> ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
> >>> I think it should be called by some functions.
> >> Because you have to adjust x/y in Paint() anyway.
> >> TOP and BOTTOM could help you to not do ascent/descent calculations
> >> yourself, but for CENTER you have to do it anyway.
> >> If you adjust x/y for all cases (top/bottom/center/baseline) to
> >> BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
> >> automatically. Edit Mode as well as repaint mode.
> >>
> >>
> >
> > what your mean about adjust x/y for all cases
> (top/bottom/center/baseline)
> > to
> > BASELINE?
> >
> > do you mean that I should add some code in paint(...) function like this:
> >
> >      TextAlign eAlign = aTmpFont.GetAlign();
> >      if ( eAlign == ALIGN_TOP )
> >      {
> >       aRealOutPos.Y() =......
> >       aRealOutPos.X() =....
> >      }
> >      if ( eAlign == ALIGN_BOTTOM )
> >      {
> >       aRealOutPos.Y() =......
> >       aRealOutPos.X() =....
> >      }
> >      if ( eAlign == ALIGN_BASELINE )
> >      {
> >       aRealOutPos.Y() =......
> >       aRealOutPos.X() =....
> >      }
> >
>
> First - use the current para attr, not GetAlign from the Font, because
> you shouldn't manipulate the alignment from the font anymore.
>
> Then look at the loop for ( nLine < nLines ), first switch statement
> covering text/field/hypenator. There you can manipulate y (or x in
> vertical writing mode). aTmpPos, not aRealOutPos.
>
>

Hi, Malte

Do you mean I should modifiy the code like this:in the loop of (nLine <
nLines )

     sal_uInt16 nAscent, nDescent;
      FontMetric aMetric( pRefDev->GetFontMetric() );
      nAscent = (sal_uInt16)aMetric.GetAscent();

     aTmpPos.X() += pLine->GetStartPosX();
     aTmpPos.Y() += nAscent;
     ... ... ...

I tried but in non-edit mode they can only change the line location but not
the character location.

It is still can not set align in non-edit mode.

can you give me some test code to implement the alignment setting in
non-edit mode?I really have no idea.

LiuTao



> Malte.
>
> > but I think this is still works in edit mode.but not in non-edit mode.
> >
> > so puzzled.I am afraid I will crash. ;-)
> >
> >> Malte.
> >>
> >>> Just like in editmode. in the function implEditEngine::print(...).this
> >>> function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
> >>> but it is in editmode.
> >>> my problem is : I can not set Align in non-edit mode.
> >>
> >>>
> >>>
> >>>
> >>>> Then all the rest in the drawing layer should work automatically.
> >>>>
> >>>> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one, and
> >>>> insert the new ID at the beginning, you don't have to manipulate the
> >>>> Version Maps, IIRC.
> >>>>
> >>>> The SvxFontAlignItem itself looks strange to me: Its bad design to use
> 4
> >>>> bool values instead of an enum, if only one value can be true, and
> >>>> exactly one value needs to be true.
> >>>>
> >>>>
> >>> I will improve.
> >>>
> >>>> Malte.
> >>>>
> >>>> JiaXiang Liu wrote, On 12/08/09 12:07:
> >>>>> Hello All,
> >>>>>
> >>>>>
> >>>>>
> >>>>> 2009/12/8 Armin Le Grand <[hidden email]
> >>>>> <mailto:[hidden email]>>
> >>>>>
> >>>>>     JiaXiang Liu schrieb:
> >>>>>
> >>>>>         Hi All,
> >>>>>
> >>>>>         2009/12/7 Malte Timmermann <[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>         <mailto:[hidden email] <mailto:
> >>>> [hidden email]>>>
> >>>>>            Hi LiuTao,
> >>>>>
> >>>>  >            given Armins explanation about the text primitive stuff,
> >> it
> >>>>>         seems it
> >>>>>            would be much easier to do the transformation to baseline
> in
> >>>>>            impedit3.cxx instead of manipulating the font alignment.
> >>>>>
> >>>>>         you mean I can only modify the impedit3.cxx to implement?
> >>>>>
> >>>>>     I do not know impedit3.cxx, but i would do the adaption (as
> >>>>>     described) in
> impTextBreakupHandler::impCreateTextPortionPrimitive.
> >>>>>     Nonetheless, even for pure VCL usage it is not sure if all usages
> >>>>>     can use the baseline when it is used. It looks like it was not
> used
> >>>>>     in editengine up to now, but maybe in SW. HDU should know.
> >>>>>
> >>>>>
> >>>>> yes,I have tryed so many times but have no result.I think it is not
> so
> >>>>> much difficult,just like to set the paragraph adjust left.when we set
> >> it
> >>>>> in edit mode it is ok , when in non-edit mode it is still ok.I guess
> if
> >>>>> there are some message should be transfered.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>            Then it would probably also work out-of-the-box in
> non-edit
> >>>> mode.
> >>>>>         Still don't know how to do that. :-(
> >>>>>
> >>>>>     As described: You have a StartPosition (rInfo.mrStartPos) that
> >>>>>     defines where to draw the text. You have the TextAlign. If
> >> TextAlign
> >>>>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of
> >> course)
> >>>>>     as if it is ALIGN_BASELINE. This means to add offsets vertically
> >> for
> >>>>>     horizontal text and probably vice-versa. The offsets depend on
> >>>>>     FontInfo information which You get with the VCL Font and an
> >>>>>     OutputDevice.
> >>>>>
> >>>>>
> >>>>> the font align is not a attribute of font.so it is painted in edit
> mode
> >>>>> in impleditengine::paint(...)
> >>>>> how to draw the alignment is in VCL.(function setalign)
> >>>>> I guess if there have a function called like : noeditview::paint(...)
> >> to
> >>>>> call the VCL to draw the alignment?
> >>>>>
> >>>>>
> >>>>> @Herbert
> >>>>>
> >>>>> Hello , Armin said you maybe know this.I wish you can help me....
> >>>>>
> >>>>>
> >>>>>            Malte.
> >>>>>
> >>>>>            Armin Le Grand wrote, On 12/07/09 12:33:
> >>>>>            > JiaXiang Liu schrieb:
> >>>>>            >> Hello Malte,Armin,
> >>>>>            >>
> >>>>>            >> Just Forward the email:
> >>>>>            >>
> >>>>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email] <mailto:
> [hidden email]
> >>>>>            >> <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]> <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>>>
> >>>>>
> >>>>>            >>
> >>>>>            >> Hello Malte,Armin
> >>>>>            >>
> >>>>>            >> @Malte
> >>>>>            >>
> >>>>>            >> I test that.It is so difficult.
> >>>>>            >>
> >>>>>            >> I setted a break point in outliner.cxx
> >>>>>            >> aDrawPortionHdl.Call(...).
> >>>>>            >> Then I find the many information is collected but not
> >>>>>         alignment.
> >>>>>            >>
> >>>>>            >> How to record the information about the currently used
> >>>>>         alignment?
> >>>>>            >> If I should add a Parameter in this area ?
> >>>>>            >>
> >>>>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
> >>>> nTextLen,
> >>>>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
> >>>>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
> >>>>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph,
> bEndOfBullet);
> >>>>>            >>
> >>>>>            >> BTW,
> >>>>>            >> aDrawPortionHdl.Call(...). is called by
> >>>>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev,
> >> Rectangle
> >>>>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
> >>>>>            nOrientation )
> >>>>>            >>
> >>>>>            >> and the pOutDev saved the alignment.
> >>>>>            >>
> >>>>>            >> This area is also not save paragraph adjust.I am so
> >>>> puzzled.
> >>>>>            >>
> >>>>>            >>
> >>>>>            >> @Armin
> >>>>>            >>
> >>>>>            >> Malte told me that you maybe know that I want to know.
> >> :-)
> >>>>>            >>
> >>>>>            > Maybe; i am responsible for DrawingLayer, not for Text
> >>>> engines;
> >>>>>            i just
> >>>>>            > have to work with TextEngines since no one really is
> >>>>>         responsible for
> >>>>>            > them currently; and Yes, they are somewhat complicated
> and
> >>>>>         grown
> >>>>>            code.
> >>>>>            > Malte once was responsible for them, thus in relation to
> >>>>>            > EditEngine/Outliner he may know more than me. I can help
> >>>> with
> >>>>>            > DrawingLayer and usage of TextParameters in prmitives,
> >>>> though.
> >>>>>            >>
> >>>>>            >> the question is :
> >>>>>            >> I am developing a new feature called "fontalign" It can
> >>>>>         set the
> >>>>>            >> text align top,center,baseline and bottom.
> >>>>>            >> In Impress,Create a new document, input some words in a
> >>>>>         text box
> >>>>>            >> in normal view.
> >>>>>            >> I can set the alignment successful in edit mode.
> >>>>>            >>
> >>>>>            > Is this already possible in the working/current code?
> >>>>>            > If Yes, where can i change those settings?
> >>>>>            >
> >>>>>            > If no (and it's a completely new feature) it has to be
> >>>>>            implemented not
> >>>>>            > only inside EditEngine/Outliner, evtl. new items there
> >> (not
> >>>>>         sure if
> >>>>>            > holding font alignment at the font itself is sufficient
> in
> >>>> all
> >>>>>            > situations) and in Paint/export/callbacks, but also in
> >> text
> >>>>>            primities,
> >>>>>            > their decompositions, exports and paintings.
> >>>>>            > I will set HDU on CC, he may now if holding alignment at
> >> the
> >>>>>            font will
> >>>>>            > be enough (if You use that currently).
> >>>>>            >
> >>>>>            >> but it can not store the setting when left the edit
> mode.
> >>>>>            >> It is OK in outline view,bucause in outline view it is
> >> also
> >>>> in
> >>>>>            >> edit mode.
> >>>>>            >>
> >>>>>            > That's right, that new feature has to be represented in
> >>>>>            TextPrimitives
> >>>>>            > and used by renderers for it.
> >>>>>            >
> >>>>>            > In short: DrawPortionInfo is the class which
> >>>>>         EditEngine/Outliner
> >>>>>            uses in
> >>>>>            > callback mode to export it's data (You already located
> >>>>>         that). The
> >>>>>            > FontAlignment info will be (i guess) at the
> >>>>>         DrawPortionInfo::mrFont
> >>>>>            > member which is also a 'Font' (the VCL class).
> >>>>>            >
> >>>>>
> >>>>>         yes,it can use the 'Font'(VCL class) member function like:
> >>>>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
> >>>>>
> >>>>>            > Primitives do not use a Font class (they are designed to
> >> be
> >>>>>            transported
> >>>>>            > over an API later), so they use
> >>>>>            > drawinglayer::primitive2d::FontAttributes where the font
> >> is
> >>>>>            described
> >>>>>            > using FamilyName/StyleName/Weight and others. There is
> no
> >>>>>         alignment
> >>>>>            > currently since it was not used yet. FontAttributes is
> >> then
> >>>>>         used in
> >>>>>            > TextSimplePortionPrimitive2D. At render time, the helper
> >>>>>            > getVclFontFromFontAttributes is used to re-create a VCL
> >> Font
> >>>>>            from the
> >>>>>            > FontAttributes, but this is only ONE way to use/render
> >> text
> >>>>>         in the
> >>>>>            > future with primitives; to use VCL again. This will
> >>>>>         probably change.
> >>>>>            >
> >>>>>            > The point is that currently, font alignment is not part
> of
> >>>>>            > FontAttributes and is not transported. As can be seen in
> >>>>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is assumed.
> I
> >>>>>         would
> >>>>>            not add
> >>>>>            > a font alignment to FontAttributes to keep it minimal
> (and
> >>>>>         it is not
> >>>>>            > necessary). The TextSimplePortionPrimitive2D (and it's
> >>>>>            derivates) are
> >>>>>            > low-level text portion holders and also have a implicit
> >>>>>         TextPosition
> >>>>>            > (part of the TextTransform), thus it would be best to
> >> adapt
> >>>> the
> >>>>>            implicit
> >>>>>            > TextStart position inside
> >>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive to
> >>>>>         always use
> >>>>>            > ALIGN_BASELINE.
> >>>>>            >
> >>>>>            > This is always possible using the FontInfo class and the
> >>>>>         offsets
> >>>>>            of the
> >>>>>            > font (bbaseline, height, etc...). This can be done in
> >>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive,
> see
> >>>>>         'apply
> >>>>>            local
> >>>>>            > offset'. rInfo.mrStartPos.Y() would need to be
> >>>>>         expanded/adapted when
> >>>>>            > text alignment is != ALIGN_BASELINE.
> >>>>>            >
> >>>>>
> >>>>>         If that means I would modify something in this area and do
> some
> >>>>>         expand?but how?
> >>>>>         Still puzzled about that.
> >>>>>
> >>>>>         Wish you can give me more hint to modify and implement the
> >>>>>         feature. :-)
> >>>>>
> >>>>>         I attach a patch.
> >>>>>         The Patch is what I have done,It did not contain XMLOFF
> >>>>>         module,outline view and vertical mode.
> >>>>>         I have implemented that. only have the non-edit mode problem.
> >>>>>
> >>>>>            > HTH!
> >>>>>            >
> >>>>>            >> I wish you can help me to solve this problem. Thank
> you.
> >>>>>            >>
> >>>>>            >> With Best Regards,
> >>>>>            >> LiuTao
> >>>>>            >>
> >>>>>            >>
> >>>>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email] <mailto:
> [hidden email]
> >>>>>            >> <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]> <mailto:[hidden email]
> >>>>  >         <mailto:[hidden email]>>>>
> >>>>>            >>
> >>>>>            >> Hello Malte,
> >>>>>            >>
> >>>>>            >> Thank you very much for the information.
> >>>>>            >>
> >>>>>            >> It is too late today fo me.
> >>>>>            >>
> >>>>>            >> I will test in Monday morning. if it is not ok, I will
> >> also
> >>>>>            >> ask Armin for this.
> >>>>>            >>
> >>>>>            >> Have a nice weekend.
> >>>>>            >>
> >>>>>            >> With Best Regards,
> >>>>>            >>
> >>>>>            >> LiuTao
> >>>>>            >>
> >>>>>            >> 2009/12/4 Malte Timmermann <[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>
> >>>>>            >> <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>>>
> >>>>>            >>
> >>>>>            >> Hi LiuTao,
> >>>>>            >>
> >>>>>            >>
> >>>>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
> >>>>>            >> > Hello Malte,
> >>>>>            >> >
> >>>>>            >> > Thank you for your answer.
> >>>>>            >> >
> >>>>>            >> > What I puzzled now is:
> >>>>>            >> >
> >>>>>            >> > Why I can not set the new attribute in no edit mode?
> >>>>>            >>
> >>>>>            >> For redrawing the content, the metrics calculated from
> >> the
> >>>>>            >> EditEngine
> >>>>>            >> are cached somewhere, and the drawing layer uses
> >>>>>            >> DrawText() directly,
> >>>>>            >> probably also with ALIGN_BASELINE.
> >>>>>            >>
> >>>>>            >> >
> >>>>>            >> > This is the* biggest problem* now and I want to solve
> >>>>>            >> it. Can you help
> >>>>>            >> > me?you said it may be the drawing layer.but I can not
> >> do
> >>>>>            >> anything about
> >>>>>            >> > that.
> >>>>>            >>
> >>>>>            >> Armin should know more about this...
> >>>>>            >>
> >>>>>            >> You might figure out by setting a break point in
> >>>> outliner.cxx
> >>>>>            >> aDrawPortionHdl.Call(...). Then you will at least be
> able
> >>>>>            >> to see how the
> >>>>>            >> information is collected. You need to record the
> >>>>>            >> information about the
> >>>>>            >> currently used alignment, and also use that information
> >> at
> >>>>>            >> the place
> >>>>>            >> where the drawtext() is done.
> >>>>>            >>
> >>>>>            >> >
> >>>>>            >> > Do you know Are there somebody in OpenOffice team is
> >>>>>            >> developing or will
> >>>>>            >> > develop this feature?
> >>>>>            >>
> >>>>>            >> Don't know / think so.
> >>>>>            >>
> >>>>>            >> Malte.
> >>>>>            >>
> >>>>>            >>
> >>>>>
> >>>>>
> >>>>  ---------------------------------------------------------------------
> >>>>>            >> To unsubscribe, e-mail:
> >> [hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>
> >>>>>            >> <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>>
> >>>>>            >> For additional commands, e-mail:
> >>>>>            >> [hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>         <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>
> >>>>>            >> <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>
> >>>>>            <mailto:[hidden email]
> >>>>>         <mailto:[hidden email]>>>
> >>>>>            >>
> >>>>>            >>
> >>>>>            >>
> >>>>>            >>
> >>>>>            >
> >>>>>
> >>>>>         With Best Regards,
> >>>>>
> >>>>>         LiuTao
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>     --
> >>>>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
> >>>>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
> >>>>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
> >>>>>     Vorsitzender des Aufsichtsrates: Martin Häring
> >>>>>
> >>>>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
> >>>>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what
> You
> >>>>>     can do for ooO!
> >>>>>
> >>>>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >>  For additional commands, e-mail: [hidden email]
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann

JiaXiang Liu wrote, On 12/10/09 04:28:

> Hi, Malte
>
> Do you mean I should modifiy the code like this:in the loop of (nLine <
> nLines )
>
>      sal_uInt16 nAscent, nDescent;
>       FontMetric aMetric( pRefDev->GetFontMetric() );
>       nAscent = (sal_uInt16)aMetric.GetAscent();
>
>      aTmpPos.X() += pLine->GetStartPosX();
>      aTmpPos.Y() += nAscent;
>      ... ... ...

.X() was already manipulated previously.
.Y() also, to match baseline

So you only need to make manipulatation here for non baseline modes.

>
> I tried but in non-edit mode they can only change the line location but not
> the character location.
>
> It is still can not set align in non-edit mode.
>
> can you give me some test code to implement the alignment setting in
> non-edit mode?I really have no idea.

Sorry, but I work on other stuff currently...

>
> LiuTao

Malte.

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

Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
In reply to this post by JiaXiang Liu
Hi LiuTao,

I couldn't resist to prove that my suggestion would work as expected... ;)

The attached patch works in edit mode as well as in paint mode.

I only did some quick test and verified the values in the debugger (for
lines w/o font changes, nAdjust must always be 0, in all modes).

NO manipulations of font align and NO addition to VCL's enum
needed/wanted. NO extra work in drawing layer needed, because everything
still is baseline.

Note: TOP will only look as expected when using upper case (or Chinese)
characters. Lower case characters will have some space above.

HTH,
Malte.


JiaXiang Liu wrote, On 12/10/09 04:28:

> 2009/12/9 Malte Timmermann <[hidden email]>
>
>>
>> JiaXiang Liu wrote, On 12/09/09 12:10:
>>  > Hi all
>>> 2009/12/9 Malte Timmermann <[hidden email]>
>>>
>>>> JiaXiang Liu wrote, On 12/09/09 10:24:
>>>>> Hello all,
>>>>>
>>>>> 2009/12/8 Malte Timmermann <[hidden email]>
>>>>>
>>>>>> I didn't review the patch, but just took a quick look.
>>>>>>
>>>>>> FontAlign is probably the wrong wording here at all.
>>>>>>
>>>>>> What you want to achieve is alignment of a text line.
>>>>>> You should probably better call it TextLineAlignment or something like
>>>>>> that.
>>>>>>
>>>>>>
>>>>> OK,I will modify it.
>>>>>
>>>>>> Again - all calculations need to be dome in some upper layer, eg.
>>>>>> EditEngine. Assuming that we really talk about text lign alignment,
>>>>>> there is no need/reason to add a new enum in VCL.
>>>>>>
>>>>> I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to
>> care
>>>>> it. assume it is no use.
>>>> If it is of no use, it shouldn't be introduced. No one will accept to
>>>> have it in VCL then.
>>>>
>>>>>> As I said, do the implementation in impedit3.cxx.
>>>>>> Instead of the suggestion in my first email, don't use
>> ALIGN_TOP/BOTTOM
>>>>>> at all, but use the font metrics to calculate the correct position so
>>>>>> that the normal output with ALIGN_BASELINE works.
>>>>>>
>>>>>>
>>>>> I want to know where(which function?) can I use the font metrics to
>>>>> calculate the correct position? and
>>>>> how to use the font metrics to calculate?
>>>> Look in impedit3.cxx, CreateLines. There you can see how the Ascent and
>>>> Descent from the FormatterFontMetric is used.
>>>>
>>>> Since your alignment doesn't influent the line calculation, you don't
>>>> need to use the new attr in CreateLines(), but only in Paint().
>>>> In Paint, the x/y position is calculated, and the DrawText with
>>>> Align_Baseline is used.
>>>>
>>>>> why do not use
>>>>> ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
>>>>> I think it should be called by some functions.
>>>> Because you have to adjust x/y in Paint() anyway.
>>>> TOP and BOTTOM could help you to not do ascent/descent calculations
>>>> yourself, but for CENTER you have to do it anyway.
>>>> If you adjust x/y for all cases (top/bottom/center/baseline) to
>>>> BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
>>>> automatically. Edit Mode as well as repaint mode.
>>>>
>>>>
>>> what your mean about adjust x/y for all cases
>> (top/bottom/center/baseline)
>>> to
>>> BASELINE?
>>>
>>> do you mean that I should add some code in paint(...) function like this:
>>>
>>>      TextAlign eAlign = aTmpFont.GetAlign();
>>>      if ( eAlign == ALIGN_TOP )
>>>      {
>>>       aRealOutPos.Y() =......
>>>       aRealOutPos.X() =....
>>>      }
>>>      if ( eAlign == ALIGN_BOTTOM )
>>>      {
>>>       aRealOutPos.Y() =......
>>>       aRealOutPos.X() =....
>>>      }
>>>      if ( eAlign == ALIGN_BASELINE )
>>>      {
>>>       aRealOutPos.Y() =......
>>>       aRealOutPos.X() =....
>>>      }
>>>
>> First - use the current para attr, not GetAlign from the Font, because
>> you shouldn't manipulate the alignment from the font anymore.
>>
>> Then look at the loop for ( nLine < nLines ), first switch statement
>> covering text/field/hypenator. There you can manipulate y (or x in
>> vertical writing mode). aTmpPos, not aRealOutPos.
>>
>>
>
> Hi, Malte
>
> Do you mean I should modifiy the code like this:in the loop of (nLine <
> nLines )
>
>      sal_uInt16 nAscent, nDescent;
>       FontMetric aMetric( pRefDev->GetFontMetric() );
>       nAscent = (sal_uInt16)aMetric.GetAscent();
>
>      aTmpPos.X() += pLine->GetStartPosX();
>      aTmpPos.Y() += nAscent;
>      ... ... ...
>
> I tried but in non-edit mode they can only change the line location but not
> the character location.
>
> It is still can not set align in non-edit mode.
>
> can you give me some test code to implement the alignment setting in
> non-edit mode?I really have no idea.
>
> LiuTao
>
>
>
>> Malte.
>>
>>> but I think this is still works in edit mode.but not in non-edit mode.
>>>
>>> so puzzled.I am afraid I will crash. ;-)
>>>
>>>> Malte.
>>>>
>>>>> Just like in editmode. in the function implEditEngine::print(...).this
>>>>> function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
>>>>> but it is in editmode.
>>>>> my problem is : I can not set Align in non-edit mode.
>>>>>
>>>>>
>>>>>> Then all the rest in the drawing layer should work automatically.
>>>>>>
>>>>>> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one, and
>>>>>> insert the new ID at the beginning, you don't have to manipulate the
>>>>>> Version Maps, IIRC.
>>>>>>
>>>>>> The SvxFontAlignItem itself looks strange to me: Its bad design to use
>> 4
>>>>>> bool values instead of an enum, if only one value can be true, and
>>>>>> exactly one value needs to be true.
>>>>>>
>>>>>>
>>>>> I will improve.
>>>>>
>>>>>> Malte.
>>>>>>
>>>>>> JiaXiang Liu wrote, On 12/08/09 12:07:
>>>>>>> Hello All,
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2009/12/8 Armin Le Grand <[hidden email]
>>>>>>> <mailto:[hidden email]>>
>>>>>>>
>>>>>>>     JiaXiang Liu schrieb:
>>>>>>>
>>>>>>>         Hi All,
>>>>>>>
>>>>>>>         2009/12/7 Malte Timmermann <[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>         <mailto:[hidden email] <mailto:
>>>>>> [hidden email]>>>
>>>>>>>            Hi LiuTao,
>>>>>>>
>>>>>>  >            given Armins explanation about the text primitive stuff,
>>>> it
>>>>>>>         seems it
>>>>>>>            would be much easier to do the transformation to baseline
>> in
>>>>>>>            impedit3.cxx instead of manipulating the font alignment.
>>>>>>>
>>>>>>>         you mean I can only modify the impedit3.cxx to implement?
>>>>>>>
>>>>>>>     I do not know impedit3.cxx, but i would do the adaption (as
>>>>>>>     described) in
>> impTextBreakupHandler::impCreateTextPortionPrimitive.
>>>>>>>     Nonetheless, even for pure VCL usage it is not sure if all usages
>>>>>>>     can use the baseline when it is used. It looks like it was not
>> used
>>>>>>>     in editengine up to now, but maybe in SW. HDU should know.
>>>>>>>
>>>>>>>
>>>>>>> yes,I have tryed so many times but have no result.I think it is not
>> so
>>>>>>> much difficult,just like to set the paragraph adjust left.when we set
>>>> it
>>>>>>> in edit mode it is ok , when in non-edit mode it is still ok.I guess
>> if
>>>>>>> there are some message should be transfered.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>            Then it would probably also work out-of-the-box in
>> non-edit
>>>>>> mode.
>>>>>>>         Still don't know how to do that. :-(
>>>>>>>
>>>>>>>     As described: You have a StartPosition (rInfo.mrStartPos) that
>>>>>>>     defines where to draw the text. You have the TextAlign. If
>>>> TextAlign
>>>>>>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of
>>>> course)
>>>>>>>     as if it is ALIGN_BASELINE. This means to add offsets vertically
>>>> for
>>>>>>>     horizontal text and probably vice-versa. The offsets depend on
>>>>>>>     FontInfo information which You get with the VCL Font and an
>>>>>>>     OutputDevice.
>>>>>>>
>>>>>>>
>>>>>>> the font align is not a attribute of font.so it is painted in edit
>> mode
>>>>>>> in impleditengine::paint(...)
>>>>>>> how to draw the alignment is in VCL.(function setalign)
>>>>>>> I guess if there have a function called like : noeditview::paint(...)
>>>> to
>>>>>>> call the VCL to draw the alignment?
>>>>>>>
>>>>>>>
>>>>>>> @Herbert
>>>>>>>
>>>>>>> Hello , Armin said you maybe know this.I wish you can help me....
>>>>>>>
>>>>>>>
>>>>>>>            Malte.
>>>>>>>
>>>>>>>            Armin Le Grand wrote, On 12/07/09 12:33:
>>>>>>>            > JiaXiang Liu schrieb:
>>>>>>>            >> Hello Malte,Armin,
>>>>>>>            >>
>>>>>>>            >> Just Forward the email:
>>>>>>>            >>
>>>>>>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email] <mailto:
>> [hidden email]
>>>>>>>            >> <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]> <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>>>
>>>>>>>
>>>>>>>            >>
>>>>>>>            >> Hello Malte,Armin
>>>>>>>            >>
>>>>>>>            >> @Malte
>>>>>>>            >>
>>>>>>>            >> I test that.It is so difficult.
>>>>>>>            >>
>>>>>>>            >> I setted a break point in outliner.cxx
>>>>>>>            >> aDrawPortionHdl.Call(...).
>>>>>>>            >> Then I find the many information is collected but not
>>>>>>>         alignment.
>>>>>>>            >>
>>>>>>>            >> How to record the information about the currently used
>>>>>>>         alignment?
>>>>>>>            >> If I should add a Parameter in this area ?
>>>>>>>            >>
>>>>>>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
>>>>>> nTextLen,
>>>>>>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
>>>>>>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
>>>>>>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph,
>> bEndOfBullet);
>>>>>>>            >>
>>>>>>>            >> BTW,
>>>>>>>            >> aDrawPortionHdl.Call(...). is called by
>>>>>>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev,
>>>> Rectangle
>>>>>>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
>>>>>>>            nOrientation )
>>>>>>>            >>
>>>>>>>            >> and the pOutDev saved the alignment.
>>>>>>>            >>
>>>>>>>            >> This area is also not save paragraph adjust.I am so
>>>>>> puzzled.
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>            >> @Armin
>>>>>>>            >>
>>>>>>>            >> Malte told me that you maybe know that I want to know.
>>>> :-)
>>>>>>>            >>
>>>>>>>            > Maybe; i am responsible for DrawingLayer, not for Text
>>>>>> engines;
>>>>>>>            i just
>>>>>>>            > have to work with TextEngines since no one really is
>>>>>>>         responsible for
>>>>>>>            > them currently; and Yes, they are somewhat complicated
>> and
>>>>>>>         grown
>>>>>>>            code.
>>>>>>>            > Malte once was responsible for them, thus in relation to
>>>>>>>            > EditEngine/Outliner he may know more than me. I can help
>>>>>> with
>>>>>>>            > DrawingLayer and usage of TextParameters in prmitives,
>>>>>> though.
>>>>>>>            >>
>>>>>>>            >> the question is :
>>>>>>>            >> I am developing a new feature called "fontalign" It can
>>>>>>>         set the
>>>>>>>            >> text align top,center,baseline and bottom.
>>>>>>>            >> In Impress,Create a new document, input some words in a
>>>>>>>         text box
>>>>>>>            >> in normal view.
>>>>>>>            >> I can set the alignment successful in edit mode.
>>>>>>>            >>
>>>>>>>            > Is this already possible in the working/current code?
>>>>>>>            > If Yes, where can i change those settings?
>>>>>>>            >
>>>>>>>            > If no (and it's a completely new feature) it has to be
>>>>>>>            implemented not
>>>>>>>            > only inside EditEngine/Outliner, evtl. new items there
>>>> (not
>>>>>>>         sure if
>>>>>>>            > holding font alignment at the font itself is sufficient
>> in
>>>>>> all
>>>>>>>            > situations) and in Paint/export/callbacks, but also in
>>>> text
>>>>>>>            primities,
>>>>>>>            > their decompositions, exports and paintings.
>>>>>>>            > I will set HDU on CC, he may now if holding alignment at
>>>> the
>>>>>>>            font will
>>>>>>>            > be enough (if You use that currently).
>>>>>>>            >
>>>>>>>            >> but it can not store the setting when left the edit
>> mode.
>>>>>>>            >> It is OK in outline view,bucause in outline view it is
>>>> also
>>>>>> in
>>>>>>>            >> edit mode.
>>>>>>>            >>
>>>>>>>            > That's right, that new feature has to be represented in
>>>>>>>            TextPrimitives
>>>>>>>            > and used by renderers for it.
>>>>>>>            >
>>>>>>>            > In short: DrawPortionInfo is the class which
>>>>>>>         EditEngine/Outliner
>>>>>>>            uses in
>>>>>>>            > callback mode to export it's data (You already located
>>>>>>>         that). The
>>>>>>>            > FontAlignment info will be (i guess) at the
>>>>>>>         DrawPortionInfo::mrFont
>>>>>>>            > member which is also a 'Font' (the VCL class).
>>>>>>>            >
>>>>>>>
>>>>>>>         yes,it can use the 'Font'(VCL class) member function like:
>>>>>>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
>>>>>>>
>>>>>>>            > Primitives do not use a Font class (they are designed to
>>>> be
>>>>>>>            transported
>>>>>>>            > over an API later), so they use
>>>>>>>            > drawinglayer::primitive2d::FontAttributes where the font
>>>> is
>>>>>>>            described
>>>>>>>            > using FamilyName/StyleName/Weight and others. There is
>> no
>>>>>>>         alignment
>>>>>>>            > currently since it was not used yet. FontAttributes is
>>>> then
>>>>>>>         used in
>>>>>>>            > TextSimplePortionPrimitive2D. At render time, the helper
>>>>>>>            > getVclFontFromFontAttributes is used to re-create a VCL
>>>> Font
>>>>>>>            from the
>>>>>>>            > FontAttributes, but this is only ONE way to use/render
>>>> text
>>>>>>>         in the
>>>>>>>            > future with primitives; to use VCL again. This will
>>>>>>>         probably change.
>>>>>>>            >
>>>>>>>            > The point is that currently, font alignment is not part
>> of
>>>>>>>            > FontAttributes and is not transported. As can be seen in
>>>>>>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is assumed.
>> I
>>>>>>>         would
>>>>>>>            not add
>>>>>>>            > a font alignment to FontAttributes to keep it minimal
>> (and
>>>>>>>         it is not
>>>>>>>            > necessary). The TextSimplePortionPrimitive2D (and it's
>>>>>>>            derivates) are
>>>>>>>            > low-level text portion holders and also have a implicit
>>>>>>>         TextPosition
>>>>>>>            > (part of the TextTransform), thus it would be best to
>>>> adapt
>>>>>> the
>>>>>>>            implicit
>>>>>>>            > TextStart position inside
>>>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive to
>>>>>>>         always use
>>>>>>>            > ALIGN_BASELINE.
>>>>>>>            >
>>>>>>>            > This is always possible using the FontInfo class and the
>>>>>>>         offsets
>>>>>>>            of the
>>>>>>>            > font (bbaseline, height, etc...). This can be done in
>>>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive,
>> see
>>>>>>>         'apply
>>>>>>>            local
>>>>>>>            > offset'. rInfo.mrStartPos.Y() would need to be
>>>>>>>         expanded/adapted when
>>>>>>>            > text alignment is != ALIGN_BASELINE.
>>>>>>>            >
>>>>>>>
>>>>>>>         If that means I would modify something in this area and do
>> some
>>>>>>>         expand?but how?
>>>>>>>         Still puzzled about that.
>>>>>>>
>>>>>>>         Wish you can give me more hint to modify and implement the
>>>>>>>         feature. :-)
>>>>>>>
>>>>>>>         I attach a patch.
>>>>>>>         The Patch is what I have done,It did not contain XMLOFF
>>>>>>>         module,outline view and vertical mode.
>>>>>>>         I have implemented that. only have the non-edit mode problem.
>>>>>>>
>>>>>>>            > HTH!
>>>>>>>            >
>>>>>>>            >> I wish you can help me to solve this problem. Thank
>> you.
>>>>>>>            >>
>>>>>>>            >> With Best Regards,
>>>>>>>            >> LiuTao
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email] <mailto:
>> [hidden email]
>>>>>>>            >> <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]> <mailto:[hidden email]
>>>>>>  >         <mailto:[hidden email]>>>>
>>>>>>>            >>
>>>>>>>            >> Hello Malte,
>>>>>>>            >>
>>>>>>>            >> Thank you very much for the information.
>>>>>>>            >>
>>>>>>>            >> It is too late today fo me.
>>>>>>>            >>
>>>>>>>            >> I will test in Monday morning. if it is not ok, I will
>>>> also
>>>>>>>            >> ask Armin for this.
>>>>>>>            >>
>>>>>>>            >> Have a nice weekend.
>>>>>>>            >>
>>>>>>>            >> With Best Regards,
>>>>>>>            >>
>>>>>>>            >> LiuTao
>>>>>>>            >>
>>>>>>>            >> 2009/12/4 Malte Timmermann <[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>
>>>>>>>            >> <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>>>
>>>>>>>            >>
>>>>>>>            >> Hi LiuTao,
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
>>>>>>>            >> > Hello Malte,
>>>>>>>            >> >
>>>>>>>            >> > Thank you for your answer.
>>>>>>>            >> >
>>>>>>>            >> > What I puzzled now is:
>>>>>>>            >> >
>>>>>>>            >> > Why I can not set the new attribute in no edit mode?
>>>>>>>            >>
>>>>>>>            >> For redrawing the content, the metrics calculated from
>>>> the
>>>>>>>            >> EditEngine
>>>>>>>            >> are cached somewhere, and the drawing layer uses
>>>>>>>            >> DrawText() directly,
>>>>>>>            >> probably also with ALIGN_BASELINE.
>>>>>>>            >>
>>>>>>>            >> >
>>>>>>>            >> > This is the* biggest problem* now and I want to solve
>>>>>>>            >> it. Can you help
>>>>>>>            >> > me?you said it may be the drawing layer.but I can not
>>>> do
>>>>>>>            >> anything about
>>>>>>>            >> > that.
>>>>>>>            >>
>>>>>>>            >> Armin should know more about this...
>>>>>>>            >>
>>>>>>>            >> You might figure out by setting a break point in
>>>>>> outliner.cxx
>>>>>>>            >> aDrawPortionHdl.Call(...). Then you will at least be
>> able
>>>>>>>            >> to see how the
>>>>>>>            >> information is collected. You need to record the
>>>>>>>            >> information about the
>>>>>>>            >> currently used alignment, and also use that information
>>>> at
>>>>>>>            >> the place
>>>>>>>            >> where the drawtext() is done.
>>>>>>>            >>
>>>>>>>            >> >
>>>>>>>            >> > Do you know Are there somebody in OpenOffice team is
>>>>>>>            >> developing or will
>>>>>>>            >> > develop this feature?
>>>>>>>            >>
>>>>>>>            >> Don't know / think so.
>>>>>>>            >>
>>>>>>>            >> Malte.
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>
>>>>>>>
>>>>>>  ---------------------------------------------------------------------
>>>>>>>            >> To unsubscribe, e-mail:
>>>> [hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>
>>>>>>>            >> <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>>
>>>>>>>            >> For additional commands, e-mail:
>>>>>>>            >> [hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>         <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>
>>>>>>>            >> <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>
>>>>>>>            <mailto:[hidden email]
>>>>>>>         <mailto:[hidden email]>>>
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>            >>
>>>>>>>            >
>>>>>>>
>>>>>>>         With Best Regards,
>>>>>>>
>>>>>>>         LiuTao
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>     --
>>>>>>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
>>>>>>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
>>>>>>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
>>>>>>>     Vorsitzender des Aufsichtsrates: Martin Häring
>>>>>>>
>>>>>>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
>>>>>>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what
>> You
>>>>>>>     can do for ooO!
>>>>>>>
>>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>>  For additional commands, e-mail: [hidden email]
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

--- /cygdrive/o/ooo320/src.m7/svx/source/editeng/impedit3.cxx   2009-09-25 13:22:28.000000000 +0200
+++ impedit3.cxx    2009-12-11 15:37:47.567886500 +0100
@@ -2994,6 +2994,40 @@
                             {
                                SeekCursor( pPortion->GetNode(), nIndex+1, aTmpFont, pOutDev );
 
+                               // For LineAdjustModes != baseline keep the baseline position, need to be restored later
+                               Point aTmpPosBaseline( aTmpPos );
+                               static int nTestLineAlignMode = 0;
+                               if ( nTestLineAlignMode )
+                               {
+                                   aTmpFont.SetPhysFont( GetRefDevice() );
+                                   FormatterFontMetric aFormatterMetrics;
+                                   RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
+                                  
+                                   long nAdjust = 0;
+                                  
+                                   if ( nTestLineAlignMode == 1 ) // TOP
+                                   {
+                                       nAdjust = -pLine->GetMaxAscent(); // TOP Most
+                                       nAdjust += aFormatterMetrics.nMaxAscent; // Now we have the baseline
+                                   }
+                                   else if ( nTestLineAlignMode == 2 ) // BOTTOM
+                                   {
+                                       nAdjust = -pLine->GetMaxAscent() + pLine->GetHeight(); // BOTTOM most
+                                       nAdjust -= aFormatterMetrics.nMaxDescent; // Now we have the baseline
+                                   }
+                                   else if ( nTestLineAlignMode == 3 ) // CENTER
+                                   {
+                                       long nGlypHeight = aFormatterMetrics.nMaxAscent + aFormatterMetrics.nMaxDescent;
+                                       nAdjust = -pLine->GetMaxAscent() + pLine->GetHeight() / 2 - nGlypHeight / 2;
+                                       nAdjust += aFormatterMetrics.nMaxAscent; // Now we have the baseline
+                                   }
+
+                                   if ( !IsVertical() )
+                                       aTmpPos.Y() += nAdjust;
+                                   else
+                                       aTmpPos.X() += nAdjust;
+                               }
+
                                 BOOL bDrawFrame = FALSE;
 
                                 if ( ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) && !aTmpFont.IsTransparent() &&
@@ -3464,6 +3498,7 @@
                                }
 
                                 pOutDev->Pop();
+                                aTmpPos = aTmpPosBaseline;
 
                                 if ( pTmpDXArray )
                                    delete[] pTmpDXArray;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

JiaXiang Liu
Hi Malte,
2009/12/11 Malte Timmermann <[hidden email]>

> Hi LiuTao,
>
> I couldn't resist to prove that my suggestion would work as expected... ;)
>
> The attached patch works in edit mode as well as in paint mode.
>
> I only did some quick test and verified the values in the debugger (for
> lines w/o font changes, nAdjust must always be 0, in all modes).
>
> NO manipulations of font align and NO addition to VCL's enum
> needed/wanted. NO extra work in drawing layer needed, because everything
> still is baseline.
>
> Note: TOP will only look as expected when using upper case (or Chinese)
> characters. Lower case characters will have some space above.
>
> HTH,
> Malte.
>
>
>

you are right,The patch works in non-edit mode.but it is wrong in edit mode.
I don't know why. I added some code without your patch in seekcursor
function like this:

 enum TextAlign at = ALIGN_BASELINE;
   SvxFontAlign eFontAlign =
((SvxFontAlignItem&)pNode->GetContentAttribs().GetItem( EE_PARA_FONTALIGN
)).GetFontAlign();
   if (eFontAlign == SVX_FONT_ALIGN_TOP)
   {
    at = ALIGN_TOP;
   }
   else if (eFontAlign == SVX_FONT_ALIGN_BOTTOM)
   {
    at = ALIGN_BOTTOM;
   }
   else if (eFontAlign == SVX_FONT_ALIGN_CENTER)
   {
    at = ALIGN_CENTER;
   }
   else
   {
    at = ALIGN_BASELINE;
   }
  rFont.SetAlign(at);

it will display right in edit mode but not in non-edit mode.

if I added this code and your patch. it will display right in non-edit mode
but not in edit mode.

BTW,if I use your patch,first I set alignment as TOP,then I set BOTTOM,It
will not align BOTTOM immediately,I should exit the edit mode and relocate
the cursor in edit box.I don't know why.

Another question:

what is the mean of aTmpPos and aRealOutPos mean?

With Best Regards,
LiuTao


> JiaXiang Liu wrote, On 12/10/09 04:28:
>  > 2009/12/9 Malte Timmermann <[hidden email]>
> >
> >>
> >> JiaXiang Liu wrote, On 12/09/09 12:10:
> >>  > Hi all
> >>> 2009/12/9 Malte Timmermann <[hidden email]>
> >>>
> >>>> JiaXiang Liu wrote, On 12/09/09 10:24:
> >>>>> Hello all,
> >>>>>
> >>>>> 2009/12/8 Malte Timmermann <[hidden email]>
> >>>>>
> >>>>>> I didn't review the patch, but just took a quick look.
> >>>>>>
> >>>>>> FontAlign is probably the wrong wording here at all.
> >>>>>>
> >>>>>> What you want to achieve is alignment of a text line.
> >>>>>> You should probably better call it TextLineAlignment or something
> like
> >>>>>> that.
> >>>>>>
> >>>>>>
> >>>>> OK,I will modify it.
> >>>>>
> >>>>>> Again - all calculations need to be dome in some upper layer, eg.
> >>>>>> EditEngine. Assuming that we really talk about text lign alignment,
> >>>>>> there is no need/reason to add a new enum in VCL.
> >>>>>>
> >>>>> I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to
> >> care
> >>>>> it. assume it is no use.
> >>>> If it is of no use, it shouldn't be introduced. No one will accept to
> >>>> have it in VCL then.
> >>>>
> >>>>>> As I said, do the implementation in impedit3.cxx.
> >>>>>> Instead of the suggestion in my first email, don't use
> >> ALIGN_TOP/BOTTOM
> >>>>>> at all, but use the font metrics to calculate the correct position
> so
> >>>>>> that the normal output with ALIGN_BASELINE works.
> >>>>>>
> >>>>>>
> >>>>> I want to know where(which function?) can I use the font metrics to
> >>>>> calculate the correct position? and
> >>>>> how to use the font metrics to calculate?
> >>>> Look in impedit3.cxx, CreateLines. There you can see how the Ascent
> and
> >>>> Descent from the FormatterFontMetric is used.
> >>>>
> >>>> Since your alignment doesn't influent the line calculation, you don't
> >>>> need to use the new attr in CreateLines(), but only in Paint().
> >>>> In Paint, the x/y position is calculated, and the DrawText with
> >>>> Align_Baseline is used.
> >>>>
> >>>>> why do not use
> >>>>> ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
> >>>>> I think it should be called by some functions.
> >>>> Because you have to adjust x/y in Paint() anyway.
> >>>> TOP and BOTTOM could help you to not do ascent/descent calculations
> >>>> yourself, but for CENTER you have to do it anyway.
> >>>> If you adjust x/y for all cases (top/bottom/center/baseline) to
> >>>> BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
> >>>> automatically. Edit Mode as well as repaint mode.
> >>>>
> >>>>
> >>> what your mean about adjust x/y for all cases
> >> (top/bottom/center/baseline)
> >>> to
> >>> BASELINE?
> >>>
> >>> do you mean that I should add some code in paint(...) function like
> this:
> >>>
> >>>      TextAlign eAlign = aTmpFont.GetAlign();
> >>>      if ( eAlign == ALIGN_TOP )
> >>>      {
> >>>       aRealOutPos.Y() =......
> >>>       aRealOutPos.X() =....
> >>>      }
> >>>      if ( eAlign == ALIGN_BOTTOM )
> >>>      {
> >>>       aRealOutPos.Y() =......
> >>>       aRealOutPos.X() =....
> >>>      }
> >>>      if ( eAlign == ALIGN_BASELINE )
> >>>      {
> >>>       aRealOutPos.Y() =......
> >>>       aRealOutPos.X() =....
> >>>      }
> >>>
> >> First - use the current para attr, not GetAlign from the Font, because
> >> you shouldn't manipulate the alignment from the font anymore.
> >>
> >> Then look at the loop for ( nLine < nLines ), first switch statement
> >> covering text/field/hypenator. There you can manipulate y (or x in
> >> vertical writing mode). aTmpPos, not aRealOutPos.
> >>
> >>
> >
> > Hi, Malte
> >
> > Do you mean I should modifiy the code like this:in the loop of (nLine <
> > nLines )
> >
> >      sal_uInt16 nAscent, nDescent;
> >       FontMetric aMetric( pRefDev->GetFontMetric() );
> >       nAscent = (sal_uInt16)aMetric.GetAscent();
> >
> >      aTmpPos.X() += pLine->GetStartPosX();
> >      aTmpPos.Y() += nAscent;
> >      ... ... ...
> >
> > I tried but in non-edit mode they can only change the line location but
> not
> > the character location.
> >
> > It is still can not set align in non-edit mode.
> >
> > can you give me some test code to implement the alignment setting in
> > non-edit mode?I really have no idea.
> >
> > LiuTao
> >
> >
> >
> >> Malte.
> >>
> >>> but I think this is still works in edit mode.but not in non-edit mode.
> >>>
> >>> so puzzled.I am afraid I will crash. ;-)
> >>>
> >>>> Malte.
> >>>>
> >>>>> Just like in editmode. in the function
> implEditEngine::print(...).this
> >>>>> function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
> >>>>> but it is in editmode.
> >>>>> my problem is : I can not set Align in non-edit mode.
> >>>>>
> >>>>>
> >>>>>> Then all the rest in the drawing layer should work automatically.
> >>>>>>
> >>>>>> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one,
> and
> >>>>>> insert the new ID at the beginning, you don't have to manipulate the
> >>>>>> Version Maps, IIRC.
> >>>>>>
> >>>>>> The SvxFontAlignItem itself looks strange to me: Its bad design to
> use
> >> 4
> >>>>>> bool values instead of an enum, if only one value can be true, and
> >>>>>> exactly one value needs to be true.
> >>>>>>
> >>>>>>
> >>>>> I will improve.
> >>>>>
> >>>>>> Malte.
> >>>>>>
> >>>>>> JiaXiang Liu wrote, On 12/08/09 12:07:
> >>>>>>> Hello All,
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> 2009/12/8 Armin Le Grand <[hidden email]
> >>>>>>> <mailto:[hidden email]>>
> >>>>>>>
> >>>>>>>     JiaXiang Liu schrieb:
> >>>>>>>
> >>>>>>>         Hi All,
> >>>>>>>
> >>>>>>>         2009/12/7 Malte Timmermann <[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>         <mailto:[hidden email] <mailto:
> >>>>>> [hidden email]>>>
> >>>>>>>            Hi LiuTao,
> >>>>>>>
> >>>>>>  >            given Armins explanation about the text primitive
> stuff,
> >>>> it
> >>>>>>>         seems it
> >>>>>>>            would be much easier to do the transformation to
> baseline
> >> in
> >>>>>>>            impedit3.cxx instead of manipulating the font alignment.
> >>>>>>>
> >>>>>>>         you mean I can only modify the impedit3.cxx to implement?
> >>>>>>>
> >>>>>>>     I do not know impedit3.cxx, but i would do the adaption (as
> >>>>>>>     described) in
> >> impTextBreakupHandler::impCreateTextPortionPrimitive.
> >>>>>>>     Nonetheless, even for pure VCL usage it is not sure if all
> usages
> >>>>>>>     can use the baseline when it is used. It looks like it was not
> >> used
> >>>>>>>     in editengine up to now, but maybe in SW. HDU should know.
> >>>>>>>
> >>>>>>>
> >>>>>>> yes,I have tryed so many times but have no result.I think it is not
> >> so
> >>>>>>> much difficult,just like to set the paragraph adjust left.when we
> set
> >>>> it
> >>>>>>> in edit mode it is ok , when in non-edit mode it is still ok.I
> guess
> >> if
> >>>>>>> there are some message should be transfered.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>            Then it would probably also work out-of-the-box in
> >> non-edit
> >>>>>> mode.
> >>>>>>>         Still don't know how to do that. :-(
> >>>>>>>
> >>>>>>>     As described: You have a StartPosition (rInfo.mrStartPos) that
> >>>>>>>     defines where to draw the text. You have the TextAlign. If
> >>>> TextAlign
> >>>>>>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of
> >>>> course)
> >>>>>>>     as if it is ALIGN_BASELINE. This means to add offsets
> vertically
> >>>> for
> >>>>>>>     horizontal text and probably vice-versa. The offsets depend on
> >>>>>>>     FontInfo information which You get with the VCL Font and an
> >>>>>>>     OutputDevice.
> >>>>>>>
> >>>>>>>
> >>>>>>> the font align is not a attribute of font.so it is painted in edit
> >> mode
> >>>>>>> in impleditengine::paint(...)
> >>>>>>> how to draw the alignment is in VCL.(function setalign)
> >>>>>>> I guess if there have a function called like :
> noeditview::paint(...)
> >>>> to
> >>>>>>> call the VCL to draw the alignment?
> >>>>>>>
> >>>>>>>
> >>>>>>> @Herbert
> >>>>>>>
> >>>>>>> Hello , Armin said you maybe know this.I wish you can help me....
> >>>>>>>
> >>>>>>>
> >>>>>>>            Malte.
> >>>>>>>
> >>>>>>>            Armin Le Grand wrote, On 12/07/09 12:33:
> >>>>>>>            > JiaXiang Liu schrieb:
> >>>>>>>            >> Hello Malte,Armin,
> >>>>>>>            >>
> >>>>>>>            >> Just Forward the email:
> >>>>>>>            >>
> >>>>>>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email] <mailto:
> >> [hidden email]
> >>>>>>>            >> <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]> <mailto:
> [hidden email]
> >>>>>>>         <mailto:[hidden email]>>>>
> >>>>>>>
> >>>>>>>            >>
> >>>>>>>            >> Hello Malte,Armin
> >>>>>>>            >>
> >>>>>>>            >> @Malte
> >>>>>>>            >>
> >>>>>>>            >> I test that.It is so difficult.
> >>>>>>>            >>
> >>>>>>>            >> I setted a break point in outliner.cxx
> >>>>>>>            >> aDrawPortionHdl.Call(...).
> >>>>>>>            >> Then I find the many information is collected but not
> >>>>>>>         alignment.
> >>>>>>>            >>
> >>>>>>>            >> How to record the information about the currently
> used
> >>>>>>>         alignment?
> >>>>>>>            >> If I should add a Parameter in this area ?
> >>>>>>>            >>
> >>>>>>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
> >>>>>> nTextLen,
> >>>>>>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
> >>>>>>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
> >>>>>>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph,
> >> bEndOfBullet);
> >>>>>>>            >>
> >>>>>>>            >> BTW,
> >>>>>>>            >> aDrawPortionHdl.Call(...). is called by
> >>>>>>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev,
> >>>> Rectangle
> >>>>>>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
> >>>>>>>            nOrientation )
> >>>>>>>            >>
> >>>>>>>            >> and the pOutDev saved the alignment.
> >>>>>>>            >>
> >>>>>>>            >> This area is also not save paragraph adjust.I am so
> >>>>>> puzzled.
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>            >> @Armin
> >>>>>>>            >>
> >>>>>>>            >> Malte told me that you maybe know that I want to
> know.
> >>>> :-)
> >>>>>>>            >>
> >>>>>>>            > Maybe; i am responsible for DrawingLayer, not for Text
> >>>>>> engines;
> >>>>>>>            i just
> >>>>>>>            > have to work with TextEngines since no one really is
> >>>>>>>         responsible for
> >>>>>>>            > them currently; and Yes, they are somewhat complicated
> >> and
> >>>>>>>         grown
> >>>>>>>            code.
> >>>>>>>            > Malte once was responsible for them, thus in relation
> to
> >>>>>>>            > EditEngine/Outliner he may know more than me. I can
> help
> >>>>>> with
> >>>>>>>            > DrawingLayer and usage of TextParameters in prmitives,
> >>>>>> though.
> >>>>>>>            >>
> >>>>>>>            >> the question is :
> >>>>>>>            >> I am developing a new feature called "fontalign" It
> can
> >>>>>>>         set the
> >>>>>>>            >> text align top,center,baseline and bottom.
> >>>>>>>            >> In Impress,Create a new document, input some words in
> a
> >>>>>>>         text box
> >>>>>>>            >> in normal view.
> >>>>>>>            >> I can set the alignment successful in edit mode.
> >>>>>>>            >>
> >>>>>>>            > Is this already possible in the working/current code?
> >>>>>>>            > If Yes, where can i change those settings?
> >>>>>>>            >
> >>>>>>>            > If no (and it's a completely new feature) it has to be
> >>>>>>>            implemented not
> >>>>>>>            > only inside EditEngine/Outliner, evtl. new items there
> >>>> (not
> >>>>>>>         sure if
> >>>>>>>            > holding font alignment at the font itself is
> sufficient
> >> in
> >>>>>> all
> >>>>>>>            > situations) and in Paint/export/callbacks, but also in
> >>>> text
> >>>>>>>            primities,
> >>>>>>>            > their decompositions, exports and paintings.
> >>>>>>>            > I will set HDU on CC, he may now if holding alignment
> at
> >>>> the
> >>>>>>>            font will
> >>>>>>>            > be enough (if You use that currently).
> >>>>>>>            >
> >>>>>>>            >> but it can not store the setting when left the edit
> >> mode.
> >>>>>>>            >> It is OK in outline view,bucause in outline view it
> is
> >>>> also
> >>>>>> in
> >>>>>>>            >> edit mode.
> >>>>>>>            >>
> >>>>>>>            > That's right, that new feature has to be represented
> in
> >>>>>>>            TextPrimitives
> >>>>>>>            > and used by renderers for it.
> >>>>>>>            >
> >>>>>>>            > In short: DrawPortionInfo is the class which
> >>>>>>>         EditEngine/Outliner
> >>>>>>>            uses in
> >>>>>>>            > callback mode to export it's data (You already located
> >>>>>>>         that). The
> >>>>>>>            > FontAlignment info will be (i guess) at the
> >>>>>>>         DrawPortionInfo::mrFont
> >>>>>>>            > member which is also a 'Font' (the VCL class).
> >>>>>>>            >
> >>>>>>>
> >>>>>>>         yes,it can use the 'Font'(VCL class) member function like:
> >>>>>>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
> >>>>>>>
> >>>>>>>            > Primitives do not use a Font class (they are designed
> to
> >>>> be
> >>>>>>>            transported
> >>>>>>>            > over an API later), so they use
> >>>>>>>            > drawinglayer::primitive2d::FontAttributes where the
> font
> >>>> is
> >>>>>>>            described
> >>>>>>>            > using FamilyName/StyleName/Weight and others. There is
> >> no
> >>>>>>>         alignment
> >>>>>>>            > currently since it was not used yet. FontAttributes is
> >>>> then
> >>>>>>>         used in
> >>>>>>>            > TextSimplePortionPrimitive2D. At render time, the
> helper
> >>>>>>>            > getVclFontFromFontAttributes is used to re-create a
> VCL
> >>>> Font
> >>>>>>>            from the
> >>>>>>>            > FontAttributes, but this is only ONE way to use/render
> >>>> text
> >>>>>>>         in the
> >>>>>>>            > future with primitives; to use VCL again. This will
> >>>>>>>         probably change.
> >>>>>>>            >
> >>>>>>>            > The point is that currently, font alignment is not
> part
> >> of
> >>>>>>>            > FontAttributes and is not transported. As can be seen
> in
> >>>>>>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is
> assumed.
> >> I
> >>>>>>>         would
> >>>>>>>            not add
> >>>>>>>            > a font alignment to FontAttributes to keep it minimal
> >> (and
> >>>>>>>         it is not
> >>>>>>>            > necessary). The TextSimplePortionPrimitive2D (and it's
> >>>>>>>            derivates) are
> >>>>>>>            > low-level text portion holders and also have a
> implicit
> >>>>>>>         TextPosition
> >>>>>>>            > (part of the TextTransform), thus it would be best to
> >>>> adapt
> >>>>>> the
> >>>>>>>            implicit
> >>>>>>>            > TextStart position inside
> >>>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive
> to
> >>>>>>>         always use
> >>>>>>>            > ALIGN_BASELINE.
> >>>>>>>            >
> >>>>>>>            > This is always possible using the FontInfo class and
> the
> >>>>>>>         offsets
> >>>>>>>            of the
> >>>>>>>            > font (bbaseline, height, etc...). This can be done in
> >>>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive,
> >> see
> >>>>>>>         'apply
> >>>>>>>            local
> >>>>>>>            > offset'. rInfo.mrStartPos.Y() would need to be
> >>>>>>>         expanded/adapted when
> >>>>>>>            > text alignment is != ALIGN_BASELINE.
> >>>>>>>            >
> >>>>>>>
> >>>>>>>         If that means I would modify something in this area and do
> >> some
> >>>>>>>         expand?but how?
> >>>>>>>         Still puzzled about that.
> >>>>>>>
> >>>>>>>         Wish you can give me more hint to modify and implement the
> >>>>>>>         feature. :-)
> >>>>>>>
> >>>>>>>         I attach a patch.
> >>>>>>>         The Patch is what I have done,It did not contain XMLOFF
> >>>>>>>         module,outline view and vertical mode.
> >>>>>>>         I have implemented that. only have the non-edit mode
> problem.
> >>>>>>>
> >>>>>>>            > HTH!
> >>>>>>>            >
> >>>>>>>            >> I wish you can help me to solve this problem. Thank
> >> you.
> >>>>>>>            >>
> >>>>>>>            >> With Best Regards,
> >>>>>>>            >> LiuTao
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email] <mailto:
> >> [hidden email]
> >>>>>>>            >> <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]> <mailto:
> [hidden email]
> >>>>>>  >         <mailto:[hidden email]>>>>
> >>>>>>>            >>
> >>>>>>>            >> Hello Malte,
> >>>>>>>            >>
> >>>>>>>            >> Thank you very much for the information.
> >>>>>>>            >>
> >>>>>>>            >> It is too late today fo me.
> >>>>>>>            >>
> >>>>>>>            >> I will test in Monday morning. if it is not ok, I
> will
> >>>> also
> >>>>>>>            >> ask Armin for this.
> >>>>>>>            >>
> >>>>>>>            >> Have a nice weekend.
> >>>>>>>            >>
> >>>>>>>            >> With Best Regards,
> >>>>>>>            >>
> >>>>>>>            >> LiuTao
> >>>>>>>            >>
> >>>>>>>            >> 2009/12/4 Malte Timmermann <[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>>
> >>>>>>>            >> <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>>>>
> >>>>>>>            >>
> >>>>>>>            >> Hi LiuTao,
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
> >>>>>>>            >> > Hello Malte,
> >>>>>>>            >> >
> >>>>>>>            >> > Thank you for your answer.
> >>>>>>>            >> >
> >>>>>>>            >> > What I puzzled now is:
> >>>>>>>            >> >
> >>>>>>>            >> > Why I can not set the new attribute in no edit
> mode?
> >>>>>>>            >>
> >>>>>>>            >> For redrawing the content, the metrics calculated
> from
> >>>> the
> >>>>>>>            >> EditEngine
> >>>>>>>            >> are cached somewhere, and the drawing layer uses
> >>>>>>>            >> DrawText() directly,
> >>>>>>>            >> probably also with ALIGN_BASELINE.
> >>>>>>>            >>
> >>>>>>>            >> >
> >>>>>>>            >> > This is the* biggest problem* now and I want to
> solve
> >>>>>>>            >> it. Can you help
> >>>>>>>            >> > me?you said it may be the drawing layer.but I can
> not
> >>>> do
> >>>>>>>            >> anything about
> >>>>>>>            >> > that.
> >>>>>>>            >>
> >>>>>>>            >> Armin should know more about this...
> >>>>>>>            >>
> >>>>>>>            >> You might figure out by setting a break point in
> >>>>>> outliner.cxx
> >>>>>>>            >> aDrawPortionHdl.Call(...). Then you will at least be
> >> able
> >>>>>>>            >> to see how the
> >>>>>>>            >> information is collected. You need to record the
> >>>>>>>            >> information about the
> >>>>>>>            >> currently used alignment, and also use that
> information
> >>>> at
> >>>>>>>            >> the place
> >>>>>>>            >> where the drawtext() is done.
> >>>>>>>            >>
> >>>>>>>            >> >
> >>>>>>>            >> > Do you know Are there somebody in OpenOffice team
> is
> >>>>>>>            >> developing or will
> >>>>>>>            >> > develop this feature?
> >>>>>>>            >>
> >>>>>>>            >> Don't know / think so.
> >>>>>>>            >>
> >>>>>>>            >> Malte.
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>
> >>>>>>>
> >>>>>>
>  ---------------------------------------------------------------------
> >>>>>>>            >> To unsubscribe, e-mail:
> >>>> [hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>>
> >>>>>>>            >> <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>>>
> >>>>>>>            >> For additional commands, e-mail:
> >>>>>>>            >> [hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>         <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>>
> >>>>>>>            >> <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>
> >>>>>>>            <mailto:[hidden email]
> >>>>>>>         <mailto:[hidden email]>>>
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>            >>
> >>>>>>>            >
> >>>>>>>
> >>>>>>>         With Best Regards,
> >>>>>>>
> >>>>>>>         LiuTao
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>     --
> >>>>>>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
> >>>>>>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
> >>>>>>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
> >>>>>>>     Vorsitzender des Aufsichtsrates: Martin Häring
> >>>>>>>
> >>>>>>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
> >>>>>>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what
> >> You
> >>>>>>>     can do for ooO!
> >>>>>>>
> >>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [hidden email]
> >>>>  For additional commands, e-mail: [hidden email]
> >>>>
> >>>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >
>
> --- /cygdrive/o/ooo320/src.m7/svx/source/editeng/impedit3.cxx   2009-09-25
> 13:22:28.000000000 +0200
> +++ impedit3.cxx    2009-12-11 15:37:47.567886500 +0100
> @@ -2994,6 +2994,40 @@
>                             {
>                                SeekCursor( pPortion->GetNode(), nIndex+1,
> aTmpFont, pOutDev );
>
> +                               // For LineAdjustModes != baseline keep the
> baseline position, need to be restored later
> +                               Point aTmpPosBaseline( aTmpPos );
> +                               static int nTestLineAlignMode = 0;
> +                               if ( nTestLineAlignMode )
> +                               {
> +                                   aTmpFont.SetPhysFont( GetRefDevice() );
> +                                   FormatterFontMetric aFormatterMetrics;
> +                                   RecalcFormatterFontMetrics(
> aFormatterMetrics, aTmpFont );
> +
> +                                   long nAdjust = 0;
> +
> +                                   if ( nTestLineAlignMode == 1 ) // TOP
> +                                   {
> +                                       nAdjust = -pLine->GetMaxAscent();
> // TOP Most
> +                                       nAdjust +=
> aFormatterMetrics.nMaxAscent; // Now we have the baseline
> +                                   }
> +                                   else if ( nTestLineAlignMode == 2 ) //
> BOTTOM
> +                                   {
> +                                       nAdjust = -pLine->GetMaxAscent() +
> pLine->GetHeight(); // BOTTOM most
> +                                       nAdjust -=
> aFormatterMetrics.nMaxDescent; // Now we have the baseline
> +                                   }
> +                                   else if ( nTestLineAlignMode == 3 ) //
> CENTER
> +                                   {
> +                                       long nGlypHeight =
> aFormatterMetrics.nMaxAscent + aFormatterMetrics.nMaxDescent;
> +                                       nAdjust = -pLine->GetMaxAscent() +
> pLine->GetHeight() / 2 - nGlypHeight / 2;
> +                                       nAdjust +=
> aFormatterMetrics.nMaxAscent; // Now we have the baseline
> +                                   }
> +
> +                                   if ( !IsVertical() )
> +                                       aTmpPos.Y() += nAdjust;
> +                                   else
> +                                       aTmpPos.X() += nAdjust;
> +                               }
> +
>                                 BOOL bDrawFrame = FALSE;
>
>                                 if ( ( pTextPortion->GetKind() ==
> PORTIONKIND_FIELD ) && !aTmpFont.IsTransparent() &&
> @@ -3464,6 +3498,7 @@
>                                }
>
>                                 pOutDev->Pop();
> +                                aTmpPos = aTmpPosBaseline;
>
>                                 if ( pTmpDXArray )
>                                    delete[] pTmpDXArray;
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: Questions about Text Align feature.

Malte Timmermann
LiuTao,

as I wrote, my patch works in edit mode as well as in non edit mode.

I have tested it in plane OOo320m7.

Of course you need to remove all your hacks where you manipulate font align.

If you still insist on your font align manipulations and the
introduction of ALIGN_CENTER, go ahead but don't expect me to answer any
future questions on this.

Malte.

JiaXiang Liu wrote, On 12/14/09 09:33:

> Hi Malte,
> 2009/12/11 Malte Timmermann <[hidden email]>
>
>> Hi LiuTao,
>>
>> I couldn't resist to prove that my suggestion would work as expected... ;)
>>
>> The attached patch works in edit mode as well as in paint mode.
>>
>> I only did some quick test and verified the values in the debugger (for
>> lines w/o font changes, nAdjust must always be 0, in all modes).
>>
>> NO manipulations of font align and NO addition to VCL's enum
>> needed/wanted. NO extra work in drawing layer needed, because everything
>> still is baseline.
>>
>> Note: TOP will only look as expected when using upper case (or Chinese)
>> characters. Lower case characters will have some space above.
>>
>> HTH,
>> Malte.
>>
>>
>>
>
> you are right,The patch works in non-edit mode.but it is wrong in edit mode.
> I don't know why. I added some code without your patch in seekcursor
> function like this:
>
>  enum TextAlign at = ALIGN_BASELINE;
>    SvxFontAlign eFontAlign =
> ((SvxFontAlignItem&)pNode->GetContentAttribs().GetItem( EE_PARA_FONTALIGN
> )).GetFontAlign();
>    if (eFontAlign == SVX_FONT_ALIGN_TOP)
>    {
>     at = ALIGN_TOP;
>    }
>    else if (eFontAlign == SVX_FONT_ALIGN_BOTTOM)
>    {
>     at = ALIGN_BOTTOM;
>    }
>    else if (eFontAlign == SVX_FONT_ALIGN_CENTER)
>    {
>     at = ALIGN_CENTER;
>    }
>    else
>    {
>     at = ALIGN_BASELINE;
>    }
>   rFont.SetAlign(at);
>
> it will display right in edit mode but not in non-edit mode.
>
> if I added this code and your patch. it will display right in non-edit mode
> but not in edit mode.
>
> BTW,if I use your patch,first I set alignment as TOP,then I set BOTTOM,It
> will not align BOTTOM immediately,I should exit the edit mode and relocate
> the cursor in edit box.I don't know why.
>
> Another question:
>
> what is the mean of aTmpPos and aRealOutPos mean?
>
> With Best Regards,
> LiuTao
>
>
>> JiaXiang Liu wrote, On 12/10/09 04:28:
>>  > 2009/12/9 Malte Timmermann <[hidden email]>
>>>> JiaXiang Liu wrote, On 12/09/09 12:10:
>>>>  > Hi all
>>>>> 2009/12/9 Malte Timmermann <[hidden email]>
>>>>>
>>>>>> JiaXiang Liu wrote, On 12/09/09 10:24:
>>>>>>> Hello all,
>>>>>>>
>>>>>>> 2009/12/8 Malte Timmermann <[hidden email]>
>>>>>>>
>>>>>>>> I didn't review the patch, but just took a quick look.
>>>>>>>>
>>>>>>>> FontAlign is probably the wrong wording here at all.
>>>>>>>>
>>>>>>>> What you want to achieve is alignment of a text line.
>>>>>>>> You should probably better call it TextLineAlignment or something
>> like
>>>>>>>> that.
>>>>>>>>
>>>>>>>>
>>>>>>> OK,I will modify it.
>>>>>>>
>>>>>>>> Again - all calculations need to be dome in some upper layer, eg.
>>>>>>>> EditEngine. Assuming that we really talk about text lign alignment,
>>>>>>>> there is no need/reason to add a new enum in VCL.
>>>>>>>>
>>>>>>> I only added a item in old enum in VCL. ALIGN_CENTER. you needn't to
>>>> care
>>>>>>> it. assume it is no use.
>>>>>> If it is of no use, it shouldn't be introduced. No one will accept to
>>>>>> have it in VCL then.
>>>>>>
>>>>>>>> As I said, do the implementation in impedit3.cxx.
>>>>>>>> Instead of the suggestion in my first email, don't use
>>>> ALIGN_TOP/BOTTOM
>>>>>>>> at all, but use the font metrics to calculate the correct position
>> so
>>>>>>>> that the normal output with ALIGN_BASELINE works.
>>>>>>>>
>>>>>>>>
>>>>>>> I want to know where(which function?) can I use the font metrics to
>>>>>>> calculate the correct position? and
>>>>>>> how to use the font metrics to calculate?
>>>>>> Look in impedit3.cxx, CreateLines. There you can see how the Ascent
>> and
>>>>>> Descent from the FormatterFontMetric is used.
>>>>>>
>>>>>> Since your alignment doesn't influent the line calculation, you don't
>>>>>> need to use the new attr in CreateLines(), but only in Paint().
>>>>>> In Paint, the x/y position is calculated, and the DrawText with
>>>>>> Align_Baseline is used.
>>>>>>
>>>>>>> why do not use
>>>>>>> ALIGN_TOP/BOTTOM?,the calculation is set in VCL.
>>>>>>> I think it should be called by some functions.
>>>>>> Because you have to adjust x/y in Paint() anyway.
>>>>>> TOP and BOTTOM could help you to not do ascent/descent calculations
>>>>>> yourself, but for CENTER you have to do it anyway.
>>>>>> If you adjust x/y for all cases (top/bottom/center/baseline) to
>>>>>> BASELINE, and don't use ALIGN_TOP/BOTTOM, all the rest should work
>>>>>> automatically. Edit Mode as well as repaint mode.
>>>>>>
>>>>>>
>>>>> what your mean about adjust x/y for all cases
>>>> (top/bottom/center/baseline)
>>>>> to
>>>>> BASELINE?
>>>>>
>>>>> do you mean that I should add some code in paint(...) function like
>> this:
>>>>>      TextAlign eAlign = aTmpFont.GetAlign();
>>>>>      if ( eAlign == ALIGN_TOP )
>>>>>      {
>>>>>       aRealOutPos.Y() =......
>>>>>       aRealOutPos.X() =....
>>>>>      }
>>>>>      if ( eAlign == ALIGN_BOTTOM )
>>>>>      {
>>>>>       aRealOutPos.Y() =......
>>>>>       aRealOutPos.X() =....
>>>>>      }
>>>>>      if ( eAlign == ALIGN_BASELINE )
>>>>>      {
>>>>>       aRealOutPos.Y() =......
>>>>>       aRealOutPos.X() =....
>>>>>      }
>>>>>
>>>> First - use the current para attr, not GetAlign from the Font, because
>>>> you shouldn't manipulate the alignment from the font anymore.
>>>>
>>>> Then look at the loop for ( nLine < nLines ), first switch statement
>>>> covering text/field/hypenator. There you can manipulate y (or x in
>>>> vertical writing mode). aTmpPos, not aRealOutPos.
>>>>
>>>>
>>> Hi, Malte
>>>
>>> Do you mean I should modifiy the code like this:in the loop of (nLine <
>>> nLines )
>>>
>>>      sal_uInt16 nAscent, nDescent;
>>>       FontMetric aMetric( pRefDev->GetFontMetric() );
>>>       nAscent = (sal_uInt16)aMetric.GetAscent();
>>>
>>>      aTmpPos.X() += pLine->GetStartPosX();
>>>      aTmpPos.Y() += nAscent;
>>>      ... ... ...
>>>
>>> I tried but in non-edit mode they can only change the line location but
>> not
>>> the character location.
>>>
>>> It is still can not set align in non-edit mode.
>>>
>>> can you give me some test code to implement the alignment setting in
>>> non-edit mode?I really have no idea.
>>>
>>> LiuTao
>>>
>>>
>>>
>>>> Malte.
>>>>
>>>>> but I think this is still works in edit mode.but not in non-edit mode.
>>>>>
>>>>> so puzzled.I am afraid I will crash. ;-)
>>>>>
>>>>>> Malte.
>>>>>>
>>>>>>> Just like in editmode. in the function
>> implEditEngine::print(...).this
>>>>>>> function call setAlign(ALIGN_TOP),Then the alignment of text is TOP.
>>>>>>> but it is in editmode.
>>>>>>> my problem is : I can not set Align in non-edit mode.
>>>>>>>
>>>>>>>
>>>>>>>> Then all the rest in the drawing layer should work automatically.
>>>>>>>>
>>>>>>>> And wrt. EE_PARA_FONTALIGN: If you decrease EE_ITEMS_START by one,
>> and
>>>>>>>> insert the new ID at the beginning, you don't have to manipulate the
>>>>>>>> Version Maps, IIRC.
>>>>>>>>
>>>>>>>> The SvxFontAlignItem itself looks strange to me: Its bad design to
>> use
>>>> 4
>>>>>>>> bool values instead of an enum, if only one value can be true, and
>>>>>>>> exactly one value needs to be true.
>>>>>>>>
>>>>>>>>
>>>>>>> I will improve.
>>>>>>>
>>>>>>>> Malte.
>>>>>>>>
>>>>>>>> JiaXiang Liu wrote, On 12/08/09 12:07:
>>>>>>>>> Hello All,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2009/12/8 Armin Le Grand <[hidden email]
>>>>>>>>> <mailto:[hidden email]>>
>>>>>>>>>
>>>>>>>>>     JiaXiang Liu schrieb:
>>>>>>>>>
>>>>>>>>>         Hi All,
>>>>>>>>>
>>>>>>>>>         2009/12/7 Malte Timmermann <[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>         <mailto:[hidden email] <mailto:
>>>>>>>> [hidden email]>>>
>>>>>>>>>            Hi LiuTao,
>>>>>>>>>
>>>>>>>>  >            given Armins explanation about the text primitive
>> stuff,
>>>>>> it
>>>>>>>>>         seems it
>>>>>>>>>            would be much easier to do the transformation to
>> baseline
>>>> in
>>>>>>>>>            impedit3.cxx instead of manipulating the font alignment.
>>>>>>>>>
>>>>>>>>>         you mean I can only modify the impedit3.cxx to implement?
>>>>>>>>>
>>>>>>>>>     I do not know impedit3.cxx, but i would do the adaption (as
>>>>>>>>>     described) in
>>>> impTextBreakupHandler::impCreateTextPortionPrimitive.
>>>>>>>>>     Nonetheless, even for pure VCL usage it is not sure if all
>> usages
>>>>>>>>>     can use the baseline when it is used. It looks like it was not
>>>> used
>>>>>>>>>     in editengine up to now, but maybe in SW. HDU should know.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> yes,I have tryed so many times but have no result.I think it is not
>>>> so
>>>>>>>>> much difficult,just like to set the paragraph adjust left.when we
>> set
>>>>>> it
>>>>>>>>> in edit mode it is ok , when in non-edit mode it is still ok.I
>> guess
>>>> if
>>>>>>>>> there are some message should be transfered.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>            Then it would probably also work out-of-the-box in
>>>> non-edit
>>>>>>>> mode.
>>>>>>>>>         Still don't know how to do that. :-(
>>>>>>>>>
>>>>>>>>>     As described: You have a StartPosition (rInfo.mrStartPos) that
>>>>>>>>>     defines where to draw the text. You have the TextAlign. If
>>>>>> TextAlign
>>>>>>>>>     != ALIGN_BASELINE, adapt StartPosition (use a local copy, of
>>>>>> course)
>>>>>>>>>     as if it is ALIGN_BASELINE. This means to add offsets
>> vertically
>>>>>> for
>>>>>>>>>     horizontal text and probably vice-versa. The offsets depend on
>>>>>>>>>     FontInfo information which You get with the VCL Font and an
>>>>>>>>>     OutputDevice.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> the font align is not a attribute of font.so it is painted in edit
>>>> mode
>>>>>>>>> in impleditengine::paint(...)
>>>>>>>>> how to draw the alignment is in VCL.(function setalign)
>>>>>>>>> I guess if there have a function called like :
>> noeditview::paint(...)
>>>>>> to
>>>>>>>>> call the VCL to draw the alignment?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> @Herbert
>>>>>>>>>
>>>>>>>>> Hello , Armin said you maybe know this.I wish you can help me....
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>            Malte.
>>>>>>>>>
>>>>>>>>>            Armin Le Grand wrote, On 12/07/09 12:33:
>>>>>>>>>            > JiaXiang Liu schrieb:
>>>>>>>>>            >> Hello Malte,Armin,
>>>>>>>>>            >>
>>>>>>>>>            >> Just Forward the email:
>>>>>>>>>            >>
>>>>>>>>>            >> 2009/12/7 JiaXiang Liu <[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email] <mailto:
>>>> [hidden email]
>>>>>>>>>            >> <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]> <mailto:
>> [hidden email]
>>>>>>>>>         <mailto:[hidden email]>>>>
>>>>>>>>>
>>>>>>>>>            >>
>>>>>>>>>            >> Hello Malte,Armin
>>>>>>>>>            >>
>>>>>>>>>            >> @Malte
>>>>>>>>>            >>
>>>>>>>>>            >> I test that.It is so difficult.
>>>>>>>>>            >>
>>>>>>>>>            >> I setted a break point in outliner.cxx
>>>>>>>>>            >> aDrawPortionHdl.Call(...).
>>>>>>>>>            >> Then I find the many information is collected but not
>>>>>>>>>         alignment.
>>>>>>>>>            >>
>>>>>>>>>            >> How to record the information about the currently
>> used
>>>>>>>>>         alignment?
>>>>>>>>>            >> If I should add a Parameter in this area ?
>>>>>>>>>            >>
>>>>>>>>>            >> DrawPortionInfo aInfo( rStartPos, rText, nTextStart,
>>>>>>>> nTextLen,
>>>>>>>>>            >> rFont, nPara, nIndex, pDXArray, pWrongSpellVector,
>>>>>>>>>            >> pFieldData, pLocale, rOverlineColor, rTextLineColor,
>>>>>>>>>            >> nRightToLeft, bEndOfLine, bEndOfParagraph,
>>>> bEndOfBullet);
>>>>>>>>>            >>
>>>>>>>>>            >> BTW,
>>>>>>>>>            >> aDrawPortionHdl.Call(...). is called by
>>>>>>>>>            >> void ImpEditEngine::Paint( OutputDevice* pOutDev,
>>>>>> Rectangle
>>>>>>>>>            >> aClipRec, Point aStartPos, sal_Bool bStripOnly, short
>>>>>>>>>            nOrientation )
>>>>>>>>>            >>
>>>>>>>>>            >> and the pOutDev saved the alignment.
>>>>>>>>>            >>
>>>>>>>>>            >> This area is also not save paragraph adjust.I am so
>>>>>>>> puzzled.
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>            >> @Armin
>>>>>>>>>            >>
>>>>>>>>>            >> Malte told me that you maybe know that I want to
>> know.
>>>>>> :-)
>>>>>>>>>            >>
>>>>>>>>>            > Maybe; i am responsible for DrawingLayer, not for Text
>>>>>>>> engines;
>>>>>>>>>            i just
>>>>>>>>>            > have to work with TextEngines since no one really is
>>>>>>>>>         responsible for
>>>>>>>>>            > them currently; and Yes, they are somewhat complicated
>>>> and
>>>>>>>>>         grown
>>>>>>>>>            code.
>>>>>>>>>            > Malte once was responsible for them, thus in relation
>> to
>>>>>>>>>            > EditEngine/Outliner he may know more than me. I can
>> help
>>>>>>>> with
>>>>>>>>>            > DrawingLayer and usage of TextParameters in prmitives,
>>>>>>>> though.
>>>>>>>>>            >>
>>>>>>>>>            >> the question is :
>>>>>>>>>            >> I am developing a new feature called "fontalign" It
>> can
>>>>>>>>>         set the
>>>>>>>>>            >> text align top,center,baseline and bottom.
>>>>>>>>>            >> In Impress,Create a new document, input some words in
>> a
>>>>>>>>>         text box
>>>>>>>>>            >> in normal view.
>>>>>>>>>            >> I can set the alignment successful in edit mode.
>>>>>>>>>            >>
>>>>>>>>>            > Is this already possible in the working/current code?
>>>>>>>>>            > If Yes, where can i change those settings?
>>>>>>>>>            >
>>>>>>>>>            > If no (and it's a completely new feature) it has to be
>>>>>>>>>            implemented not
>>>>>>>>>            > only inside EditEngine/Outliner, evtl. new items there
>>>>>> (not
>>>>>>>>>         sure if
>>>>>>>>>            > holding font alignment at the font itself is
>> sufficient
>>>> in
>>>>>>>> all
>>>>>>>>>            > situations) and in Paint/export/callbacks, but also in
>>>>>> text
>>>>>>>>>            primities,
>>>>>>>>>            > their decompositions, exports and paintings.
>>>>>>>>>            > I will set HDU on CC, he may now if holding alignment
>> at
>>>>>> the
>>>>>>>>>            font will
>>>>>>>>>            > be enough (if You use that currently).
>>>>>>>>>            >
>>>>>>>>>            >> but it can not store the setting when left the edit
>>>> mode.
>>>>>>>>>            >> It is OK in outline view,bucause in outline view it
>> is
>>>>>> also
>>>>>>>> in
>>>>>>>>>            >> edit mode.
>>>>>>>>>            >>
>>>>>>>>>            > That's right, that new feature has to be represented
>> in
>>>>>>>>>            TextPrimitives
>>>>>>>>>            > and used by renderers for it.
>>>>>>>>>            >
>>>>>>>>>            > In short: DrawPortionInfo is the class which
>>>>>>>>>         EditEngine/Outliner
>>>>>>>>>            uses in
>>>>>>>>>            > callback mode to export it's data (You already located
>>>>>>>>>         that). The
>>>>>>>>>            > FontAlignment info will be (i guess) at the
>>>>>>>>>         DrawPortionInfo::mrFont
>>>>>>>>>            > member which is also a 'Font' (the VCL class).
>>>>>>>>>            >
>>>>>>>>>
>>>>>>>>>         yes,it can use the 'Font'(VCL class) member function like:
>>>>>>>>>         (mrFont).SetAlign(ALIGN_TOP/../../..)
>>>>>>>>>
>>>>>>>>>            > Primitives do not use a Font class (they are designed
>> to
>>>>>> be
>>>>>>>>>            transported
>>>>>>>>>            > over an API later), so they use
>>>>>>>>>            > drawinglayer::primitive2d::FontAttributes where the
>> font
>>>>>> is
>>>>>>>>>            described
>>>>>>>>>            > using FamilyName/StyleName/Weight and others. There is
>>>> no
>>>>>>>>>         alignment
>>>>>>>>>            > currently since it was not used yet. FontAttributes is
>>>>>> then
>>>>>>>>>         used in
>>>>>>>>>            > TextSimplePortionPrimitive2D. At render time, the
>> helper
>>>>>>>>>            > getVclFontFromFontAttributes is used to re-create a
>> VCL
>>>>>> Font
>>>>>>>>>            from the
>>>>>>>>>            > FontAttributes, but this is only ONE way to use/render
>>>>>> text
>>>>>>>>>         in the
>>>>>>>>>            > future with primitives; to use VCL again. This will
>>>>>>>>>         probably change.
>>>>>>>>>            >
>>>>>>>>>            > The point is that currently, font alignment is not
>> part
>>>> of
>>>>>>>>>            > FontAttributes and is not transported. As can be seen
>> in
>>>>>>>>>            > getVclFontFromFontAttributes, ALIGN_BASELINE is
>> assumed.
>>>> I
>>>>>>>>>         would
>>>>>>>>>            not add
>>>>>>>>>            > a font alignment to FontAttributes to keep it minimal
>>>> (and
>>>>>>>>>         it is not
>>>>>>>>>            > necessary). The TextSimplePortionPrimitive2D (and it's
>>>>>>>>>            derivates) are
>>>>>>>>>            > low-level text portion holders and also have a
>> implicit
>>>>>>>>>         TextPosition
>>>>>>>>>            > (part of the TextTransform), thus it would be best to
>>>>>> adapt
>>>>>>>> the
>>>>>>>>>            implicit
>>>>>>>>>            > TextStart position inside
>>>>>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive
>> to
>>>>>>>>>         always use
>>>>>>>>>            > ALIGN_BASELINE.
>>>>>>>>>            >
>>>>>>>>>            > This is always possible using the FontInfo class and
>> the
>>>>>>>>>         offsets
>>>>>>>>>            of the
>>>>>>>>>            > font (bbaseline, height, etc...). This can be done in
>>>>>>>>>            > impTextBreakupHandler::impCreateTextPortionPrimitive,
>>>> see
>>>>>>>>>         'apply
>>>>>>>>>            local
>>>>>>>>>            > offset'. rInfo.mrStartPos.Y() would need to be
>>>>>>>>>         expanded/adapted when
>>>>>>>>>            > text alignment is != ALIGN_BASELINE.
>>>>>>>>>            >
>>>>>>>>>
>>>>>>>>>         If that means I would modify something in this area and do
>>>> some
>>>>>>>>>         expand?but how?
>>>>>>>>>         Still puzzled about that.
>>>>>>>>>
>>>>>>>>>         Wish you can give me more hint to modify and implement the
>>>>>>>>>         feature. :-)
>>>>>>>>>
>>>>>>>>>         I attach a patch.
>>>>>>>>>         The Patch is what I have done,It did not contain XMLOFF
>>>>>>>>>         module,outline view and vertical mode.
>>>>>>>>>         I have implemented that. only have the non-edit mode
>> problem.
>>>>>>>>>            > HTH!
>>>>>>>>>            >
>>>>>>>>>            >> I wish you can help me to solve this problem. Thank
>>>> you.
>>>>>>>>>            >>
>>>>>>>>>            >> With Best Regards,
>>>>>>>>>            >> LiuTao
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>            >> 2009/12/4 JiaXiang Liu <[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email] <mailto:
>>>> [hidden email]
>>>>>>>>>            >> <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]> <mailto:
>> [hidden email]
>>>>>>>>  >         <mailto:[hidden email]>>>>
>>>>>>>>>            >>
>>>>>>>>>            >> Hello Malte,
>>>>>>>>>            >>
>>>>>>>>>            >> Thank you very much for the information.
>>>>>>>>>            >>
>>>>>>>>>            >> It is too late today fo me.
>>>>>>>>>            >>
>>>>>>>>>            >> I will test in Monday morning. if it is not ok, I
>> will
>>>>>> also
>>>>>>>>>            >> ask Armin for this.
>>>>>>>>>            >>
>>>>>>>>>            >> Have a nice weekend.
>>>>>>>>>            >>
>>>>>>>>>            >> With Best Regards,
>>>>>>>>>            >>
>>>>>>>>>            >> LiuTao
>>>>>>>>>            >>
>>>>>>>>>            >> 2009/12/4 Malte Timmermann <[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>>
>>>>>>>>>            >> <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>>>>
>>>>>>>>>            >>
>>>>>>>>>            >> Hi LiuTao,
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>            >> JiaXiang Liu wrote, On 12/04/09 10:30:
>>>>>>>>>            >> > Hello Malte,
>>>>>>>>>            >> >
>>>>>>>>>            >> > Thank you for your answer.
>>>>>>>>>            >> >
>>>>>>>>>            >> > What I puzzled now is:
>>>>>>>>>            >> >
>>>>>>>>>            >> > Why I can not set the new attribute in no edit
>> mode?
>>>>>>>>>            >>
>>>>>>>>>            >> For redrawing the content, the metrics calculated
>> from
>>>>>> the
>>>>>>>>>            >> EditEngine
>>>>>>>>>            >> are cached somewhere, and the drawing layer uses
>>>>>>>>>            >> DrawText() directly,
>>>>>>>>>            >> probably also with ALIGN_BASELINE.
>>>>>>>>>            >>
>>>>>>>>>            >> >
>>>>>>>>>            >> > This is the* biggest problem* now and I want to
>> solve
>>>>>>>>>            >> it. Can you help
>>>>>>>>>            >> > me?you said it may be the drawing layer.but I can
>> not
>>>>>> do
>>>>>>>>>            >> anything about
>>>>>>>>>            >> > that.
>>>>>>>>>            >>
>>>>>>>>>            >> Armin should know more about this...
>>>>>>>>>            >>
>>>>>>>>>            >> You might figure out by setting a break point in
>>>>>>>> outliner.cxx
>>>>>>>>>            >> aDrawPortionHdl.Call(...). Then you will at least be
>>>> able
>>>>>>>>>            >> to see how the
>>>>>>>>>            >> information is collected. You need to record the
>>>>>>>>>            >> information about the
>>>>>>>>>            >> currently used alignment, and also use that
>> information
>>>>>> at
>>>>>>>>>            >> the place
>>>>>>>>>            >> where the drawtext() is done.
>>>>>>>>>            >>
>>>>>>>>>            >> >
>>>>>>>>>            >> > Do you know Are there somebody in OpenOffice team
>> is
>>>>>>>>>            >> developing or will
>>>>>>>>>            >> > develop this feature?
>>>>>>>>>            >>
>>>>>>>>>            >> Don't know / think so.
>>>>>>>>>            >>
>>>>>>>>>            >> Malte.
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>
>>>>>>>>>
>>  ---------------------------------------------------------------------
>>>>>>>>>            >> To unsubscribe, e-mail:
>>>>>> [hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>>
>>>>>>>>>            >> <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>>>
>>>>>>>>>            >> For additional commands, e-mail:
>>>>>>>>>            >> [hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>         <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>>
>>>>>>>>>            >> <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>
>>>>>>>>>            <mailto:[hidden email]
>>>>>>>>>         <mailto:[hidden email]>>>
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>            >>
>>>>>>>>>            >
>>>>>>>>>
>>>>>>>>>         With Best Regards,
>>>>>>>>>
>>>>>>>>>         LiuTao
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>     --
>>>>>>>>>     Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
>>>>>>>>>     D-85551 Kirchheim-Heimstetten|Amtsgericht München: HRB 161028
>>>>>>>>>     Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
>>>>>>>>>     Vorsitzender des Aufsichtsrates: Martin Häring
>>>>>>>>>
>>>>>>>>>     Regards, Armin Le Grand (AW)|Don't ask what OOo can do for You,
>>>>>>>>>     Armin.Le.Grand(at)sun.com <http://sun.com/>   |better ask what
>>>> You
>>>>>>>>>     can do for ooO!
>>>>>>>>>
>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>>  For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>> --- /cygdrive/o/ooo320/src.m7/svx/source/editeng/impedit3.cxx   2009-09-25
>> 13:22:28.000000000 +0200
>> +++ impedit3.cxx    2009-12-11 15:37:47.567886500 +0100
>> @@ -2994,6 +2994,40 @@
>>                             {
>>                                SeekCursor( pPortion->GetNode(), nIndex+1,
>> aTmpFont, pOutDev );
>>
>> +                               // For LineAdjustModes != baseline keep the
>> baseline position, need to be restored later
>> +                               Point aTmpPosBaseline( aTmpPos );
>> +                               static int nTestLineAlignMode = 0;
>> +                               if ( nTestLineAlignMode )
>> +                               {
>> +                                   aTmpFont.SetPhysFont( GetRefDevice() );
>> +                                   FormatterFontMetric aFormatterMetrics;
>> +                                   RecalcFormatterFontMetrics(
>> aFormatterMetrics, aTmpFont );
>> +
>> +                                   long nAdjust = 0;
>> +
>> +                                   if ( nTestLineAlignMode == 1 ) // TOP
>> +                                   {
>> +                                       nAdjust = -pLine->GetMaxAscent();
>> // TOP Most
>> +                                       nAdjust +=
>> aFormatterMetrics.nMaxAscent; // Now we have the baseline
>> +                                   }
>> +                                   else if ( nTestLineAlignMode == 2 ) //
>> BOTTOM
>> +                                   {
>> +                                       nAdjust = -pLine->GetMaxAscent() +
>> pLine->GetHeight(); // BOTTOM most
>> +                                       nAdjust -=
>> aFormatterMetrics.nMaxDescent; // Now we have the baseline
>> +                                   }
>> +                                   else if ( nTestLineAlignMode == 3 ) //
>> CENTER
>> +                                   {
>> +                                       long nGlypHeight =
>> aFormatterMetrics.nMaxAscent + aFormatterMetrics.nMaxDescent;
>> +                                       nAdjust = -pLine->GetMaxAscent() +
>> pLine->GetHeight() / 2 - nGlypHeight / 2;
>> +                                       nAdjust +=
>> aFormatterMetrics.nMaxAscent; // Now we have the baseline
>> +                                   }
>> +
>> +                                   if ( !IsVertical() )
>> +                                       aTmpPos.Y() += nAdjust;
>> +                                   else
>> +                                       aTmpPos.X() += nAdjust;
>> +                               }
>> +
>>                                 BOOL bDrawFrame = FALSE;
>>
>>                                 if ( ( pTextPortion->GetKind() ==
>> PORTIONKIND_FIELD ) && !aTmpFont.IsTransparent() &&
>> @@ -3464,6 +3498,7 @@
>>                                }
>>
>>                                 pOutDev->Pop();
>> +                                aTmpPos = aTmpPosBaseline;
>>
>>                                 if ( pTmpDXArray )
>>                                    delete[] pTmpDXArray;
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>

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

12