LCOV - code coverage report
Current view: top level - sc/source/filter/xml - XMLStylesImportHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 258 286 90.2 %
Date: 2012-08-25 Functions: 25 25 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 206 348 59.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "XMLStylesImportHelper.hxx"
      30                 :            : #include "xmlimprt.hxx"
      31                 :            : #include <com/sun/star/util/NumberFormat.hpp>
      32                 :            : 
      33                 :            : using namespace com::sun::star;
      34                 :            : using ::std::list;
      35                 :            : 
      36                 :        205 : void ScMyStyleNumberFormats::AddStyleNumberFormat(const rtl::OUString& rStyleName, const sal_Int32 nNumberFormat)
      37                 :            : {
      38         [ +  - ]:        205 :     aSet.insert(ScMyStyleNumberFormat(rStyleName, nNumberFormat));
      39                 :        205 : }
      40                 :            : 
      41                 :        308 : sal_Int32 ScMyStyleNumberFormats::GetStyleNumberFormat(const rtl::OUString& rStyleName)
      42                 :            : {
      43                 :        308 :     ScMyStyleNumberFormat aStyleNumberFormat(rStyleName);
      44         [ +  - ]:        308 :     ScMyStyleNumberFormatSet::iterator aItr(aSet.find(aStyleNumberFormat));
      45         [ +  + ]:        308 :     if (aItr == aSet.end())
      46                 :         99 :         return -1;
      47                 :            :     else
      48                 :        308 :         return aItr->nNumberFormat;
      49                 :            : }
      50                 :            : 
      51                 :      13139 : ScMyStyleRanges::ScMyStyleRanges() :
      52 [ +  - ][ +  - ]:      13139 :     pCurrencyList(NULL)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      53                 :            : {
      54                 :      13139 : }
      55                 :            : 
      56 [ +  - ][ +  - ]:      13139 : ScMyStyleRanges::~ScMyStyleRanges()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      57                 :            : {
      58         [ +  + ]:      13139 :     delete pCurrencyList;
      59         [ -  + ]:      26278 : }
      60                 :            : 
      61                 :       8403 : void ScMyStyleRanges::AddRange(const ScRange& rRange,
      62                 :            :     const rtl::OUString* /*pStyleName*/, const sal_Int16 nType,
      63                 :            :     ScXMLImport& /*rImport*/, const sal_uInt32 /*nMaxRanges*/)
      64                 :            : {
      65   [ +  +  +  -  :       8403 :     switch (nType)
             +  +  +  - ]
      66                 :            :     {
      67                 :            :         case util::NumberFormat::NUMBER:
      68                 :            :         {
      69         [ +  + ]:       3725 :             if (!mpNumberList)
      70         [ +  - ]:        195 :                 mpNumberList.reset(new ScSimpleRangeList);
      71                 :       3725 :             mpNumberList->addRange(rRange);
      72                 :            :         }
      73                 :       3725 :         break;
      74                 :            :         case util::NumberFormat::TEXT:
      75                 :            :         {
      76         [ +  + ]:       4540 :             if (!mpTextList)
      77         [ +  - ]:        421 :                 mpTextList.reset(new ScSimpleRangeList);
      78                 :       4540 :             mpTextList->addRange(rRange);
      79                 :            :         }
      80                 :       4540 :         break;
      81                 :            :         case util::NumberFormat::TIME:
      82                 :            :         {
      83         [ +  - ]:          3 :             if (!mpTimeList)
      84         [ +  - ]:          3 :                 mpTimeList.reset(new ScSimpleRangeList);
      85                 :          3 :             mpTimeList->addRange(rRange);
      86                 :            :         }
      87                 :          3 :         break;
      88                 :            :         case util::NumberFormat::DATETIME:
      89                 :            :         {
      90         [ #  # ]:          0 :             if (!mpDateTimeList)
      91         [ #  # ]:          0 :                 mpDateTimeList.reset(new ScSimpleRangeList);
      92                 :          0 :             mpDateTimeList->addRange(rRange);
      93                 :            :         }
      94                 :          0 :         break;
      95                 :            :         case util::NumberFormat::PERCENT:
      96                 :            :         {
      97         [ +  - ]:          6 :             if (!mpPercentList)
      98         [ +  - ]:          6 :                 mpPercentList.reset(new ScSimpleRangeList);
      99                 :          6 :             mpPercentList->addRange(rRange);
     100                 :            :         }
     101                 :          6 :         break;
     102                 :            :         case util::NumberFormat::LOGICAL:
     103                 :            :         {
     104         [ +  + ]:        123 :             if (!mpLogicalList)
     105         [ +  - ]:         21 :                 mpLogicalList.reset(new ScSimpleRangeList);
     106                 :        123 :             mpLogicalList->addRange(rRange);
     107                 :            :         }
     108                 :        123 :         break;
     109                 :            :         case util::NumberFormat::UNDEFINED:
     110                 :            :         {
     111         [ +  + ]:          6 :             if (!mpUndefinedList)
     112         [ +  - ]:          3 :                 mpUndefinedList.reset(new ScSimpleRangeList);
     113                 :          6 :             mpUndefinedList->addRange(rRange);
     114                 :            :         }
     115                 :          6 :         break;
     116                 :            :         default:
     117                 :            :         {
     118                 :            :             OSL_FAIL("wrong type");
     119                 :            :         }
     120                 :          0 :         break;
     121                 :            :     }
     122                 :       8403 : }
     123                 :            : 
     124                 :          3 : void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange,
     125                 :            :     const rtl::OUString* /*pStyleName*/, const rtl::OUString* pCurrency,
     126                 :            :     ScXMLImport& /*rImport*/, const sal_uInt32 /*nMaxRanges*/)
     127                 :            : {
     128         [ +  - ]:          3 :     if (!pCurrencyList)
     129 [ +  - ][ +  - ]:          3 :         pCurrencyList = new ScMyCurrencyStylesSet();
     130         [ +  - ]:          3 :     ScMyCurrencyStyle aStyle;
     131         [ +  - ]:          3 :     if (pCurrency)
     132                 :          3 :         aStyle.sCurrency = *pCurrency;
     133         [ +  - ]:          3 :     ScMyCurrencyStylesSet::iterator aItr(pCurrencyList->find(aStyle));
     134         [ +  - ]:          3 :     if (aItr == pCurrencyList->end())
     135                 :            :     {
     136         [ +  - ]:          3 :         std::pair<ScMyCurrencyStylesSet::iterator, bool> aPair(pCurrencyList->insert(aStyle));
     137         [ +  - ]:          3 :         if (aPair.second)
     138                 :            :         {
     139                 :          3 :             aItr = aPair.first;
     140         [ +  - ]:          3 :             aItr->mpRanges->addRange(rRange);
     141                 :            :         }
     142                 :            :     }
     143                 :            :     else
     144 [ #  # ][ +  - ]:          3 :         aItr->mpRanges->addRange(rRange);
     145                 :          3 : }
     146                 :            : 
     147                 :       3825 : void ScMyStyleRanges::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab, ScDocument* /*pDoc*/)
     148                 :            : {
     149         [ +  + ]:       3825 :     if (mpTextList)
     150                 :         82 :         mpTextList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     151         [ +  + ]:       3825 :     if (mpNumberList)
     152                 :         63 :         mpNumberList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     153         [ -  + ]:       3825 :     if (mpTimeList)
     154                 :          0 :         mpTimeList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     155         [ -  + ]:       3825 :     if (mpDateTimeList)
     156                 :          0 :         mpDateTimeList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     157         [ -  + ]:       3825 :     if (mpPercentList)
     158                 :          0 :         mpPercentList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     159         [ -  + ]:       3825 :     if (mpLogicalList)
     160                 :          0 :         mpLogicalList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     161         [ -  + ]:       3825 :     if (mpUndefinedList)
     162                 :          0 :         mpUndefinedList->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     163                 :            : 
     164         [ -  + ]:       3825 :     if (pCurrencyList)
     165                 :            :     {
     166                 :          0 :         ScMyCurrencyStylesSet::iterator aItr(pCurrencyList->begin());
     167                 :          0 :         ScMyCurrencyStylesSet::iterator aEndItr(pCurrencyList->end());
     168         [ #  # ]:          0 :         while (aItr != aEndItr)
     169                 :            :         {
     170         [ #  # ]:          0 :             aItr->mpRanges->insertCol(static_cast<SCCOL>(nCol), static_cast<SCTAB>(nTab));
     171                 :          0 :             ++aItr;
     172                 :            :         }
     173                 :            :     }
     174                 :       3825 : }
     175                 :            : 
     176                 :        652 : void ScMyStyleRanges::SetStylesToRanges(const list<ScRange>& rRanges,
     177                 :            :     const rtl::OUString* pStyleName, const sal_Int16 nCellType,
     178                 :            :     const rtl::OUString* pCurrency, ScXMLImport& rImport)
     179                 :            : {
     180                 :        652 :     list<ScRange>::const_iterator itr = rRanges.begin(), itrEnd = rRanges.end();
     181         [ +  + ]:       2211 :     for (; itr != itrEnd; ++itr)
     182         [ +  - ]:       1559 :         rImport.SetStyleToRange(*itr, pStyleName, nCellType, pCurrency);
     183                 :        652 : }
     184                 :            : 
     185                 :        777 : void ScMyStyleRanges::SetStylesToRanges(const rtl::OUString* pStyleName, ScXMLImport& rImport)
     186                 :            : {
     187         [ +  + ]:        777 :     if (mpNumberList)
     188                 :            :     {
     189         [ +  - ]:        195 :         list<ScRange> aList;
     190         [ +  - ]:        195 :         mpNumberList->getRangeList(aList);
     191         [ +  - ]:        195 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::NUMBER, NULL, rImport);
     192         [ +  - ]:        195 :         mpNumberList->clear();
     193                 :            :     }
     194         [ +  + ]:        777 :     if (mpTextList)
     195                 :            :     {
     196         [ +  - ]:        421 :         list<ScRange> aList;
     197         [ +  - ]:        421 :         mpTextList->getRangeList(aList);
     198         [ +  - ]:        421 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::TEXT, NULL, rImport);
     199         [ +  - ]:        421 :         mpTextList->clear();
     200                 :            :     }
     201         [ +  + ]:        777 :     if (mpTimeList)
     202                 :            :     {
     203         [ +  - ]:          3 :         list<ScRange> aList;
     204         [ +  - ]:          3 :         mpTimeList->getRangeList(aList);
     205         [ +  - ]:          3 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::TIME, NULL, rImport);
     206         [ +  - ]:          3 :         mpTimeList->clear();
     207                 :            :     }
     208         [ -  + ]:        777 :     if (mpDateTimeList)
     209                 :            :     {
     210         [ #  # ]:          0 :         list<ScRange> aList;
     211         [ #  # ]:          0 :         mpDateTimeList->getRangeList(aList);
     212         [ #  # ]:          0 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::DATETIME, NULL, rImport);
     213         [ #  # ]:          0 :         mpDateTimeList->clear();
     214                 :            :     }
     215         [ +  + ]:        777 :     if (mpPercentList)
     216                 :            :     {
     217         [ +  - ]:          6 :         list<ScRange> aList;
     218         [ +  - ]:          6 :         mpPercentList->getRangeList(aList);
     219         [ +  - ]:          6 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::PERCENT, NULL, rImport);
     220         [ +  - ]:          6 :         mpPercentList->clear();
     221                 :            :     }
     222         [ +  + ]:        777 :     if (mpLogicalList)
     223                 :            :     {
     224         [ +  - ]:         21 :         list<ScRange> aList;
     225         [ +  - ]:         21 :         mpLogicalList->getRangeList(aList);
     226         [ +  - ]:         21 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::LOGICAL, NULL, rImport);
     227         [ +  - ]:         21 :         mpLogicalList->clear();
     228                 :            :     }
     229         [ +  + ]:        777 :     if (mpUndefinedList)
     230                 :            :     {
     231         [ +  - ]:          3 :         list<ScRange> aList;
     232         [ +  - ]:          3 :         mpUndefinedList->getRangeList(aList);
     233         [ +  - ]:          3 :         SetStylesToRanges(aList, pStyleName, util::NumberFormat::UNDEFINED, NULL, rImport);
     234         [ +  - ]:          3 :         mpUndefinedList->clear();
     235                 :            :     }
     236         [ +  + ]:        777 :     if (pCurrencyList)
     237                 :            :     {
     238                 :          3 :         ScMyCurrencyStylesSet::iterator aItr(pCurrencyList->begin());
     239                 :          3 :         ScMyCurrencyStylesSet::iterator aEndItr(pCurrencyList->end());
     240         [ +  + ]:          6 :         while (aItr != aEndItr)
     241                 :            :         {
     242         [ +  - ]:          3 :             list<ScRange> aList;
     243         [ +  - ]:          3 :             aItr->mpRanges->getRangeList(aList);
     244         [ +  - ]:          3 :             SetStylesToRanges(aList, pStyleName, util::NumberFormat::CURRENCY, &aItr->sCurrency, rImport);
     245                 :          3 :             ++aItr;
     246                 :          3 :         }
     247                 :            :     }
     248                 :        777 : }
     249                 :            : 
     250                 :            : //----------------------------------------------------------------------------
     251                 :            : 
     252                 :        378 : ScMyStylesImportHelper::ScMyStylesImportHelper(ScXMLImport& rTempImport)
     253                 :            :     :
     254                 :        378 :     aRowDefaultStyle(aCellStyles.end()),
     255                 :            :     rImport(rTempImport),
     256                 :            :     pStyleName(NULL),
     257                 :            :     pPrevStyleName(NULL),
     258                 :            :     pCurrency(NULL),
     259                 :            :     pPrevCurrency(NULL),
     260                 :            :     nMaxRanges(0),
     261         [ +  - ]:        378 :     bPrevRangeAdded(true)
     262                 :            : {
     263                 :        378 : }
     264                 :            : 
     265                 :        378 : ScMyStylesImportHelper::~ScMyStylesImportHelper()
     266                 :            : {
     267         [ +  + ]:        378 :     if (pPrevStyleName)
     268         [ +  - ]:          6 :         delete pPrevStyleName;
     269         [ -  + ]:        378 :     if (pPrevCurrency)
     270         [ #  # ]:          0 :         delete pPrevCurrency;
     271         [ -  + ]:        378 :     if (pStyleName)
     272         [ #  # ]:          0 :         delete pStyleName;
     273         [ -  + ]:        378 :     if (pCurrency)
     274         [ #  # ]:          0 :         delete pCurrency;
     275                 :        378 : }
     276                 :            : 
     277                 :       8597 : void ScMyStylesImportHelper::ResetAttributes()
     278                 :            : {
     279         [ +  + ]:       8597 :     if (pPrevStyleName)
     280         [ +  - ]:       8376 :         delete pPrevStyleName;
     281         [ +  + ]:       8597 :     if (pPrevCurrency)
     282         [ +  - ]:          3 :         delete pPrevCurrency;
     283                 :       8597 :     pPrevStyleName = pStyleName;
     284                 :       8597 :     pPrevCurrency = pCurrency;
     285                 :       8597 :     nPrevCellType = nCellType;
     286                 :       8597 :     pStyleName = NULL;
     287                 :       8597 :     pCurrency = NULL;
     288                 :       8597 :     nCellType = 0;
     289                 :       8597 : }
     290                 :            : 
     291                 :      13139 : ScMyStylesSet::iterator ScMyStylesImportHelper::GetIterator(const rtl::OUString* pStyleNameP)
     292                 :            : {
     293         [ +  - ]:      13139 :     ScMyStyle aStyle;
     294         [ +  - ]:      13139 :     if (pStyleNameP)
     295                 :      13139 :         aStyle.sStyleName = *pStyleNameP;
     296                 :            :     else
     297                 :            :     {
     298                 :            :         OSL_FAIL("here is no stylename given");
     299                 :            :     }
     300         [ +  - ]:      13139 :     ScMyStylesSet::iterator aItr(aCellStyles.find(aStyle));
     301         [ +  + ]:      13139 :     if (aItr == aCellStyles.end())
     302                 :            :     {
     303         [ +  - ]:        777 :         std::pair<ScMyStylesSet::iterator, bool> aPair(aCellStyles.insert(aStyle));
     304         [ +  - ]:        777 :         if (aPair.second)
     305                 :        777 :             aItr = aPair.first;
     306                 :            :         else
     307                 :            :         {
     308                 :            :             OSL_FAIL("not possible to insert style");
     309                 :          0 :             return aCellStyles.end();
     310                 :            :         }
     311                 :            :     }
     312         [ +  - ]:      13139 :     return aItr;
     313                 :            : }
     314                 :            : 
     315                 :       7918 : void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange)
     316                 :            : {
     317                 :            :     OSL_ENSURE(aRowDefaultStyle != aCellStyles.end(), "no row default style");
     318         [ +  - ]:       7918 :     if (aRowDefaultStyle->sStyleName.isEmpty())
     319                 :            :     {
     320                 :       7918 :         SCCOL nStartCol(rRange.aStart.Col());
     321                 :       7918 :         SCCOL nEndCol(rRange.aEnd.Col());
     322         [ +  - ]:       7918 :         if (aColDefaultStyles.size() > sal::static_int_cast<sal_uInt32>(nStartCol))
     323                 :            :         {
     324                 :       7918 :             ScMyStylesSet::iterator aPrevItr(aColDefaultStyles[nStartCol]);
     325                 :            :             OSL_ENSURE(aColDefaultStyles.size() > sal::static_int_cast<sal_uInt32>(nEndCol), "to much columns");
     326 [ +  + ][ +  - ]:      14891 :             for (SCCOL i = nStartCol + 1; (i <= nEndCol) && (i < sal::static_int_cast<SCCOL>(aColDefaultStyles.size())); ++i)
                 [ +  + ]
     327                 :            :             {
     328         [ +  + ]:       6973 :                 if (aPrevItr != aColDefaultStyles[i])
     329                 :            :                 {
     330                 :            :                     OSL_ENSURE(aPrevItr != aCellStyles.end(), "no column default style");
     331                 :         33 :                     ScRange aRange(rRange);
     332                 :         33 :                     aRange.aStart.SetCol(nStartCol);
     333                 :         33 :                     aRange.aEnd.SetCol(i - 1);
     334         [ +  + ]:         33 :                     if (pPrevStyleName)
     335         [ +  - ]:          9 :                         delete pPrevStyleName;
     336         [ +  - ]:         33 :                     pPrevStyleName = new rtl::OUString(aPrevItr->sStyleName);
     337         [ +  - ]:         33 :                     AddSingleRange(aRange);
     338                 :         33 :                     nStartCol = i;
     339                 :         33 :                     aPrevItr = aColDefaultStyles[i];
     340                 :            :                 }
     341                 :            :             }
     342         [ +  - ]:       7918 :             if (aPrevItr != aCellStyles.end())
     343                 :            :             {
     344                 :       7918 :                 ScRange aRange(rRange);
     345                 :       7918 :                 aRange.aStart.SetCol(nStartCol);
     346         [ +  + ]:       7918 :                 if (pPrevStyleName)
     347         [ +  - ]:         24 :                     delete pPrevStyleName;
     348         [ +  - ]:       7918 :                 pPrevStyleName = new rtl::OUString(aPrevItr->sStyleName);
     349         [ +  - ]:       7918 :                 AddSingleRange(aRange);
     350                 :            :             }
     351                 :            :             else
     352                 :            :             {
     353                 :            :                 OSL_FAIL("no column default style");
     354                 :            :             }
     355                 :            :         }
     356                 :            :         else
     357                 :            :         {
     358                 :            :             OSL_FAIL("too much columns");
     359                 :            :         }
     360                 :            :     }
     361                 :            :     else
     362                 :            :     {
     363         [ #  # ]:          0 :         if (pPrevStyleName)
     364         [ #  # ]:          0 :             delete pPrevStyleName;
     365                 :          0 :         pPrevStyleName = new rtl::OUString(aRowDefaultStyle->sStyleName);
     366                 :          0 :         AddSingleRange(rRange);
     367                 :            :     }
     368                 :       7918 : }
     369                 :            : 
     370                 :       8406 : void ScMyStylesImportHelper::AddSingleRange(const ScRange& rRange)
     371                 :            : {
     372         [ +  + ]:       8406 :     if (nMaxRanges == 0)
     373                 :        224 :         nMaxRanges = aColDefaultStyles.size();
     374         [ +  - ]:       8406 :     ScMyStylesSet::iterator aItr(GetIterator(pPrevStyleName));
     375         [ +  - ]:       8406 :     if (aItr != aCellStyles.end())
     376                 :            :     {
     377         [ +  + ]:       8406 :         if (nPrevCellType != util::NumberFormat::CURRENCY)
     378                 :       8403 :             aItr->xRanges->AddRange(rRange, pPrevStyleName, nPrevCellType,
     379         [ +  - ]:       8403 :                 rImport, nMaxRanges);
     380                 :            :         else
     381                 :          3 :             aItr->xRanges->AddCurrencyRange(rRange, pPrevStyleName, pPrevCurrency,
     382         [ +  - ]:          3 :                 rImport, nMaxRanges);
     383                 :            :     }
     384                 :       8406 : }
     385                 :            : 
     386                 :       8373 : void ScMyStylesImportHelper::AddRange()
     387                 :            : {
     388 [ +  + ][ +  - ]:       8373 :     if (pPrevStyleName && !pPrevStyleName->isEmpty())
                 [ +  + ]
     389                 :        455 :         AddSingleRange(aPrevRange);
     390                 :            :     else
     391                 :       7918 :         AddDefaultRange(aPrevRange);
     392                 :       8373 :     ResetAttributes();
     393                 :       8373 : }
     394                 :            : 
     395                 :        329 : void ScMyStylesImportHelper::AddColumnStyle(const rtl::OUString& sStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat)
     396                 :            : {
     397                 :            :     (void)nColumn;  // avoid warning in product version
     398                 :            :     OSL_ENSURE(static_cast<sal_uInt32>(nColumn) == aColDefaultStyles.size(), "some columns are absent");
     399         [ +  - ]:        329 :     ScMyStylesSet::iterator aItr(GetIterator(&sStyleName));
     400                 :            :     OSL_ENSURE(aItr != aCellStyles.end(), "no column default style");
     401         [ +  - ]:        329 :     aColDefaultStyles.reserve(aColDefaultStyles.size() + nRepeat);
     402         [ +  + ]:       2764 :     for (sal_Int32 i = 0; i < nRepeat; ++i)
     403         [ +  - ]:       2435 :         aColDefaultStyles.push_back(aItr);
     404                 :        329 : }
     405                 :            : 
     406                 :       4404 : void ScMyStylesImportHelper::SetRowStyle(const rtl::OUString& sStyleName)
     407                 :            : {
     408                 :       4404 :     aRowDefaultStyle = GetIterator(&sStyleName);
     409                 :       4404 : }
     410                 :            : 
     411                 :      10481 : void ScMyStylesImportHelper::SetAttributes(rtl::OUString* pStyleNameP,
     412                 :            :     rtl::OUString* pCurrencyP, const sal_Int16 nCellTypeP)
     413                 :            : {
     414         [ +  + ]:      10481 :     if (this->pStyleName)
     415         [ +  - ]:        117 :         delete this->pStyleName;
     416         [ +  + ]:      10481 :     if (this->pCurrency)
     417         [ +  - ]:          3 :         delete this->pCurrency;
     418                 :      10481 :     this->pStyleName = pStyleNameP;
     419                 :      10481 :     this->pCurrency = pCurrencyP;
     420                 :      10481 :     this->nCellType = nCellTypeP;
     421                 :      10481 : }
     422                 :            : 
     423                 :      10481 : void ScMyStylesImportHelper::AddRange(const ScRange& rRange)
     424                 :            : {
     425         [ +  + ]:      10481 :     if (!bPrevRangeAdded)
     426                 :            :     {
     427                 :      10257 :         bool bAddRange(false);
     428   [ +  +  +  +  :      16059 :         if (nCellType == nPrevCellType &&
           +  - ][ +  + ]
     429                 :       3108 :             IsEqual(pStyleName, pPrevStyleName) &&
     430                 :       2694 :             IsEqual(pCurrency, pPrevCurrency))
     431                 :            :         {
     432         [ +  + ]:       2694 :             if (rRange.aStart.Row() == aPrevRange.aStart.Row())
     433                 :            :             {
     434         [ +  - ]:       2043 :                 if (rRange.aEnd.Row() == aPrevRange.aEnd.Row())
     435                 :            :                 {
     436                 :            :                     OSL_ENSURE(aPrevRange.aEnd.Col() + 1 == rRange.aStart.Col(), "something wents wrong");
     437                 :       2043 :                     aPrevRange.aEnd.SetCol(rRange.aEnd.Col());
     438                 :            :                 }
     439                 :            :                 else
     440                 :          0 :                     bAddRange = true;
     441                 :            :             }
     442                 :            :             else
     443                 :            :             {
     444   [ +  +  +  + ]:       1196 :                 if (rRange.aStart.Col() == aPrevRange.aStart.Col() &&
                 [ +  + ]
     445                 :        545 :                     rRange.aEnd.Col() == aPrevRange.aEnd.Col())
     446                 :            :                 {
     447                 :            :                     OSL_ENSURE(aPrevRange.aEnd.Row() + 1 == rRange.aStart.Row(), "something wents wrong");
     448                 :         65 :                     aPrevRange.aEnd.SetRow(rRange.aEnd.Row());
     449                 :            :                 }
     450                 :            :                 else
     451                 :        586 :                     bAddRange = true;
     452                 :            :             }
     453                 :            :         }
     454                 :            :         else
     455                 :       7563 :             bAddRange = true;
     456         [ +  + ]:      10257 :         if (bAddRange)
     457                 :            :         {
     458                 :       8149 :             AddRange();
     459                 :       8149 :             aPrevRange = rRange;
     460                 :            :         }
     461                 :            :     }
     462                 :            :     else
     463                 :            :     {
     464                 :        224 :         aPrevRange = rRange;
     465                 :        224 :         ResetAttributes();
     466                 :        224 :         bPrevRangeAdded = false;
     467                 :            :     }
     468                 :      10481 : }
     469                 :            : 
     470                 :       9391 : void ScMyStylesImportHelper::AddCell(const ScAddress& rAddress)
     471                 :            : {
     472                 :       9391 :     ScRange aScRange( rAddress, rAddress );
     473         [ +  - ]:       9391 :     AddRange(aScRange);
     474                 :       9391 : }
     475                 :            : 
     476                 :       1862 : void ScMyStylesImportHelper::InsertCol(const sal_Int32 nCol, const sal_Int32 nTab, ScDocument* pDoc)
     477                 :            : {
     478         [ +  - ]:       1862 :     ScXMLImport::MutexGuard aGuard(rImport);
     479                 :       1862 :     ScMyStylesSet::iterator aItr(aCellStyles.begin());
     480                 :       1862 :     ScMyStylesSet::iterator aEndItr(aCellStyles.end());
     481         [ +  + ]:       5687 :     while (aItr != aEndItr)
     482                 :            :     {
     483         [ +  - ]:       3825 :         aItr->xRanges->InsertCol(nCol, nTab, pDoc);
     484                 :       3825 :         ++aItr;
     485         [ +  - ]:       1862 :     }
     486                 :       1862 : }
     487                 :            : 
     488                 :        224 : void ScMyStylesImportHelper::EndTable()
     489                 :            : {
     490         [ +  - ]:        224 :     if (!bPrevRangeAdded)
     491                 :            :     {
     492                 :        224 :         AddRange();
     493                 :        224 :         bPrevRangeAdded = true;
     494                 :            :     }
     495                 :        224 :     nMaxRanges = 0;
     496                 :        224 : }
     497                 :            : 
     498                 :        224 : void ScMyStylesImportHelper::SetStylesToRanges()
     499                 :            : {
     500                 :        224 :     ScMyStylesSet::iterator aItr(aCellStyles.begin());
     501                 :        224 :     ScMyStylesSet::iterator aEndItr(aCellStyles.end());
     502         [ +  + ]:       1001 :     while (aItr != aEndItr)
     503                 :            :     {
     504         [ +  - ]:        777 :         aItr->xRanges->SetStylesToRanges(&aItr->sStyleName, rImport);
     505                 :        777 :         ++aItr;
     506                 :            :     }
     507                 :        224 :     aColDefaultStyles.clear();
     508                 :        224 :     aCellStyles.clear();
     509                 :        224 :     nMaxRanges = 0;
     510                 :        224 : }
     511                 :            : 
     512                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10