Bump version to 21.06.18.1
[LibreOffice.git] / sd / source / ui / view / drtxtob1.cxx
blob69e83e18f2dbb3ba777ef1777c40b3f102c75a77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <TextObjectBar.hxx>
22 #include <svx/svxids.hrc>
24 #include <editeng/eeitem.hxx>
25 #include <editeng/editview.hxx>
26 #include <editeng/outliner.hxx>
27 #include <editeng/ulspitem.hxx>
28 #include <editeng/lspcitem.hxx>
29 #include <editeng/adjustitem.hxx>
30 #include <editeng/numitem.hxx>
31 #include <svl/itempool.hxx>
32 #include <svl/stritem.hxx>
33 #include <svl/style.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <editeng/escapementitem.hxx>
38 #include <editeng/wghtitem.hxx>
39 #include <editeng/postitem.hxx>
40 #include <editeng/udlnitem.hxx>
41 #include <editeng/crossedoutitem.hxx>
42 #include <editeng/contouritem.hxx>
43 #include <editeng/shdditem.hxx>
44 #include <svx/svdpagv.hxx>
45 #include <svx/svdobj.hxx>
46 #include <editeng/flstitem.hxx>
47 #include <editeng/scripttypeitem.hxx>
48 #include <editeng/writingmodeitem.hxx>
49 #include <editeng/frmdiritem.hxx>
50 #include <editeng/cmapitem.hxx>
52 #include <app.hrc>
53 #include <strings.hrc>
54 #include <sdresid.hxx>
55 #include <prlayout.hxx>
56 #include <ViewShell.hxx>
57 #include <drawdoc.hxx>
58 #include <sdpage.hxx>
59 #include <stlpool.hxx>
60 #include <stlsheet.hxx>
61 #include <OutlineView.hxx>
62 #include <Window.hxx>
63 #include <futempl.hxx>
64 #include <DrawDocShell.hxx>
65 #include <futext.hxx>
66 #include <editeng/colritem.hxx>
68 #include <memory>
70 namespace
72 void lcl_convertStringArguments(sal_uInt16 nSlot, const std::unique_ptr<SfxItemSet>& pArgs)
74 Color aColor;
75 OUString sColor;
76 const SfxPoolItem* pColorStringItem = nullptr;
78 if (SfxItemState::SET != pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem))
79 return;
81 sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue();
83 if (sColor == "transparent")
84 aColor = COL_TRANSPARENT;
85 else
86 aColor = Color(sColor.toInt32(16));
88 switch (nSlot)
90 case SID_ATTR_CHAR_COLOR:
92 SvxColorItem aColorItem(aColor, EE_CHAR_COLOR);
93 pArgs->Put(aColorItem);
94 break;
97 case SID_ATTR_CHAR_BACK_COLOR:
99 SvxBackgroundColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR);
100 pArgs->Put(pBackgroundItem);
101 break;
107 namespace sd {
110 * Process SfxRequests
113 void TextObjectBar::Execute( SfxRequest &rReq )
115 const SfxItemSet* pArgs = rReq.GetArgs();
116 const SfxPoolItem* pPoolItem = nullptr;
117 sal_uInt16 nSlot = rReq.GetSlot();
118 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
120 std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
122 assert(mpViewShell);
124 if (OutlineView* pOView = dynamic_cast<OutlineView*>(mpView))
126 pOLV = pOView->GetViewByWindow(mpViewShell->GetActiveWindow());
127 aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
130 switch (nSlot)
132 case SID_STYLE_APPLY:
134 if( pArgs )
136 SdDrawDocument& rDoc = mpView->GetDoc();
137 assert(mpViewShell->GetViewShell());
138 rtl::Reference<FuPoor> xFunc( FuTemplate::Create( mpViewShell, static_cast< ::sd::Window*>( mpViewShell->GetViewShell()->GetWindow()), mpView, &rDoc, rReq ) );
140 if(xFunc.is())
142 xFunc->Activate();
143 xFunc->Deactivate();
145 if( rReq.GetSlot() == SID_STYLE_APPLY )
147 if (mpViewShell->GetViewFrame())
148 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
152 else
154 if (mpViewShell->GetViewFrame())
155 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON );
158 rReq.Done();
160 break;
162 case SID_INC_INDENT:
163 case SID_DEC_INDENT:
165 if( pOLV )
167 ESelection aSel = pOLV->GetSelection();
168 aSel.Adjust();
169 sal_Int32 nStartPara = aSel.nStartPara;
170 sal_Int32 nEndPara = aSel.nEndPara;
171 if( !aSel.HasRange() )
173 nStartPara = 0;
174 nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
177 pOLV->GetOutliner()->UndoActionStart( OLUNDO_ATTR );
178 for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
180 SfxStyleSheet* pStyleSheet = nullptr;
181 if (pOLV->GetOutliner() != nullptr)
182 pStyleSheet = pOLV->GetOutliner()->GetStyleSheet(nPara);
183 if (pStyleSheet != nullptr)
185 SfxItemSet aAttr( pStyleSheet->GetItemSet() );
186 SfxItemSet aTmpSet( pOLV->GetOutliner()->GetParaAttribs( nPara ) );
187 aAttr.Put( aTmpSet, false );
188 const SvxLRSpaceItem& rItem = aAttr.Get( EE_PARA_LRSPACE );
189 std::unique_ptr<SvxLRSpaceItem> pNewItem(rItem.Clone());
191 ::tools::Long nLeft = pNewItem->GetLeft();
192 if( nSlot == SID_INC_INDENT )
193 nLeft += 1000;
194 else
196 nLeft -= 1000;
197 nLeft = std::max<::tools::Long>( nLeft, 0 );
199 pNewItem->SetLeftValue( static_cast<sal_uInt16>(nLeft) );
201 SfxItemSet aNewAttrs( aAttr );
202 aNewAttrs.Put( *pNewItem );
203 pNewItem.reset();
204 pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs );
207 pOLV->GetOutliner()->UndoActionEnd();
208 mpViewShell->Invalidate( SID_UNDO );
210 rReq.Done();
212 Invalidate();
213 // to refresh preview (in outline mode), slot has to be invalidated:
214 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
217 break;
219 case SID_PARASPACE_INCREASE:
220 case SID_PARASPACE_DECREASE:
222 if( pOLV )
224 ESelection aSel = pOLV->GetSelection();
225 aSel.Adjust();
226 sal_Int32 nStartPara = aSel.nStartPara;
227 sal_Int32 nEndPara = aSel.nEndPara;
228 if( !aSel.HasRange() )
230 nStartPara = 0;
231 nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
234 pOLV->GetOutliner()->UndoActionStart( OLUNDO_ATTR );
235 for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
237 SfxStyleSheet* pStyleSheet = nullptr;
238 if (pOLV->GetOutliner() != nullptr)
239 pStyleSheet = pOLV->GetOutliner()->GetStyleSheet(nPara);
240 if (pStyleSheet != nullptr)
242 SfxItemSet aAttr( pStyleSheet->GetItemSet() );
243 SfxItemSet aTmpSet( pOLV->GetOutliner()->GetParaAttribs( nPara ) );
244 aAttr.Put( aTmpSet, false ); // sal_False= InvalidItems is not default, handle it as "holes"
245 const SvxULSpaceItem& rItem = aAttr.Get( EE_PARA_ULSPACE );
246 std::unique_ptr<SvxULSpaceItem> pNewItem(rItem.Clone());
248 ::tools::Long nUpper = pNewItem->GetUpper();
249 if( nSlot == SID_PARASPACE_INCREASE )
250 nUpper += 100;
251 else
253 nUpper -= 100;
254 nUpper = std::max<::tools::Long>( nUpper, 0 );
256 pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
258 ::tools::Long nLower = pNewItem->GetLower();
259 if( nSlot == SID_PARASPACE_INCREASE )
260 nLower += 100;
261 else
263 nLower -= 100;
264 nLower = std::max<::tools::Long>( nLower, 0 );
266 pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
268 SfxItemSet aNewAttrs( aAttr );
269 aNewAttrs.Put( *pNewItem );
270 pNewItem.reset();
271 pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs );
274 pOLV->GetOutliner()->UndoActionEnd();
275 mpViewShell->Invalidate( SID_UNDO );
277 else
279 // the following code could be enabled, if I get a correct
280 // DontCare status from JOE.
282 // gets enabled, through it doesn't really work (see above)
283 SfxItemSet aEditAttr( mpView->GetDoc().GetPool() );
284 mpView->GetAttributes( aEditAttr );
285 if( aEditAttr.GetItemState( EE_PARA_ULSPACE ) >= SfxItemState::DEFAULT )
287 SfxItemSet aNewAttrs(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
288 const SvxULSpaceItem& rItem = aEditAttr.Get( EE_PARA_ULSPACE );
289 std::unique_ptr<SvxULSpaceItem> pNewItem(rItem.Clone());
290 ::tools::Long nUpper = pNewItem->GetUpper();
292 if( nSlot == SID_PARASPACE_INCREASE )
293 nUpper += 100;
294 else
296 nUpper -= 100;
297 nUpper = std::max<::tools::Long>( nUpper, 0 );
299 pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
301 ::tools::Long nLower = pNewItem->GetLower();
302 if( nSlot == SID_PARASPACE_INCREASE )
303 nLower += 100;
304 else
306 nLower -= 100;
307 nLower = std::max<::tools::Long>( nLower, 0 );
309 pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
311 aNewAttrs.Put( *pNewItem );
312 pNewItem.reset();
314 mpView->SetAttributes( aNewAttrs );
317 rReq.Done();
319 Invalidate();
320 // to refresh preview (in outline mode), slot has to be invalidated:
321 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
322 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_PARA_ULSPACE, true );
324 break;
326 case SID_OUTLINE_LEFT:
328 if (pOLV)
330 pOLV->AdjustDepth( -1 );
332 // Ensure bold/italic etc. icon state updates
333 Invalidate();
334 // trigger preview refresh
335 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
337 rReq.Done();
339 break;
341 case SID_OUTLINE_RIGHT:
343 if (pOLV)
345 pOLV->AdjustDepth( 1 );
347 // Ensure bold/italic etc. icon state updates
348 Invalidate();
349 // trigger preview refresh
350 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
352 rReq.Done();
354 break;
356 case SID_ATTR_PARA_LRSPACE:
358 SvxLRSpaceItem aLRSpace = static_cast<const SvxLRSpaceItem&>(pArgs->Get(
359 GetPool().GetWhich(SID_ATTR_PARA_LRSPACE)));
361 SfxItemSet aEditAttr( GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
362 aLRSpace.SetWhich( EE_PARA_LRSPACE );
364 aEditAttr.Put( aLRSpace );
365 mpView->SetAttributes( aEditAttr );
367 Invalidate(SID_ATTR_PARA_LRSPACE);
369 break;
371 case SID_HANGING_INDENT:
373 SfxItemSet aLRSpaceSet( GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
374 mpView->GetAttributes( aLRSpaceSet );
375 SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( EE_PARA_LRSPACE ) );
377 SvxLRSpaceItem aNewMargin( EE_PARA_LRSPACE );
378 aNewMargin.SetTextLeft( aParaMargin.GetTextLeft() + aParaMargin.GetTextFirstLineOffset() );
379 aNewMargin.SetRight( aParaMargin.GetRight() );
380 aNewMargin.SetTextFirstLineOffset( ( aParaMargin.GetTextFirstLineOffset() ) * -1 );
381 aLRSpaceSet.Put( aNewMargin );
382 mpView->SetAttributes( aLRSpaceSet );
384 Invalidate(SID_ATTR_PARA_LRSPACE);
386 break;
388 case SID_OUTLINE_UP:
390 if (pOLV)
392 pOLV->AdjustHeight( -1 );
394 // trigger preview refresh
395 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
397 rReq.Done();
399 break;
401 case SID_OUTLINE_DOWN:
403 if (pOLV)
405 pOLV->AdjustHeight( 1 );
407 // trigger preview refresh
408 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
410 rReq.Done();
412 break;
414 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
415 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
417 mpView->SdrEndTextEdit();
418 // tdf#131571: SdrEndTextEdit invalidates pTextEditOutlinerView, the pointer retrieved for pOLV
419 // so reinitialize pOLV
420 pOLV=mpView->GetTextEditOutlinerView();
421 SfxItemSet aAttr( mpView->GetDoc().GetPool(), svl::Items<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION>{} );
422 aAttr.Put( SvxWritingModeItem(
423 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
424 css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL,
425 SDRATTR_TEXTDIRECTION ) );
426 rReq.Done( aAttr );
427 mpView->SetAttributes( aAttr );
428 Invalidate();
429 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
431 break;
433 case FN_NUM_BULLET_ON:
435 if (pOLV)
437 bool bMasterPage = false;
438 SdrPageView* pPageView = mpView->GetSdrPageView();
439 if (pPageView)
441 SdPage* pPage = static_cast<SdPage*>(pPageView->GetPage());
442 bMasterPage = pPage && (pPage->GetPageKind() == PageKind::Standard) && pPage->IsMasterPage();
445 if (!bMasterPage)
446 pOLV->ToggleBullets();
447 else
449 //Resolves: fdo#78151 in master pages if we toggle bullets on
450 //and off then just disable/enable the bulleting, but do not
451 //change the *level* of the paragraph, because the paragraph is
452 //effectively a preview of the equivalent style level, and
453 //changing the level disconnects it from the style
455 ::Outliner* pOL = pOLV->GetOutliner();
456 if (pOL)
458 const SvxNumBulletItem *pItem = nullptr;
459 SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool();
460 OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1");
461 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find(sStyleName, SfxStyleFamily::Pseudo);
462 if( pFirstStyleSheet )
463 pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, false, reinterpret_cast<const SfxPoolItem**>(&pItem));
465 if (pItem )
467 SvxNumRule aNewRule(*pItem->GetNumRule());
468 ESelection aSel = pOLV->GetSelection();
469 aSel.Adjust();
470 sal_Int32 nStartPara = aSel.nStartPara;
471 sal_Int32 nEndPara = aSel.nEndPara;
472 for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara)
474 sal_uInt16 nLevel = pOL->GetDepth(nPara);
475 SvxNumberFormat aFmt(aNewRule.GetLevel(nLevel));
477 if (aFmt.GetNumberingType() == SVX_NUM_NUMBER_NONE)
479 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
480 SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(nLevel, aFmt);
482 else
484 aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
485 aFmt.SetAbsLSpace(0);
486 aFmt.SetFirstLineOffset(0);
489 aNewRule.SetLevel(nLevel, aFmt);
492 pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET));
494 SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet, PresentationObjects::Outline_1, pSSPool);
499 break;
501 case SID_GROW_FONT_SIZE:
502 case SID_SHRINK_FONT_SIZE:
504 const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(mpViewShell->GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ));
505 const FontList* pFontList = pFonts ? pFonts->GetFontList(): nullptr;
506 if( pFontList )
508 FuText::ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pOLV, pFontList, mpView );
509 if( pOLV )
510 pOLV->SetAttribs( pOLV->GetEditView().GetEmptyItemSet() );
511 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
513 rReq.Done();
515 break;
517 case SID_THES:
519 OUString aReplaceText;
520 const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(SID_THES);
521 if (pItem2)
522 aReplaceText = pItem2->GetValue();
523 if (!aReplaceText.isEmpty())
524 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
526 break;
528 default:
530 SfxItemSet aEditAttr( mpView->GetDoc().GetPool() );
531 mpView->GetAttributes( aEditAttr );
532 SfxItemSet aNewAttr(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
534 if( !pArgs )
536 //aNewAttr.InvalidateAllItems(); <- produces problems (#35465#)
538 switch ( nSlot )
540 case SID_ATTR_CHAR_WEIGHT:
542 FontWeight eFW = aEditAttr.Get( EE_CHAR_WEIGHT ).GetWeight();
543 aNewAttr.Put( SvxWeightItem( eFW == WEIGHT_NORMAL ?
544 WEIGHT_BOLD : WEIGHT_NORMAL,
545 EE_CHAR_WEIGHT ) );
547 break;
548 case SID_ATTR_CHAR_POSTURE:
550 FontItalic eFI = aEditAttr.Get( EE_CHAR_ITALIC ).GetPosture();
551 aNewAttr.Put( SvxPostureItem( eFI == ITALIC_NORMAL ?
552 ITALIC_NONE : ITALIC_NORMAL,
553 EE_CHAR_ITALIC ) );
555 break;
556 case SID_ATTR_CHAR_UNDERLINE:
558 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle();
559 aNewAttr.Put( SvxUnderlineItem( eFU == LINESTYLE_SINGLE ?
560 LINESTYLE_NONE : LINESTYLE_SINGLE,
561 EE_CHAR_UNDERLINE ) );
563 break;
565 case SID_ULINE_VAL_NONE:
567 aNewAttr.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
568 break;
571 case SID_ULINE_VAL_SINGLE:
572 case SID_ULINE_VAL_DOUBLE:
573 case SID_ULINE_VAL_DOTTED:
575 FontLineStyle eOld = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
576 FontLineStyle eNew = eOld;
578 switch (nSlot)
580 case SID_ULINE_VAL_SINGLE:
581 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
582 break;
583 case SID_ULINE_VAL_DOUBLE:
584 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
585 break;
586 case SID_ULINE_VAL_DOTTED:
587 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
588 break;
591 SvxUnderlineItem aUnderline(eNew, EE_CHAR_UNDERLINE);
592 aNewAttr.Put(aUnderline);
594 break;
596 case SID_ATTR_CHAR_OVERLINE:
598 FontLineStyle eFO = aEditAttr.Get( EE_CHAR_OVERLINE ).GetLineStyle();
599 aNewAttr.Put( SvxOverlineItem( eFO == LINESTYLE_SINGLE ?
600 LINESTYLE_NONE : LINESTYLE_SINGLE,
601 EE_CHAR_OVERLINE ) );
603 break;
604 case SID_ATTR_CHAR_CONTOUR:
606 aNewAttr.Put( SvxContourItem( !aEditAttr.Get( EE_CHAR_OUTLINE ).GetValue(), EE_CHAR_OUTLINE ) );
608 break;
609 case SID_ATTR_CHAR_SHADOWED:
611 aNewAttr.Put( SvxShadowedItem( !aEditAttr.Get( EE_CHAR_SHADOW ).GetValue(), EE_CHAR_SHADOW ) );
613 break;
614 case SID_ATTR_CHAR_CASEMAP:
616 aNewAttr.Put( aEditAttr.Get( EE_CHAR_CASEMAP ) );
618 break;
619 case SID_ATTR_CHAR_STRIKEOUT:
621 FontStrikeout eFSO = aEditAttr.Get( EE_CHAR_STRIKEOUT ).GetStrikeout();
622 aNewAttr.Put( SvxCrossedOutItem( eFSO == STRIKEOUT_SINGLE ?
623 STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
625 break;
627 case SID_ATTR_PARA_ADJUST_LEFT:
629 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
631 break;
632 case SID_ATTR_PARA_ADJUST_CENTER:
634 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
636 break;
637 case SID_ATTR_PARA_ADJUST_RIGHT:
639 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
641 break;
642 case SID_ATTR_PARA_ADJUST_BLOCK:
644 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Block, EE_PARA_JUST ) );
646 break;
647 case SID_ATTR_PARA_LINESPACE_10:
649 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
650 aItem.SetPropLineSpace( 100 );
651 aNewAttr.Put( aItem );
653 break;
654 case SID_ATTR_PARA_LINESPACE_15:
656 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
657 aItem.SetPropLineSpace( 150 );
658 aNewAttr.Put( aItem );
660 break;
661 case SID_ATTR_PARA_LINESPACE_20:
663 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
664 aItem.SetPropLineSpace( 200 );
665 aNewAttr.Put( aItem );
667 break;
668 case SID_SET_SUPER_SCRIPT:
670 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
671 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
673 if( eEsc == SvxEscapement::Superscript )
674 aItem.SetEscapement( SvxEscapement::Off );
675 else
676 aItem.SetEscapement( SvxEscapement::Superscript );
677 aNewAttr.Put( aItem );
679 break;
680 case SID_SET_SUB_SCRIPT:
682 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
683 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
685 if( eEsc == SvxEscapement::Subscript )
686 aItem.SetEscapement( SvxEscapement::Off );
687 else
688 aItem.SetEscapement( SvxEscapement::Subscript );
689 aNewAttr.Put( aItem );
691 break;
693 // attributes for TextObjectBar
694 case SID_ATTR_CHAR_FONT:
695 mpViewShell->GetViewFrame()->GetDispatcher()->
696 Execute( SID_CHAR_DLG, SfxCallMode::ASYNCHRON );
697 break;
698 case SID_ATTR_CHAR_FONTHEIGHT:
699 mpViewShell->GetViewFrame()->GetDispatcher()->
700 Execute( SID_CHAR_DLG, SfxCallMode::ASYNCHRON );
701 break;
702 case SID_ATTR_CHAR_COLOR:
703 break;
704 // #i35937# removed need for FN_NUM_BULLET_ON handling
707 rReq.Done( aNewAttr );
708 pArgs = rReq.GetArgs();
710 else if ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ||
711 nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
713 bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
715 SvxAdjust nAdjust = SvxAdjust::Left;
716 if( SfxItemState::SET == aEditAttr.GetItemState(EE_PARA_JUST, true, &pPoolItem ) )
717 nAdjust = static_cast<const SvxAdjustItem*>(pPoolItem)->GetAdjust();
719 if( bLeftToRight )
721 aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
722 if( nAdjust == SvxAdjust::Right )
723 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
725 else
727 aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) );
728 if( nAdjust == SvxAdjust::Left )
729 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
732 rReq.Done( aNewAttr );
733 pArgs = rReq.GetArgs();
735 Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
737 else if ( nSlot == SID_ATTR_CHAR_FONT ||
738 nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
739 nSlot == SID_ATTR_CHAR_POSTURE ||
740 nSlot == SID_ATTR_CHAR_WEIGHT )
742 // #i78017 establish the same behaviour as in Writer
743 SvtScriptType nScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
744 if (nSlot == SID_ATTR_CHAR_FONT)
745 nScriptType = mpView->GetScriptType();
747 SfxItemPool& rPool = mpView->GetDoc().GetPool();
748 SvxScriptSetItem aSvxScriptSetItem( nSlot, rPool );
749 aSvxScriptSetItem.PutItemForScriptType( nScriptType, pArgs->Get( rPool.GetWhich( nSlot ) ) );
750 aNewAttr.Put( aSvxScriptSetItem.GetItemSet() );
751 rReq.Done( aNewAttr );
752 pArgs = rReq.GetArgs();
754 else if (nSlot == SID_ATTR_PARA_ADJUST_LEFT ||
755 nSlot == SID_ATTR_PARA_ADJUST_CENTER ||
756 nSlot == SID_ATTR_PARA_ADJUST_RIGHT ||
757 nSlot == SID_ATTR_PARA_ADJUST_BLOCK)
759 switch( nSlot )
761 case SID_ATTR_PARA_ADJUST_LEFT:
763 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
765 break;
766 case SID_ATTR_PARA_ADJUST_CENTER:
768 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
770 break;
771 case SID_ATTR_PARA_ADJUST_RIGHT:
773 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
775 break;
776 case SID_ATTR_PARA_ADJUST_BLOCK:
778 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Block, EE_PARA_JUST ) );
780 break;
782 rReq.Done( aNewAttr );
783 pArgs = rReq.GetArgs();
785 else if(nSlot == SID_ATTR_CHAR_KERNING)
787 aNewAttr.Put(pArgs->Get(pArgs->GetPool()->GetWhich(nSlot)));
788 rReq.Done( aNewAttr );
789 pArgs = rReq.GetArgs();
791 else if(nSlot == SID_SET_SUPER_SCRIPT )
793 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
794 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
796 if( eEsc == SvxEscapement::Superscript )
797 aItem.SetEscapement( SvxEscapement::Off );
798 else
799 aItem.SetEscapement( SvxEscapement::Superscript );
800 aNewAttr.Put( aItem );
801 rReq.Done( aNewAttr );
802 pArgs = rReq.GetArgs();
804 else if( nSlot == SID_SET_SUB_SCRIPT )
806 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
807 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
809 if( eEsc == SvxEscapement::Subscript )
810 aItem.SetEscapement( SvxEscapement::Off );
811 else
812 aItem.SetEscapement( SvxEscapement::Subscript );
813 aNewAttr.Put( aItem );
814 rReq.Done( aNewAttr );
815 pArgs = rReq.GetArgs();
818 std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone();
819 lcl_convertStringArguments(nSlot, pNewArgs);
820 mpView->SetAttributes(*pNewArgs);
822 // invalidate entire shell because of performance and
823 // extension reasons
824 Invalidate();
826 // to refresh preview (in outline mode), slot has to be invalidated:
827 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
829 break;
832 if ( nSlot != SID_STYLE_APPLY && pOLV )
834 pOLV->ShowCursor();
835 pOLV->GetWindow()->GrabFocus();
838 Invalidate( SID_OUTLINE_LEFT );
839 Invalidate( SID_OUTLINE_RIGHT );
840 Invalidate( SID_OUTLINE_UP );
841 Invalidate( SID_OUTLINE_DOWN );
844 } // end of namespace sd
846 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */