Bump version to 4.3-4
[LibreOffice.git] / lotuswordpro / source / filter / lwpparastyle.cxx
blob70b8e93ea622b2838d152ea663e24aee8c3138a5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /*************************************************************************
57 * @file
58 * For LWP filter architecture prototype
59 ************************************************************************/
60 /*************************************************************************
61 * Change History
62 Jan 2005 Created
63 ************************************************************************/
65 #include <boost/scoped_ptr.hpp>
67 #include "lwpparastyle.hxx"
68 #include "lwpfilehdr.hxx"
69 #include "lwpoverride.hxx"
70 #include "lwpparaborderoverride.hxx"
71 #include "lwpbreaksoverride.hxx"
72 #include "lwpnumberingoverride.hxx"
73 #include "lwptaboverride.hxx"
74 #include "lwpbackgroundoverride.hxx"
75 #include "xfilter/xfdefs.hxx"
76 #include "xfilter/xfparastyle.hxx"
77 #include "xfilter/xfborders.hxx"
78 #include "lwpfont.hxx"
79 #include "lwpfoundry.hxx"
80 #include "lwppiece.hxx"
81 #include "lwpshadow.hxx"
82 #include "lwpborderstuff.hxx"
83 #include "lwpmargins.hxx"
84 #include "lwptabrack.hxx"
86 #include "lwpsilverbullet.hxx"
88 LwpParaStyle::LwpParaStyle(LwpObjectHeader& objHdr, LwpSvStream* pStrm) :
89 LwpTextStyle(objHdr, pStrm), m_pKinsokuOptsOverride(new LwpKinsokuOptsOverride),
90 m_pBulletOverride(new LwpBulletOverride)
94 LwpParaStyle::~LwpParaStyle()
96 if (m_pKinsokuOptsOverride)
98 delete m_pKinsokuOptsOverride;
101 if (m_pBulletOverride)
103 delete m_pBulletOverride;
107 void LwpParaStyle::Read()
109 LwpTextStyle::Read();
111 if (LwpFileHeader::m_nFileRevision < 0x000B)
113 // read many overrides
114 LwpAlignmentOverride aAlignOverride;
115 aAlignOverride.Read(m_pObjStrm);
117 LwpSpacingOverride aSpacingOverride;
118 aSpacingOverride.Read(m_pObjStrm);
120 LwpIndentOverride aIndentOverride;
121 aIndentOverride.Read(m_pObjStrm);
123 LwpParaBorderOverride aPBOverride;
124 aPBOverride.Read(m_pObjStrm);
126 LwpBreaksOverride aBreaksOverride;
127 aBreaksOverride.Read(m_pObjStrm);
129 LwpNumberingOverride aNumberingOverride;
130 aNumberingOverride.Read(m_pObjStrm);
132 LwpTabOverride aTabOverride;
133 aTabOverride.Read(m_pObjStrm);
136 else
138 m_AlignmentStyle.ReadIndexed(m_pObjStrm);
139 m_SpacingStyle.ReadIndexed(m_pObjStrm);
140 m_IndentStyle.ReadIndexed(m_pObjStrm);
141 m_BorderStyle.ReadIndexed(m_pObjStrm);
142 m_BreaksStyle.ReadIndexed(m_pObjStrm);
143 m_NumberingStyle.ReadIndexed(m_pObjStrm);
144 m_TabStyle.ReadIndexed(m_pObjStrm);
146 m_pKinsokuOptsOverride->Read(m_pObjStrm);
147 m_pBulletOverride->Read(m_pObjStrm);
149 if (m_pObjStrm->CheckExtra())
151 m_BackgroundStyle.ReadIndexed(m_pObjStrm);
152 m_pObjStrm->SkipExtra();
158 void LwpParaStyle::Apply(XFParaStyle *pParaStyle)
160 assert(pParaStyle);
161 if (!pParaStyle)
162 return;
164 LwpVirtualPiece *pPiece = NULL;
165 //alignment:
166 pPiece = dynamic_cast<LwpVirtualPiece*>(m_AlignmentStyle.obj());
167 if( pPiece )
169 LwpAlignmentOverride *pAlign = dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
170 if( pAlign )
171 ApplyAlignment(pParaStyle,pAlign);
174 //don't known top and bottom indent now.
175 pPiece = dynamic_cast<LwpVirtualPiece*>(m_IndentStyle.obj());
176 if( pPiece )
178 LwpIndentOverride *pIndent = dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
179 if( pIndent )
181 if (!m_pBulletOverride->IsInValid())//Add by ,for remove bullet indent in named bullet style
183 boost::scoped_ptr<LwpIndentOverride> pNewIndent(pIndent->clone());
184 pNewIndent->SetMFirst(0);
185 pNewIndent->SetMRest(0);
186 ApplyIndent(NULL, pParaStyle, pNewIndent.get());
188 else
189 ApplyIndent(NULL,pParaStyle,pIndent);
192 //shadow & borders.
193 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BorderStyle.obj());
194 if( pPiece )
196 LwpParaBorderOverride *pBorder = dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
197 if( pBorder )
199 this->ApplyParaBorder(pParaStyle, pBorder);
203 pPiece = dynamic_cast<LwpVirtualPiece*>(m_SpacingStyle.obj());
204 if (pPiece)
206 LwpSpacingOverride *pSpacing = dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
207 if( pSpacing)
208 ApplySpacing(NULL,pParaStyle,pSpacing);
211 //paragraph background.
212 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BackgroundStyle.obj());
213 if( pPiece )
215 LwpBackgroundOverride *pBack = dynamic_cast<LwpBackgroundOverride*>(pPiece->GetOverride());
216 if( pBack )
218 LwpColor color = pBack->GetBackColor();
219 XFColor aXFColor( color.To24Color() );
220 pParaStyle->SetBackColor( aXFColor );
224 //add tab style
225 pPiece = dynamic_cast<LwpVirtualPiece*>(m_TabStyle.obj());
226 if( pPiece )
228 LwpTabOverride *pTab = dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
229 if(pTab)
231 ApplyTab(pParaStyle,pTab);
234 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BreaksStyle.obj());
235 if( pPiece )
237 LwpBreaksOverride *pBreak = dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
238 if(pBreak)
240 ApplyBreaks(pParaStyle,pBreak);
246 void LwpParaStyle::ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType, XFBorders* pXFBorders)
248 enumXFBorder eXFBorderSide = enumXFBorderNone;
249 switch (eType)
251 case LwpBorderStuff::LEFT:
252 eXFBorderSide = enumXFBorderLeft;
253 break;
254 case LwpBorderStuff::RIGHT:
255 eXFBorderSide = enumXFBorderRight;
256 break;
257 case LwpBorderStuff::TOP:
258 eXFBorderSide = enumXFBorderTop;
259 break;
260 case LwpBorderStuff::BOTTOM:
261 eXFBorderSide = enumXFBorderBottom;
262 break;
263 default:
264 break;
267 LwpColor aColor = pBorderStuff->GetSideColor(eType);
268 float fWidth = pBorderStuff->GetSideWidth(eType);
269 sal_uInt16 nType = pBorderStuff->GetSideType(eType);
271 switch (nType)
273 default://fall through!
274 case 0x14: //single fall through!
275 case 0x17: //treble
276 pXFBorders->SetWidth(eXFBorderSide, fWidth);
277 break;
278 case 0x15: //double , fall through!
279 case 0x16: //thick double
280 pXFBorders->SetDoubleLine(eXFBorderSide, true, false);
281 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.333));
282 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.334));
283 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.333));
284 // pXFBorders->SetWidth(eXFBorderSide, fWidth);
285 break;
286 case 0x18: //thick-thin
287 pXFBorders->SetDoubleLine(eXFBorderSide, true, false);
288 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.5));
289 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.25));
290 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.25));
291 break;
292 case 0x19: //thin-thick
293 pXFBorders->SetDoubleLine(eXFBorderSide, true, false);
294 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.7));
295 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.15));
296 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.15));
297 break;
300 if (aColor.IsValidColor())
302 XFColor aXFColor(aColor.To24Color());
303 pXFBorders->SetColor(eXFBorderSide, aXFColor );
307 void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder)
309 //convert LwpShadow:
310 LwpShadow *pShadow = pBorder->GetShadow();
311 if( pShadow )
313 LwpColor color = pShadow->GetColor();
314 float offsetX = pShadow->GetOffsetX();
315 float offsetY = pShadow->GetOffsetY();
317 if( offsetX && offsetY && color.IsValidColor() )
319 XFColor aXFColor(color.To24Color());
320 bool left = false;
321 bool top = false;
322 if( offsetX < 0 )
323 left = true;
324 if( offsetY < 0 )
325 top = true;
326 if( left )
328 if( top )
329 pParaStyle->SetShadow(enumXFShadowLeftTop,-offsetX,aXFColor);
330 else
331 pParaStyle->SetShadow(enumXFShadowLeftBottom,-offsetX,aXFColor);
333 else
335 if( top )
336 pParaStyle->SetShadow(enumXFShadowRightTop,offsetX,aXFColor);
337 else
338 pParaStyle->SetShadow(enumXFShadowRightBottom,offsetX,aXFColor);
343 //convert to XFBorders object:
344 LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff();
345 if( pBorderStuff && pBorderStuff->GetSide() != 0 )
347 XFBorders *pXFBorders = new XFBorders();
348 pParaStyle->SetBorders(pXFBorders);
350 LwpMargins* pMargins = pBorder->GetMargins();
352 // apply 4 borders respectively
353 LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
354 LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
355 float pMarginValue[4];
357 for (sal_uInt8 nC = 0; nC < 4; nC++)
359 if (pBorderStuff->HasSide(pType[nC]))
361 this->ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
363 //get border spacing to text content
364 if (pMargins)
366 pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
372 //apply border spacing to text content
373 pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
378 void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, LwpBreaksOverride* pBreaks)
380 if (pBreaks->IsKeepWithNext())
382 pParaStyle->SetBreaks(enumXFBreakKeepWithNext);
384 if (pBreaks->IsPageBreakBefore())
386 pParaStyle->SetBreaks(enumXFBreakBefPage);
388 if (pBreaks->IsPageBreakAfter())
390 pParaStyle->SetBreaks(enumXFBreakAftPage);
392 if (pBreaks->IsColumnBreakBefore())
394 pParaStyle->SetBreaks(enumXFBreakBefColumn);
396 if (pBreaks->IsColumnBreakAfter())
398 pParaStyle->SetBreaks(enumXFBreakAftColumn);
402 void LwpParaStyle::ApplyAlignment(XFParaStyle* pParaStyle, LwpAlignmentOverride* pAlign)
404 enumXFAlignType alignType = enumXFAlignStart;
405 LwpAlignmentOverride::AlignType type;
407 type = pAlign->GetAlignType();
408 pParaStyle->SetNumberRight(false);//to identify its align attribute
409 switch(type)
411 case LwpAlignmentOverride::ALIGN_LEFT:
412 alignType = enumXFAlignStart;
413 break;
414 case LwpAlignmentOverride::ALIGN_RIGHT:
415 alignType = enumXFAlignEnd;
416 break;
417 case LwpAlignmentOverride::ALIGN_CENTER:
418 alignType = enumXFAlignCenter;
419 break;
420 case LwpAlignmentOverride::ALIGN_NUMERICLEFT://if non-number in table,ALIGN_NUMERICLEFT/RIGHT are useless
421 alignType = enumXFAlignStart; //note by 1/28
422 break;
423 case LwpAlignmentOverride::ALIGN_JUSTIFY:
424 case LwpAlignmentOverride::ALIGN_JUSTIFYALL:
425 alignType = enumXFAlignJustify;
426 break;
427 case LwpAlignmentOverride::ALIGN_NUMERICRIGHT:
428 pParaStyle->SetNumberRight(true);//to identify its align attribute
429 alignType = enumXFAlignEnd;
430 break;
431 default:
432 break;
434 pParaStyle->SetAlignType(alignType);
437 void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, LwpIndentOverride* pIndent)
439 LwpPara* pParentPara;
440 if (pPara)
441 pParentPara = pPara->GetParent();
442 else
443 pParentPara = NULL;
445 SAL_WNODEPRECATED_DECLARATIONS_PUSH
446 std::auto_ptr<LwpIndentOverride> pTotalIndent(new LwpIndentOverride);
447 SAL_WNODEPRECATED_DECLARATIONS_POP
448 if (pIndent->IsUseRelative() && pParentPara)
450 LwpIndentOverride* pParentIndent = pParentPara->GetIndent();
451 if (!pParentIndent)
452 return;
453 pTotalIndent.reset(pIndent->clone());
455 //add by ,for bullet only
456 if (pPara)
458 if (pPara->GetBulletFlag())
460 pTotalIndent->SetMAll(pParentIndent->GetMAll() + pTotalIndent->GetMAll());
461 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
462 pParaStyle->SetMargins(LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(
463 pTotalIndent->GetMAll())), pTotalIndent->GetRight());
464 pPara->SetIndent(pTotalIndent.release());
465 return;
468 //end add
469 sal_uInt16 relative = pParentIndent->GetRelative();
471 sal_Int32 Amount = pParentIndent->GetMAll();
473 if (relative == LwpIndentOverride::RELATIVE_FIRST)
474 Amount += pParentIndent->GetMFirst();
475 else if (relative == LwpIndentOverride::RELATIVE_REST)
476 Amount += pParentIndent->GetMRest();
477 pTotalIndent->SetMAll(Amount + pTotalIndent->GetMAll());
478 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
480 pParaStyle->SetIndent(pTotalIndent->GetFirst());
481 pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
482 pPara->SetIndent(pTotalIndent.release());
485 else
487 pTotalIndent.reset(pIndent->clone());
488 //add by
489 if (pPara)
491 if (pPara->GetBulletFlag())
493 // pParaStyle->SetIndent(LwpTools::ConvertFromUnits(pIndent->GetMAll()));
494 pParaStyle->SetMargins(LwpTools::ConvertToMetric(
495 LwpTools::ConvertFromUnits(pIndent->GetMAll())), pIndent->GetRight());
496 pPara->SetIndent(pTotalIndent.release());
497 return;
500 //end add
502 pParaStyle->SetIndent(pIndent->GetFirst());
503 pParaStyle->SetMargins(pIndent->GetLeft(), pIndent->GetRight());
504 if (pPara)
506 pPara->SetIndent(pTotalIndent.release());
511 void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing)
513 LwpSpacingCommonOverride* spacing = pSpacing->GetSpacing();
514 LwpSpacingCommonOverride* abovepara = pSpacing->GetAboveSpacing();
515 LwpSpacingCommonOverride* belowpara = pSpacing->GetBelowSpacing();
517 LwpSpacingCommonOverride::SpacingType type = spacing->GetType();
518 sal_Int32 amount = spacing->GetAmount();
519 sal_Int32 multiple = spacing->GetMultiple();
520 enumLHType xftype;
521 double height;
523 switch(type)
525 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
527 xftype = enumLHPercent;
528 height = double(multiple)/65536L*100;
529 pParaStyle->SetLineHeight(xftype,height);
531 break;
532 case LwpSpacingCommonOverride::SPACING_LEADING:
534 xftype = enumLHSpace;
535 height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(amount));
536 pParaStyle->SetLineHeight(xftype,height);
538 break;
539 case LwpSpacingCommonOverride::SPACING_CUSTOM:
541 xftype = enumLHHeight;
542 height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
543 pParaStyle->SetLineHeight(xftype,height);
545 break;
546 case LwpSpacingCommonOverride::SPACING_NONE:
547 break;
550 //TO DO: Above Line need to be processed!!!!!!! what it means?????? 1-26
552 type = abovepara->GetType();
553 amount = abovepara->GetAmount();
554 multiple = abovepara->GetMultiple();
555 double above_val =-1;
556 switch(type)
558 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
559 // above_val = LINE_HEIGHT*float(multiple)/65536L*100; //TO DO: 1-26
560 break;
561 case LwpSpacingCommonOverride::SPACING_LEADING:
562 break;
563 case LwpSpacingCommonOverride::SPACING_CUSTOM:
564 above_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
565 break;
566 case LwpSpacingCommonOverride::SPACING_NONE:
567 break;
570 type = belowpara->GetType();
571 amount = belowpara->GetAmount();
572 multiple = belowpara->GetMultiple();
573 double below_val=-1;
574 switch(type)
576 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
577 // below_val = LINE_HEIGHT*float(multiple)/65536L*100;//TO DO: 1-26
578 break;
579 case LwpSpacingCommonOverride::SPACING_LEADING:
580 break;
581 case LwpSpacingCommonOverride::SPACING_CUSTOM:
582 below_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
583 break;
584 case LwpSpacingCommonOverride::SPACING_NONE:
585 break;
588 if (pPara)
590 if (below_val != -1)
591 pPara->SetBelowSpacing(below_val);
592 LwpPara* pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj());
593 if (pPrePara && above_val != -1)
595 above_val += pPrePara->GetBelowSpacing();
600 pParaStyle->SetMargins(-1,-1,above_val,below_val);
602 /**************************************************************************
603 * @short:
604 * @descr:
605 * @param:
606 * @param:
607 * @return:
608 **************************************************************************/
609 void LwpParaStyle::ApplyTab(XFParaStyle *pParaStyle, LwpTabOverride *pTabOverRide)
611 LwpObjectID* pTabRackID = pTabOverRide->GetTabRackID();
612 if(pTabRackID->IsNull())
614 //assert(false);
615 return;
618 LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(pTabRackID->obj());
619 if(!pTabRack)
621 //assert(false);
622 return;
625 pParaStyle->ClearTabStyles();
626 //Get margin left value
627 double dMarginLeft = pParaStyle->GetMargins().GetLeft();
629 sal_uInt16 nNumTabs = pTabRack->GetNumTabs();
630 for(sal_uInt16 nIndex=0; nIndex<nNumTabs; nIndex++)
632 //get tab type
633 LwpTab* pTab = pTabRack->Lookup(nIndex);
634 if(!pTab)
635 return;
637 enumXFTab eType = enumXFTabNone;
638 LwpTab::TabType type = pTab->GetTabType();
639 switch(type)
641 case LwpTab::TT_LEFT:
642 eType = enumXFTabLeft;
643 break;
644 case LwpTab::TT_CENTER:
645 eType = enumXFTabCenter;
646 break;
647 case LwpTab::TT_RIGHT:
648 eType = enumXFTabRight;
649 break;
650 case LwpTab::TT_NUMERIC:
651 eType = enumXFTabChar;
652 break;
655 //get position
656 sal_uInt32 nPos = pTab->GetPosition();
657 //different feature between SODC and lwp, the tab length must minus the margin left of para.
658 double fLen = LwpTools::ConvertFromUnitsToMetric(nPos) - dMarginLeft;
660 //get leader type
661 sal_Unicode cLeader = 0x00;
662 LwpTab::LeaderType leader= pTab->GetLeaderType();
663 switch(leader)
665 case LwpTab::TL_NONE:
666 cLeader = 0x20; //space
667 break;
668 case LwpTab::TL_HYPHEN: //'-'
669 cLeader = 0xAD;
670 break;
671 case LwpTab::TL_DOT: //'.'
672 cLeader = 0x2E;
673 break;
674 case LwpTab::TL_LINE: //'_'
675 cLeader = 0x5F;
676 break;
679 sal_Unicode cAlignChar = static_cast<sal_Unicode>(pTab->GetAlignChar());
681 pParaStyle->AddTabStyle(eType,fLen,cLeader,cAlignChar);
686 void LwpParaStyle::RegisterStyle()
688 XFParaStyle* pStyle = new XFParaStyle();
690 //Set name
691 OUString styleName = GetName()->str();
692 pStyle->SetStyleName(styleName);
694 //Create font
695 LwpFontManager* pFontMgr = m_pFoundry->GetFontManger();
696 XFFont* pFont = pFontMgr->CreateFont(m_nFinalFontID);
697 pStyle->SetFont(pFont);
699 //Set other paragraph properties...
701 Apply(pStyle);
702 //Add style
703 LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
704 pStyleMgr->AddStyle(*GetObjectID(), pStyle);
707 LwpAlignmentOverride* LwpParaStyle::GetAlignment()
709 if (m_AlignmentStyle.obj() == NULL)
710 return NULL;
712 LwpAlignmentPiece *pPiece = dynamic_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj());
713 if (pPiece)
714 return dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
715 return NULL;
718 LwpIndentOverride* LwpParaStyle::GetIndent()
720 if (m_IndentStyle.obj() == NULL)
721 return NULL;
723 LwpIndentPiece *pPiece = dynamic_cast<LwpIndentPiece*>(m_IndentStyle.obj());
724 if (pPiece)
725 return dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
726 return NULL;
729 LwpSpacingOverride* LwpParaStyle::GetSpacing()
731 if (m_SpacingStyle.obj() == NULL)
732 return NULL;
734 LwpSpacingPiece *pPiece = dynamic_cast<LwpSpacingPiece*>(m_SpacingStyle.obj());
735 if (pPiece)
736 return dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
737 return NULL;
740 LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const
742 if(m_BorderStyle.IsNull())
743 return NULL;
745 LwpParaBorderPiece *pPiece = dynamic_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE));
746 if (pPiece)
747 return dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
748 return NULL;
751 LwpBreaksOverride* LwpParaStyle::GetBreaks() const
753 if(m_BreaksStyle.IsNull())
754 return NULL;
756 LwpBreaksPiece *pPiece = dynamic_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE));
757 if (pPiece)
758 return dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
759 return NULL;
762 LwpBulletOverride* LwpParaStyle::GetBulletOverride() const
764 return m_pBulletOverride;
767 LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const
769 if(m_NumberingStyle.IsNull())
770 return NULL;
772 LwpNumberingPiece *pPiece = dynamic_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE));
773 if (pPiece)
774 return dynamic_cast<LwpNumberingOverride*>(pPiece->GetOverride());
775 return NULL;
778 /**************************************************************************
779 * @short:
780 * @descr:
781 * @param:
782 * @param:
783 * @return:
784 **************************************************************************/
785 LwpTabOverride* LwpParaStyle::GetTabOverride() const
787 if(m_TabStyle.obj() == NULL)
788 return NULL;
789 LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabStyle.obj());
790 if (pPiece)
791 return dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
792 return NULL;
795 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */