1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <TableWindowTitle.hxx>
21 #include <TableWindow.hxx>
22 #include <vcl/commandevent.hxx>
23 #include <vcl/event.hxx>
24 #include <TableWindowListBox.hxx>
25 #include <TableConnection.hxx>
26 #include <JoinController.hxx>
28 using namespace dbaui
;
29 using namespace ::com::sun::star::beans
;
30 using namespace ::com::sun::star::uno
;
31 OTableWindowTitle::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"))
37 m_xLabel
->connect_mouse_press(LINK(this, OTableWindowTitle
, MousePressHdl
));
40 OTableWindowTitle::~OTableWindowTitle()
45 void OTableWindowTitle::dispose()
50 InterimItemWindow::dispose();
53 IMPL_LINK(OTableWindowTitle
, MousePressHdl
, const MouseEvent
&, rEvt
, bool)
57 if( rEvt
.GetClicks() == 2)
59 Size
aSize(GetTextWidth(GetText()) + 20,
60 m_pTabWin
->GetSizePixel().Height() - m_pTabWin
->GetListBox()->GetSizePixel().Height());
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
)
66 m_pTabWin
->SetSizePixel(aSize
);
68 OJoinTableView
* pView
= m_pTabWin
->getTableView();
69 OSL_ENSURE(pView
,"No OJoinTableView!");
70 for (auto& conn
: pView
->getTableConnections())
73 pView
->InvalidateConnections();
74 pView
->getDesignView()->getController().setModified(true);
75 pView
->Invalidate(InvalidateFlags::NoChildren
);
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
);
87 else if (rEvt
.IsRight())
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
);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */