update dev300-m57
[ooovba.git] / lotuswordpro / source / filter / lwppara.cxx
bloba680bc7ba3e6b5ced61af1e11b116204b10a58f0
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /*************************************************************************
56 * @file
57 * For LWP filter architecture prototype
58 ************************************************************************/
59 /*************************************************************************
60 * Change History
61 Jan 2005 Created
62 ************************************************************************/
64 #include "lwppara.hxx"
65 #include "lwpglobalmgr.hxx"
66 #include "lwpfilehdr.hxx"
67 #include "lwpparaproperty.hxx"
68 #include "lwptools.hxx"
69 #include "lwpparastyle.hxx"
70 #include "xfilter/xffont.hxx"
71 #include "xfilter/xftextstyle.hxx"
72 #include "xfilter/xfstylemanager.hxx"
73 #include "xfilter/xfparagraph.hxx"
74 #include "xfilter/xftextcontent.hxx"
75 #include "xfilter/xftextspan.hxx"
76 #include "xfilter/xfmargins.hxx"
77 #include "xfilter/xftabstop.hxx"
78 #include "xfilter/xflinebreak.hxx"
79 #include "xfilter/xfsection.hxx"
80 #include "xfilter/xfsectionstyle.hxx"
81 #include "xfilter/xfcolor.hxx"
82 #include "xfilter/xfhyperlink.hxx"
83 #include "xfilter/xfliststyle.hxx"
84 #include "lwpcharsetmgr.hxx"
85 #include "lwpsection.hxx"
86 #include "lwplayout.hxx"
87 #include "lwpusewhen.hxx"
88 #include "lwpbulletstylemgr.hxx"
89 #include "lwpstory.hxx"
90 #include "lwpsilverbullet.hxx"
91 #include "xfilter/xflist.hxx"
92 #include "xfilter/xfframe.hxx"
94 #include "lwpdivinfo.hxx"
95 #include "lwpdoc.hxx"
96 #include "lwpholder.hxx"
97 #include "lwppagehint.hxx"
99 #include "lwpdropcapmgr.hxx"
100 #include "lwptable.hxx"
101 LwpPara::LwpPara(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
102 : LwpDLVList(objHdr, pStrm), m_pBreaks(NULL), m_pIndentOverride(NULL), m_bHasBullet(sal_False), m_bBullContinue(sal_False),
103 /*m_pParaNumbering(NULL),*/ m_pSilverBullet(NULL), m_pBullOver(NULL),m_bHasDropcap(sal_False),m_nLines(0),m_nChars(0),
104 m_BelowSpacing(0),m_pDropcapLayout(NULL), m_pXFContainer(NULL)
106 m_pProps = NULL;
107 m_SectionStyleName = A2OUSTR("");
108 m_AllText = A2OUSTR("");
111 LwpPara::~LwpPara()
114 if (m_pBreaks)
116 delete m_pBreaks;
117 m_pBreaks = NULL;
119 /* if (m_pParaNumbering)
121 delete m_pParaNumbering;
122 m_pParaNumbering = NULL;
125 if (m_pBullOver)
127 delete m_pBullOver;
128 m_pBullOver = NULL;
130 if(m_pIndentOverride)
132 delete m_pIndentOverride;
135 LwpParaProperty* pNextProp;
136 while(m_pProps)
138 pNextProp = m_pProps->GetNext();
139 delete m_pProps;
140 m_pProps = pNextProp;
144 void LwpPara::Read()
146 LwpDLVList::Read();
148 sal_Bool Simple;
149 sal_Bool Notify = sal_False;
150 // m_Fribs.SetPara(this);
151 // LwpParaPropListProperty *PropList = NULL;
152 if(LwpFileHeader::m_nFileRevision<0x0006)
153 Simple = sal_False;
154 else if(LwpFileHeader::m_nFileRevision<0x000B)
155 m_pObjStrm->QuickRead(&Simple, sizeof(Simple));
156 else
158 sal_uInt8 Flag;
159 m_pObjStrm->QuickRead(&Flag, sizeof(Flag));
161 const int DISK_SIMPLE = 1;
162 const int DISK_NOTIFY = 2;
164 Simple = (Flag & DISK_SIMPLE) ? sal_True : sal_False;
165 Notify = (Flag & DISK_NOTIFY) ? sal_True : sal_False;
168 if(!Simple)
170 m_pObjStrm->QuickRead(&m_nOrdinal, sizeof(m_nOrdinal));
171 if(LwpFileHeader::m_nFileRevision<0x000B)
173 // TODO: to process
174 assert(false);
175 /*pCForked3NotifyList Notify = new CForked3NotifyList(this);
176 Notify->GetExtraList()->QuickRead(pFile);
177 Notify->QuickRead(pFile);
178 if(Notify->GetExtraList()->IsEmpty() &&
179 Notify->IsEmpty())
180 delete Notify;
181 else
182 cNotifyList = Notify;*/
184 else
186 if (Notify)
188 LwpForked3NotifyList* pNotifyList = new LwpForked3NotifyList();
189 pNotifyList->GetExtraList()->Read(m_pObjStrm);
190 pNotifyList->Read(m_pObjStrm);
191 delete pNotifyList;
195 else
196 m_nOrdinal = 0x0001;
198 m_pObjStrm->QuickRead(&m_nFlags, sizeof(m_nFlags));
199 m_ParaStyle.ReadIndexed(m_pObjStrm);
201 if(!Simple)
203 m_Hint.Read(m_pObjStrm);
204 if (IsBadHintsInFile())
206 // This hint is no good, so throw it away -- SDC 9/28/95
207 m_Hint.Reset();
211 m_Story.ReadIndexed(m_pObjStrm);
212 if(!Simple)
214 if(LwpFileHeader::m_nFileRevision<0x000B)
216 // TODO: to process
217 assert(false);
218 /*PropList = new CParaPropListProperty(this);
219 PropList->GetList()->QuickRead(pFile);
220 if(PropList->GetList()->IsEmpty())
222 delete PropList;
223 PropList = LNULL;
226 m_pObjStrm->QuickRead(&m_nLevel, sizeof(m_nLevel));
228 // test
229 if (m_nLevel > 9)
231 m_nLevel = 9;
233 // test ends
235 else
236 m_nLevel = 0x0001;
238 m_Fribs.SetPara(this);//add by 2/1, for silver bullet
239 m_Fribs.ReadPara(m_pObjStrm);
241 m_pProps = LwpParaProperty::ReadPropertyList(m_pObjStrm,this);
244 void LwpPara::Parse(IXFStream* pOutputStream)
246 m_pXFContainer = new XFContentContainer;
247 XFConvert(m_pXFContainer);
248 m_pXFContainer->ToXml(pOutputStream);
249 m_pXFContainer->Reset();
250 delete m_pXFContainer;
251 m_pXFContainer = NULL;
254 void LwpPara::XFConvert(XFContentContainer* pCont)
256 m_pXFContainer = pCont;
258 if (static_cast<LwpStory*>(m_Story.obj())->GetDropcapFlag() == sal_True)
260 ParseDropcapContent();
261 /*LwpObject* pNextPara = GetNext()->obj();
262 if(pNextPara)
263 pNextPara->XFConvert(pCont);*/
264 return;
267 //Add the break before para
268 if (m_pBreaks && m_nOrdinal!=0)
269 AddBreakBefore(pCont);
271 //Create an XFPara for this VO_PARA
272 XFParagraph *pPara = new XFParagraph;
273 pPara->SetStyleName(m_StyleName);
275 if(m_SectionStyleName.getLength()>0)
277 XFSection* pSection = CreateXFSection();
278 LwpStory* pStory = static_cast<LwpStory*> ( m_Story.obj() );
279 pStory->AddXFContent(pSection);
280 //pSection->Add(pPara);
281 m_pXFContainer = pSection;
284 if (m_bHasBullet && m_pSilverBullet)
286 XFContentContainer* pListItem = AddBulletList(m_pXFContainer);
287 if (pListItem)
289 pListItem->Add(pPara);
292 else
294 LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
295 if (pBulletStyleMgr)
297 pBulletStyleMgr->SetCurrentSilverBullet(LwpObjectID());
298 pBulletStyleMgr->SetContinueFlag(sal_False);
300 m_pXFContainer->Add(pPara);
303 m_Fribs.SetXFPara(pPara);
304 m_Fribs.XFConvert();
306 if (m_pBreaks)
307 AddBreakAfter(m_pXFContainer);
309 // maybe useful for futer version
310 // deleted by
311 // AddTabStopForTOC();
313 //Caller is responsible for calling the next para object
314 /*LwpObject* pNextPara = GetNext()->obj();
315 if(pNextPara)
316 pNextPara->XFConvert( m_pXFContainer );*/
319 sal_Bool LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle)
321 sal_Bool bSuccess = sal_False;
322 //get story
323 LwpStory* pStory = static_cast<LwpStory*>(m_Story.obj());
324 //if pagelayout is modified, register the pagelayout
325 if(pStory->IsPMModified())
327 sal_Bool bNewSection = sal_False;
328 bNewSection = pStory->IsNeedSection();
329 LwpPageLayout* pLayout = pStory->GetCurrentLayout();
330 if(bNewSection)
332 RegisterNewSectionStyle(pLayout);
335 bSuccess = sal_True;
336 //register master page style
337 XFParaStyle* pOverStyle = new XFParaStyle();
338 *pOverStyle = *pBaseStyle;
339 pOverStyle->SetStyleName( A2OUSTR(""));
340 pOverStyle->SetMasterPage(pLayout->GetStyleName());
341 if (m_ParentStyleName.getLength())
342 pOverStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
343 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
344 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
346 return bSuccess;
349 * @short register paragraph style
351 void LwpPara::RegisterStyle()
352 { //1 reg autostyle
353 // m_Fribs.SetPara(this);
354 // m_Fribs.RegisterStyle();
356 //2 reg para style
357 if (!m_pFoundry)
358 return;
359 XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(m_ParaStyle));
360 if (pBaseStyle == NULL) return;
361 m_StyleName = pBaseStyle->GetStyleName();//such intf to be added
362 m_ParentStyleName = m_StyleName;//Add by ,2005/12/12
363 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
365 if (GetParaStyle()->GetIndent())
367 m_pIndentOverride = new LwpIndentOverride;
368 *m_pIndentOverride = *(GetParaStyle()->GetIndent()); //add by 2-6,for indent hierachy
370 // else
371 // m_pIndentOverride = NULL;
373 XFParaStyle* pOverStyle = NULL;
374 sal_Bool noSpacing = sal_True;
375 sal_Bool noIndent = sal_True;
376 LwpParaProperty* pBulletProps = NULL, *pNumberingProps = NULL;
378 if (m_pProps != NULL)
380 pOverStyle = new XFParaStyle;
381 *pOverStyle = *pBaseStyle;
382 pOverStyle->SetStyleName(A2OUSTR(""));
383 LwpParaProperty* pProps = m_pProps;
384 sal_uInt32 PropType;
385 LwpParaStyle* pParaStyle = static_cast<LwpParaStyle*>(m_ParaStyle.obj());
386 while(pProps)
388 PropType = pProps->GetType();
389 switch(PropType)
391 case PP_LOCAL_ALIGN:
393 LwpAlignmentOverride aAlign;
394 if (!pParaStyle->GetAlignment())
395 OverrideAlignment(NULL,static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),pOverStyle);
396 else
398 aAlign = *(pParaStyle->GetAlignment());
399 OverrideAlignment(&aAlign,static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),pOverStyle);
402 break;
403 case PP_LOCAL_INDENT:
405 noIndent = sal_False;
406 if (!pParaStyle->GetIndent())
407 OverrideIndent(NULL,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
409 else
411 OverrideIndent(m_pIndentOverride,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
414 break;
415 case PP_LOCAL_SPACING:
417 LwpSpacingOverride aSpacing;
418 noSpacing = sal_False;
419 if (!pParaStyle->GetSpacing())
420 OverrideSpacing(NULL,static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing(),pOverStyle);
421 else
423 aSpacing = *(pParaStyle->GetSpacing());
424 OverrideSpacing(&aSpacing,static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing(),pOverStyle);
427 break;
428 // 01/25/2005
429 case PP_LOCAL_BORDER:
431 OverrideParaBorder(pProps, pOverStyle);
432 break;
434 case PP_LOCAL_BREAKS:
436 OverrideParaBreaks(pProps, pOverStyle);
437 break;
439 case PP_LOCAL_BULLET:
441 pBulletProps = pProps;
442 // OverrideParaBullet(pProps);
443 break;
445 case PP_LOCAL_NUMBERING:
447 pNumberingProps = pProps;
448 // OverrideParaNumbering(pProps);
449 break;
451 //end
452 case PP_LOCAL_TABRACK:
454 //, 01/28/05
455 /*LwpTabOverride* pTabOverride=pParaStyle->GetTabOverride();
456 if(!pTabOverride)
458 OverrideTab(NULL,static_cast<LwpParaTabRackProperty*>(pProps)->GetTab(),pOverStyle);
460 else
462 OverrideTab(pTabOverride,static_cast<LwpParaTabRackProperty*>(pProps)->GetTab(),pOverStyle);
464 break;
466 case PP_LOCAL_BACKGROUND:
468 /* LwpBackgroundOverride aBackground;
469 if (!pParaStyle->GetBackground())
470 OverrideBackground(NULL,static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground(),pOverStyle);
471 else
473 aBackground = *(pParaStyle->GetaBackground());
474 OverrideBackground(&aBackground,static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground(),pOverStyle);
477 // modified by , 06/03/2005
478 LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground();
479 if (pBGOver)
481 LwpBackgroundStuff* pBGStuff = pBGOver->GetBGStuff();
482 if (pBGStuff && !pBGStuff->IsTransparent() )
484 if (pBGStuff->IsPatternFill())
486 XFBGImage* pXFBGImage = pBGStuff->GetFillPattern();
487 pOverStyle->SetBackImage(pXFBGImage);
489 else
491 LwpColor* pColor = pBGStuff->GetFillColor();
492 if (pColor && pColor->IsValidColor())
494 XFColor aXFColor( pColor->To24Color());
495 pOverStyle->SetBackColor( aXFColor );
500 // end modified
501 break;
503 default:
504 break;
506 pProps = pProps->GetNext();
509 if (noIndent && m_pIndentOverride)
511 if (m_pIndentOverride->IsUseRelative() && GetParent())
513 OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
516 if (m_ParentStyleName.getLength())
517 pOverStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
518 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
521 else //use named style
523 if (m_pIndentOverride)
525 if (m_pIndentOverride->IsUseRelative() && GetParent())
527 pOverStyle = new XFParaStyle;
528 *pOverStyle = *pBaseStyle;
529 OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
530 if (m_ParentStyleName.getLength())
531 pOverStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
532 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
537 if (IsInCell())
539 XFParaStyle* pOldStyle = pXFStyleManager->FindParaStyle(m_StyleName);
540 if (pOldStyle->GetNumberRight())
542 pOverStyle = new XFParaStyle;
543 *pOverStyle = *pOldStyle;
544 pOverStyle->SetAlignType(enumXFAlignStart);
545 if (m_ParentStyleName.getLength())
546 pOverStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
547 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
551 // override bullet and numbering
552 OverrideParaBullet(pBulletProps);
553 OverrideParaNumbering(pNumberingProps);
555 //add by
556 //register bullet style
557 LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
558 if (pBulletStyleMgr)
560 // if has bullet or numbering
561 if (m_bHasBullet)
563 //if it's normal bullet
564 if (m_pSilverBullet)
566 if (m_pSilverBullet->HasName())
568 m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
570 else if (!m_pBullOver->IsEditable())
572 m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_pBullOver, m_pIndentOverride);
575 // test codes
576 if (m_pSilverBullet->IsBulletOrdered())
578 rtl::OUString aPreBullStyleName;
579 LwpNumberingOverride* pNumbering = this->GetParaNumbering();
580 sal_uInt16 nPosition = pNumbering->GetPosition();
581 sal_Bool bLesser = m_pSilverBullet->IsLesserLevel(nPosition);
582 sal_Bool bResetSection = m_pSilverBullet->IsNewSection(nPosition);
583 sal_Bool bHeading;
584 LwpPara* pPara = this;
585 LwpPara* pPrePara = NULL;
586 LwpSilverBullet* pParaSilverBullet = NULL;
587 sal_uInt16 nNum = 0, nOffset = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
589 nFoundBound = nLevel = pNumbering->GetLevel();
590 if (nPosition == pNumbering->GetPosition())
592 nFoundBound++;
594 bHeading = pNumbering->IsHeading();
596 while(sal_True)
598 /*// When we hit the hint paragraph, we can stop and check the hint.
599 if (qNumberHint && (qPara == qNumberHint->GetPara()) &&
600 qNumberHint->Lookup(qSilverBullet, Level, Position, &Offset))
602 Num += Offset;
603 break;
606 pParaSilverBullet = pPara->GetSilverBullet();
607 pNumbering = pPara->GetParaNumbering();
609 if (*(pPara->GetObjectID()) != *(this->GetObjectID()))
611 if (!pParaSilverBullet)
613 break;
616 /* If lesser, stop when we hit an outline style whose level is
617 * higher than our current level.
619 // restart based on Outline level?
620 if (pNumbering && bLesser && (bHeading ? pNumbering->IsHeading() : sal_True))
622 if (nFoundLevel != 0xffff)
624 if (pNumbering->GetLevel() < nFoundLevel)
626 break;
628 if ((pNumbering->GetLevel() == nFoundLevel)
629 && (*(pParaSilverBullet->GetObjectID()) != *(m_pSilverBullet->GetObjectID())
630 || pNumbering->GetPosition() != nPosition))
632 break;
635 else
637 if (pNumbering && pNumbering->GetLevel() < nFoundBound && pParaSilverBullet
638 && (*(pParaSilverBullet->GetObjectID()) != *(m_pSilverBullet->GetObjectID())
639 || pNumbering->GetPosition() != nPosition))
641 nFoundBound = pNumbering->GetLevel();
646 /*if (qSpecificStyle
647 && qSpecificStyle == qPara->GetParaStyle(LTRUE))
648 break;
650 // See if we crossed a section boundary
651 if (ResetSection)
653 CurrPos.SetPara(qPara);
654 if (CurrPos <= SectionPos)
655 break;
659 // Don't bump the number if this bullet is skipped
660 if (m_pBullOver->IsSkip())
662 else if ( pParaSilverBullet
663 && *(pParaSilverBullet->GetObjectID()) == *(m_pSilverBullet->GetObjectID())
664 && pNumbering && nPosition == pNumbering->GetPosition())
666 if (bLesser)
668 if (nFoundLevel != 0xffff)
670 if (nFoundLevel == pNumbering->GetLevel())
672 aPreBullStyleName = pPara->GetBulletStyleName();
673 nNum++;
676 else if (pNumbering->GetLevel() <= nLevel)
678 if (pNumbering->GetLevel() >= nFoundBound)
680 break;
682 nFoundLevel = pNumbering->GetLevel();
683 aPreBullStyleName = pPara->GetBulletStyleName();
684 nNum++;
687 else
689 aPreBullStyleName = pPara->GetBulletStyleName();
690 nNum++;
694 if (pPara && pPara->GetPrevious())
695 pPrePara = static_cast<LwpPara*>(pPara->GetPrevious()->obj(VO_PARA));
696 else
697 pPrePara=NULL;
699 if (!pPrePara)
701 LwpStory* pStory = pPara->GetStory();
702 pPrePara = pStory->GetLastParaOfPreviousStory();
704 if (!pPrePara)
706 break;
709 pPara = pPrePara;
711 nNum = nNum ? nNum : 1;
713 if (nNum > 1)
715 m_aBulletStyleName = aPreBullStyleName;
716 m_bBullContinue = sal_True;
718 else
720 m_bBullContinue = sal_False;
721 if (this->IsInCell())
723 XFListStyle* pOldStyle = static_cast<XFListStyle*>(pXFStyleManager->FindStyle(m_aBulletStyleName));
724 if (pOldStyle)
726 XFListStyle* pNewStyle = new XFListStyle(*pOldStyle);
727 m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle)->GetStyleName();
732 LwpStory* pMyStory = this->GetStory();
733 if (pMyStory)
735 if (pMyStory->IsBullStyleUsedBefore(m_aBulletStyleName, m_aParaNumbering.GetPosition()))
737 //m_bBullContinue = sal_True;
739 else
741 pMyStory->AddBullStyleName2List(m_aBulletStyleName, m_aParaNumbering.GetPosition());
746 // end of test codes
750 //end add
752 if (noSpacing && GetPrevious())
754 LwpPara* pPrePara = static_cast<LwpPara*>(GetPrevious()->obj());
755 if (pPrePara && pPrePara->GetBelowSpacing()!=0)
757 pOverStyle = new XFParaStyle;
758 *pOverStyle = *GetXFParaStyle();
759 XFMargins* pMargin = &pOverStyle->GetMargins();
760 pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
761 if (m_ParentStyleName.getLength())
762 pOverStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
763 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
767 //register tab style
768 if(m_Fribs.HasFrib(FRIB_TAG_TAB))
770 XFParaStyle* pParaStyle = new XFParaStyle;
771 *pParaStyle = *GetXFParaStyle();
772 //pOverStyle->SetStyleName(A2OUSTR(""));
773 this->RegisterTabStyle(pParaStyle);
774 if (m_ParentStyleName.getLength())
775 pParaStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
776 m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
779 //register master page;
780 RegisterMasterPage(GetXFParaStyle());
782 // reg auto style,lay here for pagebreak need overrided para style
783 m_Fribs.SetPara(this);
784 m_Fribs.RegisterStyle();
786 if (m_bHasDropcap == sal_True)
788 GatherDropcapInfo();
789 XFParaStyle* pStyle = new XFParaStyle;
790 *pStyle = *GetXFParaStyle();
791 pStyle->SetDropCap(m_nChars-1,m_nLines);
792 if (m_ParentStyleName.getLength())
793 pStyle->SetParentStyleName(m_ParentStyleName); //Add by 2005/12/12
794 m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
796 // maybe useful for futer version
797 // deleted because Leader of Table is not supported in this version
798 //AddTabStyleForTOC();
801 void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
803 if( !pLayout )
804 return;
806 XFSectionStyle* pSectStyle= new XFSectionStyle();
807 XFColumns* pColumns = pLayout->GetXFColumns();
808 if(pColumns)
810 pSectStyle->SetColumns(pColumns);
812 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
813 m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName();
816 XFSection* LwpPara::CreateXFSection()
818 XFSection* pXFSection = new XFSection();
819 pXFSection->SetStyleName(m_SectionStyleName);
820 m_SectionStyleName = A2OUSTR("");
821 return pXFSection;
824 /**************************************************************************
825 * @descr: register tab style
826 * @param:
827 * @param:
828 * @return:
829 **************************************************************************/
830 void LwpPara::RegisterTabStyle(XFParaStyle* pXFParaStyle)
832 LwpTabOverride aFinaOverride;
833 LwpTabOverride* pBase = NULL;
834 //get the tabrack from the current layout
835 LwpStory* pStory = static_cast<LwpStory*>(m_Story.obj());
836 LwpMiddleLayout* pLayout = pStory->GetTabLayout();
837 if(pLayout)
839 pBase = pLayout->GetTabOverride();
840 if(pBase)
842 pBase->Override(&aFinaOverride);
846 //get the tabrack from the base parastyle
847 LwpParaStyle* pParaStyle = GetParaStyle();
848 pBase = pParaStyle->GetTabOverride();
849 if(pBase)
851 pBase->Override(&aFinaOverride);
853 //get the tabrack from the local property
854 pBase = GetLocalTabOverride();
855 if(pBase)
857 pBase->Override(&aFinaOverride);
860 LwpParaStyle::ApplyTab(pXFParaStyle, &aFinaOverride);
863 * @short parse dropcap text
865 void LwpPara::ParseDropcapContent()
867 if (!GetFoundry())
868 return;
869 XFParagraph* pDropcap = GetFoundry()->GetDropcapMgr()->GetXFPara();
870 if (pDropcap)
872 m_Fribs.SetXFPara(pDropcap);
873 m_Fribs.XFConvert();
877 * @short add paragraph break attribute
879 void LwpPara::AddBreakBefore(XFContentContainer* pCont)
881 if (!m_pBreaks)
882 return;
883 if (m_pBreaks->IsPageBreakBefore())
885 XFParagraph *pPara = new XFParagraph();
886 pPara->SetStyleName(m_BefPageBreakName);
887 pCont->Add(pPara);
889 else if (m_pBreaks->IsColumnBreakBefore())
891 XFParagraph *pPara = new XFParagraph();
892 pPara->SetStyleName(m_BefColumnBreakName);
893 pCont->Add(pPara);
897 void LwpPara::AddBreakAfter(XFContentContainer* pCont)
899 if (!m_pBreaks)
900 return;
901 if (m_pBreaks->IsPageBreakAfter())
903 XFParagraph *pPara = new XFParagraph();
904 pPara->SetStyleName(m_AftPageBreakName);
905 pCont->Add(pPara);
907 else if (m_pBreaks->IsColumnBreakAfter())
909 XFParagraph *pPara = new XFParagraph();
910 pPara->SetStyleName(m_AftColumnBreakName);
911 pCont->Add(pPara);
915 LwpVirtualLayout* LwpPara::GetLayoutWithMyStory()
917 LwpStory* pMyStory = NULL;
918 if (!m_Story.IsNull())
920 pMyStory = static_cast<LwpStory*>(m_Story.obj(VO_STORY));
921 if (!pMyStory)
923 return NULL;
926 return pMyStory->GetLayout(NULL);
929 return NULL;
932 LwpBulletStyleMgr* LwpPara::GetBulletStyleMgr()
934 if (m_pFoundry)
936 return m_pFoundry->GetBulletStyleMgr();
939 return NULL;
942 XFContentContainer* LwpPara::AddBulletList(XFContentContainer* pCont)
944 LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
945 if (!pBulletStyleMgr)
947 assert(false);
948 return NULL;
951 sal_uInt16 nLevel = m_nLevel;
952 sal_Bool bOrdered = sal_False;
953 LwpStory* pMyStory = this->GetStory();
955 pBulletStyleMgr->SetContinueFlag(m_bBullContinue);
956 #if 0
957 if (m_pSilverBullet->IsBulletOrdered())
959 LwpObjectID aSilverBulletID = pBulletStyleMgr->GetCurrentSilverBullet();
960 if (aSilverBulletID.IsNull())
962 pBulletStyleMgr->SetContinueFlag(sal_False);
964 else if (pMyStory && pMyStory->IsBullStyleUsedBefore(m_aBulletStyleName, this->m_aParaNumbering.GetPosition()))
966 pBulletStyleMgr->SetContinueFlag(sal_True);
968 /* else if (aSilverBulletID == *(m_pSilverBullet->GetObjectID()))
970 LwpNumberingOverride* pNumOver = pBulletStyleMgr->GetCurrentNumOver();
971 if (!pNumOver)
973 pBulletStyleMgr->SetContinueFlag(sal_False);
975 else if (m_aParaNumbering.GetPosition() == pNumOver->GetPosition())
977 pBulletStyleMgr->SetContinueFlag(sal_True);
980 else
982 pBulletStyleMgr->SetContinueFlag(sal_False);
985 pBulletStyleMgr->SetCurrentNumOver(m_aParaNumbering);
986 pBulletStyleMgr->SetCurrentSilverBullet(*(m_pSilverBullet->GetObjectID()));
988 #endif
990 if (m_pSilverBullet->IsBulletOrdered())
992 bOrdered = sal_True;
994 if (m_pSilverBullet->HasName())
996 // nLevel = m_pParaNumbering->GetPosition();
997 nLevel = m_aParaNumbering.GetPosition();
998 m_nLevel = nLevel;//add by ,for get para level
999 // m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
1002 return ( pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
1003 nLevel, m_pBullOver->IsSkip()) );
1006 LwpNumberingOverride* LwpPara::GetParaNumbering()
1008 return &m_aParaNumbering;
1009 #if 0
1010 LwpNumberingOverride* pNumbering = NULL;
1011 LwpParaStyle* pStyle = this->GetParaStyle();
1012 if (pStyle)
1014 pNumbering = pStyle->GetNumberingOverride();
1017 if (pNumbering)
1019 /* if (m_pParaNumbering)
1021 m_pParaNumbering->Override(pNumbering);
1023 m_aParaNumbering.Override(pNumbering);
1024 return pNumbering;
1026 else
1028 // return m_pParaNumbering;
1029 return &m_aParaNumbering;
1031 #endif
1034 void LwpForked3NotifyList::Read(LwpObjectStream* pObjStrm)
1036 m_PersistentList.Read(pObjStrm);
1039 void LwpNotifyListPersistent::Read(LwpObjectStream* pObjStrm)
1041 m_Head.ReadIndexed(pObjStrm);
1042 pObjStrm->SkipExtra();
1045 void LwpPara::Release()