fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / app / AppDetailView.cxx
blob7329b0b4cd3afa5e64fa406c6a5f4a508f02aff0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "AppDetailView.hxx"
21 #include <osl/diagnose.h>
22 #include "dbaccess_helpid.hrc"
23 #include "dbu_app.hrc"
24 #include "AppView.hxx"
25 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
26 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
27 #include <com/sun/star/ui/XImageManager.hpp>
28 #include <com/sun/star/ui/ImageType.hpp>
29 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
30 #include <com/sun/star/graphic/XGraphic.hpp>
31 #include <com/sun/star/util/URL.hpp>
32 #include "listviewitems.hxx"
33 #include <vcl/image.hxx>
34 #include <vcl/mnemonic.hxx>
35 #include <vcl/settings.hxx>
36 #include "browserids.hxx"
37 #include "AppDetailPageHelper.hxx"
38 #include <vcl/svapp.hxx>
39 #include "callbacks.hxx"
40 #include <dbaccess/IController.hxx>
41 #include "moduledbu.hxx"
42 #include <svtools/localresaccess.hxx>
43 #include "svtools/treelistentry.hxx"
44 #include "svtools/viewdataentry.hxx"
45 #include <algorithm>
46 #include "dbtreelistbox.hxx"
47 #include "IApplicationController.hxx"
48 #include "imageprovider.hxx"
49 #include "comphelper/processfactory.hxx"
51 using namespace ::dbaui;
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::sdbc;
54 using namespace ::com::sun::star::sdbcx;
55 using namespace ::com::sun::star::lang;
56 using namespace ::com::sun::star::ucb;
57 using namespace ::com::sun::star::graphic;
58 using namespace ::com::sun::star::ui;
59 using namespace ::com::sun::star::container;
60 using namespace ::com::sun::star::beans;
61 using ::com::sun::star::util::URL;
62 using ::com::sun::star::sdb::application::NamedDatabaseObject;
64 #define SPACEBETWEENENTRIES 4
66 TaskEntry::TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled )
67 :sUNOCommand( OUString::createFromAscii( _pAsciiUNOCommand ) )
68 ,nHelpID( _nHelpID )
69 ,sTitle( ModuleRes( _nTitleResourceID ) )
70 ,bHideWhenDisabled( _bHideWhenDisabled )
74 OCreationList::OCreationList( OTasksWindow& _rParent )
75 :SvTreeListBox( &_rParent, WB_TABSTOP | WB_HASBUTTONSATROOT | WB_HASBUTTONS )
76 ,m_rTaskWindow( _rParent )
77 ,m_pMouseDownEntry( NULL )
78 ,m_pLastActiveEntry( NULL )
80 sal_uInt16 nSize = SPACEBETWEENENTRIES;
81 SetSpaceBetweenEntries(nSize);
82 SetSelectionMode( NO_SELECTION );
83 SetExtendedWinBits( EWB_NO_AUTO_CURENTRY );
84 SetNodeDefaultImages( );
85 EnableEntryMnemonics();
88 void OCreationList::Paint(vcl::RenderContext& rRenderContext, const Rectangle& _rRect )
90 SetBackground();
92 if (m_pMouseDownEntry)
93 m_aOriginalFont = rRenderContext.GetFont();
95 m_aOriginalBackgroundColor = rRenderContext.GetBackground().GetColor();
96 SvTreeListBox::Paint(rRenderContext, _rRect);
97 rRenderContext.SetBackground(m_aOriginalBackgroundColor);
99 if (m_pMouseDownEntry)
100 rRenderContext.SetFont(m_aOriginalFont);
103 void OCreationList::PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry* _pEntry)
105 Wallpaper aEntryBackground(m_aOriginalBackgroundColor);
106 if (_pEntry)
108 if (_pEntry == GetCurEntry())
110 // draw a selection background
111 bool bIsMouseDownEntry = ( _pEntry == m_pMouseDownEntry );
112 vcl::RenderTools::DrawSelectionBackground(rRenderContext, *this, GetBoundingRect(_pEntry),
113 bIsMouseDownEntry ? 1 : 2, false, true, false );
115 if (bIsMouseDownEntry)
117 vcl::Font aFont(rRenderContext.GetFont());
118 aFont.SetColor(rRenderContext.GetSettings().GetStyleSettings().GetHighlightTextColor());
119 rRenderContext.SetFont(aFont);
122 // and temporary set a transparent background, for all the other
123 // paint operations the SvTreeListBox is going to do
124 aEntryBackground = Wallpaper();
125 _pEntry->SetBackColor(Color(COL_TRANSPARENT));
129 rRenderContext.SetBackground(aEntryBackground);
130 _pEntry->SetBackColor(aEntryBackground.GetColor());
133 void OCreationList::SelectSearchEntry( const void* _pEntry )
135 SvTreeListEntry* pEntry = const_cast< SvTreeListEntry* >( static_cast< const SvTreeListEntry* >( _pEntry ) );
136 OSL_ENSURE( pEntry, "OCreationList::SelectSearchEntry: invalid entry!" );
138 if ( pEntry )
139 setCurrentEntryInvalidate( pEntry );
141 if ( !HasChildPathFocus() )
142 GrabFocus();
145 void OCreationList::ExecuteSearchEntry( const void* _pEntry ) const
147 SvTreeListEntry* pEntry = const_cast< SvTreeListEntry* >( static_cast< const SvTreeListEntry* >( _pEntry ) );
148 OSL_ENSURE( pEntry, "OCreationList::ExecuteSearchEntry: invalid entry!" );
149 OSL_ENSURE( pEntry == GetCurEntry(), "OCreationList::ExecuteSearchEntry: SelectSearchEntry should have been called before!" );
151 if ( pEntry )
152 onSelected( pEntry );
155 Rectangle OCreationList::GetFocusRect( SvTreeListEntry* _pEntry, long _nLine )
157 Rectangle aRect = SvTreeListBox::GetFocusRect( _pEntry, _nLine );
158 aRect.Left() = 0;
160 // try to let the focus rect start before the bitmap item - this looks better
161 SvLBoxItem* pBitmapItem = _pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP );
162 SvLBoxTab* pTab = pBitmapItem ? GetTab( _pEntry, pBitmapItem ) : NULL;
163 SvViewDataItem* pItemData = pBitmapItem ? GetViewDataItem( _pEntry, pBitmapItem ) : NULL;
164 OSL_ENSURE( pTab && pItemData, "OCreationList::GetFocusRect: could not find the first bitmap item!" );
165 if ( pTab && pItemData )
166 aRect.Left() = pTab->GetPos() - pItemData->maSize.Width() / 2;
168 // inflate the rectangle a little bit - looks better, too
169 aRect.Left() = ::std::max< long >( 0, aRect.Left() - 2 );
170 aRect.Right() = ::std::min< long >( GetOutputSizePixel().Width() - 1, aRect.Right() + 2 );
172 return aRect;
175 void OCreationList::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
177 // don't give this to the base class, it does a ReleaseMouse as very first action
178 // Though I think this is a bug (it should ReleaseMouse only if it is going to do
179 // something with the drag-event), I hesitate to fix it in the current state,
180 // since I don't overlook the consequences, and we're close to 2.0 ...)
183 void OCreationList::ModelHasCleared()
185 SvTreeListBox::ModelHasCleared();
186 m_pLastActiveEntry = NULL;
187 m_pMouseDownEntry = NULL;
190 void OCreationList::GetFocus()
192 SvTreeListBox::GetFocus();
193 if ( !GetCurEntry() )
194 setCurrentEntryInvalidate( m_pLastActiveEntry ? m_pLastActiveEntry : GetFirstEntryInView() );
197 void OCreationList::LoseFocus()
199 SvTreeListBox::LoseFocus();
200 m_pLastActiveEntry = GetCurEntry();
201 setCurrentEntryInvalidate( NULL );
204 void OCreationList::MouseButtonDown( const MouseEvent& rMEvt )
206 SvTreeListBox::MouseButtonDown( rMEvt );
208 OSL_ENSURE( !m_pMouseDownEntry, "OCreationList::MouseButtonDown: I missed some mouse event!" );
209 m_pMouseDownEntry = GetCurEntry();
210 if ( m_pMouseDownEntry )
212 InvalidateEntry( m_pMouseDownEntry );
213 CaptureMouse();
217 void OCreationList::MouseMove( const MouseEvent& rMEvt )
219 if ( rMEvt.IsLeaveWindow() )
221 setCurrentEntryInvalidate( NULL );
223 else if ( !rMEvt.IsSynthetic() )
225 SvTreeListEntry* pEntry = GetEntry( rMEvt.GetPosPixel() );
227 if ( m_pMouseDownEntry )
229 // we're currently in a "mouse down" phase
230 OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseMove: inconsistence (1)!" );
231 if ( pEntry == m_pMouseDownEntry )
233 setCurrentEntryInvalidate( m_pMouseDownEntry );
235 else
237 OSL_ENSURE( ( GetCurEntry() == m_pMouseDownEntry ) || !GetCurEntry(),
238 "OCreationList::MouseMove: inconsistence (2)!" );
239 setCurrentEntryInvalidate( NULL );
242 else
244 // the user is simply hovering with the mouse
245 if ( setCurrentEntryInvalidate( pEntry ) )
247 if ( !m_pMouseDownEntry )
248 updateHelpText();
253 SvTreeListBox::MouseMove(rMEvt);
256 void OCreationList::MouseButtonUp( const MouseEvent& rMEvt )
258 SvTreeListEntry* pEntry = GetEntry( rMEvt.GetPosPixel() );
259 bool bExecute = false;
260 // Was the mouse released over the active entry?
261 // (i.e. the entry which was under the mouse when the button went down)
262 if ( pEntry && ( m_pMouseDownEntry == pEntry ) )
264 if ( !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
265 bExecute = true;
268 if ( m_pMouseDownEntry )
270 OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseButtonUp: hmmm .... no mouse captured, but an active entry?" );
271 ReleaseMouse();
273 InvalidateEntry( m_pMouseDownEntry );
274 m_pMouseDownEntry = NULL;
277 SvTreeListBox::MouseButtonUp( rMEvt );
279 if ( bExecute )
280 onSelected( pEntry );
283 bool OCreationList::setCurrentEntryInvalidate( SvTreeListEntry* _pEntry )
285 if ( GetCurEntry() != _pEntry )
287 if ( GetCurEntry() )
288 InvalidateEntry( GetCurEntry() );
289 SetCurEntry( _pEntry );
290 if ( GetCurEntry() )
292 InvalidateEntry( GetCurEntry() );
293 CallEventListeners( VCLEVENT_LISTBOX_SELECT, GetCurEntry() );
295 updateHelpText();
296 return true;
298 return false;
301 void OCreationList::updateHelpText()
303 sal_uInt16 nHelpTextId = 0;
304 if ( GetCurEntry() )
305 nHelpTextId = static_cast< TaskEntry* >( GetCurEntry()->GetUserData() )->nHelpID;
306 m_rTaskWindow.setHelpText( nHelpTextId );
309 void OCreationList::onSelected( SvTreeListEntry* _pEntry ) const
311 OSL_ENSURE( _pEntry, "OCreationList::onSelected: invalid entry!" );
312 URL aCommand;
313 aCommand.Complete = static_cast< TaskEntry* >( _pEntry->GetUserData() )->sUNOCommand;
314 m_rTaskWindow.getDetailView()->getBorderWin().getView()->getAppController().executeChecked( aCommand, Sequence< PropertyValue >() );
317 void OCreationList::KeyInput( const KeyEvent& rKEvt )
319 const vcl::KeyCode& rCode = rKEvt.GetKeyCode();
320 if ( !rCode.IsMod1() && !rCode.IsMod2() && !rCode.IsShift() )
322 if ( rCode.GetCode() == KEY_RETURN )
324 SvTreeListEntry* pEntry = GetCurEntry() ? GetCurEntry() : FirstSelected();
325 if ( pEntry )
326 onSelected( pEntry );
327 return;
330 SvTreeListEntry* pOldCurrent = GetCurEntry();
331 SvTreeListBox::KeyInput(rKEvt);
332 SvTreeListEntry* pNewCurrent = GetCurEntry();
334 if ( pOldCurrent != pNewCurrent )
336 if ( pOldCurrent )
337 InvalidateEntry( pOldCurrent );
338 if ( pNewCurrent )
340 InvalidateEntry( pNewCurrent );
341 CallEventListeners( VCLEVENT_LISTBOX_SELECT, pNewCurrent );
343 updateHelpText();
347 OTasksWindow::OTasksWindow(vcl::Window* _pParent,OApplicationDetailView* _pDetailView)
348 : Window(_pParent,WB_DIALOGCONTROL )
349 ,m_aCreation(VclPtr<OCreationList>::Create(*this))
350 ,m_aDescription(VclPtr<FixedText>::Create(this))
351 ,m_aHelpText(VclPtr<FixedText>::Create(this,WB_WORDBREAK))
352 ,m_aFL(VclPtr<FixedLine>::Create(this,WB_VERT))
353 ,m_pDetailView(_pDetailView)
355 SetUniqueId(UID_APP_TASKS_WINDOW);
356 m_aCreation->SetHelpId(HID_APP_CREATION_LIST);
357 m_aCreation->SetSelectHdl(LINK(this, OTasksWindow, OnEntrySelectHdl));
358 m_aHelpText->SetHelpId(HID_APP_HELP_TEXT);
359 m_aDescription->SetHelpId(HID_APP_DESCRIPTION_TEXT);
360 m_aDescription->SetText(ModuleRes(STR_DESCRIPTION));
362 Image aFolderImage = ImageProvider::getFolderImage( css::sdb::application::DatabaseObject::FORM );
363 m_aCreation->SetDefaultCollapsedEntryBmp( aFolderImage );
364 m_aCreation->SetDefaultExpandedEntryBmp( aFolderImage );
366 ImplInitSettings(true,true,true);
369 OTasksWindow::~OTasksWindow()
371 disposeOnce();
374 void OTasksWindow::dispose()
376 Clear();
377 m_aCreation.disposeAndClear();
378 m_aDescription.disposeAndClear();
379 m_aHelpText.disposeAndClear();
380 m_aFL.disposeAndClear();
381 m_pDetailView.clear();
382 vcl::Window::dispose();
385 void OTasksWindow::DataChanged( const DataChangedEvent& rDCEvt )
387 Window::DataChanged( rDCEvt );
389 if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
390 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
392 ImplInitSettings( true, true, true );
393 Invalidate();
397 void OTasksWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
399 // FIXME RenderContext
400 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
401 if( bFont )
403 vcl::Font aFont;
404 aFont = rStyleSettings.GetFieldFont();
405 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
406 SetPointFont(*this, aFont);
409 if( bForeground || bFont )
411 SetTextColor( rStyleSettings.GetFieldTextColor() );
412 SetTextFillColor();
413 m_aHelpText->SetTextColor( rStyleSettings.GetFieldTextColor() );
414 m_aHelpText->SetTextFillColor();
415 m_aDescription->SetTextColor( rStyleSettings.GetFieldTextColor() );
416 m_aDescription->SetTextFillColor();
419 if( bBackground )
421 SetBackground( rStyleSettings.GetFieldColor() );
422 m_aHelpText->SetBackground( rStyleSettings.GetFieldColor() );
423 m_aDescription->SetBackground( rStyleSettings.GetFieldColor() );
424 m_aFL->SetBackground( rStyleSettings.GetFieldColor() );
427 vcl::Font aFont = m_aDescription->GetControlFont();
428 aFont.SetWeight(WEIGHT_BOLD);
429 m_aDescription->SetControlFont(aFont);
432 void OTasksWindow::setHelpText(sal_uInt16 _nId)
434 if ( _nId )
436 OUString sText = ModuleRes(_nId);
437 m_aHelpText->SetText(sText);
439 else
441 m_aHelpText->SetText(OUString());
446 IMPL_LINK(OTasksWindow, OnEntrySelectHdl, SvTreeListBox*, /*_pTreeBox*/)
448 SvTreeListEntry* pEntry = m_aCreation->GetHdlEntry();
449 if ( pEntry )
450 m_aHelpText->SetText( ModuleRes( static_cast< TaskEntry* >( pEntry->GetUserData() )->nHelpID ) );
451 return 1L;
454 void OTasksWindow::Resize()
456 // parent window dimension
457 Size aOutputSize( GetOutputSize() );
458 long nOutputWidth = aOutputSize.Width();
459 long nOutputHeight = aOutputSize.Height();
461 Size aFLSize = LogicToPixel( Size( 2, 6 ), MAP_APPFONT );
462 sal_Int32 n6PPT = aFLSize.Height();
463 long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5);
465 m_aCreation->SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) );
466 // i77897 make the m_aHelpText a little bit smaller. (-5)
467 sal_Int32 nNewWidth = nOutputWidth - nHalfOutputWidth - aFLSize.Width() - 5;
468 m_aDescription->SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, 0), Size(nNewWidth, nOutputHeight) );
469 Size aDesc = m_aDescription->CalcMinimumSize();
470 m_aHelpText->SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, aDesc.Height() ), Size(nNewWidth, nOutputHeight - aDesc.Height() - n6PPT) );
472 m_aFL->SetPosSizePixel( Point(nHalfOutputWidth , 0), Size(aFLSize.Width(), nOutputHeight ) );
475 void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList )
477 Clear();
481 Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier =
482 theModuleUIConfigurationManagerSupplier::get( getDetailView()->getBorderWin().getView()->getORB() );
483 Reference< XUIConfigurationManager > xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(
484 OUString( "com.sun.star.sdb.OfficeDatabaseDocument" )
486 Reference< XImageManager > xImageMgr( xUIConfigMgr->getImageManager(), UNO_QUERY );
488 // copy the commands so we can use them with the config managers
489 Sequence< OUString > aCommands( _rList.size() );
490 OUString* pCommands = aCommands.getArray();
491 TaskEntryList::const_iterator aEnd = _rList.end();
492 for ( TaskEntryList::const_iterator pCopyTask = _rList.begin(); pCopyTask != aEnd; ++pCopyTask, ++pCommands )
493 *pCommands = pCopyTask->sUNOCommand;
495 Sequence< Reference< XGraphic> > aImages = xImageMgr->getImages(
496 ImageType::SIZE_DEFAULT | ImageType::COLOR_NORMAL ,
497 aCommands
500 const Reference< XGraphic >* pImages( aImages.getConstArray() );
502 for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages )
504 SvTreeListEntry* pEntry = m_aCreation->InsertEntry( pTask->sTitle );
505 pEntry->SetUserData( new TaskEntry( *pTask ) );
507 Image aImage = Image( *pImages );
508 m_aCreation->SetExpandedEntryBmp( pEntry, aImage );
509 m_aCreation->SetCollapsedEntryBmp( pEntry, aImage );
512 catch(Exception&)
516 m_aCreation->Show();
517 m_aCreation->SelectAll(false);
518 m_aHelpText->Show();
519 m_aDescription->Show();
520 m_aFL->Show();
521 m_aCreation->updateHelpText();
522 Enable(!_rList.empty());
525 void OTasksWindow::Clear()
527 m_aCreation->resetLastActive();
528 SvTreeListEntry* pEntry = m_aCreation->First();
529 while ( pEntry )
531 delete static_cast< TaskEntry* >( pEntry->GetUserData() );
532 pEntry = m_aCreation->Next(pEntry);
534 m_aCreation->Clear();
537 // class OApplicationDetailView
539 OApplicationDetailView::OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode) : OSplitterView(&_rParent,false )
540 ,m_aHorzSplitter(VclPtr<Splitter>::Create(this))
541 ,m_aTasks(VclPtr<dbaui::OTitleWindow>::Create(this,STR_TASKS,WB_BORDER | WB_DIALOGCONTROL) )
542 ,m_aContainer(VclPtr<dbaui::OTitleWindow>::Create(this,0,WB_BORDER | WB_DIALOGCONTROL) )
543 ,m_rBorderWin(_rParent)
545 SetUniqueId(UID_APP_DETAIL_VIEW);
546 ImplInitSettings( true, true, true );
548 m_pControlHelper = VclPtr<OAppDetailPageHelper>::Create(m_aContainer.get(),m_rBorderWin,_ePreviewMode);
549 m_pControlHelper->Show();
550 m_aContainer->setChildWindow(m_pControlHelper);
552 VclPtrInstance<OTasksWindow> pTasks(m_aTasks.get(),this);
553 pTasks->Show();
554 pTasks->Disable(m_rBorderWin.getView()->getCommandController().isDataSourceReadOnly());
555 m_aTasks->setChildWindow(pTasks);
556 m_aTasks->SetUniqueId(UID_APP_TASKS_VIEW);
557 m_aTasks->Show();
559 m_aContainer->SetUniqueId(UID_APP_CONTAINER_VIEW);
560 m_aContainer->Show();
562 const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
563 m_aHorzSplitter->SetPosSizePixel( Point(0,50), Size(0,nFrameWidth) );
564 // now set the components at the base class
565 set(m_aContainer.get(),m_aTasks.get());
567 m_aHorzSplitter->Show();
568 m_aHorzSplitter->SetUniqueId(UID_APP_VIEW_HORZ_SPLIT);
569 setSplitter(m_aHorzSplitter.get());
572 OApplicationDetailView::~OApplicationDetailView()
574 disposeOnce();
577 void OApplicationDetailView::dispose()
579 set(NULL,NULL);
580 setSplitter(NULL);
581 m_aHorzSplitter.disposeAndClear();
582 m_aTasks.disposeAndClear();
583 m_aContainer.disposeAndClear();
584 m_pControlHelper.clear();
585 OSplitterView::dispose();
588 void OApplicationDetailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
590 // FIXME RenderContext
591 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
592 if( bFont )
594 vcl::Font aFont;
595 aFont = rStyleSettings.GetFieldFont();
596 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
597 SetPointFont(*this, aFont);
600 if( bForeground || bFont )
602 SetTextColor( rStyleSettings.GetFieldTextColor() );
603 SetTextFillColor();
606 if( bBackground )
607 SetBackground( rStyleSettings.GetFieldColor() );
609 m_aHorzSplitter->SetBackground( rStyleSettings.GetDialogColor() );
610 m_aHorzSplitter->SetFillColor( rStyleSettings.GetDialogColor() );
611 m_aHorzSplitter->SetTextFillColor(rStyleSettings.GetDialogColor() );
614 void OApplicationDetailView::DataChanged( const DataChangedEvent& rDCEvt )
616 OSplitterView::DataChanged( rDCEvt );
618 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
619 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
620 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
621 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
622 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
624 ImplInitSettings( true, true, true );
625 Invalidate();
629 void OApplicationDetailView::GetFocus()
631 OSplitterView::GetFocus();
634 void OApplicationDetailView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics )
636 m_aExternalMnemonics = _rMnemonics;
639 bool OApplicationDetailView::interceptKeyInput( const KeyEvent& _rEvent )
641 const vcl::KeyCode& rKeyCode = _rEvent.GetKeyCode();
642 if ( rKeyCode.GetModifier() == KEY_MOD2 )
643 return getTasksWindow().HandleKeyInput( _rEvent );
645 // not handled
646 return false;
649 void OApplicationDetailView::createTablesPage(const Reference< XConnection >& _xConnection )
651 impl_createPage( E_TABLE, _xConnection, NULL );
654 void OApplicationDetailView::createPage( ElementType _eType,const Reference< XNameAccess >& _xContainer )
656 impl_createPage( _eType, NULL, _xContainer );
659 void OApplicationDetailView::impl_createPage( ElementType _eType, const Reference< XConnection >& _rxConnection,
660 const Reference< XNameAccess >& _rxNonTableElements )
662 // get the data for the pane
663 const TaskPaneData& rData = impl_getTaskPaneData( _eType );
664 getTasksWindow().fillTaskEntryList( rData.aTasks );
666 // enable the pane as a whole, depending on the availability of the first command
667 OSL_ENSURE( !rData.aTasks.empty(), "OApplicationDetailView::impl_createPage: no tasks at all!?" );
668 bool bEnabled = !rData.aTasks.empty()
669 && getBorderWin().getView()->getCommandController().isCommandEnabled( rData.aTasks[0].sUNOCommand );
670 getTasksWindow().Enable( bEnabled );
671 m_aContainer->setTitle( rData.nTitleId );
673 // let our helper create the object list
674 if ( _eType == E_TABLE )
675 m_pControlHelper->createTablesPage( _rxConnection );
676 else
677 m_pControlHelper->createPage( _eType, _rxNonTableElements );
679 // resize for proper window arrangements
680 Resize();
683 const TaskPaneData& OApplicationDetailView::impl_getTaskPaneData( ElementType _eType )
685 if ( m_aTaskPaneData.empty() )
686 m_aTaskPaneData.resize( ELEMENT_COUNT );
687 OSL_ENSURE( ( _eType >= 0 ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OApplicationDetailView::impl_getTaskPaneData: illegal element type!" );
688 TaskPaneData& rData = m_aTaskPaneData[ _eType ];
690 //oj: do not check, otherwise extensions will only be visible after a reload.
691 impl_fillTaskPaneData( _eType, rData );
693 return rData;
696 void OApplicationDetailView::impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const
698 TaskEntryList& rList( _rData.aTasks );
699 rList.clear(); rList.reserve( 4 );
701 switch ( _eType )
703 case E_TABLE:
704 rList.push_back( TaskEntry( ".uno:DBNewTable", RID_STR_TABLES_HELP_TEXT_DESIGN, RID_STR_NEW_TABLE ) );
705 rList.push_back( TaskEntry( ".uno:DBNewTableAutoPilot", RID_STR_TABLES_HELP_TEXT_WIZARD, RID_STR_NEW_TABLE_AUTO ) );
706 rList.push_back( TaskEntry( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN, RID_STR_NEW_VIEW, true ) );
707 _rData.nTitleId = RID_STR_TABLES_CONTAINER;
708 break;
710 case E_FORM:
711 rList.push_back( TaskEntry( ".uno:DBNewForm", RID_STR_FORMS_HELP_TEXT, RID_STR_NEW_FORM ) );
712 rList.push_back( TaskEntry( ".uno:DBNewFormAutoPilot", RID_STR_FORMS_HELP_TEXT_WIZARD, RID_STR_NEW_FORM_AUTO ) );
713 _rData.nTitleId = RID_STR_FORMS_CONTAINER;
714 break;
716 case E_REPORT:
717 rList.push_back( TaskEntry( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT, RID_STR_NEW_REPORT, true ) );
718 rList.push_back( TaskEntry( ".uno:DBNewReportAutoPilot", RID_STR_REPORTS_HELP_TEXT_WIZARD, RID_STR_NEW_REPORT_AUTO ) );
719 _rData.nTitleId = RID_STR_REPORTS_CONTAINER;
720 break;
722 case E_QUERY:
723 rList.push_back( TaskEntry( ".uno:DBNewQuery", RID_STR_QUERIES_HELP_TEXT, RID_STR_NEW_QUERY ) );
724 rList.push_back( TaskEntry( ".uno:DBNewQueryAutoPilot", RID_STR_QUERIES_HELP_TEXT_WIZARD, RID_STR_NEW_QUERY_AUTO ) );
725 rList.push_back( TaskEntry( ".uno:DBNewQuerySql", RID_STR_QUERIES_HELP_TEXT_SQL, RID_STR_NEW_QUERY_SQL ) );
726 _rData.nTitleId = RID_STR_QUERIES_CONTAINER;
727 break;
729 default:
730 OSL_FAIL( "OApplicationDetailView::impl_fillTaskPaneData: illegal element type!" );
733 MnemonicGenerator aAllMnemonics( m_aExternalMnemonics );
735 // remove the entries which are not enabled currently
736 for ( TaskEntryList::iterator pTask = rList.begin();
737 pTask != rList.end();
740 if ( pTask->bHideWhenDisabled
741 && !getBorderWin().getView()->getCommandController().isCommandEnabled( pTask->sUNOCommand )
743 pTask = rList.erase( pTask );
744 else
746 aAllMnemonics.RegisterMnemonic( pTask->sTitle );
747 ++pTask;
751 // for the remaining entries, assign mnemonics
752 for ( TaskEntryList::iterator pTask = rList.begin();
753 pTask != rList.end();
754 ++pTask
757 aAllMnemonics.CreateMnemonic( pTask->sTitle );
758 // don't do this for now, until our task window really supports mnemonics
762 OUString OApplicationDetailView::getQualifiedName( SvTreeListEntry* _pEntry ) const
764 return m_pControlHelper->getQualifiedName( _pEntry );
767 bool OApplicationDetailView::isLeaf(SvTreeListEntry* _pEntry)
769 return OAppDetailPageHelper::isLeaf(_pEntry);
772 bool OApplicationDetailView::isALeafSelected() const
774 return m_pControlHelper->isALeafSelected();
777 void OApplicationDetailView::selectAll()
779 m_pControlHelper->selectAll();
782 void OApplicationDetailView::sortDown()
784 m_pControlHelper->sortDown();
787 void OApplicationDetailView::sortUp()
789 m_pControlHelper->sortUp();
792 bool OApplicationDetailView::isFilled() const
794 return m_pControlHelper->isFilled();
797 ElementType OApplicationDetailView::getElementType() const
799 return m_pControlHelper->getElementType();
802 void OApplicationDetailView::clearPages(bool _bTaskAlso)
804 if ( _bTaskAlso )
805 getTasksWindow().Clear();
806 m_pControlHelper->clearPages();
809 sal_Int32 OApplicationDetailView::getSelectionCount()
811 return m_pControlHelper->getSelectionCount();
814 sal_Int32 OApplicationDetailView::getElementCount()
816 return m_pControlHelper->getElementCount();
819 void OApplicationDetailView::getSelectionElementNames( ::std::vector< OUString>& _rNames ) const
821 m_pControlHelper->getSelectionElementNames( _rNames );
824 void OApplicationDetailView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
826 m_pControlHelper->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
829 void OApplicationDetailView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
831 m_pControlHelper->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
834 void OApplicationDetailView::selectElements(const Sequence< OUString>& _aNames)
836 m_pControlHelper->selectElements( _aNames );
839 SvTreeListEntry* OApplicationDetailView::getEntry( const Point& _aPoint ) const
841 return m_pControlHelper->getEntry(_aPoint);
844 bool OApplicationDetailView::isCutAllowed()
846 return false;
849 bool OApplicationDetailView::isCopyAllowed()
851 return true;
854 bool OApplicationDetailView::isPasteAllowed() { return true; }
856 void OApplicationDetailView::copy() { }
858 void OApplicationDetailView::cut() { }
860 void OApplicationDetailView::paste() { }
862 SvTreeListEntry* OApplicationDetailView::elementAdded(ElementType _eType,const OUString& _rName, const Any& _rObject )
864 return m_pControlHelper->elementAdded(_eType,_rName, _rObject );
867 void OApplicationDetailView::elementRemoved(ElementType _eType,const OUString& _rName )
869 m_pControlHelper->elementRemoved(_eType,_rName );
872 void OApplicationDetailView::elementReplaced(ElementType _eType
873 ,const OUString& _rOldName
874 ,const OUString& _rNewName )
876 m_pControlHelper->elementReplaced( _eType, _rOldName, _rNewName );
879 PreviewMode OApplicationDetailView::getPreviewMode()
881 return m_pControlHelper->getPreviewMode();
884 bool OApplicationDetailView::isPreviewEnabled()
886 return m_pControlHelper->isPreviewEnabled();
889 void OApplicationDetailView::switchPreview(PreviewMode _eMode)
891 m_pControlHelper->switchPreview(_eMode);
894 void OApplicationDetailView::showPreview(const Reference< XContent >& _xContent)
896 m_pControlHelper->showPreview(_xContent);
899 void OApplicationDetailView::showPreview( const OUString& _sDataSourceName,
900 const OUString& _sName,
901 bool _bTable)
903 m_pControlHelper->showPreview(_sDataSourceName,_sName,_bTable);
906 bool OApplicationDetailView::isSortUp() const
908 return m_pControlHelper->isSortUp();
911 vcl::Window* OApplicationDetailView::getTreeWindow() const
913 return m_pControlHelper->getCurrentView();
916 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */