Thursday, October 25, 2018

Proposed XHP Extensions

After significant amount of time spent writing and fixing LibreOffice Help pages (XHP), I came to conclusion that the LibreOffice Help XML (XHP) is a powerful markup but a bit too hard to master for newcomers and easy to have errors and mistakes slipped in files. Some of its complexity are not absolutely required so I wrote a wiki page suggesting the implementation of XHP extensions, aiming to make life simpler for adding and reading XHP contents textually (markup).

Please note that in any case the current markup is affected, so it will preserve the legacy contents as well as the current translations. For example, the new markup for 'tip' paragraph should be

<tip id="123456" localize="true" xml-lang="en-US"></tip>

So it can replace

<paragraph id="123456" localize="true" role="tip" xml-lang="en-US"></paragraph>

Yes, it is a trivial change but I hope it will make reading easier for all.

Handling of the XHP extensions will be in the XSLT transformation and it will be patched accordingly, as well as the DTD, wiki documentation on XHP, and string extractors for Pootle.

The wiki page is

https://wiki.documentfoundation.org/Documentation/Proposed_Extensions_for_XHP

And comments are welcome, do's and dont's, thumbs up or thumbs down.

Happy help writing.

Monday, September 10, 2018

Hovering icons in Help pages

Last week I implemented a feature in our help pages using a modern CSS (Cascade Style Sheets) technique when hovering the mouse pointer on icons displayed in the page: the hovered icon is enlarged twice its size.

Almost every icon in the help pages are sized 0.22 in x 0.22in (~0,5cm x 0,5cm) which is sometimes a bit too small, especially with minimalistic designed icons such as the Colibre icon family. Enlarging the icons helps user to visualize and since it was implemented in CSS, there was no need to change the icons dimensions in the source help pages.

To see it working, please check this page and hover the mouse on icons.

Normal size

Enlarged on hover


Comments and suggestions are welcome.

Happy icon hovering!

Wednesday, August 22, 2018

Compress Images

I just submitted a patch for LibreOffice Help to document the Compress Image feature.

The Compress Image feature is active when an image is selected and you want to change the data size of the image, at the expense of a optional and controllable loss of quality set in a dialog box.

The Compress Image dialog


Compressing is useful if you insert a high resolution image in a document. For example a 4000x4000 pixel image in bitmap format (BMP) is approximately of  48MB size, which can turn you document edition hard in constrained-resources computers. By compressing the image with the right format and quality index you can reduce the size of the picture with no loss of visual quality and have the document file much lighter to edit.

Enjoy!




Tuesday, August 7, 2018

When nothing else works...

Few things in life makes me unhappy than a unoptimal or broken system. When my machine does not work at its best I start to suffer itches and bad mood.

Like many other nerds, I can't avoid to update my laptop operating system with the latest developments. No exceptions with Kubuntu 18.04, where I innocently thought it will fix some nasty bugs of 17.10 I was enduring, notably, a very slow desktop login. I took the radical approach, let's format the root partition and install from scratch.

All backups done, machine reinstalled and bingo! now I can't get a second user session, without disconnecting the first. To put in perspective, what is an operating system, especially linux, that can't get more than one user session active at the time?

As usual, Google here, Google there, countless web pages of irrelevant content... and nothing. Greping the syslog, and the culprit was sddm, the login service of Kubuntu. On Github, a report on the issue, but no further indication that the bug will be fixed someday.

Then a hint on the bug report, and it was related to the dual hybrid graphics architecture of the laptop. In my case, I have an Intel and a Radeon dual graphic laptop. The suggestion was to disable the Radeon chip and work only with the Intel, which is no big deal for me. I was happy to finally fix it.

Too easy huh? Not at all. The laptop began to warm too much, even with no CPU load. It was uncomfortable even to rest the hand on the keyboard.

Another set of Google searches and a page in Ubuntu on hybrid graphics. Joining the two solutions, I enabled back the radeon driver, and enabled the switch to let the kernel manage the second graphic chip, so sddm know about it, even if I don't use it.

Second session working, and laptop in normal temperature.





Sunday, June 24, 2018

The Styles Menu and UI Customization

Yesterday I was reviewing a nice feature implemented by the User Experience Team of LibreOffice about the Style menu in WRITER. Like all help pages I review, I must test and explore the feature, looking to get the benefits but also to note the possible pitfalls.

What caught my attention was a nice combination of LibreOffice UI and menu customization. LibreOffice allows documents to carry the customized user interface menus, toolbars and much more. If you have a document that requires a specific set of commands you can customize the user interface in Tools - Customize and store the user interface in your document. When opening the document in another machine with LibreOffice, the user interface carried by the document is displayed. I used this feature professionally when I had to convert some old Excel macros to LibreOffice and the macros had hundreds of lines just to modify the user interface. I drop these lines, did the changes in UI once and stored in the document.



So I applied the same strategy to the Styles menu. I was glad to see that you can format your document with little amount click or by activating the style menu with the keyboard. All my custom style were in the menu.

Then closed my document and opened a new document. I wanted to apply my custom styles as before but hey... it does not work. The custom styles were just doing nothing.

The trick is to customize the Styles menu with your preferred styles and add them to your document instead of the LibreOffice Writer interface (the default). This detail slipped under my nose.



Lessons learned: If you want a document with custom styles in the Styles menu, create a template with your custom styles and custom user interface and each new document based on the template will have everything set up.

Happy Text Styling !

Wednesday, June 20, 2018

LibreOffice Basic well hidden secrets

Last week I wrote a quite long help page on a poorly known feature of LibreOffice aimed to Basic macro programmers.

LibreOffice - since it was named OpenOffice.org long time ago - carried a set of Basic libraries with no documentation (that I was able to find). The libraries were created to support some important features such as Euro conversion or WikiEditor, but also had a set of modules and macro very handy for the ad-hoc or professional Basic programmer of LibreOffice.

The library is distributed in the LibreOffice installers and can be opened in the LibreOffice Macros container, accessible when opening the Basic IDE.





I got fond of the TOOLS library because it has many handy macros that otherwise requires quite a lot of hard code writing and LibreOffice API knowledge even for simple operations.

Things like getting the last used row in a spreadsheet, get the value of a cell, get the filename out of a long URI are the kind of Function's and Sub's we don't want to write again but use GetLastUsedRow, GetValueofCellbyName or FileNameoutofPath for the task.

To use the LibreOffice Tools library , add the statement

GlobalScope.BasicLibraries.LoadLibrary("Tools")

before the first macro of your module. The help page is already online in 

https://help.libreoffice.org/6.1/en-US/text/sbasic/shared/03/lib_tools.html

Note that not every library is described in details in the set of Help pages but if you feel motivated to peek in the code and write a simple description of the remaining modules and macros, join our documentation team!

Happy macro programming!


Tuesday, May 8, 2018

Bringing Localization to New Help UI

As usual, we have a clear vision of the goal we want to achieve and we know it fits perfectly in the framework available, but sometimes we don't get the smart idea the first time you look at the issue.

It was easy to do the proof of concept for the new help and the style sheet transformations, but in the hurry to get the concept, I used a pair of clutches, or plain bad solution, hoping to be able to come back later.

So time has come to fix the localization of the new Help strings, and to work to use the translation infrastructure of The Document Foundation.

The trick was under my eyes for long time. It is called  document() function in XSLT. With the document() function, I can open an external document, and process it while transforming a XML file.

So why not call an auxiliary help file, with all User Interface strings translated, and use the results inside your main transformation? That is what I did in my latest patch, where I created a help file (browserhelp.xhp) with all terms of my User  Interface.

So here is an excerpt of the document() function usage in the XSLT:

<!-- Strings for the help UI page -->
<xsl:variable name="tmp_href_ui"><xsl:value-of select="concat($urlpre,'text/shared/help/browserhelp.xhp')"/></xsl:variable>


<xsl:variable name="tmp_doc_ui" select="document($tmp_href_ui)"/>
 

<xsl:variable name ="ui_contents"><xsl:apply-templates select="$tmp_doc_ui//variable[@id='contents']"/></xsl:variable>

