bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / sidebar / CellLineStyleControl.cxx
blob339eff356dfb5a2aacf17c745d14d61902a77f99
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <CellLineStyleControl.hxx>
20 #include "sc.hrc"
21 #include "scresid.hxx"
22 #include <CellAppearancePropertyPanel.hrc>
23 #include <CellLineStyleValueSet.hxx>
24 #include <vcl/i18nhelp.hxx>
25 #include <editeng/boxitem.hxx>
26 #include <editeng/borderline.hxx>
27 #include <editeng/lineitem.hxx>
28 #include <CellAppearancePropertyPanel.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/dispatch.hxx>
32 namespace sc { namespace sidebar {
34 CellLineStyleControl::CellLineStyleControl(Window* pParent, CellAppearancePropertyPanel& rPanel)
35 : svx::sidebar::PopupControl(pParent, ScResId(RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE)),
36 mrCellAppearancePropertyPanel(rPanel),
37 maPushButtonMoreOptions(this, ScResId(PB_OPTIONS)),
38 maCellLineStyleValueSet(this, ScResId(VS_STYLE)),
39 mpStr(0),
40 mbVSfocus(true)
42 Initialize();
43 FreeResource();
46 CellLineStyleControl::~CellLineStyleControl(void)
48 delete[] mpStr;
51 void CellLineStyleControl::Initialize()
53 //maPushButtonMoreOptions.SetIcoPosX(2);
54 Link aLink = LINK(this, CellLineStyleControl, PBClickHdl);
55 maPushButtonMoreOptions.SetClickHdl(aLink);
57 maCellLineStyleValueSet.SetStyle(maCellLineStyleValueSet.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT);
58 maCellLineStyleValueSet.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor());
59 maCellLineStyleValueSet.SetColor(GetSettings().GetStyleSettings().GetMenuColor());
61 for(sal_uInt16 i = 1 ; i <= 9 ; i++)
63 maCellLineStyleValueSet.InsertItem(i);
66 mpStr = new XubString[9];
67 mpStr[0] = GetSettings().GetLocaleI18nHelper().GetNum( 5, 2 ).AppendAscii("pt");
68 mpStr[1] = GetSettings().GetLocaleI18nHelper().GetNum( 250, 2 ).AppendAscii("pt");
69 mpStr[2] = GetSettings().GetLocaleI18nHelper().GetNum( 400, 2 ).AppendAscii("pt");
70 mpStr[3] = GetSettings().GetLocaleI18nHelper().GetNum( 500, 2 ).AppendAscii("pt");
71 mpStr[4] = GetSettings().GetLocaleI18nHelper().GetNum( 110, 2 ).AppendAscii("pt");
72 mpStr[5] = GetSettings().GetLocaleI18nHelper().GetNum( 260, 2 ).AppendAscii("pt");
73 mpStr[6] = GetSettings().GetLocaleI18nHelper().GetNum( 450, 2 ).AppendAscii("pt");
74 mpStr[7] = GetSettings().GetLocaleI18nHelper().GetNum( 505, 2 ).AppendAscii("pt");
75 mpStr[8] = GetSettings().GetLocaleI18nHelper().GetNum( 750, 2 ).AppendAscii("pt");
76 maCellLineStyleValueSet.SetUnit(mpStr);
78 for(sal_uInt16 i = 1 ; i <= 9 ; i++)
80 maCellLineStyleValueSet.SetItemText(i, mpStr[i-1]);
83 SetAllNoSel();
84 aLink = LINK(this, CellLineStyleControl, VSSelectHdl);
85 maCellLineStyleValueSet.SetSelectHdl(aLink);
86 maCellLineStyleValueSet.StartSelection();
87 maCellLineStyleValueSet.Show();
90 void CellLineStyleControl::GetFocus()
92 if(!mbVSfocus)
94 maPushButtonMoreOptions.GrabFocus();
96 else
98 maCellLineStyleValueSet.GrabFocus();
102 void CellLineStyleControl::SetAllNoSel()
104 maCellLineStyleValueSet.SelectItem(0);
105 maCellLineStyleValueSet.SetNoSelection();
106 maCellLineStyleValueSet.Format();
107 Invalidate();
108 maCellLineStyleValueSet.StartSelection();
111 IMPL_LINK(CellLineStyleControl, VSSelectHdl, void *, pControl)
113 if(pControl == &maCellLineStyleValueSet)
115 const sal_uInt16 iPos(maCellLineStyleValueSet.GetSelectItemId());
116 SvxLineItem aLineItem(SID_FRAME_LINESTYLE);
117 using namespace ::com::sun::star::table::BorderLineStyle;
118 editeng::SvxBorderStyle nStyle = SOLID;
119 sal_uInt16 n1 = 0;
120 sal_uInt16 n2 = 0;
121 sal_uInt16 n3 = 0;
123 //FIXME: fully for new border line possibilities
125 switch(iPos)
127 case 1:
128 n1 = DEF_LINE_WIDTH_0;
129 break;
130 case 2:
131 n1 = DEF_LINE_WIDTH_2;
132 break;
133 case 3:
134 n1 = DEF_LINE_WIDTH_3;
135 break;
136 case 4:
137 n1 = DEF_LINE_WIDTH_4;
138 break;
139 case 5:
140 n1 = DEF_LINE_WIDTH_0;
141 n2 = DEF_LINE_WIDTH_0;
142 n3 = DEF_LINE_WIDTH_1;
143 nStyle = DOUBLE;
144 break;
145 case 6:
146 n1 = DEF_LINE_WIDTH_0;
147 n2 = DEF_LINE_WIDTH_0;
148 n3 = DEF_LINE_WIDTH_2;
149 nStyle = DOUBLE;
150 break;
151 case 7:
152 n1 = DEF_LINE_WIDTH_1;
153 n2 = DEF_LINE_WIDTH_2;
154 n3 = DEF_LINE_WIDTH_1;
155 nStyle = DOUBLE;
156 break;
157 case 8:
158 n1 = DEF_LINE_WIDTH_2;
159 n2 = DEF_LINE_WIDTH_0;
160 n3 = DEF_LINE_WIDTH_2;
161 nStyle = DOUBLE;
162 break;
163 case 9:
164 n1 = DEF_LINE_WIDTH_2;
165 n2 = DEF_LINE_WIDTH_2;
166 n3 = DEF_LINE_WIDTH_2;
167 nStyle = DOUBLE;
168 break;
169 default:
170 break;
173 editeng::SvxBorderLine aTmp;
174 aTmp.GuessLinesWidths(nStyle, n1, n2, n3);
175 aLineItem.SetLine( &aTmp );
176 mrCellAppearancePropertyPanel.GetBindings()->GetDispatcher()->Execute(SID_FRAME_LINESTYLE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
177 SetAllNoSel();
178 mrCellAppearancePropertyPanel.EndCellLineStylePopupMode();
181 return(0L);
184 IMPL_LINK(CellLineStyleControl, PBClickHdl, PushButton *, pPBtn)
186 if(pPBtn == &maPushButtonMoreOptions)
188 if(mrCellAppearancePropertyPanel.GetBindings())
190 mrCellAppearancePropertyPanel.GetBindings()->GetDispatcher()->Execute(SID_CELL_FORMAT_BORDER, SFX_CALLMODE_ASYNCHRON);
193 mrCellAppearancePropertyPanel.EndCellLineStylePopupMode();
196 return 0;
199 void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis)
201 SetAllNoSel();
202 mbVSfocus = true;
204 //FIXME: fully for new border line possibilities
206 if(out == DEF_LINE_WIDTH_0 && in == 0 && dis == 0) //1
208 maCellLineStyleValueSet.SetSelItem(1);
210 else if(out == DEF_LINE_WIDTH_2 && in == 0 && dis == 0) //2
212 maCellLineStyleValueSet.SetSelItem(2);
214 else if(out == DEF_LINE_WIDTH_3 && in == 0 && dis == 0) //3
216 maCellLineStyleValueSet.SetSelItem(3);
218 else if(out == DEF_LINE_WIDTH_4 && in == 0 && dis == 0) //4
220 maCellLineStyleValueSet.SetSelItem(4);
222 else if(out == DEF_LINE_WIDTH_0 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_1) //5
224 maCellLineStyleValueSet.SetSelItem(5);
226 else if(out == DEF_LINE_WIDTH_0 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_2) //6
228 maCellLineStyleValueSet.SetSelItem(6);
230 else if(out == DEF_LINE_WIDTH_1 && in == DEF_LINE_WIDTH_2 && dis == DEF_LINE_WIDTH_1) //7
232 maCellLineStyleValueSet.SetSelItem(7);
234 else if(out == DEF_LINE_WIDTH_2 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_2) //8
236 maCellLineStyleValueSet.SetSelItem(8);
238 else if(out == DEF_LINE_WIDTH_2 && in == DEF_LINE_WIDTH_2 && dis == DEF_LINE_WIDTH_2) //9
240 maCellLineStyleValueSet.SetSelItem(9);
242 else
244 maCellLineStyleValueSet.SetSelItem(0);
245 mbVSfocus = false;
248 maCellLineStyleValueSet.Format();
249 maCellLineStyleValueSet.StartSelection();
252 } } // end of namespace svx::sidebar
254 // eof