LCOV - code coverage report
Current view: top level - sc/source/core/tool - queryentry.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 91 0.0 %
Date: 2014-04-14 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "queryentry.hxx"
      21             : 
      22             : #include <unotools/textsearch.hxx>
      23             : 
      24             : /*
      25             :  * dialog returns the special field values "empty"/"not empty"
      26             :  * as constants SC_EMPTYFIELDS and SC_NONEMPTYFIELDS respectively in nVal in
      27             :  * conjuctions with the flag bQueryByString = FALSE.
      28             :  */
      29             : 
      30             : #define SC_EMPTYFIELDS      ((double)0x0042)
      31             : #define SC_NONEMPTYFIELDS   ((double)0x0043)
      32             : 
      33           0 : bool ScQueryEntry::Item::operator== (const Item& r) const
      34             : {
      35           0 :     return meType == r.meType && mfVal == r.mfVal && maString == r.maString;
      36             : }
      37             : 
      38           0 : ScQueryEntry::ScQueryEntry() :
      39             :     bDoQuery(false),
      40             :     nField(0),
      41             :     eOp(SC_EQUAL),
      42             :     eConnect(SC_AND),
      43             :     pSearchParam(NULL),
      44             :     pSearchText(NULL),
      45           0 :     maQueryItems(1)
      46             : {
      47           0 : }
      48             : 
      49           0 : ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
      50             :     bDoQuery(r.bDoQuery),
      51             :     nField(r.nField),
      52             :     eOp(r.eOp),
      53             :     eConnect(r.eConnect),
      54             :     pSearchParam(NULL),
      55             :     pSearchText(NULL),
      56           0 :     maQueryItems(r.maQueryItems)
      57             : {
      58           0 : }
      59             : 
      60           0 : ScQueryEntry::~ScQueryEntry()
      61             : {
      62           0 :     delete pSearchParam;
      63           0 :     delete pSearchText;
      64           0 : }
      65             : 
      66           0 : ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
      67             : {
      68           0 :     bDoQuery        = r.bDoQuery;
      69           0 :     eOp             = r.eOp;
      70           0 :     eConnect        = r.eConnect;
      71           0 :     nField          = r.nField;
      72           0 :     maQueryItems  = r.maQueryItems;
      73             : 
      74           0 :     delete pSearchParam;
      75           0 :     delete pSearchText;
      76           0 :     pSearchParam    = NULL;
      77           0 :     pSearchText     = NULL;
      78             : 
      79           0 :     return *this;
      80             : }
      81             : 
      82           0 : ScQueryEntry::QueryItemsType& ScQueryEntry::GetQueryItems()
      83             : {
      84           0 :     return maQueryItems;
      85             : }
      86             : 
      87           0 : const ScQueryEntry::QueryItemsType& ScQueryEntry::GetQueryItems() const
      88             : {
      89           0 :     return maQueryItems;
      90             : }
      91             : 
      92           0 : void ScQueryEntry::SetQueryByEmpty()
      93             : {
      94           0 :     eOp = SC_EQUAL;
      95           0 :     maQueryItems.resize(1);
      96           0 :     Item& rItem = maQueryItems[0];
      97           0 :     rItem.meType = ByEmpty;
      98           0 :     rItem.maString = svl::SharedString();
      99           0 :     rItem.mfVal = SC_EMPTYFIELDS;
     100           0 : }
     101             : 
     102           0 : bool ScQueryEntry::IsQueryByEmpty() const
     103             : {
     104           0 :     if (maQueryItems.size() != 1)
     105           0 :         return false;
     106             : 
     107           0 :     const Item& rItem = maQueryItems[0];
     108           0 :     return eOp == SC_EQUAL &&
     109           0 :         rItem.meType == ByEmpty &&
     110           0 :         rItem.maString.isEmpty() &&
     111           0 :         rItem.mfVal == SC_EMPTYFIELDS;
     112             : }
     113             : 
     114           0 : void ScQueryEntry::SetQueryByNonEmpty()
     115             : {
     116           0 :     eOp = SC_EQUAL;
     117           0 :     maQueryItems.resize(1);
     118           0 :     Item& rItem = maQueryItems[0];
     119           0 :     rItem.meType = ByEmpty;
     120           0 :     rItem.maString = svl::SharedString();
     121           0 :     rItem.mfVal = SC_NONEMPTYFIELDS;
     122           0 : }
     123             : 
     124           0 : bool ScQueryEntry::IsQueryByNonEmpty() const
     125             : {
     126           0 :     if (maQueryItems.size() != 1)
     127           0 :         return false;
     128             : 
     129           0 :     const Item& rItem = maQueryItems[0];
     130           0 :     return eOp == SC_EQUAL &&
     131           0 :         rItem.meType == ByEmpty &&
     132           0 :         rItem.maString.isEmpty() &&
     133           0 :         rItem.mfVal == SC_NONEMPTYFIELDS;
     134             : }
     135             : 
     136           0 : const ScQueryEntry::Item& ScQueryEntry::GetQueryItem() const
     137             : {
     138           0 :     if (maQueryItems.size() > 1)
     139             :         // Reset to a single query mode.
     140           0 :         maQueryItems.resize(1);
     141           0 :     return maQueryItems[0];
     142             : }
     143             : 
     144           0 : ScQueryEntry::Item& ScQueryEntry::GetQueryItem()
     145             : {
     146           0 :     if (maQueryItems.size() > 1)
     147             :         // Reset to a single query mode.
     148           0 :         maQueryItems.resize(1);
     149           0 :     return maQueryItems[0];
     150             : }
     151             : 
     152           0 : void ScQueryEntry::Clear()
     153             : {
     154           0 :     bDoQuery        = false;
     155           0 :     eOp             = SC_EQUAL;
     156           0 :     eConnect        = SC_AND;
     157           0 :     nField          = 0;
     158           0 :     maQueryItems.clear();
     159           0 :     maQueryItems.push_back(Item());
     160             : 
     161           0 :     delete pSearchParam;
     162           0 :     delete pSearchText;
     163           0 :     pSearchParam    = NULL;
     164           0 :     pSearchText     = NULL;
     165           0 : }
     166             : 
     167           0 : bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
     168             : {
     169           0 :     return bDoQuery         == r.bDoQuery
     170           0 :         && eOp              == r.eOp
     171           0 :         && eConnect         == r.eConnect
     172           0 :         && nField           == r.nField
     173           0 :         && maQueryItems   == r.maQueryItems;
     174             :     //! pSearchParam und pSearchText nicht vergleichen
     175             : }
     176             : 
     177           0 : utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
     178             : {
     179           0 :     if ( !pSearchParam )
     180             :     {
     181           0 :         OUString aStr = maQueryItems[0].maString.getString();
     182             :         pSearchParam = new utl::SearchParam(
     183           0 :             aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
     184           0 :         pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
     185             :     }
     186           0 :     return pSearchText;
     187             : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10