where I get the right location in tmp_href_ui and the document in tmp_doc_ui, and just after I get the string which identifier is 'contents'.

Later, I used the string 'contents' in the page like

<xsl:value-of select="$ui_contents"/>

 Voilà. And while we are refactoring, I drop most the the other XSLT I was using as clutch (localized.xsl) and exercised some synapses in using the <xsl:for-each> statement to traverse the list of entries in the languages drop-down selector.

Happy translating!

Monday, May 7, 2018

Screenshots in LibreOffice Help

An image worth a thousands words.

Indeed, a textual description of a software feature is too often hard to read, but a simple picture tells much about.

So I patched the LibreOffice Math help pages with screenshots taken by the ScreenShot_Test helper designed by bubli and added them to the help pages. To avoid handling images in too many scattered help files, I collected the in a new help file named screenshots.xhp under /06/ folder of the module. This way,  the images are embedded at the right page and if the screenshot has to be modifies, it is enough to edit the screenshot.xhp file instead of the target help file, which by the way can be multiple.


The Math module has only 8 screenshots under the module/ folder so it makes it easy to evaluate the impact on the size of the data. For all the supported languages (--with-lang=ALL) it adds 19M bytes of images.

While I was addressing this patch I also had to fix a folder naming issue with the helper, which bubli was so kind to approve and also a fix in the XSLT to handle the special case of the default language, en-US.

See it at work: https://help.libreoffice.org/6.1/en-US/text/smath/01/05030000.html?&DbPAR=MATH&System=UNIX



Thursday, April 26, 2018

Reworking Special Tables in New Help.

Continuing the enhancement of the new help pages, I made some changes in the XSL transformation and CSS file to remove some special tables and sections. In this case I used CSS properties available in HTML5, such as display:flex; .

Many tables were used to position elements in the page. Depending on the CSS class of the table, the purpose of the table changes. Here are the predefined roles worked so far:

onecell: As the name says, the xml table has only one cell. The html table was replaced by a div and proper css, followed by a line break.

icontable: this type of table type is constructed when the first tablecell contains an image. The html table replacement is rendered row by row by a wrapping div with display: flex; attribute and internal divs for the remaining cells in the row.

howtoget: The section "How to get" has now a wrapping div with display: flex;  and flex-direction: columns; to stack the heading and contents divs.


Notes, Tips and Warnings: The special paragraphs were mapped into tables and now are mapped in divs with display:flex;

All divs are also associated with named classes, and therefore the CSS can be tweaked independently.

The remaining tables are left as is but will also undergo some cleanup in the near future.

Happy CSS tweaking!




Monday, April 16, 2018

Fixing the switchinline transform for Help

Last week I spend quite amount of time chasing a bug on the new Help XSL transformation (XSLT) to implement the <switchinline> tag of the Help.

The initial idea was to map the <switchinline> into a javascript <switch> which is a straightforward to implement, but since the devil is in the details, I had hard times to realize that I set the output of a XSL transform as html, and when it comes to javascript, assigning a string to the output of the transform brings many issues.

Specifically, I had the issue when approaching an output like

<![CDATA[case "MAC" : text = "]]>\
<xsl:apply-templates/>\
<![CDATA[");]]>

with the output of the <xsl:apply-templates/> call resulting in strings with carriage return, apostrophes and quotes, which can't be put inside a javascript string unless adding a post processing to remove at least the LF and CR characters. So I implemented the <switchinline> inside a outer wrapping <span> and each each <case> content output into an inner <span> tag.

<span hidden="true" id="{$auxID}">\
<xsl:apply-templates/>\
</span>

Then I played with the "hidden" attribute, emulating the javascript "case" with logic inside the wrapping <span>.

Wednesday, April 11, 2018

New LibreOffice Help is also an UNO Extension Package

Today I finished a patch for LibreOffice 6.1 that displays the new Help when it is installed as a UNO extension package.

The patch consider the extension valid when the extension is installed (from  XPackageInformationProvider service) and the extension version matches the product version. When both situations are true, LibreOffice opens the HTML help pages from the extension in your default browser.

The fall-back logic implemented for LibreOffice help activation is now:
  1. The extension help (this one). If not,
  2. The new help in distribution package format (when it becomes available). If not,
  3. The old, ancient local help. If not,
  4. The new online Help.

The extension identifier is a critical parameter and is formed with the <locale> of the user interface. No big deal, the identifier will take the shape of <locale>.help.libreoffice.org.

The extension can be assembled from the offline build of the new help. Pass the param --with-help=html to your autogen.input and build the help. Then zip the files needed for your locale.

Preliminary tests  indicates that the extension will be of size above 12MB per language. It contains all necessary files for autonomous navigation, that means, all internal links are reachable within the pages of the extension. Media files were added too.

For the next LibreOffice 6.1, you can test master build only and download a temporary Help package from
https://helponline.libreoffice.org/Help_en-US_6.1.oxt

Enjoy!







Monday, April 9, 2018

Doubling your notebook clock when compiling LibreOffice

I bought a $15 "BMW"








The "BMW" let me switch the "turbo" mode of my LibreOffice compilation. Normally my Dell Vostro i7 takes 5 or 6 hours compiling LibreOffice with the internal cooling system, too weak to push the heat out of the notebook case.


From a trottled 1,2GHZ in all 4 cores to 2,9 GHz. Now my compilations takes around 2 to 3 hours.
A cheap overclock indeed.


Thursday, April 5, 2018

Direct edition of help files in Master repository: A huge improvement

One on the main issues we have when it comes to add documentation in LibreOffice Help files is the amount of work it takes to update a help file.

Currently, the help author or maintainer has to get a full build of LibreOffice, plus the help submodule and go thru all the steps of a build to display a help page. Although the Help submodule can be build individually, it requires a build of LibreOffice to display the result.

