32#include <bitmaps.hlst>
42#include <osl/diagnose.h>
46#include <com/sun/star/container/XIndexReplace.hpp>
53using ::com::sun::star::uno::Reference;
70const BrowserMode BrowserStdFlags = BrowserMode::COLUMNSELECTION |
71 BrowserMode::HLINES | BrowserMode::VLINES |
72 BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL |
73 BrowserMode::HIDESELECT;
75sal_Int32 lcl_getColumnInData( sal_uInt16 nCol )
77 return static_cast< sal_Int32
>( nCol ) - 1;
123 , m_bShowWarningBox(false)
133 m_aModifyHdl.Call(*
this);
138 m_aFocusInHdl.Call(*
this);
153 if (m_bShowWarningBox)
156 VclMessageType::Warning, VclButtonsType::Ok,
174 bool bSwapXAndYAxis );
176 void SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol );
235 : m_aUpdateDataTimer(
"SeriesHeader UpdateDataTimer" )
236 , m_xBuilder1(
Application::CreateBuilder(pParent,
"modules/schart/ui/columnfragment.ui"))
237 , m_xBuilder2(
Application::CreateBuilder(pColorParent,
"modules/schart/ui/imagefragment.ui"))
239 , m_pColorParent(pColorParent)
240 , m_xContainer1(m_xBuilder1->weld_container(
"container"))
241 , m_xContainer2(m_xBuilder2->weld_container(
"container"))
242 , m_spSymbol(m_xBuilder1->weld_image(
"image"))
244 , m_spColorBar(m_xBuilder2->weld_image(
"image"))
249 , m_bSeriesNameChangePending( false )
294 sal_Int32 nHeightPx =
m_xDevice->LogicToPixel(
Size(0, 12),
MapMode(MapUnit::MapAppFont)).Height();
336 m_nEndCol = std::max(nEndCol, nStartCol);
364 m_bSeriesNameChangePending =
true;
365 m_aUpdateDataTimer.Start();
384 if( !xChartType.is())
386 OUString aChartTypeName( xChartType->getChartType());
390 aResult = BMP_TYPE_AREA;
395 aResult = BMP_TYPE_BAR;
397 aResult = BMP_TYPE_COLUMN;
401 aResult = BMP_TYPE_LINE;
405 aResult = BMP_TYPE_XY;
409 aResult = BMP_TYPE_PIE;
414 aResult = BMP_TYPE_NET;
419 aResult = BMP_TYPE_STOCK;
423 aResult = BMP_TYPE_BUBBLE;
439bool lcl_SeriesHeaderHasFocus(
440 const std::vector< std::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader,
441 sal_Int32 * pOutIndex =
nullptr )
444 for (
auto const& elem : rSeriesHeader)
457sal_Int32 lcl_getColumnInDataOrHeader(
458 sal_uInt16 nCol,
const std::vector< std::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader )
460 sal_Int32 nColIdx = 0;
461 bool bHeaderHasFocus( lcl_SeriesHeaderHasFocus( rSeriesHeader, &nColIdx ));
463 if( bHeaderHasFocus )
464 nColIdx = lcl_getColumnInData(
static_cast< sal_uInt16
>( rSeriesHeader[nColIdx]->GetStartColumn()));
466 nColIdx = lcl_getColumnInData( nCol );
479 m_bIsReadOnly( false ),
480 m_bDataValid( true ),
481 m_aNumberEditField(
VclPtr<FormattedControl>::
Create(&EditBrowseBox::GetDataWindow(), false)),
483 m_pColumnsWin(pColumns),
484 m_pColorsWin(pColors),
485 m_rNumberEditController( new ::
svt::FormattedFieldCellController( m_aNumberEditField.
get() )),
486 m_rTextEditController( new ::
svt::EditCellController( m_aTextEditField.
get() ))
489 rFormatter.
SetDefaultValue( std::numeric_limits<double>::quiet_NaN() );
557 sal_Int32 nColIndex(0);
574 sal_Int32 nColIndex(0);
590 spHeader->applyChanges();
617 OUString aDefaultSeriesName(
SchResId(STR_COLUMN_LABEL));
619 sal_Int32 nColumnWidth =
GetDataWindow().GetTextWidth( aDefaultSeriesName )
624 for( sal_Int32 nColIdx=1; nColIdx<=nColumnCount; ++nColIdx )
639 for (
auto const& elemHeader : aHeaders)
644 if( elemHeader.m_xDataSeries.is() &&
645 ( elemHeader.m_xDataSeries->getPropertyValue(
"Color" ) >>= nColor ))
646 spHeader->SetColor( nColor );
647 spHeader->SetChartType( elemHeader.m_xChartType, elemHeader.m_bSwapXAndYAxis );
648 spHeader->SetSeriesName(
649 elemHeader.m_xDataSeries->getLabelForRole(
650 elemHeader.m_xChartType.is() ?
651 elemHeader.m_xChartType->getRoleOfSequenceForSeriesLabel() :
652 OUString(
"values-y")));
654 spHeader->SetRange( elemHeader.m_nStartColumn + 1, elemHeader.m_nEndColumn + 1 );
655 spHeader->SetGetFocusHdl( aFocusLink );
656 spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink );
680 aResult = OUString::number(nRow + 1);
684 sal_Int32 nColIndex =
static_cast< sal_Int32
>( nColumnId ) - 1;
690 if( ! std::isnan( fData ) &&
693 bool bColorChanged =
false;
697 fData, nLabelColor, bColorChanged );
707 else if( aAny>>=fDouble )
718 bool bColorChanged =
false;
720 nNumberFormat, fDouble, nLabelColor, bColorChanged );
739 static_cast< sal_Int32
>( nColumnId ) - 1, nRow );
742 return std::numeric_limits<double>::quiet_NaN();
767 EditBrowseBox::CursorMoved();
778 EditBrowseBox::MouseButtonDown( rEvt );
784 VclMessageType::Warning, VclButtonsType::Ok,
792 VclMessageType::Question, VclButtonsType::YesNo,
793 SchResId(STR_DATA_EDITOR_INCORRECT_INPUT)));
794 return xQueryBox->run() ==
RET_YES;
804 sal_uInt32 nDummy = 0;
808 if( !aText.isEmpty() &&
812 aText, nDummy, fDummy ))
834 std::make_shared<NumberFormatterWrapper>(
m_xChartDoc);
843 if( nRowCnt && nColCnt )
1032 bool bEnabled = IsEnabled();
1035 rDev.
SetTextColor( GetSettings().GetStyleSettings().GetDisableColor() );
1050 if( ! EditBrowseBox::SeekRow( nRow ))
1067 sal_Int32 nBadCol = bForward
1070 sal_Int32 nBadRow = bForward
1080 return ( nRow != nBadRow ||
1124 OSL_FAIL(
"Invalid Controller" );
1144 sal_uInt32 nNumberFormat=0;
1146 if( !aInputString.isEmpty() && pSvNumberFormatter && pSvNumberFormatter->
IsNumberFormat( aInputString, nNumberFormat, fOutDateTimeValue ) )
1149 return (
nType & SvNumFormatType::DATE) || (
nType & SvNumFormatType::TIME);
1159 bool bChangeValid =
true;
1164 OSL_ENSURE( nRow >= 0 || nCol >= 0,
"This cell should not be modified!" );
1171 sal_uInt32 nDummy = 0;
1172 double fDummy = 0.0;
1176 if( !aText.isEmpty() && pSvNumberFormatter &&
1179 bChangeValid =
false;
1184 double fData = rFormatter.
GetValue();
1193 double fValue = 0.0;
1194 bChangeValid =
false;
1219 return bChangeValid;
1228 spHeader->applyChanges();
1241 EditBrowseBox::ColumnResized( nColId );
1251 EditBrowseBox::EndScroll();
1264 for (
auto const& elemHeader : aHeaders)
1268 if( elemHeader.m_xDataSeries.is() &&
1269 ( elemHeader.m_xDataSeries->getPropertyValue(
"Color" ) >>= nColor ))
1270 spHeader->SetColor( nColor );
1271 spHeader->SetChartType( elemHeader.m_xChartType, elemHeader.m_bSwapXAndYAxis );
1272 spHeader->SetSeriesName(
1273 elemHeader.m_xDataSeries->getLabelForRole(
1274 elemHeader.m_xChartType.is() ?
1275 elemHeader.m_xChartType->getRoleOfSequenceForSeriesLabel() :
1276 OUString(
"values-y")));
1277 spHeader->SetRange( elemHeader.m_nStartColumn + 1, elemHeader.m_nEndColumn + 1 );
1278 spHeader->SetGetFocusHdl( aFocusLink );
1279 spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink );
1289 sal_uInt32 nCurrentPos = GetPosPixel().getX();
1290 sal_uInt32 nMaxPos = nCurrentPos + GetOutputSizePixel().getWidth();
1291 sal_uInt32 nStartPos = nCurrentPos;
1310 if( (*aIt)->GetStartColumn() ==
i )
1311 nStartPos = nCurrentPos;
1315 if( (*aIt)->GetEndColumn() ==
i )
1317 if( nStartPos < nMaxPos )
1319 (*aIt)->SetPixelWidth( nCurrentPos - nStartPos );
1326 pWin = pColorWin =
nullptr;
1339 rEdit.SetShowWarningBox( !m_bDataValid );
1345 MakeFieldVisible( GetCurRow(),
static_cast< sal_uInt16
>( rEdit.getStartColumn()) );
1347 m_aCursorMovedHdlLink.Call(
this );
1354 m_apDataBrowserModel->getDataSeriesByColumn( rEdit.getStartColumn() - 1 );
1359 m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType );
1360 if( xChartType.is())
1364 if( xLabeledSeq.is())
1367 if( xIndexReplace.is())
1368 xIndexReplace->replaceByIndex(
#define BROWSER_CURSORDOWN
#define BROWSER_CURSORLEFT
#define BROWSER_CURSORRIGHT
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
void RowRemoved(sal_Int32 nRow, sal_Int32 nNumRows=1, bool bDoPaint=true)
void SetUpdateMode(bool bUpdate)
bool GoToColumnId(sal_uInt16 nColId)
BrowserDataWin & GetDataWindow() const
void InsertDataColumn(sal_uInt16 nItemId, const OUString &rText, tools::Long nSize, HeaderBarItemBits nBits=HeaderBarItemBits::STDSTYLE, sal_uInt16 nPos=HEADERBAR_APPEND)
bool GoToRow(sal_Int32 nRow)
sal_Int32 GetCurRow() const
sal_uInt16 ColCount() const
void InsertHandleColumn(sal_uLong nWidth)
void RowModified(sal_Int32 nRow, sal_uInt16 nColId=BROWSER_INVALIDID)
sal_uInt16 GetCurColumnId() const
bool GetUpdateMode() const
void RowInserted(sal_Int32 nRow, sal_Int32 nNumRows=1, bool bDoPaint=true, bool bKeepSelection=false)
sal_uInt16 GetFirstVisibleColNumber() const
virtual sal_Int32 GetRowCount() const override
sal_uLong GetColumnWidth(sal_uInt16 nColumnId) const
sal_uInt16 GetColumnCount() const override
bool IsClipRegion() const
void SetTextColor(const Color &rColor)
const Color & GetTextColor() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
constexpr tools::Long Y() const
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
reference_type * get() const
std::vector< tDataHeader > tDataHeaderVector
weld::Container * m_pColorsWin
virtual bool IsTabAllowed(bool bForward) const override
tSeriesHeaderContainer m_aSeriesHeaders
virtual ::svt::CellController * GetController(sal_Int32 nRow, sal_uInt16 nCol) override
::svt::CellControllerRef m_rTextEditController
note: m_aTextEditField must precede this member!
virtual bool SaveModified() override
virtual void CursorMoved() override
bool MayMoveDownRows() const
DataBrowser(const css::uno::Reference< css::awt::XWindow > &rParent, weld::Container *pColumns, weld::Container *pColors)
double GetCellNumber(sal_Int32 nRow, sal_uInt16 nColumnId) const
returns the number in the given cell.
bool MayDeleteRow() const
sal_uInt32 GetNumberFormatKey(sal_uInt16 nCol) const
virtual void ColumnResized(sal_uInt16 nColId) override
weld::Container * m_pColumnsWin
::svt::CellControllerRef m_rNumberEditController
note: m_aNumberEditField must precede this member!
OUString GetColString(sal_Int32 nColumnId) const
void RenewSeriesHeaders()
bool CellContainsNumbers(sal_uInt16 nCol) const
bool MayMoveUpRows() const
bool MayMoveRightColumns() const
void SetCursorMovedHdl(const Link< DataBrowser *, void > &rLink)
bool MayDeleteColumn() const
virtual OUString GetCellText(sal_Int32 nRow, sal_uInt16 nColId) const override
GetCellText returns the text at the given position.
virtual void PaintCell(OutputDevice &rDev, const tools::Rectangle &rRect, sal_uInt16 nColumnId) const override
void ImplAdjustHeaderControls()
virtual void Resize() override
virtual bool SeekRow(sal_Int32 nRow) override
bool isDateTimeString(const OUString &aInputString, double &fOutDateTimeValue)
virtual void EndScroll() override
void SetReadOnly(bool bNewState)
virtual void MouseButtonDown(const BrowserMouseEvent &rEvt) override
sal_Int32 m_nSeekRow
the row that is currently painted
Link< DataBrowser *, void > m_aCursorMovedHdlLink
virtual void InitController(::svt::CellControllerRef &rController, sal_Int32 nRow, sal_uInt16 nCol) override
std::shared_ptr< NumberFormatterWrapper > m_spNumberFormatterWrapper
virtual ~DataBrowser() override
std::unique_ptr< DataBrowserModel > m_apDataBrowserModel
bool MayMoveLeftColumns() const
VclPtr< svt::EditControl > m_aTextEditField
rtl::Reference<::chart::ChartModel > m_xChartDoc
virtual void dispose() override
bool EndEditing()
confirms all pending changes to be ready to be closed
void SetDataFromModel(const rtl::Reference<::chart::ChartModel > &xChartDoc)
virtual void CellModified() override
bool MayInsertColumn() const
bool MayInsertRow() const
VclPtr< svt::FormattedControl > m_aNumberEditField
static sal_Int32 getDateTimeInputNumberFormat(const css::uno::Reference< css::util::XNumberFormatsSupplier > &xNumberFormatsSupplier, double fNumber)
virtual void SaveValue()=0
virtual void Dispatch(sal_uInt16 nId)
virtual void DeactivateCell(bool bUpdate=true)
virtual void Resize() override
virtual bool IsModified() const
virtual void dispose() override
virtual void move(weld::Widget *pWidget, weld::Container *pNewParent)=0
virtual void select_region(int nStartPos, int nEndPos)=0
virtual void set_text(const OUString &rText)=0
virtual OUString get_text() const=0
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
constexpr OUStringLiteral HID_SCH_DATA_SERIES_LABEL
#define LINK(Instance, Class, Member)
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XLabeledDataSequence > getDataSequenceByRole(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const OUString &aRole, bool bMatchPrefix=false)
Retrieves the data sequence in the given data source that matches the given role.
IMPL_LINK_NOARG(SeriesHeaderEdit, NameEdited, weld::Entry &, void)
OOO_DLLPUBLIC_CHARTTOOLS bool replaceParamterInString(OUString &rInOutResourceString, std::u16string_view rParamToReplace, std::u16string_view rReplaceWith)
OUString OOO_DLLPUBLIC_CHARTTOOLS SchResId(TranslateId aId)
IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable &, rRadio, void)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_COLUMN
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_PIE
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_SCATTER
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_AREA
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_LINE
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_NET
#define EDIT_UPDATEDATA_TIMEOUT