diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-05-22 14:17:23 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-05-22 14:17:23 +0000 |
commit | ee35fe8ce076e37d9e1f2ef00d3151d692b4a614 (patch) | |
tree | 5640dc93ddc4897b9913e1e5c03ffd278814370a | |
parent | 136ca5a9637265ecfa940ec07e707b83dbeec638 (diff) |
INTEGRATION: CWS chart2mst3 (1.1.2); FILE ADDED
2007/05/18 13:48:57 bm 1.1.2.4: #i74635# ResId cleanup for new code (moved here from sch in CWS chart2mst3)
2006/11/06 09:36:45 bm 1.1.2.3: wrong global include of an svx header
2006/10/27 14:24:40 bm 1.1.2.2: warning on Solaris removed: Make SchColorTable a member of SchColoTableItem instead of deriving. Better design and avoids operator== overload
2006/10/26 16:43:44 pb 1.1.2.1: fix: #i70903# chart options page moved from old chart
-rw-r--r-- | svx/source/dialog/optchart.cxx | 252 |
1 files changed, 252 insertions, 0 deletions
diff --git a/svx/source/dialog/optchart.cxx b/svx/source/dialog/optchart.cxx new file mode 100644 index 000000000000..6c6cacdbc26e --- /dev/null +++ b/svx/source/dialog/optchart.cxx @@ -0,0 +1,252 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optchart.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-05-22 15:17:23 $ + * + * 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_svx.hxx" + +#ifdef SVX_DLLIMPLEMENTATION +#undef SVX_DLLIMPLEMENTATION +#endif + +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <svtools/pathoptions.hxx> +#endif + +#include "dialogs.hrc" + +#include "optchart.hxx" +#include "optchart.hrc" +#include "dialmgr.hxx" + +// ==================== +// class ChartColorLB +// ==================== +void ChartColorLB::FillBox( const SvxChartColorTable & rTab ) +{ + long nCount = rTab.size(); + SetUpdateMode( FALSE ); + + for( long i = 0; i < nCount; i++ ) + { + Append( const_cast< XColorEntry * >( & rTab[ i ] )); + } + SetUpdateMode( TRUE ); +} + + +// ==================== +// class SvxDefaultColorOptPage +// ==================== +SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSet& rInAttrs ) : + + SfxTabPage( pParent, SVX_RES( RID_OPTPAGE_CHART_DEFCOLORS ), rInAttrs ), + + aGbChartColors ( this, SVX_RES( FL_CHART_COLOR_LIST ) ), + aLbChartColors ( this, SVX_RES( LB_CHART_COLOR_LIST ) ), + aGbColorBox ( this, SVX_RES( FL_COLOR_BOX ) ), + aValSetColorBox ( this, SVX_RES( CT_COLOR_BOX ) ), + aPBDefault ( this, SVX_RES( PB_RESET_TO_DEFAULT ) ) +{ + FreeResource(); + + aPBDefault.SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) ); + aLbChartColors.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, ListClickedHdl ) ); + aValSetColorBox.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) ); + + aValSetColorBox.SetStyle( aValSetColorBox.GetStyle() + | WB_VSCROLL | WB_ITEMBORDER | WB_NAMEFIELD ); + aValSetColorBox.SetColCount( 8 ); + aValSetColorBox.SetLineCount( 12 ); + aValSetColorBox.SetExtraSpacing( 0 ); + aValSetColorBox.Show(); + + pChartOptions = new SvxChartOptions; + pColorTab = new XColorTable( SvtPathOptions().GetPalettePath() ); + + const SfxPoolItem* pItem = NULL; + if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, FALSE, &pItem ) == SFX_ITEM_SET ) + { + 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 ); +} + + +SfxTabPage* __EXPORT SvxDefaultColorOptPage::Create( Window* pParent, const SfxItemSet& rAttrs ) +{ + return new SvxDefaultColorOptPage( pParent, rAttrs ); +} + +BOOL __EXPORT SvxDefaultColorOptPage::FillItemSet( SfxItemSet& rOutAttrs ) +{ + if( pColorConfig ) + rOutAttrs.Put( *SAL_STATIC_CAST( SfxPoolItem*, pColorConfig )); + + return TRUE; +} + +void __EXPORT SvxDefaultColorOptPage::Reset( const SfxItemSet& ) +{ + aLbChartColors.SelectEntryPos( 0 ); + ListClickedHdl( &aLbChartColors ); +} + +void SvxDefaultColorOptPage::FillColorBox() +{ + if( !pColorTab ) return; + + long nCount = pColorTab->Count(); + XColorEntry* pColorEntry; + + for( long i = 0; i < nCount; i++ ) + { + pColorEntry = pColorTab->GetColor( i ); + aValSetColorBox.InsertItem( (USHORT) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() ); + } +} + + +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; +} + +// ListClickedHdl +// -------------- + +IMPL_LINK( SvxDefaultColorOptPage, ListClickedHdl, ChartColorLB*, pColorList ) +{ + Color aCol = pColorList->GetSelectEntryColor(); + + long nIndex = GetColorIndex( aCol ); + + if( nIndex == -1 ) // not found + { + aValSetColorBox.SetNoSelection(); + } + else + { + aValSetColorBox.SelectItem( (USHORT)nIndex + 1 ); // ValueSet is 1-based + } + + return 0L; +} + +// BoxClickedHdl +// ------------- + +IMPL_LINK( SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, EMPTYARG ) +{ + USHORT nIdx = aLbChartColors.GetSelectEntryPos(); + 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; +} + |