2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/zformat.hxx>
|
|
|
|
#include <svl/zforlist.hxx>
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
#include "DataBrowser.hxx"
|
|
|
|
#include "DataBrowserModel.hxx"
|
|
|
|
#include "Strings.hrc"
|
|
|
|
#include "ContainerHelper.hxx"
|
|
|
|
#include "DataSeriesHelper.hxx"
|
|
|
|
#include "DiagramHelper.hxx"
|
|
|
|
#include "ChartModelHelper.hxx"
|
2010-02-03 16:18:13 +01:00
|
|
|
#include "CommonConverters.hxx"
|
|
|
|
#include "macros.hxx"
|
2011-01-14 18:11:00 +01:00
|
|
|
#include "NumberFormatterWrapper.hxx"
|
2007-05-22 16:27:33 +00:00
|
|
|
#include "servicenames_charttypes.hxx"
|
|
|
|
#include "ResId.hxx"
|
|
|
|
#include "Bitmaps.hrc"
|
|
|
|
#include "HelpIds.hrc"
|
|
|
|
|
|
|
|
#include <vcl/fixed.hxx>
|
|
|
|
#include <vcl/image.hxx>
|
2014-02-20 08:57:22 +00:00
|
|
|
#include <vcl/layout.hxx>
|
2007-05-22 16:27:33 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2007-05-22 16:27:33 +00:00
|
|
|
#include <rtl/math.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/util/XCloneable.hpp>
|
|
|
|
#include <com/sun/star/chart2/XChartDocument.hpp>
|
|
|
|
#include <com/sun/star/chart2/XChartType.hpp>
|
|
|
|
|
|
|
|
#include <com/sun/star/container/XIndexReplace.hpp>
|
2011-01-14 18:11:00 +01:00
|
|
|
#include <com/sun/star/util/XNumberFormats.hpp>
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
|
|
|
|
2015-04-16 15:41:10 +02:00
|
|
|
/* BrowserMode::COLUMNSELECTION : single cells may be selected rather than only
|
2007-05-22 16:27:33 +00:00
|
|
|
entire rows
|
|
|
|
BROWSER_(H|V)LINES : show horizontal or vertical grid-lines
|
|
|
|
|
|
|
|
BROWSER_AUTO_(H|V)SCROLL : scroll automated horizontally or vertically when
|
|
|
|
cursor is moved beyond the edge of the dialog
|
2015-04-16 15:41:10 +02:00
|
|
|
BrowserMode::HIDESELECT : Do not mark the current row with selection color
|
2007-05-22 16:27:33 +00:00
|
|
|
(usually blue)
|
|
|
|
|
|
|
|
*/
|
|
|
|
#define BROWSER_STANDARD_FLAGS \
|
2015-04-16 15:41:10 +02:00
|
|
|
BrowserMode::COLUMNSELECTION | \
|
|
|
|
BrowserMode::HLINES | BrowserMode::VLINES | \
|
|
|
|
BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL | \
|
|
|
|
BrowserMode::HIDESELECT
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2015-04-16 15:41:10 +02:00
|
|
|
// BrowserMode::HIDECURSOR would prevent flickering in edit fields, but navigating
|
2007-05-22 16:27:33 +00:00
|
|
|
// with shift up/down, and entering non-editable cells would be problematic,
|
|
|
|
// e.g. the first cell, or when being in read-only mode
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
|
|
|
|
using namespace ::svt;
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
sal_Int32 lcl_getRowInData( long nRow )
|
|
|
|
{
|
|
|
|
return static_cast< sal_Int32 >( nRow );
|
|
|
|
}
|
|
|
|
|
2011-01-14 15:18:08 +01:00
|
|
|
sal_Int32 lcl_getColumnInData( sal_uInt16 nCol )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
return static_cast< sal_Int32 >( nCol ) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace impl
|
|
|
|
{
|
|
|
|
|
|
|
|
class SeriesHeaderEdit : public Edit
|
|
|
|
{
|
|
|
|
public:
|
2015-06-08 09:29:35 +01:00
|
|
|
explicit SeriesHeaderEdit( vcl::Window * pParent );
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
void setStartColumn( sal_Int32 nStartColumn );
|
2014-06-09 10:09:42 +02:00
|
|
|
sal_Int32 getStartColumn() const { return m_nStartColumn;}
|
2008-02-18 14:40:38 +00:00
|
|
|
void SetShowWarningBox( bool bShowWarning = true );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
sal_Int32 m_nStartColumn;
|
2008-02-18 14:40:38 +00:00
|
|
|
bool m_bShowWarningBox;
|
2007-05-22 16:27:33 +00:00
|
|
|
};
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SeriesHeaderEdit::SeriesHeaderEdit( vcl::Window * pParent ) :
|
2007-05-22 16:27:33 +00:00
|
|
|
Edit( pParent ),
|
2008-02-18 14:40:38 +00:00
|
|
|
m_nStartColumn( 0 ),
|
|
|
|
m_bShowWarningBox( false )
|
2014-02-20 08:57:22 +00:00
|
|
|
{
|
|
|
|
SetHelpId(HID_SCH_DATA_SERIES_LABEL);
|
|
|
|
}
|
2010-11-16 18:57:44 -08:00
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
void SeriesHeaderEdit::setStartColumn( sal_Int32 nStartColumn )
|
|
|
|
{
|
|
|
|
m_nStartColumn = nStartColumn;
|
|
|
|
}
|
|
|
|
|
2008-02-18 14:40:38 +00:00
|
|
|
void SeriesHeaderEdit::SetShowWarningBox( bool bShowWarning )
|
|
|
|
{
|
|
|
|
m_bShowWarningBox = bShowWarning;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeaderEdit::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
Edit::MouseButtonDown( rMEvt );
|
|
|
|
|
|
|
|
if( m_bShowWarningBox )
|
2015-05-28 21:35:43 +01:00
|
|
|
ScopedVclPtr<WarningBox>::Create(this, WinBits( WB_OK ),
|
|
|
|
SCH_RESSTR(STR_INVALID_NUMBER))->Execute();
|
2008-02-18 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
class SeriesHeader
|
|
|
|
{
|
|
|
|
public:
|
2014-09-23 11:20:40 +02:00
|
|
|
explicit SeriesHeader(vcl::Window * pParent, vcl::Window *pColorParent);
|
2015-05-26 17:53:15 +01:00
|
|
|
~SeriesHeader();
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
void SetColor( const Color & rCol );
|
|
|
|
void SetPos( const Point & rPos );
|
|
|
|
void SetWidth( sal_Int32 nWidth );
|
|
|
|
void SetChartType( const Reference< chart2::XChartType > & xChartType,
|
2010-11-16 11:57:23 +00:00
|
|
|
bool bSwapXAndYAxis );
|
2013-04-01 01:58:31 +05:30
|
|
|
void SetSeriesName( const OUString & rName );
|
2007-05-22 16:27:33 +00:00
|
|
|
void SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol );
|
|
|
|
|
|
|
|
void SetPixelWidth( sal_Int32 nWidth );
|
|
|
|
|
2014-06-09 10:09:42 +02:00
|
|
|
sal_Int32 GetStartColumn() const { return m_nStartCol;}
|
|
|
|
sal_Int32 GetEndColumn() const { return m_nEndCol;}
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2015-03-19 16:02:29 +02:00
|
|
|
static const sal_Int32 nSymbolHeight = 10;
|
|
|
|
static const sal_Int32 nSymbolDistance = 2;
|
|
|
|
|
|
|
|
static sal_Int32 GetRelativeAppFontXPosForNameField() { return nSymbolHeight + nSymbolDistance; }
|
2010-02-03 16:18:13 +01:00
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
void Show();
|
2014-02-20 08:57:22 +00:00
|
|
|
void Hide();
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
/** call this before destroying the class. This notifies the listeners to
|
|
|
|
changes of the edit field for the series name.
|
|
|
|
*/
|
|
|
|
void applyChanges();
|
|
|
|
|
2015-09-24 13:53:17 +02:00
|
|
|
void SetGetFocusHdl( const Link<Control&,void>& rLink );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2015-06-28 18:15:45 +02:00
|
|
|
void SetEditChangedHdl( const Link<SeriesHeaderEdit*,void> & rLink );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
bool HasFocus() const;
|
|
|
|
|
|
|
|
private:
|
2015-03-16 12:17:44 +02:00
|
|
|
VclPtr< FixedImage > m_spSymbol;
|
|
|
|
VclPtr< SeriesHeaderEdit > m_spSeriesName;
|
|
|
|
VclPtr< FixedText > m_spColorBar;
|
2015-03-19 17:19:43 +00:00
|
|
|
VclPtr< OutputDevice> m_pDevice;
|
2015-06-28 18:15:45 +02:00
|
|
|
Link<SeriesHeaderEdit*,void> m_aChangeLink;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
void notifyChanges();
|
|
|
|
DECL_LINK( SeriesNameChanged, void * );
|
|
|
|
DECL_LINK( SeriesNameEdited, void * );
|
|
|
|
|
|
|
|
static Image GetChartTypeImage(
|
|
|
|
const Reference< chart2::XChartType > & xChartType,
|
2010-11-16 18:57:44 -08:00
|
|
|
bool bSwapXAndYAxis
|
|
|
|
);
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
sal_Int32 m_nStartCol, m_nEndCol;
|
|
|
|
sal_Int32 m_nWidth;
|
|
|
|
Point m_aPos;
|
|
|
|
bool m_bSeriesNameChangePending;
|
|
|
|
};
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SeriesHeader::SeriesHeader( vcl::Window * pParent, vcl::Window *pColorParent ) :
|
2015-04-17 22:01:46 +01:00
|
|
|
m_spSymbol( VclPtr<FixedImage>::Create( pParent, WB_NOBORDER )),
|
|
|
|
m_spSeriesName( VclPtr<SeriesHeaderEdit>::Create( pParent )),
|
|
|
|
m_spColorBar( VclPtr<FixedText>::Create( pColorParent, WB_NOBORDER )),
|
2007-05-22 16:27:33 +00:00
|
|
|
m_pDevice( pParent ),
|
|
|
|
m_nStartCol( 0 ),
|
|
|
|
m_nEndCol( 0 ),
|
|
|
|
m_nWidth( 42 ),
|
|
|
|
m_aPos( 0, 22 ),
|
|
|
|
m_bSeriesNameChangePending( false )
|
|
|
|
{
|
|
|
|
m_spSeriesName->EnableUpdateData( 4 * EDIT_UPDATEDATA_TIMEOUT ); // define is in vcl/edit.hxx
|
|
|
|
m_spSeriesName->SetUpdateDataHdl( LINK( this, SeriesHeader, SeriesNameChanged ));
|
|
|
|
m_spSeriesName->SetModifyHdl( LINK( this, SeriesHeader, SeriesNameEdited ));
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
2015-05-26 17:53:15 +01:00
|
|
|
SeriesHeader::~SeriesHeader()
|
|
|
|
{
|
|
|
|
m_spSymbol.disposeAndClear();
|
|
|
|
m_spSeriesName.disposeAndClear();
|
|
|
|
m_spColorBar.disposeAndClear();
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
void SeriesHeader::notifyChanges()
|
|
|
|
{
|
|
|
|
if( m_aChangeLink.IsSet())
|
|
|
|
m_aChangeLink.Call( m_spSeriesName.get());
|
|
|
|
|
|
|
|
m_bSeriesNameChangePending = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::applyChanges()
|
|
|
|
{
|
|
|
|
if( m_bSeriesNameChangePending )
|
|
|
|
{
|
|
|
|
notifyChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::SetColor( const Color & rCol )
|
|
|
|
{
|
|
|
|
m_spColorBar->SetControlBackground( rCol );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::SetPos( const Point & rPos )
|
|
|
|
{
|
|
|
|
m_aPos = rPos;
|
|
|
|
|
|
|
|
// chart type symbol
|
2010-02-03 16:18:13 +01:00
|
|
|
Size aSize( nSymbolHeight, nSymbolHeight );
|
2014-02-20 08:57:22 +00:00
|
|
|
aSize = m_pDevice->LogicToPixel( aSize, MAP_APPFONT );
|
|
|
|
m_spSymbol->set_width_request(aSize.Width());
|
|
|
|
m_spSymbol->set_height_request(aSize.Height());
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
// series name edit field
|
2014-02-20 08:57:22 +00:00
|
|
|
aSize.setWidth(nSymbolDistance);
|
|
|
|
aSize = m_pDevice->LogicToPixel( aSize, MAP_APPFONT );
|
|
|
|
m_spSeriesName->set_margin_left(aSize.Width() + 2);
|
2010-02-03 16:18:13 +01:00
|
|
|
aSize.setWidth( m_nWidth - nSymbolHeight - nSymbolDistance );
|
|
|
|
sal_Int32 nHeight = 12;
|
2007-05-22 16:27:33 +00:00
|
|
|
aSize.setHeight( nHeight );
|
2014-02-20 08:57:22 +00:00
|
|
|
aSize = m_pDevice->LogicToPixel( aSize, MAP_APPFONT );
|
|
|
|
m_spSeriesName->set_width_request(aSize.Width());
|
|
|
|
m_spSeriesName->set_height_request(aSize.Height());
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
// color bar
|
2014-02-20 08:57:22 +00:00
|
|
|
aSize.setWidth(1);
|
|
|
|
aSize = m_pDevice->LogicToPixel( aSize, MAP_APPFONT );
|
|
|
|
m_spColorBar->set_margin_left(aSize.Width() + 2);
|
2007-05-22 16:27:33 +00:00
|
|
|
nHeight = 3;
|
|
|
|
aSize.setWidth( m_nWidth - 1 );
|
|
|
|
aSize.setHeight( nHeight );
|
2014-02-20 08:57:22 +00:00
|
|
|
aSize = m_pDevice->LogicToPixel( aSize, MAP_APPFONT );
|
|
|
|
m_spColorBar->set_width_request(aSize.Width());
|
|
|
|
m_spColorBar->set_height_request(aSize.Height());
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::SetWidth( sal_Int32 nWidth )
|
|
|
|
{
|
|
|
|
m_nWidth = nWidth;
|
|
|
|
SetPos( m_aPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::SetPixelWidth( sal_Int32 nWidth )
|
|
|
|
{
|
|
|
|
SetWidth( m_pDevice->PixelToLogic( Size( nWidth, 0 ), MAP_APPFONT ).getWidth());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::SetChartType(
|
|
|
|
const Reference< chart2::XChartType > & xChartType,
|
2010-11-16 18:57:44 -08:00
|
|
|
bool bSwapXAndYAxis
|
|
|
|
)
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
m_spSymbol->SetImage( GetChartTypeImage( xChartType, bSwapXAndYAxis ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
2013-04-01 01:58:31 +05:30
|
|
|
void SeriesHeader::SetSeriesName( const OUString & rName )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
m_spSeriesName->SetText( rName );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol )
|
|
|
|
{
|
|
|
|
m_nStartCol = nStartCol;
|
|
|
|
m_nEndCol = (nEndCol > nStartCol) ? nEndCol : nStartCol;
|
|
|
|
m_spSeriesName->setStartColumn( nStartCol );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeriesHeader::Show()
|
|
|
|
{
|
|
|
|
m_spSymbol->Show();
|
|
|
|
m_spSeriesName->Show();
|
|
|
|
m_spColorBar->Show();
|
|
|
|
}
|
|
|
|
|
2014-02-20 08:57:22 +00:00
|
|
|
void SeriesHeader::Hide()
|
|
|
|
{
|
|
|
|
m_spSymbol->Hide();
|
|
|
|
m_spSeriesName->Hide();
|
|
|
|
m_spColorBar->Hide();
|
|
|
|
}
|
|
|
|
|
2015-06-28 18:15:45 +02:00
|
|
|
void SeriesHeader::SetEditChangedHdl( const Link<SeriesHeaderEdit*,void> & rLink )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
m_aChangeLink = rLink;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SeriesHeader, SeriesNameChanged)
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
notifyChanges();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SeriesHeader, SeriesNameEdited)
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
m_bSeriesNameChangePending = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-24 13:53:17 +02:00
|
|
|
void SeriesHeader::SetGetFocusHdl( const Link<Control&,void>& rLink )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
m_spSeriesName->SetGetFocusHdl( rLink );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SeriesHeader::HasFocus() const
|
|
|
|
{
|
|
|
|
return m_spSeriesName->HasFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
Image SeriesHeader::GetChartTypeImage(
|
|
|
|
const Reference< chart2::XChartType > & xChartType,
|
2010-11-16 18:57:44 -08:00
|
|
|
bool bSwapXAndYAxis
|
|
|
|
)
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
Image aResult;
|
|
|
|
if( !xChartType.is())
|
|
|
|
return aResult;
|
|
|
|
OUString aChartTypeName( xChartType->getChartType());
|
|
|
|
|
2014-12-18 13:21:05 +01:00
|
|
|
if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_AREA )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_AREA ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
if( bSwapXAndYAxis )
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_BAR ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
else
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_COLUMN ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_LINE ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_SCATTER )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_XY ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_PIE )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_PIE ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_NET
|
|
|
|
|| aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_NET ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
// @todo: correct image for candle-stick type
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_STOCK ) );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2014-12-18 13:21:05 +01:00
|
|
|
else if( aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE )
|
2009-07-02 19:17:43 +00:00
|
|
|
{
|
2010-11-16 18:57:44 -08:00
|
|
|
aResult = Image( SchResId( IMG_TYPE_BUBBLE ) );
|
2009-07-02 19:17:43 +00:00
|
|
|
}
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace impl
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2007-06-11 13:57:46 +00:00
|
|
|
/** returns false, if no header as the focus.
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2007-06-11 13:57:46 +00:00
|
|
|
If a header has the focus, true is returned and the index of the header
|
|
|
|
with focus is set at pIndex if pOutIndex is not 0.
|
|
|
|
*/
|
|
|
|
bool lcl_SeriesHeaderHasFocus(
|
2015-09-14 14:43:18 +01:00
|
|
|
const ::std::vector< std::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader,
|
2007-06-11 13:57:46 +00:00
|
|
|
sal_Int32 * pOutIndex = 0 )
|
|
|
|
{
|
|
|
|
sal_Int32 nIndex = 0;
|
2015-05-26 17:53:15 +01:00
|
|
|
for( auto aIt = rSeriesHeader.begin(); aIt != rSeriesHeader.end(); ++aIt, ++nIndex )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
if( (*aIt)->HasFocus())
|
|
|
|
{
|
2007-06-11 13:57:46 +00:00
|
|
|
if( pOutIndex )
|
|
|
|
*pOutIndex = nIndex;
|
|
|
|
return true;
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-11 13:57:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 lcl_getColumnInDataOrHeader(
|
2015-09-14 14:43:18 +01:00
|
|
|
sal_uInt16 nCol, const ::std::vector< std::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader )
|
2007-06-11 13:57:46 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nColIdx = 0;
|
|
|
|
bool bHeaderHasFocus( lcl_SeriesHeaderHasFocus( rSeriesHeader, &nColIdx ));
|
|
|
|
|
|
|
|
if( bHeaderHasFocus )
|
2011-01-14 15:18:08 +01:00
|
|
|
nColIdx = lcl_getColumnInData( static_cast< sal_uInt16 >( rSeriesHeader[nColIdx]->GetStartColumn()));
|
2007-06-11 13:57:46 +00:00
|
|
|
else
|
2007-05-22 16:27:33 +00:00
|
|
|
nColIdx = lcl_getColumnInData( nCol );
|
|
|
|
|
|
|
|
return nColIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
DataBrowser::DataBrowser( vcl::Window* pParent, WinBits nStyle, bool bLiveUpdate ) :
|
2015-04-17 11:11:23 +02:00
|
|
|
::svt::EditBrowseBox( pParent, EditBrowseBoxFlags::SMART_TAB_TRAVEL | EditBrowseBoxFlags::HANDLE_COLUMN_TEXT, nStyle, BROWSER_STANDARD_FLAGS ),
|
2007-05-22 16:27:33 +00:00
|
|
|
m_nSeekRow( 0 ),
|
|
|
|
m_bIsReadOnly( false ),
|
|
|
|
m_bIsDirty( false ),
|
|
|
|
m_bLiveUpdate( bLiveUpdate ),
|
2008-02-18 14:40:38 +00:00
|
|
|
m_bDataValid( true ),
|
2015-04-17 22:01:46 +01:00
|
|
|
m_aNumberEditField( VclPtr<FormattedField>::Create( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ) ),
|
|
|
|
m_aTextEditField( VclPtr<Edit>::Create( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ) ),
|
2015-01-14 16:16:32 +02:00
|
|
|
m_rNumberEditController( new ::svt::FormattedFieldCellController( m_aNumberEditField.get() )),
|
|
|
|
m_rTextEditController( new ::svt::EditCellController( m_aTextEditField.get() ))
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
double fNan;
|
|
|
|
::rtl::math::setNan( & fNan );
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aNumberEditField->SetDefaultValue( fNan );
|
|
|
|
m_aNumberEditField->TreatAsNumber( true );
|
2007-05-22 16:27:33 +00:00
|
|
|
RenewTable();
|
|
|
|
SetClean();
|
|
|
|
}
|
|
|
|
|
|
|
|
DataBrowser::~DataBrowser()
|
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-14 16:16:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::dispose()
|
|
|
|
{
|
|
|
|
m_aNumberEditField.disposeAndClear();
|
|
|
|
m_aTextEditField.disposeAndClear();
|
|
|
|
::svt::EditBrowseBox::dispose();
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::MayInsertRow() const
|
|
|
|
{
|
2007-06-11 13:57:46 +00:00
|
|
|
return ! IsReadOnly()
|
|
|
|
&& ( !lcl_SeriesHeaderHasFocus( m_aSeriesHeaders ));
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::MayInsertColumn() const
|
|
|
|
{
|
|
|
|
return ! IsReadOnly();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::MayDeleteRow() const
|
|
|
|
{
|
|
|
|
return ! IsReadOnly()
|
2007-06-11 13:57:46 +00:00
|
|
|
&& ( !lcl_SeriesHeaderHasFocus( m_aSeriesHeaders ))
|
2007-05-22 16:27:33 +00:00
|
|
|
&& ( GetCurRow() >= 0 )
|
|
|
|
&& ( GetRowCount() > 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::MayDeleteColumn() const
|
|
|
|
{
|
|
|
|
// if a series header has the focus
|
2007-06-11 13:57:46 +00:00
|
|
|
if( lcl_SeriesHeaderHasFocus( m_aSeriesHeaders ))
|
|
|
|
return true;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
return ! IsReadOnly()
|
|
|
|
&& ( GetCurColumnId() > 1 )
|
|
|
|
&& ( ColCount() > 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::MaySwapRows() const
|
|
|
|
{
|
|
|
|
return ! IsReadOnly()
|
2007-06-11 13:57:46 +00:00
|
|
|
&& ( !lcl_SeriesHeaderHasFocus( m_aSeriesHeaders ))
|
2007-05-22 16:27:33 +00:00
|
|
|
&& ( GetCurRow() >= 0 )
|
|
|
|
&& ( GetCurRow() < GetRowCount() - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::MaySwapColumns() const
|
|
|
|
{
|
|
|
|
// if a series header (except the last one) has the focus
|
|
|
|
{
|
2007-06-11 13:57:46 +00:00
|
|
|
sal_Int32 nColIndex(0);
|
|
|
|
if( lcl_SeriesHeaderHasFocus( m_aSeriesHeaders, &nColIndex ))
|
|
|
|
return (static_cast< sal_uInt32 >( nColIndex ) < (m_aSeriesHeaders.size() - 1));
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
2010-01-28 10:52:28 +01:00
|
|
|
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
|
2007-05-22 16:27:33 +00:00
|
|
|
return ! IsReadOnly()
|
2010-01-28 10:52:28 +01:00
|
|
|
&& ( nColIdx > 0 )
|
|
|
|
&& ( nColIdx < ColCount()-2 )
|
|
|
|
&& m_apDataBrowserModel.get()
|
|
|
|
&& !m_apDataBrowserModel->isCategoriesColumn( nColIdx );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::clearHeaders()
|
|
|
|
{
|
2015-09-27 19:21:35 -04:00
|
|
|
for( const auto& spHeader : m_aSeriesHeaders )
|
|
|
|
spHeader->applyChanges();
|
2007-05-22 16:27:33 +00:00
|
|
|
m_aSeriesHeaders.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::RenewTable()
|
|
|
|
{
|
|
|
|
if( ! m_apDataBrowserModel.get())
|
|
|
|
return;
|
|
|
|
|
|
|
|
long nOldRow = GetCurRow();
|
2011-01-14 15:18:08 +01:00
|
|
|
sal_uInt16 nOldColId = GetCurColumnId();
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2014-04-15 15:17:13 +02:00
|
|
|
bool bLastUpdateMode = GetUpdateMode();
|
2014-03-19 14:11:04 +02:00
|
|
|
SetUpdateMode( false );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
|
|
|
DeactivateCell();
|
|
|
|
|
|
|
|
RemoveColumns();
|
|
|
|
RowRemoved( 1, GetRowCount() );
|
|
|
|
|
|
|
|
// for row numbers
|
|
|
|
InsertHandleColumn( static_cast< sal_uInt16 >(
|
|
|
|
GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() ));
|
|
|
|
|
2012-04-29 23:36:57 +01:00
|
|
|
OUString aDefaultSeriesName(SCH_RESSTR(STR_COLUMN_LABEL));
|
2013-08-21 15:07:31 +02:00
|
|
|
replaceParamterInString( aDefaultSeriesName, "%COLUMNNUMBER", OUString::number( 24 ) );
|
2010-02-03 16:18:13 +01:00
|
|
|
sal_Int32 nColumnWidth = GetDataWindow().GetTextWidth( aDefaultSeriesName )
|
|
|
|
+ GetDataWindow().LogicToPixel( Point( 4 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0 ), MAP_APPFONT ).X();
|
2007-05-22 16:27:33 +00:00
|
|
|
sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount();
|
2007-07-25 07:30:12 +00:00
|
|
|
// nRowCount is a member of a base class
|
|
|
|
sal_Int32 nRowCountLocal = m_apDataBrowserModel->getMaxRowCount();
|
2007-05-22 16:27:33 +00:00
|
|
|
for( sal_Int32 nColIdx=1; nColIdx<=nColumnCount; ++nColIdx )
|
|
|
|
{
|
|
|
|
InsertDataColumn( static_cast< sal_uInt16 >( nColIdx ), GetColString( nColIdx ), nColumnWidth );
|
|
|
|
}
|
|
|
|
|
2007-07-25 07:30:12 +00:00
|
|
|
RowInserted( 1, nRowCountLocal );
|
2007-05-22 16:27:33 +00:00
|
|
|
GoToRow( ::std::min( nOldRow, GetRowCount() - 1 ));
|
2011-01-14 15:18:08 +01:00
|
|
|
GoToColumnId( ::std::min( nOldColId, static_cast< sal_uInt16 >( ColCount() - 1 )));
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2014-02-20 08:57:22 +00:00
|
|
|
Dialog* pDialog = GetParentDialog();
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWin = pDialog->get<VclContainer>("columns");
|
|
|
|
vcl::Window* pColorWin = pDialog->get<VclContainer>("colorcolumns");
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
// fill series headers
|
|
|
|
clearHeaders();
|
2008-06-16 11:46:47 +00:00
|
|
|
const DataBrowserModel::tDataHeaderVector& aHeaders( m_apDataBrowserModel->getDataHeaders());
|
2015-09-24 13:53:17 +02:00
|
|
|
Link<Control&,void> aFocusLink( LINK( this, DataBrowser, SeriesHeaderGotFocus ));
|
2015-06-28 18:15:45 +02:00
|
|
|
Link<impl::SeriesHeaderEdit*,void> aSeriesHeaderChangedLink( LINK( this, DataBrowser, SeriesHeaderChanged ));
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
for( DataBrowserModel::tDataHeaderVector::const_iterator aIt( aHeaders.begin());
|
|
|
|
aIt != aHeaders.end(); ++aIt )
|
|
|
|
{
|
2015-09-14 14:43:18 +01:00
|
|
|
std::shared_ptr< impl::SeriesHeader > spHeader( new impl::SeriesHeader( pWin, pColorWin ));
|
2007-05-22 16:27:33 +00:00
|
|
|
Reference< beans::XPropertySet > xSeriesProp( aIt->m_xDataSeries, uno::UNO_QUERY );
|
|
|
|
sal_Int32 nColor = 0;
|
|
|
|
// @todo: Set "DraftColor", i.e. interpolated colors for gradients, bitmaps, etc.
|
|
|
|
if( xSeriesProp.is() &&
|
2012-10-06 22:23:08 -03:00
|
|
|
( xSeriesProp->getPropertyValue( "Color" ) >>= nColor ))
|
2007-05-22 16:27:33 +00:00
|
|
|
spHeader->SetColor( Color( nColor ));
|
2010-11-16 11:57:23 +00:00
|
|
|
spHeader->SetChartType( aIt->m_xChartType, aIt->m_bSwapXAndYAxis );
|
2007-05-22 16:27:33 +00:00
|
|
|
spHeader->SetSeriesName(
|
2013-04-01 01:58:31 +05:30
|
|
|
OUString( DataSeriesHelper::getDataSeriesLabel(
|
2007-05-22 16:27:33 +00:00
|
|
|
aIt->m_xDataSeries,
|
|
|
|
(aIt->m_xChartType.is() ?
|
|
|
|
aIt->m_xChartType->getRoleOfSequenceForSeriesLabel() :
|
2012-10-06 22:23:08 -03:00
|
|
|
OUString("values-y")))));
|
2007-05-22 16:27:33 +00:00
|
|
|
// index is 1-based, as 0 is for the column that contains the row-numbers
|
|
|
|
spHeader->SetRange( aIt->m_nStartColumn + 1, aIt->m_nEndColumn + 1 );
|
|
|
|
spHeader->SetGetFocusHdl( aFocusLink );
|
|
|
|
spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink );
|
|
|
|
m_aSeriesHeaders.push_back( spHeader );
|
|
|
|
}
|
|
|
|
|
|
|
|
ImplAdjustHeaderControls();
|
|
|
|
SetDirty();
|
|
|
|
SetUpdateMode( bLastUpdateMode );
|
|
|
|
ActivateCell();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2013-04-01 01:58:31 +05:30
|
|
|
OUString DataBrowser::GetColString( sal_Int32 nColumnId ) const
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
OSL_ASSERT( m_apDataBrowserModel.get());
|
|
|
|
if( nColumnId > 0 )
|
2013-04-01 01:58:31 +05:30
|
|
|
return OUString( m_apDataBrowserModel->getRoleOfColumn( static_cast< sal_Int32 >( nColumnId ) - 1 ));
|
|
|
|
return OUString();
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
2015-04-22 15:17:23 +02:00
|
|
|
OUString DataBrowser::GetRowString( sal_Int32 nRow )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2013-08-21 15:07:31 +02:00
|
|
|
return OUString::number(nRow + 1);
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 13:52:33 +01:00
|
|
|
OUString DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2013-04-01 01:58:31 +05:30
|
|
|
OUString aResult;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
if( nColumnId == 0 )
|
|
|
|
{
|
|
|
|
aResult = GetRowString( static_cast< sal_Int32 >( nRow ));
|
|
|
|
}
|
2015-02-14 00:31:54 +02:00
|
|
|
else if( nRow >= 0 && m_apDataBrowserModel.get())
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nColIndex = static_cast< sal_Int32 >( nColumnId ) - 1;
|
|
|
|
|
|
|
|
if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::NUMBER )
|
|
|
|
{
|
|
|
|
double fData( m_apDataBrowserModel->getCellNumber( nColIndex, nRow ));
|
|
|
|
sal_Int32 nLabelColor;
|
|
|
|
|
|
|
|
if( ! ::rtl::math::isNan( fData ) &&
|
|
|
|
m_spNumberFormatterWrapper.get() )
|
2015-02-14 00:31:54 +02:00
|
|
|
{
|
|
|
|
bool bColorChanged = false;
|
2013-09-07 22:31:57 +02:00
|
|
|
aResult = m_spNumberFormatterWrapper->getFormattedString(
|
2007-05-22 16:27:33 +00:00
|
|
|
GetNumberFormatKey( nRow, nColumnId ),
|
2013-09-07 22:31:57 +02:00
|
|
|
fData, nLabelColor, bColorChanged );
|
2015-02-14 00:31:54 +02:00
|
|
|
}
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
2011-01-14 18:11:00 +01:00
|
|
|
else if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXTORDATE )
|
|
|
|
{
|
|
|
|
uno::Any aAny = m_apDataBrowserModel->getCellAny( nColIndex, nRow );
|
|
|
|
OUString aText;
|
|
|
|
double fDouble=0.0;
|
|
|
|
if( aAny>>=aText )
|
|
|
|
aResult = aText;
|
|
|
|
else if( aAny>>=fDouble )
|
|
|
|
{
|
|
|
|
if( ! ::rtl::math::isNan( fDouble ) && m_spNumberFormatterWrapper.get() )
|
2015-02-14 00:31:54 +02:00
|
|
|
{
|
2015-08-10 15:10:09 +02:00
|
|
|
// If a numberformat was available here we could directly
|
|
|
|
// obtain the corresponding edit format in
|
|
|
|
// getDateTimeInputNumberFormat() instead of doing the
|
|
|
|
// guess work.
|
|
|
|
sal_Int32 nNumberFormat = DiagramHelper::getDateTimeInputNumberFormat(
|
|
|
|
Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY), fDouble );
|
|
|
|
sal_Int32 nLabelColor;
|
2015-02-14 00:31:54 +02:00
|
|
|
bool bColorChanged = false;
|
2013-09-07 22:31:57 +02:00
|
|
|
aResult = m_spNumberFormatterWrapper->getFormattedString(
|
2015-08-10 15:10:09 +02:00
|
|
|
nNumberFormat, fDouble, nLabelColor, bColorChanged );
|
2015-02-14 00:31:54 +02:00
|
|
|
}
|
2011-01-14 18:11:00 +01:00
|
|
|
}
|
|
|
|
}
|
2007-05-22 16:27:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ASSERT( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXT );
|
|
|
|
aResult = m_apDataBrowserModel->getCellText( nColIndex, nRow );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
2011-01-14 15:18:08 +01:00
|
|
|
double DataBrowser::GetCellNumber( long nRow, sal_uInt16 nColumnId ) const
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
double fResult;
|
|
|
|
::rtl::math::setNan( & fResult );
|
|
|
|
|
|
|
|
if(( nColumnId >= 1 ) && ( nRow >= 0 ) &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
2008-03-06 15:23:30 +00:00
|
|
|
fResult = m_apDataBrowserModel->getCellNumber(
|
|
|
|
static_cast< sal_Int32 >( nColumnId ) - 1, nRow );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return fResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::Resize()
|
|
|
|
{
|
2014-04-15 15:17:13 +02:00
|
|
|
bool bLastUpdateMode = GetUpdateMode();
|
2014-03-19 14:11:04 +02:00
|
|
|
SetUpdateMode( false );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
::svt::EditBrowseBox::Resize();
|
|
|
|
ImplAdjustHeaderControls();
|
|
|
|
SetUpdateMode( bLastUpdateMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::SetReadOnly( bool bNewState )
|
|
|
|
{
|
|
|
|
bool bResult = m_bIsReadOnly;
|
|
|
|
|
|
|
|
if( m_bIsReadOnly != bNewState )
|
|
|
|
{
|
|
|
|
m_bIsReadOnly = bNewState;
|
|
|
|
Invalidate();
|
|
|
|
DeactivateCell();
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::SetClean()
|
|
|
|
{
|
|
|
|
m_bIsDirty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::SetDirty()
|
|
|
|
{
|
|
|
|
if( !m_bLiveUpdate )
|
|
|
|
m_bIsDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::CursorMoved()
|
|
|
|
{
|
|
|
|
EditBrowseBox::CursorMoved();
|
|
|
|
|
|
|
|
if( GetUpdateMode() && m_aCursorMovedHdlLink.IsSet())
|
|
|
|
m_aCursorMovedHdlLink.Call( this );
|
|
|
|
}
|
|
|
|
|
2008-02-18 14:40:38 +00:00
|
|
|
void DataBrowser::MouseButtonDown( const BrowserMouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
if( !m_bDataValid )
|
|
|
|
ShowWarningBox();
|
|
|
|
else
|
|
|
|
EditBrowseBox::MouseButtonDown( rEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::ShowWarningBox()
|
|
|
|
{
|
2015-05-28 21:35:43 +01:00
|
|
|
ScopedVclPtr<WarningBox>::Create(this, WinBits( WB_OK ),
|
|
|
|
SCH_RESSTR(STR_INVALID_NUMBER))->Execute();
|
2008-02-18 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::ShowQueryBox()
|
|
|
|
{
|
2015-04-17 22:01:46 +01:00
|
|
|
ScopedVclPtrInstance<QueryBox> pQueryBox(this, WB_YES_NO, SCH_RESSTR(STR_DATA_EDITOR_INCORRECT_INPUT));
|
2008-02-18 14:40:38 +00:00
|
|
|
|
2015-04-17 22:01:46 +01:00
|
|
|
return pQueryBox->Execute() == RET_YES;
|
2008-02-18 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::IsDataValid()
|
|
|
|
{
|
|
|
|
bool bValid = true;
|
|
|
|
const sal_Int32 nRow = lcl_getRowInData( GetCurRow());
|
|
|
|
const sal_Int32 nCol = lcl_getColumnInData( GetCurColumnId());
|
|
|
|
|
|
|
|
if( m_apDataBrowserModel->getCellType( nCol, nRow ) == DataBrowserModel::NUMBER )
|
|
|
|
{
|
|
|
|
sal_uInt32 nDummy = 0;
|
|
|
|
double fDummy = 0.0;
|
2015-01-14 16:16:32 +02:00
|
|
|
OUString aText( m_aNumberEditField->GetText());
|
2008-02-18 14:40:38 +00:00
|
|
|
|
2013-04-01 01:58:31 +05:30
|
|
|
if( !aText.isEmpty() &&
|
2008-02-18 14:40:38 +00:00
|
|
|
m_spNumberFormatterWrapper.get() &&
|
|
|
|
m_spNumberFormatterWrapper->getSvNumberFormatter() &&
|
|
|
|
! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat(
|
|
|
|
aText, nDummy, fDummy ))
|
|
|
|
{
|
|
|
|
bValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bValid;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
void DataBrowser::CellModified()
|
|
|
|
{
|
2008-02-18 14:40:38 +00:00
|
|
|
m_bDataValid = IsDataValid();
|
2007-05-22 16:27:33 +00:00
|
|
|
SetDirty();
|
|
|
|
if( m_aCellModifiedLink.IsSet())
|
|
|
|
m_aCursorMovedHdlLink.Call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::SetDataFromModel(
|
|
|
|
const Reference< chart2::XChartDocument > & xChartDoc,
|
|
|
|
const Reference< uno::XComponentContext > & xContext )
|
|
|
|
{
|
|
|
|
if( m_bLiveUpdate )
|
|
|
|
{
|
|
|
|
m_xChartDoc.set( xChartDoc );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference< util::XCloneable > xCloneable( xChartDoc, uno::UNO_QUERY );
|
|
|
|
if( xCloneable.is())
|
|
|
|
m_xChartDoc.set( xCloneable->createClone(), uno::UNO_QUERY );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_apDataBrowserModel.reset( new DataBrowserModel( m_xChartDoc, xContext ));
|
|
|
|
m_spNumberFormatterWrapper.reset(
|
|
|
|
new NumberFormatterWrapper(
|
|
|
|
Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY )));
|
|
|
|
|
2011-01-12 10:50:47 +01:00
|
|
|
if( m_spNumberFormatterWrapper.get() )
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aNumberEditField->SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() );
|
2011-01-12 10:50:47 +01:00
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
RenewTable();
|
|
|
|
|
|
|
|
const sal_Int32 nColCnt = m_apDataBrowserModel->getColumnCount();
|
|
|
|
const sal_Int32 nRowCnt = m_apDataBrowserModel->getMaxRowCount();
|
|
|
|
if( nRowCnt && nColCnt )
|
|
|
|
{
|
|
|
|
GoToRow( 0 );
|
|
|
|
GoToColumnId( 1 );
|
|
|
|
}
|
|
|
|
SetClean();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::InsertColumn()
|
|
|
|
{
|
|
|
|
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
|
|
|
|
|
|
|
|
if( nColIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
2010-01-28 14:24:55 +01:00
|
|
|
m_apDataBrowserModel->insertDataSeries( nColIdx );
|
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::InsertTextColumn()
|
|
|
|
{
|
|
|
|
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
|
|
|
|
|
|
|
|
if( nColIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
|
|
|
m_apDataBrowserModel->insertComplexCategoryLevel( nColIdx );
|
2007-05-22 16:27:33 +00:00
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::RemoveColumn()
|
|
|
|
{
|
|
|
|
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
|
|
|
|
|
|
|
|
if( nColIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
2008-02-18 14:40:38 +00:00
|
|
|
m_bDataValid = true;
|
2010-01-28 10:52:28 +01:00
|
|
|
m_apDataBrowserModel->removeDataSeriesOrComplexCategoryLevel( nColIdx );
|
2007-05-22 16:27:33 +00:00
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::InsertRow()
|
|
|
|
{
|
|
|
|
sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow());
|
|
|
|
|
|
|
|
if( nRowIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
|
|
|
m_apDataBrowserModel->insertDataPointForAllSeries( nRowIdx );
|
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::RemoveRow()
|
|
|
|
{
|
|
|
|
sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow());
|
|
|
|
|
|
|
|
if( nRowIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
2008-02-18 14:40:38 +00:00
|
|
|
m_bDataValid = true;
|
2007-05-22 16:27:33 +00:00
|
|
|
m_apDataBrowserModel->removeDataPointForAllSeries( nRowIdx );
|
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::SwapColumn()
|
|
|
|
{
|
|
|
|
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
|
|
|
|
|
|
|
|
if( nColIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
|
|
|
m_apDataBrowserModel->swapDataSeries( nColIdx );
|
|
|
|
|
|
|
|
// keep cursor in swapped column
|
|
|
|
if( GetCurColumnId() < ColCount() - 1 )
|
|
|
|
{
|
|
|
|
Dispatch( BROWSER_CURSORRIGHT );
|
|
|
|
}
|
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::SwapRow()
|
|
|
|
{
|
|
|
|
sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow());
|
|
|
|
|
|
|
|
if( nRowIdx >= 0 &&
|
|
|
|
m_apDataBrowserModel.get())
|
|
|
|
{
|
|
|
|
// save changes made to edit-field
|
|
|
|
if( IsModified() )
|
|
|
|
SaveModified();
|
|
|
|
|
|
|
|
m_apDataBrowserModel->swapDataPointForAllSeries( nRowIdx );
|
|
|
|
|
|
|
|
// keep cursor in swapped row
|
|
|
|
if( GetCurRow() < GetRowCount() - 1 )
|
|
|
|
{
|
|
|
|
Dispatch( BROWSER_CURSORDOWN );
|
|
|
|
}
|
|
|
|
RenewTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-28 18:15:45 +02:00
|
|
|
void DataBrowser::SetCursorMovedHdl( const Link<DataBrowser*,void>& rLink )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
m_aCursorMovedHdlLink = rLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementations for ::svt::EditBrowseBox (pure virtual methods)
|
|
|
|
void DataBrowser::PaintCell(
|
|
|
|
OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
|
|
|
|
{
|
|
|
|
Point aPos( rRect.TopLeft());
|
|
|
|
aPos.X() += 1;
|
|
|
|
|
2013-09-07 22:31:57 +02:00
|
|
|
OUString aText = GetCellText( m_nSeekRow, nColumnId );
|
2007-05-22 16:27:33 +00:00
|
|
|
Size TxtSize( GetDataWindow().GetTextWidth( aText ), GetDataWindow().GetTextHeight());
|
|
|
|
|
|
|
|
// clipping
|
|
|
|
if( aPos.X() < rRect.Right() || aPos.X() + TxtSize.Width() > rRect.Right() ||
|
|
|
|
aPos.Y() < rRect.Top() || aPos.Y() + TxtSize.Height() > rRect.Bottom())
|
2014-09-27 14:52:40 +02:00
|
|
|
rDev.SetClipRegion(vcl::Region(rRect));
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
// allow for a disabled control ...
|
2014-04-15 15:17:13 +02:00
|
|
|
bool bEnabled = IsEnabled();
|
2007-05-22 16:27:33 +00:00
|
|
|
Color aOriginalColor = rDev.GetTextColor();
|
|
|
|
if( ! bEnabled )
|
|
|
|
rDev.SetTextColor( GetSettings().GetStyleSettings().GetDisableColor() );
|
|
|
|
|
|
|
|
// draw the text
|
|
|
|
rDev.DrawText( aPos, aText );
|
|
|
|
|
|
|
|
// reset the color (if necessary)
|
|
|
|
if( ! bEnabled )
|
|
|
|
rDev.SetTextColor( aOriginalColor );
|
|
|
|
|
|
|
|
if( rDev.IsClipRegion())
|
|
|
|
rDev.SetClipRegion();
|
|
|
|
}
|
|
|
|
|
2014-03-19 14:11:04 +02:00
|
|
|
bool DataBrowser::SeekRow( long nRow )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
if( ! EditBrowseBox::SeekRow( nRow ))
|
2014-03-19 14:11:04 +02:00
|
|
|
return false;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
if( nRow < 0 )
|
|
|
|
m_nSeekRow = - 1;
|
|
|
|
else
|
|
|
|
m_nSeekRow = nRow;
|
|
|
|
|
2014-03-19 14:11:04 +02:00
|
|
|
return true;
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 11:14:54 +02:00
|
|
|
bool DataBrowser::IsTabAllowed( bool bForward ) const
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
long nRow = GetCurRow();
|
|
|
|
long nCol = GetCurColumnId();
|
|
|
|
|
|
|
|
// column 0 is header-column
|
|
|
|
long nBadCol = bForward
|
|
|
|
? GetColumnCount() - 1
|
|
|
|
: 1;
|
|
|
|
long nBadRow = bForward
|
|
|
|
? GetRowCount() - 1
|
|
|
|
: 0;
|
|
|
|
|
2008-02-18 14:40:38 +00:00
|
|
|
if( !m_bDataValid )
|
|
|
|
{
|
|
|
|
const_cast< DataBrowser* >( this )->ShowWarningBox();
|
2014-03-20 11:14:54 +02:00
|
|
|
return false;
|
2008-02-18 14:40:38 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
return ( nRow != nBadRow ||
|
|
|
|
nCol != nBadCol );
|
|
|
|
}
|
|
|
|
|
|
|
|
::svt::CellController* DataBrowser::GetController( long nRow, sal_uInt16 nCol )
|
|
|
|
{
|
|
|
|
if( m_bIsReadOnly )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( CellContainsNumbers( nRow, nCol ))
|
|
|
|
{
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aNumberEditField->UseInputStringForFormatting();
|
|
|
|
m_aNumberEditField->SetFormatKey( GetNumberFormatKey( nRow, nCol ));
|
2007-05-22 16:27:33 +00:00
|
|
|
return m_rNumberEditController;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_rTextEditController;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::InitController(
|
|
|
|
::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol )
|
|
|
|
{
|
|
|
|
if( rController == m_rTextEditController )
|
|
|
|
{
|
2013-04-01 01:58:31 +05:30
|
|
|
OUString aText( GetCellText( nRow, nCol ) );
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aTextEditField->SetText( aText );
|
|
|
|
m_aTextEditField->SetSelection( Selection( 0, aText.getLength() ));
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
else if( rController == m_rNumberEditController )
|
|
|
|
{
|
|
|
|
// treat invalid and empty text as Nan
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aNumberEditField->EnableNotANumber( true );
|
2007-05-22 16:27:33 +00:00
|
|
|
if( ::rtl::math::isNan( GetCellNumber( nRow, nCol )))
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aNumberEditField->SetTextValue( OUString());
|
2007-05-22 16:27:33 +00:00
|
|
|
else
|
2015-01-14 16:16:32 +02:00
|
|
|
m_aNumberEditField->SetValue( GetCellNumber( nRow, nCol ) );
|
|
|
|
OUString aText( m_aNumberEditField->GetText());
|
|
|
|
m_aNumberEditField->SetSelection( Selection( 0, aText.getLength()));
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL( "Invalid Controller" );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DataBrowser::CellContainsNumbers( sal_Int32 nRow, sal_uInt16 nCol ) const
|
|
|
|
{
|
|
|
|
if( ! m_apDataBrowserModel.get())
|
|
|
|
return false;
|
|
|
|
return (m_apDataBrowserModel->getCellType( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow )) ==
|
|
|
|
DataBrowserModel::NUMBER);
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_uInt32 DataBrowser::GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const
|
|
|
|
{
|
|
|
|
if( ! m_apDataBrowserModel.get())
|
|
|
|
return 0;
|
|
|
|
return m_apDataBrowserModel->getNumberFormatKey( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow ));
|
|
|
|
}
|
|
|
|
|
2015-08-10 15:10:09 +02:00
|
|
|
bool DataBrowser::isDateTimeString( const OUString& aInputString, double& fOutDateTimeValue )
|
2011-01-14 18:11:00 +01:00
|
|
|
{
|
|
|
|
sal_uInt32 nNumberFormat=0;
|
|
|
|
SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0;
|
2015-08-10 15:10:09 +02:00
|
|
|
if( !aInputString.isEmpty() && pSvNumberFormatter && pSvNumberFormatter->IsNumberFormat( aInputString, nNumberFormat, fOutDateTimeValue ) )
|
2011-01-14 18:11:00 +01:00
|
|
|
{
|
2015-08-10 15:10:09 +02:00
|
|
|
short nType = pSvNumberFormatter->GetType( nNumberFormat);
|
|
|
|
return (nType & util::NumberFormat::DATE) || (nType & util::NumberFormat::TIME);
|
2011-01-14 18:11:00 +01:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-20 11:14:54 +02:00
|
|
|
bool DataBrowser::SaveModified()
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
if( ! IsModified() )
|
2014-03-20 11:14:54 +02:00
|
|
|
return true;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2014-03-20 11:14:54 +02:00
|
|
|
bool bChangeValid = true;
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
const sal_Int32 nRow = lcl_getRowInData( GetCurRow());
|
|
|
|
const sal_Int32 nCol = lcl_getColumnInData( GetCurColumnId());
|
|
|
|
|
2011-05-21 10:11:48 +02:00
|
|
|
OSL_ENSURE( nRow >= 0 || nCol >= 0, "This cell should not be modified!" );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
2011-01-14 18:11:00 +01:00
|
|
|
SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0;
|
2007-05-22 16:27:33 +00:00
|
|
|
switch( m_apDataBrowserModel->getCellType( nCol, nRow ))
|
|
|
|
{
|
|
|
|
case DataBrowserModel::NUMBER:
|
|
|
|
{
|
|
|
|
sal_uInt32 nDummy = 0;
|
|
|
|
double fDummy = 0.0;
|
2015-01-14 16:16:32 +02:00
|
|
|
OUString aText( m_aNumberEditField->GetText());
|
2007-05-22 16:27:33 +00:00
|
|
|
// an empty string is valid, if no numberformatter exists, all
|
|
|
|
// values are treated as valid
|
2013-04-01 01:58:31 +05:30
|
|
|
if( !aText.isEmpty() && pSvNumberFormatter &&
|
2011-01-14 18:11:00 +01:00
|
|
|
! pSvNumberFormatter->IsNumberFormat( aText, nDummy, fDummy ) )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2014-03-20 11:14:54 +02:00
|
|
|
bChangeValid = false;
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-14 16:16:32 +02:00
|
|
|
double fData = m_aNumberEditField->GetValue();
|
2007-05-22 16:27:33 +00:00
|
|
|
bChangeValid = m_apDataBrowserModel->setCellNumber( nCol, nRow, fData );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-01-14 18:11:00 +01:00
|
|
|
case DataBrowserModel::TEXTORDATE:
|
|
|
|
{
|
2015-01-14 16:16:32 +02:00
|
|
|
OUString aText( m_aTextEditField->GetText() );
|
2015-08-10 15:10:09 +02:00
|
|
|
double fValue = 0.0;
|
2014-03-20 11:14:54 +02:00
|
|
|
bChangeValid = false;
|
2015-08-10 15:10:09 +02:00
|
|
|
if( isDateTimeString( aText, fValue ) )
|
|
|
|
bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( fValue ) );
|
2011-01-14 18:11:00 +01:00
|
|
|
if(!bChangeValid)
|
|
|
|
bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( aText ) );
|
|
|
|
}
|
|
|
|
break;
|
2007-05-22 16:27:33 +00:00
|
|
|
case DataBrowserModel::TEXT:
|
|
|
|
{
|
2015-01-14 16:16:32 +02:00
|
|
|
OUString aText( m_aTextEditField->GetText());
|
2007-05-22 16:27:33 +00:00
|
|
|
bChangeValid = m_apDataBrowserModel->setCellText( nCol, nRow, aText );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// the first valid change changes this to true
|
|
|
|
if( bChangeValid )
|
|
|
|
{
|
|
|
|
RowModified( GetCurRow(), GetCurColumnId());
|
|
|
|
::svt::CellController* pCtrl = GetController( GetCurRow(), GetCurColumnId());
|
|
|
|
if( pCtrl )
|
|
|
|
pCtrl->ClearModified();
|
|
|
|
SetDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
return bChangeValid;
|
|
|
|
}
|
|
|
|
|
2008-02-18 14:40:38 +00:00
|
|
|
bool DataBrowser::EndEditing()
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2014-06-27 11:31:06 -04:00
|
|
|
SaveModified();
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
// apply changes made to series headers
|
2015-09-27 19:21:35 -04:00
|
|
|
for( const auto& spHeader : m_aSeriesHeaders )
|
|
|
|
spHeader->applyChanges();
|
2008-02-18 14:40:38 +00:00
|
|
|
|
|
|
|
if( m_bDataValid )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return ShowQueryBox();
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const
|
|
|
|
{
|
|
|
|
return GetFirstVisibleColNumber();
|
|
|
|
}
|
|
|
|
|
2011-01-14 15:18:08 +01:00
|
|
|
void DataBrowser::ColumnResized( sal_uInt16 nColId )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2014-04-15 15:17:13 +02:00
|
|
|
bool bLastUpdateMode = GetUpdateMode();
|
2014-03-19 14:11:04 +02:00
|
|
|
SetUpdateMode( false );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
EditBrowseBox::ColumnResized( nColId );
|
|
|
|
ImplAdjustHeaderControls();
|
|
|
|
SetUpdateMode( bLastUpdateMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DataBrowser::EndScroll()
|
|
|
|
{
|
2014-04-15 15:17:13 +02:00
|
|
|
bool bLastUpdateMode = GetUpdateMode();
|
2014-03-19 14:11:04 +02:00
|
|
|
SetUpdateMode( false );
|
2007-05-22 16:27:33 +00:00
|
|
|
|
|
|
|
EditBrowseBox::EndScroll();
|
2008-07-02 10:58:06 +00:00
|
|
|
RenewSeriesHeaders();
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
SetUpdateMode( bLastUpdateMode );
|
|
|
|
}
|
|
|
|
|
2008-07-02 10:58:06 +00:00
|
|
|
void DataBrowser::RenewSeriesHeaders()
|
|
|
|
{
|
2014-02-20 08:57:22 +00:00
|
|
|
Dialog* pDialog = GetParentDialog();
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWin = pDialog->get<VclContainer>("columns");
|
|
|
|
vcl::Window* pColorWin = pDialog->get<VclContainer>("colorcolumns");
|
2008-07-02 10:58:06 +00:00
|
|
|
|
|
|
|
clearHeaders();
|
|
|
|
DataBrowserModel::tDataHeaderVector aHeaders( m_apDataBrowserModel->getDataHeaders());
|
2015-09-24 13:53:17 +02:00
|
|
|
Link<Control&,void> aFocusLink( LINK( this, DataBrowser, SeriesHeaderGotFocus ));
|
2015-06-28 18:15:45 +02:00
|
|
|
Link<impl::SeriesHeaderEdit*,void> aSeriesHeaderChangedLink( LINK( this, DataBrowser, SeriesHeaderChanged ));
|
2008-07-02 10:58:06 +00:00
|
|
|
|
|
|
|
for( DataBrowserModel::tDataHeaderVector::const_iterator aIt( aHeaders.begin());
|
|
|
|
aIt != aHeaders.end(); ++aIt )
|
|
|
|
{
|
2015-09-14 14:43:18 +01:00
|
|
|
std::shared_ptr< impl::SeriesHeader > spHeader( new impl::SeriesHeader( pWin, pColorWin ));
|
2008-07-02 10:58:06 +00:00
|
|
|
Reference< beans::XPropertySet > xSeriesProp( aIt->m_xDataSeries, uno::UNO_QUERY );
|
|
|
|
sal_Int32 nColor = 0;
|
|
|
|
if( xSeriesProp.is() &&
|
2012-10-06 22:23:08 -03:00
|
|
|
( xSeriesProp->getPropertyValue( "Color" ) >>= nColor ))
|
2008-07-02 10:58:06 +00:00
|
|
|
spHeader->SetColor( Color( nColor ));
|
2010-11-16 11:57:23 +00:00
|
|
|
spHeader->SetChartType( aIt->m_xChartType, aIt->m_bSwapXAndYAxis );
|
2008-07-02 10:58:06 +00:00
|
|
|
spHeader->SetSeriesName(
|
2013-09-07 22:31:57 +02:00
|
|
|
DataSeriesHelper::getDataSeriesLabel(
|
2008-07-02 10:58:06 +00:00
|
|
|
aIt->m_xDataSeries,
|
|
|
|
(aIt->m_xChartType.is() ?
|
|
|
|
aIt->m_xChartType->getRoleOfSequenceForSeriesLabel() :
|
2013-09-07 22:31:57 +02:00
|
|
|
OUString( "values-y"))));
|
2008-07-02 10:58:06 +00:00
|
|
|
spHeader->SetRange( aIt->m_nStartColumn + 1, aIt->m_nEndColumn + 1 );
|
|
|
|
spHeader->SetGetFocusHdl( aFocusLink );
|
|
|
|
spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink );
|
|
|
|
m_aSeriesHeaders.push_back( spHeader );
|
|
|
|
}
|
|
|
|
|
|
|
|
ImplAdjustHeaderControls();
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
void DataBrowser::ImplAdjustHeaderControls()
|
|
|
|
{
|
|
|
|
sal_uInt16 nColCount = this->GetColumnCount();
|
|
|
|
sal_uInt32 nCurrentPos = this->GetPosPixel().getX();
|
|
|
|
sal_uInt32 nMaxPos = nCurrentPos + this->GetOutputSizePixel().getWidth();
|
|
|
|
sal_uInt32 nStartPos = nCurrentPos;
|
|
|
|
|
|
|
|
// width of header column
|
|
|
|
nCurrentPos += this->GetColumnWidth( 0 );
|
2014-02-20 08:57:22 +00:00
|
|
|
|
|
|
|
Dialog* pDialog = GetParentDialog();
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWin = pDialog->get<VclContainer>("columns");
|
|
|
|
vcl::Window* pColorWin = pDialog->get<VclContainer>("colorcolumns");
|
2014-02-20 08:57:22 +00:00
|
|
|
pWin->set_margin_left(nCurrentPos);
|
|
|
|
pColorWin->set_margin_left(nCurrentPos);
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
tSeriesHeaderContainer::iterator aIt( m_aSeriesHeaders.begin());
|
|
|
|
sal_uInt16 i = this->GetFirstVisibleColumNumber();
|
|
|
|
while( (aIt != m_aSeriesHeaders.end()) && ((*aIt)->GetStartColumn() < i) )
|
2014-02-20 08:57:22 +00:00
|
|
|
{
|
|
|
|
(*aIt)->Hide();
|
2007-05-22 16:27:33 +00:00
|
|
|
++aIt;
|
2014-02-20 08:57:22 +00:00
|
|
|
}
|
2007-05-22 16:27:33 +00:00
|
|
|
for( ; i < nColCount && aIt != m_aSeriesHeaders.end(); ++i )
|
|
|
|
{
|
|
|
|
if( (*aIt)->GetStartColumn() == i )
|
|
|
|
nStartPos = nCurrentPos;
|
|
|
|
|
|
|
|
nCurrentPos += (this->GetColumnWidth( i ));
|
|
|
|
|
|
|
|
if( (*aIt)->GetEndColumn() == i )
|
|
|
|
{
|
|
|
|
if( nStartPos < nMaxPos )
|
|
|
|
{
|
|
|
|
(*aIt)->SetPixelWidth( nCurrentPos - nStartPos - 3 );
|
2014-02-20 08:57:22 +00:00
|
|
|
(*aIt)->Show();
|
|
|
|
|
|
|
|
if (pWin)
|
|
|
|
{
|
|
|
|
pWin->set_margin_left(nStartPos);
|
|
|
|
pColorWin->set_margin_left(nStartPos);
|
|
|
|
pWin = pColorWin = NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
else
|
2014-02-20 08:57:22 +00:00
|
|
|
(*aIt)->Hide();
|
2007-05-22 16:27:33 +00:00
|
|
|
++aIt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-24 13:53:17 +02:00
|
|
|
IMPL_LINK_TYPED( DataBrowser, SeriesHeaderGotFocus, Control&, rControl, void )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
2015-09-24 13:53:17 +02:00
|
|
|
impl::SeriesHeaderEdit* pEdit = static_cast<impl::SeriesHeaderEdit*>(&rControl);
|
|
|
|
pEdit->SetShowWarningBox( !m_bDataValid );
|
2008-02-18 14:40:38 +00:00
|
|
|
|
2015-09-24 13:53:17 +02:00
|
|
|
if( !m_bDataValid )
|
|
|
|
GoToCell( 0, 0 );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MakeFieldVisible( GetCurRow(), static_cast< sal_uInt16 >( pEdit->getStartColumn()), true /* bComplete */ );
|
|
|
|
ActivateCell();
|
|
|
|
m_aCursorMovedHdlLink.Call( this );
|
2007-05-22 16:27:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-28 18:15:45 +02:00
|
|
|
IMPL_LINK_TYPED( DataBrowser, SeriesHeaderChanged, impl::SeriesHeaderEdit*, pEdit, void )
|
2007-05-22 16:27:33 +00:00
|
|
|
{
|
|
|
|
if( pEdit )
|
|
|
|
{
|
|
|
|
Reference< chart2::XDataSeries > xSeries(
|
|
|
|
m_apDataBrowserModel->getDataSeriesByColumn( pEdit->getStartColumn() - 1 ));
|
|
|
|
Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
|
|
|
|
if( xSource.is())
|
|
|
|
{
|
|
|
|
Reference< chart2::XChartType > xChartType(
|
|
|
|
m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType );
|
|
|
|
if( xChartType.is())
|
|
|
|
{
|
|
|
|
Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
|
|
|
|
DataSeriesHelper::getDataSequenceByRole( xSource, xChartType->getRoleOfSequenceForSeriesLabel()));
|
|
|
|
if( xLabeledSeq.is())
|
|
|
|
{
|
|
|
|
Reference< container::XIndexReplace > xIndexReplace( xLabeledSeq->getLabel(), uno::UNO_QUERY );
|
|
|
|
if( xIndexReplace.is())
|
|
|
|
xIndexReplace->replaceByIndex(
|
|
|
|
0, uno::makeAny( OUString( pEdit->GetText())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chart
|
2010-10-12 15:59:00 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|