fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / lotuswordpro / source / filter / lwppara.cxx
blob5628772dfdef04155f0f318122a4c208aa4047dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /*************************************************************************
57 * @file
58 * For LWP filter architecture prototype
59 ************************************************************************/
60 /*************************************************************************
61 * Change History
62 Jan 2005 Created
63 ************************************************************************/
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"
95 #include "lwpdivinfo.hxx"
96 #include "lwpdoc.hxx"
97 #include "lwpholder.hxx"
98 #include "lwppagehint.hxx"
100 #include "lwpdropcapmgr.hxx"
101 #include "lwptable.hxx"
103 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 , m_pDropcapLayout(NULL), m_BelowSpacing(0), m_pXFContainer(NULL)
111 m_pProps = NULL;
112 m_SectionStyleName = A2OUSTR("");
113 m_AllText = A2OUSTR("");
116 LwpPara::~LwpPara()
119 if (m_pBreaks)
121 delete m_pBreaks;
122 m_pBreaks = NULL;
124 /* if (m_pParaNumbering)
126 delete m_pParaNumbering;
127 m_pParaNumbering = NULL;
130 if (m_pBullOver)
132 delete m_pBullOver;
133 m_pBullOver = NULL;
135 if(m_pIndentOverride)
137 delete m_pIndentOverride;
140 LwpParaProperty* pNextProp;
141 while(m_pProps)
143 pNextProp = m_pProps->GetNext();
144 delete m_pProps;
145 m_pProps = pNextProp;
149 void LwpPara::Read()
151 LwpDLVList::Read();
153 sal_Bool Simple;
154 sal_Bool Notify = sal_False;
155 if(LwpFileHeader::m_nFileRevision<0x0006)
156 Simple = sal_False;
157 else if(LwpFileHeader::m_nFileRevision<0x000B)
158 Simple = m_pObjStrm->QuickReaduInt8();
159 else
161 sal_uInt8 Flag = m_pObjStrm->QuickReaduInt8();
163 const int DISK_SIMPLE = 1;
164 const int DISK_NOTIFY = 2;
166 Simple = (Flag & DISK_SIMPLE) ? sal_True : sal_False;
167 Notify = (Flag & DISK_NOTIFY) ? sal_True : sal_False;
170 if(!Simple)
172 m_nOrdinal = m_pObjStrm->QuickReaduInt32();
173 if(LwpFileHeader::m_nFileRevision<0x000B)
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;*/
186 else
188 if (Notify)
190 LwpForked3NotifyList* pNotifyList = new LwpForked3NotifyList();
191 pNotifyList->GetExtraList()->Read(m_pObjStrm);
192 pNotifyList->Read(m_pObjStrm);
193 delete pNotifyList;
197 else
198 m_nOrdinal = 0x0001;
200 m_nFlags = m_pObjStrm->QuickReaduInt16();
201 m_ParaStyle.ReadIndexed(m_pObjStrm);
203 if(!Simple)
205 m_Hint.Read(m_pObjStrm);
206 if (IsBadHintsInFile())
208 // This hint is no good, so throw it away -- SDC 9/28/95
209 m_Hint.Reset();
213 m_Story.ReadIndexed(m_pObjStrm);
214 if(!Simple)
216 if(LwpFileHeader::m_nFileRevision<0x000B)
218 // TODO: to process
219 assert(false);
220 /*PropList = new CParaPropListProperty(this);
221 PropList->GetList()->QuickRead(pFile);
222 if(PropList->GetList()->IsEmpty())
224 delete PropList;
225 PropList = LNULL;
228 m_nLevel = m_pObjStrm->QuickReaduInt16();
230 // test
231 if (m_nLevel > 9)
233 m_nLevel = 9;
235 // test ends
237 else
238 m_nLevel = 0x0001;
240 m_Fribs.SetPara(this);//add by 2/1, for silver bullet
241 m_Fribs.ReadPara(m_pObjStrm);
243 m_pProps = LwpParaProperty::ReadPropertyList(m_pObjStrm,this);
246 void LwpPara::Parse(IXFStream* pOutputStream)
248 m_pXFContainer = new XFContentContainer;
249 XFConvert(m_pXFContainer);
250 m_pXFContainer->ToXml(pOutputStream);
251 m_pXFContainer->Reset();
252 delete m_pXFContainer;
253 m_pXFContainer = NULL;
256 void LwpPara::XFConvert(XFContentContainer* pCont)
258 m_pXFContainer = pCont;
260 LwpStory *pStory = dynamic_cast<LwpStory*>(m_Story.obj());
262 if (pStory && pStory->GetDropcapFlag() == sal_True)
264 ParseDropcapContent();
265 return;
268 //Add the break before para
269 if (m_pBreaks && m_nOrdinal!=0)
270 AddBreakBefore(pCont);
272 //Create an XFPara for this VO_PARA
273 XFParagraph *pPara = new XFParagraph;
274 pPara->SetStyleName(m_StyleName);
276 if(!m_SectionStyleName.isEmpty())
278 XFSection* pSection = CreateXFSection();
279 if (pStory)
280 pStory->AddXFContent(pSection);
281 //pSection->Add(pPara);
282 m_pXFContainer = pSection;
285 if (m_bHasBullet && m_pSilverBullet)
287 XFContentContainer* pListItem = AddBulletList(m_pXFContainer);
288 if (pListItem)
290 pListItem->Add(pPara);
293 else
295 LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
296 if (pBulletStyleMgr)
298 pBulletStyleMgr->SetCurrentSilverBullet(LwpObjectID());
299 pBulletStyleMgr->SetContinueFlag(sal_False);
301 m_pXFContainer->Add(pPara);
304 m_Fribs.SetXFPara(pPara);
305 m_Fribs.XFConvert();
307 if (m_pBreaks)
308 AddBreakAfter(m_pXFContainer);
311 sal_Bool LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle)
313 sal_Bool bSuccess = sal_False;
314 //get story
315 LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj());
316 //if pagelayout is modified, register the pagelayout
317 if(pStory && pStory->IsPMModified())
319 sal_Bool bNewSection = sal_False;
320 bNewSection = pStory->IsNeedSection();
321 LwpPageLayout* pLayout = pStory->GetCurrentLayout();
322 if(bNewSection)
324 RegisterNewSectionStyle(pLayout);
327 bSuccess = sal_True;
328 //register master page style
329 XFParaStyle* pOverStyle = new XFParaStyle();
330 *pOverStyle = *pBaseStyle;
331 pOverStyle->SetStyleName( A2OUSTR(""));
332 pOverStyle->SetMasterPage(pLayout->GetStyleName());
333 if (!m_ParentStyleName.isEmpty())
334 pOverStyle->SetParentStyleName(m_ParentStyleName);
335 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
336 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
338 return bSuccess;
341 * @short register paragraph style
343 void LwpPara::RegisterStyle()
344 { //1 reg autostyle
345 // m_Fribs.SetPara(this);
346 // m_Fribs.RegisterStyle();
348 //2 reg para style
349 if (!m_pFoundry)
350 return;
351 XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(m_ParaStyle));
352 if (pBaseStyle == NULL) return;
353 m_StyleName = pBaseStyle->GetStyleName();//such intf to be added
354 m_ParentStyleName = m_StyleName;
355 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
357 if (GetParaStyle()->GetIndent())
359 std::auto_ptr<LwpIndentOverride> pIndentOverride(GetParaStyle()->GetIndent()->clone());
360 delete m_pIndentOverride;
361 m_pIndentOverride = pIndentOverride.release();
364 XFParaStyle* pOverStyle = NULL;
365 sal_Bool noSpacing = sal_True;
366 sal_Bool noIndent = sal_True;
367 LwpParaProperty* pBulletProps = NULL, *pNumberingProps = NULL;
369 if (m_pProps != NULL)
371 pOverStyle = new XFParaStyle;
372 *pOverStyle = *pBaseStyle;
373 pOverStyle->SetStyleName(A2OUSTR(""));
374 LwpParaProperty* pProps = m_pProps;
375 sal_uInt32 PropType;
376 LwpParaStyle* pParaStyle = dynamic_cast<LwpParaStyle*>(m_ParaStyle.obj());
377 while(pProps)
379 PropType = pProps->GetType();
380 switch(PropType)
382 case PP_LOCAL_ALIGN:
384 if (!pParaStyle->GetAlignment())
385 OverrideAlignment(NULL,static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),pOverStyle);
386 else
388 boost::scoped_ptr<LwpAlignmentOverride> const pAlign(
389 pParaStyle->GetAlignment()->clone());
390 OverrideAlignment(pAlign.get(),
391 static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment(),
392 pOverStyle);
395 break;
396 case PP_LOCAL_INDENT:
398 noIndent = sal_False;
399 if (!pParaStyle->GetIndent())
400 OverrideIndent(NULL,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
402 else
404 OverrideIndent(m_pIndentOverride,static_cast<LwpParaIndentProperty*>(pProps)->GetIndent(),pOverStyle);
407 break;
408 case PP_LOCAL_SPACING:
410 noSpacing = sal_False;
411 if (!pParaStyle->GetSpacing())
412 OverrideSpacing(NULL,static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing(),pOverStyle);
413 else
415 boost::scoped_ptr<LwpSpacingOverride> const
416 pSpacing(pParaStyle->GetSpacing()->clone());
417 OverrideSpacing(pSpacing.get(),
418 static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing(),
419 pOverStyle);
422 break;
423 // 01/25/2005
424 case PP_LOCAL_BORDER:
426 OverrideParaBorder(pProps, pOverStyle);
427 break;
429 case PP_LOCAL_BREAKS:
431 OverrideParaBreaks(pProps, pOverStyle);
432 break;
434 case PP_LOCAL_BULLET:
436 pBulletProps = pProps;
437 // OverrideParaBullet(pProps);
438 break;
440 case PP_LOCAL_NUMBERING:
442 pNumberingProps = pProps;
443 // OverrideParaNumbering(pProps);
444 break;
446 //end
447 case PP_LOCAL_TABRACK:
449 //, 01/28/05
450 /*LwpTabOverride* pTabOverride=pParaStyle->GetTabOverride();
451 if(!pTabOverride)
453 OverrideTab(NULL,static_cast<LwpParaTabRackProperty*>(pProps)->GetTab(),pOverStyle);
455 else
457 OverrideTab(pTabOverride,static_cast<LwpParaTabRackProperty*>(pProps)->GetTab(),pOverStyle);
459 break;
461 case PP_LOCAL_BACKGROUND:
463 /* LwpBackgroundOverride aBackground;
464 if (!pParaStyle->GetBackground())
465 OverrideBackground(NULL,static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground(),pOverStyle);
466 else
468 aBackground = *(pParaStyle->GetaBackground());
469 OverrideBackground(&aBackground,static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground(),pOverStyle);
472 // modified by , 06/03/2005
473 LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground();
474 if (pBGOver)
476 LwpBackgroundStuff* pBGStuff = pBGOver->GetBGStuff();
477 if (pBGStuff && !pBGStuff->IsTransparent() )
479 if (pBGStuff->IsPatternFill())
481 XFBGImage* pXFBGImage = pBGStuff->GetFillPattern();
482 pOverStyle->SetBackImage(pXFBGImage);
484 else
486 LwpColor* pColor = pBGStuff->GetFillColor();
487 if (pColor && pColor->IsValidColor())
489 XFColor aXFColor( pColor->To24Color());
490 pOverStyle->SetBackColor( aXFColor );
495 // end modified
496 break;
498 default:
499 break;
501 pProps = pProps->GetNext();
504 if (noIndent && m_pIndentOverride)
506 if (m_pIndentOverride->IsUseRelative() && GetParent())
508 OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
511 if (!m_ParentStyleName.isEmpty())
512 pOverStyle->SetParentStyleName(m_ParentStyleName);
513 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
516 else //use named style
518 if (m_pIndentOverride)
520 if (m_pIndentOverride->IsUseRelative() && GetParent())
522 pOverStyle = new XFParaStyle;
523 *pOverStyle = *pBaseStyle;
524 OverrideIndent(NULL,m_pIndentOverride,pOverStyle);
525 if (!m_ParentStyleName.isEmpty())
526 pOverStyle->SetParentStyleName(m_ParentStyleName);
527 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
532 if (IsInCell())
534 XFParaStyle* pOldStyle = pXFStyleManager->FindParaStyle(m_StyleName);
535 if (pOldStyle->GetNumberRight())
537 pOverStyle = new XFParaStyle;
538 *pOverStyle = *pOldStyle;
539 pOverStyle->SetAlignType(enumXFAlignStart);
540 if (!m_ParentStyleName.isEmpty())
541 pOverStyle->SetParentStyleName(m_ParentStyleName);
542 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
546 // override bullet and numbering
547 OverrideParaBullet(pBulletProps);
548 OverrideParaNumbering(pNumberingProps);
550 //add by
551 //register bullet style
552 LwpBulletStyleMgr* pBulletStyleMgr = this->GetBulletStyleMgr();
553 if (pBulletStyleMgr)
555 // if has bullet or numbering
556 if (m_bHasBullet)
558 //if it's normal bullet
559 if (m_pSilverBullet)
561 if (m_pSilverBullet->HasName())
563 m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
565 else if (!m_pBullOver->IsEditable())
567 m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_pBullOver, m_pIndentOverride);
570 // test codes
571 if (m_pSilverBullet->IsBulletOrdered())
573 OUString aPreBullStyleName;
574 LwpNumberingOverride* pNumbering = this->GetParaNumbering();
575 sal_uInt16 nPosition = pNumbering->GetPosition();
576 sal_Bool bLesser = m_pSilverBullet->IsLesserLevel(nPosition);
577 /*sal_Bool bResetSection =*/ m_pSilverBullet->IsNewSection(nPosition);
578 sal_Bool bHeading;
579 LwpPara* pPara = this;
580 LwpPara* pPrePara = NULL;
581 LwpSilverBullet* pParaSilverBullet = NULL;
582 sal_uInt16 nNum = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
584 nFoundBound = nLevel = pNumbering->GetLevel();
585 if (nPosition == pNumbering->GetPosition())
587 nFoundBound++;
589 bHeading = pNumbering->IsHeading();
591 while(true)
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))
597 Num += Offset;
598 break;
601 pParaSilverBullet = pPara->GetSilverBullet();
602 pNumbering = pPara->GetParaNumbering();
604 if (*(pPara->GetObjectID()) != *(this->GetObjectID()))
606 if (!pParaSilverBullet)
608 break;
611 /* If lesser, stop when we hit an outline style whose level is
612 * higher than our current level.
614 // restart based on Outline level?
615 if (pNumbering && bLesser && (bHeading ? pNumbering->IsHeading() : sal_True))
617 if (nFoundLevel != 0xffff)
619 if (pNumbering->GetLevel() < nFoundLevel)
621 break;
623 if ((pNumbering->GetLevel() == nFoundLevel)
624 && (*(pParaSilverBullet->GetObjectID()) != *(m_pSilverBullet->GetObjectID())
625 || pNumbering->GetPosition() != nPosition))
627 break;
630 else
632 if (pNumbering && pNumbering->GetLevel() < nFoundBound && pParaSilverBullet
633 && (*(pParaSilverBullet->GetObjectID()) != *(m_pSilverBullet->GetObjectID())
634 || pNumbering->GetPosition() != nPosition))
636 nFoundBound = pNumbering->GetLevel();
641 /*if (qSpecificStyle
642 && qSpecificStyle == qPara->GetParaStyle(LTRUE))
643 break;
645 // See if we crossed a section boundary
646 if (ResetSection)
648 CurrPos.SetPara(qPara);
649 if (CurrPos <= SectionPos)
650 break;
654 // Don't bump the number if this bullet is skipped
655 if (m_pBullOver->IsSkip())
657 else if ( pParaSilverBullet
658 && *(pParaSilverBullet->GetObjectID()) == *(m_pSilverBullet->GetObjectID())
659 && pNumbering && nPosition == pNumbering->GetPosition())
661 if (bLesser)
663 if (nFoundLevel != 0xffff)
665 if (nFoundLevel == pNumbering->GetLevel())
667 aPreBullStyleName = pPara->GetBulletStyleName();
668 nNum++;
671 else if (pNumbering->GetLevel() <= nLevel)
673 if (pNumbering->GetLevel() >= nFoundBound)
675 break;
677 nFoundLevel = pNumbering->GetLevel();
678 aPreBullStyleName = pPara->GetBulletStyleName();
679 nNum++;
682 else
684 aPreBullStyleName = pPara->GetBulletStyleName();
685 nNum++;
689 if (pPara && pPara->GetPrevious())
690 pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj(VO_PARA));
691 else
692 pPrePara=NULL;
694 if (!pPrePara)
696 LwpStory* pStory = pPara->GetStory();
697 pPrePara = pStory->GetLastParaOfPreviousStory();
699 if (!pPrePara)
701 break;
704 pPara = pPrePara;
706 nNum = nNum ? nNum : 1;
708 if (nNum > 1)
710 m_aBulletStyleName = aPreBullStyleName;
711 m_bBullContinue = sal_True;
713 else
715 m_bBullContinue = sal_False;
716 if (this->IsInCell())
718 XFListStyle* pOldStyle = static_cast<XFListStyle*>(pXFStyleManager->FindStyle(m_aBulletStyleName));
719 if (pOldStyle)
721 XFListStyle* pNewStyle = new XFListStyle(*pOldStyle);
722 m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle)->GetStyleName();
727 LwpStory* pMyStory = this->GetStory();
728 if (pMyStory)
730 if (pMyStory->IsBullStyleUsedBefore(m_aBulletStyleName, m_pParaNumbering->GetPosition()))
732 //m_bBullContinue = sal_True;
734 else
736 pMyStory->AddBullStyleName2List(m_aBulletStyleName, m_pParaNumbering->GetPosition());
741 // end of test codes
745 //end add
747 if (noSpacing && GetPrevious())
749 LwpPara* pPrePara = dynamic_cast<LwpPara*>(GetPrevious()->obj());
750 if (pPrePara && pPrePara->GetBelowSpacing()!=0)
752 pOverStyle = new XFParaStyle;
753 *pOverStyle = *GetXFParaStyle();
754 XFMargins* pMargin = &pOverStyle->GetMargins();
755 pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
756 if (!m_ParentStyleName.isEmpty())
757 pOverStyle->SetParentStyleName(m_ParentStyleName);
758 m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName();
762 //register tab style
763 if(m_Fribs.HasFrib(FRIB_TAG_TAB))
765 XFParaStyle* pParaStyle = new XFParaStyle;
766 *pParaStyle = *GetXFParaStyle();
767 //pOverStyle->SetStyleName(A2OUSTR(""));
768 this->RegisterTabStyle(pParaStyle);
769 if (!m_ParentStyleName.isEmpty())
770 pParaStyle->SetParentStyleName(m_ParentStyleName);
771 m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
774 //register master page;
775 RegisterMasterPage(GetXFParaStyle());
777 // reg auto style,lay here for pagebreak need overrided para style
778 m_Fribs.SetPara(this);
779 m_Fribs.RegisterStyle();
781 if (m_bHasDropcap == sal_True)
783 GatherDropcapInfo();
784 XFParaStyle* pStyle = new XFParaStyle;
785 *pStyle = *GetXFParaStyle();
786 pStyle->SetDropCap(m_nChars-1,m_nLines);
787 if (!m_ParentStyleName.isEmpty())
788 pStyle->SetParentStyleName(m_ParentStyleName);
789 m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
791 // maybe useful for futer version
792 // deleted because Leader of Table is not supported in this version
793 //AddTabStyleForTOC();
796 void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
798 if( !pLayout )
799 return;
801 XFSectionStyle* pSectStyle= new XFSectionStyle();
802 XFColumns* pColumns = pLayout->GetXFColumns();
803 if(pColumns)
805 pSectStyle->SetColumns(pColumns);
807 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
808 m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName();
811 XFSection* LwpPara::CreateXFSection()
813 XFSection* pXFSection = new XFSection();
814 pXFSection->SetStyleName(m_SectionStyleName);
815 m_SectionStyleName = A2OUSTR("");
816 return pXFSection;
819 /**************************************************************************
820 * @descr: register tab style
821 * @param:
822 * @param:
823 * @return:
824 **************************************************************************/
825 void LwpPara::RegisterTabStyle(XFParaStyle* pXFParaStyle)
827 LwpTabOverride aFinaOverride;
828 LwpTabOverride* pBase = NULL;
829 //get the tabrack from the current layout
830 LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj());
831 LwpMiddleLayout* pLayout = pStory ? pStory->GetTabLayout() : NULL;
832 if(pLayout)
834 pBase = pLayout->GetTabOverride();
835 if(pBase)
837 pBase->Override(&aFinaOverride);
841 //get the tabrack from the base parastyle
842 LwpParaStyle* pParaStyle = GetParaStyle();
843 pBase = pParaStyle->GetTabOverride();
844 if(pBase)
846 pBase->Override(&aFinaOverride);
848 //get the tabrack from the local property
849 pBase = GetLocalTabOverride();
850 if(pBase)
852 pBase->Override(&aFinaOverride);
855 LwpParaStyle::ApplyTab(pXFParaStyle, &aFinaOverride);
858 * @short parse dropcap text
860 void LwpPara::ParseDropcapContent()
862 if (!GetFoundry())
863 return;
864 XFParagraph* pDropcap = GetFoundry()->GetDropcapMgr()->GetXFPara();
865 if (pDropcap)
867 m_Fribs.SetXFPara(pDropcap);
868 m_Fribs.XFConvert();
872 * @short add paragraph break attribute
874 void LwpPara::AddBreakBefore(XFContentContainer* pCont)
876 if (!m_pBreaks)
877 return;
878 if (m_pBreaks->IsPageBreakBefore())
880 XFParagraph *pPara = new XFParagraph();
881 pPara->SetStyleName(m_BefPageBreakName);
882 pCont->Add(pPara);
884 else if (m_pBreaks->IsColumnBreakBefore())
886 XFParagraph *pPara = new XFParagraph();
887 pPara->SetStyleName(m_BefColumnBreakName);
888 pCont->Add(pPara);
892 void LwpPara::AddBreakAfter(XFContentContainer* pCont)
894 if (!m_pBreaks)
895 return;
896 if (m_pBreaks->IsPageBreakAfter())
898 XFParagraph *pPara = new XFParagraph();
899 pPara->SetStyleName(m_AftPageBreakName);
900 pCont->Add(pPara);
902 else if (m_pBreaks->IsColumnBreakAfter())
904 XFParagraph *pPara = new XFParagraph();
905 pPara->SetStyleName(m_AftColumnBreakName);
906 pCont->Add(pPara);
910 LwpBulletStyleMgr* LwpPara::GetBulletStyleMgr()
912 if (m_pFoundry)
914 return m_pFoundry->GetBulletStyleMgr();
917 return NULL;
920 XFContentContainer* LwpPara::AddBulletList(XFContentContainer* pCont)
922 LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
923 if (!pBulletStyleMgr)
925 assert(false);
926 return NULL;
929 sal_uInt16 nLevel = m_nLevel;
930 sal_Bool bOrdered = sal_False;
931 /*LwpStory* pMyStory =*/ GetStory();
933 pBulletStyleMgr->SetContinueFlag(m_bBullContinue);
935 if (m_pSilverBullet->IsBulletOrdered())
937 bOrdered = sal_True;
939 if (m_pSilverBullet->HasName())
941 nLevel = m_pParaNumbering->GetPosition();
942 m_nLevel = nLevel;//add by ,for get para level
943 // m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
946 return ( pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
947 nLevel, m_pBullOver->IsSkip()) );
950 LwpNumberingOverride* LwpPara::GetParaNumbering()
952 return m_pParaNumbering.get();
955 void LwpForked3NotifyList::Read(LwpObjectStream* pObjStrm)
957 m_PersistentList.Read(pObjStrm);
960 void LwpNotifyListPersistent::Read(LwpObjectStream* pObjStrm)
962 m_Head.ReadIndexed(pObjStrm);
963 pObjStrm->SkipExtra();
966 void LwpPara::Release()
969 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */