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