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