LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpparaborderoverride.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 125 163 76.7 %
Date: 2012-08-25 Functions: 17 20 85.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 45 96 46.9 %

           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                 :            : * Border override of Wordpro.
      59                 :            : ************************************************************************/
      60                 :            : #include <memory>
      61                 :            : 
      62                 :            : #include "clone.hxx"
      63                 :            : #include    "lwpparaborderoverride.hxx"
      64                 :            : #include    "lwpborderstuff.hxx"
      65                 :            : #include    "lwpshadow.hxx"
      66                 :            : #include    "lwpmargins.hxx"
      67                 :            : 
      68                 :         18 : LwpParaBorderOverride::LwpParaBorderOverride()
      69                 :            : {
      70 [ +  - ][ +  - ]:         18 :     m_pBorderStuff = new LwpBorderStuff();
      71 [ +  - ][ +  - ]:         18 :     m_pBetweenStuff = new LwpBorderStuff();
      72         [ +  - ]:         18 :     m_pShadow = new LwpShadow();
      73         [ +  - ]:         18 :     m_pMargins = new LwpMargins();
      74                 :            : 
      75                 :         18 :     m_eAboveType = PB_NONE;
      76                 :         18 :     m_eBelowType = PB_NONE;
      77                 :         18 :     m_eRightType = PB_NONE;
      78                 :         18 :     m_eBetweenType = PB_NONE;
      79                 :            : 
      80                 :         18 :     m_nAboveWidth = 0;
      81                 :         18 :     m_nBelowWidth = 0;
      82                 :         18 :     m_nBetweenWidth = 0;
      83                 :         18 :     m_nRightWidth = 0;
      84                 :            : 
      85                 :         18 :     m_nBetweenMargin = 0;
      86                 :         18 : }
      87                 :            : 
      88                 :         12 : LwpParaBorderOverride::LwpParaBorderOverride(LwpParaBorderOverride const& rOther)
      89                 :            :     : LwpOverride(rOther)
      90                 :            :     , m_pBorderStuff(0)
      91                 :            :     , m_pBetweenStuff(0)
      92                 :            :     , m_pShadow(0)
      93                 :            :     , m_pMargins(0)
      94                 :            :     , m_eAboveType(rOther.m_eAboveType)
      95                 :            :     , m_eBelowType(rOther.m_eBelowType)
      96                 :            :     , m_eRightType(rOther.m_eRightType)
      97                 :            :     , m_eBetweenType(rOther.m_eBetweenType)
      98                 :            :     , m_nAboveWidth(rOther.m_nAboveWidth)
      99                 :            :     , m_nBelowWidth(rOther.m_nBelowWidth)
     100                 :            :     , m_nBetweenWidth(rOther.m_nBetweenWidth)
     101                 :            :     , m_nRightWidth(rOther.m_nRightWidth)
     102                 :         12 :     , m_nBetweenMargin(rOther.m_nBetweenMargin)
     103                 :            : {
     104                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     105         [ +  - ]:         12 :     std::auto_ptr<LwpBorderStuff> pBorderStuff(::clone(rOther.m_pBorderStuff));
     106         [ +  - ]:         12 :     std::auto_ptr<LwpBorderStuff> pBetweenStuff(::clone(rOther.m_pBetweenStuff));
     107         [ +  - ]:         12 :     std::auto_ptr<LwpShadow> pShadow(::clone(rOther.m_pShadow));
     108         [ +  - ]:         12 :     std::auto_ptr<LwpMargins> pMargins(::clone(rOther.m_pMargins));
     109                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     110                 :         12 :     m_pBorderStuff = pBorderStuff.release();
     111                 :         12 :     m_pBetweenStuff = pBetweenStuff.release();
     112                 :         12 :     m_pShadow = pShadow.release();
     113                 :         12 :     m_pMargins = pMargins.release();
     114                 :         12 : }
     115                 :            : 
     116                 :         30 : LwpParaBorderOverride::~LwpParaBorderOverride()
     117                 :            : {
     118         [ +  - ]:         30 :     if( m_pBorderStuff )
     119         [ +  - ]:         30 :         delete m_pBorderStuff;
     120         [ +  - ]:         30 :     if( m_pBetweenStuff )
     121         [ +  - ]:         30 :         delete m_pBetweenStuff;
     122         [ +  - ]:         30 :     if( m_pShadow )
     123         [ +  - ]:         30 :         delete m_pShadow;
     124         [ +  - ]:         30 :     if( m_pMargins )
     125                 :         30 :         delete m_pMargins;
     126         [ -  + ]:         60 : }
     127                 :            : 
     128                 :         12 : LwpParaBorderOverride* LwpParaBorderOverride::clone() const
     129                 :            : {
     130         [ +  - ]:         12 :     return new LwpParaBorderOverride(*this);
     131                 :            : }
     132                 :            : 
     133                 :         18 : void LwpParaBorderOverride::Read(LwpObjectStream *pStrm)
     134                 :            : {
     135         [ +  - ]:         18 :     if (pStrm->QuickReadBool())
     136                 :            :     {
     137                 :         18 :         ReadCommon(pStrm);
     138                 :            :         //start here:
     139                 :         18 :         m_pBorderStuff->Read(pStrm);
     140                 :         18 :         m_pShadow->Read(pStrm);
     141                 :         18 :         m_pMargins->Read(pStrm);
     142                 :            : 
     143                 :         18 :         m_eAboveType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
     144                 :         18 :         m_eBelowType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
     145                 :         18 :         m_eRightType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
     146                 :            : 
     147         [ -  + ]:         18 :         if( pStrm->CheckExtra() )
     148                 :            :         {
     149                 :          0 :             m_pBetweenStuff->Read(pStrm);
     150                 :            : 
     151                 :          0 :             m_eBetweenType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
     152                 :          0 :             m_nBetweenWidth = pStrm->QuickReaduInt32();
     153                 :          0 :             m_nBetweenMargin = pStrm->QuickReaduInt32();
     154                 :            : 
     155         [ #  # ]:          0 :             if( pStrm->CheckExtra() )
     156                 :            :             {
     157                 :          0 :                 m_eRightType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
     158                 :          0 :                 m_nRightWidth = pStrm->QuickReaduInt32();
     159                 :            :             }
     160                 :            :         }
     161                 :            :     }
     162                 :            : 
     163                 :         18 :     pStrm->SkipExtra();
     164                 :         18 : }
     165                 :            : 
     166                 :          6 : void LwpParaBorderOverride::Override(LwpParaBorderOverride* pOther)
     167                 :            : {
     168         [ +  - ]:          6 :     if (m_nApply & PBO_STUFF)
     169                 :            :     {
     170         [ +  - ]:          6 :         if (IsBorderStuffOverridden())
     171                 :            :         {
     172                 :          6 :             pOther->OverrideBorderStuff(m_pBorderStuff);
     173                 :            :         }
     174                 :            :         else
     175                 :            :         {
     176                 :          0 :             pOther->RevertBorderStuff();
     177                 :            :         }
     178                 :            :     }
     179                 :            : 
     180         [ +  - ]:          6 :     if (m_nApply & PBO_BETWEENSTUFF)
     181                 :            :     {
     182         [ +  - ]:          6 :         if (IsBetweenStuffOverridden())
     183                 :            :         {
     184                 :          6 :             pOther->OverrideBetweenStuff(m_pBetweenStuff);
     185                 :            :         }
     186                 :            :         else
     187                 :            :         {
     188                 :          0 :             pOther->RevertBetweenStuff();
     189                 :            :         }
     190                 :            :     }
     191                 :            : 
     192         [ +  + ]:          6 :     if (m_nApply & PBO_SHADOW)
     193                 :            :     {
     194         [ +  - ]:          3 :         if (IsShadowOverridden())
     195                 :            :         {
     196                 :          3 :             pOther->OverrideShadow(m_pShadow);
     197                 :            :         }
     198                 :            :         else
     199                 :            :         {
     200                 :          0 :             pOther->RevertShadow();
     201                 :            :         }
     202                 :            :     }
     203                 :            : 
     204         [ +  - ]:          6 :     if (m_nApply & PBO_MARGINS)
     205                 :            :     {
     206         [ +  - ]:          6 :         if (IsMarginsOverridden())
     207                 :            :         {
     208                 :          6 :             pOther->OverrideMargins(m_pMargins);
     209                 :            :         }
     210                 :            :         else
     211                 :            :         {
     212                 :          0 :             pOther->RevertMargins();
     213                 :            :         }
     214                 :            :     }
     215                 :            : 
     216         [ +  - ]:          6 :     if (m_nApply & PBO_ABOVETYPE)
     217                 :            :     {
     218         [ +  - ]:          6 :         if (IsAboveTypeOverridden())
     219                 :            :         {
     220                 :          6 :             pOther->OverrideAboveType(m_eAboveType);
     221                 :            :         }
     222                 :            :         else
     223                 :            :         {
     224                 :          0 :             pOther->RevertAboveType();
     225                 :            :         }
     226                 :            :     }
     227                 :            : 
     228         [ +  - ]:          6 :     if (m_nApply & PBO_BELOWTYPE)
     229                 :            :     {
     230         [ +  - ]:          6 :         if (IsBelowTypeOverridden())
     231                 :            :         {
     232                 :          6 :             pOther->OverrideBelowType(m_eBelowType);
     233                 :            :         }
     234                 :            :         else
     235                 :            :         {
     236                 :          0 :             pOther->RevertBelowType();
     237                 :            :         }
     238                 :            :     }
     239                 :            : 
     240         [ +  - ]:          6 :     if (m_nApply & PBO_RIGHTTYPE)
     241                 :            :     {
     242         [ +  - ]:          6 :         if (IsRightTypeOverridden())
     243                 :            :         {
     244                 :          6 :             pOther->OverrideRightType(m_eRightType);
     245                 :            :         }
     246                 :            :         else
     247                 :            :         {
     248                 :          0 :             pOther->RevertRightType();
     249                 :            :         }
     250                 :            :     }
     251                 :            : 
     252         [ +  - ]:          6 :     if (m_nApply & PBO_BETWEENTYPE)
     253                 :            :     {
     254         [ +  - ]:          6 :         if (IsBetweenTypeOverridden())
     255                 :            :         {
     256                 :          6 :             pOther->OverrideBetweenType(m_eBetweenType);
     257                 :            :         }
     258                 :            :         else
     259                 :            :         {
     260                 :          0 :             pOther->RevertBetweenType();
     261                 :            :         }
     262                 :            :     }
     263                 :            : 
     264         [ -  + ]:          6 :     if (m_nApply & PBO_ABOVE)
     265                 :            :     {
     266         [ #  # ]:          0 :         if (IsAboveWidthOverridden())
     267                 :            :         {
     268                 :          0 :             pOther->OverrideAboveWidth(m_nAboveWidth);
     269                 :            :         }
     270                 :            :         else
     271                 :            :         {
     272                 :          0 :             pOther->RevertAboveWidth();
     273                 :            :         }
     274                 :            :     }
     275                 :            : 
     276         [ -  + ]:          6 :     if (m_nApply & PBO_BELOW)
     277                 :            :     {
     278         [ #  # ]:          0 :         if (IsBelowWidthOverridden())
     279                 :            :         {
     280                 :          0 :             pOther->OverrideBelowWidth(m_nBelowWidth);
     281                 :            :         }
     282                 :            :         else
     283                 :            :         {
     284                 :          0 :             pOther->RevertBelowWidth();
     285                 :            :         }
     286                 :            :     }
     287                 :            : 
     288         [ +  - ]:          6 :     if (m_nApply & PBO_BETWEEN)
     289                 :            :     {
     290         [ +  - ]:          6 :         if (IsBetweenWidthOverridden())
     291                 :            :         {
     292                 :          6 :             pOther->OverrideBetweenWidth(m_nBetweenWidth);
     293                 :            :         }
     294                 :            :         else
     295                 :            :         {
     296                 :          0 :             pOther->RevertBetweenWidth();
     297                 :            :         }
     298                 :            :     }
     299                 :            : 
     300         [ +  - ]:          6 :     if (m_nApply & PBO_BETWEENMARGIN)
     301                 :            :     {
     302         [ +  - ]:          6 :         if (IsBetweenMarginOverridden())
     303                 :            :         {
     304                 :          6 :             pOther->OverrideBetweenMargin(m_nBetweenMargin);
     305                 :            :         }
     306                 :            :         else
     307                 :            :         {
     308                 :          0 :             pOther->RevertBetweenMargin();
     309                 :            :         }
     310                 :            :     }
     311                 :            : 
     312         [ -  + ]:          6 :     if (m_nApply & PBO_RIGHT)
     313                 :            :     {
     314         [ #  # ]:          0 :         if (IsRightWidthOverridden())
     315                 :            :         {
     316                 :          0 :             pOther->OverrideRightWidth(m_nRightWidth);
     317                 :            :         }
     318                 :            :         else
     319                 :            :         {
     320                 :          0 :             pOther->RevertRightWidth();
     321                 :            :         }
     322                 :            :     }
     323                 :          6 : }
     324                 :            : 
     325                 :          6 : void LwpParaBorderOverride::OverrideBorderStuff(LwpBorderStuff* pBorderStuff)
     326                 :            : {
     327                 :          6 :     *m_pBorderStuff = *pBorderStuff;
     328                 :          6 :     LwpOverride::Override(PBO_STUFF, STATE_ON);
     329                 :          6 : }
     330                 :          6 : void LwpParaBorderOverride::OverrideBetweenStuff(LwpBorderStuff* pBorderStuff)
     331                 :            : {
     332                 :          6 :     *m_pBetweenStuff = *pBorderStuff;
     333                 :          6 :     LwpOverride::Override(PBO_BETWEENSTUFF, STATE_ON);
     334                 :          6 : }
     335                 :          3 : void LwpParaBorderOverride::OverrideShadow(LwpShadow* pShadow)
     336                 :            : {
     337                 :          3 :     *m_pShadow = *pShadow;
     338                 :          3 :     LwpOverride::Override(PBO_SHADOW, STATE_ON);
     339                 :          3 : }
     340                 :          6 : void LwpParaBorderOverride::OverrideMargins(LwpMargins* pMargins)
     341                 :            : {
     342                 :          6 :     *m_pMargins = *pMargins;
     343                 :          6 :     LwpOverride::Override(PBO_MARGINS, STATE_ON);
     344                 :          6 : }
     345                 :          6 : void LwpParaBorderOverride::OverrideAboveType(BorderWidthType eNewType)
     346                 :            : {
     347                 :          6 :     m_eAboveType = eNewType;
     348                 :          6 :     LwpOverride::Override(PBO_ABOVETYPE, STATE_ON);
     349                 :          6 : }
     350                 :          6 : void LwpParaBorderOverride::OverrideBelowType(BorderWidthType eNewType)
     351                 :            : {
     352                 :          6 :     m_eBelowType = eNewType;
     353                 :          6 :     LwpOverride::Override(PBO_BELOWTYPE, STATE_ON);
     354                 :          6 : }
     355                 :          6 : void LwpParaBorderOverride::OverrideRightType(BorderWidthType eNewType)
     356                 :            : {
     357                 :          6 :     m_eRightType = eNewType;
     358                 :          6 :     LwpOverride::Override(PBO_RIGHTTYPE, STATE_ON);
     359                 :          6 : }
     360                 :          6 : void LwpParaBorderOverride::OverrideBetweenType(BorderWidthType eNewType)
     361                 :            : {
     362                 :          6 :     m_eBetweenType = eNewType;
     363                 :          6 :     LwpOverride::Override(PBO_BETWEENTYPE, STATE_ON);
     364                 :          6 : }
     365                 :          0 : void LwpParaBorderOverride::OverrideAboveWidth(sal_uInt32 nNewWidth)
     366                 :            : {
     367                 :          0 :     m_nAboveWidth = nNewWidth;
     368                 :          0 :     LwpOverride::Override(PBO_ABOVE, STATE_ON);
     369                 :          0 : }
     370                 :          0 : void LwpParaBorderOverride::OverrideBelowWidth(sal_uInt32 nNewWidth)
     371                 :            : {
     372                 :          0 :     m_nBelowWidth = nNewWidth;
     373                 :          0 :     LwpOverride::Override(PBO_BELOW, STATE_ON);
     374                 :          0 : }
     375                 :          6 : void LwpParaBorderOverride::OverrideBetweenWidth(sal_uInt32 nNewWidth)
     376                 :            : {
     377                 :          6 :     m_nBetweenWidth = nNewWidth;
     378                 :          6 :     LwpOverride::Override(PBO_BETWEEN, STATE_ON);
     379                 :          6 : }
     380                 :          0 : void LwpParaBorderOverride::OverrideRightWidth(sal_uInt32 nNewWidth)
     381                 :            : {
     382                 :          0 :     m_nRightWidth = nNewWidth;
     383                 :          0 :     LwpOverride::Override(PBO_RIGHT, STATE_ON);
     384                 :          0 : }
     385                 :          6 : void LwpParaBorderOverride::OverrideBetweenMargin(sal_uInt32 nNewMargin)
     386                 :            : {
     387                 :          6 :     m_nBetweenMargin = nNewMargin;
     388                 :          6 :     LwpOverride::Override(PBO_BETWEENMARGIN, STATE_ON);
     389                 :          6 : }
     390                 :            : 
     391                 :            : //end
     392                 :            : 
     393                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10