Line data Source code
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 : #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
21 : #define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
22 :
23 : #include <svtools/editbrowsebox.hxx>
24 : #include <vcl/outdev.hxx>
25 : #include <svtools/fmtfield.hxx>
26 : #include <com/sun/star/uno/XComponentContext.hpp>
27 :
28 : #include <vector>
29 : #include <boost/shared_ptr.hpp>
30 : #include <boost/scoped_ptr.hpp>
31 :
32 : namespace com { namespace sun { namespace star {
33 : namespace chart2 {
34 : class XChartDocument;
35 : }
36 : }}}
37 :
38 : namespace chart
39 : {
40 :
41 : class DataBrowserModel;
42 : class NumberFormatterWrapper;
43 :
44 : namespace impl
45 : {
46 : class SeriesHeader;
47 : class SeriesHeaderEdit;
48 : }
49 :
50 : class DataBrowser : public ::svt::EditBrowseBox
51 : {
52 : protected:
53 : // EditBrowseBox overridables
54 : virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const SAL_OVERRIDE;
55 : virtual bool SeekRow( long nRow ) SAL_OVERRIDE;
56 : virtual bool IsTabAllowed( bool bForward ) const SAL_OVERRIDE;
57 : virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol ) SAL_OVERRIDE;
58 : virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ) SAL_OVERRIDE;
59 : virtual bool SaveModified() SAL_OVERRIDE;
60 : virtual void CursorMoved() SAL_OVERRIDE;
61 : // called whenever the control of the current cell has been modified
62 : virtual void CellModified() SAL_OVERRIDE;
63 : virtual void ColumnResized( sal_uInt16 nColId ) SAL_OVERRIDE;
64 : virtual void EndScroll() SAL_OVERRIDE;
65 : virtual void MouseButtonDown( const BrowserMouseEvent& rEvt ) SAL_OVERRIDE;
66 :
67 : void SetDirty();
68 :
69 : public:
70 : DataBrowser( vcl::Window* pParent, WinBits nStyle, bool bLiveUpdate );
71 : virtual ~DataBrowser();
72 :
73 : /** GetCellText returns the text at the given position
74 : @param nRow
75 : the number of the row
76 : @param nColId
77 : the ID of the column
78 : @return
79 : the text out of the cell
80 : */
81 : virtual OUString GetCellText(long nRow, sal_uInt16 nColId) const SAL_OVERRIDE;
82 :
83 : /** returns the number in the given cell. If a cell is empty or contains a
84 : string, the result will be Nan
85 : */
86 : double GetCellNumber( long nRow, sal_uInt16 nColumnId ) const;
87 :
88 : bool isDateString( const OUString& aInputString, double& fOutDateValue );
89 :
90 : // Window
91 : virtual void Resize() SAL_OVERRIDE;
92 :
93 : /// @return old state
94 : bool SetReadOnly( bool bNewState );
95 0 : bool IsReadOnly() const { return m_bIsReadOnly;}
96 :
97 : /// reset the dirty status, if changes have been saved
98 : void SetClean();
99 :
100 : void SetDataFromModel( const ::com::sun::star::uno::Reference<
101 : ::com::sun::star::chart2::XChartDocument > & xChartDoc,
102 : const ::com::sun::star::uno::Reference<
103 : ::com::sun::star::uno::XComponentContext > & xContext );
104 :
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;
112 :
113 : bool MaySwapRows() const;
114 : bool MaySwapColumns() const;
115 :
116 : // mutators mutating data
117 : void InsertRow();
118 : void InsertColumn();
119 : void InsertTextColumn();
120 : void RemoveRow();
121 : void RemoveColumn();
122 :
123 : using BrowseBox::RemoveColumn;
124 : using BrowseBox::MouseButtonDown;
125 :
126 : void SwapRow();
127 : void SwapColumn();
128 :
129 : void SetCursorMovedHdl( const Link& rLink );
130 :
131 : void SetCellModifiedHdl( const Link& rLink );
132 :
133 : /// confirms all pending changes to be ready to be closed
134 : bool EndEditing();
135 :
136 : // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber()
137 : sal_Int16 GetFirstVisibleColumNumber() const;
138 :
139 : bool CellContainsNumbers( sal_Int32 nRow, sal_uInt16 nCol ) const;
140 :
141 : sal_uInt32 GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const;
142 :
143 0 : bool IsEnableItem() { return m_bDataValid;}
144 : bool IsDataValid();
145 : void ShowWarningBox();
146 : bool ShowQueryBox();
147 :
148 : void RenewSeriesHeaders();
149 :
150 : private:
151 : ::com::sun::star::uno::Reference<
152 : ::com::sun::star::chart2::XChartDocument > m_xChartDoc;
153 : boost::scoped_ptr< DataBrowserModel > m_apDataBrowserModel;
154 :
155 : typedef ::std::vector< ::boost::shared_ptr< impl::SeriesHeader > > tSeriesHeaderContainer;
156 : tSeriesHeaderContainer m_aSeriesHeaders;
157 :
158 : ::boost::shared_ptr< NumberFormatterWrapper > m_spNumberFormatterWrapper;
159 :
160 : /// the row that is currently painted
161 : long m_nSeekRow;
162 : bool m_bIsReadOnly;
163 : bool m_bIsDirty;
164 : bool m_bLiveUpdate;
165 : bool m_bDataValid;
166 :
167 : FormattedField m_aNumberEditField;
168 : Edit m_aTextEditField;
169 :
170 : /// note: m_aNumberEditField must precede this member!
171 : ::svt::CellControllerRef m_rNumberEditController;
172 : /// note: m_aTextEditField must precede this member!
173 : ::svt::CellControllerRef m_rTextEditController;
174 :
175 : Link m_aCursorMovedHdlLink;
176 : Link m_aCellModifiedLink;
177 :
178 : void clearHeaders();
179 : void RenewTable();
180 : void ImplAdjustHeaderControls();
181 :
182 : OUString GetColString( sal_Int32 nColumnId ) const;
183 : OUString GetRowString( sal_Int32 nRow ) const;
184 :
185 : DECL_LINK( SeriesHeaderGotFocus, impl::SeriesHeaderEdit* );
186 : DECL_LINK( SeriesHeaderChanged, impl::SeriesHeaderEdit* );
187 :
188 : /// not implemented: inhibit copy construction
189 : DataBrowser( const DataBrowser & );
190 : };
191 :
192 : } // namespace chart
193 :
194 : #endif // INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
195 :
196 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|