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  *  For LWP filter architecture prototype
59  ************************************************************************/
60 
61 #include "lwplaypiece.hxx"
62 #include "lwpstyledef.hxx"
63 #include <lwpfilehdr.hxx>
64 
65 
LwpRotor()66 LwpRotor::LwpRotor()
67     : m_nRotation(0)
68 {}
69 
~LwpRotor()70 LwpRotor::~LwpRotor()
71 {}
72 
Read(LwpObjectStream * pStrm)73 void LwpRotor:: Read(LwpObjectStream *pStrm)
74 {
75     m_nRotation = pStrm->QuickReadInt16();
76 }
77 
LwpLayoutGeometry(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)78 LwpLayoutGeometry::LwpLayoutGeometry(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
79     : LwpVirtualPiece(objHdr, pStrm)
80     , m_nWidth(0)
81     , m_nHeight(0)
82     , m_ContentOrientation(0)
83 {}
84 
~LwpLayoutGeometry()85 LwpLayoutGeometry::~LwpLayoutGeometry()
86 {}
87 
Read()88 void LwpLayoutGeometry::Read()
89 {
90     LwpVirtualPiece::Read();
91 
92     if(LwpFileHeader::m_nFileRevision >= 0x000B)
93     {
94         m_nWidth = m_pObjStrm->QuickReadInt32();
95         m_nHeight = m_pObjStrm->QuickReadInt32();
96         m_Origin.Read(m_pObjStrm.get());
97         m_AbsoluteOrigin.Read(m_pObjStrm.get());
98         m_ContainerRotor.Read(m_pObjStrm.get());
99         m_ContentOrientation = m_pObjStrm->QuickReaduInt8();
100         m_pObjStrm->SkipExtra();
101     }
102 }
Parse(IXFStream *)103 void LwpLayoutGeometry::Parse(IXFStream* /*pOutputStream*/)
104 {}
105 
LwpLayoutScale(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)106 LwpLayoutScale::LwpLayoutScale(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
107     : LwpVirtualPiece(objHdr, pStrm)
108     , m_nScaleMode(0)
109     , m_nScalePercentage(0)
110     , m_nScaleWidth(0)
111     , m_nScaleHeight(0)
112     , m_nContentRotation(0)
113     , m_nPlacement(0)
114 {}
115 
~LwpLayoutScale()116 LwpLayoutScale::~LwpLayoutScale()
117 {}
118 
Read()119 void LwpLayoutScale::Read()
120 {
121     LwpVirtualPiece::Read();
122 
123     if(LwpFileHeader::m_nFileRevision >= 0x000B)
124     {
125         m_nScaleMode = m_pObjStrm->QuickReaduInt16();
126         m_nScalePercentage = m_pObjStrm->QuickReaduInt32();
127         m_nScaleWidth = m_pObjStrm->QuickReadInt32();
128         m_nScaleHeight = m_pObjStrm->QuickReadInt32();
129         m_nContentRotation = m_pObjStrm->QuickReaduInt16();
130         m_Offset.Read(m_pObjStrm.get());
131 
132         m_nPlacement = m_pObjStrm->QuickReaduInt16();
133         m_pObjStrm->SkipExtra();
134     }
135 }
136 
Parse(IXFStream *)137 void LwpLayoutScale::Parse(IXFStream* /*pOutputStream*/)
138 {}
139 
LwpLayoutMargins(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)140 LwpLayoutMargins::LwpLayoutMargins(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
141     : LwpVirtualPiece(objHdr, pStrm)
142 {}
143 
~LwpLayoutMargins()144 LwpLayoutMargins::~LwpLayoutMargins()
145 {}
146 
Read()147 void LwpLayoutMargins::Read()
148 {
149     LwpVirtualPiece::Read();
150 
151     if( LwpFileHeader::m_nFileRevision >= 0x000B )
152     {
153         m_Margins.Read(m_pObjStrm.get());
154         m_ExtMargins.Read(m_pObjStrm.get());
155         m_ExtraMargins.Read(m_pObjStrm.get());
156         m_pObjStrm->SkipExtra();
157     }
158 }
159 
Parse(IXFStream *)160 void LwpLayoutMargins::Parse(IXFStream* /*pOutputStream*/)
161 {}
162 
LwpLayoutBorder(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)163 LwpLayoutBorder::LwpLayoutBorder(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
164     : LwpVirtualPiece(objHdr, pStrm)
165 {}
166 
~LwpLayoutBorder()167 LwpLayoutBorder::~LwpLayoutBorder()
168 {}
169 
Read()170 void LwpLayoutBorder::Read()
171 {
172     LwpVirtualPiece::Read();
173 
174     if( LwpFileHeader::m_nFileRevision >= 0x000B )
175     {
176         m_BorderStuff.Read(m_pObjStrm.get());
177         m_pObjStrm->SkipExtra();
178     }
179 }
180 
Parse(IXFStream *)181 void LwpLayoutBorder::Parse(IXFStream* /*pOutputStream*/)
182 {}
183 
LwpLayoutBackground(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)184 LwpLayoutBackground::LwpLayoutBackground(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
185     : LwpVirtualPiece(objHdr, pStrm)
186 {}
187 
~LwpLayoutBackground()188 LwpLayoutBackground::~LwpLayoutBackground()
189 {}
190 
Read()191 void LwpLayoutBackground::Read()
192 {
193     LwpVirtualPiece::Read();
194 
195     if( LwpFileHeader::m_nFileRevision >= 0x000B )
196     {
197         m_BackgroundStuff.Read(m_pObjStrm.get());
198         m_pObjStrm->SkipExtra();
199     }
200 }
201 
Parse(IXFStream *)202 void LwpLayoutBackground::Parse(IXFStream* /*pOutputStream*/)
203 {}
204 
LwpExternalBorder()205 LwpExternalBorder::LwpExternalBorder()
206 {}
207 
~LwpExternalBorder()208 LwpExternalBorder::~LwpExternalBorder()
209 {}
210 
Read(LwpObjectStream * pStrm)211 void LwpExternalBorder:: Read(LwpObjectStream *pStrm)
212 {
213     if( LwpFileHeader::m_nFileRevision >= 0x000F )
214     {
215         //enum {BORDER,JOIN};
216         m_LeftName.Read(pStrm);
217         m_TopName.Read(pStrm);
218         m_RightName.Read(pStrm);
219         m_BottomName.Read(pStrm);
220         // TODO: Do not know what it is for
221         /*cLeftName = CStyleMgr::GetUniqueMetaFileName(cLeftName,BORDER);
222         cRightName = CStyleMgr::GetUniqueMetaFileName(cRightName,BORDER);
223         cTopName = CStyleMgr::GetUniqueMetaFileName(cTopName,BORDER);
224         cBottomName = CStyleMgr::GetUniqueMetaFileName(cBottomName,BORDER);*/
225         pStrm->SkipExtra();
226     }
227 }
228 
LwpLayoutExternalBorder(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)229 LwpLayoutExternalBorder::LwpLayoutExternalBorder(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
230     : LwpVirtualPiece(objHdr, pStrm)
231 {}
232 
~LwpLayoutExternalBorder()233 LwpLayoutExternalBorder::~LwpLayoutExternalBorder()
234 {}
235 
Read()236 void LwpLayoutExternalBorder::Read()
237 {
238     LwpVirtualPiece::Read();
239 
240     if( LwpFileHeader::m_nFileRevision >= 0x000B )
241     {
242         m_ExtranalBorder.Read(m_pObjStrm.get());
243         m_pObjStrm->SkipExtra();
244     }
245 }
246 
Parse(IXFStream *)247 void LwpLayoutExternalBorder::Parse(IXFStream* /*pOutputStream*/)
248 {}
249 
LwpColumnInfo()250 LwpColumnInfo::LwpColumnInfo()
251     : m_nWidth(0)
252     , m_nGap(0)
253 {}
254 
~LwpColumnInfo()255 LwpColumnInfo::~LwpColumnInfo()
256 {}
257 
Read(LwpObjectStream * pStrm)258 void LwpColumnInfo:: Read(LwpObjectStream *pStrm)
259 {
260     m_nWidth = pStrm->QuickReadInt32();
261     m_nGap = pStrm->QuickReadInt32();
262 }
263 
LwpLayoutColumns(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)264 LwpLayoutColumns::LwpLayoutColumns(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
265     : LwpVirtualPiece(objHdr, pStrm)
266     , m_nNumCols(0)
267 {}
268 
~LwpLayoutColumns()269 LwpLayoutColumns::~LwpLayoutColumns()
270 {
271 }
272 
Read()273 void LwpLayoutColumns::Read()
274 {
275     LwpVirtualPiece::Read();
276 
277     if( LwpFileHeader::m_nFileRevision >= 0x000B )
278     {
279         m_nNumCols = m_pObjStrm->QuickReaduInt16();
280         m_pColumns.reset( new LwpColumnInfo[m_nNumCols] );
281         for(int i=0; i<m_nNumCols; i++)
282         {
283             m_pColumns[i].Read(m_pObjStrm.get());
284         }
285         m_pObjStrm->SkipExtra();
286     }
287 }
288 
GetColGap(sal_uInt16 nIndex)289 double LwpLayoutColumns::GetColGap(sal_uInt16 nIndex)
290 {
291     if(nIndex >= m_nNumCols)
292     {
293         return 0;
294     }
295     return m_pColumns[nIndex].GetGap();
296 }
297 
Parse(IXFStream *)298 void LwpLayoutColumns::Parse(IXFStream* /*pOutputStream*/)
299 {}
300 
LwpLayoutGutters(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)301 LwpLayoutGutters::LwpLayoutGutters(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
302     : LwpVirtualPiece(objHdr, pStrm)
303 {}
304 
~LwpLayoutGutters()305 LwpLayoutGutters::~LwpLayoutGutters()
306 {}
307 
Read()308 void LwpLayoutGutters::Read()
309 {
310     LwpVirtualPiece::Read();
311 
312     if( LwpFileHeader::m_nFileRevision >= 0x000B )
313     {
314         m_BorderBuffer.Read(m_pObjStrm.get());
315         m_pObjStrm->SkipExtra();
316     }
317 }
318 
Parse(IXFStream *)319 void LwpLayoutGutters::Parse(IXFStream* /*pOutputStream*/)
320 {}
321 
LwpJoinStuff()322 LwpJoinStuff::LwpJoinStuff()
323     : m_nPercentage(0)
324     , m_nCorners(0)
325     , m_nWidth(0)
326     , m_nHeight(0)
327     , m_nID(0)
328     , m_nScaling(0)
329 {}
330 
~LwpJoinStuff()331 LwpJoinStuff::~LwpJoinStuff()
332 {}
333 
Read(LwpObjectStream * pStrm)334 void LwpJoinStuff:: Read(LwpObjectStream *pStrm)
335 {
336     m_nWidth = pStrm->QuickReadInt32();
337     m_nHeight = pStrm->QuickReadInt32();
338     m_nPercentage = pStrm->QuickReaduInt16();
339     m_nID = pStrm->QuickReaduInt16();
340     m_nCorners = pStrm->QuickReaduInt16();
341     m_nScaling = pStrm->QuickReaduInt16();
342     m_Color.Read(pStrm);
343     pStrm->SkipExtra();
344 
345     // Bug fix: if reading in from something older than Release 9
346     // then check for the external ID and change it to solid.
347     if (LwpFileHeader::m_nFileRevision < 0x0010)
348     {
349         if (m_nID & EXTERNAL_ID)
350             m_nID = MITRE;
351     }
352 }
353 
LwpLayoutJoins(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)354 LwpLayoutJoins::LwpLayoutJoins(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
355     : LwpVirtualPiece(objHdr, pStrm)
356 {}
357 
~LwpLayoutJoins()358 LwpLayoutJoins::~LwpLayoutJoins()
359 {}
360 
Read()361 void LwpLayoutJoins::Read()
362 {
363     LwpVirtualPiece::Read();
364 
365     if( LwpFileHeader::m_nFileRevision >= 0x000B )
366     {
367         m_JoinStuff.Read(m_pObjStrm.get());
368         m_pObjStrm->SkipExtra();
369     }
370 }
371 
Parse(IXFStream *)372 void LwpLayoutJoins::Parse(IXFStream* /*pOutputStream*/)
373 {}
374 
LwpLayoutShadow(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)375 LwpLayoutShadow::LwpLayoutShadow(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
376     : LwpVirtualPiece(objHdr, pStrm)
377 {}
378 
~LwpLayoutShadow()379 LwpLayoutShadow::~LwpLayoutShadow()
380 {}
381 
Read()382 void LwpLayoutShadow::Read()
383 {
384     LwpVirtualPiece::Read();
385 
386     if( LwpFileHeader::m_nFileRevision >= 0x000B )
387     {
388         m_Shadow.Read(m_pObjStrm.get());
389         m_pObjStrm->SkipExtra();
390     }
391 }
392 
Parse(IXFStream *)393 void LwpLayoutShadow::Parse(IXFStream* /*pOutputStream*/)
394 {}
395 
LwpLayoutRelativityGuts()396 LwpLayoutRelativityGuts::LwpLayoutRelativityGuts()
397 {
398     m_nRelType = LAY_PARENT_RELATIVE;
399     m_nRelFromWhere = LAY_UPPERLEFT;
400     m_RelDistance.SetX(0);
401     m_RelDistance.SetY(0);
402     m_nTether = LAY_UPPERLEFT;
403     m_nTetherWhere = LAY_BORDER;
404     m_nFlags = 0;
405 }
406 /**************************************************************************
407  * @descr: Read LayoutRelativityGuts' information.
408 **************************************************************************/
Read(LwpObjectStream * pStrm)409 void LwpLayoutRelativityGuts::Read(LwpObjectStream *pStrm)
410 {
411     m_nRelType = pStrm->QuickReaduInt8();
412     m_nRelFromWhere = pStrm->QuickReaduInt8();
413     m_RelDistance.Read(pStrm);
414     m_nTether = pStrm->QuickReaduInt8();
415     m_nTetherWhere = pStrm->QuickReaduInt8();
416     if(LwpFileHeader::m_nFileRevision >= 0x000B)
417     {
418         m_nFlags = pStrm->QuickReaduInt8();
419     }
420     else
421     {
422         m_nFlags = 0;
423     }
424 }
425 
LwpLayoutRelativity(LwpObjectHeader const & objHdr,LwpSvStream * pStrm)426 LwpLayoutRelativity::LwpLayoutRelativity(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
427     : LwpVirtualPiece(objHdr, pStrm)
428 {
429 }
430 
~LwpLayoutRelativity()431 LwpLayoutRelativity::~LwpLayoutRelativity()
432 {
433 }
434 
Read()435 void LwpLayoutRelativity::Read()
436 {
437     LwpVirtualPiece::Read();
438     if(LwpFileHeader::m_nFileRevision >= 0x000B)
439     {
440         m_RelGuts.Read(m_pObjStrm.get());
441         m_pObjStrm->SkipExtra();
442     }
443 }
444 
Parse(IXFStream *)445 void LwpLayoutRelativity::Parse(IXFStream * /*pOutputStream*/)
446 {
447 }
448 
449 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
450