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