1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prntopts.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
40 #include "optsitem.hxx"
41 #include "prntopts.hrc"
42 #include "sdresid.hxx"
43 #include "prntopts.hxx"
45 #include <svtools/intitem.hxx>
46 #include <sfx2/request.hxx>
47 // STATIC DATA -----------------------------------------------------------
49 static USHORT pPrintOptRanges
[] =
57 /*************************************************************************
59 |* Dialog zum Aendern der Print-Optionen
61 \************************************************************************/
63 SdPrintOptions::SdPrintOptions( Window
* pParent
, const SfxItemSet
& rInAttrs
) :
64 SfxTabPage ( pParent
, SdResId( TP_PRINT_OPTIONS
), rInAttrs
),
66 aGrpPrint ( this, SdResId( GRP_PRINT
) ),
67 aCbxDraw ( this, SdResId( CBX_DRAW
) ),
68 aCbxNotes ( this, SdResId( CBX_NOTES
) ),
69 aCbxHandout ( this, SdResId( CBX_HANDOUTS
) ),
70 aCbxOutline ( this, SdResId( CBX_OUTLINE
) ),
72 aSeparator1FL ( this, SdResId( FL_SEPARATOR1
) ),
73 aGrpOutput ( this, SdResId( GRP_OUTPUT
) ),
74 aRbtColor ( this, SdResId( RBT_COLOR
) ),
75 aRbtGrayscale ( this, SdResId( RBT_GRAYSCALE
) ),
76 aRbtBlackWhite ( this, SdResId( RBT_BLACKWHITE
) ),
78 aGrpPrintExt ( this, SdResId( GRP_PRINT_EXT
) ),
79 aCbxPagename ( this, SdResId( CBX_PAGENAME
) ),
80 aCbxDate ( this, SdResId( CBX_DATE
) ),
81 aCbxTime ( this, SdResId( CBX_TIME
) ),
82 aCbxHiddenPages ( this, SdResId( CBX_HIDDEN_PAGES
) ),
84 aSeparator2FL ( this, SdResId( FL_SEPARATOR2
) ),
85 aGrpPageoptions ( this, SdResId( GRP_PAGE
) ),
86 aRbtDefault ( this, SdResId( RBT_DEFAULT
) ),
87 aRbtPagesize ( this, SdResId( RBT_PAGESIZE
) ),
88 aRbtPagetile ( this, SdResId( RBT_PAGETILE
) ),
89 aRbtBooklet ( this, SdResId( RBT_BOOKLET
) ),
90 aCbxFront ( this, SdResId( CBX_FRONT
) ),
91 aCbxBack ( this, SdResId( CBX_BACK
) ),
93 aCbxPaperbin ( this, SdResId( CBX_PAPERBIN
) ),
95 rOutAttrs ( rInAttrs
)
99 Link aLink
= LINK( this, SdPrintOptions
, ClickBookletHdl
);
100 aRbtDefault
.SetClickHdl( aLink
);
101 aRbtPagesize
.SetClickHdl( aLink
);
102 aRbtPagetile
.SetClickHdl( aLink
);
103 aRbtBooklet
.SetClickHdl( aLink
);
105 aLink
= LINK( this, SdPrintOptions
, ClickCheckboxHdl
);
106 aCbxDraw
.SetClickHdl( aLink
);
107 aCbxNotes
.SetClickHdl( aLink
);
108 aCbxHandout
.SetClickHdl( aLink
);
109 aCbxOutline
.SetClickHdl( aLink
);
116 // -----------------------------------------------------------------------
118 SdPrintOptions::~SdPrintOptions()
122 // -----------------------------------------------------------------------
124 BOOL
SdPrintOptions::FillItemSet( SfxItemSet
& rAttrs
)
126 if( aCbxDraw
.GetSavedValue() != aCbxDraw
.IsChecked() ||
127 aCbxNotes
.GetSavedValue() != aCbxNotes
.IsChecked() ||
128 aCbxHandout
.GetSavedValue() != aCbxHandout
.IsChecked() ||
129 aCbxOutline
.GetSavedValue() != aCbxOutline
.IsChecked() ||
130 aCbxDate
.GetSavedValue() != aCbxDate
.IsChecked() ||
131 aCbxTime
.GetSavedValue() != aCbxTime
.IsChecked() ||
132 aCbxPagename
.GetSavedValue() != aCbxPagename
.IsChecked() ||
133 aCbxHiddenPages
.GetSavedValue() != aCbxHiddenPages
.IsChecked() ||
134 aRbtPagesize
.GetSavedValue() != aRbtPagesize
.IsChecked() ||
135 aRbtPagetile
.GetSavedValue() != aRbtPagetile
.IsChecked() ||
136 aRbtBooklet
.GetSavedValue() != aRbtBooklet
.IsChecked() ||
137 aCbxFront
.GetSavedValue() != aCbxFront
.IsChecked() ||
138 aCbxBack
.GetSavedValue() != aCbxBack
.IsChecked() ||
139 aCbxPaperbin
.GetSavedValue() != aCbxPaperbin
.IsChecked() ||
140 aRbtColor
.GetSavedValue() != aRbtColor
.IsChecked() ||
141 aRbtGrayscale
.GetSavedValue() != aRbtGrayscale
.IsChecked() ||
142 aRbtBlackWhite
.GetSavedValue() != aRbtBlackWhite
.IsChecked() )
144 SdOptionsPrintItem
aOptions( ATTR_OPTIONS_PRINT
);
146 aOptions
.GetOptionsPrint().SetDraw( aCbxDraw
.IsChecked() );
147 aOptions
.GetOptionsPrint().SetNotes( aCbxNotes
.IsChecked() );
148 aOptions
.GetOptionsPrint().SetHandout( aCbxHandout
.IsChecked() );
149 aOptions
.GetOptionsPrint().SetOutline( aCbxOutline
.IsChecked() );
150 aOptions
.GetOptionsPrint().SetDate( aCbxDate
.IsChecked() );
151 aOptions
.GetOptionsPrint().SetTime( aCbxTime
.IsChecked() );
152 aOptions
.GetOptionsPrint().SetPagename( aCbxPagename
.IsChecked() );
153 aOptions
.GetOptionsPrint().SetHiddenPages( aCbxHiddenPages
.IsChecked() );
154 aOptions
.GetOptionsPrint().SetPagesize( aRbtPagesize
.IsChecked() );
155 aOptions
.GetOptionsPrint().SetPagetile( aRbtPagetile
.IsChecked() );
156 aOptions
.GetOptionsPrint().SetBooklet( aRbtBooklet
.IsChecked() );
157 aOptions
.GetOptionsPrint().SetFrontPage( aCbxFront
.IsChecked() );
158 aOptions
.GetOptionsPrint().SetBackPage( aCbxBack
.IsChecked() );
159 aOptions
.GetOptionsPrint().SetPaperbin( aCbxPaperbin
.IsChecked() );
161 UINT16 nQuality
= 0; // Standard, also Color
162 if( aRbtGrayscale
.IsChecked() )
164 if( aRbtBlackWhite
.IsChecked() )
166 aOptions
.GetOptionsPrint().SetOutputQuality( nQuality
);
168 rAttrs
.Put( aOptions
);
175 // -----------------------------------------------------------------------
177 void SdPrintOptions::Reset( const SfxItemSet
& rAttrs
)
179 const SdOptionsPrintItem
* pPrintOpts
= NULL
;
180 if( SFX_ITEM_SET
== rAttrs
.GetItemState( ATTR_OPTIONS_PRINT
, FALSE
,
181 (const SfxPoolItem
**) &pPrintOpts
) )
183 aCbxDraw
.Check( pPrintOpts
->GetOptionsPrint().IsDraw() );
184 aCbxNotes
.Check( pPrintOpts
->GetOptionsPrint().IsNotes() );
185 aCbxHandout
.Check( pPrintOpts
->GetOptionsPrint().IsHandout() );
186 aCbxOutline
.Check( pPrintOpts
->GetOptionsPrint().IsOutline() );
187 aCbxDate
.Check( pPrintOpts
->GetOptionsPrint().IsDate() );
188 aCbxTime
.Check( pPrintOpts
->GetOptionsPrint().IsTime() );
189 aCbxPagename
.Check( pPrintOpts
->GetOptionsPrint().IsPagename() );
190 aCbxHiddenPages
.Check( pPrintOpts
->GetOptionsPrint().IsHiddenPages() );
191 aRbtPagesize
.Check( pPrintOpts
->GetOptionsPrint().IsPagesize() );
192 aRbtPagetile
.Check( pPrintOpts
->GetOptionsPrint().IsPagetile() );
193 aRbtBooklet
.Check( pPrintOpts
->GetOptionsPrint().IsBooklet() );
194 aCbxFront
.Check( pPrintOpts
->GetOptionsPrint().IsFrontPage() );
195 aCbxBack
.Check( pPrintOpts
->GetOptionsPrint().IsBackPage() );
196 aCbxPaperbin
.Check( pPrintOpts
->GetOptionsPrint().IsPaperbin() );
198 if( !aRbtPagesize
.IsChecked() &&
199 !aRbtPagetile
.IsChecked() &&
200 !aRbtBooklet
.IsChecked() )
205 UINT16 nQuality
= pPrintOpts
->GetOptionsPrint().GetOutputQuality();
208 else if( nQuality
== 1 )
209 aRbtGrayscale
.Check();
211 aRbtBlackWhite
.Check();
213 aCbxDraw
.SaveValue();
214 aCbxNotes
.SaveValue();
215 aCbxHandout
.SaveValue();
216 aCbxOutline
.SaveValue();
217 aCbxDate
.SaveValue();
218 aCbxTime
.SaveValue();
219 aCbxPagename
.SaveValue();
220 aCbxHiddenPages
.SaveValue();
221 aRbtPagesize
.SaveValue();
222 aRbtPagetile
.SaveValue();
223 aRbtBooklet
.SaveValue();
224 aCbxPaperbin
.SaveValue();
225 aRbtColor
.SaveValue();
226 aRbtGrayscale
.SaveValue();
227 aRbtBlackWhite
.SaveValue();
229 ClickBookletHdl( NULL
);
232 // -----------------------------------------------------------------------
234 SfxTabPage
* SdPrintOptions::Create( Window
* pWindow
,
235 const SfxItemSet
& rOutAttrs
)
237 return( new SdPrintOptions( pWindow
, rOutAttrs
) );
240 //-----------------------------------------------------------------------
242 USHORT
* SdPrintOptions::GetRanges()
244 return pPrintOptRanges
;
247 //-----------------------------------------------------------------------
249 IMPL_LINK( SdPrintOptions
, ClickCheckboxHdl
, CheckBox
*, pCbx
)
251 // there must be at least one of them checked
252 if( !aCbxDraw
.IsChecked() && !aCbxNotes
.IsChecked() && !aCbxOutline
.IsChecked() && !aCbxHandout
.IsChecked() )
259 //-----------------------------------------------------------------------
261 IMPL_LINK( SdPrintOptions
, ClickBookletHdl
, CheckBox
*, EMPTYARG
)
267 void SdPrintOptions::updateControls()
269 aCbxFront
.Enable(aRbtBooklet
.IsChecked());
270 aCbxBack
.Enable(aRbtBooklet
.IsChecked());
272 aCbxDate
.Enable( !aRbtBooklet
.IsChecked() );
273 aCbxTime
.Enable( !aRbtBooklet
.IsChecked() );
275 aCbxPagename
.Enable( !aRbtBooklet
.IsChecked() && (aCbxDraw
.IsChecked() || aCbxNotes
.IsChecked() || aCbxOutline
.IsChecked()) );
278 /* -----------------------------04.05.01 10:53--------------------------------
280 ---------------------------------------------------------------------------*/
281 void lcl_MoveRB_Impl(Window
& rBtn
, long nXDiff
)
283 Point
aPos(rBtn
.GetPosPixel());
285 rBtn
.SetPosPixel(aPos
);
288 void SdPrintOptions::SetDrawMode()
290 if(aCbxNotes
.IsVisible())
298 aSeparator1FL
.Hide();
299 long nXDiff
= aGrpOutput
.GetPosPixel().X() - aGrpPrint
.GetPosPixel().X();
300 lcl_MoveRB_Impl(aRbtColor
, nXDiff
);
301 lcl_MoveRB_Impl(aRbtGrayscale
, nXDiff
);
302 lcl_MoveRB_Impl(aRbtBlackWhite
, nXDiff
);
303 lcl_MoveRB_Impl(aGrpOutput
, nXDiff
);
305 long nWidth
= aGrpOutput
.GetSizePixel().Width() + nXDiff
;
306 Size
aSize(aGrpOutput
.GetSizePixel());
307 aSize
.Width() = nWidth
;
308 aGrpOutput
.SetSizePixel(aSize
);
312 void SdPrintOptions::PageCreated (SfxAllItemSet
319 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_SDMODE_FLAG
,sal_False
);
322 UINT32 nFlags
=pFlagItem
->GetValue();
323 if ( ( nFlags
& SD_DRAW_MODE
) == SD_DRAW_MODE
)