2011-11-05 00:56:38 -04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-08-09 20:23:13 -04:00
|
|
|
/*************************************************************************
|
2011-11-05 00:56:38 -04:00
|
|
|
*
|
2012-08-09 20:23:13 -04:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2011-11-05 00:56:38 -04:00
|
|
|
*
|
2012-08-09 20:23:13 -04:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2011-11-05 00:56:38 -04:00
|
|
|
*
|
2012-08-09 20:23:13 -04:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2011-11-05 00:56:38 -04:00
|
|
|
*
|
2012-08-09 20:23:13 -04:00
|
|
|
* This file is part of OpenOffice.org.
|
2011-11-05 00:56:38 -04:00
|
|
|
*
|
2012-08-09 20:23:13 -04:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2011-11-05 00:56:38 -04:00
|
|
|
*
|
2012-08-09 20:23:13 -04:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
2011-11-05 00:56:38 -04:00
|
|
|
|
|
|
|
#include "queryentry.hxx"
|
|
|
|
|
|
|
|
#include <unotools/textsearch.hxx>
|
|
|
|
|
2011-11-07 22:55:53 -05:00
|
|
|
/*
|
|
|
|
* dialog returns the special field values "empty"/"not empty"
|
|
|
|
* as constants SC_EMPTYFIELDS and SC_NONEMPTYFIELDS respectively in nVal in
|
|
|
|
* conjuctions with the flag bQueryByString = FALSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SC_EMPTYFIELDS ((double)0x0042)
|
|
|
|
#define SC_NONEMPTYFIELDS ((double)0x0043)
|
|
|
|
|
2011-11-07 17:40:38 -05:00
|
|
|
bool ScQueryEntry::Item::operator== (const Item& r) const
|
|
|
|
{
|
|
|
|
return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString);
|
|
|
|
}
|
|
|
|
|
2011-11-05 00:56:38 -04:00
|
|
|
ScQueryEntry::ScQueryEntry() :
|
|
|
|
bDoQuery(false),
|
|
|
|
nField(0),
|
|
|
|
eOp(SC_EQUAL),
|
|
|
|
eConnect(SC_AND),
|
|
|
|
pSearchParam(NULL),
|
2011-11-07 17:40:38 -05:00
|
|
|
pSearchText(NULL),
|
|
|
|
maQueryItems(1)
|
2011-11-05 00:56:38 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
|
|
|
|
bDoQuery(r.bDoQuery),
|
|
|
|
nField(r.nField),
|
|
|
|
eOp(r.eOp),
|
|
|
|
eConnect(r.eConnect),
|
|
|
|
pSearchParam(NULL),
|
|
|
|
pSearchText(NULL),
|
2011-11-07 17:40:38 -05:00
|
|
|
maQueryItems(r.maQueryItems)
|
2011-11-05 00:56:38 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScQueryEntry::~ScQueryEntry()
|
|
|
|
{
|
|
|
|
delete pSearchParam;
|
|
|
|
delete pSearchText;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
|
|
|
|
{
|
|
|
|
bDoQuery = r.bDoQuery;
|
|
|
|
eOp = r.eOp;
|
|
|
|
eConnect = r.eConnect;
|
|
|
|
nField = r.nField;
|
2011-11-07 17:40:38 -05:00
|
|
|
maQueryItems = r.maQueryItems;
|
2011-11-05 00:56:38 -04:00
|
|
|
|
|
|
|
delete pSearchParam;
|
|
|
|
delete pSearchText;
|
|
|
|
pSearchParam = NULL;
|
|
|
|
pSearchText = NULL;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-11-14 17:15:31 -05:00
|
|
|
ScQueryEntry::QueryItemsType& ScQueryEntry::GetQueryItems()
|
|
|
|
{
|
|
|
|
return maQueryItems;
|
|
|
|
}
|
|
|
|
|
2011-11-14 16:00:30 -05:00
|
|
|
const ScQueryEntry::QueryItemsType& ScQueryEntry::GetQueryItems() const
|
|
|
|
{
|
|
|
|
return maQueryItems;
|
|
|
|
}
|
|
|
|
|
2011-11-07 22:55:53 -05:00
|
|
|
void ScQueryEntry::SetQueryByEmpty()
|
|
|
|
{
|
|
|
|
eOp = SC_EQUAL;
|
2011-11-30 01:20:45 -05:00
|
|
|
maQueryItems.resize(1);
|
|
|
|
Item& rItem = maQueryItems[0];
|
2011-11-14 16:54:44 -05:00
|
|
|
rItem.meType = ByEmpty;
|
2011-11-07 22:55:53 -05:00
|
|
|
rItem.maString = rtl::OUString();
|
|
|
|
rItem.mfVal = SC_EMPTYFIELDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScQueryEntry::IsQueryByEmpty() const
|
|
|
|
{
|
2011-11-30 01:20:45 -05:00
|
|
|
if (maQueryItems.size() != 1)
|
2011-11-07 22:55:53 -05:00
|
|
|
return false;
|
|
|
|
|
2011-11-30 01:20:45 -05:00
|
|
|
const Item& rItem = maQueryItems[0];
|
2011-11-07 22:55:53 -05:00
|
|
|
return eOp == SC_EQUAL &&
|
2011-11-14 16:54:44 -05:00
|
|
|
rItem.meType == ByEmpty &&
|
2011-11-07 22:55:53 -05:00
|
|
|
rItem.maString.isEmpty() &&
|
|
|
|
rItem.mfVal == SC_EMPTYFIELDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScQueryEntry::SetQueryByNonEmpty()
|
|
|
|
{
|
|
|
|
eOp = SC_EQUAL;
|
2011-11-30 01:20:45 -05:00
|
|
|
maQueryItems.resize(1);
|
|
|
|
Item& rItem = maQueryItems[0];
|
2011-11-14 16:54:44 -05:00
|
|
|
rItem.meType = ByEmpty;
|
2011-11-07 22:55:53 -05:00
|
|
|
rItem.maString = rtl::OUString();
|
|
|
|
rItem.mfVal = SC_NONEMPTYFIELDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScQueryEntry::IsQueryByNonEmpty() const
|
|
|
|
{
|
2011-11-30 01:20:45 -05:00
|
|
|
if (maQueryItems.size() != 1)
|
2011-11-07 22:55:53 -05:00
|
|
|
return false;
|
|
|
|
|
2011-11-30 01:20:45 -05:00
|
|
|
const Item& rItem = maQueryItems[0];
|
2011-11-07 22:55:53 -05:00
|
|
|
return eOp == SC_EQUAL &&
|
2011-11-14 16:54:44 -05:00
|
|
|
rItem.meType == ByEmpty &&
|
2011-11-07 22:55:53 -05:00
|
|
|
rItem.maString.isEmpty() &&
|
|
|
|
rItem.mfVal == SC_NONEMPTYFIELDS;
|
|
|
|
}
|
|
|
|
|
2011-11-07 17:40:38 -05:00
|
|
|
const ScQueryEntry::Item& ScQueryEntry::GetQueryItem() const
|
2011-11-05 00:56:38 -04:00
|
|
|
{
|
2011-11-07 17:40:38 -05:00
|
|
|
if (maQueryItems.size() > 1)
|
|
|
|
// Reset to a single query mode.
|
|
|
|
maQueryItems.resize(1);
|
|
|
|
return maQueryItems[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
ScQueryEntry::Item& ScQueryEntry::GetQueryItem()
|
|
|
|
{
|
|
|
|
if (maQueryItems.size() > 1)
|
|
|
|
// Reset to a single query mode.
|
|
|
|
maQueryItems.resize(1);
|
|
|
|
return maQueryItems[0];
|
2011-11-05 00:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScQueryEntry::Clear()
|
|
|
|
{
|
|
|
|
bDoQuery = false;
|
|
|
|
eOp = SC_EQUAL;
|
|
|
|
eConnect = SC_AND;
|
|
|
|
nField = 0;
|
2011-11-07 17:40:38 -05:00
|
|
|
maQueryItems.clear();
|
|
|
|
maQueryItems.push_back(Item());
|
2011-11-05 00:56:38 -04:00
|
|
|
|
|
|
|
delete pSearchParam;
|
|
|
|
delete pSearchText;
|
|
|
|
pSearchParam = NULL;
|
|
|
|
pSearchText = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
|
|
|
|
{
|
|
|
|
return bDoQuery == r.bDoQuery
|
|
|
|
&& eOp == r.eOp
|
|
|
|
&& eConnect == r.eConnect
|
|
|
|
&& nField == r.nField
|
2011-11-07 17:40:38 -05:00
|
|
|
&& maQueryItems == r.maQueryItems;
|
2011-11-05 00:56:38 -04:00
|
|
|
//! pSearchParam und pSearchText nicht vergleichen
|
|
|
|
}
|
|
|
|
|
|
|
|
utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
|
|
|
|
{
|
|
|
|
if ( !pSearchParam )
|
|
|
|
{
|
2011-11-07 17:40:38 -05:00
|
|
|
const rtl::OUString& rStr = maQueryItems[0].maString;
|
2011-11-05 00:56:38 -04:00
|
|
|
pSearchParam = new utl::SearchParam(
|
2011-11-07 17:40:38 -05:00
|
|
|
rStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
|
2011-11-05 00:56:38 -04:00
|
|
|
pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
|
|
|
|
}
|
|
|
|
return pSearchText;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|