Yesterday our friend buovjaga pointed me that gerrit (https://gerrit.libreoffice.org) has an inline editor of files in git.

This means that edition of textual XML is possible with automatic generation of a patch submitted to gerrit. Therefore, help files can be edited or corrected directly in master and with security and peer review provided by TDF security infra.

Such capacity will be extremely handy for ad-hoc correction of typos and linguistic mistakes we often do in English, as the LibreOffice project is developed by many non-Eglish native speakers.

This capacity will let help writers a direct access to patching without having to download and build LibreOffice and its help. Although the Help XML knowledge is still need to correctly write a help page, some of our skilled NL leaders and translators can now fix typos directly, without passing by the lengthy process of reporting typos.

The gerrit inline editor  will not render the page in html or other rich text display. It is pure textual editing. Rich text rendering is still being in the drawing board of the documentation team developers.

The original documentation of gerrit in-line editing is a work of our collaborator David Ostrovsky and the page is https://gerrit-review.googlesource.com/Documentation/user-inline-edit.html

Update: The complete tutorial on how touse the gerrit editor for libreOffice help pages is in this link: https://wiki.documentfoundation.org/Documentation/GerritEditing

Happy help patching!

Thursday, March 22, 2018

LibreOffice Help pages can now download example files

Following the introduction of You Tube videos in our help pages, I have enabled the capability of storing OpenDocument files in the help system.

Help authors can now add <object> elements with type="application/vnd.oasis.opendocument.*" where the "*" means "text", "spreadsheet", "drawing", "presentation", "math" and "database".

Since our help pages are mostly textual, it is not the best way to show how a given feature works. By having a real opendocument file available to download directly from the Help is a step to see a real example working.

The implementation of a opendocument object is simple. Just insert an <object> tag specifying the file location in the data attribute, the right type as a valid opendocument MIME type and an id that is a random string.
<object data="media/files/scalc/imtrigon.ods"

id="ods_id61521568603544" 

type="application/vnd.oasis.opendocument.spreadsheet" /> 

The result in the rendered page is an icon with a link to donwload the page:

https://help.libreoffice.org/6.1/en-US/text/scalc/01/func_imsin.html

just click on the icon to donwload and open the file. If your browser has the right MIME type settings, it can open the file directly in LibreOffice. The file in this example (imtrigon.ods) is a simple Calc file that can be updated easily with LibreOffice.

The intent of adding multimedia and other objects files is complimentary to the precise but often cumbersome textual description. Both are important in a help page. The textual description is a way to describe how a feature does work and the object file is the implementation of the description. When there is a discrepancy, then either the software has a bug, or the page needs a description update.

The OpenDocuments inserted in the help system work in either offline and online version of the new Help pages.

Happy open documenting!

Wednesday, March 21, 2018

Adding multimedia to the Help pages of LibreOffice

I have patched some pages of LibreOffice Help with a new feature: You Tube videos.

Now help content authors can create a video on the subject and insert in the page. The video can he hosted in an external server such as You Tube (tested) or any other  (not tested).

The implementation was done enabling the <object> tag in the stylesheet transform. In the old and offline the <object> tag was ignored:

<!-- OBJECT (UNUSED) -->
<xsl:template match="object" />


So now I enabled it in online_transform.xsl with

<!-- OBJECT -->
<xsl:template match="object"><xsl:call-template name="insertobject"/></xsl:template>

<xsl:template match="object" mode="embedded"><xsl:call-template name="insertobject"/></xsl:template>

and I handle the <object> in the insertobject template. The template can select what to do with each object type.You can see an example in the following page:

https://help.libreoffice.org/6.1/en-US/text/simpress/main0000.html

The video is added as a companion resource of the hep page, it does not intend to replace the correct writing of the hep pages.

The implications are significant. Not only a video can support the contents of the help page, but also other kind of objects can be  acesssed in the helppages.

For example, a help page on autofilter that has a table with data serving as example, can have an object of type spreadsheet inside the page and the user can click on it to open the example spreadsheet and see the live example.

The implementation of other kind of object is not finished but can be easy. In the case of objects like spreadsheets or text documents, the files can be placed in the media/ folder of the help.

Another implication when adding such richness in our help pages is the maintenance of the multimedia, given the fast improvements of the software.  Special care is needed not to add multimedia that depends on a specific release. Instead, the multimedia in the help should focus more generic use of the modules. For example, a tutorial on how to create a pivot table or to create a table of contents in a text document.

Happy multimedia.






Monday, March 12, 2018

Changing the target path for offline new help

This weekend I worked on a patch to build the new LibreOffice help where the offline version does not have the version number in its location and the online version does.

So I had to define a new param to the XSLTs to distiguish the offline and online paths. This affects the main transformation (online_transform.xsl) but also the get_tree.xsl and get_bookmark.xsl transforms.

Some tweaks on the makefiles, hacking existing ones. Module /sfx2/ had to be adapted to detect the right help available.

With the new patch, the version upgrade of the offline help will overwrite the current version, as it is wiith the old help. We keep the version in the path for the online help because we need to serve more than one version, so the server will have 6.0, 6.1, 6.2 ...

I still  look at the main stylesheet transform (online_transform.xsl) and want to refactor it by removing a lot of cruft from the old help ages.

Happy hacking.

Sunday, March 4, 2018

Resuming blogging on my activities.

Last Friday I patched the new help of LibreOffice to fix a bug about the correct detection of the operating system passes as &System= in the URL.

It affects the usage of <switch> and <switchinline> with consequences on <case> and <caseinline> as well as the <default> and <defaultinline> inside the help pages (the xhp files).

I had to change the default / defaultinline to an new entity named DEFAULTSYS, shown every time the OS is not specified.

The logic is that is there is a specific usage of &System=, then the page must display the options of the parameter specified by &System=. It must also hide all option of DEFAULTSYS in the page.

If the page has option for <case select='sys'> but the OS passed is not an option of <case>/<caseiniline> then the DEFAULTSYS options must be shown.

For example, the URL pass &System=WIN and the options are for UNIX, then the contents displyed must be DEFAULTSYS.

Patch is: https://cgit.freedesktop.org/libreoffice/help/commit/?id=13098ccef163c813ae3e196511f44a16a6e73fdd