1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "CellLineStyleControl.hxx"
22 #include "scresid.hxx"
23 #include <CellAppearancePropertyPanel.hrc>
24 #include "CellLineStyleValueSet.hxx"
25 #include <vcl/i18nhelp.hxx>
26 #include <vcl/settings.hxx>
27 #include <editeng/boxitem.hxx>
28 #include <editeng/borderline.hxx>
29 #include <editeng/lineitem.hxx>
30 #include "CellAppearancePropertyPanel.hxx"
31 #include <sfx2/bindings.hxx>
32 #include <sfx2/dispatch.hxx>
34 namespace sc
{ namespace sidebar
{
36 CellLineStyleControl::CellLineStyleControl(Window
* pParent
, CellAppearancePropertyPanel
& rPanel
)
37 : svx::sidebar::PopupControl(pParent
, ScResId(RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE
)),
38 mrCellAppearancePropertyPanel(rPanel
),
39 maPushButtonMoreOptions(this, ScResId(PB_OPTIONS
)),
40 maCellLineStyleValueSet(this, ScResId(VS_STYLE
)),
47 void CellLineStyleControl::Initialize()
49 //maPushButtonMoreOptions.SetIcoPosX(2);
50 Link aLink
= LINK(this, CellLineStyleControl
, PBClickHdl
);
51 maPushButtonMoreOptions
.SetClickHdl(aLink
);
53 maCellLineStyleValueSet
.SetStyle(maCellLineStyleValueSet
.GetStyle()| WB_3DLOOK
| WB_NO_DIRECTSELECT
);
54 maCellLineStyleValueSet
.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor());
55 maCellLineStyleValueSet
.SetColor(GetSettings().GetStyleSettings().GetMenuColor());
57 for(sal_uInt16 i
= 1 ; i
<= 9 ; i
++)
59 maCellLineStyleValueSet
.InsertItem(i
);
62 maStr
[0] = GetSettings().GetLocaleI18nHelper().GetNum( 5, 2 ) + "pt";
63 maStr
[1] = GetSettings().GetLocaleI18nHelper().GetNum( 250, 2 ) + "pt";
64 maStr
[2] = GetSettings().GetLocaleI18nHelper().GetNum( 400, 2 ) + "pt";
65 maStr
[3] = GetSettings().GetLocaleI18nHelper().GetNum( 500, 2 ) + "pt";
66 maStr
[4] = GetSettings().GetLocaleI18nHelper().GetNum( 110, 2 ) + "pt";
67 maStr
[5] = GetSettings().GetLocaleI18nHelper().GetNum( 260, 2 ) + "pt";
68 maStr
[6] = GetSettings().GetLocaleI18nHelper().GetNum( 450, 2 ) + "pt";
69 maStr
[7] = GetSettings().GetLocaleI18nHelper().GetNum( 505, 2 ) + "pt";
70 maStr
[8] = GetSettings().GetLocaleI18nHelper().GetNum( 750, 2 ) + "pt";
71 maCellLineStyleValueSet
.SetUnit(&maStr
[0]);
73 for (sal_uInt16 i
= 1; i
<= CELL_LINE_STYLE_ENTRIES
; ++i
)
75 maCellLineStyleValueSet
.SetItemText(i
, maStr
[i
-1]);
79 aLink
= LINK(this, CellLineStyleControl
, VSSelectHdl
);
80 maCellLineStyleValueSet
.SetSelectHdl(aLink
);
81 maCellLineStyleValueSet
.StartSelection();
82 maCellLineStyleValueSet
.Show();
85 void CellLineStyleControl::GetFocus()
89 maPushButtonMoreOptions
.GrabFocus();
93 maCellLineStyleValueSet
.GrabFocus();
97 void CellLineStyleControl::SetAllNoSel()
99 maCellLineStyleValueSet
.SelectItem(0);
100 maCellLineStyleValueSet
.SetNoSelection();
101 maCellLineStyleValueSet
.Format();
103 maCellLineStyleValueSet
.StartSelection();
106 IMPL_LINK(CellLineStyleControl
, VSSelectHdl
, void *, pControl
)
108 if(pControl
== &maCellLineStyleValueSet
)
110 const sal_uInt16
iPos(maCellLineStyleValueSet
.GetSelectItemId());
111 SvxLineItem
aLineItem(SID_FRAME_LINESTYLE
);
112 using namespace ::com::sun::star::table::BorderLineStyle
;
113 editeng::SvxBorderStyle nStyle
= SOLID
;
118 //FIXME: fully for new border line possibilities
123 n1
= DEF_LINE_WIDTH_0
;
126 n1
= DEF_LINE_WIDTH_2
;
129 n1
= DEF_LINE_WIDTH_3
;
132 n1
= DEF_LINE_WIDTH_4
;
135 n1
= DEF_LINE_WIDTH_0
;
136 n2
= DEF_LINE_WIDTH_0
;
137 n3
= DEF_LINE_WIDTH_1
;
141 n1
= DEF_LINE_WIDTH_0
;
142 n2
= DEF_LINE_WIDTH_0
;
143 n3
= DEF_LINE_WIDTH_2
;
147 n1
= DEF_LINE_WIDTH_1
;
148 n2
= DEF_LINE_WIDTH_2
;
149 n3
= DEF_LINE_WIDTH_1
;
153 n1
= DEF_LINE_WIDTH_2
;
154 n2
= DEF_LINE_WIDTH_0
;
155 n3
= DEF_LINE_WIDTH_2
;
159 n1
= DEF_LINE_WIDTH_2
;
160 n2
= DEF_LINE_WIDTH_2
;
161 n3
= DEF_LINE_WIDTH_2
;
168 editeng::SvxBorderLine aTmp
;
169 aTmp
.GuessLinesWidths(nStyle
, n1
, n2
, n3
);
170 aLineItem
.SetLine( &aTmp
);
171 mrCellAppearancePropertyPanel
.GetBindings()->GetDispatcher()->Execute(SID_FRAME_LINESTYLE
, SFX_CALLMODE_RECORD
, &aLineItem
, 0L);
173 mrCellAppearancePropertyPanel
.EndCellLineStylePopupMode();
179 IMPL_LINK(CellLineStyleControl
, PBClickHdl
, PushButton
*, pPBtn
)
181 if(pPBtn
== &maPushButtonMoreOptions
)
183 if(mrCellAppearancePropertyPanel
.GetBindings())
185 mrCellAppearancePropertyPanel
.GetBindings()->GetDispatcher()->Execute(SID_CELL_FORMAT_BORDER
, SFX_CALLMODE_ASYNCHRON
);
188 mrCellAppearancePropertyPanel
.EndCellLineStylePopupMode();
194 void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out
, sal_uInt16 in
, sal_uInt16 dis
)
199 //FIXME: fully for new border line possibilities
201 if(out
== DEF_LINE_WIDTH_0
&& in
== 0 && dis
== 0) //1
203 maCellLineStyleValueSet
.SetSelItem(1);
205 else if(out
== DEF_LINE_WIDTH_2
&& in
== 0 && dis
== 0) //2
207 maCellLineStyleValueSet
.SetSelItem(2);
209 else if(out
== DEF_LINE_WIDTH_3
&& in
== 0 && dis
== 0) //3
211 maCellLineStyleValueSet
.SetSelItem(3);
213 else if(out
== DEF_LINE_WIDTH_4
&& in
== 0 && dis
== 0) //4
215 maCellLineStyleValueSet
.SetSelItem(4);
217 else if(out
== DEF_LINE_WIDTH_0
&& in
== DEF_LINE_WIDTH_0
&& dis
== DEF_LINE_WIDTH_1
) //5
219 maCellLineStyleValueSet
.SetSelItem(5);
221 else if(out
== DEF_LINE_WIDTH_0
&& in
== DEF_LINE_WIDTH_0
&& dis
== DEF_LINE_WIDTH_2
) //6
223 maCellLineStyleValueSet
.SetSelItem(6);
225 else if(out
== DEF_LINE_WIDTH_1
&& in
== DEF_LINE_WIDTH_2
&& dis
== DEF_LINE_WIDTH_1
) //7
227 maCellLineStyleValueSet
.SetSelItem(7);
229 else if(out
== DEF_LINE_WIDTH_2
&& in
== DEF_LINE_WIDTH_0
&& dis
== DEF_LINE_WIDTH_2
) //8
231 maCellLineStyleValueSet
.SetSelItem(8);
233 else if(out
== DEF_LINE_WIDTH_2
&& in
== DEF_LINE_WIDTH_2
&& dis
== DEF_LINE_WIDTH_2
) //9
235 maCellLineStyleValueSet
.SetSelItem(9);
239 maCellLineStyleValueSet
.SetSelItem(0);
243 maCellLineStyleValueSet
.Format();
244 maCellLineStyleValueSet
.StartSelection();
247 } } // end of namespace svx::sidebar
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */