[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Fri Mar 15 17:51:46 PDT 2013


 sc/inc/cell.hxx                   |    4 ----
 sc/inc/document.hxx               |    6 ++++--
 sc/source/core/data/cell.cxx      |   14 ++++++--------
 sc/source/core/data/documen6.cxx  |   21 +++++++--------------
 sc/source/core/data/document.cxx  |   24 ++++++++++++++++--------
 sc/source/core/data/table5.cxx    |    4 ++--
 sc/source/filter/xml/xmlcelli.cxx |    5 +++--
 sc/source/ui/view/output2.cxx     |    3 ++-
 8 files changed, 40 insertions(+), 41 deletions(-)

New commits:
commit 297fea5feb190ba2ffa7e4185db888f39a7e6437
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 20:51:17 2013 -0400

    ScBaseCell::nScriptType is no more.
    
    Change-Id: Ic523bc5f8bf2c678cb7cf2115848d16845d2eeeb

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 214fa2d..4f09baa 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -100,9 +100,6 @@ public:
         Returns false for formula cells returning nothing, use HasEmptyData() for that. */
     bool            IsBlank() const;
 
-    inline sal_uInt8     GetScriptType() const { return nScriptType; }
-    inline void     SetScriptType( sal_uInt8 nNew ) { nScriptType = nNew; }
-
     /** Returns true, if the cell contains a broadcaster. */
     inline bool     HasBroadcaster() const { return mpBroadcaster != 0; }
     /** Returns the pointer to the cell broadcaster. */
@@ -144,7 +141,6 @@ private:
 
 protected:
     sal_uInt8            eCellType;      // enum CellType - sal_uInt8 spart Speicher
-    sal_uInt8            nScriptType;
 };
 
 // ============================================================================
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d4425d5..175bf14 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1176,9 +1176,8 @@ public:
     SC_DLLPUBLIC const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
     bool            HasStringWeakCharacters( const rtl::OUString& rString );
     SC_DLLPUBLIC sal_uInt8          GetStringScriptType( const rtl::OUString& rString );
-    SC_DLLPUBLIC sal_uInt8          GetCellScriptType( ScBaseCell* pCell, sal_uLong nNumberFormat );
+    SC_DLLPUBLIC sal_uInt8 GetCellScriptType( const ScAddress& rPos, ScBaseCell* pCell, sal_uLong nNumberFormat );
     SC_DLLPUBLIC sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell );
-    sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
 
     bool            HasDetectiveOperations() const;
     void            AddDetectiveOperation( const ScDetOpData& rData );
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 0b990a8..e37fbd2 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -70,15 +70,13 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ScNoteCell )
 
 ScBaseCell::ScBaseCell( CellType eNewType ) :
     mpBroadcaster( 0 ),
-    eCellType( sal::static_int_cast<sal_uInt8>(eNewType) ),
-    nScriptType( SC_SCRIPTTYPE_UNKNOWN )
+    eCellType( sal::static_int_cast<sal_uInt8>(eNewType) )
 {
 }
 
 ScBaseCell::ScBaseCell( const ScBaseCell& rCell ) :
     mpBroadcaster( 0 ),
-    eCellType( rCell.eCellType ),
-    nScriptType( SC_SCRIPTTYPE_UNKNOWN )
+    eCellType( rCell.eCellType )
 {
 }
 
@@ -1002,7 +1000,7 @@ void ScFormulaCell::Compile( const rtl::OUString& rFormula, bool bNoListening,
     {
         bChanged = true;
         pDocument->SetTextWidth(aPos, TEXTWIDTH_DIRTY);
-        SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+        pDocument->SetScriptType(aPos, SC_SCRIPTTYPE_UNKNOWN);
     }
     if ( bWasInFormulaTree )
         pDocument->PutInFormulaTree( this );
@@ -1096,7 +1094,7 @@ void ScFormulaCell::CompileXML( ScProgress& rProgress )
     {
         bChanged = true;
         pDocument->SetTextWidth(aPos, TEXTWIDTH_DIRTY);
-        SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+        pDocument->SetScriptType(aPos, SC_SCRIPTTYPE_UNKNOWN);
     }
 
     //  Same as in Load: after loading, it must be known if ocMacro is in any formula
@@ -1367,7 +1365,7 @@ void ScFormulaCell::Interpret()
                             pIterCell->aResult.SetResultError( errNoConvergence);
                             pIterCell->bChanged = true;
                             pDocument->SetTextWidth(pIterCell->aPos, TEXTWIDTH_DIRTY);
-                            pIterCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN);
+                            pDocument->SetScriptType(pIterCell->aPos, SC_SCRIPTTYPE_UNKNOWN);
                         }
                     }
                     // End this iteration and remove entries.
@@ -1662,7 +1660,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
         if( bChanged )
         {
             pDocument->SetTextWidth(aPos, TEXTWIDTH_DIRTY);
-            SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+            pDocument->SetScriptType(aPos, SC_SCRIPTTYPE_UNKNOWN);
         }
         if (bContentChanged && pDocument->IsStreamValid(aPos.Tab()))
         {
diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx
index d0b5aa2..507f7f9 100644
--- a/sc/source/core/data/documen6.cxx
+++ b/sc/source/core/data/documen6.cxx
@@ -114,12 +114,12 @@ sal_uInt8 ScDocument::GetStringScriptType( const rtl::OUString& rString )
     return nRet;
 }
 
-sal_uInt8 ScDocument::GetCellScriptType( ScBaseCell* pCell, sal_uLong nNumberFormat )
+sal_uInt8 ScDocument::GetCellScriptType( const ScAddress& rPos, ScBaseCell* pCell, sal_uLong nNumberFormat )
 {
     if ( !pCell )
         return 0;       // empty
 
-    sal_uInt8 nStored = pCell->GetScriptType();
+    sal_uInt8 nStored = GetScriptType(rPos);
     if ( nStored != SC_SCRIPTTYPE_UNKNOWN )         // stored value valid?
         return nStored;                             // use stored value
 
@@ -129,25 +129,17 @@ sal_uInt8 ScDocument::GetCellScriptType( ScBaseCell* pCell, sal_uLong nNumberFor
 
     sal_uInt8 nRet = GetStringScriptType( aStr );
 
-    pCell->SetScriptType( nRet );       // store for later calls
+    SetScriptType(rPos, nRet);       // store for later calls
 
     return nRet;
 }
 
 sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell )
 {
-    // if cell is not passed, take from document
-
-    if (!pCell)
-    {
-        pCell = GetCell( ScAddress( nCol, nRow, nTab ) );
-        if ( !pCell )
-            return 0;       // empty
-    }
-
     // if script type is set, don't have to get number formats
 
-    sal_uInt8 nStored = pCell->GetScriptType();
+    ScAddress aPos(nCol, nRow, nTab);
+    sal_uInt8 nStored = GetScriptType(aPos);
     if ( nStored != SC_SCRIPTTYPE_UNKNOWN )         // stored value valid?
         return nStored;                             // use stored value
 
@@ -160,7 +152,8 @@ sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseC
         pCondSet = GetCondResult( nCol, nRow, nTab );
 
     sal_uLong nFormat = pPattern->GetNumberFormat( xPoolHelper->GetFormTable(), pCondSet );
-    return GetCellScriptType( pCell, nFormat );
+
+    return GetCellScriptType(aPos, pCell, nFormat);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b366aa4..1d75d56 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5784,12 +5784,4 @@ void ScDocument::SetAutoNameCache(  ScAutoNameCache* pCache )
     pAutoNameCache = pCache;
 }
 
-sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
-{
-    if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
-        return SC_SCRIPTTYPE_UNKNOWN;
-
-    return maTabs[nTab]->GetScriptType(nCol, nRow);
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 264bba8..474cc19 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1159,7 +1159,7 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p
         rCol.SetTextWidth(nRow, TEXTWIDTH_DIRTY);
 
         if ( bNumFormatChanged )
-            pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+            rCol.SetScriptType(nRow, SC_SCRIPTTYPE_UNKNOWN);
 
         if ( bBroadcast )
         {   // nur bei CalcAsShown
@@ -1201,7 +1201,7 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p
             }
 
             if ( bNumFormatChanged )
-                pCell->SetScriptType( SC_SCRIPTTYPE_UNKNOWN );
+                aCol[nCol].SetScriptType(nRow, SC_SCRIPTTYPE_UNKNOWN);
 
             if ( bBroadcast )
             {   // nur bei CalcAsShown
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index e7464af..7126f14 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1093,9 +1093,10 @@ void ScXMLTableRowCellContext::PutValueCell( const ScAddress& rCurrentPos )
         // will be reset when the style is applied.
 
         ScBaseCell* pNewCell = new ScValueCell(fValue);
+        ScDocument* pDoc = rXMLImport.GetDocument();
         if ( rXMLImport.IsLatinDefaultStyle() )
-            pNewCell->SetScriptType( SCRIPTTYPE_LATIN );
-        rXMLImport.GetDocument()->PutCell(
+            pDoc->SetScriptType(rCurrentPos, SCRIPTTYPE_LATIN);
+        pDoc->PutCell(
             rCurrentPos.Col(), rCurrentPos.Row(),
             rCurrentPos.Tab(), pNewCell );
     }
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 5f537df..2f53d18 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1598,7 +1598,8 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
                     }
 
                     sal_uInt8 nScript = mpDoc->GetCellScriptType(
-                        pCell, pPattern->GetNumberFormat(mpDoc->GetFormatTable(), pCondSet));
+                        ScAddress(nCellX, nCellY, nTab), pCell,
+                        pPattern->GetNumberFormat(mpDoc->GetFormatTable(), pCondSet));
 
                     if (nScript == 0)
                         nScript = ScGlobal::GetDefaultScriptType();
commit 71a06c0b17842b749441b7f0750c5711332b54c2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 15 20:14:57 2013 -0400

    Accessor methods in ScDocument for cell text's script types.
    
    Change-Id: I23349ba6411bd74247e150f871f363b0eacda0a2

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index cb8aac7..d4425d5 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1849,6 +1849,9 @@ public:
     sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
     void SetTextWidth( const ScAddress& rPos, sal_uInt16 nWidth );
 
+    sal_uInt8 GetScriptType( const ScAddress& rPos ) const;
+    void SetScriptType( const ScAddress& rPos, sal_uInt8 nType );
+
 private: // CLOOK-Impl-methods
 
     /**
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ec9c7c6..b366aa4 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5711,6 +5711,22 @@ void ScDocument::SetTextWidth( const ScAddress& rPos, sal_uInt16 nWidth )
         maTabs[nTab]->SetTextWidth(rPos.Col(), rPos.Row(), nWidth);
 }
 
+sal_uInt8 ScDocument::GetScriptType( const ScAddress& rPos ) const
+{
+    SCTAB nTab = rPos.Tab();
+    if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
+        return maTabs[nTab]->GetScriptType(rPos.Col(), rPos.Row());
+
+    return SC_SCRIPTTYPE_UNKNOWN;
+}
+
+void ScDocument::SetScriptType( const ScAddress& rPos, sal_uInt8 nType )
+{
+    SCTAB nTab = rPos.Tab();
+    if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
+        maTabs[nTab]->SetScriptType(rPos.Col(), rPos.Row(), nType);
+}
+
 void ScDocument::EnableUndo( bool bVal )
 {
     // The undo manager increases lock count every time undo is disabled.


More information about the Libreoffice-commits mailing list