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 "lwppara.hxx"
66 : : #include "lwpglobalmgr.hxx"
67 : : #include "lwpfilehdr.hxx"
68 : : #include "lwpparaproperty.hxx"
69 : : #include "lwptools.hxx"
70 : : #include "lwpparastyle.hxx"
71 : : #include "xfilter/xffont.hxx"
72 : : #include "xfilter/xftextstyle.hxx"
73 : : #include "xfilter/xfstylemanager.hxx"
74 : : #include "xfilter/xfparagraph.hxx"
75 : : #include "xfilter/xftextcontent.hxx"
76 : : #include "xfilter/xftextspan.hxx"
77 : : #include "xfilter/xfmargins.hxx"
78 : : #include "xfilter/xftabstop.hxx"
79 : : #include "xfilter/xflinebreak.hxx"
80 : : #include "xfilter/xfsection.hxx"
81 : : #include "xfilter/xfsectionstyle.hxx"
82 : : #include "xfilter/xfcolor.hxx"
83 : : #include "xfilter/xfhyperlink.hxx"
84 : : #include "xfilter/xfliststyle.hxx"
85 : : #include "lwpcharsetmgr.hxx"
86 : : #include "lwpsection.hxx"
87 : : #include "lwplayout.hxx"
88 : : #include "lwpusewhen.hxx"
89 : : #include "lwpbulletstylemgr.hxx"
90 : : #include "lwpstory.hxx"
91 : : #include "lwpsilverbullet.hxx"
92 : : #include "xfilter/xflist.hxx"
93 : : #include "xfilter/xfframe.hxx"
94 : :
95 : : #include "lwpdivinfo.hxx"
96 : : #include "lwpdoc.hxx"
97 : : #include "lwpholder.hxx"
98 : : #include "lwppagehint.hxx"
99 : :
100 : : #include "lwpdropcapmgr.hxx"
101 : : #include "lwptable.hxx"
102 : :
103 : 795 : LwpPara::LwpPara(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
104 : : : LwpDLVList(objHdr, pStrm), m_pBreaks(NULL), m_pIndentOverride(NULL)
105 : : , m_bHasBullet(sal_False), m_pSilverBullet(NULL)
106 : : , /*m_pParaNumbering(NULL),*/ m_pBullOver(NULL)
107 : : , m_bBullContinue(sal_False)
108 : : , m_bHasDropcap(sal_False), m_nLines(0), m_nChars(0)
109 [ + - ][ + - ]: 795 : , m_pDropcapLayout(NULL), m_BelowSpacing(0), m_pXFContainer(NULL)
[ + - ][ + - ]
[ + - ]
110 : : {
111 : 795 : m_pProps = NULL;
112 : 795 : m_SectionStyleName = A2OUSTR("");
113 : 795 : m_AllText = A2OUSTR("");
114 : 795 : }
115 : :
116 [ + - ][ + - ]: 795 : LwpPara::~LwpPara()
117 : : {
118 : :
119 [ + + ]: 795 : if (m_pBreaks)
120 : : {
121 [ + - ][ + - ]: 381 : delete m_pBreaks;
122 : 381 : m_pBreaks = NULL;
123 : : }
124 : : /* if (m_pParaNumbering)
125 : : {
126 : : delete m_pParaNumbering;
127 : : m_pParaNumbering = NULL;
128 : : }*/
129 : :
130 [ + + ]: 795 : if (m_pBullOver)
131 : : {
132 [ + - ][ + - ]: 786 : delete m_pBullOver;
133 : 786 : m_pBullOver = NULL;
134 : : }
135 [ + + ]: 795 : if(m_pIndentOverride)
136 : : {
137 [ + - ][ + - ]: 777 : delete m_pIndentOverride;
138 : : }
139 : :
140 : : LwpParaProperty* pNextProp;
141 [ + + ]: 2004 : while(m_pProps)
142 : : {
143 : 1209 : pNextProp = m_pProps->GetNext();
144 [ + - ][ + - ]: 1209 : delete m_pProps;
145 : 1209 : m_pProps = pNextProp;
146 : : }
147 [ - + ]: 1590 : }
148 : :
149 : 795 : void LwpPara::Read()
150 : : {
151 : 795 : LwpDLVList::Read();
152 : :
153 : : sal_Bool Simple;
154 : 795 : sal_Bool Notify = sal_False;
155 [ - + ]: 795 : if(LwpFileHeader::m_nFileRevision<0x0006)
156 : 0 : Simple = sal_False;
157 [ - + ]: 795 : else if(LwpFileHeader::m_nFileRevision<0x000B)
158 : 0 : Simple = m_pObjStrm->QuickReaduInt8();
159 : : else
160 : : {
161 : 795 : sal_uInt8 Flag = m_pObjStrm->QuickReaduInt8();
162 : :
163 : 795 : const int DISK_SIMPLE = 1;
164 : 795 : const int DISK_NOTIFY = 2;
165 : :
166 : 795 : Simple = (Flag & DISK_SIMPLE) ? sal_True : sal_False;
167 [ + + ]: 795 : Notify = (Flag & DISK_NOTIFY) ? sal_True : sal_False;
168 : : }
169 : :
170 [ + + ]: 795 : if(!Simple)
171 : : {
172 : 777 : m_nOrdinal = m_pObjStrm->QuickReaduInt32();
173 [ + - ]: 777 : if(LwpFileHeader::m_nFileRevision<0x000B)
174 : : {
175 : : // TODO: to process
176 : : assert(false);
177 : : /*pCForked3NotifyList Notify = new CForked3NotifyList(this);
178 : : Notify->GetExtraList()->QuickRead(pFile);
179 : : Notify->QuickRead(pFile);
180 : : if(Notify->GetExtraList()->IsEmpty() &&
181 : : Notify->IsEmpty())
182 : : delete Notify;
183 : : else
184 : : cNotifyList = Notify;*/
185 : : }
186 : : else
187 : : {
188 [ + + ]: 777 : if (Notify)
189 : : {
190 [ + - ]: 132 : LwpForked3NotifyList* pNotifyList = new LwpForked3NotifyList();
191 : 132 : pNotifyList->GetExtraList()->Read(m_pObjStrm);
192 : 132 : pNotifyList->Read(m_pObjStrm);
193 : 132 : delete pNotifyList;
194 : : }
195 : : }
196 : : }
197 : : else
198 : 18 : m_nOrdinal = 0x0001;
199 : :
200 : 795 : m_nFlags = m_pObjStrm->QuickReaduInt16();
201 : 795 : m_ParaStyle.ReadIndexed(m_pObjStrm);
202 : :
203 [ + + ]: 795 : if(!Simple)
204 : : {
205 : 777 : m_Hint.Read(m_pObjStrm);
206 [ - + ]: 777 : if (IsBadHintsInFile())
207 : : {
208 : : // This hint is no good, so throw it away -- SDC 9/28/95
209 : 0 : m_Hint.Reset();
210 : : }
211 : : }
212 : :
213 : 795 : m_Story.ReadIndexed(m_pObjStrm);
214 [ + + ]: 795 : if(!Simple)
215 : : {
216 : 777 : if(LwpFileHeader::m_nFileRevision<0x000B)
217 : : {
218 : : // TODO: to process
219 : : assert(false);
220 : : /*PropList = new CParaPropListProperty(this);
221 : : PropList->GetList()->QuickRead(pFile);
222 : : if(PropList->GetList()->IsEmpty())
223 : : {
224 : : delete PropList;
225 : : PropList = LNULL;
226 : : }*/
227 : : }
228 : 777 : m_nLevel = m_pObjStrm->QuickReaduInt16();
229 : :
230 : : // test
231 [ - + ]: 777 : if (m_nLevel > 9)
232 : : {
233 : 0 : m_nLevel = 9;
234 : : }
235 : : // test ends
236 : : }
237 : : else
238 : 18 : m_nLevel = 0x0001;
239 : :
240 : 795 : m_Fribs.SetPara(this);//add by 2/1, for silver bullet
241 : 795 : m_Fribs.ReadPara(m_pObjStrm);
242 : :
243 : 795 : m_pProps = LwpParaProperty::ReadPropertyList(m_pObjStrm,this);
244 : 795 : }
245 : :
246 : 0 : void LwpPara::Parse(IXFStream* pOutputStream)
247 : : {
248 [ # # ]: 0 : m_pXFContainer = new XFContentContainer;
249 : 0 : XFConvert(m_pXFContainer);
250 : 0 : m_pXFContainer->ToXml(pOutputStream);
251 : 0 : m_pXFContainer->Reset();
252 [ # # ]: 0 : delete m_pXFContainer;
253 : 0 : m_pXFContainer = NULL;
254 : 0 : }
255 : :
256 : 447 : void LwpPara::XFConvert(XFContentContainer* pCont)
257 : : {
258 : 447 : m_pXFContainer = pCont;
259 : :
260 [ - + ]: 447 : LwpStory *pStory = dynamic_cast<LwpStory*>(m_Story.obj());
261 : :
262 [ + - ][ - + ]: 447 : if (pStory && pStory->GetDropcapFlag() == sal_True)
[ - + ]
263 : : {
264 : 0 : ParseDropcapContent();
265 : 447 : return;
266 : : }
267 : :
268 : : //Add the break before para
269 [ + + ][ + - ]: 447 : if (m_pBreaks && m_nOrdinal!=0)
270 : 192 : AddBreakBefore(pCont);
271 : :
272 : : //Create an XFPara for this VO_PARA
273 [ + - ]: 447 : XFParagraph *pPara = new XFParagraph;
274 [ + - ]: 447 : pPara->SetStyleName(m_StyleName);
275 : :
276 [ - + ]: 447 : if(!m_SectionStyleName.isEmpty())
277 : : {
278 : 0 : XFSection* pSection = CreateXFSection();
279 [ # # ]: 0 : if (pStory)
280 : 0 : pStory->AddXFContent(pSection);
281 : : //pSection->Add(pPara);
282 : 0 : m_pXFContainer = pSection;
283 : : }
284 : :
285 [ + + ][ + - ]: 447 : if (m_bHasBullet && m_pSilverBullet)
286 : : {
287 : 15 : XFContentContainer* pListItem = AddBulletList(m_pXFContainer);
288 [ + - ]: 15 : if (pListItem)
289 : : {
290 : 15 : pListItem->Add(pPara);
291 : 15 : }
292 : : }
293 : : else
294 : : {
295 : 432 : LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
296 [ + - ]: 432 : if (pBulletStyleMgr)
297 : : {
298 : 432 : pBulletStyleMgr->SetCurrentSilverBullet(LwpObjectID());
299 : 432 : pBulletStyleMgr->SetContinueFlag(sal_False);
300 : : }
301 : 432 : m_pXFContainer->Add(pPara);
302 : : }
303 : :
304 : 447 : m_Fribs.SetXFPara(pPara);
305 : 447 : m_Fribs.XFConvert();
306 : :
307 [ + + ]: 447 : if (m_pBreaks)
308 : 192 : AddBreakAfter(m_pXFContainer);
309 : : }
310 : :
311 : 786 : sal_Bool LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle)
312 : : {
313 : 786 : sal_Bool bSuccess = sal_False;
314 : : //get story
315 [ - + ]: 786 : LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj());
316 : : //if pagelayout is modified, register the pagelayout
317 [ + + ][ + + ]: 786 : if(pStory && pStory->IsPMModified())
[ + + ]
318 : : {
319 : 12 : sal_Bool bNewSection = sal_False;
320 : 12 : bNewSection = pStory->IsNeedSection();
321 : 12 : LwpPageLayout* pLayout = pStory->GetCurrentLayout();
322 [ - + ]: 12 : if(bNewSection)
323 : : {
324 : 0 : RegisterNewSectionStyle(pLayout);
325 : : }
326 : :
327 : 12 : bSuccess = sal_True;
328 : : //register master page style
329 [ + - ]: 12 : XFParaStyle* pOverStyle = new XFParaStyle();
330 : 12 : *pOverStyle = *pBaseStyle;
331 [ + - ]: 12 : pOverStyle->SetStyleName( A2OUSTR(""));
332 : 12 : pOverStyle->SetMasterPage(pLayout->GetStyleName());
333 [ + - ]: 12 : if (!m_ParentStyleName.isEmpty())
334 : 12 : pOverStyle->SetParentStyleName(m_ParentStyleName);
335 : 12 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
336 : 12 : m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
337 : : }
338 : 786 : return bSuccess;
339 : : }
340 : : /**
341 : : * @short register paragraph style
342 : : */
343 : 786 : void LwpPara::RegisterStyle()
344 : : { //1 reg autostyle
345 : : // m_Fribs.SetPara(this);
346 : : // m_Fribs.RegisterStyle();
347 : :
348 : : //2 reg para style
349 [ - + ]: 786 : if (!m_pFoundry)
350 : 0 : return;
351 : 786 : XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(m_ParaStyle));
352 [ - + ]: 786 : if (pBaseStyle == NULL) return;
353 : 786 : m_StyleName = pBaseStyle->GetStyleName();//such intf to be added
354 : 786 : m_ParentStyleName = m_StyleName;
355 : 786 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
356 : :
357 [ + + ]: 786 : if (GetParaStyle()->GetIndent())
358 : : {
359 [ + - ][ + - ]: 690 : std::auto_ptr<LwpIndentOverride> pIndentOverride(GetParaStyle()->GetIndent()->clone());
[ + - ]
360 [ # # ][ - + ]: 690 : delete m_pIndentOverride;
361 [ + - ]: 690 : m_pIndentOverride = pIndentOverride.release();
362 : : }
363 : :
364 : 786 : XFParaStyle* pOverStyle = NULL;
365 : 786 : sal_Bool noSpacing = sal_True;
366 : 786 : sal_Bool noIndent = sal_True;
367 : 786 : LwpParaProperty* pBulletProps = NULL, *pNumberingProps = NULL;
368 : :
369 [ + + ]: 786 : if (m_pProps != NULL)
370 : : {
371 [ + - ]: 450 : pOverStyle = new XFParaStyle;
372 : 450 : *pOverStyle = *pBaseStyle;
373 [ + - ]: 450 : pOverStyle->SetStyleName(A2OUSTR(""));
374 : 450 : LwpParaProperty* pProps = m_pProps;
375 : : sal_uInt32 PropType;
376 [ - + ]: 450 : LwpParaStyle* pParaStyle = dynamic_cast<LwpParaStyle*>(m_ParaStyle.obj());
377 [ + + ]: 1659 : while(pProps)
378 : : {
379 : 1209 : PropType = pProps->GetType();
380 [ + + + + : 1209 : switch(PropType)
+ + + + +
- ]
381 : : {
382 : : case PP_LOCAL_ALIGN:
383 : : {
384 [ - + ]: 12 : if (!pParaStyle->GetAlignment())
385 : 0 : OverrideAlignment(NULL,static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),pOverStyle);
386 : : else
387 : : {
388 : : boost::scoped_ptr<LwpAlignmentOverride> const pAlign(
389 [ + - ][ + - ]: 12 : pParaStyle->GetAlignment()->clone());
390 : : OverrideAlignment(pAlign.get(),
391 : : static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),
392 [ + - ][ + - ]: 12 : pOverStyle);
393 : : }
394 : : }
395 : 12 : break;
396 : : case PP_LOCAL_INDENT:
397 : : {
398 : 390 : noIndent = sal_False;
399 [ + + ]: 390 : if (!pParaStyle->GetIndent())
400 : 87 : OverrideIndent(NULL,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
401 : :
402 : : else
403 : : {
404 : 303 : OverrideIndent(m_pIndentOverride,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
405 : : }
406 : : }
407 : 390 : break;
408 : : case PP_LOCAL_SPACING:
409 : : {
410 : 336 : noSpacing = sal_False;
411 [ - + ]: 336 : if (!pParaStyle->GetSpacing())
412 : 0 : OverrideSpacing(NULL,static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing(),pOverStyle);
413 : : else
414 : : {
415 : : boost::scoped_ptr<LwpSpacingOverride> const
416 [ + - ][ + - ]: 336 : pSpacing(pParaStyle->GetSpacing()->clone());
417 : : OverrideSpacing(pSpacing.get(),
418 : : static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing(),
419 [ + - ][ + - ]: 336 : pOverStyle);
420 : : }
421 : : }
422 : 336 : break;
423 : : // 01/25/2005
424 : : case PP_LOCAL_BORDER:
425 : : {
426 : 6 : OverrideParaBorder(pProps, pOverStyle);
427 : 6 : break;
428 : : }
429 : : case PP_LOCAL_BREAKS:
430 : : {
431 : 381 : OverrideParaBreaks(pProps, pOverStyle);
432 : 381 : break;
433 : : }
434 : : case PP_LOCAL_BULLET:
435 : : {
436 : 12 : pBulletProps = pProps;
437 : : // OverrideParaBullet(pProps);
438 : 12 : break;
439 : : }
440 : : case PP_LOCAL_NUMBERING:
441 : : {
442 : 12 : pNumberingProps = pProps;
443 : : // OverrideParaNumbering(pProps);
444 : 12 : break;
445 : : }
446 : : //end
447 : : case PP_LOCAL_TABRACK:
448 : : {
449 : : //, 01/28/05
450 : : /*LwpTabOverride* pTabOverride=pParaStyle->GetTabOverride();
451 : : if(!pTabOverride)
452 : : {
453 : : OverrideTab(NULL,static_cast<LwpParaTabRackProperty*>(pProps)->GetTab(),pOverStyle);
454 : : }
455 : : else
456 : : {
457 : : OverrideTab(pTabOverride,static_cast<LwpParaTabRackProperty*>(pProps)->GetTab(),pOverStyle);
458 : : }*/
459 : 6 : break;
460 : : }
461 : : case PP_LOCAL_BACKGROUND:
462 : : {
463 : : /* LwpBackgroundOverride aBackground;
464 : : if (!pParaStyle->GetBackground())
465 : : OverrideBackground(NULL,static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground(),pOverStyle);
466 : : else
467 : : {
468 : : aBackground = *(pParaStyle->GetaBackground());
469 : : OverrideBackground(&aBackground,static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground(),pOverStyle);
470 : : }
471 : : */
472 : : // modified by , 06/03/2005
473 : 54 : LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground();
474 [ + - ]: 54 : if (pBGOver)
475 : : {
476 : 54 : LwpBackgroundStuff* pBGStuff = pBGOver->GetBGStuff();
477 [ + + ][ + + ]: 54 : if (pBGStuff && !pBGStuff->IsTransparent() )
[ + - ]
478 : : {
479 [ - + ]: 6 : if (pBGStuff->IsPatternFill())
480 : : {
481 : 0 : XFBGImage* pXFBGImage = pBGStuff->GetFillPattern();
482 : 0 : pOverStyle->SetBackImage(pXFBGImage);
483 : : }
484 : : else
485 : : {
486 : 6 : LwpColor* pColor = pBGStuff->GetFillColor();
487 [ + - ][ + - ]: 6 : if (pColor && pColor->IsValidColor())
[ + - ]
488 : : {
489 [ + - ]: 6 : XFColor aXFColor( pColor->To24Color());
490 [ + - ]: 6 : pOverStyle->SetBackColor( aXFColor );
491 : : }
492 : : }
493 : : }
494 : : }
495 : : // end modified
496 : 54 : break;
497 : : }
498 : : default:
499 : 0 : break;
500 : : }
501 : 1209 : pProps = pProps->GetNext();
502 : : }
503 : :
504 [ + + ][ + + ]: 450 : if (noIndent && m_pIndentOverride)
505 : : {
506 [ - + ][ # # ]: 54 : if (m_pIndentOverride->IsUseRelative() && GetParent())
[ - + ]
507 : : {
508 : 0 : OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
509 : : }
510 : : }
511 [ + - ]: 450 : if (!m_ParentStyleName.isEmpty())
512 : 450 : pOverStyle->SetParentStyleName(m_ParentStyleName);
513 : 450 : m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
514 : :
515 : : }
516 : : else //use named style
517 : : {
518 [ + + ]: 336 : if (m_pIndentOverride)
519 : : {
520 [ - + ][ # # ]: 333 : if (m_pIndentOverride->IsUseRelative() && GetParent())
[ - + ]
521 : : {
522 [ # # ]: 0 : pOverStyle = new XFParaStyle;
523 : 0 : *pOverStyle = *pBaseStyle;
524 : 0 : OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
525 [ # # ]: 0 : if (!m_ParentStyleName.isEmpty())
526 : 0 : pOverStyle->SetParentStyleName(m_ParentStyleName);
527 : 0 : m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
528 : : }
529 : : }
530 : : }
531 : :
532 [ + + ]: 786 : if (IsInCell())
533 : : {
534 [ + - ]: 12 : XFParaStyle* pOldStyle = pXFStyleManager->FindParaStyle(m_StyleName);
535 [ + + ]: 12 : if (pOldStyle->GetNumberRight())
536 : : {
537 [ + - ]: 9 : pOverStyle = new XFParaStyle;
538 : 9 : *pOverStyle = *pOldStyle;
539 : 9 : pOverStyle->SetAlignType(enumXFAlignStart);
540 [ + - ]: 9 : if (!m_ParentStyleName.isEmpty())
541 : 9 : pOverStyle->SetParentStyleName(m_ParentStyleName);
542 : 9 : m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
543 : : }
544 : : }
545 : :
546 : : // override bullet and numbering
547 : 786 : OverrideParaBullet(pBulletProps);
548 : 786 : OverrideParaNumbering(pNumberingProps);
549 : :
550 : : //add by
551 : : //register bullet style
552 : 786 : LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
553 [ + - ]: 786 : if (pBulletStyleMgr)
554 : : {
555 : : // if has bullet or numbering
556 [ + + ]: 786 : if (m_bHasBullet)
557 : : {
558 : : //if it's normal bullet
559 [ + - ]: 18 : if (m_pSilverBullet)
560 : : {
561 [ + + ]: 18 : if (m_pSilverBullet->HasName())
562 : : {
563 : 12 : m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
564 : : }
565 [ + - ]: 6 : else if (!m_pBullOver->IsEditable())
566 : : {
567 : 6 : m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_pBullOver, m_pIndentOverride);
568 : : }
569 : :
570 : : // test codes
571 [ + - ]: 18 : if (m_pSilverBullet->IsBulletOrdered())
572 : : {
573 : 18 : rtl::OUString aPreBullStyleName;
574 [ + - ]: 18 : LwpNumberingOverride* pNumbering = this->GetParaNumbering();
575 : 18 : sal_uInt16 nPosition = pNumbering->GetPosition();
576 : 18 : sal_Bool bLesser = m_pSilverBullet->IsLesserLevel(nPosition);
577 : 18 : /*sal_Bool bResetSection =*/ m_pSilverBullet->IsNewSection(nPosition);
578 : : sal_Bool bHeading;
579 : 18 : LwpPara* pPara = this;
580 : 18 : LwpPara* pPrePara = NULL;
581 : 18 : LwpSilverBullet* pParaSilverBullet = NULL;
582 : 18 : sal_uInt16 nNum = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
583 : :
584 : 18 : nFoundBound = nLevel = pNumbering->GetLevel();
585 [ + - ]: 18 : if (nPosition == pNumbering->GetPosition())
586 : : {
587 : 18 : nFoundBound++;
588 : : }
589 : 18 : bHeading = pNumbering->IsHeading();
590 : :
591 : 30 : while(sal_True)
592 : : {
593 : : /*// When we hit the hint paragraph, we can stop and check the hint.
594 : : if (qNumberHint && (qPara == qNumberHint->GetPara()) &&
595 : : qNumberHint->Lookup(qSilverBullet, Level, Position, &Offset))
596 : : {
597 : : Num += Offset;
598 : : break;
599 : : }*/
600 : :
601 : 48 : pParaSilverBullet = pPara->GetSilverBullet();
602 [ + - ]: 48 : pNumbering = pPara->GetParaNumbering();
603 : :
604 [ + + ]: 48 : if (*(pPara->GetObjectID()) != *(this->GetObjectID()))
605 : : {
606 [ + + ]: 30 : if (!pParaSilverBullet)
607 : : {
608 : 12 : break;
609 : : }
610 : :
611 : : /* If lesser, stop when we hit an outline style whose level is
612 : : * higher than our current level.
613 : : */
614 : : // restart based on Outline level?
615 [ + - ][ + - ]: 18 : if (pNumbering && bLesser && (bHeading ? pNumbering->IsHeading() : sal_True))
[ - + ][ # # ]
[ + - ]
616 : : {
617 [ + - ]: 18 : if (nFoundLevel != 0xffff)
618 : : {
619 [ - + ]: 18 : if (pNumbering->GetLevel() < nFoundLevel)
620 : : {
621 : 0 : break;
622 : : }
623 [ + - + - : 54 : if ((pNumbering->GetLevel() == nFoundLevel)
- + ][ - + ]
624 : 18 : && (*(pParaSilverBullet->GetObjectID()) != *(m_pSilverBullet->GetObjectID())
625 : 18 : || pNumbering->GetPosition() != nPosition))
626 : : {
627 : 0 : break;
628 : : }
629 : : }
630 : : else
631 : : {
632 [ # # ][ # # ]: 0 : if (pNumbering && pNumbering->GetLevel() < nFoundBound && pParaSilverBullet
[ # # # #
# # ][ # # ]
633 : 0 : && (*(pParaSilverBullet->GetObjectID()) != *(m_pSilverBullet->GetObjectID())
634 : 0 : || pNumbering->GetPosition() != nPosition))
635 : : {
636 : 0 : nFoundBound = pNumbering->GetLevel();
637 : : }
638 : : }
639 : : }
640 : :
641 : : /*if (qSpecificStyle
642 : : && qSpecificStyle == qPara->GetParaStyle(LTRUE))
643 : : break;
644 : :
645 : : // See if we crossed a section boundary
646 : : if (ResetSection)
647 : : {
648 : : CurrPos.SetPara(qPara);
649 : : if (CurrPos <= SectionPos)
650 : : break;
651 : : }*/
652 : : }
653 : :
654 : : // Don't bump the number if this bullet is skipped
655 [ + - ]: 36 : if (m_pBullOver->IsSkip())
656 : : ;
657 [ + - + - ]: 108 : else if ( pParaSilverBullet
[ + - + - ]
[ + - ]
658 : 36 : && *(pParaSilverBullet->GetObjectID()) == *(m_pSilverBullet->GetObjectID())
659 : 36 : && pNumbering && nPosition == pNumbering->GetPosition())
660 : : {
661 [ + + ]: 36 : if (bLesser)
662 : : {
663 [ + + ]: 30 : if (nFoundLevel != 0xffff)
664 : : {
665 [ + - ]: 18 : if (nFoundLevel == pNumbering->GetLevel())
666 : : {
667 : 18 : aPreBullStyleName = pPara->GetBulletStyleName();
668 : 18 : nNum++;
669 : : }
670 : : }
671 [ + - ]: 12 : else if (pNumbering->GetLevel() <= nLevel)
672 : : {
673 [ - + ]: 12 : if (pNumbering->GetLevel() >= nFoundBound)
674 : : {
675 : 0 : break;
676 : : }
677 : 12 : nFoundLevel = pNumbering->GetLevel();
678 : 12 : aPreBullStyleName = pPara->GetBulletStyleName();
679 : 12 : nNum++;
680 : : }
681 : : }
682 : : else
683 : : {
684 : 6 : aPreBullStyleName = pPara->GetBulletStyleName();
685 : 6 : nNum++;
686 : : }
687 : : }
688 : :
689 [ + - ][ + - ]: 36 : if (pPara && pPara->GetPrevious())
[ + - ]
690 [ + - ][ + + ]: 36 : pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj(VO_PARA));
691 : : else
692 : 0 : pPrePara=NULL;
693 : :
694 [ + + ]: 36 : if (!pPrePara)
695 : : {
696 [ + - ]: 6 : LwpStory* pStory = pPara->GetStory();
697 [ + - ]: 6 : pPrePara = pStory->GetLastParaOfPreviousStory();
698 : :
699 [ + - ]: 6 : if (!pPrePara)
700 : : {
701 : 6 : break;
702 : : }
703 : : }
704 : 30 : pPara = pPrePara;
705 : : }
706 [ + - ]: 18 : nNum = nNum ? nNum : 1;
707 : :
708 [ + + ]: 18 : if (nNum > 1)
709 : : {
710 : 9 : m_aBulletStyleName = aPreBullStyleName;
711 : 9 : m_bBullContinue = sal_True;
712 : : }
713 : : else
714 : : {
715 : 9 : m_bBullContinue = sal_False;
716 [ + - ][ - + ]: 9 : if (this->IsInCell())
717 : : {
718 [ # # ]: 0 : XFListStyle* pOldStyle = static_cast<XFListStyle*>(pXFStyleManager->FindStyle(m_aBulletStyleName));
719 [ # # ]: 0 : if (pOldStyle)
720 : : {
721 [ # # ][ # # ]: 0 : XFListStyle* pNewStyle = new XFListStyle(*pOldStyle);
722 [ # # ][ # # ]: 0 : m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle)->GetStyleName();
723 : : }
724 : : }
725 : : }
726 : :
727 [ + - ]: 18 : LwpStory* pMyStory = this->GetStory();
728 [ + - ]: 18 : if (pMyStory)
729 : : {
730 [ + - ][ + + ]: 18 : if (pMyStory->IsBullStyleUsedBefore(m_aBulletStyleName, m_pParaNumbering->GetPosition()))
731 : : {
732 : : //m_bBullContinue = sal_True;
733 : : }
734 : : else
735 : : {
736 [ + - ]: 9 : pMyStory->AddBullStyleName2List(m_aBulletStyleName, m_pParaNumbering->GetPosition());
737 : : }
738 : 18 : }
739 : :
740 : : }
741 : : // end of test codes
742 : : }
743 : : }
744 : : }
745 : : //end add
746 : :
747 [ + + ][ + - ]: 786 : if (noSpacing && GetPrevious())
[ + + ]
748 : : {
749 [ + + ]: 450 : LwpPara* pPrePara = dynamic_cast<LwpPara*>(GetPrevious()->obj());
750 [ + + ][ + + ]: 450 : if (pPrePara && pPrePara->GetBelowSpacing()!=0)
[ + + ]
751 : : {
752 [ + - ]: 3 : pOverStyle = new XFParaStyle;
753 : 3 : *pOverStyle = *GetXFParaStyle();
754 : 3 : XFMargins* pMargin = &pOverStyle->GetMargins();
755 : 3 : pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
756 [ + - ]: 3 : if (!m_ParentStyleName.isEmpty())
757 : 3 : pOverStyle->SetParentStyleName(m_ParentStyleName);
758 : 3 : m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
759 : : }
760 : : }
761 : :
762 : : //register tab style
763 [ + + ]: 786 : if(m_Fribs.HasFrib(FRIB_TAG_TAB))
764 : : {
765 [ + - ]: 75 : XFParaStyle* pParaStyle = new XFParaStyle;
766 : 75 : *pParaStyle = *GetXFParaStyle();
767 : : //pOverStyle->SetStyleName(A2OUSTR(""));
768 : 75 : this->RegisterTabStyle(pParaStyle);
769 [ + - ]: 75 : if (!m_ParentStyleName.isEmpty())
770 : 75 : pParaStyle->SetParentStyleName(m_ParentStyleName);
771 : 75 : m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
772 : : }
773 : :
774 : : //register master page;
775 : 786 : RegisterMasterPage(GetXFParaStyle());
776 : :
777 : : // reg auto style,lay here for pagebreak need overrided para style
778 : 786 : m_Fribs.SetPara(this);
779 : 786 : m_Fribs.RegisterStyle();
780 : :
781 [ - + ]: 783 : if (m_bHasDropcap == sal_True)
782 : : {
783 : 0 : GatherDropcapInfo();
784 [ # # ]: 0 : XFParaStyle* pStyle = new XFParaStyle;
785 : 0 : *pStyle = *GetXFParaStyle();
786 : 0 : pStyle->SetDropCap(m_nChars-1,m_nLines);
787 [ # # ]: 0 : if (!m_ParentStyleName.isEmpty())
788 : 0 : pStyle->SetParentStyleName(m_ParentStyleName);
789 : 783 : m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
790 : : }
791 : : // maybe useful for futer version
792 : : // deleted because Leader of Table is not supported in this version
793 : : //AddTabStyleForTOC();
794 : : }
795 : :
796 : 0 : void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
797 : : {
798 [ # # ]: 0 : if( !pLayout )
799 : 0 : return;
800 : :
801 [ # # ]: 0 : XFSectionStyle* pSectStyle= new XFSectionStyle();
802 : 0 : XFColumns* pColumns = pLayout->GetXFColumns();
803 [ # # ]: 0 : if(pColumns)
804 : : {
805 : 0 : pSectStyle->SetColumns(pColumns);
806 : : }
807 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
808 : 0 : m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName();
809 : : }
810 : :
811 : 0 : XFSection* LwpPara::CreateXFSection()
812 : : {
813 [ # # ]: 0 : XFSection* pXFSection = new XFSection();
814 [ # # ]: 0 : pXFSection->SetStyleName(m_SectionStyleName);
815 : 0 : m_SectionStyleName = A2OUSTR("");
816 : 0 : return pXFSection;
817 : : }
818 : :
819 : : /**************************************************************************
820 : : * @descr: register tab style
821 : : * @param:
822 : : * @param:
823 : : * @return:
824 : : **************************************************************************/
825 : 75 : void LwpPara::RegisterTabStyle(XFParaStyle* pXFParaStyle)
826 : : {
827 [ + - ]: 75 : LwpTabOverride aFinaOverride;
828 : 75 : LwpTabOverride* pBase = NULL;
829 : : //get the tabrack from the current layout
830 [ + - ][ - + ]: 75 : LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj());
831 [ + - ][ + - ]: 75 : LwpMiddleLayout* pLayout = pStory ? pStory->GetTabLayout() : NULL;
832 [ + - ]: 75 : if(pLayout)
833 : : {
834 [ + - ]: 75 : pBase = pLayout->GetTabOverride();
835 [ + + ]: 75 : if(pBase)
836 : : {
837 [ + - ]: 15 : pBase->Override(&aFinaOverride);
838 : : }
839 : : }
840 : :
841 : : //get the tabrack from the base parastyle
842 [ + - ]: 75 : LwpParaStyle* pParaStyle = GetParaStyle();
843 [ + - ]: 75 : pBase = pParaStyle->GetTabOverride();
844 [ - + ]: 75 : if(pBase)
845 : : {
846 [ # # ]: 0 : pBase->Override(&aFinaOverride);
847 : : }
848 : : //get the tabrack from the local property
849 [ + - ]: 75 : pBase = GetLocalTabOverride();
850 [ + + ]: 75 : if(pBase)
851 : : {
852 [ + - ]: 6 : pBase->Override(&aFinaOverride);
853 : : }
854 : :
855 [ + - ]: 75 : LwpParaStyle::ApplyTab(pXFParaStyle, &aFinaOverride);
856 : 75 : }
857 : : /**
858 : : * @short parse dropcap text
859 : : */
860 : 0 : void LwpPara::ParseDropcapContent()
861 : : {
862 [ # # ]: 0 : if (!GetFoundry())
863 : 0 : return;
864 : 0 : XFParagraph* pDropcap = GetFoundry()->GetDropcapMgr()->GetXFPara();
865 [ # # ]: 0 : if (pDropcap)
866 : : {
867 : 0 : m_Fribs.SetXFPara(pDropcap);
868 : 0 : m_Fribs.XFConvert();
869 : : }
870 : : }
871 : : /**
872 : : * @short add paragraph break attribute
873 : : */
874 : 192 : void LwpPara::AddBreakBefore(XFContentContainer* pCont)
875 : : {
876 [ - + ]: 192 : if (!m_pBreaks)
877 : 192 : return;
878 [ - + ]: 192 : if (m_pBreaks->IsPageBreakBefore())
879 : : {
880 [ # # ]: 0 : XFParagraph *pPara = new XFParagraph();
881 [ # # ]: 0 : pPara->SetStyleName(m_BefPageBreakName);
882 : 0 : pCont->Add(pPara);
883 : : }
884 [ - + ]: 192 : else if (m_pBreaks->IsColumnBreakBefore())
885 : : {
886 [ # # ]: 0 : XFParagraph *pPara = new XFParagraph();
887 [ # # ]: 0 : pPara->SetStyleName(m_BefColumnBreakName);
888 : 0 : pCont->Add(pPara);
889 : : }
890 : : }
891 : :
892 : 192 : void LwpPara::AddBreakAfter(XFContentContainer* pCont)
893 : : {
894 [ - + ]: 192 : if (!m_pBreaks)
895 : 192 : return;
896 [ - + ]: 192 : if (m_pBreaks->IsPageBreakAfter())
897 : : {
898 [ # # ]: 0 : XFParagraph *pPara = new XFParagraph();
899 [ # # ]: 0 : pPara->SetStyleName(m_AftPageBreakName);
900 : 0 : pCont->Add(pPara);
901 : : }
902 [ - + ]: 192 : else if (m_pBreaks->IsColumnBreakAfter())
903 : : {
904 [ # # ]: 0 : XFParagraph *pPara = new XFParagraph();
905 [ # # ]: 0 : pPara->SetStyleName(m_AftColumnBreakName);
906 : 0 : pCont->Add(pPara);
907 : : }
908 : : }
909 : :
910 : 1233 : LwpBulletStyleMgr* LwpPara::GetBulletStyleMgr()
911 : : {
912 [ + - ]: 1233 : if (m_pFoundry)
913 : : {
914 : 1233 : return m_pFoundry->GetBulletStyleMgr();
915 : : }
916 : :
917 : 1233 : return NULL;
918 : : }
919 : :
920 : 15 : XFContentContainer* LwpPara::AddBulletList(XFContentContainer* pCont)
921 : : {
922 : 15 : LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
923 [ - + ]: 15 : if (!pBulletStyleMgr)
924 : : {
925 : : assert(false);
926 : 0 : return NULL;
927 : : }
928 : :
929 : 15 : sal_uInt16 nLevel = m_nLevel;
930 : 15 : sal_Bool bOrdered = sal_False;
931 : 15 : /*LwpStory* pMyStory =*/ GetStory();
932 : :
933 : 15 : pBulletStyleMgr->SetContinueFlag(m_bBullContinue);
934 : :
935 [ + - ]: 15 : if (m_pSilverBullet->IsBulletOrdered())
936 : : {
937 : 15 : bOrdered = sal_True;
938 : : }
939 [ + + ]: 15 : if (m_pSilverBullet->HasName())
940 : : {
941 : 12 : nLevel = m_pParaNumbering->GetPosition();
942 : 12 : m_nLevel = nLevel;//add by ,for get para level
943 : : // m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
944 : : }
945 : :
946 : : return ( pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
947 : 15 : nLevel, m_pBullOver->IsSkip()) );
948 : : }
949 : :
950 : 66 : LwpNumberingOverride* LwpPara::GetParaNumbering()
951 : : {
952 : 66 : return m_pParaNumbering.get();
953 : : }
954 : :
955 : 132 : void LwpForked3NotifyList::Read(LwpObjectStream* pObjStrm)
956 : : {
957 : 132 : m_PersistentList.Read(pObjStrm);
958 : 132 : }
959 : :
960 : 270 : void LwpNotifyListPersistent::Read(LwpObjectStream* pObjStrm)
961 : : {
962 : 270 : m_Head.ReadIndexed(pObjStrm);
963 : 270 : pObjStrm->SkipExtra();
964 : 270 : }
965 : :
966 : 447 : void LwpPara::Release()
967 : 447 : {}
968 : :
969 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|