[ooo-build-commit] extensions/watchwindow

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Jan 22 18:24:51 PST 2010


 extensions/watchwindow/watchwindow-variable-formula-syntax.diff |   65 +++++++---
 1 file changed, 48 insertions(+), 17 deletions(-)

New commits:
commit 7e07e18f05b565a19885b6e16d5d658db426a0ec
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Jan 22 21:22:20 2010 -0500

    Make the displayed formula strings follow the current formula syntax.
    
    This concludes my hack on this nice WatchWindow extension from KAMI.
    
    * extensions/watchwindow/watchwindow-variable-formula-syntax.diff:

diff --git a/extensions/watchwindow/watchwindow-variable-formula-syntax.diff b/extensions/watchwindow/watchwindow-variable-formula-syntax.diff
index 006b5de..28a79dc 100644
--- a/extensions/watchwindow/watchwindow-variable-formula-syntax.diff
+++ b/extensions/watchwindow/watchwindow-variable-formula-syntax.diff
@@ -1,5 +1,5 @@
 diff --git src/org/openoffice/extensions/watchwindow/Controller.java src/org/openoffice/extensions/watchwindow/Controller.java
-index c3da795..8f0513f 100644
+index c3da795..e000b43 100644
 --- src/org/openoffice/extensions/watchwindow/Controller.java
 +++ src/org/openoffice/extensions/watchwindow/Controller.java
 @@ -1,16 +1,24 @@
