LCOV - code coverage report
Current view: top level - sc/source/core/data - documentimport.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 210 274 76.6 %
Date: 2014-04-11 Functions: 26 33 78.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "documentimport.hxx"
      11             : #include "document.hxx"
      12             : #include "table.hxx"
      13             : #include "column.hxx"
      14             : #include "formulacell.hxx"
      15             : #include "docoptio.hxx"
      16             : #include "globalnames.hxx"
      17             : #include "mtvelements.hxx"
      18             : #include "tokenarray.hxx"
      19             : #include "stringutil.hxx"
      20             : #include "compiler.hxx"
      21             : #include "paramisc.hxx"
      22             : #include "listenercontext.hxx"
      23             : 
      24             : #include "svl/sharedstringpool.hxx"
      25             : 
      26         531 : struct ScDocumentImportImpl
      27             : {
      28             :     ScDocument& mrDoc;
      29             :     sc::StartListeningContext maListenCxt;
      30             :     sc::ColumnBlockPositionSet maBlockPosSet;
      31             :     sal_uInt16 mnDefaultScriptNumeric;
      32             : 
      33         531 :     ScDocumentImportImpl(ScDocument& rDoc) :
      34             :         mrDoc(rDoc),
      35             :         maListenCxt(rDoc),
      36             :         maBlockPosSet(rDoc),
      37         531 :         mnDefaultScriptNumeric(SC_SCRIPTTYPE_UNKNOWN) {}
      38             : };
      39             : 
      40         531 : ScDocumentImport::ScDocumentImport(ScDocument& rDoc) : mpImpl(new ScDocumentImportImpl(rDoc)) {}
      41         531 : ScDocumentImport::~ScDocumentImport()
      42             : {
      43         531 :     delete mpImpl;
      44         531 : }
      45             : 
      46        7258 : ScDocument& ScDocumentImport::getDoc()
      47             : {
      48        7258 :     return mpImpl->mrDoc;
      49             : }
      50             : 
      51           0 : const ScDocument& ScDocumentImport::getDoc() const
      52             : {
      53           0 :     return mpImpl->mrDoc;
      54             : }
      55             : 
      56         107 : void ScDocumentImport::setDefaultNumericScript(sal_uInt16 nScript)
      57             : {
      58         107 :     mpImpl->mnDefaultScriptNumeric = nScript;
      59         107 : }
      60             : 
      61          84 : void ScDocumentImport::setCellStyleToSheet(SCTAB nTab, const ScStyleSheet& rStyle)
      62             : {
      63          84 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(nTab);
      64          84 :     if (!pTab)
      65          84 :         return;
      66             : 
      67          84 :     pTab->ApplyStyleArea(0, 0, MAXCOL, MAXROW, rStyle);
      68             : }
      69             : 
      70           0 : SCTAB ScDocumentImport::getSheetIndex(const OUString& rName) const
      71             : {
      72           0 :     SCTAB nTab = -1;
      73           0 :     if (!mpImpl->mrDoc.GetTable(rName, nTab))
      74           0 :         return -1;
      75             : 
      76           0 :     return nTab;
      77             : }
      78             : 
      79           0 : SCTAB ScDocumentImport::getSheetCount() const
      80             : {
      81           0 :     return mpImpl->mrDoc.maTabs.size();
      82             : }
      83             : 
      84           0 : bool ScDocumentImport::appendSheet(const OUString& rName)
      85             : {
      86           0 :     SCTAB nTabCount = mpImpl->mrDoc.maTabs.size();
      87           0 :     if (!ValidTab(nTabCount))
      88           0 :         return false;
      89             : 
      90           0 :     mpImpl->mrDoc.maTabs.push_back(new ScTable(&mpImpl->mrDoc, nTabCount, rName));
      91           0 :     return true;
      92             : }
      93             : 
      94           0 : void ScDocumentImport::setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay)
      95             : {
      96           0 :     if (!mpImpl->mrDoc.pDocOptions)
      97           0 :         mpImpl->mrDoc.pDocOptions = new ScDocOptions;
      98             : 
      99           0 :     mpImpl->mrDoc.pDocOptions->SetDate(nDay, nMonth, nYear);
     100           0 : }
     101             : 
     102         274 : void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr, ScSetStringParam* pStringParam)
     103             : {
     104         274 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     105         274 :     if (!pTab)
     106           0 :         return;
     107             : 
     108             :     sc::ColumnBlockPosition* pBlockPos =
     109         274 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     110             : 
     111         274 :     if (!pBlockPos)
     112           0 :         return;
     113             : 
     114         274 :     ScCellValue aCell;
     115         274 :     pTab->aCol[rPos.Col()].ParseString(
     116         548 :         aCell, rPos.Row(), rPos.Tab(), rStr, mpImpl->mrDoc.GetAddressConvention(), pStringParam);
     117             : 
     118         274 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     119         274 :     switch (aCell.meType)
     120             :     {
     121             :         case CELLTYPE_STRING:
     122             :             // string is copied.
     123         173 :             pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), *aCell.mpString);
     124         173 :         break;
     125             :         case CELLTYPE_EDIT:
     126             :             // Cell takes the ownership of the text object.
     127           0 :             pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aCell.mpEditText);
     128           0 :             aCell.mpEditText = NULL;
     129           0 :         break;
     130             :         case CELLTYPE_VALUE:
     131         101 :             pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aCell.mfValue);
     132         101 :         break;
     133             :         case CELLTYPE_FORMULA:
     134             :             // This formula cell instance is directly placed in the document without copying.
     135           0 :             pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aCell.mpFormula);
     136           0 :             aCell.mpFormula = NULL;
     137           0 :         break;
     138             :         default:
     139           0 :             pBlockPos->miCellPos = rCells.set_empty(pBlockPos->miCellPos, rPos.Row(), rPos.Row());
     140         274 :     }
     141             : }
     142             : 
     143       19964 : void ScDocumentImport::setNumericCell(const ScAddress& rPos, double fVal)
     144             : {
     145       19964 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     146       19964 :     if (!pTab)
     147           0 :         return;
     148             : 
     149             :     sc::ColumnBlockPosition* pBlockPos =
     150       19964 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     151             : 
     152       19964 :     if (!pBlockPos)
     153           0 :         return;
     154             : 
     155       19964 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     156       19964 :     pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), fVal);
     157             : }
     158             : 
     159       12519 : void ScDocumentImport::setStringCell(const ScAddress& rPos, const OUString& rStr)
     160             : {
     161       12519 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     162       12519 :     if (!pTab)
     163           0 :         return;
     164             : 
     165             :     sc::ColumnBlockPosition* pBlockPos =
     166       12519 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     167             : 
     168       12519 :     if (!pBlockPos)
     169           0 :         return;
     170             : 
     171       12519 :     svl::SharedString aSS = mpImpl->mrDoc.GetSharedStringPool().intern(rStr);
     172       12519 :     if (!aSS.getData())
     173           0 :         return;
     174             : 
     175       12519 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     176       12519 :     pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aSS);
     177             : }
     178             : 
     179         115 : void ScDocumentImport::setEditCell(const ScAddress& rPos, EditTextObject* pEditText)
     180             : {
     181         115 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     182         115 :     if (!pTab)
     183           0 :         return;
     184             : 
     185             :     sc::ColumnBlockPosition* pBlockPos =
     186         115 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     187             : 
     188         115 :     if (!pBlockPos)
     189           0 :         return;
     190             : 
     191         115 :     pEditText->NormalizeString(mpImpl->mrDoc.GetSharedStringPool());
     192         115 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     193         115 :     pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), pEditText);
     194             : }
     195             : 
     196           0 : void ScDocumentImport::setFormulaCell(
     197             :     const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar)
     198             : {
     199           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     200           0 :     if (!pTab)
     201           0 :         return;
     202             : 
     203             :     sc::ColumnBlockPosition* pBlockPos =
     204           0 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     205             : 
     206           0 :     if (!pBlockPos)
     207           0 :         return;
     208             : 
     209           0 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     210           0 :     pBlockPos->miCellPos =
     211           0 :         rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, rFormula, eGrammar));
     212             : }
     213             : 
     214           0 : void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray)
     215             : {
     216           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     217           0 :     if (!pTab)
     218           0 :         return;
     219             : 
     220             :     sc::ColumnBlockPosition* pBlockPos =
     221           0 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     222             : 
     223           0 :     if (!pBlockPos)
     224           0 :         return;
     225             : 
     226           0 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     227           0 :     pBlockPos->miCellPos =
     228           0 :         rCells.set(pBlockPos->miCellPos, rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, pArray));
     229             : }
     230             : 
     231        3526 : void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell)
     232             : {
     233        3526 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     234        3526 :     if (!pTab)
     235           0 :         return;
     236             : 
     237             :     sc::ColumnBlockPosition* pBlockPos =
     238        3526 :         mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
     239             : 
     240        3526 :     if (!pBlockPos)
     241           0 :         return;
     242             : 
     243        3526 :     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     244        7052 :     pBlockPos->miCellPos =
     245        7052 :         rCells.set(pBlockPos->miCellPos, rPos.Row(), pCell);
     246             : }
     247             : 
     248          39 : void ScDocumentImport::setMatrixCells(
     249             :     const ScRange& rRange, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram)
     250             : {
     251          39 :     const ScAddress& rBasePos = rRange.aStart;
     252             : 
     253          39 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rBasePos.Tab());
     254          39 :     if (!pTab)
     255           0 :         return;
     256             : 
     257             :     sc::ColumnBlockPosition* pBlockPos =
     258          39 :         mpImpl->maBlockPosSet.getBlockPosition(rBasePos.Tab(), rBasePos.Col());
     259             : 
     260          39 :     if (!pBlockPos)
     261           0 :         return;
     262             : 
     263          39 :     sc::CellStoreType& rCells = pTab->aCol[rBasePos.Col()].maCells;
     264             : 
     265             :     // Set the master cell.
     266          39 :     ScFormulaCell* pCell = new ScFormulaCell(&mpImpl->mrDoc, rBasePos, rArray, eGram, MM_FORMULA);
     267             : 
     268          78 :     pBlockPos->miCellPos =
     269          78 :         rCells.set(pBlockPos->miCellPos, rBasePos.Row(), pCell);
     270             : 
     271             :     // Matrix formulas currently need re-calculation on import.
     272             :     pCell->SetMatColsRows(
     273          39 :         rRange.aEnd.Col()-rRange.aStart.Col()+1, rRange.aEnd.Row()-rRange.aStart.Row()+1, true);
     274             : 
     275             :     // Set the reference cells.
     276             :     ScSingleRefData aRefData;
     277          39 :     aRefData.InitFlags();
     278          39 :     aRefData.SetColRel(true);
     279          39 :     aRefData.SetRowRel(true);
     280          39 :     aRefData.SetTabRel(true);
     281          39 :     aRefData.SetAddress(rBasePos, rBasePos);
     282             : 
     283          39 :     ScTokenArray aArr; // consists only of one single reference token.
     284          39 :     ScToken* t = static_cast<ScToken*>(aArr.AddMatrixSingleReference(aRefData));
     285             : 
     286          39 :     ScAddress aPos = rBasePos;
     287          80 :     for (SCROW nRow = rRange.aStart.Row()+1; nRow <= rRange.aEnd.Row(); ++nRow)
     288             :     {
     289             :         // Token array must be cloned so that each formula cell receives its own copy.
     290          41 :         aPos.SetRow(nRow);
     291             :         // Reference in each cell must point to the origin cell relative to the current cell.
     292          41 :         aRefData.SetAddress(rBasePos, aPos);
     293          41 :         t->GetSingleRef() = aRefData;
     294          41 :         boost::scoped_ptr<ScTokenArray> pTokArr(aArr.Clone());
     295          41 :         pCell = new ScFormulaCell(&mpImpl->mrDoc, aPos, *pTokArr, eGram, MM_REFERENCE);
     296          82 :         pBlockPos->miCellPos =
     297          82 :             rCells.set(pBlockPos->miCellPos, aPos.Row(), pCell);
     298          41 :     }
     299             : 
     300          77 :     for (SCCOL nCol = rRange.aStart.Col()+1; nCol <= rRange.aEnd.Col(); ++nCol)
     301             :     {
     302          38 :         pBlockPos = mpImpl->maBlockPosSet.getBlockPosition(rBasePos.Tab(), nCol);
     303          38 :         if (!pBlockPos)
     304           0 :             return;
     305             : 
     306          38 :         sc::CellStoreType& rColCells = pTab->aCol[nCol].maCells;
     307             : 
     308          38 :         aPos.SetCol(nCol);
     309          90 :         for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
     310             :         {
     311          52 :             aPos.SetRow(nRow);
     312          52 :             aRefData.SetAddress(rBasePos, aPos);
     313          52 :             t->GetSingleRef() = aRefData;
     314          52 :             boost::scoped_ptr<ScTokenArray> pTokArr(aArr.Clone());
     315          52 :             pCell = new ScFormulaCell(&mpImpl->mrDoc, aPos, *pTokArr, eGram, MM_REFERENCE);
     316         104 :             pBlockPos->miCellPos =
     317         104 :                 rColCells.set(pBlockPos->miCellPos, aPos.Row(), pCell);
     318          52 :         }
     319          39 :     }
     320             : }
     321             : 
     322           5 : void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam)
     323             : {
     324           5 :     SCTAB nTab = rRange.aStart.Tab();
     325           5 :     SCCOL nCol1 = rRange.aStart.Col();
     326           5 :     SCROW nRow1 = rRange.aStart.Row();
     327           5 :     SCCOL nCol2 = rRange.aEnd.Col();
     328           5 :     SCROW nRow2 = rRange.aEnd.Row();
     329             : 
     330           5 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(nTab);
     331           5 :     if (!pTab)
     332           0 :         return;
     333             : 
     334           5 :     ScDocument* pDoc = &mpImpl->mrDoc;
     335           5 :     ScRefAddress aRef;
     336           5 :     OUStringBuffer aFormulaBuf('=');
     337           5 :     aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocTableOp));
     338           5 :     aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocOpen));
     339             : 
     340          10 :     OUString aSep = ScCompiler::GetNativeSymbol(ocSep);
     341           5 :     if (rParam.meMode == ScTabOpParam::Column) // column only
     342             :     {
     343           2 :         aRef.Set(rParam.aRefFormulaCell.GetAddress(), true, false, false);
     344           2 :         aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
     345           2 :         aFormulaBuf.append(aSep);
     346           2 :         aFormulaBuf.append(rParam.aRefColCell.GetRefString(pDoc, nTab));
     347           2 :         aFormulaBuf.append(aSep);
     348           2 :         aRef.Set(nCol1, nRow1, nTab, false, true, true);
     349           2 :         aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
     350           2 :         nCol1++;
     351           2 :         nCol2 = std::min( nCol2, (SCCOL)(rParam.aRefFormulaEnd.Col() -
     352           2 :                     rParam.aRefFormulaCell.Col() + nCol1 + 1));
     353             :     }
     354           3 :     else if (rParam.meMode == ScTabOpParam::Row) // row only
     355             :     {
     356           1 :         aRef.Set(rParam.aRefFormulaCell.GetAddress(), false, true, false);
     357           1 :         aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
     358           1 :         aFormulaBuf.append(aSep);
     359           1 :         aFormulaBuf.append(rParam.aRefRowCell.GetRefString(pDoc, nTab));
     360           1 :         aFormulaBuf.append(aSep);
     361           1 :         aRef.Set(nCol1, nRow1, nTab, true, false, true);
     362           1 :         aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
     363           1 :         ++nRow1;
     364             :         nRow2 = std::min(
     365           1 :             nRow2, rParam.aRefFormulaEnd.Row() - rParam.aRefFormulaCell.Row() + nRow1 + 1);
     366             :     }
     367             :     else // both
     368             :     {
     369           2 :         aFormulaBuf.append(rParam.aRefFormulaCell.GetRefString(pDoc, nTab));
     370           2 :         aFormulaBuf.append(aSep);
     371           2 :         aFormulaBuf.append(rParam.aRefColCell.GetRefString(pDoc, nTab));
     372           2 :         aFormulaBuf.append(aSep);
     373           2 :         aRef.Set(nCol1, nRow1 + 1, nTab, false, true, true);
     374           2 :         aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
     375           2 :         aFormulaBuf.append(aSep);
     376           2 :         aFormulaBuf.append(rParam.aRefRowCell.GetRefString(pDoc, nTab));
     377           2 :         aFormulaBuf.append(aSep);
     378           2 :         aRef.Set(nCol1 + 1, nRow1, nTab, true, false, true);
     379           2 :         aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
     380           2 :         ++nCol1;
     381           2 :         ++nRow1;
     382             :     }
     383             : 
     384           5 :     aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocClose));
     385             : 
     386             :     ScFormulaCell aRefCell(
     387             :         pDoc, ScAddress(nCol1, nRow1, nTab), aFormulaBuf.makeStringAndClear(),
     388          10 :         formula::FormulaGrammar::GRAM_NATIVE, MM_NONE);
     389             : 
     390          26 :     for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
     391             :     {
     392             :         sc::ColumnBlockPosition* pBlockPos =
     393          21 :             mpImpl->maBlockPosSet.getBlockPosition(nTab, nCol);
     394             : 
     395          21 :         if (!pBlockPos)
     396             :             // Something went horribly wrong.
     397           0 :             return;
     398             : 
     399          21 :         sc::CellStoreType& rColCells = pTab->aCol[nCol].maCells;
     400             : 
     401         186 :         for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
     402             :         {
     403         165 :             ScAddress aPos(nCol, nRow, nTab);
     404         165 :             ScFormulaCell* pCell = new ScFormulaCell(aRefCell, *pDoc, aPos);
     405         330 :             pBlockPos->miCellPos =
     406         165 :                 rColCells.set(pBlockPos->miCellPos, nRow, pCell);
     407             :         }
     408           5 :     }
     409             : }
     410             : 
     411             : namespace {
     412             : 
     413     2549760 : class CellStoreInitializer
     414             : {
     415             :     // The pimpl pattern here is intentional.
     416             :     //
     417             :     // The problem with having the attributes in CellStoreInitializer
     418             :     // directly is that, as a functor, it might be copied around. In
     419             :     // that case miPos in _copied_ object points ot maAttrs in the
     420             :     // original object, not in the copy. So later, deep in mdds, we end
     421             :     // up comparing iterators from different sequences.
     422             :     //
     423             :     // This could be solved by defining copy constructor and operator=,
     424             :     // but given the limited usage of the class, I think it is simpler
     425             :     // to let copies share the state.
     426      509952 :     struct Impl
     427             :     {
     428             :         sc::CellTextAttrStoreType maAttrs;
     429             :         sc::CellTextAttrStoreType::iterator miPos;
     430             :         sal_uInt16 mnScriptNumeric;
     431             : 
     432      509952 :         Impl(const sal_uInt32 nMaxRowCount, const sal_uInt16 nScriptNumeric)
     433      509952 :             : maAttrs(nMaxRowCount), miPos(maAttrs.begin()), mnScriptNumeric(nScriptNumeric)
     434      509952 :         {}
     435             :     };
     436             : 
     437             :     ScDocument& mrDoc;
     438             :     sc::StartListeningContext& mrListenCxt;
     439             : 
     440             : public:
     441      509952 :     CellStoreInitializer(ScDocument& rDoc, sc::StartListeningContext& rCxt, sal_uInt16 nScriptNumeric) :
     442             :         mrDoc(rDoc),
     443             :         mrListenCxt(rCxt),
     444      509952 :         mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric))
     445      509952 :     {}
     446             : 
     447             :     boost::shared_ptr<Impl> mpImpl;
     448             : 
     449      524475 :     void operator() (const sc::CellStoreType::value_type& node)
     450             :     {
     451      524475 :         if (node.type == sc::element_type_empty)
     452     1040489 :             return;
     453             : 
     454             :         // Fill with default values for non-empty cell segments.
     455        8461 :         sc::CellTextAttr aDefault;
     456        8461 :         if (node.type == sc::element_type_numeric)
     457        3884 :             aDefault.mnScriptType = mpImpl->mnScriptNumeric;
     458        8461 :         std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
     459        8461 :         mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
     460             : 
     461        8461 :         if (node.type == sc::element_type_formula)
     462             :         {
     463             :             // Have all formula cells start listening to the document.
     464        1207 :             sc::formula_block::iterator it = sc::formula_block::begin(*node.data);
     465        1207 :             sc::formula_block::iterator itEnd = sc::formula_block::end(*node.data);
     466        5031 :             for (; it != itEnd; ++it)
     467             :             {
     468        3824 :                 ScFormulaCell& rFC = **it;
     469        3824 :                 rFC.StartListeningTo(mrListenCxt);
     470             :             }
     471        8461 :         }
     472             :     }
     473             : 
     474      509952 :     void swap(sc::CellTextAttrStoreType& rAttrs)
     475             :     {
     476      509952 :         mpImpl->maAttrs.swap(rAttrs);
     477      509952 :     }
     478             : };
     479             : 
     480             : }
     481             : 
     482         216 : void ScDocumentImport::finalize()
     483             : {
     484             :     // Populate the text width and script type arrays in all columns. Also
     485             :     // activate all formula cells.
     486         216 :     ScDocument::TableContainer::iterator itTab = mpImpl->mrDoc.maTabs.begin(), itTabEnd = mpImpl->mrDoc.maTabs.end();
     487         714 :     for (; itTab != itTabEnd; ++itTab)
     488             :     {
     489         498 :         if (!*itTab)
     490           0 :             continue;
     491             : 
     492         498 :         ScTable& rTab = **itTab;
     493         498 :         ScColumn* pCol = &rTab.aCol[0];
     494         498 :         ScColumn* pColEnd = pCol + static_cast<size_t>(MAXCOLCOUNT);
     495      510450 :         for (; pCol != pColEnd; ++pCol)
     496      509952 :             initColumn(*pCol);
     497             :     }
     498         216 : }
     499             : 
     500      509952 : void ScDocumentImport::initColumn(ScColumn& rCol)
     501             : {
     502      509952 :     CellStoreInitializer aFunc(mpImpl->mrDoc, mpImpl->maListenCxt, mpImpl->mnDefaultScriptNumeric);
     503      509952 :     std::for_each(rCol.maCells.begin(), rCol.maCells.end(), aFunc);
     504      509952 :     aFunc.swap(rCol.maCellTextAttrs);
     505      509952 :     rCol.RegroupFormulaCells();
     506      509952 :     rCol.CellStorageModified();
     507      510054 : }
     508             : 
     509             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10