merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / optdlg / tpprint.cxx
blob3e557d8d94926c095128bf234175013aa142a573
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tpprint.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
36 #include <svtools/eitem.hxx>
38 #include "tpprint.hxx"
39 #include "printopt.hxx"
40 #include "scmod.hxx"
41 #include "scresid.hxx"
42 #include "sc.hrc"
43 #include "optdlg.hrc"
45 // -----------------------------------------------------------------------
47 static USHORT pPrintOptRanges[] =
49 SID_SCPRINTOPTIONS,
50 SID_SCPRINTOPTIONS,
54 // -----------------------------------------------------------------------
56 ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
57 const SfxItemSet& rCoreAttrs )
58 : SfxTabPage ( pParent,
59 ScResId( RID_SCPAGE_PRINT ),
60 rCoreAttrs ),
61 aPagesFL ( this, ScResId( FL_PAGES ) ),
62 aSkipEmptyPagesCB( this, ScResId( BTN_SKIPEMPTYPAGES ) ),
63 aSheetsFL ( this, ScResId( FL_SHEETS ) ),
64 aSelectedSheetsCB( this, ScResId( BTN_SELECTEDSHEETS ) )
66 FreeResource();
69 ScTpPrintOptions::~ScTpPrintOptions()
73 USHORT* ScTpPrintOptions::GetRanges()
75 return pPrintOptRanges;
78 SfxTabPage* ScTpPrintOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
80 return new ScTpPrintOptions( pParent, rAttrSet );
83 int ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP )
85 if ( pSetP )
86 FillItemSet( *pSetP );
88 return LEAVE_PAGE;
91 // -----------------------------------------------------------------------
93 void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
95 ScPrintOptions aOptions;
97 const SfxPoolItem* pItem;
98 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCPRINTOPTIONS, FALSE , &pItem))
99 aOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
100 else
102 // when called from print dialog and no options set, use configuration
103 aOptions = SC_MOD()->GetPrintOptions();
106 if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_PRINT_SELECTEDSHEET, FALSE , &pItem ) )
108 BOOL bChecked = ( (const SfxBoolItem*)pItem )->GetValue();
109 aSelectedSheetsCB.Check( bChecked );
111 else
113 aSelectedSheetsCB.Check( !aOptions.GetAllSheets() );
116 aSkipEmptyPagesCB.Check( aOptions.GetSkipEmpty() );
117 aSkipEmptyPagesCB.SaveValue();
118 aSelectedSheetsCB.SaveValue();
121 // -----------------------------------------------------------------------
123 BOOL ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
125 rCoreAttrs.ClearItem( SID_PRINT_SELECTEDSHEET );
127 bool bSkipEmptyChanged = ( aSkipEmptyPagesCB.GetSavedValue() != aSkipEmptyPagesCB.IsChecked() );
128 bool bSelectedSheetsChanged = ( aSelectedSheetsCB.GetSavedValue() != aSelectedSheetsCB.IsChecked() );
130 if ( bSkipEmptyChanged || bSelectedSheetsChanged )
132 ScPrintOptions aOpt;
133 aOpt.SetSkipEmpty( aSkipEmptyPagesCB.IsChecked() );
134 aOpt.SetAllSheets( !aSelectedSheetsCB.IsChecked() );
135 rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
136 if ( bSelectedSheetsChanged )
138 rCoreAttrs.Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, aSelectedSheetsCB.IsChecked() ) );
140 return TRUE;
142 else
144 return FALSE;