@@ -72,13 +72,25 @@ index c3da795..8f0513f 100644
      public Locale getLocation() { 
          Locale locale = null;
          try {
-@@ -114,8 +142,44 @@ public class Controller {
+@@ -114,23 +142,44 @@ public class Controller {
      public String getSheetName(XSpreadsheet xSheet){
          XNamed xNamed = (XNamed)UnoRuntime.queryInterface(XNamed.class, xSheet);
          return xNamed.getName();
 -    } 
 -    
-+    }
+-    public String getCellNameWithDollars(XCell xCell) throws Exception{
+-        String cellName ="";
+-        Point address = getCellAdress(xCell);
+-        cellName = "$" + convertColumnIndexToName(address.X);
+-        cellName += "$" + (address.Y+1);
+-        return cellName;
+     }
+-    
+-    public Point getCellAdress(XCell xCell) throws Exception {
+-        XCellAddressable xCellAddress =  (XCellAddressable)UnoRuntime.queryInterface(XCellAddressable.class, xCell);
+-        CellAddress aAddress = xCellAddress.getCellAddress();
+-        Point point =  new Point(aAddress.Column,aAddress.Row);
+-        return point;
 +
 +    private FormulaToken getRefToken(XCell xCell) {
 +        
@@ -94,7 +106,8 @@ index c3da795..8f0513f 100644
 +        token.OpCode = 0;
 +        token.Data = ref;
 +        return token;
-+    }
+     }
+-    
 +
 +    private XSpreadsheet getSheetByIndex(int index) {
 +        if (m_xDocument == null)
@@ -115,11 +128,11 @@ index c3da795..8f0513f 100644
 +        }
 +        return null;
 +    }  
-+
-     public String getCellNameWithDollars(XCell xCell) throws Exception{
-         String cellName ="";
-         Point address = getCellAdress(xCell);
-@@ -170,68 +234,38 @@ public class Controller {
++        
+     public String convertColumnIndexToName(int columnPos) throws IndexOutOfBoundsException, WrappedTargetException, IndexOutOfBoundsException {   
+         XCellRange xCellRange = getActiveSheet().getCellRangeByPosition(columnPos, 0, columnPos, 0);           
+         XColumnRowRange xColumnRowRange =(XColumnRowRange)UnoRuntime.queryInterface(XColumnRowRange.class, xCellRange);
+@@ -170,68 +219,38 @@ public class Controller {
      }
      
      public boolean isValidSelectedName(String selectAreaName){
@@ -216,7 +229,7 @@ index c3da795..8f0513f 100644
      }
      
      public void removeCell()  {
-@@ -248,15 +282,16 @@ public class Controller {
+@@ -248,15 +267,16 @@ public class Controller {
      }
  
      public void done(String selectAreaName) throws Exception {
@@ -279,10 +292,10 @@ index 230919b..d4a6ca6 100644
          }
      }
 diff --git src/org/openoffice/extensions/watchwindow/WatchedCell.java src/org/openoffice/extensions/watchwindow/WatchedCell.java
-index 1a98417..7ef7ae1 100644
+index 1a98417..fd39236 100644
 --- src/org/openoffice/extensions/watchwindow/WatchedCell.java
 +++ src/org/openoffice/extensions/watchwindow/WatchedCell.java
-@@ -6,10 +6,15 @@ import com.sun.star.document.XEventListener;
+@@ -6,10 +6,16 @@ import com.sun.star.document.XEventListener;
  import com.sun.star.frame.XModel;
  import com.sun.star.lang.EventObject;
  import com.sun.star.lang.IndexOutOfBoundsException;
@@ -291,6 +304,7 @@ index 1a98417..7ef7ae1 100644
 +import com.sun.star.sheet.SingleReference;
  import com.sun.star.sheet.XCellRangeAddressable;
 +import com.sun.star.sheet.XFormulaParser;
++import com.sun.star.sheet.XFormulaTokens;
  import com.sun.star.sheet.XSpreadsheet;
  import com.sun.star.sheet.XSpreadsheetDocument;
  import com.sun.star.sheet.XSpreadsheetView;
@@ -298,7 +312,7 @@ index 1a98417..7ef7ae1 100644
  import com.sun.star.table.CellRangeAddress;
  import com.sun.star.table.XCell;
  import com.sun.star.table.XCellRange;
-@@ -22,6 +27,7 @@ import com.sun.star.util.XModifyListener;
+@@ -22,6 +28,7 @@ import com.sun.star.util.XModifyListener;
  public class WatchedCell implements XModifyListener, XEventListener{
  
      private Controller           m_Controller              = null;
@@ -306,7 +320,7 @@ index 1a98417..7ef7ae1 100644
      private String               m_sheetName               = "";
      private String               m_cellName                = "";
      private String               m_value                   = "";
-@@ -36,12 +42,12 @@ public class WatchedCell implements XModifyListener, XEventListener{
+@@ -36,12 +43,12 @@ public class WatchedCell implements XModifyListener, XEventListener{
      private XEventBroadcaster    m_xEventBroadcaster       = null;
      private String               m_modifySheetName         = "";
     
@@ -321,7 +335,7 @@ index 1a98417..7ef7ae1 100644
              m_num = numer;
              init();
              adjustCounter();
-@@ -52,10 +58,8 @@ public class WatchedCell implements XModifyListener, XEventListener{
+@@ -52,10 +59,8 @@ public class WatchedCell implements XModifyListener, XEventListener{
      }
      
      public void init() throws IndexOutOfBoundsException {
@@ -334,7 +348,7 @@ index 1a98417..7ef7ae1 100644
          setValue();
          setFormula(); 
          m_xDocument = getController().getDocument(); 
-@@ -106,25 +110,27 @@ public class WatchedCell implements XModifyListener, XEventListener{
+@@ -106,25 +111,27 @@ public class WatchedCell implements XModifyListener, XEventListener{
         m_sheetName = xNamed.getName();
      }
      
@@ -373,7 +387,24 @@ index 1a98417..7ef7ae1 100644
      public void setValue() { 
          XText xText = (XText)UnoRuntime.queryInterface(XText.class, m_xCell);
          m_value = xText.getString();
-@@ -150,9 +156,6 @@ public class WatchedCell implements XModifyListener, XEventListener{
+@@ -141,18 +148,17 @@ public class WatchedCell implements XModifyListener, XEventListener{
+     public String getValueWithSpaces(){
+         return getController().createStringWithSpace(getValue(), 26);
+     }
+-    public void setFormula(){
+-        m_formula = m_xCell.getFormula();
+-        if(!m_formula.equals("")){
+-            if(m_formula.charAt(0) != '='){
+-                m_formula ="";
+-            }
++
++    public void setFormula() {
++        XFormulaTokens xTokens = (XFormulaTokens)UnoRuntime.queryInterface(
++            XFormulaTokens.class, m_xCell);
++        FormulaToken[] tokens = xTokens.getTokens();
++        m_formula = m_Controller.getFormulaParser().printFormula(tokens, new CellAddress());
++        if (!m_formula.isEmpty()) {
++            m_formula = "=" + m_formula;
          }
      }
      


More information about the ooo-build-commit mailing list