Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / dialogs / DataBrowser.hxx
blobd3575d2e03e3f50b023cf1cf57ed2a16f004de04
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 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
21 #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
23 #include <svtools/editbrowsebox.hxx>
24 #include <vcl/fmtfield.hxx>
25 #include <vcl/weld.hxx>
27 #include <memory>
28 #include <vector>
30 namespace com { namespace sun { namespace star {
31 namespace awt {
32 class XWindow;
34 namespace chart2 {
35 class XChartDocument;
37 }}}
39 namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
41 class OutputDevice;
43 namespace chart
46 class DataBrowserModel;
47 class NumberFormatterWrapper;
49 namespace impl
51 class SeriesHeader;
52 class SeriesHeaderEdit;
55 class DataBrowser : public ::svt::EditBrowseBox
57 protected:
58 // EditBrowseBox overridables
59 virtual void PaintCell( OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColumnId ) const override;
60 virtual bool SeekRow( long nRow ) override;
61 virtual bool IsTabAllowed( bool bForward ) const override;
62 virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol ) override;
63 virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ) override;
64 virtual bool SaveModified() override;
65 virtual void CursorMoved() override;
66 // called whenever the control of the current cell has been modified
67 virtual void CellModified() override;
68 virtual void ColumnResized( sal_uInt16 nColId ) override;
69 virtual void EndScroll() override;
70 virtual void MouseButtonDown( const BrowserMouseEvent& rEvt ) override;
72 public:
73 DataBrowser(const css::uno::Reference<css::awt::XWindow> &rParent,
74 weld::Container* pColumns, weld::Container* pColors);
76 virtual ~DataBrowser() override;
77 virtual void dispose() override;
79 /** GetCellText returns the text at the given position
80 @param nRow
81 the number of the row
82 @param nColId
83 the ID of the column
84 @return
85 the text out of the cell
87 virtual OUString GetCellText(long nRow, sal_uInt16 nColId) const override;
89 /** returns the number in the given cell. If a cell is empty or contains a
90 string, the result will be Nan
92 double GetCellNumber( long nRow, sal_uInt16 nColumnId ) const;
94 bool isDateTimeString( const OUString& aInputString, double& fOutDateTimeValue );
96 // Window
97 virtual void Resize() override;
99 void SetReadOnly( bool bNewState );
100 bool IsReadOnly() const { return m_bIsReadOnly;}
102 void SetDataFromModel( const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc,
103 const css::uno::Reference< css::uno::XComponentContext > & xContext );
105 // predicates to determine what actions are possible at the current cursor
106 // position. This depends on the implementation of the according mutators
107 // below. (They are used for enabling toolbar icons)
108 bool MayInsertRow() const;
109 bool MayInsertColumn() const;
110 bool MayDeleteRow() const;
111 bool MayDeleteColumn() const;
113 bool MayMoveUpRows() const;
114 bool MayMoveDownRows() const;
115 bool MayMoveRightColumns() const;
116 bool MayMoveLeftColumns() const;
118 // mutators mutating data
119 void InsertRow();
120 void InsertColumn();
121 void InsertTextColumn();
122 void RemoveRow();
123 void RemoveColumn();
125 using BrowseBox::RemoveColumn;
126 using BrowseBox::MouseButtonDown;
128 void MoveUpRow();
129 void MoveDownRow();
130 void MoveLeftColumn();
131 void MoveRightColumn();
133 void SetCursorMovedHdl( const Link<DataBrowser*,void>& rLink );
135 /// confirms all pending changes to be ready to be closed
136 bool EndEditing();
138 bool CellContainsNumbers( sal_uInt16 nCol ) const;
140 sal_uInt32 GetNumberFormatKey( sal_uInt16 nCol ) const;
142 bool IsEnableItem() const { return m_bDataValid;}
143 bool IsDataValid() const;
144 void ShowWarningBox();
145 bool ShowQueryBox();
147 void RenewSeriesHeaders();
149 private:
150 css::uno::Reference< css::chart2::XChartDocument > m_xChartDoc;
151 std::unique_ptr< DataBrowserModel > m_apDataBrowserModel;
153 typedef std::vector< std::shared_ptr< impl::SeriesHeader > > tSeriesHeaderContainer;
154 tSeriesHeaderContainer m_aSeriesHeaders;
156 std::shared_ptr< NumberFormatterWrapper > m_spNumberFormatterWrapper;
158 /// the row that is currently painted
159 long m_nSeekRow;
160 bool m_bIsReadOnly;
161 bool m_bDataValid;
163 VclPtr<FormattedField> m_aNumberEditField;
164 VclPtr<Edit> m_aTextEditField;
165 weld::Container* m_pColumnsWin;
166 weld::Container* m_pColorsWin;
168 /// note: m_aNumberEditField must precede this member!
169 ::svt::CellControllerRef m_rNumberEditController;
170 /// note: m_aTextEditField must precede this member!
171 ::svt::CellControllerRef m_rTextEditController;
173 Link<DataBrowser*,void> m_aCursorMovedHdlLink;
175 void clearHeaders();
176 void RenewTable();
177 void ImplAdjustHeaderControls();
179 OUString GetColString( sal_Int32 nColumnId ) const;
181 DECL_LINK( SeriesHeaderGotFocus, impl::SeriesHeaderEdit&, void );
182 DECL_LINK( SeriesHeaderChanged, impl::SeriesHeaderEdit&, void );
184 DataBrowser( const DataBrowser & ) = delete;
187 } // namespace chart
189 #endif // INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */