ooo-build r13880 - in trunk: . patches/dev300



Author: kyoshida
Date: Fri Sep 12 05:04:06 2008
New Revision: 13880
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13880&view=rev

Log:
2008-09-12  Kohei Yoshida  <kyoshida novell com>

	* patches/dev300/calc-external-defined-names-sc.diff: more updates from
	mooxlsc cws.  It now handles number format from external source cells
	semi-correctly.  This is especially important for referencing dates.


Modified:
   trunk/ChangeLog
   trunk/patches/dev300/calc-external-defined-names-sc.diff

Modified: trunk/patches/dev300/calc-external-defined-names-sc.diff
==============================================================================
--- trunk/patches/dev300/calc-external-defined-names-sc.diff	(original)
+++ trunk/patches/dev300/calc-external-defined-names-sc.diff	Fri Sep 12 05:04:06 2008
@@ -289,10 +289,10 @@
  
 diff --git sc/inc/externalrefmgr.hxx sc/inc/externalrefmgr.hxx
 new file mode 100644
-index 0000000..d40afbc
+index 0000000..1e1ddea
 --- /dev/null
 +++ sc/inc/externalrefmgr.hxx
-@@ -0,0 +1,486 @@
+@@ -0,0 +1,507 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -381,22 +381,9 @@
 + */
 +class ScExternalRefCache
 +{
-+    struct RangeHash
-+    {
-+        size_t operator()(const ScRange& rRange) const
-+        {
-+            const ScAddress& s = rRange.aStart;
-+            const ScAddress& e = rRange.aEnd;
-+            return s.Tab() + s.Col() + s.Row() + e.Tab() + e.Col() + e.Row();
-+        }
-+    };
-+
 +public:
-+
 +    typedef ::boost::shared_ptr<ScToken>            TokenRef;
 +    typedef ::boost::shared_ptr<ScTokenArray>       TokenArrayRef;
-+    typedef ::std::hash_map<SCCOL, TokenRef>        RowDataType;
-+    typedef ::std::hash_map<SCROW, RowDataType>     RowsDataType;
 +
 +    struct TableName
 +    {
@@ -406,14 +393,34 @@
 +        explicit TableName(const String& rUppper, const String& rReal);
 +    };
 +
++    struct CellFormat
++    {
++        bool        mbIsSet;
++        short       mnType;
++        sal_uInt32  mnIndex;
++
++        explicit CellFormat();
++    };
++
++private:
++    /** individual cell within cached external ref table. */
++    struct Cell
++    {
++        TokenRef    mxToken;
++        sal_uInt32  mnFmtIndex;
++    };
++    typedef ::std::hash_map<SCCOL, Cell>            RowDataType;
++    typedef ::std::hash_map<SCROW, RowDataType>     RowsDataType;
++
++public:
 +    class Table
 +    {
 +    public:
 +        Table();
 +        ~Table();
 +
-+        void setCell(SCCOL nCol, SCROW nRow, TokenRef pToken);
-+        TokenRef getCell(SCCOL nCol, SCROW nRow) const;
++        void setCell(SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uInt32 nFmtIndex = 0);
++        TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = NULL) const;
 +        void getAllRows(::std::vector<SCROW>& rRows) const;
 +        void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const;
 +
@@ -442,7 +449,9 @@
 +     *         not need to delete this instance since its life cycle is
 +     *         managed by this class.</i>
 +     */
-+    ScExternalRefCache::TokenRef getCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol);
++    ScExternalRefCache::TokenRef getCellData(
++        sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, 
++        sal_uInt32* pnFmtIndex = NULL);
 +
 +    /**
 +     * Get a cached cell range data.
@@ -456,7 +465,7 @@
 +    ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const String& rName);
 +    void setRangeNameTokens(sal_uInt16 nFileId, const String& rName, TokenArrayRef pArray);
 +
-+    void setCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, TokenRef pToken);
++    void setCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, TokenRef pToken, sal_uInt32 nFmtIndex);
 +
 +    struct SingleRangeData
 +    {
@@ -480,6 +489,16 @@
 +    void clearCache(sal_uInt16 nFileId);
 +
 +private:
++    struct RangeHash
++    {
++        size_t operator()(const ScRange& rRange) const
++        {
++            const ScAddress& s = rRange.aStart;
++            const ScAddress& e = rRange.aEnd;
++            return s.Tab() + s.Col() + s.Row() + e.Tab() + e.Col() + e.Row();
++        }
++    };
++
 +    typedef ::std::hash_map<String, TokenArrayRef, ScStringHashCode>    RangeNameMap;
 +    typedef ::std::hash_map<ScRange, TokenArrayRef, RangeHash>          RangeArrayMap;
 +    typedef ::std::hash_map<String, String, ScStringHashCode>           NamePairMap;
@@ -622,7 +641,9 @@
 +
 +    void storeRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScTokenArray& rArray);
 +
-+    ScExternalRefCache::TokenRef getSingleRefToken(sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell, const ScAddress* pCurPos, SCTAB* pTab);
++    ScExternalRefCache::TokenRef getSingleRefToken(
++        sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell, 
++        const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt = NULL);
 +
 +    /**
 +     * Get an array of tokens that consist of the specified external cell
@@ -780,7 +801,7 @@
 +
 +#endif
 diff --git sc/inc/linkuno.hxx sc/inc/linkuno.hxx
-index b6fc524..0a12196 100644
+index b6fc524..6dd39e8 100644
 --- sc/inc/linkuno.hxx
 +++ sc/inc/linkuno.hxx
 @@ -36,6 +36,9 @@
@@ -847,9 +868,9 @@
 +    ScExternalRefCache::TableTypeRef mpTable;
 +    size_t mnIndex;
 +};
-+
+ 
 +// ============================================================================
-+
+ 
 +class ScExternalDocLinkObj : public cppu::WeakImplHelper1< ::com::sun::star::sheet::XExternalDocLink >
 +{
 +public:
@@ -861,31 +882,31 @@
 +        SAL_CALL addSheetCache( const ::rtl::OUString& aSheetName )
 +            throw (::com::sun::star::uno::RuntimeException);
 +
-+							// XNameAccess
-+	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
-+								throw(::com::sun::star::container::NoSuchElementException,
-+									::com::sun::star::lang::WrappedTargetException,
-+									::com::sun::star::uno::RuntimeException);
-+	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
-+								throw(::com::sun::star::uno::RuntimeException);
-+	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
-+								throw(::com::sun::star::uno::RuntimeException);
-+
-+							// XIndexAccess
-+	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
-+	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex )
-+								throw(::com::sun::star::lang::IndexOutOfBoundsException,
-+									::com::sun::star::lang::WrappedTargetException,
-+									::com::sun::star::uno::RuntimeException);
-+
-+							// XEnumerationAccess
-+	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
-+							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
-+
-+							// XElementAccess
-+	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
-+								throw(::com::sun::star::uno::RuntimeException);
-+	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
++                            // XNameAccess
++    virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
++                                throw(::com::sun::star::container::NoSuchElementException,
++                                    ::com::sun::star::lang::WrappedTargetException,
++                                    ::com::sun::star::uno::RuntimeException);
++    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
++                                throw(::com::sun::star::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
++                                throw(::com::sun::star::uno::RuntimeException);
++
++                            // XIndexAccess
++    virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
++    virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex )
++                                throw(::com::sun::star::lang::IndexOutOfBoundsException,
++                                    ::com::sun::star::lang::WrappedTargetException,
++                                    ::com::sun::star::uno::RuntimeException);
++
++                            // XEnumerationAccess
++    virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
++                            createEnumeration() throw(::com::sun::star::uno::RuntimeException);
++
++                            // XElementAccess
++    virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
++                                throw(::com::sun::star::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
 +
 +    // Attributes
 +    virtual sal_Int32 SAL_CALL getTokenIndex()
@@ -897,44 +918,44 @@
 +};
 +
 +// ============================================================================
- 
++
 +/** This is the UNO API equivalent of ScExternalRefManager. */
 +class ScExternalDocLinksObj : public cppu::WeakImplHelper1< ::com::sun::star::sheet::XExternalDocLinks >
 +{
 +public:
 +    ScExternalDocLinksObj(ScDocShell* pDocShell);
 +    ~ScExternalDocLinksObj();
- 
++
 +                            // XExternalDocLinks
 +    virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XExternalDocLink >
 +        SAL_CALL addDocLink( const ::rtl::OUString& aDocName )
 +            throw (::com::sun::star::uno::RuntimeException);
 +
-+							// XNameAccess
-+	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
-+								throw(::com::sun::star::container::NoSuchElementException,
-+									::com::sun::star::lang::WrappedTargetException,
-+									::com::sun::star::uno::RuntimeException);
-+	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
-+								throw(::com::sun::star::uno::RuntimeException);
-+	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
-+								throw(::com::sun::star::uno::RuntimeException);
-+
-+							// XIndexAccess
-+	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
-+	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex )
-+								throw(::com::sun::star::lang::IndexOutOfBoundsException,
-+									::com::sun::star::lang::WrappedTargetException,
-+									::com::sun::star::uno::RuntimeException);
-+
-+							// XEnumerationAccess
-+	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
-+							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
-+
-+							// XElementAccess
-+	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
-+								throw(::com::sun::star::uno::RuntimeException);
-+	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
++                            // XNameAccess
++    virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
++                                throw(::com::sun::star::container::NoSuchElementException,
++                                    ::com::sun::star::lang::WrappedTargetException,
++                                    ::com::sun::star::uno::RuntimeException);
++    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
++                                throw(::com::sun::star::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
++                                throw(::com::sun::star::uno::RuntimeException);
++
++                            // XIndexAccess
++    virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
++    virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex )
++                                throw(::com::sun::star::lang::IndexOutOfBoundsException,
++                                    ::com::sun::star::lang::WrappedTargetException,
++                                    ::com::sun::star::uno::RuntimeException);
++
++                            // XEnumerationAccess
++    virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
++                            createEnumeration() throw(::com::sun::star::uno::RuntimeException);
++
++                            // XElementAccess
++    virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
++                                throw(::com::sun::star::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
 +
 +private:
 +    ScExternalDocLinksObj();
@@ -2210,7 +2231,7 @@
          aString.Append( '$' );
  
 diff --git sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
-index d39afdf..be4ee1c 100644
+index fb06501..785b909 100644
 --- sc/source/core/tool/compiler.cxx
 +++ sc/source/core/tool/compiler.cxx
 @@ -74,9 +74,11 @@
@@ -2261,8 +2282,8 @@
 +        SetGrammarAndRefConvention( eMyGrammar, eOldGrammar);
  }
  
