diff options
Diffstat (limited to 'sc/source/ui/optdlg')
-rw-r--r-- | sc/source/ui/optdlg/makefile.mk | 59 | ||||
-rw-r--r-- | sc/source/ui/optdlg/opredlin.cxx | 289 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpcalc.cxx | 305 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpprint.cxx | 144 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpusrlst.cxx | 839 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpview.cxx | 745 |
6 files changed, 2381 insertions, 0 deletions
diff --git a/sc/source/ui/optdlg/makefile.mk b/sc/source/ui/optdlg/makefile.mk new file mode 100644 index 000000000000..52df7072ecf8 --- /dev/null +++ b/sc/source/ui/optdlg/makefile.mk @@ -0,0 +1,59 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sc +TARGET=optdlg + +# --- Settings ----------------------------------------------------- + +.INCLUDE : scpre.mk +.INCLUDE : settings.mk +.INCLUDE : sc.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +CXXFILES = \ + tpusrlst.cxx \ + tpview.cxx \ + tpcalc.cxx \ + tpprint.cxx \ + opredlin.cxx + +SLOFILES = \ + $(SLO)$/tpusrlst.obj \ + $(SLO)$/tpview.obj \ + $(SLO)$/tpcalc.obj \ + $(SLO)$/tpprint.obj \ + $(SLO)$/opredlin.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sc/source/ui/optdlg/opredlin.cxx b/sc/source/ui/optdlg/opredlin.cxx new file mode 100644 index 000000000000..1a45ab715dee --- /dev/null +++ b/sc/source/ui/optdlg/opredlin.cxx @@ -0,0 +1,289 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + + + +//------------------------------------------------------------------ + +#include <svx/dlgutil.hxx> +#include <svx/drawitem.hxx> +#include <svx/xtable.hxx> + +#include "appoptio.hxx" +#include "scmod.hxx" +#include "scitems.hxx" +#include "tpview.hxx" +#include "global.hxx" +#include "viewopti.hxx" +#include "tabvwsh.hxx" +#include "uiitems.hxx" +#include "scresid.hxx" +#include "docsh.hxx" +#include "sc.hrc" // -> Slot-IDs +#include "optdlg.hrc" +#include "globstr.hrc" + +#include "opredlin.hxx" +#include "opredlin.hrc" + +//------------------------------------------------------------------ + +ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent, + const SfxItemSet& rSet ) + : SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet), + aContentFT ( this, ScResId(FT_CONTENT )), + aContentColorLB ( this, ScResId(CLB_CONTENT )), + aRemoveFT ( this, ScResId(FT_REMOVE )), + aRemoveColorLB ( this, ScResId(CLB_REMOVE )), + aInsertFT ( this, ScResId(FT_INSERT )), + aInsertColorLB ( this, ScResId(CLB_INSERT )), + aMoveFT ( this, ScResId(FT_MOVE )), + aMoveColorLB ( this, ScResId(CLB_MOVE )), + aChangedGB ( this, ScResId(GB_COLORCHGS)), + aAuthorStr (ScResId(STR_AUTHOR)) +{ + FreeResource(); + + Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl); + aContentColorLB.SetSelectHdl( aLk ); + aMoveColorLB.SetSelectHdl( aLk ); + aInsertColorLB.SetSelectHdl( aLk ); + aRemoveColorLB.SetSelectHdl( aLk ); +} + +/*----------------------------------------------------------------------- + Beschreibung: + -----------------------------------------------------------------------*/ + +__EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage() +{ +} + +/*----------------------------------------------------------------------- + Beschreibung: + -----------------------------------------------------------------------*/ + +SfxTabPage* __EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet ) +{ + return new ScRedlineOptionsTabPage( pParent, rSet ); +} + +/*----------------------------------------------------------------------- + Beschreibung: + -----------------------------------------------------------------------*/ + +BOOL __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ ) +{ + ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); + + ULONG nNew=0; + USHORT nPos=0; + + nPos = aContentColorLB.GetSelectEntryPos(); + if (nPos != LISTBOX_ENTRY_NOTFOUND) + { + nPos = aContentColorLB.GetSelectEntryPos(); + if (nPos!=0) + nNew= aContentColorLB.GetEntryColor(nPos).GetColor(); + else + nNew= COL_TRANSPARENT; + + aAppOptions.SetTrackContentColor(nNew); + + } + nPos = aMoveColorLB.GetSelectEntryPos(); + if (nPos != LISTBOX_ENTRY_NOTFOUND) + { + nPos = aMoveColorLB.GetSelectEntryPos(); + if (nPos!=0) + nNew= aMoveColorLB.GetEntryColor(nPos).GetColor(); + else + nNew= COL_TRANSPARENT; + + aAppOptions.SetTrackMoveColor(nNew); + + } + nPos = aInsertColorLB.GetSelectEntryPos(); + if (nPos != LISTBOX_ENTRY_NOTFOUND) + { + nPos = aInsertColorLB.GetSelectEntryPos(); + if (nPos!=0) + nNew= aInsertColorLB.GetEntryColor(nPos).GetColor(); + else + nNew= COL_TRANSPARENT; + + aAppOptions.SetTrackInsertColor(nNew); + + } + nPos = aRemoveColorLB.GetSelectEntryPos(); + if (nPos != LISTBOX_ENTRY_NOTFOUND) + { + nPos = aRemoveColorLB.GetSelectEntryPos(); + if (nPos!=0) + nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor(); + else + nNew= COL_TRANSPARENT; + + aAppOptions.SetTrackDeleteColor(nNew); + + } + + SC_MOD()->SetAppOptions(aAppOptions); + + // Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert, + // waere das nicht noetig...) + ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); + if (pDocSh) + pDocSh->PostPaintGridAll(); + + return FALSE; +} + +/*----------------------------------------------------------------------- + Beschreibung: + -----------------------------------------------------------------------*/ + +void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ ) +{ + + XColorTable* pColorTbl = XColorTable::GetStdColorTable(); + aContentColorLB.InsertEntry(aAuthorStr); + aMoveColorLB.InsertEntry(aAuthorStr); + aInsertColorLB.InsertEntry(aAuthorStr); + aRemoveColorLB.InsertEntry(aAuthorStr); + + aContentColorLB.SetUpdateMode( FALSE); + aMoveColorLB.SetUpdateMode( FALSE); + aInsertColorLB.SetUpdateMode( FALSE); + aRemoveColorLB.SetUpdateMode( FALSE); + + for( USHORT i = 0; i < pColorTbl->Count(); ++i ) + { + XColorEntry* pEntry = pColorTbl->GetColor( i ); + Color aColor = pEntry->GetColor(); + String sName = pEntry->GetName(); + + aContentColorLB.InsertEntry( aColor, sName ); + aMoveColorLB.InsertEntry( aColor, sName ); + aInsertColorLB.InsertEntry( aColor, sName ); + aRemoveColorLB.InsertEntry( aColor, sName ); + } + aContentColorLB.SetUpdateMode( TRUE ); + aMoveColorLB.SetUpdateMode( TRUE ); + aInsertColorLB.SetUpdateMode( TRUE ); + aRemoveColorLB.SetUpdateMode( TRUE ); + + + ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); + + ULONG nColor = aAppOptions.GetTrackContentColor(); + if (nColor == COL_TRANSPARENT) + aContentColorLB.SelectEntryPos(0); + else + aContentColorLB.SelectEntry(Color(nColor)); + + nColor = aAppOptions.GetTrackMoveColor(); + if (nColor == COL_TRANSPARENT) + aMoveColorLB.SelectEntryPos(0); + else + aMoveColorLB.SelectEntry(Color(nColor)); + + + nColor = aAppOptions.GetTrackInsertColor(); + if (nColor == COL_TRANSPARENT) + aInsertColorLB.SelectEntryPos(0); + else + aInsertColorLB.SelectEntry(Color(nColor)); + + + nColor = aAppOptions.GetTrackDeleteColor(); + if (nColor == COL_TRANSPARENT) + aRemoveColorLB.SelectEntryPos(0); + else + aRemoveColorLB.SelectEntry(Color(nColor)); + +} + + +IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG ) +{ +/* + SvxFontPrevWindow *pPrev; + ListBox *pLB; + + if (pColorLB == &aInsertColorLB) + { + pPrev = &aInsertPreviewWN; + pLB = &aInsertLB; + } + else + { + pPrev = &aDeletedPreviewWN; + pLB = &aDeletedLB; + } + + SvxFont& rFont = pPrev->GetFont(); + USHORT nPos = pLB->GetSelectEntryPos(); + if (nPos == LISTBOX_ENTRY_NOTFOUND) + nPos = 0; + + CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos); + + if (pAttr->nItemId == SID_ATTR_BRUSH) + { + rFont.SetColor(Color(COL_BLACK)); + nPos = pColorLB->GetSelectEntryPos(); + if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND) + { + Brush aBrush(Color(pColorLB->GetSelectEntryColor())); + pPrev->SetBrush(aBrush); + } + else + { + Brush aBrush(Color(COL_LIGHTGRAY)); + pPrev->SetBrush(aBrush); + } + } + else + { + nPos = pColorLB->GetSelectEntryPos(); + if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND) + rFont.SetColor(pColorLB->GetEntryColor(nPos)); + else + rFont.SetColor(Color(COL_RED)); + } + + pPrev->Invalidate(); +*/ + return 0; +} + diff --git a/sc/source/ui/optdlg/tpcalc.cxx b/sc/source/ui/optdlg/tpcalc.cxx new file mode 100644 index 000000000000..5b5920e904fc --- /dev/null +++ b/sc/source/ui/optdlg/tpcalc.cxx @@ -0,0 +1,305 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + + + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <vcl/msgbox.hxx> + +#include "global.hxx" +#include "globstr.hrc" +#include "uiitems.hxx" +#include "docsh.hxx" +#include "document.hxx" +#include "docoptio.hxx" +#include "scresid.hxx" +#include "sc.hrc" // -> Slot-IDs +#include "optdlg.hrc" + +#define _TPCALC_CXX +#include "tpcalc.hxx" +#undef _TPCALC_CXX + +#include <math.h> + +// STATIC DATA ----------------------------------------------------------- + +static USHORT pCalcOptRanges[] = +{ + SID_SCDOCOPTIONS, + SID_SCDOCOPTIONS, + 0 +}; + +//======================================================================== + +ScTpCalcOptions::ScTpCalcOptions( Window* pParent, + const SfxItemSet& rCoreAttrs ) + + : SfxTabPage ( pParent, + ScResId( RID_SCPAGE_CALC ), + rCoreAttrs ), + + aGbZRefs ( this, ScResId( GB_ZREFS ) ), + aBtnIterate ( this, ScResId( BTN_ITERATE ) ), + aFtSteps ( this, ScResId( FT_STEPS ) ), + aEdSteps ( this, ScResId( ED_STEPS ) ), + aFtEps ( this, ScResId( FT_EPS ) ), + aEdEps ( this, ScResId( ED_EPS ) ), + aSeparatorFL ( this, ScResId( FL_SEPARATOR ) ), + aGbDate ( this, ScResId( GB_DATE ) ), + aBtnDateStd ( this, ScResId( BTN_DATESTD ) ), + aBtnDateSc10 ( this, ScResId( BTN_DATESC10 ) ), + aBtnDate1904 ( this, ScResId( BTN_DATE1904 ) ), + aHSeparatorFL ( this, ScResId( FL_H_SEPARATOR ) ), + aBtnCase ( this, ScResId( BTN_CASE ) ), + aBtnCalc ( this, ScResId( BTN_CALC ) ), + aBtnMatch ( this, ScResId( BTN_MATCH ) ), + aBtnRegex ( this, ScResId( BTN_REGEX ) ), + aBtnLookUp ( this, ScResId( BTN_LOOKUP ) ), + aBtnGeneralPrec ( this, ScResId( BTN_GENERAL_PREC ) ), + aFtPrec ( this, ScResId( FT_PREC ) ), + aEdPrec ( this, ScResId( ED_PREC ) ), + pOldOptions ( new ScDocOptions( + ((const ScTpCalcItem&)rCoreAttrs.Get( + GetWhich( SID_SCDOCOPTIONS ))). + GetDocOptions() ) ), + pLocalOptions ( new ScDocOptions ), + nWhichCalc ( GetWhich( SID_SCDOCOPTIONS ) ) +{ + aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT ); + Init(); + FreeResource(); + SetExchangeSupport(); +} + +//----------------------------------------------------------------------- + +__EXPORT ScTpCalcOptions::~ScTpCalcOptions() +{ + delete pOldOptions; + delete pLocalOptions; +} + +//----------------------------------------------------------------------- + +void ScTpCalcOptions::Init() +{ + aBtnIterate .SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) ); + aBtnGeneralPrec.SetClickHdl( LINK(this, ScTpCalcOptions, CheckClickHdl) ); + aBtnDateStd .SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) ); + aBtnDateSc10.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) ); + aBtnDate1904.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) ); +} + +//----------------------------------------------------------------------- + +USHORT* __EXPORT ScTpCalcOptions::GetRanges() +{ + return pCalcOptRanges; +} + +//----------------------------------------------------------------------- + +SfxTabPage* __EXPORT ScTpCalcOptions::Create( Window* pParent, const SfxItemSet& rAttrSet ) +{ + return ( new ScTpCalcOptions( pParent, rAttrSet ) ); +} + +//----------------------------------------------------------------------- + +void __EXPORT ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ ) +{ + USHORT d,m,y; + + *pLocalOptions = *pOldOptions; + + aBtnCase .Check( !pLocalOptions->IsIgnoreCase() ); + aBtnCalc .Check( pLocalOptions->IsCalcAsShown() ); + aBtnMatch .Check( pLocalOptions->IsMatchWholeCell() ); + aBtnRegex .Check( pLocalOptions->IsFormulaRegexEnabled() ); + aBtnLookUp .Check( pLocalOptions->IsLookUpColRowNames() ); + aBtnIterate.Check( pLocalOptions->IsIter() ); + aEdSteps .SetValue( pLocalOptions->GetIterCount() ); + aEdEps .SetValue( pLocalOptions->GetIterEps(), 6 ); + + pLocalOptions->GetDate( d, m, y ); + + switch ( y ) + { + case 1899: + aBtnDateStd.Check(); + break; + case 1900: + aBtnDateSc10.Check(); + break; + case 1904: + aBtnDate1904.Check(); + break; + } + + sal_uInt16 nPrec = pLocalOptions->GetStdPrecision(); + if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION) + { + aFtPrec.Disable(); + aEdPrec.Disable(); + aBtnGeneralPrec.Check(false); + } + else + { + aBtnGeneralPrec.Check(); + aFtPrec.Enable(); + aEdPrec.Enable(); + aEdPrec.SetValue(nPrec); + } + + CheckClickHdl( &aBtnIterate ); +} + + +//----------------------------------------------------------------------- + +BOOL __EXPORT ScTpCalcOptions::FillItemSet( SfxItemSet& rCoreAttrs ) +{ + // alle weiteren Optionen werden in den Handlern aktualisiert + pLocalOptions->SetIterCount( (USHORT)aEdSteps.GetValue() ); + pLocalOptions->SetIgnoreCase( !aBtnCase.IsChecked() ); + pLocalOptions->SetCalcAsShown( aBtnCalc.IsChecked() ); + pLocalOptions->SetMatchWholeCell( aBtnMatch.IsChecked() ); + pLocalOptions->SetFormulaRegexEnabled( aBtnRegex.IsChecked() ); + pLocalOptions->SetLookUpColRowNames( aBtnLookUp.IsChecked() ); + + if (aBtnGeneralPrec.IsChecked()) + pLocalOptions->SetStdPrecision( + static_cast<sal_uInt16>(aEdPrec.GetValue()) ); + else + pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION ); + + if ( *pLocalOptions != *pOldOptions ) + { + rCoreAttrs.Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) ); + return TRUE; + } + else + return FALSE; +} + +//------------------------------------------------------------------------ + +int __EXPORT ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP ) +{ + int nReturn = KEEP_PAGE; + + double fEps; + if( aEdEps.GetValue( fEps ) && (fEps > 0.0) ) + { + pLocalOptions->SetIterEps( fEps ); + nReturn = LEAVE_PAGE; + } + + if ( nReturn == KEEP_PAGE ) + { + ErrorBox( this, + WinBits( WB_OK | WB_DEF_OK ), + ScGlobal::GetRscString( STR_INVALID_EPS ) + ).Execute(); + + aEdEps.GrabFocus(); + } + else if ( pSetP ) + FillItemSet( *pSetP ); + + return nReturn; +} + +//----------------------------------------------------------------------- +// Handler: + +IMPL_LINK( ScTpCalcOptions, RadioClickHdl, RadioButton*, pBtn ) +{ + if ( pBtn == &aBtnDateStd ) + { + pLocalOptions->SetDate( 30, 12, 1899 ); + } + else if ( pBtn == &aBtnDateSc10 ) + { + pLocalOptions->SetDate( 1, 1, 1900 ); + } + else if ( pBtn == &aBtnDate1904 ) + { + pLocalOptions->SetDate( 1, 1, 1904 ); + } + + return 0; +} + +//----------------------------------------------------------------------- + +IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn ) +{ + if (pBtn == &aBtnGeneralPrec) + { + if (pBtn->IsChecked()) + { + aEdPrec.Enable(); + aFtPrec.Enable(); + } + else + { + aEdPrec.Disable(); + aFtPrec.Disable(); + } + } + else if (pBtn == &aBtnIterate) + { + if ( pBtn->IsChecked() ) + { + pLocalOptions->SetIter( TRUE ); + aFtSteps.Enable(); aEdSteps.Enable(); + aFtEps .Enable(); aEdEps .Enable(); + } + else + { + pLocalOptions->SetIter( FALSE ); + aFtSteps.Disable(); aEdSteps.Disable(); + aFtEps .Disable(); aEdEps .Disable(); + } + } + + return 0; +} + + + + diff --git a/sc/source/ui/optdlg/tpprint.cxx b/sc/source/ui/optdlg/tpprint.cxx new file mode 100644 index 000000000000..d14b79bd739a --- /dev/null +++ b/sc/source/ui/optdlg/tpprint.cxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + +#include <svl/eitem.hxx> + +#include "tpprint.hxx" +#include "printopt.hxx" +#include "scmod.hxx" +#include "scresid.hxx" +#include "sc.hrc" +#include "optdlg.hrc" + +// ----------------------------------------------------------------------- + +static USHORT pPrintOptRanges[] = +{ + SID_SCPRINTOPTIONS, + SID_SCPRINTOPTIONS, + 0 +}; + +// ----------------------------------------------------------------------- + +ScTpPrintOptions::ScTpPrintOptions( Window* pParent, + const SfxItemSet& rCoreAttrs ) + : SfxTabPage ( pParent, + ScResId( RID_SCPAGE_PRINT ), + rCoreAttrs ), + aPagesFL ( this, ScResId( FL_PAGES ) ), + aSkipEmptyPagesCB( this, ScResId( BTN_SKIPEMPTYPAGES ) ), + aSheetsFL ( this, ScResId( FL_SHEETS ) ), + aSelectedSheetsCB( this, ScResId( BTN_SELECTEDSHEETS ) ) +{ + FreeResource(); +} + +ScTpPrintOptions::~ScTpPrintOptions() +{ +} + +USHORT* ScTpPrintOptions::GetRanges() +{ + return pPrintOptRanges; +} + +SfxTabPage* ScTpPrintOptions::Create( Window* pParent, const SfxItemSet& rAttrSet ) +{ + return new ScTpPrintOptions( pParent, rAttrSet ); +} + +int ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP ) +{ + if ( pSetP ) + FillItemSet( *pSetP ); + + return LEAVE_PAGE; +} + +// ----------------------------------------------------------------------- + +void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet ) +{ + ScPrintOptions aOptions; + + const SfxPoolItem* pItem; + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCPRINTOPTIONS, FALSE , &pItem)) + aOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions(); + else + { + // when called from print dialog and no options set, use configuration + aOptions = SC_MOD()->GetPrintOptions(); + } + + if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_PRINT_SELECTEDSHEET, FALSE , &pItem ) ) + { + BOOL bChecked = ( (const SfxBoolItem*)pItem )->GetValue(); + aSelectedSheetsCB.Check( bChecked ); + } + else + { + aSelectedSheetsCB.Check( !aOptions.GetAllSheets() ); + } + + aSkipEmptyPagesCB.Check( aOptions.GetSkipEmpty() ); + aSkipEmptyPagesCB.SaveValue(); + aSelectedSheetsCB.SaveValue(); +} + +// ----------------------------------------------------------------------- + +BOOL ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs ) +{ + rCoreAttrs.ClearItem( SID_PRINT_SELECTEDSHEET ); + + bool bSkipEmptyChanged = ( aSkipEmptyPagesCB.GetSavedValue() != aSkipEmptyPagesCB.IsChecked() ); + bool bSelectedSheetsChanged = ( aSelectedSheetsCB.GetSavedValue() != aSelectedSheetsCB.IsChecked() ); + + if ( bSkipEmptyChanged || bSelectedSheetsChanged ) + { + ScPrintOptions aOpt; + aOpt.SetSkipEmpty( aSkipEmptyPagesCB.IsChecked() ); + aOpt.SetAllSheets( !aSelectedSheetsCB.IsChecked() ); + rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) ); + if ( bSelectedSheetsChanged ) + { + rCoreAttrs.Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, aSelectedSheetsCB.IsChecked() ) ); + } + return TRUE; + } + else + { + return FALSE; + } +} + diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx new file mode 100644 index 000000000000..eb7c8a6635eb --- /dev/null +++ b/sc/source/ui/optdlg/tpusrlst.cxx @@ -0,0 +1,839 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + + + +//------------------------------------------------------------------ + +#include <vcl/msgbox.hxx> + +#include "global.hxx" +#include "document.hxx" +#include "tabvwsh.hxx" +#include "viewdata.hxx" +#include "uiitems.hxx" +#include "userlist.hxx" +#include "rangeutl.hxx" +#include "crdlg.hxx" +#include "scresid.hxx" +#include "sc.hrc" // -> Slot-IDs +#include "optdlg.hrc" +#include "globstr.hrc" + +#define _TPUSRLST_CXX +#include "tpusrlst.hxx" +#undef _TPUSRLST_CXX + +//CHINA001 #include "scui_def.hxx" //CHINA001 +//CHINA001 #include "scresid.hxx" //add by CHINA001 +//CHINA001 #include "miscdlgs.hrc" //add by CHINA001 +//CHINA001 +//CHINA001 #include "scabstdlg.hxx" //CHINA001 +// STATIC DATA ----------------------------------------------------------- + +#define CR (sal_Unicode)13 +#define LF (sal_Unicode)10 + +static USHORT pUserListsRanges[] = +{ + SID_SCUSERLISTS, + SID_SCUSERLISTS, + 0 +}; + +static const sal_Unicode cDelimiter = ','; + + +//======================================================================== +// Benutzerdefinierte Listen: + + +ScTpUserLists::ScTpUserLists( Window* pParent, + const SfxItemSet& rCoreAttrs ) + + : SfxTabPage ( pParent, + ScResId( RID_SCPAGE_USERLISTS ), + rCoreAttrs ), + aFtLists ( this, ScResId( FT_LISTS ) ), + aLbLists ( this, ScResId( LB_LISTS ) ), + aFtEntries ( this, ScResId( FT_ENTRIES ) ), + aEdEntries ( this, ScResId( ED_ENTRIES ) ), + aFtCopyFrom ( this, ScResId( FT_COPYFROM ) ), + aEdCopyFrom ( this, ScResId( ED_COPYFROM ) ), + aBtnNew ( this, ScResId( BTN_NEW ) ), + aBtnAdd ( this, ScResId( BTN_ADD ) ), + aBtnRemove ( this, ScResId( BTN_REMOVE ) ), + aBtnCopy ( this, ScResId( BTN_COPY ) ), + aStrQueryRemove ( ScResId( STR_QUERYREMOVE ) ), + aStrNew ( aBtnNew.GetText() ), + aStrCancel ( ScResId( STR_DISMISS ) ), + aStrAdd ( ScResId( SCSTR_ADD ) ), + aStrModify ( ScResId( SCSTR_MODIFY ) ), + aStrCopyList ( ScResId( STR_COPYLIST ) ), + aStrCopyFrom ( ScResId( STR_COPYFROM ) ), + aStrCopyErr ( ScResId( STR_COPYERR ) ), + // + nWhichUserLists ( GetWhich( SID_SCUSERLISTS ) ), + pUserLists ( NULL ), + pDoc ( NULL ), + pViewData ( NULL ), + pRangeUtil ( new ScRangeUtil ), + bModifyMode ( FALSE ), + bCancelMode ( FALSE ), + bCopyDone ( FALSE ), + nCancelPos ( 0 ) +{ + SetExchangeSupport(); + Init(); + FreeResource(); +} + +// ----------------------------------------------------------------------- + +__EXPORT ScTpUserLists::~ScTpUserLists() +{ + delete pUserLists; + delete pRangeUtil; +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::Init() +{ + SfxViewShell* pSh = SfxViewShell::Current(); + ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, pSh); + + aLbLists.SetSelectHdl ( LINK( this, ScTpUserLists, LbSelectHdl ) ); + aBtnNew.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) ); + aBtnNew.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) ); + aBtnAdd.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) ); + aBtnRemove.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) ); + aEdEntries.SetModifyHdl ( LINK( this, ScTpUserLists, EdEntriesModHdl ) ); + + + if ( pViewSh ) + { + SCTAB nStartTab = 0; + SCTAB nEndTab = 0; + SCCOL nStartCol = 0; + SCROW nStartRow = 0; + SCCOL nEndCol = 0; + SCROW nEndRow = 0; + + pViewData = pViewSh->GetViewData(); + pDoc = pViewData->GetDocument(); + + pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab ); + + PutInOrder( nStartCol, nEndCol ); + PutInOrder( nStartRow, nEndRow ); + PutInOrder( nStartTab, nEndTab ); + + ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab + ).Format( aStrSelectedArea, SCR_ABS_3D, pDoc ); + + aBtnCopy.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) ); + aBtnCopy.Enable(); + } + else + { + aBtnCopy.Disable(); + aFtCopyFrom.Disable(); + aEdCopyFrom.Disable(); + } + +// aLbLists.GrabFocus(); +} + +// ----------------------------------------------------------------------- + +USHORT* __EXPORT ScTpUserLists::GetRanges() +{ + return pUserListsRanges; +} + +// ----------------------------------------------------------------------- + +SfxTabPage* __EXPORT ScTpUserLists::Create( Window* pParent, const SfxItemSet& rAttrSet ) +{ + return ( new ScTpUserLists( pParent, rAttrSet ) ); +} + +// ----------------------------------------------------------------------- + +void __EXPORT ScTpUserLists::Reset( const SfxItemSet& rCoreAttrs ) +{ + const ScUserListItem& rUserListItem = (const ScUserListItem&) + rCoreAttrs.Get( nWhichUserLists ); + const ScUserList* pCoreList = rUserListItem.GetUserList(); + + DBG_ASSERT( pCoreList, "UserList not found :-/" ); + + if ( pCoreList ) + { + if ( !pUserLists ) + pUserLists = new ScUserList( *pCoreList ); + else + *pUserLists = *pCoreList; + + if ( UpdateUserListBox() > 0 ) + { + aLbLists.SelectEntryPos( 0 ); + UpdateEntries( 0 ); + } + } + else if ( !pUserLists ) + pUserLists = new ScUserList; + + aEdCopyFrom.SetText( aStrSelectedArea ); + + if ( aLbLists.GetEntryCount() == 0 ) + { + aFtLists .Disable(); + aLbLists .Disable(); + aFtEntries .Disable(); + aEdEntries .Disable(); + aBtnRemove .Disable(); + } + + aBtnNew.SetText( aStrNew ); + aBtnAdd.SetText( aStrAdd ); + aBtnAdd.Disable(); + + if ( !bCopyDone && pViewData ) + { + aFtCopyFrom .Enable(); + aEdCopyFrom .Enable(); + aBtnCopy .Enable(); + } + +// aLbLists.GrabFocus(); +} + +// ----------------------------------------------------------------------- + +BOOL __EXPORT ScTpUserLists::FillItemSet( SfxItemSet& rCoreAttrs ) +{ + // Modifikationen noch nicht uebernommen? + // -> Click auf Add-Button simulieren + + if ( bModifyMode || bCancelMode ) + BtnClickHdl( &aBtnAdd ); + + const ScUserListItem& rUserListItem = (const ScUserListItem&) + GetItemSet().Get( nWhichUserLists ); + + ScUserList* pCoreList = rUserListItem.GetUserList(); + BOOL bDataModified = FALSE; + + if ( (pUserLists == NULL) && (pCoreList == NULL) ) + { + bDataModified = FALSE; + } + else if ( pUserLists != NULL ) + { + if ( pCoreList != NULL ) + bDataModified = (*pUserLists != *pCoreList); + else + bDataModified = TRUE; + } + + if ( bDataModified ) + { + ScUserListItem aULItem( nWhichUserLists ); + + if ( pUserLists ) + aULItem.SetUserList( *pUserLists ); + + rCoreAttrs.Put( aULItem ); + } + + return bDataModified; +} + +// ----------------------------------------------------------------------- + +int __EXPORT ScTpUserLists::DeactivatePage( SfxItemSet* pSetP ) +{ + if ( pSetP ) + FillItemSet( *pSetP ); + + return LEAVE_PAGE; +} + +// ----------------------------------------------------------------------- + +USHORT ScTpUserLists::UpdateUserListBox() +{ + aLbLists.Clear(); + + if ( !pUserLists ) return 0; + + //---------------------------------------------------------- + + USHORT nCount = pUserLists->GetCount(); + String aEntry; + + if ( nCount > 0 ) + { + for ( USHORT i=0; i<nCount; i++ ) + { + aEntry = (*pUserLists)[i]->GetString(); + DBG_ASSERT( aEntry.Len() > 0, "Empty UserList-entry :-/" ); + aLbLists.InsertEntry( aEntry ); + } + } + + return nCount; +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::UpdateEntries( USHORT nList ) +{ + if ( !pUserLists ) return; + + //---------------------------------------------------------- + + if ( nList < pUserLists->GetCount() ) + { + ScUserListData* pList = (*pUserLists)[nList]; + USHORT nSubCount = pList->GetSubCount(); + String aEntryListStr; + + for ( USHORT i=0; i<nSubCount; i++ ) + { + if ( i!=0 ) + aEntryListStr += CR; + aEntryListStr += pList->GetSubStr( i ); + } + + aEntryListStr.ConvertLineEnd(); + aEdEntries.SetText( aEntryListStr ); + } + else + { + DBG_ERROR( "Invalid ListIndex :-/" ); + } +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::MakeListStr( String& rListStr ) +{ + String aInputStr(rListStr); + String aStr; + + xub_StrLen nLen = aStr.Len(); + xub_StrLen c = 0; + + aInputStr.ConvertLineEnd( LINEEND_LF ); + //aStr.EraseAllChars( ' ' ); + + xub_StrLen nToken=rListStr.GetTokenCount(LF); + + for(xub_StrLen i=0;i<nToken;i++) + { + String aString=rListStr.GetToken(i,LF); + aString.EraseLeadingChars(' '); + aString.EraseTrailingChars(' '); + aStr+=aString; + aStr+=cDelimiter; + } + + /* + // '\n' durch cDelimiter ersetzen: + for ( c=0; + (c < nLen) && (nFound != STRING_NOTFOUND); + c++ ) + { + nFound = aStr.Search( LF, nFound ); + if ( nFound != STRING_NOTFOUND ) + aStr[nFound] = cDelimiter; + } + */ + + aStr.EraseLeadingChars( cDelimiter ); + aStr.EraseTrailingChars( cDelimiter ); + nLen = aStr.Len(); + + rListStr.Erase(); + + // Alle Doppelten cDelimiter entfernen: + c=0; + while ( c < nLen ) + { + rListStr += aStr.GetChar(c); + c++; + + if ( aStr.GetChar(c) == cDelimiter ) + { + rListStr += aStr.GetChar(c); + + while ( (aStr.GetChar(c) == cDelimiter) && (c < nLen) ) + c++; + } + } + +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::AddNewList( const String& rEntriesStr ) +{ + String theEntriesStr( rEntriesStr ); + + if ( !pUserLists ) + pUserLists = new ScUserList; + + MakeListStr( theEntriesStr ); + + if ( !pUserLists->Insert( new ScUserListData( theEntriesStr ) ) ) + { + DBG_ERROR( "Entry could not be inserted :-/" ); + } +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::CopyListFromArea( const ScRefAddress& rStartPos, + const ScRefAddress& rEndPos ) +{ + if ( bCopyDone ) return; + + //---------------------------------------------------------- + + SCTAB nTab = rStartPos.Tab(); + SCCOL nStartCol = rStartPos.Col(); + SCROW nStartRow = rStartPos.Row(); + SCCOL nEndCol = rEndPos.Col(); + SCROW nEndRow = rEndPos.Row(); + USHORT nCellDir = SCRET_COLS; + BOOL bValueIgnored = FALSE; + + if ( (nStartCol != nEndCol) && (nStartRow != nEndRow) ) + { + nCellDir = ScColOrRowDlg( this, aStrCopyList, aStrCopyFrom ).Execute(); +//CHINA001 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); +//CHINA001 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 +//CHINA001 +//CHINA001 VclAbstractDialog* pDlg = pFact->CreateScColOrRowDlg( this, aStrCopyList, aStrCopyFrom,ResId(RID_SCDLG_COLORROW) ); +//CHINA001 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 +//CHINA001 nCellDir = pDlg->Execute(); +//CHINA001 delete pDlg; //CHINA001 + } + else if ( nStartCol != nEndCol ) + nCellDir = SCRET_ROWS; + else + nCellDir = SCRET_COLS; + + if ( nCellDir != RET_CANCEL ) + { + String aStrList; + String aStrField; + + if ( nCellDir == SCRET_COLS ) + { + for ( SCCOL col=nStartCol; col<=nEndCol; col++ ) + { + for ( SCROW row=nStartRow; row<=nEndRow; row++ ) + { + if ( pDoc->HasStringData( col, row, nTab ) ) + { + pDoc->GetString( col, row, nTab, aStrField ); + + if ( aStrField.Len() > 0 ) + { + aStrList += aStrField; + aStrList += '\n'; + } + } + else + bValueIgnored = TRUE; + } + if ( aStrList.Len() > 0 ) + AddNewList( aStrList ); + aStrList.Erase(); + } + } + else + { + for ( SCROW row=nStartRow; row<=nEndRow; row++ ) + { + for ( SCCOL col=nStartCol; col<=nEndCol; col++ ) + { + if ( pDoc->HasStringData( col, row, nTab ) ) + { + pDoc->GetString( col, row, nTab, aStrField ); + + if ( aStrField.Len() > 0 ) + { + aStrList += aStrField; + aStrList += '\n'; + } + } + else + bValueIgnored = TRUE; + } + if ( aStrList.Len() > 0 ) + AddNewList( aStrList ); + aStrList.Erase(); + } + } + + if ( bValueIgnored ) + { + InfoBox( this, aStrCopyErr ).Execute(); + } + } + + //---------------------------------------------------------- + + bCopyDone = TRUE; + +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::ModifyList( USHORT nSelList, + const String& rEntriesStr ) +{ + if ( !pUserLists ) return; + + //---------------------------------------------------------- + + String theEntriesStr( rEntriesStr ); + + MakeListStr( theEntriesStr ); + + (*pUserLists)[nSelList]->SetString( theEntriesStr ); +} + +// ----------------------------------------------------------------------- + +void ScTpUserLists::RemoveList( USHORT nList ) +{ + if ( pUserLists ) pUserLists->AtFree( nList ); +} + +//----------------------------------------------------------------------- +// Handler: +//--------- + +IMPL_LINK( ScTpUserLists, LbSelectHdl, ListBox*, pLb ) +{ + if ( pLb == &aLbLists ) + { + USHORT nSelPos = aLbLists.GetSelectEntryPos(); + if ( nSelPos != LISTBOX_ENTRY_NOTFOUND ) + { + if ( !aFtEntries.IsEnabled() ) aFtEntries.Enable(); + if ( !aEdEntries.IsEnabled() ) aEdEntries.Enable(); + if ( !aBtnRemove.IsEnabled() ) aBtnRemove.Enable(); + if ( aBtnAdd.IsEnabled() ) aBtnAdd.Disable(); + + UpdateEntries( nSelPos ); + } + } + + return 0; +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( ScTpUserLists, BtnClickHdl, PushButton*, pBtn ) +{ + if ( pBtn == &aBtnNew ) + { + if ( !bCancelMode ) + { + nCancelPos = ( aLbLists.GetEntryCount() > 0 ) + ? aLbLists.GetSelectEntryPos() + : 0; + aLbLists.SetNoSelection(); + aFtLists.Disable(); + aLbLists.Disable(); + aFtEntries.Enable(); + aEdEntries.Enable(); + aEdEntries.SetText( EMPTY_STRING ); + aEdEntries.GrabFocus(); + aBtnAdd.Disable(); + aBtnRemove.Disable(); + //----------------------------- + if ( aBtnCopy.IsEnabled() ) + { + aBtnCopy.Disable(); + aFtCopyFrom.Disable(); + aEdCopyFrom.Disable(); + } + aBtnNew.SetText( aStrCancel ); + bCancelMode = TRUE; + } + else // if ( bCancelMode ) + { + if ( aLbLists.GetEntryCount() > 0 ) + { + aLbLists.SelectEntryPos( nCancelPos ); + LbSelectHdl( &aLbLists ); + aFtLists.Enable(); + aLbLists.Enable(); + } + else + { + aFtEntries.Disable(); + aEdEntries.Disable(); + aEdEntries.SetText( EMPTY_STRING ); + aBtnRemove.Disable(); + } + aBtnAdd.Disable(); + //----------------------------- + if ( pViewData && !bCopyDone ) + { + aBtnCopy.Enable(); + aFtCopyFrom.Enable(); + aEdCopyFrom.Enable(); + } + aBtnNew.SetText( aStrNew ); + bCancelMode = FALSE; + bModifyMode = FALSE; + } + } + else if ( pBtn == &aBtnAdd ) + { + String theEntriesStr( aEdEntries.GetText() ); + + if ( !bModifyMode ) + { + if ( theEntriesStr.Len() > 0 ) + { + AddNewList( theEntriesStr ); + UpdateUserListBox(); + aLbLists.SelectEntryPos( aLbLists.GetEntryCount()-1 ); + LbSelectHdl( &aLbLists ); + aFtLists.Enable(); + aLbLists.Enable(); + } + else + { + if ( aLbLists.GetEntryCount() > 0 ) + { + aLbLists.SelectEntryPos( nCancelPos ); + LbSelectHdl( &aLbLists ); + aLbLists.Enable(); + aLbLists.Enable(); + } + } + + aBtnAdd.Disable(); + aBtnRemove.Enable(); + aBtnNew.SetText( aStrNew ); + bCancelMode = FALSE; + } + else // if ( bModifyMode ) + { + USHORT nSelList = aLbLists.GetSelectEntryPos(); + + DBG_ASSERT( nSelList != LISTBOX_ENTRY_NOTFOUND, "Modify without List :-/" ); + + if ( theEntriesStr.Len() > 0 ) + { + ModifyList( nSelList, theEntriesStr ); + UpdateUserListBox(); + aLbLists.SelectEntryPos( nSelList ); + } + else + { + aLbLists.SelectEntryPos( 0 ); + LbSelectHdl( &aLbLists ); + } + + aBtnNew.SetText( aStrNew ); bCancelMode = FALSE; + aBtnAdd.SetText( aStrAdd ); bModifyMode = FALSE; + aBtnAdd.Disable(); + aBtnRemove.Enable(); + aFtLists.Enable(); + aLbLists.Enable(); + } + + if ( pViewData && !bCopyDone ) + { + aBtnCopy.Enable(); + aFtCopyFrom.Enable(); + aEdCopyFrom.Enable(); + } + } + else if ( pBtn == &aBtnRemove ) + { + if ( aLbLists.GetEntryCount() > 0 ) + { + USHORT nRemovePos = aLbLists.GetSelectEntryPos(); + String aMsg ( aStrQueryRemove.GetToken( 0, '#' ) ); + + aMsg += aLbLists.GetEntry( nRemovePos ); + aMsg += aStrQueryRemove.GetToken( 1, '#' ); + + + if ( RET_YES == QueryBox( this, + WinBits( WB_YES_NO | WB_DEF_YES ), + aMsg + ).Execute() ) + { + RemoveList( nRemovePos ); + UpdateUserListBox(); + + if ( aLbLists.GetEntryCount() > 0 ) + { + aLbLists.SelectEntryPos( + ( nRemovePos >= aLbLists.GetEntryCount() ) + ? aLbLists.GetEntryCount()-1 + : nRemovePos ); + LbSelectHdl( &aLbLists ); + } + else + { + aFtLists.Disable(); + aLbLists.Disable(); + aFtEntries.Disable(); + aEdEntries.Disable(); + aEdEntries.SetText( EMPTY_STRING ); + aBtnRemove.Disable(); + } + } + + if ( pViewData && !bCopyDone && !aBtnCopy.IsEnabled() ) + { + aBtnCopy.Enable(); + aFtCopyFrom.Enable(); + aEdCopyFrom.Enable(); + } + } + } + else if ( pViewData && (pBtn == &aBtnCopy) ) + { + if ( bCopyDone ) + return 0; + + //----------------------------------------------------------- + + ScRefAddress theStartPos; + ScRefAddress theEndPos; + String theAreaStr( aEdCopyFrom.GetText() ); + BOOL bAreaOk = FALSE; + + if ( theAreaStr.Len() > 0 ) + { + bAreaOk = pRangeUtil->IsAbsArea( theAreaStr, + pDoc, + pViewData->GetTabNo(), + &theAreaStr, + &theStartPos, + &theEndPos, + pDoc->GetAddressConvention() ); + if ( !bAreaOk ) + { + bAreaOk = pRangeUtil->IsAbsPos( theAreaStr, + pDoc, + pViewData->GetTabNo(), + &theAreaStr, + &theStartPos, + pDoc->GetAddressConvention() ); + theEndPos = theStartPos; + } + } + + if ( bAreaOk ) + { + CopyListFromArea( theStartPos, theEndPos ); + UpdateUserListBox(); + aLbLists.SelectEntryPos( aLbLists.GetEntryCount()-1 ); + LbSelectHdl( &aLbLists ); + aEdCopyFrom .SetText( theAreaStr ); + aEdCopyFrom .Disable(); + aBtnCopy .Disable(); + aFtCopyFrom .Disable(); + } + else + { + ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), + ScGlobal::GetRscString( STR_INVALID_TABREF ) + ).Execute(); + aEdCopyFrom.GrabFocus(); + aEdCopyFrom.SetSelection( Selection( 0, SELECTION_MAX ) ); + } + } + + return 0; +} + +// ----------------------------------------------------------------------- + +IMPL_LINK( ScTpUserLists, EdEntriesModHdl, MultiLineEdit*, pEd ) +{ + if ( pEd != &aEdEntries ) + return 0; + + //----------------------------------------------------------- + + if ( aBtnCopy.IsEnabled() ) + { + aBtnCopy .Disable(); + aFtCopyFrom .Disable(); + aEdCopyFrom .Disable(); + } + + if ( aEdEntries.GetText().Len() > 0 ) + { + if ( !bCancelMode && !bModifyMode ) + { + aBtnNew.SetText( aStrCancel ); bCancelMode = TRUE; + aBtnAdd.SetText( aStrModify ); bModifyMode = TRUE; + aBtnAdd.Enable(); + aBtnRemove.Disable(); + aFtLists.Disable(); + aLbLists.Disable(); + } + else // if ( bCancelMode || bModifyMode ) + { + if ( !aBtnAdd.IsEnabled() ) aBtnAdd.Enable(); + } + } + else + { + if ( aBtnAdd.IsEnabled() ) aBtnAdd.Disable(); + } + + return 0; +} + + + diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx new file mode 100644 index 000000000000..5c2e8dd52c9f --- /dev/null +++ b/sc/source/ui/optdlg/tpview.cxx @@ -0,0 +1,745 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +#undef SC_DLLIMPLEMENTATION + + + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include "tpview.hxx" +#include "global.hxx" +#include "viewopti.hxx" +#include "tabvwsh.hxx" +#include "uiitems.hxx" +#include "scresid.hxx" +#include "docsh.hxx" +#include "sc.hrc" // -> Slot-IDs +#include "optdlg.hrc" +#include "globstr.hrc" +#include <appoptio.hxx> +#include <scmod.hxx> +#include <svx/dlgutil.hxx> +#include <svx/drawitem.hxx> +#include <svx/xtable.hxx> + + +// STATIC DATA ----------------------------------------------------------- + + + +/*-----------------11.01.97 10.52------------------- + Optionen Inhalte +--------------------------------------------------*/ + +ScTpContentOptions::ScTpContentOptions( Window* pParent, + const SfxItemSet& rArgSet ) : + SfxTabPage(pParent, ScResId( RID_SCPAGE_CONTENT ), rArgSet), + + aLinesGB( this, ScResId(GB_LINES )), + aGridCB( this, ScResId(CB_GRID )), + aColorFT( this, ScResId(FT_COLOR )), + aColorLB( this, ScResId(LB_COLOR )), + aBreakCB( this, ScResId(CB_PAGEBREAKS )), + aGuideLineCB( this, ScResId(CB_GUIDELINE )), + aHandleCB( this, ScResId(CB_HANDLES )), + aBigHandleCB( this, ScResId(CB_BIGHANDLES )), + + aSeparator1FL (this, ScResId(FL_SEPARATOR1 )), + aDisplayGB( this, ScResId(GB_DISPLAY)), + aFormulaCB( this, ScResId(CB_FORMULA)), + aNilCB( this, ScResId(CB_NIL )), + aAnnotCB( this, ScResId(CB_ANNOT )), + aValueCB( this, ScResId(CB_VALUE )), + aAnchorCB( this, ScResId(CB_ANCHOR )), + aClipMarkCB( this, ScResId(CB_CLIP )), + aRangeFindCB( this, ScResId( CB_RFIND )), + + aObjectGB( this, ScResId(GB_OBJECT )), + aObjGrfFT( this, ScResId(FT_OBJGRF )), + aObjGrfLB( this, ScResId(LB_OBJGRF )), + aDiagramFT( this, ScResId(FT_DIAGRAM)), + aDiagramLB( this, ScResId(LB_DIAGRAM)), + aDrawFT( this, ScResId(FT_DRAW )), + aDrawLB( this, ScResId(LB_DRAW )), + + aZoomGB( this, ScResId(GB_ZOOM) ), + aSyncZoomCB( this, ScResId(CB_SYNCZOOM) ), + + aSeparator2FL (this, ScResId(FL_SEPARATOR2)), + aWindowGB( this, ScResId(GB_WINDOW )), + aRowColHeaderCB(this, ScResId(CB_ROWCOLHEADER )), + aHScrollCB( this, ScResId(CB_HSCROLL )), + aVScrollCB( this, ScResId(CB_VSCROLL )), + aTblRegCB( this, ScResId(CB_TBLREG )), + aOutlineCB( this, ScResId(CB_OUTLINE )), + pLocalOptions(0) +{ + FreeResource(); + aSeparator1FL.SetStyle( aSeparator1FL.GetStyle() | WB_VERT ); + aSeparator2FL.SetStyle( aSeparator2FL.GetStyle() | WB_VERT ); + SetExchangeSupport(); + Link aSelObjHdl(LINK( this, ScTpContentOptions, SelLbObjHdl ) ); + aObjGrfLB. SetSelectHdl(aSelObjHdl); + aDiagramLB. SetSelectHdl(aSelObjHdl); + aDrawLB. SetSelectHdl(aSelObjHdl); + + Link aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) ); + aFormulaCB .SetClickHdl(aCBHdl); + aNilCB .SetClickHdl(aCBHdl); + aAnnotCB .SetClickHdl(aCBHdl); + aValueCB .SetClickHdl(aCBHdl); + aAnchorCB .SetClickHdl(aCBHdl); + aClipMarkCB .SetClickHdl(aCBHdl); + + aVScrollCB .SetClickHdl(aCBHdl); + aHScrollCB .SetClickHdl(aCBHdl); + aTblRegCB .SetClickHdl(aCBHdl); + aOutlineCB .SetClickHdl(aCBHdl); + aBreakCB .SetClickHdl(aCBHdl); + aGuideLineCB.SetClickHdl(aCBHdl); + aHandleCB .SetClickHdl(aCBHdl); + aBigHandleCB.SetClickHdl(aCBHdl); + aRowColHeaderCB.SetClickHdl(aCBHdl); + + aGridCB .SetClickHdl( LINK( this, ScTpContentOptions, GridHdl ) ); +} +/*-----------------11.01.97 10.52------------------- + +--------------------------------------------------*/ + +ScTpContentOptions::~ScTpContentOptions() +{ + delete pLocalOptions; +} +/*-----------------11.01.97 10.52------------------- + +--------------------------------------------------*/ + +SfxTabPage* ScTpContentOptions::Create( Window* pParent, + const SfxItemSet& rCoreSet ) +{ + return new ScTpContentOptions(pParent, rCoreSet); +} +/*-----------------11.01.97 10.52------------------- + +--------------------------------------------------*/ +BOOL ScTpContentOptions::FillItemSet( SfxItemSet& rCoreSet ) +{ + BOOL bRet = FALSE; + if( aFormulaCB .GetSavedValue() != aFormulaCB .IsChecked() || + aNilCB .GetSavedValue() != aNilCB .IsChecked() || + aAnnotCB .GetSavedValue() != aAnnotCB .IsChecked() || + aValueCB .GetSavedValue() != aValueCB .IsChecked() || + aAnchorCB .GetSavedValue() != aAnchorCB .IsChecked() || + aClipMarkCB .GetSavedValue() != aClipMarkCB .IsChecked() || + aObjGrfLB .GetSavedValue() != aObjGrfLB .GetSelectEntryPos() || + aDiagramLB .GetSavedValue() != aDiagramLB .GetSelectEntryPos() || + aDrawLB .GetSavedValue() != aDrawLB .GetSelectEntryPos() || + aGridCB .GetSavedValue() != aGridCB.IsChecked() || + aRowColHeaderCB .GetSavedValue() != aRowColHeaderCB.IsChecked() || + aHScrollCB .GetSavedValue() != aHScrollCB .IsChecked() || + aVScrollCB .GetSavedValue() != aVScrollCB .IsChecked() || + aTblRegCB .GetSavedValue() != aTblRegCB .IsChecked() || + aOutlineCB .GetSavedValue() != aOutlineCB .IsChecked() || + aColorLB .GetSavedValue() != aColorLB .GetSelectEntryPos() || + aBreakCB .GetSavedValue() != aBreakCB .IsChecked() || + aGuideLineCB .GetSavedValue() != aGuideLineCB .IsChecked() || + aHandleCB .GetSavedValue() != aHandleCB .IsChecked() || + aBigHandleCB .GetSavedValue() != aBigHandleCB .IsChecked()) + { + pLocalOptions->SetGridColor( aColorLB.GetSelectEntryColor(), + aColorLB.GetSelectEntry() ); + rCoreSet.Put(ScTpViewItem(SID_SCVIEWOPTIONS, *pLocalOptions)); + bRet = TRUE; + } + if(aRangeFindCB.GetSavedValue() != aRangeFindCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER, aRangeFindCB.IsChecked())); + bRet = TRUE; + } + if(aSyncZoomCB.GetSavedValue() != aSyncZoomCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM, aSyncZoomCB.IsChecked())); + bRet = TRUE; + } + + + return bRet; +} +/*-----------------11.01.97 10.53------------------- + +--------------------------------------------------*/ + +void ScTpContentOptions::Reset( const SfxItemSet& rCoreSet ) +{ + const SfxPoolItem* pItem; + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCVIEWOPTIONS, FALSE , &pItem)) + pLocalOptions = new ScViewOptions( + ((const ScTpViewItem*)pItem)->GetViewOptions() ); + else + pLocalOptions = new ScViewOptions; + aFormulaCB .Check(pLocalOptions->GetOption(VOPT_FORMULAS)); + aNilCB .Check(pLocalOptions->GetOption(VOPT_NULLVALS)); + aAnnotCB .Check(pLocalOptions->GetOption(VOPT_NOTES)); + aValueCB .Check(pLocalOptions->GetOption(VOPT_SYNTAX)); + aAnchorCB .Check(pLocalOptions->GetOption(VOPT_ANCHOR)); + aClipMarkCB .Check(pLocalOptions->GetOption(VOPT_CLIPMARKS)); + + aObjGrfLB .SelectEntryPos( (USHORT)pLocalOptions->GetObjMode(VOBJ_TYPE_OLE) ); + aDiagramLB .SelectEntryPos( (USHORT)pLocalOptions->GetObjMode(VOBJ_TYPE_CHART) ); + aDrawLB .SelectEntryPos( (USHORT)pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW) ); + + aRowColHeaderCB.Check( pLocalOptions->GetOption(VOPT_HEADER) ); + aHScrollCB .Check( pLocalOptions->GetOption(VOPT_HSCROLL) ); + aVScrollCB .Check( pLocalOptions->GetOption(VOPT_VSCROLL) ); + aTblRegCB .Check( pLocalOptions->GetOption(VOPT_TABCONTROLS) ); + aOutlineCB .Check( pLocalOptions->GetOption(VOPT_OUTLINER) ); + + InitGridOpt(); + + aBreakCB.Check( pLocalOptions->GetOption(VOPT_PAGEBREAKS) ); + aGuideLineCB.Check( pLocalOptions->GetOption(VOPT_HELPLINES) ); + aHandleCB.Check( !pLocalOptions->GetOption(VOPT_SOLIDHANDLES) ); // inverted + aBigHandleCB.Check( pLocalOptions->GetOption(VOPT_BIGHANDLES) ); + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_RANGEFINDER, FALSE, &pItem)) + aRangeFindCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_OPT_SYNCZOOM, FALSE, &pItem)) + aSyncZoomCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + aRangeFindCB.SaveValue(); + aSyncZoomCB.SaveValue(); + + aFormulaCB .SaveValue(); + aNilCB .SaveValue(); + aAnnotCB .SaveValue(); + aValueCB .SaveValue(); + aAnchorCB .SaveValue(); + aClipMarkCB .SaveValue(); + aObjGrfLB .SaveValue(); + aDiagramLB .SaveValue(); + aDrawLB .SaveValue(); + aRowColHeaderCB .SaveValue(); + aHScrollCB .SaveValue(); + aVScrollCB .SaveValue(); + aTblRegCB .SaveValue(); + aOutlineCB .SaveValue(); + aGridCB .SaveValue(); + aColorLB .SaveValue(); + aBreakCB .SaveValue(); + aGuideLineCB .SaveValue(); + aHandleCB .SaveValue(); + aBigHandleCB .SaveValue(); +} +/*-----------------11.01.97 12.45------------------- + +--------------------------------------------------*/ + +void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet) +{ + const SfxPoolItem* pItem; + if(SFX_ITEM_SET == rSet.GetItemState(SID_SCVIEWOPTIONS, FALSE , &pItem)) + *pLocalOptions = ((const ScTpViewItem*)pItem)->GetViewOptions(); +} +/*-----------------11.01.97 12.45------------------- + +--------------------------------------------------*/ + +int ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP ) +{ + if(pSetP) + FillItemSet(*pSetP); + return SfxTabPage::LEAVE_PAGE; +} +/*-----------------11.01.97 13.43------------------- + +--------------------------------------------------*/ + +IMPL_LINK( ScTpContentOptions, SelLbObjHdl, ListBox*, pLb ) +{ + USHORT nSelPos = pLb->GetSelectEntryPos(); + ScVObjMode eMode = ScVObjMode(nSelPos); + ScVObjType eType = VOBJ_TYPE_OLE; + + if ( pLb == &aDiagramLB ) + eType = VOBJ_TYPE_CHART; + else if ( pLb == &aDrawLB ) + eType = VOBJ_TYPE_DRAW; + + pLocalOptions->SetObjMode( eType, eMode ); + + return 0; +} + +/*-----------------11.01.97 14.25------------------- + +--------------------------------------------------*/ + +IMPL_LINK( ScTpContentOptions, CBHdl, CheckBox*, pBtn ) +{ + ScViewOption eOption = VOPT_FORMULAS; + BOOL bChecked = pBtn->IsChecked(); + + if ( &aFormulaCB == pBtn ) eOption = VOPT_FORMULAS; + else if ( &aNilCB == pBtn ) eOption = VOPT_NULLVALS; + else if ( &aAnnotCB == pBtn ) eOption = VOPT_NOTES; + else if ( &aValueCB == pBtn ) eOption = VOPT_SYNTAX; + else if ( &aAnchorCB == pBtn ) eOption = VOPT_ANCHOR; + else if ( &aClipMarkCB == pBtn ) eOption = VOPT_CLIPMARKS; + else if ( &aVScrollCB == pBtn ) eOption = VOPT_VSCROLL; + else if ( &aHScrollCB == pBtn ) eOption = VOPT_HSCROLL; + else if ( &aTblRegCB == pBtn ) eOption = VOPT_TABCONTROLS; + else if ( &aOutlineCB == pBtn ) eOption = VOPT_OUTLINER; + else if ( &aBreakCB == pBtn ) eOption = VOPT_PAGEBREAKS; + else if ( &aGuideLineCB == pBtn ) eOption = VOPT_HELPLINES; + else if ( &aHandleCB == pBtn ) eOption = VOPT_SOLIDHANDLES; + else if ( &aBigHandleCB == pBtn ) eOption = VOPT_BIGHANDLES; + else if ( &aRowColHeaderCB == pBtn ) eOption = VOPT_HEADER; + + // VOPT_SOLIDHANDLES is inverted (CheckBox is "simple handles") + if ( eOption == VOPT_SOLIDHANDLES ) + pLocalOptions->SetOption( eOption, !bChecked ); + else + pLocalOptions->SetOption( eOption, bChecked ); + + + return 0; +} +/*-----------------11.01.97 13.13------------------- + +--------------------------------------------------*/ + +void ScTpContentOptions::InitGridOpt() +{ + BOOL bGrid = pLocalOptions->GetOption( VOPT_GRID ); + + aGridCB.Check( bGrid ); + + if ( bGrid ) + aColorFT.Enable(), aColorLB.Enable(); + else + aColorFT.Disable(), aColorLB.Disable(); + + if ( aColorLB.GetEntryCount() == 0 ) + { + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + // hier koennte auch eine andere DocShell kommen! + pDocSh = PTR_CAST(ScDocShell, pDocSh); + + XColorTable* pColorTable = NULL; + + if ( pDocSh ) + { + const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); + + if ( pItem ) + pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); + } + else + pColorTable = XColorTable::GetStdColorTable(); + + if ( !pColorTable ) + return; + + //------------------------------------------------------ + + aColorLB.SetUpdateMode( FALSE ); + + // Eintraege aus der Colortable + + long nCount = pColorTable->Count(); + for ( long n=0; n<nCount; n++ ) + { + XColorEntry* pEntry = pColorTable->GetColor(n); + aColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); + } + + // Standard-Gitterfarbe + + Color aStdCol( SC_STD_GRIDCOLOR ); // wie Default in ScViewOptions + if ( LISTBOX_ENTRY_NOTFOUND == + aColorLB.GetEntryPos( aStdCol ) ) + aColorLB.InsertEntry( aStdCol, ScGlobal::GetRscString( STR_GRIDCOLOR ) ); + + aColorLB.SetUpdateMode( TRUE ); + + Invalidate(); + } + + // #79720# also select grid color entry on subsequent calls + + String aName; + Color aCol = pLocalOptions->GetGridColor( &aName ); + USHORT nSelPos = aColorLB.GetEntryPos( aCol ); + + if ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) + aColorLB.SelectEntryPos( nSelPos ); + else + aColorLB.SelectEntryPos( aColorLB.InsertEntry( aCol, aName ) ); +} +/*-----------------11.01.97 13.40------------------- + +--------------------------------------------------*/ + +IMPL_LINK( ScTpContentOptions, GridHdl, CheckBox*, pBox ) +{ + BOOL bChecked = pBox->IsChecked(); + aColorFT.Enable(bChecked); + aColorLB.Enable(bChecked); + pLocalOptions->SetOption( VOPT_GRID, bChecked ); + return 0; +} +/*-----------------11.01.97 10.53------------------- + +--------------------------------------------------*/ + +ScTpLayoutOptions::ScTpLayoutOptions( Window* pParent, + const SfxItemSet& rArgSet ) : + SfxTabPage(pParent, ScResId( RID_SCPAGE_LAYOUT ), rArgSet), + aUnitGB( this, ScResId(GB_UNIT )), + aUnitFT( this, ScResId(FT_UNIT )), + aUnitLB( this, ScResId(LB_UNIT )), + aTabFT( this, ScResId( FT_TAB )), + aTabMF( this, ScResId( MF_TAB )), + aSeparatorFL( this, ScResId( FL_SEPARATOR )), + aLinkGB (this, ScResId(GB_LINK )), + aLinkFT(this, ScResId(FT_UPDATE_LINKS )), + aAlwaysRB (this, ScResId(RB_ALWAYS )), + aRequestRB (this, ScResId(RB_REQUEST )), + aNeverRB (this, ScResId(RB_NEVER )), + + aOptionsGB( this, ScResId( GB_OPTIONS )), + aAlignCB ( this, ScResId( CB_ALIGN )), + aAlignLB ( this, ScResId( LB_ALIGN )), + aEditModeCB( this, ScResId( CB_EDITMODE )), + aFormatCB( this, ScResId( CB_FORMAT )), + aExpRefCB( this, ScResId( CB_EXPREF )), + aMarkHdrCB( this, ScResId( CB_MARKHDR )), + aTextFmtCB( this, ScResId( CB_TEXTFMT )), + aReplWarnCB( this, ScResId( CB_REPLWARN )), + aUnitArr( ScResId(ST_UNIT )), + pDoc(NULL) +{ + FreeResource(); + aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT ); + SetExchangeSupport(); + + aUnitLB. SetSelectHdl( LINK( this, ScTpLayoutOptions, MetricHdl ) ); + + aAlignCB.SetClickHdl(LINK(this, ScTpLayoutOptions, AlignHdl)); + + + for ( USHORT i = 0; i < aUnitArr.Count(); ++i ) + { + String sMetric = aUnitArr.GetStringByPos( i ); + FieldUnit eFUnit = (FieldUnit)aUnitArr.GetValue( i ); + + switch ( eFUnit ) + { + case FUNIT_MM: + case FUNIT_CM: + case FUNIT_POINT: + case FUNIT_PICA: + case FUNIT_INCH: + { + // nur diese Metriken benutzen + USHORT nPos = aUnitLB.InsertEntry( sMetric ); + aUnitLB.SetEntryData( nPos, (void*)(long)eFUnit ); + } + break; + default: + { + // added to avoid warnings + } + } + } + +} +/*-----------------11.01.97 10.53------------------- + +--------------------------------------------------*/ + +ScTpLayoutOptions::~ScTpLayoutOptions() +{ +} +/*-----------------11.01.97 10.53------------------- + +--------------------------------------------------*/ + +SfxTabPage* ScTpLayoutOptions::Create( Window* pParent, + const SfxItemSet& rCoreSet ) +{ + ScTpLayoutOptions* pNew = new ScTpLayoutOptions(pParent, rCoreSet); + ScDocShell* pDocSh = PTR_CAST(ScDocShell,SfxObjectShell::Current()); + + if(pDocSh!=NULL) + pNew->SetDocument(pDocSh->GetDocument()); + return pNew; +} +/*-----------------11.01.97 10.53------------------- + +--------------------------------------------------*/ + +BOOL ScTpLayoutOptions::FillItemSet( SfxItemSet& rCoreSet ) +{ + BOOL bRet = TRUE; + const USHORT nMPos = aUnitLB.GetSelectEntryPos(); + if ( nMPos != aUnitLB.GetSavedValue() ) + { + USHORT nFieldUnit = (USHORT)(long)aUnitLB.GetEntryData( nMPos ); + rCoreSet.Put( SfxUInt16Item( SID_ATTR_METRIC, + (UINT16)nFieldUnit ) ); + bRet = TRUE; + } + + if(aTabMF.GetText() != aTabMF.GetSavedValue()) + { + rCoreSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP, + sal::static_int_cast<UINT16>( aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP)) ))); + bRet = TRUE; + } + + ScLkUpdMode nSet=LM_ALWAYS; + + if(aRequestRB.IsChecked()) + { + nSet=LM_ON_DEMAND; + } + else if(aNeverRB.IsChecked()) + { + nSet=LM_NEVER; + } + + if(aRequestRB.IsChecked() != aRequestRB.GetSavedValue() || + aNeverRB.IsChecked() != aNeverRB.GetSavedValue() ) + { + if(pDoc) + pDoc->SetLinkMode(nSet); + ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); + aAppOptions.SetLinkMode(nSet ); + SC_MOD()->SetAppOptions(aAppOptions); + bRet = TRUE; + } + if(aAlignCB.GetSavedValue() != aAlignCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_SELECTION, aAlignCB.IsChecked())); + bRet = TRUE; + } + + if(aAlignLB.GetSavedValue() != aAlignLB.GetSelectEntryPos()) + { + rCoreSet.Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS, aAlignLB.GetSelectEntryPos())); + bRet = TRUE; + } + + if(aEditModeCB.GetSavedValue() != aEditModeCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_EDITMODE, aEditModeCB.IsChecked())); + bRet = TRUE; + } + + if(aFormatCB.GetSavedValue() != aFormatCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND, aFormatCB.IsChecked())); + bRet = TRUE; + } + + + if(aExpRefCB.GetSavedValue() != aExpRefCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND, aExpRefCB.IsChecked())); + bRet = TRUE; + } + + if(aMarkHdrCB.GetSavedValue() != aMarkHdrCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, aMarkHdrCB.IsChecked())); + bRet = TRUE; + } + + if(aTextFmtCB.GetSavedValue() != aTextFmtCB.IsChecked()) + { + rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_TEXTWYSIWYG, aTextFmtCB.IsChecked())); + bRet = TRUE; + } + + if( aReplWarnCB.GetSavedValue() != aReplWarnCB.IsChecked() ) + { + rCoreSet.Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, aReplWarnCB.IsChecked() ) ); + bRet = TRUE; + } + + return bRet; +} +/*-----------------11.01.97 10.53------------------- + +--------------------------------------------------*/ + +void ScTpLayoutOptions::Reset( const SfxItemSet& rCoreSet ) +{ + aUnitLB.SetNoSelection(); + if ( rCoreSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE ) + { + const SfxUInt16Item& rItem = (SfxUInt16Item&)rCoreSet.Get( SID_ATTR_METRIC ); + FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue(); + + for ( USHORT i = 0; i < aUnitLB.GetEntryCount(); ++i ) + { + if ( (FieldUnit)(long)aUnitLB.GetEntryData( i ) == eFieldUnit ) + { + aUnitLB.SelectEntryPos( i ); + break; + } + } + ::SetFieldUnit(aTabMF, eFieldUnit); + } + aUnitLB.SaveValue(); + + const SfxPoolItem* pItem; + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_ATTR_DEFTABSTOP, FALSE, &pItem)) + aTabMF.SetValue(aTabMF.Normalize(((SfxUInt16Item*)pItem)->GetValue()), FUNIT_TWIP); + aTabMF.SaveValue(); + + aUnitLB .SaveValue(); + aTabMF .SaveValue(); + + ScLkUpdMode nSet=LM_UNKNOWN; + + if(pDoc!=NULL) + { + nSet=pDoc->GetLinkMode(); + } + + if(nSet==LM_UNKNOWN) + { + ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); + nSet=aAppOptions.GetLinkMode(); + } + + switch(nSet) + { + case LM_ALWAYS: aAlwaysRB. Check(); break; + case LM_NEVER: aNeverRB. Check(); break; + case LM_ON_DEMAND: aRequestRB. Check(); break; + default: + { + // added to avoid warnings + } + } + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTION, FALSE, &pItem)) + aAlignCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTIONPOS, FALSE, &pItem)) + aAlignLB.SelectEntryPos(((const SfxUInt16Item*)pItem)->GetValue()); + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_EDITMODE, FALSE, &pItem)) + aEditModeCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_FMT_EXPAND, FALSE, &pItem)) + aFormatCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_REF_EXPAND, FALSE, &pItem)) + aExpRefCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_MARK_HEADER, FALSE, &pItem)) + aMarkHdrCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_TEXTWYSIWYG, FALSE, &pItem)) + aTextFmtCB.Check(((const SfxBoolItem*)pItem)->GetValue()); + + if( SFX_ITEM_SET == rCoreSet.GetItemState( SID_SC_INPUT_REPLCELLSWARN, FALSE, &pItem ) ) + aReplWarnCB.Check( ( (const SfxBoolItem*)pItem)->GetValue() ); + + aAlignCB .SaveValue(); + aAlignLB .SaveValue(); + aEditModeCB .SaveValue(); + aFormatCB .SaveValue(); + + aExpRefCB .SaveValue(); + aMarkHdrCB .SaveValue(); + aTextFmtCB .SaveValue(); + aReplWarnCB .SaveValue(); + AlignHdl(&aAlignCB); + + aAlwaysRB.SaveValue(); + aNeverRB.SaveValue(); + aRequestRB.SaveValue(); +} + +/*-----------------11.01.97 12.46------------------- + +--------------------------------------------------*/ + +void ScTpLayoutOptions::ActivatePage( const SfxItemSet& /* rCoreSet */ ) +{ +} +/*-----------------11.01.97 12.46------------------- + +--------------------------------------------------*/ + +int ScTpLayoutOptions::DeactivatePage( SfxItemSet* pSetP ) +{ + if(pSetP) + FillItemSet(*pSetP); + return SfxTabPage::LEAVE_PAGE; +} + + +/*-----------------13.01.97 14.44------------------- + Metric des Deftabstops umschalten +--------------------------------------------------*/ + +IMPL_LINK(ScTpLayoutOptions, MetricHdl, ListBox*, EMPTYARG) +{ + const USHORT nMPos = aUnitLB.GetSelectEntryPos(); + if(nMPos != USHRT_MAX) + { + FieldUnit eFieldUnit = (FieldUnit)(long)aUnitLB.GetEntryData( nMPos ); + sal_Int64 nVal = + aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) ); + ::SetFieldUnit( aTabMF, eFieldUnit ); + aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP ); + } + + return 0; +} +/*-----------------11.01.97 15.30------------------- + +--------------------------------------------------*/ +IMPL_LINK( ScTpLayoutOptions, AlignHdl, CheckBox*, pBox ) +{ + aAlignLB.Enable(pBox->IsChecked()); + return 0; +} + + |