LibreOffice Module dbaccess (master) 1
TableWindowTitle.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 <TableWindowTitle.hxx>
21#include <TableWindow.hxx>
22#include <vcl/commandevent.hxx>
23#include <vcl/event.hxx>
25#include <TableConnection.hxx>
26#include <JoinController.hxx>
27
28using namespace dbaui;
29using namespace ::com::sun::star::beans;
30using namespace ::com::sun::star::uno;
31OTableWindowTitle::OTableWindowTitle(OTableWindow* pParent)
32 : InterimItemWindow(pParent, "dbaccess/ui/tabletitle.ui", "TableTitle")
33 , m_pTabWin( pParent )
34 , m_xLabel(m_xBuilder->weld_label("label"))
35 , m_xImage(m_xBuilder->weld_image("image"))
36{
37 m_xLabel->connect_mouse_press(LINK(this, OTableWindowTitle, MousePressHdl));
38}
39
41{
43}
44
46{
47 m_xImage.reset();
48 m_xLabel.reset();
49 m_pTabWin.clear();
51}
52
53IMPL_LINK(OTableWindowTitle, MousePressHdl, const MouseEvent&, rEvt, bool)
54{
55 if (rEvt.IsLeft())
56 {
57 if( rEvt.GetClicks() == 2)
58 {
59 Size aSize(GetTextWidth(GetText()) + 20,
60 m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height());
61
62 weld::TreeView& rTreeView = m_pTabWin->GetListBox()->get_widget();
63 aSize.AdjustHeight(rTreeView.get_height_rows(rTreeView.n_children() + 2));
64 if (m_pTabWin->GetSizePixel() != aSize)
65 {
66 m_pTabWin->SetSizePixel(aSize);
67
68 OJoinTableView* pView = m_pTabWin->getTableView();
69 OSL_ENSURE(pView,"No OJoinTableView!");
70 for (auto& conn : pView->getTableConnections())
71 conn->RecalcLines();
72
73 pView->InvalidateConnections();
74 pView->getDesignView()->getController().setModified(true);
75 pView->Invalidate(InvalidateFlags::NoChildren);
76 }
77 }
78 else
79 {
80 Point aPos = rEvt.GetPosPixel();
81 aPos = OutputToScreenPixel( aPos );
82 OJoinTableView* pView = m_pTabWin->getTableView();
83 OSL_ENSURE(pView,"No OJoinTableView!");
84 pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
85 }
86 }
87 else if (rEvt.IsRight())
88 {
89 CommandEvent aCEvt(rEvt.GetPosPixel(), CommandEventId::ContextMenu, true);
90 // tdf#94709 - protect shutdown code-path.
91 VclPtr<OTableWindow> xTabWin(m_pTabWin);
92 xTabWin->Command(aCEvt);
93 }
94 return false;
95}
96
97/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void dispose() override
tools::Long AdjustHeight(tools::Long n)
OJoinController & getController() const
void NotifyTitleClicked(OTableWindow *pTabWin, const Point &rMousePos)
const std::vector< VclPtr< OTableConnection > > & getTableConnections() const
gives a read only access to the connection vector
OJoinDesignView * getDesignView() const
std::unique_ptr< weld::Label > m_xLabel
std::unique_ptr< weld::Image > m_xImage
virtual void dispose() override
VclPtr< OTableWindow > m_pTabWin
virtual ~OTableWindowTitle() override
std::unique_ptr< weld::Label > m_xLabel
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
virtual int n_children() const=0
virtual int get_height_rows(int nRows) const=0
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)