LCOV - code coverage report
Current view: top level - test/source/sheet - xdatabaserange.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 99 99 100.0 %
Date: 2015-06-13 12:38:46 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <test/sheet/xdatabaserange.hxx>
      11             : 
      12             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      13             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      14             : #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
      15             : #include <com/sun/star/beans/PropertyValue.hpp>
      16             : #include <com/sun/star/sheet/XDatabaseRange.hpp>
      17             : #include <com/sun/star/sheet/XDatabaseRanges.hpp>
      18             : #include <com/sun/star/table/CellRangeAddress.hpp>
      19             : #include <com/sun/star/util/XCloseable.hpp>
      20             : #include <com/sun/star/beans/XPropertySet.hpp>
      21             : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
      22             : #include <com/sun/star/table/XCell.hpp>
      23             : #include <com/sun/star/table/XTableRows.hpp>
      24             : #include <com/sun/star/table/XColumnRowRange.hpp>
      25             : 
      26             : #include <rtl/ustring.hxx>
      27             : #include "cppunit/extensions/HelperMacros.h"
      28             : #include <iostream>
      29             : 
      30             : using namespace css;
      31             : using namespace css::uno;
      32             : 
      33             : namespace apitest {
      34             : 
      35             : /**
      36             :  * tests setDataArea and getDataArea
      37             :  */
      38           1 : void XDatabaseRange::testDataArea()
      39             : {
      40           1 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("DataArea")), UNO_QUERY_THROW);
      41             : 
      42           1 :     table::CellRangeAddress aCellAddress;
      43           1 :     aCellAddress.Sheet = 0;
      44           1 :     aCellAddress.StartColumn = 1;
      45           1 :     aCellAddress.EndColumn = 4;
      46           1 :     aCellAddress.StartRow = 2;
      47           1 :     aCellAddress.EndRow = 5;
      48           1 :     xDBRange->setDataArea(aCellAddress);
      49           1 :     table::CellRangeAddress aValue;
      50           1 :     aValue = xDBRange->getDataArea();
      51           1 :     CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
      52           1 :     CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
      53           1 :     CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
      54           1 :     CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
      55           1 :     CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
      56           1 : }
      57             : 
      58           1 : void XDatabaseRange::testGetSubtotalDescriptor()
      59             : {
      60           1 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("SubtotalDescriptor")), UNO_QUERY_THROW);
      61           2 :     uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
      62           2 :     CPPUNIT_ASSERT(xSubtotalDescr.is());
      63           1 : }
      64             : 
      65           1 : void XDatabaseRange::testGetSortDescriptor()
      66             : {
      67           1 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(OUString("SortDescriptor")), UNO_QUERY_THROW);
      68           2 :     uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
      69          10 :     for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i)
      70             :     {
      71           9 :         beans::PropertyValue xProp = xSortDescr[i];
      72             :         //std::cout << "Prop " << i << " Name: " << OUString(xProp.Name) << std::endl;
      73             : 
      74           9 :         if (xProp.Name == "IsSortColumns")
      75             :         {
      76           1 :             bool bIsSortColumns = true;
      77           1 :             xProp.Value >>= bIsSortColumns;
      78           1 :             CPPUNIT_ASSERT(bIsSortColumns);
      79             :         }
      80           8 :         else if (xProp.Name == "ContainsHeader")
      81             :         {
      82           1 :             bool bContainsHeader = true;
      83           1 :             xProp.Value >>= bContainsHeader;
      84           1 :             CPPUNIT_ASSERT(bContainsHeader);
      85             :         }
      86           7 :         else if (xProp.Name == "MaxFieldCount")
      87             :         {
      88           1 :             sal_Int32 nMaxFieldCount = 0;
      89           1 :             xProp.Value >>= nMaxFieldCount;
      90           1 :             std::cout << "Value: " << nMaxFieldCount << std::endl;
      91             : 
      92             :         }
      93           6 :         else if (xProp.Name == "SortFields")
      94             :         {
      95             : 
      96             :         }
      97           5 :         else if (xProp.Name == "BindFormatsToContent")
      98             :         {
      99           1 :             bool bBindFormatsToContent = false;
     100           1 :             xProp.Value >>= bBindFormatsToContent;
     101           1 :             CPPUNIT_ASSERT(bBindFormatsToContent);
     102             :         }
     103           4 :         else if (xProp.Name == "CopyOutputData")
     104             :         {
     105           1 :             bool bCopyOutputData = true;
     106           1 :             xProp.Value >>= bCopyOutputData;
     107           1 :             CPPUNIT_ASSERT(!bCopyOutputData);
     108             :         }
     109           3 :         else if (xProp.Name == "OutputPosition")
     110             :         {
     111             : 
     112             :         }
     113           2 :         else if (xProp.Name == "IsUserListEnabled")
     114             :         {
     115           1 :             bool bIsUserListEnabled  = true;
     116           1 :             xProp.Value >>= bIsUserListEnabled;
     117           1 :             CPPUNIT_ASSERT(!bIsUserListEnabled);
     118             : 
     119             :         }
     120           1 :         else if (xProp.Name == "UserListIndex")
     121             :         {
     122           1 :             sal_Int32 nUserListIndex = 1;
     123           1 :             xProp.Value >>= nUserListIndex;
     124           1 :             CPPUNIT_ASSERT(nUserListIndex == 0);
     125             :         }
     126          10 :     }
     127           1 : }
     128             : 
     129           1 : void XDatabaseRange::testGetFilterDescriptor()
     130             : {
     131           1 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("FilterDescriptor")), UNO_QUERY_THROW);
     132           2 :     uno::Reference< uno::XInterface > xFilterDescr( xDBRange->getFilterDescriptor(), UNO_QUERY_THROW);
     133           2 :     CPPUNIT_ASSERT(xFilterDescr.is());
     134           1 : }
     135             : 
     136           1 : void XDatabaseRange::testGetImportDescriptor()
     137             : {
     138           1 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("ImportDescriptor")), UNO_QUERY_THROW);
     139           1 :     uno::Sequence< beans::PropertyValue > xImportDescr = xDBRange->getImportDescriptor();
     140           1 :     (void) xImportDescr;
     141           1 : }
     142             : 
     143           1 : void XDatabaseRange::testRefresh()
     144             : {
     145           1 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(OUString("Refresh")), UNO_QUERY_THROW);
     146             : 
     147           1 :     const sal_Int32 nCol = 0;
     148           2 :     OUString aHidden("IsVisible");
     149           2 :     uno::Reference< sheet::XCellRangeReferrer > xCellRangeReferrer(xDBRange, UNO_QUERY_THROW);
     150           2 :     uno::Reference< table::XCellRange > xCellRange = xCellRangeReferrer->getReferredCells();
     151             : 
     152           5 :     for (sal_Int32 i = 1; i < 5; ++i)
     153             :     {
     154           4 :         uno::Reference< table::XCell > xCell = xCellRange->getCellByPosition(nCol, i);
     155           4 :         xCell->setValue(0);
     156           4 :     }
     157             : 
     158           4 :     for (sal_Int32 i = 2; i < 5; ++i)
     159             :     {
     160           3 :         uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
     161           6 :         uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
     162           6 :         uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
     163           6 :         uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
     164           6 :         Any aAny = xPropRow->getPropertyValue( aHidden );
     165             : 
     166           3 :         CPPUNIT_ASSERT(aAny.get<bool>());
     167           3 :     }
     168             : 
     169           1 :     xDBRange->refresh();
     170           1 :     std::cout << "after refresh" << std::endl;
     171             : 
     172           5 :     for (sal_Int32 i = 1; i < 5; ++i)
     173             :     {
     174           4 :         uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
     175           8 :         uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
     176           8 :         uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
     177           8 :         uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
     178           8 :         Any aAny = xPropRow->getPropertyValue( aHidden );
     179             : 
     180           4 :         CPPUNIT_ASSERT(!aAny.get<bool>());
     181           5 :     }
     182             : 
     183             : 
     184           1 : }
     185             : 
     186          90 : }
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11