7 Temmuz 2021 Çarşamba

Long Class Names Not Seen Bug Fix in LibreOffice

              

 I will talk about this bug that I solved in this blog.

First of all, we need to understand what the error is and see it by trying it. To see the error in Bugzilla, I followed the steps they suggested:

        Steps to reproduce:

                1. Open writer

                2. Insert an image

                3. Open the UNO object inspector

                4. Click on 'Current Selectio


However, it should be noted that since this is a gen bug, we must run LibreOffice with this command:

SAL_USE_VCLPLUGIN=gen gdb --args ./instdir/program/soffice.bin

When you select Writer, click Tools and click Devtools from the pop-up menu, a panel will open.


As seen here, the names written in the Class name field do not appear properly for some class names and are cut off. That's our problem!

In order to solve this problem, I first installed Glade on my computer. It is a RAD tool developed to provide quick and easy interfaces for the Glade GTK+ toolkit. It can also enable us to solve interface problems easily. 

I found the file that you need to make changes to see the interface and opened it with Glade.


 

Here I found the field I need to change as class_name_value_id.  The default version of the Horizontal setting on the right was Start. When I set this setting to Fill, I could see the class names exactly, but although a longer class name could come, I resorted to a different way to find a more precise solution.
First of all, it was necessary to find out how this field was determined in the source code and where it was. So I researched this with OpenGrok.


Here, the set_size_request(int nWidth, int nHeight) function takes the height and width size of this field. As I continue to research the parameters and values ​​that this function takes, I found that the file I need to work on is libreoffice/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx.

After realizing that the set_label() part is decisive here, I looked at its parameters and learned the return type using SAL_DEBUG to find out what kind of return the height parameter makes.
For the solution, it is necessary to take the character number of the class names and find the pixel that falls into only one character and multiply it with it.
 
In LibreOffice, I found that the function that gives the approximate pixel value is get_approximate_digit_with().  When I wrote this code, I observed that there was another small cut in the class names. Since the get_approximate_digit_with() function calculates the approximate pixel value, there could be deviations.

    Getting length of ClassName
    
sal_Int32 nStrLen = aImplementationName.getLength();
    
    The approximate number of pixels
   
 sal_Int32 nDigitWidtH= mpObjectInspectorWidgets->mpClassNameLabel >get_approximate_digit_width();

    get_about_digit_width() returns an approximate value. To always see the full class name (nStrLen+2)
    It is multiplied by the approximate pixel value by adding 2 to the class name length.
   
mpObjectInspectorWidgets->mpClassNameLabel->set_size_request((nStrLen + 2) * nDigitWidth, -1);


    now looked like this:




After the patch I sent and a test I solved, I solved my first bug.

I would like to thank Gülşah Köse for guiding and supporting me throughout the process of patch and test solution as well as error resolution. As always, I would like to thank Necdet Yücel, who taught and guided me through many things throughout my undergraduate life.