1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
32 #ifdef SD_DLLIMPLEMENTATION
33 #undef SD_DLLIMPLEMENTATION
38 #include "optsitem.hxx"
39 #include "prntopts.hrc"
40 #include "sdresid.hxx"
41 #include "prntopts.hxx"
43 #include <svl/intitem.hxx>
44 #include <sfx2/request.hxx>
46 /*************************************************************************
48 |* Dialog zum Aendern der Print-Optionen
50 \************************************************************************/
52 SdPrintOptions::SdPrintOptions( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
53 SfxTabPage ( pParent
, SdResId( TP_PRINT_OPTIONS
), rInAttrs
),
55 aGrpPrint ( this, SdResId( GRP_PRINT
) ),
56 aCbxDraw ( this, SdResId( CBX_DRAW
) ),
57 aCbxNotes ( this, SdResId( CBX_NOTES
) ),
58 aCbxHandout ( this, SdResId( CBX_HANDOUTS
) ),
59 aCbxOutline ( this, SdResId( CBX_OUTLINE
) ),
61 aSeparator1FL ( this, SdResId( FL_SEPARATOR1
) ),
62 aGrpOutput ( this, SdResId( GRP_OUTPUT
) ),
63 aRbtColor ( this, SdResId( RBT_COLOR
) ),
64 aRbtGrayscale ( this, SdResId( RBT_GRAYSCALE
) ),
65 aRbtBlackWhite ( this, SdResId( RBT_BLACKWHITE
) ),
67 aGrpPrintExt ( this, SdResId( GRP_PRINT_EXT
) ),
68 aCbxPagename ( this, SdResId( CBX_PAGENAME
) ),
69 aCbxDate ( this, SdResId( CBX_DATE
) ),
70 aCbxTime ( this, SdResId( CBX_TIME
) ),
71 aCbxHiddenPages ( this, SdResId( CBX_HIDDEN_PAGES
) ),
73 aSeparator2FL ( this, SdResId( FL_SEPARATOR2
) ),
74 aGrpPageoptions ( this, SdResId( GRP_PAGE
) ),
75 aRbtDefault ( this, SdResId( RBT_DEFAULT
) ),
76 aRbtPagesize ( this, SdResId( RBT_PAGESIZE
) ),
77 aRbtPagetile ( this, SdResId( RBT_PAGETILE
) ),
78 aRbtBooklet ( this, SdResId( RBT_BOOKLET
) ),
79 aCbxFront ( this, SdResId( CBX_FRONT
) ),
80 aCbxBack ( this, SdResId( CBX_BACK
) ),
82 aCbxPaperbin ( this, SdResId( CBX_PAPERBIN
) ),
84 rOutAttrs ( rInAttrs
)
88 Link aLink
= LINK( this, SdPrintOptions
, ClickBookletHdl
);
89 aRbtDefault
.SetClickHdl( aLink
);
90 aRbtPagesize
.SetClickHdl( aLink
);
91 aRbtPagetile
.SetClickHdl( aLink
);
92 aRbtBooklet
.SetClickHdl( aLink
);
94 aLink
= LINK( this, SdPrintOptions
, ClickCheckboxHdl
);
95 aCbxDraw
.SetClickHdl( aLink
);
96 aCbxNotes
.SetClickHdl( aLink
);
97 aCbxHandout
.SetClickHdl( aLink
);
98 aCbxOutline
.SetClickHdl( aLink
);
105 // -----------------------------------------------------------------------
107 SdPrintOptions::~SdPrintOptions()
111 // -----------------------------------------------------------------------
113 BOOL
SdPrintOptions::FillItemSet( SfxItemSet
& rAttrs
)
115 if( aCbxDraw
.GetSavedValue() != aCbxDraw
.IsChecked() ||
116 aCbxNotes
.GetSavedValue() != aCbxNotes
.IsChecked() ||
117 aCbxHandout
.GetSavedValue() != aCbxHandout
.IsChecked() ||
118 aCbxOutline
.GetSavedValue() != aCbxOutline
.IsChecked() ||
119 aCbxDate
.GetSavedValue() != aCbxDate
.IsChecked() ||
120 aCbxTime
.GetSavedValue() != aCbxTime
.IsChecked() ||
121 aCbxPagename
.GetSavedValue() != aCbxPagename
.IsChecked() ||
122 aCbxHiddenPages
.GetSavedValue() != aCbxHiddenPages
.IsChecked() ||
123 aRbtPagesize
.GetSavedValue() != aRbtPagesize
.IsChecked() ||
124 aRbtPagetile
.GetSavedValue() != aRbtPagetile
.IsChecked() ||
125 aRbtBooklet
.GetSavedValue() != aRbtBooklet
.IsChecked() ||
126 aCbxFront
.GetSavedValue() != aCbxFront
.IsChecked() ||
127 aCbxBack
.GetSavedValue() != aCbxBack
.IsChecked() ||
128 aCbxPaperbin
.GetSavedValue() != aCbxPaperbin
.IsChecked() ||
129 aRbtColor
.GetSavedValue() != aRbtColor
.IsChecked() ||
130 aRbtGrayscale
.GetSavedValue() != aRbtGrayscale
.IsChecked() ||
131 aRbtBlackWhite
.GetSavedValue() != aRbtBlackWhite
.IsChecked() )
133 SdOptionsPrintItem
aOptions( ATTR_OPTIONS_PRINT
);
135 aOptions
.GetOptionsPrint().SetDraw( aCbxDraw
.IsChecked() );
136 aOptions
.GetOptionsPrint().SetNotes( aCbxNotes
.IsChecked() );
137 aOptions
.GetOptionsPrint().SetHandout( aCbxHandout
.IsChecked() );
138 aOptions
.GetOptionsPrint().SetOutline( aCbxOutline
.IsChecked() );
139 aOptions
.GetOptionsPrint().SetDate( aCbxDate
.IsChecked() );
140 aOptions
.GetOptionsPrint().SetTime( aCbxTime
.IsChecked() );
141 aOptions
.GetOptionsPrint().SetPagename( aCbxPagename
.IsChecked() );
142 aOptions
.GetOptionsPrint().SetHiddenPages( aCbxHiddenPages
.IsChecked() );
143 aOptions
.GetOptionsPrint().SetPagesize( aRbtPagesize
.IsChecked() );
144 aOptions
.GetOptionsPrint().SetPagetile( aRbtPagetile
.IsChecked() );
145 aOptions
.GetOptionsPrint().SetBooklet( aRbtBooklet
.IsChecked() );
146 aOptions
.GetOptionsPrint().SetFrontPage( aCbxFront
.IsChecked() );
147 aOptions
.GetOptionsPrint().SetBackPage( aCbxBack
.IsChecked() );
148 aOptions
.GetOptionsPrint().SetPaperbin( aCbxPaperbin
.IsChecked() );
150 UINT16 nQuality
= 0; // Standard, also Color
151 if( aRbtGrayscale
.IsChecked() )
153 if( aRbtBlackWhite
.IsChecked() )
155 aOptions
.GetOptionsPrint().SetOutputQuality( nQuality
);
157 rAttrs
.Put( aOptions
);
164 // -----------------------------------------------------------------------
166 void SdPrintOptions::Reset( const SfxItemSet
& rAttrs
)
168 const SdOptionsPrintItem
* pPrintOpts
= NULL
;
169 if( SFX_ITEM_SET
== rAttrs
.GetItemState( ATTR_OPTIONS_PRINT
, FALSE
,
170 (const SfxPoolItem
**) &pPrintOpts
) )
172 aCbxDraw
.Check( pPrintOpts
->GetOptionsPrint().IsDraw() );
173 aCbxNotes
.Check( pPrintOpts
->GetOptionsPrint().IsNotes() );
174 aCbxHandout
.Check( pPrintOpts
->GetOptionsPrint().IsHandout() );
175 aCbxOutline
.Check( pPrintOpts
->GetOptionsPrint().IsOutline() );
176 aCbxDate
.Check( pPrintOpts
->GetOptionsPrint().IsDate() );
177 aCbxTime
.Check( pPrintOpts
->GetOptionsPrint().IsTime() );
178 aCbxPagename
.Check( pPrintOpts
->GetOptionsPrint().IsPagename() );
179 aCbxHiddenPages
.Check( pPrintOpts
->GetOptionsPrint().IsHiddenPages() );
180 aRbtPagesize
.Check( pPrintOpts
->GetOptionsPrint().IsPagesize() );
181 aRbtPagetile
.Check( pPrintOpts
->GetOptionsPrint().IsPagetile() );
182 aRbtBooklet
.Check( pPrintOpts
->GetOptionsPrint().IsBooklet() );
183 aCbxFront
.Check( pPrintOpts
->GetOptionsPrint().IsFrontPage() );
184 aCbxBack
.Check( pPrintOpts
->GetOptionsPrint().IsBackPage() );
185 aCbxPaperbin
.Check( pPrintOpts
->GetOptionsPrint().IsPaperbin() );
187 if( !aRbtPagesize
.IsChecked() &&
188 !aRbtPagetile
.IsChecked() &&
189 !aRbtBooklet
.IsChecked() )
194 UINT16 nQuality
= pPrintOpts
->GetOptionsPrint().GetOutputQuality();
197 else if( nQuality
== 1 )
198 aRbtGrayscale
.Check();
200 aRbtBlackWhite
.Check();
202 aCbxDraw
.SaveValue();
203 aCbxNotes
.SaveValue();
204 aCbxHandout
.SaveValue();
205 aCbxOutline
.SaveValue();
206 aCbxDate
.SaveValue();
207 aCbxTime
.SaveValue();
208 aCbxPagename
.SaveValue();
209 aCbxHiddenPages
.SaveValue();
210 aRbtPagesize
.SaveValue();
211 aRbtPagetile
.SaveValue();
212 aRbtBooklet
.SaveValue();
213 aCbxPaperbin
.SaveValue();
214 aRbtColor
.SaveValue();
215 aRbtGrayscale
.SaveValue();
216 aRbtBlackWhite
.SaveValue();
218 ClickBookletHdl( NULL
);
221 // -----------------------------------------------------------------------
223 SfxTabPage
* SdPrintOptions::Create( Window
* pWindow
,
224 const SfxItemSet
& rOutAttrs
)
226 return( new SdPrintOptions( pWindow
, rOutAttrs
) );
229 //-----------------------------------------------------------------------
231 IMPL_LINK( SdPrintOptions
, ClickCheckboxHdl
, CheckBox
*, pCbx
)
233 // there must be at least one of them checked
234 if( !aCbxDraw
.IsChecked() && !aCbxNotes
.IsChecked() && !aCbxOutline
.IsChecked() && !aCbxHandout
.IsChecked() )
241 //-----------------------------------------------------------------------
243 IMPL_LINK( SdPrintOptions
, ClickBookletHdl
, CheckBox
*, EMPTYARG
)
249 void SdPrintOptions::updateControls()
251 aCbxFront
.Enable(aRbtBooklet
.IsChecked());
252 aCbxBack
.Enable(aRbtBooklet
.IsChecked());
254 aCbxDate
.Enable( !aRbtBooklet
.IsChecked() );
255 aCbxTime
.Enable( !aRbtBooklet
.IsChecked() );
257 aCbxPagename
.Enable( !aRbtBooklet
.IsChecked() && (aCbxDraw
.IsChecked() || aCbxNotes
.IsChecked() || aCbxOutline
.IsChecked()) );
260 /* -----------------------------04.05.01 10:53--------------------------------
262 ---------------------------------------------------------------------------*/
263 void lcl_MoveRB_Impl(Window
& rBtn
, long nXDiff
)
265 Point
aPos(rBtn
.GetPosPixel());
267 rBtn
.SetPosPixel(aPos
);
270 void SdPrintOptions::SetDrawMode()
272 if(aCbxNotes
.IsVisible())
280 aSeparator1FL
.Hide();
281 long nXDiff
= aGrpOutput
.GetPosPixel().X() - aGrpPrint
.GetPosPixel().X();
282 lcl_MoveRB_Impl(aRbtColor
, nXDiff
);
283 lcl_MoveRB_Impl(aRbtGrayscale
, nXDiff
);
284 lcl_MoveRB_Impl(aRbtBlackWhite
, nXDiff
);
285 lcl_MoveRB_Impl(aGrpOutput
, nXDiff
);
287 long nWidth
= aGrpOutput
.GetSizePixel().Width() + nXDiff
;
288 Size
aSize(aGrpOutput
.GetSizePixel());
289 aSize
.Width() = nWidth
;
290 aGrpOutput
.SetSizePixel(aSize
);
294 void SdPrintOptions::PageCreated (SfxAllItemSet
301 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_SDMODE_FLAG
,sal_False
);
304 UINT32 nFlags
=pFlagItem
->GetValue();
305 if ( ( nFlags
& SD_DRAW_MODE
) == SD_DRAW_MODE
)
313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */