[Libreoffice] [GSOC] Multi line input bar

Anurag Jain anuragjainfzd at gmail.com
Sat May 14 17:00:09 PDT 2011


Hello there,

I've been trying to work on getting the word wrap work in the input
bar of ScTextWnd and come up with following inferences.

In the Paint() function the 'if' part is executed when we the focus is
on input bar after mouse button down event,  which invokes the
StartEditEngine() function creating objects necessary for making use
of the EditEngine class. EditEngine stops as the focus shifts from the
input bar to spreadsheet cells. Incase if we click on the cell and
type the string the else part is executed where the OutputDevice's
DrawText() method is called and EditEngine will not be used.


Since the logic for wrapping the text is to set the paper size using
the function SetPaperSize() in EditEngine which takes width and height
parameters. I tried passing the width and height of the inputbar but
I'm not able to get the proper scroll height offered by it, i.e. after
wrapping the cursor shifts a bit down showing the lower portion of the
upper line and hiding that of the current line. That's what I've
modified, but Couldn't get the desired result.

 Size barSize=GetOutputSizePixel();
        Size pSize  =LogicToPixel(pEditEngine->GetPaperSize());
        long barHeight=barSize.Height();
        long textHeight=LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
        long nDiff = (barHeight - textHeight)/2;

        barSize.Height()+=2*nDiff + barHeight;
        barSize.Width() -= 2*TEXT_STARTPOS-4;
        pEditEngine->SetUpdateMode( false );
        pEditEngine->SetPaperSize( PixelToLogic(Size(barSize)) );

@Kohei as you suggested to use the upper corner of the input bar to
draw the string, which I guess is the same as set by the DrawText in
Paint itself. Also I tried going for using the EditEngine completely
so I replaced everything inside Paint() with this code.

void ScTextWnd::Paint( const Rectangle& rRec )
{
      SetFont( aTextFont );
        long a =    GetOutputSizePixel().Height();
        long b =    GetOutputSizePixel().Width();
        long c =    LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
        long d =    LogicToPixel( Size( 0, GetTextHeight() ) ).Width();
        long nDiff =  GetOutputSizePixel().Height()
                    - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();

        long nStartPos = TEXT_STARTPOS;
        if ( bIsRTL )
        {
            //	right-align
            nStartPos += GetOutputSizePixel().Width() - 2*TEXT_STARTPOS -
                        LogicToPixel( Size( GetTextWidth( aString ), 0
) ).Width();
        }

           StartEditEngine();                             //starting edit engine
            pEditEngine->Draw(this, rRec, Point( nStartPos, nDiff/2 ),false);

}

After doing so, the wrap happens for the first line only without
scroll and things turned messy afterwards

I think I'm missing something here, may be I need to work on some more
methods and manipulate them accordingly. I'd like to have suggestions
about this thing, so that I can improvise more and more.


Thanks and regards.

-- 
Anurag Jain
Final yr B.Tech CSE
SASTRA University
Thanjavur(T.N.)-613402


More information about the LibreOffice mailing list