LCOV - code coverage report
Current view: top level - sc/source/core/data - attrib.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 178 504 35.3 %
Date: 2012-08-25 Functions: 69 124 55.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 123 835 14.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/util/CellProtection.hpp>
      30                 :            : #include <com/sun/star/util/XProtectable.hpp>
      31                 :            : #include <com/sun/star/text/XText.hpp>
      32                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      33                 :            : 
      34                 :            : #include "scitems.hxx"
      35                 :            : #include <editeng/eeitem.hxx>
      36                 :            : 
      37                 :            : #include <editeng/boxitem.hxx>
      38                 :            : #include <editeng/editdata.hxx>
      39                 :            : #include <editeng/editeng.hxx>
      40                 :            : #include <editeng/editobj.hxx>
      41                 :            : #include <editeng/flditem.hxx>
      42                 :            : 
      43                 :            : #include "attrib.hxx"
      44                 :            : #include "global.hxx"
      45                 :            : #include "editutil.hxx"
      46                 :            : #include "sc.hrc"
      47                 :            : #include "globstr.hrc"
      48                 :            : 
      49                 :            : #include "textuno.hxx"  // ScHeaderFooterContentObj
      50                 :            : 
      51                 :            : using namespace com::sun::star;
      52                 :            : 
      53                 :            : //------------------------------------------------------------------------
      54                 :            : 
      55 [ -  + ][ -  + ]:       2259 : TYPEINIT1(ScMergeAttr,          SfxPoolItem);
      56 [ -  + ][ -  + ]:       2658 : TYPEINIT1_AUTOFACTORY(ScProtectionAttr,     SfxPoolItem);
                 [ #  # ]
      57 [ -  + ][ -  + ]:       6444 : TYPEINIT1(ScRangeItem,          SfxPoolItem);
      58 [ -  + ][ -  + ]:       2148 : TYPEINIT1(ScTableListItem,      SfxPoolItem);
      59 [ -  + ][ -  + ]:      10436 : TYPEINIT1(ScPageHFItem,         SfxPoolItem);
      60 [ -  + ][ -  + ]:       6444 : TYPEINIT1(ScViewObjectModeItem, SfxEnumItem);
      61 [ #  # ][ #  # ]:         51 : TYPEINIT1(ScDoubleItem,         SfxPoolItem);
      62 [ -  + ][ -  + ]:       2148 : TYPEINIT1(ScPageScaleToItem,    SfxPoolItem);
      63                 :            : 
      64                 :            : //------------------------------------------------------------------------
      65                 :            : 
      66                 :            : //
      67                 :            : //      allgemeine Hilfsfunktionen
      68                 :            : //
      69                 :            : 
      70                 :       1569 : bool ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther )
      71                 :            : {
      72                 :            : 
      73         [ +  + ]:       1569 :     if (!pThis)
      74                 :       1359 :         return false;
      75         [ +  + ]:        210 :     if (!pOther)
      76                 :        204 :         return true;
      77                 :            : 
      78                 :          6 :     sal_uInt16 nThisSize = pThis->GetOutWidth() + pThis->GetDistance() + pThis->GetInWidth();
      79                 :          6 :     sal_uInt16 nOtherSize = pOther->GetOutWidth() + pOther->GetDistance() + pOther->GetInWidth();
      80                 :            : 
      81         [ -  + ]:          6 :     if (nThisSize > nOtherSize)
      82                 :          0 :         return true;
      83         [ -  + ]:          6 :     else if (nThisSize < nOtherSize)
      84                 :          0 :         return false;
      85                 :            :     else
      86                 :            :     {
      87 [ -  + ][ #  # ]:          6 :         if ( pOther->GetInWidth() && !pThis->GetInWidth() )
                 [ -  + ]
      88                 :          0 :             return true;
      89 [ -  + ][ #  # ]:          6 :         else if ( pThis->GetInWidth() && !pOther->GetInWidth() )
                 [ -  + ]
      90                 :          0 :             return false;
      91                 :            :         else
      92                 :            :         {
      93                 :       1569 :             return true;            //! ???
      94                 :            :         }
      95                 :            :     }
      96                 :            : }
      97                 :            : 
      98                 :            : 
      99                 :            : //
     100                 :            : //      Item - Implementierungen
     101                 :            : //
     102                 :            : 
     103                 :            : //------------------------------------------------------------------------
     104                 :            : // Merge
     105                 :            : //------------------------------------------------------------------------
     106                 :            : 
     107                 :        900 : ScMergeAttr::ScMergeAttr():
     108                 :            :     SfxPoolItem(ATTR_MERGE),
     109                 :            :     nColMerge(0),
     110                 :        900 :     nRowMerge(0)
     111                 :        900 : {}
     112                 :            : 
     113                 :            : //------------------------------------------------------------------------
     114                 :            : 
     115                 :         72 : ScMergeAttr::ScMergeAttr( SCsCOL nCol, SCsROW nRow):
     116                 :            :     SfxPoolItem(ATTR_MERGE),
     117                 :            :     nColMerge(nCol),
     118                 :         72 :     nRowMerge(nRow)
     119                 :         72 : {}
     120                 :            : 
     121                 :            : //------------------------------------------------------------------------
     122                 :            : 
     123                 :         42 : ScMergeAttr::ScMergeAttr(const ScMergeAttr& rItem):
     124                 :         42 :     SfxPoolItem(ATTR_MERGE)
     125                 :            : {
     126                 :         42 :     nColMerge = rItem.nColMerge;
     127                 :         42 :     nRowMerge = rItem.nRowMerge;
     128                 :         42 : }
     129                 :            : 
     130                 :        821 : ScMergeAttr::~ScMergeAttr()
     131                 :            : {
     132         [ -  + ]:       1570 : }
     133                 :            : 
     134                 :            : //------------------------------------------------------------------------
     135                 :            : 
     136                 :          0 : String ScMergeAttr::GetValueText() const
     137                 :            : {
     138                 :          0 :     rtl::OUStringBuffer aString;
     139         [ #  # ]:          0 :     aString.append('(');
     140         [ #  # ]:          0 :     aString.append(static_cast<sal_Int32>(nColMerge));
     141         [ #  # ]:          0 :     aString.append(',');
     142         [ #  # ]:          0 :     aString.append(static_cast<sal_Int32>(nRowMerge));
     143         [ #  # ]:          0 :     aString.append(')');
     144 [ #  # ][ #  # ]:          0 :     return aString.makeStringAndClear();
     145                 :            : }
     146                 :            : 
     147                 :            : //------------------------------------------------------------------------
     148                 :            : 
     149                 :        441 : int ScMergeAttr::operator==( const SfxPoolItem& rItem ) const
     150                 :            : {
     151                 :            :     OSL_ENSURE( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" );
     152                 :        441 :     return (Which() == rItem.Which())
     153                 :            :              && (nColMerge == ((ScMergeAttr&)rItem).nColMerge)
     154 [ +  + ][ +  + ]:        441 :              && (nRowMerge == ((ScMergeAttr&)rItem).nRowMerge);
                 [ +  - ]
     155                 :            : }
     156                 :            : 
     157                 :            : //------------------------------------------------------------------------
     158                 :            : 
     159                 :         42 : SfxPoolItem* ScMergeAttr::Clone( SfxItemPool * ) const
     160                 :            : {
     161         [ +  - ]:         42 :     return new ScMergeAttr(*this);
     162                 :            : }
     163                 :            : 
     164                 :            : //------------------------------------------------------------------------
     165                 :            : 
     166                 :          0 : SfxPoolItem* ScMergeAttr::Create( SvStream& rStream, sal_uInt16 /* nVer */ ) const
     167                 :            : {
     168                 :            :     sal_Int16   nCol;
     169                 :            :     sal_Int16   nRow;
     170         [ #  # ]:          0 :     rStream >> nCol;
     171         [ #  # ]:          0 :     rStream >> nRow;
     172 [ #  # ][ #  # ]:          0 :     return new ScMergeAttr(static_cast<SCCOL>(nCol),static_cast<SCROW>(nRow));
     173                 :            : }
     174                 :            : 
     175                 :            : //------------------------------------------------------------------------
     176                 :            : // MergeFlag
     177                 :            : //------------------------------------------------------------------------
     178                 :            : 
     179                 :        900 : ScMergeFlagAttr::ScMergeFlagAttr():
     180                 :        900 :     SfxInt16Item(ATTR_MERGE_FLAG, 0)
     181                 :            : {
     182                 :        900 : }
     183                 :            : 
     184                 :            : //------------------------------------------------------------------------
     185                 :            : 
     186                 :       5789 : ScMergeFlagAttr::ScMergeFlagAttr(sal_Int16 nFlags):
     187                 :       5789 :     SfxInt16Item(ATTR_MERGE_FLAG, nFlags)
     188                 :            : {
     189                 :       5789 : }
     190                 :            : 
     191                 :       6505 : ScMergeFlagAttr::~ScMergeFlagAttr()
     192                 :            : {
     193         [ -  + ]:       7221 : }
     194                 :            : 
     195                 :            : //------------------------------------------------------------------------
     196                 :            : // Protection
     197                 :            : //------------------------------------------------------------------------
     198                 :            : 
     199                 :        900 : ScProtectionAttr::ScProtectionAttr():
     200                 :            :     SfxPoolItem(ATTR_PROTECTION),
     201                 :            :     bProtection(true),
     202                 :            :     bHideFormula(false),
     203                 :            :     bHideCell(false),
     204                 :        900 :     bHidePrint(false)
     205                 :            : {
     206                 :        900 : }
     207                 :            : 
     208                 :            : //------------------------------------------------------------------------
     209                 :            : 
     210                 :        144 : ScProtectionAttr::ScProtectionAttr( bool bProtect, bool bHFormula,
     211                 :            :                                     bool bHCell, bool bHPrint):
     212                 :            :     SfxPoolItem(ATTR_PROTECTION),
     213                 :            :     bProtection(bProtect),
     214                 :            :     bHideFormula(bHFormula),
     215                 :            :     bHideCell(bHCell),
     216                 :        144 :     bHidePrint(bHPrint)
     217                 :            : {
     218                 :        144 : }
     219                 :            : 
     220                 :            : //------------------------------------------------------------------------
     221                 :            : 
     222                 :         73 : ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr& rItem):
     223                 :         73 :     SfxPoolItem(ATTR_PROTECTION)
     224                 :            : {
     225                 :         73 :     bProtection  = rItem.bProtection;
     226                 :         73 :     bHideFormula = rItem.bHideFormula;
     227                 :         73 :     bHideCell    = rItem.bHideCell;
     228                 :         73 :     bHidePrint   = rItem.bHidePrint;
     229                 :         73 : }
     230                 :            : 
     231                 :        933 : ScProtectionAttr::~ScProtectionAttr()
     232                 :            : {
     233         [ -  + ]:       1722 : }
     234                 :            : 
     235                 :            : //------------------------------------------------------------------------
     236                 :            : 
     237                 :         29 : bool ScProtectionAttr::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     238                 :            : {
     239                 :         29 :     nMemberId &= ~CONVERT_TWIPS;
     240   [ +  -  -  -  :         29 :     switch ( nMemberId  )
                   -  - ]
     241                 :            :     {
     242                 :            :         case 0 :
     243                 :            :         {
     244                 :         29 :             util::CellProtection aProtection;
     245                 :         29 :             aProtection.IsLocked        = bProtection;
     246                 :         29 :             aProtection.IsFormulaHidden = bHideFormula;
     247                 :         29 :             aProtection.IsHidden        = bHideCell;
     248                 :         29 :             aProtection.IsPrintHidden   = bHidePrint;
     249         [ +  - ]:         29 :             rVal <<= aProtection;
     250                 :            :             break;
     251                 :            :         }
     252                 :            :         case MID_1 :
     253         [ #  # ]:          0 :             rVal <<= (sal_Bool ) bProtection; break;
     254                 :            :         case MID_2 :
     255         [ #  # ]:          0 :             rVal <<= (sal_Bool ) bHideFormula; break;
     256                 :            :         case MID_3 :
     257         [ #  # ]:          0 :             rVal <<= (sal_Bool ) bHideCell; break;
     258                 :            :         case MID_4 :
     259         [ #  # ]:          0 :             rVal <<= (sal_Bool ) bHidePrint; break;
     260                 :            :         default:
     261                 :            :             OSL_FAIL("Wrong MemberID!");
     262                 :          0 :             return false;
     263                 :            :     }
     264                 :            : 
     265                 :         29 :     return true;
     266                 :            : }
     267                 :            : 
     268                 :         31 : bool ScProtectionAttr::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     269                 :            : {
     270                 :         31 :     bool bRet = false;
     271                 :         31 :     sal_Bool bVal = sal_False;
     272                 :         31 :     nMemberId &= ~CONVERT_TWIPS;
     273   [ +  -  -  -  :         31 :     switch ( nMemberId )
                   -  - ]
     274                 :            :     {
     275                 :            :         case 0 :
     276                 :            :         {
     277                 :         31 :             util::CellProtection aProtection;
     278 [ +  - ][ +  - ]:         31 :             if ( rVal >>= aProtection )
     279                 :            :             {
     280                 :         31 :                 bProtection  = aProtection.IsLocked;
     281                 :         31 :                 bHideFormula = aProtection.IsFormulaHidden;
     282                 :         31 :                 bHideCell    = aProtection.IsHidden;
     283                 :         31 :                 bHidePrint   = aProtection.IsPrintHidden;
     284                 :         31 :                 bRet = true;
     285                 :            :             }
     286                 :            :             else
     287                 :            :             {
     288                 :            :                 OSL_FAIL("exception - wrong argument");
     289                 :            :             }
     290                 :            :             break;
     291                 :            :         }
     292                 :            :         case MID_1 :
     293         [ #  # ]:          0 :             bRet = (rVal >>= bVal); if (bRet) bProtection=bVal; break;
     294                 :            :         case MID_2 :
     295         [ #  # ]:          0 :             bRet = (rVal >>= bVal); if (bRet) bHideFormula=bVal; break;
     296                 :            :         case MID_3 :
     297         [ #  # ]:          0 :             bRet = (rVal >>= bVal); if (bRet) bHideCell=bVal; break;
     298                 :            :         case MID_4 :
     299         [ #  # ]:          0 :             bRet = (rVal >>= bVal); if (bRet) bHidePrint=bVal; break;
     300                 :            :         default:
     301                 :            :             OSL_FAIL("Wrong MemberID!");
     302                 :            :     }
     303                 :            : 
     304                 :         31 :     return bRet;
     305                 :            : }
     306                 :            : 
     307                 :            : //------------------------------------------------------------------------
     308                 :            : 
     309                 :          0 : String ScProtectionAttr::GetValueText() const
     310                 :            : {
     311         [ #  # ]:          0 :     String aValue;
     312 [ #  # ][ #  # ]:          0 :     String aStrYes ( ScGlobal::GetRscString(STR_YES) );
     313 [ #  # ][ #  # ]:          0 :     String aStrNo  ( ScGlobal::GetRscString(STR_NO) );
     314                 :          0 :     sal_Unicode cDelim = ',';
     315                 :            : 
     316         [ #  # ]:          0 :     aValue  = '(';
     317 [ #  # ][ #  # ]:          0 :     aValue += (bProtection  ? aStrYes : aStrNo);    aValue += cDelim;
                 [ #  # ]
     318 [ #  # ][ #  # ]:          0 :     aValue += (bHideFormula ? aStrYes : aStrNo);    aValue += cDelim;
                 [ #  # ]
     319 [ #  # ][ #  # ]:          0 :     aValue += (bHideCell    ? aStrYes : aStrNo);    aValue += cDelim;
                 [ #  # ]
     320 [ #  # ][ #  # ]:          0 :     aValue += (bHidePrint   ? aStrYes : aStrNo);
     321         [ #  # ]:          0 :     aValue += ')';
     322                 :            : 
     323 [ #  # ][ #  # ]:          0 :     return aValue;
     324                 :            : }
     325                 :            : 
     326                 :            : //------------------------------------------------------------------------
     327                 :            : 
     328                 :          0 : SfxItemPresentation ScProtectionAttr::GetPresentation
     329                 :            :     (
     330                 :            :         SfxItemPresentation ePres,
     331                 :            :         SfxMapUnit /* eCoreMetric */,
     332                 :            :         SfxMapUnit /* ePresMetric */,
     333                 :            :         String& rText,
     334                 :            :         const IntlWrapper* /* pIntl */
     335                 :            :     ) const
     336                 :            : {
     337 [ #  # ][ #  # ]:          0 :     String aStrYes  ( ScGlobal::GetRscString(STR_YES) );
     338 [ #  # ][ #  # ]:          0 :     String aStrNo   ( ScGlobal::GetRscString(STR_NO) );
     339                 :          0 :     rtl::OUString aStrSep(": ");
     340                 :          0 :     rtl::OUString aStrDelim( ", ");
     341                 :            : 
     342   [ #  #  #  # ]:          0 :     switch ( ePres )
     343                 :            :     {
     344                 :            :         case SFX_ITEM_PRESENTATION_NONE:
     345         [ #  # ]:          0 :             rText.Erase();
     346                 :          0 :             break;
     347                 :            : 
     348                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
     349 [ #  # ][ #  # ]:          0 :             rText = GetValueText();
                 [ #  # ]
     350                 :          0 :             break;
     351                 :            : 
     352                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
     353 [ #  # ][ #  # ]:          0 :             rText  = ScGlobal::GetRscString(STR_PROTECTION); rText += aStrSep;
                 [ #  # ]
     354 [ #  # ][ #  # ]:          0 :             rText += (bProtection ? aStrYes : aStrNo);       rText += aStrDelim;
                 [ #  # ]
     355 [ #  # ][ #  # ]:          0 :             rText += ScGlobal::GetRscString(STR_FORMULAS);   rText += aStrSep;
                 [ #  # ]
     356 [ #  # ][ #  # ]:          0 :             rText += (!bHideFormula ? aStrYes : aStrNo);     rText += aStrDelim;
                 [ #  # ]
     357 [ #  # ][ #  # ]:          0 :             rText += ScGlobal::GetRscString(STR_HIDE);       rText += aStrSep;
                 [ #  # ]
     358 [ #  # ][ #  # ]:          0 :             rText += (bHideCell ? aStrYes : aStrNo);         rText += aStrDelim;
                 [ #  # ]
     359 [ #  # ][ #  # ]:          0 :             rText += ScGlobal::GetRscString(STR_PRINT);      rText += aStrSep;
                 [ #  # ]
     360 [ #  # ][ #  # ]:          0 :             rText += (!bHidePrint ? aStrYes : aStrNo);
     361                 :          0 :             break;
     362                 :            : 
     363                 :            :         default:
     364                 :          0 :             ePres = SFX_ITEM_PRESENTATION_NONE;
     365                 :            :     }
     366                 :            : 
     367 [ #  # ][ #  # ]:          0 :     return ePres;
     368                 :            : }
     369                 :            : 
     370                 :            : //------------------------------------------------------------------------
     371                 :            : 
     372                 :        158 : int ScProtectionAttr::operator==( const SfxPoolItem& rItem ) const
     373                 :            : {
     374                 :            :     OSL_ENSURE( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" );
     375                 :        158 :     return (Which() == rItem.Which())
     376                 :            :              && (bProtection == ((ScProtectionAttr&)rItem).bProtection)
     377                 :            :              && (bHideFormula == ((ScProtectionAttr&)rItem).bHideFormula)
     378                 :            :              && (bHideCell == ((ScProtectionAttr&)rItem).bHideCell)
     379 [ +  + ][ +  - ]:        158 :              && (bHidePrint == ((ScProtectionAttr&)rItem).bHidePrint);
         [ +  - ][ +  - ]
                 [ +  - ]
     380                 :            : }
     381                 :            : 
     382                 :            : //------------------------------------------------------------------------
     383                 :            : 
     384                 :         73 : SfxPoolItem* ScProtectionAttr::Clone( SfxItemPool * ) const
     385                 :            : {
     386         [ +  - ]:         73 :     return new ScProtectionAttr(*this);
     387                 :            : }
     388                 :            : 
     389                 :            : //------------------------------------------------------------------------
     390                 :            : 
     391                 :          0 : SfxPoolItem* ScProtectionAttr::Create( SvStream& rStream, sal_uInt16 /* n */ ) const
     392                 :            : {
     393                 :            :     sal_Bool bProtect;
     394                 :            :     sal_Bool bHFormula;
     395                 :            :     sal_Bool bHCell;
     396                 :            :     sal_Bool bHPrint;
     397                 :            : 
     398         [ #  # ]:          0 :     rStream >> bProtect;
     399         [ #  # ]:          0 :     rStream >> bHFormula;
     400         [ #  # ]:          0 :     rStream >> bHCell;
     401         [ #  # ]:          0 :     rStream >> bHPrint;
     402                 :            : 
     403 [ #  # ][ #  # ]:          0 :     return new ScProtectionAttr(bProtect,bHFormula,bHCell,bHPrint);
     404                 :            : }
     405                 :            : 
     406                 :            : //------------------------------------------------------------------------
     407                 :            : 
     408                 :          0 : bool ScProtectionAttr::SetProtection( bool bProtect)
     409                 :            : {
     410                 :          0 :     bProtection =  bProtect;
     411                 :          0 :     return true;
     412                 :            : }
     413                 :            : 
     414                 :            : //------------------------------------------------------------------------
     415                 :            : 
     416                 :          0 : bool ScProtectionAttr::SetHideFormula( bool bHFormula)
     417                 :            : {
     418                 :          0 :     bHideFormula = bHFormula;
     419                 :          0 :     return true;
     420                 :            : }
     421                 :            : 
     422                 :            : //------------------------------------------------------------------------
     423                 :            : 
     424                 :          0 : bool ScProtectionAttr::SetHideCell( bool bHCell)
     425                 :            : {
     426                 :          0 :     bHideCell = bHCell;
     427                 :          0 :     return true;
     428                 :            : }
     429                 :            : 
     430                 :            : //------------------------------------------------------------------------
     431                 :            : 
     432                 :          0 : bool ScProtectionAttr::SetHidePrint( bool bHPrint)
     433                 :            : {
     434                 :          0 :     bHidePrint = bHPrint;
     435                 :          0 :     return true;
     436                 :            : }
     437                 :            : 
     438                 :            : // -----------------------------------------------------------------------
     439                 :            : //      ScRangeItem - Tabellenbereich
     440                 :            : // -----------------------------------------------------------------------
     441                 :            : 
     442                 :          0 : int ScRangeItem::operator==( const SfxPoolItem& rAttr ) const
     443                 :            : {
     444                 :            :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     445                 :            : 
     446                 :          0 :     return ( aRange == ( (ScRangeItem&)rAttr ).aRange );
     447                 :            : }
     448                 :            : 
     449                 :            : // -----------------------------------------------------------------------
     450                 :            : 
     451                 :          0 : SfxPoolItem* ScRangeItem::Clone( SfxItemPool* ) const
     452                 :            : {
     453         [ #  # ]:          0 :     return new ScRangeItem( *this );
     454                 :            : }
     455                 :            : 
     456                 :            : //------------------------------------------------------------------------
     457                 :            : 
     458                 :          0 : SfxItemPresentation ScRangeItem::GetPresentation
     459                 :            :     (
     460                 :            :         SfxItemPresentation ePres,
     461                 :            :         SfxMapUnit          /* eCoreUnit */,
     462                 :            :         SfxMapUnit          /* ePresUnit */,
     463                 :            :         String&             rText,
     464                 :            :         const IntlWrapper* /* pIntl */
     465                 :            :     ) const
     466                 :            : {
     467                 :          0 :     rText.Erase();
     468                 :            : 
     469      [ #  #  # ]:          0 :     switch ( ePres )
     470                 :            :     {
     471                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
     472                 :          0 :         rText  = ScGlobal::GetRscString(STR_AREA);
     473                 :          0 :         rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
     474                 :            :         /* !!! fall-through !!! */
     475                 :            : 
     476                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
     477                 :            :         {
     478         [ #  # ]:          0 :             String aText;
     479                 :            :             /* Always use OOo:A1 format */
     480         [ #  # ]:          0 :             aRange.Format( aText );
     481 [ #  # ][ #  # ]:          0 :             rText += aText;
     482                 :            :         }
     483                 :          0 :         break;
     484                 :            : 
     485                 :            :         default:
     486                 :            :         {
     487                 :            :             // added to avoid warnings
     488                 :            :         }
     489                 :            :     }
     490                 :            : 
     491                 :          0 :     return ePres;
     492                 :            : }
     493                 :            : 
     494                 :            : // -----------------------------------------------------------------------
     495                 :            : //      ScTableListItem - Liste von Tabellen(-nummern)
     496                 :            : // -----------------------------------------------------------------------
     497                 :            : 
     498                 :          0 : ScTableListItem::ScTableListItem( const ScTableListItem& rCpy )
     499                 :          0 :     :   SfxPoolItem ( rCpy.Which() ),
     500                 :          0 :         nCount      ( rCpy.nCount )
     501                 :            : {
     502         [ #  # ]:          0 :     if ( nCount > 0 )
     503                 :            :     {
     504         [ #  # ]:          0 :         pTabArr = new SCTAB [nCount];
     505                 :            : 
     506         [ #  # ]:          0 :         for ( sal_uInt16 i=0; i<nCount; i++ )
     507                 :          0 :             pTabArr[i] = rCpy.pTabArr[i];
     508                 :            :     }
     509                 :            :     else
     510                 :          0 :         pTabArr = NULL;
     511                 :          0 : }
     512                 :            : 
     513                 :            : // -----------------------------------------------------------------------
     514                 :            : 
     515                 :            : 
     516                 :        716 : ScTableListItem::~ScTableListItem()
     517                 :            : {
     518         [ -  + ]:        716 :     delete [] pTabArr;
     519         [ -  + ]:       1432 : }
     520                 :            : 
     521                 :            : // -----------------------------------------------------------------------
     522                 :            : 
     523                 :          0 : ScTableListItem& ScTableListItem::operator=( const ScTableListItem& rCpy )
     524                 :            : {
     525         [ #  # ]:          0 :     delete [] pTabArr;
     526                 :            : 
     527         [ #  # ]:          0 :     if ( rCpy.nCount > 0 )
     528                 :            :     {
     529                 :          0 :         pTabArr = new SCTAB [rCpy.nCount];
     530         [ #  # ]:          0 :         for ( sal_uInt16 i=0; i<rCpy.nCount; i++ )
     531                 :          0 :             pTabArr[i] = rCpy.pTabArr[i];
     532                 :            :     }
     533                 :            :     else
     534                 :          0 :         pTabArr = NULL;
     535                 :            : 
     536                 :          0 :     nCount = rCpy.nCount;
     537                 :            : 
     538                 :          0 :     return *this;
     539                 :            : }
     540                 :            : 
     541                 :            : // -----------------------------------------------------------------------
     542                 :            : 
     543                 :          0 : int ScTableListItem::operator==( const SfxPoolItem& rAttr ) const
     544                 :            : {
     545                 :            :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     546                 :            : 
     547                 :          0 :     ScTableListItem&    rCmp   = (ScTableListItem&)rAttr;
     548                 :          0 :     bool                bEqual = (nCount == rCmp.nCount);
     549                 :            : 
     550         [ #  # ]:          0 :     if ( nCount > 0 )
     551                 :            :     {
     552                 :          0 :         sal_uInt16  i=0;
     553                 :            : 
     554 [ #  # ][ #  # ]:          0 :         bEqual = ( pTabArr && rCmp.pTabArr );
     555                 :            : 
     556 [ #  # ][ #  # ]:          0 :         while ( bEqual && i<nCount )
                 [ #  # ]
     557                 :            :         {
     558                 :          0 :             bEqual = ( pTabArr[i] == rCmp.pTabArr[i] );
     559                 :          0 :             i++;
     560                 :            :         }
     561                 :            :     }
     562                 :          0 :     return bEqual;
     563                 :            : }
     564                 :            : 
     565                 :            : // -----------------------------------------------------------------------
     566                 :            : 
     567                 :          0 : SfxPoolItem* ScTableListItem::Clone( SfxItemPool* ) const
     568                 :            : {
     569         [ #  # ]:          0 :     return new ScTableListItem( *this );
     570                 :            : }
     571                 :            : 
     572                 :            : //------------------------------------------------------------------------
     573                 :            : 
     574                 :          0 : SfxItemPresentation ScTableListItem::GetPresentation
     575                 :            :     (
     576                 :            :         SfxItemPresentation ePres,
     577                 :            :         SfxMapUnit          /* eCoreUnit */,
     578                 :            :         SfxMapUnit          /* ePresUnit */,
     579                 :            :         String&             rText,
     580                 :            :         const IntlWrapper* /* pIntl */
     581                 :            :     ) const
     582                 :            : {
     583                 :          0 :     const sal_Unicode cDelim = ',';
     584                 :            : 
     585   [ #  #  #  # ]:          0 :     switch ( ePres )
     586                 :            :     {
     587                 :            :         case SFX_ITEM_PRESENTATION_NONE:
     588                 :          0 :             rText.Erase();
     589                 :          0 :             return ePres;
     590                 :            : 
     591                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
     592                 :            :             {
     593                 :          0 :             rText  = '(';
     594 [ #  # ][ #  # ]:          0 :             if ( nCount>0 && pTabArr )
     595         [ #  # ]:          0 :                 for ( sal_uInt16 i=0; i<nCount; i++ )
     596                 :            :                 {
     597         [ #  # ]:          0 :                     rText += String::CreateFromInt32( pTabArr[i] );
     598         [ #  # ]:          0 :                     if ( i<(nCount-1) )
     599                 :          0 :                         rText += cDelim;
     600                 :            :                 }
     601                 :          0 :             rText += ')';
     602                 :            :             }
     603                 :          0 :             return ePres;
     604                 :            : 
     605                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
     606                 :          0 :             rText.Erase();
     607                 :          0 :             return SFX_ITEM_PRESENTATION_NONE;
     608                 :            : 
     609                 :            :         default:
     610                 :            :         {
     611                 :            :             // added to avoid warnings
     612                 :            :         }
     613                 :            :     }
     614                 :            : 
     615                 :          0 :     return SFX_ITEM_PRESENTATION_NONE;
     616                 :            : }
     617                 :            : 
     618                 :            : 
     619                 :            : // -----------------------------------------------------------------------
     620                 :            : //      ScPageHFItem - Daten der Kopf-/Fusszeilen
     621                 :            : // -----------------------------------------------------------------------
     622                 :            : 
     623                 :       4604 : ScPageHFItem::ScPageHFItem( sal_uInt16 nWhichP )
     624                 :            :     :   SfxPoolItem ( nWhichP ),
     625                 :            :         pLeftArea   ( NULL ),
     626                 :            :         pCenterArea ( NULL ),
     627                 :       4604 :         pRightArea  ( NULL )
     628                 :            : {
     629                 :       4604 : }
     630                 :            : 
     631                 :            : //------------------------------------------------------------------------
     632                 :            : 
     633                 :       4948 : ScPageHFItem::ScPageHFItem( const ScPageHFItem& rItem )
     634                 :            :     :   SfxPoolItem ( rItem ),
     635                 :            :         pLeftArea   ( NULL ),
     636                 :            :         pCenterArea ( NULL ),
     637                 :       4948 :         pRightArea  ( NULL )
     638                 :            : {
     639         [ +  + ]:       4948 :     if ( rItem.pLeftArea )
     640         [ +  - ]:       2282 :         pLeftArea = rItem.pLeftArea->Clone();
     641         [ +  + ]:       4948 :     if ( rItem.pCenterArea )
     642         [ +  - ]:       2366 :         pCenterArea = rItem.pCenterArea->Clone();
     643         [ +  + ]:       4948 :     if ( rItem.pRightArea )
     644         [ +  - ]:       2276 :         pRightArea = rItem.pRightArea->Clone();
     645                 :       4948 : }
     646                 :            : 
     647                 :            : //------------------------------------------------------------------------
     648                 :            : 
     649                 :       8720 : ScPageHFItem::~ScPageHFItem()
     650                 :            : {
     651 [ +  + ][ +  - ]:       8720 :     delete pLeftArea;
     652 [ +  + ][ +  - ]:       8720 :     delete pCenterArea;
     653 [ +  + ][ +  - ]:       8720 :     delete pRightArea;
     654         [ -  + ]:      17260 : }
     655                 :            : 
     656                 :            : //------------------------------------------------------------------------
     657                 :            : 
     658                 :        925 : bool ScPageHFItem::QueryValue( uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
     659                 :            : {
     660                 :            :     uno::Reference<sheet::XHeaderFooterContent> xContent =
     661 [ +  - ][ +  - ]:        925 :         new ScHeaderFooterContentObj( pLeftArea, pCenterArea, pRightArea );
                 [ +  - ]
     662                 :            : 
     663         [ +  - ]:        925 :     rVal <<= xContent;
     664                 :        925 :     return true;
     665                 :            : }
     666                 :            : 
     667                 :        863 : bool ScPageHFItem::PutValue( const uno::Any& rVal, sal_uInt8 /* nMemberId */ )
     668                 :            : {
     669                 :        863 :     bool bRet = false;
     670                 :        863 :     uno::Reference<sheet::XHeaderFooterContent> xContent;
     671 [ +  - ][ +  - ]:        863 :     if ( rVal >>= xContent )
     672                 :            :     {
     673         [ +  - ]:        863 :         if ( xContent.is() )
     674                 :            :         {
     675                 :            :             ScHeaderFooterContentObj* pImp =
     676         [ +  - ]:        863 :                     ScHeaderFooterContentObj::getImplementation( xContent );
     677         [ +  - ]:        863 :             if (pImp)
     678                 :            :             {
     679         [ +  - ]:        863 :                 const EditTextObject* pImpLeft = pImp->GetLeftEditObject();
     680 [ +  + ][ +  - ]:        863 :                 delete pLeftArea;
     681 [ +  + ][ +  - ]:        863 :                 pLeftArea = pImpLeft ? pImpLeft->Clone() : NULL;
     682                 :            : 
     683         [ +  - ]:        863 :                 const EditTextObject* pImpCenter = pImp->GetCenterEditObject();
     684 [ +  + ][ +  - ]:        863 :                 delete pCenterArea;
     685 [ +  - ][ +  - ]:        863 :                 pCenterArea = pImpCenter ? pImpCenter->Clone() : NULL;
     686                 :            : 
     687         [ +  - ]:        863 :                 const EditTextObject* pImpRight = pImp->GetRightEditObject();
     688 [ +  + ][ +  - ]:        863 :                 delete pRightArea;
     689 [ +  + ][ +  - ]:        863 :                 pRightArea = pImpRight ? pImpRight->Clone() : NULL;
     690                 :            : 
     691 [ +  + ][ +  - ]:        863 :                 if ( !pLeftArea || !pCenterArea || !pRightArea )
                 [ -  + ]
     692                 :            :                 {
     693                 :            :                     // keine Texte auf NULL stehen lassen
     694 [ +  - ][ +  - ]:        102 :                     ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true );
     695         [ +  - ]:        102 :                     if (!pLeftArea)
     696         [ +  - ]:        102 :                         pLeftArea = aEngine.CreateTextObject();
     697         [ -  + ]:        102 :                     if (!pCenterArea)
     698         [ #  # ]:          0 :                         pCenterArea = aEngine.CreateTextObject();
     699         [ +  - ]:        102 :                     if (!pRightArea)
     700 [ +  - ][ +  - ]:        102 :                         pRightArea = aEngine.CreateTextObject();
     701                 :            :                 }
     702                 :            : 
     703                 :        863 :                 bRet = true;
     704                 :            :             }
     705                 :            :         }
     706                 :            :     }
     707                 :            : 
     708                 :        863 :     if (!bRet)
     709                 :            :     {
     710                 :            :         OSL_FAIL("exception - wrong argument");
     711                 :            :     }
     712                 :            : 
     713                 :        863 :     return true;
     714                 :            : }
     715                 :            : 
     716                 :            : //------------------------------------------------------------------------
     717                 :            : 
     718                 :          0 : String ScPageHFItem::GetValueText() const
     719                 :            : {
     720         [ #  # ]:          0 :     return rtl::OUString("ScPageHFItem");
     721                 :            : }
     722                 :            : 
     723                 :            : //------------------------------------------------------------------------
     724                 :            : 
     725                 :       5421 : int ScPageHFItem::operator==( const SfxPoolItem& rItem ) const
     726                 :            : {
     727                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
     728                 :            : 
     729                 :       5421 :     const ScPageHFItem& r = (const ScPageHFItem&)rItem;
     730                 :            : 
     731                 :       5421 :     return    ScGlobal::EETextObjEqual(pLeftArea,   r.pLeftArea)
     732                 :       1129 :            && ScGlobal::EETextObjEqual(pCenterArea, r.pCenterArea)
     733         [ +  - ]:       6550 :            && ScGlobal::EETextObjEqual(pRightArea,  r.pRightArea);
           [ +  +  +  + ]
     734                 :            : }
     735                 :            : 
     736                 :            : //------------------------------------------------------------------------
     737                 :            : 
     738                 :       4948 : SfxPoolItem* ScPageHFItem::Clone( SfxItemPool* ) const
     739                 :            : {
     740         [ +  - ]:       4948 :     return new ScPageHFItem( *this );
     741                 :            : }
     742                 :            : 
     743                 :            : //------------------------------------------------------------------------
     744                 :            : 
     745                 :          0 : void lcl_SetSpace( String& rStr, const ESelection& rSel )
     746                 :            : {
     747                 :            :     // Text durch ein Leerzeichen ersetzen, damit Positionen stimmen:
     748                 :            : 
     749                 :          0 :     xub_StrLen nLen = rSel.nEndPos-rSel.nStartPos;
     750                 :          0 :     rStr.Erase( rSel.nStartPos, nLen-1 );
     751                 :          0 :     rStr.SetChar( rSel.nStartPos, ' ' );
     752                 :          0 : }
     753                 :            : 
     754                 :          0 : bool lcl_ConvertFields(EditEngine& rEng, const String* pCommands)
     755                 :            : {
     756                 :          0 :     bool bChange = false;
     757                 :          0 :     sal_uInt16 nParCnt = rEng.GetParagraphCount();
     758         [ #  # ]:          0 :     for (sal_uInt16 nPar = 0; nPar<nParCnt; nPar++)
     759                 :            :     {
     760         [ #  # ]:          0 :         String aStr = rEng.GetText( nPar );
     761                 :            :         xub_StrLen nPos;
     762                 :            : 
     763 [ #  # ][ #  # ]:          0 :         while ((nPos = aStr.Search(pCommands[0])) != STRING_NOTFOUND)
     764                 :            :         {
     765                 :          0 :             ESelection aSel( nPar,nPos, nPar,nPos+pCommands[0].Len() );
     766 [ #  # ][ #  # ]:          0 :             rEng.QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), aSel );
         [ #  # ][ #  # ]
                 [ #  # ]
     767         [ #  # ]:          0 :             lcl_SetSpace(aStr, aSel ); bChange = true;
     768                 :            :         }
     769 [ #  # ][ #  # ]:          0 :         while ((nPos = aStr.Search(pCommands[1])) != STRING_NOTFOUND)
     770                 :            :         {
     771                 :          0 :             ESelection aSel( nPar,nPos, nPar,nPos+pCommands[1].Len() );
     772 [ #  # ][ #  # ]:          0 :             rEng.QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), aSel );
         [ #  # ][ #  # ]
                 [ #  # ]
     773         [ #  # ]:          0 :             lcl_SetSpace(aStr, aSel ); bChange = true;
     774                 :            :         }
     775 [ #  # ][ #  # ]:          0 :         while ((nPos = aStr.Search(pCommands[2])) != STRING_NOTFOUND)
     776                 :            :         {
     777                 :          0 :             ESelection aSel( nPar,nPos, nPar,nPos+pCommands[2].Len() );
     778 [ #  # ][ #  # ]:          0 :             rEng.QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD), aSel );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     779         [ #  # ]:          0 :             lcl_SetSpace(aStr, aSel ); bChange = true;
     780                 :            :         }
     781 [ #  # ][ #  # ]:          0 :         while ((nPos = aStr.Search(pCommands[3])) != STRING_NOTFOUND)
     782                 :            :         {
     783                 :          0 :             ESelection aSel( nPar,nPos, nPar,nPos+pCommands[3].Len() );
     784 [ #  # ][ #  # ]:          0 :             rEng.QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD ), aSel );
         [ #  # ][ #  # ]
                 [ #  # ]
     785         [ #  # ]:          0 :             lcl_SetSpace(aStr, aSel ); bChange = true;
     786                 :            :         }
     787 [ #  # ][ #  # ]:          0 :         while ((nPos = aStr.Search(pCommands[4])) != STRING_NOTFOUND)
     788                 :            :         {
     789                 :          0 :             ESelection aSel( nPar,nPos, nPar,nPos+pCommands[4].Len() );
     790 [ #  # ][ #  # ]:          0 :             rEng.QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), aSel );
         [ #  # ][ #  # ]
                 [ #  # ]
     791         [ #  # ]:          0 :             lcl_SetSpace(aStr, aSel ); bChange = true;
     792                 :            :         }
     793 [ #  # ][ #  # ]:          0 :         while ((nPos = aStr.Search(pCommands[5])) != STRING_NOTFOUND)
     794                 :            :         {
     795                 :          0 :             ESelection aSel( nPar,nPos, nPar,nPos+pCommands[5].Len() );
     796 [ #  # ][ #  # ]:          0 :             rEng.QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), aSel );
         [ #  # ][ #  # ]
                 [ #  # ]
     797         [ #  # ]:          0 :             lcl_SetSpace(aStr, aSel ); bChange = true;
     798                 :            :         }
     799         [ #  # ]:          0 :     }
     800                 :          0 :     return bChange;
     801                 :            : }
     802                 :            : 
     803                 :            : #define SC_FIELD_COUNT  6
     804                 :            : 
     805                 :          0 : SfxPoolItem* ScPageHFItem::Create( SvStream& rStream, sal_uInt16 nVer ) const
     806                 :            : {
     807                 :          0 :     EditTextObject* pLeft   = EditTextObject::Create(rStream);
     808                 :          0 :     EditTextObject* pCenter = EditTextObject::Create(rStream);
     809                 :          0 :     EditTextObject* pRight  = EditTextObject::Create(rStream);
     810                 :            : 
     811                 :            :     OSL_ENSURE( pLeft && pCenter && pRight, "Error reading ScPageHFItem" );
     812                 :            : 
     813         [ #  # ]:          0 :     if ( pLeft == NULL   || pLeft->GetParagraphCount() == 0 ||
           [ #  #  #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     814                 :          0 :          pCenter == NULL || pCenter->GetParagraphCount() == 0 ||
     815                 :          0 :          pRight == NULL  || pRight->GetParagraphCount() == 0 )
     816                 :            :     {
     817                 :            :         //  If successfully loaded, each object contains at least one paragraph.
     818                 :            :         //  Excel import in 5.1 created broken TextObjects (#67442#) that are
     819                 :            :         //  corrected here to avoid saving wrong files again (#90487#).
     820                 :            : 
     821 [ #  # ][ #  # ]:          0 :         ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true );
     822 [ #  # ][ #  # ]:          0 :         if ( pLeft == NULL || pLeft->GetParagraphCount() == 0 )
         [ #  # ][ #  # ]
     823                 :            :         {
     824 [ #  # ][ #  # ]:          0 :             delete pLeft;
     825         [ #  # ]:          0 :             pLeft = aEngine.CreateTextObject();
     826                 :            :         }
     827 [ #  # ][ #  # ]:          0 :         if ( pCenter == NULL || pCenter->GetParagraphCount() == 0 )
         [ #  # ][ #  # ]
     828                 :            :         {
     829 [ #  # ][ #  # ]:          0 :             delete pCenter;
     830         [ #  # ]:          0 :             pCenter = aEngine.CreateTextObject();
     831                 :            :         }
     832 [ #  # ][ #  # ]:          0 :         if ( pRight == NULL || pRight->GetParagraphCount() == 0 )
         [ #  # ][ #  # ]
     833                 :            :         {
     834 [ #  # ][ #  # ]:          0 :             delete pRight;
     835         [ #  # ]:          0 :             pRight = aEngine.CreateTextObject();
     836         [ #  # ]:          0 :         }
     837                 :            :     }
     838                 :            : 
     839         [ #  # ]:          0 :     if ( nVer < 1 )             // alte Feldbefehle umsetzen
     840                 :            :     {
     841                 :            :         sal_uInt16 i;
     842         [ #  # ]:          0 :         const String& rDel = ScGlobal::GetRscString( STR_HFCMD_DELIMITER );
     843 [ #  # ][ #  # ]:          0 :         String aCommands[SC_FIELD_COUNT];
           [ #  #  #  #  
                   #  # ]
     844         [ #  # ]:          0 :         for (i=0; i<SC_FIELD_COUNT; i++)
     845         [ #  # ]:          0 :             aCommands[i] = rDel;
     846 [ #  # ][ #  # ]:          0 :         aCommands[0] += ScGlobal::GetRscString(STR_HFCMD_PAGE);
     847 [ #  # ][ #  # ]:          0 :         aCommands[1] += ScGlobal::GetRscString(STR_HFCMD_PAGES);
     848 [ #  # ][ #  # ]:          0 :         aCommands[2] += ScGlobal::GetRscString(STR_HFCMD_DATE);
     849 [ #  # ][ #  # ]:          0 :         aCommands[3] += ScGlobal::GetRscString(STR_HFCMD_TIME);
     850 [ #  # ][ #  # ]:          0 :         aCommands[4] += ScGlobal::GetRscString(STR_HFCMD_FILE);
     851 [ #  # ][ #  # ]:          0 :         aCommands[5] += ScGlobal::GetRscString(STR_HFCMD_TABLE);
     852         [ #  # ]:          0 :         for (i=0; i<SC_FIELD_COUNT; i++)
     853         [ #  # ]:          0 :             aCommands[i] += rDel;
     854                 :            : 
     855 [ #  # ][ #  # ]:          0 :         ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true );
     856         [ #  # ]:          0 :         aEngine.SetText(*pLeft);
     857 [ #  # ][ #  # ]:          0 :         if (lcl_ConvertFields(aEngine,aCommands))
     858                 :            :         {
     859 [ #  # ][ #  # ]:          0 :             delete pLeft;
     860         [ #  # ]:          0 :             pLeft = aEngine.CreateTextObject();
     861                 :            :         }
     862         [ #  # ]:          0 :         aEngine.SetText(*pCenter);
     863 [ #  # ][ #  # ]:          0 :         if (lcl_ConvertFields(aEngine,aCommands))
     864                 :            :         {
     865 [ #  # ][ #  # ]:          0 :             delete pCenter;
     866         [ #  # ]:          0 :             pCenter = aEngine.CreateTextObject();
     867                 :            :         }
     868         [ #  # ]:          0 :         aEngine.SetText(*pRight);
     869 [ #  # ][ #  # ]:          0 :         if (lcl_ConvertFields(aEngine,aCommands))
     870                 :            :         {
     871 [ #  # ][ #  # ]:          0 :             delete pRight;
     872         [ #  # ]:          0 :             pRight = aEngine.CreateTextObject();
     873 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     874                 :            :     }
     875                 :            :     else if ( nVer < 2 )
     876                 :            :     {   // nichts tun, SvxFileField nicht gegen SvxExtFileField austauschen
     877                 :            :     }
     878                 :            : 
     879         [ #  # ]:          0 :     ScPageHFItem* pItem = new ScPageHFItem( Which() );
     880                 :          0 :     pItem->SetArea( pLeft,    SC_HF_LEFTAREA   );
     881                 :          0 :     pItem->SetArea( pCenter, SC_HF_CENTERAREA );
     882                 :          0 :     pItem->SetArea( pRight,  SC_HF_RIGHTAREA  );
     883                 :            : 
     884                 :          0 :     return pItem;
     885                 :            : }
     886                 :            : 
     887                 :            : //------------------------------------------------------------------------
     888                 :            : 
     889                 :            : 
     890                 :       1660 : void ScPageHFItem::SetLeftArea( const EditTextObject& rNew )
     891                 :            : {
     892         [ +  + ]:       1660 :     delete pLeftArea;
     893                 :       1660 :     pLeftArea = rNew.Clone();
     894                 :       1660 : }
     895                 :            : 
     896                 :            : //------------------------------------------------------------------------
     897                 :            : 
     898                 :       1828 : void ScPageHFItem::SetCenterArea( const EditTextObject& rNew )
     899                 :            : {
     900         [ +  + ]:       1828 :     delete pCenterArea;
     901                 :       1828 :     pCenterArea = rNew.Clone();
     902                 :       1828 : }
     903                 :            : 
     904                 :            : //------------------------------------------------------------------------
     905                 :            : 
     906                 :       1654 : void ScPageHFItem::SetRightArea( const EditTextObject& rNew )
     907                 :            : {
     908         [ +  + ]:       1654 :     delete pRightArea;
     909                 :       1654 :     pRightArea = rNew.Clone();
     910                 :       1654 : }
     911                 :            : 
     912                 :          0 : void ScPageHFItem::SetArea( EditTextObject *pNew, int nArea )
     913                 :            : {
     914   [ #  #  #  # ]:          0 :     switch ( nArea )
     915                 :            :     {
     916         [ #  # ]:          0 :         case SC_HF_LEFTAREA:    delete pLeftArea;   pLeftArea   = pNew; break;
     917         [ #  # ]:          0 :         case SC_HF_CENTERAREA:  delete pCenterArea; pCenterArea = pNew; break;
     918         [ #  # ]:          0 :         case SC_HF_RIGHTAREA:   delete pRightArea;  pRightArea  = pNew; break;
     919                 :            :         default:
     920                 :            :             OSL_FAIL( "New Area?" );
     921                 :            :     }
     922                 :          0 : }
     923                 :            : 
     924                 :            : //-----------------------------------------------------------------------
     925                 :            : //  ScViewObjectModeItem - Darstellungsmodus von ViewObjekten
     926                 :            : //-----------------------------------------------------------------------
     927                 :            : 
     928                 :       2700 : ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP )
     929                 :       2700 :     : SfxEnumItem( nWhichP, VOBJ_MODE_SHOW )
     930                 :            : {
     931                 :       2700 : }
     932                 :            : 
     933                 :            : //------------------------------------------------------------------------
     934                 :            : 
     935                 :         15 : ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP, ScVObjMode eMode )
     936                 :         15 :     : SfxEnumItem( nWhichP, sal::static_int_cast<sal_uInt16>(eMode) )
     937                 :            : {
     938                 :         15 : }
     939                 :            : 
     940                 :            : //------------------------------------------------------------------------
     941                 :            : 
     942                 :       2178 : ScViewObjectModeItem::~ScViewObjectModeItem()
     943                 :            : {
     944         [ -  + ]:       4341 : }
     945                 :            : 
     946                 :            : //------------------------------------------------------------------------
     947                 :            : 
     948                 :          0 : SfxItemPresentation ScViewObjectModeItem::GetPresentation
     949                 :            : (
     950                 :            :     SfxItemPresentation ePres,
     951                 :            :     SfxMapUnit          /* eCoreUnit */,
     952                 :            :     SfxMapUnit          /* ePresUnit */,
     953                 :            :     String&             rText,
     954                 :            :     const IntlWrapper* /* pIntl */
     955                 :            : )   const
     956                 :            : {
     957                 :          0 :     rtl::OUString aDel(": ");
     958         [ #  # ]:          0 :     rText.Erase();
     959                 :            : 
     960      [ #  #  # ]:          0 :     switch ( ePres )
     961                 :            :     {
     962                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
     963   [ #  #  #  # ]:          0 :         switch( Which() )
     964                 :            :         {
     965                 :            :             case SID_SCATTR_PAGE_CHARTS:
     966 [ #  # ][ #  # ]:          0 :             rText  = ScGlobal::GetRscString(STR_VOBJ_CHART);
     967         [ #  # ]:          0 :             rText += aDel;
     968                 :          0 :             break;
     969                 :            : 
     970                 :            :             case SID_SCATTR_PAGE_OBJECTS:
     971 [ #  # ][ #  # ]:          0 :             rText  = ScGlobal::GetRscString(STR_VOBJ_OBJECT);
     972         [ #  # ]:          0 :             rText += aDel;
     973                 :          0 :             break;
     974                 :            : 
     975                 :            :             case SID_SCATTR_PAGE_DRAWINGS:
     976 [ #  # ][ #  # ]:          0 :             rText  = ScGlobal::GetRscString(STR_VOBJ_DRAWINGS);
     977         [ #  # ]:          0 :             rText += aDel;
     978                 :          0 :             break;
     979                 :            : 
     980                 :            :             default:
     981                 :          0 :             ePres = SFX_ITEM_PRESENTATION_NAMELESS;//das geht immer!
     982                 :          0 :             break;
     983                 :            :         }
     984                 :            :         /* !!! fall-through !!! */
     985                 :            : 
     986                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
     987 [ #  # ][ #  # ]:          0 :         rText += ScGlobal::GetRscString(STR_VOBJ_MODE_SHOW+GetValue());
     988                 :          0 :         break;
     989                 :            : 
     990                 :            :         default:
     991                 :            :         {
     992                 :            :             // added to avoid warnings
     993                 :            :         }
     994                 :            :     }
     995                 :            : 
     996                 :          0 :     return ePres;
     997                 :            : }
     998                 :            : 
     999                 :            : //------------------------------------------------------------------------
    1000                 :            : 
    1001                 :          0 : String ScViewObjectModeItem::GetValueText( sal_uInt16 nVal ) const
    1002                 :            : {
    1003                 :            :     OSL_ENSURE( nVal <= VOBJ_MODE_HIDE, "enum overflow!" );
    1004                 :            : 
    1005                 :          0 :     return ScGlobal::GetRscString( STR_VOBJ_MODE_SHOW + (nVal % 2));
    1006                 :            : }
    1007                 :            : 
    1008                 :            : //------------------------------------------------------------------------
    1009                 :            : 
    1010                 :          0 : sal_uInt16 ScViewObjectModeItem::GetValueCount() const
    1011                 :            : {
    1012                 :          0 :     return 2;
    1013                 :            : }
    1014                 :            : 
    1015                 :            : //------------------------------------------------------------------------
    1016                 :            : 
    1017                 :         15 : SfxPoolItem* ScViewObjectModeItem::Clone( SfxItemPool* ) const
    1018                 :            : {
    1019         [ +  - ]:         15 :     return new ScViewObjectModeItem( *this );
    1020                 :            : }
    1021                 :            : 
    1022                 :            : //------------------------------------------------------------------------
    1023                 :            : 
    1024                 :          0 : sal_uInt16 ScViewObjectModeItem::GetVersion( sal_uInt16 /* nFileVersion */ ) const
    1025                 :            : {
    1026                 :          0 :     return 1;
    1027                 :            : }
    1028                 :            : 
    1029                 :            : //------------------------------------------------------------------------
    1030                 :            : 
    1031                 :          0 : SfxPoolItem* ScViewObjectModeItem::Create(
    1032                 :            :                                     SvStream&   rStream,
    1033                 :            :                                     sal_uInt16      nVersion ) const
    1034                 :            : {
    1035         [ #  # ]:          0 :     if ( nVersion == 0 )
    1036                 :            :     {
    1037                 :            :         // alte Version mit AllEnumItem -> mit Mode "Show" erzeugen
    1038         [ #  # ]:          0 :         return new ScViewObjectModeItem( Which() );
    1039                 :            :     }
    1040                 :            :     else
    1041                 :            :     {
    1042                 :            :         sal_uInt16 nVal;
    1043         [ #  # ]:          0 :         rStream >> nVal;
    1044                 :            : 
    1045                 :            :         //#i80528# adapt to new range eventually
    1046         [ #  # ]:          0 :         if((sal_uInt16)VOBJ_MODE_HIDE < nVal) nVal = (sal_uInt16)VOBJ_MODE_SHOW;
    1047                 :            : 
    1048 [ #  # ][ #  # ]:          0 :         return new ScViewObjectModeItem( Which(), (ScVObjMode)nVal);
    1049                 :            :     }
    1050                 :            : }
    1051                 :            : 
    1052                 :            : // -----------------------------------------------------------------------
    1053                 :            : //      double
    1054                 :            : // -----------------------------------------------------------------------
    1055                 :            : 
    1056                 :          0 : ScDoubleItem::ScDoubleItem( sal_uInt16 nWhichP, double nVal )
    1057                 :            :     :   SfxPoolItem ( nWhichP ),
    1058                 :          0 :         nValue  ( nVal )
    1059                 :            : {
    1060                 :          0 : }
    1061                 :            : 
    1062                 :            : //------------------------------------------------------------------------
    1063                 :            : 
    1064                 :          0 : ScDoubleItem::ScDoubleItem( const ScDoubleItem& rItem )
    1065                 :          0 :     :   SfxPoolItem ( rItem )
    1066                 :            : {
    1067                 :          0 :         nValue = rItem.nValue;
    1068                 :          0 : }
    1069                 :            : 
    1070                 :            : //------------------------------------------------------------------------
    1071                 :            : 
    1072                 :          0 : String ScDoubleItem::GetValueText() const
    1073                 :            : {
    1074         [ #  # ]:          0 :     return rtl::OUString("ScDoubleItem");
    1075                 :            : }
    1076                 :            : 
    1077                 :            : //------------------------------------------------------------------------
    1078                 :            : 
    1079                 :          0 : int ScDoubleItem::operator==( const SfxPoolItem& rItem ) const
    1080                 :            : {
    1081                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
    1082                 :          0 :     const ScDoubleItem& _rItem = (const ScDoubleItem&)rItem;
    1083                 :          0 :     return int(nValue == _rItem.nValue);
    1084                 :            : }
    1085                 :            : 
    1086                 :            : //------------------------------------------------------------------------
    1087                 :            : 
    1088                 :          0 : SfxPoolItem* ScDoubleItem::Clone( SfxItemPool* ) const
    1089                 :            : {
    1090         [ #  # ]:          0 :     return new ScDoubleItem( *this );
    1091                 :            : }
    1092                 :            : 
    1093                 :            : //------------------------------------------------------------------------
    1094                 :            : 
    1095                 :          0 : SfxPoolItem* ScDoubleItem::Create( SvStream& rStream, sal_uInt16 /* nVer */ ) const
    1096                 :            : {
    1097                 :          0 :     double nTmp=0;
    1098         [ #  # ]:          0 :     rStream >> nTmp;
    1099                 :            : 
    1100 [ #  # ][ #  # ]:          0 :     ScDoubleItem* pItem = new ScDoubleItem( Which(), nTmp );
    1101                 :            : 
    1102                 :          0 :     return pItem;
    1103                 :            : }
    1104                 :            : 
    1105                 :            : //------------------------------------------------------------------------
    1106                 :            : 
    1107                 :          0 : ScDoubleItem::~ScDoubleItem()
    1108                 :            : {
    1109         [ #  # ]:          0 : }
    1110                 :            : 
    1111                 :            : 
    1112                 :            : // ============================================================================
    1113                 :            : 
    1114                 :       1055 : ScPageScaleToItem::ScPageScaleToItem() :
    1115                 :            :     SfxPoolItem( ATTR_PAGE_SCALETO ),
    1116                 :            :     mnWidth( 0 ),
    1117                 :       1055 :     mnHeight( 0 )
    1118                 :            : {
    1119                 :       1055 : }
    1120                 :            : 
    1121                 :        900 : ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight ) :
    1122                 :            :     SfxPoolItem( ATTR_PAGE_SCALETO ),
    1123                 :            :     mnWidth( nWidth ),
    1124                 :        900 :     mnHeight( nHeight )
    1125                 :            : {
    1126                 :        900 : }
    1127                 :            : 
    1128                 :       2807 : ScPageScaleToItem::~ScPageScaleToItem()
    1129                 :            : {
    1130         [ -  + ]:       4559 : }
    1131                 :            : 
    1132                 :       1055 : ScPageScaleToItem* ScPageScaleToItem::Clone( SfxItemPool* ) const
    1133                 :            : {
    1134         [ +  - ]:       1055 :     return new ScPageScaleToItem( *this );
    1135                 :            : }
    1136                 :            : 
    1137                 :          0 : int ScPageScaleToItem::operator==( const SfxPoolItem& rCmp ) const
    1138                 :            : {
    1139                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rCmp ), "ScPageScaleToItem::operator== - unequal wid or type" );
    1140                 :          0 :     const ScPageScaleToItem& rPageCmp = static_cast< const ScPageScaleToItem& >( rCmp );
    1141 [ #  # ][ #  # ]:          0 :     return ((mnWidth == rPageCmp.mnWidth) && (mnHeight == rPageCmp.mnHeight)) ? 1 : 0;
    1142                 :            : }
    1143                 :            : 
    1144                 :            : namespace {
    1145                 :          0 : void lclAppendScalePageCount( String& rText, sal_uInt16 nPages )
    1146                 :            : {
    1147                 :          0 :     rText.AppendAscii( ": " );
    1148         [ #  # ]:          0 :     if( nPages )
    1149                 :            :     {
    1150 [ #  # ][ #  # ]:          0 :         String aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES ) );
    1151 [ #  # ][ #  # ]:          0 :         aPages.SearchAndReplaceAscii( "%1", String::CreateFromInt32( nPages ) );
                 [ #  # ]
    1152 [ #  # ][ #  # ]:          0 :         rText.Append( aPages );
    1153                 :            :     }
    1154                 :            :     else
    1155                 :          0 :         rText.Append( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_AUTO ) );
    1156                 :          0 : }
    1157                 :            : } // namespace
    1158                 :            : 
    1159                 :          0 : SfxItemPresentation ScPageScaleToItem::GetPresentation(
    1160                 :            :         SfxItemPresentation ePres, SfxMapUnit, SfxMapUnit, XubString& rText, const IntlWrapper* ) const
    1161                 :            : {
    1162         [ #  # ]:          0 :     rText.Erase();
    1163 [ #  # ][ #  # ]:          0 :     if( !IsValid() || (ePres == SFX_ITEM_PRESENTATION_NONE) )
                 [ #  # ]
    1164                 :          0 :         return SFX_ITEM_PRESENTATION_NONE;
    1165                 :            : 
    1166 [ #  # ][ #  # ]:          0 :     String aName( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETO ) );
    1167 [ #  # ][ #  # ]:          0 :     String aValue( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_WIDTH ) );
    1168         [ #  # ]:          0 :     lclAppendScalePageCount( aValue, mnWidth );
    1169 [ #  # ][ #  # ]:          0 :     aValue.AppendAscii( ", " ).Append( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_HEIGHT ) );
                 [ #  # ]
    1170         [ #  # ]:          0 :     lclAppendScalePageCount( aValue, mnHeight );
    1171                 :            : 
    1172   [ #  #  #  #  :          0 :     switch( ePres )
                      # ]
    1173                 :            :     {
    1174                 :            :         case SFX_ITEM_PRESENTATION_NONE:
    1175                 :          0 :         break;
    1176                 :            : 
    1177                 :            :         case SFX_ITEM_PRESENTATION_NAMEONLY:
    1178         [ #  # ]:          0 :             rText = aName;
    1179                 :          0 :         break;
    1180                 :            : 
    1181                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
    1182         [ #  # ]:          0 :             rText = aValue;
    1183                 :          0 :         break;
    1184                 :            : 
    1185                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
    1186 [ #  # ][ #  # ]:          0 :             rText.Assign( aName ).AppendAscii( " (" ).Append( aValue ).Append( ')' );
         [ #  # ][ #  # ]
    1187                 :          0 :         break;
    1188                 :            : 
    1189                 :            :         default:
    1190                 :            :             OSL_FAIL( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
    1191                 :          0 :             ePres = SFX_ITEM_PRESENTATION_NONE;
    1192                 :            :     }
    1193 [ #  # ][ #  # ]:          0 :     return ePres;
    1194                 :            : }
    1195                 :            : 
    1196                 :          0 : bool ScPageScaleToItem::QueryValue( uno::Any& rAny, sal_uInt8 nMemberId ) const
    1197                 :            : {
    1198                 :          0 :     bool bRet = true;
    1199      [ #  #  # ]:          0 :     switch( nMemberId )
    1200                 :            :     {
    1201                 :          0 :         case SC_MID_PAGE_SCALETO_WIDTH:     rAny <<= mnWidth;   break;
    1202                 :          0 :         case SC_MID_PAGE_SCALETO_HEIGHT:    rAny <<= mnHeight;  break;
    1203                 :            :         default:
    1204                 :            :             OSL_FAIL( "ScPageScaleToItem::QueryValue - unknown member ID" );
    1205                 :          0 :             bRet = false;
    1206                 :            :     }
    1207                 :          0 :     return bRet;
    1208                 :            : }
    1209                 :            : 
    1210                 :          0 : bool ScPageScaleToItem::PutValue( const uno::Any& rAny, sal_uInt8 nMemberId )
    1211                 :            : {
    1212                 :          0 :     bool bRet = false;
    1213      [ #  #  # ]:          0 :     switch( nMemberId )
    1214                 :            :     {
    1215                 :          0 :         case SC_MID_PAGE_SCALETO_WIDTH:     bRet = rAny >>= mnWidth;    break;
    1216                 :          0 :         case SC_MID_PAGE_SCALETO_HEIGHT:    bRet = rAny >>= mnHeight;   break;
    1217                 :            :         default:
    1218                 :            :             OSL_FAIL( "ScPageScaleToItem::PutValue - unknown member ID" );
    1219                 :            :     }
    1220                 :          0 :     return bRet;
    1221                 :            : }
    1222                 :            : 
    1223                 :            : // ============================================================================
    1224                 :            : 
    1225                 :            : 
    1226                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10