1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "AppDetailView.hxx"
30 #include <osl/diagnose.h>
31 #include "dbaccess_helpid.hrc"
32 #include "dbu_app.hrc"
33 #include "AppView.hxx"
34 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
35 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
36 #include <com/sun/star/ui/XImageManager.hpp>
37 #include <com/sun/star/ui/ImageType.hpp>
38 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
39 #include <com/sun/star/graphic/XGraphic.hpp>
40 #include <com/sun/star/util/URL.hpp>
41 #include "listviewitems.hxx"
42 #include <vcl/image.hxx>
43 #include <vcl/mnemonic.hxx>
44 #include "browserids.hxx"
45 #include "AppDetailPageHelper.hxx"
46 #include <vcl/svapp.hxx>
47 #include "callbacks.hxx"
48 #include "IController.hxx"
49 #include "moduledbu.hxx"
50 #include <svtools/localresaccess.hxx>
52 #include "dbtreelistbox.hxx"
53 #include "IApplicationController.hxx"
54 #include "imageprovider.hxx"
56 using namespace ::dbaui
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::sdbc
;
59 using namespace ::com::sun::star::sdbcx
;
60 using namespace ::com::sun::star::lang
;
61 using namespace ::com::sun::star::ucb
;
62 using namespace ::com::sun::star::graphic
;
63 using namespace ::com::sun::star::ui
;
64 using namespace ::com::sun::star::container
;
65 using namespace ::com::sun::star::beans
;
66 using ::com::sun::star::util::URL
;
67 using ::com::sun::star::sdb::application::NamedDatabaseObject
;
69 #define SPACEBETWEENENTRIES 4
71 // -----------------------------------------------------------------------------
72 TaskEntry::TaskEntry( const sal_Char
* _pAsciiUNOCommand
, sal_uInt16 _nHelpID
, sal_uInt16 _nTitleResourceID
, bool _bHideWhenDisabled
)
73 :sUNOCommand( ::rtl::OUString::createFromAscii( _pAsciiUNOCommand
) )
75 ,sTitle( ModuleRes( _nTitleResourceID
) )
76 ,bHideWhenDisabled( _bHideWhenDisabled
)
80 // -----------------------------------------------------------------------------
81 OCreationList::OCreationList( OTasksWindow
& _rParent
)
82 :SvTreeListBox( &_rParent
, WB_TABSTOP
| WB_HASBUTTONSATROOT
| WB_HASBUTTONS
)
83 ,m_rTaskWindow( _rParent
)
84 ,m_pMouseDownEntry( NULL
)
85 ,m_pLastActiveEntry( NULL
)
87 sal_uInt16 nSize
= SPACEBETWEENENTRIES
;
88 SetSpaceBetweenEntries(nSize
);
89 SetSelectionMode( NO_SELECTION
);
90 SetExtendedWinBits( EWB_NO_AUTO_CURENTRY
);
91 SetNodeDefaultImages( );
92 EnableEntryMnemonics();
94 // -----------------------------------------------------------------------------
95 void OCreationList::Paint( const Rectangle
& _rRect
)
97 if ( m_pMouseDownEntry
)
98 m_aOriginalFont
= GetFont();
100 m_aOriginalBackgroundColor
= GetBackground().GetColor();
101 SvTreeListBox::Paint( _rRect
);
102 SetBackground( m_aOriginalBackgroundColor
);
104 if ( m_pMouseDownEntry
)
105 Control::SetFont( m_aOriginalFont
);
108 // -----------------------------------------------------------------------------
109 void OCreationList::PreparePaint( SvLBoxEntry
* _pEntry
)
111 Wallpaper
aEntryBackground( m_aOriginalBackgroundColor
);
114 if ( _pEntry
== GetCurEntry() )
116 // draw a selection background
117 bool bIsMouseDownEntry
= ( _pEntry
== m_pMouseDownEntry
);
118 DrawSelectionBackground( GetBoundingRect( _pEntry
), bIsMouseDownEntry
? 1 : 2, sal_False
, sal_True
, sal_False
);
120 if ( bIsMouseDownEntry
)
122 Font
aFont( GetFont() );
123 aFont
.SetColor( GetSettings().GetStyleSettings().GetHighlightTextColor() );
124 Control::SetFont( aFont
);
127 // and temporary set a transparent background, for all the other
128 // paint operations the SvTreeListBox is going to do
129 aEntryBackground
= Wallpaper( Color( COL_TRANSPARENT
) );
133 SetBackground( aEntryBackground
);
136 // -----------------------------------------------------------------------------
137 void OCreationList::SelectSearchEntry( const void* _pEntry
)
139 SvLBoxEntry
* pEntry
= const_cast< SvLBoxEntry
* >( static_cast< const SvLBoxEntry
* >( _pEntry
) );
140 OSL_ENSURE( pEntry
, "OCreationList::SelectSearchEntry: invalid entry!" );
143 setCurrentEntryInvalidate( pEntry
);
145 if ( !HasChildPathFocus() )
149 // -----------------------------------------------------------------------------
150 void OCreationList::ExecuteSearchEntry( const void* _pEntry
) const
152 SvLBoxEntry
* pEntry
= const_cast< SvLBoxEntry
* >( static_cast< const SvLBoxEntry
* >( _pEntry
) );
153 OSL_ENSURE( pEntry
, "OCreationList::ExecuteSearchEntry: invalid entry!" );
154 OSL_ENSURE( pEntry
== GetCurEntry(), "OCreationList::ExecuteSearchEntry: SelectSearchEntry should have been called before!" );
157 onSelected( pEntry
);
160 // -----------------------------------------------------------------------------
161 Rectangle
OCreationList::GetFocusRect( SvLBoxEntry
* _pEntry
, long _nLine
)
163 Rectangle aRect
= SvTreeListBox::GetFocusRect( _pEntry
, _nLine
);
166 // try to let the focus rect start before the bitmap item - this looks better
167 SvLBoxItem
* pBitmapItem
= _pEntry
->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP
);
168 SvLBoxTab
* pTab
= pBitmapItem
? GetTab( _pEntry
, pBitmapItem
) : NULL
;
169 SvViewDataItem
* pItemData
= pBitmapItem
? GetViewDataItem( _pEntry
, pBitmapItem
) : NULL
;
170 OSL_ENSURE( pTab
&& pItemData
, "OCreationList::GetFocusRect: could not find the first bitmap item!" );
171 if ( pTab
&& pItemData
)
172 aRect
.Left() = pTab
->GetPos() - pItemData
->aSize
.Width() / 2;
174 // inflate the rectangle a little bit - looks better, too
175 aRect
.Left() = ::std::max
< long >( 0, aRect
.Left() - 2 );
176 aRect
.Right() = ::std::min
< long >( GetOutputSizePixel().Width() - 1, aRect
.Right() + 2 );
180 // -----------------------------------------------------------------------------
181 void OCreationList::StartDrag( sal_Int8
/*_nAction*/, const Point
& /*_rPosPixel*/ )
183 // don't give this to the base class, it does a ReleaseMouse as very first action
184 // Though I think this is a bug (it should ReleaseMouse only if it is going to do
185 // something with the drag-event), I hesitate to fix it in the current state,
186 // since I don't overlook the consequences, and we're close to 2.0 ...)
188 // -----------------------------------------------------------------------------
189 void OCreationList::ModelHasCleared()
191 SvTreeListBox::ModelHasCleared();
192 m_pLastActiveEntry
= NULL
;
193 m_pMouseDownEntry
= NULL
;
195 // -----------------------------------------------------------------------------
196 void OCreationList::GetFocus()
198 SvTreeListBox::GetFocus();
199 if ( !GetCurEntry() )
200 setCurrentEntryInvalidate( m_pLastActiveEntry
? m_pLastActiveEntry
: GetFirstEntryInView() );
202 // -----------------------------------------------------------------------------
203 void OCreationList::LoseFocus()
205 SvTreeListBox::LoseFocus();
206 m_pLastActiveEntry
= GetCurEntry();
207 setCurrentEntryInvalidate( NULL
);
209 // -----------------------------------------------------------------------------
210 void OCreationList::MouseButtonDown( const MouseEvent
& rMEvt
)
212 SvTreeListBox::MouseButtonDown( rMEvt
);
214 OSL_ENSURE( !m_pMouseDownEntry
, "OCreationList::MouseButtonDown: I missed some mouse event!" );
215 m_pMouseDownEntry
= GetCurEntry();
216 if ( m_pMouseDownEntry
)
218 InvalidateEntry( m_pMouseDownEntry
);
222 // -----------------------------------------------------------------------------
223 void OCreationList::MouseMove( const MouseEvent
& rMEvt
)
225 if ( rMEvt
.IsLeaveWindow() )
227 setCurrentEntryInvalidate( NULL
);
229 else if ( !rMEvt
.IsSynthetic() )
231 SvLBoxEntry
* pEntry
= GetEntry( rMEvt
.GetPosPixel() );
233 if ( m_pMouseDownEntry
)
235 // we're currently in a "mouse down" phase
236 OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseMove: inconsistence (1)!" );
237 if ( pEntry
== m_pMouseDownEntry
)
239 setCurrentEntryInvalidate( m_pMouseDownEntry
);
243 OSL_ENSURE( ( GetCurEntry() == m_pMouseDownEntry
) || !GetCurEntry(),
244 "OCreationList::MouseMove: inconsistence (2)!" );
245 setCurrentEntryInvalidate( NULL
);
250 // the user is simply hovering with the mouse
251 if ( setCurrentEntryInvalidate( pEntry
) )
253 if ( !m_pMouseDownEntry
)
259 SvTreeListBox::MouseMove(rMEvt
);
261 // -----------------------------------------------------------------------------
262 void OCreationList::MouseButtonUp( const MouseEvent
& rMEvt
)
264 SvLBoxEntry
* pEntry
= GetEntry( rMEvt
.GetPosPixel() );
265 bool bExecute
= false;
266 // Was the mouse released over the active entry?
267 // (i.e. the entry which was under the mouse when the button went down)
268 if ( pEntry
&& ( m_pMouseDownEntry
== pEntry
) )
270 if ( !rMEvt
.IsShift() && !rMEvt
.IsMod1() && !rMEvt
.IsMod2() && rMEvt
.IsLeft() && rMEvt
.GetClicks() == 1 )
274 if ( m_pMouseDownEntry
)
276 OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseButtonUp: hmmm .... no mouse captured, but an active entry?" );
279 InvalidateEntry( m_pMouseDownEntry
);
280 m_pMouseDownEntry
= NULL
;
283 SvTreeListBox::MouseButtonUp( rMEvt
);
286 onSelected( pEntry
);
288 // -----------------------------------------------------------------------------
289 bool OCreationList::setCurrentEntryInvalidate( SvLBoxEntry
* _pEntry
)
291 if ( GetCurEntry() != _pEntry
)
294 InvalidateEntry( GetCurEntry() );
295 SetCurEntry( _pEntry
);
298 InvalidateEntry( GetCurEntry() );
299 CallEventListeners( VCLEVENT_LISTBOX_SELECT
, GetCurEntry() );
306 // -----------------------------------------------------------------------------
307 void OCreationList::updateHelpText()
309 sal_uInt16 nHelpTextId
= 0;
311 nHelpTextId
= reinterpret_cast< TaskEntry
* >( GetCurEntry()->GetUserData() )->nHelpID
;
312 m_rTaskWindow
.setHelpText( nHelpTextId
);
314 // -----------------------------------------------------------------------------
315 void OCreationList::onSelected( SvLBoxEntry
* _pEntry
) const
317 OSL_ENSURE( _pEntry
, "OCreationList::onSelected: invalid entry!" );
319 aCommand
.Complete
= reinterpret_cast< TaskEntry
* >( _pEntry
->GetUserData() )->sUNOCommand
;
320 m_rTaskWindow
.getDetailView()->getBorderWin().getView()->getAppController().executeChecked( aCommand
, Sequence
< PropertyValue
>() );
322 // -----------------------------------------------------------------------------
323 void OCreationList::KeyInput( const KeyEvent
& rKEvt
)
325 const KeyCode
& rCode
= rKEvt
.GetKeyCode();
326 if ( !rCode
.IsMod1() && !rCode
.IsMod2() && !rCode
.IsShift() )
328 if ( rCode
.GetCode() == KEY_RETURN
)
330 SvLBoxEntry
* pEntry
= GetCurEntry() ? GetCurEntry() : FirstSelected();
332 onSelected( pEntry
);
336 SvLBoxEntry
* pOldCurrent
= GetCurEntry();
337 SvTreeListBox::KeyInput(rKEvt
);
338 SvLBoxEntry
* pNewCurrent
= GetCurEntry();
340 if ( pOldCurrent
!= pNewCurrent
)
343 InvalidateEntry( pOldCurrent
);
346 InvalidateEntry( pNewCurrent
);
347 CallEventListeners( VCLEVENT_LISTBOX_SELECT
, pNewCurrent
);
352 // -----------------------------------------------------------------------------
353 DBG_NAME(OTasksWindow
)
354 OTasksWindow::OTasksWindow(Window
* _pParent
,OApplicationDetailView
* _pDetailView
)
355 : Window(_pParent
,WB_DIALOGCONTROL
)
357 ,m_aDescription(this)
358 ,m_aHelpText(this,WB_WORDBREAK
)
360 ,m_pDetailView(_pDetailView
)
362 DBG_CTOR(OTasksWindow
,NULL
);
363 SetUniqueId(UID_APP_TASKS_WINDOW
);
364 m_aCreation
.SetHelpId(HID_APP_CREATION_LIST
);
365 m_aCreation
.SetSelectHdl(LINK(this, OTasksWindow
, OnEntrySelectHdl
));
366 m_aHelpText
.SetHelpId(HID_APP_HELP_TEXT
);
367 m_aDescription
.SetHelpId(HID_APP_DESCRIPTION_TEXT
);
368 m_aDescription
.SetText(ModuleRes(STR_DESCRIPTION
));
370 ImageProvider aImageProvider
;
371 Image aFolderImage
= aImageProvider
.getFolderImage( DatabaseObject::FORM
);
372 m_aCreation
.SetDefaultCollapsedEntryBmp( aFolderImage
);
373 m_aCreation
.SetDefaultExpandedEntryBmp( aFolderImage
);
375 ImplInitSettings(sal_True
,sal_True
,sal_True
);
377 // -----------------------------------------------------------------------------
378 OTasksWindow::~OTasksWindow()
380 DBG_DTOR(OTasksWindow
,NULL
);
383 // -----------------------------------------------------------------------
384 void OTasksWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
386 DBG_CHKTHIS(OTasksWindow
,NULL
);
387 Window::DataChanged( rDCEvt
);
389 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
390 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
392 ImplInitSettings( sal_True
, sal_True
, sal_True
);
396 // -----------------------------------------------------------------------------
397 void OTasksWindow::ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
)
399 DBG_CHKTHIS(OTasksWindow
,NULL
);
400 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
404 aFont
= rStyleSettings
.GetFieldFont();
405 aFont
.SetColor( rStyleSettings
.GetWindowTextColor() );
406 SetPointFont( aFont
);
409 if( bForeground
|| bFont
)
411 SetTextColor( rStyleSettings
.GetFieldTextColor() );
413 m_aHelpText
.SetTextColor( rStyleSettings
.GetFieldTextColor() );
414 m_aHelpText
.SetTextFillColor();
415 m_aDescription
.SetTextColor( rStyleSettings
.GetFieldTextColor() );
416 m_aDescription
.SetTextFillColor();
421 SetBackground( rStyleSettings
.GetFieldColor() );
422 m_aHelpText
.SetBackground( rStyleSettings
.GetFieldColor() );
423 m_aDescription
.SetBackground( rStyleSettings
.GetFieldColor() );
424 m_aFL
.SetBackground( rStyleSettings
.GetFieldColor() );
427 Font aFont
= m_aDescription
.GetControlFont();
428 aFont
.SetWeight(WEIGHT_BOLD
);
429 m_aDescription
.SetControlFont(aFont
);
431 // -----------------------------------------------------------------------------
432 void OTasksWindow::setHelpText(sal_uInt16 _nId
)
434 DBG_CHKTHIS(OTasksWindow
,NULL
);
437 String sText
= ModuleRes(_nId
);
439 m_aHelpText
.SetText(sText
);
443 m_aHelpText
.SetText(String());
446 // -----------------------------------------------------------------------------
447 IMPL_LINK(OTasksWindow
, OnEntrySelectHdl
, SvTreeListBox
*, /*_pTreeBox*/)
449 DBG_CHKTHIS(OTasksWindow
,NULL
);
450 SvLBoxEntry
* pEntry
= m_aCreation
.GetHdlEntry();
452 m_aHelpText
.SetText( ModuleRes( reinterpret_cast< TaskEntry
* >( pEntry
->GetUserData() )->nHelpID
) );
455 // -----------------------------------------------------------------------------
456 void OTasksWindow::Resize()
458 DBG_CHKTHIS(OTasksWindow
,NULL
);
460 // parent window dimension
461 Size
aOutputSize( GetOutputSize() );
462 long nOutputWidth
= aOutputSize
.Width();
463 long nOutputHeight
= aOutputSize
.Height();
465 Size aFLSize
= LogicToPixel( Size( 2, 6 ), MAP_APPFONT
);
466 sal_Int32 n6PPT
= aFLSize
.Height();
467 long nHalfOutputWidth
= static_cast<long>(nOutputWidth
* 0.5);
469 m_aCreation
.SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth
- n6PPT
, nOutputHeight
) );
470 // i77897 make the m_aHelpText a little bit smaller. (-5)
471 sal_Int32 nNewWidth
= nOutputWidth
- nHalfOutputWidth
- aFLSize
.Width() - 5;
472 m_aDescription
.SetPosSizePixel( Point(nHalfOutputWidth
+ n6PPT
, 0), Size(nNewWidth
, nOutputHeight
) );
473 Size aDesc
= m_aDescription
.CalcMinimumSize();
474 m_aHelpText
.SetPosSizePixel( Point(nHalfOutputWidth
+ n6PPT
, aDesc
.Height() ), Size(nNewWidth
, nOutputHeight
- aDesc
.Height() - n6PPT
) );
476 m_aFL
.SetPosSizePixel( Point(nHalfOutputWidth
, 0), Size(aFLSize
.Width(), nOutputHeight
) );
478 // -----------------------------------------------------------------------------
479 void OTasksWindow::fillTaskEntryList( const TaskEntryList
& _rList
)
481 DBG_CHKTHIS(OTasksWindow
,NULL
);
486 Reference
< XModuleUIConfigurationManagerSupplier
> xModuleCfgMgrSupplier(
487 getDetailView()->getBorderWin().getView()->getORB()->createInstance(
488 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) )
492 Reference
< XUIConfigurationManager
> xUIConfigMgr
= xModuleCfgMgrSupplier
->getUIConfigurationManager(
493 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.OfficeDatabaseDocument" ) )
495 Reference
< XImageManager
> xImageMgr( xUIConfigMgr
->getImageManager(), UNO_QUERY
);
497 // copy the commands so we can use them with the config managers
498 Sequence
< ::rtl::OUString
> aCommands( _rList
.size() );
499 ::rtl::OUString
* pCommands
= aCommands
.getArray();
500 TaskEntryList::const_iterator aEnd
= _rList
.end();
501 for ( TaskEntryList::const_iterator pCopyTask
= _rList
.begin(); pCopyTask
!= aEnd
; ++pCopyTask
, ++pCommands
)
502 *pCommands
= pCopyTask
->sUNOCommand
;
504 Sequence
< Reference
< XGraphic
> > aImages
= xImageMgr
->getImages(
505 ImageType::SIZE_DEFAULT
| ImageType::COLOR_NORMAL
,
509 const Reference
< XGraphic
>* pImages( aImages
.getConstArray() );
511 for ( TaskEntryList::const_iterator pTask
= _rList
.begin(); pTask
!= aEnd
; ++pTask
, ++pImages
)
513 SvLBoxEntry
* pEntry
= m_aCreation
.InsertEntry( pTask
->sTitle
);
514 pEntry
->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask
) ) );
516 Image aImage
= Image( *pImages
);
517 m_aCreation
.SetExpandedEntryBmp( pEntry
, aImage
);
518 m_aCreation
.SetCollapsedEntryBmp( pEntry
, aImage
);
526 m_aCreation
.SelectAll(sal_False
);
528 m_aDescription
.Show();
530 m_aCreation
.updateHelpText();
531 Enable(!_rList
.empty());
533 // -----------------------------------------------------------------------------
534 void OTasksWindow::Clear()
536 DBG_CHKTHIS(OTasksWindow
,NULL
);
537 m_aCreation
.resetLastActive();
538 SvLBoxEntry
* pEntry
= m_aCreation
.First();
541 delete reinterpret_cast< TaskEntry
* >( pEntry
->GetUserData() );
542 pEntry
= m_aCreation
.Next(pEntry
);
546 //==================================================================
547 // class OApplicationDetailView
548 //==================================================================
549 DBG_NAME(OApplicationDetailView
)
550 OApplicationDetailView::OApplicationDetailView(OAppBorderWindow
& _rParent
,PreviewMode _ePreviewMode
) : OSplitterView(&_rParent
,sal_False
)
551 ,m_aHorzSplitter(this)
552 ,m_aTasks(this,STR_TASKS
,WB_BORDER
| WB_DIALOGCONTROL
)
553 ,m_aContainer(this,0,WB_BORDER
| WB_DIALOGCONTROL
)
554 ,m_rBorderWin(_rParent
)
556 DBG_CTOR(OApplicationDetailView
,NULL
);
557 SetUniqueId(UID_APP_DETAIL_VIEW
);
558 ImplInitSettings( sal_True
, sal_True
, sal_True
);
560 m_pControlHelper
= new OAppDetailPageHelper(&m_aContainer
,m_rBorderWin
,_ePreviewMode
);
561 m_pControlHelper
->Show();
562 m_aContainer
.setChildWindow(m_pControlHelper
);
564 OTasksWindow
* pTasks
= new OTasksWindow(&m_aTasks
,this);
566 pTasks
->Disable(m_rBorderWin
.getView()->getCommandController().isDataSourceReadOnly());
567 m_aTasks
.setChildWindow(pTasks
);
568 m_aTasks
.SetUniqueId(UID_APP_TASKS_VIEW
);
571 m_aContainer
.SetUniqueId(UID_APP_CONTAINER_VIEW
);
574 const long nFrameWidth
= LogicToPixel( Size( 3, 0 ), MAP_APPFONT
).Width();
575 m_aHorzSplitter
.SetPosSizePixel( Point(0,50), Size(0,nFrameWidth
) );
576 // now set the components at the base class
577 set(&m_aContainer
,&m_aTasks
);
579 m_aHorzSplitter
.Show();
580 m_aHorzSplitter
.SetUniqueId(UID_APP_VIEW_HORZ_SPLIT
);
581 setSplitter(&m_aHorzSplitter
);
583 // -----------------------------------------------------------------------------
584 OApplicationDetailView::~OApplicationDetailView()
586 DBG_DTOR(OApplicationDetailView
,NULL
);
589 m_pControlHelper
= NULL
;
591 // -----------------------------------------------------------------------------
592 void OApplicationDetailView::ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
)
594 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
595 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
599 aFont
= rStyleSettings
.GetFieldFont();
600 aFont
.SetColor( rStyleSettings
.GetWindowTextColor() );
601 SetPointFont( aFont
);
604 if( bForeground
|| bFont
)
606 SetTextColor( rStyleSettings
.GetFieldTextColor() );
611 SetBackground( rStyleSettings
.GetFieldColor() );
613 m_aHorzSplitter
.SetBackground( rStyleSettings
.GetDialogColor() );
614 m_aHorzSplitter
.SetFillColor( rStyleSettings
.GetDialogColor() );
615 m_aHorzSplitter
.SetTextFillColor(rStyleSettings
.GetDialogColor() );
617 // -----------------------------------------------------------------------
618 void OApplicationDetailView::DataChanged( const DataChangedEvent
& rDCEvt
)
620 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
621 OSplitterView::DataChanged( rDCEvt
);
623 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
624 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
625 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
626 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
627 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
629 ImplInitSettings( sal_True
, sal_True
, sal_True
);
633 // -----------------------------------------------------------------------------
634 void OApplicationDetailView::GetFocus()
636 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
637 OSplitterView::GetFocus();
640 // -----------------------------------------------------------------------------
641 void OApplicationDetailView::setTaskExternalMnemonics( MnemonicGenerator
& _rMnemonics
)
643 m_aExternalMnemonics
= _rMnemonics
;
646 // -----------------------------------------------------------------------------
647 bool OApplicationDetailView::interceptKeyInput( const KeyEvent
& _rEvent
)
649 const KeyCode
& rKeyCode
= _rEvent
.GetKeyCode();
650 if ( rKeyCode
.GetModifier() == KEY_MOD2
)
651 return getTasksWindow().HandleKeyInput( _rEvent
);
657 // -----------------------------------------------------------------------------
658 void OApplicationDetailView::createTablesPage(const Reference
< XConnection
>& _xConnection
)
660 impl_createPage( E_TABLE
, _xConnection
, NULL
);
663 // -----------------------------------------------------------------------------
664 void OApplicationDetailView::createPage( ElementType _eType
,const Reference
< XNameAccess
>& _xContainer
)
666 impl_createPage( _eType
, NULL
, _xContainer
);
669 // -----------------------------------------------------------------------------
670 void OApplicationDetailView::impl_createPage( ElementType _eType
, const Reference
< XConnection
>& _rxConnection
,
671 const Reference
< XNameAccess
>& _rxNonTableElements
)
673 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
675 // get the data for the pane
676 const TaskPaneData
& rData
= impl_getTaskPaneData( _eType
);
677 getTasksWindow().fillTaskEntryList( rData
.aTasks
);
679 // enable the pane as a whole, depending on the availability of the first command
680 OSL_ENSURE( !rData
.aTasks
.empty(), "OApplicationDetailView::impl_createPage: no tasks at all!?" );
681 bool bEnabled
= rData
.aTasks
.empty()
683 : getBorderWin().getView()->getCommandController().isCommandEnabled( rData
.aTasks
[0].sUNOCommand
);
684 getTasksWindow().Enable( bEnabled
);
685 m_aContainer
.setTitle( rData
.nTitleId
);
687 // let our helper create the object list
688 if ( _eType
== E_TABLE
)
689 m_pControlHelper
->createTablesPage( _rxConnection
);
691 m_pControlHelper
->createPage( _eType
, _rxNonTableElements
);
693 // resize for proper window arrangements
697 // -----------------------------------------------------------------------------
698 const TaskPaneData
& OApplicationDetailView::impl_getTaskPaneData( ElementType _eType
)
700 if ( m_aTaskPaneData
.empty() )
701 m_aTaskPaneData
.resize( ELEMENT_COUNT
);
702 OSL_ENSURE( ( _eType
>= 0 ) && ( _eType
< E_ELEMENT_TYPE_COUNT
), "OApplicationDetailView::impl_getTaskPaneData: illegal element type!" );
703 TaskPaneData
& rData
= m_aTaskPaneData
[ _eType
];
705 //oj: do not check, otherwise extensions will only be visible after a reload.
706 impl_fillTaskPaneData( _eType
, rData
);
711 // -----------------------------------------------------------------------------
712 void OApplicationDetailView::impl_fillTaskPaneData( ElementType _eType
, TaskPaneData
& _rData
) const
714 TaskEntryList
& rList( _rData
.aTasks
);
715 rList
.clear(); rList
.reserve( 4 );
720 rList
.push_back( TaskEntry( ".uno:DBNewTable", RID_STR_TABLES_HELP_TEXT_DESIGN
, RID_STR_NEW_TABLE
) );
721 rList
.push_back( TaskEntry( ".uno:DBNewTableAutoPilot", RID_STR_TABLES_HELP_TEXT_WIZARD
, RID_STR_NEW_TABLE_AUTO
) );
722 rList
.push_back( TaskEntry( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN
, RID_STR_NEW_VIEW
, true ) );
723 _rData
.nTitleId
= RID_STR_TABLES_CONTAINER
;
727 rList
.push_back( TaskEntry( ".uno:DBNewForm", RID_STR_FORMS_HELP_TEXT
, RID_STR_NEW_FORM
) );
728 rList
.push_back( TaskEntry( ".uno:DBNewFormAutoPilot", RID_STR_FORMS_HELP_TEXT_WIZARD
, RID_STR_NEW_FORM_AUTO
) );
729 _rData
.nTitleId
= RID_STR_FORMS_CONTAINER
;
733 rList
.push_back( TaskEntry( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT
, RID_STR_NEW_REPORT
, true ) );
734 rList
.push_back( TaskEntry( ".uno:DBNewReportAutoPilot", RID_STR_REPORTS_HELP_TEXT_WIZARD
, RID_STR_NEW_REPORT_AUTO
) );
735 _rData
.nTitleId
= RID_STR_REPORTS_CONTAINER
;
739 rList
.push_back( TaskEntry( ".uno:DBNewQuery", RID_STR_QUERIES_HELP_TEXT
, RID_STR_NEW_QUERY
) );
740 rList
.push_back( TaskEntry( ".uno:DBNewQueryAutoPilot", RID_STR_QUERIES_HELP_TEXT_WIZARD
, RID_STR_NEW_QUERY_AUTO
) );
741 rList
.push_back( TaskEntry( ".uno:DBNewQuerySql", RID_STR_QUERIES_HELP_TEXT_SQL
, RID_STR_NEW_QUERY_SQL
) );
742 _rData
.nTitleId
= RID_STR_QUERIES_CONTAINER
;
746 OSL_FAIL( "OApplicationDetailView::impl_fillTaskPaneData: illegal element type!" );
749 MnemonicGenerator
aAllMnemonics( m_aExternalMnemonics
);
751 // remove the entries which are not enabled currently
752 for ( TaskEntryList::iterator pTask
= rList
.begin();
753 pTask
!= rList
.end();
756 if ( pTask
->bHideWhenDisabled
757 && !getBorderWin().getView()->getCommandController().isCommandEnabled( pTask
->sUNOCommand
)
759 pTask
= rList
.erase( pTask
);
762 aAllMnemonics
.RegisterMnemonic( pTask
->sTitle
);
767 // for the remaining entries, assign mnemonics
768 for ( TaskEntryList::iterator pTask
= rList
.begin();
769 pTask
!= rList
.end();
773 aAllMnemonics
.CreateMnemonic( pTask
->sTitle
);
774 // don't do this for now, until our task window really supports mnemonics
778 // -----------------------------------------------------------------------------
779 ::rtl::OUString
OApplicationDetailView::getQualifiedName( SvLBoxEntry
* _pEntry
) const
781 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
782 return m_pControlHelper
->getQualifiedName( _pEntry
);
784 // -----------------------------------------------------------------------------
785 sal_Bool
OApplicationDetailView::isLeaf(SvLBoxEntry
* _pEntry
) const
787 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
788 return m_pControlHelper
->isLeaf(_pEntry
);
790 // -----------------------------------------------------------------------------
791 sal_Bool
OApplicationDetailView::isALeafSelected() const
793 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
794 return m_pControlHelper
->isALeafSelected();
796 // -----------------------------------------------------------------------------
797 void OApplicationDetailView::selectAll()
799 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
800 m_pControlHelper
->selectAll();
802 // -----------------------------------------------------------------------------
803 void OApplicationDetailView::sortDown()
805 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
806 m_pControlHelper
->sortDown();
808 // -----------------------------------------------------------------------------
809 void OApplicationDetailView::sortUp()
811 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
812 m_pControlHelper
->sortUp();
814 // -----------------------------------------------------------------------------
815 sal_Bool
OApplicationDetailView::isFilled() const
817 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
818 return m_pControlHelper
->isFilled();
820 // -----------------------------------------------------------------------------
821 ElementType
OApplicationDetailView::getElementType() const
823 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
824 return m_pControlHelper
->getElementType();
826 // -----------------------------------------------------------------------------
827 void OApplicationDetailView::clearPages(sal_Bool _bTaskAlso
)
829 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
831 getTasksWindow().Clear();
832 m_pControlHelper
->clearPages();
834 // -----------------------------------------------------------------------------
835 sal_Int32
OApplicationDetailView::getSelectionCount()
837 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
838 return m_pControlHelper
->getSelectionCount();
840 // -----------------------------------------------------------------------------
841 sal_Int32
OApplicationDetailView::getElementCount()
843 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
844 return m_pControlHelper
->getElementCount();
847 // -----------------------------------------------------------------------------
848 void OApplicationDetailView::getSelectionElementNames( ::std::vector
< ::rtl::OUString
>& _rNames
) const
850 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
851 m_pControlHelper
->getSelectionElementNames( _rNames
);
853 // -----------------------------------------------------------------------------
854 void OApplicationDetailView::describeCurrentSelectionForControl( const Control
& _rControl
, Sequence
< NamedDatabaseObject
>& _out_rSelectedObjects
)
856 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
857 m_pControlHelper
->describeCurrentSelectionForControl( _rControl
, _out_rSelectedObjects
);
859 // -----------------------------------------------------------------------------
860 void OApplicationDetailView::describeCurrentSelectionForType( const ElementType _eType
, Sequence
< NamedDatabaseObject
>& _out_rSelectedObjects
)
862 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
863 m_pControlHelper
->describeCurrentSelectionForType( _eType
, _out_rSelectedObjects
);
865 // -----------------------------------------------------------------------------
866 void OApplicationDetailView::selectElements(const Sequence
< ::rtl::OUString
>& _aNames
)
868 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
869 m_pControlHelper
->selectElements( _aNames
);
871 // -----------------------------------------------------------------------------
872 SvLBoxEntry
* OApplicationDetailView::getEntry( const Point
& _aPoint
) const
874 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
875 return m_pControlHelper
->getEntry(_aPoint
);
877 // -----------------------------------------------------------------------------
878 sal_Bool
OApplicationDetailView::isCutAllowed()
880 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
881 return m_pControlHelper
->isCutAllowed();
883 sal_Bool
OApplicationDetailView::isCopyAllowed()
885 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
886 return m_pControlHelper
->isCopyAllowed();
888 sal_Bool
OApplicationDetailView::isPasteAllowed() { DBG_CHKTHIS(OApplicationDetailView
,NULL
);return m_pControlHelper
->isPasteAllowed(); }
889 void OApplicationDetailView::copy() { DBG_CHKTHIS(OApplicationDetailView
,NULL
);m_pControlHelper
->copy(); }
890 void OApplicationDetailView::cut() { DBG_CHKTHIS(OApplicationDetailView
,NULL
);m_pControlHelper
->cut(); }
891 void OApplicationDetailView::paste()
893 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
894 m_pControlHelper
->paste();
896 // -----------------------------------------------------------------------------
897 SvLBoxEntry
* OApplicationDetailView::elementAdded(ElementType _eType
,const ::rtl::OUString
& _rName
, const Any
& _rObject
)
899 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
900 return m_pControlHelper
->elementAdded(_eType
,_rName
, _rObject
);
902 // -----------------------------------------------------------------------------
903 void OApplicationDetailView::elementRemoved(ElementType _eType
,const ::rtl::OUString
& _rName
)
905 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
906 m_pControlHelper
->elementRemoved(_eType
,_rName
);
908 // -----------------------------------------------------------------------------
909 void OApplicationDetailView::elementReplaced(ElementType _eType
910 ,const ::rtl::OUString
& _rOldName
911 ,const ::rtl::OUString
& _rNewName
)
913 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
914 m_pControlHelper
->elementReplaced( _eType
, _rOldName
, _rNewName
);
916 // -----------------------------------------------------------------------------
917 PreviewMode
OApplicationDetailView::getPreviewMode()
919 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
920 return m_pControlHelper
->getPreviewMode();
922 // -----------------------------------------------------------------------------
923 sal_Bool
OApplicationDetailView::isPreviewEnabled()
925 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
926 return m_pControlHelper
->isPreviewEnabled();
928 // -----------------------------------------------------------------------------
929 void OApplicationDetailView::switchPreview(PreviewMode _eMode
)
931 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
932 m_pControlHelper
->switchPreview(_eMode
);
934 // -----------------------------------------------------------------------------
935 void OApplicationDetailView::showPreview(const Reference
< XContent
>& _xContent
)
937 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
938 m_pControlHelper
->showPreview(_xContent
);
940 // -----------------------------------------------------------------------------
941 void OApplicationDetailView::showPreview( const ::rtl::OUString
& _sDataSourceName
,
942 const ::rtl::OUString
& _sName
,
945 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
946 m_pControlHelper
->showPreview(_sDataSourceName
,_sName
,_bTable
);
948 // -----------------------------------------------------------------------------
949 sal_Bool
OApplicationDetailView::isSortUp() const
951 DBG_CHKTHIS(OApplicationDetailView
,NULL
);
952 return m_pControlHelper
->isSortUp();
954 // -----------------------------------------------------------------------------
955 Window
* OApplicationDetailView::getTreeWindow() const
957 return m_pControlHelper
->getCurrentView();
960 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */