LibreOffice Module dbaccess (master) 1
dataview.cxx
Go to the documentation of this file.
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 <com/sun/star/frame/XController.hpp>
21#include <com/sun/star/frame/XModel.hpp>
22#include <dbaccess/dataview.hxx>
27#include <vcl/event.hxx>
28#include <vcl/settings.hxx>
29
30namespace dbaui
31{
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::util;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::frame;
37
39 IController& _rController,
40 const Reference< XComponentContext >& _rxContext,
41 WinBits nStyle)
42 :Window(pParent,nStyle)
43 ,m_xContext(_rxContext)
44 ,m_xController( &_rController )
45 {
47 }
48
50 {
51 }
52
54 {
56 }
57
59 {
60 m_xController.clear();
61 m_pAccel.reset();
63 }
64
66 {
67 }
68
69 void ODataView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect)
70 {
71 // draw the background
72 {
74 rRenderContext.SetLineColor(COL_TRANSPARENT);
75 rRenderContext.SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
76 rRenderContext.DrawRect(_rRect);
77 rRenderContext.Pop();
78 }
79
80 // let the base class do anything it needs
81 Window::Paint(rRenderContext, _rRect);
82 }
83
84 void ODataView::resizeAll(const tools::Rectangle& rPlayground)
85 {
86 // position the controls of the document's view
87 tools::Rectangle aPlayground(rPlayground);
88 resizeDocumentView(aPlayground);
89 }
90
92 {
95 }
97 {
98 bool bHandled = false;
99 switch ( _rNEvt.GetType() )
100 {
101 case NotifyEventType::KEYINPUT:
102 {
103 const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
104 const vcl::KeyCode& aKeyCode = pKeyEvent->GetKeyCode();
105 if ( m_pAccel && m_pAccel->execute( aKeyCode ) )
106 // the accelerator consumed the event
107 return true;
108 [[fallthrough]];
109 }
110 case NotifyEventType::KEYUP:
111 case NotifyEventType::MOUSEBUTTONDOWN:
112 case NotifyEventType::MOUSEBUTTONUP:
113 bHandled = m_xController->interceptUserInput( _rNEvt );
114 break;
115 default:
116 break;
117 }
118 return bHandled || Window::PreNotify( _rNEvt );
119 }
121 {
123
124 if ( nType != StateChangedType::InitShow )
125 return;
126
127 // now that there's a view which is finally visible, remove the "Hidden" value from the
128 // model's arguments.
129 try
130 {
131 Reference< XController > xController( m_xController->getXController(), UNO_SET_THROW );
133 if ( xModel.is() )
134 {
135 ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
136 aArgs.remove( "Hidden" );
137 xModel->attachResource( xModel->getURL(), aArgs.getPropertyValues() );
138 }
139 }
140 catch( const Exception& )
141 {
142 DBG_UNHANDLED_EXCEPTION("dbaccess");
143 }
144 }
145
147 {
148 m_pAccel->init(m_xContext, _xFrame);
149 }
150}
151
152// namespace dbaui
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const vcl::KeyCode & GetKeyCode() const
const KeyEvent * GetKeyEvent() const
NotifyEventType GetType() const
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetFillColor()
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
bool remove(const OUString &_rValueName)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
void attachFrame(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: dataview.cxx:146
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: dataview.hxx:48
virtual void StateChanged(StateChangedType nStateChange) override
Definition: dataview.cxx:120
::std::unique_ptr< ::svt::AcceleratorExecute > m_pAccel
Definition: dataview.hxx:52
virtual void Construct()
late construction
Definition: dataview.cxx:49
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &_rRect) override
Definition: dataview.cxx:69
virtual void resizeDocumentView(tools::Rectangle &_rPlayground)
Definition: dataview.cxx:65
ODataView(vcl::Window *pParent, IController &_rController, const css::uno::Reference< css::uno::XComponentContext > &, WinBits nStyle=0)
Definition: dataview.cxx:38
virtual ~ODataView() override
Definition: dataview.cxx:53
virtual void dispose() override
Definition: dataview.cxx:58
virtual void resizeAll(const tools::Rectangle &_rPlayground)
re-arrange all controls, including the toolbox, it's separator, and the "real view"
Definition: dataview.cxx:84
rtl::Reference< IController > m_xController
Definition: dataview.hxx:51
virtual void Resize() override
Definition: dataview.cxx:91
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: dataview.cxx:96
static std::unique_ptr< AcceleratorExecute > createAcceleratorHelper()
virtual void dispose() override
virtual void StateChanged(StateChangedType nStateChange)
virtual void Resize()
const AllSettings & GetSettings() const
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual bool PreNotify(NotifyEvent &rNEvt)
virtual Size GetSizePixel() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
Reference< XComponentContext > m_xContext
#define DBG_UNHANDLED_EXCEPTION(...)
@ Exception
QPRO_FUNC_TYPE nType
Reference< XController > xController
the controller of the sub component. Must not be <NULL>
Reference< XModel > xModel
the model of the sub component. Might be <NULL>
StateChangedType
sal_Int64 WinBits