Line data Source code
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 :
10 : #ifndef _RTFFLY_HXX_
11 : #define _RTFFLY_HXX_
12 :
13 : namespace writerfilter {
14 : namespace rtftok {
15 : /// Stores the vertical orientation properties of an RTF fly frame.
16 : class RTFVertOrient
17 : {
18 : public:
19 0 : RTFVertOrient(sal_uInt16 nValue)
20 0 : : nVal(nValue)
21 : {
22 0 : }
23 :
24 0 : sal_uInt16 GetOrient() const
25 : {
26 0 : return OSL_LONIBBLE(OSL_LOBYTE(nVal));
27 : }
28 :
29 0 : sal_uInt16 GetRelation() const
30 : {
31 0 : return OSL_HINIBBLE(OSL_LOBYTE(nVal));
32 : }
33 :
34 0 : sal_Int32 GetAlign() const
35 : {
36 0 : sal_Int32 nAlign = 0;
37 0 : switch( GetOrient( ) )
38 : {
39 : case text::VertOrientation::CENTER:
40 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center;
41 0 : break;
42 : case text::VertOrientation::TOP:
43 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top;
44 0 : break;
45 : case text::VertOrientation::BOTTOM:
46 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom;
47 0 : break;
48 : }
49 :
50 0 : return nAlign;
51 : }
52 :
53 0 : sal_Int32 GetAnchor() const
54 : {
55 0 : sal_Int32 nAnchor = 0;
56 0 : switch( GetRelation( ) )
57 : {
58 : case text::RelOrientation::FRAME:
59 0 : nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_text;
60 0 : break;
61 : case text::RelOrientation::PAGE_FRAME:
62 0 : nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_page;
63 0 : break;
64 : case text::RelOrientation::PAGE_PRINT_AREA:
65 0 : nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_margin;
66 0 : break;
67 : }
68 :
69 0 : return nAnchor;
70 : }
71 :
72 : sal_uInt16 GetValue() const
73 : {
74 : return nVal;
75 : }
76 :
77 : private:
78 : sal_uInt16 nVal;
79 : };
80 :
81 : /// Stores the horizontal orientation properties of an RTF fly frame.
82 : class RTFHoriOrient
83 : {
84 : public:
85 0 : RTFHoriOrient(sal_uInt16 nValue)
86 0 : : nVal(nValue)
87 : {
88 0 : }
89 :
90 0 : sal_uInt16 GetOrient() const
91 : {
92 0 : return OSL_LONIBBLE(OSL_LOBYTE(nVal));
93 : }
94 :
95 0 : sal_uInt16 GetRelation() const
96 : {
97 0 : return OSL_LONIBBLE(OSL_HIBYTE(nVal));
98 : }
99 :
100 : sal_uInt16 GetRelAnchor() const
101 : {
102 : return OSL_HINIBBLE(OSL_LOBYTE(nVal));
103 : }
104 :
105 0 : sal_Int32 GetAlign() const
106 : {
107 0 : sal_Int32 nAlign = 0;
108 0 : switch( GetOrient( ) )
109 : {
110 : case text::HoriOrientation::CENTER:
111 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_center;
112 0 : break;
113 : case text::HoriOrientation::RIGHT:
114 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right;
115 0 : break;
116 : case text::HoriOrientation::LEFT:
117 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left;
118 0 : break;
119 : case text::HoriOrientation::INSIDE:
120 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_inside;
121 0 : break;
122 : case text::HoriOrientation::OUTSIDE:
123 0 : nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_outside;
124 0 : break;
125 : }
126 :
127 0 : return nAlign;
128 : }
129 :
130 0 : sal_Int32 GetAnchor() const
131 : {
132 0 : sal_Int32 nAnchor = 0;
133 0 : switch( GetRelation( ) )
134 : {
135 : case text::RelOrientation::FRAME:
136 0 : nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_text;
137 0 : break;
138 : case text::RelOrientation::PAGE_FRAME:
139 0 : nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_page;
140 0 : break;
141 : case text::RelOrientation::PAGE_PRINT_AREA:
142 0 : nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_margin;
143 0 : break;
144 : }
145 :
146 0 : return nAnchor;
147 : }
148 :
149 : sal_uInt16 GetValue() const
150 : {
151 : return nVal;
152 : }
153 :
154 : private:
155 : sal_uInt16 nVal;
156 : };
157 : } // namespace rtftok
158 : } // namespace writerfilter
159 :
160 : #endif // _RTFFLY_HXX_
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|