LCOV - code coverage report
Current view: top level - libreoffice/lotuswordpro/source/filter - lwpbreaksoverride.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 94 38.3 %
Date: 2012-12-27 Functions: 8 15 53.3 %
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             : * Breaks override of Wordpro.
      59             : ************************************************************************/
      60             : #include <memory>
      61             : 
      62             : #include "clone.hxx"
      63             : #include    "lwpbreaksoverride.hxx"
      64             : #include    "lwpobjstrm.hxx"
      65             : #include    "lwpatomholder.hxx"
      66             : 
      67             : 
      68          20 : LwpBreaksOverride::LwpBreaksOverride()
      69             : {
      70          20 :     m_pNextStyle = new LwpAtomHolder();
      71          20 : }
      72             : 
      73         254 : LwpBreaksOverride::LwpBreaksOverride(LwpBreaksOverride const& rOther)
      74             :     : LwpOverride(rOther)
      75         254 :     , m_pNextStyle(0)
      76             : {
      77         254 :     std::auto_ptr<LwpAtomHolder> pNextStyle(::clone(rOther.m_pNextStyle));
      78         254 :     m_pNextStyle = pNextStyle.release();
      79         254 : }
      80             : 
      81         822 : LwpBreaksOverride::~LwpBreaksOverride()
      82             : {
      83         274 :     if( m_pNextStyle )
      84         274 :         delete m_pNextStyle;
      85         548 : }
      86             : 
      87         254 : LwpBreaksOverride* LwpBreaksOverride::clone() const
      88             : {
      89         254 :     return new LwpBreaksOverride(*this);
      90             : }
      91             : 
      92          20 : void    LwpBreaksOverride::Read(LwpObjectStream *pStrm)
      93             : {
      94          20 :     if (pStrm->QuickReadBool())
      95             :     {
      96          20 :         ReadCommon(pStrm);
      97             : 
      98          20 :         m_pNextStyle->Read(pStrm);
      99             :     }
     100             : 
     101          20 :     pStrm->SkipExtra();
     102          20 : }
     103             : 
     104             : //add by , 01/28/2005
     105         127 : void LwpBreaksOverride::Override(LwpBreaksOverride* pOther)
     106             : {
     107         127 :     if (m_nApply & BO_PAGEBEFORE)
     108             :     {
     109           0 :         if (IsPageBreakBeforeOverridden())
     110             :         {
     111           0 :             pOther->OverridePageBreakBefore(IsPageBreakBefore());
     112             :         }
     113             :         else
     114             :         {
     115           0 :             pOther->RevertPageBreakBefore();
     116             :         }
     117             :     }
     118         127 :     if (m_nApply & BO_PAGEAFTER)
     119             :     {
     120           0 :         if (IsPageBreakAfterOverridden())
     121             :         {
     122           0 :             pOther->OverridePageBreakAfter(IsPageBreakAfter());
     123             :         }
     124             :         else
     125             :         {
     126           0 :             pOther->RevertPageBreakAfter();
     127             :         }
     128             :     }
     129         127 :     if (m_nApply & BO_KEEPTOGETHER)
     130             :     {
     131         127 :         if (IsPageBreakWithinOverridden())
     132             :         {
     133         127 :             pOther->OverridePageBreakWithin(IsPageBreakWithin());
     134             :         }
     135             :         else
     136             :         {
     137           0 :             pOther->RevertPageBreakWithin();
     138             :         }
     139             :     }
     140         127 :     if (m_nApply & BO_COLBEFORE)
     141             :     {
     142           0 :         if (IsColumnBreakBeforeOverridden())
     143             :         {
     144           0 :             pOther->OverrideColumnBreakBefore(IsColumnBreakBefore());
     145             :         }
     146             :         else
     147             :         {
     148           0 :             pOther->RevertColumnBreakBefore();
     149             :         }
     150             :     }
     151         127 :     if (m_nApply & BO_COLAFTER)
     152             :     {
     153           0 :         if (IsColumnBreakAfterOverridden())
     154             :         {
     155           0 :             pOther->OverrideColumnBreakAfter(IsColumnBreakAfter());
     156             :         }
     157             :         else
     158             :         {
     159           0 :             pOther->RevertColumnBreakAfter();
     160             :         }
     161             :     }
     162         127 :     if (m_nApply & BO_KEEPPREV)
     163             :     {
     164           0 :         if (IsKeepWithPreviousOverridden())
     165             :         {
     166           0 :             pOther->OverrideKeepWithPrevious(IsKeepWithPrevious());
     167             :         }
     168             :         else
     169             :         {
     170           0 :             pOther->RevertKeepWithPrevious();
     171             :         }
     172             :     }
     173         127 :     if (m_nApply & BO_KEEPNEXT)
     174             :     {
     175           0 :         if (IsKeepWithNextOverridden())
     176             :         {
     177           0 :             pOther->OverrideKeepWithNext(IsKeepWithNext());
     178             :         }
     179             :         else
     180             :         {
     181           0 :             pOther->RevertKeepWithNext();
     182             :         }
     183             :     }
     184         127 :     if (m_nApply & BO_USENEXTSTYLE)
     185             :     {
     186           0 :         if (IsUseNextStyleOverridden())
     187             :         {
     188           0 :             pOther->OverrideUseNextStyle(IsUseNextStyle());
     189             :         }
     190             :         else
     191             :         {
     192           0 :             pOther->RevertUseNextStyle();
     193             :         }
     194             :     }
     195         127 : }
     196             : 
     197           0 : void LwpBreaksOverride::OverridePageBreakBefore(sal_Bool bVal)
     198             : {
     199           0 :     if(bVal)
     200             :     {
     201           0 :         LwpOverride::Override(BO_PAGEBEFORE, STATE_ON);
     202             :     }
     203             :     else
     204             :     {
     205           0 :         LwpOverride::Override(BO_PAGEBEFORE, STATE_OFF);
     206             :     }
     207           0 : }
     208           0 : void LwpBreaksOverride::OverridePageBreakAfter(sal_Bool bVal)
     209             : {
     210           0 :     if(bVal)
     211             :     {
     212           0 :         LwpOverride::Override(BO_PAGEAFTER, STATE_ON);
     213             :     }
     214             :     else
     215             :     {
     216           0 :         LwpOverride::Override(BO_PAGEAFTER, STATE_OFF);
     217             :     }
     218           0 : }
     219         127 : void LwpBreaksOverride::OverridePageBreakWithin(sal_Bool bVal)
     220             : {
     221             :     // Note the flipped logic
     222         127 :     if(!bVal)
     223             :     {
     224         127 :         LwpOverride::Override(BO_KEEPTOGETHER, STATE_ON);
     225             :     }
     226             :     else
     227             :     {
     228           0 :         LwpOverride::Override(BO_KEEPTOGETHER, STATE_OFF);
     229             :     }
     230         127 : }
     231           0 : void LwpBreaksOverride::OverrideColumnBreakBefore(sal_Bool bVal)
     232             : {
     233           0 :     if(bVal)
     234             :     {
     235           0 :         LwpOverride::Override(BO_COLBEFORE, STATE_ON);
     236             :     }
     237             :     else
     238             :     {
     239           0 :         LwpOverride::Override(BO_COLBEFORE, STATE_OFF);
     240             :     }
     241           0 : }
     242           0 : void LwpBreaksOverride::OverrideColumnBreakAfter(sal_Bool bVal)
     243             : {
     244           0 :     if(bVal)
     245             :     {
     246           0 :         LwpOverride::Override(BO_COLAFTER, STATE_ON);
     247             :     }
     248             :     else
     249             :     {
     250           0 :         LwpOverride::Override(BO_COLAFTER, STATE_OFF);
     251             :     }
     252           0 : }
     253           0 : void LwpBreaksOverride::OverrideKeepWithNext(sal_Bool bVal)
     254             : {
     255           0 :     if(bVal)
     256             :     {
     257           0 :         LwpOverride::Override(BO_KEEPNEXT, STATE_ON);
     258             :     }
     259             :     else
     260             :     {
     261           0 :         LwpOverride::Override(BO_KEEPNEXT, STATE_OFF);
     262             :     }
     263           0 : }
     264           0 : void LwpBreaksOverride::OverrideKeepWithPrevious(sal_Bool bVal)
     265             : {
     266           0 :     if(bVal)
     267             :     {
     268           0 :         LwpOverride::Override(BO_KEEPPREV, STATE_ON);
     269             :     }
     270             :     else
     271             :     {
     272           0 :         LwpOverride::Override(BO_KEEPPREV, STATE_OFF);
     273             :     }
     274           0 : }
     275           0 : void LwpBreaksOverride::OverrideUseNextStyle(sal_Bool bVal)
     276             : {
     277           0 :     if(bVal)
     278             :     {
     279           0 :         LwpOverride::Override(BO_USENEXTSTYLE, STATE_ON);
     280             :     }
     281             :     else
     282             :     {
     283           0 :         LwpOverride::Override(BO_USENEXTSTYLE, STATE_OFF);
     284             :     }
     285           0 : }
     286             : //end add
     287             : 
     288             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10