LCOV - code coverage report
Current view: top level - libreoffice/lotuswordpro/source/filter - lwppara.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 316 402 78.6 %
Date: 2012-12-27 Functions: 16 20 80.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10