Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <resourcemodel/exceptions.hxx>
21 : : #include <resourcemodel/QNameToString.hxx>
22 : : #include <WW8DocumentImpl.hxx>
23 : : #include <WW8FKPImpl.hxx>
24 : : #include <WW8PieceTableImpl.hxx>
25 : : #include <WW8BinTableImpl.hxx>
26 : : #include <WW8StreamImpl.hxx>
27 : : #include <WW8Sttbf.hxx>
28 : : #include <Dff.hxx>
29 : : #include <iterator>
30 : : #include <XNoteHelperImpl.hxx>
31 : : #include <rtl/ustring.hxx>
32 : : #include <rtl/ustrbuf.hxx>
33 : : #include <doctokLoggers.hxx>
34 : :
35 : : namespace writerfilter {
36 : : namespace doctok
37 : : {
38 : :
39 : : using namespace ::std;
40 : :
41 : : template <class T>
42 : : struct PLCFHelper
43 : : {
44 : 0 : static void processPLCFCpAndFcs(WW8DocumentImpl & rDoc,
45 : : WW8PieceTable::Pointer_t pPieceTable,
46 : : typename PLCF<T>::Pointer_t pPLCF,
47 : : PropertyType eType,
48 : : sal_uInt32 nOffset)
49 : : {
50 : 0 : sal_uInt32 nCount = pPLCF->getEntryCount();
51 [ # # ][ # # ]: 0 : for (sal_uInt32 n = 0; n < nCount; ++n)
52 : : {
53 [ # # ][ # # ]: 0 : Cp aCp(pPLCF->getFc(n) + nOffset);
54 [ # # # # ]: 0 : CpAndFc aCpAndFc = pPieceTable->createCpAndFc(aCp, eType);
55 : :
56 [ # # ][ # # ]: 0 : rDoc.insertCpAndFc(aCpAndFc);
57 : : }
58 : 0 : }
59 : : };
60 : :
61 : : // WW8DocumentIteratorImpl
62 : 0 : bool operator == (const WW8DocumentIterator & rA,
63 : : const WW8DocumentIterator & rB)
64 : : {
65 : 0 : return rA.equal(rB);
66 : : }
67 : :
68 : 0 : WW8DocumentIterator::~WW8DocumentIterator()
69 : : {
70 [ # # ]: 0 : }
71 : :
72 : 0 : WW8DocumentIteratorImpl::~WW8DocumentIteratorImpl()
73 : : {
74 [ # # ]: 0 : }
75 : :
76 : 0 : WW8DocumentIterator & WW8DocumentIteratorImpl::operator++()
77 : : {
78 : 0 : mCpAndFc = mpDocument->getNextCp(mCpAndFc);
79 : :
80 : 0 : return *this;
81 : : }
82 : :
83 : 0 : WW8DocumentIterator & WW8DocumentIteratorImpl::operator--()
84 : : {
85 : 0 : mCpAndFc = mpDocument->getPrevCp(mCpAndFc);
86 : :
87 : 0 : return *this;
88 : : }
89 : :
90 : 0 : bool WW8DocumentIteratorImpl::equal(const WW8DocumentIterator & rIt_) const
91 : : {
92 : : const WW8DocumentIteratorImpl & rIt =
93 [ # # ]: 0 : dynamic_cast<const WW8DocumentIteratorImpl &>(rIt_);
94 : :
95 [ # # ][ # # ]: 0 : return mCpAndFc == rIt.mCpAndFc && mpDocument == rIt.mpDocument;
96 : : }
97 : :
98 : : writerfilter::Reference<Properties>::Pointer_t
99 : 0 : WW8DocumentIteratorImpl::getProperties() const
100 : : {
101 : 0 : return mpDocument->getProperties(mCpAndFc);
102 : : }
103 : :
104 : : writerfilter::Reference<Stream>::Pointer_t
105 : 0 : WW8DocumentIteratorImpl::getSubDocument() const
106 : : {
107 : 0 : return mpDocument->getSubDocument(mCpAndFc);
108 : : }
109 : :
110 : 0 : WW8Stream::Sequence WW8DocumentIteratorImpl::getText()
111 : : {
112 : 0 : return mpDocument->getText(mCpAndFc);
113 : : }
114 : :
115 : : writerfilter::Reference<Properties>::Pointer_t
116 : 0 : WW8DocumentIteratorImpl::getShape() const
117 : : {
118 : 0 : return mpDocument->getShape(mCpAndFc);
119 : : }
120 : :
121 : 0 : PropertyType WW8DocumentIteratorImpl::getPropertyType() const
122 : : {
123 : 0 : return mCpAndFc.getType();
124 : : }
125 : :
126 : 0 : bool WW8DocumentIteratorImpl::isComplex() const
127 : : {
128 : 0 : return mCpAndFc.isComplex();
129 : : }
130 : :
131 : 0 : void WW8DocumentIteratorImpl::dump(ostream & o) const
132 : : {
133 : 0 : o << mCpAndFc;
134 : 0 : }
135 : :
136 : 0 : string WW8DocumentIteratorImpl::toString() const
137 : : {
138 : 0 : return mCpAndFc.toString();
139 : : }
140 : :
141 : : // WW8DocumentImpl
142 : :
143 : 0 : WW8Document::~WW8Document()
144 : : {
145 [ # # ]: 0 : }
146 : :
147 : : #if OSL_DEBUG_LEVEL > 1
148 : : class WW8IdToString : public IdToString
149 : : {
150 : : public:
151 : : WW8IdToString() : IdToString() {}
152 : : virtual ~WW8IdToString() {}
153 : :
154 : : virtual string toString(const Id & rId) const
155 : : {
156 : : string s((*SprmIdToString::Instance())(rId));
157 : :
158 : : if (s.empty())
159 : : s = (*QNameToString::Instance())(rId);
160 : :
161 : : return s;
162 : : }
163 : : };
164 : : #endif
165 : :
166 [ # # ][ # # ]: 0 : WW8DocumentImpl::~WW8DocumentImpl()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
167 : : {
168 [ # # ]: 0 : }
169 : :
170 : 0 : WW8DocumentImpl::WW8DocumentImpl(WW8Stream::Pointer_t rpStream)
171 : : : bSubDocument(false), mfcPicLoc(0), mbPicIsData(false), mpStream(rpStream),
172 [ # # ][ # # ]: 0 : mbInSection(false), mbInParagraphGroup(false), mbInCharacterGroup(false)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
173 : : {
174 [ # # ][ # # ]: 0 : mpDocStream = getSubStream("WordDocument");
[ # # ]
175 : :
176 [ # # ][ # # ]: 0 : mpSummaryInformationStream = getSubStream("\5SummaryInformation");
[ # # ]
177 : :
178 : : try
179 : : {
180 [ # # ][ # # ]: 0 : mpDataStream = getSubStream("Data");
[ # # ][ # # ]
181 : : }
182 [ # # ]: 0 : catch (const ExceptionNotFound &)
183 : : {
184 : : }
185 : :
186 : : try
187 : : {
188 [ # # ][ # # ]: 0 : mpCompObjStream = getSubStream("\1CompObj");
[ # # ][ # # ]
189 : : }
190 [ # # ]: 0 : catch (const ExceptionNotFound &)
191 : : {
192 : : }
193 : :
194 : : mpCHPFKPCache =
195 [ # # ][ # # ]: 0 : WW8FKPCache::Pointer_t(new WW8CHPFKPCacheImpl(mpDocStream, 5));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
196 : : mpPAPFKPCache =
197 [ # # ][ # # ]: 0 : WW8FKPCache::Pointer_t(new WW8PAPFKPCacheImpl(mpDocStream, 5));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
198 : :
199 [ # # ][ # # ]: 0 : mpFib = WW8Fib::Pointer_t(new WW8Fib(*mpDocStream));
[ # # ][ # # ]
[ # # ]
200 : :
201 [ # # # ]: 0 : switch (mpFib->get_fWhichTblStm())
202 : : {
203 : : case 0:
204 [ # # ][ # # ]: 0 : mpTableStream = getSubStream("0Table");
[ # # ]
205 : :
206 : 0 : break;
207 : :
208 : : case 1:
209 [ # # ][ # # ]: 0 : mpTableStream = getSubStream("1Table");
[ # # ]
210 : :
211 : 0 : break;
212 : :
213 : : default:
214 : 0 : break;
215 : : }
216 : :
217 [ # # ]: 0 : if (mpFib->get_nFib() >= 0xD9)
218 : : {
219 [ # # ][ # # ]: 0 : mpFibRgFcLcb2000.reset(new WW8FibRgFcLcb2000(*mpFib));
[ # # ]
220 : : }
221 : :
222 [ # # ]: 0 : if (mpTableStream.get() == NULL)
223 [ # # ][ # # ]: 0 : throw ExceptionNotFound("Table stream not found.");
224 : :
225 : : mpPieceTable =
226 : : WW8PieceTable::Pointer_t
227 : 0 : (new WW8PieceTableImpl(*mpTableStream, mpFib->get_fcClx(),
228 [ # # ][ # # ]: 0 : mpFib->get_lcbClx()));
[ # # ][ # # ]
[ # # ]
229 : :
230 : : {
231 [ # # ]: 0 : Cp aCp(mpPieceTable->getLastCp());
232 [ # # ]: 0 : Fc aFc(mpPieceTable->getLastFc());
233 [ # # ]: 0 : CpAndFc aCpAndFc(aCp, aFc, PROP_DOC);
234 [ # # ]: 0 : mCpAndFcs.insert(aCpAndFc);
235 : : }
236 : :
237 : : {
238 : 0 : Cp aCp(mpFib->get_ccpText());
239 : :
240 : 0 : mDocumentEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
241 [ # # ][ # # ]: 0 : PROP_DOC);
242 [ # # ]: 0 : mCpAndFcs.insert(mDocumentEndCpAndFc);
243 : :
244 : 0 : aCp += mpFib->get_ccpFtn();
245 : 0 : mFootnoteEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
246 [ # # ][ # # ]: 0 : PROP_DOC);
247 [ # # ]: 0 : mCpAndFcs.insert(mFootnoteEndCpAndFc);
248 : :
249 : 0 : aCp += mpFib->get_ccpHdd();
250 : 0 : mHeaderEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
251 [ # # ][ # # ]: 0 : PROP_DOC);
252 [ # # ]: 0 : mCpAndFcs.insert(mHeaderEndCpAndFc);
253 : :
254 : 0 : aCp += mpFib->get_ccpAtn();
255 : 0 : mAnnotationEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
256 [ # # ][ # # ]: 0 : PROP_DOC);
257 [ # # ]: 0 : mCpAndFcs.insert(mAnnotationEndCpAndFc);
258 : :
259 : 0 : aCp += mpFib->get_ccpEdn();
260 : 0 : mEndnoteEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
261 [ # # ][ # # ]: 0 : PROP_DOC);
262 [ # # ]: 0 : mCpAndFcs.insert(mEndnoteEndCpAndFc);
263 : :
264 : 0 : aCp += mpFib->get_ccpTxbx();
265 : 0 : mTextboxEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
266 [ # # ][ # # ]: 0 : PROP_DOC);
267 [ # # ]: 0 : mCpAndFcs.insert(mTextboxEndCpAndFc);
268 : :
269 : 0 : aCp += mpFib->get_ccpHdrTxbx();
270 : 0 : mTextboxHeaderEndCpAndFc = CpAndFc(aCp, mpPieceTable->cp2fc(aCp),
271 [ # # ][ # # ]: 0 : PROP_DOC);
272 [ # # ]: 0 : mCpAndFcs.insert(mTextboxHeaderEndCpAndFc);
273 : : }
274 : :
275 : : mpBinTablePAPX =
276 : : WW8BinTable::Pointer_t(new WW8BinTableImpl
277 : 0 : (*mpTableStream,
278 : 0 : mpFib->get_fcPlcfbtePapx(),
279 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfbtePapx()));
[ # # ][ # # ]
[ # # ]
280 : :
281 : : //clog << "BinTable(PAP):" << mpBinTablePAPX->toString();
282 : :
283 [ # # ]: 0 : parseBinTableCpAndFcs(*mpBinTablePAPX, PROP_PAP);
284 : :
285 : : mpBinTableCHPX =
286 : : WW8BinTable::Pointer_t(new WW8BinTableImpl
287 : 0 : (*mpTableStream,
288 : 0 : mpFib->get_fcPlcfbteChpx(),
289 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfbteChpx()));
[ # # ][ # # ]
[ # # ]
290 : :
291 [ # # ]: 0 : parseBinTableCpAndFcs(*mpBinTableCHPX, PROP_CHP);
292 : :
293 : : mpSEDs = PLCF<WW8SED>::Pointer_t(new PLCF<WW8SED>
294 : 0 : (*mpTableStream,
295 : 0 : mpFib->get_fcPlcfsed(),
296 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfsed()));
[ # # ][ # # ]
[ # # ]
297 : :
298 : : {
299 : : PLCFHelper<WW8SED>::processPLCFCpAndFcs
300 [ # # ][ # # ]: 0 : (*this, mpPieceTable, mpSEDs, PROP_SEC, 0);
[ # # ][ # # ]
[ # # ]
301 : : }
302 : :
303 [ # # ]: 0 : sal_uInt32 nHeaders = getHeaderCount();
304 : :
305 [ # # ]: 0 : if (nHeaders > 0)
306 : : {
307 : : mpHeaderOffsets = WW8StructBase::Pointer_t
308 : 0 : (new WW8StructBase(*mpTableStream,
309 : 0 : mpFib->get_fcPlcfhdd(),
310 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfhdd()));
[ # # ][ # # ]
[ # # ]
311 : :
312 : : {
313 [ # # ]: 0 : for (sal_uInt32 n = 0; n <= nHeaders; ++n)
314 : : {
315 [ # # ]: 0 : CpAndFc aCpAndFc(getHeaderCpAndFc(n));
316 : :
317 [ # # ]: 0 : mCpAndFcs.insert(aCpAndFc);
318 : : }
319 : : }
320 : : }
321 : :
322 [ # # ]: 0 : if (mpFib->get_lcbPlcffndTxt() > 0)
323 : : {
324 : : WW8StructBase::Pointer_t pCps
325 : 0 : (new WW8StructBase(*mpTableStream,
326 : 0 : mpFib->get_fcPlcffndTxt(),
327 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcffndTxt()));
[ # # ]
328 : :
329 : : PLCF<WW8FRD>::Pointer_t pRefs
330 : 0 : (new PLCF<WW8FRD>(*mpTableStream,
331 : 0 : mpFib->get_fcPlcffndRef(),
332 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcffndRef()));
[ # # ]
333 : :
334 : : mpFootnoteHelper = XNoteHelper<WW8FRD>::Pointer_t
335 : : (new XNoteHelper<WW8FRD>(pCps, pRefs, mpPieceTable, this,
336 [ # # ][ # # ]: 0 : PROP_FOOTNOTE, getDocumentEndCp()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
337 : :
338 [ # # ][ # # ]: 0 : mpFootnoteHelper->init();
[ # # ]
339 : : }
340 : :
341 [ # # ]: 0 : if (mpFib->get_lcbPlcfendTxt() > 0)
342 : : {
343 : : WW8StructBase::Pointer_t pCps
344 : 0 : (new WW8StructBase(*mpTableStream,
345 : 0 : mpFib->get_fcPlcfendTxt(),
346 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfendTxt()));
[ # # ]
347 : :
348 : : PLCF<WW8FRD>::Pointer_t pRefs
349 : 0 : (new PLCF<WW8FRD>(*mpTableStream,
350 : 0 : mpFib->get_fcPlcfendRef(),
351 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfendRef()));
[ # # ]
352 : :
353 : : mpEndnoteHelper = XNoteHelper<WW8FRD>::Pointer_t
354 : : (new XNoteHelper<WW8FRD>(pCps, pRefs, mpPieceTable, this,
355 [ # # ][ # # ]: 0 : PROP_ENDNOTE, getAnnotationEndCp()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
356 : :
357 [ # # ][ # # ]: 0 : mpEndnoteHelper->init();
[ # # ]
358 : : }
359 : :
360 [ # # ]: 0 : if (mpFib->get_lcbPlcfandTxt() > 0)
361 : : {
362 : : WW8StructBase::Pointer_t pCps
363 : 0 : (new WW8StructBase(*mpTableStream,
364 : 0 : mpFib->get_fcPlcfandTxt(),
365 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfandTxt()));
[ # # ]
366 : :
367 : : PLCF<WW8ATRD>::Pointer_t pRefs
368 : 0 : (new PLCF<WW8ATRD>(*mpTableStream,
369 : 0 : mpFib->get_fcPlcfandRef(),
370 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfandRef()));
[ # # ]
371 : :
372 : : mpAnnotationHelper = XNoteHelper<WW8ATRD>::Pointer_t
373 : : (new XNoteHelper<WW8ATRD>(pCps, pRefs, mpPieceTable, this,
374 [ # # ][ # # ]: 0 : PROP_ANNOTATION, getHeaderEndCp()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
375 : :
376 [ # # ][ # # ]: 0 : mpAnnotationHelper->init();
[ # # ]
377 : : }
378 : :
379 [ # # ]: 0 : if (mpFib->get_lcbSttbfbkmk() > 0)
380 : : {
381 : : PLCF<WW8BKF>::Pointer_t pStartCps
382 : 0 : (new PLCF<WW8BKF>(*mpTableStream, mpFib->get_fcPlcfbkf(),
383 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfbkf()));
[ # # ]
384 : :
385 : : WW8StructBase::Pointer_t pEndCps
386 : 0 : (new WW8StructBase(*mpTableStream, mpFib->get_fcPlcfbkl(),
387 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcfbkl()));
[ # # ]
388 : :
389 : : WW8Sttbf::Pointer_t pNames
390 : 0 : (new WW8Sttbf(*mpTableStream, mpFib->get_fcSttbfbkmk(),
391 [ # # ][ # # ]: 0 : mpFib->get_lcbSttbfbkmk()));
[ # # ]
392 : :
393 : : mpBookmarkHelper = BookmarkHelper::Pointer_t
394 [ # # ][ # # ]: 0 : (new BookmarkHelper(pStartCps, pEndCps, pNames, mpPieceTable, this));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
395 : :
396 [ # # ][ # # ]: 0 : mpBookmarkHelper->init();
[ # # ][ # # ]
397 : : }
398 : :
399 : : {
400 [ # # ]: 0 : PLCF<WW8FLD>::Pointer_t pPlcffldMom;
401 : :
402 [ # # ]: 0 : if (mpFib->get_lcbPlcffldMom() > 0)
403 : : {
404 : : pPlcffldMom = PLCF<WW8FLD>::Pointer_t
405 : 0 : (new PLCF<WW8FLD>(*mpTableStream,
406 : 0 : mpFib->get_fcPlcffldMom(),
407 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcffldMom()));
[ # # ][ # # ]
[ # # ]
408 : :
409 : : mpFieldHelper = FieldHelper::Pointer_t
410 : : (new FieldHelper(pPlcffldMom,
411 [ # # ][ # # ]: 0 : this));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
412 : :
413 [ # # ]: 0 : mpFieldHelper->init();
414 [ # # ]: 0 : }
415 : : }
416 : :
417 [ # # ]: 0 : PLCF<WW8FSPA>::Pointer_t pPlcspaMom;
418 [ # # ]: 0 : if (mpFib->get_lcbPlcspaMom() > 0)
419 : : {
420 : : pPlcspaMom = PLCF<WW8FSPA>::Pointer_t
421 : : (new PLCF<WW8FSPA>
422 : 0 : (*mpTableStream, mpFib->get_fcPlcspaMom(),
423 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcspaMom()));
[ # # ][ # # ]
[ # # ]
424 : : }
425 : :
426 [ # # ]: 0 : PLCF<WW8FSPA>::Pointer_t pPlcspaHdr;
427 [ # # ]: 0 : if (mpFib->get_lcbPlcspaHdr() > 0)
428 : : {
429 : : pPlcspaHdr = PLCF<WW8FSPA>::Pointer_t
430 : : (new PLCF<WW8FSPA>
431 : 0 : (*mpTableStream, mpFib->get_fcPlcspaHdr(),
432 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcspaHdr()));
[ # # ][ # # ]
[ # # ]
433 : : }
434 : :
435 : : mpShapeHelper = ShapeHelper::Pointer_t
436 [ # # ][ # # ]: 0 : (new ShapeHelper(pPlcspaMom, pPlcspaHdr, this));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
437 : :
438 [ # # ]: 0 : mpShapeHelper->init();
439 : :
440 [ # # ]: 0 : PLCF<WW8BKD>::Pointer_t pPlcbkdMother;
441 [ # # ][ # # ]: 0 : if (mpFib->get_fcBkdMother() > 0 && mpFib->get_lcbBkdMother() > 0)
[ # # ]
442 : : {
443 : : pPlcbkdMother = PLCF<WW8BKD>::Pointer_t
444 : : (new PLCF<WW8BKD>
445 : 0 : (*mpTableStream, mpFib->get_fcBkdMother(),
446 [ # # ][ # # ]: 0 : mpFib->get_lcbBkdMother()));
[ # # ][ # # ]
[ # # ]
447 : : }
448 : :
449 : : mpBreakHelper = BreakHelper::Pointer_t
450 [ # # ][ # # ]: 0 : (new BreakHelper(pPlcbkdMother, this));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
451 : :
452 [ # # ]: 0 : mpBreakHelper->init();
453 : :
454 [ # # ][ # # ]: 0 : if (mpFib->get_fcDggInfo() != 0 && mpFib->get_lcbDggInfo() > 0)
[ # # ]
455 : : {
456 : : mpDffBlock = DffBlock::Pointer_t
457 : 0 : (new DffBlock(*mpTableStream, mpFib->get_fcDggInfo(),
458 [ # # ][ # # ]: 0 : mpFib->get_lcbDggInfo(), 1));
[ # # ][ # # ]
[ # # ]
459 : :
460 [ # # ]: 0 : mpDffBlock->setDocument(this);
461 : : }
462 : :
463 [ # # ]: 0 : if (mpFib->get_lcbPlcftxbxTxt() > 0)
464 : : {
465 : : mpTextBoxStories = PLCF<WW8FTXBXS>::Pointer_t
466 : 0 : (new PLCF<WW8FTXBXS>(*mpTableStream,
467 : 0 : mpFib->get_fcPlcftxbxTxt(),
468 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcftxbxTxt()));
[ # # ][ # # ]
[ # # ]
469 : :
470 : : PLCFHelper<WW8FTXBXS>::processPLCFCpAndFcs
471 : : (*this, mpPieceTable, mpTextBoxStories, PROP_DOC,
472 [ # # ][ # # ]: 0 : mEndnoteEndCpAndFc.getCp().get());
[ # # ][ # # ]
[ # # ]
473 : : }
474 : :
475 [ # # ]: 0 : if (mCpAndFcs.size() > 0)
476 : : {
477 : 0 : mCpAndFcStart = *mCpAndFcs.begin();
478 : 0 : mCpAndFcEnd = getDocumentEndCp();
479 [ # # ][ # # ]: 0 : }
[ # # ]
480 : 0 : }
481 : :
482 : 0 : bool WW8DocumentImpl::isSpecial(sal_uInt32 nChar)
483 : : {
484 : 0 : bool bResult = false;
485 : :
486 [ # # ]: 0 : if (nChar <= 8)
487 : 0 : bResult = true;
488 [ # # ]: 0 : else if (nChar >= 10)
489 : : {
490 [ # # ]: 0 : if (nChar == 12)
491 : 0 : bResult= true;
492 [ # # ]: 0 : else if (nChar <= 16)
493 : 0 : bResult = true;
494 [ # # ]: 0 : else if (nChar >= 22)
495 : : {
496 [ # # ]: 0 : if (nChar <= 30)
497 : 0 : bResult = true;
498 [ # # ]: 0 : else if (nChar >= 33)
499 : : {
500 [ # # ]: 0 : if (nChar <= 39)
501 : 0 : bResult = true;
502 [ # # ]: 0 : else if (nChar == 41)
503 : 0 : bResult = true;
504 : : }
505 : : }
506 : : }
507 : :
508 : 0 : return bResult;
509 : : }
510 : :
511 : 0 : WW8DocumentImpl::WW8DocumentImpl(const WW8DocumentImpl & rSrc,
512 : : const CpAndFc & rStart, const CpAndFc & rEnd)
513 [ # # ][ # # ]: 0 : : bSubDocument(true), mfcPicLoc(0), mbPicIsData(false)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
514 : : {
515 [ # # ]: 0 : Assign(rSrc);
516 : :
517 : 0 : mCpAndFcStart = rStart;
518 : 0 : mCpAndFcEnd = rEnd;
519 : 0 : }
520 : :
521 : 0 : WW8DocumentImpl & WW8DocumentImpl::Assign(const WW8DocumentImpl & rSrc)
522 : : {
523 : 0 : mCpAndFcs = rSrc.mCpAndFcs;
524 : :
525 : 0 : mpCHPFKPCache = rSrc.mpCHPFKPCache;
526 : 0 : mpPAPFKPCache = rSrc.mpPAPFKPCache;
527 : :
528 : 0 : mpStream = rSrc.mpStream;
529 : 0 : mpTableStream = rSrc.mpTableStream;
530 : 0 : mpDataStream = rSrc.mpDataStream;
531 : 0 : mpDocStream = rSrc.mpDocStream;
532 : 0 : mpCompObjStream = rSrc.mpCompObjStream;
533 : :
534 : 0 : mpPieceTable = rSrc.mpPieceTable;
535 : :
536 : 0 : mpBinTableCHPX = rSrc.mpBinTableCHPX;
537 : 0 : mpBinTablePAPX = rSrc.mpBinTablePAPX;
538 : :
539 : 0 : mpSEDs = rSrc.mpSEDs;
540 : :
541 : 0 : mpFib = rSrc.mpFib;
542 : :
543 : 0 : mpHeaderOffsets = rSrc.mpHeaderOffsets;
544 : 0 : mpFootnoteHelper = rSrc.mpFootnoteHelper;
545 : 0 : mpEndnoteHelper = rSrc.mpEndnoteHelper;
546 : 0 : mpAnnotationHelper = rSrc.mpAnnotationHelper;
547 : 0 : mpShapeHelper = rSrc.mpShapeHelper;
548 : 0 : mpBreakHelper = rSrc.mpBreakHelper;
549 : :
550 : 0 : mpBookmarkHelper = rSrc.mpBookmarkHelper;
551 : :
552 : 0 : mpDffBlock = rSrc.mpDffBlock;
553 : 0 : mpTextBoxStories = rSrc.mpTextBoxStories;
554 : :
555 : 0 : mDocumentEndCpAndFc = rSrc.mDocumentEndCpAndFc;
556 : 0 : mFootnoteEndCpAndFc = rSrc.mFootnoteEndCpAndFc;
557 : :
558 : 0 : return *this;
559 : : }
560 : :
561 : 0 : string WW8DocumentImpl::getType() const
562 : : {
563 [ # # ]: 0 : return "WW8DocumentImpl";
564 : : }
565 : :
566 : 0 : void WW8DocumentImpl::parseBinTableCpAndFcs(WW8BinTable & rTable,
567 : : PropertyType eType_)
568 : : {
569 [ # # ]: 0 : for (sal_uInt32 i = 0; i < rTable.getEntryCount(); i++)
570 : : {
571 [ # # ]: 0 : Fc aFcFromTable(rTable.getFc(i));
572 : :
573 [ # # ][ # # ]: 0 : if (aFcFromTable < mpPieceTable->getFirstFc())
[ # # ]
574 [ # # ]: 0 : aFcFromTable = mpPieceTable->getFirstFc();
575 : :
576 [ # # ]: 0 : bool bComplex = mpPieceTable->isComplex(aFcFromTable);
577 : 0 : aFcFromTable.setComplex(bComplex);
578 : :
579 : : try
580 : : {
581 [ # # ]: 0 : Cp aCpFromTable(mpPieceTable->fc2cp(aFcFromTable));
582 [ # # ]: 0 : CpAndFc aCpAndFcFromTable(aCpFromTable, aFcFromTable, eType_);
583 : :
584 [ # # ]: 0 : mCpAndFcs.insert(aCpAndFcFromTable);
585 : :
586 [ # # ]: 0 : WW8FKP::Pointer_t pFKP;
587 : :
588 [ # # # ]: 0 : switch (eType_)
589 : : {
590 : : case PROP_CHP:
591 : 0 : pFKP = getFKPCHPX(rTable.getPageNumber(i),
592 [ # # ][ # # ]: 0 : aCpAndFcFromTable.isComplex());
[ # # ][ # # ]
593 : :
594 : 0 : break;
595 : :
596 : : case PROP_PAP:
597 : 0 : pFKP = getFKPPAPX(rTable.getPageNumber(i),
598 [ # # ][ # # ]: 0 : aCpAndFcFromTable.isComplex());
[ # # ][ # # ]
599 : :
600 : 0 : break;
601 : : default:
602 : 0 : break;
603 : : }
604 : :
605 [ # # ][ # # ]: 0 : for (sal_uInt32 n = 0; n < pFKP->getEntryCount(); n++)
606 : : {
607 [ # # ]: 0 : Fc aFc = pFKP->getFc(n);
608 : :
609 [ # # ][ # # ]: 0 : if (aFc < mpPieceTable->getFirstFc())
[ # # ]
610 [ # # ]: 0 : aFc = mpPieceTable->getFirstFc();
611 : :
612 [ # # ]: 0 : bool bComplexFKP = mpPieceTable->isComplex(aFc);
613 : 0 : aFc.setComplex(bComplexFKP);
614 : :
615 : : try
616 : : {
617 [ # # ]: 0 : Cp aCp = mpPieceTable->fc2cp(aFc);
618 : :
619 [ # # ]: 0 : CpAndFc aCpAndFc(aCp, aFc, eType_);
620 : :
621 [ # # ]: 0 : mCpAndFcs.insert(aCpAndFc);
622 : : }
623 [ # # # # ]: 0 : catch (const ExceptionNotFound &e)
624 : : {
625 [ # # # # ]: 0 : clog << e.getText() << endl;
626 : : }
627 [ # # ]: 0 : }
628 : : }
629 [ # # # # ]: 0 : catch (const ExceptionNotFound &e)
630 : : {
631 [ # # # # ]: 0 : clog << e.getText() << endl;
632 : : }
633 : : }
634 : 0 : }
635 : :
636 : 0 : WW8Stream::Pointer_t WW8DocumentImpl::getSubStream
637 : : (const OUString & sId) const
638 : : {
639 : 0 : return mpStream->getSubStream(sId);
640 : : }
641 : :
642 : 0 : WW8Document::Pointer_t WW8DocumentImpl::getSubDocument(SubDocumentId /*nId*/)
643 : : {
644 [ # # ]: 0 : return WW8Document::Pointer_t(new WW8DocumentImpl(*this));
645 : : }
646 : :
647 : : WW8DocumentIterator::Pointer_t
648 : 0 : WW8DocumentImpl::getIterator(const CpAndFc & rCpAndFc)
649 : : {
650 : : return WW8DocumentIterator::Pointer_t
651 [ # # ]: 0 : (new WW8DocumentIteratorImpl(this, rCpAndFc));
652 : : }
653 : :
654 : 0 : WW8DocumentIterator::Pointer_t WW8DocumentImpl::begin()
655 : : {
656 : 0 : return getIterator(getFirstCp());
657 : : }
658 : :
659 : 0 : WW8DocumentIterator::Pointer_t WW8DocumentImpl::end()
660 : : {
661 : 0 : return getIterator(getLastCp());
662 : : }
663 : :
664 : 0 : WW8Stream::Pointer_t WW8DocumentImpl::getDocStream() const
665 : : {
666 : 0 : return mpDocStream;
667 : : }
668 : :
669 : 0 : WW8Stream::Pointer_t WW8DocumentImpl::getDataStream() const
670 : : {
671 : 0 : return mpDataStream;
672 : : }
673 : :
674 : 0 : sal_uInt32 WW8DocumentImpl::getByteLength(const CpAndFc & rCpAndFc) const
675 : : {
676 [ # # ]: 0 : CpAndFc aEnd = getNextCp(rCpAndFc);
677 : :
678 : 0 : sal_uInt32 nResult = 3;
679 : :
680 [ # # ][ # # ]: 0 : if (rCpAndFc < aEnd)
681 : 0 : nResult = (aEnd - rCpAndFc) *
682 [ # # ][ # # ]: 0 : (mpPieceTable->isComplex(rCpAndFc.getCp()) ? 1 : 2);
683 : :
684 : 0 : return nResult;
685 : : }
686 : :
687 : : WW8Stream::Sequence
688 : 0 : WW8DocumentImpl::getText(const CpAndFc & rStart)
689 : : {
690 : 0 : return mpDocStream->get(rStart.getFc().get(), getByteLength(rStart));
691 : : }
692 : :
693 : 0 : const CpAndFc & WW8DocumentImpl::getFirstCp() const
694 : : {
695 : 0 : return mCpAndFcStart;
696 : : }
697 : :
698 : 0 : const CpAndFc & WW8DocumentImpl::getLastCp() const
699 : : {
700 : 0 : return mCpAndFcEnd;
701 : : }
702 : :
703 : 0 : CpAndFc WW8DocumentImpl::getDocumentEndCp() const
704 : : {
705 : 0 : return mDocumentEndCpAndFc;
706 : : }
707 : :
708 : 0 : CpAndFc WW8DocumentImpl::getFootnodeEndCp() const
709 : : {
710 : 0 : return mFootnoteEndCpAndFc;
711 : : }
712 : :
713 : 0 : CpAndFc WW8DocumentImpl::getHeaderEndCp() const
714 : : {
715 : 0 : return mHeaderEndCpAndFc;
716 : : }
717 : :
718 : 0 : CpAndFc WW8DocumentImpl::getAnnotationEndCp() const
719 : : {
720 : 0 : return mAnnotationEndCpAndFc;
721 : : }
722 : :
723 : 0 : CpAndFc WW8DocumentImpl::getEndnoteEndCp() const
724 : : {
725 : 0 : return mEndnoteEndCpAndFc;
726 : : }
727 : :
728 : 0 : CpAndFc WW8DocumentImpl::getNextCp(const CpAndFc & rCpAndFc) const
729 : : {
730 : 0 : CpAndFc aResult = mCpAndFcEnd;
731 [ # # ]: 0 : CpAndFcs::const_iterator aIt = mCpAndFcs.find(rCpAndFc);
732 : :
733 [ # # ]: 0 : if (aIt != mCpAndFcs.end())
734 : : {
735 : 0 : ++aIt;
736 : :
737 [ # # ]: 0 : if (aIt != mCpAndFcs.end())
738 : 0 : aResult = *aIt;
739 : : }
740 : : else
741 [ # # ][ # # ]: 0 : throw ExceptionNotFound("getNextCp: " + rCpAndFc.toString());
[ # # ]
742 : :
743 : 0 : return aResult;
744 : : }
745 : :
746 : 0 : CpAndFc WW8DocumentImpl::getPrevCp(const CpAndFc & rCpAndFc) const
747 : : {
748 : 0 : CpAndFc aResult = mCpAndFcStart;
749 : :
750 [ # # ]: 0 : CpAndFcs::const_iterator aIt = mCpAndFcs.find(CpAndFc(rCpAndFc));
751 : :
752 [ # # ][ # # ]: 0 : if (aIt != mCpAndFcs.end() && aIt != mCpAndFcs.begin())
[ # # ][ # # ]
[ # # ]
753 : : {
754 : 0 : --aIt;
755 : :
756 : 0 : aResult = *aIt;
757 : : }
758 : : else
759 [ # # ][ # # ]: 0 : throw ExceptionNotFound("getPrevCp: " + rCpAndFc.toString());
[ # # ]
760 : :
761 : 0 : return aResult;
762 : : }
763 : :
764 : 0 : WW8FKP::Pointer_t WW8DocumentImpl::getFKP(const CpAndFc & rCpAndFc)
765 : : {
766 : 0 : WW8FKP::Pointer_t pResult;
767 : :
768 : 0 : sal_uInt32 nPageNumber = 0;
769 : :
770 [ # # # ]: 0 : switch (rCpAndFc.getType())
771 : : {
772 : : case PROP_PAP:
773 : : {
774 : : nPageNumber =
775 [ # # ]: 0 : mpBinTablePAPX->getPageNumber(rCpAndFc.getFc());
776 : :
777 [ # # ][ # # ]: 0 : pResult = getFKPPAPX(nPageNumber, rCpAndFc.isComplex());
[ # # ]
778 : : }
779 : 0 : break;
780 : : case PROP_CHP:
781 : : {
782 : : nPageNumber =
783 [ # # ]: 0 : mpBinTableCHPX->getPageNumber(rCpAndFc.getFc());
784 : :
785 [ # # ][ # # ]: 0 : pResult = getFKPCHPX(nPageNumber, rCpAndFc.isComplex());
[ # # ]
786 : : }
787 : 0 : break;
788 : : default:
789 : 0 : break;
790 : : }
791 : :
792 [ # # ]: 0 : if (pResult.get() != NULL)
793 [ # # ]: 0 : pResult->setDocument(this);
794 : :
795 : 0 : return pResult;
796 : : }
797 : :
798 : 0 : WW8FKP::Pointer_t WW8DocumentImpl::getFKPCHPX(sal_uInt32 nIndex,
799 : : bool bComplex)
800 : : {
801 : 0 : return mpCHPFKPCache->get(nIndex, bComplex);
802 : : }
803 : :
804 : 0 : WW8FKP::Pointer_t WW8DocumentImpl::getFKPPAPX(sal_uInt32 nIndex,
805 : : bool bComplex)
806 : : {
807 : 0 : return mpPAPFKPCache->get(nIndex, bComplex);
808 : : }
809 : :
810 : 0 : writerfilter::Reference<Properties>::Pointer_t WW8DocumentImpl::getProperties
811 : : (const CpAndFc & rCpAndFc)
812 : : {
813 : 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
814 : :
815 [ # # # # : 0 : switch (rCpAndFc.getType())
# # # # #
# ]
816 : : {
817 : : case PROP_CHP:
818 : : case PROP_PAP:
819 : : {
820 : : try
821 : : {
822 [ # # ]: 0 : WW8FKP::Pointer_t pFKP = getFKP(rCpAndFc);
823 : :
824 [ # # ][ # # ]: 0 : pResult = pFKP->getProperties(rCpAndFc.getFc());
[ # # ][ # # ]
[ # # ]
825 : : }
826 [ # # ]: 0 : catch (const ExceptionOutOfBounds &)
827 : : {
828 : : }
829 : : }
830 : :
831 : 0 : break;
832 : :
833 : : case PROP_SEC:
834 : : {
835 : : pResult = writerfilter::Reference<Properties>::Pointer_t
836 [ # # ][ # # ]: 0 : (getSED(rCpAndFc));
[ # # ][ # # ]
837 : : }
838 : :
839 : 0 : break;
840 : :
841 : : case PROP_FOOTNOTE:
842 : : {
843 : : pResult = writerfilter::Reference<Properties>::Pointer_t
844 [ # # ][ # # ]: 0 : (mpFootnoteHelper->getRef(rCpAndFc));
[ # # ][ # # ]
845 : : }
846 : 0 : break;
847 : :
848 : : case PROP_ENDNOTE:
849 : : {
850 : : pResult = writerfilter::Reference<Properties>::Pointer_t
851 [ # # ][ # # ]: 0 : (mpEndnoteHelper->getRef(rCpAndFc));
[ # # ][ # # ]
852 : : }
853 : 0 : break;
854 : :
855 : : case PROP_ANNOTATION:
856 : : {
857 : : pResult = writerfilter::Reference<Properties>::Pointer_t
858 [ # # ][ # # ]: 0 : (mpAnnotationHelper->getRef(rCpAndFc));
[ # # ][ # # ]
859 : : }
860 : 0 : break;
861 : :
862 : : case PROP_BOOKMARKSTART:
863 : : case PROP_BOOKMARKEND:
864 : : {
865 [ # # ][ # # ]: 0 : pResult = getBookmark(rCpAndFc);
[ # # ]
866 : : }
867 : :
868 : 0 : break;
869 : : case PROP_FLD:
870 : : {
871 [ # # ][ # # ]: 0 : pResult = getField(rCpAndFc);
[ # # ]
872 : :
873 [ # # ][ # # ]: 0 : mpFLD = mpFieldHelper->getWW8FLD(rCpAndFc);
[ # # ]
874 : : }
875 : :
876 : 0 : break;
877 : : case PROP_SHP:
878 : : {
879 [ # # ][ # # ]: 0 : pResult = getShape(rCpAndFc);
[ # # ]
880 : : }
881 : 0 : break;
882 : : case PROP_BRK:
883 : : {
884 [ # # ][ # # ]: 0 : pResult = getBreak(rCpAndFc);
[ # # ]
885 : : }
886 : 0 : break;
887 : : default:
888 : 0 : break;
889 : : }
890 : :
891 : 0 : return pResult;
892 : : }
893 : :
894 : : writerfilter::Reference<Stream>::Pointer_t
895 : 0 : WW8DocumentImpl::getSubDocument(const CpAndFc & rCpAndFc)
896 : : {
897 : 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
898 : :
899 [ # # # # ]: 0 : switch (rCpAndFc.getType())
900 : : {
901 : : case PROP_FOOTNOTE:
902 [ # # ][ # # ]: 0 : pResult = getFootnote(rCpAndFc);
[ # # ]
903 : 0 : break;
904 : :
905 : : case PROP_ENDNOTE:
906 [ # # ][ # # ]: 0 : pResult = getEndnote(rCpAndFc);
[ # # ]
907 : 0 : break;
908 : :
909 : : case PROP_ANNOTATION:
910 [ # # ][ # # ]: 0 : pResult = getAnnotation(rCpAndFc);
[ # # ]
911 : 0 : break;
912 : :
913 : : default:
914 : 0 : break;
915 : : }
916 : :
917 : 0 : return pResult;
918 : : }
919 : :
920 : 0 : WW8SED * WW8DocumentImpl::getSED(const CpAndFc & rCpAndFc) const
921 : : {
922 : 0 : WW8SED * pResult = mpSEDs->getEntryByFc(rCpAndFc.getCp().get());
923 : :
924 : 0 : pResult->setDoc(const_cast<const WW8DocumentImpl *>(this));
925 : :
926 : 0 : return pResult;
927 : : }
928 : :
929 : 0 : writerfilter::Reference<Table>::Pointer_t WW8DocumentImpl::getListTplcs() const
930 : : {
931 : 0 : writerfilter::Reference<Table>::Pointer_t pResult;
932 : :
933 [ # # ][ # # ]: 0 : if (mpFibRgFcLcb2000.get() != NULL &&
[ # # ][ # # ]
934 [ # # ]: 0 : mpFibRgFcLcb2000->get_fcSttbRgtplc() != 0 &&
935 [ # # ]: 0 : mpFibRgFcLcb2000->get_lcbSttbRgtplc() != 0)
936 : : {
937 : : WW8SttbRgtplc * pSttbRgtplc =
938 : 0 : new WW8SttbRgtplc(*mpTableStream,
939 : 0 : mpFibRgFcLcb2000->get_fcSttbRgtplc(),
940 [ # # ][ # # ]: 0 : mpFibRgFcLcb2000->get_lcbSttbRgtplc());
[ # # ][ # # ]
941 : :
942 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Table>::Pointer_t(pSttbRgtplc);
[ # # ]
943 : : }
944 : :
945 : 0 : return pResult;
946 : : }
947 : :
948 : 0 : writerfilter::Reference<Table>::Pointer_t WW8DocumentImpl::getListTable() const
949 : : {
950 : 0 : writerfilter::Reference<Table>::Pointer_t pResult;
951 : :
952 [ # # ][ # # ]: 0 : if (mpFib->get_fcPlcfLst() != 0 && mpFib->get_lcbPlcfLst() > 0)
[ # # ]
953 : : {
954 : : try
955 : : {
956 : 0 : WW8ListTable * pList = new WW8ListTable(*mpTableStream,
957 : 0 : mpFib->get_fcPlcfLst(),
958 : 0 : mpFib->get_fcPlfLfo() -
959 [ # # ][ # # ]: 0 : mpFib->get_fcPlcfLst());
960 : :
961 : 0 : pList->setPayloadOffset(mpFib->get_lcbPlcfLst());
962 [ # # ]: 0 : pList->initPayload();
963 : :
964 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Table>::Pointer_t(pList);
[ # # ][ # # ]
965 : : }
966 [ # # ]: 0 : catch (const ExceptionOutOfBounds &) {
967 : : }
968 : : }
969 : :
970 : 0 : return pResult;
971 : : }
972 : :
973 : 0 : writerfilter::Reference<Table>::Pointer_t WW8DocumentImpl::getLFOTable() const
974 : : {
975 : 0 : writerfilter::Reference<Table>::Pointer_t pResult;
976 : :
977 [ # # ][ # # ]: 0 : if (mpFib->get_fcPlfLfo() != 0 && mpFib->get_lcbPlfLfo() > 0)
[ # # ]
978 : : {
979 : : try
980 : : {
981 : 0 : WW8LFOTable * pLFOs = new WW8LFOTable(*mpTableStream,
982 : 0 : mpFib->get_fcPlfLfo(),
983 [ # # ][ # # ]: 0 : mpFib->get_lcbPlfLfo());
984 : :
985 : 0 : pLFOs->setPayloadOffset(mpFib->get_lcbPlcfLst());
986 [ # # ]: 0 : pLFOs->initPayload();
987 : :
988 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Table>::Pointer_t(pLFOs);
[ # # ]
989 : : }
990 [ # # # # ]: 0 : catch (const Exception &e)
991 : : {
992 [ # # # # ]: 0 : clog << e.getText() << endl;
993 : : }
994 : : }
995 : :
996 : 0 : return pResult;
997 : : }
998 : :
999 : 0 : writerfilter::Reference<Table>::Pointer_t WW8DocumentImpl::getFontTable() const
1000 : : {
1001 : 0 : writerfilter::Reference<Table>::Pointer_t pResult;
1002 : :
1003 [ # # ][ # # ]: 0 : if (mpFib->get_fcSttbfffn() != 0 && mpFib->get_lcbSttbfffn() > 0)
[ # # ]
1004 : : {
1005 : 0 : WW8FontTable * pFonts = new WW8FontTable(*mpTableStream,
1006 : 0 : mpFib->get_fcSttbfffn(),
1007 [ # # ][ # # ]: 0 : mpFib->get_lcbSttbfffn());
1008 : :
1009 [ # # ]: 0 : pFonts->initPayload();
1010 : :
1011 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Table>::Pointer_t(pFonts);
[ # # ]
1012 : : }
1013 : :
1014 : 0 : return pResult;
1015 : : }
1016 : :
1017 : 0 : writerfilter::Reference<Table>::Pointer_t WW8DocumentImpl::getStyleSheet() const
1018 : : {
1019 : 0 : writerfilter::Reference<Table>::Pointer_t pResult;
1020 : :
1021 [ # # ]: 0 : if (mpFib->get_lcbStshf() > 0)
1022 : : {
1023 : 0 : WW8StyleSheet * pStyles = new WW8StyleSheet(*mpTableStream,
1024 : 0 : mpFib->get_fcStshf(),
1025 [ # # ][ # # ]: 0 : mpFib->get_lcbStshf());
1026 : :
1027 [ # # ]: 0 : pStyles->initPayload();
1028 : :
1029 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Table>::Pointer_t(pStyles);
[ # # ]
1030 : : }
1031 : :
1032 : 0 : return pResult;
1033 : : }
1034 : :
1035 : 0 : writerfilter::Reference<Table>::Pointer_t WW8DocumentImpl::getAssocTable() const
1036 : : {
1037 : 0 : writerfilter::Reference<Table>::Pointer_t pResult;
1038 : :
1039 [ # # ]: 0 : if (mpFib->get_lcbSttbfAssoc() > 0)
1040 : : {
1041 : : WW8Sttbf::Pointer_t pSttbfAssoc
1042 : 0 : (new WW8Sttbf(*mpTableStream,
1043 : 0 : mpFib->get_fcSttbfAssoc(),
1044 [ # # ][ # # ]: 0 : mpFib->get_lcbSttbfAssoc()));
[ # # ]
1045 : :
1046 : : pResult = writerfilter::Reference<Table>::Pointer_t
1047 [ # # ][ # # ]: 0 : (new WW8SttbTableResource(pSttbfAssoc));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1048 : : }
1049 : :
1050 : 0 : return pResult;
1051 : : }
1052 : :
1053 : 0 : sal_uInt32 WW8DocumentImpl::getHeaderCount() const
1054 : : {
1055 : 0 : sal_uInt32 nResult = 0;
1056 : 0 : sal_uInt32 nLcbPlcfhdd = mpFib->get_lcbPlcfhdd();
1057 : :
1058 [ # # ]: 0 : if (nLcbPlcfhdd > 4)
1059 : 0 : nResult = (nLcbPlcfhdd / 4) - 1;
1060 : :
1061 : 0 : return nResult;
1062 : : }
1063 : :
1064 : 0 : CpAndFc WW8DocumentImpl::getHeaderCpAndFc(sal_uInt32 nPos)
1065 : : {
1066 : 0 : sal_uInt32 nCount = getHeaderCount();
1067 : :
1068 : : // There are getHeaderCount() + 1 entries in mpHeaderOffsets => greater
1069 [ # # ]: 0 : if (nPos > nCount)
1070 [ # # ][ # # ]: 0 : throw ExceptionNotFound("getHeaderCpAndFc");
1071 : :
1072 [ # # ]: 0 : if (nPos == nCount)
1073 : 0 : return mHeaderEndCpAndFc;
1074 : : else
1075 : : {
1076 [ # # ]: 0 : Cp aCp(getFootnodeEndCp().getCp() + mpHeaderOffsets->getU32(nPos * 4));
1077 [ # # ]: 0 : Fc aFc(mpPieceTable->cp2fc(aCp));
1078 [ # # ]: 0 : CpAndFc aCpAndFc(aCp, aFc, PROP_DOC);
1079 : :
1080 : 0 : return aCpAndFc;
1081 : : }
1082 : :
1083 : : }
1084 : :
1085 : 0 : writerfilter::Reference<Stream>::Pointer_t WW8DocumentImpl::getHeader(sal_uInt32 nPos)
1086 : : {
1087 : : // There are getHeaderCount() headers => greater or equal
1088 [ # # ][ # # ]: 0 : if (nPos >= getHeaderCount())
1089 [ # # ][ # # ]: 0 : throw ExceptionNotFound("getHeader");
1090 : :
1091 [ # # ]: 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
1092 : :
1093 [ # # ]: 0 : CpAndFc aCpAndFcStart(getHeaderCpAndFc(nPos));
1094 [ # # ]: 0 : CpAndFc aCpAndFcEnd(getHeaderCpAndFc(nPos + 1));
1095 : :
1096 [ # # ][ # # ]: 0 : if (aCpAndFcStart < aCpAndFcEnd)
1097 : : pResult = writerfilter::Reference<Stream>::Pointer_t
1098 [ # # ][ # # ]: 0 : (new WW8DocumentImpl(*this, aCpAndFcStart, aCpAndFcEnd));
[ # # ][ # # ]
[ # # ]
1099 : :
1100 : 0 : return pResult;
1101 : : }
1102 : :
1103 : : writerfilter::Reference<Stream>::Pointer_t
1104 : 0 : WW8DocumentImpl::getFootnote(const CpAndFc & rCpAndFc)
1105 : : {
1106 : 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
1107 : :
1108 [ # # ]: 0 : if (! bSubDocument)
1109 [ # # ][ # # ]: 0 : pResult = mpFootnoteHelper->get(rCpAndFc);
[ # # ]
1110 : :
1111 : 0 : return pResult;
1112 : : }
1113 : :
1114 : : writerfilter::Reference<Stream>::Pointer_t
1115 : 0 : WW8DocumentImpl::getEndnote(const CpAndFc & rCpAndFc)
1116 : : {
1117 : 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
1118 : :
1119 [ # # ]: 0 : if (! bSubDocument)
1120 [ # # ][ # # ]: 0 : pResult = mpEndnoteHelper->get(rCpAndFc);
[ # # ]
1121 : :
1122 : 0 : return pResult;
1123 : : }
1124 : :
1125 : :
1126 : : writerfilter::Reference<Stream>::Pointer_t
1127 : 0 : WW8DocumentImpl::getAnnotation(const CpAndFc & rCpAndFc)
1128 : : {
1129 : 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
1130 : :
1131 [ # # ]: 0 : if (! bSubDocument)
1132 [ # # ][ # # ]: 0 : pResult = mpAnnotationHelper->get(rCpAndFc);
[ # # ]
1133 : :
1134 : 0 : return pResult;
1135 : : }
1136 : :
1137 : : writerfilter::Reference<Properties>::Pointer_t
1138 : 0 : WW8DocumentImpl::getBookmark(const CpAndFc & rCpAndFc) const
1139 : : {
1140 : 0 : return mpBookmarkHelper->getBookmark(rCpAndFc);
1141 : : }
1142 : :
1143 : : writerfilter::Reference<Properties>::Pointer_t
1144 : 0 : WW8DocumentImpl::getShape(const CpAndFc & rCpAndFc) const
1145 : : {
1146 : 0 : return mpShapeHelper->getShape(rCpAndFc);
1147 : : }
1148 : :
1149 : : writerfilter::Reference<Properties>::Pointer_t
1150 : 0 : WW8DocumentImpl::getShape(sal_uInt32 nSpid)
1151 : : {
1152 [ # # ]: 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
1153 [ # # ]: 0 : DffRecord::Pointer_t pShape = mpDffBlock->getShape(nSpid);
1154 : :
1155 [ # # ]: 0 : if (pShape.get() != NULL)
1156 : : {
1157 [ # # ][ # # ]: 0 : DffSpContainer * pTmp = new DffSpContainer(*pShape);
1158 [ # # ]: 0 : pTmp->setDocument(this);
1159 : :
1160 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Properties>::Pointer_t(pTmp);
[ # # ]
1161 : : }
1162 : :
1163 [ # # ]: 0 : return pResult;
1164 : : }
1165 : :
1166 : : writerfilter::Reference<Properties>::Pointer_t
1167 : 0 : WW8DocumentImpl::getBreak(const CpAndFc & rCpAndFc) const
1168 : : {
1169 : 0 : return mpBreakHelper->getBreak(rCpAndFc);
1170 : : }
1171 : :
1172 : : writerfilter::Reference<Properties>::Pointer_t
1173 : 0 : WW8DocumentImpl::getBlip(sal_uInt32 nBid)
1174 : : {
1175 : 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
1176 : :
1177 [ # # ]: 0 : if (mpDffBlock != NULL)
1178 : : {
1179 [ # # ]: 0 : DffRecord::Pointer_t pDffRecord(mpDffBlock->getBlip(nBid));
1180 : :
1181 [ # # ]: 0 : if (pDffRecord.get() != NULL)
1182 : : {
1183 [ # # ][ # # ]: 0 : DffBSE * pBlip = new DffBSE(*pDffRecord);
1184 : :
1185 [ # # ]: 0 : if (pBlip != NULL)
1186 [ # # ][ # # ]: 0 : pResult = writerfilter::Reference<Properties>::Pointer_t(pBlip);
[ # # ]
1187 [ # # ]: 0 : }
1188 : : }
1189 : :
1190 : 0 : return pResult;
1191 : : }
1192 : :
1193 : : writerfilter::Reference<Properties>::Pointer_t
1194 : 0 : WW8DocumentImpl::getField(const CpAndFc & rCpAndFc) const
1195 : : {
1196 : 0 : return mpFieldHelper->getField(rCpAndFc);
1197 : : }
1198 : :
1199 : : writerfilter::Reference<Properties>::Pointer_t
1200 : 0 : WW8DocumentImpl::getDocumentProperties() const
1201 : : {
1202 : 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
1203 : :
1204 [ # # ]: 0 : if (mpFib->get_lcbDop() > 0)
1205 : : {
1206 [ # # ][ # # ]: 0 : pResult.reset(new WW8DopBase(*mpTableStream, mpFib->get_fcDop(), mpFib->get_lcbDop()));
[ # # ]
1207 : : }
1208 : :
1209 : 0 : return pResult;
1210 : : }
1211 : :
1212 : 0 : WW8FLD::Pointer_t WW8DocumentImpl::getCurrentFLD() const
1213 : : {
1214 : 0 : return mpFLD;
1215 : : }
1216 : :
1217 : 0 : void WW8DocumentImpl::setPicLocation(sal_uInt32 fcPicLoc)
1218 : : {
1219 : 0 : mfcPicLoc = fcPicLoc;
1220 : 0 : }
1221 : :
1222 : 0 : bool WW8DocumentImpl::isPicData()
1223 : : {
1224 : 0 : return mbPicIsData;
1225 : : }
1226 : :
1227 : 0 : void WW8DocumentImpl::setPicIsData(bool bPicIsData)
1228 : : {
1229 : 0 : mbPicIsData = bPicIsData;
1230 : 0 : }
1231 : :
1232 : : writerfilter::Reference<Stream>::Pointer_t
1233 : 0 : WW8DocumentImpl::getTextboxText(sal_uInt32 nShpId) const
1234 : : {
1235 : 0 : writerfilter::Reference<Stream>::Pointer_t pResult;
1236 : :
1237 [ # # ]: 0 : if (mpTextBoxStories.get() != NULL)
1238 : : {
1239 : 0 : sal_uInt32 nCount = mpTextBoxStories->getEntryCount();
1240 : :
1241 : 0 : sal_uInt32 n = 0;
1242 [ # # ]: 0 : while (n < nCount)
1243 : : {
1244 [ # # ]: 0 : WW8FTXBXS * pTextboxStory = mpTextBoxStories->getEntryPointer(n);
1245 : :
1246 [ # # ][ # # ]: 0 : if (pTextboxStory->get_lid() == nShpId)
1247 : 0 : break;
1248 : :
1249 : 0 : ++n;
1250 : : }
1251 : :
1252 [ # # ]: 0 : if (n < nCount)
1253 : : {
1254 [ # # ]: 0 : Cp aCpStart(mpTextBoxStories->getFc(n));
1255 : 0 : aCpStart += getEndnoteEndCp().getCp().get();
1256 : : CpAndFc aCpAndFcStart =
1257 [ # # ]: 0 : mpPieceTable->createCpAndFc(aCpStart, PROP_DOC);
1258 [ # # ]: 0 : Cp aCpEnd(mpTextBoxStories->getFc(n + 1));
1259 : 0 : aCpEnd += getEndnoteEndCp().getCp().get();
1260 [ # # ]: 0 : CpAndFc aCpAndFcEnd = mpPieceTable->createCpAndFc(aCpEnd, PROP_DOC);
1261 : :
1262 : : pResult = writerfilter::Reference<Stream>::Pointer_t
1263 [ # # ][ # # ]: 0 : (new WW8DocumentImpl(*this, aCpAndFcStart, aCpAndFcEnd));
[ # # ][ # # ]
[ # # ]
1264 : : }
1265 : : }
1266 : :
1267 : 0 : return pResult;
1268 : : }
1269 : :
1270 : 0 : Id lcl_headerQName(sal_uInt32 nIndex)
1271 : : {
1272 : 0 : Id qName = NS_rtf::LN_header;
1273 : :
1274 [ # # ]: 0 : if (nIndex > 5)
1275 : : {
1276 [ # # # # : 0 : switch ((nIndex - 6) % 6)
# # # ]
1277 : : {
1278 : : case 0:
1279 : 0 : qName = NS_rtf::LN_headerl;
1280 : :
1281 : 0 : break;
1282 : : case 1:
1283 : 0 : qName = NS_rtf::LN_headerr;
1284 : :
1285 : 0 : break;
1286 : : case 2:
1287 : 0 : qName = NS_rtf::LN_footerl;
1288 : :
1289 : 0 : break;
1290 : : case 3:
1291 : 0 : qName = NS_rtf::LN_footerr;
1292 : :
1293 : 0 : break;
1294 : : case 4:
1295 : 0 : qName = NS_rtf::LN_headerf;
1296 : :
1297 : 0 : break;
1298 : : case 5:
1299 : 0 : qName = NS_rtf::LN_footerf;
1300 : :
1301 : 0 : break;
1302 : : }
1303 : : }
1304 : :
1305 : 0 : return qName;
1306 : : }
1307 : :
1308 : 0 : Fc WW8DocumentImpl::cp2fc(const Cp & cp) const
1309 : : {
1310 : 0 : return mpPieceTable->cp2fc(cp);
1311 : : }
1312 : :
1313 : 0 : CpAndFc WW8DocumentImpl::getCpAndFc(const Cp & cp, PropertyType type) const
1314 : : {
1315 [ # # ]: 0 : Fc aFc = cp2fc(cp);
1316 : :
1317 [ # # ]: 0 : return CpAndFc(cp, aFc, type);
1318 : : }
1319 : :
1320 : 0 : void WW8DocumentImpl::resolvePicture(Stream & rStream)
1321 : : {
1322 [ # # ]: 0 : WW8Stream::Pointer_t pStream = getDataStream();
1323 : :
1324 [ # # ]: 0 : if (pStream.get() != NULL)
1325 : : {
1326 [ # # ]: 0 : WW8StructBase aStruct(*pStream, mfcPicLoc, 4);
1327 [ # # ]: 0 : sal_uInt32 nCount = aStruct.getU32(0);
1328 : :
1329 : : {
1330 [ # # ][ # # ]: 0 : WW8PICF * pPicf = new WW8PICF(*pStream, mfcPicLoc, nCount);
1331 [ # # ]: 0 : pPicf->setDocument(this);
1332 : :
1333 [ # # ]: 0 : writerfilter::Reference<Properties>::Pointer_t pProps(pPicf);
1334 : :
1335 [ # # ][ # # ]: 0 : rStream.props(pProps);
[ # # ][ # # ]
1336 [ # # ]: 0 : }
1337 [ # # ]: 0 : }
1338 : 0 : }
1339 : :
1340 : 0 : void WW8DocumentImpl::resolveSpecialChar(sal_uInt32 nChar, Stream & rStream)
1341 : : {
1342 [ # # ]: 0 : switch (nChar)
1343 : : {
1344 : : case 0x1:
1345 : 0 : resolvePicture(rStream);
1346 : 0 : break;
1347 : : default:
1348 : 0 : break;
1349 : : }
1350 : 0 : }
1351 : :
1352 : 0 : void WW8DocumentImpl::text(Stream & rStream, const sal_uInt8 * data, size_t len)
1353 : : {
1354 : : #ifdef DEBUG_ELEMENT
1355 : : OUString sText( (const sal_Char*) data, len, RTL_TEXTENCODING_MS_1252 );
1356 : : debug_logger->startElement("text");
1357 : : debug_logger->chars(OUStringToOString(sText, RTL_TEXTENCODING_ASCII_US).getStr());
1358 : : debug_logger->endElement();
1359 : : #endif
1360 : 0 : rStream.text(data, len);
1361 : 0 : }
1362 : :
1363 : 0 : void WW8DocumentImpl::utext(Stream & rStream, const sal_uInt8 * data, size_t len)
1364 : : {
1365 : : #ifdef DEBUG_ELEMENT
1366 : : debug_logger->startElement("utext");
1367 : :
1368 : : OUString sText;
1369 : : OUStringBuffer aBuffer = ::rtl:: OUStringBuffer(len);
1370 : : aBuffer.append( (const sal_Unicode *) data, len);
1371 : : sText = aBuffer.makeStringAndClear();
1372 : :
1373 : : debug_logger->chars(OUStringToOString(sText, RTL_TEXTENCODING_ASCII_US).getStr());
1374 : : debug_logger->endElement();
1375 : : #endif
1376 : 0 : rStream.utext(data, len);
1377 : 0 : }
1378 : :
1379 : :
1380 : 0 : void WW8DocumentImpl::resolveText(WW8DocumentIterator::Pointer_t pIt,
1381 : : Stream & rStream)
1382 : : {
1383 [ # # ]: 0 : WW8Stream::Sequence aSeq = pIt->getText();
1384 : :
1385 : 0 : sal_uInt32 nCount = aSeq.getCount();
1386 [ # # ]: 0 : bool bComplex = pIt->isComplex();
1387 : :
1388 : : /*
1389 : : Assumption: Special characters are always at the beginning or end of a
1390 : : run.
1391 : : */
1392 [ # # ]: 0 : if (nCount > 0)
1393 : : {
1394 [ # # ]: 0 : if (nCount == 1)
1395 : 0 : bComplex = true;
1396 : :
1397 [ # # ]: 0 : if (bComplex)
1398 : : {
1399 : 0 : sal_uInt32 nStartIndex = 0;
1400 : 0 : sal_uInt32 nEndIndex = nCount - 1;
1401 : :
1402 [ # # ]: 0 : sal_uInt32 nCharFirst = aSeq[0];
1403 [ # # ]: 0 : sal_uInt32 nCharLast = aSeq[nEndIndex];
1404 : :
1405 [ # # ]: 0 : if (isSpecial(nCharFirst))
1406 : : {
1407 : 0 : nStartIndex += 1;
1408 [ # # ]: 0 : resolveSpecialChar(nCharFirst, rStream);
1409 [ # # ][ # # ]: 0 : text(rStream, &aSeq[0], 1);
1410 : : }
1411 : :
1412 [ # # ]: 0 : if (!isSpecial(nCharLast))
1413 : 0 : nEndIndex += 1;
1414 : :
1415 [ # # ]: 0 : if (nStartIndex < nEndIndex)
1416 : : {
1417 : 0 : sal_uInt32 nChars = nEndIndex - nStartIndex;
1418 [ # # ][ # # ]: 0 : text(rStream, &aSeq[nStartIndex], nChars);
1419 : :
1420 [ # # ]: 0 : if (isSpecial(nCharLast))
1421 : : {
1422 [ # # ]: 0 : resolveSpecialChar(nCharLast, rStream);
1423 [ # # ][ # # ]: 0 : text(rStream, &aSeq[nEndIndex], 1);
1424 : : }
1425 : : }
1426 : : }
1427 : : else
1428 : : {
1429 : 0 : sal_uInt32 nStartIndex = 0;
1430 : 0 : sal_uInt32 nEndIndex = nCount - 2;
1431 : :
1432 [ # # ][ # # ]: 0 : sal_uInt32 nCharFirst = aSeq[0] + (aSeq[1] << 8);
1433 [ # # ][ # # ]: 0 : sal_uInt32 nCharLast = aSeq[nEndIndex] + (aSeq[nEndIndex + 1]);
1434 : :
1435 [ # # ]: 0 : if (isSpecial(nCharFirst))
1436 : : {
1437 : 0 : nStartIndex += 2;
1438 [ # # ]: 0 : resolveSpecialChar(nCharFirst, rStream);
1439 [ # # ][ # # ]: 0 : utext(rStream, &aSeq[0], 1);
1440 : : }
1441 : :
1442 [ # # ]: 0 : if (!isSpecial(nCharLast))
1443 : 0 : nEndIndex += 2;
1444 : :
1445 [ # # ]: 0 : if (nStartIndex < nEndIndex)
1446 : : {
1447 : 0 : sal_uInt32 nChars = (nEndIndex - nStartIndex) / 2;
1448 [ # # ][ # # ]: 0 : utext(rStream, &aSeq[nStartIndex], nChars);
1449 : :
1450 [ # # ]: 0 : if (isSpecial(nCharLast))
1451 : : {
1452 [ # # ]: 0 : resolveSpecialChar(nCharLast, rStream);
1453 [ # # ][ # # ]: 0 : utext(rStream, &aSeq[nEndIndex], 1);
1454 : : }
1455 : : }
1456 : : }
1457 [ # # ]: 0 : }
1458 : 0 : }
1459 : :
1460 : 0 : void WW8DocumentImpl::startCharacterGroup(Stream & rStream)
1461 : : {
1462 [ # # ]: 0 : if (mbInCharacterGroup)
1463 : 0 : endCharacterGroup(rStream);
1464 : :
1465 : : #ifdef DEBUG_ELEMENT
1466 : : debug_logger->startElement("charactergroup");
1467 : : #endif
1468 : :
1469 : 0 : rStream.startCharacterGroup();
1470 : 0 : mbInCharacterGroup = true;
1471 : 0 : }
1472 : :
1473 : 0 : void WW8DocumentImpl::endCharacterGroup(Stream & rStream)
1474 : : {
1475 : : #ifdef DEBUG_ELEMENT
1476 : : debug_logger->endElement();
1477 : : #endif
1478 : :
1479 : 0 : rStream.endCharacterGroup();
1480 : 0 : mbInCharacterGroup = false;
1481 : 0 : }
1482 : :
1483 : 0 : void WW8DocumentImpl::startParagraphGroup(Stream & rStream)
1484 : : {
1485 [ # # ]: 0 : if (mbInParagraphGroup)
1486 : 0 : endParagraphGroup(rStream);
1487 : :
1488 : : #ifdef DEBUG_ELEMENT
1489 : : debug_logger->startElement("paragraphgroup");
1490 : : #endif
1491 : :
1492 : 0 : rStream.startParagraphGroup();
1493 : 0 : mbInParagraphGroup = true;
1494 : 0 : }
1495 : :
1496 : 0 : void WW8DocumentImpl::endParagraphGroup(Stream & rStream)
1497 : : {
1498 [ # # ]: 0 : if (mbInCharacterGroup)
1499 : 0 : endCharacterGroup(rStream);
1500 : :
1501 : : #ifdef DEBUG_ELEMENT
1502 : : debug_logger->endElement();
1503 : : #endif
1504 : 0 : rStream.endParagraphGroup();
1505 : 0 : mbInParagraphGroup = false;
1506 : 0 : }
1507 : :
1508 : 0 : void WW8DocumentImpl::startSectionGroup(Stream & rStream)
1509 : : {
1510 [ # # ]: 0 : if (mbInSection)
1511 : 0 : endSectionGroup(rStream);
1512 : :
1513 : : #ifdef DEBUG_ELEMENT
1514 : : debug_logger->startElement("sectiongroup");
1515 : : #endif
1516 : :
1517 : 0 : rStream.startSectionGroup();
1518 : 0 : mbInSection = true;
1519 : 0 : }
1520 : :
1521 : 0 : void WW8DocumentImpl::endSectionGroup(Stream & rStream)
1522 : : {
1523 [ # # ]: 0 : if (mbInParagraphGroup)
1524 : 0 : endParagraphGroup(rStream);
1525 : :
1526 : : #ifdef DEBUG_ELEMENT
1527 : : debug_logger->endElement();
1528 : : #endif
1529 : 0 : rStream.endSectionGroup();
1530 : 0 : mbInSection = false;
1531 : 0 : }
1532 : :
1533 : 0 : void WW8DocumentImpl::resolve(Stream & rStream)
1534 : : {
1535 [ # # ]: 0 : if (! bSubDocument)
1536 : : {
1537 [ # # ][ # # ]: 0 : output.addItem("<substream-names>");
1538 [ # # ][ # # ]: 0 : output.addItem(mpStream->getSubStreamNames());
1539 [ # # ][ # # ]: 0 : output.addItem("</substream-names>");
1540 : :
1541 [ # # ]: 0 : if (mpDocStream.get() != NULL)
1542 : : {
1543 [ # # ]: 0 : mpDocStream->dump(output);
1544 : : }
1545 : :
1546 [ # # ]: 0 : if (mpSummaryInformationStream.get() != NULL)
1547 : : {
1548 [ # # ]: 0 : mpSummaryInformationStream->dump(output);
1549 : : }
1550 : :
1551 : : writerfilter::Reference<Properties>::Pointer_t pFib
1552 [ # # ][ # # ]: 0 : (new WW8Fib(*mpFib));
[ # # ]
1553 [ # # ][ # # ]: 0 : rStream.props(pFib);
[ # # ]
1554 : :
1555 [ # # ]: 0 : if (mpFibRgFcLcb2000.get() != NULL)
1556 : : {
1557 : : writerfilter::Reference<Properties>::Pointer_t pFibRgFcLcb2000
1558 [ # # ][ # # ]: 0 : (new WW8FibRgFcLcb2000(*mpFibRgFcLcb2000));
[ # # ]
1559 [ # # ][ # # ]: 0 : rStream.props(pFibRgFcLcb2000);
[ # # ][ # # ]
1560 : : }
1561 : :
1562 [ # # ]: 0 : if (mpFib->get_lcbPlcftxbxBkd() > 0)
1563 : : {
1564 : 0 : PLCF<WW8BKD> aPLCF(*mpTableStream,
1565 : 0 : mpFib->get_fcPlcftxbxBkd(),
1566 [ # # ][ # # ]: 0 : mpFib->get_lcbPlcftxbxBkd());
1567 : : }
1568 : :
1569 [ # # ]: 0 : if (mpDffBlock.get() != NULL)
1570 : : {
1571 [ # # ][ # # ]: 0 : DffBlock * pTmp = new DffBlock(*mpDffBlock);
1572 : : writerfilter::Reference<Properties>::Pointer_t pDffBlock =
1573 [ # # ]: 0 : writerfilter::Reference<Properties>::Pointer_t(pTmp);
1574 : :
1575 [ # # ][ # # ]: 0 : rStream.props(pDffBlock);
[ # # ][ # # ]
1576 : : }
1577 : :
1578 : : {
1579 [ # # ][ # # ]: 0 : rStream.info("headers");
1580 [ # # ]: 0 : sal_uInt32 nHeaderCount = getHeaderCount();
1581 [ # # ]: 0 : for (sal_uInt32 n = 0; n < nHeaderCount; ++n)
1582 : : {
1583 [ # # ][ # # ]: 0 : rStream.info(getHeaderCpAndFc(n).toString());
[ # # ]
1584 : : }
1585 [ # # ][ # # ]: 0 : rStream.info("/headers");
1586 : : }
1587 : :
1588 [ # # ]: 0 : writerfilter::Reference<Table>::Pointer_t pSttbRgtplc = getListTplcs();
1589 : :
1590 [ # # ]: 0 : if (pSttbRgtplc.get() != NULL)
1591 [ # # ][ # # ]: 0 : rStream.table(NS_rtf::LN_SttbRgtplc, pSttbRgtplc);
[ # # ]
1592 : :
1593 [ # # ]: 0 : writerfilter::Reference<Table>::Pointer_t pFontTable = getFontTable();
1594 : :
1595 [ # # ]: 0 : if (pFontTable.get() != NULL)
1596 [ # # ][ # # ]: 0 : rStream.table(NS_rtf::LN_FONTTABLE, pFontTable);
[ # # ]
1597 : :
1598 : : try
1599 : : {
1600 [ # # ]: 0 : writerfilter::Reference<Table>::Pointer_t pStyleSheet = getStyleSheet();
1601 : :
1602 [ # # ]: 0 : if (pStyleSheet.get() != NULL)
1603 [ # # ][ # # ]: 0 : rStream.table(NS_rtf::LN_STYLESHEET, pStyleSheet);
[ # # ][ # # ]
1604 : : }
1605 [ # # # # ]: 0 : catch (const Exception &e)
1606 : : {
1607 [ # # # # ]: 0 : clog << e.getText() << endl;
1608 : : }
1609 : :
1610 [ # # ]: 0 : writerfilter::Reference<Table>::Pointer_t pAssocTable = getAssocTable();
1611 : :
1612 [ # # ]: 0 : if (pAssocTable.get() != NULL)
1613 [ # # ][ # # ]: 0 : rStream.table(NS_rtf::LN_SttbAssoc, pAssocTable);
[ # # ]
1614 : :
1615 [ # # ]: 0 : writerfilter::Reference<Table>::Pointer_t pListTable = getListTable();
1616 : :
1617 [ # # ]: 0 : if (pListTable.get() != NULL)
1618 [ # # ][ # # ]: 0 : rStream.table(NS_rtf::LN_LISTTABLE, pListTable);
[ # # ]
1619 : :
1620 [ # # ]: 0 : writerfilter::Reference<Table>::Pointer_t pLFOTable = getLFOTable();
1621 : :
1622 [ # # ]: 0 : if (pLFOTable.get() != NULL)
1623 [ # # ][ # # ]: 0 : rStream.table(NS_rtf::LN_LFOTABLE, pLFOTable);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1624 : : }
1625 : :
1626 [ # # ]: 0 : WW8DocumentIterator::Pointer_t pIt = begin();
1627 [ # # ]: 0 : WW8DocumentIterator::Pointer_t pItEnd = end();
1628 : :
1629 : 0 : mbInParagraphGroup = false;
1630 : 0 : mbInCharacterGroup = false;
1631 : 0 : mbInSection = false;
1632 : :
1633 : 0 : sal_uInt32 nSectionIndex = 0;
1634 : :
1635 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1636 [ # # ][ # # ]: 0 : rStream.info(pItEnd->toString());
1637 : :
1638 [ # # ][ # # ]: 0 : while (! pIt->equal(*pItEnd))
1639 : : {
1640 : : writerfilter::Reference<Properties>::Pointer_t
1641 [ # # ]: 0 : pProperties(pIt->getProperties());
1642 : :
1643 [ # # ][ # # : 0 : switch (pIt->getPropertyType())
# # # #
# ]
1644 : : {
1645 : : case PROP_FOOTNOTE:
1646 : : {
1647 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1648 : : writerfilter::Reference<Stream>::Pointer_t
1649 [ # # ]: 0 : pFootnote(pIt->getSubDocument());
1650 : :
1651 [ # # ]: 0 : if (pFootnote.get() != NULL)
1652 : : {
1653 : : #ifdef DEBUG_ELEMENT
1654 : : debug_logger->startElement("substream");
1655 : : #endif
1656 [ # # ][ # # ]: 0 : rStream.substream(NS_rtf::LN_footnote, pFootnote);
[ # # ]
1657 : : #ifdef DEBUG_ELEMENT
1658 : : debug_logger->endElement();
1659 : : #endif
1660 [ # # ]: 0 : }
1661 : : }
1662 : 0 : break;
1663 : : case PROP_ENDNOTE:
1664 : : {
1665 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1666 : : writerfilter::Reference<Stream>::Pointer_t
1667 [ # # ]: 0 : pEndnote(pIt->getSubDocument());
1668 : :
1669 [ # # ]: 0 : if (pEndnote.get() != NULL)
1670 : : {
1671 : : #ifdef DEBUG_ELEMENT
1672 : : debug_logger->startElement("substream");
1673 : : #endif
1674 [ # # ][ # # ]: 0 : rStream.substream(NS_rtf::LN_endnote, pEndnote);
[ # # ]
1675 : : #ifdef DEBUG_ELEMENT
1676 : : debug_logger->endElement();
1677 : : #endif
1678 [ # # ]: 0 : }
1679 : : }
1680 : 0 : break;
1681 : : case PROP_ANNOTATION:
1682 : : {
1683 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1684 : : writerfilter::Reference<Stream>::Pointer_t
1685 [ # # ]: 0 : pAnnotation(pIt->getSubDocument());
1686 : :
1687 [ # # ]: 0 : if (pAnnotation.get() != NULL)
1688 : : {
1689 : : #ifdef DEBUG_ELEMENT
1690 : : debug_logger->startElement("substream");
1691 : : #endif
1692 [ # # ][ # # ]: 0 : rStream.substream(NS_rtf::LN_annotation, pAnnotation);
[ # # ]
1693 : : #ifdef DEBUG_ELEMENT
1694 : : debug_logger->endElement();
1695 : : #endif
1696 [ # # ]: 0 : }
1697 : : }
1698 : 0 : break;
1699 : : case PROP_CHP:
1700 : : {
1701 [ # # ]: 0 : startCharacterGroup(rStream);
1702 : : }
1703 : :
1704 : 0 : break;
1705 : : case PROP_PAP:
1706 : : {
1707 [ # # ]: 0 : startParagraphGroup(rStream);
1708 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1709 : : }
1710 : :
1711 : 0 : break;
1712 : : case PROP_SEC:
1713 : : {
1714 [ # # ]: 0 : startSectionGroup(rStream);
1715 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1716 : :
1717 [ # # ]: 0 : if (nSectionIndex == 0)
1718 [ # # ][ # # ]: 0 : rStream.props(getDocumentProperties());
[ # # ]
1719 : :
1720 : 0 : sal_uInt32 nHeaderStartIndex = 6 + nSectionIndex * 6;
1721 : 0 : sal_uInt32 nHeaderEndIndex = nHeaderStartIndex + 6;
1722 : :
1723 [ # # ][ # # ]: 0 : if (nHeaderStartIndex >= getHeaderCount())
1724 [ # # ]: 0 : nHeaderStartIndex = getHeaderCount();
1725 : :
1726 [ # # ][ # # ]: 0 : if (nHeaderEndIndex >= getHeaderCount())
1727 [ # # ]: 0 : nHeaderEndIndex = getHeaderCount();
1728 : :
1729 [ # # ]: 0 : for (sal_uInt32 n = nHeaderStartIndex; n < nHeaderEndIndex; ++n)
1730 : : {
1731 : : writerfilter::Reference<Stream>::Pointer_t
1732 [ # # ]: 0 : pHeader(getHeader(n));
1733 : :
1734 : 0 : Id qName = lcl_headerQName(n);
1735 : :
1736 [ # # ]: 0 : if (pHeader.get() != NULL)
1737 [ # # ][ # # ]: 0 : rStream.substream(qName, pHeader);
[ # # ]
1738 [ # # ]: 0 : }
1739 : :
1740 : 0 : ++nSectionIndex;
1741 : : }
1742 : :
1743 : 0 : break;
1744 : : default:
1745 [ # # ][ # # ]: 0 : rStream.info(pIt->toString());
1746 : : }
1747 : :
1748 [ # # ]: 0 : if (pProperties.get() != NULL)
1749 : : {
1750 : : #ifdef DEBUG_PROPERTIES
1751 : : debug_logger->propertySet(pProperties,
1752 : : IdToString::Pointer_t(new WW8IdToString()));
1753 : : #endif
1754 : :
1755 [ # # ][ # # ]: 0 : rStream.props(pProperties);
[ # # ]
1756 : : }
1757 : :
1758 [ # # ][ # # ]: 0 : if (pIt->getPropertyType() == PROP_PAP)
1759 : : {
1760 [ # # ]: 0 : startCharacterGroup(rStream);
1761 : : }
1762 : :
1763 [ # # ][ # # ]: 0 : resolveText(pIt, rStream);
[ # # ]
1764 : :
1765 [ # # ]: 0 : ++(*pIt);
1766 [ # # ]: 0 : }
1767 : :
1768 [ # # ]: 0 : if (mbInCharacterGroup)
1769 [ # # ]: 0 : endCharacterGroup(rStream);
1770 : :
1771 [ # # ]: 0 : if (mbInParagraphGroup)
1772 [ # # ]: 0 : endParagraphGroup(rStream);
1773 : :
1774 [ # # ]: 0 : if (mbInSection)
1775 [ # # ][ # # ]: 0 : endSectionGroup(rStream);
[ # # ]
1776 : :
1777 : 0 : }
1778 : :
1779 : : WW8Stream::Pointer_t
1780 : 0 : WW8DocumentFactory::createStream(uno::Reference<uno::XComponentContext> rContext,
1781 : : uno::Reference<io::XInputStream> rStream)
1782 : : {
1783 [ # # ][ # # ]: 0 : return WW8Stream::Pointer_t(new WW8StreamImpl(rContext, rStream));
[ # # ]
1784 : : }
1785 : :
1786 : : WW8Document *
1787 : 0 : WW8DocumentFactory::createDocument(WW8Stream::Pointer_t rpStream)
1788 : : {
1789 [ # # ][ # # ]: 0 : return new WW8DocumentImpl(rpStream);
1790 : : }
1791 : :
1792 : : writerfilter::Reference<Properties>::Pointer_t
1793 : 0 : WW8SED::get_sepx()
1794 : : {
1795 : 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
1796 : :
1797 [ # # ][ # # ]: 0 : if (get_fcSepx() != 0xffffffff)
1798 : : {
1799 [ # # ][ # # ]: 0 : WW8StructBase aTmp(*mpDoc->getDocStream(), get_fcSepx(), 2);
[ # # ][ # # ]
1800 : : pResult = writerfilter::Reference<Properties>::Pointer_t
1801 : : (new WW8PropertySetImpl
1802 [ # # # # ]: 0 : (*mpDoc->getDocStream(), get_fcSepx() + 2,
[ # # ]
1803 [ # # ][ # # ]: 0 : (sal_uInt32) aTmp.getU16(0), false));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1804 : : }
1805 : :
1806 : 0 : return pResult;
1807 : : }
1808 : :
1809 : 0 : void WW8DocumentImpl::insertCpAndFc(const CpAndFc & rCpAndFc)
1810 : : {
1811 : 0 : mCpAndFcs.insert(rCpAndFc);
1812 : 0 : }
1813 : :
1814 : 0 : string propertyTypeToString(PropertyType nType)
1815 : : {
1816 : 0 : string result;
1817 : :
1818 [ # # # # : 0 : switch (nType)
# # # # #
# # # ]
1819 : : {
1820 : : case PROP_SHP:
1821 [ # # ]: 0 : result = "SHP";
1822 : :
1823 : 0 : break;
1824 : : case PROP_FLD:
1825 [ # # ]: 0 : result = "FLD";
1826 : :
1827 : 0 : break;
1828 : : case PROP_BOOKMARKSTART:
1829 [ # # ]: 0 : result = "BOOKMARKSTART";
1830 : :
1831 : 0 : break;
1832 : : case PROP_BOOKMARKEND:
1833 [ # # ]: 0 : result = "BOOKMARKEND";
1834 : :
1835 : 0 : break;
1836 : : case PROP_ENDNOTE:
1837 [ # # ]: 0 : result = "ENDNOTE";
1838 : :
1839 : 0 : break;
1840 : : case PROP_FOOTNOTE:
1841 [ # # ]: 0 : result = "FOOTNOTE";
1842 : :
1843 : 0 : break;
1844 : : case PROP_ANNOTATION:
1845 [ # # ]: 0 : result = "ANNOTATION";
1846 : :
1847 : 0 : break;
1848 : : case PROP_DOC:
1849 [ # # ]: 0 : result = "DOC";
1850 : :
1851 : 0 : break;
1852 : :
1853 : : case PROP_SEC:
1854 [ # # ]: 0 : result = "SEC";
1855 : :
1856 : 0 : break;
1857 : :
1858 : : case PROP_PAP:
1859 [ # # ]: 0 : result = "PAP";
1860 : :
1861 : 0 : break;
1862 : :
1863 : : case PROP_CHP:
1864 [ # # ]: 0 : result = "CHP";
1865 : :
1866 : 0 : break;
1867 : : default:
1868 : 0 : break;
1869 : : }
1870 : :
1871 : 0 : return result;
1872 : : }
1873 : :
1874 : 0 : string CpAndFc::toString() const
1875 : : {
1876 : 0 : string result;
1877 : :
1878 [ # # ]: 0 : result += "(";
1879 [ # # ][ # # ]: 0 : result += getCp().toString();
1880 [ # # ]: 0 : result += ", ";
1881 [ # # ][ # # ]: 0 : result += getFc().toString();
1882 [ # # ]: 0 : result += ", ";
1883 : :
1884 [ # # ][ # # ]: 0 : result += propertyTypeToString(getType());
1885 : :
1886 [ # # ]: 0 : result += ")";
1887 : :
1888 : 0 : return result;
1889 : : }
1890 : :
1891 : :
1892 : : // Bookmark
1893 : :
1894 : 0 : Bookmark::Bookmark(writerfilter::Reference<Properties>::Pointer_t pBKF,
1895 : : OUString & rName)
1896 [ # # ]: 0 : : mpBKF(pBKF), mName(rName)
1897 : : {
1898 : 0 : }
1899 : :
1900 : 0 : void Bookmark::resolve(Properties & rHandler)
1901 : : {
1902 [ # # ]: 0 : mpBKF->resolve(rHandler);
1903 : :
1904 [ # # ][ # # ]: 0 : WW8Value::Pointer_t pValue = createValue(mName);
1905 [ # # ][ # # ]: 0 : rHandler.attribute(NS_rtf::LN_BOOKMARKNAME, *pValue);
1906 : 0 : }
1907 : :
1908 : 0 : string Bookmark::getType() const
1909 : : {
1910 [ # # ]: 0 : return "Bookmark";
1911 : : }
1912 : :
1913 : : // BookmarkHelper
1914 : :
1915 : 0 : CpAndFc BookmarkHelper::getStartCpAndFc(sal_uInt32 nPos)
1916 : : {
1917 [ # # ]: 0 : Cp aCp(mpStartCps->getFc(nPos));
1918 [ # # ]: 0 : Fc aFc(mpPieceTable->cp2fc(aCp));
1919 [ # # ]: 0 : CpAndFc aCpAndFc(aCp, aFc, PROP_BOOKMARKSTART);
1920 : :
1921 : 0 : return aCpAndFc;
1922 : : }
1923 : :
1924 : 0 : CpAndFc BookmarkHelper::getEndCpAndFc(sal_uInt32 nPos)
1925 : : {
1926 [ # # ]: 0 : Cp aCp(mpEndCps->getU32(nPos * 4));
1927 [ # # ]: 0 : Fc aFc(mpPieceTable->cp2fc(aCp));
1928 [ # # ]: 0 : CpAndFc aCpAndFc(aCp, aFc, PROP_BOOKMARKEND);
1929 : :
1930 : 0 : return aCpAndFc;
1931 : : }
1932 : :
1933 : 0 : OUString BookmarkHelper::getName(sal_uInt32 nPos)
1934 : : {
1935 : 0 : return mpNames->getEntry(nPos);
1936 : : }
1937 : :
1938 : 0 : sal_uInt32 BookmarkHelper::getIndex(const CpAndFc & rCpAndFc)
1939 : : {
1940 : 0 : sal_uInt32 nResult = mpStartCps->getEntryCount();
1941 : :
1942 : 0 : sal_uInt32 nCp = rCpAndFc.getCp().get();
1943 : :
1944 : : sal_uInt32 n;
1945 [ # # # ]: 0 : switch (rCpAndFc.getType())
1946 : : {
1947 : : case PROP_BOOKMARKSTART:
1948 : : {
1949 : 0 : sal_uInt32 nStartsCount = mpStartCps->getEntryCount();
1950 : :
1951 [ # # ]: 0 : for (n = 0; n < nStartsCount; ++n)
1952 : : {
1953 [ # # ]: 0 : if (nCp == mpStartCps->getFc(n))
1954 : : {
1955 : 0 : nResult = n;
1956 : :
1957 : 0 : break;
1958 : : }
1959 : : }
1960 : :
1961 [ # # ]: 0 : if (n == nStartsCount)
1962 [ # # ][ # # ]: 0 : throw ExceptionNotFound("BookmarkHelper::getIndex");
1963 : : }
1964 : :
1965 : 0 : break;
1966 : :
1967 : : case PROP_BOOKMARKEND:
1968 : : {
1969 : 0 : sal_uInt32 nEndsCount = mpEndCps->getCount() / 4;
1970 : 0 : sal_uInt32 nIndex = nEndsCount;
1971 : :
1972 [ # # ]: 0 : for (n = 0; n < nEndsCount; ++n)
1973 : : {
1974 [ # # ]: 0 : if (nCp == mpEndCps->getU16(n * 4))
1975 : : {
1976 : 0 : nIndex = n;
1977 : :
1978 : 0 : break;
1979 : : }
1980 : : }
1981 : :
1982 [ # # ]: 0 : if (n == nEndsCount)
1983 [ # # ][ # # ]: 0 : throw ExceptionNotFound("BookmarkHelper::getIndex");
1984 : :
1985 : : {
1986 : : {
1987 : 0 : sal_uInt32 nStartsCount = mpStartCps->getEntryCount();
1988 [ # # ]: 0 : for (n = 0; n < nStartsCount; ++n)
1989 : : {
1990 [ # # ]: 0 : WW8BKF::Pointer_t pBKF(mpStartCps->getEntry(n));
1991 : :
1992 [ # # # # ]: 0 : if (pBKF->get_ibkl() ==
1993 : 0 : sal::static_int_cast<sal_Int32>(nIndex))
1994 : : {
1995 : 0 : nResult = n;
1996 : :
1997 : : break;
1998 : : }
1999 [ # # ][ # # ]: 0 : }
2000 : :
2001 [ # # ]: 0 : if (n == nStartsCount)
2002 [ # # ][ # # ]: 0 : throw ExceptionNotFound("BookmarkHelper::getIndex");
2003 : : }
2004 : : }
2005 : : }
2006 : :
2007 : 0 : break;
2008 : : default:
2009 : 0 : break;
2010 : : }
2011 : :
2012 : 0 : return nResult;
2013 : : }
2014 : :
2015 : 0 : void BookmarkHelper::init()
2016 : : {
2017 : : {
2018 : 0 : sal_uInt32 nStartsCount = mpStartCps->getEntryCount();
2019 : :
2020 [ # # ]: 0 : for (sal_uInt32 n = 0; n < nStartsCount; ++n)
2021 [ # # ]: 0 : mpDoc->insertCpAndFc(getStartCpAndFc(n));
2022 : : }
2023 : :
2024 : : {
2025 : 0 : sal_uInt32 nEndsCount = mpEndCps->getCount() / 4;
2026 : :
2027 [ # # ]: 0 : for (sal_uInt32 n = 0; n < nEndsCount; ++n)
2028 [ # # ]: 0 : mpDoc->insertCpAndFc(getEndCpAndFc(n));
2029 : : }
2030 : 0 : }
2031 : :
2032 : : writerfilter::Reference<Properties>::Pointer_t
2033 : 0 : BookmarkHelper::getBKF(const CpAndFc & rCpAndFc)
2034 : : {
2035 : 0 : sal_uInt32 nIndex = getIndex(rCpAndFc);
2036 : :
2037 : : return writerfilter::Reference<Properties>::Pointer_t
2038 : 0 : (mpStartCps->getEntryPointer(nIndex));
2039 : : }
2040 : :
2041 : : writerfilter::Reference<Properties>::Pointer_t
2042 : 0 : BookmarkHelper::getBookmark(const CpAndFc & rCpAndFc)
2043 : : {
2044 : 0 : writerfilter::Reference<Properties>::Pointer_t pResult;
2045 : :
2046 : : try
2047 : : {
2048 [ # # ]: 0 : OUString aName = getName(rCpAndFc);
2049 : :
2050 : : pResult = writerfilter::Reference<Properties>::Pointer_t
2051 [ # # ][ # # ]: 0 : (new Bookmark(getBKF(rCpAndFc), aName));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2052 : : }
2053 [ # # # # ]: 0 : catch (const ExceptionNotFound &e)
2054 : : {
2055 [ # # # # ]: 0 : clog << e.getText() << endl;
2056 : : }
2057 : :
2058 : 0 : return pResult;
2059 : : }
2060 : :
2061 : 0 : OUString BookmarkHelper::getName(const CpAndFc & rCpAndFc)
2062 : : {
2063 : 0 : OUString sResult;
2064 : :
2065 [ # # ]: 0 : sal_uInt32 nIndex = getIndex(rCpAndFc);
2066 : :
2067 [ # # ]: 0 : sResult = getName(nIndex);
2068 : :
2069 : 0 : return sResult;
2070 : : }
2071 : :
2072 : : template <class T, class Helper>
2073 : : struct ProcessPLCF2Map
2074 : : {
2075 : 0 : void process(typename PLCF<T>::Pointer_t pPlcf,
2076 : : typename Helper::Map_t & rMap,
2077 : : PropertyType type,
2078 : : WW8DocumentImpl * pDoc)
2079 : : {
2080 [ # # ][ # # ]: 0 : if (pPlcf.get() != NULL)
[ # # ]
2081 : : {
2082 : 0 : sal_uInt32 nCount = pPlcf->getEntryCount();
2083 : :
2084 [ # # ][ # # ]: 0 : for (sal_uInt32 n = 0; n < nCount; n++)
[ # # ]
2085 : : {
2086 [ # # ][ # # ]: 0 : Cp aCp(pPlcf->getFc(n));
[ # # ]
2087 [ # # # # : 0 : CpAndFc aCpAndFc(pDoc->getCpAndFc(aCp, type));
# # ]
2088 [ # # ][ # # ]: 0 : typename T::Pointer_t pT = pPlcf->getEntry(n);
[ # # ]
2089 : :
2090 [ # # ][ # # ]: 0 : rMap[aCpAndFc] = pT;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2091 : : }
2092 : : }
2093 : 0 : }
2094 : : };
2095 : :
2096 : 0 : FieldHelper::FieldHelper(PLCF<WW8FLD>::Pointer_t pPlcffldMom,
2097 : : WW8DocumentImpl * pDoc)
2098 [ # # ]: 0 : : mpDoc(pDoc)
2099 : : {
2100 : : ProcessPLCF2Map<WW8FLD, FieldHelper> process;
2101 [ # # ][ # # ]: 0 : process.process(pPlcffldMom, mMap, PROP_FLD, pDoc);
[ # # ]
2102 : 0 : }
2103 : :
2104 : 0 : void FieldHelper::init()
2105 : : {
2106 : 0 : Map_t::iterator aIt;
2107 : :
2108 [ # # ][ # # ]: 0 : for (aIt = mMap.begin(); aIt != mMap.end(); ++aIt)
2109 : : {
2110 [ # # ][ # # ]: 0 : mpDoc->insertCpAndFc(aIt->first);
2111 : : }
2112 : 0 : }
2113 : :
2114 : 0 : WW8FLD::Pointer_t FieldHelper::getWW8FLD(const CpAndFc & rCpAndFc)
2115 : : {
2116 : 0 : WW8FLD::Pointer_t pFld = mMap[rCpAndFc];
2117 : :
2118 : 0 : return pFld;
2119 : : }
2120 : :
2121 : : writerfilter::Reference<Properties>::Pointer_t
2122 : 0 : FieldHelper::getField(const CpAndFc & rCpAndFc)
2123 : : {
2124 [ # # ]: 0 : WW8FLD::Pointer_t pFLD = getWW8FLD(rCpAndFc);
2125 : :
2126 : : return writerfilter::Reference<Properties>::Pointer_t
2127 [ # # ][ # # ]: 0 : (new WW8FLD(*pFLD));
[ # # ][ # # ]
2128 : : }
2129 : :
2130 : 0 : ShapeHelper::ShapeHelper(PLCF<WW8FSPA>::Pointer_t pPlcspaMom,
2131 : : PLCF<WW8FSPA>::Pointer_t pPlcspaHdr,
2132 : : WW8DocumentImpl * pDoc)
2133 [ # # ]: 0 : : mpDoc(pDoc)
2134 : : {
2135 : : ProcessPLCF2Map<WW8FSPA, ShapeHelper> process;
2136 [ # # ][ # # ]: 0 : process.process(pPlcspaMom, mMap, PROP_SHP, pDoc);
[ # # ]
2137 [ # # ][ # # ]: 0 : process.process(pPlcspaHdr, mMap, PROP_SHP, pDoc);
[ # # ]
2138 : 0 : }
2139 : :
2140 : 0 : void ShapeHelper::init()
2141 : : {
2142 : 0 : Map_t::iterator aIt;
2143 : :
2144 [ # # ][ # # ]: 0 : for (aIt = mMap.begin(); aIt != mMap.end(); ++aIt)
2145 : : {
2146 [ # # ][ # # ]: 0 : mpDoc->insertCpAndFc(aIt->first);
2147 [ # # ][ # # ]: 0 : aIt->second->setDocument(mpDoc);
2148 : : }
2149 : 0 : }
2150 : :
2151 : : writerfilter::Reference<Properties>::Pointer_t
2152 : 0 : ShapeHelper::getShape(const CpAndFc & rCpAndFc)
2153 : : {
2154 [ # # ][ # # ]: 0 : WW8FSPA::Pointer_t pFSPA = mMap[rCpAndFc];
2155 : :
2156 : : return writerfilter::Reference<Properties>::Pointer_t
2157 [ # # ][ # # ]: 0 : (new WW8FSPA(*pFSPA));
[ # # ][ # # ]
2158 : : }
2159 : :
2160 : 0 : BreakHelper::BreakHelper(PLCF<WW8BKD>::Pointer_t pPlcfbkdMom,
2161 : : WW8DocumentImpl * pDoc)
2162 [ # # ]: 0 : : mpDoc(pDoc)
2163 : : {
2164 : : ProcessPLCF2Map<WW8BKD, BreakHelper> process;
2165 [ # # ][ # # ]: 0 : process.process(pPlcfbkdMom, mMap, PROP_BRK, pDoc);
[ # # ]
2166 : 0 : }
2167 : :
2168 : 0 : void BreakHelper::init()
2169 : : {
2170 : 0 : Map_t::iterator aIt;
2171 : :
2172 [ # # ][ # # ]: 0 : for (aIt = mMap.begin(); aIt != mMap.end(); ++aIt)
2173 : : {
2174 [ # # ][ # # ]: 0 : mpDoc->insertCpAndFc(aIt->first);
2175 : : }
2176 : 0 : }
2177 : :
2178 : : writerfilter::Reference<Properties>::Pointer_t
2179 : 0 : BreakHelper::getBreak(const CpAndFc & rCpAndFc)
2180 : : {
2181 [ # # ][ # # ]: 0 : WW8BKD::Pointer_t pBKD = mMap[rCpAndFc];
2182 : :
2183 : : return writerfilter::Reference<Properties>::Pointer_t
2184 [ # # ][ # # ]: 0 : (new WW8BKD(*pBKD));
[ # # ][ # # ]
2185 : : }
2186 : :
2187 : :
2188 [ + - ][ + - ]: 60 : }}
2189 : :
2190 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|