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

Generated by: LCOV version 1.10