update dev300-m57
[ooovba.git] / lotuswordpro / source / filter / lwpparastyle.cxx
blob077bd23f71fb2cbcbcba65f223487fc2a9696aa9
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /*************************************************************************
56 * @file
57 * For LWP filter architecture prototype
58 ************************************************************************/
59 /*************************************************************************
60 * Change History
61 Jan 2005 Created
62 ************************************************************************/
65 #include "lwpparastyle.hxx"
66 #include "lwpfilehdr.hxx"
67 #include "lwpoverride.hxx"
68 #include "lwpparaborderoverride.hxx"
69 #include "lwpbreaksoverride.hxx"
70 #include "lwpnumberingoverride.hxx"
71 #include "lwptaboverride.hxx"
72 #include "lwpbackgroundoverride.hxx"
73 #include "xfilter/xfdefs.hxx"
74 #include "xfilter/xfparastyle.hxx"
75 #include "xfilter/xfborders.hxx"
76 #include "lwpfont.hxx"
77 #include "lwpfoundry.hxx"
78 #include "lwppiece.hxx"
79 #include "lwpshadow.hxx"
80 #include "lwpborderstuff.hxx"
81 #include "lwpmargins.hxx"
82 #include "lwptabrack.hxx"
84 #include "lwpsilverbullet.hxx"
87 LwpParaStyle::LwpParaStyle(LwpObjectHeader& objHdr, LwpSvStream* pStrm) :
88 LwpTextStyle(objHdr, pStrm), m_pKinsokuOptsOverride(new LwpKinsokuOptsOverride),
89 m_pBulletOverride(new LwpBulletOverride)
93 LwpParaStyle::~LwpParaStyle()
95 if (m_pKinsokuOptsOverride)
97 delete m_pKinsokuOptsOverride;
100 if (m_pBulletOverride)
102 delete m_pBulletOverride;
106 void LwpParaStyle::Read()
108 LwpTextStyle::Read();
110 if (LwpFileHeader::m_nFileRevision < 0x000B)
112 // read many overrides
113 LwpAlignmentOverride aAlignOverride;
114 aAlignOverride.Read(m_pObjStrm);
116 LwpSpacingOverride aSpacingOverride;
117 aSpacingOverride.Read(m_pObjStrm);
119 LwpIndentOverride aIndentOverride;
120 aIndentOverride.Read(m_pObjStrm);
122 LwpParaBorderOverride aPBOverride;
123 aPBOverride.Read(m_pObjStrm);
125 LwpBreaksOverride aBreaksOverride;
126 aBreaksOverride.Read(m_pObjStrm);
128 LwpNumberingOverride aNumberingOverride;
129 aNumberingOverride.Read(m_pObjStrm);
131 LwpTabOverride aTabOverride;
132 aTabOverride.Read(m_pObjStrm);
135 else
137 m_AlignmentStyle.ReadIndexed(m_pObjStrm);
138 m_SpacingStyle.ReadIndexed(m_pObjStrm);
139 m_IndentStyle.ReadIndexed(m_pObjStrm);
140 m_BorderStyle.ReadIndexed(m_pObjStrm);
141 m_BreaksStyle.ReadIndexed(m_pObjStrm);
142 m_NumberingStyle.ReadIndexed(m_pObjStrm);
143 m_TabStyle.ReadIndexed(m_pObjStrm);
145 m_pKinsokuOptsOverride->Read(m_pObjStrm);
146 m_pBulletOverride->Read(m_pObjStrm);
148 if (m_pObjStrm->CheckExtra())
150 m_BackgroundStyle.ReadIndexed(m_pObjStrm);
151 m_pObjStrm->SkipExtra();
158 void LwpParaStyle::Apply(XFParaStyle *pParaStyle)
160 assert(pParaStyle);
161 LwpVirtualPiece *pPiece = NULL;
162 //alignment:
163 pPiece = (LwpVirtualPiece*)m_AlignmentStyle.obj();
164 if( pPiece )
166 LwpAlignmentOverride *pAlign = (LwpAlignmentOverride*)pPiece->GetOverride();
167 if( pAlign )
168 ApplyAlignment(pParaStyle,pAlign);
171 //don't known top and bottom indent now.
172 pPiece = (LwpVirtualPiece*)m_IndentStyle.obj();
173 if( pPiece )
175 LwpIndentOverride *pIndent = (LwpIndentOverride*)pPiece->GetOverride();
176 if( pIndent )
178 if (!m_pBulletOverride->IsInValid())//Add by ,for remove bullet indent in named bullet style
180 LwpIndentOverride* pNewIndent = new LwpIndentOverride;
181 *pNewIndent = *pIndent;
182 pNewIndent->SetMFirst(0);
183 pNewIndent->SetMRest(0);
184 ApplyIndent(NULL,pParaStyle,pNewIndent);
185 delete pNewIndent;
187 else
188 ApplyIndent(NULL,pParaStyle,pIndent);
191 //shadow & borders.
192 pPiece = (LwpVirtualPiece*)m_BorderStyle.obj();
193 if( pPiece )
195 LwpParaBorderOverride *pBorder = (LwpParaBorderOverride*)pPiece->GetOverride();
196 if( pBorder )
198 this->ApplyParaBorder(pParaStyle, pBorder);
202 pPiece = (LwpVirtualPiece*)m_SpacingStyle.obj();
203 if (pPiece)
205 LwpSpacingOverride *pSpacing = (LwpSpacingOverride*)pPiece->GetOverride();
206 if( pSpacing)
207 ApplySpacing(NULL,pParaStyle,pSpacing);
210 //paragraph background.
211 pPiece = (LwpVirtualPiece*)m_BackgroundStyle.obj();
212 if( pPiece )
214 LwpBackgroundOverride *pBack = (LwpBackgroundOverride*)pPiece->GetOverride();
215 if( pBack )
217 LwpColor color = pBack->GetBackColor();
218 XFColor aXFColor( color.To24Color() );
219 pParaStyle->SetBackColor( aXFColor );
223 // 01/28/2005
224 //add tab style
225 pPiece = (LwpVirtualPiece*)m_TabStyle.obj();
226 if( pPiece )
228 LwpTabOverride *pTab=(LwpTabOverride*)pPiece->GetOverride();
229 if(pTab)
231 ApplyTab(pParaStyle,pTab);
234 //add by 2005/02/16
235 pPiece = (LwpVirtualPiece*)m_BreaksStyle.obj();
236 if( pPiece )
238 LwpBreaksOverride *pBreak=(LwpBreaksOverride*)pPiece->GetOverride();
239 if(pBreak)
241 ApplyBreaks(pParaStyle,pBreak);
244 //add end
247 void LwpParaStyle::ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType, XFBorders* pXFBorders)
249 enumXFBorder eXFBorderSide = enumXFBorderNone;
250 switch (eType)
252 case LwpBorderStuff::LEFT:
253 eXFBorderSide = enumXFBorderLeft;
254 break;
255 case LwpBorderStuff::RIGHT:
256 eXFBorderSide = enumXFBorderRight;
257 break;
258 case LwpBorderStuff::TOP:
259 eXFBorderSide = enumXFBorderTop;
260 break;
261 case LwpBorderStuff::BOTTOM:
262 eXFBorderSide = enumXFBorderBottom;
263 break;
266 LwpColor aColor = pBorderStuff->GetSideColor(eType);
267 float fWidth = pBorderStuff->GetSideWidth(eType);
268 sal_uInt16 nType = pBorderStuff->GetSideType(eType);
270 switch (nType)
272 default://fall through!
273 case 0x14: //single fall through!
274 case 0x17: //treble
275 pXFBorders->SetWidth(eXFBorderSide, fWidth);
276 break;
277 case 0x15: //double , fall through!
278 case 0x16: //thick double
279 pXFBorders->SetDoubleLine(eXFBorderSide, sal_True, sal_False);
280 pXFBorders->SetWidthOutter(eXFBorderSide, static_cast<float>(fWidth*0.333));
281 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.334));
282 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.333));
283 // pXFBorders->SetWidth(eXFBorderSide, fWidth);
284 break;
285 case 0x18: //thick-thin
286 pXFBorders->SetDoubleLine(eXFBorderSide, sal_True, sal_False);
287 pXFBorders->SetWidthOutter(eXFBorderSide, static_cast<float>(fWidth*0.5));
288 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.25));
289 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.25));
290 break;
291 case 0x19: //thin-thick
292 pXFBorders->SetDoubleLine(eXFBorderSide, sal_True, sal_False);
293 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.7));
294 pXFBorders->SetWidthOutter(eXFBorderSide, static_cast<float>(fWidth*0.15));
295 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.15));
296 break;
299 if (aColor.IsValidColor())
301 XFColor aXFColor(aColor.To24Color());
302 pXFBorders->SetColor(eXFBorderSide, aXFColor );
306 void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder)
308 //convert LwpShadow:
309 LwpShadow *pShadow = pBorder->GetShadow();
310 if( pShadow )
312 LwpColor color = pShadow->GetColor();
313 float offsetX = pShadow->GetOffsetX();
314 float offsetY = pShadow->GetOffsetY();
316 if( offsetX && offsetY && color.IsValidColor() )
318 XFColor aXFColor(color.To24Color());
319 sal_Bool left = sal_False;
320 sal_Bool top = sal_False;
321 if( offsetX < 0 )
322 left = sal_True;
323 if( offsetY < 0 )
324 top = sal_True;
325 if( left )
327 if( top )
328 pParaStyle->SetShadow(enumXFShadowLeftTop,-offsetX,aXFColor);
329 else
330 pParaStyle->SetShadow(enumXFShadowLeftBottom,-offsetX,aXFColor);
332 else
334 if( top )
335 pParaStyle->SetShadow(enumXFShadowRightTop,offsetX,aXFColor);
336 else
337 pParaStyle->SetShadow(enumXFShadowRightBottom,offsetX,aXFColor);
342 //convert to XFBorders obejct:
343 LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff();
344 if( pBorderStuff && pBorderStuff->GetSide() != 0 )
346 XFBorders *pXFBorders = new XFBorders();
347 pParaStyle->SetBorders(pXFBorders);
349 LwpMargins* pMargins = pBorder->GetMargins();
351 // apply 4 borders respectively
352 LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
353 LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
354 float pMarginValue[4];
356 for (sal_uInt8 nC = 0; nC < 4; nC++)
358 if (pBorderStuff->HasSide(pType[nC]))
360 this->ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
362 //get border spacing to text content
363 if (pMargins)
365 pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
371 //apply border spacing to text content
372 pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
377 void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, LwpBreaksOverride* pBreaks)
379 if (pBreaks->IsKeepWithNext())
381 pParaStyle->SetBreaks(enumXFBreakKeepWithNext);
383 if (pBreaks->IsPageBreakBefore())
385 pParaStyle->SetBreaks(enumXFBreakBefPage);
387 if (pBreaks->IsPageBreakAfter())
389 pParaStyle->SetBreaks(enumXFBreakAftPage);
391 if (pBreaks->IsColumnBreakBefore())
393 pParaStyle->SetBreaks(enumXFBreakBefColumn);
395 if (pBreaks->IsColumnBreakAfter())
397 pParaStyle->SetBreaks(enumXFBreakAftColumn);
401 void LwpParaStyle::ApplyAlignment(XFParaStyle* pParaStyle, LwpAlignmentOverride* pAlign)
403 enumXFAlignType alignType = enumXFAlignStart;
404 LwpAlignmentOverride::AlignType type;
406 type = pAlign->GetAlignType();
407 pParaStyle->SetNumberRight(sal_False);//to identify its align attribute
408 switch(type)
410 case LwpAlignmentOverride::ALIGN_LEFT:
411 alignType = enumXFAlignStart;
412 break;
413 case LwpAlignmentOverride::ALIGN_RIGHT:
414 alignType = enumXFAlignEnd;
415 break;
416 case LwpAlignmentOverride::ALIGN_CENTER:
417 alignType = enumXFAlignCenter;
418 break;
419 case LwpAlignmentOverride::ALIGN_NUMERICLEFT://if non-number in table,ALIGN_NUMERICLEFT/RIGHT are useless
420 alignType = enumXFAlignStart; //note by 1/28
421 break;
422 case LwpAlignmentOverride::ALIGN_JUSTIFY:
423 case LwpAlignmentOverride::ALIGN_JUSTIFYALL:
424 alignType = enumXFAlignJustify;
425 break;
426 case LwpAlignmentOverride::ALIGN_NUMERICRIGHT:
427 pParaStyle->SetNumberRight(sal_True);//to identify its align attribute
428 alignType = enumXFAlignEnd;
429 break;
431 pParaStyle->SetAlignType(alignType);
434 void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, LwpIndentOverride* pIndent)
436 LwpPara* pParentPara;
437 if (pPara)
438 pParentPara = pPara->GetParent();
439 else
440 pParentPara = NULL;
442 LwpIndentOverride* pTotalIndent = new LwpIndentOverride;
443 if (pIndent->IsUseRelative() && pParentPara)
445 LwpIndentOverride* pParentIndent = pParentPara->GetIndent();
446 if (!pParentIndent)
447 return;
448 *pTotalIndent = *pIndent;
450 //add by ,for bullet only
451 if (pPara)
453 if (pPara->GetBulletFlag())
455 pTotalIndent->SetMAll(pParentIndent->GetMAll() + pTotalIndent->GetMAll());
456 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
457 pParaStyle->SetMargins(LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(
458 pTotalIndent->GetMAll())), pTotalIndent->GetRight());
459 pPara->SetIndent(pTotalIndent);
460 return;
463 //end add
464 sal_uInt16 relative = pParentIndent->GetRelative();
466 sal_Int32 Amount = pParentIndent->GetMAll();
468 if (relative == LwpIndentOverride::RELATIVE_FIRST)
469 Amount += pParentIndent->GetMFirst();
470 else if (relative == LwpIndentOverride::RELATIVE_REST)
471 Amount += pParentIndent->GetMRest();
472 pTotalIndent->SetMAll(Amount + pTotalIndent->GetMAll());
473 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
475 pParaStyle->SetIndent(pTotalIndent->GetFirst());
476 pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
477 pPara->SetIndent(pTotalIndent);
480 else
482 *pTotalIndent = *pIndent;
483 //add by
484 if (pPara)
486 if (pPara->GetBulletFlag())
488 // pParaStyle->SetIndent(LwpTools::ConvertFromUnits(pIndent->GetMAll()));
489 pParaStyle->SetMargins(LwpTools::ConvertToMetric(
490 LwpTools::ConvertFromUnits(pIndent->GetMAll())), pIndent->GetRight());
491 pPara->SetIndent(pTotalIndent);
492 return;
495 //end add
497 pParaStyle->SetIndent(pIndent->GetFirst());
498 pParaStyle->SetMargins(pIndent->GetLeft(), pIndent->GetRight());
499 if (pPara)
501 pPara->SetIndent(pTotalIndent);
506 void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing)
508 LwpSpacingCommonOverride* spacing = pSpacing->GetSpacing();
509 LwpSpacingCommonOverride* aboveline = pSpacing->GetAboveLineSpacing();
510 LwpSpacingCommonOverride* abovepara = pSpacing->GetAboveSpacing();
511 LwpSpacingCommonOverride* belowpara = pSpacing->GetBelowSpacing();
513 LwpSpacingCommonOverride::SpacingType type = spacing->GetType();
514 sal_Int32 amount = spacing->GetAmount();
515 sal_Int32 multiple = spacing->GetMultiple();
516 enumLHType xftype;
517 double height;
519 switch(type)
521 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
523 xftype = enumLHPercent;
524 height = double(multiple)/65536L*100;
525 pParaStyle->SetLineHeight(xftype,height);
527 break;
528 case LwpSpacingCommonOverride::SPACING_LEADING:
530 xftype = enumLHSpace;
531 height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(amount));
532 pParaStyle->SetLineHeight(xftype,height);
534 break;
535 case LwpSpacingCommonOverride::SPACING_CUSTOM:
537 xftype = enumLHHeight;
538 height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
539 pParaStyle->SetLineHeight(xftype,height);
541 break;
542 case LwpSpacingCommonOverride::SPACING_NONE:
543 break;
546 //TO DO: Above Line need to be processed!!!!!!! what it means?????? 1-26
548 type = abovepara->GetType();
549 amount = abovepara->GetAmount();
550 multiple = abovepara->GetMultiple();
551 double above_val =-1;
552 switch(type)
554 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
555 // above_val = LINE_HEIGHT*float(multiple)/65536L*100; //TO DO: 1-26
556 break;
557 case LwpSpacingCommonOverride::SPACING_LEADING:
558 break;
559 case LwpSpacingCommonOverride::SPACING_CUSTOM:
560 above_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
561 break;
562 case LwpSpacingCommonOverride::SPACING_NONE:
563 break;
566 type = belowpara->GetType();
567 amount = belowpara->GetAmount();
568 multiple = belowpara->GetMultiple();
569 double below_val=-1;
570 switch(type)
572 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
573 // below_val = LINE_HEIGHT*float(multiple)/65536L*100;//TO DO: 1-26
574 break;
575 case LwpSpacingCommonOverride::SPACING_LEADING:
576 break;
577 case LwpSpacingCommonOverride::SPACING_CUSTOM:
578 below_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
579 break;
580 case LwpSpacingCommonOverride::SPACING_NONE:
581 break;
584 if (pPara)
586 if (below_val != -1)
587 pPara->SetBelowSpacing(below_val);
588 LwpPara* pPrePara = static_cast<LwpPara*>(pPara->GetPrevious()->obj());
589 if (pPrePara && above_val != -1)
591 above_val += pPrePara->GetBelowSpacing();
596 pParaStyle->SetMargins(-1,-1,above_val,below_val);
598 /**************************************************************************
599 * @short:
600 * @descr:
601 * @param:
602 * @param:
603 * @return:
604 **************************************************************************/
605 void LwpParaStyle::ApplyTab(XFParaStyle *pParaStyle, LwpTabOverride *pTab)
607 LwpObjectID* pTabRackID = pTab->GetTabRackID();
608 if(pTabRackID->IsNull())
610 //assert(false);
611 return;
614 LwpTabRack* pTabRack = static_cast<LwpTabRack*>(pTabRackID->obj());
615 if(!pTabRack)
617 //assert(false);
618 return;
621 pParaStyle->ClearTabStyles();
622 //Get margin left value
623 double dMarginLeft = pParaStyle->GetMargins().GetLeft();
625 sal_uInt16 nNumTabs = pTabRack->GetNumTabs();
626 for(sal_uInt16 nIndex=0; nIndex<nNumTabs; nIndex++)
628 //get tab type
629 LwpTab* pTab = pTabRack->Lookup(nIndex);
630 if(!pTab)
631 return;
633 enumXFTab eType;
634 LwpTab::TabType type = pTab->GetTabType();
635 switch(type)
637 case LwpTab::TT_LEFT:
638 eType = enumXFTabLeft;
639 break;
640 case LwpTab::TT_CENTER:
641 eType = enumXFTabCenter;
642 break;
643 case LwpTab::TT_RIGHT:
644 eType = enumXFTabRight;
645 break;
646 case LwpTab::TT_NUMERIC:
647 eType = enumXFTabChar;
648 break;
651 //get position
652 sal_uInt32 nPos = pTab->GetPosition();
653 //different feature between SODC and lwp, the tab length must minus the margin left of para.
654 double fLen = LwpTools::ConvertFromUnitsToMetric(nPos) - dMarginLeft;
656 //get leader type
657 sal_Unicode cLeader;
658 LwpTab::LeaderType leader= pTab->GetLeaderType();
659 switch(leader)
661 case LwpTab::TL_NONE:
662 cLeader = 0x20; //space
663 break;
664 case LwpTab::TL_HYPHEN: //'-'
665 cLeader = 0xAD;
666 break;
667 case LwpTab::TL_DOT: //'.'
668 cLeader = 0x2E;
669 break;
670 case LwpTab::TL_LINE: //'_'
671 cLeader = 0x5F;
672 break;
675 sal_Unicode cAlignChar = static_cast<sal_Unicode>(pTab->GetAlignChar());
677 pParaStyle->AddTabStyle(eType,fLen,cLeader,cAlignChar);
683 void LwpParaStyle::RegisterStyle()
685 XFParaStyle* pStyle = new XFParaStyle();
687 //Set name
688 OUString styleName = GetName()->str();
689 pStyle->SetStyleName(styleName);
691 //Create font
692 LwpFontManager* pFontMgr = m_pFoundry->GetFontManger();
693 XFFont* pFont = pFontMgr->CreateFont(m_nFinalFontID);
694 pStyle->SetFont(pFont);
696 //Set other paragraph properties...
698 Apply(pStyle);
699 //Add style
700 LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
701 pStyleMgr->AddStyle(*GetObjectID(), pStyle);
703 /* // add list style for bullet
704 if (!m_pBulletOverride)
706 return;
708 LwpSilverBullet* pSilverBullet = static_cast<LwpSilverBullet*>(m_pBulletOverride->GetSilverBullet().obj());
709 if (!pSilverBullet)
711 return;
714 pSilverBullet->SetFoundry(m_pFoundry);
715 pSilverBullet->RegisterStyle();*/
718 LwpAlignmentOverride* LwpParaStyle::GetAlignment()
720 if (m_AlignmentStyle.obj()!= NULL)
721 return static_cast<LwpAlignmentOverride*>(static_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj())->GetOverride());
722 else
723 return NULL;
726 LwpIndentOverride* LwpParaStyle::GetIndent()
728 if (m_IndentStyle.obj() != NULL)
729 return static_cast<LwpIndentOverride*>(static_cast<LwpIndentPiece*>(m_IndentStyle.obj())->GetOverride());
730 else
731 return NULL;
734 LwpSpacingOverride* LwpParaStyle::GetSpacing()
736 if (m_SpacingStyle.obj() != NULL)
737 return static_cast<LwpSpacingOverride*>(static_cast<LwpSpacingPiece*>(m_SpacingStyle.obj())->GetOverride());
738 else
739 return NULL;
742 LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const
744 if(m_BorderStyle.IsNull()) return NULL;
745 return static_cast<LwpParaBorderOverride*>
746 (static_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE))->GetOverride());
749 LwpBreaksOverride* LwpParaStyle::GetBreaks() const
751 if(m_BreaksStyle.IsNull()) return NULL;
752 return static_cast<LwpBreaksOverride*>
753 (static_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE))->GetOverride());
756 LwpBulletOverride* LwpParaStyle::GetBulletOverride() const
758 return m_pBulletOverride;
761 LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const
763 if(m_NumberingStyle.IsNull()) return NULL;
764 return static_cast<LwpNumberingOverride*>
765 (static_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE))->GetOverride());
769 /**************************************************************************
770 * @short:
771 * @descr:
772 * @param:
773 * @param:
774 * @return:
775 **************************************************************************/
776 LwpTabOverride* LwpParaStyle::GetTabOverride() const
778 if(m_TabStyle.obj() != NULL)
779 return (LwpTabOverride*)static_cast<LwpTabPiece*>(m_TabStyle.obj())->GetOverride();
780 else
781 return NULL;
784 sal_Bool LwpParaStyle::IsNumberRight()
786 LwpAlignmentOverride* pAlign = GetAlignment();
787 if (pAlign)
789 LwpAlignmentOverride::AlignType type;
790 type = pAlign->GetAlignType();
791 if (type == LwpAlignmentOverride::ALIGN_NUMERICRIGHT)
792 return sal_True;
794 return sal_False;