LCOV - code coverage report
Current view: top level - sc/source/core/data - global2.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 175 0.0 %
Date: 2014-04-14 Functions: 0 26 0.0 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/docfile.hxx>
      21             : #include <sfx2/objsh.hxx>
      22             : #include <unotools/pathoptions.hxx>
      23             : #include <unotools/useroptions.hxx>
      24             : #include <tools/urlobj.hxx>
      25             : #include <unotools/charclass.hxx>
      26             : #include <stdlib.h>
      27             : #include <ctype.h>
      28             : #include <unotools/syslocale.hxx>
      29             : 
      30             : #include "global.hxx"
      31             : #include "rangeutl.hxx"
      32             : #include "rechead.hxx"
      33             : #include "compiler.hxx"
      34             : #include "paramisc.hxx"
      35             : 
      36             : #include "sc.hrc"
      37             : #include "globstr.hrc"
      38             : 
      39             : using ::std::vector;
      40             : 
      41             : 
      42             : // struct ScImportParam:
      43             : 
      44           0 : ScImportParam::ScImportParam() :
      45             :     nCol1(0),
      46             :     nRow1(0),
      47             :     nCol2(0),
      48             :     nRow2(0),
      49             :     bImport(false),
      50             :     bNative(false),
      51             :     bSql(true),
      52           0 :     nType(ScDbTable)
      53             : {
      54           0 : }
      55             : 
      56           0 : ScImportParam::ScImportParam( const ScImportParam& r ) :
      57             :     nCol1       (r.nCol1),
      58             :     nRow1       (r.nRow1),
      59             :     nCol2       (r.nCol2),
      60             :     nRow2       (r.nRow2),
      61             :     bImport     (r.bImport),
      62             :     aDBName     (r.aDBName),
      63             :     aStatement  (r.aStatement),
      64             :     bNative     (r.bNative),
      65             :     bSql        (r.bSql),
      66           0 :     nType       (r.nType)
      67             : {
      68           0 : }
      69             : 
      70           0 : ScImportParam::~ScImportParam()
      71             : {
      72           0 : }
      73             : 
      74           0 : ScImportParam& ScImportParam::operator=( const ScImportParam& r )
      75             : {
      76           0 :     nCol1           = r.nCol1;
      77           0 :     nRow1           = r.nRow1;
      78           0 :     nCol2           = r.nCol2;
      79           0 :     nRow2           = r.nRow2;
      80           0 :     bImport         = r.bImport;
      81           0 :     aDBName         = r.aDBName;
      82           0 :     aStatement      = r.aStatement;
      83           0 :     bNative         = r.bNative;
      84           0 :     bSql            = r.bSql;
      85           0 :     nType           = r.nType;
      86             : 
      87           0 :     return *this;
      88             : }
      89             : 
      90           0 : bool ScImportParam::operator==( const ScImportParam& rOther ) const
      91             : {
      92           0 :     return( nCol1       == rOther.nCol1 &&
      93           0 :             nRow1       == rOther.nRow1 &&
      94           0 :             nCol2       == rOther.nCol2 &&
      95           0 :             nRow2       == rOther.nRow2 &&
      96           0 :             bImport     == rOther.bImport &&
      97           0 :             aDBName     == rOther.aDBName &&
      98           0 :             aStatement  == rOther.aStatement &&
      99           0 :             bNative     == rOther.bNative &&
     100           0 :             bSql        == rOther.bSql &&
     101           0 :             nType       == rOther.nType );
     102             : 
     103             :     //! nQuerySh und pConnection sind gleich ?
     104             : }
     105             : 
     106             : 
     107             : // struct ScConsolidateParam:
     108             : 
     109           0 : ScConsolidateParam::ScConsolidateParam() :
     110           0 :     ppDataAreas( NULL )
     111             : {
     112           0 :     Clear();
     113           0 : }
     114             : 
     115           0 : ScConsolidateParam::ScConsolidateParam( const ScConsolidateParam& r ) :
     116             :         nCol(r.nCol),nRow(r.nRow),nTab(r.nTab),
     117             :         eFunction(r.eFunction),nDataAreaCount(0),
     118             :         ppDataAreas( NULL ),
     119           0 :         bByCol(r.bByCol),bByRow(r.bByRow),bReferenceData(r.bReferenceData)
     120             : {
     121           0 :     if ( r.nDataAreaCount > 0 )
     122             :     {
     123           0 :         nDataAreaCount = r.nDataAreaCount;
     124           0 :         ppDataAreas = new ScArea*[nDataAreaCount];
     125           0 :         for ( sal_uInt16 i=0; i<nDataAreaCount; i++ )
     126           0 :             ppDataAreas[i] = new ScArea( *(r.ppDataAreas[i]) );
     127             :     }
     128           0 : }
     129             : 
     130           0 : ScConsolidateParam::~ScConsolidateParam()
     131             : {
     132           0 :     ClearDataAreas();
     133           0 : }
     134             : 
     135           0 : void ScConsolidateParam::ClearDataAreas()
     136             : {
     137           0 :     if ( ppDataAreas )
     138             :     {
     139           0 :         for ( sal_uInt16 i=0; i<nDataAreaCount; i++ )
     140           0 :             delete ppDataAreas[i];
     141           0 :         delete [] ppDataAreas;
     142           0 :         ppDataAreas = NULL;
     143             :     }
     144           0 :     nDataAreaCount = 0;
     145           0 : }
     146             : 
     147           0 : void ScConsolidateParam::Clear()
     148             : {
     149           0 :     ClearDataAreas();
     150             : 
     151           0 :     nCol = 0;
     152           0 :     nRow = 0;
     153           0 :     nTab = 0;
     154           0 :     bByCol = bByRow = bReferenceData    = false;
     155           0 :     eFunction                           = SUBTOTAL_FUNC_SUM;
     156           0 : }
     157             : 
     158           0 : ScConsolidateParam& ScConsolidateParam::operator=( const ScConsolidateParam& r )
     159             : {
     160           0 :     nCol            = r.nCol;
     161           0 :     nRow            = r.nRow;
     162           0 :     nTab            = r.nTab;
     163           0 :     bByCol          = r.bByCol;
     164           0 :     bByRow          = r.bByRow;
     165           0 :     bReferenceData  = r.bReferenceData;
     166           0 :     eFunction       = r.eFunction;
     167           0 :     SetAreas( r.ppDataAreas, r.nDataAreaCount );
     168             : 
     169           0 :     return *this;
     170             : }
     171             : 
     172           0 : bool ScConsolidateParam::operator==( const ScConsolidateParam& r ) const
     173             : {
     174           0 :     bool bEqual =   (nCol           == r.nCol)
     175           0 :                  && (nRow           == r.nRow)
     176           0 :                  && (nTab           == r.nTab)
     177           0 :                  && (bByCol         == r.bByCol)
     178           0 :                  && (bByRow         == r.bByRow)
     179           0 :                  && (bReferenceData == r.bReferenceData)
     180           0 :                  && (nDataAreaCount == r.nDataAreaCount)
     181           0 :                  && (eFunction      == r.eFunction);
     182             : 
     183           0 :     if ( nDataAreaCount == 0 )
     184           0 :         bEqual = bEqual && (ppDataAreas == NULL) && (r.ppDataAreas == NULL);
     185             :     else
     186           0 :         bEqual = bEqual && (ppDataAreas != NULL) && (r.ppDataAreas != NULL);
     187             : 
     188           0 :     if ( bEqual && (nDataAreaCount > 0) )
     189           0 :         for ( sal_uInt16 i=0; i<nDataAreaCount && bEqual; i++ )
     190           0 :             bEqual = *(ppDataAreas[i]) == *(r.ppDataAreas[i]);
     191             : 
     192           0 :     return bEqual;
     193             : }
     194             : 
     195           0 : void ScConsolidateParam::SetAreas( ScArea* const* ppAreas, sal_uInt16 nCount )
     196             : {
     197           0 :     ClearDataAreas();
     198           0 :     if ( ppAreas && nCount > 0 )
     199             :     {
     200           0 :         ppDataAreas = new ScArea*[nCount];
     201           0 :         for ( sal_uInt16 i=0; i<nCount; i++ )
     202           0 :             ppDataAreas[i] = new ScArea( *(ppAreas[i]) );
     203           0 :         nDataAreaCount = nCount;
     204             :     }
     205           0 : }
     206             : 
     207             : 
     208             : // struct ScSolveParam
     209             : 
     210           0 : ScSolveParam::ScSolveParam()
     211           0 :     :   pStrTargetVal( NULL )
     212             : {
     213           0 : }
     214             : 
     215           0 : ScSolveParam::ScSolveParam( const ScSolveParam& r )
     216             :     :   aRefFormulaCell ( r.aRefFormulaCell ),
     217             :         aRefVariableCell( r.aRefVariableCell ),
     218             :         pStrTargetVal   ( r.pStrTargetVal
     219           0 :                             ? new OUString(*r.pStrTargetVal)
     220           0 :                             : NULL )
     221             : {
     222           0 : }
     223             : 
     224           0 : ScSolveParam::ScSolveParam( const ScAddress& rFormulaCell,
     225             :                             const ScAddress& rVariableCell,
     226             :                             const OUString&   rTargetValStr )
     227             :     :   aRefFormulaCell ( rFormulaCell ),
     228             :         aRefVariableCell( rVariableCell ),
     229           0 :         pStrTargetVal   ( new OUString(rTargetValStr) )
     230             : {
     231           0 : }
     232             : 
     233           0 : ScSolveParam::~ScSolveParam()
     234             : {
     235           0 :     delete pStrTargetVal;
     236           0 : }
     237             : 
     238           0 : ScSolveParam& ScSolveParam::operator=( const ScSolveParam& r )
     239             : {
     240           0 :     delete pStrTargetVal;
     241             : 
     242           0 :     aRefFormulaCell  = r.aRefFormulaCell;
     243           0 :     aRefVariableCell = r.aRefVariableCell;
     244             :     pStrTargetVal    = r.pStrTargetVal
     245           0 :                             ? new OUString(*r.pStrTargetVal)
     246           0 :                             : NULL;
     247           0 :     return *this;
     248             : }
     249             : 
     250           0 : bool ScSolveParam::operator==( const ScSolveParam& r ) const
     251             : {
     252           0 :     bool bEqual =   (aRefFormulaCell  == r.aRefFormulaCell)
     253           0 :                  && (aRefVariableCell == r.aRefVariableCell);
     254             : 
     255           0 :     if ( bEqual )
     256             :     {
     257           0 :         if ( !pStrTargetVal && !r.pStrTargetVal )
     258           0 :             bEqual = true;
     259           0 :         else if ( !pStrTargetVal || !r.pStrTargetVal )
     260           0 :             bEqual = false;
     261           0 :         else if ( pStrTargetVal && r.pStrTargetVal )
     262           0 :             bEqual = ( *pStrTargetVal == *(r.pStrTargetVal) );
     263             :     }
     264             : 
     265           0 :     return bEqual;
     266             : }
     267             : 
     268             : 
     269             : // struct ScTabOpParam
     270             : 
     271           0 : ScTabOpParam::ScTabOpParam() : meMode(Column) {}
     272             : 
     273           0 : ScTabOpParam::ScTabOpParam( const ScTabOpParam& r )
     274             :     :   aRefFormulaCell ( r.aRefFormulaCell ),
     275             :         aRefFormulaEnd  ( r.aRefFormulaEnd ),
     276             :         aRefRowCell     ( r.aRefRowCell ),
     277             :         aRefColCell     ( r.aRefColCell ),
     278           0 :     meMode(r.meMode)
     279             : {
     280           0 : }
     281             : 
     282           0 : ScTabOpParam::ScTabOpParam( const ScRefAddress& rFormulaCell,
     283             :                             const ScRefAddress& rFormulaEnd,
     284             :                             const ScRefAddress& rRowCell,
     285             :                             const ScRefAddress& rColCell,
     286             :                             Mode eMode )
     287             :     :   aRefFormulaCell ( rFormulaCell ),
     288             :         aRefFormulaEnd  ( rFormulaEnd ),
     289             :         aRefRowCell     ( rRowCell ),
     290             :         aRefColCell     ( rColCell ),
     291           0 :     meMode(eMode)
     292             : {
     293           0 : }
     294             : 
     295           0 : ScTabOpParam& ScTabOpParam::operator=( const ScTabOpParam& r )
     296             : {
     297           0 :     aRefFormulaCell  = r.aRefFormulaCell;
     298           0 :     aRefFormulaEnd   = r.aRefFormulaEnd;
     299           0 :     aRefRowCell      = r.aRefRowCell;
     300           0 :     aRefColCell      = r.aRefColCell;
     301           0 :     meMode = r.meMode;
     302           0 :     return *this;
     303             : }
     304             : 
     305           0 : bool ScTabOpParam::operator==( const ScTabOpParam& r ) const
     306             : {
     307           0 :     return (        (aRefFormulaCell == r.aRefFormulaCell)
     308           0 :                  && (aRefFormulaEnd  == r.aRefFormulaEnd)
     309           0 :                  && (aRefRowCell     == r.aRefRowCell)
     310           0 :                  && (aRefColCell     == r.aRefColCell)
     311           0 :                  && (meMode == r.meMode) );
     312             : }
     313             : 
     314           0 : OUString ScGlobal::GetAbsDocName( const OUString& rFileName,
     315             :                                 SfxObjectShell* pShell )
     316             : {
     317           0 :     OUString aAbsName;
     318           0 :     if ( !pShell->HasName() )
     319             :     {   // maybe relative to document path working directory
     320           0 :         INetURLObject aObj;
     321           0 :         SvtPathOptions aPathOpt;
     322           0 :         aObj.SetSmartURL( aPathOpt.GetWorkPath() );
     323           0 :         aObj.setFinalSlash();       // it IS a path
     324           0 :         bool bWasAbs = true;
     325           0 :         aAbsName = aObj.smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE);
     326             :         //  returned string must be encoded because it's used directly to create SfxMedium
     327             :     }
     328             :     else
     329             :     {
     330           0 :         const SfxMedium* pMedium = pShell->GetMedium();
     331           0 :         if ( pMedium )
     332             :         {
     333           0 :             bool bWasAbs = true;
     334           0 :             aAbsName = pMedium->GetURLObject().smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE);
     335             :         }
     336             :         else
     337             :         {   // This can't happen, but ...
     338             :             // just to be sure to have the same encoding
     339           0 :             INetURLObject aObj;
     340           0 :             aObj.SetSmartURL( aAbsName );
     341           0 :             aAbsName = aObj.GetMainURL(INetURLObject::NO_DECODE);
     342             :         }
     343             :     }
     344           0 :     return aAbsName;
     345             : }
     346             : 
     347           0 : OUString ScGlobal::GetDocTabName( const OUString& rFileName,
     348             :                                 const OUString& rTabName )
     349             : {
     350           0 :     OUString  aDocTab('\'');
     351           0 :     aDocTab += rFileName;
     352           0 :     sal_Int32 nPos = 1;
     353           0 :     while( (nPos = aDocTab.indexOf( '\'', nPos )) != -1 )
     354             :     {   // escape Quotes
     355           0 :         aDocTab = aDocTab.replaceAt( nPos, 0, "\\" );
     356           0 :         nPos += 2;
     357             :     }
     358           0 :     aDocTab += "'";
     359           0 :     aDocTab += OUString(SC_COMPILER_FILE_TAB_SEP);
     360           0 :     aDocTab += rTabName;    // "'Doc'#Tab"
     361           0 :     return aDocTab;
     362             : }
     363             : 
     364             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10