fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / lotuswordpro / source / filter / lwpparastyle.cxx
blob6d6d6372ce945183e6221a5931b1b9e163464b3a
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);
162 LwpVirtualPiece *pPiece = NULL;
163 //alignment:
164 pPiece = dynamic_cast<LwpVirtualPiece*>(m_AlignmentStyle.obj().get());
165 if( pPiece )
167 LwpAlignmentOverride *pAlign = dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
168 if( pAlign )
169 ApplyAlignment(pParaStyle,pAlign);
172 //don't known top and bottom indent now.
173 pPiece = dynamic_cast<LwpVirtualPiece*>(m_IndentStyle.obj().get());
174 if( pPiece )
176 LwpIndentOverride *pIndent = dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
177 if( pIndent )
179 if (!m_pBulletOverride->IsInValid())//Add by ,for remove bullet indent in named bullet style
181 boost::scoped_ptr<LwpIndentOverride> pNewIndent(pIndent->clone());
182 pNewIndent->SetMFirst(0);
183 pNewIndent->SetMRest(0);
184 ApplyIndent(NULL, pParaStyle, pNewIndent.get());
186 else
187 ApplyIndent(NULL,pParaStyle,pIndent);
190 //shadow & borders.
191 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BorderStyle.obj().get());
192 if( pPiece )
194 LwpParaBorderOverride *pBorder = dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
195 if( pBorder )
197 ApplyParaBorder(pParaStyle, pBorder);
201 pPiece = dynamic_cast<LwpVirtualPiece*>(m_SpacingStyle.obj().get());
202 if (pPiece)
204 LwpSpacingOverride *pSpacing = dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
205 if( pSpacing)
206 ApplySpacing(NULL,pParaStyle,pSpacing);
209 //paragraph background.
210 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BackgroundStyle.obj().get());
211 if( pPiece )
213 LwpBackgroundOverride *pBack = dynamic_cast<LwpBackgroundOverride*>(pPiece->GetOverride());
214 if( pBack )
216 LwpColor color = pBack->GetBackColor();
217 XFColor aXFColor( color.To24Color() );
218 pParaStyle->SetBackColor( aXFColor );
222 //add tab style
223 pPiece = dynamic_cast<LwpVirtualPiece*>(m_TabStyle.obj().get());
224 if( pPiece )
226 LwpTabOverride *pTab = dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
227 if(pTab)
229 ApplyTab(pParaStyle,pTab);
232 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BreaksStyle.obj().get());
233 if( pPiece )
235 LwpBreaksOverride *pBreak = dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
236 if(pBreak)
238 ApplyBreaks(pParaStyle,pBreak);
244 void LwpParaStyle::ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType, XFBorders* pXFBorders)
246 enumXFBorder eXFBorderSide = enumXFBorderNone;
247 switch (eType)
249 case LwpBorderStuff::LEFT:
250 eXFBorderSide = enumXFBorderLeft;
251 break;
252 case LwpBorderStuff::RIGHT:
253 eXFBorderSide = enumXFBorderRight;
254 break;
255 case LwpBorderStuff::TOP:
256 eXFBorderSide = enumXFBorderTop;
257 break;
258 case LwpBorderStuff::BOTTOM:
259 eXFBorderSide = enumXFBorderBottom;
260 break;
261 default:
262 break;
265 LwpColor aColor = pBorderStuff->GetSideColor(eType);
266 float fWidth = pBorderStuff->GetSideWidth(eType);
267 sal_uInt16 nType = pBorderStuff->GetSideType(eType);
269 switch (nType)
271 default://fall through!
272 case 0x14: //single fall through!
273 case 0x17: //treble
274 pXFBorders->SetWidth(eXFBorderSide, fWidth);
275 break;
276 case 0x15: //double , fall through!
277 case 0x16: //thick double
278 pXFBorders->SetDoubleLine(eXFBorderSide, true, false);
279 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.333));
280 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.334));
281 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.333));
282 // pXFBorders->SetWidth(eXFBorderSide, fWidth);
283 break;
284 case 0x18: //thick-thin
285 pXFBorders->SetDoubleLine(eXFBorderSide, true, false);
286 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.5));
287 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.25));
288 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.25));
289 break;
290 case 0x19: //thin-thick
291 pXFBorders->SetDoubleLine(eXFBorderSide, true, false);
292 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.7));
293 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.15));
294 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.15));
295 break;
298 if (aColor.IsValidColor())
300 XFColor aXFColor(aColor.To24Color());
301 pXFBorders->SetColor(eXFBorderSide, aXFColor );
305 void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder)
307 //convert LwpShadow:
308 LwpShadow *pShadow = pBorder->GetShadow();
309 if( pShadow )
311 LwpColor color = pShadow->GetColor();
312 float offsetX = pShadow->GetOffsetX();
313 float offsetY = pShadow->GetOffsetY();
315 if( offsetX && offsetY && color.IsValidColor() )
317 XFColor aXFColor(color.To24Color());
318 bool left = false;
319 bool top = false;
320 if( offsetX < 0 )
321 left = true;
322 if( offsetY < 0 )
323 top = true;
324 if( left )
326 if( top )
327 pParaStyle->SetShadow(enumXFShadowLeftTop,-offsetX,aXFColor);
328 else
329 pParaStyle->SetShadow(enumXFShadowLeftBottom,-offsetX,aXFColor);
331 else
333 if( top )
334 pParaStyle->SetShadow(enumXFShadowRightTop,offsetX,aXFColor);
335 else
336 pParaStyle->SetShadow(enumXFShadowRightBottom,offsetX,aXFColor);
341 //convert to XFBorders object:
342 LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff();
343 if( pBorderStuff && pBorderStuff->GetSide() != 0 )
345 XFBorders *pXFBorders = new XFBorders();
346 pParaStyle->SetBorders(pXFBorders);
348 LwpMargins* pMargins = pBorder->GetMargins();
350 // apply 4 borders respectively
351 LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
352 LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
353 float pMarginValue[4];
355 for (sal_uInt8 nC = 0; nC < 4; nC++)
357 if (pBorderStuff->HasSide(pType[nC]))
359 ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
361 //get border spacing to text content
362 if (pMargins)
364 pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
370 //apply border spacing to text content
371 pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
376 void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, LwpBreaksOverride* pBreaks)
378 if (pBreaks->IsKeepWithNext())
380 pParaStyle->SetBreaks(enumXFBreakKeepWithNext);
382 if (pBreaks->IsPageBreakBefore())
384 pParaStyle->SetBreaks(enumXFBreakBefPage);
386 if (pBreaks->IsPageBreakAfter())
388 pParaStyle->SetBreaks(enumXFBreakAftPage);
390 if (pBreaks->IsColumnBreakBefore())
392 pParaStyle->SetBreaks(enumXFBreakBefColumn);
394 if (pBreaks->IsColumnBreakAfter())
396 pParaStyle->SetBreaks(enumXFBreakAftColumn);
400 void LwpParaStyle::ApplyAlignment(XFParaStyle* pParaStyle, LwpAlignmentOverride* pAlign)
402 enumXFAlignType alignType = enumXFAlignStart;
403 LwpAlignmentOverride::AlignType type;
405 type = pAlign->GetAlignType();
406 pParaStyle->SetNumberRight(false);//to identify its align attribute
407 switch(type)
409 case LwpAlignmentOverride::ALIGN_LEFT:
410 alignType = enumXFAlignStart;
411 break;
412 case LwpAlignmentOverride::ALIGN_RIGHT:
413 alignType = enumXFAlignEnd;
414 break;
415 case LwpAlignmentOverride::ALIGN_CENTER:
416 alignType = enumXFAlignCenter;
417 break;
418 case LwpAlignmentOverride::ALIGN_NUMERICLEFT://if non-number in table,ALIGN_NUMERICLEFT/RIGHT are useless
419 alignType = enumXFAlignStart; //note by 1/28
420 break;
421 case LwpAlignmentOverride::ALIGN_JUSTIFY:
422 case LwpAlignmentOverride::ALIGN_JUSTIFYALL:
423 alignType = enumXFAlignJustify;
424 break;
425 case LwpAlignmentOverride::ALIGN_NUMERICRIGHT:
426 pParaStyle->SetNumberRight(true);//to identify its align attribute
427 alignType = enumXFAlignEnd;
428 break;
429 default:
430 break;
432 pParaStyle->SetAlignType(alignType);
435 void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, LwpIndentOverride* pIndent)
437 LwpPara* pParentPara;
438 if (pPara)
439 pParentPara = pPara->GetParent();
440 else
441 pParentPara = NULL;
443 std::unique_ptr<LwpIndentOverride> pTotalIndent(new LwpIndentOverride);
444 if (pIndent->IsUseRelative() && pParentPara)
446 LwpIndentOverride* pParentIndent = pParentPara->GetIndent();
447 if (!pParentIndent)
448 return;
449 pTotalIndent.reset(pIndent->clone());
451 //add by ,for bullet only
452 if (pPara)
454 if (pPara->GetBulletFlag())
456 pTotalIndent->SetMAll(pParentIndent->GetMAll() + pTotalIndent->GetMAll());
457 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
458 pParaStyle->SetMargins(LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(
459 pTotalIndent->GetMAll())), pTotalIndent->GetRight());
460 pPara->SetIndent(pTotalIndent.release());
461 return;
464 //end add
465 sal_uInt16 relative = pParentIndent->GetRelative();
467 sal_Int32 Amount = pParentIndent->GetMAll();
469 if (relative == LwpIndentOverride::RELATIVE_FIRST)
470 Amount += pParentIndent->GetMFirst();
471 else if (relative == LwpIndentOverride::RELATIVE_REST)
472 Amount += pParentIndent->GetMRest();
473 pTotalIndent->SetMAll(Amount + pTotalIndent->GetMAll());
474 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
476 pParaStyle->SetIndent(pTotalIndent->GetFirst());
477 pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
478 pPara->SetIndent(pTotalIndent.release());
481 else
483 pTotalIndent.reset(pIndent->clone());
484 //add by
485 if (pPara)
487 if (pPara->GetBulletFlag())
489 // pParaStyle->SetIndent(LwpTools::ConvertFromUnits(pIndent->GetMAll()));
490 pParaStyle->SetMargins(LwpTools::ConvertToMetric(
491 LwpTools::ConvertFromUnits(pIndent->GetMAll())), pIndent->GetRight());
492 pPara->SetIndent(pTotalIndent.release());
493 return;
496 //end add
498 pParaStyle->SetIndent(pIndent->GetFirst());
499 pParaStyle->SetMargins(pIndent->GetLeft(), pIndent->GetRight());
500 if (pPara)
502 pPara->SetIndent(pTotalIndent.release());
507 void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing)
509 LwpSpacingCommonOverride* spacing = pSpacing->GetSpacing();
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 = dynamic_cast<LwpPara*>(pPara->GetPrevious().obj().get());
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 *pTabOverRide)
607 LwpObjectID& rTabRackID = pTabOverRide->GetTabRackID();
608 if(rTabRackID.IsNull())
610 return;
613 LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(rTabRackID.obj().get());
614 if(!pTabRack)
616 return;
619 pParaStyle->ClearTabStyles();
620 //Get margin left value
621 double dMarginLeft = pParaStyle->GetMargins().GetLeft();
623 sal_uInt16 nNumTabs = pTabRack->GetNumTabs();
624 for(sal_uInt16 nIndex=0; nIndex<nNumTabs; nIndex++)
626 //get tab type
627 LwpTab* pTab = pTabRack->Lookup(nIndex);
628 if(!pTab)
629 return;
631 enumXFTab eType = enumXFTabNone;
632 LwpTab::TabType type = pTab->GetTabType();
633 switch(type)
635 case LwpTab::TT_LEFT:
636 eType = enumXFTabLeft;
637 break;
638 case LwpTab::TT_CENTER:
639 eType = enumXFTabCenter;
640 break;
641 case LwpTab::TT_RIGHT:
642 eType = enumXFTabRight;
643 break;
644 case LwpTab::TT_NUMERIC:
645 eType = enumXFTabChar;
646 break;
649 //get position
650 sal_uInt32 nPos = pTab->GetPosition();
651 //different feature between SODC and lwp, the tab length must minus the margin left of para.
652 double fLen = LwpTools::ConvertFromUnitsToMetric(nPos) - dMarginLeft;
654 //get leader type
655 sal_Unicode cLeader = 0x00;
656 LwpTab::LeaderType leader= pTab->GetLeaderType();
657 switch(leader)
659 case LwpTab::TL_NONE:
660 cLeader = 0x20; //space
661 break;
662 case LwpTab::TL_HYPHEN: //'-'
663 cLeader = 0xAD;
664 break;
665 case LwpTab::TL_DOT: //'.'
666 cLeader = 0x2E;
667 break;
668 case LwpTab::TL_LINE: //'_'
669 cLeader = 0x5F;
670 break;
673 sal_Unicode cAlignChar = static_cast<sal_Unicode>(pTab->GetAlignChar());
675 pParaStyle->AddTabStyle(eType,fLen,cLeader,cAlignChar);
680 void LwpParaStyle::RegisterStyle()
682 XFParaStyle* pStyle = new XFParaStyle();
684 //Set name
685 OUString styleName = GetName().str();
686 pStyle->SetStyleName(styleName);
688 //Create font
689 LwpFontManager& rFontMgr = m_pFoundry->GetFontManger();
690 rtl::Reference<XFFont> pFont = rFontMgr.CreateFont(m_nFinalFontID);
691 pStyle->SetFont(pFont);
693 //Set other paragraph properties...
695 Apply(pStyle);
696 //Add style
697 LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
698 pStyleMgr->AddStyle(GetObjectID(), pStyle);
701 LwpAlignmentOverride* LwpParaStyle::GetAlignment()
703 if (m_AlignmentStyle.obj() == NULL)
704 return NULL;
706 LwpAlignmentPiece *pPiece = dynamic_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj().get());
707 if (pPiece)
708 return dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
709 return NULL;
712 LwpIndentOverride* LwpParaStyle::GetIndent()
714 if (m_IndentStyle.obj() == NULL)
715 return NULL;
717 LwpIndentPiece *pPiece = dynamic_cast<LwpIndentPiece*>(m_IndentStyle.obj().get());
718 if (pPiece)
719 return dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
720 return NULL;
723 LwpSpacingOverride* LwpParaStyle::GetSpacing()
725 if (m_SpacingStyle.obj() == NULL)
726 return NULL;
728 LwpSpacingPiece *pPiece = dynamic_cast<LwpSpacingPiece*>(m_SpacingStyle.obj().get());
729 if (pPiece)
730 return dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
731 return NULL;
734 LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const
736 if(m_BorderStyle.IsNull())
737 return NULL;
739 LwpParaBorderPiece *pPiece = dynamic_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE).get());
740 if (pPiece)
741 return dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
742 return NULL;
745 LwpBreaksOverride* LwpParaStyle::GetBreaks() const
747 if(m_BreaksStyle.IsNull())
748 return NULL;
750 LwpBreaksPiece *pPiece = dynamic_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE).get());
751 if (pPiece)
752 return dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
753 return NULL;
757 LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const
759 if(m_NumberingStyle.IsNull())
760 return NULL;
762 LwpNumberingPiece *pPiece = dynamic_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE).get());
763 if (pPiece)
764 return dynamic_cast<LwpNumberingOverride*>(pPiece->GetOverride());
765 return NULL;
768 /**************************************************************************
769 * @short:
770 * @descr:
771 * @param:
772 * @param:
773 * @return:
774 **************************************************************************/
775 LwpTabOverride* LwpParaStyle::GetTabOverride() const
777 if(m_TabStyle.obj() == NULL)
778 return NULL;
779 LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabStyle.obj().get());
780 if (pPiece)
781 return dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
782 return NULL;
785 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */