1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SW_INC_FMTORNT_HXX
20 #define INCLUDED_SW_INC_FMTORNT_HXX
22 #include <com/sun/star/text/HoriOrientation.hpp>
23 #include <com/sun/star/text/VertOrientation.hpp>
24 #include <com/sun/star/text/RelOrientation.hpp>
26 #include "hintids.hxx"
27 #include "swtypes.hxx"
29 #include <svl/poolitem.hxx>
33 /// Defines the vertical position of a fly frame.
35 /// For example: from top (orientation), by 1cm (relative position), to the entire page (relation).
36 class SW_DLLPUBLIC SwFormatVertOrient final
: public SfxPoolItem
38 SwTwips m_nYPos
; ///< Contains *always* the current RelPos.
40 sal_Int16 m_eRelation
;
42 SwFormatVertOrient( SwTwips nY
= 0, sal_Int16 eVert
= css::text::VertOrientation::NONE
,
43 sal_Int16 eRel
= css::text::RelOrientation::PRINT_AREA
);
44 SwFormatVertOrient(SwFormatVertOrient
const &) = default; // SfxPoolItem copy function dichotomy
46 /// "Pure virtual methods" of SfxPoolItem.
47 virtual bool operator==( const SfxPoolItem
& ) const override
;
48 virtual size_t hashCode() const override
;
49 virtual SwFormatVertOrient
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
50 virtual bool GetPresentation( SfxItemPresentation ePres
,
54 const IntlWrapper
& rIntl
) const override
;
55 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
56 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
58 sal_Int16
GetVertOrient() const { return m_eOrient
; }
59 sal_Int16
GetRelationOrient() const { return m_eRelation
; }
60 void SetVertOrient( sal_Int16 eNew
)
61 { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_eOrient
= eNew
; }
62 void SetRelationOrient( sal_Int16 eNew
)
63 { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_eRelation
= eNew
; }
65 SwTwips
GetPos() const { return m_nYPos
; }
66 void SetPos( SwTwips nNew
)
67 { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_nYPos
= nNew
; }
69 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
72 virtual ItemInstanceManager
* getItemInstanceManager() const override
;
75 /// Defines the horizontal position of a fly frame.
77 /// For example: from left (orientation), by 1 cm (relative position), to the entire page
79 class SW_DLLPUBLIC SwFormatHoriOrient final
: public SfxPoolItem
81 SwTwips m_nXPos
; ///< Contains *always* the current RelPos.
83 sal_Int16 m_eRelation
;
84 bool m_bPosToggle
: 1; ///< Flip position on even pages.
86 SwFormatHoriOrient( SwTwips nX
= 0, sal_Int16 eHori
= css::text::HoriOrientation::NONE
,
87 sal_Int16 eRel
= css::text::RelOrientation::PRINT_AREA
, bool bPos
= false );
88 SwFormatHoriOrient(SwFormatHoriOrient
const &) = default; // SfxPoolItem copy function dichotomy
90 /// "Pure virtual methods" of SfxPoolItem.
91 virtual bool operator==( const SfxPoolItem
& ) const override
;
92 virtual size_t hashCode() const override
;
93 virtual SwFormatHoriOrient
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
94 virtual bool GetPresentation( SfxItemPresentation ePres
,
98 const IntlWrapper
& rIntl
) const override
;
99 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
100 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
102 sal_Int16
GetHoriOrient() const { return m_eOrient
; }
103 sal_Int16
GetRelationOrient() const { return m_eRelation
; }
104 void SetHoriOrient( sal_Int16 eNew
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_eOrient
= eNew
; }
105 void SetRelationOrient( sal_Int16 eNew
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_eRelation
= eNew
; }
107 SwTwips
GetPos() const { return m_nXPos
; }
108 void SetPos( SwTwips nNew
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_nXPos
= nNew
; }
110 bool IsPosToggle() const { return m_bPosToggle
; }
111 void SetPosToggle( bool bNew
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_bPosToggle
= bNew
; }
113 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
116 virtual ItemInstanceManager
* getItemInstanceManager() const override
;
119 inline const SwFormatVertOrient
&SwAttrSet::GetVertOrient(bool bInP
) const
120 { return Get( RES_VERT_ORIENT
,bInP
); }
121 inline const SwFormatHoriOrient
&SwAttrSet::GetHoriOrient(bool bInP
) const
122 { return Get( RES_HORI_ORIENT
,bInP
); }
124 inline const SwFormatVertOrient
&SwFormat::GetVertOrient(bool bInP
) const
125 { return m_aSet
.GetVertOrient(bInP
); }
126 inline const SwFormatHoriOrient
&SwFormat::GetHoriOrient(bool bInP
) const
127 { return m_aSet
.GetHoriOrient(bInP
); }
131 bool GetAtPageRelOrientation(sal_Int16
& rOrientation
, bool const isIgnorePrintArea
);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */