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,
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 #include "lwpdocdata.hxx"
57 #include "xfilter/xfofficemeta.hxx"
58 #include "localtime.hxx"
59 #include <rtl/ustrbuf.hxx>
60 #include "lwpfilehdr.hxx"
61 #include "lwpglobalmgr.hxx"
63 LwpDocData::LwpDocData(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
64 :LwpObject(objHdr
, pStrm
)//m_pEditorAttrList(0)
67 LwpDocData::~LwpDocData()
71 void LwpDocData::Read()
77 m_DocOptions
.nOptionFlag
= m_pObjStrm
->QuickReaduInt16();
79 m_DocOptions
.encrypt1password
.Read(m_pObjStrm
);
81 m_DocOptions
.encrypt2password
.Read(m_pObjStrm
);
83 m_DocOptions
.characterSet
.Read(m_pObjStrm
);
85 m_DocOptions
.grammerSet
.Read(m_pObjStrm
);
87 m_DocOptions
.nMarginMarks
= m_pObjStrm
->QuickReaduInt16();
88 //cMarginMarksLocation
89 m_DocOptions
.nMarginMarksLocation
= m_pObjStrm
->QuickReaduInt16();
91 m_DocOptions
.nMarginMarksChar
= m_pObjStrm
->QuickReaduInt16();
92 m_pObjStrm
->SkipExtra();
96 m_DocInfo
.description
.Read(m_pObjStrm
);
98 m_DocInfo
.keywords
.Read(m_pObjStrm
);
100 m_DocInfo
.createdBy
.Read(m_pObjStrm
);
102 m_DocInfo
.nCreationTime
= m_pObjStrm
->QuickReadInt32();
103 LtgLocalTime(m_DocInfo
.nCreationTime
,m_nCreationTime
);
105 m_DocInfo
.nLastRevisionTime
= m_pObjStrm
->QuickReadInt32();
106 LtgLocalTime(m_DocInfo
.nLastRevisionTime
,m_nLastRevisionTime
);
108 m_DocInfo
.nTotalEditTime
= m_pObjStrm
->QuickReadInt32();
110 m_nTotalEditTime
.tm_hour
= m_DocInfo
.nTotalEditTime
/ 60;
111 m_nTotalEditTime
.tm_min
= m_DocInfo
.nTotalEditTime
% 60;
112 m_nTotalEditTime
.tm_sec
= 0;
114 m_DocInfo
.cpVerDocInfo
.ReadIndexed(m_pObjStrm
);
117 m_DocInfo
.nNumEditedBy
= m_pObjStrm
->QuickReaduInt16();
118 LwpAtomHolder
* pCDLNList
= new LwpAtomHolder
[m_DocInfo
.nNumEditedBy
];
119 LwpAtomHolder
* pEditorList
= new LwpAtomHolder
[m_DocInfo
.nNumEditedBy
];
121 for ( i
= 0; i
< m_DocInfo
.nNumEditedBy
; i
++)
124 pCDLNList
[i
].Read(m_pObjStrm
); //cName
125 m_pObjStrm
->SkipExtra();
127 pEditorList
[i
].Read(m_pObjStrm
); //cName
128 m_pObjStrm
->SkipExtra();
131 m_pObjStrm
->SkipExtra();
134 delete [] pEditorList
;
138 m_DocControl
.cGreeting
.Read(m_pObjStrm
);
140 m_DocControl
.nFlags
= m_pObjStrm
->QuickReaduInt16();
142 //cDocControlProtection
143 m_DocControl
.nDocControlProtection
= m_pObjStrm
->QuickReaduInt16();
145 m_DocControl
.nLen1
= m_pObjStrm
->QuickReaduInt16();
146 //skip doc control password string
147 m_pObjStrm
->SeekRel(m_DocControl
.nLen1
);
150 m_DocControl
.nFileProtection
= m_pObjStrm
->QuickReaduInt16();
152 m_DocControl
.nLen2
= m_pObjStrm
->QuickReaduInt16();
153 //skip file password string
154 m_pObjStrm
->SeekRel(m_DocControl
.nLen2
);
157 m_DocControl
.nAutoVersioning
= m_pObjStrm
->QuickReaduInt16();
158 //cDocControlOnlyEditor
159 m_DocControl
.cDocControlOnlyEditor
.Read(m_pObjStrm
);
160 //cEditorVerification
161 m_DocControl
.nEditorVerification
= m_pObjStrm
->QuickReaduInt16();
163 m_pObjStrm
->SkipExtra();
167 sal_uInt16 numeditors
= m_pObjStrm
->QuickReaduInt16();
168 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
170 for (i
= 0;i
<numeditors
;i
++)
172 LwpEditorAttr
* pEditorAttr
= new LwpEditorAttr
;
174 pEditorAttr
->cName
.Read(m_pObjStrm
);
176 pEditorAttr
->cInitials
.Read(m_pObjStrm
);
178 pEditorAttr
->cHiLiteColor
.Read(m_pObjStrm
);
181 pEditorAttr
->nID
= m_pObjStrm
->QuickReaduInt16();
184 //CFontAttributeOverride --cAttrBits
185 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cAttrBits
= m_pObjStrm
->QuickReaduInt16();
186 //CFontAttributeOverride --cAttrOverrideBits
187 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cAttrOverrideBits
= m_pObjStrm
->QuickReaduInt16();
188 //CFontAttributeOverride --cAttrApplyBits
189 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cAttrApplyBits
= m_pObjStrm
->QuickReaduInt16();
190 //CFontAttributeOverride --cAttrOverrideBits2
191 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cAttrOverrideBits2
= m_pObjStrm
->QuickReaduInt8();
192 //CFontAttributeOverride --cAttrApplyBits2
193 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cAttrApplyBits2
= m_pObjStrm
->QuickReaduInt8();
194 //CFontAttributeOverride --cCase
195 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cCase
= m_pObjStrm
->QuickReaduInt8();
196 //CFontAttributeOverride --cUnder
197 pEditorAttr
->cInsFontOver
.cFontAttributeOverride
.cUnder
= m_pObjStrm
->QuickReaduInt8();
198 m_pObjStrm
->SkipExtra();
199 //CFontDescriptionOverrideBase--cOverrideBits
200 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cOverrideBits
= m_pObjStrm
->QuickReaduInt8();
201 //CFontDescriptionOverrideBase--cApplyBits
202 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cApplyBits
= m_pObjStrm
->QuickReaduInt8();
203 //CFontDescriptionOverrideBase--cPointSize
204 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cPointSize
= m_pObjStrm
->QuickReadInt32();
205 //CFontDescriptionOverrideBase--cOverstrike
206 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cOverstrike
= m_pObjStrm
->QuickReaduInt8();
207 //CFontDescriptionOverrideBase--cTightness
208 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cTightness
= m_pObjStrm
->QuickReaduInt16();
209 //CFontDescriptionOverrideBase--cColor
210 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cColor
.Read(m_pObjStrm
);
212 //CFontDescriptionOverrideBase--cBackgroundColor
213 pEditorAttr
->cInsFontOver
.cFontDescriptionOverrideBase
.cBackgroundColor
.Read(m_pObjStrm
);
215 m_pObjStrm
->SkipExtra();
217 pEditorAttr
->cInsFontOver
.cFaceName
.Read(m_pObjStrm
);
219 pEditorAttr
->cInsFontOver
.cAltFaceName
.Read(m_pObjStrm
);
220 m_pObjStrm
->SkipExtra();
223 //CFontAttributeOverride --cAttrBits
224 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cAttrBits
= m_pObjStrm
->QuickReaduInt16();
225 //CFontAttributeOverride --cAttrOverrideBits
226 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cAttrOverrideBits
= m_pObjStrm
->QuickReaduInt16();
227 //CFontAttributeOverride --cAttrApplyBits
228 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cAttrApplyBits
= m_pObjStrm
->QuickReaduInt16();
229 //CFontAttributeOverride --cAttrOverrideBits2
230 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cAttrOverrideBits2
= m_pObjStrm
->QuickReaduInt8();
231 //CFontAttributeOverride --cAttrApplyBits2
232 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cAttrApplyBits2
= m_pObjStrm
->QuickReaduInt8();
233 //CFontAttributeOverride --cCase
234 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cCase
= m_pObjStrm
->QuickReaduInt8();
235 //CFontAttributeOverride --cUnder
236 pEditorAttr
->cDelFontOver
.cFontAttributeOverride
.cUnder
= m_pObjStrm
->QuickReaduInt8();
237 m_pObjStrm
->SkipExtra();
238 //CFontDescriptionOverrideBase--cOverrideBits
239 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cOverrideBits
= m_pObjStrm
->QuickReaduInt8();
240 //CFontDescriptionOverrideBase--cApplyBits
241 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cApplyBits
= m_pObjStrm
->QuickReaduInt8();
242 //CFontDescriptionOverrideBase--cPointSize
243 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cPointSize
= m_pObjStrm
->QuickReadInt32();
244 //CFontDescriptionOverrideBase--cOverstrike
245 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cOverstrike
= m_pObjStrm
->QuickReaduInt8();
246 //CFontDescriptionOverrideBase--cTightness
247 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cTightness
= m_pObjStrm
->QuickReaduInt16();
248 //CFontDescriptionOverrideBase--cColor
249 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cColor
.Read(m_pObjStrm
);
251 //CFontDescriptionOverrideBase--cBackgroundColor
252 pEditorAttr
->cDelFontOver
.cFontDescriptionOverrideBase
.cBackgroundColor
.Read(m_pObjStrm
);
254 m_pObjStrm
->SkipExtra();
256 pEditorAttr
->cDelFontOver
.cFaceName
.Read(m_pObjStrm
);
258 pEditorAttr
->cDelFontOver
.cAltFaceName
.Read(m_pObjStrm
);
259 m_pObjStrm
->SkipExtra();
262 pEditorAttr
->nAbilities
= m_pObjStrm
->QuickReaduInt16();
264 pEditorAttr
->nLocks
= m_pObjStrm
->QuickReaduInt16();
266 pEditorAttr
->nSuggestions
= m_pObjStrm
->QuickReaduInt16();
269 //m_pEditorAttrList[i].cDelTextAttr.Read(m_pObjStrm);
270 if (m_pObjStrm
->QuickReadBool())
272 pEditorAttr
->cDelTextAttr
.cOverride
.cValues
= m_pObjStrm
->QuickReaduInt16();
273 pEditorAttr
->cDelTextAttr
.cOverride
.cOverride
= m_pObjStrm
->QuickReaduInt16();
274 pEditorAttr
->cDelTextAttr
.cOverride
.cApply
= m_pObjStrm
->QuickReaduInt16();
275 m_pObjStrm
->SkipExtra();
276 pEditorAttr
->cDelTextAttr
.cHideLevels
= m_pObjStrm
->QuickReaduInt16();
278 if (LwpFileHeader::m_nFileRevision
>= 0x000b)
280 pEditorAttr
->cDelTextAttr
.cBaselineOffset
= m_pObjStrm
->QuickReadInt32();
284 pEditorAttr
->cDelTextAttr
.cBaselineOffset
= 0;
287 m_pObjStrm
->SkipExtra();
289 m_pObjStrm
->SkipExtra();
291 pGlobal
->SetEditorAttrMap(pEditorAttr
->nID
, pEditorAttr
);
294 OUString
LwpDocData::DateTimeToOUString(LtTm
& dt
)
296 OUString aResult
= OUString::number(dt
.tm_year
) + "-" + OUString::number(dt
.tm_mon
) + "-" + OUString::number(dt
.tm_mday
) +
297 "T" + OUString::number(dt
.tm_hour
) + ":" + OUString::number(dt
.tm_min
) + ":" + OUString::number(dt
.tm_sec
) + ".0";
301 OUString
LwpDocData::TimeToOUString(LtTm
& dt
)
304 OUString aResult
= "PT" + OUString::number(dt
.tm_hour
) + "H" + OUString::number(dt
.tm_min
) + "M" + OUString::number(dt
.tm_sec
) + "S";
308 void LwpDocData::Parse(IXFStream
*pOutputStream
)
310 //<!DOCTYPE office:document-meta PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
311 //<office:document-meta xmlns:office="http://openoffice.org/2000/office" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" office:version="1.0">
312 //</office:document-meta>
314 xfMeta
.SetCreator(m_DocInfo
.createdBy
.str());
315 xfMeta
.SetDescription(m_DocInfo
.description
.str());
316 xfMeta
.SetKeywords(m_DocInfo
.keywords
.str());
317 xfMeta
.SetCreationTime(DateTimeToOUString(m_nCreationTime
));
318 xfMeta
.SetLastTime(DateTimeToOUString(m_nLastRevisionTime
));
319 xfMeta
.SetEditTime(TimeToOUString(m_nTotalEditTime
));
320 xfMeta
.ToXml(pOutputStream
);
323 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */