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 .
20 #undef SC_DLLIMPLEMENTATION
22 #include <svl/eitem.hxx>
24 #include "tpprint.hxx"
25 #include "printopt.hxx"
27 #include "scresid.hxx"
30 ScTpPrintOptions::ScTpPrintOptions( vcl::Window
* pParent
,
31 const SfxItemSet
& rCoreAttrs
)
32 : SfxTabPage ( pParent
,
34 "modules/scalc/ui/optdlg.ui",
37 get( m_pSkipEmptyPagesCB
, "suppressCB" );
38 get( m_pSelectedSheetsCB
, "printCB" );
39 get( m_pForceBreaksCB
, "forceBreaksCB" );
42 ScTpPrintOptions::~ScTpPrintOptions()
47 void ScTpPrintOptions::dispose()
49 m_pSkipEmptyPagesCB
.clear();
50 m_pSelectedSheetsCB
.clear();
51 m_pForceBreaksCB
.clear();
52 SfxTabPage::dispose();
55 VclPtr
<SfxTabPage
> ScTpPrintOptions::Create( vcl::Window
* pParent
, const SfxItemSet
* rAttrSet
)
57 return VclPtr
<ScTpPrintOptions
>::Create( pParent
, *rAttrSet
);
60 SfxTabPage::sfxpg
ScTpPrintOptions::DeactivatePage( SfxItemSet
* pSetP
)
68 void ScTpPrintOptions::Reset( const SfxItemSet
* rCoreSet
)
70 ScPrintOptions aOptions
;
72 const SfxPoolItem
* pItem
;
73 if(SfxItemState::SET
== rCoreSet
->GetItemState(SID_SCPRINTOPTIONS
, false , &pItem
))
74 aOptions
= static_cast<const ScTpPrintItem
*>(pItem
)->GetPrintOptions();
77 // when called from print dialog and no options set, use configuration
78 aOptions
= SC_MOD()->GetPrintOptions();
81 if ( SfxItemState::SET
== rCoreSet
->GetItemState( SID_PRINT_SELECTEDSHEET
, false , &pItem
) )
83 bool bChecked
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
84 m_pSelectedSheetsCB
->Check( bChecked
);
88 m_pSelectedSheetsCB
->Check( !aOptions
.GetAllSheets() );
91 m_pSkipEmptyPagesCB
->Check( aOptions
.GetSkipEmpty() );
92 m_pSkipEmptyPagesCB
->SaveValue();
93 m_pSelectedSheetsCB
->SaveValue();
94 m_pForceBreaksCB
->Check( aOptions
.GetForceBreaks() );
95 m_pForceBreaksCB
->SaveValue();
98 bool ScTpPrintOptions::FillItemSet( SfxItemSet
* rCoreAttrs
)
100 rCoreAttrs
->ClearItem( SID_PRINT_SELECTEDSHEET
);
102 bool bSkipEmptyChanged
= m_pSkipEmptyPagesCB
->IsValueChangedFromSaved();
103 bool bSelectedSheetsChanged
= m_pSelectedSheetsCB
->IsValueChangedFromSaved();
104 bool bForceBreaksChanged
= m_pForceBreaksCB
->IsValueChangedFromSaved();
106 if ( bSkipEmptyChanged
|| bSelectedSheetsChanged
|| bForceBreaksChanged
)
109 aOpt
.SetSkipEmpty( m_pSkipEmptyPagesCB
->IsChecked() );
110 aOpt
.SetAllSheets( !m_pSelectedSheetsCB
->IsChecked() );
111 aOpt
.SetForceBreaks( m_pForceBreaksCB
->IsChecked() );
112 rCoreAttrs
->Put( ScTpPrintItem( SID_SCPRINTOPTIONS
, aOpt
) );
113 if ( bSelectedSheetsChanged
)
115 rCoreAttrs
->Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET
, m_pSelectedSheetsCB
->IsChecked() ) );
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */