[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Feb 21 12:19:20 PST 2011


 sc/source/ui/docshell/externalrefmgr.cxx |  111 +++++++++++++++----------------
 1 file changed, 56 insertions(+), 55 deletions(-)

New commits:
commit e2aabf0a02fcd4906892a02be7d6fccd3d8c0a01
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Feb 21 15:18:24 2011 -0500

    Extracted a common code block into own method.

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index bb5b4d7..5371a4c 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1597,6 +1597,60 @@ void ScExternalRefManager::storeRangeNameTokens(sal_uInt16 nFileId, const String
     maRefCache.setRangeNameTokens(nFileId, rName, pArray);
 }
 
+namespace {
+
+void putCellDataIntoCache(
+    ScExternalRefCache& rRefCache, const ScExternalRefCache::TokenRef& pToken,
+    sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell,
+    ScExternalRefCache::CellFormat* pFmt)
+{
+    // Now, insert the token into cache table but don't cache empty cells.
+    if (pToken->GetType() != formula::svEmptyCell)
+    {
+        sal_uInt32 nFmtIndex = (pFmt && pFmt->mbIsSet) ? pFmt->mnIndex : 0;
+        rRefCache.setCellData(nFileId, rTabName, rCell.Col(), rCell.Row(), pToken, nFmtIndex);
+    }
+}
+
+/**
+ * Put the data into our internal cache table.
+ *
+ * @param rRefCache cache table set.
+ * @param pArray single range data to be returned.
+ * @param nFileId external file ID
+ * @param rTabName name of the table where the data should be cached.
+ * @param rCacheData range data to be cached.
+ * @param rCacheRange original cache range, including the empty region if
+ *                    any.
+ * @param rDataRange reduced cache range that includes only the non-empty
+ *                   data area.
+ */
+void putRangeDataIntoCache(
+    ScExternalRefCache& rRefCache, ScExternalRefCache::TokenArrayRef& pArray,
+    sal_uInt16 nFileId, const String& rTabName,
+    const vector<ScExternalRefCache::SingleRangeData>& rCacheData,
+    const ScRange& rCacheRange, const ScRange& rDataRange)
+{
+    if (pArray)
+        // Cache these values.
+        rRefCache.setCellRangeData(nFileId, rDataRange, rCacheData, pArray);
+    else
+    {
+        // Array is empty.  Fill it with an empty matrix of the required size.
+        pArray.reset(lcl_fillEmptyMatrix(rCacheRange));
+
+        // Make sure to set this range 'cached', to prevent unnecessarily
+        // accessing the src document time and time again.
+        ScExternalRefCache::TableTypeRef pCacheTab =
+            rRefCache.getCacheTable(nFileId, rTabName, true, NULL);
+        if (pCacheTab)
+            pCacheTab->setCachedCellRange(
+                rCacheRange.aStart.Col(), rCacheRange.aStart.Row(), rCacheRange.aEnd.Col(), rCacheRange.aEnd.Row());
+    }
+}
+
+}
+
 ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
     sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell,
     const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt)
@@ -1633,13 +1687,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
             getSingleRefTokenFromSrcDoc(
                 nFileId, pSrcDoc, ScAddress(rCell.Col(),rCell.Row(),nTab), pFmt);
 
-        // Now, insert the token into cache table but don't cache empty cells.
-        if (pToken->GetType() != formula::svEmptyCell)
-        {
-            sal_uInt32 nFmtIndex = (pFmt && pFmt->mbIsSet) ? pFmt->mnIndex : 0;
-            maRefCache.setCellData(nFileId, rTabName, rCell.Col(), rCell.Row(), pToken, nFmtIndex);
-        }
-
+        putCellDataIntoCache(maRefCache, pToken, nFileId, rTabName, rCell, pFmt);
         return pToken;
     }
 
@@ -1694,57 +1742,10 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
     pToken = getSingleRefTokenFromSrcDoc(
         nFileId, pSrcDoc, ScAddress(rCell.Col(),rCell.Row(),nTab), pFmt);
 
-    // Now, insert the token into cache table but don't cache empty cells.
-    if (pToken->GetType() != formula::svEmptyCell)
-    {
-        nFmtIndex = (pFmt && pFmt->mbIsSet) ? pFmt->mnIndex : 0;
-        maRefCache.setCellData(nFileId, rTabName, rCell.Col(), rCell.Row(), pToken, nFmtIndex);
-    }
-
+    putCellDataIntoCache(maRefCache, pToken, nFileId, rTabName, rCell, pFmt);
     return pToken;
 }
 
-namespace {
-
-/**
- * Put the data into our internal cache table.
- *
- * @param rRefCache cache table set.
- * @param pArray single range data to be returned.
- * @param nFileId external file ID
- * @param rTabName name of the table where the data should be cached.
- * @param rCacheData range data to be cached.
- * @param rCacheRange original cache range, including the empty region if
- *                    any.
- * @param rDataRange reduced cache range that includes only the non-empty
- *                   data area.
- */
-void putRangeDataIntoCache(
-    ScExternalRefCache& rRefCache, ScExternalRefCache::TokenArrayRef& pArray,
-    sal_uInt16 nFileId, const String& rTabName,
-    const vector<ScExternalRefCache::SingleRangeData>& rCacheData,
-    const ScRange& rCacheRange, const ScRange& rDataRange)
-{
-    if (pArray)
-        // Cache these values.
-        rRefCache.setCellRangeData(nFileId, rDataRange, rCacheData, pArray);
-    else
-    {
-        // Array is empty.  Fill it with an empty matrix of the required size.
-        pArray.reset(lcl_fillEmptyMatrix(rCacheRange));
-
-        // Make sure to set this range 'cached', to prevent unnecessarily
-        // accessing the src document time and time again.
-        ScExternalRefCache::TableTypeRef pCacheTab =
-            rRefCache.getCacheTable(nFileId, rTabName, true, NULL);
-        if (pCacheTab)
-            pCacheTab->setCachedCellRange(
-                rCacheRange.aStart.Col(), rCacheRange.aStart.Row(), rCacheRange.aEnd.Col(), rCacheRange.aEnd.Row());
-    }
-}
-
-}
-
 ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens(
     sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange, const ScAddress* pCurPos)
 {


More information about the Libreoffice-commits mailing list