LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - datauno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1083 1428 75.8 %
Date: 2012-08-25 Functions: 128 178 71.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1068 2387 44.7 %

           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 <svl/smplhint.hxx>
      30                 :            : #include <svl/zforlist.hxx>
      31                 :            : #include <vcl/svapp.hxx>
      32                 :            : 
      33                 :            : #include <com/sun/star/awt/XBitmap.hpp>
      34                 :            : #include <com/sun/star/util/SortField.hpp>
      35                 :            : #include <com/sun/star/table/TableSortField.hpp>
      36                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      37                 :            : #include <com/sun/star/table/TableOrientation.hpp>
      38                 :            : #include <com/sun/star/table/CellRangeAddress.hpp>
      39                 :            : #include <com/sun/star/sheet/DataImportMode.hpp>
      40                 :            : #include <com/sun/star/sheet/FilterOperator2.hpp>
      41                 :            : #include <com/sun/star/sheet/TableFilterField2.hpp>
      42                 :            : 
      43                 :            : #include "datauno.hxx"
      44                 :            : #include "dapiuno.hxx"
      45                 :            : #include "cellsuno.hxx"
      46                 :            : #include "miscuno.hxx"
      47                 :            : #include "targuno.hxx"
      48                 :            : #include "rangeutl.hxx"
      49                 :            : #include "dbdata.hxx"
      50                 :            : #include "docsh.hxx"
      51                 :            : #include "dbdocfun.hxx"
      52                 :            : #include "unonames.hxx"
      53                 :            : #include "globalnames.hxx"
      54                 :            : #include "globstr.hrc"
      55                 :            : #include "convuno.hxx"
      56                 :            : #include "hints.hxx"
      57                 :            : #include "attrib.hxx"
      58                 :            : #include "dpshttab.hxx"
      59                 :            : #include "queryentry.hxx"
      60                 :            : 
      61                 :            : #include <comphelper/extract.hxx>
      62                 :            : #include <comphelper/servicehelper.hxx>
      63                 :            : #include <svx/dataaccessdescriptor.hxx>
      64                 :            : 
      65                 :            : #include <limits>
      66                 :            : 
      67                 :            : using namespace com::sun::star;
      68                 :            : 
      69                 :            : //------------------------------------------------------------------------
      70                 :            : 
      71                 :            : //  alles ohne Which-ID, Map nur fuer PropertySetInfo
      72                 :            : 
      73                 :          9 : const SfxItemPropertyMapEntry* lcl_GetSubTotalPropertyMap()
      74                 :            : {
      75                 :            :     // some old property names are for 5.2 compatibility
      76                 :            : 
      77                 :            :     static SfxItemPropertyMapEntry aSubTotalPropertyMap_Impl[] =
      78                 :            :     {
      79         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_BINDFMT),  0,  &getBooleanCppuType(),       0, 0},
      80         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_CASE),     0,  &getBooleanCppuType(),       0, 0},
      81         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_ENABSORT), 0,  &getBooleanCppuType(),       0, 0},
      82         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_ENUSLIST), 0,  &getBooleanCppuType(),       0, 0},
      83         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_FORMATS),  0,  &getBooleanCppuType(),       0, 0},
      84         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_INSBRK),   0,  &getBooleanCppuType(),       0, 0},
      85         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_ISCASE),   0,  &getBooleanCppuType(),       0, 0},
      86         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_MAXFLD),   0,  &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0},
      87         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_SORTASC),  0,  &getBooleanCppuType(),       0, 0},
      88         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_ULIST),    0,  &getBooleanCppuType(),       0, 0},
      89         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_UINDEX),   0,  &getCppuType((sal_Int32*)0), 0, 0},
      90         [ +  - ]:          3 :         {MAP_CHAR_LEN(SC_UNONAME_USINDEX),  0,  &getCppuType((sal_Int32*)0), 0, 0},
      91                 :            :         {0,0,0,0,0,0}
      92 [ +  + ][ +  - ]:         12 :     };
                 [ #  # ]
      93                 :          9 :     return aSubTotalPropertyMap_Impl;
      94                 :            : }
      95                 :            : 
      96                 :         17 : const SfxItemPropertyMapEntry* lcl_GetFilterPropertyMap()
      97                 :            : {
      98                 :            :     static SfxItemPropertyMapEntry aFilterPropertyMap_Impl[] =
      99                 :            :     {
     100         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_CONTHDR),  0,  &getBooleanCppuType(),                      0, 0},
     101         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_COPYOUT),  0,  &getBooleanCppuType(),                      0, 0},
     102         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_ISCASE),   0,  &getBooleanCppuType(),                      0, 0},
     103         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_MAXFLD),   0,  &getCppuType((sal_Int32*)0),                beans::PropertyAttribute::READONLY, 0},
     104         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_ORIENT),   0,  &getCppuType((table::TableOrientation*)0),  0, 0},
     105         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_OUTPOS),   0,  &getCppuType((table::CellAddress*)0),       0, 0},
     106         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_SAVEOUT),  0,  &getBooleanCppuType(),                      0, 0},
     107         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_SKIPDUP),  0,  &getBooleanCppuType(),                      0, 0},
     108         [ +  - ]:         10 :         {MAP_CHAR_LEN(SC_UNONAME_USEREGEX), 0,  &getBooleanCppuType(),                      0, 0},
     109                 :            :         {0,0,0,0,0,0}
     110 [ +  + ][ +  - ]:         27 :     };
                 [ #  # ]
     111                 :         17 :     return aFilterPropertyMap_Impl;
     112                 :            : }
     113                 :            : 
     114                 :         22 : const SfxItemPropertyMapEntry* lcl_GetDBRangePropertyMap()
     115                 :            : {
     116                 :            :     static SfxItemPropertyMapEntry aDBRangePropertyMap_Impl[] =
     117                 :            :     {
     118         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_AUTOFLT),  0,  &getBooleanCppuType(),                      0, 0},
     119         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_FLTCRT),   0,  &getCppuType((table::CellRangeAddress*)0),  0, 0},
     120         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_FROMSELECT),0, &getBooleanCppuType(),                      0, 0},
     121         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_ISUSER),   0,  &getBooleanCppuType(),           beans::PropertyAttribute::READONLY, 0 },
     122         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_KEEPFORM), 0,  &getBooleanCppuType(),                      0, 0},
     123         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT),  0,  &getCppuType((uno::Reference<awt::XBitmap>*)0), beans::PropertyAttribute::READONLY, 0 },
     124         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), 0,  &getCppuType((rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
     125         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_MOVCELLS), 0,  &getBooleanCppuType(),                      0, 0},
     126         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_REFPERIOD), 0, &getCppuType((sal_Int32*)0),                0, 0},
     127         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_STRIPDAT), 0,  &getBooleanCppuType(),                      0, 0},
     128         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_TOKENINDEX),0, &getCppuType((sal_Int32*)0),     beans::PropertyAttribute::READONLY, 0 },
     129         [ +  - ]:          6 :         {MAP_CHAR_LEN(SC_UNONAME_USEFLTCRT),0,  &getBooleanCppuType(),                      0, 0},
     130                 :            :         {0,0,0,0,0,0}
     131 [ +  + ][ +  - ]:         28 :     };
                 [ #  # ]
     132                 :         22 :     return aDBRangePropertyMap_Impl;
     133                 :            : }
     134                 :            : 
     135                 :            : 
     136                 :            : //------------------------------------------------------------------------
     137                 :            : 
     138                 :            : #define SCDATABASERANGEOBJ_SERVICE      "com.sun.star.sheet.DatabaseRange"
     139                 :            : 
     140         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScConsolidationDescriptor, "ScConsolidationDescriptor", "com.sun.star.sheet.ConsolidationDescriptor" )
     141         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScDatabaseRangesObj, "ScDatabaseRangesObj", "com.sun.star.sheet.DatabaseRanges" )
     142         [ #  # ]:          1 : SC_SIMPLE_SERVICE_INFO( ScFilterDescriptorBase, "ScFilterDescriptorBase", "com.sun.star.sheet.SheetFilterDescriptor" )
     143         [ #  # ]:          1 : SC_SIMPLE_SERVICE_INFO( ScSubTotalDescriptorBase, "ScSubTotalDescriptorBase", "com.sun.star.sheet.SubTotalDescriptor" )
     144         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScSubTotalFieldObj, "ScSubTotalFieldObj", "com.sun.star.sheet.SubTotalField" )
     145                 :            : 
     146                 :            : 
     147                 :            : //------------------------------------------------------------------------
     148                 :            : 
     149                 :        152 : ScSubTotalFunc ScDataUnoConversion::GeneralToSubTotal( sheet::GeneralFunction eSummary )
     150                 :            : {
     151                 :            :     ScSubTotalFunc eSubTotal;
     152   [ -  +  +  +  :        152 :     switch (eSummary)
          -  -  -  -  -  
             -  -  -  - ]
     153                 :            :     {
     154                 :          0 :         case sheet::GeneralFunction_NONE:       eSubTotal = SUBTOTAL_FUNC_NONE; break;
     155                 :        144 :         case sheet::GeneralFunction_SUM:        eSubTotal = SUBTOTAL_FUNC_SUM;  break;
     156                 :          7 :         case sheet::GeneralFunction_COUNT:      eSubTotal = SUBTOTAL_FUNC_CNT2; break;
     157                 :          1 :         case sheet::GeneralFunction_AVERAGE:    eSubTotal = SUBTOTAL_FUNC_AVE;  break;
     158                 :          0 :         case sheet::GeneralFunction_MAX:        eSubTotal = SUBTOTAL_FUNC_MAX;  break;
     159                 :          0 :         case sheet::GeneralFunction_MIN:        eSubTotal = SUBTOTAL_FUNC_MIN;  break;
     160                 :          0 :         case sheet::GeneralFunction_PRODUCT:    eSubTotal = SUBTOTAL_FUNC_PROD; break;
     161                 :          0 :         case sheet::GeneralFunction_COUNTNUMS:  eSubTotal = SUBTOTAL_FUNC_CNT;  break;
     162                 :          0 :         case sheet::GeneralFunction_STDEV:      eSubTotal = SUBTOTAL_FUNC_STD;  break;
     163                 :          0 :         case sheet::GeneralFunction_STDEVP:     eSubTotal = SUBTOTAL_FUNC_STDP; break;
     164                 :          0 :         case sheet::GeneralFunction_VAR:        eSubTotal = SUBTOTAL_FUNC_VAR;  break;
     165                 :          0 :         case sheet::GeneralFunction_VARP:       eSubTotal = SUBTOTAL_FUNC_VARP; break;
     166                 :            :         case sheet::GeneralFunction_AUTO:
     167                 :            :         default:
     168                 :            :             OSL_FAIL("GeneralToSubTotal: falscher enum");
     169                 :          0 :             eSubTotal = SUBTOTAL_FUNC_NONE;
     170                 :            :     }
     171                 :        152 :     return eSubTotal;
     172                 :            : }
     173                 :            : 
     174                 :          6 : sheet::GeneralFunction  ScDataUnoConversion::SubTotalToGeneral( ScSubTotalFunc eSubTotal )
     175                 :            : {
     176                 :            :     sheet::GeneralFunction eGeneral;
     177   [ -  +  -  +  :          6 :     switch (eSubTotal)
          -  -  -  -  -  
             +  -  -  - ]
     178                 :            :     {
     179                 :          0 :         case SUBTOTAL_FUNC_NONE: eGeneral = sheet::GeneralFunction_NONE;      break;
     180                 :          1 :         case SUBTOTAL_FUNC_AVE:  eGeneral = sheet::GeneralFunction_AVERAGE;   break;
     181                 :          0 :         case SUBTOTAL_FUNC_CNT:  eGeneral = sheet::GeneralFunction_COUNTNUMS; break;
     182                 :          1 :         case SUBTOTAL_FUNC_CNT2: eGeneral = sheet::GeneralFunction_COUNT;     break;
     183                 :          0 :         case SUBTOTAL_FUNC_MAX:  eGeneral = sheet::GeneralFunction_MAX;       break;
     184                 :          0 :         case SUBTOTAL_FUNC_MIN:  eGeneral = sheet::GeneralFunction_MIN;       break;
     185                 :          0 :         case SUBTOTAL_FUNC_PROD: eGeneral = sheet::GeneralFunction_PRODUCT;   break;
     186                 :          0 :         case SUBTOTAL_FUNC_STD:  eGeneral = sheet::GeneralFunction_STDEV;     break;
     187                 :          0 :         case SUBTOTAL_FUNC_STDP: eGeneral = sheet::GeneralFunction_STDEVP;    break;
     188                 :          4 :         case SUBTOTAL_FUNC_SUM:  eGeneral = sheet::GeneralFunction_SUM;       break;
     189                 :          0 :         case SUBTOTAL_FUNC_VAR:  eGeneral = sheet::GeneralFunction_VAR;       break;
     190                 :          0 :         case SUBTOTAL_FUNC_VARP: eGeneral = sheet::GeneralFunction_VARP;      break;
     191                 :            :         default:
     192                 :            :             OSL_FAIL("SubTotalToGeneral: falscher enum");
     193                 :          0 :             eGeneral = sheet::GeneralFunction_NONE;
     194                 :          0 :             break;
     195                 :            :     }
     196                 :          6 :     return eGeneral;
     197                 :            : }
     198                 :            : 
     199                 :            : //------------------------------------------------------------------------
     200                 :            : 
     201                 :            : //  ScImportDescriptor: alles static
     202                 :            : 
     203                 :          8 : long ScImportDescriptor::GetPropertyCount()
     204                 :            : {
     205                 :          8 :     return 4;
     206                 :            : }
     207                 :            : 
     208                 :          8 : void ScImportDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScImportParam& rParam )
     209                 :            : {
     210                 :            :     OSL_ENSURE( rSeq.getLength() == GetPropertyCount(), "falscher Count" );
     211                 :            : 
     212         [ +  - ]:          8 :     beans::PropertyValue* pArray = rSeq.getArray();
     213                 :            : 
     214                 :          8 :     sheet::DataImportMode eMode = sheet::DataImportMode_NONE;
     215         [ -  + ]:          8 :     if ( rParam.bImport )
     216                 :            :     {
     217         [ #  # ]:          0 :         if ( rParam.bSql )
     218                 :          0 :             eMode = sheet::DataImportMode_SQL;
     219         [ #  # ]:          0 :         else if ( rParam.nType == ScDbQuery )
     220                 :          0 :             eMode = sheet::DataImportMode_QUERY;
     221                 :            :         else
     222                 :          0 :             eMode = sheet::DataImportMode_TABLE;        // Type ist immer ScDbQuery oder ScDbTable
     223                 :            :     }
     224                 :            : 
     225         [ +  - ]:          8 :     ::svx::ODataAccessDescriptor aDescriptor;
     226         [ +  - ]:          8 :     aDescriptor.setDataSource(rParam.aDBName);
     227 [ +  - ][ +  - ]:          8 :     if (aDescriptor.has( svx::daDataSource ))
     228                 :            :     {
     229         [ +  - ]:          8 :         pArray[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_DBNAME ));
     230         [ +  - ]:          8 :         pArray[0].Value <<= rParam.aDBName;
     231                 :            :     }
     232 [ #  # ][ #  # ]:          0 :     else if (aDescriptor.has( svx::daConnectionResource ))
     233                 :            :     {
     234         [ #  # ]:          0 :         pArray[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CONRES ));
     235         [ #  # ]:          0 :         pArray[0].Value <<= rParam.aDBName;
     236                 :            :     }
     237                 :            : 
     238         [ +  - ]:          8 :     pArray[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SRCTYPE ));
     239         [ +  - ]:          8 :     pArray[1].Value <<= eMode;
     240                 :            : 
     241         [ +  - ]:          8 :     pArray[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SRCOBJ ));
     242         [ +  - ]:          8 :     pArray[2].Value <<= rParam.aStatement;
     243                 :            : 
     244         [ +  - ]:          8 :     pArray[3].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ISNATIVE ));
     245 [ +  - ][ +  - ]:          8 :     ScUnoHelpFunctions::SetBoolInAny( pArray[3].Value, rParam.bNative );
     246                 :          8 : }
     247                 :            : 
     248                 :          6 : void ScImportDescriptor::FillImportParam( ScImportParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
     249                 :            : {
     250                 :          6 :     rtl::OUString aStrVal;
     251                 :          6 :     const beans::PropertyValue* pPropArray = rSeq.getConstArray();
     252                 :          6 :     long nPropCount = rSeq.getLength();
     253         [ +  + ]:         30 :     for (long i = 0; i < nPropCount; i++)
     254                 :            :     {
     255                 :         24 :         const beans::PropertyValue& rProp = pPropArray[i];
     256         [ +  - ]:         24 :         String aPropName(rProp.Name);
     257                 :            : 
     258 [ +  - ][ +  + ]:         24 :         if (aPropName.EqualsAscii( SC_UNONAME_ISNATIVE ))
     259         [ +  - ]:          6 :             rParam.bNative = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     260 [ +  - ][ +  + ]:         18 :         else if (aPropName.EqualsAscii( SC_UNONAME_DBNAME ))
     261                 :            :         {
     262         [ +  - ]:          6 :             if ( rProp.Value >>= aStrVal )
     263                 :          6 :                 rParam.aDBName = aStrVal;
     264                 :            :         }
     265 [ +  - ][ -  + ]:         12 :         else if (aPropName.EqualsAscii( SC_UNONAME_CONRES ))
     266                 :            :         {
     267         [ #  # ]:          0 :             if ( rProp.Value >>= aStrVal )
     268                 :          0 :                 rParam.aDBName = aStrVal;
     269                 :            :         }
     270 [ +  - ][ +  + ]:         12 :         else if (aPropName.EqualsAscii( SC_UNONAME_SRCOBJ ))
     271                 :            :         {
     272         [ +  - ]:          6 :             if ( rProp.Value >>= aStrVal )
     273                 :          6 :                 rParam.aStatement = aStrVal;
     274                 :            :         }
     275 [ +  - ][ +  - ]:          6 :         else if (aPropName.EqualsAscii( SC_UNONAME_SRCTYPE ))
     276                 :            :         {
     277                 :            :             //! test for correct enum type?
     278                 :            :             sheet::DataImportMode eMode = (sheet::DataImportMode)
     279         [ +  - ]:          6 :                                 ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
     280   [ -  +  +  -  :          6 :             switch (eMode)
                      - ]
     281                 :            :             {
     282                 :            :                 case sheet::DataImportMode_NONE:
     283                 :          0 :                     rParam.bImport = false;
     284                 :          0 :                     break;
     285                 :            :                 case sheet::DataImportMode_SQL:
     286                 :          4 :                     rParam.bImport = true;
     287                 :          4 :                     rParam.bSql    = true;
     288                 :          4 :                     break;
     289                 :            :                 case sheet::DataImportMode_TABLE:
     290                 :          2 :                     rParam.bImport = true;
     291                 :          2 :                     rParam.bSql    = false;
     292                 :          2 :                     rParam.nType   = ScDbTable;
     293                 :          2 :                     break;
     294                 :            :                 case sheet::DataImportMode_QUERY:
     295                 :          0 :                     rParam.bImport = true;
     296                 :          0 :                     rParam.bSql    = false;
     297                 :          0 :                     rParam.nType   = ScDbQuery;
     298                 :          0 :                     break;
     299                 :            :                 default:
     300                 :            :                     OSL_FAIL("falscher Mode");
     301                 :          6 :                     rParam.bImport = false;
     302                 :            :             }
     303                 :            :         }
     304         [ +  - ]:         30 :     }
     305                 :          6 : }
     306                 :            : 
     307                 :            : //------------------------------------------------------------------------
     308                 :            : 
     309                 :            : //  ScSortDescriptor: alles static
     310                 :            : 
     311                 :            : //! SortAscending muss aus der SheetSortDescriptor service-Beschreibung raus
     312                 :            : 
     313                 :          4 : long ScSortDescriptor::GetPropertyCount()
     314                 :            : {
     315                 :          4 :     return 9;       // TableSortDescriptor and SheetSortDescriptor
     316                 :            : }
     317                 :            : 
     318                 :          4 : void ScSortDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScSortParam& rParam )
     319                 :            : {
     320                 :            :     OSL_ENSURE( rSeq.getLength() == GetPropertyCount(), "falscher Count" );
     321                 :            : 
     322         [ +  - ]:          4 :     beans::PropertyValue* pArray = rSeq.getArray();
     323                 :            : 
     324                 :            :     //  Uno-Werte zusammensuchen
     325                 :            : 
     326                 :          4 :     table::CellAddress aOutPos;
     327                 :          4 :     aOutPos.Sheet  = rParam.nDestTab;
     328                 :          4 :     aOutPos.Column = rParam.nDestCol;
     329                 :          4 :     aOutPos.Row    = rParam.nDestRow;
     330                 :            : 
     331                 :          4 :     sal_uInt16 nSortCount = 0;
     332 [ +  - ][ -  + ]:          4 :     while ( nSortCount < rParam.GetSortKeyCount() && rParam.maKeyState[nSortCount].bDoSort )
                 [ -  + ]
     333                 :          0 :         ++nSortCount;
     334                 :            : 
     335         [ +  - ]:          4 :     uno::Sequence<table::TableSortField> aFields(nSortCount);
     336         [ -  + ]:          4 :     if (nSortCount)
     337                 :            :     {
     338         [ #  # ]:          0 :         table::TableSortField* pFieldArray = aFields.getArray();
     339         [ #  # ]:          0 :         for (sal_uInt16 i=0; i<nSortCount; i++)
     340                 :            :         {
     341                 :          0 :             pFieldArray[i].Field         = rParam.maKeyState[i].nField;
     342                 :          0 :             pFieldArray[i].IsAscending   = rParam.maKeyState[i].bAscending;
     343                 :          0 :             pFieldArray[i].FieldType     = table::TableSortFieldType_AUTOMATIC;     // immer Automatic
     344                 :          0 :             pFieldArray[i].IsCaseSensitive = rParam.bCaseSens;
     345                 :          0 :             pFieldArray[i].CollatorLocale = rParam.aCollatorLocale;
     346                 :          0 :             pFieldArray[i].CollatorAlgorithm = rParam.aCollatorAlgorithm;
     347                 :            :         }
     348                 :            :     }
     349                 :            : 
     350                 :            :     //  Sequence fuellen
     351                 :            : 
     352         [ +  - ]:          4 :     pArray[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ISSORTCOLUMNS ));
     353         [ +  - ]:          4 :     pArray[0].Value = ::cppu::bool2any(!rParam.bByRow);
     354                 :            : 
     355         [ +  - ]:          4 :     pArray[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CONTHDR ));
     356         [ +  - ]:          4 :     ScUnoHelpFunctions::SetBoolInAny( pArray[1].Value, rParam.bHasHeader );
     357                 :            : 
     358         [ +  - ]:          4 :     pArray[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_MAXFLD ));
     359         [ +  - ]:          4 :     pArray[2].Value <<= static_cast<sal_Int32>( rParam.GetSortKeyCount() );
     360                 :            : 
     361         [ +  - ]:          4 :     pArray[3].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SORTFLD ));
     362         [ +  - ]:          4 :     pArray[3].Value <<= aFields;
     363                 :            : 
     364         [ +  - ]:          4 :     pArray[4].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_BINDFMT ));
     365         [ +  - ]:          4 :     ScUnoHelpFunctions::SetBoolInAny( pArray[4].Value, rParam.bIncludePattern );
     366                 :            : 
     367         [ +  - ]:          4 :     pArray[5].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_COPYOUT ));
     368         [ +  - ]:          4 :     ScUnoHelpFunctions::SetBoolInAny( pArray[5].Value, !rParam.bInplace );
     369                 :            : 
     370         [ +  - ]:          4 :     pArray[6].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_OUTPOS ));
     371         [ +  - ]:          4 :     pArray[6].Value <<= aOutPos;
     372                 :            : 
     373         [ +  - ]:          4 :     pArray[7].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ISULIST ));
     374         [ +  - ]:          4 :     ScUnoHelpFunctions::SetBoolInAny( pArray[7].Value, rParam.bUserDef );
     375                 :            : 
     376         [ +  - ]:          4 :     pArray[8].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_UINDEX ));
     377 [ +  - ][ +  - ]:          4 :     pArray[8].Value <<= static_cast<sal_Int32>( rParam.nUserIndex );
     378                 :          4 : }
     379                 :            : 
     380                 :          8 : void ScSortDescriptor::FillSortParam( ScSortParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
     381                 :            : {
     382                 :          8 :     const beans::PropertyValue* pPropArray = rSeq.getConstArray();
     383                 :          8 :     long nPropCount = rSeq.getLength();
     384                 :          8 :     sal_Int16 nSortSize = rParam.GetSortKeyCount();
     385                 :            : 
     386         [ +  + ]:         80 :     for (long nProp = 0; nProp < nPropCount; nProp++)
     387                 :            :     {
     388                 :         72 :         const beans::PropertyValue& rProp = pPropArray[nProp];
     389         [ +  - ]:         72 :         String aPropName(rProp.Name);
     390                 :            : 
     391 [ +  - ][ -  + ]:         72 :         if (aPropName.EqualsAscii( SC_UNONAME_ORIENT ))
     392                 :            :         {
     393                 :            :             //! test for correct enum type?
     394                 :            :             table::TableOrientation eOrient = (table::TableOrientation)
     395         [ #  # ]:          0 :                                 ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
     396                 :          0 :             rParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
     397                 :            :         }
     398 [ +  - ][ +  + ]:         72 :         else if (aPropName.EqualsAscii( SC_UNONAME_ISSORTCOLUMNS ))
     399                 :            :         {
     400         [ +  - ]:          8 :             rParam.bByRow = !::cppu::any2bool(rProp.Value);
     401                 :            :         }
     402 [ +  - ][ +  + ]:         64 :         else if (aPropName.EqualsAscii( SC_UNONAME_CONTHDR ))
     403         [ +  - ]:          8 :             rParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     404 [ +  - ][ +  + ]:         56 :         else if (aPropName.EqualsAscii( SC_UNONAME_MAXFLD ))
     405                 :            :         {
     406                 :            :             sal_Int32 nVal;
     407 [ +  - ][ -  + ]:          8 :             if ( (rProp.Value >>= nVal) && nVal > nSortSize )
     408                 :            :             {
     409                 :            :                 //! specify exceptions
     410                 :            :                 //! throw lang::IllegalArgumentException();
     411                 :            :             }
     412                 :            :         }
     413 [ +  - ][ +  + ]:         48 :         else if (aPropName.EqualsAscii( SC_UNONAME_SORTFLD ))
     414                 :            :         {
     415         [ +  - ]:          8 :             uno::Sequence<util::SortField> aSeq;
     416         [ +  - ]:          8 :             uno::Sequence<table::TableSortField> aNewSeq;
     417 [ +  - ][ -  + ]:          8 :             if ( rProp.Value >>= aSeq )
     418                 :            :             {
     419                 :          0 :                 sal_Int32 nCount = aSeq.getLength();
     420                 :            :                 sal_Int32 i;
     421         [ #  # ]:          0 :                 if ( nCount > static_cast<sal_Int32>( rParam.GetSortKeyCount() ) )
     422                 :            :                 {
     423                 :          0 :                     nCount = nSortSize;
     424         [ #  # ]:          0 :                     rParam.maKeyState.resize(nCount);
     425                 :            :                 }
     426                 :          0 :                 const util::SortField* pFieldArray = aSeq.getConstArray();
     427         [ #  # ]:          0 :                 for (i=0; i<nCount; i++)
     428                 :            :                 {
     429                 :          0 :                     rParam.maKeyState[i].nField     = static_cast<SCCOLROW>( pFieldArray[i].Field );
     430                 :          0 :                     rParam.maKeyState[i].bAscending = pFieldArray[i].SortAscending;
     431                 :            : 
     432                 :            :                     // FieldType wird ignoriert
     433                 :          0 :                     rParam.maKeyState[i].bDoSort = true;
     434                 :            :                 }
     435         [ #  # ]:          0 :                 for (i=nCount; i<nSortSize; i++)
     436                 :          0 :                     rParam.maKeyState[i].bDoSort = false;
     437                 :            :             }
     438 [ +  - ][ +  - ]:          8 :             else if ( rProp.Value >>= aNewSeq )
     439                 :            :             {
     440                 :          8 :                 sal_Int32 nCount = aNewSeq.getLength();
     441                 :            :                 sal_Int32 i;
     442         [ -  + ]:          8 :                 if ( nCount > nSortSize )
     443                 :            :                 {
     444                 :          0 :                     nCount = nSortSize;
     445         [ #  # ]:          0 :                     rParam.maKeyState.resize(nCount);
     446                 :            :                 }
     447                 :          8 :                 const table::TableSortField* pFieldArray = aNewSeq.getConstArray();
     448         [ +  + ]:         16 :                 for (i=0; i<nCount; i++)
     449                 :            :                 {
     450                 :          8 :                     rParam.maKeyState[i].nField     = static_cast<SCCOLROW>( pFieldArray[i].Field );
     451                 :          8 :                     rParam.maKeyState[i].bAscending = pFieldArray[i].IsAscending;
     452                 :            : 
     453                 :            :                     // only one is possible, sometime we should make it possible to have different for every entry
     454                 :          8 :                     rParam.bCaseSens = pFieldArray[i].IsCaseSensitive;
     455                 :          8 :                     rParam.aCollatorLocale = pFieldArray[i].CollatorLocale;
     456                 :          8 :                     rParam.aCollatorAlgorithm = pFieldArray[i].CollatorAlgorithm;
     457                 :            : 
     458                 :            :                     // FieldType wird ignoriert
     459                 :          8 :                     rParam.maKeyState[i].bDoSort = true;
     460                 :            :                 }
     461         [ +  + ]:         24 :                 for (i=nCount; i<nSortSize; i++)
     462                 :         16 :                     rParam.maKeyState[i].bDoSort = false;
     463 [ +  - ][ +  - ]:          8 :             }
     464                 :            :         }
     465 [ +  - ][ -  + ]:         40 :         else if (aPropName.EqualsAscii( SC_UNONAME_ISCASE ))
     466                 :            :         {
     467         [ #  # ]:          0 :             rParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     468                 :            :         }
     469 [ +  - ][ +  + ]:         40 :         else if (aPropName.EqualsAscii( SC_UNONAME_BINDFMT ))
     470         [ +  - ]:          8 :             rParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     471 [ +  - ][ +  + ]:         32 :         else if (aPropName.EqualsAscii( SC_UNONAME_COPYOUT ))
     472         [ +  - ]:          8 :             rParam.bInplace = !ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     473 [ +  - ][ +  + ]:         24 :         else if (aPropName.EqualsAscii( SC_UNONAME_OUTPOS ))
     474                 :            :         {
     475                 :          8 :             table::CellAddress aAddress;
     476 [ +  - ][ +  - ]:          8 :             if ( rProp.Value >>= aAddress )
     477                 :            :             {
     478                 :          8 :                 rParam.nDestTab = aAddress.Sheet;
     479                 :          8 :                 rParam.nDestCol = (SCCOL)aAddress.Column;
     480                 :          8 :                 rParam.nDestRow = (SCROW)aAddress.Row;
     481                 :            :             }
     482                 :            :         }
     483 [ +  - ][ +  + ]:         16 :         else if (aPropName.EqualsAscii( SC_UNONAME_ISULIST ))
     484         [ +  - ]:          8 :             rParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
     485 [ +  - ][ +  - ]:          8 :         else if (aPropName.EqualsAscii( SC_UNONAME_UINDEX ))
     486                 :            :         {
     487                 :          8 :             sal_Int32 nVal = 0;
     488         [ +  - ]:          8 :             if ( rProp.Value >>= nVal )
     489                 :          8 :                 rParam.nUserIndex = (sal_uInt16)nVal;
     490                 :            :         }
     491 [ #  # ][ #  # ]:          0 :         else if (aPropName.EqualsAscii( SC_UNONAME_COLLLOC ))
     492                 :            :         {
     493         [ #  # ]:          0 :             rProp.Value >>= rParam.aCollatorLocale;
     494                 :            :         }
     495 [ #  # ][ #  # ]:          0 :         else if (aPropName.EqualsAscii( SC_UNONAME_COLLALG ))
     496                 :            :         {
     497                 :          0 :             rtl::OUString sStr;
     498         [ #  # ]:          0 :             if ( rProp.Value >>= sStr )
     499                 :          0 :                 rParam.aCollatorAlgorithm = sStr;
     500                 :            :         }
     501         [ +  - ]:         72 :     }
     502                 :          8 : }
     503                 :            : 
     504                 :            : //------------------------------------------------------------------------
     505                 :            : 
     506                 :          5 : ScSubTotalFieldObj::ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, sal_uInt16 nP ) :
     507                 :            :     xRef( pDesc ),          // Objekt festhalten
     508                 :            :     rParent( *pDesc ),
     509 [ +  - ][ +  - ]:          5 :     nPos( nP )
     510                 :            : {
     511                 :            :     OSL_ENSURE(pDesc, "ScSubTotalFieldObj: Parent ist 0");
     512                 :          5 : }
     513                 :            : 
     514                 :          5 : ScSubTotalFieldObj::~ScSubTotalFieldObj()
     515                 :            : {
     516         [ -  + ]:         10 : }
     517                 :            : 
     518                 :            : // XSubTotalField
     519                 :            : 
     520                 :          2 : sal_Int32 SAL_CALL ScSubTotalFieldObj::getGroupColumn() throw(uno::RuntimeException)
     521                 :            : {
     522         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     523         [ +  - ]:          2 :     ScSubTotalParam aParam;
     524         [ +  - ]:          2 :     rParent.GetData(aParam);
     525                 :            : 
     526         [ +  - ]:          2 :     return aParam.nField[nPos];
     527                 :            : }
     528                 :            : 
     529                 :          1 : void SAL_CALL ScSubTotalFieldObj::setGroupColumn( sal_Int32 nGroupColumn ) throw(uno::RuntimeException)
     530                 :            : {
     531         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     532         [ +  - ]:          1 :     ScSubTotalParam aParam;
     533         [ +  - ]:          1 :     rParent.GetData(aParam);
     534                 :            : 
     535                 :          1 :     aParam.nField[nPos] = (SCCOL)nGroupColumn;
     536                 :            : 
     537 [ +  - ][ +  - ]:          1 :     rParent.PutData(aParam);
     538                 :          1 : }
     539                 :            : 
     540                 :          2 : uno::Sequence<sheet::SubTotalColumn> SAL_CALL ScSubTotalFieldObj::getSubTotalColumns()
     541                 :            :                                                 throw(uno::RuntimeException)
     542                 :            : {
     543         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     544         [ +  - ]:          2 :     ScSubTotalParam aParam;
     545         [ +  - ]:          2 :     rParent.GetData(aParam);
     546                 :            : 
     547                 :          2 :     SCCOL nCount = aParam.nSubTotals[nPos];
     548         [ +  - ]:          2 :     uno::Sequence<sheet::SubTotalColumn> aSeq(nCount);
     549         [ +  - ]:          2 :     sheet::SubTotalColumn* pAry = aSeq.getArray();
     550         [ +  + ]:          5 :     for (SCCOL i=0; i<nCount; i++)
     551                 :            :     {
     552                 :          3 :         pAry[i].Column = aParam.pSubTotals[nPos][i];
     553                 :          3 :         pAry[i].Function = ScDataUnoConversion::SubTotalToGeneral(
     554                 :          3 :                                         aParam.pFunctions[nPos][i] );
     555                 :            :     }
     556         [ +  - ]:          2 :     return aSeq;
     557                 :            : }
     558                 :            : 
     559                 :          1 : void SAL_CALL ScSubTotalFieldObj::setSubTotalColumns(
     560                 :            :                             const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns )
     561                 :            :                                     throw(uno::RuntimeException)
     562                 :            : {
     563         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     564         [ +  - ]:          1 :     ScSubTotalParam aParam;
     565         [ +  - ]:          1 :     rParent.GetData(aParam);
     566                 :            : 
     567                 :          1 :     sal_uInt32 nColCount = aSubTotalColumns.getLength();
     568         [ +  - ]:          1 :     if ( nColCount <= sal::static_int_cast<sal_uInt32>(SCCOL_MAX) )
     569                 :            :     {
     570                 :          1 :         SCCOL nCount = static_cast<SCCOL>(nColCount);
     571                 :          1 :         aParam.nSubTotals[nPos] = nCount;
     572         [ +  - ]:          1 :         if (nCount != 0)
     573                 :            :         {
     574         [ +  - ]:          1 :             aParam.pSubTotals[nPos] = new SCCOL[nCount];
     575         [ +  - ]:          1 :             aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
     576                 :            : 
     577                 :          1 :             const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
     578         [ +  + ]:          3 :             for (SCCOL i=0; i<nCount; i++)
     579                 :            :             {
     580                 :          2 :                 aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
     581                 :          2 :                 aParam.pFunctions[nPos][i] =
     582                 :          2 :                             ScDataUnoConversion::GeneralToSubTotal( pAry[i].Function );
     583                 :            :             }
     584                 :            :         }
     585                 :            :         else
     586                 :            :         {
     587                 :          0 :             aParam.pSubTotals[nPos] = NULL;
     588                 :          0 :             aParam.pFunctions[nPos] = NULL;
     589                 :            :         }
     590                 :            :     }
     591                 :            :     //! sonst Exception oder so? (zuviele Spalten)
     592                 :            : 
     593 [ +  - ][ +  - ]:          1 :     rParent.PutData(aParam);
     594                 :          1 : }
     595                 :            : 
     596                 :            : //------------------------------------------------------------------------
     597                 :            : 
     598                 :          9 : ScSubTotalDescriptorBase::ScSubTotalDescriptorBase() :
     599 [ +  - ][ +  - ]:          9 :     aPropSet( lcl_GetSubTotalPropertyMap() )
     600                 :            : {
     601                 :          9 : }
     602                 :            : 
     603         [ +  - ]:          9 : ScSubTotalDescriptorBase::~ScSubTotalDescriptorBase()
     604                 :            : {
     605         [ -  + ]:          9 : }
     606                 :            : 
     607                 :            : // XSubTotalDesctiptor
     608                 :            : 
     609                 :          7 : ScSubTotalFieldObj* ScSubTotalDescriptorBase::GetObjectByIndex_Impl(sal_uInt16 nIndex)
     610                 :            : {
     611         [ +  + ]:          7 :     if ( nIndex < getCount() )
     612         [ +  - ]:          5 :         return new ScSubTotalFieldObj( this, nIndex );
     613                 :          7 :     return NULL;
     614                 :            : }
     615                 :            : 
     616                 :          1 : void SAL_CALL ScSubTotalDescriptorBase::clear() throw(uno::RuntimeException)
     617                 :            : {
     618         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     619         [ +  - ]:          1 :     ScSubTotalParam aParam;
     620         [ +  - ]:          1 :     GetData(aParam);
     621                 :            : 
     622         [ +  + ]:          4 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
     623                 :          3 :         aParam.bGroupActive[i] = false;
     624                 :            : 
     625                 :            :     //! Notify oder so fuer die Field-Objekte???
     626                 :            : 
     627 [ +  - ][ +  - ]:          1 :     PutData(aParam);
     628                 :          1 : }
     629                 :            : 
     630                 :          8 : void SAL_CALL ScSubTotalDescriptorBase::addNew(
     631                 :            :                         const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns,
     632                 :            :                         sal_Int32 nGroupColumn ) throw(uno::RuntimeException)
     633                 :            : {
     634         [ +  - ]:          8 :     SolarMutexGuard aGuard;
     635         [ +  - ]:          8 :     ScSubTotalParam aParam;
     636         [ +  - ]:          8 :     GetData(aParam);
     637                 :            : 
     638                 :          8 :     sal_uInt16 nPos = 0;
     639 [ +  - ][ +  + ]:          9 :     while ( nPos < MAXSUBTOTAL && aParam.bGroupActive[nPos] )
                 [ +  + ]
     640                 :          1 :         ++nPos;
     641                 :            : 
     642                 :          8 :     sal_uInt32 nColCount = aSubTotalColumns.getLength();
     643                 :            : 
     644 [ +  - ][ +  - ]:          8 :     if ( nPos < MAXSUBTOTAL && nColCount <= sal::static_int_cast<sal_uInt32>(SCCOL_MAX) )
                 [ +  - ]
     645                 :            :     {
     646                 :          8 :         aParam.bGroupActive[nPos] = sal_True;
     647                 :          8 :         aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn);
     648                 :            : 
     649                 :          8 :         delete aParam.pSubTotals[nPos];
     650                 :          8 :         delete aParam.pFunctions[nPos];
     651                 :            : 
     652                 :          8 :         SCCOL nCount = static_cast<SCCOL>(nColCount);
     653                 :          8 :         aParam.nSubTotals[nPos] = nCount;
     654         [ +  - ]:          8 :         if (nCount != 0)
     655                 :            :         {
     656         [ +  - ]:          8 :             aParam.pSubTotals[nPos] = new SCCOL[nCount];
     657         [ +  - ]:          8 :             aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
     658                 :            : 
     659                 :          8 :             const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
     660         [ +  + ]:         16 :             for (SCCOL i=0; i<nCount; i++)
     661                 :            :             {
     662                 :          8 :                 aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
     663                 :          8 :                 aParam.pFunctions[nPos][i] =
     664                 :          8 :                             ScDataUnoConversion::GeneralToSubTotal( pAry[i].Function );
     665                 :            :             }
     666                 :            :         }
     667                 :            :         else
     668                 :            :         {
     669                 :          0 :             aParam.pSubTotals[nPos] = NULL;
     670                 :          0 :             aParam.pFunctions[nPos] = NULL;
     671                 :            :         }
     672                 :            :     }
     673                 :            :     else                                    // too many fields / columns
     674         [ #  # ]:          0 :         throw uno::RuntimeException();      // no other exceptions specified
     675                 :            : 
     676 [ +  - ][ +  - ]:          8 :     PutData(aParam);
     677                 :          8 : }
     678                 :            : 
     679                 :            : //  Flags/Einstellungen als Properties
     680                 :            : 
     681                 :            : // XEnumerationAccess
     682                 :            : 
     683                 :          2 : uno::Reference<container::XEnumeration> SAL_CALL ScSubTotalDescriptorBase::createEnumeration()
     684                 :            :                                                     throw(uno::RuntimeException)
     685                 :            : {
     686         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     687 [ +  - ][ +  - ]:          2 :     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SubTotalFieldsEnumeration")));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     688                 :            : }
     689                 :            : 
     690                 :            : // XIndexAccess
     691                 :            : 
     692                 :         11 : sal_Int32 SAL_CALL ScSubTotalDescriptorBase::getCount() throw(uno::RuntimeException)
     693                 :            : {
     694         [ +  - ]:         11 :     SolarMutexGuard aGuard;
     695         [ +  - ]:         11 :     ScSubTotalParam aParam;
     696         [ +  - ]:         11 :     GetData(aParam);
     697                 :            : 
     698                 :         11 :     sal_uInt16 nCount = 0;
     699 [ +  - ][ +  + ]:         22 :     while ( nCount < MAXSUBTOTAL && aParam.bGroupActive[nCount] )
                 [ +  + ]
     700                 :         11 :         ++nCount;
     701         [ +  - ]:         11 :     return nCount;
     702                 :            : }
     703                 :            : 
     704                 :          7 : uno::Any SAL_CALL ScSubTotalDescriptorBase::getByIndex( sal_Int32 nIndex )
     705                 :            :                             throw(lang::IndexOutOfBoundsException,
     706                 :            :                                     lang::WrappedTargetException, uno::RuntimeException)
     707                 :            : {
     708         [ +  - ]:          7 :     SolarMutexGuard aGuard;
     709 [ +  - ][ +  + ]:          7 :     uno::Reference<sheet::XSubTotalField> xField(GetObjectByIndex_Impl((sal_uInt16)nIndex));
                 [ +  - ]
     710         [ +  + ]:          7 :     if (xField.is())
     711         [ +  - ]:         10 :         return uno::makeAny(xField);
     712                 :            :     else
     713 [ +  - ][ +  - ]:          7 :         throw lang::IndexOutOfBoundsException();
     714                 :            : }
     715                 :            : 
     716                 :          1 : uno::Type SAL_CALL ScSubTotalDescriptorBase::getElementType() throw(uno::RuntimeException)
     717                 :            : {
     718         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     719 [ +  - ][ +  - ]:          1 :     return getCppuType((uno::Reference<sheet::XSubTotalField>*)0);
     720                 :            : }
     721                 :            : 
     722                 :          1 : sal_Bool SAL_CALL ScSubTotalDescriptorBase::hasElements() throw(uno::RuntimeException)
     723                 :            : {
     724         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     725 [ +  - ][ +  - ]:          1 :     return ( getCount() != 0 );
     726                 :            : }
     727                 :            : 
     728                 :            : // XPropertySet
     729                 :            : 
     730                 :         17 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSubTotalDescriptorBase::getPropertySetInfo()
     731                 :            :                                                         throw(uno::RuntimeException)
     732                 :            : {
     733         [ +  - ]:         17 :     SolarMutexGuard aGuard;
     734                 :            :     static uno::Reference<beans::XPropertySetInfo> aRef(
     735 [ +  + ][ +  - ]:         17 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     736         [ +  - ]:         17 :     return aRef;
     737                 :            : }
     738                 :            : 
     739                 :         30 : void SAL_CALL ScSubTotalDescriptorBase::setPropertyValue(
     740                 :            :                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
     741                 :            :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     742                 :            :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     743                 :            :                         uno::RuntimeException)
     744                 :            : {
     745         [ +  - ]:         30 :     SolarMutexGuard aGuard;
     746         [ +  - ]:         30 :     ScSubTotalParam aParam;
     747         [ +  - ]:         30 :     GetData(aParam);
     748                 :            : 
     749         [ +  - ]:         30 :     String aString(aPropertyName);
     750                 :            : 
     751                 :            :     // some old property names are for 5.2 compatibility
     752                 :            : 
     753 [ +  - ][ +  + ]:         30 :     if (aString.EqualsAscii( SC_UNONAME_CASE ) || aString.EqualsAscii( SC_UNONAME_ISCASE ))
         [ +  - ][ +  + ]
                 [ +  + ]
     754         [ +  - ]:          5 :         aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     755 [ +  - ][ +  + ]:         25 :     else if (aString.EqualsAscii( SC_UNONAME_FORMATS ) || aString.EqualsAscii( SC_UNONAME_BINDFMT ))
         [ +  - ][ +  + ]
                 [ +  + ]
     756         [ +  - ]:          5 :         aParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     757 [ +  - ][ +  + ]:         20 :     else if (aString.EqualsAscii( SC_UNONAME_ENABSORT ))
     758         [ +  - ]:          3 :         aParam.bDoSort = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     759 [ +  - ][ +  + ]:         17 :     else if (aString.EqualsAscii( SC_UNONAME_SORTASC ))
     760         [ +  - ]:          3 :         aParam.bAscending = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     761 [ +  - ][ +  + ]:         14 :     else if (aString.EqualsAscii( SC_UNONAME_INSBRK ))
     762         [ +  - ]:          3 :         aParam.bPagebreak = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     763 [ +  - ][ +  + ]:         11 :     else if (aString.EqualsAscii( SC_UNONAME_ULIST ) || aString.EqualsAscii( SC_UNONAME_ENUSLIST ))
         [ +  - ][ +  + ]
                 [ +  + ]
     764         [ +  - ]:          5 :         aParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( aValue );
     765 [ +  - ][ +  + ]:          6 :     else if (aString.EqualsAscii( SC_UNONAME_UINDEX ) || aString.EqualsAscii( SC_UNONAME_USINDEX ))
         [ +  - ][ +  + ]
                 [ +  + ]
     766                 :            :     {
     767                 :          5 :         sal_Int32 nVal = 0;
     768         [ +  - ]:          5 :         if ( aValue >>= nVal )
     769                 :          5 :             aParam.nUserIndex = (sal_uInt16)nVal;
     770                 :            :     }
     771 [ +  - ][ +  - ]:          1 :     else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
     772                 :            :     {
     773                 :          1 :         sal_Int32 nVal = 0;
     774 [ +  - ][ +  - ]:          1 :         if ( (aValue >>= nVal) && nVal > sal::static_int_cast<sal_Int32>(MAXSUBTOTAL) )
                 [ +  - ]
     775                 :            :         {
     776         [ +  - ]:          1 :             throw lang::IllegalArgumentException();
     777                 :            :         }
     778                 :            :     }
     779                 :            : 
     780 [ +  - ][ +  - ]:         30 :     PutData(aParam);
                 [ +  - ]
     781                 :         29 : }
     782                 :            : 
     783                 :         71 : uno::Any SAL_CALL ScSubTotalDescriptorBase::getPropertyValue( const rtl::OUString& aPropertyName )
     784                 :            :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     785                 :            :                         uno::RuntimeException)
     786                 :            : {
     787         [ +  - ]:         71 :     SolarMutexGuard aGuard;
     788         [ +  - ]:         71 :     ScSubTotalParam aParam;
     789         [ +  - ]:         71 :     GetData(aParam);
     790                 :            : 
     791         [ +  - ]:         71 :     String aString(aPropertyName);
     792                 :         71 :     uno::Any aRet;
     793                 :            : 
     794                 :            :     // some old property names are for 5.2 compatibility
     795                 :            : 
     796 [ +  + ][ +  - ]:         71 :     if (aString.EqualsAscii( SC_UNONAME_CASE ) || aString.EqualsAscii( SC_UNONAME_ISCASE ))
         [ +  + ][ +  + ]
                 [ +  - ]
     797         [ +  - ]:         12 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bCaseSens );
     798 [ +  - ][ +  + ]:         59 :     else if (aString.EqualsAscii( SC_UNONAME_FORMATS ) || aString.EqualsAscii( SC_UNONAME_BINDFMT ))
         [ +  - ][ +  + ]
                 [ +  + ]
     799         [ +  - ]:         12 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bIncludePattern );
     800 [ +  - ][ +  + ]:         47 :     else if (aString.EqualsAscii( SC_UNONAME_ENABSORT ))
     801         [ +  - ]:          7 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bDoSort );
     802 [ +  - ][ +  + ]:         40 :     else if (aString.EqualsAscii( SC_UNONAME_SORTASC ))
     803         [ +  - ]:          7 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bAscending );
     804 [ +  - ][ +  + ]:         33 :     else if (aString.EqualsAscii( SC_UNONAME_INSBRK ))
     805         [ +  - ]:          7 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bPagebreak );
     806 [ +  - ][ +  + ]:         26 :     else if (aString.EqualsAscii( SC_UNONAME_ULIST ) || aString.EqualsAscii( SC_UNONAME_ENUSLIST ))
         [ +  - ][ +  + ]
                 [ +  + ]
     807         [ +  - ]:         12 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bUserDef );
     808 [ +  - ][ +  + ]:         14 :     else if (aString.EqualsAscii( SC_UNONAME_UINDEX ) || aString.EqualsAscii( SC_UNONAME_USINDEX ))
         [ +  - ][ +  + ]
                 [ +  + ]
     809         [ +  - ]:         12 :         aRet <<= (sal_Int32) aParam.nUserIndex;
     810 [ +  - ][ +  - ]:          2 :     else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
     811         [ +  - ]:          2 :         aRet <<= (sal_Int32) MAXSUBTOTAL;
     812                 :            : 
     813 [ +  - ][ +  - ]:         71 :     return aRet;
     814                 :            : }
     815                 :            : 
     816                 :          0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSubTotalDescriptorBase )
     817                 :            : 
     818                 :            : // XUnoTunnel
     819                 :            : 
     820                 :          2 : sal_Int64 SAL_CALL ScSubTotalDescriptorBase::getSomething(
     821                 :            :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
     822                 :            : {
     823   [ +  -  +  - ]:          4 :     if ( rId.getLength() == 16 &&
                 [ +  - ]
     824                 :          2 :           0 == memcmp( getUnoTunnelId().getConstArray(),
     825                 :          2 :                                     rId.getConstArray(), 16 ) )
     826                 :            :     {
     827                 :          2 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
     828                 :            :     }
     829                 :          2 :     return 0;
     830                 :            : }
     831                 :            : 
     832                 :            : namespace
     833                 :            : {
     834                 :            :     class theScSubTotalDescriptorBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScSubTotalDescriptorBaseUnoTunnelId> {};
     835                 :            : }
     836                 :            : 
     837                 :          4 : const uno::Sequence<sal_Int8>& ScSubTotalDescriptorBase::getUnoTunnelId()
     838                 :            : {
     839                 :          4 :     return theScSubTotalDescriptorBaseUnoTunnelId::get().getSeq();
     840                 :            : }
     841                 :            : 
     842                 :          2 : ScSubTotalDescriptorBase* ScSubTotalDescriptorBase::getImplementation(
     843                 :            :                                 const uno::Reference<sheet::XSubTotalDescriptor> xObj )
     844                 :            : {
     845                 :          2 :     ScSubTotalDescriptorBase* pRet = NULL;
     846         [ +  - ]:          2 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
     847         [ +  - ]:          2 :     if (xUT.is())
     848 [ +  - ][ +  - ]:          2 :         pRet = reinterpret_cast<ScSubTotalDescriptorBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
                 [ +  - ]
     849                 :          2 :     return pRet;
     850                 :            : }
     851                 :            : 
     852                 :            : //------------------------------------------------------------------------
     853                 :            : 
     854         [ +  - ]:          7 : ScSubTotalDescriptor::ScSubTotalDescriptor()
     855                 :            : {
     856                 :          7 : }
     857                 :            : 
     858                 :          7 : ScSubTotalDescriptor::~ScSubTotalDescriptor()
     859                 :            : {
     860         [ -  + ]:         14 : }
     861                 :            : 
     862                 :        129 : void ScSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
     863                 :            : {
     864                 :        129 :     rParam = aStoredParam;          // Abfrage fuer Interface
     865                 :        129 : }
     866                 :            : 
     867                 :         40 : void ScSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
     868                 :            : {
     869                 :         40 :     aStoredParam = rParam;          // vom Interface gesetzt
     870                 :         40 : }
     871                 :            : 
     872                 :          0 : void ScSubTotalDescriptor::SetParam( const ScSubTotalParam& rNew )
     873                 :            : {
     874                 :          0 :     aStoredParam = rNew;            // von aussen gesetzt
     875                 :          0 : }
     876                 :            : 
     877                 :            : //------------------------------------------------------------------------
     878                 :            : 
     879                 :          2 : ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar) :
     880                 :          2 :     pParent(pPar)
     881                 :            : {
     882         [ +  - ]:          2 :     if (pParent)
     883                 :          2 :         pParent->acquire();
     884                 :          2 : }
     885                 :            : 
     886                 :          2 : ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor()
     887                 :            : {
     888         [ +  - ]:          2 :     if (pParent)
     889                 :          2 :         pParent->release();
     890         [ -  + ]:          4 : }
     891                 :            : 
     892                 :          0 : void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
     893                 :            : {
     894         [ #  # ]:          0 :     if (pParent)
     895                 :          0 :         pParent->GetSubTotalParam( rParam );
     896                 :          0 : }
     897                 :            : 
     898                 :          0 : void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
     899                 :            : {
     900         [ #  # ]:          0 :     if (pParent)
     901                 :          0 :         pParent->SetSubTotalParam( rParam );
     902                 :          0 : }
     903                 :            : 
     904                 :            : //------------------------------------------------------------------------
     905                 :            : 
     906         [ +  - ]:          3 : ScConsolidationDescriptor::ScConsolidationDescriptor()
     907                 :            : {
     908                 :          3 : }
     909                 :            : 
     910         [ +  - ]:          3 : ScConsolidationDescriptor::~ScConsolidationDescriptor()
     911                 :            : {
     912         [ -  + ]:          5 : }
     913                 :            : 
     914                 :          0 : void ScConsolidationDescriptor::SetParam( const ScConsolidateParam& rNew )
     915                 :            : {
     916                 :          0 :     aParam = rNew;
     917                 :          0 : }
     918                 :            : 
     919                 :            : // XConsolidationDescriptor
     920                 :            : 
     921                 :          3 : sheet::GeneralFunction SAL_CALL ScConsolidationDescriptor::getFunction() throw(uno::RuntimeException)
     922                 :            : {
     923         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     924         [ +  - ]:          3 :     return ScDataUnoConversion::SubTotalToGeneral(aParam.eFunction);
     925                 :            : }
     926                 :            : 
     927                 :          2 : void SAL_CALL ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction )
     928                 :            :                                                     throw(uno::RuntimeException)
     929                 :            : {
     930         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     931         [ +  - ]:          2 :     aParam.eFunction = ScDataUnoConversion::GeneralToSubTotal(nFunction);
     932                 :          2 : }
     933                 :            : 
     934                 :          3 : uno::Sequence<table::CellRangeAddress> SAL_CALL ScConsolidationDescriptor::getSources()
     935                 :            :                                                         throw(uno::RuntimeException)
     936                 :            : {
     937         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     938                 :          3 :     sal_uInt16 nCount = aParam.nDataAreaCount;
     939         [ +  + ]:          3 :     if (!aParam.ppDataAreas)
     940                 :          2 :         nCount = 0;
     941                 :          3 :     table::CellRangeAddress aRange;
     942         [ +  - ]:          3 :     uno::Sequence<table::CellRangeAddress> aSeq(nCount);
     943         [ +  - ]:          3 :     table::CellRangeAddress* pAry = aSeq.getArray();
     944         [ +  + ]:          4 :     for (sal_uInt16 i=0; i<nCount; i++)
     945                 :            :     {
     946                 :          1 :         ScArea* pArea = aParam.ppDataAreas[i];
     947         [ +  - ]:          1 :         if (pArea)
     948                 :            :         {
     949                 :          1 :             aRange.Sheet        = pArea->nTab;
     950                 :          1 :             aRange.StartColumn  = pArea->nColStart;
     951                 :          1 :             aRange.StartRow     = pArea->nRowStart;
     952                 :          1 :             aRange.EndColumn    = pArea->nColEnd;
     953                 :          1 :             aRange.EndRow       = pArea->nRowEnd;
     954                 :            :         }
     955                 :          1 :         pAry[i] = aRange;
     956                 :            :     }
     957         [ +  - ]:          3 :     return aSeq;
     958                 :            : }
     959                 :            : 
     960                 :          2 : void SAL_CALL ScConsolidationDescriptor::setSources(
     961                 :            :                     const uno::Sequence<table::CellRangeAddress>& aSources )
     962                 :            :                                                 throw(uno::RuntimeException)
     963                 :            : {
     964         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     965                 :          2 :     sal_uInt16 nCount = (sal_uInt16)aSources.getLength();
     966         [ +  + ]:          2 :     if (nCount)
     967                 :            :     {
     968                 :          1 :         const table::CellRangeAddress* pAry = aSources.getConstArray();
     969         [ +  - ]:          1 :         ScArea** pNew = new ScArea*[nCount];
     970                 :            :         sal_uInt16 i;
     971         [ +  + ]:          2 :         for (i=0; i<nCount; i++)
     972                 :          2 :             pNew[i] = new ScArea( pAry[i].Sheet,
     973                 :          2 :                     static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow,
     974 [ +  - ][ +  - ]:          1 :                     static_cast<SCCOL>(pAry[i].EndColumn),   pAry[i].EndRow );
     975                 :            : 
     976         [ +  - ]:          1 :         aParam.SetAreas( pNew, nCount );    // kopiert alles
     977                 :            : 
     978         [ +  + ]:          2 :         for (i=0; i<nCount; i++)
     979                 :          1 :             delete pNew[i];
     980         [ +  - ]:          1 :         delete[] pNew;
     981                 :            :     }
     982                 :            :     else
     983 [ +  - ][ +  - ]:          2 :         aParam.ClearDataAreas();
     984                 :          2 : }
     985                 :            : 
     986                 :          2 : table::CellAddress SAL_CALL ScConsolidationDescriptor::getStartOutputPosition()
     987                 :            :                                                     throw(uno::RuntimeException)
     988                 :            : {
     989         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     990                 :          2 :     table::CellAddress aPos;
     991                 :          2 :     aPos.Column = aParam.nCol;
     992                 :          2 :     aPos.Row    = aParam.nRow;
     993                 :          2 :     aPos.Sheet  = aParam.nTab;
     994         [ +  - ]:          2 :     return aPos;
     995                 :            : }
     996                 :            : 
     997                 :          2 : void SAL_CALL ScConsolidationDescriptor::setStartOutputPosition(
     998                 :            :                                 const table::CellAddress& aStartOutputPosition )
     999                 :            :                                     throw(uno::RuntimeException)
    1000                 :            : {
    1001         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1002                 :          2 :     aParam.nCol = (SCCOL)aStartOutputPosition.Column;
    1003                 :          2 :     aParam.nRow = (SCROW)aStartOutputPosition.Row;
    1004         [ +  - ]:          2 :     aParam.nTab = aStartOutputPosition.Sheet;
    1005                 :          2 : }
    1006                 :            : 
    1007                 :          3 : sal_Bool SAL_CALL ScConsolidationDescriptor::getUseColumnHeaders() throw(uno::RuntimeException)
    1008                 :            : {
    1009         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    1010         [ +  - ]:          3 :     return aParam.bByCol;
    1011                 :            : }
    1012                 :            : 
    1013                 :          2 : void SAL_CALL ScConsolidationDescriptor::setUseColumnHeaders( sal_Bool bUseColumnHeaders )
    1014                 :            :                                                     throw(uno::RuntimeException)
    1015                 :            : {
    1016         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1017         [ +  - ]:          2 :     aParam.bByCol = bUseColumnHeaders;
    1018                 :          2 : }
    1019                 :            : 
    1020                 :          3 : sal_Bool SAL_CALL ScConsolidationDescriptor::getUseRowHeaders() throw(uno::RuntimeException)
    1021                 :            : {
    1022         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    1023         [ +  - ]:          3 :     return aParam.bByRow;
    1024                 :            : }
    1025                 :            : 
    1026                 :          2 : void SAL_CALL ScConsolidationDescriptor::setUseRowHeaders( sal_Bool bUseRowHeaders )
    1027                 :            :                                                     throw(uno::RuntimeException)
    1028                 :            : {
    1029         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1030         [ +  - ]:          2 :     aParam.bByRow = bUseRowHeaders;
    1031                 :          2 : }
    1032                 :            : 
    1033                 :          3 : sal_Bool SAL_CALL ScConsolidationDescriptor::getInsertLinks() throw(uno::RuntimeException)
    1034                 :            : {
    1035         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    1036         [ +  - ]:          3 :     return aParam.bReferenceData;
    1037                 :            : }
    1038                 :            : 
    1039                 :          2 : void SAL_CALL ScConsolidationDescriptor::setInsertLinks( sal_Bool bInsertLinks )
    1040                 :            :                                                     throw(uno::RuntimeException)
    1041                 :            : {
    1042         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1043         [ +  - ]:          2 :     aParam.bReferenceData = bInsertLinks;
    1044                 :          2 : }
    1045                 :            : 
    1046                 :         17 : ScFilterDescriptorBase::ScFilterDescriptorBase(ScDocShell* pDocShell) :
    1047                 :            :     aPropSet( lcl_GetFilterPropertyMap() ),
    1048 [ +  - ][ +  - ]:         17 :     pDocSh(pDocShell)
                 [ +  - ]
    1049                 :            : {
    1050         [ +  - ]:         17 :     if (pDocSh)
    1051         [ +  - ]:         17 :         pDocSh->GetDocument()->AddUnoObject(*this);
    1052                 :         17 : }
    1053                 :            : 
    1054 [ +  - ][ +  - ]:         17 : ScFilterDescriptorBase::~ScFilterDescriptorBase()
    1055                 :            : {
    1056         [ +  + ]:         17 :     if (pDocSh)
    1057         [ +  - ]:          9 :         pDocSh->GetDocument()->RemoveUnoObject(*this);
    1058         [ -  + ]:         17 : }
    1059                 :            : 
    1060                 :        189 : void ScFilterDescriptorBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1061                 :            : {
    1062         [ +  + ]:        189 :     if ( rHint.ISA( SfxSimpleHint ) )
    1063                 :            :     {
    1064                 :        143 :         sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
    1065         [ +  + ]:        143 :         if ( nId == SFX_HINT_DYING )
    1066                 :            :         {
    1067                 :          8 :             pDocSh = NULL;          // invalid
    1068                 :            :         }
    1069                 :            :     }
    1070                 :        189 : }
    1071                 :            : 
    1072                 :            : // XSheetFilterDescriptor and XSheetFilterDescriptor2
    1073                 :            : 
    1074                 :          4 : uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilterFields()
    1075                 :            :                                                 throw(uno::RuntimeException)
    1076                 :            : {
    1077         [ +  - ]:          4 :     SolarMutexGuard aGuard;
    1078         [ +  - ]:          4 :     ScQueryParam aParam;
    1079         [ +  - ]:          4 :     GetData(aParam);
    1080                 :            : 
    1081         [ +  - ]:          4 :     SCSIZE nEntries = aParam.GetEntryCount();   // allozierte Eintraege im Param
    1082                 :          4 :     SCSIZE nCount = 0;                          // aktive
    1083 [ +  - ][ +  + ]:         18 :     while ( nCount < nEntries &&
                 [ +  + ]
    1084         [ +  - ]:          9 :             aParam.GetEntry(nCount).bDoQuery )
    1085                 :          5 :         ++nCount;
    1086                 :            : 
    1087                 :          4 :     sheet::TableFilterField aField;
    1088         [ +  - ]:          4 :     uno::Sequence<sheet::TableFilterField> aSeq(static_cast<sal_Int32>(nCount));
    1089         [ +  - ]:          4 :     sheet::TableFilterField* pAry = aSeq.getArray();
    1090         [ +  + ]:          9 :     for (SCSIZE i=0; i<nCount; i++)
    1091                 :            :     {
    1092         [ +  - ]:          5 :         const ScQueryEntry& rEntry = aParam.GetEntry(i);
    1093 [ +  - ][ -  + ]:          5 :         if (rEntry.GetQueryItems().empty())
    1094                 :          0 :             continue;
    1095                 :            : 
    1096 [ +  - ][ +  - ]:          5 :         const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
    1097                 :            : 
    1098                 :            :         aField.Connection    = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
    1099                 :          5 :                                                              sheet::FilterConnection_OR;
    1100                 :          5 :         aField.Field         = rEntry.nField;
    1101                 :          5 :         aField.IsNumeric     = rItem.meType != ScQueryEntry::ByString;
    1102                 :          5 :         aField.StringValue   = rItem.maString;
    1103                 :          5 :         aField.NumericValue  = rItem.mfVal;
    1104                 :            : 
    1105   [ +  -  -  -  :          5 :         switch (rEntry.eOp)             // ScQueryOp
          -  -  -  -  -  
                   -  - ]
    1106                 :            :         {
    1107                 :            :             case SC_EQUAL:
    1108                 :            :                 {
    1109                 :          5 :                     aField.Operator = sheet::FilterOperator_EQUAL;
    1110 [ +  - ][ +  + ]:          5 :                     if (rEntry.IsQueryByEmpty())
    1111                 :            :                     {
    1112                 :          1 :                         aField.Operator = sheet::FilterOperator_EMPTY;
    1113                 :          1 :                         aField.NumericValue = 0;
    1114                 :            :                     }
    1115 [ +  - ][ -  + ]:          4 :                     else if (rEntry.IsQueryByNonEmpty())
    1116                 :            :                     {
    1117                 :          0 :                         aField.Operator = sheet::FilterOperator_NOT_EMPTY;
    1118                 :          0 :                         aField.NumericValue = 0;
    1119                 :            :                     }
    1120                 :            :                 }
    1121                 :          5 :                 break;
    1122                 :          0 :             case SC_LESS:           aField.Operator = sheet::FilterOperator_LESS;             break;
    1123                 :          0 :             case SC_GREATER:        aField.Operator = sheet::FilterOperator_GREATER;          break;
    1124                 :          0 :             case SC_LESS_EQUAL:     aField.Operator = sheet::FilterOperator_LESS_EQUAL;   break;
    1125                 :          0 :             case SC_GREATER_EQUAL:  aField.Operator = sheet::FilterOperator_GREATER_EQUAL;  break;
    1126                 :          0 :             case SC_NOT_EQUAL:      aField.Operator = sheet::FilterOperator_NOT_EQUAL;    break;
    1127                 :          0 :             case SC_TOPVAL:         aField.Operator = sheet::FilterOperator_TOP_VALUES;   break;
    1128                 :          0 :             case SC_BOTVAL:         aField.Operator = sheet::FilterOperator_BOTTOM_VALUES;  break;
    1129                 :          0 :             case SC_TOPPERC:        aField.Operator = sheet::FilterOperator_TOP_PERCENT;      break;
    1130                 :          0 :             case SC_BOTPERC:        aField.Operator = sheet::FilterOperator_BOTTOM_PERCENT; break;
    1131                 :            :             default:
    1132                 :            :                 OSL_FAIL("Falscher Filter-enum");
    1133                 :          0 :                 aField.Operator = sheet::FilterOperator_EMPTY;
    1134                 :            :         }
    1135                 :          5 :         pAry[i] = aField;
    1136                 :            :     }
    1137 [ +  - ][ +  - ]:          4 :     return aSeq;
    1138                 :            : }
    1139                 :            : 
    1140                 :            : namespace {
    1141                 :            : 
    1142                 :            : template<typename T>
    1143                 :          4 : void convertQueryEntryToUno(const ScQueryEntry& rEntry, T& rField)
    1144                 :            : {
    1145                 :          4 :     rField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND : sheet::FilterConnection_OR;
    1146                 :          4 :     rField.Field = rEntry.nField;
    1147                 :            : 
    1148   [ #  #  #  #  :          4 :     switch (rEntry.eOp)             // ScQueryOp
          #  #  #  #  #  
          #  #  #  #  #  
           #  #  # ][ -  
          +  -  -  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
    1149                 :            :     {
    1150                 :          0 :     case SC_EQUAL:                  rField.Operator = sheet::FilterOperator2::EQUAL;                break;
    1151                 :          2 :     case SC_LESS:                   rField.Operator = sheet::FilterOperator2::LESS;                 break;
    1152                 :          0 :     case SC_GREATER:                rField.Operator = sheet::FilterOperator2::GREATER;              break;
    1153                 :          0 :     case SC_LESS_EQUAL:             rField.Operator = sheet::FilterOperator2::LESS_EQUAL;           break;
    1154                 :          2 :     case SC_GREATER_EQUAL:          rField.Operator = sheet::FilterOperator2::GREATER_EQUAL;        break;
    1155                 :          0 :     case SC_NOT_EQUAL:              rField.Operator = sheet::FilterOperator2::NOT_EQUAL;            break;
    1156                 :          0 :     case SC_TOPVAL:                 rField.Operator = sheet::FilterOperator2::TOP_VALUES;           break;
    1157                 :          0 :     case SC_BOTVAL:                 rField.Operator = sheet::FilterOperator2::BOTTOM_VALUES;        break;
    1158                 :          0 :     case SC_TOPPERC:                rField.Operator = sheet::FilterOperator2::TOP_PERCENT;          break;
    1159                 :          0 :     case SC_BOTPERC:                rField.Operator = sheet::FilterOperator2::BOTTOM_PERCENT;       break;
    1160                 :          0 :     case SC_CONTAINS:               rField.Operator = sheet::FilterOperator2::CONTAINS;             break;
    1161                 :          0 :     case SC_DOES_NOT_CONTAIN:       rField.Operator = sheet::FilterOperator2::DOES_NOT_CONTAIN;     break;
    1162                 :          0 :     case SC_BEGINS_WITH:            rField.Operator = sheet::FilterOperator2::BEGINS_WITH;          break;
    1163                 :          0 :     case SC_DOES_NOT_BEGIN_WITH:    rField.Operator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH;  break;
    1164                 :          0 :     case SC_ENDS_WITH:              rField.Operator = sheet::FilterOperator2::ENDS_WITH;            break;
    1165                 :          0 :     case SC_DOES_NOT_END_WITH:      rField.Operator = sheet::FilterOperator2::DOES_NOT_END_WITH;    break;
    1166                 :            :     default:
    1167                 :            :         OSL_FAIL("Unknown filter operator value.");
    1168                 :          0 :         rField.Operator = sheet::FilterOperator2::EMPTY;
    1169                 :            :     }
    1170                 :          4 : }
    1171                 :            : 
    1172                 :            : template<typename T>
    1173                 :          7 : void convertUnoToQueryEntry(const T& rField, ScQueryEntry& rEntry)
    1174                 :            : {
    1175                 :          7 :     rEntry.bDoQuery = true;
    1176                 :          7 :     rEntry.eConnect = (rField.Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
    1177                 :          7 :     rEntry.nField   = rField.Field;
    1178                 :            : 
    1179   [ +  -  -  -  :          7 :     switch (rField.Operator)           // FilterOperator
          -  -  -  -  -  
          -  -  -  -  -  
             -  -  -  -  
           - ][ -  +  -  
          -  +  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
    1180                 :            :     {
    1181                 :          3 :     case sheet::FilterOperator2::EQUAL:                 rEntry.eOp = SC_EQUAL;              break;
    1182                 :          2 :     case sheet::FilterOperator2::LESS:                  rEntry.eOp = SC_LESS;               break;
    1183                 :          0 :     case sheet::FilterOperator2::GREATER:               rEntry.eOp = SC_GREATER;            break;
    1184                 :          0 :     case sheet::FilterOperator2::LESS_EQUAL:            rEntry.eOp = SC_LESS_EQUAL;         break;
    1185                 :          2 :     case sheet::FilterOperator2::GREATER_EQUAL:         rEntry.eOp = SC_GREATER_EQUAL;      break;
    1186                 :          0 :     case sheet::FilterOperator2::NOT_EQUAL:             rEntry.eOp = SC_NOT_EQUAL;          break;
    1187                 :          0 :     case sheet::FilterOperator2::TOP_VALUES:            rEntry.eOp = SC_TOPVAL;             break;
    1188                 :          0 :     case sheet::FilterOperator2::BOTTOM_VALUES:         rEntry.eOp = SC_BOTVAL;             break;
    1189                 :          0 :     case sheet::FilterOperator2::TOP_PERCENT:           rEntry.eOp = SC_TOPPERC;            break;
    1190                 :          0 :     case sheet::FilterOperator2::BOTTOM_PERCENT:        rEntry.eOp = SC_BOTPERC;            break;
    1191                 :          0 :     case sheet::FilterOperator2::CONTAINS:              rEntry.eOp = SC_CONTAINS;           break;
    1192                 :          0 :     case sheet::FilterOperator2::DOES_NOT_CONTAIN:      rEntry.eOp = SC_DOES_NOT_CONTAIN;   break;
    1193                 :          0 :     case sheet::FilterOperator2::BEGINS_WITH:           rEntry.eOp = SC_BEGINS_WITH;        break;
    1194                 :          0 :     case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH:   rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break;
    1195                 :          0 :     case sheet::FilterOperator2::ENDS_WITH:             rEntry.eOp = SC_ENDS_WITH;          break;
    1196                 :          0 :     case sheet::FilterOperator2::DOES_NOT_END_WITH:     rEntry.eOp = SC_DOES_NOT_END_WITH;  break;
    1197                 :            :     case sheet::FilterOperator2::EMPTY:
    1198                 :          0 :         rEntry.SetQueryByEmpty();
    1199                 :          0 :         break;
    1200                 :            :     case sheet::FilterOperator2::NOT_EMPTY:
    1201                 :          0 :         rEntry.SetQueryByNonEmpty();
    1202                 :          0 :         break;
    1203                 :            :     default:
    1204                 :            :         OSL_FAIL("Unknown filter operator type.");
    1205                 :          0 :         rEntry.eOp = SC_EQUAL;
    1206                 :            :     }
    1207                 :          7 : }
    1208                 :            : 
    1209                 :          2 : void fillQueryParam(
    1210                 :            :     ScQueryParam& rParam, ScDocument* pDoc,
    1211                 :            :     const uno::Sequence<sheet::TableFilterField2>& aFilterFields)
    1212                 :            : {
    1213                 :          2 :     size_t nCount = static_cast<size_t>(aFilterFields.getLength());
    1214                 :          2 :     rParam.Resize(nCount);
    1215                 :            : 
    1216                 :          2 :     const sheet::TableFilterField2* pAry = aFilterFields.getConstArray();
    1217         [ +  + ]:          6 :     for (size_t i = 0; i < nCount; ++i)
    1218                 :            :     {
    1219                 :          4 :         ScQueryEntry& rEntry = rParam.GetEntry(i);
    1220                 :          4 :         convertUnoToQueryEntry(pAry[i], rEntry);
    1221                 :            : 
    1222 [ +  - ][ +  - ]:          4 :         if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
    1223                 :            :         {
    1224                 :          4 :             ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
    1225                 :          4 :             rItems.resize(1);
    1226                 :          4 :             ScQueryEntry::Item& rItem = rItems.front();
    1227                 :          4 :             rItem.meType    = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
    1228                 :          4 :             rItem.mfVal     = pAry[i].NumericValue;
    1229                 :          4 :             rItem.maString  = pAry[i].StringValue;
    1230                 :            : 
    1231 [ +  - ][ +  + ]:          4 :             if (rItem.meType == ScQueryEntry::ByValue && pDoc)
    1232                 :          2 :                 pDoc->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, rItem.maString);
    1233                 :            :         }
    1234                 :            :     }
    1235                 :            : 
    1236                 :          2 :     size_t nParamCount = rParam.GetEntryCount();    // Param wird nicht unter 8 resized
    1237         [ +  + ]:         14 :     for (size_t i = nCount; i < nParamCount; ++i)
    1238                 :         12 :         rParam.GetEntry(i).bDoQuery = false;        // ueberzaehlige Felder zuruecksetzen
    1239                 :          2 : }
    1240                 :            : 
    1241                 :          3 : void fillQueryParam(
    1242                 :            :     ScQueryParam& rParam, ScDocument* pDoc,
    1243                 :            :     const uno::Sequence<sheet::TableFilterField3>& aFilterFields)
    1244                 :            : {
    1245                 :          3 :     size_t nCount = static_cast<size_t>(aFilterFields.getLength());
    1246                 :          3 :     rParam.Resize(nCount);
    1247                 :            : 
    1248                 :          3 :     const sheet::TableFilterField3* pAry = aFilterFields.getConstArray();
    1249         [ +  + ]:          6 :     for (size_t i = 0; i < nCount; ++i)
    1250                 :            :     {
    1251                 :          3 :         ScQueryEntry& rEntry = rParam.GetEntry(i);
    1252                 :          3 :         convertUnoToQueryEntry(pAry[i], rEntry);
    1253                 :            : 
    1254 [ +  - ][ +  - ]:          3 :         if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
    1255                 :            :         {
    1256                 :          3 :             ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
    1257                 :          3 :             rItems.clear();
    1258                 :          3 :             const uno::Sequence<sheet::FilterFieldValue>& rVals = pAry[i].Values;
    1259         [ +  + ]:          6 :             for (sal_Int32 j = 0, n = rVals.getLength(); j < n; ++j)
    1260                 :            :             {
    1261                 :          3 :                 ScQueryEntry::Item aItem;
    1262                 :          3 :                 aItem.meType   = rVals[j].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
    1263                 :          3 :                 aItem.mfVal    = rVals[j].NumericValue;
    1264                 :          3 :                 aItem.maString = rVals[j].StringValue;
    1265                 :            : 
    1266 [ #  # ][ -  + ]:          3 :                 if (aItem.meType == ScQueryEntry::ByValue && pDoc)
    1267 [ #  # ][ #  # ]:          0 :                     pDoc->GetFormatTable()->GetInputLineString(aItem.mfVal, 0, aItem.maString);
    1268                 :            : 
    1269         [ +  - ]:          3 :                 rItems.push_back(aItem);
    1270         [ +  - ]:          3 :             }
    1271                 :            :         }
    1272                 :            :     }
    1273                 :            : 
    1274                 :          3 :     size_t nParamCount = rParam.GetEntryCount();    // Param wird nicht unter 8 resized
    1275         [ +  + ]:         24 :     for (size_t i = nCount; i < nParamCount; ++i)
    1276                 :         21 :         rParam.GetEntry(i).bDoQuery = false;        // ueberzaehlige Felder zuruecksetzen
    1277                 :          3 : }
    1278                 :            : 
    1279                 :            : }
    1280                 :            : 
    1281                 :          2 : uno::Sequence<sheet::TableFilterField2> SAL_CALL ScFilterDescriptorBase::getFilterFields2()
    1282                 :            : throw(uno::RuntimeException)
    1283                 :            : {
    1284         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1285         [ +  - ]:          2 :     ScQueryParam aParam;
    1286         [ +  - ]:          2 :     GetData(aParam);
    1287                 :            : 
    1288         [ +  - ]:          2 :     SCSIZE nEntries = aParam.GetEntryCount();   // allozierte Eintraege im Param
    1289                 :          2 :     SCSIZE nCount = 0;                          // aktive
    1290 [ +  - ][ +  + ]:         12 :     while ( nCount < nEntries &&
                 [ +  + ]
    1291         [ +  - ]:          6 :         aParam.GetEntry(nCount).bDoQuery )
    1292                 :          4 :         ++nCount;
    1293                 :            : 
    1294                 :          2 :     sheet::TableFilterField2 aField;
    1295         [ +  - ]:          2 :     uno::Sequence<sheet::TableFilterField2> aSeq(static_cast<sal_Int32>(nCount));
    1296         [ +  - ]:          2 :     sheet::TableFilterField2* pAry = aSeq.getArray();
    1297         [ +  + ]:          6 :     for (SCSIZE i=0; i<nCount; i++)
    1298                 :            :     {
    1299         [ +  - ]:          4 :         const ScQueryEntry& rEntry = aParam.GetEntry(i);
    1300                 :          4 :         convertQueryEntryToUno(rEntry, aField);
    1301                 :            : 
    1302                 :          4 :         bool bByEmpty = false;
    1303         [ -  + ]:          4 :         if (aField.Operator == sheet::FilterOperator2::EQUAL)
    1304                 :            :         {
    1305 [ #  # ][ #  # ]:          0 :             if (rEntry.IsQueryByEmpty())
    1306                 :            :             {
    1307                 :          0 :                 aField.Operator = sheet::FilterOperator2::EMPTY;
    1308                 :          0 :                 aField.NumericValue = 0;
    1309                 :          0 :                 bByEmpty = true;
    1310                 :            :             }
    1311 [ #  # ][ #  # ]:          0 :             else if (rEntry.IsQueryByNonEmpty())
    1312                 :            :             {
    1313                 :          0 :                 aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
    1314                 :          0 :                 aField.NumericValue = 0;
    1315                 :          0 :                 bByEmpty = true;
    1316                 :            :             }
    1317                 :            :         }
    1318                 :            : 
    1319 [ +  - ][ +  - ]:          4 :         if (!bByEmpty && !rEntry.GetQueryItems().empty())
         [ +  - ][ +  - ]
    1320                 :            :         {
    1321 [ +  - ][ +  - ]:          4 :             const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
    1322                 :          4 :             aField.IsNumeric     = rItem.meType != ScQueryEntry::ByString;
    1323                 :          4 :             aField.StringValue   = rItem.maString;
    1324                 :          4 :             aField.NumericValue  = rItem.mfVal;
    1325                 :            :         }
    1326                 :            : 
    1327                 :          4 :         pAry[i] = aField;
    1328                 :            :     }
    1329 [ +  - ][ +  - ]:          2 :     return aSeq;
    1330                 :            : }
    1331                 :            : 
    1332                 :          0 : uno::Sequence<sheet::TableFilterField3> SAL_CALL ScFilterDescriptorBase::getFilterFields3()
    1333                 :            :     throw(uno::RuntimeException)
    1334                 :            : {
    1335         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1336         [ #  # ]:          0 :     ScQueryParam aParam;
    1337         [ #  # ]:          0 :     GetData(aParam);
    1338                 :            : 
    1339         [ #  # ]:          0 :     SCSIZE nEntries = aParam.GetEntryCount();   // allozierte Eintraege im Param
    1340                 :          0 :     SCSIZE nCount = 0;                          // aktive
    1341 [ #  # ][ #  # ]:          0 :     while ( nCount < nEntries &&
                 [ #  # ]
    1342         [ #  # ]:          0 :         aParam.GetEntry(nCount).bDoQuery )
    1343                 :          0 :         ++nCount;
    1344                 :            : 
    1345         [ #  # ]:          0 :     sheet::TableFilterField3 aField;
    1346         [ #  # ]:          0 :     uno::Sequence<sheet::TableFilterField3> aSeq(static_cast<sal_Int32>(nCount));
    1347         [ #  # ]:          0 :     sheet::TableFilterField3* pAry = aSeq.getArray();
    1348         [ #  # ]:          0 :     for (SCSIZE i = 0; i < nCount; ++i)
    1349                 :            :     {
    1350         [ #  # ]:          0 :         const ScQueryEntry& rEntry = aParam.GetEntry(i);
    1351                 :          0 :         convertQueryEntryToUno(rEntry, aField);
    1352                 :            : 
    1353                 :          0 :         bool bByEmpty = false;
    1354         [ #  # ]:          0 :         if (aField.Operator == sheet::FilterOperator2::EQUAL)
    1355                 :            :         {
    1356 [ #  # ][ #  # ]:          0 :             if (rEntry.IsQueryByEmpty())
    1357                 :            :             {
    1358                 :          0 :                 aField.Operator = sheet::FilterOperator2::EMPTY;
    1359         [ #  # ]:          0 :                 aField.Values.realloc(1);
    1360         [ #  # ]:          0 :                 aField.Values[0].NumericValue = 0;
    1361                 :          0 :                 bByEmpty = true;
    1362                 :            :             }
    1363 [ #  # ][ #  # ]:          0 :             else if (rEntry.IsQueryByNonEmpty())
    1364                 :            :             {
    1365                 :          0 :                 aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
    1366         [ #  # ]:          0 :                 aField.Values.realloc(1);
    1367         [ #  # ]:          0 :                 aField.Values[0].NumericValue = 0;
    1368                 :          0 :                 bByEmpty = true;
    1369                 :            :             }
    1370                 :            :         }
    1371                 :            : 
    1372         [ #  # ]:          0 :         if (!bByEmpty)
    1373                 :            :         {
    1374         [ #  # ]:          0 :             const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
    1375                 :          0 :             size_t nItemCount = rItems.size();
    1376         [ #  # ]:          0 :             aField.Values.realloc(nItemCount);
    1377                 :          0 :             ScQueryEntry::QueryItemsType::const_iterator itr = rItems.begin(), itrEnd = rItems.end();
    1378 [ #  # ][ #  # ]:          0 :             for (size_t j = 0; itr != itrEnd; ++itr, ++j)
                 [ #  # ]
    1379                 :            :             {
    1380 [ #  # ][ #  # ]:          0 :                 aField.Values[j].IsNumeric = itr->meType != ScQueryEntry::ByString;
    1381 [ #  # ][ #  # ]:          0 :                 aField.Values[j].StringValue = itr->maString;
    1382 [ #  # ][ #  # ]:          0 :                 aField.Values[j].NumericValue = itr->mfVal;
    1383                 :            : 
    1384                 :            :             }
    1385                 :            :         }
    1386                 :            : 
    1387         [ #  # ]:          0 :         pAry[i] = aField;
    1388                 :            :     }
    1389 [ #  # ][ #  # ]:          0 :     return aSeq;
                 [ #  # ]
    1390                 :            : }
    1391                 :            : 
    1392                 :          4 : void SAL_CALL ScFilterDescriptorBase::setFilterFields(
    1393                 :            :                 const uno::Sequence<sheet::TableFilterField>& aFilterFields )
    1394                 :            :                                                 throw(uno::RuntimeException)
    1395                 :            : {
    1396         [ +  - ]:          4 :     SolarMutexGuard aGuard;
    1397         [ +  - ]:          4 :     ScQueryParam aParam;
    1398         [ +  - ]:          4 :     GetData(aParam);
    1399                 :            : 
    1400                 :          4 :     SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
    1401         [ +  - ]:          4 :     aParam.Resize( nCount );
    1402                 :            : 
    1403                 :          4 :     const sheet::TableFilterField* pAry = aFilterFields.getConstArray();
    1404                 :            :     SCSIZE i;
    1405         [ +  + ]:         11 :     for (i=0; i<nCount; i++)
    1406                 :            :     {
    1407         [ +  - ]:          7 :         ScQueryEntry& rEntry = aParam.GetEntry(i);
    1408         [ +  - ]:          7 :         ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
    1409         [ +  - ]:          7 :         rItems.resize(1);
    1410         [ +  - ]:          7 :         ScQueryEntry::Item& rItem = rItems.front();
    1411                 :          7 :         rEntry.bDoQuery = true;
    1412                 :          7 :         rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
    1413                 :          7 :         rEntry.nField   = pAry[i].Field;
    1414                 :          7 :         rItem.meType    = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
    1415                 :          7 :         rItem.mfVal     = pAry[i].NumericValue;
    1416                 :          7 :         rItem.maString  = pAry[i].StringValue;
    1417                 :            : 
    1418 [ +  - ][ +  + ]:          7 :         if (rItem.meType != ScQueryEntry::ByString && pDocSh)
    1419 [ +  - ][ +  - ]:          4 :             pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, rItem.maString);
    1420                 :            : 
    1421   [ -  +  +  +  :          7 :         switch (pAry[i].Operator)           // FilterOperator
          +  -  -  -  -  
             -  +  -  - ]
    1422                 :            :         {
    1423                 :          0 :             case sheet::FilterOperator_EQUAL:           rEntry.eOp = SC_EQUAL;       break;
    1424                 :          2 :             case sheet::FilterOperator_LESS:            rEntry.eOp = SC_LESS;            break;
    1425                 :          1 :             case sheet::FilterOperator_GREATER:         rEntry.eOp = SC_GREATER;         break;
    1426                 :          1 :             case sheet::FilterOperator_LESS_EQUAL:      rEntry.eOp = SC_LESS_EQUAL;  break;
    1427                 :          2 :             case sheet::FilterOperator_GREATER_EQUAL:   rEntry.eOp = SC_GREATER_EQUAL; break;
    1428                 :          0 :             case sheet::FilterOperator_NOT_EQUAL:       rEntry.eOp = SC_NOT_EQUAL;   break;
    1429                 :          0 :             case sheet::FilterOperator_TOP_VALUES:      rEntry.eOp = SC_TOPVAL;      break;
    1430                 :          0 :             case sheet::FilterOperator_BOTTOM_VALUES:   rEntry.eOp = SC_BOTVAL;      break;
    1431                 :          0 :             case sheet::FilterOperator_TOP_PERCENT:     rEntry.eOp = SC_TOPPERC;         break;
    1432                 :          0 :             case sheet::FilterOperator_BOTTOM_PERCENT:  rEntry.eOp = SC_BOTPERC;         break;
    1433                 :            :             case sheet::FilterOperator_EMPTY:
    1434         [ +  - ]:          1 :                 rEntry.SetQueryByEmpty();
    1435                 :          1 :                 break;
    1436                 :            :             case sheet::FilterOperator_NOT_EMPTY:
    1437         [ #  # ]:          0 :                 rEntry.SetQueryByNonEmpty();
    1438                 :          0 :                 break;
    1439                 :            :             default:
    1440                 :            :                 OSL_FAIL("Falscher Query-enum");
    1441                 :          0 :                 rEntry.eOp = SC_EQUAL;
    1442                 :            :         }
    1443                 :            :     }
    1444                 :            : 
    1445         [ +  - ]:          4 :     SCSIZE nParamCount = aParam.GetEntryCount();    // Param wird nicht unter 8 resized
    1446         [ +  + ]:         29 :     for (i=nCount; i<nParamCount; i++)
    1447         [ +  - ]:         25 :         aParam.GetEntry(i).bDoQuery = false;        // ueberzaehlige Felder zuruecksetzen
    1448                 :            : 
    1449 [ +  - ][ +  - ]:          4 :     PutData(aParam);
                 [ +  - ]
    1450                 :          4 : }
    1451                 :            : 
    1452                 :          2 : void SAL_CALL ScFilterDescriptorBase::setFilterFields2(
    1453                 :            :     const uno::Sequence<sheet::TableFilterField2>& aFilterFields )
    1454                 :            :     throw(uno::RuntimeException)
    1455                 :            : {
    1456         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1457         [ +  - ]:          2 :     ScQueryParam aParam;
    1458         [ +  - ]:          2 :     GetData(aParam);
    1459         [ +  - ]:          2 :     fillQueryParam(aParam, pDocSh->GetDocument(), aFilterFields);
    1460 [ +  - ][ +  - ]:          2 :     PutData(aParam);
                 [ +  - ]
    1461                 :          2 : }
    1462                 :            : 
    1463                 :          3 : void SAL_CALL ScFilterDescriptorBase::setFilterFields3(
    1464                 :            :     const uno::Sequence<sheet::TableFilterField3>& aFilterFields )
    1465                 :            :     throw(uno::RuntimeException)
    1466                 :            : {
    1467         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    1468         [ +  - ]:          3 :     ScQueryParam aParam;
    1469         [ +  - ]:          3 :     GetData(aParam);
    1470         [ +  - ]:          3 :     fillQueryParam(aParam, pDocSh->GetDocument(), aFilterFields);
    1471 [ +  - ][ +  - ]:          3 :     PutData(aParam);
                 [ +  - ]
    1472                 :          3 : }
    1473                 :            : 
    1474                 :            : // Rest sind Properties
    1475                 :            : 
    1476                 :            : // XPropertySet
    1477                 :            : 
    1478                 :         24 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFilterDescriptorBase::getPropertySetInfo()
    1479                 :            :                                                         throw(uno::RuntimeException)
    1480                 :            : {
    1481         [ +  - ]:         24 :     SolarMutexGuard aGuard;
    1482                 :            :     static uno::Reference<beans::XPropertySetInfo> aRef(
    1483 [ +  + ][ +  - ]:         24 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
    1484         [ +  - ]:         24 :     return aRef;
    1485                 :            : }
    1486                 :            : 
    1487                 :         61 : void SAL_CALL ScFilterDescriptorBase::setPropertyValue(
    1488                 :            :                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
    1489                 :            :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
    1490                 :            :                         lang::IllegalArgumentException, lang::WrappedTargetException,
    1491                 :            :                         uno::RuntimeException)
    1492                 :            : {
    1493         [ +  - ]:         61 :     SolarMutexGuard aGuard;
    1494         [ +  - ]:         61 :     ScQueryParam aParam;
    1495         [ +  - ]:         61 :     GetData(aParam);
    1496                 :            : 
    1497         [ +  - ]:         61 :     String aString(aPropertyName);
    1498 [ +  - ][ +  + ]:         61 :     if (aString.EqualsAscii( SC_UNONAME_CONTHDR ))
    1499         [ +  - ]:          8 :         aParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    1500 [ +  - ][ +  + ]:         53 :     else if (aString.EqualsAscii( SC_UNONAME_COPYOUT ))
    1501         [ +  - ]:          8 :         aParam.bInplace = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
    1502 [ +  - ][ +  + ]:         45 :     else if (aString.EqualsAscii( SC_UNONAME_ISCASE ))
    1503         [ +  - ]:          8 :         aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    1504 [ +  - ][ +  + ]:         37 :     else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
    1505                 :            :     {
    1506                 :            :         // silently ignored
    1507                 :            :     }
    1508 [ +  - ][ +  + ]:         34 :     else if (aString.EqualsAscii( SC_UNONAME_ORIENT ))
    1509                 :            :     {
    1510                 :            :         //! test for correct enum type?
    1511                 :            :         table::TableOrientation eOrient = (table::TableOrientation)
    1512         [ +  - ]:          8 :                                 ScUnoHelpFunctions::GetEnumFromAny( aValue );
    1513                 :          8 :         aParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
    1514                 :            :     }
    1515 [ +  - ][ +  + ]:         26 :     else if (aString.EqualsAscii( SC_UNONAME_OUTPOS ))
    1516                 :            :     {
    1517                 :          5 :         table::CellAddress aAddress;
    1518 [ +  - ][ +  - ]:          5 :         if ( aValue >>= aAddress )
    1519                 :            :         {
    1520                 :          5 :             aParam.nDestTab = aAddress.Sheet;
    1521                 :          5 :             aParam.nDestCol = (SCCOL)aAddress.Column;
    1522                 :          5 :             aParam.nDestRow = (SCROW)aAddress.Row;
    1523                 :            :         }
    1524                 :            :     }
    1525 [ +  - ][ +  + ]:         21 :     else if (aString.EqualsAscii( SC_UNONAME_SAVEOUT ))
    1526         [ +  - ]:          5 :         aParam.bDestPers = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    1527 [ +  - ][ +  + ]:         16 :     else if (aString.EqualsAscii( SC_UNONAME_SKIPDUP ))
    1528         [ +  - ]:          8 :         aParam.bDuplicate = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
    1529 [ +  - ][ +  - ]:          8 :     else if (aString.EqualsAscii( SC_UNONAME_USEREGEX ))
    1530         [ +  - ]:          8 :         aParam.bRegExp = ScUnoHelpFunctions::GetBoolFromAny( aValue );
    1531                 :            : 
    1532 [ +  - ][ +  - ]:         61 :     PutData(aParam);
         [ +  - ][ +  - ]
    1533                 :         61 : }
    1534                 :            : 
    1535                 :         79 : uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const rtl::OUString& aPropertyName )
    1536                 :            :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    1537                 :            :                         uno::RuntimeException)
    1538                 :            : {
    1539         [ +  - ]:         79 :     SolarMutexGuard aGuard;
    1540         [ +  - ]:         79 :     ScQueryParam aParam;
    1541         [ +  - ]:         79 :     GetData(aParam);
    1542                 :            : 
    1543         [ +  - ]:         79 :     String aString(aPropertyName);
    1544                 :         79 :     uno::Any aRet;
    1545                 :            : 
    1546 [ +  + ][ +  - ]:         79 :     if (aString.EqualsAscii( SC_UNONAME_CONTHDR ))
    1547         [ +  - ]:          9 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bHasHeader );
    1548 [ +  - ][ +  + ]:         70 :     else if (aString.EqualsAscii( SC_UNONAME_COPYOUT ))
    1549         [ +  - ]:          9 :         ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bInplace) );
    1550 [ +  - ][ +  + ]:         61 :     else if (aString.EqualsAscii( SC_UNONAME_ISCASE ))
    1551         [ +  - ]:          9 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bCaseSens );
    1552 [ +  - ][ +  + ]:         52 :     else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
    1553 [ +  - ][ +  - ]:          7 :         aRet <<= (sal_Int32) aParam.GetEntryCount();
    1554 [ +  - ][ +  + ]:         45 :     else if (aString.EqualsAscii( SC_UNONAME_ORIENT ))
    1555                 :            :     {
    1556                 :            :         table::TableOrientation eOrient = aParam.bByRow ? table::TableOrientation_ROWS :
    1557         [ +  + ]:          9 :                                                           table::TableOrientation_COLUMNS;
    1558         [ +  - ]:          9 :         aRet <<= eOrient;
    1559                 :            :     }
    1560 [ +  - ][ +  + ]:         36 :     else if (aString.EqualsAscii( SC_UNONAME_OUTPOS ))
    1561                 :            :     {
    1562                 :          9 :         table::CellAddress aOutPos;
    1563                 :          9 :         aOutPos.Sheet  = aParam.nDestTab;
    1564                 :          9 :         aOutPos.Column = aParam.nDestCol;
    1565                 :          9 :         aOutPos.Row    = aParam.nDestRow;
    1566         [ +  - ]:          9 :         aRet <<= aOutPos;
    1567                 :            :     }
    1568 [ +  - ][ +  + ]:         27 :     else if (aString.EqualsAscii( SC_UNONAME_SAVEOUT ))
    1569         [ +  - ]:          9 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bDestPers );
    1570 [ +  - ][ +  + ]:         18 :     else if (aString.EqualsAscii( SC_UNONAME_SKIPDUP ))
    1571         [ +  - ]:          9 :         ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bDuplicate) );
    1572 [ +  - ][ +  - ]:          9 :     else if (aString.EqualsAscii( SC_UNONAME_USEREGEX ))
    1573         [ +  - ]:          9 :         ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bRegExp );
    1574                 :            : 
    1575 [ +  - ][ +  - ]:         79 :     return aRet;
                 [ +  - ]
    1576                 :            : }
    1577                 :            : 
    1578                 :          0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFilterDescriptorBase )
    1579                 :            : 
    1580                 :            : //------------------------------------------------------------------------
    1581                 :            : 
    1582                 :          7 : ScFilterDescriptor::ScFilterDescriptor(ScDocShell* pDocShell)
    1583                 :            :     :
    1584         [ +  - ]:          7 :     ScFilterDescriptorBase(pDocShell)
    1585                 :            : {
    1586                 :          7 : }
    1587                 :            : 
    1588         [ +  - ]:          7 : ScFilterDescriptor::~ScFilterDescriptor()
    1589                 :            : {
    1590         [ -  + ]:         12 : }
    1591                 :            : 
    1592                 :        130 : void ScFilterDescriptor::GetData( ScQueryParam& rParam ) const
    1593                 :            : {
    1594                 :        130 :     rParam = aStoredParam;          // Abfrage fuer Interface
    1595                 :        130 : }
    1596                 :            : 
    1597                 :         48 : void ScFilterDescriptor::PutData( const ScQueryParam& rParam )
    1598                 :            : {
    1599                 :         48 :     aStoredParam = rParam;          // vom Interface gesetzt
    1600                 :         48 : }
    1601                 :            : 
    1602                 :          2 : void ScFilterDescriptor::SetParam( const ScQueryParam& rNew )
    1603                 :            : {
    1604                 :          2 :     aStoredParam = rNew;            // von aussen gesetzt
    1605                 :          2 : }
    1606                 :            : 
    1607                 :            : //------------------------------------------------------------------------
    1608                 :            : 
    1609                 :          5 : ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell* pDocShell, ScDatabaseRangeObj* pPar) :
    1610                 :            :     ScFilterDescriptorBase(pDocShell),
    1611                 :          5 :     pParent(pPar)
    1612                 :            : {
    1613         [ +  - ]:          5 :     if (pParent)
    1614                 :          5 :         pParent->acquire();
    1615                 :          5 : }
    1616                 :            : 
    1617                 :          5 : ScRangeFilterDescriptor::~ScRangeFilterDescriptor()
    1618                 :            : {
    1619         [ +  - ]:          5 :     if (pParent)
    1620                 :          5 :         pParent->release();
    1621         [ -  + ]:         10 : }
    1622                 :            : 
    1623                 :         24 : void ScRangeFilterDescriptor::GetData( ScQueryParam& rParam ) const
    1624                 :            : {
    1625         [ +  - ]:         24 :     if (pParent)
    1626                 :         24 :         pParent->GetQueryParam( rParam );
    1627                 :         24 : }
    1628                 :            : 
    1629                 :         21 : void ScRangeFilterDescriptor::PutData( const ScQueryParam& rParam )
    1630                 :            : {
    1631         [ +  - ]:         21 :     if (pParent)
    1632                 :         21 :         pParent->SetQueryParam( rParam );
    1633                 :         21 : }
    1634                 :            : 
    1635                 :            : //------------------------------------------------------------------------
    1636                 :            : 
    1637                 :          5 : ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell* pDocShell, ScDataPilotDescriptorBase* pPar) :
    1638                 :            :     ScFilterDescriptorBase(pDocShell),
    1639                 :          5 :     pParent(pPar)
    1640                 :            : {
    1641         [ +  - ]:          5 :     if (pParent)
    1642                 :          5 :         pParent->acquire();
    1643                 :          5 : }
    1644                 :            : 
    1645                 :          5 : ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor()
    1646                 :            : {
    1647         [ +  - ]:          5 :     if (pParent)
    1648                 :          5 :         pParent->release();
    1649         [ -  + ]:         10 : }
    1650                 :            : 
    1651                 :          1 : void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
    1652                 :            : {
    1653         [ +  - ]:          1 :     if (pParent)
    1654                 :            :     {
    1655                 :          1 :         ScDPObject* pDPObj = pParent->GetDPObject();
    1656 [ +  - ][ +  - ]:          1 :         if (pDPObj && pDPObj->IsSheetData())
                 [ +  - ]
    1657                 :          1 :             rParam = pDPObj->GetSheetDesc()->GetQueryParam();
    1658                 :            :     }
    1659                 :          1 : }
    1660                 :            : 
    1661                 :          1 : void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam )
    1662                 :            : {
    1663         [ +  - ]:          1 :     if (pParent)
    1664                 :            :     {
    1665                 :          1 :         ScDPObject* pDPObj = pParent->GetDPObject();
    1666         [ +  - ]:          1 :         if (pDPObj)
    1667                 :            :         {
    1668         [ +  - ]:          1 :             ScSheetSourceDesc aSheetDesc(pParent->GetDocShell()->GetDocument());
    1669 [ +  - ][ +  - ]:          1 :             if (pDPObj->IsSheetData())
    1670         [ +  - ]:          1 :                 aSheetDesc = *pDPObj->GetSheetDesc();
    1671         [ +  - ]:          1 :             aSheetDesc.SetQueryParam(rParam);
    1672         [ +  - ]:          1 :             pDPObj->SetSheetDesc(aSheetDesc);
    1673 [ +  - ][ +  - ]:          1 :             pParent->SetDPObject(pDPObj);
    1674                 :            :         }
    1675                 :            :     }
    1676                 :          1 : }
    1677                 :            : 
    1678                 :            : //------------------------------------------------------------------------
    1679                 :            : 
    1680                 :         19 : ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell* pDocSh, const String& rNm) :
    1681                 :            :     pDocShell( pDocSh ),
    1682                 :            :     aName( rNm ),
    1683                 :            :     aPropSet( lcl_GetDBRangePropertyMap() ),
    1684 [ +  - ][ +  - ]:         19 :     bIsUnnamed(false)
         [ +  - ][ +  - ]
                 [ +  - ]
    1685                 :            : {
    1686         [ +  - ]:         19 :     pDocShell->GetDocument()->AddUnoObject(*this);
    1687                 :         19 : }
    1688                 :            : 
    1689                 :          3 : ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell* pDocSh, const SCTAB nTab) :
    1690                 :            :     pDocShell( pDocSh ),
    1691                 :            :     aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)),
    1692                 :            :     aPropSet( lcl_GetDBRangePropertyMap() ),
    1693                 :            :     bIsUnnamed(true),
    1694 [ +  - ][ +  - ]:          3 :     aTab( nTab )
         [ +  - ][ +  - ]
                 [ +  - ]
    1695                 :            : {
    1696         [ +  - ]:          3 :     pDocShell->GetDocument()->AddUnoObject(*this);
    1697                 :          3 : }
    1698                 :            : 
    1699 [ +  - ][ +  - ]:         22 : ScDatabaseRangeObj::~ScDatabaseRangeObj()
         [ +  - ][ +  - ]
    1700                 :            : {
    1701         [ +  + ]:         22 :     if (pDocShell)
    1702         [ +  - ]:         15 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    1703         [ -  + ]:         44 : }
    1704                 :            : 
    1705                 :        115 : void ScDatabaseRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1706                 :            : {
    1707                 :            : 
    1708 [ +  - ][ +  + ]:        115 :     if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
                 [ +  + ]
    1709                 :          7 :         pDocShell = NULL;       // ungueltig geworden
    1710         [ -  + ]:        108 :     else if ( rHint.ISA (ScDBRangeRefreshedHint) )
    1711                 :            :     {
    1712         [ #  # ]:          0 :         ScDBData* pDBData = GetDBData_Impl();
    1713                 :          0 :         const ScDBRangeRefreshedHint& rRef = (const ScDBRangeRefreshedHint&)rHint;
    1714         [ #  # ]:          0 :         ScImportParam aParam;
    1715         [ #  # ]:          0 :         pDBData->GetImportParam(aParam);
    1716 [ #  # ][ #  # ]:          0 :         if (aParam == rRef.GetImportParam())
    1717 [ #  # ][ #  # ]:          0 :             Refreshed_Impl();
    1718                 :            :     }
    1719                 :        115 : }
    1720                 :            : 
    1721                 :            : // Hilfsfuntionen
    1722                 :            : 
    1723                 :        168 : ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const
    1724                 :            : {
    1725                 :        168 :     ScDBData* pRet = NULL;
    1726         [ +  - ]:        168 :     if (pDocShell)
    1727                 :            :     {
    1728         [ +  + ]:        168 :         if (bIsUnnamed)
    1729                 :            :         {
    1730                 :         48 :             pRet = pDocShell->GetDocument()->GetAnonymousDBData(aTab);
    1731                 :            :         }
    1732                 :            :         else
    1733                 :            :         {
    1734                 :        120 :             ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
    1735         [ +  - ]:        120 :             if (pNames)
    1736                 :            :             {
    1737 [ +  - ][ +  - ]:        120 :                 ScDBData* p = pNames->getNamedDBs().findByName(aName);
    1738         [ +  - ]:        120 :                 if (p)
    1739                 :        120 :                     pRet = p;
    1740                 :            :             }
    1741                 :            :         }
    1742                 :            :     }
    1743                 :        168 :     return pRet;
    1744                 :            : }
    1745                 :            : 
    1746                 :            : // XNamed
    1747                 :            : 
    1748                 :          3 : rtl::OUString SAL_CALL ScDatabaseRangeObj::getName() throw(uno::RuntimeException)
    1749                 :            : {
    1750         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    1751 [ +  - ][ +  - ]:          3 :     return aName;
    1752                 :            : }
    1753                 :            : 
    1754                 :          2 : void SAL_CALL ScDatabaseRangeObj::setName( const rtl::OUString& aNewName )
    1755                 :            :                                                 throw(uno::RuntimeException)
    1756                 :            : {
    1757         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1758         [ +  - ]:          2 :     if (pDocShell)
    1759                 :            :     {
    1760                 :          2 :         ScDBDocFunc aFunc(*pDocShell);
    1761         [ +  - ]:          2 :         String aNewStr(aNewName);
    1762         [ +  - ]:          2 :         sal_Bool bOk = aFunc.RenameDBRange( aName, aNewStr );
    1763         [ +  - ]:          2 :         if (bOk)
    1764 [ +  - ][ +  - ]:          2 :             aName = aNewStr;
    1765         [ +  - ]:          2 :     }
    1766                 :          2 : }
    1767                 :            : 
    1768                 :            : // XDatabaseRange
    1769                 :            : 
    1770                 :          2 : table::CellRangeAddress SAL_CALL ScDatabaseRangeObj::getDataArea() throw(uno::RuntimeException)
    1771                 :            : {
    1772         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1773                 :          2 :     table::CellRangeAddress aAddress;
    1774         [ +  - ]:          2 :     ScDBData* pData = GetDBData_Impl();
    1775         [ +  - ]:          2 :     if (pData)
    1776                 :            :     {
    1777                 :          2 :         ScRange aRange;
    1778         [ +  - ]:          2 :         pData->GetArea(aRange);
    1779                 :          2 :         aAddress.Sheet       = aRange.aStart.Tab();
    1780                 :          2 :         aAddress.StartColumn = aRange.aStart.Col();
    1781                 :          2 :         aAddress.StartRow    = aRange.aStart.Row();
    1782                 :          2 :         aAddress.EndColumn   = aRange.aEnd.Col();
    1783                 :          2 :         aAddress.EndRow      = aRange.aEnd.Row();
    1784                 :            :     }
    1785         [ +  - ]:          2 :     return aAddress;
    1786                 :            : }
    1787                 :            : 
    1788                 :          2 : void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aDataArea )
    1789                 :            :                                                     throw(uno::RuntimeException)
    1790                 :            : {
    1791         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1792         [ +  - ]:          2 :     ScDBData* pData = GetDBData_Impl();
    1793 [ +  - ][ +  - ]:          2 :     if ( pDocShell && pData )
    1794                 :            :     {
    1795         [ +  - ]:          2 :         ScDBData aNewData( *pData );
    1796                 :            :         //! MoveTo ???
    1797                 :            :         aNewData.SetArea( aDataArea.Sheet, (SCCOL)aDataArea.StartColumn, (SCROW)aDataArea.StartRow,
    1798         [ +  - ]:          2 :                                            (SCCOL)aDataArea.EndColumn, (SCROW)aDataArea.EndRow );
    1799                 :          2 :         ScDBDocFunc aFunc(*pDocShell);
    1800 [ +  - ][ +  - ]:          2 :         aFunc.ModifyDBData(aNewData);
    1801         [ +  - ]:          2 :     }
    1802                 :          2 : }
    1803                 :            : 
    1804                 :          2 : uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getSortDescriptor()
    1805                 :            :                                                     throw(uno::RuntimeException)
    1806                 :            : {
    1807         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1808         [ +  - ]:          2 :     ScSortParam aParam;
    1809         [ +  - ]:          2 :     const ScDBData* pData = GetDBData_Impl();
    1810         [ +  - ]:          2 :     if (pData)
    1811                 :            :     {
    1812         [ +  - ]:          2 :         pData->GetSortParam(aParam);
    1813                 :            : 
    1814                 :            :         //  im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    1815                 :          2 :         ScRange aDBRange;
    1816         [ +  - ]:          2 :         pData->GetArea(aDBRange);
    1817         [ -  + ]:          2 :         SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
    1818         [ +  + ]:          8 :         for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
    1819 [ -  + ][ #  # ]:          6 :             if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
                 [ -  + ]
    1820                 :          0 :                 aParam.maKeyState[i].nField -= nFieldStart;
    1821                 :            :     }
    1822                 :            : 
    1823         [ +  - ]:          2 :     uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
    1824         [ +  - ]:          2 :     ScSortDescriptor::FillProperties( aSeq, aParam );
    1825 [ +  - ][ +  - ]:          2 :     return aSeq;
    1826                 :            : }
    1827                 :            : 
    1828                 :         24 : void ScDatabaseRangeObj::GetQueryParam(ScQueryParam& rQueryParam) const
    1829                 :            : {
    1830                 :         24 :     const ScDBData* pData = GetDBData_Impl();
    1831         [ +  - ]:         24 :     if (pData)
    1832                 :            :     {
    1833         [ +  - ]:         24 :         pData->GetQueryParam(rQueryParam);
    1834                 :            : 
    1835                 :            :         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    1836                 :         24 :         ScRange aDBRange;
    1837         [ +  - ]:         24 :         pData->GetArea(aDBRange);
    1838         [ +  - ]:         24 :         SCCOLROW nFieldStart = rQueryParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
    1839         [ +  - ]:         24 :         SCSIZE nCount = rQueryParam.GetEntryCount();
    1840         [ +  + ]:        216 :         for (SCSIZE i=0; i<nCount; i++)
    1841                 :            :         {
    1842         [ +  - ]:        192 :             ScQueryEntry& rEntry = rQueryParam.GetEntry(i);
    1843 [ +  + ][ +  - ]:        192 :             if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
    1844                 :          3 :                 rEntry.nField -= nFieldStart;
    1845                 :            :         }
    1846                 :            :     }
    1847                 :         24 : }
    1848                 :            : 
    1849                 :         21 : void ScDatabaseRangeObj::SetQueryParam(const ScQueryParam& rQueryParam)
    1850                 :            : {
    1851                 :         21 :     const ScDBData* pData = GetDBData_Impl();
    1852         [ +  - ]:         21 :     if (pData)
    1853                 :            :     {
    1854                 :            :         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    1855         [ +  - ]:         21 :         ScQueryParam aParam(rQueryParam);
    1856                 :         21 :         ScRange aDBRange;
    1857         [ +  - ]:         21 :         pData->GetArea(aDBRange);
    1858         [ +  - ]:         21 :         SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
    1859                 :            : 
    1860         [ +  - ]:         21 :         SCSIZE nCount = aParam.GetEntryCount();
    1861         [ +  + ]:        189 :         for (SCSIZE i=0; i<nCount; i++)
    1862                 :            :         {
    1863         [ +  - ]:        168 :                ScQueryEntry& rEntry = aParam.GetEntry(i);
    1864         [ +  + ]:        168 :                if (rEntry.bDoQuery)
    1865                 :          6 :                        rEntry.nField += nFieldStart;
    1866                 :            :         }
    1867                 :            : 
    1868         [ +  - ]:         21 :         ScDBData aNewData( *pData );
    1869         [ +  - ]:         21 :         aNewData.SetQueryParam(aParam);
    1870                 :         21 :         aNewData.SetHeader(aParam.bHasHeader);      // not in ScDBData::SetQueryParam
    1871                 :         21 :         ScDBDocFunc aFunc(*pDocShell);
    1872 [ +  - ][ +  - ]:         21 :         aFunc.ModifyDBData(aNewData);
                 [ +  - ]
    1873                 :            :     }
    1874                 :         21 : }
    1875                 :            : 
    1876                 :          5 : uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScDatabaseRangeObj::getFilterDescriptor()
    1877                 :            :                                                 throw(uno::RuntimeException)
    1878                 :            : {
    1879         [ +  - ]:          5 :     SolarMutexGuard aGuard;
    1880 [ +  - ][ +  - ]:          5 :     return new ScRangeFilterDescriptor(pDocShell, this);
         [ +  - ][ +  - ]
    1881                 :            : }
    1882                 :            : 
    1883                 :          0 : void ScDatabaseRangeObj::GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const
    1884                 :            : {
    1885                 :          0 :     const ScDBData* pData = GetDBData_Impl();
    1886         [ #  # ]:          0 :     if (pData)
    1887                 :            :     {
    1888         [ #  # ]:          0 :         pData->GetSubTotalParam(rSubTotalParam);
    1889                 :            : 
    1890                 :            :         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    1891                 :          0 :         ScRange aDBRange;
    1892         [ #  # ]:          0 :         pData->GetArea(aDBRange);
    1893                 :          0 :         SCCOL nFieldStart = aDBRange.aStart.Col();
    1894         [ #  # ]:          0 :         for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
    1895                 :            :         {
    1896         [ #  # ]:          0 :             if ( rSubTotalParam.bGroupActive[i] )
    1897                 :            :             {
    1898         [ #  # ]:          0 :                 if ( rSubTotalParam.nField[i] >= nFieldStart )
    1899                 :          0 :                     rSubTotalParam.nField[i] = sal::static_int_cast<SCCOL>( rSubTotalParam.nField[i] - nFieldStart );
    1900         [ #  # ]:          0 :                 for (SCCOL j=0; j<rSubTotalParam.nSubTotals[i]; j++)
    1901         [ #  # ]:          0 :                     if ( rSubTotalParam.pSubTotals[i][j] >= nFieldStart )
    1902                 :          0 :                         rSubTotalParam.pSubTotals[i][j] =
    1903                 :          0 :                             sal::static_int_cast<SCCOL>( rSubTotalParam.pSubTotals[i][j] - nFieldStart );
    1904                 :            :             }
    1905                 :            :         }
    1906                 :            :     }
    1907                 :          0 : }
    1908                 :            : 
    1909                 :          0 : void ScDatabaseRangeObj::SetSubTotalParam(const ScSubTotalParam& rSubTotalParam)
    1910                 :            : {
    1911                 :          0 :     const ScDBData* pData = GetDBData_Impl();
    1912         [ #  # ]:          0 :     if (pData)
    1913                 :            :     {
    1914                 :            :         //  im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
    1915         [ #  # ]:          0 :         ScSubTotalParam aParam(rSubTotalParam);
    1916                 :          0 :         ScRange aDBRange;
    1917         [ #  # ]:          0 :         pData->GetArea(aDBRange);
    1918                 :          0 :         SCCOL nFieldStart = aDBRange.aStart.Col();
    1919         [ #  # ]:          0 :         for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
    1920                 :            :         {
    1921         [ #  # ]:          0 :             if ( aParam.bGroupActive[i] )
    1922                 :            :             {
    1923                 :          0 :                 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
    1924         [ #  # ]:          0 :                 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
    1925                 :          0 :                     aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
    1926                 :            :             }
    1927                 :            :         }
    1928                 :            : 
    1929         [ #  # ]:          0 :         ScDBData aNewData( *pData );
    1930         [ #  # ]:          0 :         aNewData.SetSubTotalParam(aParam);
    1931                 :          0 :         ScDBDocFunc aFunc(*pDocShell);
    1932 [ #  # ][ #  # ]:          0 :         aFunc.ModifyDBData(aNewData);
    1933                 :            :     }
    1934                 :          0 : }
    1935                 :            : 
    1936                 :          2 : uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScDatabaseRangeObj::getSubTotalDescriptor()
    1937                 :            :                                                 throw(uno::RuntimeException)
    1938                 :            : {
    1939         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1940 [ +  - ][ +  - ]:          2 :     return new ScRangeSubTotalDescriptor(this);
         [ +  - ][ +  - ]
    1941                 :            : }
    1942                 :            : 
    1943                 :          2 : uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getImportDescriptor()
    1944                 :            :                                                 throw(uno::RuntimeException)
    1945                 :            : {
    1946         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1947         [ +  - ]:          2 :     ScImportParam aParam;
    1948         [ +  - ]:          2 :     const ScDBData* pData = GetDBData_Impl();
    1949         [ +  - ]:          2 :     if (pData)
    1950         [ +  - ]:          2 :         pData->GetImportParam(aParam);
    1951                 :            : 
    1952         [ +  - ]:          2 :     uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
    1953         [ +  - ]:          2 :     ScImportDescriptor::FillProperties( aSeq, aParam );
    1954 [ +  - ][ +  - ]:          2 :     return aSeq;
    1955                 :            : }
    1956                 :            : 
    1957                 :            : // XRefreshable
    1958                 :            : 
    1959                 :          2 : void SAL_CALL ScDatabaseRangeObj::refresh() throw(uno::RuntimeException)
    1960                 :            : {
    1961         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1962         [ +  - ]:          2 :     ScDBData* pData = GetDBData_Impl();
    1963 [ +  - ][ +  - ]:          2 :     if ( pDocShell && pData )
    1964                 :            :     {
    1965                 :          2 :         ScDBDocFunc aFunc(*pDocShell);
    1966                 :            : 
    1967                 :            :         // Import zu wiederholen?
    1968                 :          2 :         sal_Bool bContinue = sal_True;
    1969         [ +  - ]:          2 :         ScImportParam aImportParam;
    1970         [ +  - ]:          2 :         pData->GetImportParam( aImportParam );
    1971 [ -  + ][ #  # ]:          2 :         if (aImportParam.bImport && !pData->HasImportSelection())
                 [ -  + ]
    1972                 :            :         {
    1973                 :            :             SCTAB nTab;
    1974                 :            :             SCCOL nDummyCol;
    1975                 :            :             SCROW nDummyRow;
    1976         [ #  # ]:          0 :             pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
    1977         [ #  # ]:          0 :             bContinue = aFunc.DoImport( nTab, aImportParam, NULL, true );   //! Api-Flag as parameter
    1978                 :            :         }
    1979                 :            : 
    1980                 :            :         // interne Operationen (sort, query, subtotal) nur, wenn kein Fehler
    1981         [ +  - ]:          2 :         if (bContinue)
    1982 [ +  - ][ +  - ]:          2 :             aFunc.RepeatDB( pData->GetName(), true, true, bIsUnnamed, aTab );
    1983         [ +  - ]:          2 :     }
    1984                 :          2 : }
    1985                 :            : 
    1986                 :          0 : void SAL_CALL ScDatabaseRangeObj::addRefreshListener(
    1987                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
    1988                 :            :                                                 throw(uno::RuntimeException)
    1989                 :            : {
    1990         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1991                 :            :     uno::Reference<util::XRefreshListener>* pObj =
    1992                 :          0 :             new uno::Reference<util::XRefreshListener>( xListener );
    1993         [ #  # ]:          0 :     aRefreshListeners.push_back( pObj );
    1994                 :            : 
    1995                 :            :     //  hold one additional ref to keep this object alive as long as there are listeners
    1996         [ #  # ]:          0 :     if ( aRefreshListeners.size() == 1 )
    1997         [ #  # ]:          0 :         acquire();
    1998                 :          0 : }
    1999                 :            : 
    2000                 :          0 : void SAL_CALL ScDatabaseRangeObj::removeRefreshListener(
    2001                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
    2002                 :            :                                                 throw(uno::RuntimeException)
    2003                 :            : {
    2004         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2005                 :          0 :     sal_uInt16 nCount = aRefreshListeners.size();
    2006         [ #  # ]:          0 :     for ( sal_uInt16 n=nCount; n--; )
    2007                 :            :     {
    2008         [ #  # ]:          0 :         uno::Reference<util::XRefreshListener>& rObj = aRefreshListeners[n];
    2009 [ #  # ][ #  # ]:          0 :         if ( rObj == xListener )
    2010                 :            :         {
    2011 [ #  # ][ #  # ]:          0 :             aRefreshListeners.erase( aRefreshListeners.begin() + n );
                 [ #  # ]
    2012         [ #  # ]:          0 :             if ( aRefreshListeners.empty() )
    2013                 :          0 :                 release();                          // release ref for listeners
    2014                 :          0 :             break;
    2015                 :            :         }
    2016         [ #  # ]:          0 :     }
    2017                 :          0 : }
    2018                 :            : 
    2019                 :          0 : void ScDatabaseRangeObj::Refreshed_Impl()
    2020                 :            : {
    2021         [ #  # ]:          0 :     lang::EventObject aEvent;
    2022         [ #  # ]:          0 :     aEvent.Source = (cppu::OWeakObject*)this;
    2023         [ #  # ]:          0 :     for ( sal_uInt16 n=0; n<aRefreshListeners.size(); n++ )
    2024 [ #  # ][ #  # ]:          0 :         aRefreshListeners[n]->refreshed( aEvent );
         [ #  # ][ #  # ]
    2025                 :          0 : }
    2026                 :            : 
    2027                 :            : // XCellRangeSource
    2028                 :            : 
    2029                 :          5 : uno::Reference<table::XCellRange> SAL_CALL ScDatabaseRangeObj::getReferredCells()
    2030                 :            :                                                 throw(uno::RuntimeException)
    2031                 :            : {
    2032         [ +  - ]:          5 :     SolarMutexGuard aGuard;
    2033                 :          5 :     ScRange aRange;
    2034         [ +  - ]:          5 :     ScDBData* pData = GetDBData_Impl();
    2035         [ +  - ]:          5 :     if ( pData )
    2036                 :            :     {
    2037                 :            :         //! static Funktion um ScCellObj/ScCellRangeObj zu erzeugen am ScCellRangeObj ???
    2038                 :            : 
    2039         [ +  - ]:          5 :         pData->GetArea(aRange);
    2040         [ -  + ]:          5 :         if ( aRange.aStart == aRange.aEnd )
    2041 [ #  # ][ #  # ]:          0 :             return new ScCellObj( pDocShell, aRange.aStart );
                 [ #  # ]
    2042                 :            :         else
    2043 [ +  - ][ +  - ]:          5 :             return new ScCellRangeObj( pDocShell, aRange );
                 [ +  - ]
    2044                 :            :     }
    2045 [ #  # ][ +  - ]:          5 :     return NULL;
    2046                 :            : }
    2047                 :            : 
    2048                 :            : // XPropertySet
    2049                 :            : 
    2050                 :         20 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDatabaseRangeObj::getPropertySetInfo()
    2051                 :            :                                                         throw(uno::RuntimeException)
    2052                 :            : {
    2053         [ +  - ]:         20 :     SolarMutexGuard aGuard;
    2054                 :            :     static uno::Reference<beans::XPropertySetInfo> aRef(
    2055 [ +  + ][ +  - ]:         20 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
    2056         [ +  - ]:         20 :     return aRef;
    2057                 :            : }
    2058                 :            : 
    2059                 :         25 : void SAL_CALL ScDatabaseRangeObj::setPropertyValue(
    2060                 :            :                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
    2061                 :            :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
    2062                 :            :                         lang::IllegalArgumentException, lang::WrappedTargetException,
    2063                 :            :                         uno::RuntimeException)
    2064                 :            : {
    2065         [ +  - ]:         25 :     SolarMutexGuard aGuard;
    2066         [ +  - ]:         25 :     ScDBData* pData = GetDBData_Impl();
    2067 [ +  - ][ +  - ]:         25 :     if ( pDocShell && pData )
    2068                 :            :     {
    2069         [ +  - ]:         25 :         ScDBData aNewData( *pData );
    2070                 :         25 :         sal_Bool bDo = sal_True;
    2071                 :            : 
    2072         [ +  - ]:         25 :         String aString(aPropertyName);
    2073 [ +  - ][ +  + ]:         25 :         if ( aString.EqualsAscii( SC_UNONAME_KEEPFORM ) )
    2074         [ +  - ]:          3 :             aNewData.SetKeepFmt( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
    2075 [ +  - ][ +  + ]:         22 :         else if ( aString.EqualsAscii( SC_UNONAME_MOVCELLS ) )
    2076         [ +  - ]:          3 :             aNewData.SetDoSize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
    2077 [ +  - ][ +  + ]:         19 :         else if ( aString.EqualsAscii( SC_UNONAME_STRIPDAT ) )
    2078         [ +  - ]:          3 :             aNewData.SetStripData( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
    2079 [ +  - ][ +  + ]:         16 :         else if (aString.EqualsAscii( SC_UNONAME_AUTOFLT ))
    2080                 :            :         {
    2081         [ +  - ]:          6 :             sal_Bool bAutoFilter(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
    2082                 :          6 :             aNewData.SetAutoFilter(bAutoFilter);
    2083                 :          6 :             ScRange aRange;
    2084         [ +  - ]:          6 :             aNewData.GetArea(aRange);
    2085                 :          6 :             ScDocument* pDoc = pDocShell->GetDocument();
    2086 [ +  - ][ +  + ]:          6 :             if (bAutoFilter && pDoc)
    2087                 :          5 :                 pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
    2088                 :          5 :                                      aRange.aEnd.Col(), aRange.aStart.Row(),
    2089         [ +  - ]:         15 :                                      aRange.aStart.Tab(), SC_MF_AUTO );
    2090 [ +  - ][ +  - ]:          1 :             else  if (!bAutoFilter && pDoc)
    2091                 :          1 :                 pDoc->RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
    2092                 :          1 :                                      aRange.aEnd.Col(), aRange.aStart.Row(),
    2093         [ +  - ]:          3 :                                      aRange.aStart.Tab(), SC_MF_AUTO );
    2094                 :          6 :             ScRange aPaintRange(aRange.aStart, aRange.aEnd);
    2095                 :          6 :             aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
    2096 [ +  - ][ +  - ]:          6 :             pDocShell->PostPaint(aPaintRange, PAINT_GRID);
                 [ +  - ]
    2097                 :            :         }
    2098 [ +  - ][ +  + ]:         10 :         else if (aString.EqualsAscii( SC_UNONAME_USEFLTCRT ))
    2099                 :            :         {
    2100 [ +  - ][ +  + ]:          3 :             if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
    2101                 :            :             {
    2102                 :          2 :                 ScRange aRange;
    2103         [ +  - ]:          2 :                 aNewData.GetAdvancedQuerySource(aRange);
    2104         [ +  - ]:          2 :                 aNewData.SetAdvancedQuerySource(&aRange);
    2105                 :            :             }
    2106                 :            :             else
    2107         [ +  - ]:          1 :                 aNewData.SetAdvancedQuerySource(NULL);
    2108                 :            :         }
    2109 [ +  - ][ +  + ]:          7 :         else if (aString.EqualsAscii( SC_UNONAME_FLTCRT ))
    2110                 :            :         {
    2111                 :          1 :             table::CellRangeAddress aRange;
    2112 [ -  + ][ +  - ]:          1 :             if (aValue >>= aRange)
    2113                 :            :             {
    2114                 :          0 :                 ScRange aCoreRange;
    2115                 :          0 :                 ScUnoConversion::FillScRange(aCoreRange, aRange);
    2116                 :            : 
    2117         [ #  # ]:          1 :                 aNewData.SetAdvancedQuerySource(&aCoreRange);
    2118                 :            :             }
    2119                 :            :         }
    2120 [ +  - ][ +  + ]:          6 :         else if (aString.EqualsAscii( SC_UNONAME_FROMSELECT ))
    2121                 :            :         {
    2122         [ +  - ]:          3 :             aNewData.SetImportSelection(::cppu::any2bool(aValue));
    2123                 :            :         }
    2124 [ +  - ][ +  - ]:          3 :         else if (aString.EqualsAscii( SC_UNONAME_REFPERIOD ))
    2125                 :            :         {
    2126                 :          3 :             sal_Int32 nRefresh = 0;
    2127         [ +  - ]:          3 :             if (aValue >>= nRefresh)
    2128                 :            :             {
    2129                 :          3 :                 ScDocument* pDoc = pDocShell->GetDocument();
    2130         [ +  - ]:          3 :                 aNewData.SetRefreshDelay(nRefresh);
    2131 [ +  - ][ +  - ]:          3 :                 if (pDoc && pDoc->GetDBCollection())
         [ +  - ][ +  - ]
    2132                 :            :                 {
    2133         [ +  - ]:          3 :                     aNewData.SetRefreshHandler( pDoc->GetDBCollection()->GetRefreshHandler() );
    2134                 :          3 :                     aNewData.SetRefreshControl( pDoc->GetRefreshTimerControlAddress() );
    2135                 :            :                 }
    2136                 :            :             }
    2137                 :            :         }
    2138 [ #  # ][ #  # ]:          0 :         else if (aString.EqualsAscii( SC_UNONAME_CONRES ))
    2139                 :            :         {
    2140                 :            :         }
    2141                 :            :         else
    2142                 :          0 :             bDo = false;
    2143                 :            : 
    2144         [ +  - ]:         25 :         if (bDo)
    2145                 :            :         {
    2146                 :         25 :             ScDBDocFunc aFunc(*pDocShell);
    2147         [ +  - ]:         25 :             aFunc.ModifyDBData(aNewData);
    2148 [ +  - ][ +  - ]:         25 :         }
    2149         [ +  - ]:         25 :     }
    2150                 :         25 : }
    2151                 :            : 
    2152                 :         52 : uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const rtl::OUString& aPropertyName )
    2153                 :            :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
    2154                 :            :                         uno::RuntimeException)
    2155                 :            : {
    2156         [ +  - ]:         52 :     SolarMutexGuard aGuard;
    2157                 :         52 :     uno::Any aRet;
    2158         [ +  - ]:         52 :     ScDBData* pData = GetDBData_Impl();
    2159         [ +  - ]:         52 :     if ( pData )
    2160                 :            :     {
    2161         [ +  - ]:         52 :         String aString(aPropertyName);
    2162 [ +  - ][ +  + ]:         52 :         if ( aString.EqualsAscii( SC_UNONAME_KEEPFORM ) )
    2163         [ +  - ]:          7 :             ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsKeepFmt() );
    2164 [ +  - ][ +  + ]:         45 :         else if ( aString.EqualsAscii( SC_UNONAME_MOVCELLS ) )
    2165         [ +  - ]:          7 :             ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsDoSize() );
    2166 [ +  - ][ +  + ]:         38 :         else if ( aString.EqualsAscii( SC_UNONAME_STRIPDAT ) )
    2167         [ +  - ]:          7 :             ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsStripData() );
    2168 [ +  - ][ -  + ]:         31 :         else if ( aString.EqualsAscii( SC_UNONAME_ISUSER ) )
    2169                 :            :         {
    2170                 :            :             //  all database ranges except "unnamed" are user defined
    2171                 :            :             ScUnoHelpFunctions::SetBoolInAny(
    2172         [ #  # ]:          0 :                 aRet, !pData->GetName().equalsAscii(STR_DB_LOCAL_NONAME));
    2173                 :            :         }
    2174 [ +  - ][ +  - ]:         31 :         else if ( aString.EqualsAscii( SC_UNO_LINKDISPBIT ) )
    2175                 :            :         {
    2176                 :            :             //  no target bitmaps for individual entries (would be all equal)
    2177                 :            :             // ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_DBAREA );
    2178                 :            :         }
    2179 [ +  - ][ -  + ]:         31 :         else if ( aString.EqualsAscii( SC_UNO_LINKDISPNAME ) )
    2180 [ #  # ][ #  # ]:          0 :             aRet <<= rtl::OUString( aName );
    2181 [ +  - ][ +  + ]:         31 :         else if (aString.EqualsAscii( SC_UNONAME_AUTOFLT ))
    2182                 :            :         {
    2183         [ +  - ]:          7 :             sal_Bool bAutoFilter(GetDBData_Impl()->HasAutoFilter());
    2184                 :            : 
    2185         [ +  - ]:          7 :             ScUnoHelpFunctions::SetBoolInAny( aRet, bAutoFilter );
    2186                 :            :         }
    2187 [ +  - ][ +  + ]:         24 :         else if (aString.EqualsAscii( SC_UNONAME_USEFLTCRT ))
    2188                 :            :         {
    2189                 :          7 :             ScRange aRange;
    2190 [ +  - ][ +  - ]:          7 :             sal_Bool bIsAdvancedSource(GetDBData_Impl()->GetAdvancedQuerySource(aRange));
    2191                 :            : 
    2192         [ +  - ]:          7 :             ScUnoHelpFunctions::SetBoolInAny( aRet, bIsAdvancedSource );
    2193                 :            :         }
    2194 [ +  - ][ +  + ]:         17 :         else if (aString.EqualsAscii( SC_UNONAME_FLTCRT ))
    2195                 :            :         {
    2196                 :          3 :             table::CellRangeAddress aRange;
    2197                 :          3 :             ScRange aCoreRange;
    2198 [ +  - ][ +  - ]:          3 :             if (GetDBData_Impl()->GetAdvancedQuerySource(aCoreRange))
                 [ +  - ]
    2199                 :          3 :                 ScUnoConversion::FillApiRange(aRange, aCoreRange);
    2200                 :            : 
    2201         [ +  - ]:          3 :             aRet <<= aRange;
    2202                 :            :         }
    2203 [ +  - ][ +  + ]:         14 :         else if (aString.EqualsAscii( SC_UNONAME_FROMSELECT ))
    2204                 :            :         {
    2205 [ +  - ][ +  - ]:          7 :             ScUnoHelpFunctions::SetBoolInAny( aRet, GetDBData_Impl()->HasImportSelection() );
    2206                 :            :         }
    2207 [ +  - ][ +  - ]:          7 :         else if (aString.EqualsAscii( SC_UNONAME_REFPERIOD ))
    2208                 :            :         {
    2209         [ +  - ]:          7 :             sal_Int32 nRefresh(GetDBData_Impl()->GetRefreshDelay());
    2210         [ +  - ]:          7 :             aRet <<= nRefresh;
    2211                 :            :         }
    2212 [ #  # ][ #  # ]:          0 :         else if (aString.EqualsAscii( SC_UNONAME_CONRES ))
    2213                 :            :         {
    2214                 :            :         }
    2215 [ #  # ][ #  # ]:          0 :         else if (aString.EqualsAscii( SC_UNONAME_TOKENINDEX ))
    2216                 :            :         {
    2217                 :            :             // get index for use in formula tokens (read-only)
    2218 [ #  # ][ #  # ]:          0 :             aRet <<= static_cast<sal_Int32>(GetDBData_Impl()->GetIndex());
    2219         [ +  - ]:         52 :         }
    2220                 :            :     }
    2221         [ +  - ]:         52 :     return aRet;
    2222                 :            : }
    2223                 :            : 
    2224                 :          0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDatabaseRangeObj )
    2225                 :            : 
    2226                 :            : // XServiceInfo
    2227                 :            : 
    2228                 :          0 : rtl::OUString SAL_CALL ScDatabaseRangeObj::getImplementationName() throw(uno::RuntimeException)
    2229                 :            : {
    2230                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ScDatabaseRangeObj" ));
    2231                 :            : }
    2232                 :            : 
    2233                 :          1 : sal_Bool SAL_CALL ScDatabaseRangeObj::supportsService( const rtl::OUString& rServiceName )
    2234                 :            :                                                     throw(uno::RuntimeException)
    2235                 :            : {
    2236         [ +  - ]:          1 :     String aServiceStr( rServiceName );
    2237         [ +  - ]:          1 :     return aServiceStr.EqualsAscii( SCDATABASERANGEOBJ_SERVICE ) ||
    2238 [ -  + ][ #  # ]:          1 :            aServiceStr.EqualsAscii( SCLINKTARGET_SERVICE );
         [ #  # ][ +  - ]
    2239                 :            : }
    2240                 :            : 
    2241                 :          0 : uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangeObj::getSupportedServiceNames()
    2242                 :            :                                                     throw(uno::RuntimeException)
    2243                 :            : {
    2244                 :          0 :     uno::Sequence<rtl::OUString> aRet(2);
    2245         [ #  # ]:          0 :     rtl::OUString* pArray = aRet.getArray();
    2246         [ #  # ]:          0 :     pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCDATABASERANGEOBJ_SERVICE ));
    2247         [ #  # ]:          0 :     pArray[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCLINKTARGET_SERVICE ));
    2248                 :          0 :     return aRet;
    2249                 :            : }
    2250                 :            : 
    2251                 :            : //------------------------------------------------------------------------
    2252                 :            : 
    2253                 :         23 : ScDatabaseRangesObj::ScDatabaseRangesObj(ScDocShell* pDocSh) :
    2254         [ +  - ]:         23 :     pDocShell( pDocSh )
    2255                 :            : {
    2256         [ +  - ]:         23 :     pDocShell->GetDocument()->AddUnoObject(*this);
    2257                 :         23 : }
    2258                 :            : 
    2259         [ +  - ]:         23 : ScDatabaseRangesObj::~ScDatabaseRangesObj()
    2260                 :            : {
    2261         [ +  + ]:         23 :     if (pDocShell)
    2262         [ +  - ]:         16 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    2263         [ -  + ]:         46 : }
    2264                 :            : 
    2265                 :        196 : void ScDatabaseRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    2266                 :            : {
    2267                 :            :     //  Referenz-Update interessiert hier nicht
    2268                 :            : 
    2269   [ +  +  +  + ]:        390 :     if ( rHint.ISA( SfxSimpleHint ) &&
                 [ +  + ]
    2270                 :        194 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    2271                 :            :     {
    2272                 :          7 :         pDocShell = NULL;       // ungueltig geworden
    2273                 :            :     }
    2274                 :        196 : }
    2275                 :            : 
    2276                 :            : // XDatabaseRanges
    2277                 :            : 
    2278                 :          2 : ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(size_t nIndex)
    2279                 :            : {
    2280         [ -  + ]:          2 :     if (!pDocShell)
    2281                 :          0 :         return NULL;
    2282                 :            : 
    2283         [ +  - ]:          2 :     ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
    2284         [ -  + ]:          2 :     if (!pNames)
    2285                 :          0 :         return NULL;
    2286                 :            : 
    2287         [ +  - ]:          2 :     const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
    2288 [ +  - ][ +  - ]:          2 :     if (rDBs.empty() || nIndex >= rDBs.size())
         [ +  - ][ +  + ]
                 [ +  + ]
    2289                 :          1 :         return NULL;
    2290                 :            : 
    2291         [ +  - ]:          1 :     ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin();
    2292         [ +  - ]:          1 :     ::std::advance(itr, nIndex); // boundary check is done above.
    2293 [ +  - ][ +  - ]:          2 :     return new ScDatabaseRangeObj(pDocShell, itr->GetName());
         [ +  - ][ +  - ]
    2294                 :            : }
    2295                 :            : 
    2296                 :         18 : ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByName_Impl(const rtl::OUString& aName)
    2297                 :            : {
    2298 [ +  - ][ +  - ]:         18 :     if ( pDocShell && hasByName(aName) )
                 [ +  - ]
    2299                 :            :     {
    2300         [ +  - ]:         18 :         String aString(aName);
    2301 [ +  - ][ +  - ]:         18 :         return new ScDatabaseRangeObj( pDocShell, aString );
    2302                 :            :     }
    2303                 :         18 :     return NULL;
    2304                 :            : }
    2305                 :            : 
    2306                 :            : 
    2307                 :          3 : void SAL_CALL ScDatabaseRangesObj::addNewByName( const rtl::OUString& aName,
    2308                 :            :                                         const table::CellRangeAddress& aRange )
    2309                 :            :                                         throw(uno::RuntimeException)
    2310                 :            : {
    2311         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    2312                 :          3 :     sal_Bool bDone = false;
    2313         [ +  - ]:          3 :     if (pDocShell)
    2314                 :            :     {
    2315                 :          3 :         ScDBDocFunc aFunc(*pDocShell);
    2316                 :            : 
    2317         [ +  - ]:          3 :         String aString(aName);
    2318                 :            :         ScRange aNameRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
    2319                 :          3 :                             (SCCOL)aRange.EndColumn,   (SCROW)aRange.EndRow,   aRange.Sheet );
    2320 [ +  - ][ +  - ]:          3 :         bDone = aFunc.AddDBRange( aString, aNameRange, sal_True );
                 [ +  - ]
    2321                 :            :     }
    2322         [ -  + ]:          3 :     if (!bDone)
    2323 [ #  # ][ +  - ]:          3 :         throw uno::RuntimeException();      // no other exceptions specified
    2324                 :          3 : }
    2325                 :            : 
    2326                 :          0 : void SAL_CALL ScDatabaseRangesObj::removeByName( const rtl::OUString& aName )
    2327                 :            :                                         throw(uno::RuntimeException)
    2328                 :            : {
    2329         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2330                 :          0 :     sal_Bool bDone = false;
    2331         [ #  # ]:          0 :     if (pDocShell)
    2332                 :            :     {
    2333                 :          0 :         ScDBDocFunc aFunc(*pDocShell);
    2334         [ #  # ]:          0 :         String aString(aName);
    2335 [ #  # ][ #  # ]:          0 :         bDone = aFunc.DeleteDBRange( aString );
                 [ #  # ]
    2336                 :            :     }
    2337         [ #  # ]:          0 :     if (!bDone)
    2338 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException();      // no other exceptions specified
    2339                 :          0 : }
    2340                 :            : 
    2341                 :            : // XEnumerationAccess
    2342                 :            : 
    2343                 :          1 : uno::Reference<container::XEnumeration> SAL_CALL ScDatabaseRangesObj::createEnumeration()
    2344                 :            :                                                     throw(uno::RuntimeException)
    2345                 :            : {
    2346         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    2347 [ +  - ][ +  - ]:          1 :     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DatabaseRangesEnumeration")));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2348                 :            : }
    2349                 :            : 
    2350                 :            : // XIndexAccess
    2351                 :            : 
    2352                 :          2 : sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount() throw(uno::RuntimeException)
    2353                 :            : {
    2354         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    2355                 :            : 
    2356                 :            :     //! "unbenannt" weglassen ?
    2357                 :            : 
    2358         [ +  - ]:          2 :     if (pDocShell)
    2359                 :            :     {
    2360         [ +  - ]:          2 :         ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
    2361         [ +  - ]:          2 :         if (pNames)
    2362 [ +  - ][ +  - ]:          2 :             return static_cast<sal_Int32>(pNames->getNamedDBs().size());
    2363                 :            :     }
    2364         [ +  - ]:          2 :     return 0;
    2365                 :            : }
    2366                 :            : 
    2367                 :          2 : uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
    2368                 :            :                             throw(lang::IndexOutOfBoundsException,
    2369                 :            :                                     lang::WrappedTargetException, uno::RuntimeException)
    2370                 :            : {
    2371         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    2372         [ -  + ]:          2 :     if (nIndex < 0)
    2373         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
    2374                 :            : 
    2375 [ +  - ][ +  + ]:          2 :     uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl(static_cast<size_t>(nIndex)));
                 [ +  - ]
    2376         [ +  + ]:          2 :     if (xRange.is())
    2377         [ +  - ]:          2 :         return uno::makeAny(xRange);
    2378                 :            :     else
    2379 [ +  - ][ +  - ]:          2 :         throw lang::IndexOutOfBoundsException();
    2380                 :            : }
    2381                 :            : 
    2382                 :          0 : uno::Type SAL_CALL ScDatabaseRangesObj::getElementType() throw(uno::RuntimeException)
    2383                 :            : {
    2384         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2385 [ #  # ][ #  # ]:          0 :     return getCppuType((uno::Reference<sheet::XDatabaseRange>*)0);
    2386                 :            : }
    2387                 :            : 
    2388                 :          0 : sal_Bool SAL_CALL ScDatabaseRangesObj::hasElements() throw(uno::RuntimeException)
    2389                 :            : {
    2390         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2391 [ #  # ][ #  # ]:          0 :     return ( getCount() != 0 );
    2392                 :            : }
    2393                 :            : 
    2394                 :            : // XNameAccess
    2395                 :            : 
    2396                 :         18 : uno::Any SAL_CALL ScDatabaseRangesObj::getByName( const rtl::OUString& aName )
    2397                 :            :             throw(container::NoSuchElementException,
    2398                 :            :                     lang::WrappedTargetException, uno::RuntimeException)
    2399                 :            : {
    2400         [ +  - ]:         18 :     SolarMutexGuard aGuard;
    2401 [ +  - ][ +  - ]:         18 :     uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByName_Impl(aName));
                 [ +  - ]
    2402         [ +  - ]:         18 :     if (xRange.is())
    2403         [ +  - ]:         36 :         return uno::makeAny(xRange);
    2404                 :            :     else
    2405 [ #  # ][ +  - ]:         18 :         throw container::NoSuchElementException();
    2406                 :            : //    return uno::Any();
    2407                 :            : }
    2408                 :            : 
    2409                 :          4 : uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
    2410                 :            :                                                 throw(uno::RuntimeException)
    2411                 :            : {
    2412         [ +  - ]:          4 :     SolarMutexGuard aGuard;
    2413                 :            : 
    2414                 :            :     //! "unbenannt" weglassen ?
    2415                 :            : 
    2416         [ +  - ]:          4 :     if (pDocShell)
    2417                 :            :     {
    2418         [ +  - ]:          4 :         ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
    2419         [ +  - ]:          4 :         if (pNames)
    2420                 :            :         {
    2421         [ +  - ]:          4 :             const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
    2422 [ +  - ][ +  - ]:          4 :             uno::Sequence<rtl::OUString> aSeq(rDBs.size());
    2423 [ +  - ][ +  - ]:          4 :             ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
    2424 [ #  # ][ +  - ]:          4 :             for (size_t i = 0; itr != itrEnd; ++itr, ++i)
                 [ -  + ]
    2425 [ #  # ][ #  # ]:          0 :                 aSeq[i] = itr->GetName();
    2426                 :            : 
    2427 [ +  - ][ +  - ]:          4 :             return aSeq;
    2428                 :            :         }
    2429                 :            :     }
    2430 [ #  # ][ +  - ]:          4 :     return uno::Sequence<rtl::OUString>(0);
    2431                 :            : }
    2432                 :            : 
    2433                 :         21 : sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName )
    2434                 :            :                                         throw(uno::RuntimeException)
    2435                 :            : {
    2436         [ +  - ]:         21 :     SolarMutexGuard aGuard;
    2437                 :            : 
    2438                 :            :     //! "unbenannt" weglassen ?
    2439                 :            : 
    2440         [ +  - ]:         21 :     if (pDocShell)
    2441                 :            :     {
    2442         [ +  - ]:         21 :         ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
    2443         [ +  - ]:         21 :         if (pNames)
    2444 [ +  - ][ +  - ]:         21 :             return pNames->getNamedDBs().findByName(aName) != NULL;
    2445                 :            :     }
    2446         [ +  - ]:         21 :     return false;
    2447                 :            : }
    2448                 :            : 
    2449                 :            : //------------------------------------------------------------------------
    2450                 :            : 
    2451                 :          0 : ScUnnamedDatabaseRangesObj::ScUnnamedDatabaseRangesObj(ScDocShell* pDocSh) :
    2452         [ #  # ]:          0 :     pDocShell( pDocSh )
    2453                 :            : {
    2454         [ #  # ]:          0 :     pDocShell->GetDocument()->AddUnoObject(*this);
    2455                 :          0 : }
    2456                 :            : 
    2457         [ #  # ]:          0 : ScUnnamedDatabaseRangesObj::~ScUnnamedDatabaseRangesObj()
    2458                 :            : {
    2459         [ #  # ]:          0 :     if (pDocShell)
    2460         [ #  # ]:          0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    2461         [ #  # ]:          0 : }
    2462                 :            : 
    2463                 :          0 : void ScUnnamedDatabaseRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    2464                 :            : {
    2465                 :            :     //  Referenz-Update interessiert hier nicht
    2466                 :            : 
    2467   [ #  #  #  # ]:          0 :     if ( rHint.ISA( SfxSimpleHint ) &&
                 [ #  # ]
    2468                 :          0 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    2469                 :            :     {
    2470                 :          0 :         pDocShell = NULL;       // ungueltig geworden
    2471                 :            :     }
    2472                 :          0 : }
    2473                 :            : 
    2474                 :            : // XUnnamedDatabaseRanges
    2475                 :            : 
    2476                 :          0 : void ScUnnamedDatabaseRangesObj::setByTable( const table::CellRangeAddress& aRange )
    2477                 :            :                                 throw( uno::RuntimeException,
    2478                 :            :                                         lang::IndexOutOfBoundsException )
    2479                 :            : {
    2480         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2481                 :          0 :     bool bDone = false;
    2482         [ #  # ]:          0 :     if (pDocShell)
    2483                 :            :     {
    2484 [ #  # ][ #  # ]:          0 :         if ( pDocShell->GetDocument()->GetTableCount() <= aRange.Sheet )
    2485         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
    2486                 :            : 
    2487                 :          0 :         ScDBDocFunc aFunc(*pDocShell);
    2488         [ #  # ]:          0 :         String aString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME));
    2489                 :            :         ScRange aUnnamedRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
    2490                 :          0 :                             (SCCOL)aRange.EndColumn,   (SCROW)aRange.EndRow,   aRange.Sheet );
    2491 [ #  # ][ #  # ]:          0 :         bDone = aFunc.AddDBRange( aString, aUnnamedRange, sal_True );
                 [ #  # ]
    2492                 :            :     }
    2493         [ #  # ]:          0 :     if (!bDone)
    2494 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException();      // no other exceptions specified
    2495                 :          0 : }
    2496                 :            : 
    2497                 :          0 : uno::Any ScUnnamedDatabaseRangesObj::getByTable( sal_Int32 nTab )
    2498                 :            :                                 throw(uno::RuntimeException,
    2499                 :            :                                     lang::IndexOutOfBoundsException,
    2500                 :            :                                     container::NoSuchElementException)
    2501                 :            : {
    2502         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2503         [ #  # ]:          0 :     if (pDocShell)
    2504                 :            :     {
    2505 [ #  # ][ #  # ]:          0 :         if ( pDocShell->GetDocument()->GetTableCount() <= nTab )
    2506         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
    2507                 :            :         uno::Reference<sheet::XDatabaseRange> xRange(
    2508 [ #  # ][ #  # ]:          0 :             new ScDatabaseRangeObj(pDocShell, static_cast<SCTAB>(nTab)));
                 [ #  # ]
    2509         [ #  # ]:          0 :         if (xRange.is())
    2510         [ #  # ]:          0 :             return uno::makeAny(xRange);
    2511                 :            :         else
    2512         [ #  # ]:          0 :             throw container::NoSuchElementException();
    2513                 :            :     }
    2514                 :            :     else
    2515 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException();
    2516                 :            : }
    2517                 :            : 
    2518                 :          0 : sal_Bool ScUnnamedDatabaseRangesObj::hasByTable( sal_Int32 nTab )
    2519                 :            :                                     throw (uno::RuntimeException,
    2520                 :            :                                         lang::IndexOutOfBoundsException)
    2521                 :            : {
    2522         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    2523         [ #  # ]:          0 :     if (pDocShell)
    2524                 :            :     {
    2525 [ #  # ][ #  # ]:          0 :          if (pDocShell->GetDocument()->GetTableCount() <= nTab)
    2526         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
    2527 [ #  # ][ #  # ]:          0 :         if (pDocShell->GetDocument()->GetAnonymousDBData((SCTAB) nTab))
    2528                 :          0 :             return true;
    2529                 :          0 :         return false;
    2530                 :            :     }
    2531                 :            :     else
    2532         [ #  # ]:          0 :         return false;
    2533 [ +  - ][ +  - ]:        153 : }
    2534                 :            : 
    2535                 :            : //------------------------------------------------------------------------
    2536                 :            : 
    2537                 :            : 
    2538                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10