LibreOffice Module sw (master) 1
atrhndl.hxx
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#pragma once
21#define NUM_ATTRIBUTE_STACKS 45
22
23#include <vector>
24#include <swfntcch.hxx>
25
26class SwTextAttr;
27class SwAttrSet;
29class SwViewShell;
30class SfxPoolItem;
31extern const sal_uInt8 StackPos[];
32
38{
39private:
40 std::vector<const SwTextAttr*> m_aAttrStack[NUM_ATTRIBUTE_STACKS]; // stack collection
44
45 // This is the base font for the paragraph. It is stored in order to have
46 // a template, if we have to restart the attribute evaluation
47 std::optional<SwFont> m_oFnt;
48
51
52 const SwTextAttr* GetTop(sal_uInt16 nStack);
53 void RemoveFromStack(sal_uInt16 nWhich, const SwTextAttr& rAttr);
54
55 // change font according to pool item
56 void FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush );
57
58 // push attribute to specified stack, returns true, if attribute has
59 // been pushed on top of stack (important for stacks containing different
60 // attributes with different priority and redlining)
61 bool Push( const SwTextAttr& rAttr, const SfxPoolItem& rItem );
62
63 // apply top attribute on stack to font
64 void ActivateTop( SwFont& rFnt, sal_uInt16 nStackPos );
65
66public:
67 // Ctor
70
71 // set default attributes to values in rAttrSet or from cache
72 void Init( const SwAttrSet& rAttrSet,
73 const IDocumentSettingAccess& rIDocumentSettingAccess );
74 void Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAttrSet,
75 const IDocumentSettingAccess& rIDocumentSettingAccess,
76 const SwViewShell* pShell, SwFont& rFnt,
77 bool bVertLayout, bool bVertLayoutLRBT );
78
79 bool IsVertLayout() const { return m_bVertLayout; }
80
81 // remove everything from internal stacks, keep default data
82 void Reset( );
83
84 // insert specified attribute and change font
85 void PushAndChg( const SwTextAttr& rAttr, SwFont& rFnt );
86
87 // remove specified attribute and reset font
88 void PopAndChg( const SwTextAttr& rAttr, SwFont& rFnt );
89 void Pop( const SwTextAttr& rAttr );
90
91 // apply script dependent attributes
92 // void ChangeScript( SwFont& rFnt, const sal_uInt8 nScr );
93
94 // do not call these if you only used the small init function
95 inline void ResetFont( SwFont& rFnt ) const;
96 inline const SwFont* GetFont() const;
97
98 void GetDefaultAscentAndHeight(SwViewShell const * pShell,
99 OutputDevice const & rOut,
100 sal_uInt16& nAscent,
101 sal_uInt16& nHeight) const;
102};
103
104inline void SwAttrHandler::ResetFont( SwFont& rFnt ) const
105{
106 OSL_ENSURE(m_oFnt, "ResetFont without a font");
107 if (m_oFnt)
108 rFnt = *m_oFnt;
109};
110
111inline const SwFont* SwAttrHandler::GetFont() const
112{
113 return m_oFnt ? &*m_oFnt : nullptr;
114};
115
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define NUM_ATTRIBUTE_STACKS
Definition: atrhndl.hxx:21
const sal_uInt8 StackPos[]
Attribute to Stack Mapping.
Definition: atrstck.cxx:68
Provides access to settings of a document.
Used by Attribute Iterators to organize attributes on stacks to find the valid attribute in each cate...
Definition: atrhndl.hxx:38
const IDocumentSettingAccess * m_pIDocumentSettingAccess
Definition: atrhndl.hxx:42
void Init(const SwAttrSet &rAttrSet, const IDocumentSettingAccess &rIDocumentSettingAccess)
Definition: atrstck.cxx:277
const SwFont * GetFont() const
Definition: atrhndl.hxx:111
void PushAndChg(const SwTextAttr &rAttr, SwFont &rFnt)
Definition: atrstck.cxx:337
bool m_bVertLayout
Definition: atrhndl.hxx:49
void ResetFont(SwFont &rFnt) const
Definition: atrhndl.hxx:104
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
bool IsVertLayout() const
Definition: atrhndl.hxx:79
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
#define NUM_DEFAULT_VALUES
Definition: swfntcch.hxx:22
unsigned char sal_uInt8