1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
52 #include <strings.hrc>
53 #include <sdresid.hxx>
54 #include <prlayout.hxx>
55 #include <ViewShell.hxx>
56 #include <drawdoc.hxx>
58 #include <stlpool.hxx>
59 #include <stlsheet.hxx>
60 #include <OutlineView.hxx>
62 #include <futempl.hxx>
63 #include <DrawDocShell.hxx>
65 #include <editeng/colritem.hxx>
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
;
85 if (OutlineView
* pOView
= dynamic_cast<OutlineView
*>(mpView
))
87 pOLV
= pOView
->GetViewByWindow(mpViewShell
->GetActiveWindow());
88 aGuard
.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView
&>(*mpView
) ) );
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
) );
106 if( rReq
.GetSlot() == SID_STYLE_APPLY
)
108 if (mpViewShell
->GetViewFrame())
109 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY
);
115 if (mpViewShell
->GetViewFrame())
116 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER
, SfxCallMode::ASYNCHRON
);
128 ESelection aSel
= pOLV
->GetSelection();
130 sal_Int32 nStartPara
= aSel
.nStartPara
;
131 sal_Int32 nEndPara
= aSel
.nEndPara
;
132 if( !aSel
.HasRange() )
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
)
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
);
173 // to refresh preview (in outline mode), slot has to be invalidated:
174 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
179 case SID_PARASPACE_INCREASE
:
180 case SID_PARASPACE_DECREASE
:
184 ESelection aSel
= pOLV
->GetSelection();
186 sal_Int32 nStartPara
= aSel
.nStartPara
;
187 sal_Int32 nEndPara
= aSel
.nEndPara
;
188 if( !aSel
.HasRange() )
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
)
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
)
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
);
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
)
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
)
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
);
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 );
284 case SID_OUTLINE_LEFT
:
288 pOLV
->AdjustDepth( -1 );
290 // Ensure bold/italic etc. icon state updates
292 // trigger preview refresh
293 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
299 case SID_OUTLINE_RIGHT
:
303 pOLV
->AdjustDepth( 1 );
305 // Ensure bold/italic etc. icon state updates
307 // trigger preview refresh
308 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
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
);
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
);
350 pOLV
->AdjustHeight( -1 );
352 // trigger preview refresh
353 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
359 case SID_OUTLINE_DOWN
:
363 pOLV
->AdjustHeight( 1 );
365 // trigger preview refresh
366 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
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
) );
385 mpView
->SetAttributes( aAttr
);
387 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
391 case FN_NUM_BULLET_ON
:
395 bool bMasterPage
= false;
396 SdrPageView
* pPageView
= mpView
->GetSdrPageView();
399 SdPage
* pPage
= static_cast<SdPage
*>(pPageView
->GetPage());
400 bMasterPage
= pPage
&& (pPage
->GetPageKind() == PageKind::Standard
) && pPage
->IsMasterPage();
404 pOLV
->ToggleBullets();
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();
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);
425 SvxNumRule
aNewRule(pItem
->GetNumRule());
426 ESelection aSel
= pOLV
->GetSelection();
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
);
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
);
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;
466 FuText::ChangeFontSize( nSlot
== SID_GROW_FONT_SIZE
, pOLV
, pFontList
, mpView
);
468 pOLV
->SetAttribs( pOLV
->GetEditView().GetEmptyItemSet() );
469 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT
);
477 OUString aReplaceText
;
478 const SfxStringItem
* pItem2
= rReq
.GetArg(FN_PARAM_THES_WORD_REPLACE
);
480 aReplaceText
= pItem2
->GetValue();
481 if (!aReplaceText
.isEmpty())
482 ReplaceTextWithSynonym( pOLV
->GetEditView(), aReplaceText
);
488 SfxItemSet
aEditAttr( mpView
->GetDoc().GetPool() );
489 mpView
->GetAttributes( aEditAttr
);
490 SfxItemSet
aNewAttr(*(aEditAttr
.GetPool()), aEditAttr
.GetRanges());
494 //aNewAttr.InvalidateAllItems(); <- produces problems (#35465#)
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
,
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
,
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
) );
523 case SID_ULINE_VAL_NONE
:
525 aNewAttr
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
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
;
538 case SID_ULINE_VAL_SINGLE
:
539 eNew
= ( eOld
== LINESTYLE_SINGLE
) ? LINESTYLE_NONE
: LINESTYLE_SINGLE
;
541 case SID_ULINE_VAL_DOUBLE
:
542 eNew
= ( eOld
== LINESTYLE_DOUBLE
) ? LINESTYLE_NONE
: LINESTYLE_DOUBLE
;
544 case SID_ULINE_VAL_DOTTED
:
545 eNew
= ( eOld
== LINESTYLE_DOTTED
) ? LINESTYLE_NONE
: LINESTYLE_DOTTED
;
549 SvxUnderlineItem
aUnderline(eNew
, EE_CHAR_UNDERLINE
);
550 aNewAttr
.Put(aUnderline
);
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
) );
562 case SID_ATTR_CHAR_CONTOUR
:
564 aNewAttr
.Put( SvxContourItem( !aEditAttr
.Get( EE_CHAR_OUTLINE
).GetValue(), EE_CHAR_OUTLINE
) );
567 case SID_ATTR_CHAR_SHADOWED
:
569 aNewAttr
.Put( SvxShadowedItem( !aEditAttr
.Get( EE_CHAR_SHADOW
).GetValue(), EE_CHAR_SHADOW
) );
572 case SID_ATTR_CHAR_CASEMAP
:
574 aNewAttr
.Put( aEditAttr
.Get( EE_CHAR_CASEMAP
) );
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
) );
585 case SID_ATTR_PARA_ADJUST_LEFT
:
587 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Left
, EE_PARA_JUST
) );
590 case SID_ATTR_PARA_ADJUST_CENTER
:
592 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Center
, EE_PARA_JUST
) );
595 case SID_ATTR_PARA_ADJUST_RIGHT
:
597 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Right
, EE_PARA_JUST
) );
600 case SID_ATTR_PARA_ADJUST_BLOCK
:
602 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Block
, EE_PARA_JUST
) );
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
);
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
);
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
);
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
);
634 aItem
.SetEscapement( SvxEscapement::Superscript
);
635 aNewAttr
.Put( aItem
);
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
);
646 aItem
.SetEscapement( SvxEscapement::Subscript
);
647 aNewAttr
.Put( aItem
);
651 // attributes for TextObjectBar
652 case SID_ATTR_CHAR_FONT
:
653 mpViewShell
->GetViewFrame()->GetDispatcher()->
654 Execute( SID_CHAR_DLG
, SfxCallMode::ASYNCHRON
);
656 case SID_ATTR_CHAR_FONTHEIGHT
:
657 mpViewShell
->GetViewFrame()->GetDispatcher()->
658 Execute( SID_CHAR_DLG
, SfxCallMode::ASYNCHRON
);
660 case SID_ATTR_CHAR_COLOR
:
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();
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
) );
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
)
719 case SID_ATTR_PARA_ADJUST_LEFT
:
721 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Left
, EE_PARA_JUST
) );
724 case SID_ATTR_PARA_ADJUST_CENTER
:
726 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Center
, EE_PARA_JUST
) );
729 case SID_ATTR_PARA_ADJUST_RIGHT
:
731 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Right
, EE_PARA_JUST
) );
734 case SID_ATTR_PARA_ADJUST_BLOCK
:
736 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Block
, EE_PARA_JUST
) );
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
);
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
);
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
807 // to refresh preview (in outline mode), slot has to be invalidated:
808 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
813 if ( nSlot
!= SID_STYLE_APPLY
&& pOLV
)
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: */