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(vcl::Window
* pParent
, CellAppearancePropertyPanel
& rPanel
)
37 : svx::sidebar::PopupControl(pParent
, ScResId(RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE
)),
38 mrCellAppearancePropertyPanel(rPanel
),
39 maPushButtonMoreOptions(VclPtr
<PushButton
>::Create(this, ScResId(PB_OPTIONS
))),
40 maCellLineStyleValueSet(VclPtr
<sc::sidebar::CellLineStyleValueSet
>::Create(this, ScResId(VS_STYLE
))),
47 CellLineStyleControl::~CellLineStyleControl()
52 void CellLineStyleControl::dispose()
54 maPushButtonMoreOptions
.disposeAndClear();
55 maCellLineStyleValueSet
.disposeAndClear();
56 svx::sidebar::PopupControl::dispose();
59 void CellLineStyleControl::Initialize()
61 //maPushButtonMoreOptions->SetIcoPosX(2);
62 Link
<> aLink
= LINK(this, CellLineStyleControl
, PBClickHdl
);
63 maPushButtonMoreOptions
->SetClickHdl(aLink
);
65 maCellLineStyleValueSet
->SetStyle(maCellLineStyleValueSet
->GetStyle()| WB_3DLOOK
| WB_NO_DIRECTSELECT
);
66 maCellLineStyleValueSet
->SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor());
67 maCellLineStyleValueSet
->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
69 for(sal_uInt16 i
= 1 ; i
<= 9 ; i
++)
71 maCellLineStyleValueSet
->InsertItem(i
);
74 maStr
[0] = GetSettings().GetLocaleI18nHelper().GetNum( 5, 2 ) + "pt";
75 maStr
[1] = GetSettings().GetLocaleI18nHelper().GetNum( 250, 2 ) + "pt";
76 maStr
[2] = GetSettings().GetLocaleI18nHelper().GetNum( 400, 2 ) + "pt";
77 maStr
[3] = GetSettings().GetLocaleI18nHelper().GetNum( 500, 2 ) + "pt";
78 maStr
[4] = GetSettings().GetLocaleI18nHelper().GetNum( 110, 2 ) + "pt";
79 maStr
[5] = GetSettings().GetLocaleI18nHelper().GetNum( 260, 2 ) + "pt";
80 maStr
[6] = GetSettings().GetLocaleI18nHelper().GetNum( 450, 2 ) + "pt";
81 maStr
[7] = GetSettings().GetLocaleI18nHelper().GetNum( 505, 2 ) + "pt";
82 maStr
[8] = GetSettings().GetLocaleI18nHelper().GetNum( 750, 2 ) + "pt";
83 maCellLineStyleValueSet
->SetUnit(&maStr
[0]);
85 for (sal_uInt16 i
= 1; i
<= CELL_LINE_STYLE_ENTRIES
; ++i
)
87 maCellLineStyleValueSet
->SetItemText(i
, maStr
[i
-1]);
91 aLink
= LINK(this, CellLineStyleControl
, VSSelectHdl
);
92 maCellLineStyleValueSet
->SetSelectHdl(aLink
);
93 maCellLineStyleValueSet
->StartSelection();
94 maCellLineStyleValueSet
->Show();
97 void CellLineStyleControl::GetFocus()
99 if (!mbVSfocus
&& maPushButtonMoreOptions
)
100 maPushButtonMoreOptions
->GrabFocus();
101 else if (maCellLineStyleValueSet
)
102 maCellLineStyleValueSet
->GrabFocus();
105 void CellLineStyleControl::SetAllNoSel()
107 maCellLineStyleValueSet
->SelectItem(0);
108 maCellLineStyleValueSet
->SetNoSelection();
109 maCellLineStyleValueSet
->SetFormat();
110 maCellLineStyleValueSet
->Invalidate();
112 maCellLineStyleValueSet
->StartSelection();
115 IMPL_LINK(CellLineStyleControl
, VSSelectHdl
, void *, pControl
)
117 if(pControl
== maCellLineStyleValueSet
.get())
119 const sal_uInt16
iPos(maCellLineStyleValueSet
->GetSelectItemId());
120 SvxLineItem
aLineItem(SID_FRAME_LINESTYLE
);
121 using namespace ::com::sun::star::table::BorderLineStyle
;
122 editeng::SvxBorderStyle nStyle
= SOLID
;
127 //FIXME: fully for new border line possibilities
132 n1
= DEF_LINE_WIDTH_0
;
135 n1
= DEF_LINE_WIDTH_2
;
138 n1
= DEF_LINE_WIDTH_3
;
141 n1
= DEF_LINE_WIDTH_4
;
144 n1
= DEF_LINE_WIDTH_0
;
145 n2
= DEF_LINE_WIDTH_0
;
146 n3
= DEF_LINE_WIDTH_1
;
150 n1
= DEF_LINE_WIDTH_0
;
151 n2
= DEF_LINE_WIDTH_0
;
152 n3
= DEF_LINE_WIDTH_2
;
156 n1
= DEF_LINE_WIDTH_1
;
157 n2
= DEF_LINE_WIDTH_2
;
158 n3
= DEF_LINE_WIDTH_1
;
162 n1
= DEF_LINE_WIDTH_2
;
163 n2
= DEF_LINE_WIDTH_0
;
164 n3
= DEF_LINE_WIDTH_2
;
168 n1
= DEF_LINE_WIDTH_2
;
169 n2
= DEF_LINE_WIDTH_2
;
170 n3
= DEF_LINE_WIDTH_2
;
177 editeng::SvxBorderLine aTmp
;
178 aTmp
.GuessLinesWidths(nStyle
, n1
, n2
, n3
);
179 aLineItem
.SetLine( &aTmp
);
180 mrCellAppearancePropertyPanel
.GetBindings()->GetDispatcher()->Execute(SID_FRAME_LINESTYLE
, SfxCallMode::RECORD
, &aLineItem
, 0L);
182 mrCellAppearancePropertyPanel
.EndCellLineStylePopupMode();
188 IMPL_LINK(CellLineStyleControl
, PBClickHdl
, PushButton
*, pPBtn
)
190 if(pPBtn
== maPushButtonMoreOptions
.get())
192 if(mrCellAppearancePropertyPanel
.GetBindings())
194 mrCellAppearancePropertyPanel
.GetBindings()->GetDispatcher()->Execute(SID_CELL_FORMAT_BORDER
, SfxCallMode::ASYNCHRON
);
197 mrCellAppearancePropertyPanel
.EndCellLineStylePopupMode();
203 void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out
, sal_uInt16 in
, sal_uInt16 dis
)
208 //FIXME: fully for new border line possibilities
210 if(out
== DEF_LINE_WIDTH_0
&& in
== 0 && dis
== 0) //1
212 maCellLineStyleValueSet
->SetSelItem(1);
214 else if(out
== DEF_LINE_WIDTH_2
&& in
== 0 && dis
== 0) //2
216 maCellLineStyleValueSet
->SetSelItem(2);
218 else if(out
== DEF_LINE_WIDTH_3
&& in
== 0 && dis
== 0) //3
220 maCellLineStyleValueSet
->SetSelItem(3);
222 else if(out
== DEF_LINE_WIDTH_4
&& in
== 0 && dis
== 0) //4
224 maCellLineStyleValueSet
->SetSelItem(4);
226 else if(out
== DEF_LINE_WIDTH_0
&& in
== DEF_LINE_WIDTH_0
&& dis
== DEF_LINE_WIDTH_1
) //5
228 maCellLineStyleValueSet
->SetSelItem(5);
230 else if(out
== DEF_LINE_WIDTH_0
&& in
== DEF_LINE_WIDTH_0
&& dis
== DEF_LINE_WIDTH_2
) //6
232 maCellLineStyleValueSet
->SetSelItem(6);
234 else if(out
== DEF_LINE_WIDTH_1
&& in
== DEF_LINE_WIDTH_2
&& dis
== DEF_LINE_WIDTH_1
) //7
236 maCellLineStyleValueSet
->SetSelItem(7);
238 else if(out
== DEF_LINE_WIDTH_2
&& in
== DEF_LINE_WIDTH_0
&& dis
== DEF_LINE_WIDTH_2
) //8
240 maCellLineStyleValueSet
->SetSelItem(8);
242 else if(out
== DEF_LINE_WIDTH_2
&& in
== DEF_LINE_WIDTH_2
&& dis
== DEF_LINE_WIDTH_2
) //9
244 maCellLineStyleValueSet
->SetSelItem(9);
248 maCellLineStyleValueSet
->SetSelItem(0);
251 maCellLineStyleValueSet
->SetFormat();
252 maCellLineStyleValueSet
->Invalidate();
253 maCellLineStyleValueSet
->StartSelection();
256 } } // end of namespace svx::sidebar
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */