LCOV - code coverage report
Current view: top level - include/connectivity - filtermanager.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : #ifndef INCLUDED_CONNECTIVITY_FILTERMANAGER_HXX
      20             : #define INCLUDED_CONNECTIVITY_FILTERMANAGER_HXX
      21             : 
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : #include <com/sun/star/sdb/XSQLQueryComposer.hpp>
      24             : #include <com/sun/star/sdbc/XConnection.hpp>
      25             : 
      26             : #include <rtl/ustrbuf.hxx>
      27             : 
      28             : #include <vector>
      29             : #include <connectivity/dbtoolsdllapi.hxx>
      30             : 
      31             : 
      32             : namespace dbtools
      33             : {
      34             : 
      35             : 
      36             : 
      37             :     //= FilterManager
      38             : 
      39             :     /** manages the filter of a database component with filter properties
      40             : 
      41             :         The idea is that the filter which a database component actually really uses is composed of several single
      42             :         filter components (which all are conjunctive).
      43             : 
      44             :         First, there is a component which is visible to the clients of the database component itself - if they ask
      45             :         the database component for the Filter property, they will get this public filter.
      46             : 
      47             :         Second, there is an implicit filter, which is (to be) created from the MasterFields and DetailFields
      48             :         property of the database component, if the latter denote columns.<br/>
      49             :         For instance, if there is a link-pair CustomerID->cid, where |CustomerID| is a column of the master
      50             :         database component, and |cid| is a column of the detail database component (the database component we're responsible for), then there will
      51             :         be an implicit filter "cid = :param_cid_link" (or something like this), which is never visible
      52             :         to the clients of the database component, but nevertheless needs to be propagated to the aggregated RowSet.<br/>
      53             :         Actually, this implicit filter is maintained by the FormParameterManager.
      54             : 
      55             :         Potentially, there could be more filter components (for instance, you could imagine database component
      56             :         controls which act as live filter, which could be implemented with a third component), but
      57             :         at the moment there are only these two.
      58             :     */
      59           0 :     class OOO_DLLPUBLIC_DBTOOLS FilterManager
      60             :     {
      61             :     public:
      62             :         enum FilterComponent
      63             :         {
      64             :             fcPublicFilter = 0,     // the filter which is to be published as "Filter" property of the database component
      65             :             fcLinkFilter,           // the filter part which is implicitly created for a database component when connecting
      66             :                                     // master and detail database components via column names
      67             : 
      68             :             FC_COMPONENT_COUNT      // boundary delimiter, not to be used from outside
      69             :         };
      70             : 
      71             :     private:
      72             :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
      73             :                                             m_xComponentAggregate;
      74             :         ::std::vector< OUString >           m_aFilterComponents;
      75             :         bool                                m_bApplyPublicFilter;
      76             : 
      77             :     public:
      78             :         /// ctor
      79             :         explicit FilterManager();
      80             : 
      81             :         /// late ctor
      82             :         void    initialize(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxComponentAggregate );
      83             : 
      84             :         /// makes the object forgetting the references to the database component
      85             :         void    dispose( );
      86             : 
      87             :         const OUString&  getFilterComponent( FilterComponent _eWhich ) const;
      88             :         void                    setFilterComponent( FilterComponent _eWhich, const OUString& _rComponent );
      89             : 
      90           0 :         inline bool     isApplyPublicFilter( ) const { return m_bApplyPublicFilter; }
      91             :                void     setApplyPublicFilter( bool _bApply );
      92             : 
      93             :     private:
      94             :         /** retrieves a filter which is a conjunction of all single filter components
      95             :         */
      96             :         OUString         getComposedFilter( ) const;
      97             : 
      98             :         /** appends one filter component to the statement in our composer
      99             :         */
     100             :         void    appendFilterComponent( OUStringBuffer& io_appendTo, const OUString& i_component ) const;
     101             : 
     102             :         /// checks whether there is only one (or even no) non-empty filter component
     103             :         bool    isThereAtMostOneComponent( OUStringBuffer& o_singleComponent ) const;
     104             : 
     105             :         /// returns the index of the first filter component which should be considered when building the composed filter
     106           0 :         inline  sal_Int32   getFirstApplicableFilterIndex() const
     107             :         {
     108           0 :             return m_bApplyPublicFilter ? fcPublicFilter : fcPublicFilter + 1;
     109             :         }
     110             :     };
     111             : 
     112             : 
     113             : } // namespacefrm
     114             : 
     115             : 
     116             : #endif // CONNECTIVITY_FORMFILTERMANAGER_HXX
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10