LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppDetailPageHelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 6 0.0 %
Date: 2014-04-14 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef 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           0 :     class OPreviewWindow : public 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             :         sal_Bool ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
      65             :         void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
      66             :     protected:
      67             :         virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
      68             :     public:
      69             :         OPreviewWindow(Window* _pParent);
      70             : 
      71             :         // window overloads
      72             :         virtual void Paint(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 Window
      79             :     {
      80             :         DBTreeListBox*      m_pLists[ELEMENT_COUNT];
      81             :         OAppBorderWindow&   m_rBorderWin;
      82             :         FixedLine           m_aFL;
      83             :         ToolBox             m_aTBPreview;
      84             :         Window              m_aBorder;
      85             :         OPreviewWindow      m_aPreview;
      86             :         ::svtools::ODocumentInfoPreview
      87             :                             m_aDocumentInfo;
      88             :         Window*             m_pTablePreview;
      89             :         ::std::auto_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             :         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(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(OnDropdownClickHdl, ToolBox*);
     165             : 
     166           0 :         inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
     167             :         void ImplInitSettings();
     168             : 
     169             :     public:
     170             :         OAppDetailPageHelper(Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
     171             :         virtual ~OAppDetailPageHelper();
     172             : 
     173             :         // window overloads
     174             :         virtual void Resize() SAL_OVERRIDE;
     175             :         virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     176             : 
     177             :         sal_Bool isCutAllowed();
     178             :         sal_Bool isCopyAllowed();
     179             :         sal_Bool isPasteAllowed();
     180             :         void copy();
     181             :         void cut();
     182             :         void paste();
     183             : 
     184             :         /** creates the tables page
     185             :             @param  _xConnection
     186             :                 The connection to get the table names
     187             :         */
     188             :         void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
     189             : 
     190             :         /** creates the page for the specific type.
     191             :             @param  _eType
     192             :                 The type which should be created. E_TABLE isn't allowed.
     193             :             @param  _xContainer
     194             :                 The container of the elements to be inserted.
     195             :         */
     196             :         void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
     197             : 
     198             :         /** returns the current visible tree list box
     199             :         */
     200           0 :         inline DBTreeListBox* getCurrentView() const
     201             :         {
     202           0 :             ElementType eType = getElementType();
     203           0 :             return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)] : NULL;
     204             :         }
     205             : 
     206             :         /// select all entries in the visible control
     207             :         void selectAll();
     208             : 
     209             :         /// returns <TRUE/> if it sorts ascending
     210             :         sal_Bool isSortUp() const;
     211             : 
     212             :         /// sorts all entries ascending
     213             :         void sortDown();
     214             : 
     215             :         /// sorts all entries descending
     216             :         void sortUp();
     217             : 
     218             :         /** returns the element names which are selected
     219             :             @param  _rNames
     220             :                 The list will be filled.
     221             :         */
     222             :         void getSelectionElementNames( ::std::vector< OUString>& _rNames ) const;
     223             : 
     224             :         /** describes the current selection for the given control
     225             :         */
     226             :         void    describeCurrentSelectionForControl(
     227             :                     const Control& _rControl,
     228             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     229             :                 );
     230             : 
     231             :         /** describes the current selection for the given ElementType
     232             :         */
     233             :         void    describeCurrentSelectionForType(
     234             :                     const ElementType _eType,
     235             :                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
     236             :                 );
     237             : 
     238             :         /** select all names on the currently selected container. Non existence names where ignored.
     239             :         *
     240             :         * \param _aNames the element names
     241             :         */
     242             :         void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
     243             : 
     244             :         /** return the qualified name.
     245             :             @param  _pEntry
     246             :                 The entry of a table, or query, form, report to get the qualified name.
     247             :                 If the entry is <NULL/>, the first selected is chosen.
     248             :             @return
     249             :                 the qualified name
     250             :         */
     251             :         OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
     252             : 
     253             :         /// return the element of currently select entry
     254             :         ElementType getElementType() const;
     255             : 
     256             :         /// returns the count of selected entries
     257             :         sal_Int32 getSelectionCount();
     258             : 
     259             :         /// returns the count of entries
     260             :         sal_Int32 getElementCount();
     261             : 
     262             :         /** returns if an entry is a leaf
     263             :             @param _pEntry
     264             :                 The entry to check
     265             :             @return
     266             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     267             :         */
     268             :         bool    isLeaf(SvTreeListEntry* _pEntry) const;
     269             : 
     270             :         /** returns if one of the selected entries is a leaf
     271             :             @return
     272             :                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
     273             :         */
     274             :         sal_Bool isALeafSelected() const;
     275             : 
     276             :         SvTreeListEntry* getEntry( const Point& _aPosPixel ) const;
     277             : 
     278             :         /// clears the detail pages
     279             :         void clearPages();
     280             : 
     281             :         /// returns <TRUE/> when a detail page was filled
     282             :         sal_Bool isFilled() const;
     283             : 
     284             :         /** adds a new object to the detail page.
     285             :             @param  _eType
     286             :                 The type where the entry shold be appended.
     287             :             @param  _rName
     288             :                 The name of the object to be inserted
     289             :             @param  _rObject
     290             :                 The object to add.
     291             :             @param  _rxConn
     292             :                 If we insert a table, the connection must be set.
     293             :         */
     294             :         SvTreeListEntry*  elementAdded(ElementType eType
     295             :                         ,const OUString& _rName
     296             :                         ,const ::com::sun::star::uno::Any& _rObject );
     297             : 
     298             :         /** replaces a objects name with a new one
     299             :             @param  _eType
     300             :                 The type where the entry shold be appended.
     301             :             @param  _rOldName
     302             :                 The old name of the object to be replaced
     303             :             @param  _rNewName
     304             :                 The new name of the object to be replaced
     305             :             @param  _rxConn
     306             :                 If we insert a table, the connection must be set.
     307             :         */
     308             :         void elementReplaced(ElementType eType
     309             :                         ,const OUString& _rOldName
     310             :                         ,const OUString& _rNewName );
     311             : 
     312             :         /** removes an element from the detail page.
     313             :             @param  _eType
     314             :                 The type where the entry shold be appended.
     315             :             @param  _rName
     316             :                 The name of the element to be removed.
     317             :             @param  _rxConn
     318             :                 If we remove a table, the connection must be set.
     319             :         */
     320             :         void elementRemoved(ElementType _eType
     321             :                             ,const OUString& _rName );
     322             : 
     323             :         /// returns the preview mode
     324             :         PreviewMode getPreviewMode();
     325             : 
     326             :         /// <TRUE/> if the preview is enabled
     327             :         sal_Bool isPreviewEnabled();
     328             : 
     329             :         /** switches to the given preview mode
     330             :             @param  _eMode
     331             :                 the mode to set for the preview
     332             :             @param  _bForce
     333             :                 Force the preview to be resetted
     334             :         */
     335             :         void switchPreview(PreviewMode _eMode,sal_Bool _bForce = sal_False);
     336             : 
     337             :         /** shows the Preview of the content when it is enabled.
     338             :             @param  _xContent
     339             :                 The content which must support the "preview" command.
     340             :         */
     341             :         void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
     342             : 
     343             :         /** shows the Preview of a table or query
     344             :             @param  _sDataSourceName
     345             :                 the name of the data source
     346             :             @param  _sName
     347             :                 the name of table or query
     348             :             @param  _bTable
     349             :                 <TRUE/> if it is a table, otherwise <FALSE/>
     350             :             @return void
     351             :         */
     352             :         void showPreview(   const OUString& _sDataSourceName,
     353             :                             const OUString& _sName,
     354             :                             sal_Bool _bTable);
     355             : 
     356             :     protected:
     357             :         void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     358             :     };
     359             : }
     360             : #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILPAGEHELPER_HXX
     361             : 
     362             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10