LCOV - code coverage report
Current view: top level - libreoffice/test/source/sheet - xdatabaserange.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 98 0.0 %
Date: 2012-12-27 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include <test/sheet/xdatabaserange.hxx>
      30             : 
      31             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      32             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      33             : #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
      34             : #include <com/sun/star/beans/PropertyValue.hpp>
      35             : #include <com/sun/star/sheet/XDatabaseRange.hpp>
      36             : #include <com/sun/star/sheet/XDatabaseRanges.hpp>
      37             : #include <com/sun/star/table/CellRangeAddress.hpp>
      38             : #include <com/sun/star/util/XCloseable.hpp>
      39             : #include <com/sun/star/beans/XPropertySet.hpp>
      40             : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
      41             : #include <com/sun/star/table/XCell.hpp>
      42             : #include <com/sun/star/table/XTableRows.hpp>
      43             : #include <com/sun/star/table/XColumnRowRange.hpp>
      44             : 
      45             : #include <rtl/ustring.hxx>
      46             : #include "cppunit/extensions/HelperMacros.h"
      47             : #include <iostream>
      48             : 
      49             : using namespace com::sun::star::uno;
      50             : 
      51             : namespace apitest {
      52             : 
      53             : /**
      54             :  * tests setDataArea and getDataArea
      55             :  */
      56           0 : void XDatabaseRange::testDataArea()
      57             : {
      58           0 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataArea"))), UNO_QUERY_THROW);
      59             : 
      60           0 :     table::CellRangeAddress aCellAddress;
      61           0 :     aCellAddress.Sheet = 0;
      62           0 :     aCellAddress.StartColumn = 1;
      63           0 :     aCellAddress.EndColumn = 4;
      64           0 :     aCellAddress.StartRow = 2;
      65           0 :     aCellAddress.EndRow = 5;
      66           0 :     xDBRange->setDataArea(aCellAddress);
      67           0 :     table::CellRangeAddress aValue;
      68           0 :     aValue = xDBRange->getDataArea();
      69           0 :     CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
      70           0 :     CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
      71           0 :     CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
      72           0 :     CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
      73           0 :     CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
      74           0 : }
      75             : 
      76           0 : void XDatabaseRange::testGetSubtotalDescriptor()
      77             : {
      78           0 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubtotalDescriptor"))), UNO_QUERY_THROW);
      79           0 :     uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
      80           0 :     CPPUNIT_ASSERT(xSubtotalDescr.is());
      81           0 : }
      82             : 
      83           0 : void XDatabaseRange::testGetSortDescriptor()
      84             : {
      85           0 :     uno::Reference< sheet::XDatabaseRange > xDBRange(init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortDescriptor"))), UNO_QUERY_THROW);
      86           0 :     uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
      87           0 :     for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i)
      88             :     {
      89           0 :         beans::PropertyValue xProp = xSortDescr[i];
      90             :         //std::cout << "Prop " << i << " Name: " << rtl::OUString(xProp.Name) << std::endl;
      91             : 
      92           0 :         if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSortColumns")))
      93             :         {
      94           0 :             sal_Bool bIsSortColumns = sal_True;
      95           0 :             xProp.Value >>= bIsSortColumns;
      96           0 :             CPPUNIT_ASSERT(bIsSortColumns == sal_True);
      97             :         }
      98           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContainsHeader")))
      99             :         {
     100           0 :             sal_Bool bContainsHeader = sal_True;
     101           0 :             xProp.Value >>= bContainsHeader;
     102           0 :             CPPUNIT_ASSERT(bContainsHeader == sal_True);
     103             :         }
     104           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxFieldCount")))
     105             :         {
     106           0 :             sal_Int32 nMaxFieldCount = 0;
     107           0 :             xProp.Value >>= nMaxFieldCount;
     108           0 :             std::cout << "Value: " << nMaxFieldCount << std::endl;
     109             : 
     110             :         }
     111           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortFields")))
     112             :         {
     113             : 
     114             :         }
     115           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BindFormatsToContent")))
     116             :         {
     117           0 :             sal_Bool bBindFormatsToContent = sal_False;
     118           0 :             xProp.Value >>= bBindFormatsToContent;
     119           0 :             CPPUNIT_ASSERT(bBindFormatsToContent == sal_True);
     120             :         }
     121           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CopyOutputData")))
     122             :         {
     123           0 :             sal_Bool bCopyOutputData = sal_True;
     124           0 :             xProp.Value >>= bCopyOutputData;
     125           0 :             CPPUNIT_ASSERT(bCopyOutputData == sal_False);
     126             :         }
     127           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputPosition")))
     128             :         {
     129             : 
     130             :         }
     131           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUserListEnabled")))
     132             :         {
     133           0 :             sal_Bool bIsUserListEnabled  = sal_True;
     134           0 :             xProp.Value >>= bIsUserListEnabled;
     135           0 :             CPPUNIT_ASSERT(bIsUserListEnabled == sal_False);
     136             : 
     137             :         }
     138           0 :         else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserListIndex")))
     139             :         {
     140           0 :             sal_Int32 nUserListIndex = 1;
     141           0 :             xProp.Value >>= nUserListIndex;
     142           0 :             CPPUNIT_ASSERT(nUserListIndex == 0);
     143             :         }
     144           0 :     }
     145           0 : }
     146             : 
     147           0 : void XDatabaseRange::testGetFilterDescriptor()
     148             : {
     149           0 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterDescriptor"))), UNO_QUERY_THROW);
     150           0 :     uno::Reference< uno::XInterface > xFilterDescr( xDBRange->getFilterDescriptor(), UNO_QUERY_THROW);
     151           0 :     CPPUNIT_ASSERT(xFilterDescr.is());
     152           0 : }
     153             : 
     154           0 : void XDatabaseRange::testGetImportDescriptor()
     155             : {
     156           0 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImportDescriptor"))), UNO_QUERY_THROW);
     157           0 :     uno::Sequence< beans::PropertyValue > xImportDescr = xDBRange->getImportDescriptor();
     158           0 : }
     159             : 
     160           0 : void XDatabaseRange::testRefresh()
     161             : {
     162           0 :     uno::Reference< sheet::XDatabaseRange > xDBRange( init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Refresh"))), UNO_QUERY_THROW);
     163             : 
     164           0 :     const sal_Int32 nCol = 0;
     165           0 :     rtl::OUString aHidden(RTL_CONSTASCII_USTRINGPARAM("IsVisible"));
     166           0 :     uno::Reference< sheet::XCellRangeReferrer > xCellRangeReferrer(xDBRange, UNO_QUERY_THROW);
     167           0 :     uno::Reference< table::XCellRange > xCellRange = xCellRangeReferrer->getReferredCells();
     168             : 
     169           0 :     for (sal_Int32 i = 1; i < 5; ++i)
     170             :     {
     171           0 :         uno::Reference< table::XCell > xCell = xCellRange->getCellByPosition(nCol, i);
     172           0 :         xCell->setValue(0);
     173           0 :     }
     174             : 
     175           0 :     for (sal_Int32 i = 2; i < 5; ++i)
     176             :     {
     177           0 :         uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
     178           0 :         uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
     179           0 :         uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
     180           0 :         uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
     181           0 :         Any aAny = xPropRow->getPropertyValue( aHidden );
     182             : 
     183           0 :         CPPUNIT_ASSERT(aAny.get<sal_Bool>() == sal_True);
     184           0 :     }
     185             : 
     186           0 :     xDBRange->refresh();
     187           0 :     std::cout << "after refresh" << std::endl;
     188             : 
     189           0 :     for (sal_Int32 i = 1; i < 5; ++i)
     190             :     {
     191           0 :         uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
     192           0 :         uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
     193           0 :         uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
     194           0 :         uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
     195           0 :         Any aAny = xPropRow->getPropertyValue( aHidden );
     196             : 
     197           0 :         CPPUNIT_ASSERT(aAny.get<sal_Bool>() == sal_False);
     198           0 :     }
     199             : 
     200             : 
     201           0 : }
     202             : 
     203           0 : }
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10