GSOC ReportBuilder Weekly Update

Michael Weghorn m.weghorn at posteo.de
Wed Jul 2 16:29:51 UTC 2025


On 2025-07-01 23:32, Adam Seskunas wrote:
> 1. A quick look through the list of available functions and it seems 
> that they match up with what is  currently available in ReportBuilder. 
> If there are specific functions missing, they could      potentially be 
> implemented in C++ since they would be few in number.

That sounds promising.
> 
> 2. Using XFunctionAccess abstracts away the function input and output 
> types to uno::Any. It is to be determined whether this will make things 
> easier or harder. My current plan is to get the Formula code as 
> operational as possible, then move on to the next step of implementing 
> the Grouping code, and then come back to this issue.
> 
> 3. A Formula may contain other Formulas, database input or be entirely 
> user defined. This means that a Formula must be parsed and potentially 
> compiled. There is a library for this located here
> https://opengrok.libreoffice.org/xref/core/include/formula/ <https:// 
> opengrok.libreoffice.org/xref/core/include/formula/>
> There is also some Java wrapper code that uses some Pentaho libraries 
> that seems to have roughly the same function, located here
> https://opengrok.libreoffice.org/xref/core/reportbuilder/java/org/ 
> libreoffice/report/pentaho/SOFormulaParser.java? 
> r=bb437029c1e5331bcc3f8fb2fc87837142a52f33 <https:// 
> opengrok.libreoffice.org/xref/core/reportbuilder/java/org/libreoffice/ 
> report/pentaho/SOFormulaParser.java? 
> r=bb437029c1e5331bcc3f8fb2fc87837142a52f33>
> 
> Which leads to my current progress, trying to get Formulas parsed in 
> some meaningful way using the libraries in include/formula. Currently 
> I'm working on getting a working Reference to an XFormulaParser UNO 
> object in reportdesign/source/filter/xmlExport.cxx.
> 
> If anyone knows of any documentation or good examples of using the 
> parser or compiler located in include/formula I would be very 
> appreciative of any information.

The below might not yet be the proper way to do it in the end, but at 
least seems to result in a Reference<XFormulaParser> (just added in a 
"random place" in the mentioned xmlExport.cxx), using the Calc 
implementation (ScFormulaParserObj, not the reportdesign one) in a quick 
test - maybe that helps for experimenting at least.

Maybe others have more suggestions, also for good examples on how to use 
the existing logic implemented in the formula module. (Otherwise, 
reading existing code would be the only suggestion that comes to mind, 
but you're likely aware of that already.)


diff --git a/reportdesign/source/filter/xml/xmlExport.cxx 
b/reportdesign/source/filter/xml/xmlExport.cxx
index 14c416e2333d..ce2651034e17 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -29,6 +29,7 @@
  #include "xmlHelper.hxx"
  #include <strings.hxx>
  #include "xmlPropertyHandler.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
  #include <com/sun/star/util/NumberFormat.hpp>
  #include <com/sun/star/util/MeasureUnit.hpp>
  #include <com/sun/star/report/GroupOn.hpp>
@@ -36,6 +37,7 @@
  #include <com/sun/star/report/XImageControl.hpp>
  #include <com/sun/star/report/XShape.hpp>
  #include <com/sun/star/report/XFunction.hpp>
+#include <com/sun/star/sheet/XFormulaParser.hpp>
  #include <com/sun/star/awt/FontDescriptor.hpp>
  #include <com/sun/star/table/BorderLine2.hpp>
  #include <com/sun/star/table/BorderLineStyle.hpp>
@@ -180,6 +182,18 @@ ORptExport::ORptExport(const Reference< 
XComponentContext >& _rxContext, OUStrin
  : SvXMLExport( _rxContext, implementationName, 
util::MeasureUnit::MM_100TH, XML_REPORT, SvXMLExportFlags::OASIS)
  ,m_bAllreadyFilled(false)
  {
+    // WIP/DEMO: get a XFormulaParser (instance  of Calc's 
ScFormulaParserObj implementation)
+    uno::Reference<lang::XMultiComponentFactory> xFactory = 
_rxContext->getServiceManager();
+    uno::Reference<lang::XMultiServiceFactory> 
xServiceFactory(xFactory, uno::UNO_QUERY);
+    css::uno::Reference< ::css::lang::XComponent > 
xCalcComponent(xServiceFactory->createInstance(
+        u"com.sun.star.comp.Calc.SpreadsheetDocument"_ustr), 
css::uno::UNO_QUERY_THROW);
+    uno::Reference<lang::XMultiServiceFactory> xSM(xCalcComponent, 
css::uno::UNO_QUERY_THROW);
+    Reference<css::sheet::XFormulaParser > 
xParser(xSM->createInstance(u"com.sun.star.sheet.FormulaParser"_ustr), 
UNO_QUERY );
+    assert(xParser.is());
+
+    SAL_WARN("reportdesign", "Have a parser");
+
+
      setExportFlags( SvXMLExportFlags::OASIS | nExportFlag);
  
GetMM100UnitConverter().SetCoreMeasureUnit(css::util::MeasureUnit::MM_100TH);
      GetMM100UnitConverter().SetXMLMeasureUnit(css::util::MeasureUnit::CM);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20250702/3b22a4a4/attachment.sig>


More information about the LibreOffice mailing list