Line data Source code
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 :
21 : #undef SC_DLLIMPLEMENTATION
22 :
23 : #include <svl/eitem.hxx>
24 :
25 : #include "tpprint.hxx"
26 : #include "printopt.hxx"
27 : #include "scmod.hxx"
28 : #include "scresid.hxx"
29 : #include "sc.hrc"
30 : #include "optdlg.hrc"
31 :
32 : // -----------------------------------------------------------------------
33 :
34 0 : ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
35 : const SfxItemSet& rCoreAttrs )
36 : : SfxTabPage ( pParent,
37 : "optCalcPrintPage",
38 : "modules/scalc/ui/optdlg.ui",
39 0 : rCoreAttrs )
40 : {
41 0 : get( m_pSkipEmptyPagesCB , "suppressCB" );
42 0 : get( m_pSelectedSheetsCB , "printCB" );
43 0 : }
44 :
45 0 : ScTpPrintOptions::~ScTpPrintOptions()
46 : {
47 0 : }
48 :
49 0 : SfxTabPage* ScTpPrintOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
50 : {
51 0 : return new ScTpPrintOptions( pParent, rAttrSet );
52 : }
53 :
54 0 : int ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP )
55 : {
56 0 : if ( pSetP )
57 0 : FillItemSet( *pSetP );
58 :
59 0 : return LEAVE_PAGE;
60 : }
61 :
62 : // -----------------------------------------------------------------------
63 :
64 0 : void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
65 : {
66 0 : ScPrintOptions aOptions;
67 :
68 : const SfxPoolItem* pItem;
69 0 : if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCPRINTOPTIONS, false , &pItem))
70 0 : aOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
71 : else
72 : {
73 : // when called from print dialog and no options set, use configuration
74 0 : aOptions = SC_MOD()->GetPrintOptions();
75 : }
76 :
77 0 : if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_PRINT_SELECTEDSHEET, false , &pItem ) )
78 : {
79 0 : sal_Bool bChecked = ( (const SfxBoolItem*)pItem )->GetValue();
80 0 : m_pSelectedSheetsCB->Check( bChecked );
81 : }
82 : else
83 : {
84 0 : m_pSelectedSheetsCB->Check( !aOptions.GetAllSheets() );
85 : }
86 :
87 0 : m_pSkipEmptyPagesCB->Check( aOptions.GetSkipEmpty() );
88 0 : m_pSkipEmptyPagesCB->SaveValue();
89 0 : m_pSelectedSheetsCB->SaveValue();
90 0 : }
91 :
92 : // -----------------------------------------------------------------------
93 :
94 0 : sal_Bool ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
95 : {
96 0 : rCoreAttrs.ClearItem( SID_PRINT_SELECTEDSHEET );
97 :
98 0 : bool bSkipEmptyChanged = ( m_pSkipEmptyPagesCB->GetSavedValue() != m_pSkipEmptyPagesCB->IsChecked() );
99 0 : bool bSelectedSheetsChanged = ( m_pSelectedSheetsCB->GetSavedValue() != m_pSelectedSheetsCB->IsChecked() );
100 :
101 0 : if ( bSkipEmptyChanged || bSelectedSheetsChanged )
102 : {
103 0 : ScPrintOptions aOpt;
104 0 : aOpt.SetSkipEmpty( m_pSkipEmptyPagesCB->IsChecked() );
105 0 : aOpt.SetAllSheets( !m_pSelectedSheetsCB->IsChecked() );
106 0 : rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
107 0 : if ( bSelectedSheetsChanged )
108 : {
109 0 : rCoreAttrs.Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, m_pSelectedSheetsCB->IsChecked() ) );
110 : }
111 0 : return sal_True;
112 : }
113 : else
114 : {
115 0 : return false;
116 : }
117 0 : }
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|