- void ScCompiler::SetFormulaLanguage( const ScCompiler::OpCodeMapPtr & xMap )
-@@ -736,7 +733,25 @@ void ScCompiler::SetFormulaLanguage( const ScCompiler::OpCodeMapPtr & xMap )
+ 
+@@ -737,7 +734,25 @@ void ScCompiler::SetFormulaLanguage( const ScCompiler::OpCodeMapPtr & xMap )
          }
          else
              pCharClass = ScGlobal::pCharClass;
@@ -2288,7 +2309,7 @@
  }
  
  
-@@ -865,20 +880,19 @@ ScCompiler::OpCodeMap::createSequenceOfAvailableMappings( const sal_Int32 nGroup
+@@ -866,20 +881,19 @@ ScCompiler::OpCodeMap::createSequenceOfAvailableMappings( const sal_Int32 nGroup
              sal_Int32 nOff;
              OpCode    eOp;
          } aMap[] = {
@@ -2322,7 +2343,7 @@
          };
          const size_t nCount = sizeof(aMap)/sizeof(aMap[0]);
          // Preallocate vector elements.
-@@ -1077,7 +1091,7 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv )
+@@ -1078,7 +1092,7 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv )
  /*   */     t[32] = SC_COMPILER_C_CHAR_DONTCARE | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
  /* ! */     t[33] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
      if (ScAddress::CONV_ODF == meConv)
@@ -2331,7 +2352,7 @@
  /* " */     t[34] = SC_COMPILER_C_CHAR_STRING | SC_COMPILER_C_STRING_SEP;
  /* # */     t[35] = SC_COMPILER_C_WORD_SEP;
  /* $ */     t[36] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT;
-@@ -1092,8 +1106,10 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv )
+@@ -1093,8 +1107,10 @@ ScCompiler::Convention::Convention( ScAddress::Convention eConv )
  /* - */     t[45] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_SIGN;
  /* . */     t[46] = SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_VALUE | SC_COMPILER_C_IDENT;
  /* / */     t[47] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
@@ -2343,7 +2364,7 @@
  /* : */     t[58] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD;
  /* ; */     t[59] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
  /* < */     t[60] = SC_COMPILER_C_CHAR_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-@@ -1101,8 +1117,10 @@ for (i = 48; i < 58; i++)
+@@ -1102,8 +1118,10 @@ for (i = 48; i < 58; i++)
  /* > */     t[62] = SC_COMPILER_C_CHAR_BOOL | SC_COMPILER_C_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
  /* ? */     t[63] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD;
  /* @ */     // FREE
@@ -2355,7 +2376,7 @@
      if (ScAddress::CONV_ODF == meConv)
      {
  /* [ */     t[91] = SC_COMPILER_C_ODF_LBRACKET;
-@@ -1118,14 +1136,17 @@ for (i = 65; i < 91; i++)
+@@ -1119,14 +1137,17 @@ for (i = 65; i < 91; i++)
  /* ^ */     t[94] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
  /* _ */     t[95] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT;
  /* ` */     // FREE
@@ -2375,7 +2396,7 @@
      {
  /*   */     t[32] |=   SC_COMPILER_C_WORD;
  /* ! */     t[33] |=   SC_COMPILER_C_IDENT | SC_COMPILER_C_WORD;
-@@ -1164,9 +1185,14 @@ for (i = 97; i < 123; i++)
+@@ -1165,9 +1186,14 @@ for (i = 97; i < 123; i++)
  
          if( ScAddress::CONV_XL_R1C1 == meConv )
          {
@@ -2393,7 +2414,7 @@
          }
      }
  }
