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