LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppDetailPageHelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 7 85.7 %
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_APPDETAILPAGEHELPER_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILPAGEHELPER_HXX
      21             : 
      22             : #include <vector>
      23             : 
      24             : #include <rtl/ustring.hxx>
      25             : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
      26             : #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
      27             : #include <com/sun/star/ucb/XContent.hpp>
      28             : #include "AppElementType.hxx"
      29             : #include <svtools/treelistbox.hxx>
      30             : #include <svtools/DocumentInfoPreview.hxx>
      31             : #include <vcl/fixed.hxx>
      32             : #include <vcl/toolbox.hxx>
      33             : #include <vcl/cvtgrf.hxx>
      34             : #include <vcl/graph.hxx>
      35             : #include <svtools/grfmgr.hxx>
      36             : #include "callbacks.hxx"
      37             : #include <memory>
      38             : 
      39             : namespace com{ namespace sun { namespace star { namespace awt   { class XWindow; } } } }
      40             : namespace com{ namespace sun { namespace star { namespace frame { class XFrame2; } } } }
      41             : namespace com{ namespace sun { namespace star { namespace io    { class XPersist; } } } }
      42             : 
      43             : #define ELEMENT_COUNT   size_t(E_ELEMENT_TYPE_COUNT)
      44             : 
      45             : namespace dbaui
      46             : {
      47             :     class OAppBorderWindow;
      48             :     class DBTreeListBox;
      49             : 
      50          10 :     class OPreviewWindow : public vcl::Window
      51             :     {
      52             :         GraphicObject       m_aGraphicObj;
      53             :         Rectangle           m_aPreviewRect;
      54             : 
      55             :         /** gets the graphic cnter rect
      56             :             @param  rGraphic
      57             :                 the graphic
      58             :             @param  rResultRect
      59             :                 the resulting rectangle
      60             : 
      61             :             @return
      62             :                 <TRUE/> when successful
      63             :         */
      64             :         bool ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
      65             :         void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
      66             :     protected:
      67             :         virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
      68             :     public:
      69             :         OPreviewWindow(vcl::Window* _pParent);
      70             : 
      71             :         // Window overrides
      72             :         virtual void Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) SAL_OVERRIDE;
      73             : 
      74           0 :         void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
      75             :     };
      76             :     // A helper class for the controls in the detail page.
      77             :     // Combines general functionality.
      78             :     class OAppDetailPageHelper : public vcl::Window
      79             :     {
      80             :         VclPtr<DBTreeListBox>     m_pLists[ELEMENT_COUNT];
      81             :         OAppBorderWindow&   m_rBorderWin;
      82             :         VclPtr<FixedLine>         m_aFL;
      83             :         VclPtr<ToolBox>           m_aTBPreview;
      84             :         VclPtr<Window>            m_aBorder;
      85             :         VclPtr<OPreviewWindow>    m_aPreview;
      86             :         VclPtr< ::svtools::ODocumentInfoPreview>
      87             :                                   m_aDocumentInfo;
      88             :         VclPtr<vcl::Window>       m_pTablePreview;
      89             :         ::std::unique_ptr<PopupMenu> m_aMenu;
      90             :         PreviewMode         m_ePreviewMode;
      91             :         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 >
      92             :                             m_xFrame;
      93             :         ::com::sun::star::uno::Reference < ::com::sun::star::io::XPersist >
      94             :                             m_xDocInfo;
      95             :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
      96             :                             m_xWindow;
      97             : 
      98             :         /// returns the index of the visible control
      99             :         int getVisibleControlIndex() const;
     100             : 
     101             :         /** sorts the entries in the tree list box.
     102             :             @param  _nPos
     103             :                 Which list should be sorted.
     104             :             @param  _eSortMode
     105             :                 How should be sorted.
     106             :         */
     107             :         void sort(int _nPos,SvSortMode _eSortMode );
     108             : 
     109             :         /** retrieves the resource ids of the images representing elements of the given type
     110             :         */
     111             :         static void getElementIcons( ElementType _eType, sal_uInt16& _rImageId);
     112             : 
     113             :         /** fills the names in the listbox
     114             :             @param  _xContainer
     115             :                 This can either be the queries, forms or report names.
     116             :             @param  _eType
     117             :                 the type of elements which are being filled
     118             :             @param _nImageId
     119             :                 the resource id of the image to use for non-container entries
     120             :             @param  _pParent
     121             :                 The parent of the entries to be inserted.
     122             :         */
     123             :         void fillNames( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer,
     124             :                         const ElementType _eType,
     125             :                         const sal_uInt16 _nImageId,
     126             :                         SvTreeListEntry* _pParent );
     127             : 
     128             :         /** sets the detail page
     129             :             @param  _pWindow
     130             :                 The control which should be visible.
     131             :         */
     132             :         void setDetailPage(vcl::Window* _pWindow);
     133             : 
     134             :         /** sets all HandleCallbacks
     135             :             @param  _pTreeView
     136             :                 The newly created DBTreeListBox
     137             :             @param  _rImage
     138             :                 the resource id of the default icon
     139             :             @return
     140             :                 The new tree.
     141             :         */
     142             :         DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rImage );
     143             : 
     144             :         /** creates the tree and sets all HandleCallbacks
     145             :             @param  _nHelpId
     146             :                 The help id of the control
     147             :             @param  _nCollapsedBitmap
     148             :                 The image to use in high contrast mode.
     149             :             @return
     150             :                 The new tree.
     151             :         */
     152             :         DBTreeListBox* createSimpleTree( const OString& _sHelpId, const Image& _rImage);
     153             : 
     154             :         DECL_LINK( OnEntryDoubleClick,          SvTreeListBox* );
     155             :         DECL_LINK( OnEntrySelChange,            void* );
     156             : 
     157             :         DECL_LINK( OnCutEntry,                  void* );
     158             :         DECL_LINK( OnCopyEntry,                 void* );
     159             :         DECL_LINK( OnPasteEntry,                void* );
     160             :         DECL_LINK( OnDeleteEntry,               void* );
     161             : 
     162             :         DECL_LINK(PreviewChangeHdl, void*);
     163             :         // click a TB slot
     164             :         DECL_LINK_TYPED(OnDropdownClickHdl, ToolBox*, void);
     165             : 
     166           9 :         inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
     167             :         void ImplInitSettings();
     168             : 
     169             :     public:
     170             :         OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
     171             :         virtual ~OAppDetailPageHelper();
     172             :         virtual void dispose() SAL_OVERRIDE;
     173             : 
     174             :         // Window overrides
     175             :         virtual void Resize() SAL_OVERRIDE;
     176             :         virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     177             : 
     178             :         /** creates the tables page
     179             :             @param  _xConnection
     180             :                 The connection to get the table names
     181             :         */
     182             :         void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
     183             : 
     184             :         /** creates the page for the specific type.
     185             :             @param  _eType
     186             :                 The type which should be created. E_TABLE isn't allowed.
     187             :             @param  _xContainer
     188             :                 The container of the elements to be inserted.
     189             :         */
     190             :         void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
     191             : 
     192             :         /** returns the current visible tree list box
     193             :         */
     194          31 :         inline DBTreeListBox* getCurrentView() const
     195             :         {
     196          31 :             ElementType eType = getElementType();
     197          31 :             return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)].get() : NULL;
     198             :         }
     199             : 
     200             :         /// select all entries in the visible control
     201             :         void selectAll();
     202             : 
     203             :         /// returns <TRUE/> if it sorts ascending
     204             :         bool isSortUp() const;
     205             : 
     206             :         /// sorts all entries ascending
     207             :         void sortDown();
     208             : 
     209             :         /// sorts all entries descending
     210             :         void sortUp();
     211             : 
     212             :         /** returns the element names which are selected
     213             :             @param  _rNames
     214             :                 The list will be filled.
     215             :         */
     216             :         void getSelectionElementNames( ::std::vector< OUString>& _rNames ) const;
     217             : 
     218             :         /** describes the current selection for the given control
     219             :         */
     220             :         void    describeCurrentSelectionForControl(
     221             :                     const Control& _rControl,
     222             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     223             :                 );
     224             : 
     225             :         /** describes the current selection for the given ElementType
     226             :         */
     227             :         void    describeCurrentSelectionForType(
     228             :                     const ElementType _eType,
     229             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     230             :                 );
     231             : 
     232             :         /** select all names on the currently selected container. Non existence names where ignored.
     233             :         *
     234             :         * \param _aNames the element names
     235             :         */
     236             :         void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
     237             : 
     238             :         /** return the qualified name.
     239             :             @param  _pEntry
     240             :                 The entry of a table, or query, form, report to get the qualified name.
     241             :                 If the entry is <NULL/>, the first selected is chosen.
     242             :             @return
     243             :                 the qualified name
     244             :         */
     245             :         OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
     246             : 
     247             :         /// return the element of currently select entry
     248             :         ElementType getElementType() const;
     249             : 
     250             :         /// returns the count of selected entries
     251             :         sal_Int32 getSelectionCount();
     252             : 
     253             :         /// returns the count of entries
     254             :         sal_Int32 getElementCount();
     255             : 
     256             :         /** returns if an entry is a leaf
     257             :             @param _pEntry
     258             :                 The entry to check
     259             :             @return
     260             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     261             :         */
     262             :         static bool isLeaf(SvTreeListEntry* _pEntry);
     263             : 
     264             :         /** returns if one of the selected entries is a leaf
     265             :             @return
     266             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     267             :         */
     268             :         bool isALeafSelected() const;
     269             : 
     270             :         SvTreeListEntry* getEntry( const Point& _aPosPixel ) const;
     271             : 
     272             :         /// clears the detail pages
     273             :         void clearPages();
     274             : 
     275             :         /// returns <TRUE/> when a detail page was filled
     276             :         bool isFilled() const;
     277             : 
     278             :         /** adds a new object to the detail page.
     279             :             @param  _eType
     280             :                 The type where the entry shold be appended.
     281             :             @param  _rName
     282             :                 The name of the object to be inserted
     283             :             @param  _rObject
     284             :                 The object to add.
     285             :             @param  _rxConn
     286             :                 If we insert a table, the connection must be set.
     287             :         */
     288             :         SvTreeListEntry*  elementAdded(ElementType eType
     289             :                         ,const OUString& _rName
     290             :                         ,const ::com::sun::star::uno::Any& _rObject );
     291             : 
     292             :         /** replaces a objects name with a new one
     293             :             @param  _eType
     294             :                 The type where the entry shold be appended.
     295             :             @param  _rOldName
     296             :                 The old name of the object to be replaced
     297             :             @param  _rNewName
     298             :                 The new name of the object to be replaced
     299             :             @param  _rxConn
     300             :                 If we insert a table, the connection must be set.
     301             :         */
     302             :         void elementReplaced(ElementType eType
     303             :                         ,const OUString& _rOldName
     304             :                         ,const OUString& _rNewName );
     305             : 
     306             :         /** removes an element from the detail page.
     307             :             @param  _eType
     308             :                 The type where the entry shold be appended.
     309             :             @param  _rName
     310             :                 The name of the element to be removed.
     311             :             @param  _rxConn
     312             :                 If we remove a table, the connection must be set.
     313             :         */
     314             :         void elementRemoved(ElementType _eType
     315             :                             ,const OUString& _rName );
     316             : 
     317             :         /// returns the preview mode
     318          27 :         PreviewMode getPreviewMode() { return m_ePreviewMode;}
     319             : 
     320             :         /// <TRUE/> if the preview is enabled
     321             :         bool isPreviewEnabled();
     322             : 
     323             :         /** switches to the given preview mode
     324             :             @param  _eMode
     325             :                 the mode to set for the preview
     326             :             @param  _bForce
     327             :                 Force the preview to be resetted
     328             :         */
     329             :         void switchPreview(PreviewMode _eMode,bool _bForce = false);
     330             : 
     331             :         /** shows the Preview of the content when it is enabled.
     332             :             @param  _xContent
     333             :                 The content which must support the "preview" command.
     334             :         */
     335             :         void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
     336             : 
     337             :         /** shows the Preview of a table or query
     338             :             @param  _sDataSourceName
     339             :                 the name of the data source
     340             :             @param  _sName
     341             :                 the name of table or query
     342             :             @param  _bTable
     343             :                 <TRUE/> if it is a table, otherwise <FALSE/>
     344             :             @return void
     345             :         */
     346             :         void showPreview(   const OUString& _sDataSourceName,
     347             :                             const OUString& _sName,
     348             :                             bool _bTable);
     349             : 
     350             :     protected:
     351             :         void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     352             :     };
     353             : }
     354             : #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILPAGEHELPER_HXX
     355             : 
     356             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11