fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / browser / dataview.cxx
blob00002a84a6e52bf76f445fa0fb39cdea328f0f4f
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 <dbaccess/dataview.hxx>
21 #include <toolkit/helper/vclunohelper.hxx>
22 #include <comphelper/types.hxx>
23 #include <comphelper/namedvaluecollection.hxx>
24 #include <sfx2/app.hxx>
25 #include <sfx2/imgmgr.hxx>
26 #include <dbaccess/IController.hxx>
27 #include "UITools.hxx"
28 #include <sfx2/sfx.hrc>
29 #include <svtools/imgdef.hxx>
30 #include <tools/diagnose_ex.h>
31 #include <vcl/settings.hxx>
33 namespace dbaui
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::util;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::frame;
41 ODataView::ODataView( vcl::Window* pParent,
42 IController& _rController,
43 const Reference< XComponentContext >& _rxContext,
44 WinBits nStyle)
45 :Window(pParent,nStyle)
46 ,m_xContext(_rxContext)
47 ,m_xController( &_rController )
48 ,m_aSeparator( VclPtr<FixedLine>::Create(this) )
50 m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
51 m_aSeparator->Show();
54 void ODataView::Construct()
58 ODataView::~ODataView()
60 disposeOnce();
63 void ODataView::dispose()
65 m_xController.clear();
66 m_aSeparator.disposeAndClear();
67 m_pAccel.reset();
68 vcl::Window::dispose();
71 void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
75 void ODataView::Paint(vcl::RenderContext& rRenderContext, const Rectangle& _rRect)
77 // draw the background
79 rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR);
80 rRenderContext.SetLineColor(COL_TRANSPARENT);
81 rRenderContext.SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
82 rRenderContext.DrawRect(_rRect);
83 rRenderContext.Pop();
86 // let the base class do anything it needs
87 Window::Paint(rRenderContext, _rRect);
90 void ODataView::resizeAll( const Rectangle& _rPlayground )
92 Rectangle aPlayground( _rPlayground );
94 // position the separator
95 const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
96 m_aSeparator->SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
97 aPlayground.Top() += aSeparatorSize.Height() + 1;
99 // position the controls of the document's view
100 resizeDocumentView( aPlayground );
103 void ODataView::Resize()
105 Window::Resize();
106 resizeAll( Rectangle( Point( 0, 0), GetSizePixel() ) );
108 bool ODataView::PreNotify( NotifyEvent& _rNEvt )
110 bool bHandled = false;
111 switch ( _rNEvt.GetType() )
113 case MouseNotifyEvent::KEYINPUT:
115 const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
116 const vcl::KeyCode& aKeyCode = pKeyEvent->GetKeyCode();
117 if ( m_pAccel.get() && m_pAccel->execute( aKeyCode ) )
118 // the accelerator consumed the event
119 return true;
121 // NO break
122 case MouseNotifyEvent::KEYUP:
123 case MouseNotifyEvent::MOUSEBUTTONDOWN:
124 case MouseNotifyEvent::MOUSEBUTTONUP:
125 bHandled = m_xController->interceptUserInput( _rNEvt );
126 break;
127 default:
128 break;
130 return bHandled || Window::PreNotify( _rNEvt );
132 void ODataView::StateChanged( StateChangedType nType )
134 Window::StateChanged( nType );
136 if ( nType == StateChangedType::ControlBackground )
138 // Check if we need to get new images for normal/high contrast mode
139 m_xController->notifyHiContrastChanged();
142 if ( nType == StateChangedType::InitShow )
144 // now that there's a view which is finally visible, remove the "Hidden" value from the
145 // model's arguments.
148 Reference< XController > xController( m_xController->getXController(), UNO_SET_THROW );
149 Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
150 if ( xModel.is() )
152 ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
153 aArgs.remove( "Hidden" );
154 xModel->attachResource( xModel->getURL(), aArgs.getPropertyValues() );
157 catch( const Exception& )
159 DBG_UNHANDLED_EXCEPTION();
163 void ODataView::DataChanged( const DataChangedEvent& rDCEvt )
165 Window::DataChanged( rDCEvt );
167 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
168 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
169 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
170 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
171 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
173 // Check if we need to get new images for normal/high contrast mode
174 m_xController->notifyHiContrastChanged();
177 void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
179 m_pAccel->init(m_xContext, _xFrame);
183 // namespace dbaui
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */