1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: requestoptions.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_MISC_REQUESTOPTIONS_HXX_
32 #define CONFIGMGR_MISC_REQUESTOPTIONS_HXX_
34 #include <com/sun/star/lang/Locale.hpp>
35 #include <rtl/ustring.hxx>
39 // ---------------------------------------------------------------------------
42 Options which can be used to modify a request for data
47 /// Default constructor. Sets options to use defaults.
51 , m_bEnableAsync(true)
55 /// @returns <TRUE/>, if data can be written asynchronously
56 bool isAsyncEnabled() const { return m_bEnableAsync
; }
57 /// @returns <TRUE/>, if data is reloaded into cache
58 bool isRefreshEnabled() const { return m_bReload
; }
60 <TRUE/>, if a locale is specified, <BR/>
61 <FALSE/>, if the default locale should be used
63 bool hasLocale() const { return m_sLocale
.Language
.getLength() != 0; }
64 /// @returns the locale to get data for
65 bool isForAllLocales() const;
66 /// @returns the locale to get data for - compatibilty version
67 rtl::OUString
getLocale() const { return getIsoLocale(); }
68 /// @returns the locale to get data for
69 rtl::OUString
getIsoLocale() const;
70 /// @returns the locale to get data for
71 com::sun::star::lang::Locale
const & getUnoLocale() const { return m_sLocale
; }
74 <TRUE/>, if an entity is specified, <BR/>
75 <FALSE/>, if data of the session user is requested
77 bool hasEntity() const { return m_sEntity
.getLength() != 0; }
78 /// @returns the entity to get data for
79 rtl::OUString
getEntity() const { return m_sEntity
; }
81 /// sets the entity to get data for to the given entity
82 void setEntity(rtl::OUString
const & _sEntity
) { m_sEntity
= _sEntity
; }
83 /// resets the entity to get data for to be the session user
84 void clearEntity() { m_sEntity
= rtl::OUString(); }
86 /// sets the locale so data is gotten for all locales
88 /// sets the locale to get data for to the given locale
89 void setLocale(com::sun::star::lang::Locale
const & _aLocale
) { m_sLocale
= _aLocale
; }
90 /// sets the locale to get data for to the given locale
91 void setIsoLocale(rtl::OUString
const & _sLocale
);
92 /// sets a fallback locale, if no locale is set yet
93 void ensureLocaleSet();
95 /// marks asyncronous access a enabled or disabled
96 void enableAsync(bool _bEnable
= true) { m_bEnableAsync
= _bEnable
; }
97 /// enforce a refresh to cache
98 void forceRefresh(bool _bEnable
= true) { m_bReload
= _bEnable
; }
99 // comparison/container helpers
100 /// function that defines a weak strict ordering on RequestOptions
101 friend sal_Int32
compareRequestOptions(RequestOptions
const& lhs
, RequestOptions
const& rhs
);
103 com::sun::star::lang::Locale m_sLocale
; /// locale to fetch data for
104 rtl::OUString m_sEntity
; /// user/group/role to fetch data for
105 bool m_bEnableAsync
; /// true, if data may be
106 bool m_bReload
; /// reload into cache from backend
109 // ---------------------------------------------------------------------------
110 struct lessRequestOptions
112 bool operator()(RequestOptions
const & lhs
, RequestOptions
const & rhs
) const
113 { return compareRequestOptions(lhs
,rhs
) < 0; }
115 // ---------------------------------------------------------------------------
116 struct equalRequestOptions
118 bool operator()(RequestOptions
const & lhs
, RequestOptions
const & rhs
) const
119 { return compareRequestOptions(lhs
,rhs
) == 0; }
121 // ---------------------------------------------------------------------------