summaryrefslogtreecommitdiff
path: root/cui/source/options/optchart.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/options/optchart.cxx')
-rw-r--r--cui/source/options/optchart.cxx305
1 files changed, 0 insertions, 305 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx
deleted file mode 100644
index 6293a8fe8..000000000
--- a/cui/source/options/optchart.cxx
+++ /dev/null
@@ -1,305 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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>
-#include <cuires.hrc>
-#include "optchart.hxx"
-#include "optchart.hrc"
-#include <dialmgr.hxx>
-#include <vcl/msgbox.hxx>
-#include <svx/svxids.hrc> // for SID_SCH_EDITOPTIONS
-
-// ====================
-// class ChartColorLB
-// ====================
-void ChartColorLB::FillBox( const SvxChartColorTable & rTab )
-{
- long nCount = rTab.size();
- SetUpdateMode( sal_False );
-
- for( long i = 0; i < nCount; i++ )
- {
- Append( const_cast< XColorEntry * >( & rTab[ i ] ));
- }
- SetUpdateMode( sal_True );
-}
-
-
-// ====================
-// class SvxDefaultColorOptPage
-// ====================
-SvxDefaultColorOptPage::SvxDefaultColorOptPage( Window* pParent, const SfxItemSet& rInAttrs ) :
-
- SfxTabPage( pParent, CUI_RES( RID_OPTPAGE_CHART_DEFCOLORS ), rInAttrs ),
-
- 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 ) ),
- aPBDefault ( this, CUI_RES( PB_RESET_TO_DEFAULT ) ),
- aPBAdd ( this, CUI_RES( PB_ADD_CHART_COLOR ) ),
- aPBRemove ( this, CUI_RES( PB_REMOVE_CHART_COLOR ) )
-{
- FreeResource();
-
- aPBDefault.SetClickHdl( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) );
- aPBAdd.SetClickHdl( LINK( this, SvxDefaultColorOptPage, AddChartColor ) );
- aPBRemove.SetClickHdl( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) );
- aLbChartColors.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, ListClickedHdl ) );
- aValSetColorBox.SetSelectHdl( LINK( this, SvxDefaultColorOptPage, BoxClickedHdl ) );
-
- aValSetColorBox.SetStyle( aValSetColorBox.GetStyle()
- | WB_ITEMBORDER | WB_NAMEFIELD );
- aValSetColorBox.SetColCount( 8 );
- aValSetColorBox.SetLineCount( 13 );
- aValSetColorBox.SetExtraSpacing( 0 );
- aValSetColorBox.Show();
-
- pChartOptions = new SvxChartOptions;
- pColorTab = new XColorTable( SvtPathOptions().GetPalettePath() );
-
- const SfxPoolItem* pItem = NULL;
- if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, sal_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* SvxDefaultColorOptPage::Create( Window* pParent, const SfxItemSet& rAttrs )
-{
- return new SvxDefaultColorOptPage( pParent, rAttrs );
-}
-
-sal_Bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet& rOutAttrs )
-{
- if( pColorConfig )
- rOutAttrs.Put( *SAL_STATIC_CAST( SfxPoolItem*, pColorConfig ));
-
- return sal_True;
-}
-
-void SvxDefaultColorOptPage::Reset( const SfxItemSet& )
-{
- aLbChartColors.SelectEntryPos( 0 );
- ListClickedHdl( &aLbChartColors );
-}
-
-void SvxDefaultColorOptPage::FillColorBox()
-{
- if( !pColorTab ) return;
-
- long nCount = pColorTab->Count();
- XColorEntry* pColorEntry;
-
- if( nCount > 104 )
- aValSetColorBox.SetStyle( aValSetColorBox.GetStyle() | WB_VSCROLL );
-
- for( long i = 0; i < nCount; i++ )
- {
- pColorEntry = pColorTab->GetColor( i );
- aValSetColorBox.InsertItem( (sal_uInt16) 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();
- aLbChartColors.SelectEntryPos( 0 );
- aPBRemove.Enable( sal_True );
- }
-
- return 0L;
-}
-
-// AddChartColor
-// ------------
-
-IMPL_LINK( SvxDefaultColorOptPage, AddChartColor, void *, EMPTYARG )
-{
- if( pColorConfig )
- {
- ColorData black = RGB_COLORDATA( 0x00, 0x00, 0x00 );
-
- pColorConfig->GetColorTable().append (XColorEntry ( black, pColorConfig->GetColorTable().getDefaultName(pColorConfig->GetColorTable().size())));
-
- aLbChartColors.Clear();
- aLbChartColors.FillBox( pColorConfig->GetColorTable() );
-
- aLbChartColors.GetFocus();
- aLbChartColors.SelectEntryPos( pColorConfig->GetColorTable().size() - 1 );
- aPBRemove.Enable( sal_True );
- }
-
- return 0L;
-}
-
-// RemoveChartColor
-// ----------------
-
-IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, PushButton*, pButton )
-{
- size_t nIndex = aLbChartColors.GetSelectEntryPos();
-
- if (aLbChartColors.GetSelectEntryCount() == 0)
- return 0L;
-
- if( pColorConfig )
- {
- OSL_ENSURE(pColorConfig->GetColorTable().size() > 1, "don't delete the last chart color");
- QueryBox aQuery(pButton, CUI_RES(RID_OPTQB_COLOR_CHART_DELETE));
- aQuery.SetText(String(CUI_RES(RID_OPTSTR_COLOR_CHART_DELETE)));
- if(RET_YES == aQuery.Execute())
- {
-
- pColorConfig->GetColorTable().remove( nIndex );
-
- aLbChartColors.Clear();
- aLbChartColors.FillBox( pColorConfig->GetColorTable() );
-
- aLbChartColors.GetFocus();
-
- if (nIndex == aLbChartColors.GetEntryCount() && aLbChartColors.GetEntryCount() > 0)
- aLbChartColors.SelectEntryPos( pColorConfig->GetColorTable().size() - 1 );
- else if (aLbChartColors.GetEntryCount() > 0)
- aLbChartColors.SelectEntryPos( nIndex );
- else
- aPBRemove.Enable( sal_False );
- }
- }
-
- 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( (sal_uInt16)nIndex + 1 ); // ValueSet is 1-based
- }
-
- return 0L;
-}
-
-// BoxClickedHdl
-// -------------
-
-IMPL_LINK( SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, EMPTYARG )
-{
- sal_uInt16 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;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */