fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / sidebar / CellLineStyleControl.cxx
blobc250b903d350435aeba9fcc3b52fe383851ab57a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
21 #include "sc.hrc"
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))),
41 mbVSfocus(true)
43 Initialize();
44 FreeResource();
47 CellLineStyleControl::~CellLineStyleControl()
49 disposeOnce();
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]);
90 SetAllNoSel();
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();
111 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;
123 sal_uInt16 n1 = 0;
124 sal_uInt16 n2 = 0;
125 sal_uInt16 n3 = 0;
127 //FIXME: fully for new border line possibilities
129 switch(iPos)
131 case 1:
132 n1 = DEF_LINE_WIDTH_0;
133 break;
134 case 2:
135 n1 = DEF_LINE_WIDTH_2;
136 break;
137 case 3:
138 n1 = DEF_LINE_WIDTH_3;
139 break;
140 case 4:
141 n1 = DEF_LINE_WIDTH_4;
142 break;
143 case 5:
144 n1 = DEF_LINE_WIDTH_0;
145 n2 = DEF_LINE_WIDTH_0;
146 n3 = DEF_LINE_WIDTH_1;
147 nStyle = DOUBLE;
148 break;
149 case 6:
150 n1 = DEF_LINE_WIDTH_0;
151 n2 = DEF_LINE_WIDTH_0;
152 n3 = DEF_LINE_WIDTH_2;
153 nStyle = DOUBLE;
154 break;
155 case 7:
156 n1 = DEF_LINE_WIDTH_1;
157 n2 = DEF_LINE_WIDTH_2;
158 n3 = DEF_LINE_WIDTH_1;
159 nStyle = DOUBLE;
160 break;
161 case 8:
162 n1 = DEF_LINE_WIDTH_2;
163 n2 = DEF_LINE_WIDTH_0;
164 n3 = DEF_LINE_WIDTH_2;
165 nStyle = DOUBLE;
166 break;
167 case 9:
168 n1 = DEF_LINE_WIDTH_2;
169 n2 = DEF_LINE_WIDTH_2;
170 n3 = DEF_LINE_WIDTH_2;
171 nStyle = DOUBLE;
172 break;
173 default:
174 break;
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);
181 SetAllNoSel();
182 mrCellAppearancePropertyPanel.EndCellLineStylePopupMode();
185 return 0L;
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();
200 return 0;
203 void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis)
205 SetAllNoSel();
206 mbVSfocus = true;
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);
246 else
248 maCellLineStyleValueSet->SetSelItem(0);
249 mbVSfocus = false;
251 maCellLineStyleValueSet->SetFormat();
252 maCellLineStyleValueSet->Invalidate();
253 maCellLineStyleValueSet->StartSelection();
256 } } // end of namespace svx::sidebar
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */