1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef __FRAMEWORK_QUERIES_H_ 25*b1cdbd2cSJim Jagielski #define __FRAMEWORK_QUERIES_H_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 28*b1cdbd2cSJim Jagielski // own includes 29*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski #include <general.h> 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 34*b1cdbd2cSJim Jagielski // other includes 35*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 36*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/Sequence.hxx> 37*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx> 38*b1cdbd2cSJim Jagielski #include <rtl/ustrbuf.hxx> 39*b1cdbd2cSJim Jagielski 40*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 41*b1cdbd2cSJim Jagielski // namespace 42*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 43*b1cdbd2cSJim Jagielski 44*b1cdbd2cSJim Jagielski namespace framework{ 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 47*b1cdbd2cSJim Jagielski // const 48*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//** 51*b1cdbd2cSJim Jagielski @short These values describe our supported queries for type, filter ... properties. 52*b1cdbd2cSJim Jagielski They are used by our FilterFactory or ouer TypeDetection to return 53*b1cdbd2cSJim Jagielski subsets of our cached configuration. 54*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/ 55*b1cdbd2cSJim Jagielski #define BASE_QUERY_ALL DECLARE_ASCII("_query_all" ) 56*b1cdbd2cSJim Jagielski #define BASE_QUERY_WRITER DECLARE_ASCII("_query_Writer" ) 57*b1cdbd2cSJim Jagielski #define BASE_QUERY_WEB DECLARE_ASCII("_query_web" ) 58*b1cdbd2cSJim Jagielski #define BASE_QUERY_GLOBAL DECLARE_ASCII("_query_global" ) 59*b1cdbd2cSJim Jagielski #define BASE_QUERY_CHART DECLARE_ASCII("_query_chart" ) 60*b1cdbd2cSJim Jagielski #define BASE_QUERY_CALC DECLARE_ASCII("_query_calc" ) 61*b1cdbd2cSJim Jagielski #define BASE_QUERY_IMPRESS DECLARE_ASCII("_query_impress" ) 62*b1cdbd2cSJim Jagielski #define BASE_QUERY_DRAW DECLARE_ASCII("_query_draw" ) 63*b1cdbd2cSJim Jagielski #define BASE_QUERY_MATH DECLARE_ASCII("_query_math" ) 64*b1cdbd2cSJim Jagielski #define BASE_QUERY_GRAPHICS DECLARE_ASCII("_query_graphics") 65*b1cdbd2cSJim Jagielski 66*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//** 67*b1cdbd2cSJim Jagielski @short These parameters can be used in combination with BASE_QUERY_... defines to 68*b1cdbd2cSJim Jagielski specialize it. 69*b1cdbd2cSJim Jagielski use follow syntax to do so: "<query>[:<param>[=<value>]]" 70*b1cdbd2cSJim Jagielski e.g.: "_query_writer:default_first:use_order:sort_prop=uiname" 71*b1cdbd2cSJim Jagielski 72*b1cdbd2cSJim Jagielski argument description default 73*b1cdbd2cSJim Jagielski ----------------------------------------------------------------------------------------------- 74*b1cdbd2cSJim Jagielski iflags=<mask> include filters by given mask 0 75*b1cdbd2cSJim Jagielski eflags=<mask> exclude filters by given mask 0 76*b1cdbd2cSJim Jagielski sort_prop=<[name,uiname]> sort by internal name or uiname name 77*b1cdbd2cSJim Jagielski descending sort descending false 78*b1cdbd2cSJim Jagielski use_order use order flag of filters for sorting false 79*b1cdbd2cSJim Jagielski default_first set default filter on top of return list false 80*b1cdbd2cSJim Jagielski case_sensitive compare "sort_prop" case sensitive false 81*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/ 82*b1cdbd2cSJim Jagielski #define SEPERATOR_QUERYPARAM ((sal_Unicode)':') 83*b1cdbd2cSJim Jagielski #define SEPERATOR_QUERYPARAMVALUE ((sal_Unicode)'=') 84*b1cdbd2cSJim Jagielski 85*b1cdbd2cSJim Jagielski #define QUERYPARAM_IFLAGS DECLARE_ASCII("iflags" ) 86*b1cdbd2cSJim Jagielski #define QUERYPARAM_EFLAGS DECLARE_ASCII("eflags" ) 87*b1cdbd2cSJim Jagielski #define QUERYPARAM_SORT_PROP DECLARE_ASCII("sort_prop" ) 88*b1cdbd2cSJim Jagielski 89*b1cdbd2cSJim Jagielski #define QUERYPARAM_DESCENDING DECLARE_ASCII("descending" ) 90*b1cdbd2cSJim Jagielski #define QUERYPARAM_USE_ORDER DECLARE_ASCII("use_order" ) 91*b1cdbd2cSJim Jagielski #define QUERYPARAM_DEFAULT_FIRST DECLARE_ASCII("default_first" ) 92*b1cdbd2cSJim Jagielski #define QUERYPARAM_CASE_SENSITIVE DECLARE_ASCII("case_sensitive" ) 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski #define QUERYPARAMVALUE_SORT_PROP_NAME DECLARE_ASCII("name" ) 95*b1cdbd2cSJim Jagielski #define QUERYPARAMVALUE_SORT_PROP_UINAME DECLARE_ASCII("uiname" ) 96*b1cdbd2cSJim Jagielski 97*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//** 98*b1cdbd2cSJim Jagielski @short Helper class to support easy building of a query statements. 99*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/ 100*b1cdbd2cSJim Jagielski class QueryBuilder 101*b1cdbd2cSJim Jagielski { 102*b1cdbd2cSJim Jagielski public: 103*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 104*b1cdbd2cSJim Jagielski // start with empty query 105*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- QueryBuilder()106*b1cdbd2cSJim Jagielski QueryBuilder() 107*b1cdbd2cSJim Jagielski { 108*b1cdbd2cSJim Jagielski resetAll(); 109*b1cdbd2cSJim Jagielski } 110*b1cdbd2cSJim Jagielski 111*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 112*b1cdbd2cSJim Jagielski // returns full query as copy of internal set values 113*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- getQuery()114*b1cdbd2cSJim Jagielski ::rtl::OUString getQuery() 115*b1cdbd2cSJim Jagielski { 116*b1cdbd2cSJim Jagielski ::rtl::OUStringBuffer sCopy( m_sParams ); 117*b1cdbd2cSJim Jagielski sCopy.insert( 0, m_sBase ); 118*b1cdbd2cSJim Jagielski return sCopy.makeStringAndClear(); 119*b1cdbd2cSJim Jagielski } 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 122*b1cdbd2cSJim Jagielski // set new or change existing base query part 123*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- setBase(const::rtl::OUString & sBase)124*b1cdbd2cSJim Jagielski void setBase( const ::rtl::OUString& sBase ) 125*b1cdbd2cSJim Jagielski { 126*b1cdbd2cSJim Jagielski m_sBase = sBase; 127*b1cdbd2cSJim Jagielski } 128*b1cdbd2cSJim Jagielski 129*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 130*b1cdbd2cSJim Jagielski // add new parameter (with optional value) to param list 131*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- addParam(const::rtl::OUString & sParam,const::rtl::OUString & sValue=::rtl::OUString ())132*b1cdbd2cSJim Jagielski void addParam( const ::rtl::OUString& sParam, const ::rtl::OUString& sValue = ::rtl::OUString() ) 133*b1cdbd2cSJim Jagielski { 134*b1cdbd2cSJim Jagielski m_sParams.append( SEPERATOR_QUERYPARAM ); 135*b1cdbd2cSJim Jagielski m_sParams.append( sParam ); 136*b1cdbd2cSJim Jagielski if( sValue.getLength() > 0 ) 137*b1cdbd2cSJim Jagielski { 138*b1cdbd2cSJim Jagielski m_sParams.append( SEPERATOR_QUERYPARAMVALUE ); 139*b1cdbd2cSJim Jagielski m_sParams.append( sValue ); 140*b1cdbd2cSJim Jagielski } 141*b1cdbd2cSJim Jagielski } 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 144*b1cdbd2cSJim Jagielski // forget all setted params and start with empty ones 145*b1cdbd2cSJim Jagielski // Attention: base of query isn't changed! 146*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- resetParams()147*b1cdbd2cSJim Jagielski void resetParams() 148*b1cdbd2cSJim Jagielski { 149*b1cdbd2cSJim Jagielski m_sParams.makeStringAndClear(); 150*b1cdbd2cSJim Jagielski m_sParams.ensureCapacity( 256 ); 151*b1cdbd2cSJim Jagielski } 152*b1cdbd2cSJim Jagielski 153*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 154*b1cdbd2cSJim Jagielski // start with new empty query 155*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- resetAll()156*b1cdbd2cSJim Jagielski void resetAll() 157*b1cdbd2cSJim Jagielski { 158*b1cdbd2cSJim Jagielski m_sBase = ::rtl::OUString(); 159*b1cdbd2cSJim Jagielski resetParams(); 160*b1cdbd2cSJim Jagielski } 161*b1cdbd2cSJim Jagielski 162*b1cdbd2cSJim Jagielski private: 163*b1cdbd2cSJim Jagielski ::rtl::OUString m_sBase ; 164*b1cdbd2cSJim Jagielski ::rtl::OUStringBuffer m_sParams ; 165*b1cdbd2cSJim Jagielski 166*b1cdbd2cSJim Jagielski }; // class QueryBuilder 167*b1cdbd2cSJim Jagielski 168*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//** 169*b1cdbd2cSJim Jagielski @short Helper class to analyze queries and split into his different parts (base, params and values). 170*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/ 171*b1cdbd2cSJim Jagielski class QueryAnalyzer 172*b1cdbd2cSJim Jagielski { 173*b1cdbd2cSJim Jagielski public: 174*b1cdbd2cSJim Jagielski 175*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 176*b1cdbd2cSJim Jagielski // it's will not perform to compare strings as query type ... 177*b1cdbd2cSJim Jagielski // so we convert it into these enum values. 178*b1cdbd2cSJim Jagielski // default = E_ALL! 179*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 180*b1cdbd2cSJim Jagielski enum EQuery 181*b1cdbd2cSJim Jagielski { 182*b1cdbd2cSJim Jagielski E_ALL , 183*b1cdbd2cSJim Jagielski E_WRITER , 184*b1cdbd2cSJim Jagielski E_WEB , 185*b1cdbd2cSJim Jagielski E_GLOBAL , 186*b1cdbd2cSJim Jagielski E_CHART , 187*b1cdbd2cSJim Jagielski E_CALC , 188*b1cdbd2cSJim Jagielski E_IMPRESS , 189*b1cdbd2cSJim Jagielski E_DRAW , 190*b1cdbd2cSJim Jagielski E_MATH , 191*b1cdbd2cSJim Jagielski E_GRAPHICS 192*b1cdbd2cSJim Jagielski }; 193*b1cdbd2cSJim Jagielski 194*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 195*b1cdbd2cSJim Jagielski // these are valid values for param "sort_prop". 196*b1cdbd2cSJim Jagielski // other ones are not supported! 197*b1cdbd2cSJim Jagielski // default = E_NAME 198*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 199*b1cdbd2cSJim Jagielski enum ESortProp 200*b1cdbd2cSJim Jagielski { 201*b1cdbd2cSJim Jagielski E_NAME , 202*b1cdbd2cSJim Jagielski E_UINAME 203*b1cdbd2cSJim Jagielski }; 204*b1cdbd2cSJim Jagielski 205*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 206*b1cdbd2cSJim Jagielski // analyze given query and split it into his different parts; <base>:<param1>:<param2=value>... 207*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- QueryAnalyzer(const::rtl::OUString & sQuery)208*b1cdbd2cSJim Jagielski QueryAnalyzer( const ::rtl::OUString& sQuery ) 209*b1cdbd2cSJim Jagielski // Don't forget to set default values for non given params! 210*b1cdbd2cSJim Jagielski : m_eQuery ( E_ALL ) // return ALL filter ... 211*b1cdbd2cSJim Jagielski , m_nIFlags ( 0 ) // which has set ANY flag ... (we remove all entries which match with these mask .. => 0!) 212*b1cdbd2cSJim Jagielski , m_nEFlags ( 0 ) // (only used, if nIFlags==0 and himself!=0!) 213*b1cdbd2cSJim Jagielski , m_eSortProp ( E_NAME ) // sort it by internal name ... 214*b1cdbd2cSJim Jagielski , m_bDescending ( sal_False ) // in ascending order ... 215*b1cdbd2cSJim Jagielski , m_bCaseSensitive( sal_False ) // ignore case ... 216*b1cdbd2cSJim Jagielski , m_bUseOrder ( sal_False ) // don't use order flag ... 217*b1cdbd2cSJim Jagielski , m_bDefaultFirst ( sal_False ) // and don't handle default entries in special case! 218*b1cdbd2cSJim Jagielski { 219*b1cdbd2cSJim Jagielski // Translate old query format to new one first! 220*b1cdbd2cSJim Jagielski ::rtl::OUString sNewQuery( sQuery ); 221*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_textdocument_withdefault") ) 222*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_writer:default_first:use_order:sort_prop=uiname"); 223*b1cdbd2cSJim Jagielski else 224*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_webdocument_withdefault") ) 225*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_web:default_first:use_order:sort_prop=uiname"); 226*b1cdbd2cSJim Jagielski else 227*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_globaldocument_withdefault") ) 228*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_global:default_first:use_order:sort_prop=uiname"); 229*b1cdbd2cSJim Jagielski else 230*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_chartdocument_withdefault") ) 231*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_chart:default_first:use_order:sort_prop=uiname"); 232*b1cdbd2cSJim Jagielski else 233*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_spreadsheetdocument_withdefault") ) 234*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_calc:default_first:use_order:sort_prop=uiname"); 235*b1cdbd2cSJim Jagielski else 236*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_presentationdocument_withdefault") ) 237*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_impress:default_first:use_order:sort_prop=uiname"); 238*b1cdbd2cSJim Jagielski else 239*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_drawingdocument_withdefault") ) 240*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_draw:default_first:use_order:sort_prop=uiname"); 241*b1cdbd2cSJim Jagielski else 242*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_formulaproperties_withdefault") ) 243*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_math:default_first:use_order:sort_prop=uiname"); 244*b1cdbd2cSJim Jagielski else 245*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_textdocument") ) 246*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_writer:use_order:sort_prop=uiname"); 247*b1cdbd2cSJim Jagielski else 248*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_webdocument") ) 249*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_web:use_order:sort_prop=uiname"); 250*b1cdbd2cSJim Jagielski else 251*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_globaldocument") ) 252*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_global:use_order:sort_prop=uiname"); 253*b1cdbd2cSJim Jagielski else 254*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_chartdocument") ) 255*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_chart:use_order:sort_prop=uiname"); 256*b1cdbd2cSJim Jagielski else 257*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_spreadsheetdocument") ) 258*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_calc:use_order:sort_prop=uiname"); 259*b1cdbd2cSJim Jagielski else 260*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_presentationdocument") ) 261*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_impress:use_order:sort_prop=uiname"); 262*b1cdbd2cSJim Jagielski else 263*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_drawingdocument") ) 264*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_draw:use_order:sort_prop=uiname"); 265*b1cdbd2cSJim Jagielski else 266*b1cdbd2cSJim Jagielski if( sQuery == DECLARE_ASCII("_filterquery_formulaproperties") ) 267*b1cdbd2cSJim Jagielski sNewQuery=DECLARE_ASCII("_query_math:use_order:sort_prop=uiname"); 268*b1cdbd2cSJim Jagielski 269*b1cdbd2cSJim Jagielski // Analyze query ... 270*b1cdbd2cSJim Jagielski // Try to find base of it and safe it for faster access as enum value! 271*b1cdbd2cSJim Jagielski sal_Int32 nToken = 0; 272*b1cdbd2cSJim Jagielski ::rtl::OUString sParam ; 273*b1cdbd2cSJim Jagielski ::rtl::OUString sBase = sNewQuery.getToken( 0, SEPERATOR_QUERYPARAM, nToken ); 274*b1cdbd2cSJim Jagielski 275*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_ALL ) == sal_True ) m_eQuery = E_ALL ; else 276*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_WRITER ) == sal_True ) m_eQuery = E_WRITER ; else 277*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_WEB ) == sal_True ) m_eQuery = E_WEB ; else 278*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_GLOBAL ) == sal_True ) m_eQuery = E_GLOBAL ; else 279*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_CHART ) == sal_True ) m_eQuery = E_CHART ; else 280*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_CALC ) == sal_True ) m_eQuery = E_CALC ; else 281*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_IMPRESS ) == sal_True ) m_eQuery = E_IMPRESS ; else 282*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_DRAW ) == sal_True ) m_eQuery = E_DRAW ; else 283*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_MATH ) == sal_True ) m_eQuery = E_MATH ; else 284*b1cdbd2cSJim Jagielski if( sBase.equalsIgnoreAsciiCase( BASE_QUERY_GRAPHICS ) == sal_True ) m_eQuery = E_GRAPHICS ; 285*b1cdbd2cSJim Jagielski 286*b1cdbd2cSJim Jagielski // Try to get additional parameters ... 287*b1cdbd2cSJim Jagielski while( nToken >= 0 ) 288*b1cdbd2cSJim Jagielski { 289*b1cdbd2cSJim Jagielski sParam = sNewQuery.getToken( 0, SEPERATOR_QUERYPARAM, nToken ); 290*b1cdbd2cSJim Jagielski // "default_first" 291*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_DEFAULT_FIRST, QUERYPARAM_DEFAULT_FIRST.getLength() ) == 0 ) 292*b1cdbd2cSJim Jagielski { 293*b1cdbd2cSJim Jagielski m_bDefaultFirst = sal_True; 294*b1cdbd2cSJim Jagielski } 295*b1cdbd2cSJim Jagielski else 296*b1cdbd2cSJim Jagielski // "use_order" 297*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_USE_ORDER, QUERYPARAM_USE_ORDER.getLength() ) == 0 ) 298*b1cdbd2cSJim Jagielski { 299*b1cdbd2cSJim Jagielski m_bUseOrder = sal_True; 300*b1cdbd2cSJim Jagielski } 301*b1cdbd2cSJim Jagielski else 302*b1cdbd2cSJim Jagielski // "descending" 303*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_DESCENDING, QUERYPARAM_DESCENDING.getLength() ) == 0 ) 304*b1cdbd2cSJim Jagielski { 305*b1cdbd2cSJim Jagielski m_bDescending = sal_True; 306*b1cdbd2cSJim Jagielski } 307*b1cdbd2cSJim Jagielski else 308*b1cdbd2cSJim Jagielski // "case_sensitive" 309*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_CASE_SENSITIVE, QUERYPARAM_CASE_SENSITIVE.getLength() ) == 0 ) 310*b1cdbd2cSJim Jagielski { 311*b1cdbd2cSJim Jagielski m_bCaseSensitive = sal_True; 312*b1cdbd2cSJim Jagielski } 313*b1cdbd2cSJim Jagielski else 314*b1cdbd2cSJim Jagielski // "iflags=<mask>" 315*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_IFLAGS, QUERYPARAM_IFLAGS.getLength() ) == 0 ) 316*b1cdbd2cSJim Jagielski { 317*b1cdbd2cSJim Jagielski sal_Int32 nSubToken = 0; 318*b1cdbd2cSJim Jagielski ::rtl::OUString sParamName = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken ); 319*b1cdbd2cSJim Jagielski if( nSubToken > 0 ) 320*b1cdbd2cSJim Jagielski { 321*b1cdbd2cSJim Jagielski m_nIFlags = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken ).toInt32(); 322*b1cdbd2cSJim Jagielski } 323*b1cdbd2cSJim Jagielski } 324*b1cdbd2cSJim Jagielski else 325*b1cdbd2cSJim Jagielski // "eflags=<mask>" 326*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_EFLAGS, QUERYPARAM_EFLAGS.getLength() ) == 0 ) 327*b1cdbd2cSJim Jagielski { 328*b1cdbd2cSJim Jagielski sal_Int32 nSubToken = 0; 329*b1cdbd2cSJim Jagielski ::rtl::OUString sParamName = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken ); 330*b1cdbd2cSJim Jagielski if( nSubToken > 0 ) 331*b1cdbd2cSJim Jagielski { 332*b1cdbd2cSJim Jagielski m_nEFlags = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken ).toInt32(); 333*b1cdbd2cSJim Jagielski } 334*b1cdbd2cSJim Jagielski } 335*b1cdbd2cSJim Jagielski else 336*b1cdbd2cSJim Jagielski // "sort_prop=<[name,uiname]>" 337*b1cdbd2cSJim Jagielski if( sParam.compareTo( QUERYPARAM_SORT_PROP, QUERYPARAM_SORT_PROP.getLength() ) == 0 ) 338*b1cdbd2cSJim Jagielski { 339*b1cdbd2cSJim Jagielski sal_Int32 nSubToken = 0; 340*b1cdbd2cSJim Jagielski ::rtl::OUString sParamName = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken ); 341*b1cdbd2cSJim Jagielski if( nSubToken > 0 ) 342*b1cdbd2cSJim Jagielski { 343*b1cdbd2cSJim Jagielski ::rtl::OUString sParamValue = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken ); 344*b1cdbd2cSJim Jagielski if( sParamValue.compareTo( QUERYPARAMVALUE_SORT_PROP_NAME, QUERYPARAMVALUE_SORT_PROP_NAME.getLength() ) == 0 ) 345*b1cdbd2cSJim Jagielski m_eSortProp = E_NAME; 346*b1cdbd2cSJim Jagielski else 347*b1cdbd2cSJim Jagielski if( sParamValue.compareTo( QUERYPARAMVALUE_SORT_PROP_UINAME, QUERYPARAMVALUE_SORT_PROP_UINAME.getLength() ) == 0 ) 348*b1cdbd2cSJim Jagielski m_eSortProp = E_UINAME; 349*b1cdbd2cSJim Jagielski } 350*b1cdbd2cSJim Jagielski } 351*b1cdbd2cSJim Jagielski } 352*b1cdbd2cSJim Jagielski } 353*b1cdbd2cSJim Jagielski 354*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 355*b1cdbd2cSJim Jagielski // return type of query. User can decide then, which action should be started. 356*b1cdbd2cSJim Jagielski // For faster work we converted query string into corresponding enum value! 357*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- getQueryType() const358*b1cdbd2cSJim Jagielski EQuery getQueryType() const { return m_eQuery; } 359*b1cdbd2cSJim Jagielski 360*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 361*b1cdbd2cSJim Jagielski // access to additional parameter values 362*b1cdbd2cSJim Jagielski // Methods return default of realy set values! 363*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- getIFlags() const364*b1cdbd2cSJim Jagielski sal_uInt32 getIFlags () const { return m_nIFlags ; } getEFlags() const365*b1cdbd2cSJim Jagielski sal_uInt32 getEFlags () const { return m_nEFlags ; } getSortProp() const366*b1cdbd2cSJim Jagielski ESortProp getSortProp () const { return m_eSortProp ; } getDescending() const367*b1cdbd2cSJim Jagielski sal_Bool getDescending () const { return m_bDescending ; } getCaseSensitive() const368*b1cdbd2cSJim Jagielski sal_Bool getCaseSensitive() const { return m_bCaseSensitive; } getUseOrder() const369*b1cdbd2cSJim Jagielski sal_Bool getUseOrder () const { return m_bUseOrder ; } getDefaultFirst() const370*b1cdbd2cSJim Jagielski sal_Bool getDefaultFirst () const { return m_bDefaultFirst ; } 371*b1cdbd2cSJim Jagielski 372*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 373*b1cdbd2cSJim Jagielski // this method checks if given string match any supported query. 374*b1cdbd2cSJim Jagielski // (ignore additional parameters!) 375*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- isQuery(const::rtl::OUString & sQuery)376*b1cdbd2cSJim Jagielski static sal_Bool isQuery( const ::rtl::OUString& sQuery ) 377*b1cdbd2cSJim Jagielski { 378*b1cdbd2cSJim Jagielski return( 379*b1cdbd2cSJim Jagielski ( sQuery.compareToAscii( "_query_" , 7 ) == 0 ) || // new style 380*b1cdbd2cSJim Jagielski ( sQuery.compareToAscii( "_filterquery_", 13 ) == 0 ) // old style! 381*b1cdbd2cSJim Jagielski ); 382*b1cdbd2cSJim Jagielski } 383*b1cdbd2cSJim Jagielski 384*b1cdbd2cSJim Jagielski private: 385*b1cdbd2cSJim Jagielski EQuery m_eQuery ; 386*b1cdbd2cSJim Jagielski sal_uInt32 m_nIFlags ; 387*b1cdbd2cSJim Jagielski sal_uInt32 m_nEFlags ; 388*b1cdbd2cSJim Jagielski ESortProp m_eSortProp ; 389*b1cdbd2cSJim Jagielski sal_Bool m_bDescending ; 390*b1cdbd2cSJim Jagielski sal_Bool m_bCaseSensitive ; 391*b1cdbd2cSJim Jagielski sal_Bool m_bUseOrder ; 392*b1cdbd2cSJim Jagielski sal_Bool m_bDefaultFirst ; 393*b1cdbd2cSJim Jagielski 394*b1cdbd2cSJim Jagielski }; // class QueryAnalyzer 395*b1cdbd2cSJim Jagielski 396*b1cdbd2cSJim Jagielski } // namespace framework 397*b1cdbd2cSJim Jagielski 398*b1cdbd2cSJim Jagielski #endif // #ifndef __FRAMEWORK_QUERIES_H_ 399