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