xref: /aoo41x/main/sw/source/ui/envelp/envprt.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vcl/print.hxx>
33cdf0e10cSrcweir #include <svtools/prnsetup.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "swtypes.hxx"
36cdf0e10cSrcweir #include "cmdid.h"
37cdf0e10cSrcweir #include "envprt.hxx"
38cdf0e10cSrcweir #include "envlop.hxx"
39cdf0e10cSrcweir #include "uitool.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "envprt.hrc"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
SwEnvPrtPage(Window * pParent,const SfxItemSet & rSet)47cdf0e10cSrcweir SwEnvPrtPage::SwEnvPrtPage(Window* pParent, const SfxItemSet& rSet) :
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	SfxTabPage(pParent, SW_RES(TP_ENV_PRT), rSet),
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 	aAlignBox    (this, SW_RES(BOX_ALIGN  )),
52cdf0e10cSrcweir 	aTopButton   (this, SW_RES(BTN_TOP    )),
53cdf0e10cSrcweir 	aBottomButton(this, SW_RES(BTN_BOTTOM )),
54cdf0e10cSrcweir 	aRightText   (this, SW_RES(TXT_RIGHT  )),
55cdf0e10cSrcweir 	aRightField  (this, SW_RES(FLD_RIGHT  )),
56cdf0e10cSrcweir 	aDownText    (this, SW_RES(TXT_DOWN   )),
57cdf0e10cSrcweir 	aDownField   (this, SW_RES(FLD_DOWN   )),
58cdf0e10cSrcweir 	aPrinterInfo (this, SW_RES(TXT_PRINTER)),
59cdf0e10cSrcweir     aNoNameFL    (this, SW_RES(FL_NONAME )),
60cdf0e10cSrcweir     aPrinterFL   (this, SW_RES(FL_PRINTER )),
61cdf0e10cSrcweir 	aPrtSetup    (this, SW_RES(BTN_PRTSETUP))
62cdf0e10cSrcweir 
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	FreeResource();
65cdf0e10cSrcweir 	SetExchangeSupport();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	// Metriken
68cdf0e10cSrcweir 	FieldUnit eUnit = ::GetDfltMetric(sal_False);
69cdf0e10cSrcweir 	SetMetric(aRightField, eUnit);
70cdf0e10cSrcweir 	SetMetric(aDownField , eUnit);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	// Handler installieren
73cdf0e10cSrcweir 	aTopButton   .SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl));
74cdf0e10cSrcweir 	aBottomButton.SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl));
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	aPrtSetup    .SetClickHdl(LINK(this, SwEnvPrtPage, ButtonHdl));
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	// Bitmaps
79cdf0e10cSrcweir 	aBottomButton.GetClickHdl().Call(&aBottomButton);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	// ToolBox
82cdf0e10cSrcweir 	Size aSz = aAlignBox.CalcWindowSizePixel();
83cdf0e10cSrcweir 	aAlignBox.SetSizePixel(aSz);
84cdf0e10cSrcweir //    aAlignBox.SetPosPixel(Point(aNoNameFL.GetPosPixel().X() + (aNoNameFL.GetSizePixel().Width() - aSz.Width()) / 2, aAlignBox.GetPosPixel().Y()));
85cdf0e10cSrcweir 	aAlignBox.SetClickHdl(LINK(this, SwEnvPrtPage, AlignHdl));
86cdf0e10cSrcweir 
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir // --------------------------------------------------------------------------
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
~SwEnvPrtPage()93cdf0e10cSrcweir SwEnvPrtPage::~SwEnvPrtPage()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir // --------------------------------------------------------------------------
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
IMPL_LINK(SwEnvPrtPage,ClickHdl,Button *,EMPTYARG)101cdf0e10cSrcweir IMPL_LINK( SwEnvPrtPage, ClickHdl, Button *, EMPTYARG )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
104cdf0e10cSrcweir 	if (aBottomButton.IsChecked())
105cdf0e10cSrcweir 	{
106cdf0e10cSrcweir 		// Briefumschlaege von unten
107cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_HOR_LEFT, Bitmap(SW_RES(bHC ? BMP_HOR_LEFT_LOWER_H : BMP_HOR_LEFT_LOWER)));
108cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_HOR_CNTR, Bitmap(SW_RES(bHC ? BMP_HOR_CNTR_LOWER_H : BMP_HOR_CNTR_LOWER)));
109cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_HOR_RGHT, Bitmap(SW_RES(bHC ? BMP_HOR_RGHT_LOWER_H : BMP_HOR_RGHT_LOWER)));
110cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_VER_LEFT, Bitmap(SW_RES(bHC ? BMP_VER_LEFT_LOWER_H : BMP_VER_LEFT_LOWER)));
111cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_VER_CNTR, Bitmap(SW_RES(bHC ? BMP_VER_CNTR_LOWER_H : BMP_VER_CNTR_LOWER)));
112cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_VER_RGHT, Bitmap(SW_RES(bHC ? BMP_VER_RGHT_LOWER_H : BMP_VER_RGHT_LOWER)));
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir 	else
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		// Briefumschlaege von oben
117cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_HOR_LEFT, Bitmap(SW_RES(bHC ? BMP_HOR_LEFT_UPPER_H : BMP_HOR_LEFT_UPPER)));
118cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_HOR_CNTR, Bitmap(SW_RES(bHC ? BMP_HOR_CNTR_UPPER_H : BMP_HOR_CNTR_UPPER)));
119cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_HOR_RGHT, Bitmap(SW_RES(bHC ? BMP_HOR_RGHT_UPPER_H : BMP_HOR_RGHT_UPPER)));
120cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_VER_LEFT, Bitmap(SW_RES(bHC ? BMP_VER_LEFT_UPPER_H : BMP_VER_LEFT_UPPER)));
121cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_VER_CNTR, Bitmap(SW_RES(bHC ? BMP_VER_CNTR_UPPER_H : BMP_VER_CNTR_UPPER)));
122cdf0e10cSrcweir 		aAlignBox.SetItemImage(ITM_VER_RGHT, Bitmap(SW_RES(bHC ? BMP_VER_RGHT_UPPER_H : BMP_VER_RGHT_UPPER)));
123cdf0e10cSrcweir 	}
124cdf0e10cSrcweir 	return 0;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir // --------------------------------------------------------------------------
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
IMPL_LINK(SwEnvPrtPage,ButtonHdl,Button *,pBtn)131cdf0e10cSrcweir IMPL_LINK( SwEnvPrtPage, ButtonHdl, Button *, pBtn )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	if (pBtn == &aPrtSetup)
134cdf0e10cSrcweir 	{
135cdf0e10cSrcweir 		// Druck-Setup aufrufen
136cdf0e10cSrcweir 		if (pPrt)
137cdf0e10cSrcweir 		{
138cdf0e10cSrcweir 			PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
139cdf0e10cSrcweir 			pDlg->SetPrinter(pPrt);
140cdf0e10cSrcweir 			pDlg->Execute();
141cdf0e10cSrcweir 			delete pDlg;
142cdf0e10cSrcweir 			GrabFocus();
143cdf0e10cSrcweir 			aPrinterInfo.SetText(pPrt->GetName());
144cdf0e10cSrcweir 		}
145cdf0e10cSrcweir 	}
146cdf0e10cSrcweir 	return 0;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // --------------------------------------------------------------------------
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 
IMPL_LINK(SwEnvPrtPage,AlignHdl,ToolBox *,EMPTYARG)153cdf0e10cSrcweir IMPL_LINK( SwEnvPrtPage, AlignHdl, ToolBox *, EMPTYARG )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	if (aAlignBox.GetCurItemId())
156cdf0e10cSrcweir 	{
157cdf0e10cSrcweir 		for (sal_uInt16 i = ITM_HOR_LEFT; i <= ITM_VER_RGHT; i++)
158cdf0e10cSrcweir 			aAlignBox.CheckItem(i, sal_False);
159cdf0e10cSrcweir 		aAlignBox.CheckItem(aAlignBox.GetCurItemId(), sal_True);
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir 	else
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir 		// GetCurItemId() == 0 ist moeglich!
164cdf0e10cSrcweir 		const SwEnvItem& rItem = (const SwEnvItem&) GetItemSet().Get(FN_ENVELOP);
165cdf0e10cSrcweir 		aAlignBox.CheckItem((sal_uInt16) rItem.eAlign + ITM_HOR_LEFT, sal_True);
166cdf0e10cSrcweir 	}
167cdf0e10cSrcweir 	return 0;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir // --------------------------------------------------------------------------
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rSet)174cdf0e10cSrcweir SfxTabPage* SwEnvPrtPage::Create(Window* pParent, const SfxItemSet& rSet)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir 	return new SwEnvPrtPage(pParent, rSet);
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir // --------------------------------------------------------------------------
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 
ActivatePage(const SfxItemSet &)183cdf0e10cSrcweir void SwEnvPrtPage::ActivatePage(const SfxItemSet&)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	if (pPrt)
186cdf0e10cSrcweir 		aPrinterInfo.SetText(pPrt->GetName());
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir // --------------------------------------------------------------------------
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
DeactivatePage(SfxItemSet * _pSet)193cdf0e10cSrcweir int SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     if( _pSet )
196cdf0e10cSrcweir         FillItemSet(*_pSet);
197cdf0e10cSrcweir 	return SfxTabPage::LEAVE_PAGE;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir // --------------------------------------------------------------------------
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
FillItem(SwEnvItem & rItem)204cdf0e10cSrcweir void SwEnvPrtPage::FillItem(SwEnvItem& rItem)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	sal_uInt16 nID = 0;
207cdf0e10cSrcweir 	for (sal_uInt16 i = ITM_HOR_LEFT; i <= ITM_VER_RGHT && !nID; i++)
208cdf0e10cSrcweir 		if (aAlignBox.IsItemChecked(i))
209cdf0e10cSrcweir 			nID = i;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	rItem.eAlign          = (SwEnvAlign) (nID - ITM_HOR_LEFT);
212cdf0e10cSrcweir 	rItem.bPrintFromAbove = aTopButton.IsChecked();
213cdf0e10cSrcweir     rItem.lShiftRight     = static_cast< sal_Int32 >(GetFldVal(aRightField));
214cdf0e10cSrcweir     rItem.lShiftDown      = static_cast< sal_Int32 >(GetFldVal(aDownField ));
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir // --------------------------------------------------------------------------
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rSet)221cdf0e10cSrcweir sal_Bool SwEnvPrtPage::FillItemSet(SfxItemSet& rSet)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	FillItem(GetParent()->aEnvItem);
224cdf0e10cSrcweir 	rSet.Put(GetParent()->aEnvItem);
225cdf0e10cSrcweir 	return sal_True;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir // ----------------------------------------------------------------------------
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 
Reset(const SfxItemSet & rSet)232cdf0e10cSrcweir void SwEnvPrtPage::Reset(const SfxItemSet& rSet)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir //    SfxItemSet aSet(rSet);
235cdf0e10cSrcweir //    aSet.Put(GetParent()->aEnvItem);
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	// Item auslesen
238cdf0e10cSrcweir 	const SwEnvItem& rItem = (const SwEnvItem&) rSet.Get(FN_ENVELOP);
239cdf0e10cSrcweir 	aAlignBox.CheckItem((sal_uInt16) rItem.eAlign + ITM_HOR_LEFT);
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	if (rItem.bPrintFromAbove)
242cdf0e10cSrcweir 		aTopButton   .Check();
243cdf0e10cSrcweir 	else
244cdf0e10cSrcweir 		aBottomButton.Check();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	SetFldVal(aRightField, rItem.lShiftRight);
247cdf0e10cSrcweir 	SetFldVal(aDownField , rItem.lShiftDown );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	ActivatePage(rSet);
250cdf0e10cSrcweir 	ClickHdl(&aTopButton);
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 
256