LibreOffice Module chart2 (master) 1
dlg_DataEditor.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 <dlg_DataEditor.hxx>
21#include "DataBrowser.hxx"
22#include <ChartModel.hxx>
24
25#include <com/sun/star/awt/XWindow.hpp>
26#include <utility>
27
28using namespace ::com::sun::star;
29using ::com::sun::star::uno::Reference;
30
31namespace chart
32{
33
37 : GenericDialogController(pParent, "modules/schart/ui/chartdatadialog.ui", "ChartDataDialog")
38 , m_bReadOnly(false)
39 , m_xChartDoc(std::move(xChartDoc))
40 , m_xContext(xContext)
41 , m_xTbxData(m_xBuilder->weld_toolbar("toolbar"))
42 , m_xCloseBtn(m_xBuilder->weld_button("close"))
43 , m_xTable(m_xBuilder->weld_container("datawindow"))
44 , m_xColumns(m_xBuilder->weld_container("columns"))
45 , m_xColors(m_xBuilder->weld_container("colorcolumns"))
46 , m_xTableCtrlParent(m_xTable->CreateChildFrame())
47 , m_xBrwData(VclPtr<DataBrowser>::Create(m_xTableCtrlParent, m_xColumns.get(), m_xColors.get()))
48{
49 m_xCloseBtn->connect_clicked(LINK(this, DataEditor, CloseHdl));
50
51 Size aSize(m_xTable->get_approximate_digit_width() * 75, m_xTable->get_text_height() * 15);
52 m_xTable->set_size_request(aSize.Width(), aSize.Height());
53
54 m_xBrwData->Show();
55
56 m_xTbxData->connect_clicked(LINK(this, DataEditor, ToolboxHdl));
57
58 m_xBrwData->SetCursorMovedHdl( LINK( this, DataEditor, BrowserCursorMovedHdl ));
59
60 m_xBrwData->SetDataFromModel( m_xChartDoc );
61 m_xBrwData->GrabFocus();
62
63 bool bReadOnly = true;
64 if( m_xChartDoc.is())
65 bReadOnly = m_xChartDoc->isReadonly();
67}
68
70{
71 m_xBrwData.disposeAndClear();
72 m_xTableCtrlParent->dispose();
73 m_xTableCtrlParent.clear();
74}
75
76// react on click (or keypress) on toolbar icon
77IMPL_LINK(DataEditor, ToolboxHdl, const OUString&, rId, void)
78{
79 if (rId == "InsertRow")
80 m_xBrwData->InsertRow();
81 else if (rId == "InsertColumn")
82 m_xBrwData->InsertColumn();
83 else if (rId == "InsertTextColumn")
84 m_xBrwData->InsertTextColumn();
85 else if (rId == "RemoveRow")
86 m_xBrwData->RemoveRow();
87 else if (rId == "RemoveColumn")
88 m_xBrwData->RemoveColumn();
89 else if (rId == "MoveLeftColumn")
90 m_xBrwData->MoveLeftColumn();
91 else if (rId == "MoveRightColumn")
92 m_xBrwData->MoveRightColumn();
93 else if (rId == "MoveUpRow")
94 m_xBrwData->MoveUpRow();
95 else if (rId == "MoveDownRow")
96 m_xBrwData->MoveDownRow();
97}
98
99// refresh toolbar icons according to currently selected cell in browse box
100IMPL_LINK_NOARG(DataEditor, BrowserCursorMovedHdl, DataBrowser*, void)
101{
102 if( m_bReadOnly )
103 return;
104
105 bool bIsDataValid = m_xBrwData->IsEnableItem();
106
107 m_xTbxData->set_item_sensitive("InsertRow", bIsDataValid && m_xBrwData->MayInsertRow() );
108 m_xTbxData->set_item_sensitive("InsertColumn", bIsDataValid && m_xBrwData->MayInsertColumn() );
109 m_xTbxData->set_item_sensitive("InsertTextColumn", bIsDataValid && m_xBrwData->MayInsertColumn() );
110 m_xTbxData->set_item_sensitive("RemoveRow", m_xBrwData->MayDeleteRow() );
111 m_xTbxData->set_item_sensitive("RemoveColumn", m_xBrwData->MayDeleteColumn() );
112
113 m_xTbxData->set_item_sensitive("MoveLeftColumn", bIsDataValid && m_xBrwData->MayMoveLeftColumns() );
114 m_xTbxData->set_item_sensitive("MoveRightColumn", bIsDataValid && m_xBrwData->MayMoveRightColumns() );
115 m_xTbxData->set_item_sensitive("MoveDownRow", bIsDataValid && m_xBrwData->MayMoveDownRows() );
116 m_xTbxData->set_item_sensitive("MoveUpRow", bIsDataValid && m_xBrwData->MayMoveUpRows() );
117}
118
119// disable all modifying controls
120void DataEditor::SetReadOnly( bool bReadOnly )
121{
123 if( m_bReadOnly )
124 {
125 m_xTbxData->set_item_sensitive("InsertRow", false);
126 m_xTbxData->set_item_sensitive("InsertColumn", false);
127 m_xTbxData->set_item_sensitive("InsertTextColumn", false);
128 m_xTbxData->set_item_sensitive("RemoveRow", false);
129 m_xTbxData->set_item_sensitive("RemoveColumn", false);
130 m_xTbxData->set_item_sensitive("MoveLeftColumn", false);
131 m_xTbxData->set_item_sensitive("MoveRightColumn", false);
132 m_xTbxData->set_item_sensitive("MoveUpRow", false);
133 m_xTbxData->set_item_sensitive("MoveDownRow", false);
134 }
135
136 m_xBrwData->SetReadOnly( m_bReadOnly );
137}
138
140{
141 bool bApplied = m_xBrwData->EndEditing(); // apply changes to model
142 if (bApplied)
143 m_xDialog->response(RET_CLOSE);
144}
145
146} // namespace chart
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference<::chart::ChartModel > m_xChartDoc
Reference< uno::XComponentContext > m_xContext
Reference< XExecutableDialog > m_xDialog
constexpr tools::Long Height() const
constexpr tools::Long Width() const
std::unique_ptr< weld::Toolbar > m_xTbxData
DataEditor(weld::Window *pParent, rtl::Reference<::chart::ChartModel > xChartDoc, const css::uno::Reference< css::uno::XComponentContext > &xContext)
css::uno::Reference< css::awt::XWindow > m_xTableCtrlParent
virtual ~DataEditor() override
std::unique_ptr< weld::Container > m_xTable
void SetReadOnly(bool bReadOnly)
std::unique_ptr< weld::Button > m_xCloseBtn
rtl::Reference<::chart::ChartModel > m_xChartDoc
VclPtr< DataBrowser > m_xBrwData
bool bReadOnly
bool m_bReadOnly
IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable &, rRadio, void)
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
RET_CLOSE