bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / dlg / prntopts.cxx
blob2c8131e2810443f7c85978a4fc9c81b8dbeaef20
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <sdattr.hrc>
21 #include <optsitem.hxx>
22 #include <prntopts.hxx>
23 #include <app.hrc>
24 #include <svl/intitem.hxx>
26 /**
27 * dialog to adjust print options
29 SdPrintOptions::SdPrintOptions( vcl::Window* pParent, const SfxItemSet& rInAttrs ) :
30 SfxTabPage ( pParent, "prntopts" , "modules/simpress/ui/prntopts.ui" , &rInAttrs )
32 get( m_pFrmContent , "contentframe" );
33 get( m_pCbxDraw , "drawingcb" );
34 get( m_pCbxNotes , "notecb" );
35 get( m_pCbxHandout , "handoutcb" );
36 get( m_pCbxOutline , "outlinecb");
37 get( m_pRbtColor , "defaultrb" );
38 get( m_pRbtGrayscale , "grayscalerb" );
39 get( m_pRbtBlackWhite , "blackwhiterb" );
40 get( m_pCbxPagename , "pagenmcb" );
41 get( m_pCbxDate , "datecb" );
42 get( m_pCbxTime , "timecb" );
43 get( m_pCbxHiddenPages , "hiddenpgcb" );
44 get( m_pRbtDefault , "pagedefaultrb" );
45 get( m_pRbtPagesize , "fittopgrb" );
46 get( m_pRbtPagetile , "tilepgrb" );
47 get( m_pRbtBooklet , "brouchrb" );
48 get( m_pCbxFront , "frontcb" );
49 get( m_pCbxBack , "backcb" );
50 get( m_pCbxPaperbin , "papertryfrmprntrcb" );
52 Link<Button*,void> aLink = LINK( this, SdPrintOptions, ClickBookletHdl );
53 m_pRbtDefault->SetClickHdl( aLink );
54 m_pRbtPagesize->SetClickHdl( aLink );
55 m_pRbtPagetile->SetClickHdl( aLink );
56 m_pRbtBooklet->SetClickHdl( aLink );
58 aLink = LINK( this, SdPrintOptions, ClickCheckboxHdl );
59 m_pCbxDraw->SetClickHdl( aLink );
60 m_pCbxNotes->SetClickHdl( aLink );
61 m_pCbxHandout->SetClickHdl( aLink );
62 m_pCbxOutline->SetClickHdl( aLink );
64 #ifndef MACOSX
65 SetDrawMode();
66 #endif
69 SdPrintOptions::~SdPrintOptions()
71 disposeOnce();
74 void SdPrintOptions::dispose()
76 m_pFrmContent.clear();
77 m_pCbxDraw.clear();
78 m_pCbxNotes.clear();
79 m_pCbxHandout.clear();
80 m_pCbxOutline.clear();
81 m_pRbtColor.clear();
82 m_pRbtGrayscale.clear();
83 m_pRbtBlackWhite.clear();
84 m_pCbxPagename.clear();
85 m_pCbxDate.clear();
86 m_pCbxTime.clear();
87 m_pCbxHiddenPages.clear();
88 m_pRbtDefault.clear();
89 m_pRbtPagesize.clear();
90 m_pRbtPagetile.clear();
91 m_pRbtBooklet.clear();
92 m_pCbxFront.clear();
93 m_pCbxBack.clear();
94 m_pCbxPaperbin.clear();
95 SfxTabPage::dispose();
98 bool SdPrintOptions::FillItemSet( SfxItemSet* rAttrs )
100 if( m_pCbxDraw->IsValueChangedFromSaved() ||
101 m_pCbxNotes->IsValueChangedFromSaved() ||
102 m_pCbxHandout->IsValueChangedFromSaved() ||
103 m_pCbxOutline->IsValueChangedFromSaved() ||
104 m_pCbxDate->IsValueChangedFromSaved() ||
105 m_pCbxTime->IsValueChangedFromSaved() ||
106 m_pCbxPagename->IsValueChangedFromSaved() ||
107 m_pCbxHiddenPages->IsValueChangedFromSaved() ||
108 m_pRbtPagesize->IsValueChangedFromSaved() ||
109 m_pRbtPagetile->IsValueChangedFromSaved() ||
110 m_pRbtBooklet->IsValueChangedFromSaved() ||
111 m_pCbxFront->IsValueChangedFromSaved() ||
112 m_pCbxBack->IsValueChangedFromSaved() ||
113 m_pCbxPaperbin->IsValueChangedFromSaved() ||
114 m_pRbtColor->IsValueChangedFromSaved() ||
115 m_pRbtGrayscale->IsValueChangedFromSaved()||
116 m_pRbtBlackWhite->IsValueChangedFromSaved())
118 SdOptionsPrintItem aOptions;
120 aOptions.GetOptionsPrint().SetDraw( m_pCbxDraw->IsChecked() );
121 aOptions.GetOptionsPrint().SetNotes( m_pCbxNotes->IsChecked() );
122 aOptions.GetOptionsPrint().SetHandout( m_pCbxHandout->IsChecked() );
123 aOptions.GetOptionsPrint().SetOutline( m_pCbxOutline->IsChecked() );
124 aOptions.GetOptionsPrint().SetDate( m_pCbxDate->IsChecked() );
125 aOptions.GetOptionsPrint().SetTime( m_pCbxTime->IsChecked() );
126 aOptions.GetOptionsPrint().SetPagename( m_pCbxPagename->IsChecked() );
127 aOptions.GetOptionsPrint().SetHiddenPages( m_pCbxHiddenPages->IsChecked() );
128 aOptions.GetOptionsPrint().SetPagesize( m_pRbtPagesize->IsChecked() );
129 aOptions.GetOptionsPrint().SetPagetile( m_pRbtPagetile->IsChecked() );
130 aOptions.GetOptionsPrint().SetBooklet( m_pRbtBooklet->IsChecked() );
131 aOptions.GetOptionsPrint().SetFrontPage( m_pCbxFront->IsChecked() );
132 aOptions.GetOptionsPrint().SetBackPage( m_pCbxBack->IsChecked() );
133 aOptions.GetOptionsPrint().SetPaperbin( m_pCbxPaperbin->IsChecked() );
135 sal_uInt16 nQuality = 0; // Standard, also Color
136 if( m_pRbtGrayscale->IsChecked() )
137 nQuality = 1;
138 if( m_pRbtBlackWhite->IsChecked() )
139 nQuality = 2;
140 aOptions.GetOptionsPrint().SetOutputQuality( nQuality );
142 rAttrs->Put( aOptions );
144 return true;
146 return false;
149 void SdPrintOptions::Reset( const SfxItemSet* rAttrs )
151 const SdOptionsPrintItem* pPrintOpts = nullptr;
152 if( SfxItemState::SET == rAttrs->GetItemState( ATTR_OPTIONS_PRINT, false,
153 reinterpret_cast<const SfxPoolItem**>(&pPrintOpts) ) )
155 m_pCbxDraw->Check( pPrintOpts->GetOptionsPrint().IsDraw() );
156 m_pCbxNotes->Check( pPrintOpts->GetOptionsPrint().IsNotes() );
157 m_pCbxHandout->Check( pPrintOpts->GetOptionsPrint().IsHandout() );
158 m_pCbxOutline->Check( pPrintOpts->GetOptionsPrint().IsOutline() );
159 m_pCbxDate->Check( pPrintOpts->GetOptionsPrint().IsDate() );
160 m_pCbxTime->Check( pPrintOpts->GetOptionsPrint().IsTime() );
161 m_pCbxPagename->Check( pPrintOpts->GetOptionsPrint().IsPagename() );
162 m_pCbxHiddenPages->Check( pPrintOpts->GetOptionsPrint().IsHiddenPages() );
163 m_pRbtPagesize->Check( pPrintOpts->GetOptionsPrint().IsPagesize() );
164 m_pRbtPagetile->Check( pPrintOpts->GetOptionsPrint().IsPagetile() );
165 m_pRbtBooklet->Check( pPrintOpts->GetOptionsPrint().IsBooklet() );
166 m_pCbxFront->Check( pPrintOpts->GetOptionsPrint().IsFrontPage() );
167 m_pCbxBack->Check( pPrintOpts->GetOptionsPrint().IsBackPage() );
168 m_pCbxPaperbin->Check( pPrintOpts->GetOptionsPrint().IsPaperbin() );
170 if( !m_pRbtPagesize->IsChecked() &&
171 !m_pRbtPagetile->IsChecked() &&
172 !m_pRbtBooklet->IsChecked() )
174 m_pRbtDefault->Check();
177 sal_uInt16 nQuality = pPrintOpts->GetOptionsPrint().GetOutputQuality();
178 if( nQuality == 0 )
179 m_pRbtColor->Check();
180 else if( nQuality == 1 )
181 m_pRbtGrayscale->Check();
182 else
183 m_pRbtBlackWhite->Check();
185 m_pCbxDraw->SaveValue();
186 m_pCbxNotes->SaveValue();
187 m_pCbxHandout->SaveValue();
188 m_pCbxOutline->SaveValue();
189 m_pCbxDate->SaveValue();
190 m_pCbxTime->SaveValue();
191 m_pCbxPagename->SaveValue();
192 m_pCbxHiddenPages->SaveValue();
193 m_pRbtPagesize->SaveValue();
194 m_pRbtPagetile->SaveValue();
195 m_pRbtBooklet->SaveValue();
196 m_pCbxPaperbin->SaveValue();
197 m_pRbtColor->SaveValue();
198 m_pRbtGrayscale->SaveValue();
199 m_pRbtBlackWhite->SaveValue();
201 ClickBookletHdl( nullptr );
204 VclPtr<SfxTabPage> SdPrintOptions::Create( TabPageParent pWindow,
205 const SfxItemSet* rOutAttrs )
207 return VclPtr<SdPrintOptions>::Create( pWindow.pParent, *rOutAttrs );
210 IMPL_LINK( SdPrintOptions, ClickCheckboxHdl, Button*, pCbx, void )
212 // there must be at least one of them checked
213 if( !m_pCbxDraw->IsChecked() && !m_pCbxNotes->IsChecked() && !m_pCbxOutline->IsChecked() && !m_pCbxHandout->IsChecked() )
214 static_cast<CheckBox*>(pCbx)->Check();
216 updateControls();
219 IMPL_LINK_NOARG(SdPrintOptions, ClickBookletHdl, Button*, void)
221 updateControls();
224 void SdPrintOptions::updateControls()
226 m_pCbxFront->Enable(m_pRbtBooklet->IsChecked());
227 m_pCbxBack->Enable(m_pRbtBooklet->IsChecked());
229 m_pCbxDate->Enable( !m_pRbtBooklet->IsChecked() );
230 m_pCbxTime->Enable( !m_pRbtBooklet->IsChecked() );
232 m_pCbxPagename->Enable( !m_pRbtBooklet->IsChecked() && (m_pCbxDraw->IsChecked() || m_pCbxNotes->IsChecked() || m_pCbxOutline->IsChecked()) );
235 void SdPrintOptions::SetDrawMode()
237 if(m_pCbxNotes->IsVisible())
239 m_pFrmContent->Hide();
243 void SdPrintOptions::PageCreated (const SfxAllItemSet&
244 #ifdef MACOSX
245 aSet
246 #endif
249 #ifdef MACOSX
250 const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_SDMODE_FLAG, false);
251 if (pFlagItem)
253 sal_uInt32 nFlags=pFlagItem->GetValue();
254 if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
255 SetDrawMode();
257 #else
258 SetDrawMode();
259 #endif
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */