LibreOffice Module sw (master) 1
atrstck.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 "atrhndl.hxx"
21#include <svl/itemiter.hxx>
22#include <vcl/outdev.hxx>
23#include <editeng/cmapitem.hxx>
24#include <editeng/colritem.hxx>
28#include <editeng/fontitem.hxx>
29#include <editeng/fhgtitem.hxx>
30#include <editeng/kernitem.hxx>
32#include <editeng/langitem.hxx>
33#include <editeng/postitem.hxx>
34#include <editeng/shdditem.hxx>
35#include <editeng/udlnitem.hxx>
36#include <editeng/wghtitem.hxx>
37#include <editeng/wrlmitem.hxx>
44#include <editeng/boxitem.hxx>
45#include <editeng/shaditem.hxx>
46#include <viewopt.hxx>
47#include <charfmt.hxx>
48#include <fchrfmt.hxx>
49#include <fmtautofmt.hxx>
50#include <editeng/brushitem.hxx>
51#include <fmtinfmt.hxx>
52#include <txtinet.hxx>
54#include <viewsh.hxx>
55
69{
70 0, // // 0
71 1, // RES_CHRATR_CASEMAP = RES_CHRATR_BEGIN // 1
72 0, // RES_CHRATR_CHARSETCOLOR, // 2
73 2, // RES_CHRATR_COLOR, // 3
74 3, // RES_CHRATR_CONTOUR, // 4
75 4, // RES_CHRATR_CROSSEDOUT, // 5
76 5, // RES_CHRATR_ESCAPEMENT, // 6
77 6, // RES_CHRATR_FONT, // 7
78 7, // RES_CHRATR_FONTSIZE, // 8
79 8, // RES_CHRATR_KERNING, // 9
80 9, // RES_CHRATR_LANGUAGE, // 10
81 10, // RES_CHRATR_POSTURE, // 11
82 0, // RES_CHRATR_UNUSED1, // 12
83 11, // RES_CHRATR_SHADOWED, // 13
84 12, // RES_CHRATR_UNDERLINE, // 14
85 13, // RES_CHRATR_WEIGHT, // 15
86 14, // RES_CHRATR_WORDLINEMODE, // 16
87 15, // RES_CHRATR_AUTOKERN, // 17
88 16, // RES_CHRATR_BLINK, // 18
89 17, // RES_CHRATR_NOHYPHEN, // 19
90 0, // RES_CHRATR_UNUSED2, // 20
91 18, // RES_CHRATR_BACKGROUND, // 21
92 19, // RES_CHRATR_CJK_FONT, // 22
93 20, // RES_CHRATR_CJK_FONTSIZE, // 23
94 21, // RES_CHRATR_CJK_LANGUAGE, // 24
95 22, // RES_CHRATR_CJK_POSTURE, // 25
96 23, // RES_CHRATR_CJK_WEIGHT, // 26
97 24, // RES_CHRATR_CTL_FONT, // 27
98 25, // RES_CHRATR_CTL_FONTSIZE, // 28
99 26, // RES_CHRATR_CTL_LANGUAGE, // 29
100 27, // RES_CHRATR_CTL_POSTURE, // 30
101 28, // RES_CHRATR_CTL_WEIGHT, // 31
102 29, // RES_CHRATR_ROTATE, // 32
103 30, // RES_CHRATR_EMPHASIS_MARK, // 33
104 31, // RES_CHRATR_TWO_LINES, // 34
105 32, // RES_CHRATR_SCALEW, // 35
106 33, // RES_CHRATR_RELIEF, // 36
107 34, // RES_CHRATR_HIDDEN, // 37
108 35, // RES_CHRATR_OVERLINE, // 38
109 0, // RES_CHRATR_RSID, // 39
110 36, // RES_CHRATR_BOX, // 40
111 37, // RES_CHRATR_SHADOW, // 41
112 38, // RES_CHRATR_HIGHLIGHT, // 42
113 0, // RES_CHRATR_GRABBAG, // 43
114 0, // RES_CHRATR_BIDIRTL, // 44
115 0, // RES_CHRATR_IDCTHINT, // 45
116 39, // RES_TXTATR_REFMARK, // 46
117 40, // RES_TXTATR_TOXMARK, // 47
118 41, // RES_TXTATR_META, // 48
119 41, // RES_TXTATR_METAFIELD, // 49
120 0, // RES_TXTATR_AUTOFMT, // 50
121 0, // RES_TXTATR_INETFMT // 51
122 0, // RES_TXTATR_CHARFMT, // 52
123 42, // RES_TXTATR_CJK_RUBY, // 53
124 0, // RES_TXTATR_UNKNOWN_CONTAINER, // 54
125 43, // RES_TXTATR_INPUTFIELD // 55
126 44, // RES_TXTATR_CONTENTCONTROL // 56
127};
128
129namespace CharFormat
130{
131
133const SfxItemSet* GetItemSet( const SfxPoolItem& rAttr )
134{
135 const SfxItemSet* pSet = nullptr;
136
137 if ( RES_TXTATR_AUTOFMT == rAttr.Which() )
138 {
139 pSet = rAttr.StaticWhichCast(RES_TXTATR_AUTOFMT).GetStyleHandle().get();
140 }
141 else
142 {
143 // Get the attributes from the template
144 const SwCharFormat* pFormat = RES_TXTATR_INETFMT == rAttr.Which() ?
145 rAttr.StaticWhichCast(RES_TXTATR_INETFMT).GetTextINetFormat()->GetCharFormat() :
146 static_cast<const SwFormatCharFormat&>(rAttr).GetCharFormat();
147 if( pFormat )
148 {
149 pSet = &pFormat->GetAttrSet();
150 }
151 }
152
153 return pSet;
154}
155
157const SfxPoolItem* GetItem( const SwTextAttr& rAttr, sal_uInt16 nWhich )
158{
159 if ( RES_TXTATR_INETFMT == rAttr.Which() ||
160 RES_TXTATR_CHARFMT == rAttr.Which() ||
161 RES_TXTATR_AUTOFMT == rAttr.Which() )
162 {
163 const SfxItemSet* pSet = CharFormat::GetItemSet( rAttr.GetAttr() );
164 if ( !pSet ) return nullptr;
165
166 bool bInParent = RES_TXTATR_AUTOFMT != rAttr.Which();
167 const SfxPoolItem* pItem;
168 bool bRet = SfxItemState::SET == pSet->GetItemState( nWhich, bInParent, &pItem );
169
170 return bRet ? pItem : nullptr;
171 }
172
173 return ( nWhich == rAttr.Which() ) ? &rAttr.GetAttr() : nullptr;
174}
175
177bool IsItemIncluded( const sal_uInt16 nWhich, const SwTextAttr *pAttr )
178{
179 bool bRet = false;
180
181 const SfxItemSet* pItemSet = CharFormat::GetItemSet( pAttr->GetAttr() );
182 if ( pItemSet )
183 bRet = SfxItemState::SET == pItemSet->GetItemState( nWhich );
184
185 return bRet;
186}
187}
188
196static bool lcl_ChgHyperLinkColor( const SwTextAttr& rAttr,
197 const SfxPoolItem& rItem,
198 const SwViewShell* pShell,
199 Color* pColor )
200{
201 if ( !pShell ||
202 RES_TXTATR_INETFMT != rAttr.Which() ||
203 RES_CHRATR_COLOR != rItem.Which() )
204 return false;
205
206 // #i15455#
207 // 1. case:
208 // We do not want to show visited links:
209 // (printing, pdf export, page preview)
210
211 SwTextINetFormat & rINetAttr(const_cast<SwTextINetFormat&>(
212 static_txtattr_cast<SwTextINetFormat const&>(rAttr)));
213 if ( pShell->GetOut()->GetOutDevType() == OUTDEV_PRINTER ||
214 pShell->GetViewOptions()->IsPDFExport() ||
215 pShell->GetViewOptions()->IsPagePreview() )
216 {
217 if (rINetAttr.IsVisited())
218 {
219 if ( pColor )
220 {
221 // take color from character format 'unvisited link'
222 rINetAttr.SetVisited(false);
223 const SwCharFormat* pTmpFormat = rINetAttr.GetCharFormat();
224 if (const SvxColorItem* pItem = pTmpFormat->GetItemIfSet(RES_CHRATR_COLOR))
225 *pColor = pItem->GetValue();
226 rINetAttr.SetVisited(true);
227 }
228 return true;
229 }
230
231 return false;
232 }
233
234 // 2. case:
235 // We do not want to apply the color set in the hyperlink
236 // attribute, instead we take the colors from the view options:
237
238 if ( pShell->GetWin() &&
239 (
240 (rINetAttr.IsVisited() && SwViewOption::IsVisitedLinks()) ||
241 (!rINetAttr.IsVisited() && SwViewOption::IsLinks())
242 )
243 )
244 {
245 if ( pColor )
246 {
247 if (rINetAttr.IsVisited())
248 {
249 // take color from view option 'visited link color'
251 }
252 else
253 {
254 // take color from view option 'unvisited link color'
255 *pColor = SwViewOption::GetLinksColor();
256 }
257 }
258 return true;
259 }
260
261 return false;
262}
263
265 : m_pIDocumentSettingAccess(nullptr)
266 , m_pShell(nullptr)
267 , m_bVertLayout(false)
268 , m_bVertLayoutLRBT(false)
269{
270 memset( m_pDefaultArray, 0, NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
271}
272
274{
275}
276
277void SwAttrHandler::Init( const SwAttrSet& rAttrSet,
278 const IDocumentSettingAccess& rIDocumentSettingAcces )
279{
280 m_pIDocumentSettingAccess = &rIDocumentSettingAcces;
281 m_pShell = nullptr;
282
283 for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++ )
284 m_pDefaultArray[ StackPos[ i ] ] = &rAttrSet.Get( i );
285}
286
287void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
288 const IDocumentSettingAccess& rIDocumentSettingAcces,
289 const SwViewShell* pSh,
290 SwFont& rFnt, bool bVL, bool bVertLayoutLRBT )
291{
292 // initialize default array
293 memcpy( m_pDefaultArray, pPoolItem,
294 NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
295
296 m_pIDocumentSettingAccess = &rIDocumentSettingAcces;
297 m_pShell = pSh;
298
299 // do we have to apply additional paragraph attributes?
300 m_bVertLayout = bVL;
301 m_bVertLayoutLRBT = bVertLayoutLRBT;
302
303 if ( pAS && pAS->Count() )
304 {
305 SfxItemIter aIter( *pAS );
306 sal_uInt16 nWhich;
307 const SfxPoolItem* pItem = aIter.GetCurItem();
308 do
309 {
310 nWhich = pItem->Which();
311 if (isCHRATR(nWhich))
312 {
313 m_pDefaultArray[ StackPos[ nWhich ] ] = pItem;
314 FontChg( *pItem, rFnt, true );
315 }
316
317 pItem = aIter.NextItem();
318 } while (pItem);
319 }
320
321 // It is possible, that Init is called more than once, e.g., in a
322 // SwTextFrame::FormatOnceMore situation or (since sw_redlinehide)
323 // from SwAttrIter::Seek(); in the latter case SwTextSizeInfo::m_pFnt
324 // is an alias of m_pFnt so it must not be deleted!
325 if (m_oFnt)
326 *m_oFnt = rFnt;
327 else
328 m_oFnt.emplace(rFnt);
329}
330
332{
333 for (auto& i : m_aAttrStack)
334 i.clear();
335}
336
337void SwAttrHandler::PushAndChg( const SwTextAttr& rAttr, SwFont& rFnt )
338{
339 // these special attributes in fact represent a collection of attributes
340 // they have to be pushed to each stack they belong to
341 if ( RES_TXTATR_INETFMT == rAttr.Which() ||
342 RES_TXTATR_CHARFMT == rAttr.Which() ||
343 RES_TXTATR_AUTOFMT == rAttr.Which() )
344 {
345 const SfxItemSet* pSet = CharFormat::GetItemSet( rAttr.GetAttr() );
346 if ( !pSet ) return;
347
348 for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
349 {
350 const SfxPoolItem* pItem;
351 bool bRet = SfxItemState::SET == pSet->GetItemState( i, rAttr.Which() != RES_TXTATR_AUTOFMT, &pItem );
352
353 if ( bRet )
354 {
355 // we push rAttr onto the appropriate stack
356 if ( Push( rAttr, *pItem ) )
357 {
358 // we let pItem change rFnt
359 Color aColor;
360 if (lcl_ChgHyperLinkColor(rAttr, *pItem, m_pShell, &aColor))
361 {
362 SvxColorItem aItemNext( aColor, RES_CHRATR_COLOR );
363 FontChg( aItemNext, rFnt, true );
364 }
365 else
366 FontChg( *pItem, rFnt, true );
367 }
368 }
369 }
370 }
371 // this is the usual case, we have a basic attribute, push it onto the
372 // stack and change the font
373 else
374 {
375 if ( Push( rAttr, rAttr.GetAttr() ) )
376 // we let pItem change rFnt
377 FontChg( rAttr.GetAttr(), rFnt, true );
378 }
379}
380
381const SwTextAttr* SwAttrHandler::GetTop(sal_uInt16 nStack)
382{
383 return m_aAttrStack[nStack].empty() ? nullptr : m_aAttrStack[nStack].back();
384}
385
386bool SwAttrHandler::Push( const SwTextAttr& rAttr, const SfxPoolItem& rItem )
387{
388 OSL_ENSURE( rItem.Which() < RES_TXTATR_WITHEND_END,
389 "I do not want this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
390
391 // robust
392 if ( RES_TXTATR_WITHEND_END <= rItem.Which() )
393 return false;
394
395 const sal_uInt16 nStack = StackPos[ rItem.Which() ];
396
397 // attributes originating from redlining have highest priority
398 // second priority are hyperlink attributes, which have a color replacement
399 const SwTextAttr* pTopAttr = GetTop(nStack);
400 if ( !pTopAttr
401 || rAttr.IsPriorityAttr()
402 || ( !pTopAttr->IsPriorityAttr()
403 && !lcl_ChgHyperLinkColor(*pTopAttr, rItem, m_pShell, nullptr)))
404 {
405 m_aAttrStack[nStack].push_back(&rAttr);
406 return true;
407 }
408
409 const auto it = m_aAttrStack[nStack].end() - 1;
410 m_aAttrStack[nStack].insert(it, &rAttr);
411 return false;
412}
413
414void SwAttrHandler::RemoveFromStack(sal_uInt16 nWhich, const SwTextAttr& rAttr)
415{
416 auto& rStack = m_aAttrStack[StackPos[nWhich]];
417 const auto it = std::find(rStack.begin(), rStack.end(), &rAttr);
418 if (it != rStack.end())
419 rStack.erase(it);
420}
421
422void SwAttrHandler::PopAndChg( const SwTextAttr& rAttr, SwFont& rFnt )
423{
424 if ( RES_TXTATR_WITHEND_END <= rAttr.Which() )
425 return; // robust
426
427 // these special attributes in fact represent a collection of attributes
428 // they have to be removed from each stack they belong to
429 if ( RES_TXTATR_INETFMT == rAttr.Which() ||
430 RES_TXTATR_CHARFMT == rAttr.Which() ||
431 RES_TXTATR_AUTOFMT == rAttr.Which() )
432 {
433 const SfxItemSet* pSet = CharFormat::GetItemSet( rAttr.GetAttr() );
434 if ( !pSet ) return;
435
436 for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
437 {
438 const SfxPoolItem* pItem;
439 bool bRet = SfxItemState::SET == pSet->GetItemState( i, RES_TXTATR_AUTOFMT != rAttr.Which(), &pItem );
440 if ( bRet )
441 {
442 // we remove rAttr from the appropriate stack
443 RemoveFromStack(i, rAttr);
444 // reset font according to attribute on top of stack
445 // or default value
446 ActivateTop( rFnt, i );
447 }
448 }
449 }
450 // this is the usual case, we have a basic attribute, remove it from the
451 // stack and reset the font
452 else
453 {
454 RemoveFromStack(rAttr.Which(), rAttr);
455 // reset font according to attribute on top of stack
456 // or default value
457 ActivateTop( rFnt, rAttr.Which() );
458 }
459}
460
462void SwAttrHandler::Pop( const SwTextAttr& rAttr )
463{
464 OSL_ENSURE( rAttr.Which() < RES_TXTATR_WITHEND_END,
465 "I do not have this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
466
467 if ( rAttr.Which() < RES_TXTATR_WITHEND_END )
468 {
469 RemoveFromStack(rAttr.Which(), rAttr);
470 }
471}
472
473void SwAttrHandler::ActivateTop( SwFont& rFnt, const sal_uInt16 nAttr )
474{
475 OSL_ENSURE( nAttr < RES_TXTATR_WITHEND_END,
476 "I cannot activate this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
477
478 const sal_uInt16 nStackPos = StackPos[ nAttr ];
479 const SwTextAttr* pTopAt = GetTop(nStackPos);
480 if ( pTopAt )
481 {
482 const SfxPoolItem* pItemNext(nullptr);
483
484 // check if top attribute is collection of attributes
485 if ( RES_TXTATR_INETFMT == pTopAt->Which() ||
486 RES_TXTATR_CHARFMT == pTopAt->Which() ||
487 RES_TXTATR_AUTOFMT == pTopAt->Which() )
488 {
489 const SfxItemSet* pSet = CharFormat::GetItemSet( pTopAt->GetAttr() );
490 if (pSet)
491 pSet->GetItemState( nAttr, RES_TXTATR_AUTOFMT != pTopAt->Which(), &pItemNext );
492 }
493
494 if (pItemNext)
495 {
496 Color aColor;
497 if (lcl_ChgHyperLinkColor(*pTopAt, *pItemNext, m_pShell, &aColor))
498 {
499 SvxColorItem aItemNext( aColor, RES_CHRATR_COLOR );
500 FontChg( aItemNext, rFnt, false );
501 }
502 else
503 FontChg( *pItemNext, rFnt, false );
504 }
505 else
506 FontChg( pTopAt->GetAttr(), rFnt, false );
507 }
508
509 // default value has to be set, we only have default values for char attribs
510 else if ( nStackPos < NUM_DEFAULT_VALUES )
511 FontChg( *m_pDefaultArray[ nStackPos ], rFnt, false );
512 else if ( RES_TXTATR_REFMARK == nAttr )
513 rFnt.GetRef()--;
514 else if ( RES_TXTATR_TOXMARK == nAttr )
515 rFnt.GetTox()--;
516 else if ( (RES_TXTATR_META == nAttr) || (RES_TXTATR_METAFIELD == nAttr) )
517 {
518 rFnt.GetMeta()--;
519 }
520 else if (nAttr == RES_TXTATR_CONTENTCONTROL)
521 {
522 rFnt.GetContentControl()--;
523 }
524 else if ( RES_TXTATR_CJK_RUBY == nAttr )
525 {
526 // ruby stack has no more attributes
527 // check, if a rotation attribute has to be applied
528 const sal_uInt16 nTwoLineStack = StackPos[ RES_CHRATR_TWO_LINES ];
529 bool bTwoLineAct = false;
530 const SwTextAttr* pTwoLineAttr = GetTop(nTwoLineStack);
531
532 if ( pTwoLineAttr )
533 {
534 const auto& rTwoLineItem = *CharFormat::GetItem( *pTwoLineAttr, RES_CHRATR_TWO_LINES );
535 bTwoLineAct = rTwoLineItem.GetValue();
536 }
537 else
538 bTwoLineAct = m_pDefaultArray[ nTwoLineStack ]->StaticWhichCast(RES_CHRATR_TWO_LINES).GetValue();
539
540 if ( bTwoLineAct )
541 return;
542
543 // eventually, a rotate attribute has to be activated
544 const sal_uInt16 nRotateStack = StackPos[ RES_CHRATR_ROTATE ];
545 const SwTextAttr* pRotateAttr = GetTop(nRotateStack);
546
547 if ( pRotateAttr )
548 {
549 const auto& rRotateItem = *CharFormat::GetItem( *pRotateAttr, RES_CHRATR_ROTATE );
550 rFnt.SetVertical( rRotateItem.GetValue(), m_bVertLayout );
551 }
552 else
553 rFnt.SetVertical( m_pDefaultArray[ nRotateStack ]->StaticWhichCast(RES_CHRATR_ROTATE).GetValue(), m_bVertLayout );
554 }
555 else if ( RES_TXTATR_INPUTFIELD == nAttr )
556 rFnt.GetInputField()--;
557}
558
564void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush )
565{
566 switch ( rItem.Which() )
567 {
568 case RES_CHRATR_CASEMAP :
569 rFnt.SetCaseMap( rItem.StaticWhichCast(RES_CHRATR_CASEMAP).GetCaseMap() );
570 break;
571 case RES_CHRATR_COLOR :
572 rFnt.SetColor( rItem.StaticWhichCast(RES_CHRATR_COLOR).GetValue() );
573 break;
574 case RES_CHRATR_CONTOUR :
575 rFnt.SetOutline( rItem.StaticWhichCast(RES_CHRATR_CONTOUR).GetValue() );
576 break;
578 rFnt.SetStrikeout( rItem.StaticWhichCast(RES_CHRATR_CROSSEDOUT).GetStrikeout() );
579 break;
582 rFnt.SetProportion( rItem.StaticWhichCast(RES_CHRATR_ESCAPEMENT).GetProportionalHeight() );
583 break;
584 case RES_CHRATR_FONT :
585 {
586 auto& rFontItem = rItem.StaticWhichCast(RES_CHRATR_FONT);
587 rFnt.SetName( rFontItem.GetFamilyName(), SwFontScript::Latin );
588 rFnt.SetStyleName( rFontItem.GetStyleName(), SwFontScript::Latin );
589 rFnt.SetFamily( rFontItem.GetFamily(), SwFontScript::Latin );
590 rFnt.SetPitch( rFontItem.GetPitch(), SwFontScript::Latin );
591 rFnt.SetCharSet( rFontItem.GetCharSet(), SwFontScript::Latin );
592 break;
593 }
596 break;
597 case RES_CHRATR_KERNING :
598 rFnt.SetFixKerning( rItem.StaticWhichCast(RES_CHRATR_KERNING).GetValue() );
599 break;
602 break;
603 case RES_CHRATR_POSTURE :
605 break;
607 rFnt.SetShadow( rItem.StaticWhichCast(RES_CHRATR_SHADOWED).GetValue() );
608 break;
610 {
611 const sal_uInt16 nStackPos = StackPos[ RES_CHRATR_HIDDEN ];
612 const SwTextAttr* pTopAt = GetTop(nStackPos);
613
614 const SfxPoolItem* pTmpItem = pTopAt ?
616 m_pDefaultArray[ nStackPos ];
617
618 if ((m_pShell && !m_pShell->GetWin()) ||
619 (pTmpItem && !pTmpItem->StaticWhichCast(RES_CHRATR_HIDDEN).GetValue()) )
620 {
621 rFnt.SetUnderline( rItem.StaticWhichCast(RES_CHRATR_UNDERLINE).GetLineStyle() );
622 rFnt.SetUnderColor( rItem.StaticWhichCast(RES_CHRATR_UNDERLINE).GetColor() );
623 }
624 break;
625 }
626 case RES_CHRATR_BOX:
627 {
628 const SvxBoxItem& aBoxItem = rItem.StaticWhichCast(RES_CHRATR_BOX);
629 rFnt.SetTopBorder( aBoxItem.GetTop() );
630 rFnt.SetBottomBorder( aBoxItem.GetBottom() );
631 rFnt.SetRightBorder( aBoxItem.GetRight() );
632 rFnt.SetLeftBorder( aBoxItem.GetLeft() );
633 rFnt.SetTopBorderDist( aBoxItem.GetDistance(SvxBoxItemLine::TOP) );
634 rFnt.SetBottomBorderDist( aBoxItem.GetDistance(SvxBoxItemLine::BOTTOM) );
635 rFnt.SetRightBorderDist( aBoxItem.GetDistance(SvxBoxItemLine::RIGHT) );
636 rFnt.SetLeftBorderDist( aBoxItem.GetDistance(SvxBoxItemLine::LEFT) );
637 break;
638 }
640 {
641 const SvxShadowItem& aShadowItem = rItem.StaticWhichCast(RES_CHRATR_SHADOW);
642 rFnt.SetShadowColor( aShadowItem.GetColor() );
643 rFnt.SetShadowWidth( aShadowItem.GetWidth() );
644 rFnt.SetShadowLocation( aShadowItem.GetLocation() );
645 break;
646 }
648 rFnt.SetOverline( rItem.StaticWhichCast(RES_CHRATR_OVERLINE).GetLineStyle() );
649 rFnt.SetOverColor( rItem.StaticWhichCast(RES_CHRATR_OVERLINE).GetColor() );
650 break;
651 case RES_CHRATR_WEIGHT :
653 break;
656 break;
658 if( rItem.StaticWhichCast(RES_CHRATR_AUTOKERN).GetValue() )
659 {
662 FontKerning::FontSpecific :
663 FontKerning::Asian );
664 }
665 else
666 rFnt.SetAutoKern( FontKerning::NONE );
667 break;
669 rFnt.SetBackColor(rItem.StaticWhichCast(RES_CHRATR_BACKGROUND).GetColor());
670 break;
673 break;
675 {
676 auto& rFontItem = rItem.StaticWhichCast(RES_CHRATR_CJK_FONT);
677 rFnt.SetName( rFontItem.GetFamilyName(), SwFontScript::CJK );
678 rFnt.SetStyleName( rFontItem.GetStyleName(), SwFontScript::CJK );
679 rFnt.SetFamily( rFontItem.GetFamily(), SwFontScript::CJK );
680 rFnt.SetPitch( rFontItem.GetPitch(), SwFontScript::CJK );
681 rFnt.SetCharSet( rFontItem.GetCharSet(), SwFontScript::CJK );
682 break;
683 }
686 break;
689 break;
692 break;
695 break;
697 {
698 auto& rFontItem = rItem.StaticWhichCast(RES_CHRATR_CTL_FONT);
699 rFnt.SetName( rFontItem.GetFamilyName(), SwFontScript::CTL );
700 rFnt.SetStyleName( rFontItem.GetStyleName(), SwFontScript::CTL );
701 rFnt.SetFamily( rFontItem.GetFamily(), SwFontScript::CTL );
702 rFnt.SetPitch( rFontItem.GetPitch(), SwFontScript::CTL );
703 rFnt.SetCharSet( rFontItem.GetCharSet(), SwFontScript::CTL );
704 break;
705 }
708 break;
711 break;
714 break;
717 break;
719 rFnt.SetEmphasisMark( rItem.StaticWhichCast(RES_CHRATR_EMPHASIS_MARK).GetEmphasisMark() );
720 break;
721 case RES_CHRATR_SCALEW :
722 rFnt.SetPropWidth( rItem.StaticWhichCast(RES_CHRATR_SCALEW).GetValue() );
723 break;
724 case RES_CHRATR_RELIEF :
725 rFnt.SetRelief( rItem.StaticWhichCast(RES_CHRATR_RELIEF).GetValue() );
726 break;
727 case RES_CHRATR_HIDDEN :
728 if (m_pShell && m_pShell->GetWin())
729 {
730 if ( rItem.StaticWhichCast(RES_CHRATR_HIDDEN).GetValue() )
732 else
734 }
735 break;
736 case RES_CHRATR_ROTATE :
737 {
738 // rotate attribute is applied, when:
739 // 1. ruby stack is empty and
740 // 2. top of two line stack ( or default attribute )is an
741 // deactivated two line attribute
742 const bool bRuby =
743 0 != m_aAttrStack[ StackPos[ RES_TXTATR_CJK_RUBY ] ].size();
744
745 if ( bRuby )
746 break;
747
748 const sal_uInt16 nTwoLineStack = StackPos[ RES_CHRATR_TWO_LINES ];
749 bool bTwoLineAct = false;
750 const SwTextAttr* pTwoLineAttr = GetTop(nTwoLineStack);
751
752 if ( pTwoLineAttr )
753 {
754 const auto& rTwoLineItem = *CharFormat::GetItem( *pTwoLineAttr, RES_CHRATR_TWO_LINES );
755 bTwoLineAct = rTwoLineItem.GetValue();
756 }
757 else
758 bTwoLineAct = m_pDefaultArray[ nTwoLineStack ]->StaticWhichCast(RES_CHRATR_TWO_LINES).GetValue();
759
760 if ( !bTwoLineAct )
762
763 break;
764 }
766 {
767 bool bRuby = 0 !=
769
770 // two line is activated, if
771 // 1. no ruby attribute is set and
772 // 2. attribute is active
773 if ( !bRuby && rItem.StaticWhichCast(RES_CHRATR_TWO_LINES).GetValue() )
774 {
775 rFnt.SetVertical( 0_deg10, m_bVertLayout );
776 break;
777 }
778
779 // a deactivating two line attribute is on top of stack,
780 // check if rotate attribute has to be enabled
781 if ( bRuby )
782 break;
783
784 const sal_uInt16 nRotateStack = StackPos[ RES_CHRATR_ROTATE ];
785 const SwTextAttr* pRotateAttr = GetTop(nRotateStack);
786
787 if ( pRotateAttr )
788 {
789 const auto& rRotateItem = *CharFormat::GetItem( *pRotateAttr, RES_CHRATR_ROTATE );
790 rFnt.SetVertical( rRotateItem.GetValue(), m_bVertLayout );
791 }
792 else
793 rFnt.SetVertical(m_pDefaultArray[ nRotateStack ]->StaticWhichCast(RES_CHRATR_ROTATE).GetValue(), m_bVertLayout);
794 break;
795 }
797 rFnt.SetVertical( 0_deg10, m_bVertLayout );
798 break;
799 case RES_TXTATR_REFMARK :
800 if ( bPush )
801 rFnt.GetRef()++;
802 else
803 rFnt.GetRef()--;
804 break;
805 case RES_TXTATR_TOXMARK :
806 if ( bPush )
807 rFnt.GetTox()++;
808 else
809 rFnt.GetTox()--;
810 break;
811 case RES_TXTATR_META:
813 if ( bPush )
814 rFnt.GetMeta()++;
815 else
816 rFnt.GetMeta()--;
817 break;
819 if (bPush)
820 {
821 rFnt.GetContentControl()++;
822 }
823 else
824 {
825 rFnt.GetContentControl()--;
826 }
827 break;
829 if ( bPush )
830 rFnt.GetInputField()++;
831 else
832 rFnt.GetInputField()--;
833 break;
834 }
835}
836
839 sal_uInt16& nAscent, sal_uInt16& nHeight ) const
840{
841 OSL_ENSURE(m_oFnt, "No font available for GetDefaultAscentAndHeight");
842
843 if (m_oFnt)
844 {
845 SwFont aFont( *m_oFnt );
846 nHeight = aFont.GetHeight( pShell, rOut );
847 nAscent = aFont.GetAscent( pShell, rOut );
848 }
849}
850
851/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool lcl_ChgHyperLinkColor(const SwTextAttr &rAttr, const SfxPoolItem &rItem, const SwViewShell *pShell, Color *pColor)
The color of hyperlinks is taken from the associated character attribute, depending on its 'visited' ...
Definition: atrstck.cxx:196
const sal_uInt8 StackPos[RES_TXTATR_WITHEND_END - RES_CHRATR_BEGIN+1]
Attribute to Stack Mapping.
Definition: atrstck.cxx:68
Provides access to settings of a document.
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
OutDevType GetOutDevType() const
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
sal_uInt16 Count() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
T & StaticWhichCast(TypedWhichId< T > nId)
sal_uInt16 Which() const
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetRight() const
const editeng::SvxBorderLine * GetLeft() const
sal_Int16 GetDistance(SvxBoxItemLine nLine, bool bAllowNegative=false) const
const editeng::SvxBorderLine * GetBottom() const
sal_uInt16 GetWidth() const
const Color & GetColor() const
SvxShadowLocation GetLocation() const
const IDocumentSettingAccess * m_pIDocumentSettingAccess
Definition: atrhndl.hxx:42
void Init(const SwAttrSet &rAttrSet, const IDocumentSettingAccess &rIDocumentSettingAccess)
Definition: atrstck.cxx:277
void PushAndChg(const SwTextAttr &rAttr, SwFont &rFnt)
Definition: atrstck.cxx:337
bool m_bVertLayout
Definition: atrhndl.hxx:49
void Pop(const SwTextAttr &rAttr)
Only used during redlining.
Definition: atrstck.cxx:462
const SwViewShell * m_pShell
Definition: atrhndl.hxx:43
std::optional< SwFont > m_oFnt
Definition: atrhndl.hxx:47
bool Push(const SwTextAttr &rAttr, const SfxPoolItem &rItem)
Definition: atrstck.cxx:386
void Reset()
Definition: atrstck.cxx:331
std::vector< const SwTextAttr * > m_aAttrStack[NUM_ATTRIBUTE_STACKS]
Definition: atrhndl.hxx:40
const SfxPoolItem * m_pDefaultArray[NUM_DEFAULT_VALUES]
Definition: atrhndl.hxx:41
void FontChg(const SfxPoolItem &rItem, SwFont &rFnt, bool bPush)
When popping an attribute from the stack, the top more remaining attribute in the stack becomes valid...
Definition: atrstck.cxx:564
void PopAndChg(const SwTextAttr &rAttr, SwFont &rFnt)
Definition: atrstck.cxx:422
void ActivateTop(SwFont &rFnt, sal_uInt16 nStackPos)
Definition: atrstck.cxx:473
void GetDefaultAscentAndHeight(SwViewShell const *pShell, OutputDevice const &rOut, sal_uInt16 &nAscent, sal_uInt16 &nHeight) const
Takes the default font and calculated the ascent and height.
Definition: atrstck.cxx:838
bool m_bVertLayoutLRBT
Definition: atrhndl.hxx:50
const SwTextAttr * GetTop(sal_uInt16 nStack)
Definition: atrstck.cxx:381
void RemoveFromStack(sal_uInt16 nWhich, const SwTextAttr &rAttr)
Definition: atrstck.cxx:414
Represents the style of a text portion.
Definition: charfmt.hxx:27
sal_uInt8 & GetRef()
Definition: swfont.hxx:251
void SetOverline(const FontLineStyle eOverline)
Definition: swfont.hxx:564
void SetCharSet(const rtl_TextEncoding eCharSet, const SwFontScript nWhich)
Definition: swfont.hxx:494
void SetPropWidth(const sal_uInt16 nNew)
Definition: swfont.hxx:697
void SetBottomBorder(const editeng::SvxBorderLine *pBottomBorder)
Definition: swfont.cxx:84
void SetShadowLocation(const SvxShadowLocation aLocation)
Definition: swfont.hxx:941
void SetStrikeout(const FontStrikeout eStrikeout)
Definition: swfont.hxx:579
void SetItalic(const FontItalic eItalic, const SwFontScript nWhich)
Definition: swfont.hxx:594
void SetHighlightColor(const Color &aNewColor)
Definition: swfont.hxx:948
void SetEscapement(const short nNewEsc)
Definition: swfont.hxx:788
sal_uInt8 & GetTox()
Definition: swfont.hxx:249
void SetVertical(Degree10 nDir, const bool bVertLayout=false, const bool bVertLayoutLRBT=false)
Definition: swfont.cxx:417
void SetLeftBorder(const editeng::SvxBorderLine *pLeftBorder)
Definition: swfont.cxx:110
sal_uInt8 & GetMeta()
Definition: swfont.hxx:253
void SetUnderColor(const Color &rColor)
Definition: swfont.hxx:216
void SetEmphasisMark(const FontEmphasisMark eValue)
Definition: swfont.hxx:689
void SetName(const OUString &rName, const SwFontScript nWhich)
Definition: swfont.hxx:468
void SetProportion(const sal_uInt8 nNewPropr)
Definition: swfont.hxx:769
void SetTopBorderDist(const sal_uInt16 nTopDist)
Definition: swfont.hxx:834
void SetSize(const Size &rSize, const SwFontScript nWhich)
Definition: swfont.hxx:741
void SetBackColor(std::optional< Color > xNewColor)
Definition: swfont.cxx:64
void SetOutline(const bool bOutline)
Definition: swfont.hxx:607
sal_uInt8 & GetContentControl()
Definition: swfont.hxx:255
void SetLeftBorderDist(const sal_uInt16 nLeftDist)
Definition: swfont.hxx:855
sal_uInt8 & GetInputField()
Definition: swfont.hxx:257
void SetPitch(const FontPitch ePitch, const SwFontScript nWhich)
Definition: swfont.hxx:508
void SetRightBorderDist(const sal_uInt16 nRightDist)
Definition: swfont.hxx:848
void SetRightBorder(const editeng::SvxBorderLine *pRightBorder)
Definition: swfont.cxx:97
void SetShadow(const bool bShadow)
Definition: swfont.hxx:622
void SetColor(const Color &rColor)
Definition: swfont.hxx:418
void SetTopBorder(const editeng::SvxBorderLine *pTopBorder)
Definition: swfont.cxx:71
void SetAutoKern(FontKerning nAutoKern)
Definition: swfont.hxx:637
void SetOverColor(const Color &rColor)
Definition: swfont.hxx:218
void SetUnderline(const FontLineStyle eUnderline)
Definition: swfont.hxx:549
void SetCaseMap(const SvxCaseMap eNew)
Definition: swfont.hxx:661
void SetShadowColor(const Color &rColor)
Definition: swfont.hxx:927
void SetWordLineMode(const bool bWordLineMode)
Definition: swfont.hxx:675
void SetFamily(const FontFamily eFamily, const SwFontScript nWhich)
Definition: swfont.hxx:455
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
Definition: swfont.hxx:327
void SetLanguage(LanguageType eNewLang, const SwFontScript nWhich)
Definition: swfont.hxx:811
void SetShadowWidth(const sal_uInt16 nWidth)
Definition: swfont.hxx:934
void SetWeight(const FontWeight eWeight, const SwFontScript nWhich)
Definition: swfont.hxx:536
void SetRelief(const FontRelief eNew)
Definition: swfont.hxx:715
tools::Long GetHeight() const
Definition: swfont.hxx:284
void SetFixKerning(const short nNewKern)
Definition: swfont.hxx:654
void SetBottomBorderDist(const sal_uInt16 nBottomDist)
Definition: swfont.hxx:841
void SetStyleName(const OUString &rStyleName, const SwFontScript nWhich)
Definition: swfont.hxx:481
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Templatized version of GetItemState() to directly return the correct type.
Definition: format.hxx:111
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:167
bool IsPriorityAttr() const
Definition: txatbase.hxx:103
sal_uInt16 Which() const
Definition: txatbase.hxx:116
bool IsVisited() const
Definition: txtinet.hxx:54
void SetVisited(bool bNew)
Definition: txtinet.hxx:55
SwCharFormat * GetCharFormat()
Definition: txtatr2.cxx:111
static bool IsLinks()
Definition: viewopt.hxx:778
static Color & GetVisitedLinksColor()
Definition: viewopt.cxx:404
bool IsPagePreview() const
Definition: viewopt.hxx:743
static Color & GetLinksColor()
Definition: viewopt.cxx:399
bool IsPDFExport() const
Definition: viewopt.hxx:532
static bool IsVisitedLinks()
Definition: viewopt.hxx:779
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:347
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:433
vcl::Window * GetWin() const
Definition: viewsh.hxx:346
LINESTYLE_DOTTED
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:469
constexpr TypedWhichId< SvxAutoKernItem > RES_CHRATR_AUTOKERN(17)
constexpr TypedWhichId< SvxShadowItem > RES_CHRATR_SHADOW(41)
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
constexpr TypedWhichId< SvxShadowedItem > RES_CHRATR_SHADOWED(13)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr sal_uInt16 RES_TXTATR_WITHEND_END(57)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SvxBrushItem > RES_CHRATR_HIGHLIGHT(42)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SvxContourItem > RES_CHRATR_CONTOUR(4)
constexpr TypedWhichId< SvxCharReliefItem > RES_CHRATR_RELIEF(36)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SvxCharHiddenItem > RES_CHRATR_HIDDEN(37)
constexpr TypedWhichId< SvxEscapementItem > RES_CHRATR_ESCAPEMENT(6)
constexpr TypedWhichId< SvxCharScaleWidthItem > RES_CHRATR_SCALEW(35)
constexpr TypedWhichId< SvxBrushItem > RES_CHRATR_BACKGROUND(21)
constexpr TypedWhichId< SvxCaseMapItem > RES_CHRATR_CASEMAP(RES_CHRATR_BEGIN)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SvxEmphasisMarkItem > RES_CHRATR_EMPHASIS_MARK(33)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
constexpr TypedWhichId< SvxOverlineItem > RES_CHRATR_OVERLINE(38)
constexpr TypedWhichId< SvxCharRotateItem > RES_CHRATR_ROTATE(32)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
constexpr TypedWhichId< SvxWordLineModeItem > RES_CHRATR_WORDLINEMODE(16)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SvxKerningItem > RES_CHRATR_KERNING(9)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SvxTwoLinesItem > RES_CHRATR_TWO_LINES(34)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
constexpr TypedWhichId< SvxBoxItem > RES_CHRATR_BOX(40)
constexpr TypedWhichId< SwFormatRuby > RES_TXTATR_CJK_RUBY(53)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
Shell * m_pShell
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
Returns the item set associated with a character/inet/auto style.
Definition: atrstck.cxx:133
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
Extracts pool item of type nWhich from rAttr.
Definition: atrstck.cxx:157
bool IsItemIncluded(const sal_uInt16 nWhich, const SwTextAttr *pAttr)
Checks if item is included in character/inet/auto style.
Definition: atrstck.cxx:177
int i
const char GetValue[]
OUTDEV_PRINTER
#define NUM_DEFAULT_VALUES
Definition: swfntcch.hxx:22
unsigned char sal_uInt8