LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - SelectionBrowseBox.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 3 0.0 %
Date: 2015-06-13 12:38:46 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_DBACCESS_SOURCE_UI_QUERYDESIGN_SELECTIONBROWSEBOX_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_SELECTIONBROWSEBOX_HXX
      21             : 
      22             : #include <svtools/editbrowsebox.hxx>
      23             : #include "TableFieldDescription.hxx"
      24             : #include "JoinExchange.hxx"
      25             : #include "QEnumTypes.hxx"
      26             : #include <com/sun/star/util/XNumberFormatter.hpp>
      27             : #include <svtools/transfer.hxx>
      28             : 
      29             : namespace connectivity
      30             : {
      31             :     class OSQLParseNode;
      32             : }
      33             : 
      34             : namespace dbaui
      35             : {
      36             : #define BROW_FIELD_ROW          0
      37             : #define BROW_COLUMNALIAS_ROW    1
      38             : #define BROW_TABLE_ROW          2
      39             : #define BROW_ORDER_ROW          3
      40             : #define BROW_VIS_ROW            4
      41             : #define BROW_FUNCTION_ROW       5
      42             : #define BROW_CRIT1_ROW          6
      43             : #define BROW_CRIT2_ROW          7
      44             : #define BROW_CRIT3_ROW          8
      45             : #define BROW_CRIT4_ROW          9
      46             : #define BROW_CRIT5_ROW          10
      47             : #define BROW_CRIT6_ROW          11
      48             : #define BROW_ROW_CNT            12
      49             : 
      50             :     class OQueryDesignView;
      51             :     class OSelectionBrowseBox : public ::svt::EditBrowseBox
      52             :     {
      53             :         friend class OQueryDesignView;
      54             :         ::std::vector<bool>                 m_bVisibleRow;              // at pos we find the RowId
      55             :         Timer                               m_timerInvalidate;
      56             : 
      57             :         long                                m_nSeekRow;
      58             :         BrowserMode                         m_nMode;                    // remember the BrowseModes
      59             :         VclPtr<Edit>                               m_pTextCell;
      60             :         VclPtr< ::svt::CheckBoxControl>             m_pVisibleCell;
      61             :         VclPtr< ::svt::ComboBoxControl>             m_pFieldCell;
      62             :         VclPtr< ::svt::ListBoxControl>              m_pFunctionCell;
      63             :         VclPtr< ::svt::ListBoxControl>              m_pTableCell;
      64             :         VclPtr< ::svt::ListBoxControl>              m_pOrderCell;
      65             : 
      66             :         OTableFieldDescRef                  m_pEmptyEntry;              // default entry in the list may reference more than once
      67             : 
      68             :         sal_Int32                           m_nMaxColumns;              // maximum number of columns in a Select-Statement
      69             : 
      70             :         OUString                            m_aFunctionStrings;
      71             :         sal_uInt16                          m_nVisibleCount;            // maximum number of visible rows
      72             :         sal_uInt32                          m_nLastSortColumn;          // index of last (highest) sort column
      73             :         bool                            m_bOrderByUnRelated;
      74             :         bool                            m_bGroupByUnRelated;
      75             :         bool                            m_bStopTimer;
      76             :         bool                            m_bWasEditing;
      77             :         bool                            m_bDisableErrorBox;
      78             :         bool                            m_bInUndoMode;
      79             : 
      80             :         DECL_LINK_TYPED(OnInvalidateTimer, Timer*, void);
      81             :     public:                         OSelectionBrowseBox( vcl::Window* pParent );
      82             :                                     virtual ~OSelectionBrowseBox();
      83             :         virtual void                dispose() SAL_OVERRIDE;
      84             : 
      85             :         void                        initialize();
      86             :         OTableFieldDescRef          InsertField( const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPosition = BROWSER_INVALIDID, bool bVis=true, bool bActivate=true );
      87             :         OTableFieldDescRef          InsertField( const OTableFieldDescRef& rInfo, sal_uInt16 _nColumnPosition = BROWSER_INVALIDID, bool bVis=true, bool bActivate=true );
      88             :         void                        InsertColumn( OTableFieldDescRef pEntry, sal_uInt16& _nColumnPosition );
      89             :         void                        RemoveColumn( sal_uInt16 _nColumnId );
      90             :         void                        DeleteFields( const OUString& rAliasName );
      91             : 
      92             :         bool                        HasFieldByAliasName(const OUString& rFieldName, OTableFieldDescRef& rInfo) const;
      93             : 
      94             :         // AddGroupBy:: inserts a field with function == grouping. If the fields already exists and uses an aggregate function,
      95             :         // the flag is not set
      96             :         void                        AddGroupBy( const OTableFieldDescRef& rInfo,sal_uInt32 _nCurrentPos);
      97             :         void                        AddCondition( const OTableFieldDescRef& rInfo,
      98             :                                                   const OUString& rValue,
      99             :                                                   const sal_uInt16 nLevel,
     100             :                                                   bool _bAddOrOnOneLine  );
     101             :         void                        DuplicateConditionLevel( const sal_uInt16 nLevel);
     102             :         void                        AddOrder(const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos);
     103             :         void                        ClearAll();
     104             :         OTableFieldDescRef          AppendNewCol( sal_uInt16 nCnt=1 );
     105             :         bool                        Save();
     106             :         OQueryDesignView*           getDesignView();
     107             :         OQueryDesignView*           getDesignView() const;
     108             :         sal_uInt16                  FieldsCount();
     109             : 
     110             :         void                        SetColWidth(sal_uInt16 nColId, long lNewWidth);
     111             :                                         // unlike SetColumnWidth of the base class it checks an active cell in this column
     112             : 
     113             :         OUString                    GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId);
     114             :         void                        SetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId, const OUString& strNewText);
     115             :                                         // cell content (formatted as string) set/return
     116             :         sal_Int32                   GetNoneVisibleRows() const;
     117             :         void                        SetNoneVisbleRow(long nRows);
     118             :         bool                        IsRowVisible(sal_uInt16 _nWhich) const;
     119             :         void                        SetRowVisible(sal_uInt16 _nWhich, bool _bVis);
     120             : 
     121             :         void                        SetReadOnly(bool bRO);
     122             :         // calculate an optimal size. Basically, this takes into account the number of visible rows.
     123             :         Size                        CalcOptimalSize( const Size& _rAvailable );
     124             : 
     125             :         // can the current content be cut
     126             :         bool                        isPasteAllowed();
     127             :         bool                        isCutAllowed();
     128             :         bool                        isCopyAllowed();
     129             :         void                        cut();
     130             :         void                        paste();
     131             :         void                        copy();
     132             : 
     133             :         virtual void                GetFocus() SAL_OVERRIDE;
     134             :         virtual void                DeactivateCell(bool bUpdate = true) SAL_OVERRIDE;
     135           0 :         virtual void                ColumnMoved( sal_uInt16 nColId ) SAL_OVERRIDE { ColumnMoved(nColId,true); }
     136             :         void                        ColumnMoved( sal_uInt16 nColId, bool _bCreateUndo);
     137             : 
     138             :         void                        Fill();
     139             :         void                        PreFill();
     140             : 
     141             :         /** Disables the generation of undo actions
     142             :         */
     143           0 :         inline void                 EnterUndoMode() { m_bInUndoMode = true; }
     144             :         /** Enables the generation of undo actions
     145             :         */
     146           0 :         inline void                 LeaveUndoMode() { m_bInUndoMode = false; }
     147             : 
     148             :         /** GetCellText returns the text at the given position
     149             :             @param  _nRow
     150             :                 the number of the row
     151             :             @param  _nColId
     152             :                 the ID of the column
     153             :             @return
     154             :                 the text out of the cell
     155             :         */
     156             :         virtual OUString            GetCellText(long _nRow, sal_uInt16 _nColId) const SAL_OVERRIDE;
     157             : 
     158             :         /** returns the description of the row.
     159             :             @param  _nRow
     160             :                 The row number.
     161             :             @return
     162             :                 The header text of the specified row.
     163             :         */
     164             :         virtual OUString     GetRowDescription( sal_Int32 _nRow ) const SAL_OVERRIDE;
     165             : 
     166             :         /** return the name of the specified object.
     167             :             @param  eObjType
     168             :                 The type to ask for
     169             :             @param  _nPosition
     170             :                 The position of a tablecell (index position), header bar  column/row cell
     171             :             @return
     172             :                 The name of the specified object.
     173             :         */
     174             :         virtual OUString     GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const SAL_OVERRIDE;
     175             : 
     176             :         // IAccessibleTableProvider
     177             :         /** Creates the accessible object of a data table cell.
     178             :         @param nRow  The row index of the cell.
     179             :         @param nColumnId  The column ID of the cell.
     180             :         @return  The XAccessible interface of the specified cell. */
     181             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId ) SAL_OVERRIDE;
     182             : 
     183             :     protected:
     184             :         virtual bool                SeekRow( long nRow ) SAL_OVERRIDE;
     185             : 
     186             :         virtual void                PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const SAL_OVERRIDE;
     187             :         virtual void                PaintCell(OutputDevice& rDev, const Rectangle& rRect,
     188             :                                               sal_uInt16 nColumnId ) const SAL_OVERRIDE;
     189             : 
     190             :         virtual sal_Int8            AcceptDrop( const BrowserAcceptDropEvent& rEvt ) SAL_OVERRIDE;
     191             :         virtual sal_Int8            ExecuteDrop( const BrowserExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     192             :         virtual void                MouseButtonDown( const BrowserMouseEvent& rEvt ) SAL_OVERRIDE;
     193             :         virtual void                MouseButtonUp( const BrowserMouseEvent& rEvt ) SAL_OVERRIDE;
     194             :         virtual void                KeyInput( const KeyEvent& rEvt ) SAL_OVERRIDE;
     195             :         virtual void                Command(const CommandEvent& rEvt) SAL_OVERRIDE;
     196             :         virtual void                ArrangeControls(sal_uInt16& nX, sal_uInt16 nY) SAL_OVERRIDE;
     197             : 
     198             :         virtual ::svt::CellController*  GetController(long nRow, sal_uInt16 nCol) SAL_OVERRIDE;
     199             :         virtual void                InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol) SAL_OVERRIDE;
     200             :         virtual void                CellModified() SAL_OVERRIDE;
     201             :         virtual bool                SaveModified() SAL_OVERRIDE;
     202             :         virtual void                Init() SAL_OVERRIDE;
     203             :         sal_uInt32                  GetTotalCellWidth(long nRow, sal_uInt16 nColId) const;
     204             :         virtual void                ColumnResized( sal_uInt16 nColId ) SAL_OVERRIDE;
     205             : 
     206             :         virtual sal_uInt32          GetTotalCellWidth(long nRow, sal_uInt16 nColId) SAL_OVERRIDE;
     207             : 
     208             :         // if you want to have an own header ...
     209             :         virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE;
     210             : 
     211             :         void                        stopTimer();
     212             :         void                        startTimer();
     213             : 
     214             :     private:
     215             :         OTableFieldDescRef          FindFirstFreeCol(sal_uInt16& _rColumnPosition);
     216             : 
     217             :             // rCol contains the Nummer (in pOTableFieldDescList) of the first column, which itself tells it is empty
     218             :             // if there are none, rCol is undefined and the returnvalue NULL
     219             :         void                        CheckFreeColumns(sal_uInt16& _rColumnPosition);
     220             : 
     221             :             // check if empty columns are available, if not,  a new Packen is appended
     222             :             // rCol contains the Nummer of the first empty column (in pOTableFieldDescList)
     223             : 
     224             :         void            RemoveField( sal_uInt16 nId );
     225             :         Rectangle       GetInvalidRect( sal_uInt16 nColId );
     226             :         long            GetRealRow(long nRow) const;
     227             :         long            GetBrowseRow(long nRowId) const;
     228             :         bool            GetFunctionName(sal_uInt32 _nFunctionTokenId, OUString& rFkt);
     229             :         void            appendUndoAction(const OUString& _rOldValue,const OUString& _rNewValue,sal_Int32 _nRow, bool& _bListAction);
     230             :         void            appendUndoAction(const OUString& _rOldValue,const OUString& _rNewValue,sal_Int32 _nRow);
     231             :         OTableFields&   getFields() const;
     232             :         static void     enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl);
     233             :         void            setTextCellContext(const OTableFieldDescRef& _rEntry,const OUString& _sText,const OString& _sHelpId);
     234             :         void            invalidateUndoRedo();
     235             :         OTableFieldDescRef getEntry(OTableFields::size_type _nPos);
     236             : 
     237             :         void            adjustSelectionMode( bool _bClickedOntoHeader, bool _bClickedOntoHandleCol );
     238             : 
     239             :         /** save the filed change in save modified
     240             :             @param  _sFieldName
     241             :                 The field name inserted by the user.
     242             :             @param  _pEntry
     243             :                 The entry which will contain the necessary entries.
     244             :             @param  _bListAction
     245             :                 Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
     246             :             @return
     247             :                 <TRUE/> if an error occurred otherwise <FALSE/>
     248             :         */
     249             :         bool            saveField(OUString& _sFieldName, OTableFieldDescRef& _pEntry, bool& _bListAction);
     250             : 
     251             :         /** sets the table window at the _pEntry
     252             :             @param  _pEntry
     253             :                 The entry where the window should be set.
     254             :             @param  _sTableName
     255             :                 The table name to search for.
     256             :             @return
     257             :                 <TRUE/> if the table name was set otherwise <FALSE/>
     258             :         */
     259             :         bool            fillEntryTable(OTableFieldDescRef& _pEntry,const OUString& _sTableName);
     260             : 
     261             :         /** uses the parse node to fill all information into the field
     262             :             @param  _pColumnRef
     263             :                 The parse node used to fill the info into the field.
     264             :             @param  _xMetaData
     265             :                 Use to parse the node to a string.
     266             :             @param  _pEntry
     267             :                 The entry which will contain the necessary entries.
     268             :             @param  _bListAction
     269             :                 Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
     270             :             @return
     271             :                 <TRUE/> if an error occurred otherwise <FALSE/>
     272             :         */
     273             :         bool            fillColumnRef(  const ::connectivity::OSQLParseNode* _pColumnRef,
     274             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     275             :                                         OTableFieldDescRef& _pEntry,
     276             :                                         bool& _bListAction);
     277             :         bool            fillColumnRef(  const OUString& _sColumnName,
     278             :                                         const OUString& _sTableRange,
     279             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
     280             :                                         OTableFieldDescRef& _pEntry,
     281             :                                         bool& _bListAction);
     282             : 
     283             :         /** append an undo action for the table field
     284             :             @param  _sOldAlias
     285             :                 The old table alias.
     286             :             @param  _sAlias
     287             :                 The new alias name.
     288             :             @param  _bListAction
     289             :                 Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
     290             :         */
     291             :         void            notifyTableFieldChanged(const OUString& _sOldAlias,const OUString& _sAlias, bool& _bListAction,sal_uInt16 _nColumnId);
     292             : 
     293             :         /** append an undo action for the function field
     294             :             @param  _sOldFunctionName
     295             :                 The old value.
     296             :             @param  _sFunctionName
     297             :                 The new function name.
     298             :             @param  _bListAction
     299             :                 Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
     300             :         */
     301             :         void            notifyFunctionFieldChanged(const OUString& _sOldFunctionName,const OUString& _sFunctionName, bool& _bListAction,sal_uInt16 _nColumnId);
     302             : 
     303             :         /** clears the function fields of the submitted entry if it doesn't match the SQL standard and append an undo action.
     304             :             E.q. AGGREGATE functions are only valid when the field name isn't an asterisk
     305             :             @param  _sFieldName
     306             :                 The field name.
     307             :             @param  _pEntry
     308             :                 The entry to be cleared
     309             :             @param  _bListAction
     310             :                 When <TRUE/> an list action will be created.
     311             :         */
     312             :         void            clearEntryFunctionField(const OUString& _sFieldName,OTableFieldDescRef& _pEntry, bool& _bListAction,sal_uInt16 _nColumnId);
     313             : 
     314             :         /** remove or insert the necessary function types
     315             :             @param  _pEntry
     316             :                 The currently edited entry.
     317             :         */
     318             :         void            setFunctionCell(OTableFieldDescRef& _pEntry);
     319             : 
     320             :     private:
     321             :         using ::svt::EditBrowseBox::AcceptDrop;
     322             :         using ::svt::EditBrowseBox::ExecuteDrop;
     323             :         using ::svt::EditBrowseBox::MouseButtonDown;
     324             :         using ::svt::EditBrowseBox::MouseButtonUp;
     325             :     };
     326             : }
     327             : #endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_SELECTIONBROWSEBOX_HXX
     328             : 
     329             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11