/src/libreoffice/sw/inc/fmtanchr.hxx
Line | Count | Source |
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 | | #ifndef INCLUDED_SW_INC_FMTANCHR_HXX |
20 | | #define INCLUDED_SW_INC_FMTANCHR_HXX |
21 | | |
22 | | #include "swdllapi.h" |
23 | | #include "hintids.hxx" |
24 | | #include "format.hxx" |
25 | | #include "pam.hxx" |
26 | | #include <svl/poolitem.hxx> |
27 | | #include <svx/swframetypes.hxx> |
28 | | |
29 | | #include <memory> |
30 | | #include <optional> |
31 | | |
32 | | /// FlyAnchors |
33 | | class SW_DLLPUBLIC SwFormatAnchor final : public SfxPoolItem |
34 | | { |
35 | | std::optional<SwPosition> m_oContentAnchor; /**< 0 for page-bound frames. |
36 | | Index for paragraph-bound frames. |
37 | | Position for character-bound frames. */ |
38 | | RndStdIds m_eAnchorId; |
39 | | sal_uInt16 m_nPageNumber; ///< Page number for page-bound frames. |
40 | | |
41 | | /// #i28701# - getting anchor positions ordered |
42 | | sal_uInt32 m_nOrder; |
43 | | static sal_uInt32 s_nOrderCounter; |
44 | | |
45 | | public: |
46 | | DECLARE_ITEM_TYPE_FUNCTION(SwFormatAnchor) |
47 | | SwFormatAnchor( RndStdIds eRnd = RndStdIds::FLY_AT_PAGE, sal_uInt16 nPageNum = 0 ); |
48 | | SwFormatAnchor( const SwFormatAnchor &rCpy ); |
49 | | virtual ~SwFormatAnchor() override; |
50 | | |
51 | | SwFormatAnchor &operator=( const SwFormatAnchor& ); |
52 | | |
53 | | /// "pure virtual methods" of SfxPoolItem |
54 | | virtual bool operator==( const SfxPoolItem& ) const override; |
55 | | virtual SwFormatAnchor* Clone( SfxItemPool* pPool = nullptr ) const override; |
56 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
57 | | MapUnit eCoreMetric, |
58 | | MapUnit ePresMetric, |
59 | | OUString &rText, |
60 | | const IntlWrapper& rIntl ) const override; |
61 | | |
62 | | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
63 | | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
64 | | |
65 | 59.8M | RndStdIds GetAnchorId() const { return m_eAnchorId; } |
66 | 507k | void SetType( RndStdIds nRndId ) { m_eAnchorId = nRndId; } |
67 | | |
68 | 78.3k | sal_uInt16 GetPageNum() const { return m_nPageNumber; } |
69 | 895 | void SetPageNum( sal_uInt16 nNew ) { m_nPageNumber = nNew; } |
70 | | |
71 | | SwNode* GetAnchorNode() const; |
72 | 10.6M | const SwPosition* GetContentAnchor() const { return m_oContentAnchor ? &*m_oContentAnchor : nullptr; } |
73 | | SwContentNode* GetAnchorContentNode() const; |
74 | | sal_Int32 GetAnchorContentOffset() const; |
75 | | void SetAnchor( const SwPosition *pPos ); |
76 | | |
77 | | // #i28701# |
78 | 115k | sal_uInt32 GetOrder() const { return m_nOrder;} |
79 | | |
80 | | void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
81 | | }; |
82 | | |
83 | | inline const SwFormatAnchor &SwAttrSet::GetAnchor(bool bInP) const |
84 | 53.8M | { return Get(RES_ANCHOR, bInP); } |
85 | | |
86 | | inline const SwFormatAnchor &SwFormat::GetAnchor(bool bInP) const |
87 | 53.8M | { return m_aSet.GetAnchor(bInP); } |
88 | | |
89 | | #endif |
90 | | |
91 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |