LibreOffice Module sw (master)  1
txtattr.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <hintids.hxx>
21 
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>
35 #include <sfx2/htmlmode.hxx>
37 #include <editeng/frmdiritem.hxx>
38 #include <editeng/cmapitem.hxx>
39 #include <osl/diagnose.h>
40 #include <paratr.hxx>
41 
42 #include <fmtinfmt.hxx>
43 #include <wrtsh.hxx>
44 #include <view.hxx>
45 #include <viewopt.hxx>
46 #include <uitool.hxx>
47 #include <textsh.hxx>
48 #include <swundo.hxx>
49 #include <fmtcol.hxx>
50 
51 #include <cmdid.h>
52 #include <globals.h>
53 #include <SwStyleNameMapper.hxx>
54 #include <swabstdlg.hxx>
55 #include <memory>
56 
57 const sal_uInt32 nFontInc = 40; // 2pt
58 const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
59 
61 {
62  SwWrtShell &rSh = GetShell();
63  const SfxItemSet *pArgs = rReq.GetArgs();
64  int eState = STATE_TOGGLE;
65  sal_uInt16 nWhich = rReq.GetSlot();
66 
67  if(pArgs )
68  {
69  const SfxPoolItem* pItem;
70  pArgs->GetItemState(nWhich, false, &pItem);
71  eState = static_cast<const SfxBoolItem &>( pArgs->
72  Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
73  }
74 
75  SfxItemSet aSet( GetPool(), svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1> );
76  if (STATE_TOGGLE == eState)
77  rSh.GetCurAttr( aSet );
78 
79  switch ( nWhich )
80  {
81  case FN_SET_SUB_SCRIPT:
83  {
84  SvxEscapement eEscape = SvxEscapement::Subscript;
85  switch (eState)
86  {
87  case STATE_TOGGLE:
88  {
89  short nTmpEsc = aSet.Get( RES_CHRATR_ESCAPEMENT ).GetEsc();
90  eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
91  SvxEscapement::Superscript:
92  SvxEscapement::Subscript;
93  if( (nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0) ||
94  (nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0) )
95  eEscape = SvxEscapement::Off;
96 
98  if( nWhich == FN_SET_SUB_SCRIPT )
100  false ) );
101  else
103  false ) );
104 
105  }
106  break;
107  case STATE_ON:
108  eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
109  SvxEscapement::Superscript:
110  SvxEscapement::Subscript;
111  break;
112  case STATE_OFF:
113  eEscape = SvxEscapement::Off;
114  break;
115  }
116  SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
117  if(eEscape == SvxEscapement::Superscript)
118  aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
119  else if(eEscape == SvxEscapement::Subscript)
120  aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
121  rSh.SetAttrItem( aEscape );
122  rReq.AppendItem( aEscape );
123  rReq.Done();
124  }
125  break;
126 
127  case FN_SET_SMALL_CAPS:
128  {
129  SvxCaseMap eCaseMap = SvxCaseMap::SmallCaps;
130  switch (eState)
131  {
132  case STATE_TOGGLE:
133  {
134  SvxCaseMap eTmpCaseMap = aSet.Get(RES_CHRATR_CASEMAP).GetCaseMap();
135  if (eTmpCaseMap == SvxCaseMap::SmallCaps)
136  eCaseMap = SvxCaseMap::NotMapped;
137  }
138  break;
139  case STATE_ON:
140  // Nothing to do, already set.
141  break;
142  case STATE_OFF:
143  eCaseMap = SvxCaseMap::NotMapped;
144  break;
145  }
146  SvxCaseMapItem aCaseMap(eCaseMap, RES_CHRATR_CASEMAP);
147  rSh.SetAttrItem(aCaseMap);
148  rReq.AppendItem(aCaseMap);
149  rReq.Done();
150  }
151  break;
152 
154  rSh.QuickUpdateStyle();
155  rReq.Done();
156  break;
157 
158  case SID_ULINE_VAL_NONE:
159  {
161  rSh.SetAttrItem( aUnderline );
162  rReq.AppendItem( aUnderline );
163  rReq.Done();
164  break;
165  }
166 
167  case SID_ULINE_VAL_SINGLE:
168  case SID_ULINE_VAL_DOUBLE:
169  case SID_ULINE_VAL_DOTTED:
170  {
171  FontLineStyle eOld = aSet.Get(RES_CHRATR_UNDERLINE).GetLineStyle();
172  FontLineStyle eNew = eOld;
173 
174  switch (nWhich)
175  {
176  case SID_ULINE_VAL_SINGLE:
177  eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
178  break;
179  case SID_ULINE_VAL_DOUBLE:
180  eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
181  break;
182  case SID_ULINE_VAL_DOTTED:
183  eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
184  break;
185  }
186 
187  SvxUnderlineItem aUnderline(eNew, RES_CHRATR_UNDERLINE );
188  rSh.SetAttrItem( aUnderline );
189  rReq.AppendItem( aUnderline );
190  rReq.Done();
191  }
192  break;
194  if( !rSh.HasReadonlySel() && rSh.IsEndPara())
195  rSh.DontExpandFormat();
196  break;
197  default:
198  OSL_FAIL("wrong dispatcher");
199  return;
200  }
201 }
202 
204 {
205  sal_uInt16 nSlot = rReq.GetSlot();
206  const SfxItemSet* pArgs = rReq.GetArgs();
207  bool bArgs = pArgs != nullptr && pArgs->Count() > 0;
208  SwWrtShell& rWrtSh = GetShell();
209  SwTextFormatColl* pColl = nullptr;
210 
211  // Is only set if the whole paragraph is selected and AutoUpdateFormat is set.
212  if (rWrtSh.HasSelection() && rWrtSh.IsSelFullPara())
213  {
214  pColl = rWrtSh.GetCurTextFormatColl();
215  if ( pColl && !pColl->IsAutoUpdateFormat() )
216  pColl = nullptr;
217  }
218  SfxItemPool& rPool = GetPool();
219  sal_uInt16 nWhich = rPool.GetWhich( nSlot );
220  switch (nSlot)
221  {
222  case FN_TXTATR_INET:
223  // Special treatment of the PoolId of the SwFormatInetFormat
224  if(bArgs)
225  {
226  const SfxPoolItem& rItem = pArgs->Get( nWhich );
227 
228  SwFormatINetFormat aINetFormat( static_cast<const SwFormatINetFormat&>(rItem) );
229  if ( USHRT_MAX == aINetFormat.GetVisitedFormatId() )
230  {
231  OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected visited character format ID at hyperlink attribute" );
232  aINetFormat.SetVisitedFormatAndId(
233  aINetFormat.GetVisitedFormat(),
235  }
236  if ( USHRT_MAX == aINetFormat.GetINetFormatId() )
237  {
238  OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected unvisited character format ID at hyperlink attribute" );
239  aINetFormat.SetINetFormatAndId(
240  aINetFormat.GetINetFormat(),
242  }
243 
244  if ( pColl )
245  pColl->SetFormatAttr( aINetFormat );
246  else
247  rWrtSh.SetAttrItem( aINetFormat );
248  rReq.Done();
249  }
250  break;
251 
252  case FN_GROW_FONT_SIZE:
253  case FN_SHRINK_FONT_SIZE:
254  {
255  SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
256  rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
257  SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
258 
259  SvtScriptType nScriptTypes = rWrtSh.GetScriptType();
260  const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
261  aSetItem.GetItemOfScript( nScriptTypes ) ) );
262  std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >> vItems;
263  // simple case where selected text has one size and
264  // (tdf#124919) selection is not multiple table cells
265  if (pSize && !rWrtSh.IsTableMode())
266  {
267  // must create new one, otherwise document is without pam
268  SwPaM* pPaM = rWrtSh.GetCursor();
269  vItems.emplace_back( pSize, std::make_unique<SwPaM>( *(pPaM->GetMark()), *(pPaM->GetPoint())) );
270  }
271  else
272  vItems = rWrtSh.GetItemWithPaM( RES_CHRATR_FONTSIZE );
273 
274  rWrtSh.StartUndo( SwUndoId::INSATTR );
275  for( std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >& iPair : vItems )
276  {
277  std::unique_ptr<SwPaM> pPaM = std::move(iPair.second);
278  const SfxPoolItem* pItem = iPair.first;
279  aSetItem.GetItemSet().ClearItem();
280  rWrtSh.GetPaMAttr( pPaM.get(), aSetItem.GetItemSet() );
281  aAttrSet.SetRanges( aSetItem.GetItemSet().GetRanges() );
282 
283  pSize = static_cast<const SvxFontHeightItem*>( pItem );
284  if (pSize)
285  {
286  SvxFontHeightItem aSize(*pSize);
287 
288  sal_uInt32 nSize = aSize.GetHeight();
289 
290  if ( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
291  nSize = nFontMaxSz;
292  else if ( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
293  nSize = nFontInc;
294 
295  aSize.SetHeight( nSize );
296  aSetItem.PutItemForScriptType( nScriptTypes, aSize );
297  aAttrSet.Put( aSetItem.GetItemSet() );
298  if( pColl )
299  pColl->SetFormatAttr( aAttrSet );
300  else
301  rWrtSh.SetAttrSet( aAttrSet, SetAttrMode::DEFAULT, pPaM.get() );
302  }
303  }
304  rWrtSh.EndUndo( SwUndoId::INSATTR );
305  rReq.Done();
306  }
307  break;
308 
309  default:
310  OSL_FAIL("wrong dispatcher");
311  return;
312  }
313 }
314 
316 {
317  SvxAdjust eAdjst;
318  sal_uInt16 ePropL;
319  const SfxItemSet* pArgs = rReq.GetArgs();
320 
321  // Get both attributes immediately isn't more expensive!!
322  SfxItemSet aSet( GetPool(),
325 
326  sal_uInt16 nSlot = rReq.GetSlot();
327  switch (nSlot)
328  {
329  case SID_ATTR_PARA_ADJUST:
330  {
331  if( pArgs && SfxItemState::SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
332  {
333  const SvxAdjustItem& rAdj = pArgs->Get(RES_PARATR_ADJUST);
334  SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
335  if ( rAdj.GetAdjust() == SvxAdjust::Block )
336  {
337  aAdj.SetLastBlock( rAdj.GetLastBlock() );
338  aAdj.SetOneWord( rAdj.GetOneWord() );
339  }
340 
341  aSet.Put(aAdj);
342  }
343  }
344  break;
345  case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SvxAdjust::Left; goto SET_ADJUST;
346  case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SvxAdjust::Right; goto SET_ADJUST;
347  case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SvxAdjust::Center; goto SET_ADJUST;
348  case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SvxAdjust::Block; goto SET_ADJUST;
349 SET_ADJUST:
350  {
351  aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
352  rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), true ) );
353  }
354  break;
355 
356  case SID_ATTR_PARA_LINESPACE:
357  if(pArgs && SfxItemState::SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
358  {
359  SvxLineSpacingItem aLineSpace = static_cast<const SvxLineSpacingItem&>( pArgs->Get(
360  GetPool().GetWhich(nSlot)));
361  aSet.Put( aLineSpace );
362  }
363  break;
364  case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE;
365  case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE;
366  case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE;
367 
368 SET_LINESPACE:
369  {
370 
371  SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
372  aLineSpacing.SetLineSpaceRule( SvxLineSpaceRule::Auto );
373  if( 100 == ePropL )
374  aLineSpacing.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
375  else
376  aLineSpacing.SetPropLineSpace(ePropL);
377  aSet.Put( aLineSpacing );
378  }
379  break;
380 
381  case SID_ATTR_PARA_LEFT_TO_RIGHT :
382  case SID_ATTR_PARA_RIGHT_TO_LEFT :
383  {
384  SfxItemSet aAdjustSet( GetPool(),
385  svl::Items<RES_PARATR_ADJUST, RES_PARATR_ADJUST> );
386  GetShell().GetCurAttr(aAdjustSet);
387  bool bChgAdjust = false;
388  SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, false);
389  if(eAdjustState >= SfxItemState::DEFAULT)
390  {
391  SvxAdjust eAdjust =
392  aAdjustSet.Get(RES_PARATR_ADJUST).GetAdjust();
393  bChgAdjust = (SvxAdjust::Left == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
394  (SvxAdjust::Right == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
395  }
396  else
397  bChgAdjust = true;
398 
399  SvxFrameDirection eFrameDirection =
400  (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
401  SvxFrameDirection::Horizontal_LR_TB : SvxFrameDirection::Horizontal_RL_TB;
402  aSet.Put( SvxFrameDirectionItem( eFrameDirection, RES_FRAMEDIR ) );
403 
404  if (bChgAdjust)
405  {
406  SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
407  SvxAdjust::Left : SvxAdjust::Right;
408  SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
409  aSet.Put( aAdjust );
410  aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
411  GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
412  // Toggle numbering alignment
413  const SwNumRule* pCurRule = GetShell().GetNumRuleAtCurrCursorPos();
414  if( pCurRule )
415  {
416  SvxNumRule aRule = pCurRule->MakeSvxNumRule();
417 
418  for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
419  {
420  SvxNumberFormat aFormat(aRule.GetLevel(i));
421  if(SvxAdjust::Left == aFormat.GetNumAdjust())
422  aFormat.SetNumAdjust( SvxAdjust::Right );
423 
424  else if(SvxAdjust::Right == aFormat.GetNumAdjust())
425  aFormat.SetNumAdjust( SvxAdjust::Left );
426 
427  aRule.SetLevel(i, aFormat, aRule.Get(i) != nullptr);
428  }
429  SwNumRule aSetRule( pCurRule->GetName(),
430  pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
431  aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
432  aSetRule.SetAutoRule( true );
433  // no start or continuation of a list - list style is only changed
434  GetShell().SetCurNumRule( aSetRule, false );
435  }
436  }
437  }
438  break;
439 
440  default:
441  OSL_FAIL("wrong dispatcher");
442  return;
443  }
444  SwWrtShell& rWrtSh = GetShell();
445  SwTextFormatColl* pColl = rWrtSh.GetCurTextFormatColl();
446  if(pColl && pColl->IsAutoUpdateFormat())
447  {
448  rWrtSh.AutoUpdatePara(pColl, aSet);
449  }
450  else
451  rWrtSh.SetAttrSet( aSet, SetAttrMode::DEFAULT, nullptr, true);
452  rReq.Done();
453 }
454 
456 {
457  SwWrtShell &rSh = GetShell();
458  const SfxItemSet *pArgs = rReq.GetArgs();
459  const SfxPoolItem *pItem = nullptr;
460 
461  sal_uInt16 nSlot = rReq.GetSlot();
462  if(pArgs)
463  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
464  switch ( nSlot )
465  {
467  if( pItem )
468  {
469  OUString sCharStyleName = static_cast<const SfxStringItem*>(pItem)->GetValue();
470  SfxItemSet aSet(GetPool(), svl::Items<RES_PARATR_DROP, RES_PARATR_DROP>);
471  rSh.GetCurAttr(aSet);
472  SwFormatDrop aDropItem(aSet.Get(RES_PARATR_DROP));
473  SwCharFormat* pFormat = nullptr;
474  if(!sCharStyleName.isEmpty())
475  pFormat = rSh.FindCharFormatByName( sCharStyleName );
476  aDropItem.SetCharFormat( pFormat );
477  aSet.Put(aDropItem);
478  rSh.SetAttrSet(aSet);
479  }
480  break;
481  case FN_FORMAT_DROPCAPS:
482  {
483  if(pItem)
484  {
485  rSh.SetAttrItem(*pItem);
486  rReq.Done();
487  }
488  else
489  {
491  HINT_END, HINT_END>);
492  rSh.GetCurAttr(aSet);
495  if (pDlg->Execute() == RET_OK)
496  {
497  rSh.StartAction();
498  rSh.StartUndo( SwUndoId::START );
499  if ( SfxItemState::SET == aSet.GetItemState(HINT_END,false,&pItem) )
500  {
501  if ( !static_cast<const SfxStringItem*>(pItem)->GetValue().isEmpty() )
502  rSh.ReplaceDropText(static_cast<const SfxStringItem*>(pItem)->GetValue());
503  }
504  rSh.SetAttrSet(*pDlg->GetOutputItemSet());
505  rSh.EndUndo( SwUndoId::END );
506  rSh.EndAction();
507  rReq.Done(*pDlg->GetOutputItemSet());
508  }
509  }
510  }
511  break;
512  case SID_ATTR_PARA_PAGEBREAK:
513  if(pItem)
514  {
515  rSh.SetAttrItem( *pItem );
516  rReq.Done();
517  }
518  break;
519  case SID_ATTR_PARA_MODEL:
520  {
521  if(pItem)
522  {
523  SfxItemSet aCoreSet( GetPool(),
525  SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL>);
526  aCoreSet.Put(*pItem);
527  SfxToSwPageDescAttr( rSh, aCoreSet);
528  rSh.SetAttrSet(aCoreSet);
529  rReq.Done();
530  }
531  }
532  break;
533 
534  default:
535  OSL_FAIL("wrong dispatcher");
536  return;
537  }
538 }
539 
541 {
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);
548 
549  SfxWhichIter aIter(rSet);
550  sal_uInt16 nSlot = aIter.FirstWhich();
551  bool bFlag = false;
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);
557 
558  if( SfxItemState::DEFAULT == eState )
559  pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
560  if( SfxItemState::DEFAULT <= eState )
561  {
562  eAdjust = static_cast<const SvxAdjustItem* >( pItem)->GetAdjust();
563  bAdjustGood = true;
564  }
565 
566  short nEsc = 0;
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();
572 
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 )
579  {
580  if(SvxInterLineSpaceRule::Off ==
581  static_cast<const SvxLineSpacingItem* >(pItem)->GetInterLineSpaceRule())
582  nLineSpace = 100;
583  else
584  nLineSpace = static_cast<const SvxLineSpacingItem* >(pItem)->GetPropLineSpace();
585  }
586 
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();
593 
594  while (nSlot)
595  {
596  switch(nSlot)
597  {
598  case FN_SET_SUPER_SCRIPT:
599  bFlag = 0 < nEsc;
600  break;
601  case FN_SET_SUB_SCRIPT:
602  bFlag = 0 > nEsc;
603  break;
604  case FN_SET_SMALL_CAPS:
605  bFlag = eCaseMap == SvxCaseMap::SmallCaps;
606  break;
607  case SID_ATTR_PARA_ADJUST_LEFT:
608  if (!bAdjustGood)
609  {
610  rSet.InvalidateItem( nSlot );
611  nSlot = 0;
612  }
613  else
614  bFlag = SvxAdjust::Left == eAdjust;
615  break;
616  case SID_ATTR_PARA_ADJUST_RIGHT:
617  if (!bAdjustGood)
618  {
619  rSet.InvalidateItem( nSlot );
620  nSlot = 0;
621  }
622  else
623  bFlag = SvxAdjust::Right == eAdjust;
624  break;
625  case SID_ATTR_PARA_ADJUST_CENTER:
626  if (!bAdjustGood)
627  {
628  rSet.InvalidateItem( nSlot );
629  nSlot = 0;
630  }
631  else
632  bFlag = SvxAdjust::Center == eAdjust;
633  break;
634  case SID_ATTR_PARA_ADJUST_BLOCK:
635  {
636  if (!bAdjustGood)
637  {
638  rSet.InvalidateItem( nSlot );
639  nSlot = 0;
640  }
641  else
642  {
643  bFlag = SvxAdjust::Block == eAdjust;
644  sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
645  if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_FULL_STYLES ))
646  {
647  rSet.DisableItem( nSlot );
648  nSlot = 0;
649  }
650  }
651  }
652  break;
653  case SID_ATTR_PARA_LINESPACE_10:
654  bFlag = nLineSpace == 100;
655  break;
656  case SID_ATTR_PARA_LINESPACE_15:
657  bFlag = nLineSpace == 150;
658  break;
659  case SID_ATTR_PARA_LINESPACE_20:
660  bFlag = nLineSpace == 200;
661  break;
662  case FN_GROW_FONT_SIZE:
663  case FN_SHRINK_FONT_SIZE:
664  {
665  SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
666  *rSet.GetPool() );
667  aSetItem.GetItemSet().Put( aCoreSet, false );
668  const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
669  aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) );
670 
671  if( pSize ) // selection is of one size
672  {
673  sal_uInt32 nSize = pSize->GetHeight();
674  if( nSize == nFontMaxSz )
676  else if( nSize == nFontInc )
678  }
679  else
680  {
681  std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >>
682  vFontHeight = rSh.GetItemWithPaM( RES_CHRATR_FONTSIZE );
683  for ( const std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>& aIt : vFontHeight )
684  {
685  if (!aIt.first)
686  {
689  break;
690  }
691  pSize = static_cast<const SvxFontHeightItem*>( aIt.first );
692  sal_uInt32 nSize = pSize->GetHeight();
693  if( nSize == nFontMaxSz )
695  else if( nSize == nFontInc )
697  }
698  }
699  nSlot = 0;
700  }
701  break;
702  case SID_ULINE_VAL_NONE:
703  case SID_ULINE_VAL_SINGLE:
704  case SID_ULINE_VAL_DOUBLE:
705  case SID_ULINE_VAL_DOTTED:
706  {
707  eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
708  if( eState >= SfxItemState::DEFAULT )
709  {
710  FontLineStyle eLineStyle = aCoreSet.Get(RES_CHRATR_UNDERLINE).GetLineStyle();
711 
712  switch (nSlot)
713  {
714  case SID_ULINE_VAL_NONE:
715  rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_NONE));
716  break;
717  case SID_ULINE_VAL_SINGLE:
718  rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_SINGLE));
719  break;
720  case SID_ULINE_VAL_DOUBLE:
721  rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_DOUBLE));
722  break;
723  case SID_ULINE_VAL_DOTTED:
724  rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_DOTTED));
725  break;
726  }
727  }
728  else
729  rSet.InvalidateItem(nSlot);
730  nSlot = 0;
731  }
732  break;
733  case SID_ATTR_PARA_ADJUST:
734  if (!bAdjustGood)
735  rSet.InvalidateItem( nSlot );
736  else
737  rSet.Put(SvxAdjustItem(eAdjust, SID_ATTR_PARA_ADJUST ));
738  nSlot = 0;
739  break;
740  case SID_ATTR_PARA_LRSPACE:
741  case SID_ATTR_PARA_LEFTSPACE:
742  case SID_ATTR_PARA_RIGHTSPACE:
743  case SID_ATTR_PARA_FIRSTLINESPACE:
744  {
745  eState = aCoreSet.GetItemState(RES_LR_SPACE);
746  if( eState >= SfxItemState::DEFAULT )
747  {
748  SvxLRSpaceItem aLR = aCoreSet.Get( RES_LR_SPACE );
749  aLR.SetWhich(nSlot);
750  rSet.Put(aLR);
751  }
752  else
753  rSet.InvalidateItem(nSlot);
754  nSlot = 0;
755  }
756  break;
757 
758  case SID_ATTR_PARA_LEFT_TO_RIGHT :
759  case SID_ATTR_PARA_RIGHT_TO_LEFT :
760  {
761  if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
762  {
763  rSet.DisableItem( nSlot );
764  nSlot = 0;
765  }
766  else
767  {
768  // is the item set?
769  sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
770  if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
771  aCoreSet.GetItemState( RES_FRAMEDIR, false ) >= SfxItemState::DEFAULT)
772  {
773  SvxFrameDirection eFrameDir =
774  aCoreSet.Get(RES_FRAMEDIR).GetValue();
775  if (SvxFrameDirection::Environment == eFrameDir)
776  {
777  eFrameDir = rSh.IsInRightToLeftText() ?
778  SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB;
779  }
780  bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
781  SvxFrameDirection::Horizontal_LR_TB == eFrameDir) ||
782  (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
783  SvxFrameDirection::Horizontal_RL_TB == eFrameDir);
784  }
785  else
786  {
787  rSet.InvalidateItem(nSlot);
788  nSlot = 0;
789  }
790  }
791  }
792  break;
793 
794  case SID_ATTR_CHAR_LANGUAGE:
795  case SID_ATTR_CHAR_KERNING:
796  case RES_PARATR_DROP:
797  {
798 #if OSL_DEBUG_LEVEL > 1
799  const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), true);
800  rSet.Put(rItem);
801 #else
802  rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot)));
803 #endif
804  nSlot = 0;
805  }
806  break;
807  case SID_ATTR_PARA_MODEL:
808  {
809  SfxItemSet aTemp(GetPool(),
811  SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL>);
812  aTemp.Put(aCoreSet);
813  ::SwToSfxPageDescAttr(aTemp);
814  rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
815  nSlot = 0;
816  }
817  break;
818  case RES_TXTATR_INETFMT:
819  {
820  SfxItemSet aSet(GetPool(), svl::Items<RES_TXTATR_INETFMT, RES_TXTATR_INETFMT>);
821  rSh.GetCurAttr(aSet);
822  const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT);
823  rSet.Put(rItem);
824  nSlot = 0;
825  }
826  break;
827 
828  default:
829  // Do nothing
830  nSlot = 0;
831  break;
832 
833  }
834  if( nSlot )
835  {
836  aFlagItem.SetWhich( nSlot );
837  aFlagItem.SetValue( bFlag );
838  rSet.Put( aFlagItem );
839  }
840  nSlot = aIter.NextWhich();
841  }
842 
843  rSet.Put(aCoreSet,false);
844 }
845 
846 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
SwTextFormatColl * GetCurTextFormatColl() const
Get the named paragraph format of the current selection.
Definition: edattr.cxx:244
constexpr sal_uInt16 HINT_END(RES_TBX_DUMMY)
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
WhichRangesContainer const aTextFormatCollSetRange(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_PARATR_BEGIN, RES_PARATR_END-1, RES_PARATR_LIST_LEVEL, RES_PARATR_LIST_LEVEL, RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
SwView & GetView()
Definition: basesh.hxx:59
void PutItemForScriptType(SvtScriptType nScriptType, const SfxPoolItem &rItem)
constexpr TypedWhichId< SvxEscapementItem > RES_CHRATR_ESCAPEMENT(6)
void SwToSfxPageDescAttr(SfxItemSet &rSet)
Definition: uitool.cxx:726
SvxAdjust GetAdjust() const
#define FN_SET_SUPER_SCRIPT
Definition: cmdid.h:308
void SetState(const SfxItemSet &rSet)
static constexpr auto Items
void ExecParaAttrArgs(SfxRequest &)
Definition: txtattr.cxx:455
std::string GetValue
const SwNumRule * GetNumRuleAtCurrCursorPos() const
Definition: ednumber.cxx:727
SvxCaseMap
bool IsTableMode() const
Definition: crsrsh.hxx:642
OUString sCharStyleName
SwWrtShell & GetShell()
Definition: basesh.cxx:2774
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
const SwPosition * GetMark() const
Definition: pam.hxx:209
void SetAttrSet(const SfxItemSet &, SetAttrMode nFlags=SetAttrMode::DEFAULT, SwPaM *pCursor=nullptr, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:151
const SvxNumberFormat * Get(sal_uInt16 nLevel) const
void SetHeight(sal_uInt32 nNewHeight, const sal_uInt16 nNewProp=100, MapUnit eUnit=MapUnit::MapRelative)
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 FirstWhich()
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
const OUString & GetName() const
Definition: numrule.hxx:225
bool IsSelFullPara() const
Definition: crsrsh.cxx:3400
SvxFrameDirection
void Done(bool bRemove=false)
void ExecParaAttr(SfxRequest &)
Definition: txtattr.cxx:315
#define DFLT_ESC_AUTO_SUB
void GetAttrState(SfxItemSet &)
Definition: txtattr.cxx:540
void AutoUpdatePara(SwTextFormatColl *pColl, const SfxItemSet &rStyleSet, SwPaM *pPaM=nullptr)
Definition: wrtsh1.cxx:1617
const SfxItemSet * GetArgs() const
void SfxToSwPageDescAttr(const SwWrtShell &rShell, SfxItemSet &rSet)
Definition: uitool.cxx:665
virtual bool SetFormatAttr(const SfxPoolItem &rAttr) override
Override to recognize changes on the and register/unregister the paragragh style at t...
Definition: fmtcol.cxx:343
void SetLineSpaceRule(SvxLineSpaceRule e)
#define FN_UPDATE_STYLE_BY_EXAMPLE
Definition: cmdid.h:324
SvxAdjust GetOneWord() const
sal_uInt16 NextWhich()
void SetLastBlock(const SvxAdjust eType)
void SetCurNumRule(const SwNumRule &, const bool bCreateNewList, const OUString &sContinuedListId=OUString(), const bool bResetIndentAttrs=false)
Optional parameter (default value false).
Definition: ednumber.cxx:771
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
constexpr TypedWhichId< SvxCaseMapItem > RES_CHRATR_CASEMAP(RES_CHRATR_BEGIN)
const SwView & GetView() const
Definition: wrtsh.hxx:431
void SetPropLineSpace(const sal_uInt16 nProp)
LINESTYLE_NONE
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
#define DFLT_ESC_AUTO_SUPER
#define FN_SHRINK_FONT_SIZE
Definition: cmdid.h:306
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
SfxItemPool & GetPool() const
SvxNumRule MakeSvxNumRule() const
Definition: number.cxx:901
sal_uInt16 GetINetFormatId() const
Definition: fmtinfmt.hxx:107
virtual VclPtr< SfxAbstractDialog > CreateSwDropCapsDialog(weld::Window *pParent, const SfxItemSet &rSet)=0
void SetVisitedFormatAndId(const OUString &rNm, const sal_uInt16 nId)
Definition: fmtinfmt.hxx:112
void SetNumAdjust(SvxAdjust eSet)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void ExecCharAttr(SfxRequest &)
Definition: txtattr.cxx:60
const sal_uInt32 nFontInc
Definition: txtattr.cxx:57
sal_uInt16 GetVisitedFormatId() const
Definition: fmtinfmt.hxx:125
#define FN_SET_SUB_SCRIPT
Definition: cmdid.h:309
SvtScriptType
bool IsInRightToLeftText() const
Definition: crsrsh.cxx:3443
const sal_uInt32 nFontMaxSz
Definition: txtattr.cxx:58
SvtScriptType GetScriptType() const
returns the script type of the selection
Definition: edattr.cxx:676
bool HasSelection() const
Definition: wrtsh.hxx:144
#define SW_MOD()
Definition: swmodule.hxx:256
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: edfmt.cxx:149
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SvxAdjust
int i
const SwPosition * GetPoint() const
Definition: pam.hxx:207
void ExecCharAttrArgs(SfxRequest &)
Definition: txtattr.cxx:203
SfxBindings & GetBindings()
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:112
sal_uInt16 Count() const
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
bool DontExpandFormat()
If Cursor is at the end of a character style in which the DontExpand-flag is not yet set...
Definition: editsh.cxx:734
SvxAdjust GetLastBlock() const
const SvxNumberFormat & GetLevel(sal_uInt16 nLevel) const
sal_uInt16 GetLevelCount() const
LINESTYLE_SINGLE
constexpr TypedWhichId< SvxLineSpacingItem > RES_PARATR_LINESPACING(RES_PARATR_BEGIN)
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
bool IsAutoUpdateFormat() const
Query / set bAutoUpdateFormat-flag.
Definition: format.hxx:172
bool HasReadonlySel() const
Definition: crsrsh.cxx:3346
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
Represents the style of a text portion.
Definition: charfmt.hxx:26
SfxItemPool * GetPool() const
void SetValue(bool const bTheValue)
SwDocShell * GetDocShell()
Definition: view.cxx:1127
std::vector< std::pair< const SfxPoolItem *, std::unique_ptr< SwPaM > > > GetItemWithPaM(sal_uInt16 nWhich)
Get RES_CHRATR_* items of one type in the current selection.
Definition: edattr.cxx:294
bool GetPaMAttr(SwPaM *pPaM, SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Apply / remove attributes.
Definition: edattr.cxx:59
#define FN_SET_SMALL_CAPS
Definition: cmdid.h:310
#define FN_DROP_CHAR_STYLE_NAME
Definition: cmdid.h:818
void StartAction()
Definition: crsrsh.cxx:227
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:79
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void SetInterLineSpaceRule(SvxInterLineSpaceRule e)
const OUString & GetVisitedFormat() const
Definition: fmtinfmt.hxx:120
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
sal_uInt32 GetHeight() const
SfxItemState
void DisableItem(sal_uInt16 nWhich)
HTMLMODE_SOME_STYLES
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
#define GetWhich(nSlot)
LINESTYLE_DOTTED
void SetWhich(sal_uInt16 nId)
RET_OK
void SetSvxRule(const SvxNumRule &, SwDoc *pDoc)
Definition: number.cxx:889
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:177
#define FN_GROW_FONT_SIZE
Definition: cmdid.h:305
#define FN_TXTATR_INET
Definition: cmdid.h:734
SvxEscapement
HTMLMODE_FULL_STYLES
void AppendItem(const SfxPoolItem &)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
const OUString & GetINetFormat() const
Definition: fmtinfmt.hxx:102
bool IsEndPara() const
Definition: crsrsh.cxx:1114
LINESTYLE_DOUBLE
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:62
FontLineStyle
void ReplaceDropText(const OUString &rStr, SwPaM *pPaM=nullptr)
Definition: editsh.cxx:504
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
void QuickUpdateStyle()
Definition: wrtsh1.cxx:1604
void SetINetFormatAndId(const OUString &rNm, const sal_uInt16 nId)
Definition: fmtinfmt.hxx:94
const SfxPoolItem * GetItemOfScript(SvtScriptType nScript) const
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
sal_Int16 GetCaseMap(sal_Int32 nToken)
#define FN_REMOVE_DIRECT_CHAR_FORMATS
Definition: cmdid.h:482
#define FN_FORMAT_DROPCAPS
Definition: cmdid.h:319
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:244