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 <hintids.hxx>
22 #include <svl/whiter.hxx>
23 #include <svl/stritem.hxx>
24 #include <svl/ctloptions.hxx>
25 #include <swmodule.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/request.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <editeng/fhgtitem.hxx>
30 #include <editeng/adjustitem.hxx>
31 #include <editeng/lspcitem.hxx>
32 #include <editeng/lrspitem.hxx>
33 #include <editeng/udlnitem.hxx>
34 #include <editeng/escapementitem.hxx>
35 #include <editeng/pmdlitem.hxx>
36 #include <sfx2/htmlmode.hxx>
37 #include <editeng/scripttypeitem.hxx>
38 #include <editeng/frmdiritem.hxx>
39 #include <editeng/cmapitem.hxx>
40 #include <osl/diagnose.h>
43 #include <fmtinfmt.hxx>
46 #include <viewopt.hxx>
54 #include <SwStyleNameMapper.hxx>
55 #include <swabstdlg.hxx>
58 const sal_uInt32 nFontInc
= 40; // 2pt
59 const sal_uInt32 nFontMaxSz
= 19998; // 999.9pt
61 void SwTextShell::ExecCharAttr(SfxRequest
&rReq
)
63 SwWrtShell
&rSh
= GetShell();
64 const SfxItemSet
*pArgs
= rReq
.GetArgs();
65 int eState
= STATE_TOGGLE
;
66 sal_uInt16 nWhich
= rReq
.GetSlot();
70 const SfxPoolItem
* pItem
;
71 pArgs
->GetItemState(nWhich
, false, &pItem
);
72 eState
= static_cast<const SfxBoolItem
&>( pArgs
->
73 Get( nWhich
)).GetValue() ? STATE_ON
: STATE_OFF
;
76 SfxItemSetFixed
<RES_CHRATR_BEGIN
, RES_CHRATR_END
-1> aSet( GetPool() );
77 if (STATE_TOGGLE
== eState
)
78 rSh
.GetCurAttr( aSet
);
82 case FN_SET_SUB_SCRIPT
:
83 case FN_SET_SUPER_SCRIPT
:
85 SvxEscapement eEscape
= SvxEscapement::Subscript
;
90 short nTmpEsc
= aSet
.Get( RES_CHRATR_ESCAPEMENT
).GetEsc();
91 eEscape
= nWhich
== FN_SET_SUPER_SCRIPT
?
92 SvxEscapement::Superscript
:
93 SvxEscapement::Subscript
;
94 if( (nWhich
== FN_SET_SUB_SCRIPT
&& nTmpEsc
< 0) ||
95 (nWhich
== FN_SET_SUPER_SCRIPT
&& nTmpEsc
> 0) )
96 eEscape
= SvxEscapement::Off
;
98 SfxBindings
& rBind
= GetView().GetViewFrame().GetBindings();
99 if( nWhich
== FN_SET_SUB_SCRIPT
)
100 rBind
.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT
,
103 rBind
.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT
,
109 eEscape
= nWhich
== FN_SET_SUPER_SCRIPT
?
110 SvxEscapement::Superscript
:
111 SvxEscapement::Subscript
;
114 eEscape
= SvxEscapement::Off
;
117 SvxEscapementItem
aEscape( eEscape
, RES_CHRATR_ESCAPEMENT
);
118 if(eEscape
== SvxEscapement::Superscript
)
119 aEscape
.GetEsc() = DFLT_ESC_AUTO_SUPER
;
120 else if(eEscape
== SvxEscapement::Subscript
)
121 aEscape
.GetEsc() = DFLT_ESC_AUTO_SUB
;
122 rSh
.SetAttrItem( aEscape
);
123 rReq
.AppendItem( aEscape
);
128 case FN_SET_SMALL_CAPS
:
130 SvxCaseMap eCaseMap
= SvxCaseMap::SmallCaps
;
135 SvxCaseMap eTmpCaseMap
= aSet
.Get(RES_CHRATR_CASEMAP
).GetCaseMap();
136 if (eTmpCaseMap
== SvxCaseMap::SmallCaps
)
137 eCaseMap
= SvxCaseMap::NotMapped
;
141 // Nothing to do, already set.
144 eCaseMap
= SvxCaseMap::NotMapped
;
147 SvxCaseMapItem
aCaseMap(eCaseMap
, RES_CHRATR_CASEMAP
);
148 rSh
.SetAttrItem(aCaseMap
);
149 rReq
.AppendItem(aCaseMap
);
154 case FN_UPDATE_STYLE_BY_EXAMPLE
:
155 rSh
.QuickUpdateStyle();
159 case SID_ULINE_VAL_NONE
:
161 SvxUnderlineItem
aUnderline(LINESTYLE_NONE
, RES_CHRATR_UNDERLINE
);
162 rSh
.SetAttrItem( aUnderline
);
163 rReq
.AppendItem( aUnderline
);
168 case SID_ULINE_VAL_SINGLE
:
169 case SID_ULINE_VAL_DOUBLE
:
170 case SID_ULINE_VAL_DOTTED
:
172 FontLineStyle eOld
= aSet
.Get(RES_CHRATR_UNDERLINE
).GetLineStyle();
173 FontLineStyle eNew
= eOld
;
177 case SID_ULINE_VAL_SINGLE
:
178 eNew
= ( eOld
== LINESTYLE_SINGLE
) ? LINESTYLE_NONE
: LINESTYLE_SINGLE
;
180 case SID_ULINE_VAL_DOUBLE
:
181 eNew
= ( eOld
== LINESTYLE_DOUBLE
) ? LINESTYLE_NONE
: LINESTYLE_DOUBLE
;
183 case SID_ULINE_VAL_DOTTED
:
184 eNew
= ( eOld
== LINESTYLE_DOTTED
) ? LINESTYLE_NONE
: LINESTYLE_DOTTED
;
188 SvxUnderlineItem
aUnderline(eNew
, RES_CHRATR_UNDERLINE
);
189 rSh
.SetAttrItem( aUnderline
);
190 rReq
.AppendItem( aUnderline
);
194 case FN_REMOVE_DIRECT_CHAR_FORMATS
:
195 if( !rSh
.HasReadonlySel() && rSh
.IsEndPara())
196 rSh
.DontExpandFormat();
199 OSL_FAIL("wrong dispatcher");
204 void SwTextShell::ExecCharAttrArgs(SfxRequest
&rReq
)
206 sal_uInt16 nSlot
= rReq
.GetSlot();
207 const SfxItemSet
* pArgs
= rReq
.GetArgs();
208 bool bArgs
= pArgs
!= nullptr && pArgs
->Count() > 0;
209 SwWrtShell
& rWrtSh
= GetShell();
210 SwTextFormatColl
* pColl
= nullptr;
212 // Is only set if the whole paragraph is selected and AutoUpdateFormat is set.
213 if (rWrtSh
.HasSelection() && rWrtSh
.IsSelFullPara())
215 pColl
= rWrtSh
.GetCurTextFormatColl();
216 if ( pColl
&& !pColl
->IsAutoUpdateOnDirectFormat() )
219 SfxItemPool
& rPool
= GetPool();
220 sal_uInt16 nWhich
= rPool
.GetWhich( nSlot
);
224 // Special treatment of the PoolId of the SwFormatInetFormat
227 const SfxPoolItem
& rItem
= pArgs
->Get( nWhich
);
229 SwFormatINetFormat
aINetFormat( static_cast<const SwFormatINetFormat
&>(rItem
) );
230 if ( USHRT_MAX
== aINetFormat
.GetVisitedFormatId() )
232 OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected visited character format ID at hyperlink attribute" );
233 aINetFormat
.SetVisitedFormatAndId(
234 aINetFormat
.GetVisitedFormat(),
235 SwStyleNameMapper::GetPoolIdFromUIName( aINetFormat
.GetVisitedFormat(), SwGetPoolIdFromName::ChrFmt
) );
237 if ( USHRT_MAX
== aINetFormat
.GetINetFormatId() )
239 OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected unvisited character format ID at hyperlink attribute" );
240 aINetFormat
.SetINetFormatAndId(
241 aINetFormat
.GetINetFormat(),
242 SwStyleNameMapper::GetPoolIdFromUIName( aINetFormat
.GetINetFormat(), SwGetPoolIdFromName::ChrFmt
) );
246 pColl
->SetFormatAttr( aINetFormat
);
248 rWrtSh
.SetAttrItem( aINetFormat
);
253 case FN_GROW_FONT_SIZE
:
254 case FN_SHRINK_FONT_SIZE
:
256 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONTHEIGHT
, rPool
);
257 rWrtSh
.GetCurAttr( aSetItem
.GetItemSet() );
258 SfxItemSet
aAttrSet( rPool
, aSetItem
.GetItemSet().GetRanges() );
260 SvtScriptType nScriptTypes
= rWrtSh
.GetScriptType();
261 const SvxFontHeightItem
* pSize( static_cast<const SvxFontHeightItem
*>(
262 aSetItem
.GetItemOfScript( nScriptTypes
) ) );
263 std::vector
<std::pair
< const SfxPoolItem
*, std::unique_ptr
<SwPaM
> >> vItems
;
264 // simple case where selected text has one size and
265 // (tdf#124919) selection is not multiple table cells
266 if (pSize
&& !rWrtSh
.IsTableMode())
268 // must create new one, otherwise document is without pam
269 SwPaM
* pPaM
= rWrtSh
.GetCursor();
270 vItems
.emplace_back( pSize
, std::make_unique
<SwPaM
>( *(pPaM
->GetMark()), *(pPaM
->GetPoint())) );
273 vItems
= rWrtSh
.GetItemWithPaM( RES_CHRATR_FONTSIZE
);
275 rWrtSh
.StartUndo( SwUndoId::INSATTR
);
276 for( std::pair
< const SfxPoolItem
*, std::unique_ptr
<SwPaM
> >& iPair
: vItems
)
278 std::unique_ptr
<SwPaM
> pPaM
= std::move(iPair
.second
);
279 const SfxPoolItem
* pItem
= iPair
.first
;
280 aSetItem
.GetItemSet().ClearItem();
281 rWrtSh
.GetPaMAttr( pPaM
.get(), aSetItem
.GetItemSet() );
282 aAttrSet
.SetRanges( aSetItem
.GetItemSet().GetRanges() );
284 pSize
= static_cast<const SvxFontHeightItem
*>( pItem
);
287 SvxFontHeightItem
aSize(*pSize
);
289 sal_uInt32 nSize
= aSize
.GetHeight();
291 if ( nSlot
== FN_GROW_FONT_SIZE
&& ( nSize
+= nFontInc
) > nFontMaxSz
)
293 else if ( nSlot
== FN_SHRINK_FONT_SIZE
&& ( nSize
-= nFontInc
) < nFontInc
)
296 aSize
.SetHeight( nSize
);
297 aSetItem
.PutItemForScriptType( nScriptTypes
, aSize
);
298 aAttrSet
.Put( aSetItem
.GetItemSet() );
300 pColl
->SetFormatAttr( aAttrSet
);
302 rWrtSh
.SetAttrSet( aAttrSet
, SetAttrMode::DEFAULT
, pPaM
.get() );
305 rWrtSh
.EndUndo( SwUndoId::INSATTR
);
311 OSL_FAIL("wrong dispatcher");
316 void SwTextShell::ExecParaAttr(SfxRequest
&rReq
)
320 const SfxItemSet
* pArgs
= rReq
.GetArgs();
322 // Get both attributes immediately isn't more expensive!!
324 <RES_PARATR_LINESPACING
, RES_PARATR_ADJUST
,
325 RES_FRAMEDIR
, RES_FRAMEDIR
> aSet( GetPool() );
327 sal_uInt16 nSlot
= rReq
.GetSlot();
330 case SID_ATTR_PARA_ADJUST
:
332 if( pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(RES_PARATR_ADJUST
) )
334 const SvxAdjustItem
& rAdj
= pArgs
->Get(RES_PARATR_ADJUST
);
335 SvxAdjustItem
aAdj( rAdj
.GetAdjust(), RES_PARATR_ADJUST
);
336 if ( rAdj
.GetAdjust() == SvxAdjust::Block
)
338 aAdj
.SetLastBlock( rAdj
.GetLastBlock() );
339 aAdj
.SetOneWord( rAdj
.GetOneWord() );
346 case SID_ATTR_PARA_ADJUST_LEFT
: eAdjst
= SvxAdjust::Left
; goto SET_ADJUST
;
347 case SID_ATTR_PARA_ADJUST_RIGHT
: eAdjst
= SvxAdjust::Right
; goto SET_ADJUST
;
348 case SID_ATTR_PARA_ADJUST_CENTER
: eAdjst
= SvxAdjust::Center
; goto SET_ADJUST
;
349 case SID_ATTR_PARA_ADJUST_BLOCK
: eAdjst
= SvxAdjust::Block
; goto SET_ADJUST
;
352 aSet
.Put(SvxAdjustItem(eAdjst
,RES_PARATR_ADJUST
));
353 rReq
.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot
), true ) );
357 case SID_ATTR_PARA_LINESPACE
:
358 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( GetPool().GetWhich(nSlot
) ))
360 SvxLineSpacingItem aLineSpace
= static_cast<const SvxLineSpacingItem
&>( pArgs
->Get(
361 GetPool().GetWhich(nSlot
)));
362 aSet
.Put( aLineSpace
);
365 case SID_ATTR_PARA_LINESPACE_10
: ePropL
= 100; goto SET_LINESPACE
;
366 case SID_ATTR_PARA_LINESPACE_15
: ePropL
= 150; goto SET_LINESPACE
;
367 case SID_ATTR_PARA_LINESPACE_115
: ePropL
= 115; goto SET_LINESPACE
;
368 case SID_ATTR_PARA_LINESPACE_20
: ePropL
= 200; goto SET_LINESPACE
;
373 SvxLineSpacingItem
aLineSpacing(ePropL
, RES_PARATR_LINESPACING
);
374 aLineSpacing
.SetLineSpaceRule( SvxLineSpaceRule::Auto
);
376 aLineSpacing
.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off
);
378 aLineSpacing
.SetPropLineSpace(ePropL
);
379 aSet
.Put( aLineSpacing
);
383 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
384 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
386 SfxItemSetFixed
<RES_PARATR_ADJUST
, RES_PARATR_ADJUST
> aAdjustSet( GetPool() );
387 GetShell().GetCurAttr(aAdjustSet
);
388 bool bChgAdjust
= false;
389 SfxItemState eAdjustState
= aAdjustSet
.GetItemState(RES_PARATR_ADJUST
, false);
390 if(eAdjustState
>= SfxItemState::DEFAULT
)
393 aAdjustSet
.Get(RES_PARATR_ADJUST
).GetAdjust();
394 bChgAdjust
= (SvxAdjust::Left
== eAdjust
&& SID_ATTR_PARA_RIGHT_TO_LEFT
== nSlot
) ||
395 (SvxAdjust::Right
== eAdjust
&& SID_ATTR_PARA_LEFT_TO_RIGHT
== nSlot
);
400 SvxFrameDirection eFrameDirection
=
401 (SID_ATTR_PARA_LEFT_TO_RIGHT
== nSlot
) ?
402 SvxFrameDirection::Horizontal_LR_TB
: SvxFrameDirection::Horizontal_RL_TB
;
403 aSet
.Put( SvxFrameDirectionItem( eFrameDirection
, RES_FRAMEDIR
) );
407 SvxAdjust eAdjust
= (SID_ATTR_PARA_LEFT_TO_RIGHT
== nSlot
) ?
408 SvxAdjust::Left
: SvxAdjust::Right
;
409 SvxAdjustItem
aAdjust( eAdjust
, RES_PARATR_ADJUST
);
411 aAdjust
.SetWhich(SID_ATTR_PARA_ADJUST
);
412 GetView().GetViewFrame().GetBindings().SetState( aAdjust
);
413 // Toggle numbering alignment
414 const SwNumRule
* pCurRule
= GetShell().GetNumRuleAtCurrCursorPos();
417 SvxNumRule aRule
= pCurRule
->MakeSvxNumRule();
419 for(sal_uInt16 i
= 0; i
< aRule
.GetLevelCount(); i
++)
421 SvxNumberFormat
aFormat(aRule
.GetLevel(i
));
422 if(SvxAdjust::Left
== aFormat
.GetNumAdjust())
423 aFormat
.SetNumAdjust( SvxAdjust::Right
);
425 else if(SvxAdjust::Right
== aFormat
.GetNumAdjust())
426 aFormat
.SetNumAdjust( SvxAdjust::Left
);
428 aRule
.SetLevel(i
, aFormat
, aRule
.Get(i
) != nullptr);
430 SwNumRule
aSetRule( pCurRule
->GetName(),
431 pCurRule
->Get( 0 ).GetPositionAndSpaceMode() );
432 aSetRule
.SetSvxRule( aRule
, GetShell().GetDoc());
433 aSetRule
.SetAutoRule( true );
434 // no start or continuation of a list - list style is only changed
435 GetShell().SetCurNumRule( aSetRule
, false );
442 OSL_FAIL("wrong dispatcher");
445 SwWrtShell
& rWrtSh
= GetShell();
446 SwTextFormatColl
* pColl
= rWrtSh
.GetCurTextFormatColl();
447 if(pColl
&& pColl
->IsAutoUpdateOnDirectFormat())
449 rWrtSh
.AutoUpdatePara(pColl
, aSet
);
452 rWrtSh
.SetAttrSet( aSet
, SetAttrMode::DEFAULT
, nullptr, true);
456 void SwTextShell::ExecParaAttrArgs(SfxRequest
&rReq
)
458 SwWrtShell
&rSh
= GetShell();
459 const SfxItemSet
*pArgs
= rReq
.GetArgs();
460 const SfxPoolItem
*pItem
= nullptr;
462 sal_uInt16 nSlot
= rReq
.GetSlot();
464 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), false, &pItem
);
467 case FN_DROP_CHAR_STYLE_NAME
:
470 OUString sCharStyleName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
471 SfxItemSetFixed
<RES_PARATR_DROP
, RES_PARATR_DROP
> aSet(GetPool());
472 rSh
.GetCurAttr(aSet
);
473 SwFormatDrop
aDropItem(aSet
.Get(RES_PARATR_DROP
));
474 SwCharFormat
* pFormat
= nullptr;
475 if(!sCharStyleName
.isEmpty())
476 pFormat
= rSh
.FindCharFormatByName( sCharStyleName
);
477 aDropItem
.SetCharFormat( pFormat
);
479 rSh
.SetAttrSet(aSet
);
482 case FN_FORMAT_DROPCAPS
:
486 rSh
.SetAttrItem(*pItem
);
491 SfxItemSetFixed
<RES_PARATR_DROP
, RES_PARATR_DROP
,
492 HINT_END
, HINT_END
> aSet(GetPool());
493 rSh
.GetCurAttr(aSet
);
494 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
495 ScopedVclPtr
<SfxAbstractDialog
> pDlg(pFact
->CreateSwDropCapsDialog(GetView().GetFrameWeld(), aSet
));
496 if (pDlg
->Execute() == RET_OK
)
499 rSh
.StartUndo( SwUndoId::START
);
500 if ( const SfxStringItem
* pHintItem
= aSet
.GetItemIfSet(HINT_END
,false) )
502 if ( !pHintItem
->GetValue().isEmpty() )
503 rSh
.ReplaceDropText(pHintItem
->GetValue());
505 rSh
.SetAttrSet(*pDlg
->GetOutputItemSet());
506 rSh
.EndUndo( SwUndoId::END
);
508 rReq
.Done(*pDlg
->GetOutputItemSet());
513 case SID_ATTR_PARA_PAGEBREAK
:
516 rSh
.SetAttrItem( *pItem
);
520 case SID_ATTR_PARA_MODEL
:
524 SfxItemSetFixed
<RES_PAGEDESC
, RES_PAGEDESC
,
525 SID_ATTR_PARA_MODEL
, SID_ATTR_PARA_MODEL
> aCoreSet( GetPool() );
526 aCoreSet
.Put(*pItem
);
527 SfxToSwPageDescAttr( rSh
, aCoreSet
);
528 rSh
.SetAttrSet(aCoreSet
);
535 OSL_FAIL("wrong dispatcher");
540 void SwTextShell::GetAttrState(SfxItemSet
&rSet
)
542 SwWrtShell
&rSh
= GetShell();
543 SfxItemPool
& rPool
= GetPool();
544 SfxItemSet
aCoreSet(rPool
, aTextFormatCollSetRange
);
545 // Request *all* text attributes from the core.
546 // fdo#78737: this is called from SvxRuler, which requires the list indents!
547 rSh
.GetCurAttr(aCoreSet
, /* bMergeIndentValuesOfNumRule = */ true);
549 SfxWhichIter
aIter(rSet
);
550 sal_uInt16 nSlot
= aIter
.FirstWhich();
552 SfxBoolItem aFlagItem
;
553 const SfxPoolItem
* pItem
= nullptr;
554 SvxAdjust eAdjust
= SvxAdjust::Left
;
555 bool bAdjustGood
= false;
556 SfxItemState eState
= aCoreSet
.GetItemState(RES_PARATR_ADJUST
, false, &pItem
);
558 if( SfxItemState::DEFAULT
== eState
)
559 pItem
= &rPool
.GetDefaultItem(RES_PARATR_ADJUST
);
560 if( SfxItemState::DEFAULT
<= eState
)
562 eAdjust
= static_cast<const SvxAdjustItem
* >( pItem
)->GetAdjust();
567 eState
= aCoreSet
.GetItemState(RES_CHRATR_ESCAPEMENT
, false, &pItem
);
568 if( SfxItemState::DEFAULT
== eState
)
569 pItem
= &rPool
.GetDefaultItem(RES_CHRATR_ESCAPEMENT
);
570 if( eState
>= SfxItemState::DEFAULT
)
571 nEsc
= static_cast<const SvxEscapementItem
* >(pItem
)->GetEsc();
573 sal_uInt16 nLineSpace
= 0;
574 eState
= aCoreSet
.GetItemState(RES_PARATR_LINESPACING
, false, &pItem
);
575 if( SfxItemState::DEFAULT
== eState
)
576 pItem
= &rPool
.GetDefaultItem(RES_PARATR_LINESPACING
);
577 if( SfxItemState::DEFAULT
<= eState
&&
578 static_cast<const SvxLineSpacingItem
* >(pItem
)->GetLineSpaceRule() == SvxLineSpaceRule::Auto
)
580 if(SvxInterLineSpaceRule::Off
==
581 static_cast<const SvxLineSpacingItem
* >(pItem
)->GetInterLineSpaceRule())
584 nLineSpace
= static_cast<const SvxLineSpacingItem
* >(pItem
)->GetPropLineSpace();
587 SvxCaseMap eCaseMap
= SvxCaseMap::NotMapped
;
588 eState
= aCoreSet
.GetItemState(RES_CHRATR_CASEMAP
, false, &pItem
);
589 if (eState
== SfxItemState::DEFAULT
)
590 pItem
= &rPool
.GetDefaultItem(RES_CHRATR_CASEMAP
);
591 if (eState
>= SfxItemState::DEFAULT
)
592 eCaseMap
= static_cast<const SvxCaseMapItem
*>(pItem
)->GetCaseMap();
598 case FN_SET_SUPER_SCRIPT
:
601 case FN_SET_SUB_SCRIPT
:
604 case FN_SET_SMALL_CAPS
:
605 bFlag
= eCaseMap
== SvxCaseMap::SmallCaps
;
607 case SID_ATTR_PARA_ADJUST_LEFT
:
610 rSet
.InvalidateItem( nSlot
);
614 bFlag
= SvxAdjust::Left
== eAdjust
;
616 case SID_ATTR_PARA_ADJUST_RIGHT
:
619 rSet
.InvalidateItem( nSlot
);
623 bFlag
= SvxAdjust::Right
== eAdjust
;
625 case SID_ATTR_PARA_ADJUST_CENTER
:
628 rSet
.InvalidateItem( nSlot
);
632 bFlag
= SvxAdjust::Center
== eAdjust
;
634 case SID_ATTR_PARA_ADJUST_BLOCK
:
638 rSet
.InvalidateItem( nSlot
);
643 bFlag
= SvxAdjust::Block
== eAdjust
;
644 sal_uInt16 nHtmlMode
= GetHtmlMode(rSh
.GetView().GetDocShell());
645 if((nHtmlMode
& HTMLMODE_ON
) && !(nHtmlMode
& HTMLMODE_FULL_STYLES
))
647 rSet
.DisableItem( nSlot
);
653 case SID_ATTR_PARA_LINESPACE_10
:
654 bFlag
= nLineSpace
== 100;
656 case SID_ATTR_PARA_LINESPACE_115
:
657 bFlag
= nLineSpace
== 115;
659 case SID_ATTR_PARA_LINESPACE_15
:
660 bFlag
= nLineSpace
== 150;
662 case SID_ATTR_PARA_LINESPACE_20
:
663 bFlag
= nLineSpace
== 200;
665 case FN_GROW_FONT_SIZE
:
666 case FN_SHRINK_FONT_SIZE
:
668 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONTHEIGHT
,
670 aSetItem
.GetItemSet().Put( aCoreSet
, false );
671 const SvxFontHeightItem
* pSize( static_cast<const SvxFontHeightItem
*>(
672 aSetItem
.GetItemOfScript( rSh
.GetScriptType() ) ) );
674 if( pSize
) // selection is of one size
676 sal_uInt32 nSize
= pSize
->GetHeight();
677 if( nSize
== nFontMaxSz
)
678 rSet
.DisableItem( FN_GROW_FONT_SIZE
);
679 else if( nSize
== nFontInc
)
680 rSet
.DisableItem( FN_SHRINK_FONT_SIZE
);
684 std::vector
<std::pair
< const SfxPoolItem
*, std::unique_ptr
<SwPaM
> >>
685 vFontHeight
= rSh
.GetItemWithPaM( RES_CHRATR_FONTSIZE
);
686 for ( const std::pair
< const SfxPoolItem
*, std::unique_ptr
<SwPaM
>>& aIt
: vFontHeight
)
690 rSet
.DisableItem(FN_GROW_FONT_SIZE
);
691 rSet
.DisableItem(FN_SHRINK_FONT_SIZE
);
694 pSize
= static_cast<const SvxFontHeightItem
*>( aIt
.first
);
695 sal_uInt32 nSize
= pSize
->GetHeight();
696 if( nSize
== nFontMaxSz
)
697 rSet
.DisableItem( FN_GROW_FONT_SIZE
);
698 else if( nSize
== nFontInc
)
699 rSet
.DisableItem( FN_SHRINK_FONT_SIZE
);
705 case SID_ULINE_VAL_NONE
:
706 case SID_ULINE_VAL_SINGLE
:
707 case SID_ULINE_VAL_DOUBLE
:
708 case SID_ULINE_VAL_DOTTED
:
710 eState
= aCoreSet
.GetItemState(RES_CHRATR_UNDERLINE
);
711 if( eState
>= SfxItemState::DEFAULT
)
713 FontLineStyle eLineStyle
= aCoreSet
.Get(RES_CHRATR_UNDERLINE
).GetLineStyle();
717 case SID_ULINE_VAL_NONE
:
718 rSet
.Put(SfxBoolItem(nSlot
, eLineStyle
== LINESTYLE_NONE
));
720 case SID_ULINE_VAL_SINGLE
:
721 rSet
.Put(SfxBoolItem(nSlot
, eLineStyle
== LINESTYLE_SINGLE
));
723 case SID_ULINE_VAL_DOUBLE
:
724 rSet
.Put(SfxBoolItem(nSlot
, eLineStyle
== LINESTYLE_DOUBLE
));
726 case SID_ULINE_VAL_DOTTED
:
727 rSet
.Put(SfxBoolItem(nSlot
, eLineStyle
== LINESTYLE_DOTTED
));
732 rSet
.InvalidateItem(nSlot
);
736 case SID_ATTR_PARA_ADJUST
:
738 rSet
.InvalidateItem( nSlot
);
740 rSet
.Put(SvxAdjustItem(eAdjust
, SID_ATTR_PARA_ADJUST
));
743 case SID_ATTR_PARA_LRSPACE
:
744 case SID_ATTR_PARA_LEFTSPACE
:
745 case SID_ATTR_PARA_RIGHTSPACE
:
746 case SID_ATTR_PARA_FIRSTLINESPACE
:
748 eState
= aCoreSet
.GetItemState(RES_MARGIN_FIRSTLINE
);
749 eState
= std::min(aCoreSet
.GetItemState(RES_MARGIN_TEXTLEFT
), eState
);
750 eState
= std::min(aCoreSet
.GetItemState(RES_MARGIN_RIGHT
), eState
);
751 if( eState
>= SfxItemState::DEFAULT
)
753 SvxLRSpaceItem
aLR(RES_LR_SPACE
);
754 SvxFirstLineIndentItem
const& rFirstLine(aCoreSet
.Get(RES_MARGIN_FIRSTLINE
));
755 SvxTextLeftMarginItem
const& rLeftMargin(aCoreSet
.Get(RES_MARGIN_TEXTLEFT
));
756 SvxRightMarginItem
const& rRightMargin(aCoreSet
.Get(RES_MARGIN_RIGHT
));
757 aLR
.SetTextFirstLineOffset(rFirstLine
.GetTextFirstLineOffset(), rFirstLine
.GetPropTextFirstLineOffset());
758 aLR
.SetAutoFirst(rFirstLine
.IsAutoFirst());
759 aLR
.SetTextLeft(rLeftMargin
.GetTextLeft(), rLeftMargin
.GetPropLeft());
760 aLR
.SetRight(rRightMargin
.GetRight(), rRightMargin
.GetPropRight());
765 rSet
.InvalidateItem(nSlot
);
770 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
771 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
773 if ( !SvtCTLOptions::IsCTLFontEnabled() )
775 rSet
.DisableItem( nSlot
);
781 sal_uInt16 nHtmlMode
= GetHtmlMode(rSh
.GetView().GetDocShell());
782 if((!(nHtmlMode
& HTMLMODE_ON
) || (0 != (nHtmlMode
& HTMLMODE_SOME_STYLES
))) &&
783 aCoreSet
.GetItemState( RES_FRAMEDIR
, false ) >= SfxItemState::DEFAULT
)
785 SvxFrameDirection eFrameDir
=
786 aCoreSet
.Get(RES_FRAMEDIR
).GetValue();
787 if (SvxFrameDirection::Environment
== eFrameDir
)
789 eFrameDir
= rSh
.IsInRightToLeftText() ?
790 SvxFrameDirection::Horizontal_RL_TB
: SvxFrameDirection::Horizontal_LR_TB
;
792 bFlag
= (SID_ATTR_PARA_LEFT_TO_RIGHT
== nSlot
&&
793 SvxFrameDirection::Horizontal_LR_TB
== eFrameDir
) ||
794 (SID_ATTR_PARA_RIGHT_TO_LEFT
== nSlot
&&
795 SvxFrameDirection::Horizontal_RL_TB
== eFrameDir
);
799 rSet
.InvalidateItem(nSlot
);
806 case SID_ATTR_CHAR_LANGUAGE
:
807 case SID_ATTR_CHAR_KERNING
:
808 case RES_PARATR_DROP
:
810 rSet
.Put(aCoreSet
.Get( GetPool().GetWhich(nSlot
)));
814 case SID_ATTR_PARA_MODEL
:
817 <RES_PAGEDESC
,RES_PAGEDESC
,
818 SID_ATTR_PARA_MODEL
,SID_ATTR_PARA_MODEL
> aTemp(GetPool());
820 ::SwToSfxPageDescAttr(aTemp
);
821 rSet
.Put(aTemp
.Get(SID_ATTR_PARA_MODEL
));
825 case RES_TXTATR_INETFMT
:
827 SfxItemSetFixed
<RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
> aSet(GetPool());
828 rSh
.GetCurAttr(aSet
);
829 const SfxPoolItem
& rItem
= aSet
.Get(RES_TXTATR_INETFMT
);
843 aFlagItem
.SetWhich( nSlot
);
844 aFlagItem
.SetValue( bFlag
);
845 rSet
.Put( aFlagItem
);
847 nSlot
= aIter
.NextWhich();
850 rSet
.Put(aCoreSet
,false);
853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */