LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppDetailPageHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 709 0.0 %
Date: 2012-08-25 Functions: 0 77 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1160 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                 :            : 
      20                 :            : #include "AppDetailPageHelper.hxx"
      21                 :            : #include "moduledbu.hxx"
      22                 :            : #include <tools/debug.hxx>
      23                 :            : #include <tools/diagnose_ex.h>
      24                 :            : #include <connectivity/dbtools.hxx>
      25                 :            : #include "tabletree.hxx"
      26                 :            : #include "UITools.hxx"
      27                 :            : #include "dbtreelistbox.hxx"
      28                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      29                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      30                 :            : #include <com/sun/star/awt/XTabController.hpp>
      31                 :            : #include <com/sun/star/sdbc/XConnection.hpp>
      32                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      33                 :            : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
      34                 :            : #include <com/sun/star/frame/XFrame.hpp>
      35                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      36                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      37                 :            : #include <com/sun/star/frame/XFrames.hpp>
      38                 :            : #include <com/sun/star/frame/XFramesSupplier.hpp>
      39                 :            : #include <com/sun/star/awt/XWindow.hpp>
      40                 :            : #include <toolkit/helper/vclunohelper.hxx>
      41                 :            : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      42                 :            : #include <com/sun/star/ucb/XCommandProcessor.hpp>
      43                 :            : #include <com/sun/star/ucb/Command.hpp>
      44                 :            : #include <com/sun/star/form/XLoadable.hpp>
      45                 :            : #include <com/sun/star/container/XChild.hpp>
      46                 :            : #include <com/sun/star/container/XContainer.hpp>
      47                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      48                 :            : #include <com/sun/star/util/XCloseable.hpp>
      49                 :            : #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
      50                 :            : #include <com/sun/star/sdb/application/DatabaseObject.hpp>
      51                 :            : #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
      52                 :            : #include "AppView.hxx"
      53                 :            : #include "dbaccess_helpid.hrc"
      54                 :            : #include "dbu_app.hrc"
      55                 :            : #include "callbacks.hxx"
      56                 :            : #include "IController.hxx"
      57                 :            : #include "dbustrings.hrc"
      58                 :            : #include "dbaccess_slotid.hrc"
      59                 :            : #include "databaseobjectview.hxx"
      60                 :            : #include "imageprovider.hxx"
      61                 :            : #include <vcl/waitobj.hxx>
      62                 :            : #include <tools/stream.hxx>
      63                 :            : #include <rtl/ustrbuf.hxx>
      64                 :            : #include "IApplicationController.hxx"
      65                 :            : 
      66                 :            : #include <com/sun/star/document/XDocumentProperties.hpp>
      67                 :            : 
      68                 :            : 
      69                 :            : using namespace ::dbaui;
      70                 :            : using namespace ::com::sun::star::container;
      71                 :            : using namespace ::com::sun::star::uno;
      72                 :            : using namespace ::com::sun::star::ucb;
      73                 :            : using namespace ::com::sun::star::frame;
      74                 :            : using namespace ::com::sun::star::form;
      75                 :            : using namespace ::com::sun::star::sdb;
      76                 :            : using namespace ::com::sun::star::sdb::application;
      77                 :            : using namespace ::com::sun::star::sdbc;
      78                 :            : using namespace ::com::sun::star::sdbcx;
      79                 :            : using namespace ::com::sun::star::beans;
      80                 :            : using namespace ::com::sun::star;
      81                 :            : using ::com::sun::star::awt::XTabController;
      82                 :            : 
      83                 :            : namespace dbaui
      84                 :            : {
      85                 :            :     namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
      86                 :            :     namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
      87                 :            : }
      88                 :            : 
      89                 :            : namespace
      90                 :            : {
      91                 :          0 :     SvLBoxEntry* lcl_findEntry_impl(DBTreeListBox& rTree,const ::rtl::OUString& _rName,SvLBoxEntry* _pFirst)
      92                 :            :     {
      93                 :          0 :         SvLBoxEntry* pReturn = NULL;
      94                 :          0 :         sal_Int32 nIndex = 0;
      95         [ #  # ]:          0 :         String sName( _rName.getToken(0,'/',nIndex) );
      96                 :            : 
      97                 :          0 :         SvLBoxEntry* pEntry = _pFirst;
      98         [ #  # ]:          0 :         while( pEntry )
      99                 :            :         {
     100 [ #  # ][ #  # ]:          0 :             if ( rTree.GetEntryText(pEntry) == sName )
         [ #  # ][ #  # ]
     101                 :            :             {
     102         [ #  # ]:          0 :                 if ( nIndex != -1 )
     103                 :            :                 {
     104         [ #  # ]:          0 :                     sName = _rName.getToken(0,'/',nIndex);
     105         [ #  # ]:          0 :                     pEntry = rTree.FirstChild(pEntry);
     106                 :            :                 }
     107                 :            :                 else
     108                 :            :                 {
     109                 :          0 :                     pReturn = pEntry;
     110                 :          0 :                     break;
     111                 :            :                 }
     112                 :            :             }
     113                 :            :             else
     114         [ #  # ]:          0 :                 pEntry = rTree.NextSibling(pEntry);
     115                 :            :         }
     116         [ #  # ]:          0 :         return pReturn;
     117                 :            :     }
     118                 :          0 :     SvLBoxEntry* lcl_findEntry(DBTreeListBox& rTree,const ::rtl::OUString& _rName,SvLBoxEntry* _pFirst)
     119                 :            :     {
     120                 :          0 :         sal_Int32 nIndex = 0;
     121                 :          0 :         ::rtl::OUString sErase = _rName.getToken(0,'/',nIndex); // we don't want to have the "private:forms" part
     122 [ #  # ][ #  # ]:          0 :         return (nIndex != -1 ? lcl_findEntry_impl(rTree,_rName.copy(sErase.getLength() + 1),_pFirst) : NULL);
         [ #  # ][ #  # ]
     123                 :            :     }
     124                 :            :     //==================================================================
     125                 :            :     // class OPreviewWindow
     126                 :            :     //==================================================================
     127         [ #  # ]:          0 :     class OTablePreviewWindow : public Window
     128                 :            :     {
     129                 :            :         DECL_LINK(OnDisableInput, void*);
     130                 :            :         void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
     131                 :            :     protected:
     132                 :            :         virtual void DataChanged(const DataChangedEvent& rDCEvt);
     133                 :            :     public:
     134                 :            :         OTablePreviewWindow( Window* pParent, WinBits nStyle = 0 );
     135                 :            :         virtual long Notify( NotifyEvent& rNEvt );
     136                 :            :     };
     137                 :            :     // -----------------------------------------------------------------------------
     138                 :          0 :     OTablePreviewWindow::OTablePreviewWindow(Window* pParent, WinBits nStyle) : Window( pParent, nStyle)
     139                 :            :     {
     140         [ #  # ]:          0 :         ImplInitSettings( sal_True, sal_True, sal_True );
     141                 :          0 :     }
     142                 :            :     // -----------------------------------------------------------------------------
     143                 :          0 :     long OTablePreviewWindow::Notify( NotifyEvent& rNEvt )
     144                 :            :     {
     145                 :          0 :         long nRet = Window::Notify( rNEvt );
     146 [ #  # ][ #  # ]:          0 :         if ( rNEvt.GetType() == EVENT_INPUTENABLE && IsInputEnabled() )
                 [ #  # ]
     147         [ #  # ]:          0 :             PostUserEvent( LINK( this, OTablePreviewWindow, OnDisableInput) );
     148                 :          0 :         return nRet;
     149                 :            :     }
     150                 :            :     // -----------------------------------------------------------------------------
     151                 :          0 :     IMPL_LINK_NOARG(OTablePreviewWindow, OnDisableInput)
     152                 :            :     {
     153                 :          0 :         EnableInput(sal_False);
     154                 :          0 :         return 0L;
     155                 :            :     }
     156                 :            :     // -----------------------------------------------------------------------------
     157                 :          0 :     void OTablePreviewWindow::DataChanged( const DataChangedEvent& rDCEvt )
     158                 :            :     {
     159                 :          0 :         Window::DataChanged( rDCEvt );
     160                 :            : 
     161         [ #  # ]:          0 :         if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
           [ #  #  #  # ]
     162                 :          0 :             (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     163                 :            :         {
     164                 :          0 :             ImplInitSettings( sal_True, sal_True, sal_True );
     165                 :          0 :             Invalidate();
     166                 :            :         }
     167                 :          0 :     }
     168                 :            :     // -----------------------------------------------------------------------------
     169                 :          0 :     void OTablePreviewWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
     170                 :            :     {
     171                 :          0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     172         [ #  # ]:          0 :         if( bFont )
     173                 :            :         {
     174         [ #  # ]:          0 :             Font aFont;
     175         [ #  # ]:          0 :             aFont = rStyleSettings.GetFieldFont();
     176         [ #  # ]:          0 :             aFont.SetColor( rStyleSettings.GetWindowTextColor() );
     177 [ #  # ][ #  # ]:          0 :             SetPointFont( aFont );
     178                 :            :         }
     179                 :            : 
     180 [ #  # ][ #  # ]:          0 :         if( bForeground || bFont )
     181                 :            :         {
     182                 :          0 :             SetTextColor( rStyleSettings.GetFieldTextColor() );
     183                 :          0 :             SetTextFillColor();
     184                 :            :         }
     185                 :            : 
     186         [ #  # ]:          0 :         if( bBackground )
     187         [ #  # ]:          0 :             SetBackground( rStyleSettings.GetFieldColor() );
     188                 :          0 :     }
     189                 :            : 
     190                 :            : }
     191                 :            : //==================================================================
     192                 :            : // class OAppDetailPageHelper
     193                 :            : DBG_NAME(OAppDetailPageHelper)
     194                 :            : //==================================================================
     195                 :          0 : OAppDetailPageHelper::OAppDetailPageHelper(Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL)
     196                 :            :     ,m_rBorderWin(_rBorderWin)
     197                 :            :     ,m_aFL(this,WB_VERT)
     198                 :            :     ,m_aTBPreview(this,WB_TABSTOP )
     199                 :            :     ,m_aBorder(this,WB_BORDER | WB_READONLY)
     200                 :            :     ,m_aPreview(&m_aBorder)
     201                 :            :     ,m_aDocumentInfo(&m_aBorder,WB_LEFT | WB_VSCROLL | WB_READONLY )
     202                 :            :     ,m_pTablePreview(NULL)
     203 [ #  # ][ #  # ]:          0 :     ,m_ePreviewMode(_ePreviewMode)
         [ #  # ][ #  # ]
                 [ #  # ]
     204                 :            : {
     205                 :            :     DBG_CTOR(OAppDetailPageHelper,NULL);
     206                 :            : 
     207         [ #  # ]:          0 :     m_aBorder.SetBorderStyle(WINDOW_BORDER_MONO);
     208                 :            : 
     209 [ #  # ][ #  # ]:          0 :     m_aMenu.reset(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) ));
                 [ #  # ]
     210                 :            : 
     211         [ #  # ]:          0 :     m_aTBPreview.SetOutStyle(TOOLBOX_STYLE_FLAT);
     212 [ #  # ][ #  # ]:          0 :     m_aTBPreview.InsertItem(SID_DB_APP_DISABLE_PREVIEW,m_aMenu->GetItemText(SID_DB_APP_DISABLE_PREVIEW),TIB_LEFT|TIB_DROPDOWN|TIB_AUTOSIZE|TIB_RADIOCHECK);
                 [ #  # ]
     213         [ #  # ]:          0 :     m_aTBPreview.SetHelpId(HID_APP_VIEW_PREVIEW_CB);
     214 [ #  # ][ #  # ]:          0 :     m_aTBPreview.SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) );
     215                 :          0 :     m_aTBPreview.EnableMenuStrings();
     216         [ #  # ]:          0 :     m_aTBPreview.Enable(sal_True);
     217                 :            : 
     218         [ #  # ]:          0 :     m_aBorder.SetUniqueId(UID_APP_VIEW_PREVIEW_1);
     219                 :            : 
     220         [ #  # ]:          0 :     m_aPreview.SetHelpId(HID_APP_VIEW_PREVIEW_1);
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :     m_pTablePreview = new OTablePreviewWindow(&m_aBorder,WB_READONLY | WB_DIALOGCONTROL );
     223         [ #  # ]:          0 :     m_pTablePreview->SetHelpId(HID_APP_VIEW_PREVIEW_2);
     224                 :            : 
     225         [ #  # ]:          0 :     m_aDocumentInfo.SetHelpId(HID_APP_VIEW_PREVIEW_3);
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :     m_xWindow = VCLUnoHelper::GetInterface( m_pTablePreview );
     228                 :            : 
     229         [ #  # ]:          0 :     SetUniqueId(UID_APP_DETAILPAGE_HELPER);
     230         [ #  # ]:          0 :     for (int i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
     231                 :          0 :         m_pLists[i] = NULL;
     232         [ #  # ]:          0 :     ImplInitSettings();
     233                 :          0 : }
     234                 :            : // -----------------------------------------------------------------------------
     235 [ #  # ][ #  # ]:          0 : OAppDetailPageHelper::~OAppDetailPageHelper()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     236                 :            : {
     237                 :            :     try
     238                 :            :     {
     239         [ #  # ]:          0 :         Reference< ::util::XCloseable> xCloseable(m_xFrame,UNO_QUERY);
     240         [ #  # ]:          0 :         if ( xCloseable.is() )
     241 [ #  # ][ #  # ]:          0 :             xCloseable->close(sal_True);
                 [ #  # ]
     242                 :            :     }
     243         [ #  # ]:          0 :     catch(const Exception&)
     244                 :            :     {
     245                 :            :         OSL_FAIL("Exception thrown while disposing preview frame!");
     246                 :            :     }
     247                 :            : 
     248         [ #  # ]:          0 :     for (int i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
     249                 :            :     {
     250         [ #  # ]:          0 :         if ( m_pLists[i] )
     251                 :            :         {
     252                 :          0 :             m_pLists[i]->clearCurrentSelection();
     253         [ #  # ]:          0 :             m_pLists[i]->Hide();
     254                 :            :             SAL_WNODEPRECATED_DECLARATIONS_PUSH
     255                 :          0 :             ::std::auto_ptr<DBTreeListBox> aTemp(m_pLists[i]);
     256                 :            :             SAL_WNODEPRECATED_DECLARATIONS_POP
     257                 :          0 :             m_pLists[i]->clearCurrentSelection();   // why a second time?
     258         [ #  # ]:          0 :             m_pLists[i] = NULL;
     259                 :            :         }
     260                 :            : 
     261                 :            :     }
     262                 :            : 
     263                 :            :     DBG_DTOR(OAppDetailPageHelper,NULL);
     264         [ #  # ]:          0 : }
     265                 :            : // -----------------------------------------------------------------------------
     266                 :          0 : int OAppDetailPageHelper::getVisibleControlIndex() const
     267                 :            : {
     268                 :          0 :     int i = 0;
     269         [ #  # ]:          0 :     for (; i < E_ELEMENT_TYPE_COUNT ; ++i)
     270                 :            :     {
     271 [ #  # ][ #  # ]:          0 :         if ( m_pLists[i] && m_pLists[i]->IsVisible() )
                 [ #  # ]
     272                 :          0 :             break;
     273                 :            :     }
     274                 :          0 :     return i;
     275                 :            : }
     276                 :            : // -----------------------------------------------------------------------------
     277                 :          0 : void OAppDetailPageHelper::selectAll()
     278                 :            : {
     279                 :          0 :     int nPos = getVisibleControlIndex();
     280         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     281                 :            :     {
     282                 :          0 :         m_pLists[nPos]->SelectAll(sal_True);
     283                 :            :     }
     284                 :          0 : }
     285                 :            : // -----------------------------------------------------------------------------
     286                 :          0 : void OAppDetailPageHelper::sort(int _nPos,SvSortMode _eSortMode )
     287                 :            : {
     288                 :            :     OSL_ENSURE(m_pLists[_nPos],"List can not be NULL! ->GPF");
     289                 :          0 :     SvLBoxTreeList* pModel = m_pLists[_nPos]->GetModel();
     290                 :          0 :     SvSortMode eOldSortMode = pModel->GetSortMode();
     291                 :          0 :     pModel->SetSortMode(_eSortMode);
     292         [ #  # ]:          0 :     if ( eOldSortMode != _eSortMode )
     293                 :          0 :         pModel->Resort();
     294                 :          0 : }
     295                 :            : // -----------------------------------------------------------------------------
     296                 :          0 : sal_Bool OAppDetailPageHelper::isSortUp() const
     297                 :            : {
     298                 :          0 :     SvSortMode eSortMode = SortNone;
     299                 :          0 :     int nPos = getVisibleControlIndex();
     300         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     301                 :            :     {
     302                 :          0 :         SvLBoxTreeList* pModel = m_pLists[nPos]->GetModel();
     303                 :          0 :         eSortMode = pModel->GetSortMode();
     304                 :            :     }
     305                 :          0 :     return eSortMode == SortAscending;
     306                 :            : }
     307                 :            : // -----------------------------------------------------------------------------
     308                 :          0 : void OAppDetailPageHelper::sortDown()
     309                 :            : {
     310                 :          0 :     int nPos = getVisibleControlIndex();
     311         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     312                 :          0 :         sort(nPos,SortDescending);
     313                 :          0 : }
     314                 :            : // -----------------------------------------------------------------------------
     315                 :          0 : void OAppDetailPageHelper::sortUp()
     316                 :            : {
     317                 :          0 :     int nPos = getVisibleControlIndex();
     318         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     319                 :          0 :         sort(nPos,SortAscending);
     320                 :          0 : }
     321                 :            : // -----------------------------------------------------------------------------
     322                 :          0 : void OAppDetailPageHelper::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const
     323                 :            : {
     324                 :          0 :     int nPos = getVisibleControlIndex();
     325         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     326                 :            :     {
     327                 :          0 :         DBTreeListBox& rTree = *m_pLists[nPos];
     328                 :          0 :         sal_Int32 nCount = rTree.GetEntryCount();
     329                 :          0 :         _rNames.reserve(nCount);
     330                 :          0 :         SvLBoxEntry* pEntry = rTree.FirstSelected();
     331                 :          0 :         ElementType eType = getElementType();
     332         [ #  # ]:          0 :         while( pEntry )
     333                 :            :         {
     334         [ #  # ]:          0 :             if ( eType == E_TABLE )
     335                 :            :             {
     336         [ #  # ]:          0 :                 if( rTree.GetChildCount(pEntry) == 0 )
     337         [ #  # ]:          0 :                     _rNames.push_back( getQualifiedName( pEntry ) );
     338                 :            :             }
     339                 :            :             else
     340                 :            :             {
     341 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString sName = rTree.GetEntryText(pEntry);
                 [ #  # ]
     342         [ #  # ]:          0 :                 SvLBoxEntry* pParent = rTree.GetParent(pEntry);
     343         [ #  # ]:          0 :                 while(pParent)
     344                 :            :                 {
     345 [ #  # ][ #  # ]:          0 :                     sName = rTree.GetEntryText(pParent) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
         [ #  # ][ #  # ]
     346         [ #  # ]:          0 :                     pParent = rTree.GetParent(pParent);
     347                 :            :                 }
     348         [ #  # ]:          0 :                 _rNames.push_back(sName);
     349                 :            :             }
     350                 :          0 :             pEntry = rTree.NextSelected(pEntry);
     351                 :            :         }
     352                 :            :     }
     353                 :          0 : }
     354                 :            : 
     355                 :            : // -----------------------------------------------------------------------------
     356                 :          0 : void OAppDetailPageHelper::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
     357                 :            : {
     358                 :          0 :     enum ElementType eType = E_TABLE;
     359         [ #  # ]:          0 :     for ( size_t i=0; i < E_ELEMENT_TYPE_COUNT; eType = static_cast< ElementType >( ++i ) )
     360                 :            :     {
     361         [ #  # ]:          0 :         if ( m_pLists[eType] == &_rControl )
     362                 :            :         {
     363                 :          0 :             describeCurrentSelectionForType( eType, _out_rSelectedObjects );
     364                 :          0 :             return;
     365                 :            :         }
     366                 :            :     }
     367                 :            :     OSL_FAIL( "OAppDetailPageHelper::describeCurrentSelectionForControl: invalid control!" );
     368                 :            : }
     369                 :            : 
     370                 :            : // -----------------------------------------------------------------------------
     371                 :          0 : void OAppDetailPageHelper::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
     372                 :            : {
     373                 :            :     OSL_ENSURE( _eType < E_ELEMENT_TYPE_COUNT, "OAppDetailPageHelper::describeCurrentSelectionForType: invalid type!" );
     374         [ #  # ]:          0 :     DBTreeListBox* pList = ( _eType < E_ELEMENT_TYPE_COUNT ) ? m_pLists[ _eType ] : NULL;
     375                 :            :     OSL_ENSURE( pList, "OAppDetailPageHelper::describeCurrentSelectionForType: "
     376                 :            :                        "You really should ensure this type has already been viewed before!" );
     377         [ #  # ]:          0 :     if ( !pList )
     378                 :          0 :         return;
     379                 :            : 
     380         [ #  # ]:          0 :     ::std::vector< NamedDatabaseObject > aSelected;
     381                 :            : 
     382         [ #  # ]:          0 :     SvLBoxEntry* pEntry = pList->FirstSelected();
     383         [ #  # ]:          0 :     while( pEntry )
     384                 :            :     {
     385                 :          0 :         NamedDatabaseObject aObject;
     386   [ #  #  #  # ]:          0 :         switch ( _eType )
     387                 :            :         {
     388                 :            :         case E_TABLE:
     389                 :            :         {
     390         [ #  # ]:          0 :             OTableTreeListBox& rTableTree = dynamic_cast< OTableTreeListBox& >( *pList );
     391         [ #  # ]:          0 :             aObject = rTableTree.describeObject( pEntry );
     392                 :            :         }
     393                 :          0 :         break;
     394                 :            :         case E_QUERY:
     395                 :          0 :             aObject.Type = DatabaseObject::QUERY;
     396 [ #  # ][ #  # ]:          0 :             aObject.Name = pList->GetEntryText( pEntry );
                 [ #  # ]
     397                 :          0 :             break;
     398                 :            : 
     399                 :            :         case E_FORM:
     400                 :            :         case E_REPORT:
     401                 :            :         {
     402 [ #  # ][ #  # ]:          0 :             ::rtl::OUString sName = pList->GetEntryText(pEntry);
                 [ #  # ]
     403         [ #  # ]:          0 :             SvLBoxEntry* pParent = pList->GetParent(pEntry);
     404         [ #  # ]:          0 :             while ( pParent )
     405                 :            :             {
     406                 :          0 :                 ::rtl::OUStringBuffer buffer;
     407 [ #  # ][ #  # ]:          0 :                 buffer.append( pList->GetEntryText( pParent ) );
         [ #  # ][ #  # ]
     408         [ #  # ]:          0 :                 buffer.append( sal_Unicode( '/' ) );
     409         [ #  # ]:          0 :                 buffer.append( sName );
     410         [ #  # ]:          0 :                 sName = buffer.makeStringAndClear();
     411                 :            : 
     412         [ #  # ]:          0 :                 pParent = pList->GetParent( pParent );
     413                 :          0 :             }
     414                 :            : 
     415         [ #  # ]:          0 :             if ( isLeaf( pEntry ) )
     416         [ #  # ]:          0 :                 aObject.Type = ( _eType == E_FORM ) ? DatabaseObject::FORM : DatabaseObject::REPORT;
     417                 :            :             else
     418         [ #  # ]:          0 :                 aObject.Type = ( _eType == E_FORM ) ? DatabaseObjectContainer::FORMS_FOLDER : DatabaseObjectContainer::REPORTS_FOLDER;
     419                 :          0 :             aObject.Name = sName;
     420                 :            :         }
     421                 :          0 :         break;
     422                 :            :         default:
     423                 :            :             OSL_FAIL( "OAppDetailPageHelper::describeCurrentSelectionForType: unexpected type!" );
     424                 :          0 :             break;
     425                 :            :         }
     426                 :            : 
     427         [ #  # ]:          0 :         if ( !aObject.Name.isEmpty() )
     428                 :            :         {
     429         [ #  # ]:          0 :             aSelected.push_back( aObject );
     430                 :            :         }
     431                 :            : 
     432         [ #  # ]:          0 :         pEntry = pList->NextSelected(pEntry);
     433                 :          0 :     }
     434                 :            : 
     435         [ #  # ]:          0 :     _out_rSelectedObjects.realloc( aSelected.size() );
     436 [ #  # ][ #  # ]:          0 :     ::std::copy( aSelected.begin(), aSelected.end(), _out_rSelectedObjects.getArray() );
     437                 :            : }
     438                 :            : 
     439                 :            : // -----------------------------------------------------------------------------
     440                 :          0 : void OAppDetailPageHelper::selectElements(const Sequence< ::rtl::OUString>& _aNames)
     441                 :            : {
     442                 :          0 :     int nPos = getVisibleControlIndex();
     443         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     444                 :            :     {
     445                 :          0 :         DBTreeListBox& rTree = *m_pLists[nPos];
     446                 :          0 :         rTree.SelectAll(sal_False);
     447                 :          0 :         const ::rtl::OUString* pIter = _aNames.getConstArray();
     448                 :          0 :         const ::rtl::OUString* pEnd  = pIter + _aNames.getLength();
     449         [ #  # ]:          0 :         for(;pIter != pEnd;++pIter)
     450                 :            :         {
     451         [ #  # ]:          0 :             SvLBoxEntry* pEntry = rTree.GetEntryPosByName(*pIter);
     452         [ #  # ]:          0 :             if ( pEntry )
     453                 :          0 :                 rTree.Select(pEntry);
     454                 :            :         }
     455                 :            :     }
     456                 :          0 : }
     457                 :            : // -----------------------------------------------------------------------------
     458                 :          0 : ::rtl::OUString OAppDetailPageHelper::getQualifiedName( SvLBoxEntry* _pEntry ) const
     459                 :            : {
     460                 :          0 :     int nPos = getVisibleControlIndex();
     461                 :          0 :     ::rtl::OUString sComposedName;
     462                 :            : 
     463         [ #  # ]:          0 :     if ( nPos >= E_ELEMENT_TYPE_COUNT )
     464                 :          0 :         return sComposedName;
     465                 :            : 
     466                 :            :     OSL_ENSURE(m_pLists[nPos],"Tables tree view is NULL! -> GPF");
     467                 :          0 :     DBTreeListBox& rTree = *m_pLists[nPos];
     468                 :            : 
     469                 :          0 :     SvLBoxEntry* pEntry = _pEntry;
     470         [ #  # ]:          0 :     if ( !pEntry )
     471         [ #  # ]:          0 :         pEntry = rTree.FirstSelected();
     472                 :            : 
     473         [ #  # ]:          0 :     if ( !pEntry )
     474                 :          0 :         return sComposedName;
     475                 :            : 
     476 [ #  # ][ #  # ]:          0 :     if ( getElementType() == E_TABLE )
     477                 :            :     {
     478         [ #  # ]:          0 :         const OTableTreeListBox& rTreeView = dynamic_cast< const OTableTreeListBox& >( *m_pLists[nPos] );
     479 [ #  # ][ #  # ]:          0 :         sComposedName = rTreeView.getQualifiedTableName( pEntry );
                 [ #  # ]
     480                 :            :     }
     481                 :            :     else
     482                 :            :     {
     483 [ #  # ][ #  # ]:          0 :         sComposedName = rTree.GetEntryText(pEntry);
                 [ #  # ]
     484         [ #  # ]:          0 :         SvLBoxEntry* pParent = rTree.GetParent(pEntry);
     485         [ #  # ]:          0 :         while(pParent)
     486                 :            :         {
     487 [ #  # ][ #  # ]:          0 :             sComposedName = rTree.GetEntryText(pParent) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sComposedName;
         [ #  # ][ #  # ]
     488         [ #  # ]:          0 :             pParent = rTree.GetParent(pParent);
     489                 :            :         }
     490                 :            :     }
     491                 :            : 
     492                 :          0 :     return sComposedName;
     493                 :            : }
     494                 :            : // -----------------------------------------------------------------------------
     495                 :          0 : ElementType OAppDetailPageHelper::getElementType() const
     496                 :            : {
     497                 :          0 :     int nPos = getVisibleControlIndex();
     498                 :          0 :     return static_cast<ElementType>(nPos);
     499                 :            : }
     500                 :            : // -----------------------------------------------------------------------------
     501                 :          0 : sal_Int32 OAppDetailPageHelper::getSelectionCount()
     502                 :            : {
     503                 :          0 :     sal_Int32 nCount = 0;
     504                 :          0 :     int nPos = getVisibleControlIndex();
     505         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     506                 :            :     {
     507                 :          0 :         DBTreeListBox& rTree = *m_pLists[nPos];
     508                 :          0 :         SvLBoxEntry* pEntry = rTree.FirstSelected();
     509         [ #  # ]:          0 :         while( pEntry )
     510                 :            :         {
     511                 :          0 :             ++nCount;
     512                 :          0 :             pEntry = rTree.NextSelected(pEntry);
     513                 :            :         }
     514                 :            :     }
     515                 :          0 :     return nCount;
     516                 :            : }
     517                 :            : // -----------------------------------------------------------------------------
     518                 :          0 : sal_Int32 OAppDetailPageHelper::getElementCount()
     519                 :            : {
     520                 :          0 :     sal_Int32 nCount = 0;
     521                 :          0 :     int nPos = getVisibleControlIndex();
     522         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     523                 :            :     {
     524                 :          0 :         nCount = m_pLists[nPos]->GetEntryCount();
     525                 :            :     }
     526                 :          0 :     return nCount;
     527                 :            : }
     528                 :            : // -----------------------------------------------------------------------------
     529                 :          0 : sal_Bool OAppDetailPageHelper::isCutAllowed()
     530                 :            : {
     531                 :          0 :     return sal_False;
     532                 :            : }
     533                 :            : // -----------------------------------------------------------------------------
     534                 :          0 : sal_Bool OAppDetailPageHelper::isCopyAllowed()
     535                 :            : {
     536                 :          0 :     return sal_True;
     537                 :            : }
     538                 :            : // -----------------------------------------------------------------------------
     539                 :          0 : sal_Bool OAppDetailPageHelper::isPasteAllowed()
     540                 :            : {
     541                 :          0 :     return sal_True;
     542                 :            : }
     543                 :            : // -----------------------------------------------------------------------------
     544                 :          0 : void OAppDetailPageHelper::copy()
     545                 :            : {
     546                 :          0 : }
     547                 :            : // -----------------------------------------------------------------------------
     548                 :          0 : void OAppDetailPageHelper::cut()
     549                 :            : {
     550                 :          0 : }
     551                 :            : // -----------------------------------------------------------------------------
     552                 :          0 : void OAppDetailPageHelper::paste()
     553                 :            : {
     554                 :          0 : }
     555                 :            : // -----------------------------------------------------------------------------
     556                 :          0 : bool OAppDetailPageHelper::isLeaf(SvLBoxEntry* _pEntry) const
     557                 :            : {
     558         [ #  # ]:          0 :     if ( !_pEntry )
     559                 :          0 :         return false;
     560                 :          0 :     sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
     561 [ #  # ][ #  # ]:          0 :     if  (   ( nEntryType == DatabaseObjectContainer::TABLES )
         [ #  # ][ #  # ]
                 [ #  # ]
     562                 :            :         ||  ( nEntryType == DatabaseObjectContainer::CATALOG )
     563                 :            :         ||  ( nEntryType == DatabaseObjectContainer::SCHEMA )
     564                 :            :         ||  ( nEntryType == DatabaseObjectContainer::FORMS_FOLDER )
     565                 :            :         ||  ( nEntryType == DatabaseObjectContainer::REPORTS_FOLDER )
     566                 :            :         )
     567                 :          0 :         return false;
     568                 :            : 
     569                 :          0 :     return true;
     570                 :            : }
     571                 :            : 
     572                 :            : // -----------------------------------------------------------------------------
     573                 :          0 : sal_Bool OAppDetailPageHelper::isALeafSelected() const
     574                 :            : {
     575                 :          0 :     int nPos = getVisibleControlIndex();
     576                 :          0 :     sal_Bool bLeafSelected = sal_False;
     577         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     578                 :            :     {
     579                 :          0 :         DBTreeListBox& rTree = *m_pLists[nPos];
     580                 :          0 :         SvLBoxEntry* pEntry = rTree.FirstSelected( );
     581 [ #  # ][ #  # ]:          0 :         while( !bLeafSelected && pEntry )
                 [ #  # ]
     582                 :            :         {
     583                 :          0 :             bLeafSelected = isLeaf( pEntry );
     584                 :          0 :             pEntry = rTree.NextSelected(pEntry);
     585                 :            :         }
     586                 :            :     }
     587                 :          0 :     return bLeafSelected;
     588                 :            : }
     589                 :            : // -----------------------------------------------------------------------------
     590                 :          0 : SvLBoxEntry* OAppDetailPageHelper::getEntry( const Point& _aPosPixel) const
     591                 :            : {
     592                 :          0 :     SvLBoxEntry* pReturn = NULL;
     593                 :          0 :     int nPos = getVisibleControlIndex();
     594         [ #  # ]:          0 :     if ( nPos < E_ELEMENT_TYPE_COUNT )
     595                 :          0 :         pReturn = m_pLists[nPos]->GetEntry( _aPosPixel,sal_True );
     596                 :          0 :     return pReturn;
     597                 :            : }
     598                 :            : // -----------------------------------------------------------------------------
     599                 :          0 : void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xConnection)
     600                 :            : {
     601                 :            :     OSL_ENSURE(_xConnection.is(),"Connection is NULL! -> GPF");
     602                 :            : 
     603         [ #  # ]:          0 :     if ( !m_pLists[E_TABLE] )
     604                 :            :     {
     605                 :            :         OTableTreeListBox* pTreeView = new OTableTreeListBox(this
     606         [ #  # ]:          0 :                                                             ,getBorderWin().getView()->getORB()
     607                 :            :                                                             ,WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP
     608 [ #  # ][ #  # ]:          0 :                                                             ,sal_False);
                 [ #  # ]
     609         [ #  # ]:          0 :         pTreeView->SetHelpId(HID_APP_TABLE_TREE);
     610                 :          0 :         m_pLists[E_TABLE] = pTreeView;
     611                 :            : 
     612         [ #  # ]:          0 :         ImageProvider aImageProvider( _xConnection );
     613                 :            :         createTree( pTreeView,
     614                 :            :             aImageProvider.getDefaultImage( DatabaseObject::TABLE )
     615 [ #  # ][ #  # ]:          0 :         );
                 [ #  # ]
     616                 :            : 
     617         [ #  # ]:          0 :         pTreeView->notifyHiContrastChanged();
     618 [ #  # ][ #  # ]:          0 :         m_aBorder.SetZOrder(pTreeView, WINDOW_ZORDER_BEHIND);
     619                 :            :     }
     620         [ #  # ]:          0 :     if ( !m_pLists[E_TABLE]->GetEntryCount() )
     621                 :            :     {
     622                 :          0 :         static_cast<OTableTreeListBox*>(m_pLists[E_TABLE])->UpdateTableList(_xConnection);
     623                 :            : 
     624                 :          0 :         SvLBoxEntry* pEntry = m_pLists[E_TABLE]->First();
     625         [ #  # ]:          0 :         if ( pEntry )
     626                 :          0 :             m_pLists[E_TABLE]->Expand(pEntry);
     627                 :          0 :         m_pLists[E_TABLE]->SelectAll(sal_False);
     628                 :            :     }
     629                 :            : 
     630                 :          0 :     setDetailPage(m_pLists[E_TABLE]);
     631                 :          0 : }
     632                 :            : 
     633                 :            : // -----------------------------------------------------------------------------
     634                 :          0 : void OAppDetailPageHelper::getElementIcons( ElementType _eType, sal_uInt16& _rImageId)
     635                 :            : {
     636         [ #  # ]:          0 :     ImageProvider aImageProvider;
     637                 :          0 :     _rImageId = 0;
     638                 :            : 
     639                 :          0 :     sal_Int32 nDatabaseObjectType( 0 );
     640   [ #  #  #  # ]:          0 :     switch(_eType )
     641                 :            :     {
     642                 :          0 :         case E_FORM:    nDatabaseObjectType = DatabaseObject::FORM; break;
     643                 :          0 :         case E_REPORT:  nDatabaseObjectType = DatabaseObject::REPORT; break;
     644                 :          0 :         case E_QUERY:   nDatabaseObjectType = DatabaseObject::QUERY; break;
     645                 :            :         default:
     646                 :            :             OSL_FAIL( "OAppDetailPageHelper::GetElementIcons: invalid element type!" );
     647                 :          0 :             return;
     648                 :            :     }
     649 [ #  # ][ #  # ]:          0 :     _rImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType );
                 [ #  # ]
     650                 :            : }
     651                 :            : 
     652                 :            : // -----------------------------------------------------------------------------
     653                 :          0 : void OAppDetailPageHelper::createPage(ElementType _eType,const Reference< XNameAccess >& _xContainer)
     654                 :            : {
     655                 :            :     OSL_ENSURE(E_TABLE != _eType,"E_TABLE isn't allowed.");
     656                 :            : 
     657                 :          0 :     sal_uInt16 nImageId = 0;
     658                 :          0 :     rtl::OString sHelpId;
     659         [ #  # ]:          0 :     ImageProvider aImageProvider;
     660         [ #  # ]:          0 :     Image aFolderImage;
     661   [ #  #  #  # ]:          0 :     switch( _eType )
     662                 :            :     {
     663                 :            :         case E_FORM:
     664                 :          0 :             sHelpId = HID_APP_FORM_TREE;
     665 [ #  # ][ #  # ]:          0 :             aFolderImage = aImageProvider.getFolderImage( DatabaseObject::FORM );
                 [ #  # ]
     666                 :          0 :             break;
     667                 :            :         case E_REPORT:
     668                 :          0 :             sHelpId = HID_APP_REPORT_TREE;
     669 [ #  # ][ #  # ]:          0 :             aFolderImage = aImageProvider.getFolderImage( DatabaseObject::REPORT );
                 [ #  # ]
     670                 :          0 :             break;
     671                 :            :         case E_QUERY:
     672                 :          0 :             sHelpId = HID_APP_QUERY_TREE;
     673 [ #  # ][ #  # ]:          0 :             aFolderImage = aImageProvider.getFolderImage( DatabaseObject::QUERY );
                 [ #  # ]
     674                 :          0 :             break;
     675                 :            :         default:
     676                 :            :             OSL_FAIL("Illegal call!");
     677                 :            :     }
     678         [ #  # ]:          0 :     getElementIcons( _eType, nImageId );
     679                 :            : 
     680         [ #  # ]:          0 :     if ( !m_pLists[_eType] )
     681                 :            :     {
     682         [ #  # ]:          0 :         m_pLists[_eType] = createSimpleTree( sHelpId, aFolderImage );
     683                 :            :     }
     684                 :            : 
     685         [ #  # ]:          0 :     if ( m_pLists[_eType] )
     686                 :            :     {
     687 [ #  # ][ #  # ]:          0 :         if ( !m_pLists[_eType]->GetEntryCount() && _xContainer.is() )
                 [ #  # ]
     688                 :            :         {
     689         [ #  # ]:          0 :             fillNames( _xContainer, _eType, nImageId, NULL );
     690                 :            : 
     691         [ #  # ]:          0 :             m_pLists[_eType]->SelectAll(sal_False);
     692                 :            :         }
     693         [ #  # ]:          0 :         setDetailPage(m_pLists[_eType]);
     694 [ #  # ][ #  # ]:          0 :     }
     695                 :          0 : }
     696                 :            : // -----------------------------------------------------------------------------
     697                 :          0 : void OAppDetailPageHelper::setDetailPage(Window* _pWindow)
     698                 :            : {
     699                 :            :     OSL_ENSURE(_pWindow,"OAppDetailPageHelper::setDetailPage: Window is NULL!");
     700                 :          0 :     Window* pCurrent = getCurrentView();
     701         [ #  # ]:          0 :     if ( pCurrent )
     702                 :          0 :         pCurrent->Hide();
     703                 :            : 
     704         [ #  # ]:          0 :     showPreview(NULL);
     705                 :          0 :     sal_Bool bHasFocus = sal_False;
     706                 :          0 :     m_aFL.Show();
     707                 :            :     {
     708                 :          0 :         bHasFocus = pCurrent->HasChildPathFocus();
     709                 :          0 :     _pWindow->Show();
     710                 :            :     }
     711                 :          0 :     m_aTBPreview.Show();
     712                 :          0 :     m_aBorder.Show();
     713                 :          0 :     switchPreview(m_ePreviewMode,sal_True);
     714                 :            : 
     715         [ #  # ]:          0 :     if ( bHasFocus )
     716                 :          0 :         _pWindow->GrabFocus();
     717                 :          0 :     Resize();
     718                 :          0 : }
     719                 :            : 
     720                 :            : // -----------------------------------------------------------------------------
     721                 :            : namespace
     722                 :            : {
     723                 :            :     namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
     724                 :            :     namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
     725                 :            : 
     726                 :          0 :     static sal_Int32 lcl_getFolderIndicatorForType( const ElementType _eType )
     727                 :            :     {
     728                 :            :         const sal_Int32 nFolderIndicator =
     729                 :            :                 ( _eType == E_FORM ) ? DatabaseObjectContainer::FORMS_FOLDER
     730 [ #  # ][ #  # ]:          0 :             :   ( _eType == E_REPORT ) ? DatabaseObjectContainer::REPORTS_FOLDER : -1;
     731                 :          0 :         return nFolderIndicator;
     732                 :            :     }
     733                 :            : }
     734                 :            : 
     735                 :            : // -----------------------------------------------------------------------------
     736                 :          0 : void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContainer, const ElementType _eType,
     737                 :            :                                       const sal_uInt16 _nImageId, SvLBoxEntry* _pParent )
     738                 :            : {
     739                 :            :     OSL_ENSURE(_xContainer.is(),"Data source is NULL! -> GPF");
     740                 :            :     OSL_ENSURE( ( _eType >= E_TABLE ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OAppDetailPageHelper::fillNames: invalid type!" );
     741                 :            : 
     742                 :          0 :     DBTreeListBox* pList = m_pLists[ _eType ];
     743                 :            :     OSL_ENSURE( pList, "OAppDetailPageHelper::fillNames: you really should create the list before calling this!" );
     744         [ #  # ]:          0 :     if ( !pList )
     745                 :          0 :         return;
     746                 :            : 
     747 [ #  # ][ #  # ]:          0 :     if ( _xContainer.is() && _xContainer->hasElements() )
                 [ #  # ]
     748                 :            :     {
     749                 :          0 :         const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType );
     750                 :            : 
     751 [ #  # ][ #  # ]:          0 :         Sequence< ::rtl::OUString> aSeq = _xContainer->getElementNames();
     752                 :          0 :         const ::rtl::OUString* pIter = aSeq.getConstArray();
     753                 :          0 :         const ::rtl::OUString* pEnd  = pIter + aSeq.getLength();
     754         [ #  # ]:          0 :         for(;pIter != pEnd;++pIter)
     755                 :            :         {
     756                 :          0 :             SvLBoxEntry* pEntry = NULL;
     757 [ #  # ][ #  # ]:          0 :             Reference<XNameAccess> xSubElements(_xContainer->getByName(*pIter),UNO_QUERY);
                 [ #  # ]
     758         [ #  # ]:          0 :             if ( xSubElements.is() )
     759                 :            :             {
     760 [ #  # ][ #  # ]:          0 :                 pEntry = pList->InsertEntry( *pIter, _pParent, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) );
                 [ #  # ]
     761 [ #  # ][ #  # ]:          0 :                 getBorderWin().getView()->getAppController().containerFound( Reference< XContainer >( xSubElements, UNO_QUERY ) );
                 [ #  # ]
     762         [ #  # ]:          0 :                 fillNames( xSubElements, _eType, _nImageId, pEntry );
     763                 :            :             }
     764                 :            :             else
     765                 :            :             {
     766 [ #  # ][ #  # ]:          0 :                 pEntry = pList->InsertEntry( *pIter, _pParent );
                 [ #  # ]
     767                 :            : 
     768 [ #  # ][ #  # ]:          0 :                 Image aImage = Image( ModuleRes( _nImageId ) );
     769         [ #  # ]:          0 :                 pList->SetExpandedEntryBmp(  pEntry, aImage );
     770 [ #  # ][ #  # ]:          0 :                 pList->SetCollapsedEntryBmp( pEntry, aImage );
     771                 :            :             }
     772         [ #  # ]:          0 :         }
     773                 :            :     }
     774                 :            : }
     775                 :            : // -----------------------------------------------------------------------------
     776                 :          0 : DBTreeListBox* OAppDetailPageHelper::createSimpleTree( const rtl::OString& _sHelpId, const Image& _rImage)
     777                 :            : {
     778 [ #  # ][ #  # ]:          0 :     DBTreeListBox* pTreeView = new DBTreeListBox(this,getBorderWin().getView()->getORB(),WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP);
     779                 :          0 :     pTreeView->SetHelpId( _sHelpId );
     780                 :          0 :     return createTree( pTreeView, _rImage );
     781                 :            : }
     782                 :            : 
     783                 :            : // -----------------------------------------------------------------------------
     784                 :          0 : DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, const Image& _rImage )
     785                 :            : {
     786         [ #  # ]:          0 :     WaitObject aWaitCursor(this);
     787                 :            : 
     788 [ #  # ][ #  # ]:          0 :     _pTreeView->SetStyle(_pTreeView->GetStyle() | WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP);
     789                 :          0 :     _pTreeView->GetModel()->SetSortMode(SortAscending);
     790         [ #  # ]:          0 :     _pTreeView->EnableCheckButton( NULL ); // do not show any buttons
     791         [ #  # ]:          0 :     _pTreeView->SetSelectionMode(MULTIPLE_SELECTION);
     792                 :            : 
     793         [ #  # ]:          0 :     _pTreeView->SetDefaultCollapsedEntryBmp( _rImage );
     794         [ #  # ]:          0 :     _pTreeView->SetDefaultExpandedEntryBmp( _rImage );
     795                 :            : 
     796         [ #  # ]:          0 :     _pTreeView->SetDoubleClickHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
     797         [ #  # ]:          0 :     _pTreeView->SetEnterKeyHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
     798         [ #  # ]:          0 :     _pTreeView->SetSelChangeHdl(LINK(this, OAppDetailPageHelper, OnEntrySelChange));
     799                 :            : 
     800         [ #  # ]:          0 :     _pTreeView->setCutHandler(LINK(this, OAppDetailPageHelper, OnCutEntry));
     801         [ #  # ]:          0 :     _pTreeView->setCopyHandler(LINK(this, OAppDetailPageHelper, OnCopyEntry));
     802         [ #  # ]:          0 :     _pTreeView->setPasteHandler(LINK(this, OAppDetailPageHelper, OnPasteEntry));
     803         [ #  # ]:          0 :     _pTreeView->setDeleteHandler(LINK(this, OAppDetailPageHelper, OnDeleteEntry));
     804                 :            : 
     805 [ #  # ][ #  # ]:          0 :     _pTreeView->setControlActionListener( &getBorderWin().getView()->getAppController() );
     806 [ #  # ][ #  # ]:          0 :     _pTreeView->setContextMenuProvider( &getBorderWin().getView()->getAppController() );
     807                 :            : 
     808         [ #  # ]:          0 :     return _pTreeView;
     809                 :            : }
     810                 :            : // -----------------------------------------------------------------------------
     811                 :          0 : void OAppDetailPageHelper::clearPages()
     812                 :            : {
     813         [ #  # ]:          0 :     showPreview(NULL);
     814         [ #  # ]:          0 :     for (size_t i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
     815                 :            :     {
     816         [ #  # ]:          0 :         if ( m_pLists[i] )
     817                 :          0 :             m_pLists[i]->Clear();
     818                 :            :     }
     819                 :          0 : }
     820                 :            : // -----------------------------------------------------------------------------
     821                 :          0 : sal_Bool OAppDetailPageHelper::isFilled() const
     822                 :            : {
     823                 :          0 :     size_t i = 0;
     824 [ #  # ][ #  # ]:          0 :     for (; i < E_ELEMENT_TYPE_COUNT && !m_pLists[i]; ++i)
                 [ #  # ]
     825                 :            :         ;
     826                 :          0 :     return i != E_ELEMENT_TYPE_COUNT;
     827                 :            : }
     828                 :            : // -----------------------------------------------------------------------------
     829                 :          0 : void OAppDetailPageHelper::elementReplaced(ElementType _eType
     830                 :            :                                                     ,const ::rtl::OUString& _rOldName
     831                 :            :                                                     ,const ::rtl::OUString& _rNewName )
     832                 :            : {
     833                 :          0 :     DBTreeListBox* pTreeView = getCurrentView();
     834         [ #  # ]:          0 :     if ( pTreeView )
     835                 :            :     {
     836                 :          0 :         ::rtl::OUString sNewName = _rNewName;
     837                 :          0 :         SvLBoxEntry* pEntry = NULL;
     838   [ #  #  #  # ]:          0 :         switch( _eType )
     839                 :            :         {
     840                 :            :             case E_TABLE:
     841         [ #  # ]:          0 :                 static_cast<OTableTreeListBox*>(pTreeView)->removedTable( _rOldName );
     842         [ #  # ]:          0 :                 static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rNewName );
     843                 :          0 :                 return;
     844                 :            : 
     845                 :            :             case E_QUERY:
     846 [ #  # ][ #  # ]:          0 :                 pEntry = lcl_findEntry_impl(*pTreeView,_rOldName,pTreeView->First());
     847                 :          0 :                 break;
     848                 :            :             case E_FORM:
     849                 :            :             case E_REPORT:
     850 [ #  # ][ #  # ]:          0 :                 pEntry = lcl_findEntry(*pTreeView,_rOldName,pTreeView->First());
     851                 :          0 :                 break;
     852                 :            :             default:
     853                 :            :                 OSL_FAIL("Invalid element type");
     854                 :            :         }
     855                 :            :         OSL_ENSURE(pEntry,"Do you know that the name isn't existence!");
     856         [ #  # ]:          0 :         if ( pEntry )
     857                 :            :         {
     858 [ #  # ][ #  # ]:          0 :             pTreeView->SetEntryText(pEntry,sNewName);
                 [ #  # ]
     859         [ #  # ]:          0 :         }
     860                 :            :     }
     861                 :            : }
     862                 :            : // -----------------------------------------------------------------------------
     863                 :          0 : SvLBoxEntry* OAppDetailPageHelper::elementAdded(ElementType _eType,const ::rtl::OUString& _rName, const Any& _rObject )
     864                 :            : {
     865                 :          0 :     SvLBoxEntry* pRet = NULL;
     866                 :          0 :     DBTreeListBox* pTreeView = m_pLists[_eType];
     867 [ #  # ][ #  # ]:          0 :     if( _eType == E_TABLE && pTreeView )
     868                 :            :     {
     869                 :          0 :         pRet = static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rName );
     870                 :            :     }
     871         [ #  # ]:          0 :     else if ( pTreeView )
     872                 :            :     {
     873                 :            : 
     874                 :          0 :         SvLBoxEntry* pEntry = NULL;
     875         [ #  # ]:          0 :         Reference<XChild> xChild(_rObject,UNO_QUERY);
     876 [ #  # ][ #  # ]:          0 :         if ( xChild.is() && E_QUERY != _eType )
                 [ #  # ]
     877                 :            :         {
     878 [ #  # ][ #  # ]:          0 :             Reference<XContent> xContent(xChild->getParent(),UNO_QUERY);
                 [ #  # ]
     879         [ #  # ]:          0 :             if ( xContent.is() )
     880                 :            :             {
     881 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString sName = xContent->getIdentifier()->getContentIdentifier();
         [ #  # ][ #  # ]
     882 [ #  # ][ #  # ]:          0 :                 pEntry = lcl_findEntry(*pTreeView,sName,pTreeView->First());
     883                 :          0 :             }
     884                 :            :         }
     885                 :            : 
     886                 :          0 :         sal_uInt16 nImageId = 0;
     887         [ #  # ]:          0 :         getElementIcons( _eType, nImageId );
     888         [ #  # ]:          0 :         Reference<XNameAccess> xContainer(_rObject,UNO_QUERY);
     889         [ #  # ]:          0 :         if ( xContainer.is() )
     890                 :            :         {
     891                 :          0 :             const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType );
     892 [ #  # ][ #  # ]:          0 :             pRet = pTreeView->InsertEntry( _rName, pEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) );
                 [ #  # ]
     893         [ #  # ]:          0 :             fillNames( xContainer, _eType, nImageId, pRet );
     894                 :            :         }
     895                 :            :         else
     896                 :            :         {
     897 [ #  # ][ #  # ]:          0 :             pRet = pTreeView->InsertEntry( _rName, pEntry );
                 [ #  # ]
     898                 :            : 
     899 [ #  # ][ #  # ]:          0 :             Image aImage = Image( ModuleRes( nImageId ) );
     900         [ #  # ]:          0 :             pTreeView->SetExpandedEntryBmp(  pRet, aImage );
     901 [ #  # ][ #  # ]:          0 :             pTreeView->SetCollapsedEntryBmp( pRet, aImage );
     902                 :          0 :         }
     903                 :            :     }
     904                 :          0 :     return pRet;
     905                 :            : }
     906                 :            : // -----------------------------------------------------------------------------
     907                 :          0 : void OAppDetailPageHelper::elementRemoved( ElementType _eType,const ::rtl::OUString& _rName )
     908                 :            : {
     909                 :          0 :     DBTreeListBox* pTreeView = getCurrentView();
     910         [ #  # ]:          0 :     if ( pTreeView )
     911                 :            :     {
     912   [ #  #  #  # ]:          0 :         switch( _eType )
     913                 :            :         {
     914                 :            :             case E_TABLE:
     915                 :            :                 // we don't need to clear the table here, it is already done by the dispose listener
     916                 :          0 :                 static_cast< OTableTreeListBox* >( pTreeView )->removedTable( _rName );
     917                 :          0 :                 break;
     918                 :            :             case E_QUERY:
     919         [ #  # ]:          0 :                 if ( pTreeView )
     920                 :            :                 {
     921                 :          0 :                     SvLBoxEntry* pEntry = lcl_findEntry_impl(*pTreeView,_rName,pTreeView->First());
     922         [ #  # ]:          0 :                     if ( pEntry )
     923                 :          0 :                         pTreeView->GetModel()->Remove(pEntry);
     924                 :            :                 }
     925                 :          0 :                 break;
     926                 :            :             case E_FORM:
     927                 :            :             case E_REPORT:
     928                 :            :                 {
     929         [ #  # ]:          0 :                     if ( pTreeView )
     930                 :            :                     {
     931                 :          0 :                         SvLBoxEntry* pEntry = lcl_findEntry(*pTreeView,_rName,pTreeView->First());
     932         [ #  # ]:          0 :                         if ( pEntry )
     933                 :          0 :                             pTreeView->GetModel()->Remove(pEntry);
     934                 :            :                     }
     935                 :            :                 }
     936                 :          0 :                 break;
     937                 :            :             default:
     938                 :            :                 OSL_FAIL("Invalid element type");
     939                 :            :         }
     940         [ #  # ]:          0 :         if ( !pTreeView->GetEntryCount() )
     941         [ #  # ]:          0 :             showPreview(NULL);
     942                 :            :     }
     943                 :          0 : }
     944                 :            : // -----------------------------------------------------------------------------
     945                 :          0 : IMPL_LINK(OAppDetailPageHelper, OnEntryDoubleClick, SvTreeListBox*, _pTree)
     946                 :            : {
     947                 :            :     OSL_ENSURE( _pTree, "OAppDetailPageHelper, OnEntryDoubleClick: invalid callback!" );
     948 [ #  # ][ #  # ]:          0 :     bool bHandled = ( _pTree != NULL ) && getBorderWin().getView()->getAppController().onEntryDoubleClick( *_pTree );
     949         [ #  # ]:          0 :     return bHandled ? 1L : 0L;
     950                 :            : }
     951                 :            : // -----------------------------------------------------------------------------
     952                 :          0 : IMPL_LINK(OAppDetailPageHelper, OnEntrySelChange, void*, /*NOINTERESTEDIN*/)
     953                 :            : {
     954                 :          0 :     getBorderWin().getView()->getAppController().onSelectionChanged();
     955                 :          0 :     return 1L;
     956                 :            : }
     957                 :            : // -----------------------------------------------------------------------------
     958                 :          0 : IMPL_LINK( OAppDetailPageHelper, OnCutEntry, void*, /*NOINTERESTEDIN*/ )
     959                 :            : {
     960                 :          0 :     getBorderWin().getView()->getAppController().onCutEntry();
     961                 :          0 :     return 1L;
     962                 :            : }
     963                 :            : // -----------------------------------------------------------------------------
     964                 :          0 : IMPL_LINK( OAppDetailPageHelper, OnCopyEntry, void*, /*NOINTERESTEDIN*/ )
     965                 :            : {
     966                 :          0 :     getBorderWin().getView()->getAppController().onCopyEntry();
     967                 :          0 :     return 1L;
     968                 :            : }
     969                 :            : // -----------------------------------------------------------------------------
     970                 :          0 : IMPL_LINK( OAppDetailPageHelper, OnPasteEntry, void*, /*NOINTERESTEDIN*/ )
     971                 :            : {
     972                 :          0 :     getBorderWin().getView()->getAppController().onPasteEntry();
     973                 :          0 :     return 1L;
     974                 :            : }
     975                 :            : // -----------------------------------------------------------------------------
     976                 :          0 : IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, void*, /*NOINTERESTEDIN*/ )
     977                 :            : {
     978                 :          0 :     getBorderWin().getView()->getAppController().onDeleteEntry();
     979                 :          0 :     return 1L;
     980                 :            : }
     981                 :            : // -----------------------------------------------------------------------------
     982                 :          0 : void OAppDetailPageHelper::Resize()
     983                 :            : {
     984                 :            :     // parent window dimension
     985         [ #  # ]:          0 :     Size aOutputSize( GetOutputSize() );
     986                 :          0 :     long nOutputWidth  = aOutputSize.Width();
     987                 :          0 :     long nOutputHeight = aOutputSize.Height();
     988                 :            : 
     989         [ #  # ]:          0 :     Window* pWindow = getCurrentView();
     990         [ #  # ]:          0 :     if ( pWindow )
     991                 :            :     {
     992 [ #  # ][ #  # ]:          0 :         Size aFLSize = LogicToPixel( Size( 2, 6 ), MAP_APPFONT );
                 [ #  # ]
     993                 :          0 :         sal_Int32 n6PPT = aFLSize.Height();
     994                 :          0 :         long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5);
     995                 :            : 
     996         [ #  # ]:          0 :         pWindow->SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) );
     997                 :            : 
     998         [ #  # ]:          0 :         m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0 ), Size(aFLSize.Width(), nOutputHeight ) );
     999                 :            : 
    1000 [ #  # ][ #  # ]:          0 :         String sText = m_aTBPreview.GetItemText(SID_DB_APP_DISABLE_PREVIEW);
    1001         [ #  # ]:          0 :         Size aTBSize = m_aTBPreview.CalcWindowSizePixel();
    1002                 :          0 :         m_aTBPreview.SetPosSizePixel(Point(nOutputWidth - aTBSize.getWidth(), 0 ),
    1003         [ #  # ]:          0 :                                      aTBSize );
    1004                 :            : 
    1005                 :          0 :         m_aBorder.SetPosSizePixel(Point(nHalfOutputWidth + aFLSize.Width() + n6PPT, aTBSize.getHeight() + n6PPT ),
    1006         [ #  # ]:          0 :                                   Size(nHalfOutputWidth - aFLSize.Width() - n6PPT, nOutputHeight - 2*n6PPT - aTBSize.getHeight()) );
    1007 [ #  # ][ #  # ]:          0 :         m_aPreview.SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() );
    1008 [ #  # ][ #  # ]:          0 :         m_aDocumentInfo.SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() );
    1009 [ #  # ][ #  # ]:          0 :         m_pTablePreview->SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() );
                 [ #  # ]
    1010                 :            :     }
    1011                 :          0 : }
    1012                 :            : // -----------------------------------------------------------------------------
    1013                 :          0 : PreviewMode OAppDetailPageHelper::getPreviewMode()
    1014                 :            : {
    1015                 :          0 :     return m_ePreviewMode;
    1016                 :            : }
    1017                 :            : // -----------------------------------------------------------------------------
    1018                 :          0 : sal_Bool OAppDetailPageHelper::isPreviewEnabled()
    1019                 :            : {
    1020                 :          0 :     return m_ePreviewMode != E_PREVIEWNONE;
    1021                 :            : }
    1022                 :            : // -----------------------------------------------------------------------------
    1023                 :          0 : void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,sal_Bool _bForce)
    1024                 :            : {
    1025 [ #  # ][ #  # ]:          0 :     if ( m_ePreviewMode != _eMode || _bForce )
    1026                 :            :     {
    1027                 :          0 :         m_ePreviewMode = _eMode;
    1028                 :            : 
    1029                 :          0 :         getBorderWin().getView()->getAppController().previewChanged(static_cast<sal_Int32>(m_ePreviewMode));
    1030                 :            : 
    1031                 :          0 :         sal_uInt16 nSelectedAction = SID_DB_APP_DISABLE_PREVIEW;
    1032   [ #  #  #  # ]:          0 :         switch ( m_ePreviewMode )
    1033                 :            :         {
    1034                 :            :             case E_PREVIEWNONE:
    1035                 :          0 :                 nSelectedAction = SID_DB_APP_DISABLE_PREVIEW;
    1036                 :          0 :                 break;
    1037                 :            :             case E_DOCUMENT:
    1038                 :          0 :                 nSelectedAction = SID_DB_APP_VIEW_DOC_PREVIEW;
    1039                 :          0 :                 break;
    1040                 :            :             case E_DOCUMENTINFO:
    1041         [ #  # ]:          0 :                 if ( getBorderWin().getView()->getAppController().isCommandEnabled(SID_DB_APP_VIEW_DOCINFO_PREVIEW) )
    1042                 :          0 :                     nSelectedAction = SID_DB_APP_VIEW_DOCINFO_PREVIEW;
    1043                 :            :                 else
    1044                 :          0 :                     m_ePreviewMode = E_PREVIEWNONE;
    1045                 :          0 :                 break;
    1046                 :            :         }
    1047                 :            : 
    1048                 :          0 :         m_aMenu->CheckItem(nSelectedAction);
    1049         [ #  # ]:          0 :         m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, m_aMenu->GetItemText(nSelectedAction));
    1050                 :          0 :         Resize();
    1051                 :            : 
    1052                 :            :         // simulate a selectionChanged event at the controller, to force the preview to be updated
    1053         [ #  # ]:          0 :         if ( isPreviewEnabled() )
    1054                 :            :         {
    1055 [ #  # ][ #  # ]:          0 :             if ( getCurrentView() && getCurrentView()->FirstSelected() )
                 [ #  # ]
    1056                 :            :             {
    1057                 :          0 :                 getBorderWin().getView()->getAppController().onSelectionChanged();
    1058                 :            :             }
    1059                 :            :         }
    1060                 :            :         else
    1061                 :            :         {
    1062                 :          0 :             m_pTablePreview->Hide();
    1063                 :          0 :             m_aPreview.Hide();
    1064                 :          0 :             m_aDocumentInfo.Hide();
    1065                 :            :         }
    1066                 :            :     }
    1067                 :          0 : }
    1068                 :            : // -----------------------------------------------------------------------------
    1069                 :          0 : void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent)
    1070                 :            : {
    1071         [ #  # ]:          0 :     if ( isPreviewEnabled() )
    1072                 :            :     {
    1073         [ #  # ]:          0 :         m_pTablePreview->Hide();
    1074                 :            : 
    1075         [ #  # ]:          0 :         WaitObject aWaitCursor( this );
    1076                 :            :         try
    1077                 :            :         {
    1078         [ #  # ]:          0 :             Reference<XCommandProcessor> xContent(_xContent,UNO_QUERY);
    1079         [ #  # ]:          0 :             if ( xContent.is() )
    1080                 :            :             {
    1081                 :          0 :                 com::sun::star::ucb::Command aCommand;
    1082         [ #  # ]:          0 :                 if ( m_ePreviewMode == E_DOCUMENT )
    1083         [ #  # ]:          0 :                     aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("preview"));
    1084                 :            :                 else
    1085         [ #  # ]:          0 :                     aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getDocumentInfo"));
    1086                 :            : 
    1087 [ #  # ][ #  # ]:          0 :                 Any aPreview = xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >());
         [ #  # ][ #  # ]
    1088         [ #  # ]:          0 :                 if ( m_ePreviewMode == E_DOCUMENT )
    1089                 :            :                 {
    1090         [ #  # ]:          0 :                     m_aDocumentInfo.Hide();
    1091         [ #  # ]:          0 :                     m_aPreview.Show();
    1092                 :            : 
    1093         [ #  # ]:          0 :                     Graphic aGraphic;
    1094         [ #  # ]:          0 :                     Sequence < sal_Int8 > aBmpSequence;
    1095 [ #  # ][ #  # ]:          0 :                     if ( aPreview >>= aBmpSequence )
    1096                 :            :                     {
    1097         [ #  # ]:          0 :                         SvMemoryStream  aData( aBmpSequence.getArray(),
    1098                 :          0 :                                             aBmpSequence.getLength(),
    1099         [ #  # ]:          0 :                                             STREAM_READ );
    1100                 :            : 
    1101 [ #  # ][ #  # ]:          0 :                         GraphicConverter::Import(aData,aGraphic);
    1102                 :            :                     }
    1103         [ #  # ]:          0 :                     m_aPreview.setGraphic( aGraphic );
    1104 [ #  # ][ #  # ]:          0 :                     m_aPreview.Invalidate();
                 [ #  # ]
    1105                 :            :                 }
    1106                 :            :                 else
    1107                 :            :                 {
    1108         [ #  # ]:          0 :                     m_aPreview.Hide();
    1109         [ #  # ]:          0 :                     m_aDocumentInfo.clear();
    1110         [ #  # ]:          0 :                     m_aDocumentInfo.Show();
    1111                 :            :                     Reference<document::XDocumentProperties> xProp(
    1112         [ #  # ]:          0 :                         aPreview, UNO_QUERY);
    1113         [ #  # ]:          0 :                     if ( xProp.is() )
    1114 [ #  # ][ #  # ]:          0 :                         m_aDocumentInfo.fill(xProp,String());
         [ #  # ][ #  # ]
    1115                 :          0 :                 }
    1116                 :            :             }
    1117                 :            :             else
    1118                 :            :             {
    1119         [ #  # ]:          0 :                 m_aPreview.Hide();
    1120         [ #  # ]:          0 :                 m_aDocumentInfo.Hide();
    1121         [ #  # ]:          0 :             }
    1122                 :            :         }
    1123         [ #  # ]:          0 :         catch( const Exception& )
    1124                 :            :         {
    1125                 :            :             DBG_UNHANDLED_EXCEPTION();
    1126         [ #  # ]:          0 :         }
    1127                 :            :     }
    1128                 :          0 : }
    1129                 :            : // -----------------------------------------------------------------------------
    1130                 :          0 : void OAppDetailPageHelper::showPreview( const ::rtl::OUString& _sDataSourceName,
    1131                 :            :                                         const ::rtl::OUString& _sName,
    1132                 :            :                                         sal_Bool _bTable)
    1133                 :            : {
    1134         [ #  # ]:          0 :     if ( isPreviewEnabled() )
    1135                 :            :     {
    1136         [ #  # ]:          0 :         WaitObject aWaitCursor( this );
    1137         [ #  # ]:          0 :         m_aPreview.Hide();
    1138         [ #  # ]:          0 :         m_aDocumentInfo.Hide();
    1139         [ #  # ]:          0 :         m_pTablePreview->Show();
    1140         [ #  # ]:          0 :         if ( !m_xFrame.is() )
    1141                 :            :         {
    1142                 :            :             try
    1143                 :            :             {
    1144 [ #  # ][ #  # ]:          0 :                 m_xFrame = Reference < XFrame > ( getBorderWin().getView()->getORB()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame")) ), UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1145 [ #  # ][ #  # ]:          0 :                 m_xFrame->initialize( m_xWindow );
    1146                 :            : 
    1147                 :            :                 // no layout manager (and thus no toolbars) in the preview
    1148                 :            :                 // Must be called after initialize ... but before any other call to this frame.
    1149                 :            :                 // Otherwise frame throws "life time exceptions" as e.g. NON_INITIALIZED
    1150         [ #  # ]:          0 :                 Reference< XPropertySet > xFrameProps( m_xFrame, UNO_QUERY_THROW );
    1151 [ #  # ][ #  # ]:          0 :                 xFrameProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ), makeAny(Reference< XLayoutManager >()) );
         [ #  # ][ #  # ]
    1152                 :            : 
    1153 [ #  # ][ #  # ]:          0 :                 Reference<XFramesSupplier> xSup(getBorderWin().getView()->getAppController().getXController()->getFrame(),UNO_QUERY);
         [ #  # ][ #  # ]
                 [ #  # ]
    1154         [ #  # ]:          0 :                 if ( xSup.is() )
    1155                 :            :                 {
    1156 [ #  # ][ #  # ]:          0 :                     Reference<XFrames> xFrames = xSup->getFrames();
    1157 [ #  # ][ #  # ]:          0 :                     xFrames->append(m_xFrame);
    1158         [ #  # ]:          0 :                 }
    1159                 :            :             }
    1160         [ #  # ]:          0 :             catch(const Exception&)
    1161                 :            :             {
    1162                 :            :             }
    1163                 :            :         }
    1164                 :            : 
    1165 [ #  # ][ #  # ]:          0 :         Reference< XDatabaseDocumentUI > xApplication( getBorderWin().getView()->getAppController().getXController(), UNO_QUERY );
                 [ #  # ]
    1166                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1167                 :            :         ::std::auto_ptr< DatabaseObjectView > pDispatcher( new ResultSetBrowser(
    1168         [ #  # ]:          0 :             getBorderWin().getView()->getORB(), xApplication, NULL, _bTable
    1169 [ #  # ][ #  # ]:          0 :         ) );
         [ #  # ][ #  # ]
    1170                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1171         [ #  # ]:          0 :         pDispatcher->setTargetFrame( m_xFrame );
    1172                 :            : 
    1173         [ #  # ]:          0 :         ::comphelper::NamedValueCollection aArgs;
    1174         [ #  # ]:          0 :         aArgs.put( "Preview", sal_True );
    1175         [ #  # ]:          0 :         aArgs.put( "ReadOnly", sal_True );
    1176         [ #  # ]:          0 :         aArgs.put( "AsTemplate", sal_False );
    1177 [ #  # ][ #  # ]:          0 :         aArgs.put( (::rtl::OUString)PROPERTY_SHOWMENU, sal_False );
    1178                 :            : 
    1179 [ #  # ][ #  # ]:          0 :         Reference< XController > xPreview( pDispatcher->openExisting( makeAny( _sDataSourceName ), _sName, aArgs ), UNO_QUERY );
                 [ #  # ]
    1180                 :          0 :         sal_Bool bClearPreview = !xPreview.is();
    1181                 :            : 
    1182                 :            :         // clear the preview when the query or table could not be loaded
    1183         [ #  # ]:          0 :         if ( !bClearPreview )
    1184                 :            :         {
    1185         [ #  # ]:          0 :             Reference< XTabController > xTabController( xPreview, UNO_QUERY );
    1186                 :          0 :             bClearPreview = !xTabController.is();
    1187         [ #  # ]:          0 :             if ( !bClearPreview )
    1188                 :            :             {
    1189 [ #  # ][ #  # ]:          0 :                 Reference< XLoadable > xLoadable( xTabController->getModel(), UNO_QUERY );
                 [ #  # ]
    1190 [ #  # ][ #  # ]:          0 :                 bClearPreview = !( xLoadable.is() && xLoadable->isLoaded() );
         [ #  # ][ #  # ]
    1191                 :          0 :             }
    1192                 :            :         }
    1193         [ #  # ]:          0 :         if ( bClearPreview )
    1194 [ #  # ][ #  # ]:          0 :             showPreview(NULL);
         [ #  # ][ #  # ]
                 [ #  # ]
    1195                 :            :     }
    1196                 :          0 : }
    1197                 :            : // -----------------------------------------------------------------------------
    1198                 :          0 : IMPL_LINK(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, /*pToolBox*/)
    1199                 :            : {
    1200         [ #  # ]:          0 :     m_aTBPreview.EndSelection();
    1201                 :            : 
    1202                 :            :     // tell the toolbox that the item is pressed down
    1203         [ #  # ]:          0 :     m_aTBPreview.SetItemDown( SID_DB_APP_DISABLE_PREVIEW, sal_True );
    1204                 :            : 
    1205                 :            :     // simulate a mouse move (so the "down" state is really painted)
    1206         [ #  # ]:          0 :     Point aPoint = m_aTBPreview.GetItemRect( SID_DB_APP_DISABLE_PREVIEW ).TopLeft();
    1207         [ #  # ]:          0 :     MouseEvent aMove( aPoint, 0, MOUSE_SIMPLEMOVE | MOUSE_SYNTHETIC );
    1208         [ #  # ]:          0 :     m_aTBPreview.MouseMove( aMove );
    1209                 :            : 
    1210         [ #  # ]:          0 :     m_aTBPreview.Update();
    1211                 :            : 
    1212                 :            :     // execute the menu
    1213                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1214 [ #  # ][ #  # ]:          0 :     ::std::auto_ptr<PopupMenu> aMenu(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) ));
                 [ #  # ]
    1215                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    1216                 :            : 
    1217                 :            :     sal_uInt16 pActions[] = { SID_DB_APP_DISABLE_PREVIEW
    1218                 :            :                             , SID_DB_APP_VIEW_DOC_PREVIEW
    1219                 :            :                             , SID_DB_APP_VIEW_DOCINFO_PREVIEW
    1220                 :          0 :     };
    1221                 :            : 
    1222         [ #  # ]:          0 :     for(size_t i=0; i < sizeof(pActions)/sizeof(pActions[0]);++i)
    1223                 :            :     {
    1224 [ #  # ][ #  # ]:          0 :         aMenu->CheckItem(pActions[i],m_aMenu->IsItemChecked(pActions[i]));
    1225                 :            :     }
    1226 [ #  # ][ #  # ]:          0 :     aMenu->EnableItem( SID_DB_APP_VIEW_DOCINFO_PREVIEW, getBorderWin().getView()->getAppController().isCommandEnabled(SID_DB_APP_VIEW_DOCINFO_PREVIEW) );
                 [ #  # ]
    1227                 :            : 
    1228                 :            :     // no disabled entries
    1229         [ #  # ]:          0 :     aMenu->RemoveDisabledEntries();
    1230                 :            : 
    1231 [ #  # ][ #  # ]:          0 :     sal_uInt16 nSelectedAction = aMenu->Execute(&m_aTBPreview, m_aTBPreview.GetItemRect( SID_DB_APP_DISABLE_PREVIEW ));
    1232                 :            :     // "cleanup" the toolbox state
    1233         [ #  # ]:          0 :     MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
    1234         [ #  # ]:          0 :     m_aTBPreview.MouseMove( aLeave );
    1235         [ #  # ]:          0 :     m_aTBPreview.SetItemDown( SID_DB_APP_DISABLE_PREVIEW, sal_False);
    1236         [ #  # ]:          0 :     if ( nSelectedAction )
    1237                 :            :     {
    1238 [ #  # ][ #  # ]:          0 :         m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, aMenu->GetItemText(nSelectedAction));
                 [ #  # ]
    1239         [ #  # ]:          0 :         Resize();
    1240 [ #  # ][ #  # ]:          0 :         getBorderWin().getView()->getAppController().executeChecked(nSelectedAction,Sequence<PropertyValue>());
         [ #  # ][ #  # ]
    1241                 :            :     }
    1242         [ #  # ]:          0 :     return 0L;
    1243                 :            : }
    1244                 :            : 
    1245                 :            : // -----------------------------------------------------------------------------
    1246                 :          0 : void OAppDetailPageHelper::KeyInput( const KeyEvent& rKEvt )
    1247                 :            : {
    1248                 :          0 :     SvTreeListBox* pCurrentView = getCurrentView();
    1249                 :            :     OSL_PRECOND( pCurrentView, "OAppDetailPageHelper::KeyInput: how this?" );
    1250                 :            : 
    1251                 :          0 :     KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction(); (void)eFunc;
    1252                 :          0 :     sal_uInt16      nCode = rKEvt.GetKeyCode().GetCode();
    1253                 :            : 
    1254 [ #  # ][ #  # ]:          0 :     if ( ( KEY_RETURN == nCode ) && pCurrentView )
    1255                 :            :     {
    1256                 :          0 :         getBorderWin().getView()->getAppController().onEntryDoubleClick( *pCurrentView );
    1257                 :            :     }
    1258                 :            :     else
    1259                 :          0 :         Window::KeyInput(rKEvt);
    1260                 :          0 : }
    1261                 :            : 
    1262                 :            : // -----------------------------------------------------------------------------
    1263                 :          0 : void OAppDetailPageHelper::DataChanged( const DataChangedEvent& rDCEvt )
    1264                 :            : {
    1265                 :          0 :     Window::DataChanged( rDCEvt );
    1266                 :            : 
    1267 [ #  # ][ #  #  :          0 :         if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
          #  #  #  #  #  
                #  #  # ]
    1268                 :          0 :         (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
    1269                 :          0 :         (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    1270                 :          0 :         ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1271                 :          0 :         (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    1272                 :            : 
    1273                 :            :     {
    1274                 :          0 :         ImplInitSettings();
    1275         [ #  # ]:          0 :         if ( m_pLists[ E_TABLE ] )
    1276                 :            :         {
    1277         [ #  # ]:          0 :             OTableTreeListBox* pTableTree = dynamic_cast< OTableTreeListBox* >( m_pLists[ E_TABLE ] );
    1278                 :            :             OSL_ENSURE( pTableTree != NULL, "OAppDetailPageHelper::DataChanged: a tree list for tables which is no TableTreeList?" );
    1279         [ #  # ]:          0 :             if ( pTableTree )
    1280                 :          0 :                 pTableTree->notifyHiContrastChanged();
    1281                 :            :         }
    1282                 :            :     }
    1283                 :          0 : }
    1284                 :            : // -----------------------------------------------------------------------------
    1285                 :          0 : void OAppDetailPageHelper::ImplInitSettings()
    1286                 :            : {
    1287                 :          0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    1288         [ #  # ]:          0 :         Font aFont;
    1289         [ #  # ]:          0 :         aFont = rStyleSettings.GetFieldFont();
    1290         [ #  # ]:          0 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
    1291         [ #  # ]:          0 :         SetPointFont( aFont );
    1292         [ #  # ]:          0 :         m_aTBPreview.SetPointFont( aFont );
    1293                 :            : 
    1294         [ #  # ]:          0 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
    1295         [ #  # ]:          0 :         SetTextFillColor();
    1296         [ #  # ]:          0 :         m_aBorder.SetTextColor( rStyleSettings.GetFieldTextColor() );
    1297         [ #  # ]:          0 :         m_aBorder.SetTextFillColor();
    1298         [ #  # ]:          0 :         m_aTBPreview.SetTextColor( rStyleSettings.GetFieldTextColor() );
    1299         [ #  # ]:          0 :         m_aTBPreview.SetTextFillColor();
    1300                 :            : 
    1301 [ #  # ][ #  # ]:          0 :         SetBackground( rStyleSettings.GetFieldColor() );
                 [ #  # ]
    1302 [ #  # ][ #  # ]:          0 :         m_aBorder.SetBackground( rStyleSettings.GetFieldColor() );
                 [ #  # ]
    1303 [ #  # ][ #  # ]:          0 :         m_aFL.SetBackground( rStyleSettings.GetFieldColor() );
                 [ #  # ]
    1304 [ #  # ][ #  # ]:          0 :         m_aDocumentInfo.SetBackground( rStyleSettings.GetFieldColor() );
                 [ #  # ]
    1305 [ #  # ][ #  # ]:          0 :         m_aTBPreview.SetBackground( rStyleSettings.GetFieldColor() );
                 [ #  # ]
    1306 [ #  # ][ #  # ]:          0 :         m_pTablePreview->SetBackground( rStyleSettings.GetFieldColor() );
         [ #  # ][ #  # ]
    1307                 :          0 : }
    1308                 :            : // -----------------------------------------------------------------------------
    1309                 :          0 : OPreviewWindow::OPreviewWindow(Window* _pParent)
    1310 [ #  # ][ #  # ]:          0 : : Window(_pParent)
    1311                 :            : {
    1312         [ #  # ]:          0 :     ImplInitSettings( sal_True, sal_True, sal_True );
    1313                 :          0 : }
    1314                 :            : // -----------------------------------------------------------------------------
    1315                 :          0 : sal_Bool OPreviewWindow::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const
    1316                 :            : {
    1317                 :          0 :     const Size aWinSize( GetOutputSizePixel() );
    1318 [ #  # ][ #  # ]:          0 :     Size       aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
         [ #  # ][ #  # ]
    1319                 :          0 :     sal_Bool       bRet = sal_False;
    1320                 :            : 
    1321 [ #  # ][ #  # ]:          0 :     if( aNewSize.Width() && aNewSize.Height() )
                 [ #  # ]
    1322                 :            :     {
    1323                 :            :         // scale to fit window
    1324                 :          0 :         const double fGrfWH = (double) aNewSize.Width() / aNewSize.Height();
    1325                 :          0 :         const double fWinWH = (double) aWinSize.Width() / aWinSize.Height();
    1326                 :            : 
    1327         [ #  # ]:          0 :         if ( fGrfWH < fWinWH )
    1328                 :            :         {
    1329                 :          0 :             aNewSize.Width() = (long) ( aWinSize.Height() * fGrfWH );
    1330                 :          0 :             aNewSize.Height()= aWinSize.Height();
    1331                 :            :         }
    1332                 :            :         else
    1333                 :            :         {
    1334                 :          0 :             aNewSize.Width() = aWinSize.Width();
    1335                 :          0 :             aNewSize.Height()= (long) ( aWinSize.Width() / fGrfWH);
    1336                 :            :         }
    1337                 :            : 
    1338                 :          0 :         const Point aNewPos( ( aWinSize.Width()  - aNewSize.Width() ) >> 1,
    1339                 :          0 :                              ( aWinSize.Height() - aNewSize.Height() ) >> 1 );
    1340                 :            : 
    1341         [ #  # ]:          0 :         rResultRect = Rectangle( aNewPos, aNewSize );
    1342                 :          0 :         bRet = sal_True;
    1343                 :            :     }
    1344                 :            : 
    1345                 :          0 :     return bRet;
    1346                 :            : }
    1347                 :            : 
    1348                 :            : // ------------------------------------------------------------------------
    1349                 :            : 
    1350                 :          0 : void OPreviewWindow::Paint( const Rectangle& rRect )
    1351                 :            : {
    1352                 :          0 :     Window::Paint( rRect );
    1353                 :            : 
    1354         [ #  # ]:          0 :     if( ImplGetGraphicCenterRect( m_aGraphicObj.GetGraphic(), m_aPreviewRect ) )
    1355                 :            :     {
    1356                 :          0 :         const Point aPos( m_aPreviewRect.TopLeft() );
    1357         [ #  # ]:          0 :         const Size  aSize( m_aPreviewRect.GetSize() );
    1358                 :            : 
    1359         [ #  # ]:          0 :         if( m_aGraphicObj.IsAnimated() )
    1360         [ #  # ]:          0 :             m_aGraphicObj.StartAnimation( this, aPos, aSize );
    1361                 :            :         else
    1362         [ #  # ]:          0 :             m_aGraphicObj.Draw( this, aPos, aSize );
    1363                 :            :     }
    1364                 :          0 : }
    1365                 :            : // -----------------------------------------------------------------------------
    1366                 :          0 : void OPreviewWindow::DataChanged( const DataChangedEvent& rDCEvt )
    1367                 :            : {
    1368                 :          0 :     Window::DataChanged( rDCEvt );
    1369                 :            : 
    1370         [ #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
           [ #  #  #  # ]
    1371                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1372                 :            :     {
    1373                 :          0 :         ImplInitSettings( sal_True, sal_True, sal_True );
    1374                 :          0 :         Invalidate();
    1375                 :            :     }
    1376                 :          0 : }
    1377                 :            : // -----------------------------------------------------------------------------
    1378                 :          0 : void OPreviewWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
    1379                 :            : {
    1380                 :          0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    1381         [ #  # ]:          0 :     if( bFont )
    1382                 :            :     {
    1383         [ #  # ]:          0 :         Font aFont;
    1384         [ #  # ]:          0 :         aFont = rStyleSettings.GetFieldFont();
    1385         [ #  # ]:          0 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
    1386 [ #  # ][ #  # ]:          0 :         SetPointFont( aFont );
    1387                 :            :     }
    1388                 :            : 
    1389 [ #  # ][ #  # ]:          0 :     if( bForeground || bFont )
    1390                 :            :     {
    1391                 :          0 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
    1392                 :          0 :         SetTextFillColor();
    1393                 :            :     }
    1394                 :            : 
    1395         [ #  # ]:          0 :     if( bBackground )
    1396         [ #  # ]:          0 :         SetBackground( rStyleSettings.GetFieldColor() );
    1397                 :          0 : }
    1398                 :            : // -----------------------------------------------------------------------------
    1399                 :            : // -----------------------------------------------------------------------------
    1400                 :            : 
    1401                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10