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