| 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 "ShapeController.hxx" |
| 21 |
#include <ChartController.hxx> |
| 22 |
#include <ViewElementListProvider.hxx> |
| 23 |
#include <dlg_ShapeFont.hxx> |
| 24 |
#include <dlg_ShapeParagraph.hxx> |
| 25 |
#include <ChartModel.hxx> |
| 26 |
#include <chartview/DrawModelWrapper.hxx> |
| 27 |
#include <com/sun/star/drawing/XShapes.hpp> |
| 28 |
#include <com/sun/star/frame/CommandGroup.hpp> |
| 29 |
|
| 30 |
#include <vcl/svapp.hxx> |
| 31 |
#include <editeng/formatbreakitem.hxx> |
| 32 |
#include <editeng/editids.hrc> |
| 33 |
#include <editeng/eeitem.hxx> |
| 34 |
#include <editeng/hyphenzoneitem.hxx> |
| 35 |
#include <editeng/orphitem.hxx> |
| 36 |
#include <editeng/spltitem.hxx> |
| 37 |
#include <svx/svxdlg.hxx> |
| 38 |
#include <editeng/widwitem.hxx> |
| 39 |
#include <comphelper/diagnose_ex.hxx> |
| 40 |
|
| 41 |
using namespace ::com::sun::star; |
| 42 |
using namespace ::com::sun::star::frame; |
| 43 |
|
| 44 |
using ::com::sun::star::uno::Reference; |
| 45 |
using ::com::sun::star::uno::Sequence; |
| 46 |
|
| 47 |
namespace chart |
| 48 |
{ |
| 49 |
|
| 50 |
ShapeController::ShapeController( const Reference< uno::XComponentContext >& rxContext, |
| 51 |
ChartController* pController ) |
| 52 |
:FeatureCommandDispatchBase( rxContext ) |
| 53 |
,m_pChartController( pController ) |
| 54 |
{ |
| 55 |
} |
| 56 |
|
| 57 |
ShapeController::~ShapeController() |
| 58 |
{ |
| 59 |
} |
| 60 |
|
| 61 |
// WeakComponentImplHelperBase |
| 62 |
void ShapeController::disposing(std::unique_lock<std::mutex>& /*rGuard*/) |
| 63 |
{ |
| 64 |
} |
| 65 |
|
| 66 |
// XEventListener |
| 67 |
void ShapeController::disposing( const lang::EventObject& /* Source */ ) |
| 68 |
{ |
| 69 |
} |
| 70 |
|
| 71 |
FeatureState ShapeController::getState( const OUString& rCommand ) |
| 72 |
{ |
| 73 |
FeatureState aReturn; |
| 74 |
aReturn.bEnabled = false; |
| 75 |
aReturn.aState <<= false; |
| 76 |
|
| 77 |
bool bWritable = false; |
| 78 |
if ( m_pChartController ) |
| 79 |
{ |
| 80 |
rtl::Reference< ChartModel > xStorable = m_pChartController->getChartModel(); |
| 81 |
if ( xStorable.is() ) |
| 82 |
{ |
| 83 |
bWritable = !xStorable->isReadonly(); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand ); |
| 88 |
if ( aIter != m_aSupportedFeatures.end() ) |
| 89 |
{ |
| 90 |
ChartCommandID nFeatureId = aIter->second.nFeatureId; |
| 91 |
switch ( nFeatureId ) |
| 92 |
{ |
| 93 |
case ChartCommandID::ShapeFormatLine: |
| 94 |
case ChartCommandID::ShapeFormatArea: |
| 95 |
case ChartCommandID::ShapeTextAttributes: |
| 96 |
case ChartCommandID::ShapeTransformDialog: |
| 97 |
case ChartCommandID::ShapeObjectTitleDescription: |
| 98 |
case ChartCommandID::ShapeRenameObject: |
| 99 |
case ChartCommandID::ShapeFontDialog: |
| 100 |
case ChartCommandID::ShapeParagraphDialog: |
| 101 |
{ |
| 102 |
aReturn.bEnabled = bWritable; |
| 103 |
aReturn.aState <<= false; |
| 104 |
} |
| 105 |
break; |
| 106 |
case ChartCommandID::ShapeBringToFront: |
| 107 |
case ChartCommandID::ShapeForward: |
| 108 |
{ |
| 109 |
aReturn.bEnabled = ( bWritable && isForwardPossible() ); |
| 110 |
aReturn.aState <<= false; |
| 111 |
} |
| 112 |
break; |
| 113 |
case ChartCommandID::ShapeBackward: |
| 114 |
case ChartCommandID::ShapeSendToBack: |
| 115 |
{ |
| 116 |
|
| 117 |
aReturn.bEnabled = ( bWritable && isBackwardPossible() ); |
| 118 |
aReturn.aState <<= false; |
| 119 |
} |
| 120 |
break; |
| 121 |
default: |
| 122 |
{ |
| 123 |
aReturn.bEnabled = false; |
| 124 |
aReturn.aState <<= false; |
| 125 |
} |
| 126 |
break; |
| 127 |
} |
| 128 |
} |
| 129 |
|
| 130 |
return aReturn; |
| 131 |
} |
| 132 |
|
| 133 |
void ShapeController::execute( const OUString& rCommand, const Sequence< beans::PropertyValue>& ) |
| 134 |
{ |
| 135 |
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand ); |
| 136 |
if ( aIter == m_aSupportedFeatures.end() ) |
| 137 |
return; |
| 138 |
|
| 139 |
ChartCommandID nFeatureId = aIter->second.nFeatureId; |
| 140 |
switch ( nFeatureId ) |
| 141 |
{ |
| 142 |
case ChartCommandID::ShapeFormatLine: |
| 143 |
{ |
| 144 |
executeDispatch_FormatLine(); |
| 145 |
} |
| 146 |
break; |
| 147 |
case ChartCommandID::ShapeFormatArea: |
| 148 |
{ |
| 149 |
executeDispatch_FormatArea(); |
| 150 |
} |
| 151 |
break; |
| 152 |
case ChartCommandID::ShapeTextAttributes: |
| 153 |
{ |
| 154 |
executeDispatch_TextAttributes(); |
| 155 |
} |
| 156 |
break; |
| 157 |
case ChartCommandID::ShapeTransformDialog: |
| 158 |
{ |
| 159 |
executeDispatch_TransformDialog(); |
| 160 |
} |
| 161 |
break; |
| 162 |
case ChartCommandID::ShapeObjectTitleDescription: |
| 163 |
{ |
| 164 |
executeDispatch_ObjectTitleDescription(); |
| 165 |
} |
| 166 |
break; |
| 167 |
case ChartCommandID::ShapeRenameObject: |
| 168 |
{ |
| 169 |
executeDispatch_RenameObject(); |
| 170 |
} |
| 171 |
break; |
| 172 |
case ChartCommandID::ShapeBringToFront: |
| 173 |
case ChartCommandID::ShapeForward: |
| 174 |
case ChartCommandID::ShapeBackward: |
| 175 |
case ChartCommandID::ShapeSendToBack: |
| 176 |
{ |
| 177 |
executeDispatch_ChangeZOrder( nFeatureId ); |
| 178 |
} |
| 179 |
break; |
| 180 |
case ChartCommandID::ShapeFontDialog: |
| 181 |
{ |
| 182 |
executeDispatch_FontDialog(); |
| 183 |
} |
| 184 |
break; |
| 185 |
case ChartCommandID::ShapeParagraphDialog: |
| 186 |
{ |
| 187 |
executeDispatch_ParagraphDialog(); |
| 188 |
} |
| 189 |
break; |
| 190 |
default: |
| 191 |
{ |
| 192 |
} |
| 193 |
break; |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
void ShapeController::describeSupportedFeatures() |
| 198 |
{ |
| 199 |
implDescribeSupportedFeature( u".uno:FormatLine"_ustr, ChartCommandID::ShapeFormatLine, CommandGroup::FORMAT ); |
| 200 |
implDescribeSupportedFeature( u".uno:FormatArea"_ustr, ChartCommandID::ShapeFormatArea, CommandGroup::FORMAT ); |
| 201 |
implDescribeSupportedFeature( u".uno:TextAttributes"_ustr, ChartCommandID::ShapeTextAttributes, CommandGroup::FORMAT ); |
| 202 |
implDescribeSupportedFeature( u".uno:TransformDialog"_ustr, ChartCommandID::ShapeTransformDialog, CommandGroup::FORMAT ); |
| 203 |
implDescribeSupportedFeature( u".uno:ObjectTitleDescription"_ustr, ChartCommandID::ShapeObjectTitleDescription, CommandGroup::FORMAT ); |
| 204 |
implDescribeSupportedFeature( u".uno:RenameObject"_ustr, ChartCommandID::ShapeRenameObject, CommandGroup::FORMAT ); |
| 205 |
implDescribeSupportedFeature( u".uno:BringToFront"_ustr, ChartCommandID::ShapeBringToFront, CommandGroup::FORMAT ); |
| 206 |
implDescribeSupportedFeature( u".uno:Forward"_ustr, ChartCommandID::ShapeForward, CommandGroup::FORMAT ); |
| 207 |
implDescribeSupportedFeature( u".uno:Backward"_ustr, ChartCommandID::ShapeBackward, CommandGroup::FORMAT ); |
| 208 |
implDescribeSupportedFeature( u".uno:SendToBack"_ustr, ChartCommandID::ShapeSendToBack, CommandGroup::FORMAT ); |
| 209 |
implDescribeSupportedFeature( u".uno:FontDialog"_ustr, ChartCommandID::ShapeFontDialog, CommandGroup::EDIT ); |
| 210 |
implDescribeSupportedFeature( u".uno:ParagraphDialog"_ustr, ChartCommandID::ShapeParagraphDialog, CommandGroup::EDIT ); |
| 211 |
} |
| 212 |
|
| 213 |
IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxObjectNameDialog&, rDialog, bool ) |
| 214 |
{ |
| 215 |
OUString aName = rDialog.GetName(); |
| 216 |
|
| 217 |
if ( !aName.isEmpty() ) |
| 218 |
{ |
| 219 |
DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr ); |
| 220 |
if ( pDrawViewWrapper && pDrawViewWrapper->getNamedSdrObject( aName ) ) |
| 221 |
{ |
| 222 |
return false; |
| 223 |
} |
| 224 |
} |
| 225 |
return true; |
| 226 |
} |
| 227 |
|
| 228 |
void ShapeController::executeDispatch_FormatLine() |
| 229 |
{ |
| 230 |
SolarMutexGuard aGuard; |
| 231 |
if ( !m_pChartController ) |
| 232 |
return; |
| 233 |
|
| 234 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 235 |
DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); |
| 236 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 237 |
if ( !(pChartWindow && pDrawModelWrapper && pDrawViewWrapper) ) |
| 238 |
return; |
| 239 |
|
| 240 |
SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); |
| 241 |
SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); |
| 242 |
bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0; |
| 243 |
if ( bHasMarked ) |
| 244 |
{ |
| 245 |
pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); |
| 246 |
} |
| 247 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 248 |
ScopedVclPtr< SfxAbstractTabDialog > pDlg( |
| 249 |
pFact->CreateSvxLineTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), |
| 250 |
pSelectedObj, bHasMarked)); |
| 251 |
if ( pDlg->Execute() == RET_OK ) |
| 252 |
{ |
| 253 |
const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); |
| 254 |
if ( bHasMarked ) |
| 255 |
{ |
| 256 |
pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false ); |
| 257 |
} |
| 258 |
else |
| 259 |
{ |
| 260 |
pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
void ShapeController::executeDispatch_FormatArea() |
| 266 |
{ |
| 267 |
SolarMutexGuard aGuard; |
| 268 |
if ( !m_pChartController ) |
| 269 |
return; |
| 270 |
|
| 271 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 272 |
DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); |
| 273 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 274 |
if ( !(pChartWindow && pDrawModelWrapper && pDrawViewWrapper) ) |
| 275 |
return; |
| 276 |
|
| 277 |
SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); |
| 278 |
bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0; |
| 279 |
if ( bHasMarked ) |
| 280 |
{ |
| 281 |
pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); |
| 282 |
} |
| 283 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 284 |
ScopedVclPtr< AbstractSvxAreaTabDialog > pDlg( |
| 285 |
pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true, false)); |
| 286 |
if ( pDlg->Execute() == RET_OK ) |
| 287 |
{ |
| 288 |
const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); |
| 289 |
if ( bHasMarked ) |
| 290 |
{ |
| 291 |
pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false ); |
| 292 |
} |
| 293 |
else |
| 294 |
{ |
| 295 |
pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
void ShapeController::executeDispatch_TextAttributes() |
| 301 |
{ |
| 302 |
SolarMutexGuard aGuard; |
| 303 |
if ( !m_pChartController ) |
| 304 |
return; |
| 305 |
|
| 306 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 307 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 308 |
if ( !(pChartWindow && pDrawViewWrapper) ) |
| 309 |
return; |
| 310 |
|
| 311 |
SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); |
| 312 |
bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0; |
| 313 |
if ( bHasMarked ) |
| 314 |
{ |
| 315 |
pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); |
| 316 |
} |
| 317 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 318 |
VclPtr< SfxAbstractTabDialog > pDlg( |
| 319 |
pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper)); |
| 320 |
pDlg->StartExecuteAsync( |
| 321 |
[pDlg, bHasMarked, pDrawViewWrapper] (sal_Int32 nResult)->void |
| 322 |
{ |
| 323 |
if ( RET_OK == nResult ) |
| 324 |
{ |
| 325 |
const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); |
| 326 |
if ( bHasMarked ) |
| 327 |
{ |
| 328 |
pDrawViewWrapper->SetAttributes( *pOutAttr ); |
| 329 |
} |
| 330 |
else |
| 331 |
{ |
| 332 |
pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); |
| 333 |
} |
| 334 |
} |
| 335 |
pDlg->disposeOnce(); |
| 336 |
} |
| 337 |
); |
| 338 |
} |
| 339 |
|
| 340 |
void ShapeController::executeDispatch_TransformDialog() |
| 341 |
{ |
| 342 |
SolarMutexGuard aGuard; |
| 343 |
if ( !m_pChartController ) |
| 344 |
return; |
| 345 |
|
| 346 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 347 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 348 |
if ( !(pChartWindow && pDrawViewWrapper) ) |
| 349 |
return; |
| 350 |
|
| 351 |
SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); |
| 352 |
if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == SdrObjKind::Caption ) |
| 353 |
{ |
| 354 |
// item set for caption |
| 355 |
SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool()); |
| 356 |
pDrawViewWrapper->GetAttributes( aAttr ); |
| 357 |
// item set for position and size |
| 358 |
SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); |
| 359 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 360 |
ScopedVclPtr< SfxAbstractTabDialog > pDlg( |
| 361 |
pFact->CreateCaptionDialog(pChartWindow, pDrawViewWrapper)); |
| 362 |
SfxItemSet aCombAttr(*aAttr.GetPool(), pDlg->GetInputRanges(*aAttr.GetPool())); |
| 363 |
aCombAttr.Put( aAttr ); |
| 364 |
aCombAttr.Put( aGeoAttr ); |
| 365 |
pDlg->SetInputSet( &aCombAttr ); |
| 366 |
if ( pDlg->Execute() == RET_OK ) |
| 367 |
{ |
| 368 |
const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); |
| 369 |
pDrawViewWrapper->SetAttributes( *pOutAttr ); |
| 370 |
pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr ); |
| 371 |
} |
| 372 |
} |
| 373 |
else |
| 374 |
{ |
| 375 |
SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); |
| 376 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 377 |
ScopedVclPtr< SfxAbstractTabDialog > pDlg( |
| 378 |
pFact->CreateSvxTransformTabDialog(pChartWindow, &aGeoAttr, pDrawViewWrapper)); |
| 379 |
if ( pDlg->Execute() == RET_OK ) |
| 380 |
{ |
| 381 |
const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); |
| 382 |
pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr ); |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
void ShapeController::executeDispatch_ObjectTitleDescription() |
| 388 |
{ |
| 389 |
SolarMutexGuard aGuard; |
| 390 |
if ( !m_pChartController ) |
| 391 |
return; |
| 392 |
|
| 393 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 394 |
if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() == 1) ) |
| 395 |
return; |
| 396 |
|
| 397 |
SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); |
| 398 |
if ( !pSelectedObj ) |
| 399 |
return; |
| 400 |
|
| 401 |
OUString aTitle( pSelectedObj->GetTitle() ); |
| 402 |
OUString aDescription( pSelectedObj->GetDescription() ); |
| 403 |
bool isDecorative(pSelectedObj->IsDecorative()); |
| 404 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 405 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 406 |
VclPtr< AbstractSvxObjectTitleDescDialog > pDlg( |
| 407 |
pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription, isDecorative)); |
| 408 |
pDlg->StartExecuteAsync( |
| 409 |
[pDlg, pSelectedObj] (sal_Int32 nResult)->void |
| 410 |
{ |
| 411 |
if (nResult == RET_OK) |
| 412 |
{ |
| 413 |
pSelectedObj->SetTitle( pDlg->GetTitle() ); |
| 414 |
pSelectedObj->SetDescription( pDlg->GetDescription() ); |
| 415 |
pSelectedObj->SetDecorative(pDlg->IsDecorative()); |
| 416 |
} |
| 417 |
pDlg->disposeOnce(); |
| 418 |
} |
| 419 |
); |
| 420 |
} |
| 421 |
|
| 422 |
void ShapeController::executeDispatch_RenameObject() |
| 423 |
{ |
| 424 |
SolarMutexGuard aGuard; |
| 425 |
if ( !m_pChartController ) |
| 426 |
return; |
| 427 |
|
| 428 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 429 |
if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() == 1) ) |
| 430 |
return; |
| 431 |
|
| 432 |
SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); |
| 433 |
if ( !pSelectedObj ) |
| 434 |
return; |
| 435 |
|
| 436 |
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
| 437 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 438 |
VclPtr< AbstractSvxObjectNameDialog > pDlg( |
| 439 |
pFact->CreateSvxObjectNameDialog(pChartWindow, pSelectedObj->GetName())); |
| 440 |
pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) ); |
| 441 |
pDlg->StartExecuteAsync( |
| 442 |
[pDlg, pSelectedObj] (sal_Int32 nResult)->void |
| 443 |
{ |
| 444 |
if (nResult == RET_OK) |
| 445 |
{ |
| 446 |
OUString aName = pDlg->GetName(); |
| 447 |
if (pSelectedObj->GetName() != aName) |
| 448 |
{ |
| 449 |
pSelectedObj->SetName( aName ); |
| 450 |
} |
| 451 |
} |
| 452 |
pDlg->disposeOnce(); |
| 453 |
} |
| 454 |
); |
| 455 |
} |
| 456 |
|
| 457 |
void ShapeController::executeDispatch_ChangeZOrder( ChartCommandID nId ) |
| 458 |
{ |
| 459 |
SolarMutexGuard aGuard; |
| 460 |
DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr ); |
| 461 |
if ( !pDrawViewWrapper ) |
| 462 |
return; |
| 463 |
|
| 464 |
switch ( nId ) |
| 465 |
{ |
| 466 |
case ChartCommandID::ShapeBringToFront: |
| 467 |
{ |
| 468 |
if ( isForwardPossible() ) |
| 469 |
{ |
| 470 |
pDrawViewWrapper->PutMarkedToTop(); |
| 471 |
} |
| 472 |
} |
| 473 |
break; |
| 474 |
case ChartCommandID::ShapeForward: |
| 475 |
{ |
| 476 |
if ( isForwardPossible() ) |
| 477 |
{ |
| 478 |
pDrawViewWrapper->MovMarkedToTop(); |
| 479 |
} |
| 480 |
} |
| 481 |
break; |
| 482 |
case ChartCommandID::ShapeBackward: |
| 483 |
{ |
| 484 |
if ( isBackwardPossible() ) |
| 485 |
{ |
| 486 |
pDrawViewWrapper->MovMarkedToBtm(); |
| 487 |
} |
| 488 |
} |
| 489 |
break; |
| 490 |
case ChartCommandID::ShapeSendToBack: |
| 491 |
{ |
| 492 |
if ( isBackwardPossible() ) |
| 493 |
{ |
| 494 |
SdrObject* pFirstObj = getFirstAdditionalShape(); |
| 495 |
pDrawViewWrapper->PutMarkedBehindObj( pFirstObj ); |
| 496 |
} |
| 497 |
} |
| 498 |
break; |
| 499 |
default: |
| 500 |
{ |
| 501 |
} |
| 502 |
break; |
| 503 |
} |
| 504 |
} |
| 505 |
|
| 506 |
void ShapeController::executeDispatch_FontDialog() |
| 507 |
{ |
| 508 |
SolarMutexGuard aGuard; |
| 509 |
if ( !m_pChartController ) |
| 510 |
return; |
| 511 |
|
| 512 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 513 |
DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); |
| 514 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 515 |
if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper ) |
| 516 |
{ |
| 517 |
SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool()); |
| 518 |
pDrawViewWrapper->GetAttributes( aAttr ); |
| 519 |
ViewElementListProvider aViewElementListProvider( pDrawModelWrapper ); |
| 520 |
ShapeFontDialog aDlg(pChartWindow, &aAttr, &aViewElementListProvider); |
| 521 |
if (aDlg.run() == RET_OK) |
| 522 |
{ |
| 523 |
const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet(); |
| 524 |
pDrawViewWrapper->SetAttributes( *pOutAttr ); |
| 525 |
} |
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
void ShapeController::executeDispatch_ParagraphDialog() |
| 530 |
{ |
| 531 |
SolarMutexGuard aGuard; |
| 532 |
if ( !m_pChartController ) |
| 533 |
return; |
| 534 |
|
| 535 |
weld::Window* pChartWindow(m_pChartController->GetChartFrame()); |
| 536 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 537 |
if ( !(pChartWindow && pDrawViewWrapper) ) |
| 538 |
return; |
| 539 |
|
| 540 |
SfxItemPool& rPool = pDrawViewWrapper->GetModel().GetItemPool(); |
| 541 |
SfxItemSet aAttr( rPool ); |
| 542 |
pDrawViewWrapper->GetAttributes( aAttr ); |
| 543 |
|
| 544 |
SfxItemSetFixed< |
| 545 |
EE_ITEMS_START, EE_ITEMS_END, |
| 546 |
SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS> aNewAttr(rPool); |
| 547 |
aNewAttr.Put( aAttr ); |
| 548 |
aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) ); |
| 549 |
aNewAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, SID_ATTR_PARA_PAGEBREAK ) ); |
| 550 |
aNewAttr.Put( SvxFormatSplitItem( true, SID_ATTR_PARA_SPLIT) ); |
| 551 |
aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) ); |
| 552 |
aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) ); |
| 553 |
|
| 554 |
ShapeParagraphDialog aDlg(pChartWindow, &aNewAttr); |
| 555 |
if (aDlg.run() == RET_OK) |
| 556 |
{ |
| 557 |
const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet(); |
| 558 |
pDrawViewWrapper->SetAttributes( *pOutAttr ); |
| 559 |
} |
| 560 |
} |
| 561 |
|
| 562 |
SdrObject* ShapeController::getFirstAdditionalShape() |
| 563 |
{ |
| 564 |
SdrObject* pFirstObj = nullptr; |
| 565 |
|
| 566 |
try |
| 567 |
{ |
| 568 |
DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr ); |
| 569 |
if ( pDrawModelWrapper ) |
| 570 |
{ |
| 571 |
Reference< drawing::XShape > xFirstShape; |
| 572 |
rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() ); |
| 573 |
Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); |
| 574 |
sal_Int32 nCount = xDrawPage->getCount(); |
| 575 |
for ( sal_Int32 i = 0; i < nCount; ++i ) |
| 576 |
{ |
| 577 |
Reference< drawing::XShape > xShape; |
| 578 |
if ( xDrawPage->getByIndex( i ) >>= xShape ) |
| 579 |
{ |
| 580 |
if ( xShape.is() && xShape != xChartRoot ) |
| 581 |
{ |
| 582 |
xFirstShape = std::move(xShape); |
| 583 |
break; |
| 584 |
} |
| 585 |
} |
| 586 |
} |
| 587 |
if ( xFirstShape.is() ) |
| 588 |
{ |
| 589 |
pFirstObj = DrawViewWrapper::getSdrObject( xFirstShape ); |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
catch ( const uno::Exception& ) |
| 594 |
{ |
| 595 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 596 |
} |
| 597 |
|
| 598 |
return pFirstObj; |
| 599 |
} |
| 600 |
|
| 601 |
SdrObject* ShapeController::getLastAdditionalShape() |
| 602 |
{ |
| 603 |
SdrObject* pLastObj = nullptr; |
| 604 |
|
| 605 |
try |
| 606 |
{ |
| 607 |
DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr ); |
| 608 |
if ( pDrawModelWrapper ) |
| 609 |
{ |
| 610 |
Reference< drawing::XShape > xLastShape; |
| 611 |
rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() ); |
| 612 |
Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); |
| 613 |
sal_Int32 nCount = xDrawPage->getCount(); |
| 614 |
for ( sal_Int32 i = nCount - 1; i >= 0; --i ) |
| 615 |
{ |
| 616 |
Reference< drawing::XShape > xShape; |
| 617 |
if ( xDrawPage->getByIndex( i ) >>= xShape ) |
| 618 |
{ |
| 619 |
if ( xShape.is() && xShape != xChartRoot ) |
| 620 |
{ |
| 621 |
xLastShape = std::move(xShape); |
| 622 |
break; |
| 623 |
} |
| 624 |
} |
| 625 |
} |
| 626 |
if ( xLastShape.is() ) |
| 627 |
{ |
| 628 |
pLastObj = DrawViewWrapper::getSdrObject( xLastShape ); |
| 629 |
} |
| 630 |
} |
| 631 |
} |
| 632 |
catch ( const uno::Exception& ) |
| 633 |
{ |
| 634 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 635 |
} |
| 636 |
|
| 637 |
return pLastObj; |
| 638 |
} |
| 639 |
|
| 640 |
bool ShapeController::isBackwardPossible() |
| 641 |
{ |
| 642 |
if ( m_pChartController && m_pChartController->isAdditionalShapeSelected() ) |
| 643 |
{ |
| 644 |
SolarMutexGuard aGuard; |
| 645 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 646 |
if ( pDrawViewWrapper ) |
| 647 |
{ |
| 648 |
SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); |
| 649 |
SdrObject* pFirstObj = getFirstAdditionalShape(); |
| 650 |
if ( pSelectedObj && pFirstObj && pSelectedObj != pFirstObj ) |
| 651 |
{ |
| 652 |
return true; |
| 653 |
} |
| 654 |
} |
| 655 |
} |
| 656 |
return false; |
| 657 |
} |
| 658 |
|
| 659 |
bool ShapeController::isForwardPossible() |
| 660 |
{ |
| 661 |
if ( m_pChartController && m_pChartController->isAdditionalShapeSelected() ) |
| 662 |
{ |
| 663 |
SolarMutexGuard aGuard; |
| 664 |
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); |
| 665 |
if ( pDrawViewWrapper ) |
| 666 |
{ |
| 667 |
SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); |
| 668 |
SdrObject* pLastObj = getLastAdditionalShape(); |
| 669 |
if ( pSelectedObj && pLastObj && pSelectedObj != pLastObj ) |
| 670 |
{ |
| 671 |
return true; |
| 672 |
} |
| 673 |
} |
| 674 |
} |
| 675 |
return false; |
| 676 |
} |
| 677 |
|
| 678 |
} // namespace chart |
| 679 |
|
| 680 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |