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