LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/core/data - documentimport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 68 1.5 %
Date: 2013-07-09 Functions: 2 18 11.1 %
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             : 
      19           0 : struct ScDocumentImportImpl
      20             : {
      21             :     ScDocument& mrDoc;
      22             :     sc::ColumnBlockPositionSet maBlockPosSet;
      23             : 
      24           0 :     ScDocumentImportImpl(ScDocument& rDoc) : mrDoc(rDoc), maBlockPosSet(rDoc) {}
      25             : };
      26             : 
      27           0 : ScDocumentImport::ScDocumentImport(ScDocument& rDoc) : mpImpl(new ScDocumentImportImpl(rDoc)) {}
      28           0 : ScDocumentImport::~ScDocumentImport()
      29             : {
      30           0 :     delete mpImpl;
      31           0 : }
      32             : 
      33           0 : ScDocument& ScDocumentImport::getDoc()
      34             : {
      35           0 :     return mpImpl->mrDoc;
      36             : }
      37             : 
      38           0 : const ScDocument& ScDocumentImport::getDoc() const
      39             : {
      40           0 :     return mpImpl->mrDoc;
      41             : }
      42             : 
      43           0 : SCTAB ScDocumentImport::getSheetIndex(const OUString& rName) const
      44             : {
      45           0 :     SCTAB nTab = -1;
      46           0 :     if (!mpImpl->mrDoc.GetTable(rName, nTab))
      47           0 :         return -1;
      48             : 
      49           0 :     return nTab;
      50             : }
      51             : 
      52           0 : SCTAB ScDocumentImport::getSheetCount() const
      53             : {
      54           0 :     return mpImpl->mrDoc.maTabs.size();
      55             : }
      56             : 
      57           0 : bool ScDocumentImport::appendSheet(const OUString& rName)
      58             : {
      59           0 :     SCTAB nTabCount = mpImpl->mrDoc.maTabs.size();
      60           0 :     if (!ValidTab(nTabCount))
      61           0 :         return false;
      62             : 
      63           0 :     mpImpl->mrDoc.maTabs.push_back(new ScTable(&mpImpl->mrDoc, nTabCount, rName));
      64           0 :     return true;
      65             : }
      66             : 
      67           0 : void ScDocumentImport::setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay)
      68             : {
      69           0 :     if (!mpImpl->mrDoc.pDocOptions)
      70           0 :         mpImpl->mrDoc.pDocOptions = new ScDocOptions;
      71             : 
      72           0 :     mpImpl->mrDoc.pDocOptions->SetDate(nDay, nMonth, nYear);
      73           0 : }
      74             : 
      75           0 : void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr)
      76             : {
      77           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
      78           0 :     if (!pTab)
      79           0 :         return;
      80             : 
      81           0 :     pTab->aCol[rPos.Col()].SetString(
      82           0 :         rPos.Row(), rPos.Tab(), rStr, mpImpl->mrDoc.GetAddressConvention());
      83             : }
      84             : 
      85           0 : void ScDocumentImport::setNumericCell(const ScAddress& rPos, double fVal)
      86             : {
      87           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
      88           0 :     if (!pTab)
      89           0 :         return;
      90             : 
      91           0 :     pTab->aCol[rPos.Col()].SetValue(rPos.Row(), fVal);
      92             : }
      93             : 
      94           0 : void ScDocumentImport::setStringCell(const ScAddress& rPos, const OUString& rStr)
      95             : {
      96           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
      97           0 :     if (!pTab)
      98           0 :         return;
      99             : 
     100           0 :     pTab->aCol[rPos.Col()].SetRawString(rPos.Row(), rStr);
     101             : }
     102             : 
     103           0 : void ScDocumentImport::setFormulaCell(
     104             :     const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar)
     105             : {
     106           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     107           0 :     if (!pTab)
     108           0 :         return;
     109             : 
     110           0 :     pTab->aCol[rPos.Col()].SetFormulaCell(
     111           0 :         rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, rFormula, eGrammar));
     112             : }
     113             : 
     114           0 : void ScDocumentImport::setFormulaCell(const ScAddress& rPos, const ScTokenArray& rArray)
     115             : {
     116           0 :     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     117           0 :     if (!pTab)
     118           0 :         return;
     119             : 
     120           0 :     pTab->aCol[rPos.Col()].SetFormulaCell(
     121           0 :         rPos.Row(), new ScFormulaCell(&mpImpl->mrDoc, rPos, &rArray));
     122             : }
     123             : 
     124           0 : void ScDocumentImport::finalize()
     125             : {
     126             :     // Populate the text width and script type arrays in all columns.
     127           0 :     ScDocument::TableContainer::iterator itTab = mpImpl->mrDoc.maTabs.begin(), itTabEnd = mpImpl->mrDoc.maTabs.end();
     128           0 :     for (; itTab != itTabEnd; ++itTab)
     129             :     {
     130           0 :         if (!*itTab)
     131           0 :             continue;
     132             : 
     133           0 :         ScTable& rTab = **itTab;
     134           0 :         ScColumn* pCol = &rTab.aCol[0];
     135           0 :         ScColumn* pColEnd = pCol + static_cast<size_t>(MAXCOLCOUNT);
     136           0 :         for (; pCol != pColEnd; ++pCol)
     137             :         {
     138           0 :             ScColumn& rCol = *pCol;
     139           0 :             rCol.ResetCellTextAttrs();
     140             :         }
     141             :     }
     142          93 : }
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10