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