Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / lotuswordpro / source / filter / lwppara.cxx
blobf27b6840ff1b548582893efb43cac17db089acb1
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 ************************************************************************/
61 #include "lwppara.hxx"
62 #include "lwpglobalmgr.hxx"
63 #include "lwpfilehdr.hxx"
64 #include "lwpparaproperty.hxx"
65 #include "lwptools.hxx"
66 #include "lwpparastyle.hxx"
67 #include "xfilter/xffont.hxx"
68 #include "xfilter/xftextstyle.hxx"
69 #include "xfilter/xfstylemanager.hxx"
70 #include "xfilter/xfparagraph.hxx"
71 #include "xfilter/xftextcontent.hxx"
72 #include "xfilter/xftextspan.hxx"
73 #include "xfilter/xfmargins.hxx"
74 #include "xfilter/xftabstop.hxx"
75 #include "xfilter/xflinebreak.hxx"
76 #include "xfilter/xfsection.hxx"
77 #include "xfilter/xfsectionstyle.hxx"
78 #include "xfilter/xfcolor.hxx"
79 #include "xfilter/xfhyperlink.hxx"
80 #include "xfilter/xfliststyle.hxx"
81 #include "lwpcharsetmgr.hxx"
82 #include "lwpsection.hxx"
83 #include "lwplayout.hxx"
84 #include "lwpusewhen.hxx"
85 #include "lwpbulletstylemgr.hxx"
86 #include "lwpstory.hxx"
87 #include "lwpsilverbullet.hxx"
88 #include "xfilter/xflist.hxx"
89 #include "xfilter/xfframe.hxx"
91 #include "lwpdivinfo.hxx"
92 #include "lwpdoc.hxx"
93 #include "lwpholder.hxx"
94 #include "lwppagehint.hxx"
96 #include "lwpdropcapmgr.hxx"
97 #include "lwptable.hxx"
99 LwpPara::LwpPara(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
100 : LwpDLVList(objHdr, pStrm)
101 , m_nOrdinal(0)
102 , m_nFlags(0)
103 , m_nLevel(0)
104 , m_pProps(nullptr)
105 , m_pBreaks(nullptr)
106 , m_pIndentOverride(nullptr)
107 , m_FontID(0)
108 , m_AllText("")
109 , m_bHasBullet(false)
110 , m_pSilverBullet(nullptr)
111 , m_pBullOver(nullptr)
112 , m_bBullContinue(false)
113 , m_SectionStyleName("")
114 , m_bHasDropcap(false)
115 , m_nLines(0)
116 , m_nChars(0)
117 , m_pDropcapLayout(nullptr)
118 , m_BelowSpacing(0)
119 , m_pXFContainer(nullptr)
123 LwpPara::~LwpPara()
126 if (m_pBreaks)
128 delete m_pBreaks;
129 m_pBreaks = nullptr;
131 /* if (m_pParaNumbering)
133 delete m_pParaNumbering;
134 m_pParaNumbering = NULL;
137 if (m_pBullOver)
139 delete m_pBullOver;
140 m_pBullOver = nullptr;
142 if(m_pIndentOverride)
144 delete m_pIndentOverride;
147 LwpParaProperty* pNextProp;
148 while(m_pProps)
150 pNextProp = m_pProps->GetNext();
151 delete m_pProps;
152 m_pProps = pNextProp;
156 void LwpPara::Read()
158 LwpDLVList::Read();
160 bool Simple;
161 bool Notify = false;
162 if(LwpFileHeader::m_nFileRevision<0x0006)
163 Simple = false;
164 else if(LwpFileHeader::m_nFileRevision<0x000B)
165 Simple = m_pObjStrm->QuickReaduInt8() != 0;
166 else
168 sal_uInt8 Flag = m_pObjStrm->QuickReaduInt8();
170 const int DISK_SIMPLE = 1;
171 const int DISK_NOTIFY = 2;
173 Simple = (Flag & DISK_SIMPLE) != 0;
174 Notify = (Flag & DISK_NOTIFY) != 0;
177 if(!Simple)
179 m_nOrdinal = m_pObjStrm->QuickReaduInt32();
180 if(LwpFileHeader::m_nFileRevision<0x000B)
182 // TODO: to process
183 assert(false);
184 /*pCForked3NotifyList Notify = new CForked3NotifyList(this);
185 Notify->GetExtraList()->QuickRead(pFile);
186 Notify->QuickRead(pFile);
187 if(Notify->GetExtraList()->IsEmpty() &&
188 Notify->IsEmpty())
189 delete Notify;
190 else
191 cNotifyList = Notify;*/
193 else
195 if (Notify)
197 LwpForked3NotifyList* pNotifyList = new LwpForked3NotifyList();
198 pNotifyList->GetExtraList().Read(m_pObjStrm);
199 pNotifyList->Read(m_pObjStrm);
200 delete pNotifyList;
204 else
205 m_nOrdinal = 0x0001;
207 m_nFlags = m_pObjStrm->QuickReaduInt16();
208 m_ParaStyle.ReadIndexed(m_pObjStrm);
210 if(!Simple)
212 m_Hint.Read(m_pObjStrm);
215 m_Story.ReadIndexed(m_pObjStrm);
216 if(!Simple)
218 if(LwpFileHeader::m_nFileRevision<0x000B)
220 // TODO: to process
221 assert(false);
222 /*PropList = new CParaPropListProperty(this);
223 PropList->GetList()->QuickRead(pFile);
224 if(PropList->GetList()->IsEmpty())
226 delete PropList;
227 PropList = LNULL;
230 m_nLevel = m_pObjStrm->QuickReaduInt16();
232 if (m_nLevel > 9)
234 m_nLevel = 9;
237 else
238 m_nLevel = 0x0001;
240 m_Fribs.SetPara(this);// 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 if (!m_pXFContainer)
251 return;
252 m_pXFContainer->ToXml(pOutputStream);
253 m_pXFContainer->Reset();
254 delete m_pXFContainer;
255 m_pXFContainer = nullptr;
258 void LwpPara::XFConvert(XFContentContainer* pCont)
260 m_pXFContainer = pCont;
262 LwpStory *pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
264 if (pStory && pStory->GetDropcapFlag())
266 ParseDropcapContent();
267 return;
270 //Add the break before para
271 if (m_pBreaks && m_nOrdinal!=0)
272 AddBreakBefore(pCont);
274 //Create an XFPara for this VO_PARA
275 XFParagraph *pPara = new XFParagraph;
276 rtl::Reference<XFContentContainer> xHolder(pPara);
277 pPara->SetStyleName(m_StyleName);
279 if(!m_SectionStyleName.isEmpty())
281 XFSection* pSection = CreateXFSection();
282 if (pStory)
283 pStory->AddXFContent(pSection);
284 //pSection->Add(pPara);
285 m_pXFContainer = pSection;
288 if (m_bHasBullet && m_pSilverBullet)
290 XFContentContainer* pListItem = AddBulletList(m_pXFContainer);
291 if (pListItem)
293 pListItem->Add(pPara);
296 else if (m_pXFContainer)
298 LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
299 if (pBulletStyleMgr)
301 pBulletStyleMgr->SetCurrentSilverBullet(LwpObjectID());
302 pBulletStyleMgr->SetContinueFlag(false);
304 m_pXFContainer->Add(pPara);
307 m_Fribs.SetXFPara(pPara);
308 m_Fribs.XFConvert();
310 if (m_pBreaks && m_pXFContainer)
311 AddBreakAfter(m_pXFContainer);
314 void LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle)
316 //get story
317 LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
318 //if pagelayout is modified, register the pagelayout
319 if(pStory && pStory->IsPMModified())
321 bool bNewSection = pStory->IsNeedSection();
322 LwpPageLayout* pLayout = pStory->GetCurrentLayout();
323 if(bNewSection)
325 RegisterNewSectionStyle(pLayout);
328 //register master page style
329 XFParaStyle* pOverStyle = new XFParaStyle();
330 *pOverStyle = *pBaseStyle;
331 pOverStyle->SetStyleName( "");
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).m_pStyle->GetStyleName();
340 * @short register paragraph style
342 void LwpPara::RegisterStyle()
343 { //1 reg autostyle
344 // m_Fribs.SetPara(this);
345 // m_Fribs.RegisterStyle();
347 //2 reg para style
348 if (!m_pFoundry)
349 return;
350 XFParaStyle* pBaseStyle = dynamic_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(m_ParaStyle));
351 if (pBaseStyle == nullptr) return;
352 m_StyleName = pBaseStyle->GetStyleName();//such intf to be added
353 m_ParentStyleName = m_StyleName;
354 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
356 LwpParaStyle* pParaStyle = GetParaStyle();
357 if (pParaStyle && pParaStyle->GetIndent())
359 std::unique_ptr<LwpIndentOverride> pIndentOverride(GetParaStyle()->GetIndent()->clone());
360 delete m_pIndentOverride;
361 m_pIndentOverride = pIndentOverride.release();
364 XFParaStyle* pOverStyle = nullptr;
365 bool noSpacing = true;
366 LwpParaProperty* pBulletProps = nullptr, *pNumberingProps = nullptr;
368 if (m_pProps != nullptr)
370 bool noIndent = true;
371 pOverStyle = new XFParaStyle;
372 *pOverStyle = *pBaseStyle;
373 pOverStyle->SetStyleName("");
374 LwpParaProperty* pProps = m_pProps;
375 sal_uInt32 PropType;
376 LwpParaStyle& rParaStyle = dynamic_cast<LwpParaStyle&>(*m_ParaStyle.obj());
377 while (pProps)
379 PropType = pProps->GetType();
380 switch(PropType)
382 case PP_LOCAL_ALIGN:
384 LwpAlignmentOverride *pAlignment = static_cast<LwpParaAlignProperty*>(pProps)->GetAlignment();
385 if (pAlignment)
387 if (!rParaStyle.GetAlignment())
388 OverrideAlignment(nullptr, pAlignment, pOverStyle);
389 else
391 std::unique_ptr<LwpAlignmentOverride> const pAlign(
392 rParaStyle.GetAlignment()->clone());
393 OverrideAlignment(pAlign.get(),
394 pAlignment,
395 pOverStyle);
398 break;
400 case PP_LOCAL_INDENT:
402 noIndent = false;
403 LwpIndentOverride *pIndent = static_cast<LwpParaIndentProperty*>(pProps)->GetIndent();
404 if (pIndent)
406 if (!rParaStyle.GetIndent())
407 OverrideIndent(nullptr, pIndent, pOverStyle);
408 else
409 OverrideIndent(m_pIndentOverride, pIndent, pOverStyle);
411 break;
413 case PP_LOCAL_SPACING:
415 noSpacing = false;
416 LwpSpacingOverride *pSpacing = static_cast<LwpParaSpacingProperty*>(pProps)->GetSpacing();
417 if (pSpacing)
419 if (!rParaStyle.GetSpacing())
420 OverrideSpacing(nullptr, pSpacing, pOverStyle);
421 else
423 std::unique_ptr<LwpSpacingOverride> const
424 pNewSpacing(rParaStyle.GetSpacing()->clone());
425 OverrideSpacing(pNewSpacing.get(), pSpacing, pOverStyle);
428 break;
430 case PP_LOCAL_BORDER:
432 OverrideParaBorder(pProps, pOverStyle);
433 break;
435 case PP_LOCAL_BREAKS:
437 OverrideParaBreaks(pProps, pOverStyle);
438 break;
440 case PP_LOCAL_BULLET:
442 pBulletProps = pProps;
443 break;
445 case PP_LOCAL_NUMBERING:
447 pNumberingProps = pProps;
448 break;
450 case PP_LOCAL_TABRACK:
452 break;
454 case PP_LOCAL_BACKGROUND:
456 LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps)->GetBackground();
457 if (pBGOver)
459 LwpBackgroundStuff& rBGStuff = pBGOver->GetBGStuff();
460 if (!rBGStuff.IsTransparent() )
462 if (rBGStuff.IsPatternFill())
464 XFBGImage* pXFBGImage = rBGStuff.GetFillPattern();
465 pOverStyle->SetBackImage(pXFBGImage);
467 else
469 LwpColor* pColor = rBGStuff.GetFillColor();
470 if (pColor && pColor->IsValidColor())
472 XFColor aXFColor( pColor->To24Color());
473 pOverStyle->SetBackColor( aXFColor );
478 break;
480 default:
481 break;
483 pProps = pProps->GetNext();
486 if (noIndent && m_pIndentOverride)
488 if (m_pIndentOverride->IsUseRelative() && GetParent())
490 OverrideIndent(nullptr,m_pIndentOverride,pOverStyle);
493 if (!m_ParentStyleName.isEmpty())
494 pOverStyle->SetParentStyleName(m_ParentStyleName);
495 m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
498 else //use named style
500 if (m_pIndentOverride)
502 if (m_pIndentOverride->IsUseRelative() && GetParent())
504 pOverStyle = new XFParaStyle;
505 *pOverStyle = *pBaseStyle;
506 OverrideIndent(nullptr,m_pIndentOverride,pOverStyle);
507 if (!m_ParentStyleName.isEmpty())
508 pOverStyle->SetParentStyleName(m_ParentStyleName);
509 m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
514 if (IsInCell())
516 XFParaStyle* pOldStyle = pXFStyleManager->FindParaStyle(m_StyleName);
517 if (pOldStyle->GetNumberRight())
519 pOverStyle = new XFParaStyle;
520 *pOverStyle = *pOldStyle;
521 pOverStyle->SetAlignType(enumXFAlignStart);
522 if (!m_ParentStyleName.isEmpty())
523 pOverStyle->SetParentStyleName(m_ParentStyleName);
524 m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
528 // override bullet and numbering
529 OverrideParaBullet(pBulletProps);
530 OverrideParaNumbering(pNumberingProps);
532 //register bullet style
533 LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
534 if (pBulletStyleMgr)
536 // if has bullet or numbering
537 if (m_bHasBullet)
539 //if it's normal bullet
540 if (m_pSilverBullet)
542 if (m_pSilverBullet->HasName())
544 m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
546 else if (!m_pBullOver->IsEditable())
548 m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_pBullOver, m_pIndentOverride);
551 // test codes
552 if (m_pSilverBullet->IsBulletOrdered())
554 OUString aPreBullStyleName;
555 LwpNumberingOverride* pNumbering = GetParaNumbering();
556 sal_uInt16 nPosition = pNumbering->GetPosition();
557 bool bLesser = m_pSilverBullet->IsLesserLevel(nPosition);
558 LwpPara* pPara = this;
559 LwpPara* pPrePara = nullptr;
560 sal_uInt16 nNum = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
562 nFoundBound = nLevel = pNumbering->GetLevel();
563 if (nPosition == pNumbering->GetPosition())
565 nFoundBound++;
567 bool bHeading = pNumbering->IsHeading();
569 while(true)
571 /*// When we hit the hint paragraph, we can stop and check the hint.
572 if (qNumberHint && (qPara == qNumberHint->GetPara()) &&
573 qNumberHint->Lookup(qSilverBullet, Level, Position, &Offset))
575 Num += Offset;
576 break;
579 LwpSilverBullet* pParaSilverBullet = pPara->GetSilverBullet();
580 pNumbering = pPara->GetParaNumbering();
582 if (pPara->GetObjectID() != GetObjectID())
584 if (!pParaSilverBullet)
586 break;
589 /* If lesser, stop when we hit an outline style whose level is
590 * higher than our current level.
592 // restart based on Outline level?
593 if (pNumbering && bLesser && (!bHeading || pNumbering->IsHeading()))
595 if (nFoundLevel != 0xffff)
597 if (pNumbering->GetLevel() < nFoundLevel)
599 break;
601 if ((pNumbering->GetLevel() == nFoundLevel)
602 && (pParaSilverBullet->GetObjectID() != m_pSilverBullet->GetObjectID()
603 || pNumbering->GetPosition() != nPosition))
605 break;
608 else
610 if (pNumbering && pNumbering->GetLevel() < nFoundBound && pParaSilverBullet
611 && (pParaSilverBullet->GetObjectID() != m_pSilverBullet->GetObjectID()
612 || pNumbering->GetPosition() != nPosition))
614 nFoundBound = pNumbering->GetLevel();
619 /*if (qSpecificStyle
620 && qSpecificStyle == qPara->GetParaStyle(LTRUE))
621 break;
623 // See if we crossed a section boundary
624 if (ResetSection)
626 CurrPos.SetPara(qPara);
627 if (CurrPos <= SectionPos)
628 break;
632 // Don't bump the number if this bullet is skipped
633 if (m_pBullOver->IsSkip())
635 else if ( pParaSilverBullet
636 && pParaSilverBullet->GetObjectID() == m_pSilverBullet->GetObjectID()
637 && pNumbering && nPosition == pNumbering->GetPosition())
639 if (bLesser)
641 if (nFoundLevel != 0xffff)
643 if (nFoundLevel == pNumbering->GetLevel())
645 aPreBullStyleName = pPara->GetBulletStyleName();
646 nNum++;
649 else if (pNumbering->GetLevel() <= nLevel)
651 if (pNumbering->GetLevel() >= nFoundBound)
653 break;
655 nFoundLevel = pNumbering->GetLevel();
656 aPreBullStyleName = pPara->GetBulletStyleName();
657 nNum++;
660 else
662 aPreBullStyleName = pPara->GetBulletStyleName();
663 nNum++;
667 pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious().obj(VO_PARA).get());
669 if (!pPrePara)
671 LwpStory* pStory = pPara->GetStory();
672 pPrePara = pStory ? pStory->GetLastParaOfPreviousStory() : nullptr;
674 if (!pPrePara)
676 break;
679 pPara = pPrePara;
681 nNum = nNum ? nNum : 1;
683 if (nNum > 1)
685 m_aBulletStyleName = aPreBullStyleName;
686 m_bBullContinue = true;
688 else
690 m_bBullContinue = false;
691 if (IsInCell())
693 XFListStyle* pOldStyle = static_cast<XFListStyle*>(pXFStyleManager->FindStyle(m_aBulletStyleName));
694 if (pOldStyle)
696 XFListStyle* pNewStyle = new XFListStyle(*pOldStyle);
697 m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName();
702 LwpStory* pMyStory = GetStory();
703 if (pMyStory)
705 if (pMyStory->IsBullStyleUsedBefore(m_aBulletStyleName, m_pParaNumbering->GetPosition()))
707 //m_bBullContinue = sal_True;
709 else
711 pMyStory->AddBullStyleName2List(m_aBulletStyleName, m_pParaNumbering->GetPosition());
716 // end of test codes
721 if (noSpacing)
723 LwpPara* pPrePara = dynamic_cast<LwpPara*>(GetPrevious().obj().get());
724 if (pPrePara && pPrePara->GetBelowSpacing()!=0)
726 pOverStyle = new XFParaStyle;
727 *pOverStyle = *GetXFParaStyle();
728 XFMargins* pMargin = &pOverStyle->GetMargins();
729 pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
730 if (!m_ParentStyleName.isEmpty())
731 pOverStyle->SetParentStyleName(m_ParentStyleName);
732 m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
736 //register tab style
737 if(m_Fribs.HasFrib(FRIB_TAG_TAB))
739 XFParaStyle* pNewParaStyle = new XFParaStyle;
740 *pNewParaStyle = *GetXFParaStyle();
741 //pOverStyle->SetStyleName("");
742 RegisterTabStyle(pNewParaStyle);
743 if (!m_ParentStyleName.isEmpty())
744 pNewParaStyle->SetParentStyleName(m_ParentStyleName);
745 m_StyleName = pXFStyleManager->AddStyle(pNewParaStyle).m_pStyle->GetStyleName();
748 //register master page;
749 RegisterMasterPage(GetXFParaStyle());
751 // reg auto style,lay here for pagebreak need overrided para style
752 m_Fribs.SetPara(this);
753 m_Fribs.RegisterStyle();
755 if (m_bHasDropcap)
757 GatherDropcapInfo();
758 XFParaStyle* pStyle = new XFParaStyle;
759 *pStyle = *GetXFParaStyle();
760 pStyle->SetDropCap(m_nChars-1,m_nLines);
761 if (!m_ParentStyleName.isEmpty())
762 pStyle->SetParentStyleName(m_ParentStyleName);
763 m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
765 // maybe useful for further version
766 // deleted because Leader of Table is not supported in this version
767 //AddTabStyleForTOC();
770 void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
772 if( !pLayout )
773 return;
775 XFSectionStyle* pSectStyle= new XFSectionStyle();
776 XFColumns* pColumns = pLayout->GetXFColumns();
777 if(pColumns)
779 pSectStyle->SetColumns(pColumns);
781 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
782 m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName();
785 XFSection* LwpPara::CreateXFSection()
787 XFSection* pXFSection = new XFSection();
788 pXFSection->SetStyleName(m_SectionStyleName);
789 m_SectionStyleName.clear();
790 return pXFSection;
793 /**************************************************************************
794 * @descr: register tab style
795 **************************************************************************/
796 void LwpPara::RegisterTabStyle(XFParaStyle* pXFParaStyle)
798 LwpTabOverride aFinaOverride;
799 LwpTabOverride* pBase = nullptr;
800 //get the tabrack from the current layout
801 LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
802 LwpMiddleLayout* pLayout = pStory ? pStory->GetTabLayout() : nullptr;
803 if(pLayout)
805 pBase = pLayout->GetTabOverride();
806 if(pBase)
808 pBase->Override(&aFinaOverride);
812 //get the tabrack from the base parastyle
813 LwpParaStyle* pParaStyle = GetParaStyle();
814 pBase = pParaStyle->GetTabOverride();
815 if(pBase)
817 pBase->Override(&aFinaOverride);
819 //get the tabrack from the local property
820 pBase = GetLocalTabOverride();
821 if(pBase)
823 pBase->Override(&aFinaOverride);
826 LwpParaStyle::ApplyTab(pXFParaStyle, &aFinaOverride);
829 * @short parse dropcap text
831 void LwpPara::ParseDropcapContent()
833 if (!GetFoundry())
834 return;
835 XFParagraph* pDropcap = GetFoundry()->GetDropcapMgr()->GetXFPara();
836 if (pDropcap)
838 m_Fribs.SetXFPara(pDropcap);
839 m_Fribs.XFConvert();
843 * @short add paragraph break attribute
845 void LwpPara::AddBreakBefore(XFContentContainer* pCont)
847 if (!m_pBreaks || !pCont)
848 return;
849 if (m_pBreaks->IsPageBreakBefore())
851 XFParagraph *pPara = new XFParagraph();
852 pPara->SetStyleName(m_BefPageBreakName);
853 pCont->Add(pPara);
855 else if (m_pBreaks->IsColumnBreakBefore())
857 XFParagraph *pPara = new XFParagraph();
858 pPara->SetStyleName(m_BefColumnBreakName);
859 pCont->Add(pPara);
863 void LwpPara::AddBreakAfter(XFContentContainer* pCont)
865 if (!m_pBreaks)
866 return;
867 if (m_pBreaks->IsPageBreakAfter())
869 XFParagraph *pPara = new XFParagraph();
870 pPara->SetStyleName(m_AftPageBreakName);
871 pCont->Add(pPara);
873 else if (m_pBreaks->IsColumnBreakAfter())
875 XFParagraph *pPara = new XFParagraph();
876 pPara->SetStyleName(m_AftColumnBreakName);
877 pCont->Add(pPara);
881 LwpBulletStyleMgr* LwpPara::GetBulletStyleMgr()
883 if (m_pFoundry)
885 return m_pFoundry->GetBulletStyleMgr();
888 return nullptr;
891 XFContentContainer* LwpPara::AddBulletList(XFContentContainer* pCont)
893 LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
894 if (!pBulletStyleMgr)
896 assert(false);
897 return nullptr;
900 sal_uInt16 nLevel = m_nLevel;
901 bool bOrdered = false;
902 /*LwpStory* pMyStory =*/ GetStory();
904 pBulletStyleMgr->SetContinueFlag(m_bBullContinue);
906 if (m_pSilverBullet->IsBulletOrdered())
908 bOrdered = true;
910 if (m_pSilverBullet->HasName())
912 nLevel = m_pParaNumbering->GetPosition();
913 m_nLevel = nLevel;//for get para level
916 return ( pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
917 nLevel, m_pBullOver->IsSkip()) );
920 LwpNumberingOverride* LwpPara::GetParaNumbering()
922 return m_pParaNumbering.get();
925 void LwpForked3NotifyList::Read(LwpObjectStream* pObjStrm)
927 m_PersistentList.Read(pObjStrm);
930 void LwpNotifyListPersistent::Read(LwpObjectStream* pObjStrm)
932 m_Head.ReadIndexed(pObjStrm);
933 pObjStrm->SkipExtra();
936 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */