1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
28 #include "scresid.hxx"
32 // -----------------------------------------------------------------------
34 ScTpPrintOptions::ScTpPrintOptions( Window
* pParent
,
35 const SfxItemSet
& rCoreAttrs
)
36 : SfxTabPage ( pParent
,
37 ScResId( RID_SCPAGE_PRINT
),
39 aPagesFL ( this, ScResId( FL_PAGES
) ),
40 aSkipEmptyPagesCB( this, ScResId( BTN_SKIPEMPTYPAGES
) ),
41 aSheetsFL ( this, ScResId( FL_SHEETS
) ),
42 aSelectedSheetsCB( this, ScResId( BTN_SELECTEDSHEETS
) )
47 ScTpPrintOptions::~ScTpPrintOptions()
51 SfxTabPage
* ScTpPrintOptions::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
53 return new ScTpPrintOptions( pParent
, rAttrSet
);
56 int ScTpPrintOptions::DeactivatePage( SfxItemSet
* pSetP
)
59 FillItemSet( *pSetP
);
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();
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
);
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
)
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() ) );
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */