[Libreoffice-commits] core.git: 3 commits - dbaccess/source reportbuilder/java reportdesign/source sal/inc xmloff/inc xmloff/source

Lionel Elie Mamane lionel at mamane.lu
Tue Mar 12 10:19:16 PDT 2013


 dbaccess/source/core/dataaccess/ModelImpl.cxx                                           |    4 -
 reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java                    |    9 +-
 reportbuilder/java/org/libreoffice/report/pentaho/PentahoReportJob.java                 |   40 +++++++++-
 reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroup.java                |   11 ++
 reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroupInstanceSection.java |   13 +++
 reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java      |    5 +
 reportdesign/source/filter/xml/xmlEnums.hxx                                             |    1 
 reportdesign/source/filter/xml/xmlExport.cxx                                            |   15 +++
 reportdesign/source/filter/xml/xmlfilter.cxx                                            |    1 
 sal/inc/rtl/ustring.h                                                                   |    2 
 xmloff/inc/xmloff/xmltoken.hxx                                                          |    1 
 xmloff/source/core/xmltoken.cxx                                                         |    1 
 12 files changed, 88 insertions(+), 15 deletions(-)

New commits:
commit 404e5097a86325d36b17731fad568ca37839a67a
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Mar 12 18:06:31 2013 +0100

    janitorial: typo in comment
    
    Change-Id: Idd62c2768a03f7aab8ff11165425f8c383653f38

diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h
index 23ea47a..ba19b83 100644
--- a/sal/inc/rtl/ustring.h
+++ b/sal/inc/rtl/ustring.h
@@ -1754,7 +1754,7 @@ SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
     the number of the token to return, starting at index.
 
     @param cTok
-    the character that seperates the tokens.
+    the character that separates the tokens.
 
     @param idx
     the position at which searching for the token starts.  Must not be greater
commit 4178806bb010129f3b13b62825476666fe48ddcd
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Mar 12 17:57:57 2013 +0100

    reportbuilder: make "Group on" not-"Each Value" actually work
    
    Change-Id: Id5d73f9aac48ebfb6987e5bf0df37e62f1817bdc

diff --git a/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java b/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java
index a22be04..24e1fe1 100644
--- a/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java
+++ b/reportbuilder/java/org/libreoffice/report/SDBCReportDataFactory.java
@@ -139,6 +139,7 @@ public class SDBCReportDataFactory implements DataSourceFactory
     private static final Log LOGGER = LogFactory.getLog(SDBCReportDataFactory.class);
     public static final String COMMAND_TYPE = "command-type";
     public static final String ESCAPE_PROCESSING = "escape-processing";
+    public static final String SORT_EXPRESSIONS = "sort-expressions";
     public static final String GROUP_EXPRESSIONS = "group-expressions";
     public static final String MASTER_VALUES = "master-values";
     public static final String MASTER_COLUMNS = "master-columns";
@@ -229,10 +230,10 @@ public class SDBCReportDataFactory implements DataSourceFactory
         }
     }
 
-    private String getOrderStatement(final int commandType, final String command, final List groupExpressions)
+    private String getOrderStatement(final int commandType, final String command, final List sortExpressions)
     {
         final StringBuffer order = new StringBuffer();
-        final int count = groupExpressions.size();
+        final int count = sortExpressions.size();
         if (count != 0)
         {
             try
@@ -244,7 +245,7 @@ public class SDBCReportDataFactory implements DataSourceFactory
                 {
                     for (int i = 0; i < count; i++)
                     {
-                        final Object[] pair = (Object[]) groupExpressions.get(i);
+                        final Object[] pair = (Object[]) sortExpressions.get(i);
                         String expression = (String) pair[0];
 
                         if (!expression.startsWith(quote) && columns.hasByName(expression))
@@ -533,7 +534,7 @@ public class SDBCReportDataFactory implements DataSourceFactory
             WrappedTargetException,
             NoSuchElementException
     {
-        final StringBuffer order = new StringBuffer(getOrderStatement(commandType, command, (ArrayList<?>) parameters.get(GROUP_EXPRESSIONS)));
+        final StringBuffer order = new StringBuffer(getOrderStatement(commandType, command, (ArrayList<?>) parameters.get(SORT_EXPRESSIONS)));
         if (order.length() > 0 && commandType != CommandType.TABLE)
         {
             String statement = command;
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/PentahoReportJob.java b/reportbuilder/java/org/libreoffice/report/pentaho/PentahoReportJob.java
index e1cf4f3..fc8b4ff 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/PentahoReportJob.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/PentahoReportJob.java
@@ -311,6 +311,37 @@ public class PentahoReportJob implements ReportJob
         }
     }
 
+    private void collectSortExpressions(final Node[] nodes, final List<Object[]> expressions, final FormulaParser parser, final Expression reportFunctions[])
+    {
+        for (int i = 0; i < nodes.length; i++)
+        {
+            final Node node = nodes[i];
+            if (node instanceof OfficeGroup)
+            {
+                final OfficeGroup group = (OfficeGroup) node;
+                final String exp = group.getSortingExpression();
+                if (exp == null)
+                {
+                    continue;
+                }
+
+                final Object[] pair = new Object[2];
+                pair[0] = exp;
+                pair[1] = group.getAttribute(OfficeNamespaces.OOREPORT_NS, "sort-ascending");
+                expressions.add(pair);
+            }
+            else if (node instanceof OfficeDetailSection)
+            {
+                return;
+            }
+            if (node instanceof Section)
+            {
+                final Section section = (Section) node;
+                collectSortExpressions(section.getNodeArray(), expressions, parser, reportFunctions);
+            }
+        }
+    }
+
     private void setMetaDataProperties(DefaultReportJob job)
     {
         job.getConfiguration().setConfigProperty(ReportEngineParameterNames.AUTHOR, (String) jobProperties.getProperty(ReportEngineParameterNames.AUTHOR));
@@ -343,11 +374,14 @@ public class PentahoReportJob implements ReportJob
             final Node[] nodes = report.getNodeArray();
 
             final FormulaParser parser = new FormulaParser();
-            final ArrayList<Object[]> expressions = new ArrayList<Object[]>();
             final OfficeReport officeReport = (OfficeReport) ((Section) nodes[0]).getNode(0);
             final Section reportBody = (Section) officeReport.getBodySection();
-            collectGroupExpressions(reportBody.getNodeArray(), expressions, parser, officeReport.getExpressions());
-            parameters.put(SDBCReportDataFactory.GROUP_EXPRESSIONS, expressions);
+            final ArrayList<Object[]> sortExpressions = new ArrayList<Object[]>();
+            collectSortExpressions(reportBody.getNodeArray(), sortExpressions, parser, officeReport.getExpressions());
+            parameters.put(SDBCReportDataFactory.SORT_EXPRESSIONS, sortExpressions);
+            final ArrayList<Object[]> groupExpressions = new ArrayList<Object[]>();
+            collectGroupExpressions(reportBody.getNodeArray(), groupExpressions, parser, officeReport.getExpressions());
+            parameters.put(SDBCReportDataFactory.GROUP_EXPRESSIONS, groupExpressions);
             final String command = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, "command");
             final String commandType = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, SDBCReportDataFactory.COMMAND_TYPE);
             final String escapeProcessing = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, SDBCReportDataFactory.ESCAPE_PROCESSING);
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroup.java b/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroup.java
index b10aab1..79ea585 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroup.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroup.java
@@ -81,4 +81,15 @@ public class OfficeGroup extends Section
         }
         return instanceSection.getGroupingExpression();
     }
