1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26
27 #include <sfx2/basedlgs.hxx>
28 #include <cuires.hrc>
29 #include "dstribut.hxx"
30 #include "dstribut.hrc"
31 #include <svx/dialogs.hrc>
32 #include <svx/svddef.hxx>
33 #include <dialmgr.hxx>
34 #include <tools/shl.hxx>
35
36 static sal_uInt16 pRanges[] =
37 {
38 SDRATTR_MEASURE_FIRST,
39 SDRATTR_MEASURE_LAST,
40 0
41 };
42
43 /*************************************************************************
44 |*
45 |* Dialog
46 |*
47 \************************************************************************/
48
SvxDistributeDialog(Window * pParent,const SfxItemSet & rInAttrs,SvxDistributeHorizontal eHor,SvxDistributeVertical eVer)49 SvxDistributeDialog::SvxDistributeDialog(
50 Window* pParent,
51 const SfxItemSet& rInAttrs,
52 SvxDistributeHorizontal eHor,
53 SvxDistributeVertical eVer)
54 : SfxSingleTabDialog(pParent, rInAttrs, RID_SVXPAGE_DISTRIBUTE ),
55 mpPage(0L)
56 {
57 mpPage = new SvxDistributePage(this, rInAttrs, eHor, eVer);
58 SetTabPage(mpPage);
59 SetText(mpPage->GetText());
60 }
61
62 /*************************************************************************
63 |*
64 |* Dtor
65 |*
66 \************************************************************************/
67
~SvxDistributeDialog()68 SvxDistributeDialog::~SvxDistributeDialog()
69 {
70 }
71
72 /*************************************************************************
73 |*
74 |* Tabpage
75 |*
76 \************************************************************************/
77
SvxDistributePage(Window * pWindow,const SfxItemSet & rInAttrs,SvxDistributeHorizontal eHor,SvxDistributeVertical eVer)78 SvxDistributePage::SvxDistributePage(
79 Window* pWindow,
80 const SfxItemSet& rInAttrs,
81 SvxDistributeHorizontal eHor,
82 SvxDistributeVertical eVer)
83 : SvxTabPage(pWindow, CUI_RES(RID_SVXPAGE_DISTRIBUTE), rInAttrs),
84 meDistributeHor(eHor),
85 meDistributeVer(eVer),
86 maFlHorizontal (this, CUI_RES(FL_HORIZONTAL )),
87 maBtnHorNone (this, CUI_RES(BTN_HOR_NONE )),
88 maBtnHorLeft (this, CUI_RES(BTN_HOR_LEFT )),
89 maBtnHorCenter (this, CUI_RES(BTN_HOR_CENTER )),
90 maBtnHorDistance (this, CUI_RES(BTN_HOR_DISTANCE )),
91 maBtnHorRight (this, CUI_RES(BTN_HOR_RIGHT )),
92 maHorLow (this, CUI_RES(IMG_HOR_LOW )),
93 maHorCenter (this, CUI_RES(IMG_HOR_CENTER )),
94 maHorDistance (this, CUI_RES(IMG_HOR_DISTANCE )),
95 maHorHigh (this, CUI_RES(IMG_HOR_HIGH )),
96 maFlVertical (this, CUI_RES(FL_VERTICAL )),
97 maBtnVerNone (this, CUI_RES(BTN_VER_NONE )),
98 maBtnVerTop (this, CUI_RES(BTN_VER_TOP )),
99 maBtnVerCenter (this, CUI_RES(BTN_VER_CENTER )),
100 maBtnVerDistance (this, CUI_RES(BTN_VER_DISTANCE )),
101 maBtnVerBottom (this, CUI_RES(BTN_VER_BOTTOM )),
102 maVerLow (this, CUI_RES(IMG_VER_LOW )),
103 maVerCenter (this, CUI_RES(IMG_VER_CENTER )),
104 maVerDistance (this, CUI_RES(IMG_VER_DISTANCE )),
105 maVerHigh (this, CUI_RES(IMG_VER_HIGH ))
106 {
107 maHorLow.SetModeImage( Image( CUI_RES( IMG_HOR_LOW_H ) ), BMP_COLOR_HIGHCONTRAST );
108 maHorCenter.SetModeImage( Image( CUI_RES( IMG_HOR_CENTER_H ) ), BMP_COLOR_HIGHCONTRAST );
109 maHorDistance.SetModeImage( Image( CUI_RES( IMG_HOR_DISTANCE_H ) ), BMP_COLOR_HIGHCONTRAST );
110 maHorHigh.SetModeImage( Image( CUI_RES( IMG_HOR_HIGH_H ) ), BMP_COLOR_HIGHCONTRAST );
111 maVerDistance.SetModeImage( Image( CUI_RES( IMG_VER_DISTANCE_H ) ), BMP_COLOR_HIGHCONTRAST );
112 maVerLow.SetModeImage( Image( CUI_RES( IMG_VER_LOW_H ) ), BMP_COLOR_HIGHCONTRAST );
113 maVerCenter.SetModeImage( Image( CUI_RES( IMG_VER_CENTER_H ) ), BMP_COLOR_HIGHCONTRAST );
114 maVerHigh.SetModeImage( Image( CUI_RES( IMG_VER_HIGH_H ) ), BMP_COLOR_HIGHCONTRAST );
115
116 FreeResource();
117 }
118
119 /*************************************************************************
120 |*
121 |* Dtor
122 |*
123 \************************************************************************/
124
~SvxDistributePage()125 SvxDistributePage::~SvxDistributePage()
126 {
127 }
128
129 /*************************************************************************
130 |*
131 |* create the tabpage
132 |*
133 \************************************************************************/
134
Create(Window * pWindow,const SfxItemSet & rAttrs,SvxDistributeHorizontal eHor,SvxDistributeVertical eVer)135 SfxTabPage* SvxDistributePage::Create(Window* pWindow, const SfxItemSet& rAttrs,
136 SvxDistributeHorizontal eHor, SvxDistributeVertical eVer)
137 {
138 return(new SvxDistributePage(pWindow, rAttrs, eHor, eVer));
139 }
140
141 /*************************************************************************
142 |*
143 |*
144 |*
145 \************************************************************************/
146
GetRanges()147 sal_uInt16* SvxDistributePage::GetRanges()
148 {
149 return(pRanges);
150 }
151
152 /*************************************************************************
153 |*
154 |*
155 |*
156 \************************************************************************/
157
PointChanged(Window *,RECT_POINT)158 void SvxDistributePage::PointChanged(Window* /*pWindow*/, RECT_POINT /*eRP*/)
159 {
160 }
161
162 /*************************************************************************
163 |*
164 |* read the delivered Item-Set
165 |*
166 \************************************************************************/
167
Reset(const SfxItemSet &)168 void __EXPORT SvxDistributePage::Reset(const SfxItemSet& )
169 {
170 maBtnHorNone.SetState(sal_False);
171 maBtnHorLeft.SetState(sal_False);
172 maBtnHorCenter.SetState(sal_False);
173 maBtnHorDistance.SetState(sal_False);
174 maBtnHorRight.SetState(sal_False);
175
176 switch(meDistributeHor)
177 {
178 case SvxDistributeHorizontalNone : maBtnHorNone.SetState(sal_True); break;
179 case SvxDistributeHorizontalLeft : maBtnHorLeft.SetState(sal_True); break;
180 case SvxDistributeHorizontalCenter : maBtnHorCenter.SetState(sal_True); break;
181 case SvxDistributeHorizontalDistance : maBtnHorDistance.SetState(sal_True); break;
182 case SvxDistributeHorizontalRight : maBtnHorRight.SetState(sal_True); break;
183 }
184
185 maBtnVerNone.SetState(sal_False);
186 maBtnVerTop.SetState(sal_False);
187 maBtnVerCenter.SetState(sal_False);
188 maBtnVerDistance.SetState(sal_False);
189 maBtnVerBottom.SetState(sal_False);
190
191 switch(meDistributeVer)
192 {
193 case SvxDistributeVerticalNone : maBtnVerNone.SetState(sal_True); break;
194 case SvxDistributeVerticalTop : maBtnVerTop.SetState(sal_True); break;
195 case SvxDistributeVerticalCenter : maBtnVerCenter.SetState(sal_True); break;
196 case SvxDistributeVerticalDistance : maBtnVerDistance.SetState(sal_True); break;
197 case SvxDistributeVerticalBottom : maBtnVerBottom.SetState(sal_True); break;
198 }
199 }
200
201 /*************************************************************************
202 |*
203 |* Fill the delivered Item-Set with dialogbox-attributes
204 |*
205 \************************************************************************/
206
FillItemSet(SfxItemSet &)207 sal_Bool SvxDistributePage::FillItemSet( SfxItemSet& )
208 {
209 SvxDistributeHorizontal eDistributeHor(SvxDistributeHorizontalNone);
210 SvxDistributeVertical eDistributeVer(SvxDistributeVerticalNone);
211
212 if(maBtnHorLeft.IsChecked())
213 eDistributeHor = SvxDistributeHorizontalLeft;
214 else if(maBtnHorCenter.IsChecked())
215 eDistributeHor = SvxDistributeHorizontalCenter;
216 else if(maBtnHorDistance.IsChecked())
217 eDistributeHor = SvxDistributeHorizontalDistance;
218 else if(maBtnHorRight.IsChecked())
219 eDistributeHor = SvxDistributeHorizontalRight;
220
221 if(maBtnVerTop.IsChecked())
222 eDistributeVer = SvxDistributeVerticalTop;
223 else if(maBtnVerCenter.IsChecked())
224 eDistributeVer = SvxDistributeVerticalCenter;
225 else if(maBtnVerDistance.IsChecked())
226 eDistributeVer = SvxDistributeVerticalDistance;
227 else if(maBtnVerBottom.IsChecked())
228 eDistributeVer = SvxDistributeVerticalBottom;
229
230 if(eDistributeHor != meDistributeHor || eDistributeVer != meDistributeVer)
231 {
232 meDistributeHor = eDistributeHor;
233 meDistributeVer = eDistributeVer;
234 return sal_True;
235 }
236
237 return sal_False;
238 }
239
240
241