[Libreoffice-commits] .: 3 commits - sc/inc sc/Library_sc.mk sc/qa sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Nov 4 22:05:57 PDT 2011
sc/Library_sc.mk | 1
sc/inc/lookupcache.hxx | 43 ----
sc/inc/queryentry.hxx | 78 ++++++++
sc/inc/queryparam.hxx | 48 -----
sc/qa/unit/ucalc.cxx | 1
sc/source/core/data/dociter.cxx | 1
sc/source/core/data/documen3.cxx | 1
sc/source/core/data/dpcachetable.cxx | 1
sc/source/core/data/dpobject.cxx | 2
sc/source/core/data/dpshttab.cxx | 1
sc/source/core/data/dptablecache.cxx | 1
sc/source/core/data/table2.cxx | 1
sc/source/core/data/table3.cxx | 1
sc/source/core/inc/interpre.hxx | 31 ---
sc/source/core/tool/dbdata.cxx | 1
sc/source/core/tool/doubleref.cxx | 1
sc/source/core/tool/interpr1.cxx | 31 +++
sc/source/core/tool/lookupcache.cxx | 43 ++++
sc/source/core/tool/queryentry.cxx | 191 ++++++++++++++++++++
sc/source/core/tool/queryparam.cxx | 212 ++---------------------
sc/source/filter/excel/excimp8.cxx | 1
sc/source/filter/excel/excrecds.cxx | 1
sc/source/filter/xml/XMLExportDataPilot.cxx | 1
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 1
sc/source/filter/xml/xmldrani.cxx | 1
sc/source/filter/xml/xmlfilti.cxx | 1
sc/source/ui/dbgui/filtdlg.cxx | 1
sc/source/ui/dbgui/pfiltdlg.cxx | 1
sc/source/ui/docshell/dbdocfun.cxx | 1
sc/source/ui/unoobj/cellsuno.cxx | 1
sc/source/ui/unoobj/datauno.cxx | 2
sc/source/ui/vba/vbarange.cxx | 1
sc/source/ui/view/cellsh2.cxx | 2
sc/source/ui/view/dbfunc.cxx | 1
sc/source/ui/view/dbfunc3.cxx | 1
sc/source/ui/view/gridwin.cxx | 1
sc/source/ui/view/gridwin4.cxx | 1
37 files changed, 412 insertions(+), 297 deletions(-)
New commits:
commit 9c8670847f0945c05c8f40e83f0d845c0d3cff6b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Sat Nov 5 01:05:29 2011 -0400
Removed queryentry.hxx include from lookupcache.hxx header.
For better encapsulation of ScQueryEntry.
diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx
index 49b5def..d70b1b5 100644
--- a/sc/inc/lookupcache.hxx
+++ b/sc/inc/lookupcache.hxx
@@ -32,7 +32,6 @@
#include "address.hxx"
#include "global.hxx"
#include "queryparam.hxx"
-#include "queryentry.hxx"
#include "formula/token.hxx"
#include <svl/listener.hxx>
#include <tools/string.hxx>
@@ -91,45 +90,9 @@ public:
public:
- explicit QueryCriteria( const ScQueryEntry & rEntry ) :
- mfVal(0.0), mbAlloc(false), mbString(false)
- {
- switch (rEntry.eOp)
- {
- case SC_EQUAL :
- meOp = EQUAL;
- break;
- case SC_LESS_EQUAL :
- meOp = LESS_EQUAL;
- break;
- case SC_GREATER_EQUAL :
- meOp = GREATER_EQUAL;
- break;
- default:
- meOp = UNKNOWN;
- DBG_ERRORFILE( "ScLookupCache::QueryCriteria not prepared for this ScQueryOp");
- }
- if (rEntry.bQueryByString)
- setString(rEntry.GetQueryString());
- else
- setDouble( rEntry.nVal);
- }
- QueryCriteria( const QueryCriteria & r ) :
- mfVal( r.mfVal),
- mbAlloc( false),
- mbString( false),
- meOp( r.meOp)
- {
- if (r.mbString && r.mpStr)
- {
- mpStr = new String( *r.mpStr);
- mbAlloc = mbString = true;
- }
- }
- ~QueryCriteria()
- {
- deleteString();
- }
+ explicit QueryCriteria( const ScQueryEntry & rEntry );
+ QueryCriteria( const QueryCriteria & r );
+ ~QueryCriteria();
QueryOp getQueryOp() const { return meOp; }
diff --git a/sc/source/core/tool/lookupcache.cxx b/sc/source/core/tool/lookupcache.cxx
index 1fbc1ec..3c82a2a 100644
--- a/sc/source/core/tool/lookupcache.cxx
+++ b/sc/source/core/tool/lookupcache.cxx
@@ -31,6 +31,49 @@
#include "lookupcache.hxx"
#include "document.hxx"
+#include "queryentry.hxx"
+
+ScLookupCache::QueryCriteria::QueryCriteria( const ScQueryEntry& rEntry ) :
+ mfVal(0.0), mbAlloc(false), mbString(false)
+{
+ switch (rEntry.eOp)
+ {
+ case SC_EQUAL :
+ meOp = EQUAL;
+ break;
+ case SC_LESS_EQUAL :
+ meOp = LESS_EQUAL;
+ break;
+ case SC_GREATER_EQUAL :
+ meOp = GREATER_EQUAL;
+ break;
+ default:
+ meOp = UNKNOWN;
+ DBG_ERRORFILE( "ScLookupCache::QueryCriteria not prepared for this ScQueryOp");
+ }
+ if (rEntry.bQueryByString)
+ setString(rEntry.GetQueryString());
+ else
+ setDouble( rEntry.nVal);
+}
+
+ScLookupCache::QueryCriteria::QueryCriteria( const ScLookupCache::QueryCriteria & r ) :
+ mfVal( r.mfVal),
+ mbAlloc( false),
+ mbString( false),
+ meOp( r.meOp)
+{
+ if (r.mbString && r.mpStr)
+ {
+ mpStr = new String( *r.mpStr);
+ mbAlloc = mbString = true;
+ }
+}
+
+ScLookupCache::QueryCriteria::~QueryCriteria()
+{
+ deleteString();
+}
ScLookupCache::ScLookupCache( ScDocument * pDoc, const ScRange & rRange ) :
maRange( rRange),
commit 7b6b60608b8a403e39b2919ba1c186fd64ea1f77
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Sat Nov 5 00:59:59 2011 -0400
Moved ScCompare and ScCompareOptions out of the header.
They are only referenced in interpr1.cxx.
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 8c0b34f..ddfd6d9 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -37,7 +37,6 @@
#include "document.hxx"
#include "scmatrix.hxx"
#include "externalrefmgr.hxx"
-#include "queryentry.hxx"
#include <math.h>
#include <map>
@@ -52,35 +51,8 @@ struct MatrixDoubleOp;
struct ScQueryParam;
struct ScDBQueryParamBase;
-struct ScCompare
-{
- double nVal[2];
- String* pVal[2];
- bool bVal[2];
- bool bEmpty[2];
- ScCompare( String* p1, String* p2 )
- {
- pVal[ 0 ] = p1;
- pVal[ 1 ] = p2;
- bEmpty[0] = false;
- bEmpty[1] = false;
- }
-};
-
-struct ScCompareOptions
-{
- ScQueryEntry aQueryEntry;
- bool bRegEx;
- bool bMatchWholeCell;
- bool bIgnoreCase;
-
- ScCompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg );
-private:
- // Not implemented, prevent usage.
- ScCompareOptions();
- ScCompareOptions( const ScCompareOptions & );
- ScCompareOptions& operator=( const ScCompareOptions & );
-};
+struct ScCompare;
+struct ScCompareOptions;
class ScToken;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index d8c2f5d..d8328bb 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -75,6 +75,7 @@
#include <basic/sbstar.hxx>
#include "doubleref.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#define SC_DOUBLE_MAXVALUE 1.7e307
@@ -90,6 +91,36 @@ using namespace formula;
using ::std::auto_ptr;
using ::rtl::OUString;
+struct ScCompare
+{
+ double nVal[2];
+ String* pVal[2];
+ bool bVal[2];
+ bool bEmpty[2];
+ ScCompare( String* p1, String* p2 )
+ {
+ pVal[ 0 ] = p1;
+ pVal[ 1 ] = p2;
+ bEmpty[0] = false;
+ bEmpty[1] = false;
+ }
+};
+
+struct ScCompareOptions
+{
+ ScQueryEntry aQueryEntry;
+ bool bRegEx;
+ bool bMatchWholeCell;
+ bool bIgnoreCase;
+
+ ScCompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg );
+private:
+ // Not implemented, prevent usage.
+ ScCompareOptions();
+ ScCompareOptions( const ScCompareOptions & );
+ ScCompareOptions& operator=( const ScCompareOptions & );
+};
+
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
commit 3df7746a66714351110cab6b4e4ef79cfe9fc874
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Sat Nov 5 00:56:38 2011 -0400
Moved ScQueryEntry into its own file set.
Because I'll be modifying this struct in the next few days...
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index a1671f8..afa9835 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -198,6 +198,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/tool/printopt \
sc/source/core/tool/prnsave \
sc/source/core/tool/progress \
+ sc/source/core/tool/queryentry \
sc/source/core/tool/queryparam \
sc/source/core/tool/rangelst \
sc/source/core/tool/rangenam \
diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx
index cdf3b42..49b5def 100644
--- a/sc/inc/lookupcache.hxx
+++ b/sc/inc/lookupcache.hxx
@@ -32,6 +32,7 @@
#include "address.hxx"
#include "global.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include "formula/token.hxx"
#include <svl/listener.hxx>
#include <tools/string.hxx>
@@ -40,7 +41,6 @@
class ScDocument;
-
/** Lookup cache for one range used with interpreter functions such as VLOOKUP
and MATCH. Caches query for a specific row and the resulting address looked
up, in case other lookups of the same query in the same row are to be
diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
new file mode 100644
index 0000000..57b39fa
--- /dev/null
+++ b/sc/inc/queryentry.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __SC_QUERYENTRY_HXX__
+#define __SC_QUERYENTRY_HXX__
+
+#include "address.hxx"
+#include "global.hxx"
+
+#include <vector>
+
+namespace utl {
+ class SearchParam;
+ class TextSearch;
+}
+
+struct ScQueryEntry
+{
+ typedef std::vector<rtl::OUString> QueryStringsType;
+
+ bool bDoQuery;
+ bool bQueryByString;
+ bool bQueryByDate;
+ SCCOLROW nField;
+ ScQueryOp eOp;
+ ScQueryConnect eConnect;
+ double nVal;
+ mutable utl::SearchParam* pSearchParam; // if RegExp, not saved
+ mutable utl::TextSearch* pSearchText; // if RegExp, not saved
+
+ ScQueryEntry();
+ ScQueryEntry(const ScQueryEntry& r);
+ ~ScQueryEntry();
+
+ // creates pSearchParam and pSearchText if necessary, always RegExp!
+ utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
+
+ bool IsQueryStringEmpty() const;
+ bool MatchByString(const rtl::OUString& rStr, bool bCaseSens) const;
+ void SwapQueryStrings(QueryStringsType& rStrings);
+ void SortQueryStrings(bool bCaseSens);
+ SC_DLLPUBLIC void SetQueryString(const rtl::OUString& rStr);
+ SC_DLLPUBLIC rtl::OUString GetQueryString() const;
+ void Clear();
+ ScQueryEntry& operator=( const ScQueryEntry& r );
+ bool operator==( const ScQueryEntry& r ) const;
+private:
+ QueryStringsType maQueryStrings;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 6b87397..b971121 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -32,7 +32,7 @@
#include "global.hxx"
#include "scmatrix.hxx"
-#include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
/*
* dialog returns the special field values "empty"/"not empty"
@@ -44,45 +44,7 @@
#define SC_NONEMPTYFIELDS ((double)0x0043)
struct ScDBQueryParamInternal;
-
-namespace utl {
- class SearchParam;
- class TextSearch;
-}
-
-struct ScQueryEntry
-{
- typedef std::vector<rtl::OUString> QueryStringsType;
-
- bool bDoQuery;
- bool bQueryByString;
- bool bQueryByDate;
- SCCOLROW nField;
- ScQueryOp eOp;
- ScQueryConnect eConnect;
- double nVal;
- mutable utl::SearchParam* pSearchParam; // if RegExp, not saved
- mutable utl::TextSearch* pSearchText; // if RegExp, not saved
-
- ScQueryEntry();
- ScQueryEntry(const ScQueryEntry& r);
- ~ScQueryEntry();
-
- // creates pSearchParam and pSearchText if necessary, always RegExp!
- utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
-
- bool IsQueryStringEmpty() const;
- bool MatchByString(const rtl::OUString& rStr, bool bCaseSens) const;
- void SwapQueryStrings(QueryStringsType& rStrings);
- void SortQueryStrings(bool bCaseSens);
- SC_DLLPUBLIC void SetQueryString(const rtl::OUString& rStr);
- SC_DLLPUBLIC rtl::OUString GetQueryString() const;
- void Clear();
- ScQueryEntry& operator=( const ScQueryEntry& r );
- bool operator==( const ScQueryEntry& r ) const;
-private:
- QueryStringsType maQueryStrings;
-};
+struct ScQueryEntry;
struct ScQueryParamBase
{
@@ -101,15 +63,15 @@ struct ScQueryParamBase
SC_DLLPUBLIC SCSIZE GetEntryCount() const;
SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const;
SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n);
- void Resize(SCSIZE nNew);
- SC_DLLPUBLIC void DeleteQuery( SCSIZE nPos );
+ void Resize(size_t nNew);
+ SC_DLLPUBLIC void DeleteQuery(size_t nPos);
void FillInExcelSyntax(String& aCellStr, SCSIZE nIndex);
protected:
ScQueryParamBase();
ScQueryParamBase(const ScQueryParamBase& r);
- std::vector<ScQueryEntry> maEntries;
+ boost::ptr_vector<ScQueryEntry> maEntries;
};
// ============================================================================
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a19e300..a7af452 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -43,6 +43,7 @@
#include "clipparam.hxx"
#include "refundo.hxx"
#include "undoblk.hxx"
+#include "queryentry.hxx"
#include "docsh.hxx"
#include "docfunc.hxx"
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index aba2ac5..dcc0247 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -46,6 +46,7 @@
#include "cellform.hxx"
#include "segmenttree.hxx"
#include "progress.hxx"
+#include "queryentry.hxx"
#include "globstr.hrc"
#include "tools/fract.hxx"
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 0388403..84056a7 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -83,6 +83,7 @@
#include "formulaparserpool.hxx"
#include "clipparam.hxx"
#include "sheetevents.hxx"
+#include "queryentry.hxx"
#include <memory>
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 8d599d2..89d01df 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -36,6 +36,7 @@
#include "dptabsrc.hxx"
#include "dpobject.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include <com/sun/star/i18n/LocaleDataItem.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index f42043a..38bf5c5 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -53,6 +53,8 @@
#include "unonames.hxx"
#include "dpglobal.hxx"
#include "globstr.hrc"
+#include "queryentry.hxx"
+
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sdb/XCompletedExecution.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index ebac350..5f97b2b 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -45,6 +45,7 @@
#include "globstr.hrc"
#include "dpglobal.hxx"
#include "rangenam.hxx"
+#include "queryentry.hxx"
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 8f9852d..133d231 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -32,6 +32,7 @@
#include "dptablecache.hxx"
#include "document.hxx"
#include "cell.hxx"
+#include "queryentry.hxx"
#include "globstr.hrc"
#include <rtl/math.hxx>
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 7a49a13..b52aa14 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -60,6 +60,7 @@
#include "sheetevents.hxx"
#include "globstr.hrc"
#include "segmenttree.hxx"
+#include "queryentry.hxx"
// STATIC DATA -----------------------------------------------------------
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 31ad25a..aeedd41 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -60,6 +60,7 @@
#include "cellform.hxx"
#include "postit.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include "segmenttree.hxx"
#include "subtotalparam.hxx"
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index a693f58..8c0b34f 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -37,6 +37,7 @@
#include "document.hxx"
#include "scmatrix.hxx"
#include "externalrefmgr.hxx"
+#include "queryentry.hxx"
#include <math.h>
#include <map>
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 40bc0d3..abb4c6d 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -38,6 +38,7 @@
#include "rechead.hxx"
#include "document.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include "globstr.hrc"
#include "subtotalparam.hxx"
diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx
index 417e28e..446c3c6 100644
--- a/sc/source/core/tool/doubleref.cxx
+++ b/sc/source/core/tool/doubleref.cxx
@@ -36,6 +36,7 @@
#include "global.hxx"
#include "document.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include "globstr.hrc"
#include <memory>
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
new file mode 100644
index 0000000..c69354b
--- /dev/null
+++ b/sc/source/core/tool/queryentry.cxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "queryentry.hxx"
+
+#include <unotools/textsearch.hxx>
+#include <unotools/transliterationwrapper.hxx>
+#include <unotools/collatorwrapper.hxx>
+
+ScQueryEntry::ScQueryEntry() :
+ bDoQuery(false),
+ bQueryByString(false),
+ bQueryByDate(false),
+ nField(0),
+ eOp(SC_EQUAL),
+ eConnect(SC_AND),
+ nVal(0.0),
+ pSearchParam(NULL),
+ pSearchText(NULL)
+{
+}
+
+ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
+ bDoQuery(r.bDoQuery),
+ bQueryByString(r.bQueryByString),
+ bQueryByDate(r.bQueryByDate),
+ nField(r.nField),
+ eOp(r.eOp),
+ eConnect(r.eConnect),
+ nVal(r.nVal),
+ pSearchParam(NULL),
+ pSearchText(NULL),
+ maQueryStrings(r.maQueryStrings)
+{
+}
+
+ScQueryEntry::~ScQueryEntry()
+{
+ delete pSearchParam;
+ delete pSearchText;
+}
+
+ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
+{
+ bDoQuery = r.bDoQuery;
+ bQueryByString = r.bQueryByString;
+ bQueryByDate = r.bQueryByDate;
+ eOp = r.eOp;
+ eConnect = r.eConnect;
+ nField = r.nField;
+ nVal = r.nVal;
+ maQueryStrings = r.maQueryStrings;
+
+ delete pSearchParam;
+ delete pSearchText;
+ pSearchParam = NULL;
+ pSearchText = NULL;
+
+ return *this;
+}
+
+bool ScQueryEntry::IsQueryStringEmpty() const
+{
+ return maQueryStrings.empty();
+}
+
+namespace {
+
+class CompareString : std::binary_function<rtl::OUString, rtl::OUString, bool>
+{
+ CollatorWrapper* mpCollator;
+public:
+ CompareString(bool bCaseSens) :
+ mpCollator(
+ bCaseSens ? ScGlobal::GetCaseCollator() : ScGlobal::GetCollator())
+ {}
+
+ bool operator() (const rtl::OUString& rL, const rtl::OUString& rR) const
+ {
+ return mpCollator->compareString(rL, rR) < 0;
+ }
+};
+
+}
+
+bool ScQueryEntry::MatchByString(const rtl::OUString& rStr, bool bCaseSens) const
+{
+ QueryStringsType::const_iterator itr =
+ std::lower_bound(
+ maQueryStrings.begin(), maQueryStrings.end(), rStr, CompareString(bCaseSens));
+
+ if (itr == maQueryStrings.end())
+ return false;
+
+ utl::TransliterationWrapper* pTransliteration =
+ bCaseSens ? ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
+ return pTransliteration->isEqual(rStr, *itr);
+}
+
+void ScQueryEntry::SwapQueryStrings(QueryStringsType& rStrings)
+{
+ maQueryStrings.swap(rStrings);
+}
+
+void ScQueryEntry::SortQueryStrings(bool bCaseSens)
+{
+ std::sort(maQueryStrings.begin(), maQueryStrings.end(), CompareString(bCaseSens));
+}
+
+void ScQueryEntry::SetQueryString(const rtl::OUString& rStr)
+{
+ maQueryStrings.clear();
+ if (!rStr.isEmpty())
+ maQueryStrings.push_back(rStr);
+}
+
+rtl::OUString ScQueryEntry::GetQueryString() const
+{
+ return maQueryStrings.empty() ? rtl::OUString() : maQueryStrings[0];
+}
+
+void ScQueryEntry::Clear()
+{
+ bDoQuery = false;
+ bQueryByString = false;
+ bQueryByDate = false;
+ eOp = SC_EQUAL;
+ eConnect = SC_AND;
+ nField = 0;
+ nVal = 0.0;
+ maQueryStrings.clear();
+
+ delete pSearchParam;
+ delete pSearchText;
+ pSearchParam = NULL;
+ pSearchText = NULL;
+}
+
+bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
+{
+ return bDoQuery == r.bDoQuery
+ && bQueryByString == r.bQueryByString
+ && bQueryByDate == r.bQueryByDate
+ && eOp == r.eOp
+ && eConnect == r.eConnect
+ && nField == r.nField
+ && nVal == r.nVal
+ && maQueryStrings == r.maQueryStrings;
+ //! pSearchParam und pSearchText nicht vergleichen
+}
+
+utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
+{
+ if ( !pSearchParam )
+ {
+ rtl::OUString aStr;
+ if (!maQueryStrings.empty())
+ aStr = maQueryStrings[0];
+ pSearchParam = new utl::SearchParam(
+ aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
+ pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
+ }
+ return pSearchText;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 29fdb8b..7536021 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -32,179 +32,18 @@
// INCLUDE ---------------------------------------------------------------
#include "queryparam.hxx"
-#include <unotools/textsearch.hxx>
-#include <unotools/transliterationwrapper.hxx>
-#include <unotools/collatorwrapper.hxx>
-
-using ::std::vector;
-
-namespace {
-
-const SCSIZE MAXQUERY = 8;
-
-}
-
-ScQueryEntry::ScQueryEntry() :
- bDoQuery(false),
- bQueryByString(false),
- bQueryByDate(false),
- nField(0),
- eOp(SC_EQUAL),
- eConnect(SC_AND),
- nVal(0.0),
- pSearchParam(NULL),
- pSearchText(NULL)
-{
-}
-
-ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
- bDoQuery(r.bDoQuery),
- bQueryByString(r.bQueryByString),
- bQueryByDate(r.bQueryByDate),
- nField(r.nField),
- eOp(r.eOp),
- eConnect(r.eConnect),
- nVal(r.nVal),
- pSearchParam(NULL),
- pSearchText(NULL),
- maQueryStrings(r.maQueryStrings)
-{
-}
-
-ScQueryEntry::~ScQueryEntry()
-{
- delete pSearchParam;
- delete pSearchText;
-}
-
-ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
-{
- bDoQuery = r.bDoQuery;
- bQueryByString = r.bQueryByString;
- bQueryByDate = r.bQueryByDate;
- eOp = r.eOp;
- eConnect = r.eConnect;
- nField = r.nField;
- nVal = r.nVal;
- maQueryStrings = r.maQueryStrings;
-
- delete pSearchParam;
- delete pSearchText;
- pSearchParam = NULL;
- pSearchText = NULL;
-
- return *this;
-}
-
-bool ScQueryEntry::IsQueryStringEmpty() const
-{
- return maQueryStrings.empty();
-}
+#include "queryentry.hxx"
namespace {
-class CompareString : std::binary_function<rtl::OUString, rtl::OUString, bool>
-{
- CollatorWrapper* mpCollator;
-public:
- CompareString(bool bCaseSens) :
- mpCollator(
- bCaseSens ? ScGlobal::GetCaseCollator() : ScGlobal::GetCollator())
- {}
-
- bool operator() (const rtl::OUString& rL, const rtl::OUString& rR) const
- {
- return mpCollator->compareString(rL, rR) < 0;
- }
-};
-
-}
-
-bool ScQueryEntry::MatchByString(const rtl::OUString& rStr, bool bCaseSens) const
-{
- QueryStringsType::const_iterator itr =
- std::lower_bound(
- maQueryStrings.begin(), maQueryStrings.end(), rStr, CompareString(bCaseSens));
-
- if (itr == maQueryStrings.end())
- return false;
-
- utl::TransliterationWrapper* pTransliteration =
- bCaseSens ? ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
- return pTransliteration->isEqual(rStr, *itr);
-}
-
-void ScQueryEntry::SwapQueryStrings(QueryStringsType& rStrings)
-{
- maQueryStrings.swap(rStrings);
-}
-
-void ScQueryEntry::SortQueryStrings(bool bCaseSens)
-{
- std::sort(maQueryStrings.begin(), maQueryStrings.end(), CompareString(bCaseSens));
-}
-
-void ScQueryEntry::SetQueryString(const rtl::OUString& rStr)
-{
- maQueryStrings.clear();
- if (!rStr.isEmpty())
- maQueryStrings.push_back(rStr);
-}
-
-rtl::OUString ScQueryEntry::GetQueryString() const
-{
- return maQueryStrings.empty() ? rtl::OUString() : maQueryStrings[0];
-}
+const size_t MAXQUERY = 8;
-void ScQueryEntry::Clear()
-{
- bDoQuery = false;
- bQueryByString = false;
- bQueryByDate = false;
- eOp = SC_EQUAL;
- eConnect = SC_AND;
- nField = 0;
- nVal = 0.0;
- maQueryStrings.clear();
-
- delete pSearchParam;
- delete pSearchText;
- pSearchParam = NULL;
- pSearchText = NULL;
-}
-
-bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
-{
- return bDoQuery == r.bDoQuery
- && bQueryByString == r.bQueryByString
- && bQueryByDate == r.bQueryByDate
- && eOp == r.eOp
- && eConnect == r.eConnect
- && nField == r.nField
- && nVal == r.nVal
- && maQueryStrings == r.maQueryStrings;
- //! pSearchParam und pSearchText nicht vergleichen
-}
-
-utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
-{
- if ( !pSearchParam )
- {
- rtl::OUString aStr;
- if (!maQueryStrings.empty())
- aStr = maQueryStrings[0];
- pSearchParam = new utl::SearchParam(
- aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
- pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
- }
- return pSearchText;
}
-// ============================================================================
-
-ScQueryParamBase::ScQueryParamBase() :
- maEntries(MAXQUERY)
+ScQueryParamBase::ScQueryParamBase()
{
+ for (size_t i = 0; i < MAXQUERY; ++i)
+ maEntries.push_back(new ScQueryEntry);
}
ScQueryParamBase::ScQueryParamBase(const ScQueryParamBase& r) :
@@ -238,36 +77,37 @@ ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n)
return maEntries[n];
}
-void ScQueryParamBase::Resize(SCSIZE nNew)
+void ScQueryParamBase::Resize(size_t nNew)
{
- if ( nNew < MAXQUERY )
+ if (nNew < MAXQUERY)
nNew = MAXQUERY; // never less than MAXQUERY
- vector<ScQueryEntry> aNewEntries(nNew);
- SCSIZE nCopy = ::std::min(maEntries.size(), nNew);
- for (SCSIZE i=0; i<nCopy; i++)
- aNewEntries[i] = maEntries[i];
-
- maEntries.swap(aNewEntries);
+ if (nNew < maEntries.size())
+ {
+ size_t n = maEntries.size() - nNew;
+ for (size_t i = 0; i < n; ++i)
+ maEntries.pop_back();
+ }
+ else if (nNew > maEntries.size())
+ {
+ size_t n = nNew - maEntries.size();
+ for (size_t i = 0; i < n; ++i)
+ maEntries.push_back(new ScQueryEntry);
+ }
}
-void ScQueryParamBase::DeleteQuery( SCSIZE nPos )
+void ScQueryParamBase::DeleteQuery(size_t nPos)
{
if (nPos >= maEntries.size())
return;
- size_t n = maEntries.size();
- vector<ScQueryEntry> aNewEntries;
- aNewEntries.reserve(n);
- for (size_t i = 0; i < n; ++i)
- if (i != nPos)
- aNewEntries.push_back(maEntries[i]);
+ boost::ptr_vector<ScQueryEntry>::iterator itr = maEntries.begin();
+ std::advance(itr, nPos);
+ maEntries.erase(itr);
// Don't forget to append an empty entry to make up for the removed one.
// The size of the entries is not supposed to change.
- aNewEntries.push_back(ScQueryEntry());
-
- maEntries.swap(aNewEntries);
+ maEntries.push_back(new ScQueryEntry);
}
void ScQueryParamBase::FillInExcelSyntax(String& aCellStr, SCSIZE nIndex)
@@ -387,7 +227,9 @@ void ScQueryParam::Clear()
bHasHeader = bCaseSens = bRegExp = bMixedComparison = false;
bInplace = bByRow = bDuplicate = sal_True;
- std::vector<ScQueryEntry> aNewEntries(MAXQUERY);
+ boost::ptr_vector<ScQueryEntry> aNewEntries;
+ for (size_t i = 0; i < MAXQUERY; ++i)
+ aNewEntries.push_back(new ScQueryEntry);
maEntries.swap(aNewEntries);
ClearDestParams();
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 94e74ef..15d68e3 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -105,6 +105,7 @@
#include "stlsheet.hxx"
#include "detfunc.hxx"
#include "macromgr.hxx"
+#include "queryentry.hxx"
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index dfa2fc0..669d851 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -87,6 +87,7 @@
#include "stlpool.hxx"
#include "editutil.hxx"
#include "formula/errorcodes.hxx"
+#include "queryentry.hxx"
#include "excdoc.hxx"
#include "xeescher.hxx"
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 8a70167..39a2896 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -51,6 +51,7 @@
#include "dpdimsave.hxx"
#include "dpgroup.hxx"
#include "rangeutl.hxx"
+#include "queryentry.hxx"
#include <com/sun/star/sheet/DataImportMode.hpp>
#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 71110f8..c00d1bb 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -49,6 +49,7 @@
#include "rangeutl.hxx"
#include "subtotalparam.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include "svx/dataaccessdescriptor.hxx"
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 9f88a20..a9759e5 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -48,6 +48,7 @@
#include "convuno.hxx"
#include "XMLConverter.hxx"
#include "rangeutl.hxx"
+#include "queryentry.hxx"
#include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx>
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index baf9f9c..72df5ef 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -38,6 +38,7 @@
#include "convuno.hxx"
#include "XMLConverter.hxx"
#include "rangeutl.hxx"
+#include "queryentry.hxx"
#include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx>
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index 2b332ff..db730ab 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -45,6 +45,7 @@
#include "document.hxx"
#include "docsh.hxx"
#include "scresid.hxx"
+#include "queryentry.hxx"
#include "foptmgr.hxx"
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
index c776021..a1a25b7 100644
--- a/sc/source/ui/dbgui/pfiltdlg.cxx
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -46,6 +46,7 @@
#include "globalnames.hxx"
#include "dbdata.hxx"
#include "scresid.hxx"
+#include "queryentry.hxx"
#include "sc.hrc"
#include "filter.hrc"
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 6bf85b5..e786a78 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -59,6 +59,7 @@
#include "drwlayer.hxx"
#include "dpshttab.hxx"
#include "hints.hxx"
+#include "queryentry.hxx"
// -----------------------------------------------------------------
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index e6e1d32..5f7db57 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -123,6 +123,7 @@
#include "rangeseq.hxx"
#include "unowids.hxx"
#include "paramisc.hxx"
+#include "queryentry.hxx"
#include "formula/errorcodes.hxx"
#include "unoreflist.hxx"
#include "formula/grammar.hxx"
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 9a6e4a0..5e43474 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -61,6 +61,8 @@
#include "hints.hxx"
#include "attrib.hxx"
#include "dpshttab.hxx"
+#include "queryentry.hxx"
+
#include <comphelper/extract.hxx>
#include <comphelper/servicehelper.hxx>
#include <svx/dataaccessdescriptor.hxx>
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 3373263..d18fa5d 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -177,6 +177,7 @@
#include "patattr.hxx"
#include "olinetab.hxx"
#include "transobj.hxx"
+#include "queryentry.hxx"
#include <comphelper/anytostring.hxx>
#include <global.hxx>
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index e38cf1c..1fb7c5f 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -75,6 +75,8 @@
#include "scabstdlg.hxx"
#include "impex.hxx"
#include "asciiopt.hxx"
+#include "queryentry.hxx"
+
using namespace com::sun::star;
#define IS_AVAILABLE(WhichId,ppItem) \
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 23ac9a9..2498fa3 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -50,6 +50,7 @@
#include "global.hxx"
#include "dbdocfun.hxx"
#include "editable.hxx"
+#include "queryentry.hxx"
//==================================================================
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 1d26fd0..3b03dec 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -80,6 +80,7 @@
#include "unonames.hxx"
#include "cell.hxx"
#include "userlist.hxx"
+#include "queryentry.hxx"
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 8293b6f..aab30fc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -132,6 +132,7 @@
#include "drawview.hxx"
#include "dragdata.hxx"
#include "cliputil.hxx"
+#include "queryentry.hxx"
#include <svx/sdrpagewindow.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 612763c..1db7cd9 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -69,6 +69,7 @@
#include "fillinfo.hxx"
#include "dpcontrol.hxx"
#include "queryparam.hxx"
+#include "queryentry.hxx"
#include "sc.hrc"
#include <vcl/virdev.hxx>
More information about the Libreoffice-commits
mailing list