+
+    public String getSortingExpression()
+    {
+        final OfficeGroupInstanceSection instanceSection =
+                (OfficeGroupInstanceSection) findFirstChild(JFreeReportInfo.REPORT_NAMESPACE, "group-instance");
+        if (instanceSection == null)
+        {
+            return null;
+        }
+        return instanceSection.getSortingExpression();
+    }
 }
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroupInstanceSection.java b/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroupInstanceSection.java
index a9adad3..cd7ed7b 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroupInstanceSection.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/model/OfficeGroupInstanceSection.java
@@ -27,7 +27,20 @@ import org.jfree.report.structure.Group;
 public class OfficeGroupInstanceSection extends Group
 {
 
+    String sortingExpression;
+
     public OfficeGroupInstanceSection()
     {
     }
+
+    public void setSortingExpression(String s)
+    {
+        sortingExpression=s;
+    }
+
+    public String getSortingExpression()
+    {
+        return sortingExpression;
+    }
+
 }
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java
index 22def36..7843d8a 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java
@@ -77,6 +77,11 @@ public class GroupReadHandler extends ElementReadHandler
             function.setFormula(groupExpr);
             groupInstanceSection.setGroupingExpression(function);
         }
+        final String sortExpr  = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "sort-expression");
+        if (sortExpr != null && !"".equals(sortExpr))
+        {
+            groupInstanceSection.setSortingExpression(sortExpr);
+        }
     }
 
     /**
diff --git a/reportdesign/source/filter/xml/xmlEnums.hxx b/reportdesign/source/filter/xml/xmlEnums.hxx
index 53df992..1d98a4d 100644
--- a/reportdesign/source/filter/xml/xmlEnums.hxx
+++ b/reportdesign/source/filter/xml/xmlEnums.hxx
@@ -60,6 +60,7 @@ namespace rptxml
         XML_TOK_START_NEW_COLUMN            ,
         XML_TOK_RESET_PAGE_NUMBER           ,
         XML_TOK_PRINT_HEADER_ON_EACH_PAGE   ,
+        XML_TOK_SORT_EXPRESSION             ,
         XML_TOK_GROUP_EXPRESSION            ,
         XML_TOK_GROUP_HEADER                ,
         XML_TOK_GROUP_GROUP                 ,
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index ba25f5e..781c713 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -1078,7 +1078,8 @@ sal_Bool ORptExport::exportGroup(const Reference<XReportDefinition>& _xReportDef
                     if ( xGroup->getResetPageNumber() )
                         AddAttribute(XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER, XML_TRUE );
 
-                    ::rtl::OUString sExpression = xGroup->getExpression();
+                    const ::rtl::OUString sField = xGroup->getExpression();
+                    ::rtl::OUString sExpression  = sField;
                     if ( !sExpression.isEmpty() )
                     {
                         static ::rtl::OUString s_sQuote(RTL_CONSTASCII_USTRINGPARAM("\"\""));
@@ -1097,6 +1098,7 @@ sal_Bool ORptExport::exportGroup(const Reference<XReportDefinition>& _xReportDef
                         sFormula += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\")"));
                         sExpression = sFormula;
                     }
+                    AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_EXPRESSION, sField);
                     AddAttribute(XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION,sExpression);
                     sal_Int16 nRet = xGroup->getKeepTogether();
                     ::rtl::OUStringBuffer sValue;
@@ -1525,6 +1527,7 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG
                 ::rtl::OUString sFunction,sPrefix,sPostfix;
                 ::rtl::OUString sExpression = xGroup->getExpression();
                 ::rtl::OUString sFunctionName;
+                ::rtl::OUString sInitialFormula;
                 switch(nGroupOn)
                 {
                     case report::GroupOn::PREFIX_CHARACTERS:
@@ -1558,14 +1561,18 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG
                         {
                             sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT"));
                             uno::Reference< XFunction> xCountFunction = xFunctions->createFunction();
-                            xCountFunction->setInitialFormula(beans::Optional< ::rtl::OUString>(sal_True,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:1"))));
+                            xCountFunction->setInitialFormula(beans::Optional< ::rtl::OUString>(sal_True,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:0"))));
                             ::rtl::OUString sCountName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_count_")) + sExpression;
                             xCountFunction->setName(sCountName);
                             xCountFunction->setFormula(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[")) + sCountName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("] + 1")));
                             exportFunction(xCountFunction);
                             sExpression = sCountName;
-                            sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" / ")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval());
+                            // The reference to sCountName in the formula of sFunctionName refers to the *old* value
+                            // so we need to expand the the formula of sCountName
+                            sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" + 1) / ")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval());
                             sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression;
+                            sFunction = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("("));
+                            sInitialFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:0"));
                         }
                         break;
                     default:
@@ -1580,6 +1587,8 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG
                         sFunctionName = sFunctionName.replace(pReplaceChars[j],'_');
 
                     xFunction->setName(sFunctionName);
+                    if ( !sInitialFormula.isEmpty() )
+                        xFunction->setInitialFormula(beans::Optional< ::rtl::OUString>(sal_True, sInitialFormula));
                     sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFunction;
                     sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("(["));
                     sFunction += sExpression;
diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx
index 22fbd15..71c8e67 100644
--- a/reportdesign/source/filter/xml/xmlfilter.cxx
+++ b/reportdesign/source/filter/xml/xmlfilter.cxx
@@ -797,6 +797,7 @@ const SvXMLTokenMap& ORptFilter::GetGroupElemTokenMap() const
             { XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER           ,   XML_TOK_RESET_PAGE_NUMBER           },
             { XML_NAMESPACE_REPORT, XML_PRINT_HEADER_ON_EACH_PAGE   ,   XML_TOK_PRINT_HEADER_ON_EACH_PAGE   },
             { XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER           ,   XML_TOK_RESET_PAGE_NUMBER           },
+            { XML_NAMESPACE_REPORT, XML_SORT_EXPRESSION             ,   XML_TOK_SORT_EXPRESSION             },
             { XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION            ,   XML_TOK_GROUP_EXPRESSION            },
             { XML_NAMESPACE_REPORT, XML_GROUP_HEADER                ,   XML_TOK_GROUP_HEADER                },
             { XML_NAMESPACE_REPORT, XML_GROUP                       ,   XML_TOK_GROUP_GROUP                 },
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index e7e886e..605256f 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -2941,6 +2941,7 @@ namespace xmloff { namespace token {
         XML_START_NEW_COLUMN            ,
         XML_RESET_PAGE_NUMBER           ,
         XML_PRINT_HEADER_ON_EACH_PAGE   ,
+        XML_SORT_EXPRESSION             ,
         XML_GROUP_EXPRESSION            ,
         XML_GROUP_HEADER                ,
         XML_GROUP_FOOTER                ,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index afd52ba..46e3a4f 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -2937,6 +2937,7 @@ namespace xmloff { namespace token {
         TOKEN( "start-new-column",       XML_START_NEW_COLUMN            ),
         TOKEN( "reset-page-number",       XML_RESET_PAGE_NUMBER          ),
         TOKEN( "print-header-on-each-page",       XML_PRINT_HEADER_ON_EACH_PAGE  ),
+        TOKEN( "sort-expression",        XML_SORT_EXPRESSION             ),
         TOKEN( "group-expression",       XML_GROUP_EXPRESSION            ),
         TOKEN( "group-header",       XML_GROUP_HEADER                ),
         TOKEN( "group-footer",       XML_GROUP_FOOTER                ),
commit 36caac0e029a3caf50cb27af339efd69008d414e
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Mar 12 17:48:27 2013 +0100

    There's no reason for these defaults in one constructor but not the other
    
    Change-Id: I62e9351a21b0519a3ef70c328f33e1b7f7427926

diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 2d77fc1..62c5713 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -427,11 +427,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >&
             ,m_pSharedConnectionManager(NULL)
             ,m_nControllerLockCount(0)
 {
-    // some kind of default
     DBG_CTOR(ODatabaseModelImpl,NULL);
-    m_sConnectURL = "jdbc:";
-    m_aTableFilter.realloc(1);
-    m_aTableFilter[0] = "%";
     impl_construct_nothrow();
 }
 


More information about the Libreoffice-commits mailing list