1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CONNECTIVITY_FILTERMANAGER_HXX
20 #define INCLUDED_CONNECTIVITY_FILTERMANAGER_HXX
22 #include <config_options.h>
23 #include <com/sun/star/uno/Reference.hxx>
25 #include <rtl/ustrbuf.hxx>
27 #include <connectivity/dbtoolsdllapi.hxx>
29 namespace com::sun::star::beans
{ class XPropertySet
; }
38 /** manages the filter of a database component with filter properties
40 The idea is that the filter which a database component actually really uses is composed of several single
41 filter components (which all are conjunctive).
43 First, there is a component which is visible to the clients of the database component itself - if they ask
44 the database component for the Filter property, they will get this public filter.
46 Second, there is an implicit filter, which is (to be) created from the MasterFields and DetailFields
47 property of the database component, if the latter denote columns.<br/>
48 For instance, if there is a link-pair CustomerID->cid, where |CustomerID| is a column of the master
49 database component, and |cid| is a column of the detail database component (the database component we're responsible for), then there will
50 be an implicit filter "cid = :param_cid_link" (or something like this), which is never visible
51 to the clients of the database component, but nevertheless needs to be propagated to the aggregated RowSet.<br/>
52 Actually, this implicit filter is maintained by the FormParameterManager.
54 Potentially, there could be more filter components (for instance, you could imagine database component
55 controls which act as live filter, which could be implemented with a third component), but
56 at the moment there are only these two.
58 class UNLESS_MERGELIBS_MORE(OOO_DLLPUBLIC_DBTOOLS
) FilterManager
61 enum class FilterComponent
63 PublicFilter
, // The filter which is to be published as "Filter" property of the database component.
64 LinkFilter
, // The filter part which is implicitly created for a database component when connecting
65 // master and detail database components via column names.
66 PublicHaving
, // the same, but should go in HAVING clause instead of WHERE clause
71 css::uno::Reference
< css::beans::XPropertySet
> m_xComponentAggregate
;
72 OUString m_aPublicFilterComponent
;
73 OUString m_aPublicHavingComponent
;
74 OUString m_aLinkFilterComponent
;
75 OUString m_aLinkHavingComponent
;
76 bool m_bApplyPublicFilter
;
80 explicit FilterManager();
83 void initialize(const css::uno::Reference
< css::beans::XPropertySet
>& _rxComponentAggregate
);
85 /// makes the object forgetting the references to the database component
88 const OUString
& getFilterComponent( FilterComponent _eWhich
) const;
89 void setFilterComponent( FilterComponent _eWhich
, const OUString
& _rComponent
);
91 bool isApplyPublicFilter( ) const { return m_bApplyPublicFilter
; }
92 void setApplyPublicFilter( bool _bApply
);
95 /** retrieves a filter which is a conjunction of all single filter components
97 OUString
getComposedFilter( ) const;
98 OUString
getComposedHaving( ) const;
100 /** appends one filter component to the statement in our composer
102 static void appendFilterComponent( OUStringBuffer
& io_appendTo
, std::u16string_view i_component
);
104 /// checks whether there is only one (or even no) non-empty filter component
105 bool isThereAtMostOneFilterComponent( OUString
& o_singleComponent
) const;
106 bool isThereAtMostOneHavingComponent( OUString
& o_singleComponent
) const;
113 #endif // CONNECTIVITY_FORMFILTERMANAGER_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */