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