Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * The Contents of this file are made available subject to the terms of
5 : : * either of the following licenses
6 : : *
7 : : * - GNU Lesser General Public License Version 2.1
8 : : * - Sun Industry Standards Source License Version 1.1
9 : : *
10 : : * Sun Microsystems Inc., October, 2000
11 : : *
12 : : * GNU Lesser General Public License Version 2.1
13 : : * =============================================
14 : : * Copyright 2000 by Sun Microsystems, Inc.
15 : : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : : *
17 : : * This library is free software; you can redistribute it and/or
18 : : * modify it under the terms of the GNU Lesser General Public
19 : : * License version 2.1, as published by the Free Software Foundation.
20 : : *
21 : : * This library is distributed in the hope that it will be useful,
22 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : : * Lesser General Public License for more details.
25 : : *
26 : : * You should have received a copy of the GNU Lesser General Public
27 : : * License along with this library; if not, write to the Free Software
28 : : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : : * MA 02111-1307 USA
30 : : *
31 : : *
32 : : * Sun Industry Standards Source License Version 1.1
33 : : * =================================================
34 : : * The contents of this file are subject to the Sun Industry Standards
35 : : * Source License Version 1.1 (the "License"); You may not use this file
36 : : * except in compliance with the License. You may obtain a copy of the
37 : : * License at http://www.openoffice.org/license.html.
38 : : *
39 : : * Software provided under this License is provided on an "AS IS" basis,
40 : : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : : * See the License for the specific provisions governing your rights and
44 : : * obligations concerning the Software.
45 : : *
46 : : * The Initial Developer of the Original Code is: IBM Corporation
47 : : *
48 : : * Copyright: 2008 by IBM Corporation
49 : : *
50 : : * All Rights Reserved.
51 : : *
52 : : * Contributor(s): _______________________________________
53 : : *
54 : : *
55 : : ************************************************************************/
56 : : /*************************************************************************
57 : : * @file
58 : : * Frame object for OOo.This is the basic object for all Shape Layer.
59 : : * You can reference to the XFFrame object.
60 : : ************************************************************************/
61 : : #ifndef _XFFRAME_HXX
62 : : #define _XFFRAME_HXX
63 : :
64 : : #include "xfglobal.hxx"
65 : : #include "xfcontent.hxx"
66 : : #include "xfrect.hxx"
67 : : #include "xfcontentcontainer.hxx"
68 : :
69 : : #define XFFRAME_FLAG_HEIGHT 0x00000001
70 : : #define XFFRAME_FLAG_MINHEIGHT 0x00000002
71 : : #define XFFRAME_FLAG_MAXHEIGHT 0x00000004
72 : : /**
73 : : * @brief
74 : : * Base class for all frame object,include drawing,image,text-box.
75 : : *
76 : : * Use SetX(),SetY(),SetWidth(),SetHeight() to set postion for the frame.
77 : : * Only if you set anchor type to enumXFAnchorPage, the SetAnchorPage functions.
78 : : */
79 : : class XFFrame : public XFContentContainer
80 : : {
81 : : public:
82 : : XFFrame();
83 : : XFFrame(sal_Bool isTextBox);
84 : :
85 : : virtual ~XFFrame();
86 : :
87 : : public:
88 : : using XFContentContainer::Add;
89 : :
90 : : /**
91 : : * @descr override the add function to adjust z-index.
92 : : */
93 : : virtual void Add(IXFContent *pContent);
94 : :
95 : : /**
96 : : * @descr: Set the anchor type for the frame object.
97 : : */
98 : : void SetAnchorType(enumXFAnchor type);
99 : :
100 : : /**
101 : : * @descr: if it's page anchor,set the page number.
102 : : */
103 : : void SetAnchorPage(sal_Int32 page);
104 : :
105 : : /**
106 : : * @descr Set frame name.
107 : : */
108 : : void SetName(rtl::OUString name);
109 : :
110 : : /**
111 : : * @descr Set z-index of the frame.
112 : : */
113 : : void SetZIndex(sal_uInt32 zIndex);
114 : : /**
115 : : * @descr Set frame position X.
116 : : */
117 : : void SetX(double x);
118 : :
119 : : /**
120 : : * @descr Set frame position Y.
121 : : */
122 : : void SetY(double y);
123 : :
124 : : /**
125 : : * @descr Set frame wieth.
126 : : */
127 : : void SetWidth(double width);
128 : :
129 : : /**
130 : : * @descr Set frame height. Be careful SetHeight and SetMinHeight will override each other.
131 : : */
132 : : void SetHeight(double height);
133 : :
134 : : /**
135 : : * @descr Set frame min-height. Be careful SetHeight and SetMinHeight will override each other.
136 : : */
137 : : void SetMinHeight(double minHeight);
138 : :
139 : : /**
140 : : * @descr Set frame max-height.
141 : : */
142 : : void SetMaxHeight(double minHeight);
143 : :
144 : : /**
145 : : * @descr Set frame position.
146 : : */
147 : : void SetPosition(double x, double y, double width, double height);
148 : :
149 : : /**
150 : : * @descr Set frame position.
151 : : */
152 : : void SetPosition(const XFRect& rect);
153 : :
154 : : /**
155 : : * @descr: Link the text content of the two frame.
156 : : */
157 : : void SetNextLink(rtl::OUString next);
158 : :
159 : : /**
160 : : * @descr Get the frame type. image, drawing or text-box.
161 : : */
162 : : virtual enumXFFrameType GetFrameType();
163 : :
164 : : /**
165 : : * @descr Get content type, enumXFContentFrame.
166 : : */
167 : : virtual enumXFContent GetContentType();
168 : :
169 : : /**
170 : : * @descr serialize.
171 : : */
172 : : virtual void ToXml(IXFStream *pStrm);
173 : :
174 : : private:
175 : : void StartFrame(IXFStream *pStrm);
176 : :
177 : : void EndFrame(IXFStream *pStrm);
178 : :
179 : : void AdjustZIndex();
180 : :
181 : : protected:
182 : : enumXFAnchor m_eAnchor;
183 : : sal_Int32 m_nAnchorPage;
184 : : rtl::OUString m_strName;
185 : : sal_uInt32 m_nZIndex;
186 : : XFRect m_aRect;
187 : : double m_fMinHeight;
188 : : double m_fMaxHeight;
189 : : rtl::OUString m_strNextLink;
190 : : enumXFFrameType m_eType;
191 : : sal_uInt32 m_nFlag;
192 : : sal_Bool m_isTextBox;
193 : : };
194 : :
195 : 96 : inline void XFFrame::SetAnchorType(enumXFAnchor anchor)
196 : : {
197 : 96 : m_eAnchor = anchor;
198 : 96 : }
199 : :
200 : 0 : inline void XFFrame::SetName(rtl::OUString name)
201 : : {
202 : 0 : m_strName = name;
203 : 0 : }
204 : :
205 : 39 : inline void XFFrame::SetX(double x)
206 : : {
207 : 39 : m_aRect.SetX(x);
208 : 39 : }
209 : :
210 : 39 : inline void XFFrame::SetY(double y)
211 : : {
212 : 39 : m_aRect.SetY(y);
213 : 39 : }
214 : :
215 : 96 : inline void XFFrame::SetWidth(double width)
216 : : {
217 : 96 : m_aRect.SetWidth(width);
218 : 96 : }
219 : :
220 : 96 : inline void XFFrame::SetHeight(double height)
221 : : {
222 : 96 : m_aRect.SetHeight(height);
223 : 96 : m_nFlag |= XFFRAME_FLAG_HEIGHT;
224 : 96 : m_nFlag &= XFFRAME_FLAG_HEIGHT;
225 : 96 : }
226 : :
227 : 18 : inline void XFFrame::SetMinHeight(double minHeight)
228 : : {
229 : 18 : m_fMinHeight = minHeight;
230 : 18 : m_nFlag |= XFFRAME_FLAG_MINHEIGHT;
231 : 18 : m_nFlag &= XFFRAME_FLAG_MINHEIGHT;
232 : 18 : }
233 : :
234 : : inline void XFFrame::SetMaxHeight(double maxHeight)
235 : : {
236 : : m_fMaxHeight = maxHeight;
237 : : m_nFlag |= XFFRAME_FLAG_MAXHEIGHT;
238 : : m_nFlag &= XFFRAME_FLAG_MAXHEIGHT;
239 : : }
240 : :
241 : 9 : inline void XFFrame::SetPosition(double x, double y, double width, double height)
242 : : {
243 : 9 : m_aRect.SetStartPoint(XFPoint(x,y));
244 : 9 : m_aRect.SetSize(width,height);
245 : 9 : m_nFlag |= XFFRAME_FLAG_HEIGHT;
246 : 9 : }
247 : :
248 : 0 : inline void XFFrame::SetPosition(const XFRect& rect)
249 : : {
250 : 0 : m_aRect = rect;
251 : 0 : }
252 : :
253 : 39 : inline void XFFrame::SetNextLink(rtl::OUString next)
254 : : {
255 : 39 : m_strNextLink = next;
256 : 39 : }
257 : :
258 : 78 : inline void XFFrame::SetAnchorPage(sal_Int32 page)
259 : : {
260 : 78 : m_nAnchorPage = page;
261 : 78 : }
262 : :
263 : : #endif
264 : :
265 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|