bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / dlg / prntopts.cxx
blobd70a42e66aeb72c5e262417aa3e585bc46f15e45
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.hxx"
21 #include "optsitem.hxx"
22 #include "prntopts.hrc"
23 #include "sdresid.hxx"
24 #include "prntopts.hxx"
25 #include "app.hrc"
26 #include <svl/intitem.hxx>
27 #include <sfx2/request.hxx>
29 /**
30 * dialog to adjust print options
32 SdPrintOptions::SdPrintOptions( Window* pParent, const SfxItemSet& rInAttrs ) :
33 SfxTabPage ( pParent, SdResId( TP_PRINT_OPTIONS ), rInAttrs ),
35 aGrpPrint ( this, SdResId( GRP_PRINT ) ),
36 aCbxDraw ( this, SdResId( CBX_DRAW ) ),
37 aCbxNotes ( this, SdResId( CBX_NOTES ) ),
38 aCbxHandout ( this, SdResId( CBX_HANDOUTS ) ),
39 aCbxOutline ( this, SdResId( CBX_OUTLINE ) ),
41 aSeparator1FL ( this, SdResId( FL_SEPARATOR1 ) ),
42 aGrpOutput ( this, SdResId( GRP_OUTPUT ) ),
43 aRbtColor ( this, SdResId( RBT_COLOR ) ),
44 aRbtGrayscale ( this, SdResId( RBT_GRAYSCALE ) ),
45 aRbtBlackWhite ( this, SdResId( RBT_BLACKWHITE ) ),
47 aGrpPrintExt ( this, SdResId( GRP_PRINT_EXT ) ),
48 aCbxPagename ( this, SdResId( CBX_PAGENAME ) ),
49 aCbxDate ( this, SdResId( CBX_DATE ) ),
50 aCbxTime ( this, SdResId( CBX_TIME ) ),
51 aCbxHiddenPages ( this, SdResId( CBX_HIDDEN_PAGES ) ),
53 aSeparator2FL ( this, SdResId( FL_SEPARATOR2 ) ),
54 aGrpPageoptions ( this, SdResId( GRP_PAGE ) ),
55 aRbtDefault ( this, SdResId( RBT_DEFAULT ) ),
56 aRbtPagesize ( this, SdResId( RBT_PAGESIZE ) ),
57 aRbtPagetile ( this, SdResId( RBT_PAGETILE ) ),
58 aRbtBooklet ( this, SdResId( RBT_BOOKLET ) ),
59 aCbxFront ( this, SdResId( CBX_FRONT ) ),
60 aCbxBack ( this, SdResId( CBX_BACK ) ),
62 aCbxPaperbin ( this, SdResId( CBX_PAPERBIN ) ),
64 rOutAttrs ( rInAttrs )
66 FreeResource();
68 Link aLink = LINK( this, SdPrintOptions, ClickBookletHdl );
69 aRbtDefault.SetClickHdl( aLink );
70 aRbtPagesize.SetClickHdl( aLink );
71 aRbtPagetile.SetClickHdl( aLink );
72 aRbtBooklet.SetClickHdl( aLink );
74 aLink = LINK( this, SdPrintOptions, ClickCheckboxHdl );
75 aCbxDraw.SetClickHdl( aLink );
76 aCbxNotes.SetClickHdl( aLink );
77 aCbxHandout.SetClickHdl( aLink );
78 aCbxOutline.SetClickHdl( aLink );
80 #ifndef MACOSX
81 SetDrawMode();
82 #endif
84 aCbxFront.SetAccessibleRelationLabeledBy( &aRbtBooklet );
85 aCbxBack.SetAccessibleRelationLabeledBy( &aRbtBooklet );
88 // -----------------------------------------------------------------------
90 SdPrintOptions::~SdPrintOptions()
94 // -----------------------------------------------------------------------
96 sal_Bool SdPrintOptions::FillItemSet( SfxItemSet& rAttrs )
98 if( aCbxDraw.GetSavedValue() != aCbxDraw.IsChecked() ||
99 aCbxNotes.GetSavedValue() != aCbxNotes.IsChecked() ||
100 aCbxHandout.GetSavedValue() != aCbxHandout.IsChecked() ||
101 aCbxOutline.GetSavedValue() != aCbxOutline.IsChecked() ||
102 aCbxDate.GetSavedValue() != aCbxDate.IsChecked() ||
103 aCbxTime.GetSavedValue() != aCbxTime.IsChecked() ||
104 aCbxPagename.GetSavedValue() != aCbxPagename.IsChecked() ||
105 aCbxHiddenPages.GetSavedValue() != aCbxHiddenPages.IsChecked() ||
106 aRbtPagesize.GetSavedValue() != aRbtPagesize.IsChecked() ||
107 aRbtPagetile.GetSavedValue() != aRbtPagetile.IsChecked() ||
108 aRbtBooklet.GetSavedValue() != aRbtBooklet.IsChecked() ||
109 aCbxFront.GetSavedValue() != aCbxFront.IsChecked() ||
110 aCbxBack.GetSavedValue() != aCbxBack.IsChecked() ||
111 aCbxPaperbin.GetSavedValue() != aCbxPaperbin.IsChecked() ||
112 aRbtColor.GetSavedValue() != aRbtColor.IsChecked() ||
113 aRbtGrayscale.GetSavedValue() != aRbtGrayscale.IsChecked() ||
114 aRbtBlackWhite.GetSavedValue() != aRbtBlackWhite.IsChecked() )
116 SdOptionsPrintItem aOptions( ATTR_OPTIONS_PRINT );
118 aOptions.GetOptionsPrint().SetDraw( aCbxDraw.IsChecked() );
119 aOptions.GetOptionsPrint().SetNotes( aCbxNotes.IsChecked() );
120 aOptions.GetOptionsPrint().SetHandout( aCbxHandout.IsChecked() );
121 aOptions.GetOptionsPrint().SetOutline( aCbxOutline.IsChecked() );
122 aOptions.GetOptionsPrint().SetDate( aCbxDate.IsChecked() );
123 aOptions.GetOptionsPrint().SetTime( aCbxTime.IsChecked() );
124 aOptions.GetOptionsPrint().SetPagename( aCbxPagename.IsChecked() );
125 aOptions.GetOptionsPrint().SetHiddenPages( aCbxHiddenPages.IsChecked() );
126 aOptions.GetOptionsPrint().SetPagesize( aRbtPagesize.IsChecked() );
127 aOptions.GetOptionsPrint().SetPagetile( aRbtPagetile.IsChecked() );
128 aOptions.GetOptionsPrint().SetBooklet( aRbtBooklet.IsChecked() );
129 aOptions.GetOptionsPrint().SetFrontPage( aCbxFront.IsChecked() );
130 aOptions.GetOptionsPrint().SetBackPage( aCbxBack.IsChecked() );
131 aOptions.GetOptionsPrint().SetPaperbin( aCbxPaperbin.IsChecked() );
133 sal_uInt16 nQuality = 0; // Standard, also Color
134 if( aRbtGrayscale.IsChecked() )
135 nQuality = 1;
136 if( aRbtBlackWhite.IsChecked() )
137 nQuality = 2;
138 aOptions.GetOptionsPrint().SetOutputQuality( nQuality );
140 rAttrs.Put( aOptions );
142 return( sal_True );
144 return( sal_False );
147 // -----------------------------------------------------------------------
149 void SdPrintOptions::Reset( const SfxItemSet& rAttrs )
151 const SdOptionsPrintItem* pPrintOpts = NULL;
152 if( SFX_ITEM_SET == rAttrs.GetItemState( ATTR_OPTIONS_PRINT, sal_False,
153 (const SfxPoolItem**) &pPrintOpts ) )
155 aCbxDraw.Check( pPrintOpts->GetOptionsPrint().IsDraw() );
156 aCbxNotes.Check( pPrintOpts->GetOptionsPrint().IsNotes() );
157 aCbxHandout.Check( pPrintOpts->GetOptionsPrint().IsHandout() );
158 aCbxOutline.Check( pPrintOpts->GetOptionsPrint().IsOutline() );
159 aCbxDate.Check( pPrintOpts->GetOptionsPrint().IsDate() );
160 aCbxTime.Check( pPrintOpts->GetOptionsPrint().IsTime() );
161 aCbxPagename.Check( pPrintOpts->GetOptionsPrint().IsPagename() );
162 aCbxHiddenPages.Check( pPrintOpts->GetOptionsPrint().IsHiddenPages() );
163 aRbtPagesize.Check( pPrintOpts->GetOptionsPrint().IsPagesize() );
164 aRbtPagetile.Check( pPrintOpts->GetOptionsPrint().IsPagetile() );
165 aRbtBooklet.Check( pPrintOpts->GetOptionsPrint().IsBooklet() );
166 aCbxFront.Check( pPrintOpts->GetOptionsPrint().IsFrontPage() );
167 aCbxBack.Check( pPrintOpts->GetOptionsPrint().IsBackPage() );
168 aCbxPaperbin.Check( pPrintOpts->GetOptionsPrint().IsPaperbin() );
170 if( !aRbtPagesize.IsChecked() &&
171 !aRbtPagetile.IsChecked() &&
172 !aRbtBooklet.IsChecked() )
174 aRbtDefault.Check();
177 sal_uInt16 nQuality = pPrintOpts->GetOptionsPrint().GetOutputQuality();
178 if( nQuality == 0 )
179 aRbtColor.Check();
180 else if( nQuality == 1 )
181 aRbtGrayscale.Check();
182 else
183 aRbtBlackWhite.Check();
185 aCbxDraw.SaveValue();
186 aCbxNotes.SaveValue();
187 aCbxHandout.SaveValue();
188 aCbxOutline.SaveValue();
189 aCbxDate.SaveValue();
190 aCbxTime.SaveValue();
191 aCbxPagename.SaveValue();
192 aCbxHiddenPages.SaveValue();
193 aRbtPagesize.SaveValue();
194 aRbtPagetile.SaveValue();
195 aRbtBooklet.SaveValue();
196 aCbxPaperbin.SaveValue();
197 aRbtColor.SaveValue();
198 aRbtGrayscale.SaveValue();
199 aRbtBlackWhite.SaveValue();
201 ClickBookletHdl( NULL );
204 // -----------------------------------------------------------------------
206 SfxTabPage* SdPrintOptions::Create( Window* pWindow,
207 const SfxItemSet& rOutAttrs )
209 return( new SdPrintOptions( pWindow, rOutAttrs ) );
212 //-----------------------------------------------------------------------
214 IMPL_LINK( SdPrintOptions, ClickCheckboxHdl, CheckBox *, pCbx )
216 // there must be at least one of them checked
217 if( !aCbxDraw.IsChecked() && !aCbxNotes.IsChecked() && !aCbxOutline.IsChecked() && !aCbxHandout.IsChecked() )
218 pCbx->Check();
220 updateControls();
221 return 0;
224 //-----------------------------------------------------------------------
226 IMPL_LINK_NOARG(SdPrintOptions, ClickBookletHdl)
228 updateControls();
229 return 0;
232 void SdPrintOptions::updateControls()
234 aCbxFront.Enable(aRbtBooklet.IsChecked());
235 aCbxBack.Enable(aRbtBooklet.IsChecked());
237 aCbxDate.Enable( !aRbtBooklet.IsChecked() );
238 aCbxTime.Enable( !aRbtBooklet.IsChecked() );
240 aCbxPagename.Enable( !aRbtBooklet.IsChecked() && (aCbxDraw.IsChecked() || aCbxNotes.IsChecked() || aCbxOutline.IsChecked()) );
243 static void lcl_MoveRB_Impl(Window& rBtn, long nXDiff)
245 Point aPos(rBtn.GetPosPixel());
246 aPos.X() -= nXDiff;
247 rBtn.SetPosPixel(aPos);
250 void SdPrintOptions::SetDrawMode()
252 if(aCbxNotes.IsVisible())
254 aCbxNotes.Hide();
255 aCbxHandout.Hide();
256 aCbxOutline.Hide();
257 aCbxDraw.Hide();
258 aGrpPrint.Hide();
260 aSeparator1FL.Hide();
261 long nXDiff = aGrpOutput.GetPosPixel().X() - aGrpPrint.GetPosPixel().X();
262 lcl_MoveRB_Impl(aRbtColor, nXDiff);
263 lcl_MoveRB_Impl(aRbtGrayscale, nXDiff);
264 lcl_MoveRB_Impl(aRbtBlackWhite, nXDiff);
265 lcl_MoveRB_Impl(aGrpOutput, nXDiff);
267 long nWidth = aGrpOutput.GetSizePixel().Width() + nXDiff;
268 Size aSize(aGrpOutput.GetSizePixel());
269 aSize.Width() = nWidth;
270 aGrpOutput.SetSizePixel(aSize);
274 void SdPrintOptions::PageCreated (SfxAllItemSet
275 #ifdef MACOSX
276 aSet
277 #endif
280 #ifdef MACOSX
281 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False);
282 if (pFlagItem)
284 sal_uInt32 nFlags=pFlagItem->GetValue();
285 if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
286 SetDrawMode();
288 #else
289 SetDrawMode();
290 #endif
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */