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