xref: /AOO41X/main/cui/source/tabpages/dstribut.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 
31 #include <sfx2/basedlgs.hxx>
32 #include <cuires.hrc>
33 #include "dstribut.hxx"
34 #include "dstribut.hrc"
35 #include <svx/dialogs.hrc>
36 #include <svx/svddef.hxx>
37 #include <dialmgr.hxx>
38 #include <tools/shl.hxx>
39 
40 static sal_uInt16 pRanges[] =
41 {
42 	SDRATTR_MEASURE_FIRST,
43 	SDRATTR_MEASURE_LAST,
44 	0
45 };
46 
47 /*************************************************************************
48 |*
49 |* Dialog
50 |*
51 \************************************************************************/
52 
53 SvxDistributeDialog::SvxDistributeDialog(
54 	Window* pParent,
55 	const SfxItemSet& rInAttrs,
56 	SvxDistributeHorizontal eHor,
57 	SvxDistributeVertical eVer)
58 :	SfxSingleTabDialog(pParent, rInAttrs, RID_SVXPAGE_DISTRIBUTE ),
59 	mpPage(0L)
60 {
61 	mpPage = new SvxDistributePage(this, rInAttrs, eHor, eVer);
62 	SetTabPage(mpPage);
63 	SetText(mpPage->GetText());
64 }
65 
66 /*************************************************************************
67 |*
68 |* Dtor
69 |*
70 \************************************************************************/
71 
72 SvxDistributeDialog::~SvxDistributeDialog()
73 {
74 }
75 
76 /*************************************************************************
77 |*
78 |* Tabpage
79 |*
80 \************************************************************************/
81 
82 SvxDistributePage::SvxDistributePage(
83 	Window* pWindow,
84 	const SfxItemSet& rInAttrs,
85 	SvxDistributeHorizontal eHor,
86 	SvxDistributeVertical eVer)
87 :	SvxTabPage(pWindow, CUI_RES(RID_SVXPAGE_DISTRIBUTE), rInAttrs),
88 	meDistributeHor(eHor),
89 	meDistributeVer(eVer),
90 	maFlHorizontal		(this, CUI_RES(FL_HORIZONTAL		)),
91 	maBtnHorNone		(this, CUI_RES(BTN_HOR_NONE		)),
92 	maBtnHorLeft		(this, CUI_RES(BTN_HOR_LEFT		)),
93 	maBtnHorCenter		(this, CUI_RES(BTN_HOR_CENTER		)),
94 	maBtnHorDistance	(this, CUI_RES(BTN_HOR_DISTANCE	)),
95 	maBtnHorRight		(this, CUI_RES(BTN_HOR_RIGHT		)),
96 	maHorLow			(this, CUI_RES(IMG_HOR_LOW		)),
97 	maHorCenter			(this, CUI_RES(IMG_HOR_CENTER		)),
98 	maHorDistance		(this, CUI_RES(IMG_HOR_DISTANCE	)),
99 	maHorHigh			(this, CUI_RES(IMG_HOR_HIGH		)),
100 	maFlVertical		(this, CUI_RES(FL_VERTICAL		)),
101 	maBtnVerNone		(this, CUI_RES(BTN_VER_NONE		)),
102 	maBtnVerTop			(this, CUI_RES(BTN_VER_TOP		)),
103 	maBtnVerCenter		(this, CUI_RES(BTN_VER_CENTER		)),
104 	maBtnVerDistance	(this, CUI_RES(BTN_VER_DISTANCE	)),
105 	maBtnVerBottom		(this, CUI_RES(BTN_VER_BOTTOM		)),
106     maVerLow            (this, CUI_RES(IMG_VER_LOW        )),
107 	maVerCenter			(this, CUI_RES(IMG_VER_CENTER		)),
108     maVerDistance       (this, CUI_RES(IMG_VER_DISTANCE   )),
109     maVerHigh           (this, CUI_RES(IMG_VER_HIGH       ))
110 {
111 	maHorLow.SetModeImage( Image( CUI_RES( IMG_HOR_LOW_H ) ), BMP_COLOR_HIGHCONTRAST );
112 	maHorCenter.SetModeImage( Image( CUI_RES( IMG_HOR_CENTER_H ) ), BMP_COLOR_HIGHCONTRAST );
113 	maHorDistance.SetModeImage( Image( CUI_RES( IMG_HOR_DISTANCE_H ) ), BMP_COLOR_HIGHCONTRAST );
114 	maHorHigh.SetModeImage( Image( CUI_RES( IMG_HOR_HIGH_H ) ), BMP_COLOR_HIGHCONTRAST );
115 	maVerDistance.SetModeImage( Image( CUI_RES( IMG_VER_DISTANCE_H ) ), BMP_COLOR_HIGHCONTRAST );
116 	maVerLow.SetModeImage( Image( CUI_RES( IMG_VER_LOW_H ) ), BMP_COLOR_HIGHCONTRAST );
117 	maVerCenter.SetModeImage( Image( CUI_RES( IMG_VER_CENTER_H ) ), BMP_COLOR_HIGHCONTRAST );
118 	maVerHigh.SetModeImage( Image( CUI_RES( IMG_VER_HIGH_H ) ), BMP_COLOR_HIGHCONTRAST );
119 
120 	FreeResource();
121 }
122 
123 /*************************************************************************
124 |*
125 |* Dtor
126 |*
127 \************************************************************************/
128 
129 SvxDistributePage::~SvxDistributePage()
130 {
131 }
132 
133 /*************************************************************************
134 |*
135 |* create the tabpage
136 |*
137 \************************************************************************/
138 
139 SfxTabPage* SvxDistributePage::Create(Window* pWindow, const SfxItemSet& rAttrs,
140 	SvxDistributeHorizontal eHor, SvxDistributeVertical eVer)
141 {
142 	return(new SvxDistributePage(pWindow, rAttrs, eHor, eVer));
143 }
144 
145 /*************************************************************************
146 |*
147 |*
148 |*
149 \************************************************************************/
150 
151 sal_uInt16*	SvxDistributePage::GetRanges()
152 {
153 	return(pRanges);
154 }
155 
156 /*************************************************************************
157 |*
158 |*
159 |*
160 \************************************************************************/
161 
162 void SvxDistributePage::PointChanged(Window* /*pWindow*/, RECT_POINT /*eRP*/)
163 {
164 }
165 
166 /*************************************************************************
167 |*
168 |* read the delivered Item-Set
169 |*
170 \************************************************************************/
171 
172 void __EXPORT SvxDistributePage::Reset(const SfxItemSet& )
173 {
174 	maBtnHorNone.SetState(sal_False);
175 	maBtnHorLeft.SetState(sal_False);
176 	maBtnHorCenter.SetState(sal_False);
177 	maBtnHorDistance.SetState(sal_False);
178 	maBtnHorRight.SetState(sal_False);
179 
180 	switch(meDistributeHor)
181 	{
182 		case SvxDistributeHorizontalNone : maBtnHorNone.SetState(sal_True); break;
183 		case SvxDistributeHorizontalLeft : maBtnHorLeft.SetState(sal_True); break;
184 		case SvxDistributeHorizontalCenter : maBtnHorCenter.SetState(sal_True); break;
185 		case SvxDistributeHorizontalDistance : maBtnHorDistance.SetState(sal_True); break;
186 		case SvxDistributeHorizontalRight : maBtnHorRight.SetState(sal_True); break;
187 	}
188 
189 	maBtnVerNone.SetState(sal_False);
190 	maBtnVerTop.SetState(sal_False);
191 	maBtnVerCenter.SetState(sal_False);
192 	maBtnVerDistance.SetState(sal_False);
193 	maBtnVerBottom.SetState(sal_False);
194 
195 	switch(meDistributeVer)
196 	{
197 		case SvxDistributeVerticalNone : maBtnVerNone.SetState(sal_True); break;
198 		case SvxDistributeVerticalTop : maBtnVerTop.SetState(sal_True); break;
199 		case SvxDistributeVerticalCenter : maBtnVerCenter.SetState(sal_True); break;
200 		case SvxDistributeVerticalDistance : maBtnVerDistance.SetState(sal_True); break;
201 		case SvxDistributeVerticalBottom : maBtnVerBottom.SetState(sal_True); break;
202 	}
203 }
204 
205 /*************************************************************************
206 |*
207 |* Fill the delivered Item-Set with dialogbox-attributes
208 |*
209 \************************************************************************/
210 
211 sal_Bool SvxDistributePage::FillItemSet( SfxItemSet& )
212 {
213 	SvxDistributeHorizontal eDistributeHor(SvxDistributeHorizontalNone);
214 	SvxDistributeVertical eDistributeVer(SvxDistributeVerticalNone);
215 
216 	if(maBtnHorLeft.IsChecked())
217 		eDistributeHor = SvxDistributeHorizontalLeft;
218 	else if(maBtnHorCenter.IsChecked())
219 		eDistributeHor = SvxDistributeHorizontalCenter;
220 	else if(maBtnHorDistance.IsChecked())
221 		eDistributeHor = SvxDistributeHorizontalDistance;
222 	else if(maBtnHorRight.IsChecked())
223 		eDistributeHor = SvxDistributeHorizontalRight;
224 
225 	if(maBtnVerTop.IsChecked())
226 		eDistributeVer = SvxDistributeVerticalTop;
227 	else if(maBtnVerCenter.IsChecked())
228 		eDistributeVer = SvxDistributeVerticalCenter;
229 	else if(maBtnVerDistance.IsChecked())
230 		eDistributeVer = SvxDistributeVerticalDistance;
231 	else if(maBtnVerBottom.IsChecked())
232 		eDistributeVer = SvxDistributeVerticalBottom;
233 
234 	if(eDistributeHor != meDistributeHor || eDistributeVer != meDistributeVer)
235 	{
236 		meDistributeHor = eDistributeHor;
237 		meDistributeVer = eDistributeVer;
238 		return sal_True;
239 	}
240 
241 	return sal_False;
242 }
243 
244 
245