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: dstribut.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_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
37 #include <sfx2/basedlgs.hxx>
39 #include <svx/dialogs.hrc>
40 #include "dstribut.hxx"
41 #include "dstribut.hrc"
43 #include <svx/svddef.hxx>
44 #include <svx/dialmgr.hxx>
45 #include <tools/shl.hxx>
47 static USHORT pRanges
[] =
49 SDRATTR_MEASURE_FIRST
,
54 /*************************************************************************
58 \************************************************************************/
60 SvxDistributeDialog::SvxDistributeDialog(
62 const SfxItemSet
& rInAttrs
,
63 SvxDistributeHorizontal eHor
,
64 SvxDistributeVertical eVer
)
65 : SfxSingleTabDialog(pParent
, rInAttrs
, RID_SVXPAGE_DISTRIBUTE
),
68 mpPage
= new SvxDistributePage(this, rInAttrs
, eHor
, eVer
);
70 SetText(mpPage
->GetText());
73 /*************************************************************************
77 \************************************************************************/
79 SvxDistributeDialog::~SvxDistributeDialog()
83 /*************************************************************************
87 \************************************************************************/
89 SvxDistributePage::SvxDistributePage(
91 const SfxItemSet
& rInAttrs
,
92 SvxDistributeHorizontal eHor
,
93 SvxDistributeVertical eVer
)
94 : SvxTabPage(pWindow
, SVX_RES(RID_SVXPAGE_DISTRIBUTE
), rInAttrs
),
95 meDistributeHor(eHor
),
96 meDistributeVer(eVer
),
97 maFlHorizontal (this, SVX_RES(FL_HORIZONTAL
)),
98 maBtnHorNone (this, SVX_RES(BTN_HOR_NONE
)),
99 maBtnHorLeft (this, SVX_RES(BTN_HOR_LEFT
)),
100 maBtnHorCenter (this, SVX_RES(BTN_HOR_CENTER
)),
101 maBtnHorDistance (this, SVX_RES(BTN_HOR_DISTANCE
)),
102 maBtnHorRight (this, SVX_RES(BTN_HOR_RIGHT
)),
103 maHorLow (this, SVX_RES(IMG_HOR_LOW
)),
104 maHorCenter (this, SVX_RES(IMG_HOR_CENTER
)),
105 maHorDistance (this, SVX_RES(IMG_HOR_DISTANCE
)),
106 maHorHigh (this, SVX_RES(IMG_HOR_HIGH
)),
107 maFlVertical (this, SVX_RES(FL_VERTICAL
)),
108 maBtnVerNone (this, SVX_RES(BTN_VER_NONE
)),
109 maBtnVerTop (this, SVX_RES(BTN_VER_TOP
)),
110 maBtnVerCenter (this, SVX_RES(BTN_VER_CENTER
)),
111 maBtnVerDistance (this, SVX_RES(BTN_VER_DISTANCE
)),
112 maBtnVerBottom (this, SVX_RES(BTN_VER_BOTTOM
)),
113 maVerLow (this, SVX_RES(IMG_VER_LOW
)),
114 maVerCenter (this, SVX_RES(IMG_VER_CENTER
)),
115 maVerDistance (this, SVX_RES(IMG_VER_DISTANCE
)),
116 maVerHigh (this, SVX_RES(IMG_VER_HIGH
))
118 maHorLow
.SetModeImage( Image( SVX_RES( IMG_HOR_LOW_H
) ), BMP_COLOR_HIGHCONTRAST
);
119 maHorCenter
.SetModeImage( Image( SVX_RES( IMG_HOR_CENTER_H
) ), BMP_COLOR_HIGHCONTRAST
);
120 maHorDistance
.SetModeImage( Image( SVX_RES( IMG_HOR_DISTANCE_H
) ), BMP_COLOR_HIGHCONTRAST
);
121 maHorHigh
.SetModeImage( Image( SVX_RES( IMG_HOR_HIGH_H
) ), BMP_COLOR_HIGHCONTRAST
);
122 maVerDistance
.SetModeImage( Image( SVX_RES( IMG_VER_DISTANCE_H
) ), BMP_COLOR_HIGHCONTRAST
);
123 maVerLow
.SetModeImage( Image( SVX_RES( IMG_VER_LOW_H
) ), BMP_COLOR_HIGHCONTRAST
);
124 maVerCenter
.SetModeImage( Image( SVX_RES( IMG_VER_CENTER_H
) ), BMP_COLOR_HIGHCONTRAST
);
125 maVerHigh
.SetModeImage( Image( SVX_RES( IMG_VER_HIGH_H
) ), BMP_COLOR_HIGHCONTRAST
);
130 /*************************************************************************
134 \************************************************************************/
136 SvxDistributePage::~SvxDistributePage()
140 /*************************************************************************
142 |* create the tabpage
144 \************************************************************************/
146 SfxTabPage
* SvxDistributePage::Create(Window
* pWindow
, const SfxItemSet
& rAttrs
,
147 SvxDistributeHorizontal eHor
, SvxDistributeVertical eVer
)
149 return(new SvxDistributePage(pWindow
, rAttrs
, eHor
, eVer
));
152 /*************************************************************************
156 \************************************************************************/
158 UINT16
* SvxDistributePage::GetRanges()
163 /*************************************************************************
167 \************************************************************************/
169 void SvxDistributePage::PointChanged(Window
* /*pWindow*/, RECT_POINT
/*eRP*/)
173 /*************************************************************************
175 |* read the delivered Item-Set
177 \************************************************************************/
179 void __EXPORT
SvxDistributePage::Reset(const SfxItemSet
& )
181 maBtnHorNone
.SetState(FALSE
);
182 maBtnHorLeft
.SetState(FALSE
);
183 maBtnHorCenter
.SetState(FALSE
);
184 maBtnHorDistance
.SetState(FALSE
);
185 maBtnHorRight
.SetState(FALSE
);
187 switch(meDistributeHor
)
189 case SvxDistributeHorizontalNone
: maBtnHorNone
.SetState(TRUE
); break;
190 case SvxDistributeHorizontalLeft
: maBtnHorLeft
.SetState(TRUE
); break;
191 case SvxDistributeHorizontalCenter
: maBtnHorCenter
.SetState(TRUE
); break;
192 case SvxDistributeHorizontalDistance
: maBtnHorDistance
.SetState(TRUE
); break;
193 case SvxDistributeHorizontalRight
: maBtnHorRight
.SetState(TRUE
); break;
196 maBtnVerNone
.SetState(FALSE
);
197 maBtnVerTop
.SetState(FALSE
);
198 maBtnVerCenter
.SetState(FALSE
);
199 maBtnVerDistance
.SetState(FALSE
);
200 maBtnVerBottom
.SetState(FALSE
);
202 switch(meDistributeVer
)
204 case SvxDistributeVerticalNone
: maBtnVerNone
.SetState(TRUE
); break;
205 case SvxDistributeVerticalTop
: maBtnVerTop
.SetState(TRUE
); break;
206 case SvxDistributeVerticalCenter
: maBtnVerCenter
.SetState(TRUE
); break;
207 case SvxDistributeVerticalDistance
: maBtnVerDistance
.SetState(TRUE
); break;
208 case SvxDistributeVerticalBottom
: maBtnVerBottom
.SetState(TRUE
); break;
212 /*************************************************************************
214 |* Fill the delivered Item-Set with dialogbox-attributes
216 \************************************************************************/
218 BOOL
SvxDistributePage::FillItemSet( SfxItemSet
& )
220 SvxDistributeHorizontal
eDistributeHor(SvxDistributeHorizontalNone
);
221 SvxDistributeVertical
eDistributeVer(SvxDistributeVerticalNone
);
223 if(maBtnHorLeft
.IsChecked())
224 eDistributeHor
= SvxDistributeHorizontalLeft
;
225 else if(maBtnHorCenter
.IsChecked())
226 eDistributeHor
= SvxDistributeHorizontalCenter
;
227 else if(maBtnHorDistance
.IsChecked())
228 eDistributeHor
= SvxDistributeHorizontalDistance
;
229 else if(maBtnHorRight
.IsChecked())
230 eDistributeHor
= SvxDistributeHorizontalRight
;
232 if(maBtnVerTop
.IsChecked())
233 eDistributeVer
= SvxDistributeVerticalTop
;
234 else if(maBtnVerCenter
.IsChecked())
235 eDistributeVer
= SvxDistributeVerticalCenter
;
236 else if(maBtnVerDistance
.IsChecked())
237 eDistributeVer
= SvxDistributeVerticalDistance
;
238 else if(maBtnVerBottom
.IsChecked())
239 eDistributeVer
= SvxDistributeVerticalBottom
;
241 if(eDistributeHor
!= meDistributeHor
|| eDistributeVer
!= meDistributeVer
)
243 meDistributeHor
= eDistributeHor
;
244 meDistributeVer
= eDistributeVer
;