2007/02/27 16:27:59 bm 1.1.2.37: #i71233# disable dialog commit when there are invalid ranges or series with missing mandatory roles 2007/02/27 13:45:31 bm 1.1.2.36: Disable controls and tabs when invalid ranges were entered 2007/02/09 12:31:17 bm 1.1.2.35: implement adaptions for different look in wizard and stand-alone source data dialog, according to spec FlexibleSourceRangeSelection 2007/02/08 21:25:33 iha 1.1.2.34: resync m195 -> m202 2006/10/27 14:59:19 iha 1.1.2.33: name consolidation 2006/10/24 11:55:16 bm 1.1.2.32: enable range chooser in Calc 2005/11/14 17:53:12 iha 1.1.2.31: don't update model again at end of execute as this was done already - undo is done outside of the dialog 2005/10/11 09:20:09 bm 1.1.2.30: license header change 2005/09/29 12:12:25 iha 1.1.2.29: #i55138# helpId 2005/09/27 15:02:53 iha 1.1.2.28: #i55138# enable helpids for data ranges dialog (resource depth must be <3 ) 2005/08/18 15:20:41 bm 1.1.2.27: (gs)etDiagram -> (gs)etFirstDiagram to avoid name clashes with old API 2005/04/15 14:48:07 bm 1.1.2.26: data source and range choose dialog rework 2004/06/30 16:14:16 bm 1.1.2.25: some fixes 2004/06/29 12:21:52 bm 1.1.2.24: shared data for range chooser and data source tab pages 2004/06/17 13:05:10 bm 1.1.2.23: some minor preliminary fixes 2004/06/17 10:03:24 bm 1.1.2.22: data source dialog is a tab dialog now using the same tabpages as the wizard 2004/06/03 09:31:41 bm 1.1.2.21: Embedding API changes 2004/05/24 17:47:44 bm 1.1.2.20: data source dialog is deprecated -> is a tabpage now 2004/05/17 17:33:48 iha 1.1.2.19: provide object naming; resource cleanup 2004/05/07 16:24:23 iha 1.1.2.18: #i20344# moved RefButton to RangeSelectionButton 2004/05/07 16:12:03 bm 1.1.2.17: get label text from ranges bigger than one cell 2004/05/05 20:46:59 iha 1.1.2.16: resource cleanup 2004/05/05 15:58:21 iha 1.1.2.15: update label content from spreadsheet cell 2004/04/28 19:07:01 iha 1.1.2.14: #i20344# icon cleanup, prepare line subtypes 2004/04/27 15:52:27 bm 1.1.2.13: warning removed 2004/04/27 14:27:41 bm 1.1.2.12: warnings removed 2004/04/27 13:28:29 bm 1.1.2.11: use internal role-name as key for role-entries. (listbox now contains internal-role-name (invisible), UI role-name, range string) 2004/04/15 17:25:32 bm 1.1.2.10: control-enabling DialogSeries is now declared in cxx 2004/04/14 12:20:06 bm 1.1.2.9: createRangeSelection: also works for embedded chart in calc 2004/04/13 09:53:11 bm 1.1.2.8: show correct string for multi-cell labels 2004/04/08 15:19:55 bm 1.1.2.7: disable categories range ('shrink') button 2004/04/08 15:16:19 bm 1.1.2.6: use values-x instead of domain-x 2004/04/08 14:56:31 bm 1.1.2.5: applying categories to model, accept changes made in editfields (no check yet) 2004/04/07 18:46:21 bm 1.1.2.4: dialog uses internal data structure, additional field for label range 2004/03/29 13:24:38 bm 1.1.2.3: XDataSource: getSourceRangeRepresentation -> getSourceIdentifier 2004/03/19 16:43:14 bm 1.1.2.2: show names of data series correctly 2004/03/19 14:26:19 bm 1.1.2.1: dialog for flexible source range selection
251 lines
7.7 KiB
C++
251 lines
7.7 KiB
C++
/*************************************************************************
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: dlg_DataSource.cxx,v $
|
|
*
|
|
* $Revision: 1.2 $
|
|
*
|
|
* last change: $Author: vg $ $Date: 2007-05-22 17:33:25 $
|
|
*
|
|
* The Contents of this file are made available subject to
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
|
*
|
|
*
|
|
* GNU Lesser General Public License Version 2.1
|
|
* =============================================
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
* MA 02111-1307 USA
|
|
*
|
|
************************************************************************/
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_chart2.hxx"
|
|
|
|
#include "dlg_DataSource.hxx"
|
|
#include "dlg_DataSource.hrc"
|
|
#include "Strings.hrc"
|
|
#include "ResId.hxx"
|
|
#include "ChartTypeTemplateProvider.hxx"
|
|
#include "DiagramHelper.hxx"
|
|
#include "DialogModel.hxx"
|
|
#include "HelpIds.hrc"
|
|
|
|
#include "tp_RangeChooser.hxx"
|
|
#include "tp_DataSource.hxx"
|
|
|
|
// for RET_OK
|
|
#ifndef _SV_MSGBOX_HXX
|
|
#include <vcl/msgbox.hxx>
|
|
#endif
|
|
|
|
using namespace ::com::sun::star;
|
|
using namespace ::com::sun::star::chart2;
|
|
using namespace ::chart;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
using ::com::sun::star::uno::Sequence;
|
|
using ::rtl::OUString;
|
|
|
|
// --------------------------------------------------------------------------------
|
|
|
|
|
|
namespace chart
|
|
{
|
|
|
|
// ----------------------------------------
|
|
|
|
class DocumentChartTypeTemplateProvider : public ChartTypeTemplateProvider
|
|
{
|
|
public:
|
|
DocumentChartTypeTemplateProvider(
|
|
const Reference< chart2::XChartDocument > & xDoc );
|
|
virtual ~DocumentChartTypeTemplateProvider();
|
|
|
|
// ____ ChartTypeTemplateProvider ____
|
|
virtual Reference< chart2::XChartTypeTemplate > getCurrentTemplate() const;
|
|
|
|
private:
|
|
Reference< chart2::XChartTypeTemplate > m_xTemplate;
|
|
};
|
|
|
|
DocumentChartTypeTemplateProvider::DocumentChartTypeTemplateProvider(
|
|
const Reference< chart2::XChartDocument > & xDoc )
|
|
{
|
|
if( xDoc.is())
|
|
{
|
|
Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram());
|
|
if( xDia.is())
|
|
{
|
|
DiagramHelper::tTemplateWithServiceName aResult(
|
|
DiagramHelper::getTemplateForDiagram(
|
|
xDia,
|
|
Reference< lang::XMultiServiceFactory >(
|
|
xDoc->getChartTypeManager(), uno::UNO_QUERY ) ));
|
|
m_xTemplate.set( aResult.first );
|
|
}
|
|
}
|
|
}
|
|
|
|
DocumentChartTypeTemplateProvider::~DocumentChartTypeTemplateProvider()
|
|
{}
|
|
|
|
Reference< chart2::XChartTypeTemplate > DocumentChartTypeTemplateProvider::getCurrentTemplate() const
|
|
{
|
|
return m_xTemplate;
|
|
}
|
|
|
|
// ----------------------------------------
|
|
|
|
class DataSourceTabControl : public TabControl
|
|
{
|
|
public:
|
|
DataSourceTabControl( Window* pParent, const ResId& rResId );
|
|
~DataSourceTabControl();
|
|
|
|
virtual long DeactivatePage();
|
|
|
|
void DisableTabToggling();
|
|
void EnableTabToggling();
|
|
|
|
private:
|
|
bool m_bTogglingEnabled;
|
|
};
|
|
|
|
DataSourceTabControl::DataSourceTabControl( Window* pParent, const ResId& rResId ) :
|
|
TabControl( pParent, rResId ),
|
|
m_bTogglingEnabled( true )
|
|
{}
|
|
|
|
DataSourceTabControl::~DataSourceTabControl()
|
|
{}
|
|
|
|
// Note that the result is long, but is intended to be a bool
|
|
long DataSourceTabControl::DeactivatePage()
|
|
{
|
|
bool bCanDeactivate( TabControl::DeactivatePage() != 0 );
|
|
|
|
bCanDeactivate = (bCanDeactivate && m_bTogglingEnabled);
|
|
|
|
return (bCanDeactivate ? 1 : 0 );
|
|
}
|
|
|
|
void DataSourceTabControl::DisableTabToggling()
|
|
{
|
|
m_bTogglingEnabled = false;
|
|
}
|
|
|
|
void DataSourceTabControl::EnableTabToggling()
|
|
{
|
|
m_bTogglingEnabled = true;
|
|
}
|
|
|
|
// ----------------------------------------
|
|
|
|
// static
|
|
USHORT DataSourceDialog::m_nLastPageId = 0;
|
|
|
|
DataSourceDialog::DataSourceDialog(
|
|
Window * pParent,
|
|
const Reference< XChartDocument > & xChartDocument,
|
|
const Reference< uno::XComponentContext > & xContext ) :
|
|
|
|
TabDialog( pParent, SchResId( DLG_DATA_SOURCE )),
|
|
|
|
m_xChartDocument( xChartDocument ),
|
|
m_xContext( xContext ),
|
|
m_apDocTemplateProvider( new DocumentChartTypeTemplateProvider( xChartDocument )),
|
|
m_apDialogModel( new DialogModel( xChartDocument, xContext )),
|
|
|
|
m_pTabControl( new DataSourceTabControl( this, SchResId( TABCTRL ) )),
|
|
m_aBtnOK( this, SchResId( BTN_OK ) ),
|
|
m_aBtnCancel( this, SchResId( BTN_CANCEL ) ),
|
|
m_aBtnHelp( this, SchResId( BTN_HELP ) ),
|
|
|
|
m_pRangeChooserTabePage(0),
|
|
m_pDataSourceTabPage(0),
|
|
m_bRangeChooserTabIsValid( true ),
|
|
m_bDataSourceTabIsValid( true )
|
|
{
|
|
FreeResource();
|
|
|
|
//don't create the tabpages before FreeResource, otherwise the help ids are not matched correctly
|
|
m_pRangeChooserTabePage = new RangeChooserTabPage( m_pTabControl, *(m_apDialogModel.get()),
|
|
m_apDocTemplateProvider.get(), this, true /* bHideDescription */ );
|
|
m_pDataSourceTabPage = new DataSourceTabPage( m_pTabControl, *(m_apDialogModel.get()),
|
|
m_apDocTemplateProvider.get(), this, true /* bHideDescription */ );
|
|
|
|
m_pTabControl->InsertPage( TP_RANGECHOOSER, String( SchResId( STR_PAGE_DATA_RANGE )));
|
|
m_pTabControl->InsertPage( TP_DATA_SOURCE, String( SchResId( STR_OBJECT_DATASERIES_PLURAL )));
|
|
|
|
m_pTabControl->SetTabPage( TP_RANGECHOOSER, m_pRangeChooserTabePage );
|
|
m_pTabControl->SetTabPage( TP_DATA_SOURCE, m_pDataSourceTabPage );
|
|
|
|
m_pTabControl->SelectTabPage( m_nLastPageId );
|
|
|
|
SetHelpId( HID_SCH_DLG_RANGES );
|
|
}
|
|
|
|
DataSourceDialog::~DataSourceDialog()
|
|
{
|
|
delete m_pRangeChooserTabePage;
|
|
delete m_pDataSourceTabPage;
|
|
|
|
m_nLastPageId = m_pTabControl->GetCurPageId();
|
|
delete m_pTabControl;
|
|
}
|
|
|
|
void DataSourceDialog::setInvalidPage( TabPage * pTabPage )
|
|
{
|
|
if( pTabPage == m_pRangeChooserTabePage )
|
|
m_bRangeChooserTabIsValid = false;
|
|
else if( pTabPage == m_pDataSourceTabPage )
|
|
m_bDataSourceTabIsValid = false;
|
|
|
|
if( ! (m_bRangeChooserTabIsValid && m_bDataSourceTabIsValid ))
|
|
{
|
|
m_aBtnOK.Enable( FALSE );
|
|
OSL_ASSERT( m_pTabControl );
|
|
// note: there seems to be no suitable mechanism to address pages by
|
|
// identifier, at least it is unclear what the page identifiers are.
|
|
// @todo: change the fixed numbers to identifiers
|
|
if( m_bRangeChooserTabIsValid )
|
|
m_pTabControl->SetCurPageId( m_pTabControl->GetPageId( 1 ));
|
|
else if( m_bDataSourceTabIsValid )
|
|
m_pTabControl->SetCurPageId( m_pTabControl->GetPageId( 0 ));
|
|
m_pTabControl->DisableTabToggling();
|
|
}
|
|
}
|
|
|
|
void DataSourceDialog::setValidPage( TabPage * pTabPage )
|
|
{
|
|
if( pTabPage == m_pRangeChooserTabePage )
|
|
m_bRangeChooserTabIsValid = true;
|
|
else if( pTabPage == m_pDataSourceTabPage )
|
|
m_bDataSourceTabIsValid = true;
|
|
|
|
if( m_bRangeChooserTabIsValid && m_bDataSourceTabIsValid )
|
|
{
|
|
m_aBtnOK.Enable( TRUE );
|
|
OSL_ASSERT( m_pTabControl );
|
|
m_pTabControl->EnableTabToggling();
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace chart
|