2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2009-10-31 00:36:06 +01:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2009-10-31 00:36:06 +01:00
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <unotools/pathoptions.hxx>
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <cuires.hrc>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include "optchart.hxx"
|
|
|
|
#include "optchart.hrc"
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <dialmgr.hxx>
|
2009-11-11 18:31:36 +01:00
|
|
|
#include <svx/svxids.hrc> // for SID_SCH_EDITOPTIONS
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
// ====================
|
|
|
|
// class ChartColorLB
|
|
|
|
// ====================
|
|
|
|
void ChartColorLB::FillBox( const SvxChartColorTable & rTab )
|
|
|
|
{
|
|
|
|
long nCount = rTab.size();
|
2011-01-14 12:41:27 +01:00
|
|
|
SetUpdateMode( sal_False );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
for( long i = 0; i < nCount; i++ )
|
|
|
|
{
|
|
|
|
Append( const_cast< XColorEntry * >( & rTab[ i ] ));
|
|
|
|
}
|
2011-01-14 12:41:27 +01:00
|
|
|
SetUpdateMode( sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ====================
|
|
|
|
// class SvxDefaultColorOptPage
|
|
|
|
// ====================
|
|
|
|
SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSet& rInAttrs ) :
|
|
|
|
|
2009-11-02 20:49:14 +01:00
|
|
|
SfxTabPage( pParent, CUI_RES( RID_OPTPAGE_CHART_DEFCOLORS ), rInAttrs ),
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2009-11-02 20:49:14 +01:00
|
|
|
aGbChartColors ( this, CUI_RES( FL_CHART_COLOR_LIST ) ),
|
|
|
|
aLbChartColors ( this, CUI_RES( LB_CHART_COLOR_LIST ) ),
|
|
|
|
aGbColorBox ( this, CUI_RES( FL_COLOR_BOX ) ),
|
|
|
|
aValSetColorBox ( this, CUI_RES( CT_COLOR_BOX ) ),
|
2011-03-24 21:33:46 +01:00
|
|
|
aPBDefault ( this, CUI_RES( PB_RESET_TO_DEFAULT ) ),
|
|
|
|
aPBAdd ( this, CUI_RES( PB_ADD_CHART_COLOR ) ),
|
|
|
|
aPBRemove ( this, CUI_RES( PB_REMOVE_CHART_COLOR ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
aPBDefault.SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) );
|
2011-03-24 21:33:46 +01:00
|
|
|
aPBAdd.SetClickHdl( LINK( this, SvxDefaultColorOptPage, AddChartColor ) );
|
|
|
|
aPBRemove.SetClickHdl( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
aLbChartColors.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, ListClickedHdl ) );
|
|
|
|
aValSetColorBox.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) );
|
|
|
|
|
|
|
|
aValSetColorBox.SetStyle( aValSetColorBox.GetStyle()
|
2011-03-06 10:02:54 +01:00
|
|
|
| WB_ITEMBORDER | WB_NAMEFIELD );
|
2009-10-31 00:36:06 +01:00
|
|
|
aValSetColorBox.SetColCount( 8 );
|
2011-03-06 10:02:54 +01:00
|
|
|
aValSetColorBox.SetLineCount( 13 );
|
2009-10-31 00:36:06 +01:00
|
|
|
aValSetColorBox.SetExtraSpacing( 0 );
|
|
|
|
aValSetColorBox.Show();
|
|
|
|
|
|
|
|
pChartOptions = new SvxChartOptions;
|
|
|
|
pColorTab = new XColorTable( SvtPathOptions().GetPalettePath() );
|
|
|
|
|
|
|
|
const SfxPoolItem* pItem = NULL;
|
2011-01-14 12:41:27 +01:00
|
|
|
if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, sal_False, &pItem ) == SFX_ITEM_SET )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
pColorConfig = SAL_STATIC_CAST( SvxChartColorTableItem*, pItem->Clone() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SvxChartColorTable aTable;
|
|
|
|
aTable.useDefault();
|
|
|
|
pColorConfig = new SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aTable );
|
|
|
|
pColorConfig->SetOptions( pChartOptions );
|
|
|
|
}
|
|
|
|
|
|
|
|
Construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
SvxDefaultColorOptPage::~SvxDefaultColorOptPage()
|
|
|
|
{
|
|
|
|
// save changes
|
|
|
|
pChartOptions->SetDefaultColors( pColorConfig->GetColorTable() );
|
|
|
|
pChartOptions->Commit();
|
|
|
|
|
|
|
|
delete pColorConfig;
|
|
|
|
delete pColorTab;
|
|
|
|
delete pChartOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvxDefaultColorOptPage::Construct()
|
|
|
|
{
|
|
|
|
if( pColorConfig )
|
|
|
|
aLbChartColors.FillBox( pColorConfig->GetColorTable() );
|
|
|
|
|
|
|
|
FillColorBox();
|
|
|
|
|
|
|
|
aLbChartColors.SelectEntryPos( 0 );
|
|
|
|
ListClickedHdl( &aLbChartColors );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
SfxTabPage* SvxDefaultColorOptPage::Create( Window* pParent, const SfxItemSet& rAttrs )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
return new SvxDefaultColorOptPage( pParent, rAttrs );
|
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_Bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet& rOutAttrs )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
if( pColorConfig )
|
|
|
|
rOutAttrs.Put( *SAL_STATIC_CAST( SfxPoolItem*, pColorConfig ));
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
return sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void SvxDefaultColorOptPage::Reset( const SfxItemSet& )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
aLbChartColors.SelectEntryPos( 0 );
|
|
|
|
ListClickedHdl( &aLbChartColors );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvxDefaultColorOptPage::FillColorBox()
|
|
|
|
{
|
|
|
|
if( !pColorTab ) return;
|
|
|
|
|
|
|
|
long nCount = pColorTab->Count();
|
|
|
|
XColorEntry* pColorEntry;
|
|
|
|
|
2011-03-06 10:02:54 +01:00
|
|
|
if( nCount > 104 )
|
|
|
|
aValSetColorBox.SetStyle( aValSetColorBox.GetStyle() | WB_VSCROLL );
|
|
|
|
|
2009-10-31 00:36:06 +01:00
|
|
|
for( long i = 0; i < nCount; i++ )
|
|
|
|
{
|
|
|
|
pColorEntry = pColorTab->GetColor( i );
|
2011-01-14 12:41:27 +01:00
|
|
|
aValSetColorBox.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long SvxDefaultColorOptPage::GetColorIndex( const Color& rCol )
|
|
|
|
{
|
|
|
|
if( pColorTab )
|
|
|
|
{
|
|
|
|
long nCount = pColorTab->Count();
|
|
|
|
XColorEntry* pColorEntry;
|
|
|
|
|
|
|
|
for( long i = nCount - 1; i >= 0; i-- ) // default chart colors are at the end of the table
|
|
|
|
{
|
|
|
|
pColorEntry = pColorTab->GetColor( i );
|
|
|
|
if( pColorEntry && pColorEntry->GetColor() == rCol )
|
|
|
|
return SAL_STATIC_CAST( XPropertyTable*, pColorTab )->Get( pColorEntry->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1L;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// event handlers
|
|
|
|
// --------------------
|
|
|
|
|
|
|
|
// ResetToDefaults
|
|
|
|
// ---------------
|
|
|
|
|
|
|
|
IMPL_LINK( SvxDefaultColorOptPage, ResetToDefaults, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
if( pColorConfig )
|
|
|
|
{
|
|
|
|
pColorConfig->GetColorTable().useDefault();
|
|
|
|
|
|
|
|
aLbChartColors.Clear();
|
|
|
|
aLbChartColors.FillBox( pColorConfig->GetColorTable() );
|
|
|
|
|
|
|
|
aLbChartColors.GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2011-03-24 21:33:46 +01:00
|
|
|
// AddChartColor
|
|
|
|
// ------------
|
|
|
|
|
|
|
|
IMPL_LINK( SvxDefaultColorOptPage, AddChartColor, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
if( pColorConfig )
|
|
|
|
{
|
|
|
|
ColorData black = RGB_COLORDATA( 0x00, 0x00, 0x00 );
|
|
|
|
|
|
|
|
pColorConfig->GetColorTable().append (XColorEntry ( black, pColorConfig->GetColorTable().getNextDefaultName()));
|
|
|
|
|
|
|
|
aLbChartColors.Clear();
|
|
|
|
aLbChartColors.FillBox( pColorConfig->GetColorTable() );
|
|
|
|
|
|
|
|
aLbChartColors.GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveChartColor
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
if( pColorConfig )
|
|
|
|
{
|
|
|
|
pColorConfig->GetColorTable().remove( aLbChartColors.GetSelectEntryPos() );
|
|
|
|
|
|
|
|
aLbChartColors.Clear();
|
|
|
|
aLbChartColors.FillBox( pColorConfig->GetColorTable() );
|
|
|
|
|
|
|
|
aLbChartColors.GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2009-10-31 00:36:06 +01:00
|
|
|
// ListClickedHdl
|
|
|
|
// --------------
|
|
|
|
|
|
|
|
IMPL_LINK( SvxDefaultColorOptPage, ListClickedHdl, ChartColorLB*, pColorList )
|
|
|
|
{
|
|
|
|
Color aCol = pColorList->GetSelectEntryColor();
|
|
|
|
|
|
|
|
long nIndex = GetColorIndex( aCol );
|
|
|
|
|
|
|
|
if( nIndex == -1 ) // not found
|
|
|
|
{
|
|
|
|
aValSetColorBox.SetNoSelection();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
aValSetColorBox.SelectItem( (sal_uInt16)nIndex + 1 ); // ValueSet is 1-based
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
// BoxClickedHdl
|
|
|
|
// -------------
|
|
|
|
|
|
|
|
IMPL_LINK( SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, EMPTYARG )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nIdx = aLbChartColors.GetSelectEntryPos();
|
2009-10-31 00:36:06 +01:00
|
|
|
if( nIdx != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
{
|
|
|
|
XColorEntry aEntry( aValSetColorBox.GetItemColor( aValSetColorBox.GetSelectItemId() ),
|
|
|
|
aLbChartColors.GetSelectEntry() );
|
|
|
|
|
|
|
|
aLbChartColors.Modify( & aEntry, nIdx );
|
|
|
|
pColorConfig->ReplaceColorByIndex( nIdx, aEntry );
|
|
|
|
|
|
|
|
aLbChartColors.SelectEntryPos( nIdx ); // reselect entry
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|