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