1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/outdev.hxx>
25 #include <svtools/fmtfield.hxx>
26 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/scoped_ptr.hpp>
32 namespace com
{ namespace sun
{ namespace star
{
41 class DataBrowserModel
;
42 class NumberFormatterWrapper
;
47 class SeriesHeaderEdit
;
50 class DataBrowser
: public ::svt::EditBrowseBox
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
;
70 DataBrowser( vcl::Window
* pParent
, WinBits nStyle
, bool bLiveUpdate
);
71 virtual ~DataBrowser();
72 virtual void dispose() SAL_OVERRIDE
;
74 /** GetCellText returns the text at the given position
80 the text out of the cell
82 virtual OUString
GetCellText(long nRow
, sal_uInt16 nColId
) const SAL_OVERRIDE
;
84 /** returns the number in the given cell. If a cell is empty or contains a
85 string, the result will be Nan
87 double GetCellNumber( long nRow
, sal_uInt16 nColumnId
) const;
89 bool isDateTimeString( const OUString
& aInputString
, double& fOutDateTimeValue
);
92 virtual void Resize() SAL_OVERRIDE
;
95 bool SetReadOnly( bool bNewState
);
96 bool IsReadOnly() const { return m_bIsReadOnly
;}
98 /// reset the dirty status, if changes have been saved
101 void SetDataFromModel( const ::com::sun::star::uno::Reference
<
102 ::com::sun::star::chart2::XChartDocument
> & xChartDoc
,
103 const ::com::sun::star::uno::Reference
<
104 ::com::sun::star::uno::XComponentContext
> & xContext
);
106 // predicates to determine what actions are possible at the current cursor
107 // position. This depends on the implementation of the according mutators
108 // below. (They are used for enabling toolbar icons)
109 bool MayInsertRow() const;
110 bool MayInsertColumn() const;
111 bool MayDeleteRow() const;
112 bool MayDeleteColumn() const;
114 bool MaySwapRows() const;
115 bool MaySwapColumns() const;
117 // mutators mutating data
120 void InsertTextColumn();
124 using BrowseBox::RemoveColumn
;
125 using BrowseBox::MouseButtonDown
;
130 void SetCursorMovedHdl( const Link
<>& rLink
);
132 void SetCellModifiedHdl( const Link
<>& rLink
);
134 /// confirms all pending changes to be ready to be closed
137 // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber()
138 sal_Int16
GetFirstVisibleColumNumber() const;
140 bool CellContainsNumbers( sal_Int32 nRow
, sal_uInt16 nCol
) const;
142 sal_uInt32
GetNumberFormatKey( sal_Int32 nRow
, sal_uInt16 nCol
) const;
144 bool IsEnableItem() { return m_bDataValid
;}
146 void ShowWarningBox();
149 void RenewSeriesHeaders();
152 ::com::sun::star::uno::Reference
<
153 ::com::sun::star::chart2::XChartDocument
> m_xChartDoc
;
154 boost::scoped_ptr
< DataBrowserModel
> m_apDataBrowserModel
;
156 typedef ::std::vector
< ::boost::shared_ptr
< impl::SeriesHeader
> > tSeriesHeaderContainer
;
157 tSeriesHeaderContainer m_aSeriesHeaders
;
159 ::boost::shared_ptr
< NumberFormatterWrapper
> m_spNumberFormatterWrapper
;
161 /// the row that is currently painted
168 VclPtr
<FormattedField
> m_aNumberEditField
;
169 VclPtr
<Edit
> m_aTextEditField
;
171 /// note: m_aNumberEditField must precede this member!
172 ::svt::CellControllerRef m_rNumberEditController
;
173 /// note: m_aTextEditField must precede this member!
174 ::svt::CellControllerRef m_rTextEditController
;
176 Link
<> m_aCursorMovedHdlLink
;
177 Link
<> m_aCellModifiedLink
;
181 void ImplAdjustHeaderControls();
183 OUString
GetColString( sal_Int32 nColumnId
) const;
184 static OUString
GetRowString( sal_Int32 nRow
);
186 DECL_LINK( SeriesHeaderGotFocus
, impl::SeriesHeaderEdit
* );
187 DECL_LINK( SeriesHeaderChanged
, impl::SeriesHeaderEdit
* );
189 DataBrowser( const DataBrowser
& ) SAL_DELETED_FUNCTION
;
194 #endif // INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_DATABROWSER_HXX
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */