bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / optdlg / tpprint.cxx
blob9ca45c14e0873321e8be8a5c50ad4b438b5a1cb1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #undef SC_DLLIMPLEMENTATION
23 #include <svl/eitem.hxx>
25 #include "tpprint.hxx"
26 #include "printopt.hxx"
27 #include "scmod.hxx"
28 #include "scresid.hxx"
29 #include "sc.hrc"
30 #include "optdlg.hrc"
32 // -----------------------------------------------------------------------
34 ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
35 const SfxItemSet& rCoreAttrs )
36 : SfxTabPage ( pParent,
37 ScResId( RID_SCPAGE_PRINT ),
38 rCoreAttrs ),
39 aPagesFL ( this, ScResId( FL_PAGES ) ),
40 aSkipEmptyPagesCB( this, ScResId( BTN_SKIPEMPTYPAGES ) ),
41 aSheetsFL ( this, ScResId( FL_SHEETS ) ),
42 aSelectedSheetsCB( this, ScResId( BTN_SELECTEDSHEETS ) )
44 FreeResource();
47 ScTpPrintOptions::~ScTpPrintOptions()
51 SfxTabPage* ScTpPrintOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
53 return new ScTpPrintOptions( pParent, rAttrSet );
56 int ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP )
58 if ( pSetP )
59 FillItemSet( *pSetP );
61 return LEAVE_PAGE;
64 // -----------------------------------------------------------------------
66 void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
68 ScPrintOptions aOptions;
70 const SfxPoolItem* pItem;
71 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCPRINTOPTIONS, false , &pItem))
72 aOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
73 else
75 // when called from print dialog and no options set, use configuration
76 aOptions = SC_MOD()->GetPrintOptions();
79 if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_PRINT_SELECTEDSHEET, false , &pItem ) )
81 sal_Bool bChecked = ( (const SfxBoolItem*)pItem )->GetValue();
82 aSelectedSheetsCB.Check( bChecked );
84 else
86 aSelectedSheetsCB.Check( !aOptions.GetAllSheets() );
89 aSkipEmptyPagesCB.Check( aOptions.GetSkipEmpty() );
90 aSkipEmptyPagesCB.SaveValue();
91 aSelectedSheetsCB.SaveValue();
94 // -----------------------------------------------------------------------
96 sal_Bool ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
98 rCoreAttrs.ClearItem( SID_PRINT_SELECTEDSHEET );
100 bool bSkipEmptyChanged = ( aSkipEmptyPagesCB.GetSavedValue() != aSkipEmptyPagesCB.IsChecked() );
101 bool bSelectedSheetsChanged = ( aSelectedSheetsCB.GetSavedValue() != aSelectedSheetsCB.IsChecked() );
103 if ( bSkipEmptyChanged || bSelectedSheetsChanged )
105 ScPrintOptions aOpt;
106 aOpt.SetSkipEmpty( aSkipEmptyPagesCB.IsChecked() );
107 aOpt.SetAllSheets( !aSelectedSheetsCB.IsChecked() );
108 rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
109 if ( bSelectedSheetsChanged )
111 rCoreAttrs.Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, aSelectedSheetsCB.IsChecked() ) );
113 return sal_True;
115 else
117 return false;
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */