fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / lotuswordpro / source / filter / lwpobjid.cxx
blob0962f375240b62a7e87c424a32c1fe7c61dc4cf0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /*************************************************************************
57 * @file
58 * For LWP filter architecture prototype
59 ************************************************************************/
60 /*************************************************************************
61 * Change History
62 Jan 2005 Created
63 ************************************************************************/
65 #include "lwpobjid.hxx"
66 #include "lwpfilehdr.hxx"
67 #include "lwpobjfactory.hxx"
68 #include "lwpglobalmgr.hxx"
70 LwpObjectID::LwpObjectID(sal_uInt32 low, sal_uInt16 high)
71 :m_nLow(low), m_nHigh(high), m_nIndex(0), m_bIsCompressed(false)
74 /**
75 * @descr Read object id with format: low(4bytes)+high(2bytes) from stream
76 * for LWP7 record
78 sal_uInt32 LwpObjectID::Read(LwpSvStream *pStrm)
80 pStrm->ReadUInt32( m_nLow );
81 pStrm->ReadUInt16( m_nHigh );
82 return DiskSize();
84 /**
85 * @descr Read object id with format: low(4bytes)+high(2bytes) from object stream
87 sal_uInt32 LwpObjectID::Read(LwpObjectStream *pObj)
89 m_nLow = pObj->QuickReaduInt32();
90 m_nHigh = pObj->QuickReaduInt16();
91 return DiskSize();
93 /**
94 * @descr Read object id with indexed format from stream
95 * if index>0, lowid is get from time table per the index
96 * else index+lowid+highid
98 sal_uInt32 LwpObjectID::ReadIndexed(LwpSvStream *pStrm)
100 //note the m_nLow store the index instead of time from the timetable as in LWP
101 m_bIsCompressed = false;
102 if( LwpFileHeader::m_nFileRevision < 0x000B)
104 return Read(pStrm);
107 pStrm->ReadUInt8( m_nIndex );
109 if (m_nIndex)
111 m_bIsCompressed = true;
112 //m_nLow = index; //note the m_nLow stores the index instead of the actual time id
113 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
114 LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
115 LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
116 m_nLow = rIdxMgr.GetObjTime( (sal_uInt16)m_nIndex);
118 else
120 pStrm->ReadUInt32( m_nLow );
122 pStrm->ReadUInt16( m_nHigh );
123 return DiskSizeIndexed();
127 * @descr Read object id with indexed format from object stream
128 * if index>0, lowid is get from time table per the index
129 * else index+lowid+highid
131 sal_uInt32 LwpObjectID::ReadIndexed(LwpObjectStream *pStrm)
133 m_bIsCompressed = false;
134 if(LwpFileHeader::m_nFileRevision < 0x000B)
136 return Read(pStrm);
139 m_nIndex = pStrm->QuickReaduInt8();
140 if (m_nIndex)
142 m_bIsCompressed = true;
143 //m_nLow = index; //note the m_nLow stores the index instead of the actual time id
144 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
145 LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
146 LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
147 m_nLow = rIdxMgr.GetObjTime( (sal_uInt16)m_nIndex);
149 else
150 m_nLow = pStrm->QuickReaduInt32();
151 m_nHigh = pStrm->QuickReaduInt16();
152 return DiskSizeIndexed();
155 * @descr Read object id with compressed format from object stream
156 * if diff == 255: 255+lowid+highid
157 * else lowid equals to the lowid of previous low id
158 * and high id = the high id of previous id + diff +1
160 sal_uInt32 LwpObjectID::ReadCompressed( LwpObjectStream* pObj, LwpObjectID &prev )
162 sal_uInt8 diff = pObj->QuickReaduInt8();
163 sal_uInt32 len=1;
165 if (diff == 255)
167 len += Read(pObj);
169 else
171 m_nLow = prev.GetLow();
172 m_nHigh = prev.GetHigh() + diff +1;
174 return len;
177 * @descr return the size of indexed object id
179 sal_uInt32 LwpObjectID::DiskSizeIndexed() const
181 return sizeof(sal_uInt8)
182 + ((m_nIndex != 0) ? 0 : sizeof(m_nLow))
183 + sizeof(m_nHigh);
186 * @descr get object from object factory per the object id
188 rtl::Reference<LwpObject> LwpObjectID::obj(VO_TYPE tag) const
190 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
191 LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
192 if(IsNull())
194 return NULL;
196 rtl::Reference<LwpObject> pObj = pObjMgr->QueryObject(*this);
197 if( tag!=VO_INVALID && (pObj.is()) )
199 if(static_cast<sal_uInt32>(tag) != pObj->GetTag())
201 pObj.clear();
204 return pObj;
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */