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