LibreOffice Module sc (master) 1
tpprint.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#undef SC_DLLIMPLEMENTATION
21
22#include <svl/eitem.hxx>
23
24#include <tpprint.hxx>
25#include <printopt.hxx>
26#include <scmod.hxx>
27#include <sc.hrc>
28
30 const SfxItemSet& rCoreAttrs )
31 : SfxTabPage(pPage, pController, "modules/scalc/ui/optdlg.ui", "optCalcPrintPage", &rCoreAttrs )
32 , m_xSkipEmptyPagesCB(m_xBuilder->weld_check_button("suppressCB"))
33 , m_xSelectedSheetsCB(m_xBuilder->weld_check_button("printCB"))
34 , m_xForceBreaksCB(m_xBuilder->weld_check_button("forceBreaksCB"))
35{
36}
37
39{
40}
41
42std::unique_ptr<SfxTabPage> ScTpPrintOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
43{
44 return std::make_unique<ScTpPrintOptions>(pPage, pController, *rAttrSet);
45}
46
48{
49 if ( pSetP )
50 FillItemSet( pSetP );
51
52 return DeactivateRC::LeavePage;
53}
54
55void ScTpPrintOptions::Reset( const SfxItemSet* rCoreSet )
56{
57 ScPrintOptions aOptions;
58
59 if(const ScTpPrintItem* pItem = rCoreSet->GetItemIfSet(SID_SCPRINTOPTIONS, false))
60 aOptions = pItem->GetPrintOptions();
61 else
62 {
63 // when called from print dialog and no options set, use configuration
64 aOptions = SC_MOD()->GetPrintOptions();
65 }
66
67 if ( const SfxBoolItem* pItem = rCoreSet->GetItemIfSet( SID_PRINT_SELECTEDSHEET, false))
68 {
69 bool bChecked = pItem->GetValue();
70 m_xSelectedSheetsCB->set_active( bChecked );
71 }
72 else
73 {
74 m_xSelectedSheetsCB->set_active( !aOptions.GetAllSheets() );
75 }
76
77 m_xSkipEmptyPagesCB->set_active( aOptions.GetSkipEmpty() );
78 m_xSkipEmptyPagesCB->save_state();
79 m_xSelectedSheetsCB->save_state();
80 m_xForceBreaksCB->set_active( aOptions.GetForceBreaks() );
81 m_xForceBreaksCB->save_state();
82}
83
85{
86 rCoreAttrs->ClearItem( SID_PRINT_SELECTEDSHEET );
87
88 bool bSkipEmptyChanged = m_xSkipEmptyPagesCB->get_state_changed_from_saved();
89 bool bSelectedSheetsChanged = m_xSelectedSheetsCB->get_state_changed_from_saved();
90 bool bForceBreaksChanged = m_xForceBreaksCB->get_state_changed_from_saved();
91
92 if ( bSkipEmptyChanged || bSelectedSheetsChanged || bForceBreaksChanged )
93 {
94 ScPrintOptions aOpt;
95 aOpt.SetSkipEmpty( m_xSkipEmptyPagesCB->get_active() );
96 aOpt.SetAllSheets( !m_xSelectedSheetsCB->get_active() );
97 aOpt.SetForceBreaks( m_xForceBreaksCB->get_active() );
98 rCoreAttrs->Put( ScTpPrintItem( aOpt ) );
99 if ( bSelectedSheetsChanged )
100 {
101 rCoreAttrs->Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, m_xSelectedSheetsCB->get_active() ) );
102 }
103 return true;
104 }
105 else
106 {
107 return false;
108 }
109}
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetSkipEmpty() const
Definition: printopt.hxx:36
void SetSkipEmpty(bool bVal)
Definition: printopt.hxx:37
bool GetForceBreaks() const
Definition: printopt.hxx:40
void SetAllSheets(bool bVal)
Definition: printopt.hxx:39
void SetForceBreaks(bool bVal)
Definition: printopt.hxx:41
bool GetAllSheets() const
Definition: printopt.hxx:38
virtual void Reset(const SfxItemSet *rCoreSet) override
Definition: tpprint.cxx:55
std::unique_ptr< weld::CheckButton > m_xForceBreaksCB
Definition: tpprint.hxx:28
ScTpPrintOptions(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
Definition: tpprint.cxx:29
virtual bool FillItemSet(SfxItemSet *rCoreSet) override
Definition: tpprint.cxx:84
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: tpprint.cxx:47
std::unique_ptr< weld::CheckButton > m_xSkipEmptyPagesCB
Definition: tpprint.hxx:26
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rCoreSet)
Definition: tpprint.cxx:42
std::unique_ptr< weld::CheckButton > m_xSelectedSheetsCB
Definition: tpprint.hxx:27
virtual ~ScTpPrintOptions() override
Definition: tpprint.cxx:38
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
#define SC_MOD()
Definition: scmod.hxx:249
DeactivateRC