[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf' - sc/source

Daniel Bankston dbank at kemper.freedesktop.org
Sat Jun 16 02:44:57 PDT 2012


 sc/source/filter/xml/xmlcelli.cxx |   58 ++++++-------------
 sc/source/filter/xml/xmlcelli.hxx |    1 
 sc/source/filter/xml/xmlsubti.cxx |   39 +------------
 sc/source/filter/xml/xmlsubti.hxx |    1 
 sc/source/filter/xml/xmltabi.cxx  |  113 +++++++++++++++++---------------------
 sc/source/filter/xml/xmltabi.hxx  |    4 -
 6 files changed, 75 insertions(+), 141 deletions(-)

New commits:
commit 8d4d75c7d67832c65472d48637d1a200682c4d5f
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Sat Jun 16 04:42:05 2012 -0500

    Remove subtable import code since sc core doesn't support it
    
    Change-Id: Ic9be156a9468bec4bccdce40ddd51344002067f9

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index ce52a6c..56aafc7 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -133,7 +133,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
     nCellType(util::NumberFormat::TEXT),
     bIsMerged(false),
     bIsMatrix(false),
-    bHasSubTable(false),
     bIsCovered(bTempIsCovered),
     bIsEmpty(true),
     bHasTextImport(false),
@@ -399,23 +398,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
         break;
         case XML_TOK_TABLE_ROW_CELL_TABLE:
         {
-            const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-            rtl::OUString aLocalName;
-            for( sal_Int16 i=0; i < nAttrCount; i++ )
-            {
-                sal_uInt16 nAttrPrefix = rXMLImport.GetNamespaceMap().GetKeyByAttrName(
-                                                    xAttrList->getNameByIndex( i ), &aLocalName );
-                if (    nAttrPrefix == XML_NAMESPACE_TABLE
-                    &&  IsXMLToken(aLocalName, XML_IS_SUB_TABLE))
-                {
-                    bHasSubTable = IsXMLToken(xAttrList->getValueByIndex( i ), XML_TRUE);
-                }
-            }
-            OSL_ENSURE(bHasSubTable, "it should be a subtable");
-            pContext = new ScXMLTableContext( rXMLImport , nPrefix,
-                            rLName, xAttrList, true, static_cast<sal_Int32>(nMergedCols) );
-            nMergedCols = 1;
-            bIsMerged = false;
+            SAL_WARN("sc", "ScXMLTableRowCellContext::CreateChildContext: subtables are not supported");
         }
         break;
         case XML_TOK_TABLE_ROW_CELL_ANNOTATION:
@@ -1106,34 +1089,31 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
 
 void ScXMLTableRowCellContext::EndElement()
 {
-    if( !bHasSubTable )
+    if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
     {
-        if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
+        UniReference< XMLTextImportHelper > aTextImport = rXMLImport.GetTextImport();
+        if( aTextImport->GetCursor().is() )
         {
-            UniReference< XMLTextImportHelper > aTextImport = rXMLImport.GetTextImport();
-            if( aTextImport->GetCursor().is() )
+            if( aTextImport->GetCursor()->goLeft(1, true) )
             {
-                if( aTextImport->GetCursor()->goLeft(1, true) )
-                {
-                    aTextImport->GetText()->insertString(
-                        aTextImport->GetCursorAsRange(), rtl::OUString(), true );
-                }
-                aTextImport->ResetCursor();
+                aTextImport->GetText()->insertString(
+                    aTextImport->GetCursorAsRange(), rtl::OUString(), true );
             }
+            aTextImport->ResetCursor();
         }
-
-        ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
-        if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
-            aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
-        if( bIsMerged )
-            DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
-        if( !pOUFormula )
-            AddNonFormulaCells( aCellPos );
-        else // if ( pOUFormula )
-            AddFormulaCell( aCellPos );
     }
+
+    ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos();
+    if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
+        aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
+    if( bIsMerged )
+        DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
+    if( !pOUFormula )
+        AddNonFormulaCells( aCellPos );
+    else // if ( pOUFormula )
+        AddFormulaCell( aCellPos );
+
     bIsMerged = false;
-    bHasSubTable = false;
     nMergedCols = 1;
     nMergedRows = 1;
     nColsRepeated = 1;
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index cf1b091..3df155e 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -67,7 +67,6 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
     sal_Int16   nCellType;
     bool        bIsMerged;
     bool        bIsMatrix;
-    bool        bHasSubTable;
     bool        bIsCovered;
     bool        bIsEmpty;
     bool        bHasTextImport;
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 950cbbd..3d88df0 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -223,7 +223,9 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
         }
     }
 
-    NewTable(1);
+    maTables.push_back(new ScMyTableData(nCurrentSheet));
+    pCurrentTab = & maTables.back();
+    pCurrentTab->SetSpannedCols(1);
 }
 
 void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
@@ -372,41 +374,6 @@ void ScMyTables::AddColumn(bool bIsCovered)
     }
 }
 
-void ScMyTables::NewTable(sal_Int32 nTempSpannedCols)
-{
-    maTables.push_back(new ScMyTableData(nCurrentSheet));
-    pCurrentTab = & maTables.back();
-
-    size_t nTables = maTables.size();
-    if (nTables > 1)
-    {
-        ScMyTableData& rFirstTab = maTables.front();
-
-        const sal_Int32 nCol = rFirstTab.GetColumn();
-        const sal_Int32 nColCount = rFirstTab.GetColCount();
-        const sal_Int32 nColsPerCol = rFirstTab.GetColsPerCol(nCol);
-
-        sal_Int32 nSpannedCols = rFirstTab.GetSpannedCols();
-        sal_Int32 nTemp = nSpannedCols - nColCount;
-        sal_Int32 nTemp2 = nCol - nColCount + 1;
-        if ((nTemp > 0) && (nTemp2 == 0))
-            nTempSpannedCols *= nTemp + 1;
-        else
-            if (nColsPerCol > 1)
-                nTempSpannedCols *= nColsPerCol;
-
-        sal_Int32 nToMerge;
-        if (nSpannedCols > nColCount)
-            nToMerge = rFirstTab.GetChangedCols(nCol, nCol + nColsPerCol + nSpannedCols - nColCount);
-        else
-            nToMerge = rFirstTab.GetChangedCols(nCol, nCol + nColsPerCol);
-        if (nToMerge > nCol)
-            nTempSpannedCols += nToMerge;
-    }
-
-    pCurrentTab->SetSpannedCols(nTempSpannedCols);
-}
-
 void ScMyTables::UpdateRowHeights()
 {
     if (rImport.GetModel().is())
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index edab1bd..8252f4c 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -155,7 +155,6 @@ public:
     void                                AddRow();
     void                                SetRowStyle(const rtl::OUString& rCellStyleName);
     void                                AddColumn(bool bIsCovered);
-    void                                NewTable(sal_Int32 nTempSpannedCols);
     void                                UpdateRowHeights();
     void                                FixupOLEs() { aFixupOLEs.FixupOLEs(); }
     bool                                IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 7add17f..7384e3b 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -155,9 +155,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
                                       sal_uInt16 nPrfx,
                                       const ::rtl::OUString& rLName,
                                       const ::com::sun::star::uno::Reference<
-                                      ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
-                                      const bool bTempIsSubTable,
-                                      const sal_Int32 nSpannedCols) :
+                                      ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) :
     SvXMLImportContext( rImport, nPrfx, rLName ),
     pExternalRefInfo(NULL),
     nStartOffset(-1),
@@ -167,77 +165,70 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
     // get start offset in file (if available)
     nStartOffset = GetScImport().GetByteOffset();
 
-    if (!bTempIsSubTable)
+    ScXMLTabProtectionData aProtectData;
+    rtl::OUString sName;
+    rtl::OUString sStyleName;
+    sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+    const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap();
+    for( sal_Int16 i=0; i < nAttrCount; ++i )
     {
-        ScXMLTabProtectionData aProtectData;
-        rtl::OUString sName;
-        rtl::OUString sStyleName;
-        sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
-        const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableAttrTokenMap();
-        for( sal_Int16 i=0; i < nAttrCount; ++i )
-        {
-            const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
-            rtl::OUString aLocalName;
-            sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
-                                                sAttrName, &aLocalName ));
-            const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+        const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+        rtl::OUString aLocalName;
+        sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+                                            sAttrName, &aLocalName ));
+        const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
 
