android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / drtxtob1.cxx
blobf6301ba1b59208dc416c235d93274a92f0628a8b
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 <editeng/flstitem.hxx>
46 #include <editeng/scripttypeitem.hxx>
47 #include <editeng/writingmodeitem.hxx>
48 #include <editeng/frmdiritem.hxx>
49 #include <editeng/cmapitem.hxx>
51 #include <app.hrc>
52 #include <strings.hrc>
53 #include <sdresid.hxx>
54 #include <prlayout.hxx>
55 #include <ViewShell.hxx>
56 #include <drawdoc.hxx>
57 #include <sdpage.hxx>
58 #include <stlpool.hxx>
59 #include <stlsheet.hxx>
60 #include <OutlineView.hxx>
61 #include <Window.hxx>
62 #include <futempl.hxx>
63 #include <DrawDocShell.hxx>
64 #include <futext.hxx>
65 #include <editeng/colritem.hxx>
67 #include <memory>
69 namespace sd {
71 /**
72 * Process SfxRequests
75 void TextObjectBar::Execute( SfxRequest &rReq )
77 const SfxItemSet* pArgs = rReq.GetArgs();
78 sal_uInt16 nSlot = rReq.GetSlot();
79 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
81 std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
83 assert(mpViewShell);
85 if (OutlineView* pOView = dynamic_cast<OutlineView*>(mpView))
87 pOLV = pOView->GetViewByWindow(mpViewShell->GetActiveWindow());
88 aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
91 switch (nSlot)
93 case SID_STYLE_APPLY:
95 if( pArgs )
97 SdDrawDocument& rDoc = mpView->GetDoc();
98 assert(mpViewShell->GetViewShell());
99 rtl::Reference<FuPoor> xFunc( FuTemplate::Create( mpViewShell, static_cast< ::sd::Window*>( mpViewShell->GetViewShell()->GetWindow()), mpView, &rDoc, rReq ) );
101 if(xFunc.is())
103 xFunc->Activate();
104 xFunc->Deactivate();
106 if( rReq.GetSlot() == SID_STYLE_APPLY )
108 if (mpViewShell->GetViewFrame())
109 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
113 else
115 if (mpViewShell->GetViewFrame())
116 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON );
119 rReq.Done();
121 break;
123 case SID_INC_INDENT:
124 case SID_DEC_INDENT:
126 if( pOLV )
128 ESelection aSel = pOLV->GetSelection();
129 aSel.Adjust();
130 sal_Int32 nStartPara = aSel.nStartPara;
131 sal_Int32 nEndPara = aSel.nEndPara;
132 if( !aSel.HasRange() )
134 nStartPara = 0;
135 nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
138 pOLV->GetOutliner()->UndoActionStart( OLUNDO_ATTR );
139 for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
141 SfxStyleSheet* pStyleSheet = nullptr;
142 if (pOLV->GetOutliner() != nullptr)
143 pStyleSheet = pOLV->GetOutliner()->GetStyleSheet(nPara);
144 if (pStyleSheet != nullptr)
146 SfxItemSet aAttr( pStyleSheet->GetItemSet() );
147 SfxItemSet aTmpSet( pOLV->GetOutliner()->GetParaAttribs( nPara ) );
148 aAttr.Put( aTmpSet, false );
149 const SvxLRSpaceItem& rItem = aAttr.Get( EE_PARA_LRSPACE );
150 std::unique_ptr<SvxLRSpaceItem> pNewItem(rItem.Clone());
152 ::tools::Long nLeft = pNewItem->GetLeft();
153 if( nSlot == SID_INC_INDENT )
154 nLeft += 1000;
155 else
157 nLeft -= 1000;
158 nLeft = std::max<::tools::Long>( nLeft, 0 );
160 pNewItem->SetLeftValue( static_cast<sal_uInt16>(nLeft) );
162 SfxItemSet aNewAttrs( aAttr );
163 aNewAttrs.Put( std::move(pNewItem) );
164 pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs );
167 pOLV->GetOutliner()->UndoActionEnd();
168 mpViewShell->Invalidate( SID_UNDO );
170 rReq.Done();
172 Invalidate();
173 // to refresh preview (in outline mode), slot has to be invalidated:
174 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
177 break;
179 case SID_PARASPACE_INCREASE:
180 case SID_PARASPACE_DECREASE:
182 if( pOLV )
184 ESelection aSel = pOLV->GetSelection();
185 aSel.Adjust();
186 sal_Int32 nStartPara = aSel.nStartPara;
187 sal_Int32 nEndPara = aSel.nEndPara;
188 if( !aSel.HasRange() )
190 nStartPara = 0;
191 nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
194 pOLV->GetOutliner()->UndoActionStart( OLUNDO_ATTR );
195 for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
197 SfxStyleSheet* pStyleSheet = nullptr;
198 if (pOLV->GetOutliner() != nullptr)
199 pStyleSheet = pOLV->GetOutliner()->GetStyleSheet(nPara);
200 if (pStyleSheet != nullptr)
202 SfxItemSet aAttr( pStyleSheet->GetItemSet() );
203 SfxItemSet aTmpSet( pOLV->GetOutliner()->GetParaAttribs( nPara ) );
204 aAttr.Put( aTmpSet, false ); // sal_False= InvalidItems is not default, handle it as "holes"
205 const SvxULSpaceItem& rItem = aAttr.Get( EE_PARA_ULSPACE );
206 std::unique_ptr<SvxULSpaceItem> pNewItem(rItem.Clone());
208 ::tools::Long nUpper = pNewItem->GetUpper();
209 if( nSlot == SID_PARASPACE_INCREASE )
210 nUpper += 100;
211 else
213 nUpper -= 100;
214 nUpper = std::max<::tools::Long>( nUpper, 0 );
216 pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
218 ::tools::Long nLower = pNewItem->GetLower();
219 if( nSlot == SID_PARASPACE_INCREASE )
220 nLower += 100;
221 else
223 nLower -= 100;
224 nLower = std::max<::tools::Long>( nLower, 0 );
226 pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
228 SfxItemSet aNewAttrs( aAttr );
229 aNewAttrs.Put( std::move(pNewItem) );
230 pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs );
233 pOLV->GetOutliner()->UndoActionEnd();
234 mpViewShell->Invalidate( SID_UNDO );
236 else
238 // the following code could be enabled, if I get a correct
239 // DontCare status from JOE.
241 // gets enabled, through it doesn't really work (see above)
242 SfxItemSet aEditAttr( mpView->GetDoc().GetPool() );
243 mpView->GetAttributes( aEditAttr );
244 if( aEditAttr.GetItemState( EE_PARA_ULSPACE ) >= SfxItemState::DEFAULT )
246 SfxItemSet aNewAttrs(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
247 const SvxULSpaceItem& rItem = aEditAttr.Get( EE_PARA_ULSPACE );
248 std::unique_ptr<SvxULSpaceItem> pNewItem(rItem.Clone());
249 ::tools::Long nUpper = pNewItem->GetUpper();
251 if( nSlot == SID_PARASPACE_INCREASE )
252 nUpper += 100;
253 else
255 nUpper -= 100;
256 nUpper = std::max<::tools::Long>( nUpper, 0 );
258 pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
260 ::tools::Long nLower = pNewItem->GetLower();
261 if( nSlot == SID_PARASPACE_INCREASE )
262 nLower += 100;
263 else
265 nLower -= 100;
266 nLower = std::max<::tools::Long>( nLower, 0 );
268 pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
270 aNewAttrs.Put( std::move(pNewItem) );
272 mpView->SetAttributes( aNewAttrs );
275 rReq.Done();
277 Invalidate();
278 // to refresh preview (in outline mode), slot has to be invalidated:
279 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
280 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_PARA_ULSPACE, true );
282 break;
284 case SID_OUTLINE_LEFT:
286 if (pOLV)
288 pOLV->AdjustDepth( -1 );
290 // Ensure bold/italic etc. icon state updates
291 Invalidate();
292 // trigger preview refresh
293 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
295 rReq.Done();
297 break;
299 case SID_OUTLINE_RIGHT:
301 if (pOLV)
303 pOLV->AdjustDepth( 1 );
305 // Ensure bold/italic etc. icon state updates
306 Invalidate();
307 // trigger preview refresh
308 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
310 rReq.Done();
312 break;
314 case SID_ATTR_PARA_LRSPACE:
316 SvxLRSpaceItem aLRSpace = static_cast<const SvxLRSpaceItem&>(pArgs->Get(
317 SID_ATTR_PARA_LRSPACE));
319 SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aEditAttr( GetPool() );
320 aLRSpace.SetWhich( EE_PARA_LRSPACE );
322 aEditAttr.Put( aLRSpace );
323 mpView->SetAttributes( aEditAttr );
325 Invalidate(SID_ATTR_PARA_LRSPACE);
327 break;
329 case SID_HANGING_INDENT:
331 SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aLRSpaceSet( GetPool() );
332 mpView->GetAttributes( aLRSpaceSet );
333 SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( EE_PARA_LRSPACE ) );
335 SvxLRSpaceItem aNewMargin( EE_PARA_LRSPACE );
336 aNewMargin.SetTextLeft( aParaMargin.GetTextLeft() + aParaMargin.GetTextFirstLineOffset() );
337 aNewMargin.SetRight( aParaMargin.GetRight() );
338 aNewMargin.SetTextFirstLineOffset( ( aParaMargin.GetTextFirstLineOffset() ) * -1 );
339 aLRSpaceSet.Put( aNewMargin );
340 mpView->SetAttributes( aLRSpaceSet );
342 Invalidate(SID_ATTR_PARA_LRSPACE);
344 break;
346 case SID_OUTLINE_UP:
348 if (pOLV)
350 pOLV->AdjustHeight( -1 );
352 // trigger preview refresh
353 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
355 rReq.Done();
357 break;
359 case SID_OUTLINE_DOWN:
361 if (pOLV)
363 pOLV->AdjustHeight( 1 );
365 // trigger preview refresh
366 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
368 rReq.Done();
370 break;
372 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
373 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
375 mpView->SdrEndTextEdit();
376 // tdf#131571: SdrEndTextEdit invalidates pTextEditOutlinerView, the pointer retrieved for pOLV
377 // so reinitialize pOLV
378 pOLV=mpView->GetTextEditOutlinerView();
379 SfxItemSetFixed<SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION> aAttr( mpView->GetDoc().GetPool() );
380 aAttr.Put( SvxWritingModeItem(
381 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
382 css::text::WritingMode_LR_TB : css::text::WritingMode_TB_RL,
383 SDRATTR_TEXTDIRECTION ) );
384 rReq.Done( aAttr );
385 mpView->SetAttributes( aAttr );
386 Invalidate();
387 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
389 break;
391 case FN_NUM_BULLET_ON:
393 if (pOLV)
395 bool bMasterPage = false;
396 SdrPageView* pPageView = mpView->GetSdrPageView();
397 if (pPageView)
399 SdPage* pPage = static_cast<SdPage*>(pPageView->GetPage());
400 bMasterPage = pPage && (pPage->GetPageKind() == PageKind::Standard) && pPage->IsMasterPage();
403 if (!bMasterPage)
404 pOLV->ToggleBullets();
405 else
407 //Resolves: fdo#78151 in master pages if we toggle bullets on
408 //and off then just disable/enable the bulleting, but do not
409 //change the *level* of the paragraph, because the paragraph is
410 //effectively a preview of the equivalent style level, and
411 //changing the level disconnects it from the style
413 ::Outliner* pOL = pOLV->GetOutliner();
414 if (pOL)
416 const SvxNumBulletItem *pItem = nullptr;
417 SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool();
418 OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1");
419 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find(sStyleName, SfxStyleFamily::Pseudo);
420 if( pFirstStyleSheet )
421 pItem = pFirstStyleSheet->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET, false);
423 if (pItem )
425 SvxNumRule aNewRule(pItem->GetNumRule());
426 ESelection aSel = pOLV->GetSelection();
427 aSel.Adjust();
428 sal_Int32 nStartPara = aSel.nStartPara;
429 sal_Int32 nEndPara = aSel.nEndPara;
430 for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara)
432 sal_uInt16 nLevel = pOL->GetDepth(nPara);
433 SvxNumberFormat aFmt(aNewRule.GetLevel(nLevel));
435 if (aFmt.GetNumberingType() == SVX_NUM_NUMBER_NONE)
437 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
438 SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(nLevel, aFmt);
440 else
442 aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
443 aFmt.SetAbsLSpace(0);
444 aFmt.SetFirstLineOffset(0);
447 aNewRule.SetLevel(nLevel, aFmt);
450 pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(std::move(aNewRule), EE_PARA_NUMBULLET));
452 SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet, PresentationObjects::Outline_1, pSSPool);
457 break;
459 case SID_GROW_FONT_SIZE:
460 case SID_SHRINK_FONT_SIZE:
462 const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(mpViewShell->GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ));
463 const FontList* pFontList = pFonts ? pFonts->GetFontList(): nullptr;
464 if( pFontList )
466 FuText::ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pOLV, pFontList, mpView );
467 if( pOLV )
468 pOLV->SetAttribs( pOLV->GetEditView().GetEmptyItemSet() );
469 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
471 rReq.Done();
473 break;
475 case SID_THES:
477 OUString aReplaceText;
478 const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE);
479 if (pItem2)
480 aReplaceText = pItem2->GetValue();
481 if (!aReplaceText.isEmpty())
482 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
484 break;
486 default:
488 SfxItemSet aEditAttr( mpView->GetDoc().GetPool() );
489 mpView->GetAttributes( aEditAttr );
490 SfxItemSet aNewAttr(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
492 if( !pArgs )
494 //aNewAttr.InvalidateAllItems(); <- produces problems (#35465#)
496 switch ( nSlot )
498 case SID_ATTR_CHAR_WEIGHT:
500 FontWeight eFW = aEditAttr.Get( EE_CHAR_WEIGHT ).GetWeight();
501 aNewAttr.Put( SvxWeightItem( eFW == WEIGHT_NORMAL ?
502 WEIGHT_BOLD : WEIGHT_NORMAL,
503 EE_CHAR_WEIGHT ) );
505 break;
506 case SID_ATTR_CHAR_POSTURE:
508 FontItalic eFI = aEditAttr.Get( EE_CHAR_ITALIC ).GetPosture();
509 aNewAttr.Put( SvxPostureItem( eFI == ITALIC_NORMAL ?
510 ITALIC_NONE : ITALIC_NORMAL,
511 EE_CHAR_ITALIC ) );
513 break;
514 case SID_ATTR_CHAR_UNDERLINE:
516 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle();
517 aNewAttr.Put( SvxUnderlineItem( eFU == LINESTYLE_SINGLE ?
518 LINESTYLE_NONE : LINESTYLE_SINGLE,
519 EE_CHAR_UNDERLINE ) );
521 break;
523 case SID_ULINE_VAL_NONE:
525 aNewAttr.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
526 break;
529 case SID_ULINE_VAL_SINGLE:
530 case SID_ULINE_VAL_DOUBLE:
531 case SID_ULINE_VAL_DOTTED:
533 FontLineStyle eOld = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
534 FontLineStyle eNew = eOld;
536 switch (nSlot)
538 case SID_ULINE_VAL_SINGLE:
539 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
540 break;
541 case SID_ULINE_VAL_DOUBLE:
542 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
543 break;
544 case SID_ULINE_VAL_DOTTED:
545 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
546 break;
549 SvxUnderlineItem aUnderline(eNew, EE_CHAR_UNDERLINE);
550 aNewAttr.Put(aUnderline);
552 break;
554 case SID_ATTR_CHAR_OVERLINE:
556 FontLineStyle eFO = aEditAttr.Get( EE_CHAR_OVERLINE ).GetLineStyle();
557 aNewAttr.Put( SvxOverlineItem( eFO == LINESTYLE_SINGLE ?
558 LINESTYLE_NONE : LINESTYLE_SINGLE,
559 EE_CHAR_OVERLINE ) );
561 break;
562 case SID_ATTR_CHAR_CONTOUR:
564 aNewAttr.Put( SvxContourItem( !aEditAttr.Get( EE_CHAR_OUTLINE ).GetValue(), EE_CHAR_OUTLINE ) );
566 break;
567 case SID_ATTR_CHAR_SHADOWED:
569 aNewAttr.Put( SvxShadowedItem( !aEditAttr.Get( EE_CHAR_SHADOW ).GetValue(), EE_CHAR_SHADOW ) );
571 break;
572 case SID_ATTR_CHAR_CASEMAP:
574 aNewAttr.Put( aEditAttr.Get( EE_CHAR_CASEMAP ) );
576 break;
577 case SID_ATTR_CHAR_STRIKEOUT:
579 FontStrikeout eFSO = aEditAttr.Get( EE_CHAR_STRIKEOUT ).GetStrikeout();
580 aNewAttr.Put( SvxCrossedOutItem( eFSO == STRIKEOUT_SINGLE ?
581 STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
583 break;
585 case SID_ATTR_PARA_ADJUST_LEFT:
587 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
589 break;
590 case SID_ATTR_PARA_ADJUST_CENTER:
592 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
594 break;
595 case SID_ATTR_PARA_ADJUST_RIGHT:
597 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
599 break;
600 case SID_ATTR_PARA_ADJUST_BLOCK:
602 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Block, EE_PARA_JUST ) );
604 break;
605 case SID_ATTR_PARA_LINESPACE_10:
607 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
608 aItem.SetPropLineSpace( 100 );
609 aNewAttr.Put( aItem );
611 break;
612 case SID_ATTR_PARA_LINESPACE_15:
614 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
615 aItem.SetPropLineSpace( 150 );
616 aNewAttr.Put( aItem );
618 break;
619 case SID_ATTR_PARA_LINESPACE_20:
621 SvxLineSpacingItem aItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL );
622 aItem.SetPropLineSpace( 200 );
623 aNewAttr.Put( aItem );
625 break;
626 case SID_SET_SUPER_SCRIPT:
628 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
629 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
631 if( eEsc == SvxEscapement::Superscript )
632 aItem.SetEscapement( SvxEscapement::Off );
633 else
634 aItem.SetEscapement( SvxEscapement::Superscript );
635 aNewAttr.Put( aItem );
637 break;
638 case SID_SET_SUB_SCRIPT:
640 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
641 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
643 if( eEsc == SvxEscapement::Subscript )
644 aItem.SetEscapement( SvxEscapement::Off );
645 else
646 aItem.SetEscapement( SvxEscapement::Subscript );
647 aNewAttr.Put( aItem );
649 break;
651 // attributes for TextObjectBar
652 case SID_ATTR_CHAR_FONT:
653 mpViewShell->GetViewFrame()->GetDispatcher()->
654 Execute( SID_CHAR_DLG, SfxCallMode::ASYNCHRON );
655 break;
656 case SID_ATTR_CHAR_FONTHEIGHT:
657 mpViewShell->GetViewFrame()->GetDispatcher()->
658 Execute( SID_CHAR_DLG, SfxCallMode::ASYNCHRON );
659 break;
660 case SID_ATTR_CHAR_COLOR:
661 break;
662 // #i35937# removed need for FN_NUM_BULLET_ON handling
665 rReq.Done( aNewAttr );
666 pArgs = rReq.GetArgs();
668 else if ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ||
669 nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
671 bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
673 SvxAdjust nAdjust = SvxAdjust::Left;
674 if( const SvxAdjustItem* pAdjustItem = aEditAttr.GetItemIfSet(EE_PARA_JUST) )
675 nAdjust = pAdjustItem->GetAdjust();
677 if( bLeftToRight )
679 aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
680 if( nAdjust == SvxAdjust::Right )
681 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
683 else
685 aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) );
686 if( nAdjust == SvxAdjust::Left )
687 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
690 rReq.Done( aNewAttr );
691 pArgs = rReq.GetArgs();
693 Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
695 else if ( nSlot == SID_ATTR_CHAR_FONT ||
696 nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
697 nSlot == SID_ATTR_CHAR_POSTURE ||
698 nSlot == SID_ATTR_CHAR_WEIGHT )
700 // #i78017 establish the same behaviour as in Writer
701 SvtScriptType nScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
702 if (nSlot == SID_ATTR_CHAR_FONT)
703 nScriptType = mpView->GetScriptType();
705 SfxItemPool& rPool = mpView->GetDoc().GetPool();
706 SvxScriptSetItem aSvxScriptSetItem( nSlot, rPool );
707 aSvxScriptSetItem.PutItemForScriptType( nScriptType, pArgs->Get( rPool.GetWhich( nSlot ) ) );
708 aNewAttr.Put( aSvxScriptSetItem.GetItemSet() );
709 rReq.Done( aNewAttr );
710 pArgs = rReq.GetArgs();
712 else if (nSlot == SID_ATTR_PARA_ADJUST_LEFT ||
713 nSlot == SID_ATTR_PARA_ADJUST_CENTER ||
714 nSlot == SID_ATTR_PARA_ADJUST_RIGHT ||
715 nSlot == SID_ATTR_PARA_ADJUST_BLOCK)
717 switch( nSlot )
719 case SID_ATTR_PARA_ADJUST_LEFT:
721 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
723 break;
724 case SID_ATTR_PARA_ADJUST_CENTER:
726 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
728 break;
729 case SID_ATTR_PARA_ADJUST_RIGHT:
731 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
733 break;
734 case SID_ATTR_PARA_ADJUST_BLOCK:
736 aNewAttr.Put( SvxAdjustItem( SvxAdjust::Block, EE_PARA_JUST ) );
738 break;
740 rReq.Done( aNewAttr );
741 pArgs = rReq.GetArgs();
743 else if(nSlot == SID_ATTR_CHAR_KERNING)
745 aNewAttr.Put(pArgs->Get(pArgs->GetPool()->GetWhich(nSlot)));
746 rReq.Done( aNewAttr );
747 pArgs = rReq.GetArgs();
749 else if(nSlot == SID_SET_SUPER_SCRIPT )
751 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
752 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
754 if( eEsc == SvxEscapement::Superscript )
755 aItem.SetEscapement( SvxEscapement::Off );
756 else
757 aItem.SetEscapement( SvxEscapement::Superscript );
758 aNewAttr.Put( aItem );
759 rReq.Done( aNewAttr );
760 pArgs = rReq.GetArgs();
762 else if( nSlot == SID_SET_SUB_SCRIPT )
764 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
765 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
767 if( eEsc == SvxEscapement::Subscript )
768 aItem.SetEscapement( SvxEscapement::Off );
769 else
770 aItem.SetEscapement( SvxEscapement::Subscript );
771 aNewAttr.Put( aItem );
772 rReq.Done( aNewAttr );
773 pArgs = rReq.GetArgs();
776 std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone();
778 // Merge the color parameters to the color itself.
779 std::unique_ptr<SvxColorItem> pColorItem;
780 if (nSlot == SID_ATTR_CHAR_COLOR)
782 pColorItem = std::make_unique<SvxColorItem>(pNewArgs->Get(EE_CHAR_COLOR));
783 model::ComplexColor aComplexColor;
785 if (const SfxInt16Item* pIntItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_THEME_INDEX, false))
787 aComplexColor.setSchemeColor(model::convertToThemeColorType(pIntItem->GetValue()));
789 if (const SfxInt16Item* pIntItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_LUM_MOD, false))
791 aComplexColor.addTransformation({model::TransformationType::LumMod, pIntItem->GetValue()});
793 if (const SfxInt16Item* pIntItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_LUM_OFF, false))
795 aComplexColor.addTransformation({model::TransformationType::LumOff, pIntItem->GetValue()});
797 pColorItem->setComplexColor(aComplexColor);
798 pNewArgs->Put(std::move(pColorItem));
801 mpView->SetAttributes(*pNewArgs);
803 // invalidate entire shell because of performance and
804 // extension reasons
805 Invalidate();
807 // to refresh preview (in outline mode), slot has to be invalidated:
808 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, true );
810 break;
813 if ( nSlot != SID_STYLE_APPLY && pOLV )
815 pOLV->ShowCursor();
816 pOLV->GetWindow()->GrabFocus();
819 Invalidate( SID_OUTLINE_LEFT );
820 Invalidate( SID_OUTLINE_RIGHT );
821 Invalidate( SID_OUTLINE_UP );
822 Invalidate( SID_OUTLINE_DOWN );
825 } // end of namespace sd
827 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */