LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpbulletstylemgr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 78 106 73.6 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 68 150 45.3 %

           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                 :            : /*************************************************************************
      57                 :            :  * @file
      58                 :            :  *  For LWP filter architecture prototype
      59                 :            :  ************************************************************************/
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  Jan 2005           Created
      63                 :            :  ************************************************************************/
      64                 :            : #include "lwpbulletstylemgr.hxx"
      65                 :            : #include "lwpdoc.hxx"
      66                 :            : #include "lwpstory.hxx"
      67                 :            : #include "lwpdivinfo.hxx"
      68                 :            : #include "lwppara.hxx"
      69                 :            : #include "lwpsilverbullet.hxx"
      70                 :            : #include "lwptools.hxx"
      71                 :            : #include "lwpparaproperty.hxx"
      72                 :            : #include "xfilter/xfliststyle.hxx"
      73                 :            : #include "xfilter/xfstylemanager.hxx"
      74                 :            : #include "xfilter/xflist.hxx"
      75                 :            : #include "lwpglobalmgr.hxx"
      76                 :            : 
      77                 :         27 : LwpBulletStyleMgr::LwpBulletStyleMgr() :
      78 [ +  - ][ +  - ]:         27 : m_pBulletList(NULL), m_bContinue(sal_True), m_bIsBulletSkipped(sal_False), m_nCurrentPos(0xFF)
      79                 :            : {
      80                 :         27 : }
      81         [ +  - ]:         24 : LwpBulletStyleMgr::~LwpBulletStyleMgr()
      82                 :            : {
      83         [ -  + ]:         24 :     if (m_pBulletList)
      84                 :            :     {
      85 [ #  # ][ #  # ]:          0 :         delete m_pBulletList;
      86                 :            :     }
      87                 :            : 
      88                 :         24 :     m_vIDsPairList.clear();
      89                 :         24 :     m_vStyleNameList.clear();
      90         [ -  + ]:         48 : }
      91                 :            : 
      92                 :            : /**
      93                 :            :  * @short   Register bullet style to style-list. The function only register the bullet and single customized numbering
      94                 :            :  *      not inluding the numbering sequence.
      95                 :            :  * @param   pPara pointer to the current paragraph which has a bullet/numbering.
      96                 :            :  * @param   pBullOver pointer to the bulletoverride of current paragraph.
      97                 :            :  * @param   pIndent pointer to the indentoverride of current paragraph.
      98                 :            :  */
      99                 :          6 : rtl::OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverride* pBullOver,
     100                 :            :     LwpIndentOverride* pIndent)
     101                 :            : {
     102                 :          6 :     rtl::OUString aEmpty;
     103                 :            : 
     104 [ +  - ][ -  + ]:          6 :     if(!pPara || !pIndent || !pBullOver)
                 [ +  - ]
     105                 :            :     {
     106                 :          0 :         return aEmpty;
     107                 :            :     }
     108                 :            : 
     109                 :          6 :     LwpSilverBullet* pSilverBullet = pPara->GetSilverBullet();
     110         [ -  + ]:          6 :     if (!pSilverBullet)
     111                 :            :     {
     112                 :            :         assert(false);
     113                 :          0 :         return aEmpty;
     114                 :            :     }
     115                 :            : 
     116         [ +  - ]:          6 :     LwpPara* pBulletPara = pSilverBullet->GetBulletPara();
     117         [ -  + ]:          6 :     if (!pBulletPara)
     118                 :            :     {
     119                 :            :         assert(false);
     120                 :          0 :         return aEmpty;
     121                 :            :     }
     122                 :            : 
     123         [ +  - ]:          6 :     LwpParaProperty* pProp = pPara->GetProperty(PP_LOCAL_INDENT);
     124                 :          6 :     LwpParaIndentProperty* pIndentProp = NULL;
     125         [ +  - ]:          6 :     LwpObjectID aIndentID;
     126         [ -  + ]:          6 :     if (pProp)
     127                 :            :     {
     128                 :          0 :         pIndentProp = static_cast<LwpParaIndentProperty*>(pProp);
     129                 :          0 :         aIndentID = pIndentProp->GetIndentID();
     130                 :            :     }
     131                 :            : 
     132                 :          6 :     LwpObjectID aBulletID = pBullOver->GetSilverBullet();
     133 [ +  - ][ +  - ]:          6 :     boost::shared_ptr<LwpBulletOverride> pBulletOver(pBullOver->clone());
     134                 :            : 
     135                 :          6 :     sal_uInt16 nNameIndex = 0;
     136                 :          6 :     std::vector <OverridePair>::iterator iter;
     137 [ +  - ][ +  + ]:          6 :     for(iter = m_vIDsPairList.begin(); iter != m_vIDsPairList.end(); ++iter)
     138                 :            :     {
     139         [ +  - ]:          6 :         if (iter->first->GetSilverBullet() == aBulletID && iter->second == aIndentID
           [ +  -  +  - ]
         [ +  - ][ +  - ]
     140                 :          3 :             && iter->first->IsRightAligned() == pBullOver->IsRightAligned())
     141                 :            :         {
     142                 :          3 :             return m_vStyleNameList[nNameIndex];
     143                 :            :         }
     144                 :            :         else
     145                 :            :         {
     146                 :          0 :             nNameIndex++;
     147                 :            :         }
     148                 :            :     }
     149                 :            : 
     150 [ +  - ][ +  - ]:          3 :     m_vIDsPairList.push_back(std::make_pair(pBulletOver, aIndentID));
                 [ +  - ]
     151                 :          3 :     rtl::OUString aStyleName;
     152                 :            : 
     153                 :          3 :     LwpFribPtr* pBulletParaFribs = pBulletPara->GetFribs();
     154         [ +  - ]:          3 :     sal_Bool bIsNumbering = (sal_Bool)(pBulletParaFribs->HasFrib(FRIB_TAG_PARANUMBER) != 0);
     155                 :            : 
     156                 :          3 :     enumXFAlignType eAlign = enumXFAlignStart;
     157         [ -  + ]:          3 :     if (pBullOver->IsRightAligned())
     158                 :            :     {
     159                 :          0 :         eAlign = enumXFAlignEnd;
     160                 :            :     }
     161                 :            : 
     162 [ +  - ][ +  - ]:          3 :     XFListStyle* pListStyle = new XFListStyle();
     163         [ +  - ]:          3 :     XFStyleManager* pXFStyleMgr = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     164                 :            : 
     165         [ -  + ]:          3 :     if (!bIsNumbering)
     166                 :            :     {
     167         [ #  # ]:          0 :         for (sal_uInt8 nC = 1; nC < 11; nC++)
     168                 :            :         {
     169                 :            :             pListStyle->SetListBullet(nC, pSilverBullet->GetBulletChar(), pSilverBullet->GetBulletFontName(),
     170 [ #  # ][ #  # ]:          0 :                 pSilverBullet->GetPrefix(), pSilverBullet->GetSuffix());
                 [ #  # ]
     171                 :            : 
     172         [ #  # ]:          0 :             if (pIndent->GetMRest() > 0.001)
     173                 :            :             {
     174                 :            :                 pListStyle->SetListPosition(nC, 0.0,
     175         [ #  # ]:          0 :                     LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent->GetMRest())), 0.0, eAlign);
     176                 :            :             }
     177                 :            :             else
     178                 :            :             {
     179                 :            :                 pListStyle->SetListPosition(nC, 0.0,
     180         [ #  # ]:          0 :                     0.0, LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent->GetMFirst())), eAlign);
     181                 :            :             }
     182                 :            :         }
     183                 :            : 
     184 [ #  # ][ #  # ]:          0 :         aStyleName = pXFStyleMgr->AddStyle(pListStyle)->GetStyleName();
     185                 :            :     }
     186                 :            :     else
     187                 :            :     {
     188         [ +  - ]:          3 :         ParaNumbering aParaNumbering;
     189         [ +  - ]:          3 :         pBulletPara->GetParaNumber(1, &aParaNumbering);
     190                 :          3 :         LwpFribParaNumber* pParaNumber = aParaNumbering.pParaNumber;
     191         [ +  - ]:          3 :         if (pParaNumber)
     192                 :            :         {
     193         [ +  + ]:         30 :             for (sal_uInt8 nPos = 1; nPos < 10; nPos++)
     194                 :            :             {
     195         [ +  - ]:         27 :                 if (pParaNumber->GetStyleID() != NUMCHAR_other)
     196                 :            :                 {
     197                 :         27 :                     rtl::OUString aPrefix;
     198                 :         27 :                     XFNumFmt aFmt;
     199         [ -  + ]:         27 :                     if (aParaNumbering.pPrefix)
     200                 :            :                     {
     201                 :          0 :                         aPrefix += aParaNumbering.pPrefix->GetText();
     202                 :            :                     }
     203                 :            : 
     204         [ +  - ]:         27 :                     rtl::OUString aNumber = LwpSilverBullet::GetNumCharByStyleID(pParaNumber);
     205 [ +  - ][ -  + ]:         27 :                     if (pParaNumber->GetStyleID() == NUMCHAR_01 || pParaNumber->GetStyleID() == NUMCHAR_Chinese4)
                 [ -  + ]
     206                 :            :                     {
     207                 :          0 :                         aPrefix += rtl::OUString("0");
     208                 :            :                     }
     209                 :         27 :                     aFmt.SetPrefix(aPrefix);
     210                 :            : 
     211                 :         27 :                     aFmt.SetFormat(aNumber);
     212                 :            : 
     213         [ -  + ]:         27 :                     if (aParaNumbering.pSuffix)
     214                 :            :                     {
     215                 :          0 :                         aFmt.SetSuffix(aParaNumbering.pSuffix->GetText());
     216                 :            :                     }
     217                 :            : 
     218                 :            :                     //set numbering format into the style-list.
     219         [ +  - ]:         27 :                     pListStyle->SetListNumber(nPos, aFmt, pParaNumber->GetStart()+1);
     220                 :            : 
     221                 :            :                 }
     222                 :            :                 else
     223                 :            :                 {
     224                 :          0 :                     rtl::OUString aPrefix, aSuffix;
     225         [ #  # ]:          0 :                     if (aParaNumbering.pPrefix)
     226                 :            :                     {
     227                 :          0 :                         aPrefix = aParaNumbering.pPrefix->GetText();
     228                 :            :                     }
     229         [ #  # ]:          0 :                     if (aParaNumbering.pSuffix)
     230                 :            :                     {
     231                 :          0 :                         aSuffix = aParaNumbering.pSuffix->GetText();
     232                 :            :                     }
     233                 :            : 
     234         [ #  # ]:          0 :                     pListStyle->SetListBullet(nPos, LwpSilverBullet::GetNumCharByStyleID(pParaNumber).toChar(),
     235         [ #  # ]:          0 :                         rtl::OUString("Times New Roman"), aPrefix, aSuffix);
     236                 :            :                 }
     237                 :            : 
     238         [ +  - ]:         27 :                 pListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0);
     239                 :            :             }
     240 [ +  - ][ +  - ]:          3 :             aStyleName = pXFStyleMgr->AddStyle(pListStyle)->GetStyleName();
     241                 :            :         }
     242                 :            : 
     243                 :            :     }
     244                 :            : 
     245         [ +  - ]:          3 :     m_vStyleNameList.push_back(aStyleName);
     246         [ +  - ]:          6 :     return aStyleName;
     247                 :            : 
     248                 :            : }
     249                 :            : 
     250                 :            : #include "xfilter/xflistitem.hxx"
     251                 :            : //Create nested XFList and XFItems and then add it to XFContentContainer(pCont)
     252                 :            : //Return the inner XFItem created.
     253                 :         15 : XFContentContainer* LwpBulletStyleMgr::AddBulletList(
     254                 :            :         XFContentContainer* pCont, sal_Bool bIsOrdered,
     255                 :            :         const rtl::OUString& rStyleName, sal_Int16 nLevel, sal_Bool bIsBulletSkiped)
     256                 :            : {
     257                 :            :     assert(nLevel>0);
     258                 :            : 
     259                 :         15 :     m_bIsBulletSkipped = bIsBulletSkiped;
     260                 :            : 
     261                 :            :     //todo: need judge here.
     262                 :         15 :     sal_Bool bContinue = m_bContinue;
     263                 :            : 
     264                 :            :     XFList* theList;
     265                 :         15 :     XFList* prevList = NULL;
     266                 :            :     XFListItem* theItem;
     267                 :         15 :     XFListItem* InnerItem = NULL;
     268         [ +  + ]:         54 :     for (sal_Int8 nC = nLevel-1; nC >= 0; nC--)
     269                 :            :     {
     270         [ +  - ]:         39 :         theList = new XFList();
     271         [ +  - ]:         39 :         theItem = new XFListItem();
     272                 :         39 :         theList->Add(theItem);
     273                 :            : 
     274         [ +  - ]:         39 :         if (bIsOrdered)
     275                 :            :         {
     276                 :         39 :             theList->SetOrdered(sal_True);
     277                 :            :         }
     278                 :            :         else
     279                 :            :         {
     280                 :          0 :             bContinue = sal_False;
     281                 :          0 :             theList->SetOrdered(sal_False);
     282                 :            :         }
     283                 :            : 
     284         [ +  + ]:         39 :         if (nC == nLevel-1)
     285                 :            :         {
     286                 :         15 :             theList->SetContinueNumber(bContinue);
     287                 :            :         }
     288                 :            :         //Add the outer list to pCont
     289         [ +  + ]:         39 :         if (nC == 0)
     290                 :            :         {
     291         [ +  - ]:         15 :             theList->SetStyleName(rStyleName);
     292                 :         15 :             pCont->Add(theList);
     293                 :            :         }
     294                 :            : 
     295 [ +  + ][ -  + ]:         39 :         if ((nC == nLevel-1) && bIsBulletSkiped)
     296                 :            :         {
     297                 :          0 :             theItem->SetIsHeader(sal_True);
     298                 :            : 
     299                 :          0 :             theList->SetContinueNumber(sal_True);
     300                 :            :             // end of add
     301                 :            :         }
     302                 :            : 
     303         [ +  + ]:         39 :         if(nC == nLevel-1)
     304                 :            :         {
     305                 :         15 :             InnerItem = theItem;
     306                 :            :         }
     307                 :            : 
     308         [ +  + ]:         39 :         if(prevList)
     309                 :            :         {
     310                 :         24 :             theItem->Add(prevList);
     311                 :            :         }
     312                 :         39 :         prevList = theList;
     313                 :            :     }
     314                 :         15 :     return InnerItem;
     315                 :            : }
     316                 :            : 
     317                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10