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