Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * The Contents of this file are made available subject to the terms of
5 : : * either of the following licenses
6 : : *
7 : : * - GNU Lesser General Public License Version 2.1
8 : : * - Sun Industry Standards Source License Version 1.1
9 : : *
10 : : * Sun Microsystems Inc., October, 2000
11 : : *
12 : : * GNU Lesser General Public License Version 2.1
13 : : * =============================================
14 : : * Copyright 2000 by Sun Microsystems, Inc.
15 : : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : : *
17 : : * This library is free software; you can redistribute it and/or
18 : : * modify it under the terms of the GNU Lesser General Public
19 : : * License version 2.1, as published by the Free Software Foundation.
20 : : *
21 : : * This library is distributed in the hope that it will be useful,
22 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : : * Lesser General Public License for more details.
25 : : *
26 : : * You should have received a copy of the GNU Lesser General Public
27 : : * License along with this library; if not, write to the Free Software
28 : : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : : * MA 02111-1307 USA
30 : : *
31 : : *
32 : : * Sun Industry Standards Source License Version 1.1
33 : : * =================================================
34 : : * The contents of this file are subject to the Sun Industry Standards
35 : : * Source License Version 1.1 (the "License"); You may not use this file
36 : : * except in compliance with the License. You may obtain a copy of the
37 : : * License at http://www.openoffice.org/license.html.
38 : : *
39 : : * Software provided under this License is provided on an "AS IS" basis,
40 : : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : : * See the License for the specific provisions governing your rights and
44 : : * obligations concerning the Software.
45 : : *
46 : : * The Initial Developer of the Original Code is: IBM Corporation
47 : : *
48 : : * Copyright: 2008 by IBM Corporation
49 : : *
50 : : * All Rights Reserved.
51 : : *
52 : : * Contributor(s): _______________________________________
53 : : *
54 : : *
55 : : ************************************************************************/
56 : : /*************************************************************************
57 : : * @file
58 : : * For LWP filter architecture prototype
59 : : ************************************************************************/
60 : : /*************************************************************************
61 : : * Change History
62 : : Jan 2005 Created
63 : : ************************************************************************/
64 : :
65 : : #include "lwpfoundry.hxx"
66 : : #include "lwpfilehdr.hxx"
67 : : #include "lwpdoc.hxx"
68 : : #include "lwpmarker.hxx"
69 : : #include "lwpholder.hxx"
70 : : #include "lwpbulletstylemgr.hxx"
71 : : #include "lwpcontent.hxx"
72 : : #include "lwpvpointer.hxx"
73 : : #include "lwpsection.hxx"
74 : : #include "lwpcharacterstyle.hxx"
75 : : #include "lwpglobalmgr.hxx"
76 : :
77 : 27 : LwpFoundry::LwpFoundry(LwpObjectStream *pStrm, LwpDocument* pDoc)
78 : : : m_pDoc(pDoc)
79 : : , m_bRegisteredAll(false)
80 : : , m_pPieceMgr(NULL)
81 [ + - ][ + - ]: 27 : , m_pStyleMgr(NULL)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
82 : : {
83 [ + - ]: 27 : Read(pStrm);
84 [ + - ][ + - ]: 27 : m_pDropcapMgr = new LwpDropcapMgr;
85 [ + - ][ + - ]: 27 : m_pBulletStyleMgr = new LwpBulletStyleMgr();
86 : 27 : m_pBulletStyleMgr->SetFoundry(this);
87 : 27 : }
88 : :
89 [ + - ]: 24 : LwpFoundry::~LwpFoundry()
90 : : {
91 [ + + ]: 24 : if(m_pPieceMgr)
92 : : {
93 [ + - ]: 12 : delete m_pPieceMgr;
94 : : }
95 [ + - ]: 24 : if(m_pStyleMgr)
96 : : {
97 [ + - ][ + - ]: 24 : delete m_pStyleMgr;
98 : : }
99 [ + - ]: 24 : if (m_pDropcapMgr)
100 [ + - ][ + - ]: 24 : delete m_pDropcapMgr;
101 [ + - ]: 24 : if (m_pBulletStyleMgr)
102 : : {
103 [ + - ][ + - ]: 24 : delete m_pBulletStyleMgr;
104 : : }
105 : 24 : }
106 : :
107 : 27 : void LwpFoundry::Read(LwpObjectStream *pStrm)
108 : : {
109 [ + + ]: 27 : if (!m_pDoc->IsChildDoc())
110 : : {
111 : 15 : m_VerMgr.Read(pStrm);
112 : : }
113 : 27 : m_ObjMgr.Read(pStrm);
114 : :
115 : 27 : m_MarkerHead.ReadIndexed(pStrm);
116 : 27 : m_FootnoteMgr.ReadIndexed(pStrm);
117 : :
118 : 27 : m_NumMgr.Read(pStrm);
119 : 27 : m_BulMgr.Read(pStrm);
120 : :
121 : 27 : m_SectionList.Read(pStrm);
122 : 27 : m_Layout.ReadIndexed(pStrm);
123 : :
124 : 27 : ReadStyles(pStrm);
125 : :
126 : 27 : m_BookMarkHead.ReadIndexed(pStrm);
127 : 27 : m_DdeLinkHead.ReadIndexed(pStrm);
128 : 27 : m_DirtBagHead.ReadIndexed(pStrm);
129 : 27 : m_NamedOutlineSeqHead.ReadIndexed(pStrm);
130 : :
131 : 27 : m_EnumLayoutHead.ReadIndexed(pStrm);
132 : 27 : m_EnumLayoutTail.ReadIndexed(pStrm);
133 : 27 : m_NamedObjects.ReadIndexed(pStrm);
134 : :
135 : 27 : m_nLastClickHere = pStrm->QuickReaduInt32();
136 : 27 : m_SmartTextMgr.ReadIndexed(pStrm);
137 : :
138 : 27 : m_ContentMgr.Read(pStrm);
139 : 27 : m_FontMgr.Read(pStrm);
140 : :
141 [ + - ][ + + ]: 27 : if (!m_pDoc->IsChildDoc() && LwpFileHeader::m_nFileRevision >= 0x000B)
[ + + ]
142 : : {
143 [ + - ]: 15 : m_pPieceMgr = new LwpPieceManager();
144 : :
145 : 15 : m_pPieceMgr->Read(pStrm);
146 : : }
147 : :
148 [ + - ]: 27 : if( LwpFileHeader::m_nFileRevision >= 0x000B)
149 : : {
150 : 27 : m_DftDropCapStyle.ReadIndexed(pStrm);
151 : : }
152 [ + - ]: 27 : if( LwpFileHeader::m_nFileRevision >= 0x000F)
153 : : {
154 : 27 : m_DftHeaderStyle.ReadIndexed(pStrm);
155 : 27 : m_DftFooterStyle.ReadIndexed(pStrm);
156 : : }
157 : 27 : pStrm->SkipExtra();
158 : :
159 [ + - ]: 27 : m_pStyleMgr = new LwpStyleManager();
160 : 27 : m_pStyleMgr->SetFoundry(this);
161 : 27 : }
162 : :
163 : :
164 : 27 : void LwpFoundry::ReadStyles(LwpObjectStream *pStrm)
165 : : {
166 : 27 : m_TextStyle.ReadIndexed(pStrm);
167 : 27 : m_DefaultTextStyle.ReadIndexed(pStrm);
168 : 27 : m_DefaultClickStyle.ReadIndexed(pStrm);
169 : 27 : m_PageStyle.ReadIndexed(pStrm);
170 : 27 : m_FrameStyle.ReadIndexed(pStrm);
171 : :
172 : 27 : m_TableStyle.ReadIndexed(pStrm);
173 : 27 : m_CellStyle.ReadIndexed(pStrm);
174 : 27 : m_DftFrameStyle.ReadIndexed(pStrm);
175 : 27 : m_DftPageStyle.ReadIndexed(pStrm);
176 : 27 : m_DftTableStyle.ReadIndexed(pStrm);
177 : :
178 : 27 : m_DftCellStyle.ReadIndexed(pStrm);
179 : 27 : m_DftColumnStyle.ReadIndexed(pStrm);
180 : 27 : m_DftLeftColumnStyle.ReadIndexed(pStrm);
181 : 27 : m_DftRighColumnStyle.ReadIndexed(pStrm);
182 : :
183 : 27 : }
184 : :
185 : : #include "xfilter/xfstylemanager.hxx"
186 : : #include "lwplayout.hxx"
187 : :
188 : 24 : void LwpFoundry::RegisterAllLayouts()
189 : : {
190 [ - + ]: 24 : if (m_bRegisteredAll)
191 : : {
192 : : OSL_FAIL("recursive LwpFoundry::RegisterAllLayouts!\n");
193 : 24 : return;
194 : : }
195 : :
196 : 24 : m_bRegisteredAll = true;
197 : :
198 : : //Register CellStyle
199 : 24 : LwpObject* pStyle = m_CellStyle.obj();
200 [ + - ]: 24 : if( pStyle )
201 : : {
202 : 24 : pStyle->SetFoundry(this);
203 : 24 : pStyle->RegisterStyle();
204 : : }
205 : :
206 : : //register content page layout list: Layout
207 : 24 : pStyle = m_Layout.obj();
208 [ + - ]: 24 : if( pStyle )
209 : : {
210 : 24 : pStyle->SetFoundry(this);
211 : 24 : pStyle->RegisterStyle();
212 : : }
213 : :
214 : : //Register page style layout list: PageStyle, such as "Default Page"
215 : 24 : pStyle = m_PageStyle.obj();
216 [ + - ]: 24 : if( pStyle )
217 : : {
218 : 24 : pStyle->SetFoundry(this);
219 : 24 : pStyle->RegisterStyle();
220 : : }
221 : :
222 : : //Register FrameStyle
223 : 24 : pStyle = m_FrameStyle.obj();
224 [ + - ]: 24 : if( pStyle )
225 : : {
226 : 24 : pStyle->SetFoundry(this);
227 : 24 : pStyle->RegisterStyle();
228 : : }
229 : :
230 : : }
231 : :
232 : 0 : LwpBookMark* LwpFoundry::GetBookMark(LwpObjectID objMarker)
233 : : {
234 : : LwpDLVListHeadHolder* pHeadHolder= static_cast
235 : 0 : <LwpDLVListHeadHolder*>(m_BookMarkHead.obj());
236 : 0 : LwpObjectID* pObjID = pHeadHolder->GetHeadID();
237 : : LwpBookMark* pBookMark;
238 [ # # ]: 0 : if (pObjID)
239 : 0 : pBookMark = static_cast<LwpBookMark*>(pObjID->obj());
240 : : else
241 : 0 : return NULL;
242 : :
243 [ # # ]: 0 : while (pBookMark)
244 : : {
245 [ # # ]: 0 : if (pBookMark->IsRightMarker(objMarker))
246 : 0 : return pBookMark;
247 : 0 : pObjID = pBookMark->GetNext();
248 [ # # ]: 0 : if (pObjID)
249 : 0 : pBookMark = static_cast<LwpBookMark*>(pObjID->obj());
250 : : else
251 : 0 : return NULL;
252 : : }
253 : 0 : return NULL;
254 : : }
255 : :
256 : : /**
257 : : * @descr: Get next content
258 : : *
259 : : */
260 : 0 : LwpContent* LwpFoundry::EnumContents(LwpContent * pContent)
261 : : {
262 : 0 : return GetContentManager()->EnumContents(pContent);
263 : : }
264 : :
265 : : /**
266 : : * @descr: Get next section
267 : : *
268 : : */
269 : 0 : LwpSection* LwpFoundry::EnumSections(LwpSection * pSection)
270 : : {
271 : 0 : return static_cast<LwpSection*>(m_SectionList.Enumerate(pSection));
272 : : }
273 : :
274 : : /**
275 : : * @descr: Get default text style id
276 : : *
277 : : */
278 : 0 : LwpObjectID * LwpFoundry::GetDefaultTextStyle()
279 : : {
280 : 0 : LwpVersionedPointer * pPointer = static_cast<LwpVersionedPointer *>(m_DefaultTextStyle.obj());
281 [ # # ]: 0 : if (!pPointer)
282 : 0 : return NULL;
283 : :
284 : 0 : return pPointer->GetPointer();
285 : : }
286 : :
287 : : /**
288 : : * @descr: Get paragraph style object id according to its style name
289 : : *
290 : : */
291 : 0 : LwpObjectID * LwpFoundry::FindParaStyleByName(OUString name)
292 : : {
293 : : //Register all text styles: para styles, character styles
294 : 0 : LwpDLVListHeadHolder* pParaStyleHolder = static_cast<LwpDLVListHeadHolder*>(GetTextStyleHead()->obj());
295 [ # # ]: 0 : if(pParaStyleHolder)
296 : : {
297 : 0 : LwpTextStyle* pParaStyle = static_cast<LwpTextStyle*> (pParaStyleHolder->GetHeadID()->obj());
298 [ # # ]: 0 : while(pParaStyle)
299 : : {
300 : 0 : OUString strName = pParaStyle->GetName()->str();
301 [ # # ]: 0 : if(strName == name)
302 : 0 : return pParaStyle->GetObjectID();
303 [ # # ][ # # ]: 0 : pParaStyle = static_cast<LwpTextStyle*>(pParaStyle->GetNext()->obj());
304 : 0 : }
305 : : }
306 : :
307 : 0 : return NULL;
308 : : }
309 : :
310 : : /**
311 : : * @descr: Get style name registered according the original style name
312 : : *
313 : : */
314 : 0 : OUString LwpFoundry::FindActuralStyleName(OUString name)
315 : : {
316 [ # # ]: 0 : LwpObjectID* pID = FindParaStyleByName(name);
317 [ # # ]: 0 : if(pID)
318 : : {
319 : 0 : IXFStyle* pStyle = GetStyleManager()->GetStyle(*pID);
320 [ # # ]: 0 : if(pStyle)
321 : : {
322 : 0 : return pStyle->GetStyleName();
323 : : }
324 : : }
325 : :
326 : 0 : return name;
327 : : }
328 : :
329 : 15 : void LwpVersionManager::Read(LwpObjectStream *pStrm)
330 : : {
331 : : // TODO: skip the data for prototype
332 : 15 : Skip(pStrm);
333 : 15 : }
334 : :
335 : 15 : void LwpVersionManager::Skip(LwpObjectStream *pStrm)
336 : : {
337 : 15 : pStrm->QuickReaduInt32();
338 : 15 : sal_uInt16 Count = pStrm->QuickReaduInt16();
339 : :
340 [ + + ]: 30 : while(Count--)
341 : : {
342 : 15 : sal_uInt32 tag = pStrm->QuickReaduInt32();
343 [ + - ]: 15 : switch(tag)
344 : : {
345 : : case TAG_USER_VERSION:
346 : : // TODO: skip the CUserVersionControl
347 : 15 : pStrm->SeekRel(pStrm->QuickReaduInt16());
348 : 15 : break;
349 : :
350 : : default:
351 : 0 : pStrm->SeekRel(pStrm->QuickReaduInt16());
352 : 0 : pStrm->SkipExtra();
353 : 0 : break;
354 : : }
355 : : }
356 : 15 : pStrm->SkipExtra();
357 : 15 : }
358 : :
359 : 27 : void LwpObjectManager::Read(LwpObjectStream *pStrm)
360 : : {
361 : :
362 [ + - ]: 27 : LwpObjectID dummy;
363 [ + - ]: 27 : dummy.Read(pStrm);
364 : : // TODO: judge if we need to set the cDelta by the dummy id
365 : :
366 [ + - ]: 27 : m_Division.ReadIndexed(pStrm);
367 [ + - ]: 27 : pStrm->SkipExtra();
368 : 27 : }
369 : :
370 : 27 : void LwpNumberManager::Read(LwpObjectStream *pStrm)
371 : : {
372 : 27 : m_TableRange.ReadIndexed(pStrm);
373 : 27 : pStrm->SkipExtra();
374 : 27 : }
375 : :
376 : 27 : void LwpBulletManager::Read(LwpObjectStream *pStrm)
377 : : {
378 : 27 : m_Head.ReadIndexed(pStrm);
379 : 27 : pStrm->SkipExtra();
380 : 27 : }
381 : :
382 : 27 : void LwpContentManager::Read(LwpObjectStream *pStrm)
383 : : {
384 : 27 : m_ContentList.ReadIndexed(pStrm);
385 : :
386 : : // TODO: to judge the file revision
387 : :
388 : 27 : m_EnumHead.ReadIndexed(pStrm);
389 : 27 : m_EnumTail.ReadIndexed(pStrm);
390 : :
391 : 27 : m_OleObjCount.ReadIndexed(pStrm);
392 : :
393 [ + - ]: 27 : if( LwpFileHeader::m_nFileRevision >= 0x000B)
394 : : {
395 : 27 : m_GrapHead.ReadIndexed(pStrm);
396 : 27 : m_GrapTail.ReadIndexed(pStrm);
397 : 27 : m_OleHead.ReadIndexed(pStrm);
398 : 27 : m_OleTail.ReadIndexed(pStrm);
399 : : }
400 : :
401 : 27 : pStrm->SkipExtra();
402 : 27 : }
403 : :
404 : : /**
405 : : * @descr: Get next content
406 : : *
407 : : */
408 : 0 : LwpContent* LwpContentManager::EnumContents(LwpContent* pContent)
409 : : {
410 [ # # ]: 0 : if(pContent)
411 : 0 : return pContent->GetNextEnumerated();
412 : 0 : LwpVersionedPointer* pPointer = static_cast<LwpVersionedPointer*>(m_EnumHead.obj());
413 [ # # ]: 0 : return pPointer ? static_cast<LwpContent*>(pPointer->GetPointer()->obj()) : NULL;
414 : : }
415 : :
416 : 15 : void LwpPieceManager::Read(LwpObjectStream *pStrm)
417 : : {
418 : 15 : m_GeometryPieceList.ReadIndexed(pStrm);
419 : 15 : m_ScalePieceList.ReadIndexed(pStrm);
420 : 15 : m_MarginsPieceList.ReadIndexed(pStrm);
421 : 15 : m_ColumnsPieceList.ReadIndexed(pStrm);
422 : 15 : m_BorderStuffPieceList.ReadIndexed(pStrm);
423 : :
424 : 15 : m_GutterStuffPieceList.ReadIndexed(pStrm);
425 : 15 : m_BackgroundStuffPieceList.ReadIndexed(pStrm);
426 : 15 : m_JoinStuffPieceList.ReadIndexed(pStrm);
427 : 15 : m_ShadowPieceList.ReadIndexed(pStrm);
428 : 15 : m_NumericsPieceList.ReadIndexed(pStrm);
429 : :
430 : 15 : m_RelativityPieceList.ReadIndexed(pStrm);
431 : 15 : m_AlignmentPieceList.ReadIndexed(pStrm);
432 : 15 : m_IndentPieceList.ReadIndexed(pStrm);
433 : 15 : m_ParaBorderPieceList.ReadIndexed(pStrm);
434 : 15 : m_SpacingPieceList.ReadIndexed(pStrm);
435 : :
436 : 15 : m_BreaksPieceList.ReadIndexed(pStrm);
437 : 15 : m_NumberingPieceList.ReadIndexed(pStrm);
438 : 15 : m_TabPieceList.ReadIndexed(pStrm);
439 : 15 : m_CharacterBorderPieceList.ReadIndexed(pStrm);
440 : 15 : m_AmikakePieceList.ReadIndexed(pStrm);
441 : :
442 [ + + ]: 15 : if(pStrm->CheckExtra())
443 : : {
444 : 12 : m_ParaBackgroundPieceList.ReadIndexed(pStrm);
445 : 12 : m_ExternalBorderStuffPieceList.ReadIndexed(pStrm);
446 : 12 : m_ExternalJoinStuffPieceList.ReadIndexed(pStrm);
447 : 12 : pStrm->SkipExtra();
448 : : }
449 : 15 : }
450 : :
451 : 27 : void LwpOrderedObjectManager::Read(LwpObjectStream *pStrm)
452 : : {
453 : 27 : m_Head.ReadIndexed(pStrm);
454 : 27 : }
455 : :
456 : : /**
457 : : * @descr: Get next orderedobject, copy from lwp source code
458 : : *
459 : : */
460 : 0 : LwpOrderedObject* LwpOrderedObjectManager::Enumerate(LwpOrderedObject * pLast)
461 : : {
462 : : // If Last has a next, return it.
463 [ # # ][ # # ]: 0 : if(pLast && !pLast->GetNext()->IsNull())
[ # # ]
464 : 0 : return static_cast<LwpOrderedObject*>(pLast->GetNext()->obj());
465 : :
466 : 0 : LwpListList* pList = NULL;
467 [ # # ]: 0 : if(pLast)
468 : : {
469 : : // We're at the end of Last's list (not Liszt's list).
470 : : // Start with the next active list
471 : 0 : pList = static_cast<LwpListList*>(pLast->GetListList()->obj());
472 : 0 : pList= GetNextActiveListList(pList);
473 : : }
474 : : else
475 : : {
476 : : // Start with the first active ListList
477 : 0 : pList = GetNextActiveListList(NULL);
478 : : }
479 : :
480 [ # # ]: 0 : if(pList)
481 : : {
482 : 0 : return static_cast<LwpOrderedObject*>(pList->GetHead()->obj());
483 : : }
484 : :
485 : 0 : return NULL;
486 : : }
487 : :
488 : : /**
489 : : * @descr: Get next listlist object, copy from lwp source code
490 : : *
491 : : */
492 : 0 : LwpListList* LwpOrderedObjectManager::GetNextActiveListList(LwpListList * pLast)
493 : : {
494 : 0 : LwpListList* pList = NULL;
495 : 0 : LwpContent* pContent = NULL;
496 [ # # ]: 0 : if(pLast)
497 : 0 : pList = static_cast<LwpListList*>(pLast->GetNext()->obj());
498 : : else
499 : : {
500 : 0 : LwpDLVListHeadHolder* pHeadHolder= static_cast<LwpDLVListHeadHolder*>(m_Head.obj());
501 [ # # ]: 0 : if(pHeadHolder)
502 : : {
503 : 0 : pList = static_cast<LwpListList*>(pHeadHolder->GetHeadID()->obj());
504 : : }
505 : : }
506 : :
507 [ # # ]: 0 : while(pList)
508 : : {
509 : 0 : pContent = static_cast<LwpContent*>(pList->GetObject()->obj());
510 [ # # # # ]: 0 : if(pContent && pContent->HasNonEmbeddedLayouts() &&
[ # # ][ # # ]
511 : 0 : !pContent->IsStyleContent())
512 : 0 : return pList;
513 : 0 : pList = static_cast<LwpListList*>(pList->GetNext()->obj());
514 : : }
515 : 0 : return NULL;
516 : : }
517 : :
518 : 27 : LwpStyleManager::LwpStyleManager()
519 [ + - ]: 27 : : m_pFoundry(0)
520 : : {
521 : 27 : }
522 : :
523 : 24 : LwpStyleManager::~LwpStyleManager()
524 : : {
525 [ + - ]: 24 : m_StyleList.clear();
526 : 24 : }
527 : :
528 : :
529 : : #include "xfilter/xfstylemanager.hxx"
530 : : /*
531 : : VO_PARASTYLE/VO_CHARACTERSTYLE call this method to add its created style to XFStyleManager
532 : : 1. Add the style to XFStyleManager, and return the <office:styles> style name
533 : : 2. Add it to LwpParaStyleMap.
534 : : Prerequisite: pStyle has been created and all properties has been set to it.
535 : : Return the XFStyle* added by XFStyleManager
536 : : */
537 : 204 : IXFStyle* LwpStyleManager::AddStyle(LwpObjectID styleObjID, IXFStyle* pStyle)
538 : : {
539 : : assert(pStyle);
540 : : //pStyle may change if same style is found in XFStyleManager
541 : 204 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
542 : 204 : pStyle = pXFStyleManager->AddStyle(pStyle);
543 [ + - ]: 204 : m_StyleList.insert(LwpStyleMap::value_type(styleObjID, pStyle));
544 : 204 : return pStyle;
545 : : }
546 : :
547 : : /*
548 : : Called by VO_PARA or other objects to get style name based on the Style object ID
549 : : 1) Get style from LwpParaStyleMap based on the LwpObjectID of VO_PARASTYLE.
550 : : Prerequisite: VO_PARASTYLE/VO_CHARACTERSTYLE should call AddStyle first.
551 : : Return empty string if no style found.
552 : : */
553 : 786 : IXFStyle* LwpStyleManager::GetStyle(const LwpObjectID &styleObjID)
554 : : {
555 [ + - ]: 786 : LwpStyleMap::const_iterator it = m_StyleList.find(styleObjID);
556 [ + - ][ + - ]: 786 : if (it != m_StyleList.end()) {
557 [ + - ]: 786 : return((*it).second);
558 : : }
559 : 786 : return NULL;
560 : : }
561 : :
562 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|