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 "AppView.hxx"
21 : #include "dbu_app.hrc"
22 : #include <tools/debug.hxx>
23 : #include <tools/diagnose_ex.h>
24 : #include "dbaccess_helpid.hrc"
25 : #include <vcl/toolbox.hxx>
26 : #include <unotools/configmgr.hxx>
27 : #include <vcl/waitobj.hxx>
28 : #include <comphelper/types.hxx>
29 : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
30 : #include <com/sun/star/beans/XPropertySet.hpp>
31 : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
32 : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
33 : #include <unotools/syslocale.hxx>
34 : #include "UITools.hxx"
35 : #include "AppDetailView.hxx"
36 : #include "tabletree.hxx"
37 : #include "AppSwapWindow.hxx"
38 : #include <vcl/svapp.hxx>
39 : #include "AppTitleWindow.hxx"
40 : #include "dsntypes.hxx"
41 : #include "dbustrings.hrc"
42 : #include "IController.hxx"
43 : #include "browserids.hxx"
44 : #include <unotools/pathoptions.hxx>
45 : #include "IApplicationController.hxx"
46 :
47 : using namespace ::dbaui;
48 : using namespace ::com::sun::star::uno;
49 : using namespace ::com::sun::star::ucb;
50 : using namespace ::com::sun::star::beans;
51 : using namespace ::com::sun::star::sdb;
52 : using namespace ::com::sun::star::sdbc;
53 : using namespace ::com::sun::star::sdbcx;
54 : using namespace ::com::sun::star::datatransfer::clipboard;
55 : using namespace ::com::sun::star::lang;
56 : using namespace ::com::sun::star::beans;
57 : using namespace ::com::sun::star::frame;
58 : using namespace ::com::sun::star::container;
59 : using ::com::sun::star::sdb::application::NamedDatabaseObject;
60 :
61 : //==================================================================
62 : // class OAppBorderWindow
63 : DBG_NAME(OAppBorderWindow)
64 : //==================================================================
65 0 : OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL)
66 : ,m_pPanel(NULL)
67 : ,m_pDetailView(NULL)
68 0 : ,m_pView(_pParent)
69 : {
70 : DBG_CTOR(OAppBorderWindow,NULL);
71 :
72 0 : SetBorderStyle(WINDOW_BORDER_MONO);
73 :
74 0 : m_pPanel = new OTitleWindow(this,STR_DATABASE,WB_BORDER | WB_DIALOGCONTROL ,sal_False);
75 0 : m_pPanel->SetBorderStyle(WINDOW_BORDER_MONO);
76 0 : OApplicationSwapWindow* pSwap = new OApplicationSwapWindow( m_pPanel, *this );
77 0 : pSwap->Show();
78 0 : pSwap->SetUniqueId(UID_APP_SWAP_VIEW);
79 :
80 0 : m_pPanel->setChildWindow(pSwap);
81 0 : m_pPanel->SetUniqueId(UID_APP_DATABASE_VIEW);
82 0 : m_pPanel->Show();
83 :
84 0 : m_pDetailView = new OApplicationDetailView(*this,_ePreviewMode);
85 0 : m_pDetailView->Show();
86 :
87 0 : ImplInitSettings();
88 0 : }
89 : // -----------------------------------------------------------------------------
90 0 : OAppBorderWindow::~OAppBorderWindow()
91 : {
92 : // destroy children
93 0 : if ( m_pPanel )
94 : {
95 0 : m_pPanel->Hide();
96 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
97 0 : ::std::auto_ptr<Window> aTemp(m_pPanel);
98 : SAL_WNODEPRECATED_DECLARATIONS_POP
99 0 : m_pPanel = NULL;
100 : }
101 0 : if ( m_pDetailView )
102 : {
103 0 : m_pDetailView->Hide();
104 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
105 0 : ::std::auto_ptr<Window> aTemp(m_pDetailView);
106 : SAL_WNODEPRECATED_DECLARATIONS_POP
107 0 : m_pDetailView = NULL;
108 : }
109 :
110 : DBG_DTOR(OAppBorderWindow,NULL);
111 0 : }
112 : // -----------------------------------------------------------------------------
113 0 : void OAppBorderWindow::GetFocus()
114 : {
115 0 : if ( m_pPanel )
116 0 : m_pPanel->GrabFocus();
117 0 : }
118 : // -----------------------------------------------------------------------------
119 0 : void OAppBorderWindow::Resize()
120 : {
121 : // parent window dimension
122 0 : Size aOutputSize( GetOutputSize() );
123 0 : long nOutputWidth = aOutputSize.Width();
124 0 : long nOutputHeight = aOutputSize.Height();
125 0 : long nX = 0;
126 :
127 0 : Size aFLSize = LogicToPixel( Size( 3, 8 ), MAP_APPFONT );
128 0 : if ( m_pPanel )
129 : {
130 0 : OApplicationSwapWindow* pSwap = getPanel();
131 0 : if ( pSwap )
132 : {
133 0 : if ( pSwap->GetEntryCount() != 0 )
134 0 : nX = pSwap->GetBoundingBox( pSwap->GetEntry(0) ).GetWidth() + aFLSize.Height();
135 : }
136 0 : nX = ::std::max(m_pPanel->GetWidthPixel() ,nX);
137 0 : m_pPanel->SetPosSizePixel(Point(0,0),Size(nX,nOutputHeight));
138 : }
139 :
140 0 : if ( m_pDetailView )
141 0 : m_pDetailView->SetPosSizePixel(Point(nX + aFLSize.Width(),0),Size(nOutputWidth - nX - aFLSize.Width(),nOutputHeight));
142 0 : }
143 : // -----------------------------------------------------------------------------
144 0 : void OAppBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
145 : {
146 0 : Window::DataChanged( rDCEvt );
147 :
148 0 : if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
149 0 : (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
150 0 : (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
151 0 : ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
152 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
153 : {
154 0 : ImplInitSettings();
155 0 : Invalidate();
156 : }
157 0 : }
158 : // -----------------------------------------------------------------------------
159 0 : void OAppBorderWindow::ImplInitSettings()
160 : {
161 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
162 : if( true )
163 : {
164 0 : Font aFont;
165 0 : aFont = rStyleSettings.GetFieldFont();
166 0 : aFont.SetColor( rStyleSettings.GetWindowTextColor() );
167 0 : SetPointFont( aFont );
168 : }
169 :
170 : if( true )
171 : {
172 0 : SetTextColor( rStyleSettings.GetFieldTextColor() );
173 0 : SetTextFillColor();
174 : }
175 :
176 : if( true )
177 0 : SetBackground( rStyleSettings.GetDialogColor() );
178 0 : }
179 : // -----------------------------------------------------------------------------
180 0 : OApplicationView* OAppBorderWindow::getView() const
181 : {
182 0 : return m_pView;
183 : }
184 :
185 : // -----------------------------------------------------------------------------
186 0 : OApplicationSwapWindow* OAppBorderWindow::getPanel() const
187 : {
188 0 : return static_cast< OApplicationSwapWindow* >( m_pPanel->getChildWindow() );
189 : }
190 :
191 : // -----------------------------------------------------------------------------
192 0 : OApplicationDetailView* OAppBorderWindow::getDetailView() const
193 : {
194 0 : return m_pDetailView;
195 : }
196 :
197 : //==================================================================
198 : // class OApplicationView
199 : //==================================================================
200 : DBG_NAME(OApplicationView);
201 : //------------------------------------------------------------------------------
202 0 : OApplicationView::OApplicationView( Window* pParent
203 : ,const Reference< XComponentContext >& _rxOrb
204 : ,IApplicationController& _rAppController
205 : ,PreviewMode _ePreviewMode
206 : ) :
207 : ODataView( pParent, _rAppController, _rxOrb, WB_DIALOGCONTROL )
208 : ,m_rAppController( _rAppController )
209 0 : ,m_eChildFocus(NONE)
210 : {
211 : DBG_CTOR(OApplicationView,NULL);
212 :
213 : try
214 : {
215 0 : m_aLocale = SvtSysLocale().GetLanguageTag().getLocale();
216 : }
217 0 : catch(Exception&)
218 : {
219 : }
220 :
221 0 : m_pWin = new OAppBorderWindow(this,_ePreviewMode);
222 0 : m_pWin->SetUniqueId(UID_APP_VIEW_BORDER_WIN);
223 0 : m_pWin->Show();
224 :
225 0 : ImplInitSettings();
226 0 : }
227 :
228 : //------------------------------------------------------------------------------
229 0 : OApplicationView::~OApplicationView()
230 : {
231 : DBG_DTOR(OApplicationView,NULL);
232 :
233 : {
234 0 : stopComponentListening(m_xObject);
235 0 : m_pWin->Hide();
236 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
237 0 : ::std::auto_ptr<Window> aTemp(m_pWin);
238 : SAL_WNODEPRECATED_DECLARATIONS_POP
239 0 : m_pWin = NULL;
240 : }
241 0 : }
242 : // -----------------------------------------------------------------------------
243 0 : void OApplicationView::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics )
244 : {
245 0 : if ( m_pWin && m_pWin->getPanel() )
246 0 : m_pWin->getPanel()->createIconAutoMnemonics( _rMnemonics );
247 0 : }
248 :
249 : // -----------------------------------------------------------------------------
250 0 : void OApplicationView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics )
251 : {
252 0 : if ( m_pWin && m_pWin->getDetailView() )
253 0 : m_pWin->getDetailView()->setTaskExternalMnemonics( _rMnemonics );
254 0 : }
255 :
256 : // -----------------------------------------------------------------------------
257 0 : void OApplicationView::DataChanged( const DataChangedEvent& rDCEvt )
258 : {
259 0 : ODataView::DataChanged( rDCEvt );
260 :
261 0 : if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
262 0 : (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
263 0 : (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
264 0 : ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
265 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
266 : {
267 0 : ImplInitSettings();
268 0 : Invalidate();
269 : }
270 0 : }
271 : //------------------------------------------------------------------------------
272 0 : void OApplicationView::resizeDocumentView(Rectangle& _rPlayground)
273 : {
274 0 : if ( m_pWin && !_rPlayground.IsEmpty() )
275 : {
276 0 : Size aFLSize = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
277 0 : _rPlayground.Move( aFLSize.A(),aFLSize.B() );
278 0 : Size aOldSize = _rPlayground.GetSize();
279 0 : _rPlayground.SetSize( Size(aOldSize.A() - 2*aFLSize.A(), aOldSize.B() - 2*aFLSize.B()) );
280 :
281 0 : m_pWin->SetPosSizePixel(_rPlayground.TopLeft() , _rPlayground.GetSize() );
282 : }
283 : // just for completeness: there is no space left, we occupied it all ...
284 0 : _rPlayground.SetPos( _rPlayground.BottomRight() );
285 0 : _rPlayground.SetSize( Size( 0, 0 ) );
286 0 : }
287 : //------------------------------------------------------------------------------
288 0 : long OApplicationView::PreNotify( NotifyEvent& rNEvt )
289 : {
290 0 : switch(rNEvt.GetType())
291 : {
292 : case EVENT_GETFOCUS:
293 0 : if( m_pWin && getPanel() && getPanel()->HasChildPathFocus() )
294 0 : m_eChildFocus = PANELSWAP;
295 0 : else if ( m_pWin && getDetailView() && getDetailView()->HasChildPathFocus() )
296 0 : m_eChildFocus = DETAIL;
297 : else
298 0 : m_eChildFocus = NONE;
299 0 : break;
300 : case EVENT_KEYINPUT:
301 : {
302 0 : const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
303 : // give the pane the chance to intercept mnemonic accelerators
304 : // #i34790#
305 0 : if ( getPanel() && getPanel()->interceptKeyInput( *pKeyEvent ) )
306 0 : return 1L;
307 : // and ditto the detail view
308 : // #i72799#
309 0 : if ( getDetailView() && getDetailView()->interceptKeyInput( *pKeyEvent ) )
310 0 : return 1L;
311 : }
312 0 : break;
313 : }
314 :
315 0 : return ODataView::PreNotify(rNEvt);
316 : }
317 : // -----------------------------------------------------------------------------
318 0 : IClipboardTest* OApplicationView::getActiveChild() const
319 : {
320 0 : IClipboardTest* pTest = NULL;
321 0 : if ( DETAIL == m_eChildFocus )
322 0 : pTest = getDetailView();
323 0 : return pTest;
324 : }
325 : // -----------------------------------------------------------------------------
326 0 : sal_Bool OApplicationView::isCopyAllowed()
327 : {
328 0 : IClipboardTest* pTest = getActiveChild();
329 0 : return pTest && pTest->isCopyAllowed();
330 : }
331 : // -----------------------------------------------------------------------------
332 0 : sal_Bool OApplicationView::isCutAllowed()
333 : {
334 0 : IClipboardTest* pTest = getActiveChild();
335 0 : return pTest && pTest->isCutAllowed();
336 : }
337 : // -----------------------------------------------------------------------------
338 0 : sal_Bool OApplicationView::isPasteAllowed()
339 : {
340 0 : IClipboardTest* pTest = getActiveChild();
341 0 : return pTest && pTest->isPasteAllowed();
342 : }
343 : // -----------------------------------------------------------------------------
344 0 : void OApplicationView::copy()
345 : {
346 0 : IClipboardTest* pTest = getActiveChild();
347 0 : if ( pTest )
348 0 : pTest->copy();
349 0 : }
350 : // -----------------------------------------------------------------------------
351 0 : void OApplicationView::cut()
352 : {
353 0 : IClipboardTest* pTest = getActiveChild();
354 0 : if ( pTest )
355 0 : pTest->cut();
356 0 : }
357 : // -----------------------------------------------------------------------------
358 0 : void OApplicationView::paste()
359 : {
360 0 : IClipboardTest* pTest = getActiveChild();
361 0 : if ( pTest )
362 0 : pTest->paste();
363 0 : }
364 : // -----------------------------------------------------------------------------
365 0 : ::rtl::OUString OApplicationView::getQualifiedName( SvTreeListEntry* _pEntry ) const
366 : {
367 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
368 0 : return getDetailView()->getQualifiedName( _pEntry );
369 : }
370 : // -----------------------------------------------------------------------------
371 0 : sal_Bool OApplicationView::isLeaf(SvTreeListEntry* _pEntry) const
372 : {
373 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
374 0 : return getDetailView()->isLeaf(_pEntry);
375 : }
376 : // -----------------------------------------------------------------------------
377 0 : sal_Bool OApplicationView::isALeafSelected() const
378 : {
379 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
380 0 : return getDetailView()->isALeafSelected();
381 : }
382 : // -----------------------------------------------------------------------------
383 0 : void OApplicationView::selectAll()
384 : {
385 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
386 0 : getDetailView()->selectAll();
387 0 : }
388 : // -----------------------------------------------------------------------------
389 0 : sal_Bool OApplicationView::isSortUp() const
390 : {
391 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
392 0 : return getDetailView()->isSortUp();
393 : }
394 : // -----------------------------------------------------------------------------
395 0 : void OApplicationView::sortDown()
396 : {
397 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
398 0 : getDetailView()->sortDown();
399 0 : }
400 : // -----------------------------------------------------------------------------
401 0 : void OApplicationView::sortUp()
402 : {
403 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
404 0 : getDetailView()->sortUp();
405 0 : }
406 : // -----------------------------------------------------------------------------
407 0 : sal_Bool OApplicationView::isFilled() const
408 : {
409 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
410 0 : return getDetailView()->isFilled();
411 : }
412 : // -----------------------------------------------------------------------------
413 0 : ElementType OApplicationView::getElementType() const
414 : {
415 : OSL_ENSURE(m_pWin && getDetailView() && getPanel(),"Detail view is NULL! -> GPF");
416 0 : return getDetailView()->HasChildPathFocus() ? getDetailView()->getElementType() : getPanel()->getElementType();
417 : }
418 : // -----------------------------------------------------------------------------
419 0 : sal_Int32 OApplicationView::getSelectionCount()
420 : {
421 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
422 0 : return getDetailView()->getSelectionCount();
423 : }
424 : // -----------------------------------------------------------------------------
425 0 : sal_Int32 OApplicationView::getElementCount()
426 : {
427 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
428 0 : return getDetailView()->getElementCount();
429 : }
430 : // -----------------------------------------------------------------------------
431 0 : void OApplicationView::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const
432 : {
433 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
434 0 : getDetailView()->getSelectionElementNames( _rNames );
435 0 : }
436 : // -----------------------------------------------------------------------------
437 0 : void OApplicationView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
438 : {
439 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
440 0 : getDetailView()->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
441 0 : }
442 : // -----------------------------------------------------------------------------
443 0 : void OApplicationView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
444 : {
445 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
446 0 : getDetailView()->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
447 0 : }
448 : // -----------------------------------------------------------------------------
449 0 : void OApplicationView::selectElements(const Sequence< ::rtl::OUString>& _aNames)
450 : {
451 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
452 0 : getDetailView()->selectElements( _aNames );
453 0 : }
454 : // -----------------------------------------------------------------------------
455 0 : SvTreeListEntry* OApplicationView::elementAdded(ElementType eType,const ::rtl::OUString& _rName, const Any& _rObject )
456 : {
457 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
458 0 : return getDetailView()->elementAdded(eType,_rName,_rObject);
459 : }
460 : // -----------------------------------------------------------------------------
461 0 : void OApplicationView::elementRemoved(ElementType eType,const ::rtl::OUString& _rName )
462 : {
463 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
464 0 : getDetailView()->elementRemoved(eType,_rName);
465 0 : }
466 : // -----------------------------------------------------------------------------
467 0 : void OApplicationView::elementReplaced(ElementType _eType
468 : ,const ::rtl::OUString& _rOldName
469 : ,const ::rtl::OUString& _rNewName )
470 : {
471 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
472 0 : getDetailView()->elementReplaced(_eType, _rOldName, _rNewName );
473 0 : }
474 : // -----------------------------------------------------------------------------
475 0 : void OApplicationView::clearPages(sal_Bool _bTaskAlso)
476 : {
477 : OSL_ENSURE(m_pWin && getDetailView() && getPanel(),"Detail view is NULL! -> GPF");
478 0 : getPanel()->clearSelection();
479 0 : getDetailView()->clearPages(_bTaskAlso);
480 0 : }
481 : // -----------------------------------------------------------------------------
482 0 : void OApplicationView::selectContainer(ElementType _eType)
483 : {
484 : OSL_ENSURE(m_pWin && getPanel(),"Detail view is NULL! -> GPF");
485 0 : WaitObject aWO(this);
486 0 : getPanel()->selectContainer(_eType);
487 0 : }
488 : // -----------------------------------------------------------------------------
489 0 : SvTreeListEntry* OApplicationView::getEntry( const Point& _aPosPixel ) const
490 : {
491 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
492 0 : return getDetailView()->getEntry(_aPosPixel);
493 : }
494 : // -----------------------------------------------------------------------------
495 0 : PreviewMode OApplicationView::getPreviewMode()
496 : {
497 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
498 0 : return getDetailView()->getPreviewMode();
499 : }
500 : // -----------------------------------------------------------------------------
501 0 : sal_Bool OApplicationView::isPreviewEnabled()
502 : {
503 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
504 0 : return getDetailView()->isPreviewEnabled();
505 : }
506 : // -----------------------------------------------------------------------------
507 0 : void OApplicationView::switchPreview(PreviewMode _eMode)
508 : {
509 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
510 0 : getDetailView()->switchPreview(_eMode);
511 0 : }
512 : // -----------------------------------------------------------------------------
513 0 : void OApplicationView::showPreview(const Reference< XContent >& _xContent)
514 : {
515 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
516 0 : stopComponentListening(m_xObject);
517 0 : m_xObject = NULL;
518 0 : getDetailView()->showPreview(_xContent);
519 0 : }
520 : // -----------------------------------------------------------------------------
521 0 : void OApplicationView::showPreview( const ::rtl::OUString& _sDataSourceName,
522 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
523 : const ::rtl::OUString& _sName,
524 : sal_Bool _bTable)
525 : {
526 : OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
527 0 : if ( isPreviewEnabled() )
528 : {
529 0 : stopComponentListening(m_xObject);
530 0 : m_xObject = NULL;
531 : try
532 : {
533 0 : Reference<XNameAccess> xNameAccess;
534 0 : if ( _bTable )
535 : {
536 0 : Reference<XTablesSupplier> xSup(_xConnection,UNO_QUERY);
537 0 : if ( xSup.is() )
538 0 : xNameAccess.set(xSup->getTables(),UNO_QUERY);
539 : }
540 : else
541 : {
542 0 : Reference<XQueriesSupplier> xSup(_xConnection,UNO_QUERY);
543 0 : if ( xSup.is() )
544 0 : xNameAccess.set(xSup->getQueries(),UNO_QUERY);
545 : }
546 0 : if ( xNameAccess.is() && xNameAccess->hasByName(_sName) )
547 0 : m_xObject.set(xNameAccess->getByName(_sName),UNO_QUERY);
548 : }
549 0 : catch( const Exception& )
550 : {
551 : DBG_UNHANDLED_EXCEPTION();
552 : }
553 0 : if ( m_xObject.is() )
554 0 : startComponentListening(m_xObject);
555 0 : getDetailView()->showPreview(_sDataSourceName,_sName,_bTable);
556 : }
557 0 : }
558 : // -----------------------------------------------------------------------------
559 0 : void OApplicationView::GetFocus()
560 : {
561 0 : if ( m_eChildFocus == NONE && m_pWin )
562 : {
563 0 : m_pWin->GrabFocus();
564 : }
565 0 : }
566 : // -----------------------------------------------------------------------------
567 0 : void OApplicationView::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
568 : {
569 0 : if ( m_pWin && getDetailView() )
570 0 : showPreview(NULL);
571 0 : }
572 : // -----------------------------------------------------------------------------
573 0 : void OApplicationView::ImplInitSettings()
574 : {
575 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
576 : if( true )
577 : {
578 0 : Font aFont;
579 0 : aFont = rStyleSettings.GetFieldFont();
580 0 : aFont.SetColor( rStyleSettings.GetWindowTextColor() );
581 0 : SetPointFont( aFont );
582 : }
583 :
584 : if( true )
585 : {
586 0 : SetTextColor( rStyleSettings.GetFieldTextColor() );
587 0 : SetTextFillColor();
588 : }
589 :
590 : if( true )
591 0 : SetBackground( rStyleSettings.GetFieldColor() );
592 0 : }
593 : //-----------------------------------------------------------------------------
594 :
595 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|