Move string calculations from writer2latex.util.Misc to the separate class writer2latex.util.Calc + add JavaDoc
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@256 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
67ceaae08a
commit
6f46ed3177
19 changed files with 319 additions and 213 deletions
|
@ -39,6 +39,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> This class reads and collects global information about an OOo document.
|
||||
|
|
|
@ -27,6 +27,7 @@ package writer2latex.office;
|
|||
|
||||
//import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Calc;
|
||||
//import org.w3c.dom.NamedNodeMap;
|
||||
//import java.util.Hashtable;
|
||||
import writer2latex.util.Misc;
|
||||
|
@ -139,7 +140,7 @@ public class StyleWithProperties extends OfficeStyle {
|
|||
int nRealIndex = bIsOldProps ? OLDPROPS : nIndex;
|
||||
if (properties[nRealIndex].containsProperty(sName)) {
|
||||
String sValue = properties[nRealIndex].getProperty(sName);
|
||||
return Misc.truncateLength(sValue);
|
||||
return Calc.truncateLength(sValue);
|
||||
}
|
||||
else if (bInherit && getParentName()!=null) {
|
||||
StyleWithProperties parentStyle = (StyleWithProperties) family.getStyle(getParentName());
|
||||
|
@ -206,16 +207,16 @@ public class StyleWithProperties extends OfficeStyle {
|
|||
= (StyleWithProperties) family.getStyle(getParentName());
|
||||
if (parentStyle!=null) {
|
||||
String sParentValue = parentStyle.getAbsoluteProperty(nIndex,sProperty);
|
||||
if (sParentValue!=null) { return Misc.multiply(sValue,sParentValue); }
|
||||
if (sParentValue!=null) { return Calc.multiply(sValue,sParentValue); }
|
||||
}
|
||||
else if (getFamily()!=null && getFamily().getDefaultStyle()!=null) {
|
||||
StyleWithProperties style = (StyleWithProperties) getFamily().getDefaultStyle();
|
||||
String sDefaultValue=(String) style.getProperty(nIndex,sProperty,false);
|
||||
if (sValue !=null) { return Misc.multiply(sValue,sDefaultValue); }
|
||||
if (sValue !=null) { return Calc.multiply(sValue,sDefaultValue); }
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Misc.truncateLength(sValue);
|
||||
return Calc.truncateLength(sValue);
|
||||
}
|
||||
}
|
||||
else if (getParentName()!=null){
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import writer2latex.util.Calc;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
|
@ -137,7 +138,7 @@ public class TableReader {
|
|||
else if (sTableWidth!=null){
|
||||
// Calculate the relative column width from the absolute column widths
|
||||
// This may not add up to exactly 100%, but we will live with that
|
||||
sRelColWidth[nCol] = Misc.divide(sColWidth[nCol], sTableWidth, true);
|
||||
sRelColWidth[nCol] = Calc.divide(sColWidth[nCol], sTableWidth, true);
|
||||
}
|
||||
else {
|
||||
// The table has not width, distribute the columns evenly
|
||||
|
@ -471,7 +472,7 @@ public class TableReader {
|
|||
int nCols = Misc.getPosInteger(cell.getAttribute(XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
|
||||
String sWidth = sColWidth[nCol];
|
||||
for (int i=nCol+1; i<nCol+nCols; i++) {
|
||||
sWidth = Misc.add(sWidth,sColWidth[i]);
|
||||
sWidth = Calc.add(sWidth,sColWidth[i]);
|
||||
}
|
||||
return sWidth;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue