LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppView.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 6 83.3 %
Date: 2015-06-13 12:38:46 Functions: 5 6 83.3 %
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_APPVIEW_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
      21             : 
      22             : #include <dbaccess/dataview.hxx>
      23             : #include <com/sun/star/container/XNameAccess.hpp>
      24             : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
      25             : #include <com/sun/star/ucb/XContent.hpp>
      26             : #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
      27             : #include <vcl/fixed.hxx>
      28             : #include <unotools/eventlisteneradapter.hxx>
      29             : #include "IClipBoardTest.hxx"
      30             : #include "AppElementType.hxx"
      31             : 
      32             : namespace com{ namespace sun { namespace star { namespace beans    { class XPropertySet; } } } }
      33             : 
      34             : class Control;
      35             : class SvTreeListEntry;
      36             : class MnemonicGenerator;
      37             : 
      38             : namespace dbaui
      39             : {
      40             :     class IApplicationController;
      41             :     class OApplicationView;
      42             :     class OApplicationDetailView;
      43             :     class OApplicationSwapWindow;
      44             :     class OTitleWindow;
      45             :     class OAppBorderWindow : public vcl::Window
      46             :     {
      47             :         VclPtr<OTitleWindow>                m_pPanel;
      48             :         VclPtr<OApplicationDetailView>      m_pDetailView;
      49             :         VclPtr<OApplicationView>            m_pView;
      50             : 
      51             :         void ImplInitSettings();
      52             :     protected:
      53             :         // Window
      54             :         virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
      55             :     public:
      56             :         OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode);
      57             :         virtual ~OAppBorderWindow();
      58             :         virtual void dispose() SAL_OVERRIDE;
      59             : 
      60             :         // Window overrides
      61             :         virtual void GetFocus() SAL_OVERRIDE;
      62             :         virtual void Resize() SAL_OVERRIDE;
      63             : 
      64          32 :         OApplicationView*       getView() const { return m_pView;}
      65             :         OApplicationSwapWindow* getPanel() const;
      66         412 :         OApplicationDetailView* getDetailView() const { return m_pDetailView;}
      67             :     };
      68             : 
      69             :     class OApplicationView : public ODataView
      70             :                             ,public IClipboardTest
      71             :                             ,public ::utl::OEventListenerAdapter
      72             :     {
      73             :         enum ChildFocusState
      74             :         {
      75             :             PANELSWAP,
      76             :             DETAIL,
      77             :             NONE
      78             :         };
      79             :     private:
      80             :         ::com::sun::star::lang::Locale      m_aLocale;
      81             :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
      82             :                                             m_xObject;
      83             :         VclPtr<OAppBorderWindow>            m_pWin;
      84             :         IApplicationController&             m_rAppController;
      85             :         ChildFocusState                     m_eChildFocus;
      86             : 
      87             :         IClipboardTest* getActiveChild() const;
      88             : 
      89             :         void ImplInitSettings();
      90             :     protected:
      91             : 
      92             :         // return the Rectangle where I can paint myself
      93             :         virtual void resizeDocumentView(Rectangle& rRect) SAL_OVERRIDE;
      94             : 
      95             :         // OEventListenerAdapter
      96             :         virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ) SAL_OVERRIDE;
      97             : 
      98             :         // Window
      99             :         virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     100             :     public:
     101             :         OApplicationView(   vcl::Window* pParent
     102             :                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
     103             :                             ,IApplicationController&            _rAppController
     104             :                             ,PreviewMode _ePreviewMode
     105             :                             );
     106             :         virtual ~OApplicationView();
     107             :         virtual void dispose() SAL_OVERRIDE;
     108             : 
     109             :         /// automatically creates mnemonics for the icon/texts in our left hand side panel
     110             :         void    createIconAutoMnemonics( MnemonicGenerator& _rMnemonics );
     111             : 
     112             :         /// automatically creates mnemonics for the texts in our task pane
     113             :         void    setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
     114             : 
     115             :         // Window overrides
     116             :         virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     117             :         virtual void GetFocus() SAL_OVERRIDE;
     118             : 
     119          19 :         inline IApplicationController&                  getAppController() const { return m_rAppController; }
     120             :         inline const ::com::sun::star::lang::Locale&    getLocale() const { return m_aLocale;}
     121             : 
     122             :         // IClipboardTest
     123             :         virtual bool isCutAllowed() SAL_OVERRIDE;
     124             :         virtual bool isCopyAllowed() SAL_OVERRIDE;
     125             :         virtual bool isPasteAllowed() SAL_OVERRIDE;
     126           0 :         virtual bool hasChildPathFocus() SAL_OVERRIDE { return HasChildPathFocus(); }
     127             :         virtual void copy() SAL_OVERRIDE;
     128             :         virtual void cut() SAL_OVERRIDE;
     129             :         virtual void paste() SAL_OVERRIDE;
     130             : 
     131             :         /// get the left panel
     132         243 :         inline OApplicationSwapWindow*  getPanel()      const { return m_pWin->getPanel(); }
     133             :         /// get the detail page
     134         398 :         inline OApplicationDetailView*  getDetailView() const { return m_pWin->getDetailView(); }
     135             : 
     136             :         /** return the qualified name.
     137             :             @param  _pEntry
     138             :                 The entry of a table, or query, form, report to get the qualified name.
     139             :                 If the entry is <NULL/>, the first selected is chosen.
     140             :             @return
     141             :                 the qualified name
     142             :         */
     143             :         OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
     144             : 
     145             :         /** returns if an entry is a leaf
     146             :             @param _pEntry
     147             :                 The entry to check
     148             :             @return
     149             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     150             :         */
     151             :         bool isLeaf(SvTreeListEntry* _pEntry) const;
     152             : 
     153             :         /** returns if one of the selected entries is a leaf
     154             :             @return
     155             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     156             :         */
     157             :         bool isALeafSelected() const;
     158             : 
     159             :         /** select all entries in the detail page
     160             :         */
     161             :         void selectAll();
     162             : 
     163             :         /// returns <TRUE/> if it sorts ascending
     164             :         bool isSortUp() const;
     165             : 
     166             :         /// sort the entries in the detail page down
     167             :         void sortDown();
     168             : 
     169             :         /// sort the entries in the detail page up
     170             :         void sortUp();
     171             : 
     172             :         /// returns <TRUE/> when a detail page was filled
     173             :         bool isFilled() const;
     174             : 
     175             :         /// return the element of currently select entry
     176             :         ElementType getElementType() const;
     177             : 
     178             :         /// returns the count of entries
     179             :         sal_Int32 getElementCount();
     180             : 
     181             :         /// returns the count of selected entries
     182             :         sal_Int32 getSelectionCount();
     183             : 
     184             :         /** clears the detail page and the selection on the left side.
     185             :             @param  _bTaskAlso
     186             :                 If <TRUE/> the task window will also be cleared.
     187             :         */
     188             :         void clearPages(bool _bTaskAlso = true);
     189             : 
     190             :         /** returns the element names which are selected
     191             :             @param  _rNames
     192             :                 The list will be filled.
     193             :         */
     194             :         void getSelectionElementNames( ::std::vector< OUString>& _rNames ) const;
     195             : 
     196             :         /** describes the current selection for the given control
     197             :         */
     198             :         void    describeCurrentSelectionForControl(
     199             :                     const Control& _rControl,
     200             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     201             :                 );
     202             : 
     203             :         /** describes the current selection for the given ElementType
     204             :         */
     205             :         void    describeCurrentSelectionForType(
     206             :                     const ElementType _eType,
     207             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     208             :                 );
     209             : 
     210             :         /** select all names on the currently selected container. Non existence names where ignored.
     211             :         *
     212             :         * \param _aNames the element names
     213             :         */
     214             :         void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
     215             : 
     216             :         /** adds a new object to the detail page.
     217             :             @param  _eType
     218             :                 The type where the entry shold be appended.
     219             :             @param  _rName
     220             :                 The name of the object to be inserted
     221             :             @param  _rObject
     222             :                 The object to add.
     223             :             @param  _rxConn
     224             :                 If we insert a table, the connection must be set.
     225             :         */
     226             :         SvTreeListEntry* elementAdded(ElementType _eType
     227             :                         ,const OUString& _rName
     228             :                         ,const ::com::sun::star::uno::Any& _rObject );
     229             : 
     230             :         /** replaces a objects name with a new one
     231             :             @param  _eType
     232             :                 The type where the entry shold be appended.
     233             :             @param  _rOldName
     234             :                 The old name of the object to be replaced
     235             :             @param  _rNewName
     236             :                 The new name of the object to be replaced
     237             :             @param  _rxConn
     238             :                 If we insert a table, the connection must be set.
     239             :             @param  _xObject
     240             :                 The object which was replaced
     241             :         */
     242             :         void elementReplaced(ElementType eType
     243             :                         ,const OUString& _rOldName
     244             :                         ,const OUString& _rNewName );
     245             : 
     246             :         /** removes an element from the detail page.
     247             :             @param  _eType
     248             :                 The type where the entry shold be appended.
     249             :             @param  _rName
     250             :                 The name of the element to be removed.
     251             :             @param  _rxConn
     252             :                 If we remove a table, the connection must be set.
     253             :         */
     254             :         void elementRemoved(ElementType _eType
     255             :                             ,const OUString& _rName );
     256             : 
     257             :         /** changes the container which should be displayed. The select handler will also be called.
     258             :             @param  _eType
     259             :                 Which container to show.
     260             :         */
     261             :         void selectContainer(ElementType _eType);
     262             : 
     263             :         /// returns the preview mode
     264             :         PreviewMode getPreviewMode();
     265             : 
     266             :         /// <TRUE/> if the preview is enabled
     267             :         bool isPreviewEnabled();
     268             : 
     269             :         /** switches to the given preview mode
     270             :             @param  _eMode
     271             :                 the mode to set for the preview
     272             :         */
     273             :         void switchPreview(PreviewMode _eMode);
     274             : 
     275             :         /** shows the Preview of the content when it is enabled.
     276             :             @param  _xContent
     277             :                 The content which must support the "preview" command.
     278             :         */
     279             :         void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
     280             : 
     281             :         /** shows the Preview of a table or query
     282             :             @param  _sDataSourceName
     283             :                 the name of the data source
     284             :             @param  _xConnection
     285             :                 the connection which will be shared
     286             :             @param  _sName
     287             :                 the name of table or query
     288             :             @param  _bTable
     289             :                 <TRUE/> if it is a table, otherwise <FALSE/>
     290             :             @return void
     291             :         */
     292             :         void showPreview(   const OUString& _sDataSourceName,
     293             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
     294             :                             const OUString& _sName,
     295             :                             bool _bTable);
     296             : 
     297             :         SvTreeListEntry* getEntry( const Point& _aPosPixel ) const;
     298             :     };
     299             : }
     300             : #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
     301             : 
     302             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11