[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - 4 commits - reportbuilder/java reportdesign/source
Lionel Elie Mamane
lionel at mamane.lu
Fri Dec 12 09:13:17 PST 2014
reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormatValueUtility.java | 3
reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java | 138 +++++++---
reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/VariablesCollection.java | 7
reportdesign/source/filter/xml/xmlExport.cxx | 15 +
4 files changed, 127 insertions(+), 36 deletions(-)
New commits:
commit c582a7b280afc96ecf897356e0885d2bcf289710
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Wed Apr 10 17:49:53 2013 +0200
fdo#67930 work around fdo#68024
don't emit string-value attribute
Change-Id: I3668b88437451523f2b6bb3c2c82e1929f7ba3d8
Reviewed-on: https://gerrit.libreoffice.org/5371
Tested-by: Miklos Vajna <vmiklos at suse.cz>
Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
(cherry picked from commit 76408b0f0d7e91cddb8b056069a2ee547109b156)
(cherry picked from commit 1e10f6d229587ffc2a955c225b489645f8016e23)
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormatValueUtility.java b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormatValueUtility.java
index 8eecd85..d20927f 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormatValueUtility.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormatValueUtility.java
@@ -170,7 +170,8 @@ public class FormatValueUtility
{
variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "string");
}
- variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, STRING_VALUE, String.valueOf(value));
+ // work around fdo#68024
+ //variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, STRING_VALUE, String.valueOf(value));
}
else
{
commit 0efdc1504c3e8cb4644cefadd86bc131e78e4d2e
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Dec 12 17:32:46 2014 +0100
fdo#87044: reportbuilder: Revert "fdo#67930 don't use variables ...
... for formattedtext in header/footer"
This reverts commit b0e3c6b8fa548defd5a3af2b8bf88b0b49589753.
This reverts commit fc92c1abebcfe9b18649d35b76bf22e001e332da.
The other fix from the libreoffice-4-1 branch seems to work better.
Change-Id: Idc5d7543c11dff74977729dab5afd978197dab6a
(cherry picked from commit d6ce95ae2288859fe74d601f1bdaf616ab1ee7f0)
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
index 8c1f619..afd8a59 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
@@ -99,39 +99,30 @@ public class FormattedTextLayoutController
DataSourceException
{
final FormattedTextElement element = (FormattedTextElement) getNode();
- // LEM 20130812 I have absolutely no clue why it wants to go via
- // a variable like that. It complicates things, is fragile
- // (because the variable-set is done in *every* detail section
- // again and again. This in itself is not that bad, but when
- // the detail section is of height zero, the "set" is never done...
- // and this whole schema fails). For now, keep the code in case
- // something break. If we survive the 4.2 cycle (in its entirety)
- // without regression traced to this, then remove it (for 4.4 or
- // something like that).
- // final VariablesCollection vc = getVariablesCollection();
- // if (vc != null)
- // {
- // final String name = vc.addVariable(element);
- // final AttributeMap variablesGet = new AttributeMap();
- // variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
- // Element.TYPE_ATTRIBUTE, "variable-get");
- // variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
- // Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS);
- // variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name);
-
- // final String dataStyleName = computeValueStyle();
- // if (dataStyleName != null)
- // {
- // variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, "data-style-name", dataStyleName);
- // }
-
- // final String valueType = computeValueType();
- // variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE, valueType);
- // target.startElement(variablesGet);
-
- // target.endElement(variablesGet);
- // }
- // else
+ final VariablesCollection vc = getVariablesCollection();
+ if (vc != null)
+ {
+ final String name = vc.addVariable(element);
+ final AttributeMap variablesGet = new AttributeMap();
+ variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
+ Element.TYPE_ATTRIBUTE, "variable-get");
+ variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
+ Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS);
+ variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name);
+
+ final String dataStyleName = computeValueStyle();
+ if (dataStyleName != null)
+ {
+ variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, "data-style-name", dataStyleName);
+ }
+
+ final String valueType = computeValueType();
+ variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE, valueType);
+ target.startElement(variablesGet);
+
+ target.endElement(variablesGet);
+ }
+ else
{
final DataFlags df = FormatValueUtility.computeDataFlag(element, getFlowController());
if (df != null)
commit fdf5b3de7b6907d8fbf1989040066de091bad2ca
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Dec 12 17:47:33 2014 +0100
reportbuilder: re-add numerous bits of dead code needed by bug fix
Change-Id: Ia0a8b8ec3b4684ad6766467c8e3413f91dc8bf67
(cherry picked from commit 458f22c338f39ad777ad3f34b45a81b4eb8dfe8e)
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
index 7f1470e..8c1f619 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
@@ -18,13 +18,18 @@
package org.libreoffice.report.pentaho.layoutprocessor;
+import org.libreoffice.report.OfficeToken;
import org.libreoffice.report.pentaho.OfficeNamespaces;
import org.libreoffice.report.pentaho.model.FormattedTextElement;
+import org.libreoffice.report.pentaho.model.OfficeDocument;
+import org.libreoffice.report.pentaho.model.OfficeStyle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jfree.layouting.util.AttributeMap;
import org.jfree.report.DataFlags;
import org.jfree.report.DataSourceException;
+import org.jfree.report.JFreeReportInfo;
import org.jfree.report.ReportDataFactoryException;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.expressions.FormulaExpression;
@@ -47,6 +52,27 @@ public class FormattedTextLayoutController
private static final Log LOGGER = LogFactory.getLog(FormattedTextLayoutController.class);
+ private VariablesCollection getVariablesCollection()
+ {
+ LayoutController parent = getParent();
+ while (parent != null)
+ {
+ if (parent instanceof OfficeRepeatingStructureLayoutController)
+ {
+ final OfficeRepeatingStructureLayoutController orslc =
+ (OfficeRepeatingStructureLayoutController) parent;
+ if (orslc.isNormalFlowProcessing())
+ {
+ return null;
+ }
+
+ return orslc.getVariablesCollection();
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
@Override
public boolean isValueChanged()
{
@@ -128,6 +154,21 @@ public class FormattedTextLayoutController
return join(getFlowController());
}
+ private OfficeDocument getDocument()
+ {
+ LayoutController parent = getParent();
+ while (parent != null)
+ {
+ final Object node = parent.getNode();
+ if (node instanceof OfficeDocument)
+ {
+ return (OfficeDocument) node;
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
private Element getParentTableCell()
{
LayoutController parent = getParent();
@@ -143,4 +184,44 @@ public class FormattedTextLayoutController
return null;
}
+ private String computeValueStyle()
+ {
+ final Element tce = getParentTableCell();
+ if (tce == null)
+ {
+ return null;
+ }
+
+ final String cellStyleName = (String) tce.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
+ if (cellStyleName == null)
+ {
+ return null;
+ }
+ final OfficeDocument document = getDocument();
+ if (document == null)
+ {
+ return null;
+ }
+
+ final OfficeStyle style = document.getStylesCollection().getStyle("table-cell", cellStyleName);
+ return (String) style.getAttribute(OfficeNamespaces.STYLE_NS, "data-style-name");
+ }
+
+ private String computeValueType()
+ {
+ final Element tce = getParentTableCell();
+ if (tce == null)
+ {
+ // NO particular format means: Fallback to string and hope and pray ..
+ throw new IllegalStateException("A formatted text element must be a child of a Table-Cell.");
+ }
+
+ final String type = (String) tce.getAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE);
+ if (type == null)
+ {
+ LOGGER.error("The Table-Cell does not have a office:value attribute defined. Your content will be messed up.");
+ return "string";
+ }
+ return type;
+ }
}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/VariablesCollection.java b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/VariablesCollection.java
index 961206a..4bb380e 100644
--- a/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/VariablesCollection.java
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/layoutprocessor/VariablesCollection.java
@@ -68,7 +68,12 @@ public class VariablesCollection
return namePrefix;
}
-
+ public String addVariable(final FormattedTextElement element)
+ {
+ variables.add(element);
+ final int size = variables.size();
+ return namePrefix + size;
+ }
public FormattedTextElement[] getVariables()
{
commit a055781f00c7ae6479b3b09d254760734dda839c
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Dec 11 20:09:40 2014 +0100
reportdesign: avoid assertion on duplicate properties ...
... from XMLAutoStylePoolProperties that happens when opening bugdoc
from fdo#87044.
Change-Id: I7002cf5176cd326f57b50fb6030ffb89160c237b
(cherry picked from commit 541800fa17c6a4f9552c76e5290b5011addb1264)
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index 7498267..28942bd 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -1229,7 +1229,20 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted
sal_Int32 nStyleMapIndex = m_xCellStylesExportPropertySetMapper->getPropertySetMapper()->FindEntryIndex( CTF_RPT_NUMBERFORMAT );
addDataStyle(nNumberFormat);
XMLPropertyState aNumberStyleState( nStyleMapIndex, uno::makeAny( getDataStyleName(nNumberFormat) ) );
- aPropertyStates.push_back( aNumberStyleState );
+ auto const iter(::std::find_if(
+ aPropertyStates.begin(), aPropertyStates.end(),
+ [nStyleMapIndex] (XMLPropertyState const& rItem)
+ { return rItem.mnIndex == nStyleMapIndex; } ));
+ if (iter == aPropertyStates.end())
+ {
+ aPropertyStates.push_back( aNumberStyleState );
+ }
+ else
+ { // there is already a property but it has the wrong type
+ // (integer not string); TODO: can we prevent it
+ // getting added earlier?
+ (*iter) = aNumberStyleState;
+ }
}
}
}
More information about the Libreoffice-commits
mailing list