LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpdoc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 268 361 74.2 %
Date: 2012-08-25 Functions: 36 43 83.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 165 366 45.1 %

           Branch data     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                 :            : #include "lwpglobalmgr.hxx"
      57                 :            : #include "lwpdoc.hxx"
      58                 :            : #include "lwpfootnote.hxx"
      59                 :            : #include "lwppagehint.hxx"
      60                 :            : #include "lwpdivinfo.hxx"
      61                 :            : #include "lwpholder.hxx"
      62                 :            : #include "lwpparastyle.hxx"
      63                 :            : #include "lwpstory.hxx"
      64                 :            : #include "lwppara.hxx"
      65                 :            : #include "lwpsilverbullet.hxx"
      66                 :            : #include "lwplayout.hxx"
      67                 :            : #include "lwppagelayout.hxx"
      68                 :            : #include "xfilter/xfstylemanager.hxx"
      69                 :            : #include <osl/thread.h>
      70                 :            : 
      71                 :         30 : LwpDocument::LwpDocument(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
      72 [ +  - ][ +  - ]:         30 :     : LwpDLNFPVList(objHdr, pStrm), m_pOwnedFoundry(NULL), m_pLnOpts(NULL)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      73                 :         27 : {}
      74                 :            : 
      75         [ +  - ]:         24 : LwpDocument::~LwpDocument()
      76                 :            : {
      77         [ +  - ]:         24 :     if(m_pLnOpts)
      78                 :            :     {
      79         [ +  - ]:         24 :         delete m_pLnOpts;
      80                 :            :     }
      81         [ +  - ]:         24 :     if(m_pOwnedFoundry)
      82                 :            :     {
      83 [ +  - ][ +  - ]:         24 :         delete m_pOwnedFoundry;
      84                 :            :     }
      85         [ -  + ]:         48 : }
      86                 :            : /**
      87                 :            :  * @descr   Read VO_Document from object stream
      88                 :            :  **/
      89                 :         27 : void LwpDocument::Read()
      90                 :            : {
      91                 :         27 :     LwpDLNFPVList::Read();
      92                 :            : 
      93                 :         27 :     ReadPlug();
      94                 :            : 
      95                 :         27 :     m_nPersistentFlags = m_pObjStrm->QuickReaduInt32();
      96                 :            : 
      97                 :            :     //Skip the SortOption and UIDocument
      98                 :            :     {
      99         [ +  - ]:         27 :         LwpSortOption m_DocSort( m_pObjStrm );
     100 [ +  - ][ +  - ]:         27 :         LwpUIDocument m_UIDoc( m_pObjStrm );
     101                 :            :     }
     102                 :            : 
     103         [ +  - ]:         27 :     m_pLnOpts = new LwpLineNumberOptions(m_pObjStrm);
     104                 :            : 
     105                 :            :     //Skip LwpUserDictFiles
     106                 :            :     {
     107         [ +  - ]:         27 :         LwpUserDictFiles m_UsrDicts( m_pObjStrm );
     108                 :            :     }
     109                 :            : 
     110         [ +  + ]:         27 :     if( !IsChildDoc())
     111                 :            :     {
     112                 :            :         //Skip LwpPrinterInfo
     113 [ +  - ][ +  - ]:         15 :         LwpPrinterInfo m_PrtInfo( m_pObjStrm );
     114                 :            :     }
     115                 :            : 
     116         [ +  - ]:         27 :     m_pFoundry = m_pOwnedFoundry = new LwpFoundry(m_pObjStrm, this);
     117                 :            : 
     118                 :         27 :     m_DivOpts.ReadIndexed(m_pObjStrm);
     119                 :            : 
     120         [ +  + ]:         27 :     if(!IsChildDoc())
     121                 :            :     {
     122                 :         15 :         m_FootnoteOpts.ReadIndexed(m_pObjStrm);
     123                 :         15 :         m_DocData.ReadIndexed(m_pObjStrm);
     124                 :            :     }
     125                 :            :     else
     126                 :            :     {
     127                 :            :         //Skip the docdata used in old version
     128         [ +  - ]:         12 :         LwpObjectID dummyDocData;
     129         [ +  - ]:         12 :         dummyDocData.ReadIndexed(m_pObjStrm);
     130                 :            :     }
     131                 :         27 :     m_DivInfo.ReadIndexed(m_pObjStrm);
     132                 :         27 :     m_Epoch.Read(m_pObjStrm);
     133                 :         27 :     m_WYSIWYGPageHints.ReadIndexed(m_pObjStrm);
     134                 :         24 :     m_VerDoc.ReadIndexed(m_pObjStrm);
     135                 :         24 :     m_STXInfo.ReadIndexed(m_pObjStrm);
     136                 :         24 : }
     137                 :            : 
     138                 :            : /**
     139                 :            :  * @descr   Read plug related data from m_pObjStram
     140                 :            :  **/
     141                 :         27 : void LwpDocument::ReadPlug()
     142                 :            : {
     143                 :         27 :     m_DocSockID.ReadIndexed(m_pObjStrm);
     144                 :         27 :     m_nFlags = m_pObjStrm->QuickReaduInt16();
     145                 :         27 :     m_pObjStrm->SkipExtra();
     146                 :         27 : }
     147                 :            : 
     148                 :            : /**
     149                 :            :  * @descr   Parse obj to IXFStream
     150                 :            :  **/
     151                 :         18 : void LwpDocument::Parse(IXFStream* pOutputStream)
     152                 :            : {
     153                 :            :     //check the name and skip script division
     154         [ +  - ]:         18 :     if (!IsSkippedDivision())
     155                 :            :     {
     156                 :            :         //the frames which anchor are to page must output before other contents
     157                 :         18 :         ParseFrameInPage(pOutputStream);
     158                 :         18 :         ParseDocContent(pOutputStream);
     159                 :            :     }
     160                 :            : 
     161                 :         18 :     LwpObject* pDocSock = GetSocket()->obj( VO_DOCSOCK );
     162         [ +  - ]:         18 :     if(pDocSock!=NULL)
     163                 :            :     {
     164                 :         18 :         pDocSock->Parse(pOutputStream);
     165                 :            :     }
     166                 :         18 : }
     167                 :            : 
     168                 :         18 : sal_Bool LwpDocument::IsSkippedDivision()
     169                 :            : {
     170                 :         18 :     OUString sDivName;
     171                 :         18 :     sal_uInt8 ret = sal_False;
     172 [ -  + ][ +  - ]:         18 :     LwpDivInfo* pDiv = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj(VO_DIVISIONINFO));
     173         [ -  + ]:         18 :     if (pDiv == NULL)
     174                 :          0 :         return sal_True;
     175                 :         18 :     sDivName = pDiv->GetDivName();
     176 [ -  + ][ -  + ]:         18 :     if (!sDivName.isEmpty() && !pDiv->IsGotoable()) //including toa,scripts division
                 [ +  + ]
     177                 :          0 :         return sal_True;
     178                 :            :     //skip endnote division
     179                 :         18 :     OUString strClassName = pDiv->GetClassName();
     180 [ +  - ][ -  + ]:         72 :     if (strClassName.equals(A2OUSTR(STR_DivisionEndnote))
           [ +  -  +  -  
                   -  + ]
     181         [ +  - ]:         36 :         || strClassName.equals(A2OUSTR(STR_DivisionGroupEndnote))
     182         [ +  - ]:         36 :         || strClassName.equals(A2OUSTR(STR_DocumentEndnote)))
     183                 :            :     {
     184 [ #  # ][ #  # ]:          0 :         LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDiv->GetInitialLayoutID()->obj(VO_PAGELAYOUT));
     185         [ #  # ]:          0 :         if(pPageLayout)
     186                 :            :         {
     187 [ #  # ][ #  # ]:          0 :             LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent()->obj(VO_STORY));
     188         [ #  # ]:          0 :             if(pStory)
     189                 :            :             {
     190                 :            :                 //This judgement maybe have problem. If there is only one para in the story,
     191                 :            :                 //this endnote division has no other contents except endnote table.
     192                 :          0 :                 LwpObjectID* pFirst = pStory->GetFirstPara();
     193                 :          0 :                 LwpObjectID* pLast = pStory->GetLastPara();
     194         [ #  # ]:          0 :                 if(*pFirst == *pLast)
     195                 :          0 :                     ret = sal_True;
     196                 :            :             }
     197                 :            :         }
     198                 :            :     }
     199                 :         18 :     return ret;
     200                 :            : }
     201                 :            : 
     202                 :            : /**
     203                 :            :  * @descr  Register all styles in this division
     204                 :            :  */
     205                 :         24 : void LwpDocument::RegisterStyle()
     206                 :            : {
     207                 :         24 :     RegisterDefaultParaStyles();
     208                 :         24 :     RegisterGraphicsStyles();
     209                 :         24 :     RegisterBulletStyles();
     210                 :            : 
     211                 :         24 :     RegisterTextStyles();
     212                 :         24 :     RegisterLayoutStyles();
     213                 :         24 :     RegisterStylesInPara();
     214                 :            : 
     215                 :         21 :     RegisterLinenumberStyles();
     216                 :         21 :     RegisterFootnoteStyles();
     217                 :            : 
     218                 :            :     //Register styles in other document connected with this document: next doc, children doc
     219                 :         21 :     LwpObject* pDocSock = GetSocket()->obj();
     220         [ +  - ]:         21 :     if(pDocSock!=NULL)
     221                 :            :     {
     222                 :         21 :         pDocSock->RegisterStyle();
     223                 :            :     }
     224                 :         18 : }
     225                 :            : /**
     226                 :            :  * @descr  Register all named para styles
     227                 :            :  */
     228                 :         24 : void LwpDocument::RegisterTextStyles()
     229                 :            : {
     230                 :            :     //Register all text styles: para styles, character styles
     231         [ -  + ]:         24 :     LwpDLVListHeadHolder* pParaStyleHolder = dynamic_cast<LwpDLVListHeadHolder*>(m_pFoundry->GetTextStyleHead()->obj());
     232         [ +  - ]:         24 :     if(pParaStyleHolder)
     233                 :            :     {
     234         [ +  + ]:         24 :         LwpTextStyle* pParaStyle = dynamic_cast<LwpTextStyle*> (pParaStyleHolder->GetHeadID()->obj());
     235         [ +  + ]:        228 :         while(pParaStyle)
     236                 :            :         {
     237                 :        204 :             pParaStyle->SetFoundry(m_pFoundry);
     238                 :        204 :             pParaStyle->RegisterStyle();
     239         [ +  + ]:        204 :             pParaStyle = dynamic_cast<LwpParaStyle*>(pParaStyle->GetNext()->obj());
     240                 :            :         }
     241                 :            :     }
     242                 :         24 :     ChangeStyleName();//add by ,for click here block,05/5/26
     243                 :         24 : }
     244                 :            : /**
     245                 :            :  * @descr  Register all layouts styles (page master and master page)
     246                 :            :  *       All para styles used in master page (header and footer) are registered and then showed
     247                 :            :  */
     248                 :         24 : void LwpDocument::RegisterLayoutStyles()
     249                 :            : {
     250                 :            :     //Register all layout styles, before register all styles in para
     251                 :         24 :     m_pFoundry->RegisterAllLayouts();
     252                 :            : 
     253                 :            :     //set initial pagelayout in story for parsing pagelayout
     254         [ -  + ]:         24 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO));
     255                 :         24 :     LwpPageLayout* pPageLayout = NULL;
     256         [ +  - ]:         24 :     if(pDivInfo)
     257                 :            :     {
     258         [ +  + ]:         24 :         pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID()->obj(VO_PAGELAYOUT));
     259         [ +  + ]:         24 :         if(pPageLayout)
     260                 :            :         {
     261                 :            :             //In Ole division, the content of pagelayout is VO_OLEOBJECT
     262         [ -  + ]:         12 :             LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent()->obj(VO_STORY));
     263         [ +  - ]:         12 :             if(pStory)
     264                 :            :             {
     265                 :            :                 //add all the pagelayout in order into the pagelayout list;
     266                 :         12 :                 pStory->SortPageLayout();
     267                 :         12 :                 pStory->SetCurrentLayout(pPageLayout);
     268                 :            :             }
     269                 :            :         }
     270                 :            :     }
     271                 :         24 : }
     272                 :            : /**
     273                 :            :  * @descr  Register all styles used in para
     274                 :            :  */
     275                 :         24 : void LwpDocument::RegisterStylesInPara()
     276                 :            : {
     277                 :            :     //Register all automatic styles in para
     278         [ -  + ]:         24 :     LwpHeadContent* pContent = dynamic_cast<LwpHeadContent*> (m_pFoundry->GetContentManager()->GetContentList()->obj());
     279         [ +  - ]:         24 :     if(pContent)
     280                 :            :     {
     281         [ +  + ]:         24 :         LwpStory* pStory = dynamic_cast<LwpStory*>(pContent->GetChildHead()->obj(VO_STORY));
     282         [ +  + ]:        141 :         while(pStory)
     283                 :            :         {
     284                 :            :             //Register the child para
     285                 :        120 :             pStory->SetFoundry(m_pFoundry);
     286                 :        120 :             pStory->RegisterStyle();
     287         [ +  + ]:        117 :             pStory = dynamic_cast<LwpStory*>(pStory->GetNext()->obj(VO_STORY));
     288                 :            :         }
     289                 :            :     }
     290                 :         21 : }
     291                 :            : /**
     292                 :            :  * @descr  Register all bullet styles used in this division
     293                 :            :  */
     294                 :         24 : void LwpDocument::RegisterBulletStyles()
     295                 :            : {
     296                 :            :     //Register bullet styles
     297                 :            :     LwpDLVListHeadHolder* mBulletHead = dynamic_cast<LwpDLVListHeadHolder*>
     298         [ -  + ]:         24 :                 (m_pFoundry->GetBulletManagerID()->obj(VO_HEADHOLDER));
     299         [ +  - ]:         24 :     if( mBulletHead )
     300                 :            :     {
     301                 :            :         LwpSilverBullet* pBullet = dynamic_cast<LwpSilverBullet*>
     302         [ +  + ]:         24 :                             (mBulletHead->GetHeadID()->obj());
     303         [ +  + ]:         63 :         while(pBullet)
     304                 :            :         {
     305                 :         39 :             pBullet->SetFoundry(m_pFoundry);
     306                 :         39 :             pBullet->RegisterStyle();
     307         [ +  + ]:         39 :             pBullet = dynamic_cast<LwpSilverBullet*> (pBullet->GetNext()->obj());
     308                 :            :         }
     309                 :            :     }
     310                 :         24 : }
     311                 :            : /**
     312                 :            :  * @descr  Register all styles used in VO_Graphic
     313                 :            :  */
     314                 :         24 : void LwpDocument::RegisterGraphicsStyles()
     315                 :            : {
     316                 :            :     //Register all graphics styles, the first object should register the next;
     317                 :         24 :     LwpObject* pGraphic = m_pFoundry->GetGraphicListHead()->obj(VO_GRAPHIC);
     318         [ -  + ]:         24 :     if(pGraphic)
     319                 :            :     {
     320                 :          0 :         pGraphic->SetFoundry(m_pFoundry);
     321                 :          0 :         pGraphic->RegisterStyle();
     322                 :            :     }
     323                 :         24 : }
     324                 :            : /**
     325                 :            :  * @descr  Register line number styles
     326                 :            :  */
     327                 :         21 : void LwpDocument::RegisterLinenumberStyles()
     328                 :            : {
     329         [ -  + ]:         21 :     if (!m_pLnOpts)
     330                 :         21 :         return;
     331                 :         21 :     m_pLnOpts->RegisterStyle();
     332                 :            : }
     333                 :            : 
     334                 :            : /**
     335                 :            : * @descr   Register footnote/endnote configuration for the entire document
     336                 :            : */
     337                 :         21 : void LwpDocument::RegisterFootnoteStyles()
     338                 :            : {
     339                 :            :     //Register footnote and endnote configuration for the entire document
     340         [ +  + ]:         21 :     if(!m_FootnoteOpts.IsNull())
     341                 :            :     {
     342         [ -  + ]:         12 :         LwpFootnoteOptions* pFootnoteOpts = dynamic_cast<LwpFootnoteOptions*>(m_FootnoteOpts.obj());
     343         [ +  - ]:         12 :         if (pFootnoteOpts)
     344                 :            :         {
     345                 :         12 :             pFootnoteOpts->SetMasterPage(A2OUSTR("Endnote"));
     346                 :         12 :             pFootnoteOpts->RegisterStyle();
     347                 :            :         }
     348                 :            :     }
     349                 :            :     //Register endnote page style for endnote configuration, use the last division that has endnote for the endnote page style
     350                 :            :     //This page style must register after its division default styles have registered
     351                 :         21 :     LwpDocument* pEndnoteDiv = GetLastDivisionThatHasEndnote();
     352         [ -  + ]:         21 :     if(this == pEndnoteDiv)
     353                 :            :     {
     354         [ #  # ]:          0 :         LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast<LwpDLVListHeadTailHolder*>(GetPageHintsID()->obj());
     355         [ #  # ]:          0 :         if(pHeadTail)
     356                 :            :         {
     357         [ #  # ]:          0 :             LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetTail()->obj());
     358 [ #  # ][ #  # ]:          0 :             if(pPageHint && !pPageHint->GetPageLayoutID()->IsNull())
                 [ #  # ]
     359                 :            :             {
     360         [ #  # ]:          0 :                 LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pPageHint->GetPageLayoutID()->obj());
     361         [ #  # ]:          0 :                 if(pPageLayout)
     362                 :            :                 {
     363                 :          0 :                     pPageLayout->SetFoundry(GetFoundry());
     364                 :          0 :                     pPageLayout->RegisterEndnoteStyle();
     365                 :            :                 }
     366                 :            :             }
     367                 :            :         }
     368                 :            :     }
     369                 :         21 : }
     370                 :            : 
     371                 :            : /**
     372                 :            : * @descr   Register default para styles
     373                 :            : */
     374                 :            : #include "lwpverdocument.hxx"
     375                 :         24 : void LwpDocument::RegisterDefaultParaStyles()
     376                 :            : {
     377         [ +  + ]:         24 :     if(!IsChildDoc())
     378                 :            :     {
     379                 :            :         //Get First Division
     380                 :            :         //LwpDocument* pFirstDoc = GetFirstDivision();
     381                 :         12 :         LwpDocument* pFirstDoc = GetFirstDivisionWithContentsThatIsNotOLE();
     382         [ +  - ]:         12 :         if(pFirstDoc)
     383                 :            :         {
     384         [ -  + ]:         12 :             LwpVerDocument* pVerDoc = dynamic_cast<LwpVerDocument*>(pFirstDoc->GetVerDoc()->obj());
     385         [ +  - ]:         12 :             if(pVerDoc)
     386                 :            :             {
     387                 :         12 :                 pVerDoc->RegisterStyle();
     388                 :            :             }
     389                 :            :         }
     390                 :            : 
     391                 :            :     }
     392                 :         24 : }
     393                 :            : 
     394                 :            : /**
     395                 :            :  * @descr  Parse content in this division to IXFStream
     396                 :            :  * LwpDocument->LwpDivInfo->LwpPageLayout.Parse()
     397                 :            :  */
     398                 :         18 : void LwpDocument::ParseDocContent(IXFStream* pOutputStream)
     399                 :            : {
     400                 :            :     //Parse content in PageLayout
     401         [ -  + ]:         18 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj());
     402         [ -  + ]:         18 :     if(pDivInfo==NULL) return;
     403                 :            : 
     404                 :         18 :     LwpObject* pLayoutObj = pDivInfo->GetInitialLayoutID()->obj();
     405         [ +  + ]:         18 :     if(pLayoutObj==NULL)
     406                 :            :     {
     407                 :            :         //master document not supported now.
     408                 :          9 :         return;
     409                 :            :     }
     410                 :          9 :     pLayoutObj->SetFoundry(m_pFoundry);
     411                 :         18 :     pLayoutObj->Parse(pOutputStream);
     412                 :            : }
     413                 :            : 
     414                 :            : /**
     415                 :            :  * @descr    Get the footnoteoptions from the root document
     416                 :            :  */
     417                 :         24 : LwpObjectID* LwpDocument::GetValidFootnoteOpts()
     418                 :            : {
     419                 :         24 :     LwpDocument* pRoot = GetRootDocument();
     420         [ +  - ]:         24 :     if(pRoot)
     421                 :            :     {
     422                 :         24 :         return pRoot->GetFootnoteOpts();
     423                 :            :     }
     424                 :         24 :     return NULL;
     425                 :            : }
     426                 :            : 
     427                 :            : /**
     428                 :            :  * @descr    Get the endnote type
     429                 :            :  */
     430                 :          0 : sal_uInt16 LwpDocument::GetEndnoteType()
     431                 :            : {
     432 [ #  # ][ #  # ]:          0 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj());
     433         [ #  # ]:          0 :     if (!pDivInfo)
     434                 :          0 :         return FN_DONTCARE;
     435                 :          0 :     OUString strClassName = pDivInfo->GetClassName();
     436         [ #  # ]:          0 :     if (strClassName.equals(A2OUSTR(STR_DivisionEndnote)))
     437                 :          0 :         return FN_DIVISION_SEPARATE;
     438         [ #  # ]:          0 :     if (strClassName.equals(A2OUSTR(STR_DivisionGroupEndnote)))
     439                 :          0 :         return FN_DIVISIONGROUP_SEPARATE;
     440         [ #  # ]:          0 :     if (strClassName.equals(A2OUSTR(STR_DocumentEndnote)))
     441                 :          0 :         return FN_DOCUMENT_SEPARATE;
     442                 :          0 :     return FN_DONTCARE;
     443                 :            : }
     444                 :            : /**
     445                 :            :  * @descr       Get previous division
     446                 :            :  */
     447                 :         42 : LwpDocument* LwpDocument::GetPreviousDivision()
     448                 :            : {
     449         [ -  + ]:         42 :     LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
     450         [ +  - ]:         42 :     if(pDocSock)
     451                 :            :     {
     452         [ -  + ]:         42 :         return dynamic_cast<LwpDocument*>(pDocSock->GetPrevious()->obj());
     453                 :            :     }
     454                 :         42 :     return NULL;
     455                 :            : }
     456                 :            : /**
     457                 :            :  * @descr    Get next division
     458                 :            :  */
     459                 :          9 :  LwpDocument* LwpDocument::GetNextDivision()
     460                 :            : {
     461         [ -  + ]:          9 :     LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
     462         [ +  - ]:          9 :     if(pDocSock)
     463                 :            :     {
     464         [ -  + ]:          9 :         return dynamic_cast<LwpDocument*>(pDocSock->GetNext()->obj());
     465                 :            :     }
     466                 :          9 :     return NULL;
     467                 :            : }
     468                 :            : /**
     469                 :            :  * @descr    Get parent division
     470                 :            :  */
     471                 :        804 :  LwpDocument* LwpDocument::GetParentDivision()
     472                 :            : {
     473         [ -  + ]:        804 :     LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
     474         [ +  - ]:        804 :     if(pDocSock)
     475                 :            :     {
     476         [ +  + ]:        804 :         return dynamic_cast<LwpDocument*>(pDocSock->GetParent()->obj());
     477                 :            :     }
     478                 :        804 :     return NULL;
     479                 :            : }
     480                 :            : /**
     481                 :            :  * @descr    Get previous division in group, copy from lwp source code
     482                 :            :  */
     483                 :          0 :  LwpDocument* LwpDocument::GetPreviousInGroup()
     484                 :            : {
     485                 :          0 :     LwpDocument* pPrev = NULL;
     486                 :            : 
     487         [ #  # ]:          0 :     for (pPrev = GetPreviousDivision(); pPrev; pPrev = pPrev->GetPreviousDivision())
     488                 :            :     {
     489         [ #  # ]:          0 :         LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pPrev->GetDivInfoID()->obj());
     490 [ #  # ][ #  # ]:          0 :         if(pDivInfo && pDivInfo->HasContents())
                 [ #  # ]
     491                 :          0 :             return pPrev;
     492                 :            :     }
     493                 :          0 :     return NULL;
     494                 :            : }
     495                 :            : /**
     496                 :            :  * @descr       Get previous division in group, copy from lwp source code
     497                 :            :  */
     498                 :          0 :  LwpDocument* LwpDocument::GetNextInGroup()
     499                 :            : {
     500                 :          0 :     LwpDocument* pNext = NULL;
     501                 :            : 
     502         [ #  # ]:          0 :     for (pNext = GetNextDivision(); pNext; pNext = pNext->GetNextDivision())
     503                 :            :     {
     504         [ #  # ]:          0 :         LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pNext->GetDivInfoID()->obj());
     505 [ #  # ][ #  # ]:          0 :         if(pDivInfo && pDivInfo->HasContents())
                 [ #  # ]
     506                 :          0 :             return pNext;
     507                 :            :     }
     508                 :            : 
     509                 :          0 :     return NULL;
     510                 :            : }
     511                 :            : /**
     512                 :            :  * @descr    Get previous division which has contents, copy from lwp source code
     513                 :            :  */
     514                 :         42 :  LwpDocument* LwpDocument::GetPreviousDivisionWithContents()
     515                 :            : {
     516         [ -  + ]:         42 :     if(GetPreviousDivision())
     517                 :            :     {
     518                 :          0 :         LwpDocument* pDoc = GetPreviousDivision()->GetLastDivisionWithContents();
     519         [ #  # ]:          0 :         if (pDoc)
     520                 :          0 :             return pDoc;
     521                 :            :     }
     522         [ +  + ]:         42 :     if(GetParentDivision())
     523                 :         21 :         return GetParentDivision()->GetPreviousDivisionWithContents();
     524                 :         42 :     return NULL;
     525                 :            : }
     526                 :            :  /**
     527                 :            :  * @descr    Get last division which has contents, copy from lwp source code
     528                 :            :  */
     529                 :         42 :  LwpDocument* LwpDocument::GetLastDivisionWithContents()
     530                 :            : {
     531         [ -  + ]:         42 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj());
     532 [ +  - ][ +  + ]:         42 :     if(pDivInfo && pDivInfo->HasContents())
                 [ +  + ]
     533                 :            :     {
     534                 :         21 :         return this;
     535                 :            :     }
     536                 :            : 
     537                 :         21 :     LwpDocument* pDivision = GetLastDivision();
     538                 :         21 :     LwpDocument* pContentDivision = NULL;
     539                 :            : 
     540         [ +  - ]:         21 :     while(pDivision)
     541                 :            :     {
     542                 :         21 :         pContentDivision = pDivision->GetLastDivisionWithContents();
     543         [ +  - ]:         21 :         if(pContentDivision)
     544                 :            :         {
     545                 :         21 :             return pContentDivision;
     546                 :            :         }
     547                 :          0 :         pDivision = pDivision->GetPreviousDivision();
     548                 :            :     }
     549                 :            : 
     550                 :         42 :     return NULL;
     551                 :            : }
     552                 :            :  /**
     553                 :            :  * @descr    Get last division in group  which has contents, copy from lwp source code
     554                 :            :  */
     555                 :          0 :  LwpDocument* LwpDocument::GetLastInGroupWithContents()
     556                 :            : {
     557                 :          0 :     LwpDocument* pLast = NULL;
     558                 :          0 :     LwpDocument* pNext = this;
     559                 :            : 
     560         [ #  # ]:          0 :     while (pNext)
     561                 :            :     {
     562         [ #  # ]:          0 :         LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pNext->GetDivInfoID()->obj());
     563 [ #  # ][ #  # ]:          0 :         if (pDivInfo && pDivInfo->HasContents())
                 [ #  # ]
     564                 :          0 :             pLast = pNext;
     565                 :          0 :         pNext = pNext->GetNextInGroup();
     566                 :            :     }
     567         [ #  # ]:          0 :     if (pLast)
     568                 :          0 :         return pLast;
     569                 :          0 :     return NULL;
     570                 :            : }
     571                 :            :   /**
     572                 :            :  * @descr    Get last division
     573                 :            :  */
     574                 :         21 :  LwpDocument* LwpDocument::GetLastDivision()
     575                 :            : {
     576         [ -  + ]:         21 :     LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
     577         [ +  - ]:         21 :     if(pDocSock)
     578         [ +  - ]:         21 :         return dynamic_cast<LwpDocument*>(pDocSock->GetChildTail()->obj());
     579                 :         21 :     return NULL;
     580                 :            : }
     581                 :            : 
     582                 :            :   /**
     583                 :            :  * @descr    Get first division
     584                 :            :  */
     585                 :         30 :  LwpDocument* LwpDocument::GetFirstDivision()
     586                 :            : {
     587         [ -  + ]:         30 :     LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
     588         [ +  - ]:         30 :     if(pDocSock)
     589         [ +  + ]:         30 :         return dynamic_cast<LwpDocument*>(pDocSock->GetChildHead()->obj());
     590                 :         30 :     return NULL;
     591                 :            : }
     592                 :            : 
     593                 :            :  /**
     594                 :            :  * @descr    Get root document
     595                 :            :  */
     596                 :        753 :  LwpDocument* LwpDocument::GetRootDocument()
     597                 :            : {
     598                 :        753 :     LwpDocument* pRoot = this;
     599         [ +  - ]:       1494 :     while(pRoot)
     600                 :            :     {
     601         [ +  + ]:       1494 :         if(!pRoot->IsChildDoc())
     602                 :        753 :             return pRoot;
     603                 :        741 :         pRoot = pRoot->GetParentDivision();
     604                 :            :     }
     605                 :        753 :     return NULL;
     606                 :            : }
     607                 :            :   /**
     608                 :            :  * @descr    Get first division with contents that is not ole, copy from lwp-source code
     609                 :            :  */
     610                 :         24 :  LwpDocument* LwpDocument::GetFirstDivisionWithContentsThatIsNotOLE()
     611                 :            : {
     612         [ -  + ]:         24 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj());
     613         [ +  - ]:         36 :     if(pDivInfo && pDivInfo->HasContents()
           [ +  +  +  - ]
                 [ +  + ]
     614                 :         12 :         && !pDivInfo->IsOleDivision())
     615                 :         12 :         return this;
     616                 :            : 
     617                 :         12 :     LwpDocument* pDivision = GetFirstDivision();
     618                 :            : 
     619                 :         12 :     LwpDocument*  pContentDivision = NULL;
     620                 :            : 
     621         [ +  - ]:         12 :     while (pDivision)
     622                 :            :     {
     623                 :         12 :         pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
     624         [ +  - ]:         12 :         if(pContentDivision)
     625                 :         12 :             return pContentDivision;
     626                 :          0 :         pDivision = pDivision->GetNextDivision();
     627                 :            :     }
     628                 :         24 :     return NULL;
     629                 :            : }
     630                 :            :  /**
     631                 :            :  * @descr    Get last division that has endnote
     632                 :            :  */
     633                 :         21 :  LwpDocument* LwpDocument::GetLastDivisionThatHasEndnote()
     634                 :            : {
     635                 :         21 :     LwpDocument* pRoot = GetRootDocument();
     636                 :         21 :     LwpDocument *pLastDoc = pRoot->GetLastDivisionWithContents();
     637         [ +  + ]:         42 :     while(pLastDoc)
     638                 :            :     {
     639         [ -  + ]:         21 :         if(pLastDoc->GetEnSuperTableLayout())
     640                 :          0 :             return pLastDoc;
     641                 :         21 :         pLastDoc = pLastDoc->GetPreviousDivisionWithContents();
     642                 :            :     }
     643                 :         21 :     return NULL;
     644                 :            : 
     645                 :            : }
     646                 :            :  /**
     647                 :            :  * @descr    Get endnote supertable layout, every division has only one endnote supertable layout.
     648                 :            :  */
     649                 :         21 :  LwpVirtualLayout* LwpDocument::GetEnSuperTableLayout()
     650                 :            : {
     651         [ -  + ]:         21 :     LwpHeadLayout* pHeadLayout = dynamic_cast<LwpHeadLayout*>(GetFoundry()->GetLayout()->obj());
     652         [ +  - ]:         21 :     if(pHeadLayout)
     653                 :            :     {
     654                 :         21 :         return pHeadLayout->FindEnSuperTableLayout();
     655                 :            :     }
     656                 :         21 :     return NULL;
     657                 :            : }
     658                 :            : 
     659                 :            : /**
     660                 :            :  * @descr    Get the numbers of page  before pEndDivision, copy from lwp source code
     661                 :            :  */
     662                 :          0 :  sal_Bool LwpDocument::GetNumberOfPages(LwpDocument* pEndDivision, sal_uInt16& nCount)
     663                 :            : {
     664         [ #  # ]:          0 :     if(this == pEndDivision)
     665                 :          0 :         return sal_True;
     666                 :            : 
     667         [ #  # ]:          0 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj());
     668         [ #  # ]:          0 :     if(pDivInfo)
     669                 :            :     {
     670                 :          0 :         pDivInfo->GetNumberOfPages(nCount);
     671                 :            :     }
     672                 :            : 
     673                 :          0 :     LwpDocument* pDivision = GetFirstDivision();
     674         [ #  # ]:          0 :     while(pDivision)
     675                 :            :     {
     676         [ #  # ]:          0 :         if(pDivision->GetNumberOfPages(pEndDivision,nCount))
     677                 :          0 :             return sal_True;
     678                 :          0 :         pDivision = pDivision->GetNextDivision();
     679                 :            : 
     680                 :            :     }
     681                 :          0 :     return sal_False;
     682                 :            : }
     683                 :            : /**
     684                 :            :  * @descr    Get the numbers of page  before curruent division
     685                 :            :  */
     686                 :          0 : sal_uInt16 LwpDocument::GetNumberOfPagesBefore()
     687                 :            : {
     688                 :          0 :     sal_uInt16 nPageNumber = 0;
     689         [ #  # ]:          0 :     LwpDocument* pRoot = GetRootDocument();
     690         [ #  # ]:          0 :     if(pRoot)
     691         [ #  # ]:          0 :         pRoot->GetNumberOfPages(this,nPageNumber);
     692                 :          0 :     return nPageNumber;
     693                 :            : }
     694                 :            : 
     695                 :            :  /**
     696                 :            :  * @descr    Get Max number of pages
     697                 :            :  */
     698                 :          0 :  void  LwpDocument::MaxNumberOfPages(sal_uInt16& nNumPages)
     699                 :            : {
     700                 :          0 :     LwpDocument* pDivision = GetFirstDivision();
     701                 :            : 
     702         [ #  # ]:          0 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj());
     703         [ #  # ]:          0 :     if(pDivInfo)
     704                 :          0 :         nNumPages += pDivInfo->GetMaxNumberOfPages();
     705         [ #  # ]:          0 :     while(pDivision)
     706                 :            :     {
     707                 :          0 :         pDivision->MaxNumberOfPages(nNumPages);
     708                 :          0 :         pDivision = pDivision->GetNextDivision();
     709                 :            :     }
     710                 :          0 : }
     711                 :            :   /**
     712                 :            :  * @descr    Parse the frame which anchor is to page before parse other contents,
     713                 :            :  *          This method is called when the document is root document.
     714                 :            :  */
     715                 :         18 : void LwpDocument::ParseFrameInPage(IXFStream * pOutputStream)
     716                 :            : {
     717         [ +  + ]:         18 :     if(IsChildDoc())
     718                 :         18 :         return;
     719                 :            : 
     720         [ +  - ]:          9 :     XFContentContainer* pXFContainer = new XFContentContainer;
     721                 :            : 
     722                 :          9 :     XFConvertFrameInPage(pXFContainer);
     723                 :            : 
     724                 :          9 :     pXFContainer->ToXml(pOutputStream);
     725         [ +  - ]:          9 :     delete pXFContainer;
     726                 :          9 :     pXFContainer = NULL;
     727                 :            : }
     728                 :            :  /**
     729                 :            :  * @descr    Parse the frame which anchor is to page in the entire document
     730                 :            :  */
     731                 :         18 : void LwpDocument::XFConvertFrameInPage(XFContentContainer * pCont)
     732                 :            : {
     733                 :         18 :     LwpDocument* pDivision = GetFirstDivision();
     734                 :            : 
     735         [ -  + ]:         18 :     LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (GetDivInfoID()->obj());
     736         [ +  - ]:         18 :     if(pDivInfo)
     737                 :            :     {
     738         [ +  + ]:         18 :         LwpPageLayout*  pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID()->obj());
     739         [ +  + ]:         18 :         if(pPageLayout)
     740                 :            :         {
     741         [ -  + ]:          9 :             LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent()->obj());
     742         [ +  - ]:          9 :             if(pStory)
     743                 :          9 :                 pStory->XFConvertFrameInPage(pCont);
     744                 :            :         }
     745                 :            :     }
     746         [ +  + ]:         27 :     while(pDivision)
     747                 :            :     {
     748                 :          9 :         pDivision->XFConvertFrameInPage(pCont);
     749                 :          9 :         pDivision = pDivision->GetNextDivision();
     750                 :            :     }
     751                 :         18 : }
     752                 :            :  /**
     753                 :            :  * @descr    change click here to placeholder
     754                 :            :  */
     755                 :         24 : void LwpDocument::ChangeStyleName()
     756                 :            : {
     757                 :         24 :     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     758 [ +  - ][ +  - ]:         24 :     XFTextStyle* pStyle = dynamic_cast<XFTextStyle*>(pXFStyleManager->FindStyle(A2OUSTR("ClickHere")));
     759         [ -  + ]:         24 :     if (pStyle)
     760                 :            :     {
     761         [ #  # ]:          0 :         pStyle->SetStyleName(A2OUSTR("Placeholder"));
     762                 :            :     }
     763                 :         24 : }
     764                 :         24 : LwpDocSock::LwpDocSock(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
     765         [ +  - ]:         24 :     :LwpDLNFVList(objHdr, pStrm)
     766                 :         24 : {}
     767                 :            : 
     768                 :            :  /**
     769                 :            :  * @descr    read VO_DOCSOCK from file
     770                 :            :  */
     771                 :         24 : void LwpDocSock::Read()
     772                 :            : {
     773                 :         24 :     LwpDLNFVList::Read();
     774                 :         24 :     m_Doc.ReadIndexed(m_pObjStrm);
     775                 :         24 :     m_pObjStrm->SkipExtra();
     776                 :         24 : }
     777                 :            :  /**
     778                 :            :  * @descr    register styles in documents plugged
     779                 :            :  */
     780                 :         21 : void LwpDocSock::RegisterStyle()
     781                 :            : {
     782                 :         21 :     LwpObject* pDoc = GetNext()->obj();
     783         [ -  + ]:         21 :     if(pDoc)
     784                 :          0 :         pDoc->RegisterStyle();
     785                 :            : 
     786                 :         21 :     pDoc = GetChildHead()->obj();
     787         [ +  + ]:         21 :     if(pDoc)
     788                 :         12 :         pDoc->RegisterStyle();
     789                 :         18 : }
     790                 :            :  /**
     791                 :            :  * @descr    parse contents of documents plugged
     792                 :            :  */
     793                 :         18 : void LwpDocSock::Parse(IXFStream* pOutputStream)
     794                 :            : {
     795                 :         18 :     LwpObject* pDoc = GetChildHead()->obj();
     796         [ +  + ]:         18 :     if(pDoc)
     797                 :          9 :         pDoc->Parse(pOutputStream);
     798                 :            : 
     799                 :         18 :     pDoc = GetNext()->obj();
     800         [ -  + ]:         18 :     if(pDoc)
     801                 :          0 :         pDoc->Parse(pOutputStream);
     802                 :         18 : }
     803                 :            : 
     804                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10