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 rSh.SetAttrItem( aEscape );
119 rReq.AppendItem( aEscape );
120 rReq.Done();
121 }
122 break;
123
125 {
126 SvxCaseMap eCaseMap = SvxCaseMap::SmallCaps;
127 switch (eState)
128 {
129 case STATE_TOGGLE:
130 {
131 SvxCaseMap eTmpCaseMap = aSet.Get(RES_CHRATR_CASEMAP).GetCaseMap();
132 if (eTmpCaseMap == SvxCaseMap::SmallCaps)
133 eCaseMap = SvxCaseMap::NotMapped;
134 }
135 break;
136 case STATE_ON:
137 // Nothing to do, already set.
138 break;
139 case STATE_OFF:
140 eCaseMap = SvxCaseMap::NotMapped;
141 break;
142 }
143 SvxCaseMapItem aCaseMap(eCaseMap, RES_CHRATR_CASEMAP);
144 rSh.SetAttrItem(aCaseMap);
145 rReq.AppendItem(aCaseMap);
146 rReq.Done();
147 }
148 break;
149
151 rSh.QuickUpdateStyle();
152 rReq.Done();
153 break;
154
155 case SID_ULINE_VAL_NONE:
156 {
158 rSh.SetAttrItem( aUnderline );
159 rReq.AppendItem( aUnderline );
160 rReq.Done();
161 break;
162 }
163
164 case SID_ULINE_VAL_SINGLE:
165 case SID_ULINE_VAL_DOUBLE:
166 case SID_ULINE_VAL_DOTTED:
167 {
168 FontLineStyle eOld = aSet.Get(RES_CHRATR_UNDERLINE).GetLineStyle();
169 FontLineStyle eNew = eOld;
170
171 switch (nWhich)
172 {
173 case SID_ULINE_VAL_SINGLE:
174 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
175 break;
176 case SID_ULINE_VAL_DOUBLE:
177 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
178 break;
179 case SID_ULINE_VAL_DOTTED:
180 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
181 break;
182 }
183
184 SvxUnderlineItem aUnderline(eNew, RES_CHRATR_UNDERLINE );
185 rSh.SetAttrItem( aUnderline );
186 rReq.AppendItem( aUnderline );
187 rReq.Done();
188 }
189 break;
191 if( !rSh.HasReadonlySel() && rSh.IsEndPara())
192 rSh.DontExpandFormat();
193 break;
194 default:
195 OSL_FAIL("wrong dispatcher");
196 return;
197 }
198}
199
201{
202 sal_uInt16 nSlot = rReq.GetSlot();
203 const SfxItemSet* pArgs = rReq.GetArgs();
204 bool bArgs = pArgs != nullptr && pArgs->Count() > 0;
205 SwWrtShell& rWrtSh = GetShell();
206 SwTextFormatColl* pColl = nullptr;
207
208 // Is only set if the whole paragraph is selected and AutoUpdateFormat is set.
209 if (rWrtSh.HasSelection() && rWrtSh.IsSelFullPara())
210 {
211 pColl = rWrtSh.GetCurTextFormatColl();
212 if ( pColl && !pColl->IsAutoUpdateOnDirectFormat() )
213 pColl = nullptr;
214 }
215 SfxItemPool& rPool = GetPool();
216 sal_uInt16 nWhich = rPool.GetWhich( nSlot );
217 switch (nSlot)
218 {
219 case FN_TXTATR_INET:
220 // Special treatment of the PoolId of the SwFormatInetFormat
221 if(bArgs)
222 {
223 const SfxPoolItem& rItem = pArgs->Get( nWhich );
224
225 SwFormatINetFormat aINetFormat( static_cast<const SwFormatINetFormat&>(rItem) );
226 if ( USHRT_MAX == aINetFormat.GetVisitedFormatId() )
227 {
228 OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected visited character format ID at hyperlink attribute" );
229 aINetFormat.SetVisitedFormatAndId(
230 aINetFormat.GetVisitedFormat(),
232 }
233 if ( USHRT_MAX == aINetFormat.GetINetFormatId() )
234 {
235 OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected unvisited character format ID at hyperlink attribute" );
236 aINetFormat.SetINetFormatAndId(
237 aINetFormat.GetINetFormat(),
239 }
240
241 if ( pColl )
242 pColl->SetFormatAttr( aINetFormat );
243 else
244 rWrtSh.SetAttrItem( aINetFormat );
245 rReq.Done();
246 }
247 break;
248
251 {
252 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
253 rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
254 SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
255
256 SvtScriptType nScriptTypes = rWrtSh.GetScriptType();
257 const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
258 aSetItem.GetItemOfScript( nScriptTypes ) ) );
259 std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >> vItems;
260 // simple case where selected text has one size and
261 // (tdf#124919) selection is not multiple table cells
262 if (pSize && !rWrtSh.IsTableMode())
263 {
264 // must create new one, otherwise document is without pam
265 SwPaM* pPaM = rWrtSh.GetCursor();
266 vItems.emplace_back( pSize, std::make_unique<SwPaM>( *(pPaM->GetMark()), *(pPaM->GetPoint())) );
267 }
268 else
269 vItems = rWrtSh.GetItemWithPaM( RES_CHRATR_FONTSIZE );
270
272 for( std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >& iPair : vItems )
273 {
274 std::unique_ptr<SwPaM> pPaM = std::move(iPair.second);
275 const SfxPoolItem* pItem = iPair.first;
276 aSetItem.GetItemSet().ClearItem();
277 rWrtSh.GetPaMAttr( pPaM.get(), aSetItem.GetItemSet() );
278 aAttrSet.SetRanges( aSetItem.GetItemSet().GetRanges() );
279
280 pSize = static_cast<const SvxFontHeightItem*>( pItem );
281 if (pSize)
282 {
283 SvxFontHeightItem aSize(*pSize);
284
285 sal_uInt32 nSize = aSize.GetHeight();
286
287 if ( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
288 nSize = nFontMaxSz;
289 else if ( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
290 nSize = nFontInc;
291
292 aSize.SetHeight( nSize );
293 aSetItem.PutItemForScriptType( nScriptTypes, aSize );
294 aAttrSet.Put( aSetItem.GetItemSet() );
295 if( pColl )
296 pColl->SetFormatAttr( aAttrSet );
297 else
298 rWrtSh.SetAttrSet( aAttrSet, SetAttrMode::DEFAULT, pPaM.get() );
299 }
300 }
301 rWrtSh.EndUndo( SwUndoId::INSATTR );
302 rReq.Done();
303 }
304 break;
305
306 default:
307 OSL_FAIL("wrong dispatcher");
308 return;
309 }
310}
311
313{
314 SvxAdjust eAdjst;
315 sal_uInt16 ePropL;
316 const SfxItemSet* pArgs = rReq.GetArgs();
317
318 // Get both attributes immediately isn't more expensive!!
322
323 sal_uInt16 nSlot = rReq.GetSlot();
324 switch (nSlot)
325 {
326 case SID_ATTR_PARA_ADJUST:
327 {
328 if( pArgs && SfxItemState::SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
329 {
330 const SvxAdjustItem& rAdj = pArgs->Get(RES_PARATR_ADJUST);
332 if ( rAdj.GetAdjust() == SvxAdjust::Block )
333 {
334 aAdj.SetLastBlock( rAdj.GetLastBlock() );
335 aAdj.SetOneWord( rAdj.GetOneWord() );
336 }
337
338 aSet.Put(aAdj);
339 }
340 }
341 break;
342 case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SvxAdjust::Left; goto SET_ADJUST;
343 case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SvxAdjust::Right; goto SET_ADJUST;
344 case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SvxAdjust::Center; goto SET_ADJUST;
345 case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SvxAdjust::Block; goto SET_ADJUST;
346SET_ADJUST:
347 {
348 aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
349 rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), true ) );
350 }
351 break;
352
353 case SID_ATTR_PARA_LINESPACE:
354 if(pArgs && SfxItemState::SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
355 {
356 SvxLineSpacingItem aLineSpace = static_cast<const SvxLineSpacingItem&>( pArgs->Get(
357 GetPool().GetWhich(nSlot)));
358 aSet.Put( aLineSpace );
359 }
360 break;
361 case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE;
362 case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE;
363 case SID_ATTR_PARA_LINESPACE_115: ePropL = 115; goto SET_LINESPACE;
364 case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE;
365
366SET_LINESPACE:
367 {
368
369 SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
370 aLineSpacing.SetLineSpaceRule( SvxLineSpaceRule::Auto );
371 if( 100 == ePropL )
372 aLineSpacing.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
373 else
374 aLineSpacing.SetPropLineSpace(ePropL);
375 aSet.Put( aLineSpacing );
376 }
377 break;
378
379 case SID_ATTR_PARA_LEFT_TO_RIGHT :
380 case SID_ATTR_PARA_RIGHT_TO_LEFT :
381 {
383 GetShell().GetCurAttr(aAdjustSet);
384 bool bChgAdjust = false;
385 SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, false);
386 if(eAdjustState >= SfxItemState::DEFAULT)
387 {
388 SvxAdjust eAdjust =
389 aAdjustSet.Get(RES_PARATR_ADJUST).GetAdjust();
390 bChgAdjust = (SvxAdjust::Left == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
391 (SvxAdjust::Right == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
392 }
393 else
394 bChgAdjust = true;
395
396 SvxFrameDirection eFrameDirection =
397 (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
398 SvxFrameDirection::Horizontal_LR_TB : SvxFrameDirection::Horizontal_RL_TB;
399 aSet.Put( SvxFrameDirectionItem( eFrameDirection, RES_FRAMEDIR ) );
400
401 if (bChgAdjust)
402 {
403 SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
404 SvxAdjust::Left : SvxAdjust::Right;
405 SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
406 aSet.Put( aAdjust );
407 aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
408 GetView().GetViewFrame().GetBindings().SetState( aAdjust );
409 // Toggle numbering alignment
410 const SwNumRule* pCurRule = GetShell().GetNumRuleAtCurrCursorPos();
411 if( pCurRule )
412 {
413 SvxNumRule aRule = pCurRule->MakeSvxNumRule();
414
415 for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
416 {
417 SvxNumberFormat aFormat(aRule.GetLevel(i));
418 if(SvxAdjust::Left == aFormat.GetNumAdjust())
419 aFormat.SetNumAdjust( SvxAdjust::Right );
420
421 else if(SvxAdjust::Right == aFormat.GetNumAdjust())
422 aFormat.SetNumAdjust( SvxAdjust::Left );
423
424 aRule.SetLevel(i, aFormat, aRule.Get(i) != nullptr);
425 }
426 SwNumRule aSetRule( pCurRule->GetName(),
427 pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
428 aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
429 aSetRule.SetAutoRule( true );
430 // no start or continuation of a list - list style is only changed
431 GetShell().SetCurNumRule( aSetRule, false );
432 }
433 }
434 }
435 break;
436
437 default:
438 OSL_FAIL("wrong dispatcher");
439 return;
440 }
441 SwWrtShell& rWrtSh = GetShell();
442 SwTextFormatColl* pColl = rWrtSh.GetCurTextFormatColl();
443 if(pColl && pColl->IsAutoUpdateOnDirectFormat())
444 {
445 rWrtSh.AutoUpdatePara(pColl, aSet);
446 }
447 else
448 rWrtSh.SetAttrSet( aSet, SetAttrMode::DEFAULT, nullptr, true);
449 rReq.Done();
450}
451
453{
454 SwWrtShell &rSh = GetShell();
455 const SfxItemSet *pArgs = rReq.GetArgs();
456 const SfxPoolItem *pItem = nullptr;
457
458 sal_uInt16 nSlot = rReq.GetSlot();
459 if(pArgs)
460 pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
461 switch ( nSlot )
462 {
464 if( pItem )
465 {
466 OUString sCharStyleName = static_cast<const SfxStringItem*>(pItem)->GetValue();
468 rSh.GetCurAttr(aSet);
469 SwFormatDrop aDropItem(aSet.Get(RES_PARATR_DROP));
470 SwCharFormat* pFormat = nullptr;
471 if(!sCharStyleName.isEmpty())
472 pFormat = rSh.FindCharFormatByName( sCharStyleName );
473 aDropItem.SetCharFormat( pFormat );
474 aSet.Put(aDropItem);
475 rSh.SetAttrSet(aSet);
476 }
477 break;
479 {
480 if(pItem)
481 {
482 rSh.SetAttrItem(*pItem);
483 rReq.Done();
484 }
485 else
486 {
488 HINT_END, HINT_END> aSet(GetPool());
489 rSh.GetCurAttr(aSet);
492 if (pDlg->Execute() == RET_OK)
493 {
494 rSh.StartAction();
496 if ( const SfxStringItem* pHintItem = aSet.GetItemIfSet(HINT_END,false) )
497 {
498 if ( !pHintItem->GetValue().isEmpty() )
499 rSh.ReplaceDropText(pHintItem->GetValue());
500 }
501 rSh.SetAttrSet(*pDlg->GetOutputItemSet());
502 rSh.EndUndo( SwUndoId::END );
503 rSh.EndAction();
504 rReq.Done(*pDlg->GetOutputItemSet());
505 }
506 }
507 }
508 break;
509 case SID_ATTR_PARA_PAGEBREAK:
510 if(pItem)
511 {
512 rSh.SetAttrItem( *pItem );
513 rReq.Done();
514 }
515 break;
516 case SID_ATTR_PARA_MODEL:
517 {
518 if(pItem)
519 {
521 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL> aCoreSet( GetPool() );
522 aCoreSet.Put(*pItem);
523 SfxToSwPageDescAttr( rSh, aCoreSet);
524 rSh.SetAttrSet(aCoreSet);
525 rReq.Done();
526 }
527 }
528 break;
529
530 default:
531 OSL_FAIL("wrong dispatcher");
532 return;
533 }
534}
535
537{
538 SwWrtShell &rSh = GetShell();
539 SfxItemPool& rPool = GetPool();
540 SfxItemSet aCoreSet(rPool, aTextFormatCollSetRange);
541 // Request *all* text attributes from the core.
542 // fdo#78737: this is called from SvxRuler, which requires the list indents!
543 rSh.GetCurAttr(aCoreSet, /* bMergeIndentValuesOfNumRule = */ true);
544
545 SfxWhichIter aIter(rSet);
546 sal_uInt16 nSlot = aIter.FirstWhich();
547 bool bFlag = false;
548 SfxBoolItem aFlagItem;
549 const SfxPoolItem* pItem = nullptr;
550 SvxAdjust eAdjust = SvxAdjust::Left;
551 bool bAdjustGood = false;
552 SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, false, &pItem);
553
554 if( SfxItemState::DEFAULT == eState )
555 pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
556 if( SfxItemState::DEFAULT <= eState )
557 {
558 eAdjust = static_cast<const SvxAdjustItem* >( pItem)->GetAdjust();
559 bAdjustGood = true;
560 }
561
562 short nEsc = 0;
563 eState = aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, false, &pItem);
564 if( SfxItemState::DEFAULT == eState )
566 if( eState >= SfxItemState::DEFAULT )
567 nEsc = static_cast<const SvxEscapementItem* >(pItem)->GetEsc();
568
569 sal_uInt16 nLineSpace = 0;
570 eState = aCoreSet.GetItemState(RES_PARATR_LINESPACING, false, &pItem);
571 if( SfxItemState::DEFAULT == eState )
573 if( SfxItemState::DEFAULT <= eState &&
574 static_cast<const SvxLineSpacingItem* >(pItem)->GetLineSpaceRule() == SvxLineSpaceRule::Auto )
575 {
576 if(SvxInterLineSpaceRule::Off ==
577 static_cast<const SvxLineSpacingItem* >(pItem)->GetInterLineSpaceRule())
578 nLineSpace = 100;
579 else
580 nLineSpace = static_cast<const SvxLineSpacingItem* >(pItem)->GetPropLineSpace();
581 }
582
583 SvxCaseMap eCaseMap = SvxCaseMap::NotMapped;
584 eState = aCoreSet.GetItemState(RES_CHRATR_CASEMAP, false, &pItem);
585 if (eState == SfxItemState::DEFAULT)
586 pItem = &rPool.GetDefaultItem(RES_CHRATR_CASEMAP);
587 if (eState >= SfxItemState::DEFAULT)
588 eCaseMap = static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap();
589
590 while (nSlot)
591 {
592 switch(nSlot)
593 {
595 bFlag = 0 < nEsc;
596 break;
598 bFlag = 0 > nEsc;
599 break;
601 bFlag = eCaseMap == SvxCaseMap::SmallCaps;
602 break;
603 case SID_ATTR_PARA_ADJUST_LEFT:
604 if (!bAdjustGood)
605 {
606 rSet.InvalidateItem( nSlot );
607 nSlot = 0;
608 }
609 else
610 bFlag = SvxAdjust::Left == eAdjust;
611 break;
612 case SID_ATTR_PARA_ADJUST_RIGHT:
613 if (!bAdjustGood)
614 {
615 rSet.InvalidateItem( nSlot );
616 nSlot = 0;
617 }
618 else
619 bFlag = SvxAdjust::Right == eAdjust;
620 break;
621 case SID_ATTR_PARA_ADJUST_CENTER:
622 if (!bAdjustGood)
623 {
624 rSet.InvalidateItem( nSlot );
625 nSlot = 0;
626 }
627 else
628 bFlag = SvxAdjust::Center == eAdjust;
629 break;
630 case SID_ATTR_PARA_ADJUST_BLOCK:
631 {
632 if (!bAdjustGood)
633 {
634 rSet.InvalidateItem( nSlot );
635 nSlot = 0;
636 }
637 else
638 {
639 bFlag = SvxAdjust::Block == eAdjust;
640 sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
641 if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_FULL_STYLES ))
642 {
643 rSet.DisableItem( nSlot );
644 nSlot = 0;
645 }
646 }
647 }
648 break;
649 case SID_ATTR_PARA_LINESPACE_10:
650 bFlag = nLineSpace == 100;
651 break;
652 case SID_ATTR_PARA_LINESPACE_115:
653 bFlag = nLineSpace == 115;
654 break;
655 case SID_ATTR_PARA_LINESPACE_15:
656 bFlag = nLineSpace == 150;
657 break;
658 case SID_ATTR_PARA_LINESPACE_20:
659 bFlag = nLineSpace == 200;
660 break;
663 {
664 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
665 *rSet.GetPool() );
666 aSetItem.GetItemSet().Put( aCoreSet, false );
667 const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
668 aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) );
669
670 if( pSize ) // selection is of one size
671 {
672 sal_uInt32 nSize = pSize->GetHeight();
673 if( nSize == nFontMaxSz )
675 else if( nSize == nFontInc )
677 }
678 else
679 {
680 std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM> >>
681 vFontHeight = rSh.GetItemWithPaM( RES_CHRATR_FONTSIZE );
682 for ( const std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>& aIt : vFontHeight )
683 {
684 if (!aIt.first)
685 {
688 break;
689 }
690 pSize = static_cast<const SvxFontHeightItem*>( aIt.first );
691 sal_uInt32 nSize = pSize->GetHeight();
692 if( nSize == nFontMaxSz )
694 else if( nSize == nFontInc )
696 }
697 }
698 nSlot = 0;
699 }
700 break;
701 case SID_ULINE_VAL_NONE:
702 case SID_ULINE_VAL_SINGLE:
703 case SID_ULINE_VAL_DOUBLE:
704 case SID_ULINE_VAL_DOTTED:
705 {
706 eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
707 if( eState >= SfxItemState::DEFAULT )
708 {
709 FontLineStyle eLineStyle = aCoreSet.Get(RES_CHRATR_UNDERLINE).GetLineStyle();
710
711 switch (nSlot)
712 {
713 case SID_ULINE_VAL_NONE:
714 rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_NONE));
715 break;
716 case SID_ULINE_VAL_SINGLE:
717 rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_SINGLE));
718 break;
719 case SID_ULINE_VAL_DOUBLE:
720 rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_DOUBLE));
721 break;
722 case SID_ULINE_VAL_DOTTED:
723 rSet.Put(SfxBoolItem(nSlot, eLineStyle == LINESTYLE_DOTTED));
724 break;
725 }
726 }
727 else
728 rSet.InvalidateItem(nSlot);
729 nSlot = 0;
730 }
731 break;
732 case SID_ATTR_PARA_ADJUST:
733 if (!bAdjustGood)
734 rSet.InvalidateItem( nSlot );
735 else
736 rSet.Put(SvxAdjustItem(eAdjust, SID_ATTR_PARA_ADJUST ));
737 nSlot = 0;
738 break;
739 case SID_ATTR_PARA_LRSPACE:
740 case SID_ATTR_PARA_LEFTSPACE:
741 case SID_ATTR_PARA_RIGHTSPACE:
742 case SID_ATTR_PARA_FIRSTLINESPACE:
743 {
744 eState = aCoreSet.GetItemState(RES_MARGIN_FIRSTLINE);
745 eState = std::min(aCoreSet.GetItemState(RES_MARGIN_TEXTLEFT), eState);
746 eState = std::min(aCoreSet.GetItemState(RES_MARGIN_RIGHT), eState);
747 if( eState >= SfxItemState::DEFAULT )
748 {
750 SvxFirstLineIndentItem const& rFirstLine(aCoreSet.Get(RES_MARGIN_FIRSTLINE));
751 SvxTextLeftMarginItem const& rLeftMargin(aCoreSet.Get(RES_MARGIN_TEXTLEFT));
752 SvxRightMarginItem const& rRightMargin(aCoreSet.Get(RES_MARGIN_RIGHT));
754 aLR.SetAutoFirst(rFirstLine.IsAutoFirst());
755 aLR.SetTextLeft(rLeftMargin.GetTextLeft(), rLeftMargin.GetPropLeft());
756 aLR.SetRight(rRightMargin.GetRight(), rRightMargin.GetPropRight());
757 aLR.SetWhich(nSlot);
758 rSet.Put(aLR);
759 }
760 else
761 rSet.InvalidateItem(nSlot);
762 nSlot = 0;
763 }
764 break;
765
766 case SID_ATTR_PARA_LEFT_TO_RIGHT :
767 case SID_ATTR_PARA_RIGHT_TO_LEFT :
768 {
770 {
771 rSet.DisableItem( nSlot );
772 nSlot = 0;
773 }
774 else
775 {
776 // is the item set?
777 sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
778 if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
779 aCoreSet.GetItemState( RES_FRAMEDIR, false ) >= SfxItemState::DEFAULT)
780 {
781 SvxFrameDirection eFrameDir =
782 aCoreSet.Get(RES_FRAMEDIR).GetValue();
783 if (SvxFrameDirection::Environment == eFrameDir)
784 {
785 eFrameDir = rSh.IsInRightToLeftText() ?
786 SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB;
787 }
788 bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
789 SvxFrameDirection::Horizontal_LR_TB == eFrameDir) ||
790 (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
791 SvxFrameDirection::Horizontal_RL_TB == eFrameDir);
792 }
793 else
794 {
795 rSet.InvalidateItem(nSlot);
796 nSlot = 0;
797 }
798 }
799 }
800 break;
801
802 case SID_ATTR_CHAR_LANGUAGE:
803 case SID_ATTR_CHAR_KERNING:
804 case RES_PARATR_DROP:
805 {
806 rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot)));
807 nSlot = 0;
808 }
809 break;
810 case SID_ATTR_PARA_MODEL:
811 {
814 SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL> aTemp(GetPool());
815 aTemp.Put(aCoreSet);
817 rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
818 nSlot = 0;
819 }
820 break;
822 {
824 rSh.GetCurAttr(aSet);
825 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT);
826 rSet.Put(rItem);
827 nSlot = 0;
828 }
829 break;
830
831 default:
832 // Do nothing
833 nSlot = 0;
834 break;
835
836 }
837 if( nSlot )
838 {
839 aFlagItem.SetWhich( nSlot );
840 aFlagItem.SetValue( bFlag );
841 rSet.Put( aFlagItem );
842 }
843 nSlot = aIter.NextWhich();
844 }
845
846 rSet.Put(aCoreSet,false);
847}
848
849/* 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:3001
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:668
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:452
void ExecCharAttr(SfxRequest &)
Definition: txtattr.cxx:61
void GetAttrState(SfxItemSet &)
Definition: txtattr.cxx:536
void ExecParaAttr(SfxRequest &)
Definition: txtattr.cxx:312
void ExecCharAttrArgs(SfxRequest &)
Definition: txtattr.cxx:200
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
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:415