android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / atrhndl.hxx
blob851615325a06582f5939d25ad4479b685f914a6f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
21 #define NUM_ATTRIBUTE_STACKS 45
23 #include <vector>
24 #include <swfntcch.hxx>
26 class SwTextAttr;
27 class SwAttrSet;
28 class IDocumentSettingAccess;
29 class SwViewShell;
30 class SfxPoolItem;
31 extern const sal_uInt8 StackPos[];
33 /**
34 * Used by Attribute Iterators to organize attributes on stacks to
35 * find the valid attribute in each category
37 class SwAttrHandler
39 private:
40 std::vector<const SwTextAttr*> m_aAttrStack[NUM_ATTRIBUTE_STACKS]; // stack collection
41 const SfxPoolItem* m_pDefaultArray[ NUM_DEFAULT_VALUES ];
42 const IDocumentSettingAccess* m_pIDocumentSettingAccess;
43 const SwViewShell* m_pShell;
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;
49 bool m_bVertLayout;
50 bool m_bVertLayoutLRBT;
52 const SwTextAttr* GetTop(sal_uInt16 nStack);
53 void RemoveFromStack(sal_uInt16 nWhich, const SwTextAttr& rAttr);
55 // change font according to pool item
56 void FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush );
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 );
63 // apply top attribute on stack to font
64 void ActivateTop( SwFont& rFnt, sal_uInt16 nStackPos );
66 public:
67 // Ctor
68 SwAttrHandler();
69 ~SwAttrHandler();
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 );
79 bool IsVertLayout() const { return m_bVertLayout; }
81 // remove everything from internal stacks, keep default data
82 void Reset( );
84 // insert specified attribute and change font
85 void PushAndChg( const SwTextAttr& rAttr, SwFont& rFnt );
87 // remove specified attribute and reset font
88 void PopAndChg( const SwTextAttr& rAttr, SwFont& rFnt );
89 void Pop( const SwTextAttr& rAttr );
91 // apply script dependent attributes
92 // void ChangeScript( SwFont& rFnt, const sal_uInt8 nScr );
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;
98 void GetDefaultAscentAndHeight(SwViewShell const * pShell,
99 OutputDevice const & rOut,
100 sal_uInt16& nAscent,
101 sal_uInt16& nHeight) const;
104 inline void SwAttrHandler::ResetFont( SwFont& rFnt ) const
106 OSL_ENSURE(m_oFnt, "ResetFont without a font");
107 if (m_oFnt)
108 rFnt = *m_oFnt;
111 inline const SwFont* SwAttrHandler::GetFont() const
113 return m_oFnt ? &*m_oFnt : nullptr;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */