1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dbaccess.hxx" 30 #ifndef DBAUI_APPDETAILVIEW_HXX 31 #include "AppDetailView.hxx" 32 #endif 33 #ifndef _TOOLS_DEBUG_HXX 34 #include <tools/debug.hxx> 35 #endif 36 #ifndef _DBA_DBACCESS_HELPID_HRC_ 37 #include "dbaccess_helpid.hrc" 38 #endif 39 #ifndef _DBU_APP_HRC_ 40 #include "dbu_app.hrc" 41 #endif 42 #ifndef DBAUI_APPVIEW_HXX 43 #include "AppView.hxx" 44 #endif 45 #ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_ 46 #include <com/sun/star/ui/XUIConfigurationManager.hpp> 47 #endif 48 #ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_ 49 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> 50 #endif 51 #ifndef _COM_SUN_STAR_UI_XIMAGEMANAGER_HPP_ 52 #include <com/sun/star/ui/XImageManager.hpp> 53 #endif 54 #ifndef _COM_SUN_STAR_UI_IMAGETYPE_HPP_ 55 #include <com/sun/star/ui/ImageType.hpp> 56 #endif 57 #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ 58 #include <com/sun/star/sdbcx/XViewsSupplier.hpp> 59 #endif 60 #ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_ 61 #include <com/sun/star/graphic/XGraphic.hpp> 62 #endif 63 #ifndef _COM_SUN_STAR_UTIL_URL_HPP_ 64 #include <com/sun/star/util/URL.hpp> 65 #endif 66 #ifndef _DBAUI_LISTVIEWITEMS_HXX_ 67 #include "listviewitems.hxx" 68 #endif 69 #ifndef _IMAGE_HXX //autogen 70 #include <vcl/image.hxx> 71 #endif 72 #ifndef _SV_MNEMONIC_HXX 73 #include <vcl/mnemonic.hxx> 74 #endif 75 #ifndef _SV_MNEMONIC_HXX 76 #include <vcl/mnemonic.hxx> 77 #endif 78 #ifndef DBACCESS_UI_BROWSER_ID_HXX 79 #include "browserids.hxx" 80 #endif 81 #ifndef DBAUI_APPDETAILPAGEHELPER_HXX 82 #include "AppDetailPageHelper.hxx" 83 #endif 84 #ifndef _SV_SVAPP_HXX //autogen 85 #include <vcl/svapp.hxx> 86 #endif 87 #ifndef _DBACCESS_UI_CALLBACKS_HXX_ 88 #include "callbacks.hxx" 89 #endif 90 #ifndef DBAUI_ICONTROLLER_HXX 91 #include "IController.hxx" 92 #endif 93 #ifndef _DBAUI_MODULE_DBU_HXX_ 94 #include "moduledbu.hxx" 95 #endif 96 #ifndef _SVTOOLS_LOCALRESACCESS_HXX_ 97 #include <svtools/localresaccess.hxx> 98 #endif 99 #include <algorithm> 100 #include "dbtreelistbox.hxx" 101 #include "IApplicationController.hxx" 102 #include "imageprovider.hxx" 103 104 using namespace ::dbaui; 105 using namespace ::com::sun::star::uno; 106 using namespace ::com::sun::star::sdbc; 107 using namespace ::com::sun::star::sdbcx; 108 using namespace ::com::sun::star::lang; 109 using namespace ::com::sun::star::ucb; 110 using namespace ::com::sun::star::graphic; 111 using namespace ::com::sun::star::ui; 112 using namespace ::com::sun::star::container; 113 using namespace ::com::sun::star::beans; 114 using ::com::sun::star::util::URL; 115 using ::com::sun::star::sdb::application::NamedDatabaseObject; 116 117 #define SPACEBETWEENENTRIES 4 118 119 // ----------------------------------------------------------------------------- 120 TaskEntry::TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled ) 121 :sUNOCommand( ::rtl::OUString::createFromAscii( _pAsciiUNOCommand ) ) 122 ,nHelpID( _nHelpID ) 123 ,sTitle( ModuleRes( _nTitleResourceID ) ) 124 ,bHideWhenDisabled( _bHideWhenDisabled ) 125 { 126 } 127 128 // ----------------------------------------------------------------------------- 129 OCreationList::OCreationList( OTasksWindow& _rParent ) 130 :SvTreeListBox( &_rParent, WB_TABSTOP | WB_HASBUTTONSATROOT | WB_HASBUTTONS ) 131 ,m_rTaskWindow( _rParent ) 132 ,m_pMouseDownEntry( NULL ) 133 ,m_pLastActiveEntry( NULL ) 134 { 135 sal_uInt16 nSize = SPACEBETWEENENTRIES; 136 SetSpaceBetweenEntries(nSize); 137 SetSelectionMode( NO_SELECTION ); 138 SetExtendedWinBits( EWB_NO_AUTO_CURENTRY ); 139 SetNodeDefaultImages( ); 140 EnableEntryMnemonics(); 141 } 142 // ----------------------------------------------------------------------------- 143 void OCreationList::Paint( const Rectangle& _rRect ) 144 { 145 if ( m_pMouseDownEntry ) 146 m_aOriginalFont = GetFont(); 147 148 m_aOriginalBackgroundColor = GetBackground().GetColor(); 149 SvTreeListBox::Paint( _rRect ); 150 SetBackground( m_aOriginalBackgroundColor ); 151 152 if ( m_pMouseDownEntry ) 153 Control::SetFont( m_aOriginalFont ); 154 } 155 156 // ----------------------------------------------------------------------------- 157 void OCreationList::PreparePaint( SvLBoxEntry* _pEntry ) 158 { 159 Wallpaper aEntryBackground( m_aOriginalBackgroundColor ); 160 if ( _pEntry ) 161 { 162 if ( _pEntry == GetCurEntry() ) 163 { 164 // draw a selection background 165 bool bIsMouseDownEntry = ( _pEntry == m_pMouseDownEntry ); 166 DrawSelectionBackground( GetBoundingRect( _pEntry ), bIsMouseDownEntry ? 1 : 2, sal_False, sal_True, sal_False ); 167 168 if ( bIsMouseDownEntry ) 169 { 170 Font aFont( GetFont() ); 171 aFont.SetColor( GetSettings().GetStyleSettings().GetHighlightTextColor() ); 172 Control::SetFont( aFont ); 173 } 174 175 // and temporary set a transparent background, for all the other 176 // paint operations the SvTreeListBox is going to do 177 aEntryBackground = Wallpaper( Color( COL_TRANSPARENT ) ); 178 } 179 } 180 181 SetBackground( aEntryBackground ); 182 } 183 184 // ----------------------------------------------------------------------------- 185 void OCreationList::SelectSearchEntry( const void* _pEntry ) 186 { 187 SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) ); 188 DBG_ASSERT( pEntry, "OCreationList::SelectSearchEntry: invalid entry!" ); 189 190 if ( pEntry ) 191 setCurrentEntryInvalidate( pEntry ); 192 193 if ( !HasChildPathFocus() ) 194 GrabFocus(); 195 } 196 197 // ----------------------------------------------------------------------------- 198 void OCreationList::ExecuteSearchEntry( const void* _pEntry ) const 199 { 200 SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) ); 201 DBG_ASSERT( pEntry, "OCreationList::ExecuteSearchEntry: invalid entry!" ); 202 DBG_ASSERT( pEntry == GetCurEntry(), "OCreationList::ExecuteSearchEntry: SelectSearchEntry should have been called before!" ); 203 204 if ( pEntry ) 205 onSelected( pEntry ); 206 } 207 208 // ----------------------------------------------------------------------------- 209 Rectangle OCreationList::GetFocusRect( SvLBoxEntry* _pEntry, long _nLine ) 210 { 211 Rectangle aRect = SvTreeListBox::GetFocusRect( _pEntry, _nLine ); 212 aRect.Left() = 0; 213 214 // try to let the focus rect start before the bitmap item - this looks better 215 SvLBoxItem* pBitmapItem = _pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ); 216 SvLBoxTab* pTab = pBitmapItem ? GetTab( _pEntry, pBitmapItem ) : NULL; 217 SvViewDataItem* pItemData = pBitmapItem ? GetViewDataItem( _pEntry, pBitmapItem ) : NULL; 218 DBG_ASSERT( pTab && pItemData, "OCreationList::GetFocusRect: could not find the first bitmap item!" ); 219 if ( pTab && pItemData ) 220 aRect.Left() = pTab->GetPos() - pItemData->aSize.Width() / 2; 221 222 // inflate the rectangle a little bit - looks better, too 223 aRect.Left() = ::std::max< long >( 0, aRect.Left() - 2 ); 224 aRect.Right() = ::std::min< long >( GetOutputSizePixel().Width() - 1, aRect.Right() + 2 ); 225 226 return aRect; 227 } 228 // ----------------------------------------------------------------------------- 229 void OCreationList::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ ) 230 { 231 // don't give this to the base class, it does a ReleaseMouse as very first action 232 // Though I think this is a bug (it should ReleaseMouse only if it is going to do 233 // something with the drag-event), I hesitate to fix it in the current state, 234 // since I don't overlook the consequences, and we're close to 2.0 ...) 235 } 236 // ----------------------------------------------------------------------------- 237 void OCreationList::ModelHasCleared() 238 { 239 SvTreeListBox::ModelHasCleared(); 240 m_pLastActiveEntry = NULL; 241 m_pMouseDownEntry = NULL; 242 } 243 // ----------------------------------------------------------------------------- 244 void OCreationList::GetFocus() 245 { 246 SvTreeListBox::GetFocus(); 247 if ( !GetCurEntry() ) 248 setCurrentEntryInvalidate( m_pLastActiveEntry ? m_pLastActiveEntry : GetFirstEntryInView() ); 249 } 250 // ----------------------------------------------------------------------------- 251 void OCreationList::LoseFocus() 252 { 253 SvTreeListBox::LoseFocus(); 254 m_pLastActiveEntry = GetCurEntry(); 255 setCurrentEntryInvalidate( NULL ); 256 } 257 // ----------------------------------------------------------------------------- 258 void OCreationList::MouseButtonDown( const MouseEvent& rMEvt ) 259 { 260 SvTreeListBox::MouseButtonDown( rMEvt ); 261 262 DBG_ASSERT( !m_pMouseDownEntry, "OCreationList::MouseButtonDown: I missed some mouse event!" ); 263 m_pMouseDownEntry = GetCurEntry(); 264 if ( m_pMouseDownEntry ) 265 { 266 InvalidateEntry( m_pMouseDownEntry ); 267 CaptureMouse(); 268 } 269 } 270 // ----------------------------------------------------------------------------- 271 void OCreationList::MouseMove( const MouseEvent& rMEvt ) 272 { 273 if ( rMEvt.IsLeaveWindow() ) 274 { 275 setCurrentEntryInvalidate( NULL ); 276 } 277 else if ( !rMEvt.IsSynthetic() ) 278 { 279 SvLBoxEntry* pEntry = GetEntry( rMEvt.GetPosPixel() ); 280 281 if ( m_pMouseDownEntry ) 282 { 283 // we're currently in a "mouse down" phase 284 DBG_ASSERT( IsMouseCaptured(), "OCreationList::MouseMove: inconsistence (1)!" ); 285 if ( pEntry == m_pMouseDownEntry ) 286 { 287 setCurrentEntryInvalidate( m_pMouseDownEntry ); 288 } 289 else 290 { 291 DBG_ASSERT( ( GetCurEntry() == m_pMouseDownEntry ) || !GetCurEntry(), 292 "OCreationList::MouseMove: inconsistence (2)!" ); 293 setCurrentEntryInvalidate( NULL ); 294 } 295 } 296 else 297 { 298 // the user is simply hovering with the mouse 299 if ( setCurrentEntryInvalidate( pEntry ) ) 300 { 301 if ( !m_pMouseDownEntry ) 302 updateHelpText(); 303 } 304 } 305 } 306 307 SvTreeListBox::MouseMove(rMEvt); 308 } 309 // ----------------------------------------------------------------------------- 310 void OCreationList::MouseButtonUp( const MouseEvent& rMEvt ) 311 { 312 SvLBoxEntry* pEntry = GetEntry( rMEvt.GetPosPixel() ); 313 bool bExecute = false; 314 // Was the mouse released over the active entry? 315 // (i.e. the entry which was under the mouse when the button went down) 316 if ( pEntry && ( m_pMouseDownEntry == pEntry ) ) 317 { 318 if ( !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && rMEvt.IsLeft() && rMEvt.GetClicks() == 1 ) 319 bExecute = true; 320 } 321 322 if ( m_pMouseDownEntry ) 323 { 324 DBG_ASSERT( IsMouseCaptured(), "OCreationList::MouseButtonUp: hmmm .... no mouse captured, but an active entry?" ); 325 ReleaseMouse(); 326 327 InvalidateEntry( m_pMouseDownEntry ); 328 m_pMouseDownEntry = NULL; 329 } 330 331 SvTreeListBox::MouseButtonUp( rMEvt ); 332 333 if ( bExecute ) 334 onSelected( pEntry ); 335 } 336 // ----------------------------------------------------------------------------- 337 bool OCreationList::setCurrentEntryInvalidate( SvLBoxEntry* _pEntry ) 338 { 339 if ( GetCurEntry() != _pEntry ) 340 { 341 if ( GetCurEntry() ) 342 InvalidateEntry( GetCurEntry() ); 343 SetCurEntry( _pEntry ); 344 if ( GetCurEntry() ) 345 { 346 InvalidateEntry( GetCurEntry() ); 347 CallEventListeners( VCLEVENT_LISTBOX_SELECT, GetCurEntry() ); 348 } 349 updateHelpText(); 350 return true; 351 } 352 return false; 353 } 354 // ----------------------------------------------------------------------------- 355 void OCreationList::updateHelpText() 356 { 357 sal_uInt16 nHelpTextId = 0; 358 if ( GetCurEntry() ) 359 nHelpTextId = reinterpret_cast< TaskEntry* >( GetCurEntry()->GetUserData() )->nHelpID; 360 m_rTaskWindow.setHelpText( nHelpTextId ); 361 } 362 // ----------------------------------------------------------------------------- 363 void OCreationList::onSelected( SvLBoxEntry* _pEntry ) const 364 { 365 DBG_ASSERT( _pEntry, "OCreationList::onSelected: invalid entry!" ); 366 URL aCommand; 367 aCommand.Complete = reinterpret_cast< TaskEntry* >( _pEntry->GetUserData() )->sUNOCommand; 368 m_rTaskWindow.getDetailView()->getBorderWin().getView()->getAppController().executeChecked( aCommand, Sequence< PropertyValue >() ); 369 } 370 // ----------------------------------------------------------------------------- 371 void OCreationList::KeyInput( const KeyEvent& rKEvt ) 372 { 373 const KeyCode& rCode = rKEvt.GetKeyCode(); 374 if ( !rCode.IsMod1() && !rCode.IsMod2() && !rCode.IsShift() ) 375 { 376 if ( rCode.GetCode() == KEY_RETURN ) 377 { 378 SvLBoxEntry* pEntry = GetCurEntry() ? GetCurEntry() : FirstSelected(); 379 if ( pEntry ) 380 onSelected( pEntry ); 381 return; 382 } 383 } 384 SvLBoxEntry* pOldCurrent = GetCurEntry(); 385 SvTreeListBox::KeyInput(rKEvt); 386 SvLBoxEntry* pNewCurrent = GetCurEntry(); 387 388 if ( pOldCurrent != pNewCurrent ) 389 { 390 if ( pOldCurrent ) 391 InvalidateEntry( pOldCurrent ); 392 if ( pNewCurrent ) 393 { 394 InvalidateEntry( pNewCurrent ); 395 CallEventListeners( VCLEVENT_LISTBOX_SELECT, pNewCurrent ); 396 } // if ( pNewCurrent ) 397 updateHelpText(); 398 } 399 } 400 // ----------------------------------------------------------------------------- 401 DBG_NAME(OTasksWindow) 402 OTasksWindow::OTasksWindow(Window* _pParent,OApplicationDetailView* _pDetailView) 403 : Window(_pParent,WB_DIALOGCONTROL ) 404 ,m_aCreation(*this) 405 ,m_aDescription(this) 406 ,m_aHelpText(this,WB_WORDBREAK) 407 ,m_aFL(this,WB_VERT) 408 ,m_pDetailView(_pDetailView) 409 { 410 DBG_CTOR(OTasksWindow,NULL); 411 SetUniqueId(UID_APP_TASKS_WINDOW); 412 m_aCreation.SetHelpId(HID_APP_CREATION_LIST); 413 m_aCreation.SetSelectHdl(LINK(this, OTasksWindow, OnEntrySelectHdl)); 414 m_aHelpText.SetHelpId(HID_APP_HELP_TEXT); 415 m_aDescription.SetHelpId(HID_APP_DESCRIPTION_TEXT); 416 m_aDescription.SetText(ModuleRes(STR_DESCRIPTION)); 417 418 ImageProvider aImageProvider; 419 Image aFolderImage = aImageProvider.getFolderImage( DatabaseObject::FORM, false ); 420 m_aCreation.SetDefaultCollapsedEntryBmp( aFolderImage ); 421 m_aCreation.SetDefaultExpandedEntryBmp( aFolderImage ); 422 423 ImplInitSettings(sal_True,sal_True,sal_True); 424 } 425 // ----------------------------------------------------------------------------- 426 OTasksWindow::~OTasksWindow() 427 { 428 DBG_DTOR(OTasksWindow,NULL); 429 Clear(); 430 } 431 // ----------------------------------------------------------------------- 432 void OTasksWindow::DataChanged( const DataChangedEvent& rDCEvt ) 433 { 434 DBG_CHKTHIS(OTasksWindow,NULL); 435 Window::DataChanged( rDCEvt ); 436 437 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 438 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 439 { 440 ImplInitSettings( sal_True, sal_True, sal_True ); 441 Invalidate(); 442 } 443 } 444 // ----------------------------------------------------------------------------- 445 void OTasksWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) 446 { 447 DBG_CHKTHIS(OTasksWindow,NULL); 448 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 449 if( bFont ) 450 { 451 Font aFont; 452 aFont = rStyleSettings.GetFieldFont(); 453 aFont.SetColor( rStyleSettings.GetWindowTextColor() ); 454 SetPointFont( aFont ); 455 } 456 457 if( bForeground || bFont ) 458 { 459 SetTextColor( rStyleSettings.GetFieldTextColor() ); 460 SetTextFillColor(); 461 m_aHelpText.SetTextColor( rStyleSettings.GetFieldTextColor() ); 462 m_aHelpText.SetTextFillColor(); 463 m_aDescription.SetTextColor( rStyleSettings.GetFieldTextColor() ); 464 m_aDescription.SetTextFillColor(); 465 //m_aFL.SetTextColor( rStyleSettings.GetFieldTextColor() ); 466 //m_aFL.SetTextFillColor(); 467 } 468 469 if( bBackground ) 470 { 471 SetBackground( rStyleSettings.GetFieldColor() ); 472 m_aHelpText.SetBackground( rStyleSettings.GetFieldColor() ); 473 m_aDescription.SetBackground( rStyleSettings.GetFieldColor() ); 474 m_aFL.SetBackground( rStyleSettings.GetFieldColor() ); 475 } 476 477 Font aFont = m_aDescription.GetControlFont(); 478 aFont.SetWeight(WEIGHT_BOLD); 479 m_aDescription.SetControlFont(aFont); 480 } 481 // ----------------------------------------------------------------------------- 482 void OTasksWindow::setHelpText(sal_uInt16 _nId) 483 { 484 DBG_CHKTHIS(OTasksWindow,NULL); 485 if ( _nId ) 486 { 487 String sText = ModuleRes(_nId); 488 489 // calulate the size of the text field 490 // Size aHelpTextSize = m_aHelpText.GetSizePixel(); 491 // Size aHelpTextPixelSize = LogicToPixel( aHelpTextSize, MAP_APPFONT ); 492 // Rectangle aPrimaryRect( Point(0,0), aHelpTextSize ); 493 // Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sText, TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT | TEXT_DRAW_WORDBREAK ) ); 494 m_aHelpText.SetText(sText); 495 } 496 else 497 { 498 m_aHelpText.SetText(String()); 499 } 500 } 501 // ----------------------------------------------------------------------------- 502 IMPL_LINK(OTasksWindow, OnEntrySelectHdl, SvTreeListBox*, /*_pTreeBox*/) 503 { 504 DBG_CHKTHIS(OTasksWindow,NULL); 505 SvLBoxEntry* pEntry = m_aCreation.GetHdlEntry(); 506 if ( pEntry ) 507 m_aHelpText.SetText( ModuleRes( reinterpret_cast< TaskEntry* >( pEntry->GetUserData() )->nHelpID ) ); 508 return 1L; 509 } 510 // ----------------------------------------------------------------------------- 511 void OTasksWindow::Resize() 512 { 513 DBG_CHKTHIS(OTasksWindow,NULL); 514 ////////////////////////////////////////////////////////////////////// 515 // Abmessungen parent window 516 Size aOutputSize( GetOutputSize() ); 517 long nOutputWidth = aOutputSize.Width(); 518 long nOutputHeight = aOutputSize.Height(); 519 520 Size aFLSize = LogicToPixel( Size( 2, 6 ), MAP_APPFONT ); 521 sal_Int32 n6PPT = aFLSize.Height(); 522 long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5); 523 524 m_aCreation.SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) ); 525 // i77897 make the m_aHelpText a little bit smaller. (-5) 526 sal_Int32 nNewWidth = nOutputWidth - nHalfOutputWidth - aFLSize.Width() - 5; 527 // m_aHelpText.SetBackground( MAKE_SALCOLOR( 0xe0, 0xe0, 0xe0 ) ); 528 // Wallpaper aLightGray(Color(0xe0, 0xe0, 0xe0)); 529 // m_aHelpText.SetBackground( aLightGray ); 530 m_aDescription.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, 0), Size(nNewWidth, nOutputHeight) ); 531 Size aDesc = m_aDescription.CalcMinimumSize(); 532 m_aHelpText.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, aDesc.Height() ), Size(nNewWidth, nOutputHeight - aDesc.Height() - n6PPT) ); 533 534 m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0), Size(aFLSize.Width(), nOutputHeight ) ); 535 } 536 // ----------------------------------------------------------------------------- 537 void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) 538 { 539 DBG_CHKTHIS(OTasksWindow,NULL); 540 Clear(); 541 542 try 543 { 544 Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(getDetailView()->getBorderWin().getView()->getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"))),UNO_QUERY); 545 Reference<XUIConfigurationManager> xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument"))); 546 Reference<XImageManager> xImageMgr(xUIConfigMgr->getImageManager(),UNO_QUERY); 547 548 // copy the commands so we can use them with the config managers 549 Sequence< ::rtl::OUString > aCommands( _rList.size() ); 550 ::rtl::OUString* pCommands = aCommands.getArray(); 551 TaskEntryList::const_iterator aEnd = _rList.end(); 552 for ( TaskEntryList::const_iterator pCopyTask = _rList.begin(); pCopyTask != aEnd; ++pCopyTask, ++pCommands ) 553 *pCommands = pCopyTask->sUNOCommand; 554 555 Sequence< Reference< XGraphic> > aImages = xImageMgr->getImages( ImageType::SIZE_DEFAULT | ImageType::COLOR_NORMAL, aCommands ); 556 Sequence< Reference< XGraphic> > aHCImages = xImageMgr->getImages( ImageType::SIZE_DEFAULT | ImageType::COLOR_HIGHCONTRAST, aCommands ); 557 558 const Reference< XGraphic >* pImages( aImages.getConstArray() ); 559 const Reference< XGraphic >* pHCImages( aHCImages.getConstArray() ); 560 561 for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages, ++pHCImages ) 562 { 563 SvLBoxEntry* pEntry = m_aCreation.InsertEntry( pTask->sTitle ); 564 pEntry->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask ) ) ); 565 566 Image aImage = Image( *pImages ); 567 m_aCreation.SetExpandedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL ); 568 m_aCreation.SetCollapsedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL ); 569 570 Image aHCImage = Image( *pHCImages ); 571 m_aCreation.SetExpandedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST ); 572 m_aCreation.SetCollapsedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST ); 573 } 574 } 575 catch(Exception&) 576 { 577 } 578 579 m_aCreation.Show(); 580 m_aCreation.SelectAll(sal_False); 581 m_aHelpText.Show(); 582 m_aDescription.Show(); 583 m_aFL.Show(); 584 m_aCreation.updateHelpText(); 585 Enable(!_rList.empty()); 586 } 587 // ----------------------------------------------------------------------------- 588 void OTasksWindow::Clear() 589 { 590 DBG_CHKTHIS(OTasksWindow,NULL); 591 m_aCreation.resetLastActive(); 592 SvLBoxEntry* pEntry = m_aCreation.First(); 593 while ( pEntry ) 594 { 595 delete reinterpret_cast< TaskEntry* >( pEntry->GetUserData() ); 596 pEntry = m_aCreation.Next(pEntry); 597 } 598 m_aCreation.Clear(); 599 } 600 //================================================================== 601 // class OApplicationDetailView 602 //================================================================== 603 DBG_NAME(OApplicationDetailView) 604 OApplicationDetailView::OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode) : OSplitterView(&_rParent,sal_False ) 605 ,m_aHorzSplitter(this) 606 ,m_aTasks(this,STR_TASKS,WB_BORDER | WB_DIALOGCONTROL ) 607 ,m_aContainer(this,0,WB_BORDER | WB_DIALOGCONTROL ) 608 ,m_rBorderWin(_rParent) 609 { 610 DBG_CTOR(OApplicationDetailView,NULL); 611 SetUniqueId(UID_APP_DETAIL_VIEW); 612 ImplInitSettings( sal_True, sal_True, sal_True ); 613 614 m_pControlHelper = new OAppDetailPageHelper(&m_aContainer,m_rBorderWin,_ePreviewMode); 615 m_pControlHelper->Show(); 616 m_aContainer.setChildWindow(m_pControlHelper); 617 618 OTasksWindow* pTasks = new OTasksWindow(&m_aTasks,this); 619 pTasks->Show(); 620 pTasks->Disable(m_rBorderWin.getView()->getCommandController().isDataSourceReadOnly()); 621 m_aTasks.setChildWindow(pTasks); 622 m_aTasks.SetUniqueId(UID_APP_TASKS_VIEW); 623 m_aTasks.Show(); 624 625 m_aContainer.SetUniqueId(UID_APP_CONTAINER_VIEW); 626 m_aContainer.Show(); 627 628 const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width(); 629 m_aHorzSplitter.SetPosSizePixel( Point(0,50), Size(0,nFrameWidth) ); 630 // now set the components at the base class 631 set(&m_aContainer,&m_aTasks); 632 633 m_aHorzSplitter.Show(); 634 m_aHorzSplitter.SetUniqueId(UID_APP_VIEW_HORZ_SPLIT); 635 setSplitter(&m_aHorzSplitter); 636 } 637 // ----------------------------------------------------------------------------- 638 OApplicationDetailView::~OApplicationDetailView() 639 { 640 DBG_DTOR(OApplicationDetailView,NULL); 641 set(NULL,NULL); 642 setSplitter(NULL); 643 m_pControlHelper = NULL; 644 } 645 // ----------------------------------------------------------------------------- 646 void OApplicationDetailView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) 647 { 648 DBG_CHKTHIS(OApplicationDetailView,NULL); 649 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 650 if( bFont ) 651 { 652 Font aFont; 653 aFont = rStyleSettings.GetFieldFont(); 654 aFont.SetColor( rStyleSettings.GetWindowTextColor() ); 655 SetPointFont( aFont ); 656 } 657 658 if( bForeground || bFont ) 659 { 660 SetTextColor( rStyleSettings.GetFieldTextColor() ); 661 SetTextFillColor(); 662 } 663 664 if( bBackground ) 665 SetBackground( rStyleSettings.GetFieldColor() ); 666 667 //SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetDialogColor() ) ); 668 m_aHorzSplitter.SetBackground( rStyleSettings.GetDialogColor() ); 669 m_aHorzSplitter.SetFillColor( rStyleSettings.GetDialogColor() ); 670 m_aHorzSplitter.SetTextFillColor(rStyleSettings.GetDialogColor() ); 671 } 672 // ----------------------------------------------------------------------- 673 void OApplicationDetailView::DataChanged( const DataChangedEvent& rDCEvt ) 674 { 675 DBG_CHKTHIS(OApplicationDetailView,NULL); 676 OSplitterView::DataChanged( rDCEvt ); 677 678 if ( (rDCEvt.GetType() == DATACHANGED_FONTS) || 679 (rDCEvt.GetType() == DATACHANGED_DISPLAY) || 680 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || 681 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && 682 (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) 683 { 684 ImplInitSettings( sal_True, sal_True, sal_True ); 685 Invalidate(); 686 } 687 } 688 // ----------------------------------------------------------------------------- 689 void OApplicationDetailView::GetFocus() 690 { 691 DBG_CHKTHIS(OApplicationDetailView,NULL); 692 OSplitterView::GetFocus(); 693 } 694 695 // ----------------------------------------------------------------------------- 696 void OApplicationDetailView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics ) 697 { 698 m_aExternalMnemonics = _rMnemonics; 699 } 700 701 // ----------------------------------------------------------------------------- 702 bool OApplicationDetailView::interceptKeyInput( const KeyEvent& _rEvent ) 703 { 704 const KeyCode& rKeyCode = _rEvent.GetKeyCode(); 705 if ( rKeyCode.GetModifier() == KEY_MOD2 ) 706 return getTasksWindow().HandleKeyInput( _rEvent ); 707 708 // not handled 709 return false; 710 } 711 712 // ----------------------------------------------------------------------------- 713 void OApplicationDetailView::createTablesPage(const Reference< XConnection >& _xConnection ) 714 { 715 impl_createPage( E_TABLE, _xConnection, NULL ); 716 } 717 718 // ----------------------------------------------------------------------------- 719 void OApplicationDetailView::createPage( ElementType _eType,const Reference< XNameAccess >& _xContainer ) 720 { 721 impl_createPage( _eType, NULL, _xContainer ); 722 } 723 724 // ----------------------------------------------------------------------------- 725 void OApplicationDetailView::impl_createPage( ElementType _eType, const Reference< XConnection >& _rxConnection, 726 const Reference< XNameAccess >& _rxNonTableElements ) 727 { 728 DBG_CHKTHIS(OApplicationDetailView,NULL); 729 730 // get the data for the pane 731 const TaskPaneData& rData = impl_getTaskPaneData( _eType ); 732 getTasksWindow().fillTaskEntryList( rData.aTasks ); 733 734 // enable the pane as a whole, depending on the availability of the first command 735 OSL_ENSURE( !rData.aTasks.empty(), "OApplicationDetailView::impl_createPage: no tasks at all!?" ); 736 bool bEnabled = rData.aTasks.empty() 737 ? false 738 : getBorderWin().getView()->getCommandController().isCommandEnabled( rData.aTasks[0].sUNOCommand ); 739 getTasksWindow().Enable( bEnabled ); 740 m_aContainer.setTitle( rData.nTitleId ); 741 742 // let our helper create the object list 743 if ( _eType == E_TABLE ) 744 m_pControlHelper->createTablesPage( _rxConnection ); 745 else 746 m_pControlHelper->createPage( _eType, _rxNonTableElements ); 747 748 // resize for proper window arrangements 749 Resize(); 750 } 751 752 // ----------------------------------------------------------------------------- 753 const TaskPaneData& OApplicationDetailView::impl_getTaskPaneData( ElementType _eType ) 754 { 755 if ( m_aTaskPaneData.empty() ) 756 m_aTaskPaneData.resize( ELEMENT_COUNT ); 757 OSL_ENSURE( ( _eType >= 0 ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OApplicationDetailView::impl_getTaskPaneData: illegal element type!" ); 758 TaskPaneData& rData = m_aTaskPaneData[ _eType ]; 759 760 // if ( rData.aTasks.empty() ) 761 //oj: do not check, otherwise extensions will only be visible after a reload. 762 impl_fillTaskPaneData( _eType, rData ); 763 764 return rData; 765 } 766 767 // ----------------------------------------------------------------------------- 768 void OApplicationDetailView::impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const 769 { 770 TaskEntryList& rList( _rData.aTasks ); 771 rList.clear(); rList.reserve( 4 ); 772 773 switch ( _eType ) 774 { 775 case E_TABLE: 776 rList.push_back( TaskEntry( ".uno:DBNewTable", RID_STR_TABLES_HELP_TEXT_DESIGN, RID_STR_NEW_TABLE ) ); 777 rList.push_back( TaskEntry( ".uno:DBNewTableAutoPilot", RID_STR_TABLES_HELP_TEXT_WIZARD, RID_STR_NEW_TABLE_AUTO ) ); 778 rList.push_back( TaskEntry( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN, RID_STR_NEW_VIEW, true ) ); 779 _rData.nTitleId = RID_STR_TABLES_CONTAINER; 780 break; 781 782 case E_FORM: 783 rList.push_back( TaskEntry( ".uno:DBNewForm", RID_STR_FORMS_HELP_TEXT, RID_STR_NEW_FORM ) ); 784 rList.push_back( TaskEntry( ".uno:DBNewFormAutoPilot", RID_STR_FORMS_HELP_TEXT_WIZARD, RID_STR_NEW_FORM_AUTO ) ); 785 _rData.nTitleId = RID_STR_FORMS_CONTAINER; 786 break; 787 788 case E_REPORT: 789 rList.push_back( TaskEntry( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT, RID_STR_NEW_REPORT, true ) ); 790 rList.push_back( TaskEntry( ".uno:DBNewReportAutoPilot", RID_STR_REPORTS_HELP_TEXT_WIZARD, RID_STR_NEW_REPORT_AUTO ) ); 791 _rData.nTitleId = RID_STR_REPORTS_CONTAINER; 792 break; 793 794 case E_QUERY: 795 rList.push_back( TaskEntry( ".uno:DBNewQuery", RID_STR_QUERIES_HELP_TEXT, RID_STR_NEW_QUERY ) ); 796 rList.push_back( TaskEntry( ".uno:DBNewQueryAutoPilot", RID_STR_QUERIES_HELP_TEXT_WIZARD, RID_STR_NEW_QUERY_AUTO ) ); 797 rList.push_back( TaskEntry( ".uno:DBNewQuerySql", RID_STR_QUERIES_HELP_TEXT_SQL, RID_STR_NEW_QUERY_SQL ) ); 798 _rData.nTitleId = RID_STR_QUERIES_CONTAINER; 799 break; 800 801 default: 802 OSL_ENSURE( false, "OApplicationDetailView::impl_fillTaskPaneData: illegal element type!" ); 803 } 804 805 MnemonicGenerator aAllMnemonics( m_aExternalMnemonics ); 806 807 // remove the entries which are not enabled currently 808 for ( TaskEntryList::iterator pTask = rList.begin(); 809 pTask != rList.end(); 810 ) 811 { 812 if ( pTask->bHideWhenDisabled 813 && !getBorderWin().getView()->getCommandController().isCommandEnabled( pTask->sUNOCommand ) 814 ) 815 pTask = rList.erase( pTask ); 816 else 817 { 818 aAllMnemonics.RegisterMnemonic( pTask->sTitle ); 819 ++pTask; 820 } 821 } 822 823 // for the remaining entries, assign mnemonics 824 for ( TaskEntryList::iterator pTask = rList.begin(); 825 pTask != rList.end(); 826 ++pTask 827 ) 828 { 829 aAllMnemonics.CreateMnemonic( pTask->sTitle ); 830 // don't do this for now, until our task window really supports mnemonics 831 } 832 } 833 834 // ----------------------------------------------------------------------------- 835 ::rtl::OUString OApplicationDetailView::getQualifiedName( SvLBoxEntry* _pEntry ) const 836 { 837 DBG_CHKTHIS(OApplicationDetailView,NULL); 838 return m_pControlHelper->getQualifiedName( _pEntry ); 839 } 840 // ----------------------------------------------------------------------------- 841 sal_Bool OApplicationDetailView::isLeaf(SvLBoxEntry* _pEntry) const 842 { 843 DBG_CHKTHIS(OApplicationDetailView,NULL); 844 return m_pControlHelper->isLeaf(_pEntry); 845 } 846 // ----------------------------------------------------------------------------- 847 sal_Bool OApplicationDetailView::isALeafSelected() const 848 { 849 DBG_CHKTHIS(OApplicationDetailView,NULL); 850 return m_pControlHelper->isALeafSelected(); 851 } 852 // ----------------------------------------------------------------------------- 853 void OApplicationDetailView::selectAll() 854 { 855 DBG_CHKTHIS(OApplicationDetailView,NULL); 856 m_pControlHelper->selectAll(); 857 } 858 // ----------------------------------------------------------------------------- 859 void OApplicationDetailView::sortDown() 860 { 861 DBG_CHKTHIS(OApplicationDetailView,NULL); 862 m_pControlHelper->sortDown(); 863 } 864 // ----------------------------------------------------------------------------- 865 void OApplicationDetailView::sortUp() 866 { 867 DBG_CHKTHIS(OApplicationDetailView,NULL); 868 m_pControlHelper->sortUp(); 869 } 870 // ----------------------------------------------------------------------------- 871 sal_Bool OApplicationDetailView::isFilled() const 872 { 873 DBG_CHKTHIS(OApplicationDetailView,NULL); 874 return m_pControlHelper->isFilled(); 875 } 876 // ----------------------------------------------------------------------------- 877 ElementType OApplicationDetailView::getElementType() const 878 { 879 DBG_CHKTHIS(OApplicationDetailView,NULL); 880 return m_pControlHelper->getElementType(); 881 } 882 // ----------------------------------------------------------------------------- 883 void OApplicationDetailView::clearPages(sal_Bool _bTaskAlso) 884 { 885 DBG_CHKTHIS(OApplicationDetailView,NULL); 886 if ( _bTaskAlso ) 887 getTasksWindow().Clear(); 888 m_pControlHelper->clearPages(); 889 } 890 // ----------------------------------------------------------------------------- 891 sal_Int32 OApplicationDetailView::getSelectionCount() 892 { 893 DBG_CHKTHIS(OApplicationDetailView,NULL); 894 return m_pControlHelper->getSelectionCount(); 895 } 896 // ----------------------------------------------------------------------------- 897 sal_Int32 OApplicationDetailView::getElementCount() 898 { 899 DBG_CHKTHIS(OApplicationDetailView,NULL); 900 return m_pControlHelper->getElementCount(); 901 } 902 903 // ----------------------------------------------------------------------------- 904 void OApplicationDetailView::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const 905 { 906 DBG_CHKTHIS(OApplicationDetailView,NULL); 907 m_pControlHelper->getSelectionElementNames( _rNames ); 908 } 909 // ----------------------------------------------------------------------------- 910 void OApplicationDetailView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects ) 911 { 912 DBG_CHKTHIS(OApplicationDetailView,NULL); 913 m_pControlHelper->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects ); 914 } 915 // ----------------------------------------------------------------------------- 916 void OApplicationDetailView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects ) 917 { 918 DBG_CHKTHIS(OApplicationDetailView,NULL); 919 m_pControlHelper->describeCurrentSelectionForType( _eType, _out_rSelectedObjects ); 920 } 921 // ----------------------------------------------------------------------------- 922 void OApplicationDetailView::selectElements(const Sequence< ::rtl::OUString>& _aNames) 923 { 924 DBG_CHKTHIS(OApplicationDetailView,NULL); 925 m_pControlHelper->selectElements( _aNames ); 926 } 927 // ----------------------------------------------------------------------------- 928 SvLBoxEntry* OApplicationDetailView::getEntry( const Point& _aPoint ) const 929 { 930 DBG_CHKTHIS(OApplicationDetailView,NULL); 931 return m_pControlHelper->getEntry(_aPoint); 932 } 933 // ----------------------------------------------------------------------------- 934 sal_Bool OApplicationDetailView::isCutAllowed() 935 { 936 DBG_CHKTHIS(OApplicationDetailView,NULL); 937 return m_pControlHelper->isCutAllowed(); 938 } 939 sal_Bool OApplicationDetailView::isCopyAllowed() 940 { 941 DBG_CHKTHIS(OApplicationDetailView,NULL); 942 return m_pControlHelper->isCopyAllowed(); 943 } 944 sal_Bool OApplicationDetailView::isPasteAllowed() { DBG_CHKTHIS(OApplicationDetailView,NULL);return m_pControlHelper->isPasteAllowed(); } 945 void OApplicationDetailView::copy() { DBG_CHKTHIS(OApplicationDetailView,NULL);m_pControlHelper->copy(); } 946 void OApplicationDetailView::cut() { DBG_CHKTHIS(OApplicationDetailView,NULL);m_pControlHelper->cut(); } 947 void OApplicationDetailView::paste() 948 { 949 DBG_CHKTHIS(OApplicationDetailView,NULL); 950 m_pControlHelper->paste(); 951 } 952 // ----------------------------------------------------------------------------- 953 SvLBoxEntry* OApplicationDetailView::elementAdded(ElementType _eType,const ::rtl::OUString& _rName, const Any& _rObject ) 954 { 955 DBG_CHKTHIS(OApplicationDetailView,NULL); 956 return m_pControlHelper->elementAdded(_eType,_rName, _rObject ); 957 } 958 // ----------------------------------------------------------------------------- 959 void OApplicationDetailView::elementRemoved(ElementType _eType,const ::rtl::OUString& _rName ) 960 { 961 DBG_CHKTHIS(OApplicationDetailView,NULL); 962 m_pControlHelper->elementRemoved(_eType,_rName ); 963 } 964 // ----------------------------------------------------------------------------- 965 void OApplicationDetailView::elementReplaced(ElementType _eType 966 ,const ::rtl::OUString& _rOldName 967 ,const ::rtl::OUString& _rNewName ) 968 { 969 DBG_CHKTHIS(OApplicationDetailView,NULL); 970 m_pControlHelper->elementReplaced( _eType, _rOldName, _rNewName ); 971 } 972 // ----------------------------------------------------------------------------- 973 PreviewMode OApplicationDetailView::getPreviewMode() 974 { 975 DBG_CHKTHIS(OApplicationDetailView,NULL); 976 return m_pControlHelper->getPreviewMode(); 977 } 978 // ----------------------------------------------------------------------------- 979 sal_Bool OApplicationDetailView::isPreviewEnabled() 980 { 981 DBG_CHKTHIS(OApplicationDetailView,NULL); 982 return m_pControlHelper->isPreviewEnabled(); 983 } 984 // ----------------------------------------------------------------------------- 985 void OApplicationDetailView::switchPreview(PreviewMode _eMode) 986 { 987 DBG_CHKTHIS(OApplicationDetailView,NULL); 988 m_pControlHelper->switchPreview(_eMode); 989 } 990 // ----------------------------------------------------------------------------- 991 void OApplicationDetailView::showPreview(const Reference< XContent >& _xContent) 992 { 993 DBG_CHKTHIS(OApplicationDetailView,NULL); 994 m_pControlHelper->showPreview(_xContent); 995 } 996 // ----------------------------------------------------------------------------- 997 void OApplicationDetailView::showPreview( const ::rtl::OUString& _sDataSourceName, 998 const ::rtl::OUString& _sName, 999 sal_Bool _bTable) 1000 { 1001 DBG_CHKTHIS(OApplicationDetailView,NULL); 1002 m_pControlHelper->showPreview(_sDataSourceName,_sName,_bTable); 1003 } 1004 // ----------------------------------------------------------------------------- 1005 sal_Bool OApplicationDetailView::isSortUp() const 1006 { 1007 DBG_CHKTHIS(OApplicationDetailView,NULL); 1008 return m_pControlHelper->isSortUp(); 1009 } 1010 // ----------------------------------------------------------------------------- 1011 Window* OApplicationDetailView::getTreeWindow() const 1012 { 1013 return m_pControlHelper->getCurrentView(); 1014 } 1015 1016