-            switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
-            {
-                case XML_TOK_TABLE_NAME:
-                        sName = sValue;
-                    break;
-                case XML_TOK_TABLE_STYLE_NAME:
-                        sStyleName = sValue;
-                    break;
-                case XML_TOK_TABLE_PROTECTED:
-                    aProtectData.mbProtected = IsXMLToken(sValue, XML_TRUE);
+        switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+        {
+            case XML_TOK_TABLE_NAME:
+                    sName = sValue;
                 break;
-                case XML_TOK_TABLE_PRINT_RANGES:
-                        sPrintRanges = sValue;
-                    break;
-                case XML_TOK_TABLE_PASSWORD:
-                    aProtectData.maPassword = sValue;
+            case XML_TOK_TABLE_STYLE_NAME:
+                    sStyleName = sValue;
                 break;
-                case XML_TOK_TABLE_PASSHASH:
-                    aProtectData.meHash1 = ScPassHashHelper::getHashTypeFromURI(sValue);
+            case XML_TOK_TABLE_PROTECTED:
+                aProtectData.mbProtected = IsXMLToken(sValue, XML_TRUE);
+            break;
+            case XML_TOK_TABLE_PRINT_RANGES:
+                    sPrintRanges = sValue;
                 break;
-                case XML_TOK_TABLE_PASSHASH_2:
-                    aProtectData.meHash2 = ScPassHashHelper::getHashTypeFromURI(sValue);
+            case XML_TOK_TABLE_PASSWORD:
+                aProtectData.maPassword = sValue;
+            break;
+            case XML_TOK_TABLE_PASSHASH:
+                aProtectData.meHash1 = ScPassHashHelper::getHashTypeFromURI(sValue);
+            break;
+            case XML_TOK_TABLE_PASSHASH_2:
+                aProtectData.meHash2 = ScPassHashHelper::getHashTypeFromURI(sValue);
+            break;
+            case XML_TOK_TABLE_PRINT:
+                {
+                    if (IsXMLToken(sValue, XML_FALSE))
+                        bPrintEntireSheet = false;
+                }
                 break;
-                case XML_TOK_TABLE_PRINT:
-                    {
-                        if (IsXMLToken(sValue, XML_FALSE))
-                            bPrintEntireSheet = false;
-                    }
-                    break;
-            }
         }
+    }
 
-        rtl::OUString aExtUrl, aExtTabName;
-        if (lcl_isExternalRefCache(sName, aExtUrl, aExtTabName))
-        {
-            // This is an external ref cache table.
-            pExternalRefInfo.reset(new ScXMLExternalTabData);
-            pExternalRefInfo->maFileUrl = aExtUrl;
-            ScDocument* pDoc = GetScImport().GetDocument();
-            if (pDoc)
-            {
-                ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
-                pExternalRefInfo->mnFileId = pRefMgr->getExternalFileId(aExtUrl);
-                pExternalRefInfo->mpCacheTable = pRefMgr->getCacheTable(pExternalRefInfo->mnFileId, aExtTabName, true);
-                pExternalRefInfo->mpCacheTable->setWholeTableCached();
-            }
-        }
-        else
+    rtl::OUString aExtUrl, aExtTabName;
+    if (lcl_isExternalRefCache(sName, aExtUrl, aExtTabName))
+    {
+        // This is an external ref cache table.
+        pExternalRefInfo.reset(new ScXMLExternalTabData);
+        pExternalRefInfo->maFileUrl = aExtUrl;
+        ScDocument* pDoc = GetScImport().GetDocument();
+        if (pDoc)
         {
-            // This is a regular table.
-            GetScImport().GetTables().NewSheet(sName, sStyleName, aProtectData);
+            ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+            pExternalRefInfo->mnFileId = pRefMgr->getExternalFileId(aExtUrl);
+            pExternalRefInfo->mpCacheTable = pRefMgr->getCacheTable(pExternalRefInfo->mnFileId, aExtTabName, true);
+            pExternalRefInfo->mpCacheTable->setWholeTableCached();
         }
     }
     else
     {
-        GetScImport().GetTables().NewTable(nSpannedCols);
+        // This is a regular table.
+        GetScImport().GetTables().NewSheet(sName, sStyleName, aProtectData);
     }
 }
 
diff --git a/sc/source/filter/xml/xmltabi.hxx b/sc/source/filter/xml/xmltabi.hxx
index 8ccf841..8a55978 100644
--- a/sc/source/filter/xml/xmltabi.hxx
+++ b/sc/source/filter/xml/xmltabi.hxx
@@ -62,9 +62,7 @@ public:
     ScXMLTableContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
                         const ::rtl::OUString& rLName,
                         const ::com::sun::star::uno::Reference<
-                                        ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
-                        const bool bTempIsSubTable = false,
-                        const sal_Int32 nSpannedCols = 0);
+                                        ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
 
     virtual ~ScXMLTableContext();
 


More information about the Libreoffice-commits mailing list