LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppDetailView.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 7 10 70.0 %
Date: 2015-06-13 12:38:46 Functions: 10 15 66.7 %
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_APP_APPDETAILVIEW_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILVIEW_HXX
      21             : 
      22             : #include <com/sun/star/frame/XController.hpp>
      23             : #include <com/sun/star/container/XNameAccess.hpp>
      24             : #include <com/sun/star/sdbc/XConnection.hpp>
      25             : #include <com/sun/star/ucb/XContent.hpp>
      26             : #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
      27             : #include <vcl/split.hxx>
      28             : #include <vcl/fixed.hxx>
      29             : #include <vcl/mnemonic.hxx>
      30             : #include "IClipBoardTest.hxx"
      31             : #include "AppTitleWindow.hxx"
      32             : #include "AppElementType.hxx"
      33             : #include <svtools/treelistbox.hxx>
      34             : #include "VertSplitView.hxx"
      35             : 
      36             : #include <vector>
      37             : 
      38             : class SvTreeListEntry;
      39             : 
      40             : namespace dbaui
      41             : {
      42             :     class OAppBorderWindow;
      43             :     class OApplicationDetailView;
      44             :     class OAppDetailPageHelper;
      45             :     class OTasksWindow;
      46             : 
      47          10 :     class OCreationList : public SvTreeListBox
      48             :     {
      49             :         OTasksWindow&   m_rTaskWindow;
      50             : 
      51             :         // members related to drawing the currently hovered/selected entry
      52             :         SvTreeListEntry*        m_pMouseDownEntry;
      53             :         SvTreeListEntry*        m_pLastActiveEntry;
      54             :         Color                   m_aOriginalBackgroundColor;
      55             :         vcl::Font               m_aOriginalFont;
      56             : 
      57             :     public:
      58             :         OCreationList( OTasksWindow& _rParent );
      59             :         // Window overrides
      60             :         virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      61             :         virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      62             :         virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      63             :         virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
      64             :         virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
      65             :         virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) SAL_OVERRIDE;
      66             :         virtual void GetFocus() SAL_OVERRIDE;
      67             :         virtual void LoseFocus() SAL_OVERRIDE;
      68             : 
      69           8 :         inline void resetLastActive() { m_pLastActiveEntry = NULL;}
      70             : 
      71             :         void    updateHelpText();
      72             : 
      73             :     protected:
      74             :         virtual void        PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry& rEntry) SAL_OVERRIDE;
      75             :         virtual Rectangle   GetFocusRect( SvTreeListEntry* _pEntry, long _nLine ) SAL_OVERRIDE;
      76             :         virtual void        ModelHasCleared() SAL_OVERRIDE;
      77             : 
      78             :         // IMnemonicEntryList
      79             :         virtual void        SelectSearchEntry( const void* _pEntry ) SAL_OVERRIDE;
      80             :         virtual void        ExecuteSearchEntry( const void* _pEntry ) const SAL_OVERRIDE;
      81             : 
      82             :     private:
      83             :         void    onSelected( SvTreeListEntry* _pEntry ) const;
      84             :         /** sets a new current entry, and invalidates the old and the new one, if necessary
      85             :             @return <TRUE/> if and only if the "current entry" changed
      86             :         */
      87             :         bool    setCurrentEntryInvalidate( SvTreeListEntry* _pEntry );
      88             :     };
      89             : 
      90          18 :     struct TaskEntry
      91             :     {
      92             :         OUString        sUNOCommand;
      93             :         sal_uInt16      nHelpID;
      94             :         OUString        sTitle;
      95             :         bool            bHideWhenDisabled;
      96             :             // TODO: we should be consistent in the task pane and the menus/toolbars:
      97             :             // If an entry is disabled in the latter, it should also be disabled in the former.
      98             :             // If an entry is *hidden* in the former, it should also be hidden in the latter.
      99             : 
     100             :         TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled = false );
     101             :     };
     102             :     typedef ::std::vector< TaskEntry >  TaskEntryList;
     103             : 
     104          24 :     struct TaskPaneData
     105             :     {
     106             :         /// the tasks available in the pane
     107             :         TaskEntryList   aTasks;
     108             :         /// the resource ID for the title of the pane
     109             :         sal_uInt16          nTitleId;
     110             :     };
     111             : 
     112             :     class OTasksWindow : public vcl::Window
     113             :     {
     114             :         VclPtr<OCreationList>               m_aCreation;
     115             :         VclPtr<FixedText>                   m_aDescription;
     116             :         VclPtr<FixedText>                   m_aHelpText;
     117             :         VclPtr<FixedLine>                   m_aFL;
     118             :         VclPtr<OApplicationDetailView>      m_pDetailView;
     119             : 
     120             :         DECL_LINK( OnEntrySelectHdl,        SvTreeListBox* );
     121             :         void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     122             :     protected:
     123             :         virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
     124             :     public:
     125             :         OTasksWindow(vcl::Window* _pParent,OApplicationDetailView* _pDetailView);
     126             :         virtual ~OTasksWindow();
     127             :         virtual void dispose() SAL_OVERRIDE;
     128             : 
     129             :         // Window overrides
     130             :         virtual void Resize() SAL_OVERRIDE;
     131             : 
     132           3 :         OApplicationDetailView* getDetailView() const { return m_pDetailView; }
     133             : 
     134             :         /// fills the Creation listbox with the necessary strings and images
     135             :         void fillTaskEntryList( const TaskEntryList& _rList );
     136             : 
     137           0 :         inline bool HandleKeyInput( const KeyEvent& _rKEvt )
     138             :         {
     139           0 :             return m_aCreation->HandleKeyInput( _rKEvt );
     140             :         }
     141             : 
     142             :         void Clear();
     143             :         void setHelpText(sal_uInt16 _nId);
     144             :     };
     145             :     class OApplicationDetailView : public OSplitterView
     146             :                                  , public IClipboardTest
     147             :     {
     148             :         VclPtr<Splitter>                    m_aHorzSplitter;
     149             :         VclPtr<OTitleWindow>                m_aTasks;
     150             :         VclPtr<OTitleWindow>                m_aContainer;
     151             :         OAppBorderWindow&                   m_rBorderWin;       // my parent
     152             :         VclPtr<OAppDetailPageHelper>        m_pControlHelper;
     153             :         ::std::vector< TaskPaneData >       m_aTaskPaneData;
     154             :         MnemonicGenerator                   m_aExternalMnemonics;
     155             : 
     156             :         void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     157             : 
     158             :     protected:
     159             :         virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
     160             : 
     161             :     public:
     162             :         OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode);
     163             :         virtual ~OApplicationDetailView();
     164             :         // Window overrides
     165             :         virtual void dispose() SAL_OVERRIDE;
     166             :         virtual void GetFocus() SAL_OVERRIDE;
     167             : 
     168             :         /** creates the tables page
     169             :             @param  _xConnection
     170             :                 The connection to get the table names
     171             :         */
     172             :         void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
     173             : 
     174             :         /** creates the page for the specific type.
     175             :             @param  _eType
     176             :                 The type which should be created. E_TABLE isn't allowed.
     177             :             @param  _xContainer
     178             :                 The container of the elements to be inserted.
     179             :         */
     180             :         void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
     181             : 
     182             :         void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
     183             : 
     184             :         /** called to give the window the chance to intercept key events, while it has not
     185             :             the focus
     186             : 
     187             :             @return <TRUE/> if and only if the event has been handled, and should not
     188             :                 not be further processed
     189             :         */
     190             :         bool    interceptKeyInput( const KeyEvent& _rEvent );
     191             : 
     192           6 :         inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
     193           6 :         inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks->getChildWindow() ); }
     194             : 
     195             :         bool isCutAllowed() SAL_OVERRIDE ;
     196             :         bool isCopyAllowed() SAL_OVERRIDE    ;
     197             :         bool isPasteAllowed() SAL_OVERRIDE;
     198           0 :         virtual bool hasChildPathFocus() SAL_OVERRIDE { return HasChildPathFocus(); }
     199             :         void copy() SAL_OVERRIDE;
     200             :         void cut() SAL_OVERRIDE;
     201             :         void paste() SAL_OVERRIDE;
     202             : 
     203             :         /** return the qualified name.
     204             :             @param  _pEntry
     205             :                 The entry of a table, or query, form, report to get the qualified name.
     206             :                 If the entry is <NULL/>, the first selected is chosen.
     207             :             @return
     208             :                 the qualified name
     209             :         */
     210             :         OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
     211             : 
     212             :         /** returns if an entry is a leaf
     213             :             @param _pEntry
     214             :                 The entry to check
     215             :             @return
     216             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     217             :         */
     218             :         static bool isLeaf(SvTreeListEntry* _pEntry);
     219             : 
     220             :         /** returns if one of the selected entries is a leaf
     221             :             @return
     222             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     223             :         */
     224             :         bool isALeafSelected() const;
     225             : 
     226             :         /** select all entries in the detail page
     227             :         */
     228             :         void selectAll();
     229             : 
     230             :         /// returns <TRUE/> if it sorts ascending
     231             :         bool isSortUp() const;
     232             : 
     233             :         /// sort the entries in the detail page down
     234             :         void sortDown();
     235             : 
     236             :         /// sort the entries in the detail page up
     237             :         void sortUp();
     238             : 
     239             :         /// returns <TRUE/> when a detail page was filled
     240             :         bool isFilled() const;
     241             : 
     242             :         /// return the element of currently select entry
     243             :         ElementType getElementType() const;
     244             : 
     245             :         /** clears the detail pages.
     246             :             @param  _bTaskAlso
     247             :                 If <TRUE/> the task window will also be cleared.
     248             :         */
     249             :         void clearPages(bool _bTaskAlso = true);
     250             : 
     251             :         /// returns the count of entries
     252             :         sal_Int32 getElementCount();
     253             : 
     254             :         /// returns the count of selected entries
     255             :         sal_Int32 getSelectionCount();
     256             : 
     257             :         /** returns the element names which are selected
     258             :             @param  _rNames
     259             :                 The list will be filled.
     260             :         */
     261             :         void getSelectionElementNames(::std::vector< OUString>& _rNames ) const;
     262             : 
     263             :         /** describes the current selection for the given control
     264             :         */
     265             :         void    describeCurrentSelectionForControl(
     266             :                     const Control& _rControl,
     267             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     268             :                 );
     269             : 
     270             :         /** describes the current selection for the given ElementType
     271             :         */
     272             :         void    describeCurrentSelectionForType(
     273             :                     const ElementType _eType,
     274             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     275             :                 );
     276             : 
     277             :         /** select all names on the currently selected container. Non existence names where ignored.
     278             :         *
     279             :         * \param _aNames the element names
     280             :         */
     281             :         void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
     282             : 
     283             :         /** adds a new object to the detail page.
     284             :             @param  _eType
     285             :                 The type where the entry shold be appended.
     286             :             @param  _rName
     287             :                 The name of the object to be inserted
     288             :             @param  _rObject
     289             :                 The object to add.
     290             :             @param  _rxConn
     291             :                 If we insert a table, the connection must be set.
     292             :         */
     293             :         SvTreeListEntry* elementAdded(ElementType eType
     294             :                         ,const OUString& _rName
     295             :                         ,const ::com::sun::star::uno::Any& _rObject );
     296             : 
     297             :         /** replaces a objects name with a new one
     298             :             @param  _eType
     299             :                 The type where the entry shold be appended.
     300             :             @param  _rOldName
     301             :                 The old name of the object to be replaced
     302             :             @param  _rNewName
     303             :                 The new name of the object to be replaced
     304             :             @param  _rxConn
     305             :                 If we insert a table, the connection must be set.
     306             :             @param  _xObject
     307             :                 The object which was replaced
     308             :         */
     309             :         void elementReplaced(ElementType eType
     310             :                         ,const OUString& _rOldName
     311             :                         ,const OUString& _rNewName );
     312             : 
     313             :         /** removes an element from the detail page.
     314             :             @param  _eType
     315             :                 The type where the entry shold be appended.
     316             :             @param  _rName
     317             :                 The name of the element to be removed.
     318             :             @param  _rxConn
     319             :                 If we remove a table, the connection must be set.
     320             :         */
     321             :         void elementRemoved(ElementType _eType
     322             :                             ,const OUString& _rName );
     323             : 
     324             :         /// returns the preview mode
     325             :         PreviewMode getPreviewMode();
     326             : 
     327             :         /// <TRUE/> if the preview is enabled
     328             :         bool isPreviewEnabled();
     329             : 
     330             :         /** switches to the given preview mode
     331             :             @param  _eMode
     332             :                 the mode to set for the preview
     333             :         */
     334             :         void switchPreview(PreviewMode _eMode);
     335             : 
     336             :         /** shows the Preview of the content when it is enabled.
     337             :             @param  _xContent
     338             :                 The content which must support the "preview" command.
     339             :         */
     340             :         void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
     341             : 
     342             :         /** shows the Preview of a table or query
     343             :             @param  _sDataSourceName
     344             :                 the name of the data source
     345             :             @param  _sName
     346             :                 the name of table or query
     347             :             @param  _bTable
     348             :                 <TRUE/> if it is a table, otherwise <FALSE/>
     349             :             @return void
     350             :         */
     351             :         void showPreview(   const OUString& _sDataSourceName,
     352             :                             const OUString& _sName,
     353             :                             bool _bTable);
     354             : 
     355             :         SvTreeListEntry* getEntry( const Point& _aPoint ) const;
     356             : 
     357             :         vcl::Window* getTreeWindow() const;
     358             :     private:
     359             :         void                impl_createPage(
     360             :                                 ElementType _eType,
     361             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     362             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxNonTableElements
     363             :                             );
     364             : 
     365             :         const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
     366             :         void                impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const;
     367             :     };
     368             : }
     369             : #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILVIEW_HXX
     370             : 
     371             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11