1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include "precompiled_sc.hxx" 23 24 #include <CellLineStyleControl.hxx> 25 #include "sc.hrc" 26 #include "scresid.hxx" 27 #include <CellAppearancePropertyPanel.hrc> 28 #include <CellLineStyleValueSet.hxx> 29 #include <vcl/i18nhelp.hxx> 30 #include <editeng/boxitem.hxx> 31 #include <editeng/bolnitem.hxx> 32 #include <CellAppearancePropertyPanel.hxx> 33 #include <sfx2/bindings.hxx> 34 #include <sfx2/dispatch.hxx> 35 36 namespace sc { namespace sidebar { 37 38 CellLineStyleControl::CellLineStyleControl(Window* pParent, CellAppearancePropertyPanel& rPanel) 39 : svx::sidebar::PopupControl(pParent, ScResId(RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE)), 40 mrCellAppearancePropertyPanel(rPanel), 41 maPushButtonMoreOptions(this, ScResId(PB_OPTIONS)), 42 maCellLineStyleValueSet(this, ScResId(VS_STYLE)), 43 mpStr(0), 44 mbVSfocus(true) 45 { 46 Initialize(); 47 FreeResource(); 48 } 49 50 CellLineStyleControl::~CellLineStyleControl(void) 51 { 52 delete[] mpStr; 53 } 54 55 void CellLineStyleControl::Initialize() 56 { 57 //if(!GetSettings().GetStyleSettings().GetHighContrastMode()) 58 //{ 59 // maPushButtonMoreOptions.SetDefBkColor(GetSettings().GetStyleSettings().GetPopupPanelBackgroundColor());//Color(244,245,249) 60 // maPushButtonMoreOptions.SetHoverBkColor(GetSettings().GetStyleSettings().GetCustButtonHoverColor());//Color( 93, 120, 163 ) 61 // maPushButtonMoreOptions.SetHoverTxtColor(GetSettings().GetStyleSettings().GetCustButtonTextHoverColor());//Color( 255, 255, 255 ) 62 //} 63 //else 64 //{ 65 // maPushButtonMoreOptions.SetDefBkColor(GetSettings().GetStyleSettings().GetMenuColor());//Color(244,245,249) 66 // maPushButtonMoreOptions.SetHoverBkColor(GetSettings().GetStyleSettings().GetMenuColor());//Color( 93, 120, 163 ) 67 // maPushButtonMoreOptions.SetHoverTxtColor(GetSettings().GetStyleSettings().GetCustButtonTextHoverColor());//Color( 255, 255, 255 ) 68 //} 69 70 //maPushButtonMoreOptions.SetIcoPosX(2); 71 Link aLink = LINK(this, CellLineStyleControl, PBClickHdl); 72 maPushButtonMoreOptions.SetClickHdl(aLink); 73 74 maCellLineStyleValueSet.SetStyle(maCellLineStyleValueSet.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT); 75 maCellLineStyleValueSet.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor()); 76 maCellLineStyleValueSet.SetColor(GetSettings().GetStyleSettings().GetMenuColor()); 77 78 for(sal_uInt16 i = 1 ; i <= 9 ; i++) 79 { 80 maCellLineStyleValueSet.InsertItem(i); 81 } 82 83 mpStr = new XubString[9]; 84 mpStr[0] = GetSettings().GetLocaleI18nHelper().GetNum( 5, 2 ).AppendAscii("pt"); 85 mpStr[1] = GetSettings().GetLocaleI18nHelper().GetNum( 250, 2 ).AppendAscii("pt"); 86 mpStr[2] = GetSettings().GetLocaleI18nHelper().GetNum( 400, 2 ).AppendAscii("pt"); 87 mpStr[3] = GetSettings().GetLocaleI18nHelper().GetNum( 500, 2 ).AppendAscii("pt"); 88 mpStr[4] = GetSettings().GetLocaleI18nHelper().GetNum( 110, 2 ).AppendAscii("pt"); 89 mpStr[5] = GetSettings().GetLocaleI18nHelper().GetNum( 260, 2 ).AppendAscii("pt"); 90 mpStr[6] = GetSettings().GetLocaleI18nHelper().GetNum( 450, 2 ).AppendAscii("pt"); 91 mpStr[7] = GetSettings().GetLocaleI18nHelper().GetNum( 505, 2 ).AppendAscii("pt"); 92 mpStr[8] = GetSettings().GetLocaleI18nHelper().GetNum( 750, 2 ).AppendAscii("pt"); 93 maCellLineStyleValueSet.SetUnit(mpStr); 94 95 for(sal_uInt16 i = 1 ; i <= 9 ; i++) 96 { 97 maCellLineStyleValueSet.SetItemText(i, mpStr[i-1]); 98 } 99 100 SetAllNoSel(); 101 aLink = LINK(this, CellLineStyleControl, VSSelectHdl); 102 maCellLineStyleValueSet.SetSelectHdl(aLink); 103 maCellLineStyleValueSet.StartSelection(); 104 maCellLineStyleValueSet.Show(); 105 } 106 107 void CellLineStyleControl::GetFocus() 108 { 109 if(!mbVSfocus) 110 { 111 maPushButtonMoreOptions.GrabFocus(); 112 } 113 else 114 { 115 maCellLineStyleValueSet.GrabFocus(); 116 } 117 } 118 119 void CellLineStyleControl::SetAllNoSel() 120 { 121 maCellLineStyleValueSet.SelectItem(0); 122 maCellLineStyleValueSet.SetNoSelection(); 123 maCellLineStyleValueSet.Format(); 124 Invalidate(); 125 maCellLineStyleValueSet.StartSelection(); 126 } 127 128 IMPL_LINK(CellLineStyleControl, VSSelectHdl, void *, pControl) 129 { 130 if(pControl == &maCellLineStyleValueSet) 131 { 132 const sal_uInt16 iPos(maCellLineStyleValueSet.GetSelectItemId()); 133 SvxLineItem aLineItem(SID_FRAME_LINESTYLE); 134 sal_uInt16 n1 = 0; 135 sal_uInt16 n2 = 0; 136 sal_uInt16 n3 = 0; 137 138 switch(iPos) 139 { 140 case 1: 141 n1 = DEF_LINE_WIDTH_0; 142 break; 143 case 2: 144 n1 = DEF_LINE_WIDTH_2; 145 break; 146 case 3: 147 n1 = DEF_LINE_WIDTH_3; 148 break; 149 case 4: 150 n1 = DEF_LINE_WIDTH_4; 151 break; 152 case 5: 153 n1 = DEF_DOUBLE_LINE0_OUT; 154 n2 = DEF_DOUBLE_LINE0_IN; 155 n3 = DEF_DOUBLE_LINE0_DIST; 156 break; 157 case 6: 158 n1 = DEF_DOUBLE_LINE7_OUT; 159 n2 = DEF_DOUBLE_LINE7_IN; 160 n3 = DEF_DOUBLE_LINE7_DIST; 161 break; 162 case 7: 163 n1 = DEF_DOUBLE_LINE4_OUT; 164 n2 = DEF_DOUBLE_LINE4_IN; 165 n3 = DEF_DOUBLE_LINE4_DIST; 166 break; 167 case 8: 168 n1 = DEF_DOUBLE_LINE9_OUT; 169 n2 = DEF_DOUBLE_LINE9_IN; 170 n3 = DEF_DOUBLE_LINE9_DIST; 171 break; 172 case 9: 173 n1 = DEF_DOUBLE_LINE2_OUT; 174 n2 = DEF_DOUBLE_LINE2_IN; 175 n3 = DEF_DOUBLE_LINE2_DIST; 176 break; 177 default: 178 break; 179 } 180 181 SvxBorderLine aTmp( NULL, n1, n2, n3 ); 182 aLineItem.SetLine( &aTmp ); 183 mrCellAppearancePropertyPanel.GetBindings()->GetDispatcher()->Execute(SID_FRAME_LINESTYLE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 184 SetAllNoSel(); 185 mrCellAppearancePropertyPanel.EndCellLineStylePopupMode(); 186 } 187 188 return(0L); 189 } 190 191 IMPL_LINK(CellLineStyleControl, PBClickHdl, PushButton *, pPBtn) 192 { 193 if(pPBtn == &maPushButtonMoreOptions) 194 { 195 if(mrCellAppearancePropertyPanel.GetBindings()) 196 { 197 mrCellAppearancePropertyPanel.GetBindings()->GetDispatcher()->Execute(SID_CELL_FORMAT_BORDER, SFX_CALLMODE_ASYNCHRON); 198 } 199 200 mrCellAppearancePropertyPanel.EndCellLineStylePopupMode(); 201 } 202 203 return 0; 204 } 205 206 void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis) 207 { 208 SetAllNoSel(); 209 mbVSfocus = true; 210 211 if(out == DEF_LINE_WIDTH_0 && in == 0 && dis == 0) //1 212 { 213 maCellLineStyleValueSet.SetSelItem(1); 214 } 215 else if(out == DEF_LINE_WIDTH_2 && in == 0 && dis == 0) //2 216 { 217 maCellLineStyleValueSet.SetSelItem(2); 218 } 219 else if(out == DEF_LINE_WIDTH_3 && in == 0 && dis == 0) //3 220 { 221 maCellLineStyleValueSet.SetSelItem(3); 222 } 223 else if(out == DEF_LINE_WIDTH_4 && in == 0 && dis == 0) //4 224 { 225 maCellLineStyleValueSet.SetSelItem(4); 226 } 227 else if(out == DEF_DOUBLE_LINE0_OUT && in == DEF_DOUBLE_LINE0_IN && dis == DEF_DOUBLE_LINE0_DIST) //5 228 { 229 maCellLineStyleValueSet.SetSelItem(5); 230 } 231 else if(out == DEF_DOUBLE_LINE7_OUT && in == DEF_DOUBLE_LINE7_IN && dis == DEF_DOUBLE_LINE7_DIST) //6 232 { 233 maCellLineStyleValueSet.SetSelItem(6); 234 } 235 else if(out == DEF_DOUBLE_LINE4_OUT && in == DEF_DOUBLE_LINE4_IN && dis == DEF_DOUBLE_LINE4_DIST) //7 236 { 237 maCellLineStyleValueSet.SetSelItem(7); 238 } 239 else if(out == DEF_DOUBLE_LINE9_OUT && in == DEF_DOUBLE_LINE9_IN && dis == DEF_DOUBLE_LINE9_DIST) //8 240 { 241 maCellLineStyleValueSet.SetSelItem(8); 242 } 243 else if(out == DEF_DOUBLE_LINE2_OUT && in == DEF_DOUBLE_LINE2_IN && dis == DEF_DOUBLE_LINE2_DIST) //9 244 { 245 maCellLineStyleValueSet.SetSelItem(9); 246 } 247 else 248 { 249 maCellLineStyleValueSet.SetSelItem(0); 250 mbVSfocus = false; 251 } 252 253 maCellLineStyleValueSet.Format(); 254 maCellLineStyleValueSet.StartSelection(); 255 } 256 257 } } // end of namespace svx::sidebar 258 259 // eof 260