LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - SelectionBrowseBox.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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;  // an Pos steht die RowId
      57                 :            :         Timer                               m_timerInvalidate;
      58                 :            : 
      59                 :            :         long                                m_nSeekRow;
      60                 :            :         BrowserMode                         m_nMode;                        // Merken des 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;              // maximale Anzahl der Spalten in einem Select-Statement
      71                 :            : 
      72                 :            :         String                              m_aFunctionStrings;
      73                 :            :         sal_uInt16                          m_nVisibleCount;                // Anzahl der max sichtbaren Zeilen
      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 ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const;
      94                 :            :         // AddGroupBy:: F"ugt ein Feld mit Funktion == Grupierung. Falls das Feld schon vorhanden ist und ein Aggregate Funktion
      95                 :            :         // benutzt, wird das Flag nicht gesetzt
      96                 :            :         void                        AddGroupBy( const OTableFieldDescRef& rInfo,sal_uInt32 _nCurrentPos);
      97                 :            :         void                        AddCondition( const OTableFieldDescRef& rInfo,
      98                 :            :                                                   const String& 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                 :            :         sal_Bool                    Save();
     106                 :            :         OQueryDesignView*           getDesignView();
     107                 :            :         OQueryDesignView*           getDesignView() const;
     108                 :            :         sal_uInt16                  FieldsCount();
     109                 :            : 
     110                 :            :         void                        SetColWidth(sal_uInt16 nColId, long lNewWidth);
     111                 :            :                                     // beachtet im Gegensatz zum SetColumnWidth der Basisklasse auch eine eventuell aktive Zelle in dieser Spalte
     112                 :            : 
     113                 :            :         String                      GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId);
     114                 :            :         void                        SetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId, const String& strNewText);
     115                 :            :                                         // Zelleninhalt (als String formatiert) setzen/liefern
     116                 :            :         sal_Int32                   GetNoneVisibleRows() const;
     117                 :            :         void                        SetNoneVisbleRow(long nRows);
     118                 :            :         sal_Bool                    IsRowVisible(sal_uInt16 _nWhich) const;
     119                 :            :         void                        SetRowVisible(sal_uInt16 _nWhich, sal_Bool _bVis);
     120                 :            : 
     121                 :            :         void                        SetReadOnly(sal_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                 :            :         sal_Bool                    isPasteAllowed();
     127                 :            :         sal_Bool                    isCutAllowed();
     128                 :            :         sal_Bool                    isCopyAllowed();
     129                 :            :         void                        cut();
     130                 :            :         void                        paste();
     131                 :            :         void                        copy();
     132                 :            : 
     133                 :            :         virtual void                GetFocus();
     134                 :            :         virtual void                DeactivateCell(sal_Bool bUpdate = sal_True);
     135                 :          0 :         virtual void                ColumnMoved( sal_uInt16 nColId ) { ColumnMoved(nColId,sal_True); }
     136                 :            :         void                        ColumnMoved( sal_uInt16 nColId,sal_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 = sal_True; }
     144                 :            :         /** Enables the generation of undo actions
     145                 :            :         */
     146                 :          0 :         inline void                 LeaveUndoMode() { m_bInUndoMode = sal_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 String              GetCellText(long _nRow, sal_uInt16 _nColId) const;
     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 ::rtl::OUString     GetRowDescription( sal_Int32 _nRow ) const;
     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  colum/row cell
     171                 :            :             @return
     172                 :            :                 The name of the specified object.
     173                 :            :         */
     174                 :            :         virtual ::rtl::OUString     GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
     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 );
     182                 :            : 
     183                 :            : 
     184                 :            :     protected:
     185                 :            :         virtual sal_Bool            SeekRow( long nRow );
     186                 :            : 
     187                 :            :         virtual void                PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const;
     188                 :            :         virtual void                PaintCell(OutputDevice& rDev, const Rectangle& rRect,
     189                 :            :                                               sal_uInt16 nColumnId ) const;
     190                 :            : 
     191                 :            :         virtual sal_Int8            AcceptDrop( const BrowserAcceptDropEvent& rEvt );
     192                 :            :         virtual sal_Int8            ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
     193                 :            :         virtual void                MouseButtonDown( const BrowserMouseEvent& rEvt );
     194                 :            :         virtual void                MouseButtonUp( const BrowserMouseEvent& rEvt );
     195                 :            :         virtual void                KeyInput( const KeyEvent& rEvt );
     196                 :            :         virtual void                Command(const CommandEvent& rEvt);
     197                 :            :         virtual void                ArrangeControls(sal_uInt16& nX, sal_uInt16 nY);
     198                 :            : 
     199                 :            :         virtual ::svt::CellController*  GetController(long nRow, sal_uInt16 nCol);
     200                 :            :         virtual void                InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
     201                 :            :         virtual void                CellModified();
     202                 :            :         virtual sal_Bool            SaveModified();
     203                 :            :         virtual void                Init();
     204                 :            :         virtual sal_uInt32          GetTotalCellWidth(long nRow, sal_uInt16 nColId) const;
     205                 :            :         virtual void                ColumnResized( sal_uInt16 nColId );
     206                 :            : 
     207                 :            :         virtual sal_uInt32          GetTotalCellWidth(long nRow, sal_uInt16 nColId);
     208                 :            : 
     209                 :            :         virtual sal_uInt16          GetDefaultColumnWidth(const String& rName) const;
     210                 :            :         // if you want to have an own header ...
     211                 :            :         virtual BrowserHeader*      imp_CreateHeaderBar(BrowseBox* pParent);
     212                 :            : 
     213                 :            :         void                        stopTimer();
     214                 :            :         void                        startTimer();
     215                 :            : 
     216                 :            :     private:
     217                 :            :         OTableFieldDescRef          FindFirstFreeCol(sal_uInt16& _rColumnPosition);
     218                 :            :             // rCol enthaelt die Nummer (in pOTableFieldDescList) der ersten Spalte, die von sich sagt, dass sie leer ist
     219                 :            :             // wenn es keine solche gibt, ist rCol undefiniert und der Rueckgabewert NULL
     220                 :            :         void                        CheckFreeColumns(sal_uInt16& _rColumnPosition);
     221                 :            :             // testet, ob es noch freie Spalten gibt, wenn nicht, wird ein neuer Packen angefuegt
     222                 :            :             // rCol enthaelt die Nummer der ersten freien Spalte (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                 :            :         sal_Bool        GetFunctionName(sal_uInt32 _nFunctionTokenId,String& rFkt);
     229                 :            :         void            appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow,sal_Bool& _bListAction);
     230                 :            :         void            appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow);
     231                 :            :         OTableFields&   getFields() const;
     232                 :            :         void            enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl);
     233                 :            :         void            setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,const rtl::OString& _sHelpId);
     234                 :            :         void            invalidateUndoRedo();
     235                 :            :         OTableFieldDescRef getEntry(OTableFields::size_type _nPos);
     236                 :            : 
     237                 :            :         void            adjustSelectionMode( sal_Bool _bClickedOntoHeader, sal_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                 :            :         sal_Bool        saveField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_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                 :            :         sal_Bool        fillEntryTable(OTableFieldDescRef& _pEntry,const ::rtl::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                 :            :         sal_Bool        fillColumnRef(  const ::connectivity::OSQLParseNode* _pColumnRef,
     274                 :            :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     275                 :            :                                         OTableFieldDescRef& _pEntry,
     276                 :            :                                         sal_Bool& _bListAction);
     277                 :            :         sal_Bool        fillColumnRef(  const ::rtl::OUString& _sColumnName,
     278                 :            :                                         const ::rtl::OUString& _sTableRange,
     279                 :            :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
     280                 :            :                                         OTableFieldDescRef& _pEntry,
     281                 :            :                                         sal_Bool& _bListAction);
     282                 :            : 
     283                 :            : 
     284                 :            :         /** append an undo action for the table field
     285                 :            :             @param  _sOldAlias
     286                 :            :                 The old table alias.
     287                 :            :             @param  _sAlias
     288                 :            :                 The new alias name.
     289                 :            :             @param  _bListAction
     290                 :            :                 Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
     291                 :            :         */
     292                 :            :         void            notifyTableFieldChanged(const String& _sOldAlias,const String& _sAlias,sal_Bool& _bListAction,sal_uInt16 _nColumnId);
     293                 :            : 
     294                 :            :         /** append an undo action for the function field
     295                 :            :             @param  _sOldFunctionName
     296                 :            :                 The old value.
     297                 :            :             @param  _sFunctionName
     298                 :            :                 The new function name.
     299                 :            :             @param  _bListAction
     300                 :            :                 Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
     301                 :            :         */
     302                 :            :         void            notifyFunctionFieldChanged(const String& _sOldFunctionName,const String& _sFunctionName,sal_Bool& _bListAction,sal_uInt16 _nColumnId);
     303                 :            : 
     304                 :            :         /** clears the function fields of the submitted entry if it doesn't match the SQL standard and append an undo action.
     305                 :            :             E.q. AGGREGATE functions are only valid when the field name isn't an asterix
     306                 :            :             @param  _sFieldName
     307                 :            :                 The field name.
     308                 :            :             @param  _pEntry
     309                 :            :                 The entry to be cleared
     310                 :            :             @param  _bListAction
     311                 :            :                 When <TRUE/> an list action will be created.
     312                 :            :         */
     313                 :            :         void            clearEntryFunctionField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction,sal_uInt16 _nColumnId);
     314                 :            : 
     315                 :            :         /** remove or insert the necessary function types
     316                 :            :             @param  _pEntry
     317                 :            :                 The currently edited entry.
     318                 :            :         */
     319                 :            :         void            setFunctionCell(OTableFieldDescRef& _pEntry);
     320                 :            : 
     321                 :            :     private:
     322                 :            :         using ::svt::EditBrowseBox::AcceptDrop;
     323                 :            :         using ::svt::EditBrowseBox::ExecuteDrop;
     324                 :            :         using ::svt::EditBrowseBox::MouseButtonDown;
     325                 :            :         using ::svt::EditBrowseBox::MouseButtonUp;
     326                 :            :     };
     327                 :            : }
     328                 :            : #endif // DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
     329                 :            : 
     330                 :            : 
     331                 :            : 
     332                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10