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