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