1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 20 #include <com/sun/star/chart2/LegendPosition.hpp> 21 #include <com/sun/star/chart/ChartLegendExpansion.hpp> 22 #include <com/sun/star/chart2/XChartTypeContainer.hpp> 23 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> 24 25 #include "ChartElementsPanel.hxx" 26 #include <ChartController.hxx> 27 #include <comphelper/processfactory.hxx> 28 29 #include <LegendHelper.hxx> 30 #include <ChartModelHelper.hxx> 31 #include <AxisHelper.hxx> 32 #include <DiagramHelper.hxx> 33 #include <ChartTypeHelper.hxx> 34 35 #include <ChartModel.hxx> 36 37 38 using namespace css; 39 using namespace css::uno; 40 41 namespace chart { namespace sidebar { 42 43 namespace { 44 45 enum class GridType 46 { 47 VERT_MAJOR, 48 VERT_MINOR, 49 HOR_MAJOR, 50 HOR_MINOR 51 }; 52 53 enum class AxisType 54 { 55 X_MAIN, 56 Y_MAIN, 57 Z_MAIN, 58 X_SECOND, 59 Y_SECOND 60 }; 61 62 ChartModel* getChartModel(const css::uno::Reference<css::frame::XModel>& xModel) 63 { 64 ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get()); 65 66 return pModel; 67 } 68 69 bool isLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel) 70 { 71 ChartModel* pModel = getChartModel(xModel); 72 if (!pModel) 73 return false; 74 75 Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); 76 if( xLegendProp.is()) 77 { 78 try 79 { 80 bool bShow = false; 81 if( xLegendProp->getPropertyValue( "Show") >>= bShow ) 82 { 83 return bShow; 84 } 85 } 86 catch(const uno::Exception &) 87 { 88 } 89 } 90 91 return false; 92 } 93 94 void setLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel, bool bVisible) 95 { 96 ChartModel* pModel = getChartModel(xModel); 97 if (!pModel) 98 return; 99 100 if (bVisible) 101 LegendHelper::showLegend(*pModel, comphelper::getProcessComponentContext()); 102 else 103 LegendHelper::hideLegend(*pModel); 104 } 105 106 bool isTitleVisisble(const css::uno::Reference<css::frame::XModel>& xModel, TitleHelper::eTitleType eTitle) 107 { 108 css::uno::Reference<css::uno::XInterface> xTitle = TitleHelper::getTitle(eTitle, xModel); 109 if (!xTitle.is()) 110 return false; 111 112 css::uno::Reference<css::beans::XPropertySet> xPropSet(xTitle, css::uno::UNO_QUERY_THROW); 113 css::uno::Any aAny = xPropSet->getPropertyValue("Visible"); 114 bool bVisible = aAny.get<bool>(); 115 return bVisible; 116 } 117 118 bool isGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridType eType) 119 { 120 Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); 121 if(xDiagram.is()) 122 { 123 sal_Int32 nDimensionIndex = 0; 124 if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR) 125 nDimensionIndex = 1; 126 127 bool bMajor = (eType == GridType::HOR_MAJOR || eType == GridType::VERT_MAJOR); 128 129 bool bHasGrid = AxisHelper::isGridShown(nDimensionIndex, 0, bMajor, xDiagram); 130 return bHasGrid; 131 } 132 return false; 133 } 134 135 void setGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridType eType, bool bVisible) 136 { 137 Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); 138 if(xDiagram.is()) 139 { 140 sal_Int32 nDimensionIndex = 0; 141 if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR) 142 nDimensionIndex = 1; 143 sal_Int32 nCooSysIndex = 0; 144 145 bool bMajor = (eType == GridType::HOR_MAJOR || eType == GridType::VERT_MAJOR); 146 147 if (bVisible) 148 AxisHelper::showGrid(nDimensionIndex, nCooSysIndex, bMajor, 149 xDiagram); 150 else 151 AxisHelper::hideGrid(nDimensionIndex, nCooSysIndex, bMajor, xDiagram); 152 } 153 } 154 155 bool isAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisType eType) 156 { 157 Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); 158 if(xDiagram.is()) 159 { 160 sal_Int32 nDimensionIndex = 0; 161 if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND) 162 nDimensionIndex = 1; 163 else if (eType == AxisType::Z_MAIN) 164 nDimensionIndex = 2; 165 166 bool bMajor = !(eType == AxisType::X_SECOND || eType == AxisType::Y_SECOND); 167 168 bool bHasAxis = AxisHelper::isAxisShown(nDimensionIndex, bMajor, xDiagram); 169 return bHasAxis; 170 } 171 return false; 172 } 173 174 void setAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisType eType, bool bVisible) 175 { 176 Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); 177 if(xDiagram.is()) 178 { 179 sal_Int32 nDimensionIndex = 0; 180 if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND) 181 nDimensionIndex = 1; 182 else if (eType == AxisType::Z_MAIN) 183 nDimensionIndex = 2; 184 185 bool bMajor = !(eType == AxisType::X_SECOND || eType == AxisType::Y_SECOND); 186 187 if (bVisible) 188 AxisHelper::showAxis(nDimensionIndex, bMajor, xDiagram, comphelper::getProcessComponentContext()); 189 else 190 AxisHelper::hideAxis(nDimensionIndex, bMajor, xDiagram); 191 } 192 } 193 194 sal_Int32 getLegendPos(const css::uno::Reference<css::frame::XModel>& xModel) 195 { 196 ChartModel* pModel = getChartModel(xModel); 197 if (!pModel) 198 return 4; 199 200 Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); 201 if (!xLegendProp.is()) 202 return 4; 203 204 chart2::LegendPosition eLegendPos = chart2::LegendPosition_CUSTOM; 205 xLegendProp->getPropertyValue("AnchorPosition") >>= eLegendPos; 206 switch(eLegendPos) 207 { 208 case chart2::LegendPosition_LINE_START: 209 return 3; 210 case chart2::LegendPosition_LINE_END: 211 return 0; 212 case chart2::LegendPosition_PAGE_START: 213 return 1; 214 case chart2::LegendPosition_PAGE_END: 215 return 2; 216 default: 217 return 4; 218 } 219 } 220 221 void setLegendPos(const css::uno::Reference<css::frame::XModel>& xModel, sal_Int32 nPos) 222 { 223 ChartModel* pModel = getChartModel(xModel); 224 if (!pModel) 225 return; 226 227 Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); 228 if (!xLegendProp.is()) 229 return; 230 231 chart2::LegendPosition eLegendPos = chart2::LegendPosition_CUSTOM; 232 css::chart::ChartLegendExpansion eExpansion = css::chart::ChartLegendExpansion_HIGH; 233 switch(nPos) 234 { 235 case 1: 236 eLegendPos = chart2::LegendPosition_PAGE_START; 237 eExpansion = css::chart::ChartLegendExpansion_WIDE; 238 break; 239 case 3: 240 eLegendPos = chart2::LegendPosition_LINE_START; 241 break; 242 case 0: 243 eLegendPos = chart2::LegendPosition_LINE_END; 244 break; 245 case 2: 246 eLegendPos = chart2::LegendPosition_PAGE_END; 247 eExpansion = css::chart::ChartLegendExpansion_WIDE; 248 break; 249 case 4: 250 eLegendPos = chart2::LegendPosition_CUSTOM; 251 break; 252 default: 253 assert(false); 254 } 255 256 xLegendProp->setPropertyValue("AnchorPosition", css::uno::Any(eLegendPos)); 257 xLegendProp->setPropertyValue("Expansion", css::uno::Any(eExpansion)); 258 259 if (eLegendPos != chart2::LegendPosition_CUSTOM) 260 { 261 xLegendProp->setPropertyValue("RelativePosition", uno::Any()); 262 } 263 } 264 265 } 266 267 ChartElementsPanel::ChartElementsPanel( 268 vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, 269 ChartController* pController) 270 : PanelLayout(pParent, "ChartElementsPanel", "modules/schart/ui/sidebarelements.ui", rxFrame, true) 271 , mxCBTitle(m_xBuilder->weld_check_button("checkbutton_title")) 272 , mxCBSubtitle(m_xBuilder->weld_check_button("checkbutton_subtitle")) 273 , mxCBXAxis(m_xBuilder->weld_check_button("checkbutton_x_axis")) 274 , mxCBXAxisTitle(m_xBuilder->weld_check_button("checkbutton_x_axis_title")) 275 , mxCBYAxis(m_xBuilder->weld_check_button("checkbutton_y_axis")) 276 , mxCBYAxisTitle(m_xBuilder->weld_check_button("checkbutton_y_axis_title")) 277 , mxCBZAxis(m_xBuilder->weld_check_button("checkbutton_z_axis")) 278 , mxCBZAxisTitle(m_xBuilder->weld_check_button("checkbutton_z_axis_title")) 279 , mxCB2ndXAxis(m_xBuilder->weld_check_button("checkbutton_2nd_x_axis")) 280 , mxCB2ndXAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_x_axis_title")) 281 , mxCB2ndYAxis(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis")) 282 , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis_title")) 283 , mxCBLegend(m_xBuilder->weld_check_button("checkbutton_legend")) 284 , mxCBGridVerticalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_major")) 285 , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_major")) 286 , mxCBGridVerticalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_minor")) 287 , mxCBGridHorizontalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_minor")) 288 , mxTextTitle(m_xBuilder->weld_label("text_title")) 289 , mxTextSubTitle(m_xBuilder->weld_label("text_subtitle")) 290 , mxLBAxis(m_xBuilder->weld_label("label_axes")) 291 , mxLBGrid(m_xBuilder->weld_label("label_gri")) 292 , mxLBLegendPosition(m_xBuilder->weld_combo_box("comboboxtext_legend")) 293 , mxBoxLegend(m_xBuilder->weld_widget("box_legend")) 294 , maContext() 295 , mxModel(pController->getModel()) 296 , mxListener(new ChartSidebarModifyListener(this)) 297 , mbModelValid(true) 298 { 299 maTextTitle = mxTextTitle->get_label(); 300 maTextSubTitle = mxTextSubTitle->get_label(); 301 302 Initialize(); 303 } 304 305 ChartElementsPanel::~ChartElementsPanel() 306 { 307 disposeOnce(); 308 } 309 310 void ChartElementsPanel::dispose() 311 { 312 css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); 313 xBroadcaster->removeModifyListener(mxListener); 314 mxCBTitle.reset(); 315 mxCBSubtitle.reset(); 316 mxCBXAxis.reset(); 317 mxCBXAxisTitle.reset(); 318 mxCBYAxis.reset(); 319 mxCBYAxisTitle.reset(); 320 mxCBZAxis.reset(); 321 mxCBZAxisTitle.reset(); 322 mxCB2ndXAxis.reset(); 323 mxCB2ndXAxisTitle.reset(); 324 mxCB2ndYAxis.reset(); 325 mxCB2ndYAxisTitle.reset(); 326 mxCBLegend.reset(); 327 mxCBGridVerticalMajor.reset(); 328 mxCBGridHorizontalMajor.reset(); 329 mxCBGridVerticalMinor.reset(); 330 mxCBGridHorizontalMinor.reset(); 331 332 mxLBLegendPosition.reset(); 333 mxBoxLegend.reset(); 334 335 mxLBAxis.reset(); 336 mxLBGrid.reset(); 337 338 mxTextTitle.reset(); 339 mxTextSubTitle.reset(); 340 341 PanelLayout::dispose(); 342 } 343 344 void ChartElementsPanel::Initialize() 345 { 346 css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); 347 xBroadcaster->addModifyListener(mxListener); 348 updateData(); 349 350 Link<weld::ToggleButton&,void> aLink = LINK(this, ChartElementsPanel, CheckBoxHdl); 351 mxCBTitle->connect_toggled(aLink); 352 mxCBSubtitle->connect_toggled(aLink); 353 mxCBXAxis->connect_toggled(aLink); 354 mxCBXAxisTitle->connect_toggled(aLink); 355 mxCBYAxis->connect_toggled(aLink); 356 mxCBYAxisTitle->connect_toggled(aLink); 357 mxCBZAxis->connect_toggled(aLink); 358 mxCBZAxisTitle->connect_toggled(aLink); 359 mxCB2ndXAxis->connect_toggled(aLink); 360 mxCB2ndXAxisTitle->connect_toggled(aLink); 361 mxCB2ndYAxis->connect_toggled(aLink); 362 mxCB2ndYAxisTitle->connect_toggled(aLink); 363 mxCBLegend->connect_toggled(aLink); 364 mxCBGridVerticalMajor->connect_toggled(aLink); 365 mxCBGridHorizontalMajor->connect_toggled(aLink); 366 mxCBGridVerticalMinor->connect_toggled(aLink); 367 mxCBGridHorizontalMinor->connect_toggled(aLink); 368 369 mxLBLegendPosition->connect_changed(LINK(this, ChartElementsPanel, LegendPosHdl)); 370 } 371 372 namespace { 373 374 css::uno::Reference<css::chart2::XChartType> getChartType(const css::uno::Reference<css::frame::XModel>& xModel) 375 { 376 css::uno::Reference<css::chart2::XChartDocument> xChartDoc(xModel, css::uno::UNO_QUERY_THROW); 377 css::uno::Reference<chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram(); 378 if (!xDiagram.is()) { 379 return css::uno::Reference<css::chart2::XChartType>(); 380 } 381 382 css::uno::Reference<css::chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, css::uno::UNO_QUERY_THROW ); 383 384 css::uno::Sequence<css::uno::Reference<css::chart2::XCoordinateSystem>> xCooSysSequence(xCooSysContainer->getCoordinateSystems()); 385 386 if (!xCooSysSequence.hasElements()) 387 return css::uno::Reference<css::chart2::XChartType>(); 388 389 css::uno::Reference<css::chart2::XChartTypeContainer> xChartTypeContainer(xCooSysSequence[0], css::uno::UNO_QUERY_THROW); 390 391 css::uno::Sequence<css::uno::Reference<css::chart2::XChartType>> xChartTypeSequence(xChartTypeContainer->getChartTypes()); 392 393 if (!xChartTypeSequence.hasElements()) 394 return css::uno::Reference<css::chart2::XChartType>(); 395 396 return xChartTypeSequence[0]; 397 } 398 399 } 400 401 void ChartElementsPanel::updateData() 402 { 403 if (!mbModelValid) 404 return; 405 406 Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(mxModel)); 407 sal_Int32 nDimension = DiagramHelper::getDimension(xDiagram); 408 SolarMutexGuard aGuard; 409 410 mxCBLegend->set_active(isLegendVisible(mxModel)); 411 mxBoxLegend->set_sensitive( isLegendVisible(mxModel) ); 412 mxCBTitle->set_active(isTitleVisisble(mxModel, TitleHelper::MAIN_TITLE)); 413 mxCBSubtitle->set_active(isTitleVisisble(mxModel, TitleHelper::SUB_TITLE)); 414 mxCBXAxisTitle->set_active(isTitleVisisble(mxModel, TitleHelper::X_AXIS_TITLE)); 415 mxCBYAxisTitle->set_active(isTitleVisisble(mxModel, TitleHelper::Y_AXIS_TITLE)); 416 mxCBZAxisTitle->set_active(isTitleVisisble(mxModel, TitleHelper::Z_AXIS_TITLE)); 417 mxCB2ndXAxisTitle->set_active(isTitleVisisble(mxModel, TitleHelper::SECONDARY_X_AXIS_TITLE)); 418 mxCB2ndYAxisTitle->set_active(isTitleVisisble(mxModel, TitleHelper::SECONDARY_Y_AXIS_TITLE)); 419 mxCBGridVerticalMajor->set_active(isGridVisible(mxModel, GridType::VERT_MAJOR)); 420 mxCBGridHorizontalMajor->set_active(isGridVisible(mxModel, GridType::HOR_MAJOR)); 421 mxCBGridVerticalMinor->set_active(isGridVisible(mxModel, GridType::VERT_MINOR)); 422 mxCBGridHorizontalMinor->set_active(isGridVisible(mxModel, GridType::HOR_MINOR)); 423 mxCBXAxis->set_active(isAxisVisible(mxModel, AxisType::X_MAIN)); 424 mxCBYAxis->set_active(isAxisVisible(mxModel, AxisType::Y_MAIN)); 425 mxCBZAxis->set_active(isAxisVisible(mxModel, AxisType::Z_MAIN)); 426 mxCB2ndXAxis->set_active(isAxisVisible(mxModel, AxisType::X_SECOND)); 427 mxCB2ndYAxis->set_active(isAxisVisible(mxModel, AxisType::Y_SECOND)); 428 429 430 bool bSupportsMainAxis = ChartTypeHelper::isSupportingMainAxis( 431 getChartType(mxModel), 0, 0); 432 if (bSupportsMainAxis) 433 { 434 mxCBXAxis->show(); 435 mxCBYAxis->show(); 436 mxCBZAxis->show(); 437 mxCBXAxisTitle->show(); 438 mxCBYAxisTitle->show(); 439 mxCBZAxisTitle->show(); 440 mxCBGridVerticalMajor->show(); 441 mxCBGridVerticalMinor->show(); 442 mxCBGridHorizontalMajor->show(); 443 mxCBGridHorizontalMinor->show(); 444 mxLBAxis->show(); 445 mxLBGrid->show(); 446 } 447 else 448 { 449 mxCBXAxis->hide(); 450 mxCBYAxis->hide(); 451 mxCBZAxis->hide(); 452 mxCBXAxisTitle->hide(); 453 mxCBYAxisTitle->hide(); 454 mxCBZAxisTitle->hide(); 455 mxCBGridVerticalMajor->hide(); 456 mxCBGridVerticalMinor->hide(); 457 mxCBGridHorizontalMajor->hide(); 458 mxCBGridHorizontalMinor->hide(); 459 mxLBAxis->hide(); 460 mxLBGrid->hide(); 461 } 462 463 if (nDimension == 3) 464 { 465 mxCBZAxis->set_sensitive(true); 466 mxCBZAxisTitle->set_sensitive(true); 467 } 468 else 469 { 470 mxCBZAxis->set_sensitive(false); 471 mxCBZAxisTitle->set_sensitive(false); 472 } 473 474 mxLBLegendPosition->set_active(getLegendPos(mxModel)); 475 } 476 477 VclPtr<vcl::Window> ChartElementsPanel::Create ( 478 vcl::Window* pParent, 479 const css::uno::Reference<css::frame::XFrame>& rxFrame, 480 ChartController* pController) 481 { 482 if (pParent == nullptr) 483 throw lang::IllegalArgumentException("no parent Window given to ChartElementsPanel::Create", nullptr, 0); 484 if ( ! rxFrame.is()) 485 throw lang::IllegalArgumentException("no XFrame given to ChartElementsPanel::Create", nullptr, 1); 486 return VclPtr<ChartElementsPanel>::Create( 487 pParent, rxFrame, pController); 488 } 489 490 void ChartElementsPanel::DataChanged( 491 const DataChangedEvent& ) 492 { 493 updateData(); 494 } 495 496 void ChartElementsPanel::HandleContextChange( 497 const vcl::EnumContext& rContext) 498 { 499 if(maContext == rContext) 500 { 501 // Nothing to do. 502 return; 503 } 504 505 maContext = rContext; 506 updateData(); 507 } 508 509 void ChartElementsPanel::modelInvalid() 510 { 511 mbModelValid = false; 512 } 513 514 void ChartElementsPanel::updateModel( 515 css::uno::Reference<css::frame::XModel> xModel) 516 { 517 if (mbModelValid) 518 { 519 css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); 520 xBroadcaster->removeModifyListener(mxListener); 521 } 522 523 mxModel = xModel; 524 mbModelValid = true; 525 526 css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); 527 xBroadcasterNew->addModifyListener(mxListener); 528 } 529 530 IMPL_LINK(ChartElementsPanel, CheckBoxHdl, weld::ToggleButton&, rCheckBox, void) 531 { 532 bool bChecked = rCheckBox.get_active(); 533 if (&rCheckBox == mxCBTitle.get()) 534 setTitleVisible(TitleHelper::MAIN_TITLE, bChecked); 535 else if (&rCheckBox == mxCBSubtitle.get()) 536 setTitleVisible(TitleHelper::SUB_TITLE, bChecked); 537 else if (&rCheckBox == mxCBXAxis.get()) 538 setAxisVisible(mxModel, AxisType::X_MAIN, bChecked); 539 else if (&rCheckBox == mxCBXAxisTitle.get()) 540 setTitleVisible(TitleHelper::X_AXIS_TITLE, bChecked); 541 else if (&rCheckBox == mxCBYAxis.get()) 542 setAxisVisible(mxModel, AxisType::Y_MAIN, bChecked); 543 else if (&rCheckBox == mxCBYAxisTitle.get()) 544 setTitleVisible(TitleHelper::Y_AXIS_TITLE, bChecked); 545 else if (&rCheckBox == mxCBZAxis.get()) 546 setAxisVisible(mxModel, AxisType::Z_MAIN, bChecked); 547 else if (&rCheckBox == mxCBZAxisTitle.get()) 548 setTitleVisible(TitleHelper::Z_AXIS_TITLE, bChecked); 549 else if (&rCheckBox == mxCB2ndXAxis.get()) 550 setAxisVisible(mxModel, AxisType::X_SECOND, bChecked); 551 else if (&rCheckBox == mxCB2ndXAxisTitle.get()) 552 setTitleVisible(TitleHelper::SECONDARY_X_AXIS_TITLE, bChecked); 553 else if (&rCheckBox == mxCB2ndYAxis.get()) 554 setAxisVisible(mxModel, AxisType::Y_SECOND, bChecked); 555 else if (&rCheckBox == mxCB2ndYAxisTitle.get()) 556 setTitleVisible(TitleHelper::SECONDARY_Y_AXIS_TITLE, bChecked); 557 else if (&rCheckBox == mxCBLegend.get()) 558 { 559 mxBoxLegend->set_sensitive( bChecked ); 560 setLegendVisible(mxModel, bChecked); 561 } 562 else if (&rCheckBox == mxCBGridVerticalMajor.get()) 563 setGridVisible(mxModel, GridType::VERT_MAJOR, bChecked); 564 else if (&rCheckBox == mxCBGridHorizontalMajor.get()) 565 setGridVisible(mxModel, GridType::HOR_MAJOR, bChecked); 566 else if (&rCheckBox == mxCBGridVerticalMinor.get()) 567 setGridVisible(mxModel, GridType::VERT_MINOR, bChecked); 568 else if (&rCheckBox == mxCBGridHorizontalMinor.get()) 569 setGridVisible(mxModel, GridType::HOR_MINOR, bChecked); 570 } 571 572 IMPL_LINK_NOARG(ChartElementsPanel, LegendPosHdl, weld::ComboBox&, void) 573 { 574 sal_Int32 nPos = mxLBLegendPosition->get_active(); 575 setLegendPos(mxModel, nPos); 576 } 577 578 void ChartElementsPanel::setTitleVisible(TitleHelper::eTitleType eTitle, bool bVisible) 579 { 580 if (bVisible) 581 { 582 OUString aText = eTitle == TitleHelper::SUB_TITLE ? maTextSubTitle : maTextTitle; 583 TitleHelper::createOrShowTitle(eTitle, aText, mxModel, comphelper::getProcessComponentContext()); 584 } 585 else 586 { 587 TitleHelper::hideTitle(eTitle, mxModel); 588 } 589 } 590 591 }} // end of namespace ::chart::sidebar 592 593 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 594
