tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / lotuswordpro / source / filter / lwpobjid.cxx
bloba0a278ec5af707f09d9ab959661957ee1d10fe5b
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 ************************************************************************/
61 #include <lwpobjid.hxx>
62 #include <lwpfilehdr.hxx>
63 #include <lwpobjfactory.hxx>
64 #include <lwpglobalmgr.hxx>
66 LwpObjectID::LwpObjectID()
67 : m_nLow(0)
68 , m_nHigh(0)
69 , m_nIndex(0)
70 , m_bIsCompressed(false)
73 /**
74 * @descr Read object id with format: low(4bytes)+high(2bytes) from stream
75 * for LWP7 record
77 void LwpObjectID::Read(LwpSvStream* pStrm)
79 pStrm->ReadUInt32(m_nLow);
80 pStrm->ReadUInt16(m_nHigh);
82 /**
83 * @descr Read object id with format: low(4bytes)+high(2bytes) from object stream
85 sal_uInt32 LwpObjectID::Read(LwpObjectStream* pObj)
87 m_nLow = pObj->QuickReaduInt32();
88 m_nHigh = pObj->QuickReaduInt16();
89 return DiskSize();
91 /**
92 * @descr Read object id with indexed format from stream
93 * if index>0, lowid is get from time table per the index
94 * else index+lowid+highid
96 void LwpObjectID::ReadIndexed(LwpSvStream* pStrm)
98 //note the m_nLow store the index instead of time from the timetable as in LWP
99 m_bIsCompressed = false;
100 if (LwpFileHeader::m_nFileRevision < 0x000B)
102 Read(pStrm);
103 return;
106 pStrm->ReadUInt8(m_nIndex);
108 if (m_nIndex)
110 m_bIsCompressed = true;
111 //m_nLow = index; //note the m_nLow stores the index instead of the actual time id
112 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
113 LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
114 LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
115 m_nLow = rIdxMgr.GetObjTime(static_cast<sal_uInt16>(m_nIndex));
117 else
119 pStrm->ReadUInt32(m_nLow);
121 pStrm->ReadUInt16(m_nHigh);
122 DiskSizeIndexed();
126 * @descr Read object id with indexed format from object stream
127 * if index>0, lowid is get from time table per the index
128 * else index+lowid+highid
130 sal_uInt32 LwpObjectID::ReadIndexed(LwpObjectStream* pStrm)
132 m_bIsCompressed = false;
133 if (LwpFileHeader::m_nFileRevision < 0x000B)
135 return Read(pStrm);
138 m_nIndex = pStrm->QuickReaduInt8();
139 if (m_nIndex)
141 m_bIsCompressed = true;
142 //m_nLow = index; //note the m_nLow stores the index instead of the actual time id
143 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
144 LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
145 LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
146 m_nLow = rIdxMgr.GetObjTime(static_cast<sal_uInt16>(m_nIndex));
148 else
149 m_nLow = pStrm->QuickReaduInt32();
150 m_nHigh = pStrm->QuickReaduInt16();
151 return DiskSizeIndexed();
154 * @descr Read object id with compressed format from object stream
155 * if diff == 255: 255+lowid+highid
156 * else lowid equals to the lowid of previous low id
157 * and high id = the high id of previous id + diff +1
159 void LwpObjectID::ReadCompressed(LwpObjectStream* pObj, LwpObjectID const& prev)
161 sal_uInt8 diff = pObj->QuickReaduInt8();
163 if (diff == 255)
165 Read(pObj);
167 else
169 m_nLow = prev.GetLow();
170 m_nHigh = prev.GetHigh() + diff + 1;
174 * @descr return the size of indexed object id
176 sal_uInt32 LwpObjectID::DiskSizeIndexed() const
178 return sizeof(sal_uInt8) + ((m_nIndex != 0) ? 0 : sizeof(m_nLow)) + sizeof(m_nHigh);
181 * @descr get object from object factory per the object id
183 rtl::Reference<LwpObject> LwpObjectID::obj(VO_TYPE tag) const
185 if (IsNull())
187 return nullptr;
189 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
190 LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
191 rtl::Reference<LwpObject> pObj = pObjMgr->QueryObject(*this);
192 if (tag != VO_INVALID && (pObj.is()))
194 if (static_cast<sal_uInt32>(tag) != pObj->GetTag())
196 pObj.clear();
199 return pObj;
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */