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 <sfx2/sidebar/propertypanel.hrc> 23 #include <sfx2/sidebar/Theme.hxx> 24 #include <sfx2/sidebar/ControlFactory.hxx> 25 #include <LinePropertyPanel.hxx> 26 #include <LinePropertyPanel.hrc> 27 #include <svx/dialogs.hrc> 28 #include <svx/dialmgr.hxx> 29 #include <sfx2/objsh.hxx> 30 #include <sfx2/bindings.hxx> 31 #include <sfx2/dispatch.hxx> 32 #include <svx/xlnclit.hxx> 33 #include <svx/xtable.hxx> 34 #include <svx/xdash.hxx> 35 #include <svx/drawitem.hxx> 36 #include <svx/svxitems.hrc> 37 #include <svtools/valueset.hxx> 38 #include <unotools/pathoptions.hxx> 39 #include <unotools/viewoptions.hxx> 40 #include <comphelper/processfactory.hxx> 41 #include <i18npool/mslangid.hxx> 42 #include <svx/xlineit0.hxx> 43 #include <svx/xlndsit.hxx> 44 #include <vcl/svapp.hxx> 45 #include <svx/xlnwtit.hxx> 46 #include <vcl/lstbox.hxx> 47 #include <svx/tbxcolorupdate.hxx> 48 #include <vcl/toolbox.hxx> 49 #include <svx/xlntrit.hxx> 50 #include <svx/xlnstit.hxx> 51 #include <svx/xlnedit.hxx> 52 #include <svx/xlncapit.hxx> 53 #include <svx/xlinjoit.hxx> 54 #include "svx/sidebar/PopupContainer.hxx" 55 #include "svx/sidebar/PopupControl.hxx" 56 #include <svx/sidebar/ColorControl.hxx> 57 #include "LineStyleControl.hxx" 58 #include "LineWidthControl.hxx" 59 #include <boost/bind.hpp> 60 61 using namespace css; 62 using namespace cssu; 63 using ::sfx2::sidebar::Theme; 64 65 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 66 67 namespace { 68 short GetItemId_Impl_line( ValueSet& rValueSet, const Color& rCol ) 69 { 70 if(rCol == COL_AUTO) 71 return 0; 72 73 bool bFound = false; 74 sal_uInt16 nCount = rValueSet.GetItemCount(); 75 sal_uInt16 n = 1; 76 77 while ( !bFound && n <= nCount ) 78 { 79 Color aValCol = rValueSet.GetItemColor(n); 80 81 bFound = ( aValCol.GetRed() == rCol.GetRed() 82 && aValCol.GetGreen() == rCol.GetGreen() 83 && aValCol.GetBlue() == rCol.GetBlue() ); 84 85 if ( !bFound ) 86 n++; 87 } 88 return bFound ? n : -1; 89 } 90 91 Color GetTransparentColor (void) 92 { 93 return COL_TRANSPARENT; 94 } 95 96 void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLineEndList& rList) 97 { 98 const sal_uInt32 nCount(rList.Count()); 99 rListBoxStart.SetUpdateMode(false); 100 rListBoxEnd.SetUpdateMode(false); 101 102 for(sal_uInt32 i(0); i < nCount; i++) 103 { 104 XLineEndEntry* pEntry = rList.GetLineEnd(i); 105 const Bitmap* pBitmap = const_cast< XLineEndList& >(rList).CreateBitmapForUI(i); 106 107 if(pBitmap) 108 { 109 Bitmap aCopyStart(*pBitmap); 110 Bitmap aCopyEnd(*pBitmap); 111 delete pBitmap; 112 const Size aBmpSize(aCopyStart.GetSizePixel()); 113 const Rectangle aCropRectStart(Point(), Size(aBmpSize.Width() / 2, aBmpSize.Height())); 114 const Rectangle aCropRectEnd(Point(aBmpSize.Width() / 2, 0), Size(aBmpSize.Width() / 2, aBmpSize.Height())); 115 116 aCopyStart.Crop(aCropRectStart); 117 rListBoxStart.InsertEntry( 118 pEntry->GetName(), 119 aCopyStart); 120 121 aCopyEnd.Crop(aCropRectEnd); 122 rListBoxEnd.InsertEntry( 123 pEntry->GetName(), 124 aCopyEnd); 125 } 126 else 127 { 128 rListBoxStart.InsertEntry(pEntry->GetName()); 129 rListBoxEnd.InsertEntry(pEntry->GetName()); 130 } 131 } 132 133 rListBoxStart.SetUpdateMode(true); 134 rListBoxEnd.SetUpdateMode(true); 135 } 136 } // end of anonymous namespace 137 138 // namespace open 139 140 namespace svx { namespace sidebar { 141 142 LinePropertyPanel::LinePropertyPanel( 143 Window* pParent, 144 const cssu::Reference<css::frame::XFrame>& rxFrame, 145 SfxBindings* pBindings) 146 : Control( 147 pParent, 148 SVX_RES(RID_SIDEBAR_LINE_PANEL)), 149 mpFTWidth(new FixedText(this, SVX_RES(FT_WIDTH))), 150 mpTBWidthBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 151 mpTBWidth(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBWidthBackground.get(), SVX_RES(TB_WIDTH))), 152 mpFTColor(new FixedText(this, SVX_RES(FT_COLOR))), 153 mpTBColorBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 154 mpTBColor(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBColorBackground.get(), SVX_RES(TB_COLOR))), 155 mpFTStyle(new FixedText(this, SVX_RES(FT_STYLE))), 156 mpTBStyleBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 157 mpTBStyle(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBStyleBackground.get(), SVX_RES(TB_STYLE))), 158 mpFTTrancparency(new FixedText(this, SVX_RES(FT_TRANSPARENT))), 159 mpMFTransparent(new MetricField(this, SVX_RES(MF_TRANSPARENT))), 160 mpFTArrow(new FixedText(this, SVX_RES(FT_ARROW))), 161 mpLBStart(new ListBox(this, SVX_RES(LB_START))), 162 mpLBEnd(new ListBox(this, SVX_RES(LB_END))), 163 mpFTEdgeStyle(new FixedText(this, SVX_RES(FT_EDGESTYLE))), 164 mpLBEdgeStyle(new ListBox(this, SVX_RES(LB_EDGESTYLE))), 165 mpFTCapStyle(new FixedText(this, SVX_RES(FT_CAPSTYLE))), 166 mpLBCapStyle(new ListBox(this, SVX_RES(LB_CAPSTYLE))), 167 maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this), 168 maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this), 169 maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this), 170 maColorControl(SID_ATTR_LINE_COLOR, *pBindings, *this), 171 maStartControl(SID_ATTR_LINE_START, *pBindings, *this), 172 maEndControl(SID_ATTR_LINE_END, *pBindings, *this), 173 maLineEndListControl(SID_LINEEND_LIST, *pBindings, *this), 174 maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this), 175 maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this), 176 maCapStyle(SID_ATTR_LINE_CAP, *pBindings, *this), 177 maColor(COL_BLACK), 178 mpColorUpdater(new ::svx::ToolboxButtonColorUpdater(SID_ATTR_LINE_COLOR, TBI_COLOR, mpTBColor.get(), TBX_UPDATER_MODE_CHAR_COLOR_NEW)), 179 mpStyleItem(), 180 mpDashItem(), 181 mnTrans(0), 182 meMapUnit(SFX_MAPUNIT_MM), 183 mnWidthCoreValue(0), 184 mpLineEndList(0), 185 mpStartItem(0), 186 mpEndItem(0), 187 maColorPopup(this, ::boost::bind(&LinePropertyPanel::CreateColorPopupControl, this, _1)), 188 maLineStylePopup(this, ::boost::bind(&LinePropertyPanel::CreateLineStylePopupControl, this, _1)), 189 maLineWidthPopup(this, ::boost::bind(&LinePropertyPanel::CreateLineWidthPopupControl, this, _1)), 190 maIMGColor(SVX_RES(IMG_COLOR)), 191 maIMGNone(SVX_RES(IMG_NONE_ICON)), 192 mpIMGStyleIcon(), 193 mpIMGWidthIcon(), 194 mpIMGStyleIconH(), 195 mpIMGWidthIconH(), 196 mxFrame(rxFrame), 197 mpBindings(pBindings), 198 mbColorAvailable(true), 199 mbStyleAvailable(false), 200 mbDashAvailable(false), 201 mbTransAvailable(true), 202 mbWidthValuable(true), 203 mbStartAvailable(true), 204 mbEndAvailable(true) 205 { 206 Initialize(); 207 FreeResource(); 208 } 209 210 211 212 LinePropertyPanel::~LinePropertyPanel() 213 { 214 // Destroy the toolboxes, then their background windows. 215 mpTBWidth.reset(); 216 mpTBColor.reset(); 217 mpTBStyle.reset(); 218 mpTBWidthBackground.reset(); 219 mpTBColorBackground.reset(); 220 mpTBStyleBackground.reset(); 221 } 222 223 224 225 void LinePropertyPanel::Initialize() 226 { 227 mpFTWidth->SetBackground(Wallpaper()); 228 mpFTColor->SetBackground(Wallpaper()); 229 mpFTStyle->SetBackground(Wallpaper()); 230 mpFTTrancparency->SetBackground(Wallpaper()); 231 mpFTArrow->SetBackground(Wallpaper()); 232 mpFTEdgeStyle->SetBackground(Wallpaper()); 233 mpFTCapStyle->SetBackground(Wallpaper()); 234 235 mpIMGStyleIcon.reset(new Image[11]); 236 mpIMGStyleIcon[0] = Image(SVX_RES(IMG_LINE1_ICON)); 237 mpIMGStyleIcon[1] = Image(SVX_RES(IMG_LINE2_ICON)); 238 mpIMGStyleIcon[2] = Image(SVX_RES(IMG_LINE3_ICON)); 239 mpIMGStyleIcon[3] = Image(SVX_RES(IMG_LINE4_ICON)); 240 mpIMGStyleIcon[4] = Image(SVX_RES(IMG_LINE5_ICON)); 241 mpIMGStyleIcon[5] = Image(SVX_RES(IMG_LINE6_ICON)); 242 mpIMGStyleIcon[6] = Image(SVX_RES(IMG_LINE7_ICON)); 243 mpIMGStyleIcon[7] = Image(SVX_RES(IMG_LINE8_ICON)); 244 mpIMGStyleIcon[8] = Image(SVX_RES(IMG_LINE9_ICON)); 245 mpIMGStyleIcon[9] = Image(SVX_RES(IMG_LINE10_ICON)); 246 mpIMGStyleIcon[10] = Image(SVX_RES(IMG_LINE11_ICON)); 247 248 mpIMGWidthIcon.reset(new Image[8]); 249 mpIMGWidthIcon[0] = Image(SVX_RES(IMG_WIDTH1_ICON)); 250 mpIMGWidthIcon[1] = Image(SVX_RES(IMG_WIDTH2_ICON)); 251 mpIMGWidthIcon[2] = Image(SVX_RES(IMG_WIDTH3_ICON)); 252 mpIMGWidthIcon[3] = Image(SVX_RES(IMG_WIDTH4_ICON)); 253 mpIMGWidthIcon[4] = Image(SVX_RES(IMG_WIDTH5_ICON)); 254 mpIMGWidthIcon[5] = Image(SVX_RES(IMG_WIDTH6_ICON)); 255 mpIMGWidthIcon[6] = Image(SVX_RES(IMG_WIDTH7_ICON)); 256 mpIMGWidthIcon[7] = Image(SVX_RES(IMG_WIDTH8_ICON)); 257 258 //high contrast 259 mpIMGStyleIconH.reset(new Image[11]); 260 mpIMGStyleIconH[0] = Image(SVX_RES(IMG_LINE1_ICON_H)); 261 mpIMGStyleIconH[1] = Image(SVX_RES(IMG_LINE2_ICON_H)); 262 mpIMGStyleIconH[2] = Image(SVX_RES(IMG_LINE3_ICON_H)); 263 mpIMGStyleIconH[3] = Image(SVX_RES(IMG_LINE4_ICON_H)); 264 mpIMGStyleIconH[4] = Image(SVX_RES(IMG_LINE5_ICON_H)); 265 mpIMGStyleIconH[5] = Image(SVX_RES(IMG_LINE6_ICON_H)); 266 mpIMGStyleIconH[6] = Image(SVX_RES(IMG_LINE7_ICON_H)); 267 mpIMGStyleIconH[7] = Image(SVX_RES(IMG_LINE8_ICON_H)); 268 mpIMGStyleIconH[8] = Image(SVX_RES(IMG_LINE9_ICON_H)); 269 mpIMGStyleIconH[9] = Image(SVX_RES(IMG_LINE10_ICON_H)); 270 mpIMGStyleIconH[10] = Image(SVX_RES(IMG_LINE11_ICON_H)); 271 272 mpIMGWidthIconH.reset(new Image[8]); 273 mpIMGWidthIconH[0] = Image(SVX_RES(IMG_WIDTH1_ICON_H)); 274 mpIMGWidthIconH[1] = Image(SVX_RES(IMG_WIDTH2_ICON_H)); 275 mpIMGWidthIconH[2] = Image(SVX_RES(IMG_WIDTH3_ICON_H)); 276 mpIMGWidthIconH[3] = Image(SVX_RES(IMG_WIDTH4_ICON_H)); 277 mpIMGWidthIconH[4] = Image(SVX_RES(IMG_WIDTH5_ICON_H)); 278 mpIMGWidthIconH[5] = Image(SVX_RES(IMG_WIDTH6_ICON_H)); 279 mpIMGWidthIconH[6] = Image(SVX_RES(IMG_WIDTH7_ICON_H)); 280 mpIMGWidthIconH[7] = Image(SVX_RES(IMG_WIDTH8_ICON_H)); 281 //end 282 283 meMapUnit = maWidthControl.GetCoreMetric(); 284 285 mpTBColor->SetItemImage(TBI_COLOR, maIMGColor); 286 Size aTbxSize( mpTBColor->CalcWindowSizePixel() ); 287 mpTBColor->SetOutputSizePixel( aTbxSize ); 288 mpTBColor->SetItemBits( TBI_COLOR, mpTBColor->GetItemBits( TBI_COLOR ) | TIB_DROPDOWNONLY ); 289 mpTBColor->SetQuickHelpText(TBI_COLOR,String(SVX_RES(STR_QH_TB_COLOR))); //Add 290 mpTBColor->SetBackground(Wallpaper()); 291 mpTBColor->SetPaintTransparent(true); 292 Link aLink = LINK(this, LinePropertyPanel, ToolboxColorSelectHdl); 293 mpTBColor->SetDropdownClickHdl ( aLink ); 294 mpTBColor->SetSelectHdl ( aLink ); 295 296 mpTBStyle->SetItemImage(TBI_STYLE, mpIMGStyleIcon[0]); 297 aTbxSize = mpTBStyle->CalcWindowSizePixel() ; 298 mpTBStyle->SetOutputSizePixel( aTbxSize ); 299 mpTBStyle->SetItemBits( TBI_STYLE, mpTBStyle->GetItemBits( TBI_STYLE ) | TIB_DROPDOWNONLY ); 300 mpTBStyle->SetQuickHelpText(TBI_STYLE,String(SVX_RES(STR_QH_TB_STYLE))); //Add 301 mpTBStyle->SetBackground(Wallpaper()); 302 mpTBStyle->SetPaintTransparent(true); 303 aLink = LINK(this, LinePropertyPanel, ToolboxStyleSelectHdl); 304 mpTBStyle->SetDropdownClickHdl ( aLink ); 305 mpTBStyle->SetSelectHdl ( aLink ); 306 307 mpTBWidth->SetItemImage(TBI_WIDTH, mpIMGWidthIcon[0]); 308 aTbxSize = mpTBWidth->CalcWindowSizePixel() ; 309 mpTBWidth->SetOutputSizePixel( aTbxSize ); 310 mpTBWidth->SetItemBits( TBI_WIDTH, mpTBWidth->GetItemBits( TBI_WIDTH ) | TIB_DROPDOWNONLY ); 311 mpTBWidth->SetQuickHelpText(TBI_WIDTH,String(SVX_RES(STR_QH_TB_WIDTH))); //Add 312 mpTBWidth->SetBackground(Wallpaper()); 313 mpTBWidth->SetPaintTransparent(true); 314 aLink = LINK(this, LinePropertyPanel, ToolboxWidthSelectHdl); 315 mpTBWidth->SetDropdownClickHdl ( aLink ); 316 mpTBWidth->SetSelectHdl ( aLink ); 317 318 FillLineEndList(); 319 SelectEndStyle(true); 320 SelectEndStyle(false); 321 aLink = LINK( this, LinePropertyPanel, ChangeStartHdl ); 322 mpLBStart->SetSelectHdl( aLink ); 323 mpLBStart->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Beginning Style"))); //wj acc 324 mpLBStart->SetDropDownLineCount(std::min(sal_uInt16(20), mpLBStart->GetEntryCount())); 325 aLink = LINK( this, LinePropertyPanel, ChangeEndHdl ); 326 mpLBEnd->SetSelectHdl( aLink ); 327 mpLBEnd->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Ending Style"))); //wj acc 328 mpLBEnd->SetDropDownLineCount(std::min(sal_uInt16(20), mpLBEnd->GetEntryCount())); 329 330 aLink = LINK(this, LinePropertyPanel, ChangeTransparentHdl); 331 mpMFTransparent->SetModifyHdl(aLink); 332 mpMFTransparent->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency"))); //wj acc 333 334 mpTBWidth->SetAccessibleRelationLabeledBy(mpFTWidth.get()); 335 mpTBColor->SetAccessibleRelationLabeledBy(mpFTColor.get()); 336 mpTBStyle->SetAccessibleRelationLabeledBy(mpFTStyle.get()); 337 mpMFTransparent->SetAccessibleRelationLabeledBy(mpFTTrancparency.get()); 338 mpLBStart->SetAccessibleRelationLabeledBy(mpFTArrow.get()); 339 mpLBEnd->SetAccessibleRelationLabeledBy(mpLBEnd.get()); 340 341 aLink = LINK( this, LinePropertyPanel, ChangeEdgeStyleHdl ); 342 mpLBEdgeStyle->SetSelectHdl( aLink ); 343 mpLBEdgeStyle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Corner Style"))); 344 345 aLink = LINK( this, LinePropertyPanel, ChangeCapStyleHdl ); 346 mpLBCapStyle->SetSelectHdl( aLink ); 347 mpLBCapStyle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cap Style"))); 348 } 349 350 351 352 void LinePropertyPanel::SetupIcons(void) 353 { 354 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons)) 355 { 356 // todo 357 } 358 else 359 { 360 // todo 361 } 362 } 363 364 365 366 LinePropertyPanel* LinePropertyPanel::Create ( 367 Window* pParent, 368 const cssu::Reference<css::frame::XFrame>& rxFrame, 369 SfxBindings* pBindings) 370 { 371 if (pParent == NULL) 372 throw lang::IllegalArgumentException(A2S("no parent Window given to LinePropertyPanel::Create"), NULL, 0); 373 if ( ! rxFrame.is()) 374 throw lang::IllegalArgumentException(A2S("no XFrame given to LinePropertyPanel::Create"), NULL, 1); 375 if (pBindings == NULL) 376 throw lang::IllegalArgumentException(A2S("no SfxBindings given to LinePropertyPanel::Create"), NULL, 2); 377 378 return new LinePropertyPanel( 379 pParent, 380 rxFrame, 381 pBindings); 382 } 383 384 385 386 387 void LinePropertyPanel::DataChanged( 388 const DataChangedEvent& rEvent) 389 { 390 (void)rEvent; 391 392 SetupIcons(); 393 } 394 395 396 397 398 void LinePropertyPanel::NotifyItemUpdate( 399 sal_uInt16 nSID, 400 SfxItemState eState, 401 const SfxPoolItem* pState) 402 { 403 switch(nSID) 404 { 405 case SID_ATTR_LINE_COLOR: 406 { 407 if( eState == SFX_ITEM_DISABLED) 408 { 409 mpFTColor->Disable(); 410 mpTBColor->Disable(); 411 mbColorAvailable = false; 412 mpColorUpdater->Update(COL_WHITE); 413 } 414 else 415 { 416 mpFTColor->Enable(); 417 mpTBColor->Enable(); 418 const XLineColorItem* pItem = dynamic_cast< const XLineColorItem* >(pState); 419 420 if(eState >= SFX_ITEM_DEFAULT && pItem) 421 { 422 maColor = pItem->GetColorValue(); 423 mbColorAvailable = true; 424 mpColorUpdater->Update(maColor); 425 } 426 else 427 { 428 mbColorAvailable = false; 429 mpColorUpdater->Update(COL_WHITE); 430 } 431 } 432 break; 433 } 434 case SID_ATTR_LINE_STYLE: 435 case SID_ATTR_LINE_DASH: 436 { 437 if( eState == SFX_ITEM_DISABLED) 438 { 439 mpFTStyle->Disable(); 440 mpTBStyle->Disable(); 441 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 442 } 443 else 444 { 445 mpFTStyle->Enable(); 446 mpTBStyle->Enable(); 447 if( eState >= SFX_ITEM_DEFAULT ) 448 { 449 if(nSID == SID_ATTR_LINE_STYLE) 450 { 451 const XLineStyleItem* pItem = dynamic_cast< const XLineStyleItem* >(pState); 452 453 if(pItem) 454 { 455 mbStyleAvailable =true; 456 mpStyleItem.reset(pState ? (XLineStyleItem*)pItem->Clone() : 0); 457 } 458 } 459 else if(nSID == SID_ATTR_LINE_DASH) 460 { 461 const XLineDashItem* pItem = dynamic_cast< const XLineDashItem* >(pState); 462 463 if(pItem) 464 { 465 mbDashAvailable = true; 466 mpDashItem.reset(pState ? (XLineDashItem*)pItem->Clone() : 0); 467 } 468 } 469 } 470 else 471 { 472 if(nSID == SID_ATTR_LINE_STYLE) 473 mbStyleAvailable = false; 474 else 475 mbDashAvailable = false; 476 } 477 SetStyleIcon(); 478 } 479 break; 480 } 481 case SID_ATTR_LINE_TRANSPARENCE: 482 { 483 if( eState == SFX_ITEM_DISABLED ) 484 { 485 mpFTTrancparency->Disable(); 486 mpMFTransparent->Disable(); 487 mpMFTransparent->SetValue(0);//add 488 mpMFTransparent->SetText(String()); 489 mbTransAvailable = false; 490 } 491 else 492 { 493 mpFTTrancparency->Enable(); 494 mpMFTransparent->Enable(); 495 mbTransAvailable = true; 496 const XLineTransparenceItem* pItem = dynamic_cast< const XLineTransparenceItem* >(pState); 497 498 if(eState != SFX_ITEM_DONTCARE && pItem) 499 { 500 mnTrans = pItem->GetValue(); 501 mpMFTransparent->SetValue(mnTrans); 502 } 503 else 504 { 505 mpMFTransparent->SetValue(0);//add 506 mpMFTransparent->SetText(String()); 507 } 508 } 509 break; 510 } 511 case SID_ATTR_LINE_WIDTH: 512 { 513 if(eState == SFX_ITEM_DISABLED) 514 { 515 mpTBWidth->Disable(); 516 mpFTWidth->Disable(); 517 } 518 else 519 { 520 //enable 521 mpTBWidth->Enable(); 522 mpFTWidth->Enable(); 523 const XLineWidthItem* pItem = dynamic_cast< const XLineWidthItem* >(pState); 524 525 if(eState >= SFX_ITEM_AVAILABLE && pItem) 526 { 527 mnWidthCoreValue = pItem->GetValue(); 528 mbWidthValuable = true; 529 } 530 else 531 { 532 mbWidthValuable = false; 533 } 534 } 535 SetWidthIcon(); 536 break; 537 } 538 case SID_ATTR_LINE_START: 539 { 540 mpFTArrow->Enable(); 541 mpLBStart->Enable(); 542 543 if(eState != SFX_ITEM_DONTCARE) 544 { 545 const XLineStartItem* pItem = dynamic_cast< const XLineStartItem* >(pState); 546 547 if(pItem) 548 { 549 mbStartAvailable = true; //add 550 mpStartItem.reset(pItem ? (XLineStartItem*)pItem->Clone() : 0); 551 SelectEndStyle(true); 552 break; 553 } 554 } 555 556 mpLBStart->SetNoSelection(); 557 mbStartAvailable = false; //add 558 break; 559 } 560 case SID_ATTR_LINE_END: 561 { 562 mpFTArrow->Enable(); 563 mpLBEnd->Enable(); 564 565 if(eState != SFX_ITEM_DONTCARE) 566 { 567 const XLineEndItem* pItem = dynamic_cast< const XLineEndItem* >(pState); 568 569 if(pItem) 570 { 571 mbEndAvailable = true; //add 572 mpEndItem.reset(pItem ? (XLineEndItem*)pItem->Clone() : 0); 573 SelectEndStyle(false); 574 break; 575 } 576 } 577 578 mpLBEnd->SetNoSelection(); 579 mbEndAvailable = false; //add 580 break; 581 } 582 case SID_LINEEND_LIST: 583 { 584 FillLineEndList(); 585 SelectEndStyle(true); 586 SelectEndStyle(false); 587 break; 588 } 589 case SID_ATTR_LINE_JOINT: 590 { 591 if(eState == SFX_ITEM_DISABLED) 592 { 593 mpLBEdgeStyle->Disable(); 594 } 595 else 596 { 597 mpLBEdgeStyle->Enable(); 598 const XLineJointItem* pItem = dynamic_cast< const XLineJointItem* >(pState); 599 sal_uInt16 nEntryPos(0); 600 601 if(eState >= SFX_ITEM_AVAILABLE && pItem) 602 { 603 switch(pItem->GetValue()) 604 { 605 case com::sun::star::drawing::LineJoint_MIDDLE: 606 case com::sun::star::drawing::LineJoint_ROUND: 607 { 608 nEntryPos = 1; 609 break; 610 } 611 case com::sun::star::drawing::LineJoint_NONE: 612 { 613 nEntryPos = 2; 614 break; 615 } 616 case com::sun::star::drawing::LineJoint_MITER: 617 { 618 nEntryPos = 3; 619 break; 620 } 621 case com::sun::star::drawing::LineJoint_BEVEL: 622 { 623 nEntryPos = 4; 624 break; 625 } 626 627 default: 628 break; 629 } 630 } 631 632 if(nEntryPos) 633 { 634 mpLBEdgeStyle->SelectEntryPos(nEntryPos - 1); 635 } 636 else 637 { 638 mpLBEdgeStyle->SetNoSelection(); 639 } 640 } 641 break; 642 } 643 case SID_ATTR_LINE_CAP: 644 { 645 if(eState == SFX_ITEM_DISABLED) 646 { 647 mpLBCapStyle->Disable(); 648 } 649 else 650 { 651 mpLBCapStyle->Enable(); 652 const XLineCapItem* pItem = dynamic_cast< const XLineCapItem* >(pState); 653 sal_uInt16 nEntryPos(0); 654 655 if(eState >= SFX_ITEM_AVAILABLE && pItem) 656 { 657 switch(pItem->GetValue()) 658 { 659 case com::sun::star::drawing::LineCap_BUTT: 660 { 661 nEntryPos = 1; 662 break; 663 } 664 case com::sun::star::drawing::LineCap_ROUND: 665 { 666 nEntryPos = 2; 667 break; 668 } 669 case com::sun::star::drawing::LineCap_SQUARE: 670 { 671 nEntryPos = 3; 672 break; 673 } 674 675 default: 676 break; 677 } 678 } 679 680 if(nEntryPos) 681 { 682 mpLBCapStyle->SelectEntryPos(nEntryPos - 1); 683 } 684 else 685 { 686 mpLBCapStyle->SetNoSelection(); 687 } 688 } 689 break; 690 } 691 } 692 } 693 694 695 696 SfxBindings* LinePropertyPanel::GetBindings() 697 { 698 return mpBindings; 699 } 700 701 702 703 IMPL_LINK( LinePropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 704 { 705 return 0; 706 } 707 708 709 710 711 IMPL_LINK(LinePropertyPanel, ToolboxColorSelectHdl,ToolBox*, pToolBox) 712 { 713 sal_uInt16 nId = pToolBox->GetCurItemId(); 714 if(nId == TBI_COLOR) 715 { 716 maColorPopup.Show(*pToolBox); 717 maColorPopup.SetCurrentColor(maColor, mbColorAvailable); 718 } 719 return 0; 720 } 721 722 723 724 725 IMPL_LINK(LinePropertyPanel, ToolboxStyleSelectHdl,ToolBox*, pToolBox) 726 { 727 if (pToolBox->GetCurItemId() == TBI_STYLE) 728 { 729 maLineStylePopup.SetStyleSelect(mpStyleItem.get(), mpDashItem.get(), mbStyleAvailable, mbDashAvailable); 730 maLineStylePopup.Show(*pToolBox); 731 } 732 return 0; 733 } 734 735 736 737 738 IMPL_LINK(LinePropertyPanel, ChangeStartHdl, void*, EMPTYARG) 739 { 740 sal_uInt16 nPos = mpLBStart->GetSelectEntryPos(); 741 if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != mpLBStart->GetSavedValue() ) 742 { 743 XLineStartItem* pItem = NULL; 744 if( nPos == 0 ) 745 pItem = new XLineStartItem(); 746 else if( mpLineEndList && mpLineEndList->Count() > (long) ( nPos - 1 ) ) 747 pItem = new XLineStartItem( mpLBStart->GetSelectEntry(),mpLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ); 748 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SFX_CALLMODE_RECORD, pItem, 0L); 749 delete pItem; 750 } 751 return 0; 752 } 753 754 755 756 757 IMPL_LINK(LinePropertyPanel, ChangeEndHdl, void*, EMPTYARG) 758 { 759 sal_uInt16 nPos = mpLBEnd->GetSelectEntryPos(); 760 if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != mpLBEnd->GetSavedValue() ) 761 { 762 XLineEndItem* pItem = NULL; 763 if( nPos == 0 ) 764 pItem = new XLineEndItem(); 765 else if( mpLineEndList && mpLineEndList->Count() > (long) ( nPos - 1 ) ) 766 pItem = new XLineEndItem( mpLBEnd->GetSelectEntry(), mpLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ); 767 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SFX_CALLMODE_RECORD, pItem, 0L); 768 delete pItem; 769 } 770 return 0; 771 } 772 773 774 775 776 IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, EMPTYARG) 777 { 778 const sal_uInt16 nPos(mpLBEdgeStyle->GetSelectEntryPos()); 779 780 if(LISTBOX_ENTRY_NOTFOUND != nPos && nPos != mpLBEdgeStyle->GetSavedValue()) 781 { 782 XLineJointItem* pItem = 0; 783 784 switch(nPos) 785 { 786 case 0: // rounded 787 { 788 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_ROUND); 789 break; 790 } 791 case 1: // none 792 { 793 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_NONE); 794 break; 795 } 796 case 2: // mitered 797 { 798 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_MITER); 799 break; 800 } 801 case 3: // beveled 802 { 803 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL); 804 break; 805 } 806 } 807 808 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, SFX_CALLMODE_RECORD, pItem, 0L); 809 delete pItem; 810 } 811 return 0; 812 } 813 814 815 816 817 IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, EMPTYARG) 818 { 819 const sal_uInt16 nPos(mpLBCapStyle->GetSelectEntryPos()); 820 821 if(LISTBOX_ENTRY_NOTFOUND != nPos && nPos != mpLBCapStyle->GetSavedValue()) 822 { 823 XLineCapItem* pItem = 0; 824 825 switch(nPos) 826 { 827 case 0: // flat 828 { 829 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_BUTT); 830 break; 831 } 832 case 1: // round 833 { 834 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_ROUND); 835 break; 836 } 837 case 2: // square 838 { 839 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_SQUARE); 840 break; 841 } 842 } 843 844 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, SFX_CALLMODE_RECORD, pItem, 0L); 845 delete pItem; 846 } 847 return 0; 848 } 849 850 851 852 853 IMPL_LINK(LinePropertyPanel, ToolboxWidthSelectHdl,ToolBox*, pToolBox) 854 { 855 if (pToolBox->GetCurItemId() == TBI_WIDTH) 856 { 857 maLineWidthPopup.SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); 858 maLineWidthPopup.Show(*pToolBox); 859 } 860 return 0; 861 } 862 863 864 865 866 IMPL_LINK( LinePropertyPanel, ChangeTransparentHdl, void *, EMPTYARG ) 867 { 868 sal_uInt16 nVal = (sal_uInt16)mpMFTransparent->GetValue(); 869 XLineTransparenceItem aItem( nVal ); 870 871 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L); 872 return( 0L ); 873 } 874 875 876 877 878 PopupControl* LinePropertyPanel::CreateColorPopupControl (PopupContainer* pParent) 879 { 880 const ResId aResId(SVX_RES(STR_AUTOMATICE)); 881 882 return new ColorControl( 883 pParent, 884 mpBindings, 885 SVX_RES(RID_POPUPPANEL_LINEPAGE_COLOR), 886 SVX_RES(VS_COLOR), 887 ::boost::bind(GetTransparentColor), 888 ::boost::bind(&LinePropertyPanel::SetColor, this, _1, _2), 889 pParent, 890 &aResId); 891 } 892 893 894 895 896 PopupControl* LinePropertyPanel::CreateLineStylePopupControl (PopupContainer* pParent) 897 { 898 return new LineStyleControl (pParent, *this); 899 } 900 901 902 903 904 PopupControl* LinePropertyPanel::CreateLineWidthPopupControl (PopupContainer* pParent) 905 { 906 return new LineWidthControl(pParent, *this); 907 } 908 909 910 911 912 void LinePropertyPanel::EndLineStylePopupMode (void) 913 { 914 maLineStylePopup.Hide(); 915 } 916 917 918 919 920 void LinePropertyPanel::EndLineWidthPopupMode (void) 921 { 922 maLineWidthPopup.Hide(); 923 } 924 925 926 927 928 void LinePropertyPanel::SetStyleIcon() 929 { 930 if(!mbStyleAvailable) 931 { //custome style that not listed in panel 932 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 933 return; 934 } 935 936 const XLineStyle eXLS(mpStyleItem ? (XLineStyle)mpStyleItem->GetValue() : XLINE_NONE); 937 938 switch(eXLS) 939 { 940 case XLINE_NONE: 941 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 942 break; 943 case XLINE_SOLID: 944 mpTBStyle->SetItemImage(TBI_STYLE, GetDisplayBackground().GetColor().IsDark() ? mpIMGStyleIconH[0] : mpIMGStyleIcon[0]); 945 break; 946 case XLINE_DASH: 947 if(mpDashItem && mbDashAvailable) 948 { 949 XDash aDash = mpDashItem->GetDashValue(); 950 sal_uInt16 n = 0; 951 for( ; n < 10; n++ ) 952 { 953 if( Dash_Set[n] == aDash ) 954 { 955 mpTBStyle->SetItemImage(TBI_STYLE, GetDisplayBackground().GetColor().IsDark() ? mpIMGStyleIconH[n+1] :mpIMGStyleIcon[n+1]); 956 break; 957 } 958 } 959 if(n == 10) 960 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 961 } 962 else 963 { 964 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 965 } 966 break; 967 } 968 } 969 970 971 972 void LinePropertyPanel::SetWidthIcon(int n) 973 { 974 if(n==0) 975 mpTBWidth->SetItemImage( TBI_WIDTH, maIMGNone); 976 else 977 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[n-1] : mpIMGWidthIcon[n-1]); 978 } 979 980 981 982 void LinePropertyPanel::SetWidthIcon() 983 { 984 if(!mbWidthValuable) 985 { 986 mpTBWidth->SetItemImage( TBI_WIDTH, maIMGNone); 987 return; 988 } 989 990 long nVal = LogicToLogic(mnWidthCoreValue * 10,(MapUnit)meMapUnit , MAP_POINT); 991 992 if(nVal <= 6) 993 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[0] : mpIMGWidthIcon[0]); 994 else if(nVal > 6 && nVal <= 9) 995 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[1] : mpIMGWidthIcon[1]); 996 else if(nVal > 9 && nVal <= 12) 997 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[2] : mpIMGWidthIcon[2]); 998 else if(nVal > 12 && nVal <= 19) 999 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[3] : mpIMGWidthIcon[3]); 1000 else if(nVal > 19 && nVal <= 26) 1001 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[4] : mpIMGWidthIcon[4]); 1002 else if(nVal > 26 && nVal <= 37) 1003 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[5] : mpIMGWidthIcon[5]); 1004 else if(nVal > 37 && nVal <=52) 1005 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[6] : mpIMGWidthIcon[6]); 1006 else if(nVal > 52) 1007 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[7] : mpIMGWidthIcon[7]); 1008 1009 } 1010 1011 1012 1013 void LinePropertyPanel::SetLineStyleItem(XLineStyleItem* pStyle) 1014 { 1015 mpStyleItem.reset(pStyle ? (XLineStyleItem*)pStyle->Clone() : 0); 1016 } 1017 1018 1019 1020 void LinePropertyPanel::SetLineDashItem(XLineDashItem* pDash) 1021 { 1022 mpDashItem.reset(pDash ? (XLineDashItem*)pDash->Clone() : 0); 1023 } 1024 1025 1026 1027 void LinePropertyPanel::SetColor ( 1028 const String& rsColorName, 1029 const Color aColor) 1030 { 1031 XLineColorItem aColorItem(rsColorName, aColor); 1032 mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L); 1033 maColor = aColor; 1034 } 1035 1036 1037 1038 void LinePropertyPanel::SetWidth(long nWidth) 1039 { 1040 mnWidthCoreValue = nWidth; 1041 mbWidthValuable = true; 1042 } 1043 1044 1045 1046 void LinePropertyPanel::FillLineEndList() 1047 { 1048 SfxObjectShell* pSh = SfxObjectShell::Current(); 1049 if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) ) 1050 { 1051 mpLBStart->Enable(); 1052 SvxLineEndListItem aItem( *(const SvxLineEndListItem*)(pSh->GetItem( SID_LINEEND_LIST ) ) ); 1053 mpLineEndList = aItem.GetLineEndList(); 1054 String sNone( SVX_RES( RID_SVXSTR_NONE ) ); 1055 mpLBStart->Clear(); 1056 mpLBEnd->Clear(); 1057 mpLBStart->InsertEntry( sNone ); 1058 mpLBEnd->InsertEntry( sNone ); 1059 1060 if(mpLineEndList) 1061 { 1062 FillLineEndListBox(*mpLBStart, *mpLBEnd, *mpLineEndList); 1063 } 1064 1065 mpLBStart->SelectEntryPos(0); 1066 mpLBEnd->SelectEntryPos(0); 1067 } 1068 else 1069 { 1070 mpLBStart->Disable(); 1071 mpLBEnd->Disable(); 1072 } 1073 } 1074 1075 1076 1077 void LinePropertyPanel::SelectEndStyle(bool bStart) 1078 { 1079 sal_Bool bSelected(false); 1080 1081 if(bStart) 1082 { 1083 //<<add 1084 if( !mbStartAvailable ) 1085 { 1086 mpLBStart->SetNoSelection(); 1087 return; 1088 } 1089 //add end>> 1090 if(mpStartItem && mpLineEndList) 1091 { 1092 const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue(); 1093 for(sal_Int32 a(0);!bSelected && a < mpLineEndList->Count(); a++) 1094 { 1095 XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(a); 1096 const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); 1097 if(rItemPolygon == rEntryPolygon) 1098 { 1099 mpLBStart->SelectEntryPos((sal_uInt16)a + 1); 1100 bSelected = true; 1101 } 1102 } 1103 } 1104 if(!bSelected) 1105 mpLBStart->SelectEntryPos( 0 ); 1106 } 1107 else 1108 { 1109 //<<add 1110 if( !mbEndAvailable ) 1111 { 1112 mpLBEnd->SetNoSelection(); 1113 return; 1114 } 1115 //add end>> 1116 if(mpEndItem && mpLineEndList) 1117 { 1118 const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue(); 1119 for(sal_Int32 a(0);!bSelected && a < mpLineEndList->Count(); a++) 1120 { 1121 XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(a); 1122 const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); 1123 if(rItemPolygon == rEntryPolygon) 1124 { 1125 mpLBEnd->SelectEntryPos((sal_uInt16)a + 1); 1126 bSelected = true; 1127 } 1128 } 1129 } 1130 if(!bSelected) 1131 mpLBEnd->SelectEntryPos( 0 ); 1132 } 1133 } 1134 1135 1136 } } // end of namespace svx::sidebar 1137 1138 // eof 1139