-@@ -1190,7 +1216,7 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
+@@ -1191,7 +1217,7 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
                  {
                      rRes.TokenType = KParseType::SINGLE_QUOTE_NAME;
                      rRes.EndPos = nPos+1;
@@ -2402,7 +2423,7 @@
                  }
                  ++nPos;
              }
-@@ -1198,9 +1224,203 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
+@@ -1199,9 +1225,203 @@ static bool lcl_isValidQuotedText( const String& rFormula, xub_StrLen nSrcPos, P
          }
      }
  
@@ -2606,7 +2627,7 @@
  struct Convention_A1 : public ScCompiler::Convention
  {
      Convention_A1( ScAddress::Convention eConv ) : ScCompiler::Convention( eConv ) { }
-@@ -1214,14 +1434,14 @@ struct Convention_A1 : public ScCompiler::Convention
+@@ -1215,14 +1435,14 @@ struct Convention_A1 : public ScCompiler::Convention
                                 const CharClass* pCharClass) const
      {
          ParseResult aRet;
@@ -2623,7 +2644,7 @@
          return pCharClass->parseAnyToken( rFormula,
                  nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
      }
-@@ -1404,6 +1624,121 @@ struct ConventionOOO_A1 : public Convention_A1
+@@ -1405,6 +1625,121 @@ struct ConventionOOO_A1 : public Convention_A1
  
          return sal_Unicode(0);
      }
@@ -2745,7 +2766,7 @@
  };
  
  
-@@ -1422,6 +1757,25 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
+@@ -1423,6 +1758,25 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
      {
          MakeRefStrImpl( rBuffer, rComp, rRef, bSingleRef, true);
      }
@@ -2771,7 +2792,7 @@
  };
  
  static const ConventionOOO_A1_ODF ConvOOO_A1_ODF;
-@@ -1525,11 +1879,129 @@ struct ConventionXL
+@@ -1526,11 +1880,129 @@ struct ConventionXL
          }
          return sal_Unicode(0);
      }
@@ -2901,7 +2922,7 @@
      void MakeRefStr( rtl::OUStringBuffer&   rBuf,
                       const ScCompiler&      rComp,
                       const ComplRefData& rRef,
-@@ -1583,22 +2055,11 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
+@@ -1584,22 +2056,11 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
              }
          }
  
@@ -2926,7 +2947,7 @@
          }
      }
  
-@@ -1606,8 +2067,10 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
+@@ -1607,8 +2068,10 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
                                         xub_StrLen nSrcPos,
                                         const CharClass* pCharClass) const
      {
@@ -2938,7 +2959,7 @@
              return aRet;
  
          static const sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
-@@ -1623,11 +2086,83 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
+@@ -1624,11 +2087,83 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
      {
          return ConventionXL::getSpecialSymbol(eSymType);
      }
@@ -3022,7 +3043,7 @@
  //-----------------------------------------------------------------------------
  
  static void
-@@ -1732,8 +2267,10 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
+@@ -1733,8 +2268,10 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
                                 xub_StrLen nSrcPos,
                                 const CharClass* pCharClass) const
      {
@@ -3034,7 +3055,7 @@
              return aRet;
  
          static const sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
-@@ -1750,6 +2287,96 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
+@@ -1751,6 +2288,96 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
      {
          return ConventionXL::getSpecialSymbol(eSymType);
      }
@@ -3131,7 +3152,7 @@
  };
  
  static const ConventionXL_R1C1 ConvXL_R1C1;
-@@ -1816,13 +2443,15 @@ void ScCompiler::CheckTabQuotes( String& rString,
+@@ -1817,13 +2444,15 @@ void ScCompiler::CheckTabQuotes( String& rString,
          KParseType::IDENTNAME, rString, 0, nStartFlags, EMPTY_STRING, nContFlags, EMPTY_STRING);
      bool bNeedsQuote = !((aRes.TokenType & KParseType::IDENTNAME) && aRes.EndPos == rString.Len());
  
@@ -3148,7 +3169,7 @@
              if( bNeedsQuote )
              {
                  static const String one_quote = static_cast<sal_Unicode>( '\'' );
-@@ -1858,6 +2487,7 @@ void ScCompiler::SetRefConvention( ScAddress::Convention eConv )
+@@ -1859,6 +2488,7 @@ void ScCompiler::SetRefConvention( ScAddress::Convention eConv )
          case ScAddress::CONV_ODF :      SetRefConvention( pConvOOO_A1_ODF ); break;
          case ScAddress::CONV_XL_A1 :    SetRefConvention( pConvXL_A1 );  break;
          case ScAddress::CONV_XL_R1C1 :  SetRefConvention( pConvXL_R1C1 ); break;
@@ -3156,7 +3177,7 @@
      }
  }
  
-@@ -2184,71 +2814,88 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
+@@ -2185,71 +2815,88 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
                  }
                  // fall through and follow logic
              case ssSkipReference:
@@ -3292,7 +3313,7 @@
                      }
                      else if (':' == c)
                      {
-@@ -2263,7 +2910,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
+@@ -2264,7 +2911,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
                          eState = ssStop;
                      }
                      if (bAddToSymbol && eState != ssSkipReference)
@@ -3301,7 +3322,7 @@
                  }
                  break;
              case ssStop:
-@@ -2544,7 +3191,8 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
+@@ -2545,7 +3192,8 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
  {
      ScRange aRange( aPos, aPos );
      const ScAddress::Details aDetails( pConv->meConv, aPos );
@@ -3311,7 +3332,7 @@
      if( nFlags & SCA_VALID )
      {
          ScRawToken aToken;
-@@ -2563,7 +3211,17 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
+@@ -2564,7 +3212,17 @@ BOOL ScCompiler::IsDoubleReference( const String& rName )
              aRef.Ref2.SetTabDeleted( TRUE );        // #REF!
          aRef.Ref2.SetFlag3D( ( nFlags & SCA_TAB2_3D ) != 0 );
          aRef.CalcRelFromAbs( aPos );
@@ -3330,7 +3351,7 @@
          pRawToken = aToken.Clone();
      }
  
-@@ -2575,7 +3233,8 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
+@@ -2576,7 +3234,8 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
  {
      ScAddress aAddr( aPos );
      const ScAddress::Details aDetails( pConv->meConv, aPos );
@@ -3340,7 +3361,7 @@
      // Something must be valid in order to recognize Sheet1.blah or blah.a1
      // as a (wrong) reference.
      if( nFlags & ( SCA_VALID_COL|SCA_VALID_ROW|SCA_VALID_TAB ) )
-@@ -2599,7 +3258,16 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
+@@ -2600,7 +3259,16 @@ BOOL ScCompiler::IsSingleReference( const String& rName )
              nFlags |= SCA_VALID;
          }
          aRef.CalcRelFromAbs( aPos );
@@ -3358,7 +3379,7 @@
          pRawToken = aToken.Clone();
      }
  
-@@ -2707,6 +3375,32 @@ BOOL ScCompiler::IsNamedRange( const String& rUpperName )
+@@ -2708,6 +3376,32 @@ BOOL ScCompiler::IsNamedRange( const String& rUpperName )
          return FALSE;
  }
  
