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/namedcolor.hxx>
35 #include <sfx2/request.hxx>
36 #include <sfx2/viewfrm.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <editeng/escapementitem.hxx>
39 #include <editeng/wghtitem.hxx>
40 #include <editeng/postitem.hxx>
41 #include <editeng/udlnitem.hxx>
42 #include <editeng/crossedoutitem.hxx>
43 #include <editeng/contouritem.hxx>
44 #include <editeng/shdditem.hxx>
45 #include <svx/svdpagv.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>
51 #include <editeng/tstpitem.hxx>
54 #include <strings.hrc>
55 #include <sdresid.hxx>
56 #include <prlayout.hxx>
57 #include <ViewShell.hxx>
58 #include <drawdoc.hxx>
60 #include <stlpool.hxx>
61 #include <stlsheet.hxx>
62 #include <OutlineView.hxx>
64 #include <futempl.hxx>
65 #include <DrawDocShell.hxx>
67 #include <editeng/colritem.hxx>
76 void TextObjectBar::Execute(SfxRequest
& rReq
)
78 ExecuteImpl(mpViewShell
, mpView
, rReq
, this);
81 void TextObjectBar::ExecuteImpl(ViewShell
* mpViewShell
, ::sd::View
* mpView
, SfxRequest
& rReq
, SfxShell
* pTextObjectBar
)
83 const SfxItemSet
* pArgs
= rReq
.GetArgs();
84 sal_uInt16 nSlot
= rReq
.GetSlot();
85 OutlinerView
* pOLV
= mpView
->GetTextEditOutlinerView();
87 // Default indent used e.g. in SID_DEC_INDENT, SID_INC_INDENT and SID_HANGING_INDENT
88 const ::tools::Long nIndentDefaultDist
= 1000; // 1000 twips
90 std::unique_ptr
<OutlineViewModelChangeGuard
, o3tl::default_delete
<OutlineViewModelChangeGuard
>> aGuard
;
94 if (OutlineView
* pOView
= dynamic_cast<OutlineView
*>(mpView
))
96 pOLV
= pOView
->GetViewByWindow(mpViewShell
->GetActiveWindow());
97 aGuard
.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView
&>(*mpView
) ) );
102 case SID_STYLE_APPLY
:
106 SdDrawDocument
& rDoc
= mpView
->GetDoc();
107 assert(mpViewShell
->GetViewShell());
108 rtl::Reference
<FuPoor
> xFunc( FuTemplate::Create( mpViewShell
, static_cast< ::sd::Window
*>( mpViewShell
->GetViewShell()->GetWindow()), mpView
, &rDoc
, rReq
) );
115 if( rReq
.GetSlot() == SID_STYLE_APPLY
)
117 if (mpViewShell
->GetViewFrame())
118 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY
);
124 if (mpViewShell
->GetViewFrame())
125 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER
, SfxCallMode::ASYNCHRON
);
137 ESelection aSel
= pOLV
->GetSelection();
139 sal_Int32 nStartPara
= aSel
.start
.nPara
;
140 sal_Int32 nEndPara
= aSel
.end
.nPara
;
141 if( !aSel
.HasRange() )
144 nEndPara
= pOLV
->GetOutliner()->GetParagraphCount() - 1;
147 pOLV
->GetOutliner()->UndoActionStart( OLUNDO_ATTR
);
148 for( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; nPara
++ )
150 SfxStyleSheet
* pStyleSheet
= nullptr;
151 if (pOLV
->GetOutliner() != nullptr)
152 pStyleSheet
= pOLV
->GetOutliner()->GetStyleSheet(nPara
);
153 if (pStyleSheet
!= nullptr)
155 SfxItemSet
aAttr( pStyleSheet
->GetItemSet() );
156 SfxItemSet
aTmpSet( pOLV
->GetOutliner()->GetParaAttribs( nPara
) );
157 aAttr
.Put( aTmpSet
, false );
158 const SvxLRSpaceItem
& rItem
= aAttr
.Get( EE_PARA_LRSPACE
);
159 std::unique_ptr
<SvxLRSpaceItem
> pNewItem(rItem
.Clone());
161 ::tools::Long nLeft
= pNewItem
->ResolveLeft({});
162 if( nSlot
== SID_INC_INDENT
)
163 nLeft
+= nIndentDefaultDist
;
166 nLeft
-= nIndentDefaultDist
;
167 nLeft
= std::max
<::tools::Long
>( nLeft
, 0 );
169 pNewItem
->SetLeft(SvxIndentValue::twips(static_cast<sal_uInt16
>(nLeft
)));
171 aAttr
.Put( std::move(pNewItem
) );
172 pOLV
->GetOutliner()->SetParaAttribs( nPara
, aAttr
);
175 pOLV
->GetOutliner()->UndoActionEnd();
176 mpViewShell
->Invalidate( SID_UNDO
);
181 pTextObjectBar
->Invalidate();
182 // to refresh preview (in outline mode), slot has to be invalidated:
183 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
188 case SID_PARASPACE_INCREASE
:
189 case SID_PARASPACE_DECREASE
:
193 ESelection aSel
= pOLV
->GetSelection();
195 sal_Int32 nStartPara
= aSel
.start
.nPara
;
196 sal_Int32 nEndPara
= aSel
.end
.nPara
;
197 if( !aSel
.HasRange() )
200 nEndPara
= pOLV
->GetOutliner()->GetParagraphCount() - 1;
203 pOLV
->GetOutliner()->UndoActionStart( OLUNDO_ATTR
);
204 for( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; nPara
++ )
206 SfxStyleSheet
* pStyleSheet
= nullptr;
207 if (pOLV
->GetOutliner() != nullptr)
208 pStyleSheet
= pOLV
->GetOutliner()->GetStyleSheet(nPara
);
209 if (pStyleSheet
!= nullptr)
211 SfxItemSet
aAttr( pStyleSheet
->GetItemSet() );
212 SfxItemSet
aTmpSet( pOLV
->GetOutliner()->GetParaAttribs( nPara
) );
213 aAttr
.Put( aTmpSet
, false ); // sal_False= InvalidItems is not default, handle it as "holes"
214 const SvxULSpaceItem
& rItem
= aAttr
.Get( EE_PARA_ULSPACE
);
215 std::unique_ptr
<SvxULSpaceItem
> pNewItem(rItem
.Clone());
217 ::tools::Long nUpper
= pNewItem
->GetUpper();
218 if( nSlot
== SID_PARASPACE_INCREASE
)
223 nUpper
= std::max
<::tools::Long
>( nUpper
, 0 );
225 pNewItem
->SetUpper( static_cast<sal_uInt16
>(nUpper
) );
227 ::tools::Long nLower
= pNewItem
->GetLower();
228 if( nSlot
== SID_PARASPACE_INCREASE
)
233 nLower
= std::max
<::tools::Long
>( nLower
, 0 );
235 pNewItem
->SetLower( static_cast<sal_uInt16
>(nLower
) );
237 SfxItemSet
aNewAttrs(std::move(aAttr
));
238 aNewAttrs
.Put( std::move(pNewItem
) );
239 pOLV
->GetOutliner()->SetParaAttribs( nPara
, aNewAttrs
);
242 pOLV
->GetOutliner()->UndoActionEnd();
243 mpViewShell
->Invalidate( SID_UNDO
);
247 // the following code could be enabled, if I get a correct
248 // DontCare status from JOE.
250 // gets enabled, through it doesn't really work (see above)
251 SfxItemSet
aEditAttr( mpView
->GetDoc().GetPool() );
252 mpView
->GetAttributes( aEditAttr
);
253 if( aEditAttr
.GetItemState( EE_PARA_ULSPACE
) >= SfxItemState::DEFAULT
)
255 SfxItemSet
aNewAttrs(*(aEditAttr
.GetPool()), aEditAttr
.GetRanges());
256 const SvxULSpaceItem
& rItem
= aEditAttr
.Get( EE_PARA_ULSPACE
);
257 std::unique_ptr
<SvxULSpaceItem
> pNewItem(rItem
.Clone());
258 ::tools::Long nUpper
= pNewItem
->GetUpper();
260 if( nSlot
== SID_PARASPACE_INCREASE
)
265 nUpper
= std::max
<::tools::Long
>( nUpper
, 0 );
267 pNewItem
->SetUpper( static_cast<sal_uInt16
>(nUpper
) );
269 ::tools::Long nLower
= pNewItem
->GetLower();
270 if( nSlot
== SID_PARASPACE_INCREASE
)
275 nLower
= std::max
<::tools::Long
>( nLower
, 0 );
277 pNewItem
->SetLower( static_cast<sal_uInt16
>(nLower
) );
279 aNewAttrs
.Put( std::move(pNewItem
) );
281 mpView
->SetAttributes( aNewAttrs
);
287 pTextObjectBar
->Invalidate();
288 // to refresh preview (in outline mode), slot has to be invalidated:
289 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
290 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_PARA_ULSPACE
, true );
294 case SID_OUTLINE_LEFT
:
298 pOLV
->AdjustDepth( -1 );
300 // Ensure bold/italic etc. icon state updates
302 pTextObjectBar
->Invalidate();
303 // trigger preview refresh
304 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
310 case SID_OUTLINE_RIGHT
:
314 pOLV
->AdjustDepth( 1 );
316 // Ensure bold/italic etc. icon state updates
318 pTextObjectBar
->Invalidate();
319 // trigger preview refresh
320 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
326 case SID_ATTR_PARA_LRSPACE
:
328 SvxLRSpaceItem aLRSpace
= static_cast<const SvxLRSpaceItem
&>(pArgs
->Get(
329 SID_ATTR_PARA_LRSPACE
));
331 SfxItemSetFixed
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttr(mpView
->GetDoc().GetPool());
332 aLRSpace
.SetWhich( EE_PARA_LRSPACE
);
334 aEditAttr
.Put( aLRSpace
);
335 mpView
->SetAttributes( aEditAttr
);
338 pTextObjectBar
->Invalidate(SID_ATTR_PARA_LRSPACE
);
342 case SID_HANGING_INDENT
:
344 SfxItemSetFixed
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aLRSpaceSet(mpView
->GetDoc().GetPool());
345 mpView
->GetAttributes( aLRSpaceSet
);
346 SvxLRSpaceItem
aParaMargin( aLRSpaceSet
.Get( EE_PARA_LRSPACE
) );
348 SvxLRSpaceItem
aNewMargin( EE_PARA_LRSPACE
);
350 auto nIndentDist
= aParaMargin
.ResolveTextFirstLineOffset({});
352 if (nIndentDist
== 0.0)
353 nIndentDist
= nIndentDefaultDist
;
355 aNewMargin
.SetTextLeft(
356 SvxIndentValue::twips(aParaMargin
.ResolveTextLeft({}) + nIndentDist
));
357 aNewMargin
.SetRight(aParaMargin
.GetRight());
358 aNewMargin
.SetTextFirstLineOffset(SvxIndentValue::twips(nIndentDist
* -1));
360 aLRSpaceSet
.Put( aNewMargin
);
361 mpView
->SetAttributes( aLRSpaceSet
);
364 pTextObjectBar
->Invalidate(SID_ATTR_PARA_LRSPACE
);
372 pOLV
->AdjustHeight( -1 );
374 // trigger preview refresh
375 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
381 case SID_OUTLINE_DOWN
:
385 pOLV
->AdjustHeight( 1 );
387 // trigger preview refresh
388 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
394 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
395 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
397 mpView
->SdrEndTextEdit();
398 // tdf#131571: SdrEndTextEdit invalidates pTextEditOutlinerView, the pointer retrieved for pOLV
399 // so reinitialize pOLV
400 pOLV
=mpView
->GetTextEditOutlinerView();
401 SfxItemSetFixed
<SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
> aAttr( mpView
->GetDoc().GetPool() );
402 aAttr
.Put( SvxWritingModeItem(
403 nSlot
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
?
404 css::text::WritingMode_LR_TB
: css::text::WritingMode_TB_RL
,
405 SDRATTR_TEXTDIRECTION
) );
407 mpView
->SetAttributes( aAttr
);
409 pTextObjectBar
->Invalidate();
410 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
414 case FN_NUM_BULLET_ON
:
418 bool bMasterPage
= false;
419 SdrPageView
* pPageView
= mpView
->GetSdrPageView();
422 SdPage
* pPage
= static_cast<SdPage
*>(pPageView
->GetPage());
423 bMasterPage
= pPage
&& (pPage
->GetPageKind() == PageKind::Standard
) && pPage
->IsMasterPage();
427 pOLV
->ToggleBullets();
430 //Resolves: fdo#78151 in master pages if we toggle bullets on
431 //and off then just disable/enable the bulleting, but do not
432 //change the *level* of the paragraph, because the paragraph is
433 //effectively a preview of the equivalent style level, and
434 //changing the level disconnects it from the style
436 ::Outliner
* pOL
= pOLV
->GetOutliner();
439 const SvxNumBulletItem
*pItem
= nullptr;
440 SfxStyleSheetBasePool
* pSSPool
= mpView
->GetDocSh()->GetStyleSheetPool();
441 OUString
sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE
) + " 1");
442 SfxStyleSheetBase
* pFirstStyleSheet
= pSSPool
->Find(sStyleName
, SfxStyleFamily::Pseudo
);
443 if( pFirstStyleSheet
)
444 pItem
= pFirstStyleSheet
->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET
, false);
448 SvxNumRule
aNewRule(pItem
->GetNumRule());
449 ESelection aSel
= pOLV
->GetSelection();
451 sal_Int32 nStartPara
= aSel
.start
.nPara
;
452 sal_Int32 nEndPara
= aSel
.end
.nPara
;
453 for (sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
455 sal_uInt16 nLevel
= pOL
->GetDepth(nPara
);
456 SvxNumberFormat
aFmt(aNewRule
.GetLevel(nLevel
));
458 if (aFmt
.GetNumberingType() == SVX_NUM_NUMBER_NONE
)
460 aFmt
.SetNumberingType(SVX_NUM_CHAR_SPECIAL
);
461 SdStyleSheetPool::setDefaultOutlineNumberFormatBulletAndIndent(nLevel
, aFmt
);
465 aFmt
.SetNumberingType(SVX_NUM_NUMBER_NONE
);
466 aFmt
.SetAbsLSpace(0);
467 aFmt
.SetFirstLineOffset(0);
470 aNewRule
.SetLevel(nLevel
, aFmt
);
473 pFirstStyleSheet
->GetItemSet().Put(SvxNumBulletItem(std::move(aNewRule
), EE_PARA_NUMBULLET
));
475 SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet
, PresentationObjects::Outline_1
, pSSPool
);
482 case SID_GROW_FONT_SIZE
:
483 case SID_SHRINK_FONT_SIZE
:
485 const SvxFontListItem
* pFonts
= static_cast<const SvxFontListItem
*>(mpViewShell
->GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST
));
486 const FontList
* pFontList
= pFonts
? pFonts
->GetFontList(): nullptr;
489 FuText::ChangeFontSize( nSlot
== SID_GROW_FONT_SIZE
, pOLV
, pFontList
, mpView
);
491 pOLV
->SetAttribs( pOLV
->GetEditView().GetEmptyItemSet() );
492 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT
);
500 OUString aReplaceText
;
501 const SfxStringItem
* pItem2
= rReq
.GetArg(FN_PARAM_THES_WORD_REPLACE
);
503 aReplaceText
= pItem2
->GetValue();
504 if (!aReplaceText
.isEmpty())
505 ReplaceTextWithSynonym( pOLV
->GetEditView(), aReplaceText
);
511 SfxItemSet
aEditAttr( mpView
->GetDoc().GetPool() );
512 mpView
->GetAttributes( aEditAttr
);
513 SfxItemSet
aNewAttr(*(aEditAttr
.GetPool()), aEditAttr
.GetRanges());
518 SdrTextHorzAdjust eAnchor
;
521 case SID_ATTR_CHAR_WEIGHT
:
523 FontWeight eFW
= aEditAttr
.Get( EE_CHAR_WEIGHT
).GetWeight();
524 aNewAttr
.Put( SvxWeightItem( eFW
== WEIGHT_NORMAL
?
525 WEIGHT_BOLD
: WEIGHT_NORMAL
,
529 case SID_ATTR_CHAR_POSTURE
:
531 FontItalic eFI
= aEditAttr
.Get( EE_CHAR_ITALIC
).GetPosture();
532 aNewAttr
.Put( SvxPostureItem( eFI
== ITALIC_NORMAL
?
533 ITALIC_NONE
: ITALIC_NORMAL
,
537 case SID_ATTR_CHAR_UNDERLINE
:
539 FontLineStyle eFU
= aEditAttr
.Get( EE_CHAR_UNDERLINE
).GetLineStyle();
540 aNewAttr
.Put( SvxUnderlineItem( eFU
== LINESTYLE_SINGLE
?
541 LINESTYLE_NONE
: LINESTYLE_SINGLE
,
542 EE_CHAR_UNDERLINE
) );
546 case SID_ULINE_VAL_NONE
:
548 aNewAttr
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
552 case SID_ULINE_VAL_SINGLE
:
553 case SID_ULINE_VAL_DOUBLE
:
554 case SID_ULINE_VAL_DOTTED
:
556 FontLineStyle eOld
= aEditAttr
.Get(EE_CHAR_UNDERLINE
).GetLineStyle();
557 FontLineStyle eNew
= eOld
;
561 case SID_ULINE_VAL_SINGLE
:
562 eNew
= ( eOld
== LINESTYLE_SINGLE
) ? LINESTYLE_NONE
: LINESTYLE_SINGLE
;
564 case SID_ULINE_VAL_DOUBLE
:
565 eNew
= ( eOld
== LINESTYLE_DOUBLE
) ? LINESTYLE_NONE
: LINESTYLE_DOUBLE
;
567 case SID_ULINE_VAL_DOTTED
:
568 eNew
= ( eOld
== LINESTYLE_DOTTED
) ? LINESTYLE_NONE
: LINESTYLE_DOTTED
;
572 SvxUnderlineItem
aUnderline(eNew
, EE_CHAR_UNDERLINE
);
573 aNewAttr
.Put(aUnderline
);
577 case SID_ATTR_CHAR_OVERLINE
:
579 FontLineStyle eFO
= aEditAttr
.Get( EE_CHAR_OVERLINE
).GetLineStyle();
580 aNewAttr
.Put( SvxOverlineItem( eFO
== LINESTYLE_SINGLE
?
581 LINESTYLE_NONE
: LINESTYLE_SINGLE
,
582 EE_CHAR_OVERLINE
) );
585 case SID_ATTR_CHAR_CONTOUR
:
587 aNewAttr
.Put( SvxContourItem( !aEditAttr
.Get( EE_CHAR_OUTLINE
).GetValue(), EE_CHAR_OUTLINE
) );
590 case SID_ATTR_CHAR_SHADOWED
:
592 aNewAttr
.Put( SvxShadowedItem( !aEditAttr
.Get( EE_CHAR_SHADOW
).GetValue(), EE_CHAR_SHADOW
) );
595 case SID_ATTR_CHAR_CASEMAP
:
597 aNewAttr
.Put( aEditAttr
.Get( EE_CHAR_CASEMAP
) );
600 case SID_ATTR_CHAR_STRIKEOUT
:
602 FontStrikeout eFSO
= aEditAttr
.Get( EE_CHAR_STRIKEOUT
).GetStrikeout();
603 aNewAttr
.Put( SvxCrossedOutItem( eFSO
== STRIKEOUT_SINGLE
?
604 STRIKEOUT_NONE
: STRIKEOUT_SINGLE
, EE_CHAR_STRIKEOUT
) );
608 case SID_ATTR_PARA_ADJUST_LEFT
: eAdjst
= SvxAdjust::Left
; eAnchor
= SDRTEXTHORZADJUST_LEFT
; goto SET_ADJUST
;
609 case SID_ATTR_PARA_ADJUST_CENTER
: eAdjst
= SvxAdjust::Center
; eAnchor
= SDRTEXTHORZADJUST_CENTER
; goto SET_ADJUST
;
610 case SID_ATTR_PARA_ADJUST_RIGHT
: eAdjst
= SvxAdjust::Right
; eAnchor
= SDRTEXTHORZADJUST_RIGHT
; goto SET_ADJUST
;
611 case SID_ATTR_PARA_ADJUST_BLOCK
: eAdjst
= SvxAdjust::Block
; eAnchor
= SDRTEXTHORZADJUST_BLOCK
; goto SET_ADJUST
;
614 aNewAttr
.Put(SvxAdjustItem(eAdjst
, EE_PARA_JUST
));
616 ESelection aSel
= pOLV
->GetSelection();
618 sal_Int32 nStartPara
= aSel
.start
.nPara
;
619 if (!aSel
.HasRange())
623 aNewAttr
.Put(SdrTextHorzAdjustItem(eAnchor
));
627 case SID_ATTR_PARA_LINESPACE_10
:
629 SvxLineSpacingItem
aItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
630 aItem
.SetPropLineSpace( 100 );
631 aNewAttr
.Put( aItem
);
634 case SID_ATTR_PARA_LINESPACE_15
:
636 SvxLineSpacingItem
aItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
637 aItem
.SetPropLineSpace( 150 );
638 aNewAttr
.Put( aItem
);
641 case SID_ATTR_PARA_LINESPACE_20
:
643 SvxLineSpacingItem
aItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
644 aItem
.SetPropLineSpace( 200 );
645 aNewAttr
.Put( aItem
);
648 case SID_SET_SUPER_SCRIPT
:
650 SvxEscapementItem
aItem( EE_CHAR_ESCAPEMENT
);
651 SvxEscapement eEsc
= static_cast<SvxEscapement
>(aEditAttr
.Get( EE_CHAR_ESCAPEMENT
).GetEnumValue());
653 if( eEsc
== SvxEscapement::Superscript
)
654 aItem
.SetEscapement( SvxEscapement::Off
);
656 aItem
.SetEscapement( SvxEscapement::Superscript
);
657 aNewAttr
.Put( aItem
);
660 case SID_SET_SUB_SCRIPT
:
662 SvxEscapementItem
aItem( EE_CHAR_ESCAPEMENT
);
663 SvxEscapement eEsc
= static_cast<SvxEscapement
>(aEditAttr
.Get( EE_CHAR_ESCAPEMENT
).GetEnumValue());
665 if( eEsc
== SvxEscapement::Subscript
)
666 aItem
.SetEscapement( SvxEscapement::Off
);
668 aItem
.SetEscapement( SvxEscapement::Subscript
);
669 aNewAttr
.Put( aItem
);
673 case SID_SET_SMALL_CAPS
:
675 SvxCaseMap eCaseMap
= aEditAttr
.Get(EE_CHAR_CASEMAP
).GetCaseMap();
676 if (eCaseMap
== SvxCaseMap::SmallCaps
)
677 eCaseMap
= SvxCaseMap::NotMapped
;
679 eCaseMap
= SvxCaseMap::SmallCaps
;
680 SvxCaseMapItem
aItem(eCaseMap
, EE_CHAR_CASEMAP
);
685 // attributes for TextObjectBar
686 case SID_ATTR_CHAR_FONT
:
687 case SID_ATTR_CHAR_FONTHEIGHT
:
688 mpViewShell
->GetViewFrame()->GetDispatcher()->
689 Execute( SID_CHAR_DLG
, SfxCallMode::ASYNCHRON
);
691 case SID_ATTR_CHAR_COLOR
:
692 case SID_ATTR_CHAR_BACK_COLOR
:
694 const sal_uInt16 nEEWhich
695 = aEditAttr
.GetPool()->GetWhichIDFromSlotID(nSlot
);
696 const std::optional
<NamedColor
> oColor
697 = mpViewShell
->GetDocSh()->GetRecentColor(nSlot
);
698 if (oColor
.has_value())
700 const model::ComplexColor aCol
= (*oColor
).getComplexColor();
701 aNewAttr
.Put(SvxColorItem(aCol
.getFinalColor(), aCol
, nEEWhich
));
705 // #i35937# removed need for FN_NUM_BULLET_ON handling
708 rReq
.Done( aNewAttr
);
709 pArgs
= rReq
.GetArgs();
711 else if ( nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
||
712 nSlot
== SID_ATTR_PARA_RIGHT_TO_LEFT
)
714 bool bLeftToRight
= nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
716 SvxAdjust nAdjust
= SvxAdjust::Left
;
717 if( const SvxAdjustItem
* pAdjustItem
= aEditAttr
.GetItemIfSet(EE_PARA_JUST
) )
718 nAdjust
= pAdjustItem
->GetAdjust();
722 aNewAttr
.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB
, EE_PARA_WRITINGDIR
) );
723 if( nAdjust
== SvxAdjust::Right
)
724 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Left
, EE_PARA_JUST
) );
728 aNewAttr
.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB
, EE_PARA_WRITINGDIR
) );
729 if( nAdjust
== SvxAdjust::Left
)
730 aNewAttr
.Put( SvxAdjustItem( SvxAdjust::Right
, EE_PARA_JUST
) );
733 rReq
.Done( aNewAttr
);
734 pArgs
= rReq
.GetArgs();
737 pTextObjectBar
->Invalidate(SID_RULER_TEXT_RIGHT_TO_LEFT
);
739 else if ( nSlot
== SID_ATTR_CHAR_FONT
||
740 nSlot
== SID_ATTR_CHAR_FONTHEIGHT
||
741 nSlot
== SID_ATTR_CHAR_POSTURE
||
742 nSlot
== SID_ATTR_CHAR_WEIGHT
)
744 // #i78017 establish the same behaviour as in Writer
745 SvtScriptType nScriptType
= SvtScriptType::LATIN
| SvtScriptType::ASIAN
| SvtScriptType::COMPLEX
;
746 if (nSlot
== SID_ATTR_CHAR_FONT
)
747 nScriptType
= mpView
->GetScriptType();
749 SfxItemPool
& rPool
= mpView
->GetDoc().GetPool();
750 SvxScriptSetItem
aSvxScriptSetItem( nSlot
, rPool
);
751 aSvxScriptSetItem
.PutItemForScriptType( nScriptType
, pArgs
->Get( rPool
.GetWhichIDFromSlotID( nSlot
) ) );
752 aNewAttr
.Put( aSvxScriptSetItem
.GetItemSet() );
753 rReq
.Done( aNewAttr
);
754 pArgs
= rReq
.GetArgs();
756 else if (nSlot
== SID_ATTR_PARA_ADJUST_LEFT
||
757 nSlot
== SID_ATTR_PARA_ADJUST_CENTER
||
758 nSlot
== SID_ATTR_PARA_ADJUST_RIGHT
||
759 nSlot
== SID_ATTR_PARA_ADJUST_BLOCK
)
762 SdrTextHorzAdjust eAnchor
;
763 if (nSlot
== SID_ATTR_PARA_ADJUST_LEFT
) {
764 eAdjst
= SvxAdjust::Left
; eAnchor
= SDRTEXTHORZADJUST_LEFT
;
766 else if (nSlot
== SID_ATTR_PARA_ADJUST_CENTER
) {
767 eAdjst
= SvxAdjust::Center
; eAnchor
= SDRTEXTHORZADJUST_CENTER
;
769 else if (nSlot
== SID_ATTR_PARA_ADJUST_RIGHT
) {
770 eAdjst
= SvxAdjust::Right
; eAnchor
= SDRTEXTHORZADJUST_RIGHT
;
773 eAdjst
= SvxAdjust::Block
; eAnchor
= SDRTEXTHORZADJUST_BLOCK
;
776 aNewAttr
.Put(SvxAdjustItem(eAdjst
, EE_PARA_JUST
));
778 ESelection aSel
= pOLV
->GetSelection();
780 sal_Int32 nStartPara
= aSel
.start
.nPara
;
781 if (!aSel
.HasRange())
785 aNewAttr
.Put(SdrTextHorzAdjustItem(eAnchor
));
787 rReq
.Done( aNewAttr
);
788 pArgs
= rReq
.GetArgs();
790 else if(nSlot
== SID_ATTR_CHAR_KERNING
)
792 aNewAttr
.Put(pArgs
->Get(pArgs
->GetPool()->GetWhichIDFromSlotID(nSlot
)));
793 rReq
.Done( aNewAttr
);
794 pArgs
= rReq
.GetArgs();
796 else if(nSlot
== SID_SET_SUPER_SCRIPT
)
798 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
799 SvxEscapement eEsc
= static_cast<SvxEscapement
>(aEditAttr
.Get( EE_CHAR_ESCAPEMENT
).GetEnumValue());
801 if( eEsc
== SvxEscapement::Superscript
)
802 aItem
.SetEscapement( SvxEscapement::Off
);
804 aItem
.SetEscapement( SvxEscapement::Superscript
);
805 aNewAttr
.Put( aItem
);
806 rReq
.Done( aNewAttr
);
807 pArgs
= rReq
.GetArgs();
809 else if( nSlot
== SID_SET_SUB_SCRIPT
)
811 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
812 SvxEscapement eEsc
= static_cast<SvxEscapement
>(aEditAttr
.Get( EE_CHAR_ESCAPEMENT
).GetEnumValue());
814 if( eEsc
== SvxEscapement::Subscript
)
815 aItem
.SetEscapement( SvxEscapement::Off
);
817 aItem
.SetEscapement( SvxEscapement::Subscript
);
818 aNewAttr
.Put( aItem
);
819 rReq
.Done( aNewAttr
);
820 pArgs
= rReq
.GetArgs();
823 std::unique_ptr
<SfxItemSet
> pNewArgs
= pArgs
->Clone();
824 mpView
->SetAttributes(*pNewArgs
);
826 // invalidate entire shell because of performance and
829 pTextObjectBar
->Invalidate();
831 // to refresh preview (in outline mode), slot has to be invalidated:
832 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE
, true );
837 if ( nSlot
!= SID_STYLE_APPLY
&& pOLV
)
840 pOLV
->GetWindow()->GrabFocus();
845 pTextObjectBar
->Invalidate(SID_OUTLINE_LEFT
);
846 pTextObjectBar
->Invalidate(SID_OUTLINE_RIGHT
);
847 pTextObjectBar
->Invalidate(SID_OUTLINE_UP
);
848 pTextObjectBar
->Invalidate(SID_OUTLINE_DOWN
);
852 } // end of namespace sd
854 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */