update dev300-m58
[ooovba.git] / chart2 / source / controller / dialogs / DataBrowser.hxx
blobc1af7db8082f4fe0aeff996195b1929c8ec81b46
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DataBrowser.hxx,v $
10 * $Revision: 1.6.8.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CHART_DATA_BROWSER_HXX
32 #define CHART_DATA_BROWSER_HXX
34 #include <svtools/editbrowsebox.hxx>
35 #include <vcl/outdev.hxx>
36 #include <svtools/fmtfield.hxx>
37 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <vector>
40 #include <memory>
41 #include <boost/shared_ptr.hpp>
43 namespace com { namespace sun { namespace star {
44 namespace chart2 {
45 class XChartDocument;
47 }}}
49 namespace chart
52 class DataBrowserModel;
53 class NumberFormatterWrapper;
55 namespace impl
57 class SeriesHeader;
58 class SeriesHeaderEdit;
61 class DataBrowser : public ::svt::EditBrowseBox
63 protected:
64 // EditBrowseBox overridables
65 virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const;
66 virtual sal_Bool SeekRow( long nRow );
67 virtual sal_Bool IsTabAllowed( sal_Bool bForward ) const;
68 virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
69 virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
70 virtual sal_Bool SaveModified();
71 virtual void CursorMoved();
72 // called whenever the control of the current cell has been modified
73 virtual void CellModified();
74 virtual void ColumnResized( USHORT nColId );
75 virtual void EndScroll();
76 virtual void MouseButtonDown( const BrowserMouseEvent& rEvt );
78 void SetDirty();
80 public:
81 DataBrowser( Window* pParent, const ResId & rId, bool bLiveUpdate );
82 virtual ~DataBrowser();
84 /** GetCellText returns the text at the given position
85 @param nRow
86 the number of the row
87 @param nColId
88 the ID of the column
89 @return
90 the text out of the cell
92 virtual String GetCellText(long nRow, USHORT nColId) const;
94 /** returns the number in the given cell. If a cell is empty or contains a
95 string, the result will be Nan
97 double GetCellNumber( long nRow, USHORT nColumnId ) const;
99 // Window
100 virtual void Resize();
102 /// @return old state
103 bool SetReadOnly( bool bNewState );
104 bool IsReadOnly() const;
106 /// reset the dirty status, if changes have been saved
107 void SetClean();
109 void SetDataFromModel( const ::com::sun::star::uno::Reference<
110 ::com::sun::star::chart2::XChartDocument > & xChartDoc,
111 const ::com::sun::star::uno::Reference<
112 ::com::sun::star::uno::XComponentContext > & xContext );
114 // void setNumberFormatter();
116 // predicates to determine what actions are possible at the current cursor
117 // position. This depends on the implementation of the according mutators
118 // below. (They are used for enabling toolbar icons)
119 bool MayInsertRow() const;
120 bool MayInsertColumn() const;
121 bool MayDeleteRow() const;
122 bool MayDeleteColumn() const;
124 bool MaySwapRows() const;
125 bool MaySwapColumns() const;
127 // bool MaySortRow() const;
128 // bool MaySortColumn() const;
130 // mutators mutating data
131 void InsertRow();
132 void InsertColumn();
133 void RemoveRow();
134 void RemoveColumn();
136 using BrowseBox::RemoveColumn;
137 using BrowseBox::MouseButtonDown;
139 void SwapRow();
140 void SwapColumn();
142 void SetCursorMovedHdl( const Link& rLink );
144 void SetCellModifiedHdl( const Link& rLink );
146 /// confirms all pending changes to be ready to be closed
147 bool EndEditing();
149 // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber()
150 sal_Int16 GetFirstVisibleColumNumber() const;
152 sal_Int32 GetTotalWidth() const;
154 bool CellContainsNumbers( sal_Int32 nRow, sal_uInt16 nCol ) const;
156 sal_uInt32 GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const;
158 bool IsEnableItem();
159 bool IsDataValid();
160 void ShowWarningBox();
161 bool ShowQueryBox();
163 void RenewSeriesHeaders();
165 private:
166 ::com::sun::star::uno::Reference<
167 ::com::sun::star::chart2::XChartDocument > m_xChartDoc;
168 ::std::auto_ptr< DataBrowserModel > m_apDataBrowserModel;
170 typedef ::std::vector< ::boost::shared_ptr< impl::SeriesHeader > > tSeriesHeaderContainer;
171 tSeriesHeaderContainer m_aSeriesHeaders;
173 ::boost::shared_ptr< NumberFormatterWrapper > m_spNumberFormatterWrapper;
175 /// the row that is currently painted
176 long m_nSeekRow;
177 bool m_bIsReadOnly;
178 bool m_bIsDirty;
179 bool m_bLiveUpdate;
180 bool m_bDataValid;
182 FormattedField m_aNumberEditField;
183 Edit m_aTextEditField;
185 /// note: m_aNumberEditField must precede this member!
186 ::svt::CellControllerRef m_rNumberEditController;
187 /// note: m_aTextEditField must precede this member!
188 ::svt::CellControllerRef m_rTextEditController;
190 Link m_aCursorMovedHdlLink;
191 Link m_aCellModifiedLink;
193 void clearHeaders();
194 void RenewTable();
195 void ImplAdjustHeaderControls();
197 String GetColString( sal_Int32 nColumnId ) const;
198 String GetRowString( sal_Int32 nRow ) const;
200 DECL_LINK( SeriesHeaderGotFocus, impl::SeriesHeaderEdit* );
201 DECL_LINK( SeriesHeaderChanged, impl::SeriesHeaderEdit* );
203 /// not implemented: inhibit copy construction
204 DataBrowser( const DataBrowser & );
207 } // namespace chart
209 #endif // CHART_DATA_BROWSER_HXX