@@ -3391,7 +3412,7 @@
  BOOL ScCompiler::IsDBRange( const String& rName )
  {
      USHORT n;
-@@ -3242,7 +3936,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray )
+@@ -3243,7 +3937,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray )
          if (mnPredetectedReference)
          {
              String aStr( cSymbol);
@@ -3400,7 +3421,7 @@
              {
                  /* TODO: it would be nice to generate a #REF! error here, which
                   * would need an ocBad token with additional error value.
-@@ -3305,6 +3999,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray )
+@@ -3306,6 +4000,7 @@ BOOL ScCompiler::NextNewToken( bool bInArray )
                && !(bAllowBooleans && IsBoolean( aUpper ))
                && !IsValue( aUpper )
                && !IsNamedRange( aUpper )
@@ -3408,7 +3429,7 @@
                && !IsDBRange( aUpper )
                && !IsColRowName( aUpper )
                && !(bMayBeFuncName && IsMacro( aUpper ))
-@@ -3627,9 +4322,9 @@ BOOL ScCompiler::GetToken()
+@@ -3628,9 +4323,9 @@ BOOL ScCompiler::GetToken()
          else
          {
              if ( nWasColRowName >= 2 && pToken->GetOpCode() == ocColRowName )
@@ -3420,7 +3441,7 @@
              }
          }
      }
-@@ -3640,6 +4335,50 @@ BOOL ScCompiler::GetToken()
+@@ -3641,6 +4336,50 @@ BOOL ScCompiler::GetToken()
      }
      if( pToken->GetOpCode() == ocSubTotal )
          glSubTotal = TRUE;
@@ -3471,7 +3492,7 @@
      else if( pToken->GetOpCode() == ocName )
      {
          ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( pToken->GetIndex() );
-@@ -3795,7 +4534,7 @@ BOOL ScCompiler::GetToken()
+@@ -3796,7 +4535,7 @@ BOOL ScCompiler::GetToken()
                      {   // next defined RowNameRange to the right limits column
                          const ScRange& rRange = pR->GetRange(1);
                          if ( rRange.aStart.Row() <= nRow && nRow <= rRange.aEnd.Row() )
@@ -3480,7 +3501,7 @@
                              SCCOL nTmp = rRange.aStart.Col();
                              if ( nStartCol < nTmp && nTmp <= nMaxCol )
                                  nMaxCol = nTmp - 1;
-@@ -4419,6 +5158,11 @@ void ScCompiler::Factor()
+@@ -4420,6 +5159,11 @@ void ScCompiler::Factor()
                  bCorrected = TRUE;
              }
          }
@@ -3492,7 +3513,7 @@
          else
          {
              SetError( errUnknownToken );
-@@ -4700,7 +5444,7 @@ void ScCompiler::MoveRelWrap()
+@@ -4701,7 +5445,7 @@ void ScCompiler::MoveRelWrap()
      for( ScToken* t = pArr->GetNextReference(); t;
                    t = pArr->GetNextReference() )
      {
@@ -3501,7 +3522,7 @@
              ScRefUpdate::MoveRelWrap( pDoc, aPos, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() );
          else
              ScRefUpdate::MoveRelWrap( pDoc, aPos, t->GetDoubleRef() );
-@@ -4717,7 +5461,7 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc,
+@@ -4718,7 +5462,7 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc,
      for( ScToken* t = rArr.GetNextReference(); t;
                    t = rArr.GetNextReference() )
      {
@@ -3510,7 +3531,7 @@
              ScRefUpdate::MoveRelWrap( pDoc, rPos, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() );
          else
              ScRefUpdate::MoveRelWrap( pDoc, rPos, t->GetDoubleRef() );
-@@ -4829,7 +5573,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
+@@ -4830,7 +5574,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
              else if( t->GetType() != svIndex )  // it may be a DB area!!!
              {
                  t->CalcAbsIfRel( rOldPos );
@@ -3519,7 +3540,7 @@
                  {
                      if ( ScRefUpdate::Update( pDoc, eUpdateRefMode, aPos,
                              r, nDx, nDy, nDz,
-@@ -5637,111 +6381,144 @@ ScToken* ScCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToke
+@@ -5638,111 +6382,144 @@ ScToken* ScCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuffer, ScToke
          DBG_ERRORFILE("unknown OpCode");
          rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF));
      }
@@ -3751,7 +3772,7 @@
          rBuffer.append(sal_Unicode(' '));
      if ( bAllowArrAdvance )
 diff --git sc/source/core/tool/interpr4.cxx sc/source/core/tool/interpr4.cxx
-index 5f6faa3..e48178b 100644
+index 5f6faa3..a59792f 100644
 --- sc/source/core/tool/interpr4.cxx
 +++ sc/source/core/tool/interpr4.cxx
 @@ -7,7 +7,7 @@
@@ -3771,7 +3792,7 @@
  
  using namespace com::sun::star;
  
-@@ -2980,6 +2981,75 @@ void ScInterpreter::ScColRowNameAuto()
+@@ -2980,6 +2981,81 @@ void ScInterpreter::ScColRowNameAuto()
          PushError( errNoRef );
  }
  
@@ -3795,8 +3816,9 @@
 +
 +            aData.CalcAbsIfRel(aPos);
 +            ScAddress aAddr(aData.nCol, aData.nRow, aData.nTab);
++            ScExternalRefCache::CellFormat aFmt;
 +            ScExternalRefCache::TokenRef xNew = pRefMgr->getSingleRefToken(
-+                pCur->GetIndex(), pCur->GetString(), aAddr, &aPos, NULL);
++                pCur->GetIndex(), pCur->GetString(), aAddr, &aPos, NULL, &aFmt);
 +
 +            if (!xNew)
 +                break;
@@ -3809,6 +3831,11 @@
 +                // Cell in the source doc is empty.  Put 0.
 +                PushInt(0);
 +
++            if (aFmt.mbIsSet)
++            {
++                nFuncFmtType = aFmt.mnType;
++                nFuncFmtIndex = aFmt.mnIndex;
++            }
 +            return;
 +        }
 +        break;
@@ -3847,7 +3874,7 @@
  // --- internals ------------------------------------------------------------
  
  
-@@ -3412,6 +3482,7 @@ StackVar ScInterpreter::Interpret()
+@@ -3412,6 +3488,7 @@ StackVar ScInterpreter::Interpret()
                  case ocDBArea           : ScDBArea();                   break;
                  case ocColRowNameAuto   : ScColRowNameAuto();           break;
  // separated    case ocPush             : Push( (ScToken&) *pCur );     break;
@@ -9025,10 +9052,10 @@
  
 diff --git sc/source/ui/docshell/externalrefmgr.cxx sc/source/ui/docshell/externalrefmgr.cxx
 new file mode 100644
-index 0000000..ae864bb
+index 0000000..17037ed
 --- /dev/null
 +++ sc/source/ui/docshell/externalrefmgr.cxx
-@@ -0,0 +1,1742 @@
+@@ -0,0 +1,1793 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9091,6 +9118,7 @@
 +#include "svtools/itemset.hxx"
 +#include "svtools/stritem.hxx"
 +#include "svtools/urihelper.hxx"
++#include "svtools/zformat.hxx"
 +#include "svx/linkmgr.hxx"
 +#include "tools/urlobj.hxx"
 +#include "unotools/ucbhelper.hxx"
@@ -9160,7 +9188,7 @@
 +{
 +}
 +
-+void ScExternalRefCache::Table::setCell(SCCOL nCol, SCROW nRow, TokenRef pToken)
++void ScExternalRefCache::Table::setCell(SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uInt32 nFmtIndex)
 +{
 +    using ::std::pair;
 +    RowsDataType::iterator itrRow = maRows.find(nRow);
@@ -9179,10 +9207,13 @@
 +    // Insert this token into the specified column location.  I don't need to
 +    // check for existing data.  Just overwrite it.
 +    RowDataType& rRow = itrRow->second;
-+    rRow.insert(RowDataType::value_type(nCol, pToken));
++    ScExternalRefCache::Cell aCell;
++    aCell.mxToken = pToken;
++    aCell.mnFmtIndex = nFmtIndex;
++    rRow.insert(RowDataType::value_type(nCol, aCell));
 +}
 +
-+ScExternalRefCache::TokenRef ScExternalRefCache::Table::getCell(SCCOL nCol, SCROW nRow) const
++ScExternalRefCache::TokenRef ScExternalRefCache::Table::getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex) const
 +{
 +    RowsDataType::const_iterator itrTable = maRows.find(nRow);
 +    if (itrTable == maRows.end())
@@ -9199,7 +9230,11 @@
 +        return TokenRef();
 +    }
 +
-+    return itrRow->second;
++    const Cell& rCell = itrRow->second;
++    if (pnFmtIndex)
++        *pnFmtIndex = rCell.mnFmtIndex;
++
++    return rCell.mxToken;
 +}
 +
 +void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows) const
@@ -9243,6 +9278,13 @@
 +
 +// ----------------------------------------------------------------------------
 +
++ScExternalRefCache::CellFormat::CellFormat() :
++    mbIsSet(false), mnType(NUMBERFORMAT_ALL), mnIndex(0)
++{
++}
++
++// ----------------------------------------------------------------------------
++
 +ScExternalRefCache::ScExternalRefCache()
 +{
 +}
@@ -9290,7 +9332,8 @@
 +    return &itr->second;
 +}
 +
-+ScExternalRefCache::TokenRef ScExternalRefCache::getCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol)
++ScExternalRefCache::TokenRef ScExternalRefCache::getCellData(
++    sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, sal_uInt32* pnFmtIndex)
 +{
 +    DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
 +    if (itrDoc == maDocs.end())
@@ -9314,7 +9357,7 @@
 +        // the table data is not instantiated yet.
 +        return TokenRef();
 +    }
-+    return pTableData->getCell(nCol, nRow);
++    return pTableData->getCell(nCol, nRow, pnFmtIndex);
 +}
 +
 +ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange)
@@ -9425,7 +9468,8 @@
 +    pDoc->maRealRangeNameMap.insert(NamePairMap::value_type(aUpperName, rName));
 +}
 +
-+void ScExternalRefCache::setCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, TokenRef pToken)
++void ScExternalRefCache::setCellData(sal_uInt16 nFileId, const String& rTabName, SCROW nRow, SCCOL nCol, 
++                                     TokenRef pToken, sal_uInt32 nFmtIndex)
 +{
 +    if (!isDocInitialized(nFileId))
 +        return;
@@ -9448,7 +9492,7 @@
 +    if (!pTableData.get())
 +        pTableData.reset(new Table);
 +
-+    pTableData->setCell(nCol, nRow, pToken);
++    pTableData->setCell(nCol, nRow, pToken, nFmtIndex);
 +}
 +
 +void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRange, const vector<SingleRangeData>& rData,
@@ -10034,6 +10078,13 @@
 +    }
 +    else
 +    {
++        if (itrOld == itrNew)
++        {
++            // No need to move the table.  Just update the table index.
++            (*itrOld)->mnIndex = nNewTab;
++            return;
++        }
++
 +        if (nOldTab < nNewTab)
 +        {
 +            // Iterate from the old tab position to the new tab position (not
@@ -10058,8 +10109,8 @@
 +        {
 +            // nNewTab < nOldTab
 +
-+            // Iterate from the new tab position to the old tab position, and
-+            // increment the tab index by one. 
++            // Iterate from the new tab position to the one before the old tab
++            // position, and increment their tab index by one.
 +            list<TabItemRef>::iterator itr = itrNew;
 +            for (++itr; itr != itrOld; ++itr)
 +                (*itr)->mnIndex += 1;
@@ -10067,6 +10118,7 @@
 +            (*itrOld)->mnIndex = nNewTab;
 +            maTables.insert(itrNew, *itrOld);
 +
++            // Remove the original table.
 +            maTables.erase(itrOld);
 +        }
 +    }
@@ -10152,7 +10204,7 @@
 +
 +ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
 +    sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell,
-+    const ScAddress* pCurPos, SCTAB* pTab)
++    const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt)
 +{
 +    if (pCurPos)
 +        insertRefCell(nFileId, *pCurPos);
@@ -10162,10 +10214,23 @@
 +    if (pTab)
 +        *pTab = -1;
 +
++    if (pFmt)
++        pFmt->mbIsSet = false;
++
 +    // Check if the given table name and the cell position is cached.
-+    ScExternalRefCache::TokenRef pToken = maRefCache.getCellData(nFileId, rTabName, rCell.Row(), rCell.Col());
-+    if (pToken.get())
-+    {
++    sal_uInt32 nFmtIndex = 0;
++    ScExternalRefCache::TokenRef pToken = maRefCache.getCellData(
++        nFileId, rTabName, rCell.Row(), rCell.Col(), &nFmtIndex);
++    if (pToken)
++    {
++        if (pFmt)
++        {
++            pFmt->mbIsSet = true;
++            pFmt->mnIndex = nFmtIndex;
++            SvNumberFormatter* pNumFormat = mpDoc->GetFormatTable();
++            const SvNumberformat* pEntry = pNumFormat->GetEntry(nFmtIndex);
++            pFmt->mnType = pEntry ? pEntry->GetType() : NUMBERFORMAT_ALL;
++        }
 +        return pToken;
 +    }
 +
@@ -10190,6 +10255,17 @@
 +    pSrcDoc->GetCell(rCell.Col(), rCell.Row(), nTab, pCell);
 +    ScExternalRefCache::TokenRef pTok(lcl_convertToToken(pCell));
 +
++    pSrcDoc->GetNumberFormat(rCell.Col(), rCell.Row(), nTab, nFmtIndex);
++
++    if (pFmt)
++    {
++        pFmt->mbIsSet = true;
++        pFmt->mnIndex = nFmtIndex;
++        SvNumberFormatter* pNumFormat = pSrcDoc->GetFormatTable();
++        const SvNumberformat* pEntry = pNumFormat->GetEntry(nFmtIndex);
++        pFmt->mnType = pEntry ? pEntry->GetType() : NUMBERFORMAT_ALL;
++    }
++
 +    if (!pTok.get())
 +    {
 +        // Cell in the source document is probably empty.
@@ -10197,7 +10273,7 @@
 +    }
 +
 +    // Now, insert the token into cache table.
-+    maRefCache.setCellData(nFileId, rTabName, rCell.Row(), rCell.Col(), pTok);
++    maRefCache.setCellData(nFileId, rTabName, rCell.Row(), rCell.Col(), pTok, nFmtIndex);
 +    return pTok;
 +}
 +
@@ -10351,7 +10427,6 @@
 +
 +void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell)
 +{
-+    using ::std::pair;
 +    RefCellMap::iterator itr = maRefCells.find(nFileId);
 +    if (itr == maRefCells.end())
 +    {
@@ -10369,6 +10444,9 @@
 +
 +ScDocument* ScExternalRefManager::getSrcDocument(sal_uInt16 nFileId)
 +{
++    if (!mpDoc->IsExecuteLinkEnabled())
++        return NULL;
++
 +    DocShellMap::iterator itrEnd = maDocShells.end();
 +    DocShellMap::iterator itr = maDocShells.find(nFileId);
 +
@@ -11614,3 +11692,36 @@
  			if (!bLink)
  				if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks())
  					bLink = TRUE;
+diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx
+index 1fee6ea..651f0c3 100644
+--- sc/source/ui/view/viewfunc.cxx
++++ sc/source/ui/view/viewfunc.cxx
+@@ -619,6 +619,28 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS
+ 				if ( pDoc->GetScriptType( nCol, nRow, i ) != nOldScript )
+ 					bEditDeleted = TRUE;
+ 
++        // Set the number format to the cell pattern _only when_ no number
++        // format is already set.
++        ScBaseCell* pCell;
++        pDoc->GetCell(nCol, nRow, nTab, pCell);
++        if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA && 
++            pDoc->GetNumberFormat(ScAddress(nCol, nRow, nTab)) == 0)
++        {
++            ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
++            sal_uInt32 nStdFmtIndex = pFCell->GetStandardFormat(*pDoc->GetFormatTable(), 0);
++            if (nStdFmtIndex)
++            {
++                const ScPatternAttr* pOldPat = pDoc->GetPattern(nCol, nRow, nTab);
++                ScPatternAttr aNewPat(*pOldPat);
++                SfxItemSet& rSet = aNewPat.GetItemSet();
++                SfxUInt32Item aValFmt(ATTR_VALUE_FORMAT, nStdFmtIndex);
++                rSet.Put(aValFmt);
++                aNewPat.DeleteUnchanged(pOldPat);
++                pDoc->SetPattern(nCol, nRow, nTab, aNewPat, true);
++                bNumFmtChanged = true;
++            }
++        }
++
+ 		HideAllCursors();
+ 
+ 		if (bEditDeleted || pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT ))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]