1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b3f79822SAndrew Rist * distributed with this work for additional information
6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17*b3f79822SAndrew Rist * specific language governing permissions and limitations
18*b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*b3f79822SAndrew Rist *************************************************************/
21*b3f79822SAndrew Rist
22*b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <svl/eitem.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "tpprint.hxx"
32cdf0e10cSrcweir #include "printopt.hxx"
33cdf0e10cSrcweir #include "scmod.hxx"
34cdf0e10cSrcweir #include "scresid.hxx"
35cdf0e10cSrcweir #include "sc.hrc"
36cdf0e10cSrcweir #include "optdlg.hrc"
37cdf0e10cSrcweir
38cdf0e10cSrcweir // -----------------------------------------------------------------------
39cdf0e10cSrcweir
40cdf0e10cSrcweir static sal_uInt16 pPrintOptRanges[] =
41cdf0e10cSrcweir {
42cdf0e10cSrcweir SID_SCPRINTOPTIONS,
43cdf0e10cSrcweir SID_SCPRINTOPTIONS,
44cdf0e10cSrcweir 0
45cdf0e10cSrcweir };
46cdf0e10cSrcweir
47cdf0e10cSrcweir // -----------------------------------------------------------------------
48cdf0e10cSrcweir
ScTpPrintOptions(Window * pParent,const SfxItemSet & rCoreAttrs)49cdf0e10cSrcweir ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
50cdf0e10cSrcweir const SfxItemSet& rCoreAttrs )
51cdf0e10cSrcweir : SfxTabPage ( pParent,
52cdf0e10cSrcweir ScResId( RID_SCPAGE_PRINT ),
53cdf0e10cSrcweir rCoreAttrs ),
54cdf0e10cSrcweir aPagesFL ( this, ScResId( FL_PAGES ) ),
55cdf0e10cSrcweir aSkipEmptyPagesCB( this, ScResId( BTN_SKIPEMPTYPAGES ) ),
56cdf0e10cSrcweir aSheetsFL ( this, ScResId( FL_SHEETS ) ),
57cdf0e10cSrcweir aSelectedSheetsCB( this, ScResId( BTN_SELECTEDSHEETS ) )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir FreeResource();
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
~ScTpPrintOptions()62cdf0e10cSrcweir ScTpPrintOptions::~ScTpPrintOptions()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
GetRanges()66cdf0e10cSrcweir sal_uInt16* ScTpPrintOptions::GetRanges()
67cdf0e10cSrcweir {
68cdf0e10cSrcweir return pPrintOptRanges;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rAttrSet)71cdf0e10cSrcweir SfxTabPage* ScTpPrintOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir return new ScTpPrintOptions( pParent, rAttrSet );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
DeactivatePage(SfxItemSet * pSetP)76cdf0e10cSrcweir int ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir if ( pSetP )
79cdf0e10cSrcweir FillItemSet( *pSetP );
80cdf0e10cSrcweir
81cdf0e10cSrcweir return LEAVE_PAGE;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir // -----------------------------------------------------------------------
85cdf0e10cSrcweir
Reset(const SfxItemSet & rCoreSet)86cdf0e10cSrcweir void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir ScPrintOptions aOptions;
89cdf0e10cSrcweir
90cdf0e10cSrcweir const SfxPoolItem* pItem;
91cdf0e10cSrcweir if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCPRINTOPTIONS, sal_False , &pItem))
92cdf0e10cSrcweir aOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
93cdf0e10cSrcweir else
94cdf0e10cSrcweir {
95cdf0e10cSrcweir // when called from print dialog and no options set, use configuration
96cdf0e10cSrcweir aOptions = SC_MOD()->GetPrintOptions();
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_PRINT_SELECTEDSHEET, sal_False , &pItem ) )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir sal_Bool bChecked = ( (const SfxBoolItem*)pItem )->GetValue();
102cdf0e10cSrcweir aSelectedSheetsCB.Check( bChecked );
103cdf0e10cSrcweir }
104cdf0e10cSrcweir else
105cdf0e10cSrcweir {
106cdf0e10cSrcweir aSelectedSheetsCB.Check( !aOptions.GetAllSheets() );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir aSkipEmptyPagesCB.Check( aOptions.GetSkipEmpty() );
110cdf0e10cSrcweir aSkipEmptyPagesCB.SaveValue();
111cdf0e10cSrcweir aSelectedSheetsCB.SaveValue();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir // -----------------------------------------------------------------------
115cdf0e10cSrcweir
FillItemSet(SfxItemSet & rCoreAttrs)116cdf0e10cSrcweir sal_Bool ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir rCoreAttrs.ClearItem( SID_PRINT_SELECTEDSHEET );
119cdf0e10cSrcweir
120cdf0e10cSrcweir bool bSkipEmptyChanged = ( aSkipEmptyPagesCB.GetSavedValue() != aSkipEmptyPagesCB.IsChecked() );
121cdf0e10cSrcweir bool bSelectedSheetsChanged = ( aSelectedSheetsCB.GetSavedValue() != aSelectedSheetsCB.IsChecked() );
122cdf0e10cSrcweir
123cdf0e10cSrcweir if ( bSkipEmptyChanged || bSelectedSheetsChanged )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir ScPrintOptions aOpt;
126cdf0e10cSrcweir aOpt.SetSkipEmpty( aSkipEmptyPagesCB.IsChecked() );
127cdf0e10cSrcweir aOpt.SetAllSheets( !aSelectedSheetsCB.IsChecked() );
128cdf0e10cSrcweir rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
129cdf0e10cSrcweir if ( bSelectedSheetsChanged )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir rCoreAttrs.Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, aSelectedSheetsCB.IsChecked() ) );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir return sal_True;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir else
136cdf0e10cSrcweir {
137cdf0e10cSrcweir return sal_False;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141