LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - forbiuno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 29 100.0 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 50 58.0 %

           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 <editeng/forbiddencharacterstable.hxx>
      30                 :            : 
      31                 :            : #include "forbiuno.hxx"
      32                 :            : #include "docsh.hxx"
      33                 :            : 
      34                 :            : using namespace ::com::sun::star;
      35                 :            : 
      36                 :            : //------------------------------------------------------------------------
      37                 :            : 
      38                 :         11 : rtl::Reference<SvxForbiddenCharactersTable> lcl_GetForbidden( ScDocShell* pDocSh )
      39                 :            : {
      40                 :         11 :     rtl::Reference<SvxForbiddenCharactersTable> xRet;
      41         [ +  - ]:         11 :     if ( pDocSh )
      42                 :            :     {
      43                 :         11 :         ScDocument* pDoc = pDocSh->GetDocument();
      44 [ +  - ][ +  - ]:         11 :         xRet = pDoc->GetForbiddenCharacters();
                 [ +  - ]
      45         [ +  + ]:         11 :         if ( !xRet.is() )
      46                 :            :         {
      47                 :            :             //  create an empty SvxForbiddenCharactersTable for SvxUnoForbiddenCharsTable,
      48                 :            :             //  so changes can be stored.
      49                 :            : 
      50 [ +  - ][ +  - ]:          7 :             xRet = new SvxForbiddenCharactersTable( pDoc->GetServiceManager() );
         [ +  - ][ +  - ]
      51 [ +  - ][ +  - ]:          7 :             pDoc->SetForbiddenCharacters( xRet );
                 [ +  - ]
      52                 :            :         }
      53                 :            :     }
      54                 :         11 :     return xRet;
      55                 :            : }
      56                 :            : 
      57                 :         11 : ScForbiddenCharsObj::ScForbiddenCharsObj( ScDocShell* pDocSh ) :
      58                 :            :     SvxUnoForbiddenCharsTable( lcl_GetForbidden( pDocSh ) ),
      59 [ +  - ][ +  - ]:         11 :     pDocShell( pDocSh )
      60                 :            : {
      61         [ +  - ]:         11 :     if (pDocShell)
      62         [ +  - ]:         11 :         pDocShell->GetDocument()->AddUnoObject(*this);
      63                 :         11 : }
      64                 :            : 
      65         [ +  - ]:         11 : ScForbiddenCharsObj::~ScForbiddenCharsObj()
      66                 :            : {
      67         [ +  + ]:         11 :     if (pDocShell)
      68         [ +  - ]:          7 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
      69         [ -  + ]:         22 : }
      70                 :            : 
      71                 :          7 : void ScForbiddenCharsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
      72                 :            : {
      73   [ +  -  +  + ]:         14 :     if ( rHint.ISA( SfxSimpleHint ) &&
                 [ +  + ]
      74                 :          7 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
      75                 :            :     {
      76                 :          4 :         pDocShell = NULL;       // document gone
      77                 :            :     }
      78                 :          7 : }
      79                 :            : 
      80                 :          3 : void ScForbiddenCharsObj::onChange()
      81                 :            : {
      82         [ +  - ]:          3 :     if (pDocShell)
      83                 :            :     {
      84         [ +  - ]:          3 :         pDocShell->GetDocument()->SetForbiddenCharacters( mxForbiddenChars );
      85                 :          3 :         pDocShell->PostPaintGridAll();
      86                 :          3 :         pDocShell->SetDocumentModified();
      87                 :            :     }
      88                 :          3 : }
      89                 :            : 
      90                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10