build fix
[LibreOffice.git] / lotuswordpro / source / filter / lwpparastyle.cxx
blob99143b004d82dbc487e4149463d5b14ce90a137e
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 ************************************************************************/
61 #include <memory>
63 #include "lwpparastyle.hxx"
64 #include "lwpfilehdr.hxx"
65 #include "lwpoverride.hxx"
66 #include "lwpparaborderoverride.hxx"
67 #include "lwpbreaksoverride.hxx"
68 #include "lwpnumberingoverride.hxx"
69 #include "lwptaboverride.hxx"
70 #include "lwpbackgroundoverride.hxx"
71 #include "xfilter/xfdefs.hxx"
72 #include "xfilter/xfparastyle.hxx"
73 #include "xfilter/xfborders.hxx"
74 #include "lwpfont.hxx"
75 #include "lwpfoundry.hxx"
76 #include "lwppiece.hxx"
77 #include "lwpshadow.hxx"
78 #include "lwpborderstuff.hxx"
79 #include "lwpmargins.hxx"
80 #include "lwptabrack.hxx"
82 #include "lwpsilverbullet.hxx"
84 LwpParaStyle::LwpParaStyle(LwpObjectHeader& objHdr, LwpSvStream* pStrm) :
85 LwpTextStyle(objHdr, pStrm), m_pKinsokuOptsOverride(new LwpKinsokuOptsOverride),
86 m_pBulletOverride(new LwpBulletOverride)
90 LwpParaStyle::~LwpParaStyle()
92 if (m_pKinsokuOptsOverride)
94 delete m_pKinsokuOptsOverride;
97 if (m_pBulletOverride)
99 delete m_pBulletOverride;
103 void LwpParaStyle::Read()
105 LwpTextStyle::Read();
107 if (LwpFileHeader::m_nFileRevision < 0x000B)
109 // read many overrides
110 LwpAlignmentOverride aAlignOverride;
111 aAlignOverride.Read(m_pObjStrm.get());
113 LwpSpacingOverride aSpacingOverride;
114 aSpacingOverride.Read(m_pObjStrm.get());
116 LwpIndentOverride aIndentOverride;
117 aIndentOverride.Read(m_pObjStrm.get());
119 LwpParaBorderOverride aPBOverride;
120 aPBOverride.Read(m_pObjStrm.get());
122 LwpBreaksOverride aBreaksOverride;
123 aBreaksOverride.Read(m_pObjStrm.get());
125 LwpNumberingOverride aNumberingOverride;
126 aNumberingOverride.Read(m_pObjStrm.get());
128 LwpTabOverride aTabOverride;
129 aTabOverride.Read(m_pObjStrm.get());
132 else
134 m_AlignmentStyle.ReadIndexed(m_pObjStrm.get());
135 m_SpacingStyle.ReadIndexed(m_pObjStrm.get());
136 m_IndentStyle.ReadIndexed(m_pObjStrm.get());
137 m_BorderStyle.ReadIndexed(m_pObjStrm.get());
138 m_BreaksStyle.ReadIndexed(m_pObjStrm.get());
139 m_NumberingStyle.ReadIndexed(m_pObjStrm.get());
140 m_TabStyle.ReadIndexed(m_pObjStrm.get());
142 m_pKinsokuOptsOverride->Read(m_pObjStrm.get());
143 m_pBulletOverride->Read(m_pObjStrm.get());
145 if (m_pObjStrm->CheckExtra())
147 m_BackgroundStyle.ReadIndexed(m_pObjStrm.get());
148 m_pObjStrm->SkipExtra();
154 void LwpParaStyle::Apply(XFParaStyle *pParaStyle)
156 assert(pParaStyle);
158 LwpVirtualPiece *pPiece = nullptr;
159 //alignment:
160 pPiece = dynamic_cast<LwpVirtualPiece*>(m_AlignmentStyle.obj().get());
161 if( pPiece )
163 LwpAlignmentOverride *pAlign = dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
164 if( pAlign )
165 ApplyAlignment(pParaStyle,pAlign);
168 //don't known top and bottom indent now.
169 pPiece = dynamic_cast<LwpVirtualPiece*>(m_IndentStyle.obj().get());
170 if( pPiece )
172 LwpIndentOverride *pIndent = dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
173 if( pIndent )
175 if (!m_pBulletOverride->IsInValid())// for remove bullet indent in named bullet style
177 std::unique_ptr<LwpIndentOverride> pNewIndent(pIndent->clone());
178 pNewIndent->SetMFirst(0);
179 pNewIndent->SetMRest(0);
180 ApplyIndent(nullptr, pParaStyle, pNewIndent.get());
182 else
183 ApplyIndent(nullptr,pParaStyle,pIndent);
186 //shadow & borders.
187 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BorderStyle.obj().get());
188 if( pPiece )
190 LwpParaBorderOverride *pBorder = dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
191 if( pBorder )
193 ApplyParaBorder(pParaStyle, pBorder);
197 pPiece = dynamic_cast<LwpVirtualPiece*>(m_SpacingStyle.obj().get());
198 if (pPiece)
200 LwpSpacingOverride *pSpacing = dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
201 if( pSpacing)
202 ApplySpacing(nullptr,pParaStyle,pSpacing);
205 //paragraph background.
206 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BackgroundStyle.obj().get());
207 if( pPiece )
209 LwpBackgroundOverride *pBack = dynamic_cast<LwpBackgroundOverride*>(pPiece->GetOverride());
210 if( pBack )
212 LwpColor color = pBack->GetBackColor();
213 XFColor aXFColor( color.To24Color() );
214 pParaStyle->SetBackColor( aXFColor );
218 //add tab style
219 pPiece = dynamic_cast<LwpVirtualPiece*>(m_TabStyle.obj().get());
220 if( pPiece )
222 LwpTabOverride *pTab = dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
223 if(pTab)
225 ApplyTab(pParaStyle,pTab);
228 pPiece = dynamic_cast<LwpVirtualPiece*>(m_BreaksStyle.obj().get());
229 if( pPiece )
231 LwpBreaksOverride *pBreak = dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
232 if(pBreak)
234 ApplyBreaks(pParaStyle,pBreak);
240 void LwpParaStyle::ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType, XFBorders* pXFBorders)
242 enumXFBorder eXFBorderSide = enumXFBorderNone;
243 switch (eType)
245 case LwpBorderStuff::LEFT:
246 eXFBorderSide = enumXFBorderLeft;
247 break;
248 case LwpBorderStuff::RIGHT:
249 eXFBorderSide = enumXFBorderRight;
250 break;
251 case LwpBorderStuff::TOP:
252 eXFBorderSide = enumXFBorderTop;
253 break;
254 case LwpBorderStuff::BOTTOM:
255 eXFBorderSide = enumXFBorderBottom;
256 break;
257 default:
258 break;
261 LwpColor aColor = pBorderStuff->GetSideColor(eType);
262 float fWidth = pBorderStuff->GetSideWidth(eType);
263 sal_uInt16 nType = pBorderStuff->GetSideType(eType);
265 switch (nType)
267 default://fall through!
268 case 0x14: //single fall through!
269 case 0x17: //treble
270 pXFBorders->SetWidth(eXFBorderSide, fWidth);
271 break;
272 case 0x15: //double , fall through!
273 case 0x16: //thick double
274 pXFBorders->SetDoubleLine(eXFBorderSide);
275 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.333));
276 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.334));
277 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.333));
278 // pXFBorders->SetWidth(eXFBorderSide, fWidth);
279 break;
280 case 0x18: //thick-thin
281 pXFBorders->SetDoubleLine(eXFBorderSide);
282 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.5));
283 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.25));
284 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.25));
285 break;
286 case 0x19: //thin-thick
287 pXFBorders->SetDoubleLine(eXFBorderSide);
288 pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.7));
289 pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.15));
290 pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.15));
291 break;
294 if (aColor.IsValidColor())
296 XFColor aXFColor(aColor.To24Color());
297 pXFBorders->SetColor(eXFBorderSide, aXFColor );
301 void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder)
303 //convert LwpShadow:
304 LwpShadow *pShadow = pBorder->GetShadow();
305 if( pShadow )
307 LwpColor color = pShadow->GetColor();
308 float offsetX = pShadow->GetOffsetX();
309 float offsetY = pShadow->GetOffsetY();
311 if( offsetX && offsetY && color.IsValidColor() )
313 XFColor aXFColor(color.To24Color());
314 bool left = false;
315 bool top = false;
316 if( offsetX < 0 )
317 left = true;
318 if( offsetY < 0 )
319 top = true;
320 if( left )
322 if( top )
323 pParaStyle->SetShadow(enumXFShadowLeftTop,-offsetX,aXFColor);
324 else
325 pParaStyle->SetShadow(enumXFShadowLeftBottom,-offsetX,aXFColor);
327 else
329 if( top )
330 pParaStyle->SetShadow(enumXFShadowRightTop,offsetX,aXFColor);
331 else
332 pParaStyle->SetShadow(enumXFShadowRightBottom,offsetX,aXFColor);
337 //convert to XFBorders object:
338 LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff();
339 if( pBorderStuff && pBorderStuff->GetSide() != 0 )
341 XFBorders *pXFBorders = new XFBorders();
342 pParaStyle->SetBorders(pXFBorders);
344 LwpMargins* pMargins = pBorder->GetMargins();
346 // apply 4 borders respectively
347 LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
348 LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
349 float pMarginValue[4];
351 for (sal_uInt8 nC = 0; nC < 4; nC++)
353 if (pBorderStuff->HasSide(pType[nC]))
355 ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
357 //get border spacing to text content
358 if (pMargins)
360 pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
366 //apply border spacing to text content
367 pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
372 void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, LwpBreaksOverride* pBreaks)
374 if (pBreaks->IsKeepWithNext())
376 pParaStyle->SetBreaks(enumXFBreakKeepWithNext);
378 if (pBreaks->IsPageBreakBefore())
380 pParaStyle->SetBreaks(enumXFBreakBefPage);
382 if (pBreaks->IsPageBreakAfter())
384 pParaStyle->SetBreaks(enumXFBreakAftPage);
386 if (pBreaks->IsColumnBreakBefore())
388 pParaStyle->SetBreaks(enumXFBreakBefColumn);
390 if (pBreaks->IsColumnBreakAfter())
392 pParaStyle->SetBreaks(enumXFBreakAftColumn);
396 void LwpParaStyle::ApplyAlignment(XFParaStyle* pParaStyle, LwpAlignmentOverride* pAlign)
398 enumXFAlignType alignType = enumXFAlignStart;
399 LwpAlignmentOverride::AlignType type;
401 type = pAlign->GetAlignType();
402 pParaStyle->SetNumberRight(false);//to identify its align attribute
403 switch(type)
405 case LwpAlignmentOverride::ALIGN_LEFT:
406 alignType = enumXFAlignStart;
407 break;
408 case LwpAlignmentOverride::ALIGN_RIGHT:
409 alignType = enumXFAlignEnd;
410 break;
411 case LwpAlignmentOverride::ALIGN_CENTER:
412 alignType = enumXFAlignCenter;
413 break;
414 case LwpAlignmentOverride::ALIGN_NUMERICLEFT://if non-number in table,ALIGN_NUMERICLEFT/RIGHT are useless
415 alignType = enumXFAlignStart; //note by 1/28
416 break;
417 case LwpAlignmentOverride::ALIGN_JUSTIFY:
418 case LwpAlignmentOverride::ALIGN_JUSTIFYALL:
419 alignType = enumXFAlignJustify;
420 break;
421 case LwpAlignmentOverride::ALIGN_NUMERICRIGHT:
422 pParaStyle->SetNumberRight(true);//to identify its align attribute
423 alignType = enumXFAlignEnd;
424 break;
425 default:
426 break;
428 pParaStyle->SetAlignType(alignType);
431 void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, LwpIndentOverride* pIndent)
433 LwpPara* pParentPara;
434 if (pPara)
435 pParentPara = pPara->GetParent();
436 else
437 pParentPara = nullptr;
439 std::unique_ptr<LwpIndentOverride> pTotalIndent(new LwpIndentOverride);
440 if (pIndent->IsUseRelative() && pParentPara)
442 LwpIndentOverride* pParentIndent = pParentPara->GetIndent();
443 if (!pParentIndent)
444 return;
445 pTotalIndent.reset(pIndent->clone());
447 //for bullet only
448 if (pPara)
450 if (pPara->GetBulletFlag())
452 pTotalIndent->SetMAll(pParentIndent->GetMAll() + pTotalIndent->GetMAll());
453 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
454 pParaStyle->SetMargins(LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(
455 pTotalIndent->GetMAll())), pTotalIndent->GetRight());
456 pPara->SetIndent(pTotalIndent.release());
457 return;
460 sal_uInt16 relative = pParentIndent->GetRelative();
462 sal_Int32 Amount = pParentIndent->GetMAll();
464 if (relative == LwpIndentOverride::RELATIVE_FIRST)
465 Amount += pParentIndent->GetMFirst();
466 else if (relative == LwpIndentOverride::RELATIVE_REST)
467 Amount += pParentIndent->GetMRest();
468 pTotalIndent->SetMAll(Amount + pTotalIndent->GetMAll());
469 pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
471 pParaStyle->SetIndent(pTotalIndent->GetFirst());
472 pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
473 pPara->SetIndent(pTotalIndent.release());
476 else
478 pTotalIndent.reset(pIndent->clone());
479 if (pPara)
481 if (pPara->GetBulletFlag())
483 pParaStyle->SetMargins(LwpTools::ConvertToMetric(
484 LwpTools::ConvertFromUnits(pIndent->GetMAll())), pIndent->GetRight());
485 pPara->SetIndent(pTotalIndent.release());
486 return;
490 pParaStyle->SetIndent(pIndent->GetFirst());
491 pParaStyle->SetMargins(pIndent->GetLeft(), pIndent->GetRight());
492 if (pPara)
494 pPara->SetIndent(pTotalIndent.release());
499 void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing)
501 LwpSpacingCommonOverride* spacing = pSpacing->GetSpacing();
502 LwpSpacingCommonOverride* abovepara = pSpacing->GetAboveSpacing();
503 LwpSpacingCommonOverride* belowpara = pSpacing->GetBelowSpacing();
505 LwpSpacingCommonOverride::SpacingType type = spacing->GetType();
506 sal_Int32 amount = spacing->GetAmount();
507 sal_Int32 multiple = spacing->GetMultiple();
508 enumLHType xftype;
509 double height;
511 switch(type)
513 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
515 xftype = enumLHPercent;
516 height = double(multiple)/65536L*100;
517 pParaStyle->SetLineHeight(xftype,height);
519 break;
520 case LwpSpacingCommonOverride::SPACING_LEADING:
522 xftype = enumLHSpace;
523 height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(amount));
524 pParaStyle->SetLineHeight(xftype,height);
526 break;
527 case LwpSpacingCommonOverride::SPACING_CUSTOM:
529 xftype = enumLHHeight;
530 height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
531 pParaStyle->SetLineHeight(xftype,height);
533 break;
534 case LwpSpacingCommonOverride::SPACING_NONE:
535 break;
538 //TO DO: Above Line need to be processed!!!!!!! what it means?????? 1-26
540 type = abovepara->GetType();
541 amount = abovepara->GetAmount();
542 multiple = abovepara->GetMultiple();
543 double above_val =-1;
544 switch(type)
546 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
547 break;
548 case LwpSpacingCommonOverride::SPACING_LEADING:
549 break;
550 case LwpSpacingCommonOverride::SPACING_CUSTOM:
551 above_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
552 break;
553 case LwpSpacingCommonOverride::SPACING_NONE:
554 break;
557 type = belowpara->GetType();
558 amount = belowpara->GetAmount();
559 multiple = belowpara->GetMultiple();
560 double below_val=-1;
561 switch(type)
563 case LwpSpacingCommonOverride::SPACING_DYNAMIC:
564 break;
565 case LwpSpacingCommonOverride::SPACING_LEADING:
566 break;
567 case LwpSpacingCommonOverride::SPACING_CUSTOM:
568 below_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
569 break;
570 case LwpSpacingCommonOverride::SPACING_NONE:
571 break;
574 if (pPara)
576 if (below_val != -1)
577 pPara->SetBelowSpacing(below_val);
578 LwpPara* pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious().obj().get());
579 if (pPrePara && above_val != -1)
581 above_val += pPrePara->GetBelowSpacing();
586 pParaStyle->SetMargins(-1,-1,above_val,below_val);
589 void LwpParaStyle::ApplyTab(XFParaStyle *pParaStyle, LwpTabOverride *pTabOverRide)
591 LwpObjectID& rTabRackID = pTabOverRide->GetTabRackID();
592 if(rTabRackID.IsNull())
594 return;
597 LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(rTabRackID.obj().get());
598 if(!pTabRack)
600 return;
603 pParaStyle->ClearTabStyles();
604 //Get margin left value
605 double dMarginLeft = pParaStyle->GetMargins().GetLeft();
607 sal_uInt16 nNumTabs = pTabRack->GetNumTabs();
608 for(sal_uInt16 nIndex=0; nIndex<nNumTabs; nIndex++)
610 //get tab type
611 LwpTab* pTab = pTabRack->Lookup(nIndex);
612 if(!pTab)
613 return;
615 enumXFTab eType = enumXFTabNone;
616 LwpTab::TabType type = pTab->GetTabType();
617 switch(type)
619 case LwpTab::TT_LEFT:
620 eType = enumXFTabLeft;
621 break;
622 case LwpTab::TT_CENTER:
623 eType = enumXFTabCenter;
624 break;
625 case LwpTab::TT_RIGHT:
626 eType = enumXFTabRight;
627 break;
628 case LwpTab::TT_NUMERIC:
629 eType = enumXFTabChar;
630 break;
633 //get position
634 sal_uInt32 nPos = pTab->GetPosition();
635 //different feature between SODC and lwp, the tab length must minus the margin left of para.
636 double fLen = LwpTools::ConvertFromUnitsToMetric(nPos) - dMarginLeft;
638 //get leader type
639 sal_Unicode cLeader = 0x00;
640 LwpTab::LeaderType leader= pTab->GetLeaderType();
641 switch(leader)
643 case LwpTab::TL_NONE:
644 cLeader = 0x20; //space
645 break;
646 case LwpTab::TL_HYPHEN: //'-'
647 cLeader = 0xAD;
648 break;
649 case LwpTab::TL_DOT: //'.'
650 cLeader = 0x2E;
651 break;
652 case LwpTab::TL_LINE: //'_'
653 cLeader = 0x5F;
654 break;
657 sal_Unicode cAlignChar = static_cast<sal_Unicode>(pTab->GetAlignChar());
659 pParaStyle->AddTabStyle(eType,fLen,cLeader,cAlignChar);
664 void LwpParaStyle::RegisterStyle()
666 if (!m_pFoundry)
667 throw std::runtime_error("missing Foundry");
669 XFParaStyle* pStyle = new XFParaStyle();
671 //Set name
672 OUString styleName = GetName().str();
673 pStyle->SetStyleName(styleName);
675 //Create font
676 LwpFontManager& rFontMgr = m_pFoundry->GetFontManger();
677 rtl::Reference<XFFont> pFont = rFontMgr.CreateFont(m_nFinalFontID);
678 pStyle->SetFont(pFont);
680 //Set other paragraph properties...
682 Apply(pStyle);
683 //Add style
684 LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
685 pStyleMgr->AddStyle(GetObjectID(), pStyle);
688 LwpAlignmentOverride* LwpParaStyle::GetAlignment()
690 if (m_AlignmentStyle.obj() == nullptr)
691 return nullptr;
693 LwpAlignmentPiece *pPiece = dynamic_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj().get());
694 if (pPiece)
695 return dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
696 return nullptr;
699 LwpIndentOverride* LwpParaStyle::GetIndent()
701 if (m_IndentStyle.obj() == nullptr)
702 return nullptr;
704 LwpIndentPiece *pPiece = dynamic_cast<LwpIndentPiece*>(m_IndentStyle.obj().get());
705 if (pPiece)
706 return dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
707 return nullptr;
710 LwpSpacingOverride* LwpParaStyle::GetSpacing()
712 if (m_SpacingStyle.obj() == nullptr)
713 return nullptr;
715 LwpSpacingPiece *pPiece = dynamic_cast<LwpSpacingPiece*>(m_SpacingStyle.obj().get());
716 if (pPiece)
717 return dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
718 return nullptr;
721 LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const
723 if(m_BorderStyle.IsNull())
724 return nullptr;
726 LwpParaBorderPiece *pPiece = dynamic_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE).get());
727 if (pPiece)
728 return dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
729 return nullptr;
732 LwpBreaksOverride* LwpParaStyle::GetBreaks() const
734 if(m_BreaksStyle.IsNull())
735 return nullptr;
737 LwpBreaksPiece *pPiece = dynamic_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE).get());
738 if (pPiece)
739 return dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
740 return nullptr;
744 LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const
746 if(m_NumberingStyle.IsNull())
747 return nullptr;
749 LwpNumberingPiece *pPiece = dynamic_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE).get());
750 if (pPiece)
751 return dynamic_cast<LwpNumberingOverride*>(pPiece->GetOverride());
752 return nullptr;
755 LwpTabOverride* LwpParaStyle::GetTabOverride() const
757 if(m_TabStyle.obj() == nullptr)
758 return nullptr;
759 LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabStyle.obj().get());
760 if (pPiece)
761 return dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
762 return nullptr;
765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */