1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
41 #include <boost/shared_ptr.hpp>
43 namespace com
{ namespace sun
{ namespace star
{
52 class DataBrowserModel
;
53 class NumberFormatterWrapper
;
58 class SeriesHeaderEdit
;
61 class DataBrowser
: public ::svt::EditBrowseBox
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
);
81 DataBrowser( Window
* pParent
, const ResId
& rId
, bool bLiveUpdate
);
82 virtual ~DataBrowser();
84 /** GetCellText returns the text at the given position
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;
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
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
136 using BrowseBox::RemoveColumn
;
137 using BrowseBox::MouseButtonDown
;
142 void SetCursorMovedHdl( const Link
& rLink
);
144 void SetCellModifiedHdl( const Link
& rLink
);
146 /// confirms all pending changes to be ready to be closed
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;
160 void ShowWarningBox();
163 void RenewSeriesHeaders();
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
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
;
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
& );
209 #endif // CHART_DATA_BROWSER_HXX