LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfliststyle.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 160 0.0 %
Date: 2014-04-14 Functions: 0 14 0.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             :  * Styles for ordered list and unordered list.
      59             :  ************************************************************************/
      60             : #include "xfliststyle.hxx"
      61             : 
      62           0 : XFListLevel::XFListLevel()
      63             : {
      64           0 :     m_nLevel = 0;
      65           0 :     m_nDisplayLevel = 0;
      66           0 :     m_fIndent = 0;
      67           0 :     m_fMinLabelWidth = 0.499;
      68           0 :     m_fMinLabelDistance = 0;
      69           0 :     m_eAlign = enumXFAlignStart;
      70           0 :     m_eListType = enumXFListLevelNumber;
      71           0 : }
      72             : 
      73           0 : void XFListLevel::ToXml(IXFStream * /*pStrm*/)
      74             : {
      75           0 : }
      76             : 
      77           0 : void XFListlevelNumber::ToXml(IXFStream *pStrm)
      78             : {
      79           0 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
      80             : 
      81           0 :     pAttrList->Clear();
      82           0 :     pAttrList->AddAttribute( "text:level", OUString::number((sal_Int32)m_nLevel) );
      83             :     //text:style-name,ignore now.
      84           0 :     m_aNumFmt.ToXml(pStrm);
      85           0 :     if( m_nDisplayLevel )
      86           0 :         pAttrList->AddAttribute( "text:display-levels", OUString::number((sal_Int32)m_nDisplayLevel) );
      87             : 
      88           0 :     pStrm->StartElement( "text:list-level-style-number" );
      89             : 
      90             :     //<style:properties>...</style:properties>
      91           0 :     pAttrList->Clear();
      92           0 :     if( m_fIndent > FLOAT_MIN )
      93             :     {
      94           0 :         pAttrList->AddAttribute( "text:space-before", OUString::number(m_fIndent) + "cm" );
      95             :     }
      96           0 :     if( m_fMinLabelWidth > FLOAT_MIN )
      97             :     {
      98           0 :         pAttrList->AddAttribute( "text:min-label-width", OUString::number(m_fMinLabelWidth) + "cm" );
      99             :     }
     100           0 :     if( m_fMinLabelDistance > FLOAT_MIN )
     101             :     {
     102           0 :         pAttrList->AddAttribute( "text:min-label-distance", OUString::number(m_fMinLabelDistance) + "cm" );
     103             :     }
     104           0 :     pAttrList->AddAttribute( "fo:text-align", GetAlignName(m_eAlign) );
     105             : 
     106           0 :     pStrm->StartElement( "style:properties" );
     107           0 :     pStrm->EndElement( "style:properties" );
     108             : 
     109           0 :     pStrm->EndElement( "text:list-level-style-number" );
     110           0 : }
     111             : 
     112           0 : void    XFListLevelBullet::ToXml(IXFStream *pStrm)
     113             : {
     114           0 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     115             : 
     116           0 :     pAttrList->Clear();
     117           0 :     pAttrList->AddAttribute( "text:level", OUString::number((sal_Int32)m_nLevel) );
     118             :     //text:style-name,ignore now.
     119           0 :     m_aNumFmt.ToXml(pStrm);
     120             :     //bullet-char
     121           0 :     OUString   bullet(m_chBullet);
     122           0 :     pAttrList->AddAttribute( "text:bullet-char", bullet );
     123             : 
     124           0 :     pStrm->StartElement( "text:list-level-style-bullet" );
     125             : 
     126             :     //<style:properties>...</style:properties>
     127           0 :     pAttrList->Clear();
     128           0 :     if( m_fIndent != 0 )
     129             :     {
     130           0 :         pAttrList->AddAttribute( "text:space-before", OUString::number(m_fIndent) + "cm" );
     131             :     }
     132           0 :     if( m_fMinLabelWidth != 0 )
     133             :     {
     134           0 :         pAttrList->AddAttribute( "text:min-label-width", OUString::number(m_fMinLabelWidth) + "cm" );
     135             :     }
     136           0 :     if( m_fMinLabelDistance != 0 )
     137             :     {
     138           0 :         pAttrList->AddAttribute( "text:min-label-distance", OUString::number(m_fMinLabelDistance) + "cm" );
     139             :     }
     140             : 
     141           0 :     pAttrList->AddAttribute( "fo:text-align", GetAlignName(m_eAlign) );
     142             : 
     143           0 :     if( !m_strFontName.isEmpty() )
     144             :     {
     145           0 :         pAttrList->AddAttribute( "style:font-name", m_strFontName );
     146             :     }
     147           0 :     pStrm->StartElement( "style:properties" );
     148           0 :     pStrm->EndElement( "style:properties" );
     149             : 
     150           0 :     pStrm->EndElement( "text:list-level-style-bullet" );
     151           0 : }
     152             : 
     153           0 : XFListStyle::XFListStyle()
     154             : {
     155           0 :     XFNumFmt    nf;
     156           0 :     nf.SetSuffix( "." );
     157           0 :     nf.SetFormat( "1" );
     158             : 
     159           0 :     for( int i=0; i<10; i++ )
     160             :     {
     161           0 :         m_pListLevels[i] = new XFListlevelNumber();
     162           0 :         m_pListLevels[i]->SetListlevelType(enumXFListLevelNumber);
     163           0 :         m_pListLevels[i]->SetMinLabelWidth(0.499);
     164           0 :         m_pListLevels[i]->SetIndent(0.501*(i+1));
     165           0 :         m_pListLevels[i]->SetLevel(i+1);
     166           0 :         ( (XFListlevelNumber*)m_pListLevels[i])->SetNumFmt(nf);
     167           0 :     }
     168           0 : }
     169             : 
     170           0 : XFListStyle::XFListStyle(const XFListStyle& other):XFStyle(other)
     171             : {
     172             :     enumXFListLevel type;
     173           0 :     for( int i=0; i<10; i++ )
     174             :     {
     175           0 :         type = other.m_pListLevels[i]->m_eListType;
     176           0 :         if( type == enumXFListLevelNumber )
     177             :         {
     178           0 :             XFListlevelNumber *pNum = (XFListlevelNumber*)other.m_pListLevels[i];
     179           0 :             m_pListLevels[i] = new XFListlevelNumber(*pNum);
     180             :         }
     181           0 :         else if( type == enumXFListLevelBullet )
     182             :         {
     183           0 :             XFListLevelBullet *pBullet = (XFListLevelBullet*)other.m_pListLevels[i];
     184           0 :             m_pListLevels[i] = new XFListLevelBullet(*pBullet);
     185             :         }
     186             :         else
     187           0 :             m_pListLevels[i] = NULL;
     188             :     }
     189           0 : }
     190             : 
     191           0 : XFListStyle& XFListStyle::operator=(const XFListStyle& other)
     192             : {
     193             :     enumXFListLevel type;
     194           0 :     for( int i=0; i<10; i++ )
     195             :     {
     196           0 :         type = other.m_pListLevels[i]->m_eListType;
     197           0 :         if( type == enumXFListLevelNumber )
     198             :         {
     199           0 :             XFListlevelNumber *pNum = (XFListlevelNumber*)m_pListLevels[i];
     200           0 :             m_pListLevels[i] = new XFListlevelNumber(*pNum);
     201             :         }
     202           0 :         else if( type == enumXFListLevelBullet )
     203             :         {
     204           0 :             XFListLevelBullet *pBullet = (XFListLevelBullet*)m_pListLevels[i];
     205           0 :             m_pListLevels[i] = new XFListLevelBullet(*pBullet);
     206             :         }
     207             :         else
     208           0 :             m_pListLevels[i] = NULL;
     209             :     }
     210           0 :     return *this;
     211             : }
     212             : 
     213           0 : XFListStyle::~XFListStyle()
     214             : {
     215           0 :     for( int i=0; i<10; i++ )
     216             :     {
     217           0 :         if( m_pListLevels[i] )
     218           0 :             delete m_pListLevels[i];
     219             :     }
     220           0 : }
     221             : 
     222           0 : void    XFListStyle::SetDisplayLevel(sal_Int32 level, sal_Int16 nDisplayLevel)
     223             : {
     224             :     assert(level>=1&&level<=10);
     225             : 
     226           0 :     XFListLevel *pLevel = m_pListLevels[level-1];
     227           0 :     if( !pLevel )
     228             :     {
     229           0 :         pLevel = new XFListlevelNumber();
     230           0 :         pLevel->SetListlevelType(enumXFListLevelNumber);
     231           0 :         pLevel->SetLevel(level+1);
     232           0 :         pLevel->SetMinLabelWidth(0.499);
     233           0 :         pLevel->SetIndent(0.501*(level+1));
     234           0 :         pLevel->SetDisplayLevel(nDisplayLevel);
     235           0 :         m_pListLevels[level-1] = pLevel;
     236             :     }
     237             :     else
     238           0 :         pLevel->SetDisplayLevel(nDisplayLevel);
     239           0 : }
     240             : 
     241           0 : void    XFListStyle::SetListPosition(sal_Int32 level,
     242             :                 double indent,
     243             :                 double minLabelWidth,
     244             :                 double minLabelDistance,
     245             :                 enumXFAlignType align
     246             :                 )
     247             : {
     248             :     assert(level>=1&&level<=10);
     249             : 
     250           0 :     XFListLevel *pLevel = m_pListLevels[level-1];
     251           0 :     if( !pLevel )
     252             :     {
     253           0 :         pLevel = new XFListLevelBullet();
     254           0 :         pLevel->SetListlevelType(enumXFListLevelNumber);
     255           0 :         pLevel->SetLevel(level+1);
     256           0 :         pLevel->SetIndent(indent);
     257           0 :         pLevel->SetMinLabelWidth(minLabelWidth);
     258           0 :         pLevel->SetMinLabelDistance(minLabelDistance);
     259           0 :         pLevel->SetAlignType(align);
     260           0 :         m_pListLevels[level-1] = pLevel;
     261             :     }
     262             :     else
     263             :     {
     264           0 :         pLevel->SetIndent(indent);
     265           0 :         pLevel->SetMinLabelWidth(minLabelWidth);
     266           0 :         pLevel->SetMinLabelDistance(minLabelDistance);
     267           0 :         pLevel->SetAlignType(align);
     268             :     }
     269           0 : }
     270             : 
     271           0 : void    XFListStyle::SetListBullet(sal_Int32 level,
     272             :                                    UChar32 bullet,
     273             :                                    const OUString& fontname,
     274             :                                    const OUString& prefix,
     275             :                                    const OUString& suffix
     276             :                                    )
     277             : {
     278             :     assert(level>=1&&level<=10);
     279             : 
     280           0 :     if( m_pListLevels[level-1] )
     281           0 :         delete m_pListLevels[level-1];
     282             : 
     283           0 :     XFListLevelBullet *pLevel = new XFListLevelBullet();
     284           0 :     pLevel->SetPrefix(prefix);
     285           0 :     pLevel->SetSuffix(suffix);
     286           0 :     pLevel->SetBulletChar(bullet);
     287           0 :     pLevel->SetFontName(fontname);
     288             : 
     289           0 :     pLevel->SetListlevelType(enumXFListLevelBullet);
     290           0 :     pLevel->SetMinLabelWidth(0.499);
     291           0 :     pLevel->SetIndent(0.501*level);
     292           0 :     pLevel->SetLevel(level);
     293           0 :     m_pListLevels[level-1] = pLevel;
     294           0 : }
     295             : 
     296           0 : void    XFListStyle::SetListNumber(sal_Int32 level, XFNumFmt& fmt, sal_Int16 start )
     297             : {
     298             :     assert(level>=1&&level<=10);
     299             : 
     300           0 :     if( m_pListLevels[level-1] )
     301           0 :         delete m_pListLevels[level-1];
     302             : 
     303           0 :     XFListlevelNumber *pLevel = new XFListlevelNumber();
     304           0 :     pLevel->SetNumFmt(fmt);
     305           0 :     pLevel->SetStartValue(start);
     306             : 
     307           0 :     pLevel->SetListlevelType(enumXFListLevelNumber);
     308           0 :     pLevel->SetMinLabelWidth(0.499);
     309           0 :     pLevel->SetIndent(0.501*level);
     310           0 :     pLevel->SetLevel(level);
     311           0 :     m_pListLevels[level-1] = pLevel;
     312           0 : }
     313             : 
     314           0 : void XFListStyle::ToXml(IXFStream *pStrm)
     315             : {
     316           0 :     IXFAttrList *pAttrList = pStrm->GetAttrList();
     317             : 
     318           0 :     pAttrList->Clear();
     319           0 :     pAttrList->AddAttribute( "style:name", GetStyleName() );
     320           0 :     if( !GetParentStyleName().isEmpty() )
     321           0 :         pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
     322           0 :     pStrm->StartElement( "text:list-style" );
     323             : 
     324           0 :     for( int i=0; i<10; i++ )
     325             :     {
     326           0 :         XFListLevel *pLevel = m_pListLevels[i];
     327           0 :         if( pLevel )
     328           0 :             pLevel->ToXml(pStrm);
     329             :     }
     330             : 
     331           0 :     pStrm->EndElement( "text:list-style" );
     332           0 : }
     333             : 
     334             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10