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 
42 std::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 
55 void ScTpPrintOptions::Reset( const SfxItemSet* rCoreSet )
56 {
57  ScPrintOptions aOptions;
58 
59  const SfxPoolItem* pItem;
60  if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCPRINTOPTIONS, false , &pItem))
61  aOptions = static_cast<const ScTpPrintItem*>(pItem)->GetPrintOptions();
62  else
63  {
64  // when called from print dialog and no options set, use configuration
65  aOptions = SC_MOD()->GetPrintOptions();
66  }
67 
68  if ( SfxItemState::SET == rCoreSet->GetItemState( SID_PRINT_SELECTEDSHEET, false , &pItem ) )
69  {
70  bool bChecked = static_cast<const SfxBoolItem*>(pItem)->GetValue();
71  m_xSelectedSheetsCB->set_active( bChecked );
72  }
73  else
74  {
75  m_xSelectedSheetsCB->set_active( !aOptions.GetAllSheets() );
76  }
77 
78  m_xSkipEmptyPagesCB->set_active( aOptions.GetSkipEmpty() );
79  m_xSkipEmptyPagesCB->save_state();
80  m_xSelectedSheetsCB->save_state();
81  m_xForceBreaksCB->set_active( aOptions.GetForceBreaks() );
82  m_xForceBreaksCB->save_state();
83 }
84 
86 {
87  rCoreAttrs->ClearItem( SID_PRINT_SELECTEDSHEET );
88 
89  bool bSkipEmptyChanged = m_xSkipEmptyPagesCB->get_state_changed_from_saved();
90  bool bSelectedSheetsChanged = m_xSelectedSheetsCB->get_state_changed_from_saved();
91  bool bForceBreaksChanged = m_xForceBreaksCB->get_state_changed_from_saved();
92 
93  if ( bSkipEmptyChanged || bSelectedSheetsChanged || bForceBreaksChanged )
94  {
95  ScPrintOptions aOpt;
96  aOpt.SetSkipEmpty( m_xSkipEmptyPagesCB->get_active() );
97  aOpt.SetAllSheets( !m_xSelectedSheetsCB->get_active() );
98  aOpt.SetForceBreaks( m_xForceBreaksCB->get_active() );
99  rCoreAttrs->Put( ScTpPrintItem( aOpt ) );
100  if ( bSelectedSheetsChanged )
101  {
102  rCoreAttrs->Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, m_xSelectedSheetsCB->get_active() ) );
103  }
104  return true;
105  }
106  else
107  {
108  return false;
109  }
110 }
111 
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool FillItemSet(SfxItemSet *rCoreSet) override
Definition: tpprint.cxx:85
virtual ~ScTpPrintOptions() override
Definition: tpprint.cxx:38
std::string GetValue
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_xForceBreaksCB
Definition: tpprint.hxx:29
void SetForceBreaks(bool bVal)
Definition: printopt.hxx:42
bool GetForceBreaks() const
Definition: printopt.hxx:41
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetAllSheets(bool bVal)
Definition: printopt.hxx:40
#define SC_MOD()
Definition: scmod.hxx:253
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::CheckButton > m_xSelectedSheetsCB
Definition: tpprint.hxx:28
std::unique_ptr< weld::CheckButton > m_xSkipEmptyPagesCB
Definition: tpprint.hxx:27
bool GetAllSheets() const
Definition: printopt.hxx:39
ScTpPrintOptions(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
Definition: tpprint.cxx:29
void SetSkipEmpty(bool bVal)
Definition: printopt.hxx:38
DeactivateRC
bool GetSkipEmpty() const
Definition: printopt.hxx:37
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: tpprint.cxx:47
virtual void Reset(const SfxItemSet *rCoreSet) override
Definition: tpprint.cxx:55