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