LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoredlines.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 10 83 12.0 %
Date: 2014-04-11 Functions: 4 21 19.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/beans/XPropertySet.hpp>
      21             : #include <cppuhelper/supportsservice.hxx>
      22             : 
      23             : #include <osl/mutex.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : 
      26             : #include <unoredlines.hxx>
      27             : #include <unoredline.hxx>
      28             : #include <unomid.h>
      29             : #include <pagedesc.hxx>
      30             : #include "poolfmt.hxx"
      31             : #include <doc.hxx>
      32             : #include <docary.hxx>
      33             : #include <redline.hxx>
      34             : #include <switerator.hxx>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : 
      38          21 : SwXRedlines::SwXRedlines(SwDoc* _pDoc) :
      39          21 :     SwUnoCollection(_pDoc)
      40             : {
      41          21 : }
      42             : 
      43          42 : SwXRedlines::~SwXRedlines()
      44             : {
      45          42 : }
      46             : 
      47           0 : sal_Int32 SwXRedlines::getCount(  ) throw(uno::RuntimeException, std::exception)
      48             : {
      49           0 :     SolarMutexGuard aGuard;
      50           0 :     if(!IsValid())
      51           0 :         throw uno::RuntimeException();
      52           0 :     const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
      53           0 :     return rRedTbl.size();
      54             : }
      55             : 
      56           0 : uno::Any SwXRedlines::getByIndex(sal_Int32 nIndex)
      57             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
      58             : {
      59           0 :     SolarMutexGuard aGuard;
      60           0 :     if(!IsValid())
      61           0 :         throw uno::RuntimeException();
      62           0 :     const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
      63           0 :     uno::Any aRet;
      64           0 :     if ((rRedTbl.size() > static_cast<size_t>(nIndex)) && (nIndex >= 0))
      65             :     {
      66           0 :         uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTbl[nIndex], *GetDoc() );
      67           0 :         aRet <<= xRet;
      68             :     }
      69             :     else
      70           0 :         throw lang::IndexOutOfBoundsException();
      71           0 :     return aRet;
      72             : }
      73             : 
      74           0 : uno::Reference< container::XEnumeration >  SwXRedlines::createEnumeration(void)
      75             :     throw( uno::RuntimeException, std::exception )
      76             : {
      77           0 :     SolarMutexGuard aGuard;
      78           0 :     if(!IsValid())
      79           0 :         throw uno::RuntimeException();
      80           0 :     return uno::Reference< container::XEnumeration >(new SwXRedlineEnumeration(*GetDoc()));
      81             : }
      82             : 
      83           0 : uno::Type SwXRedlines::getElementType(  ) throw(uno::RuntimeException, std::exception)
      84             : {
      85           0 :     return ::getCppuType((uno::Reference<beans::XPropertySet>*)0);
      86             : }
      87             : 
      88          42 : sal_Bool SwXRedlines::hasElements(  ) throw(uno::RuntimeException, std::exception)
      89             : {
      90          42 :     SolarMutexGuard aGuard;
      91          42 :     if(!IsValid())
      92           0 :         throw uno::RuntimeException();
      93          42 :     const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
      94          42 :     return rRedTbl.size() > 0;
      95             : }
      96             : 
      97           0 : OUString SwXRedlines::getImplementationName(void) throw( uno::RuntimeException, std::exception )
      98             : {
      99           0 :     return OUString("SwXRedlines");
     100             : }
     101             : 
     102           0 : sal_Bool SwXRedlines::supportsService(const OUString& ServiceName)
     103             :     throw( uno::RuntimeException, std::exception )
     104             : {
     105           0 :     return cppu::supportsService(this, ServiceName);
     106             : }
     107             : 
     108           0 : uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames(void)
     109             :     throw( uno::RuntimeException, std::exception )
     110             : {
     111             :     OSL_FAIL("not implemented");
     112           0 :     return uno::Sequence< OUString >();
     113             : }
     114             : 
     115           0 : beans::XPropertySet*    SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
     116             : {
     117           0 :     SwPageDesc* pStdDesc = rDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD);
     118           0 :     SwIterator<SwXRedline,SwPageDesc> aIter(*pStdDesc);
     119           0 :     SwXRedline* pxRedline = aIter.First();
     120           0 :     while(pxRedline)
     121             :     {
     122           0 :         if(pxRedline->GetRedline() == &rRedline)
     123           0 :             break;
     124           0 :         pxRedline = aIter.Next();
     125             :     }
     126           0 :     if( !pxRedline )
     127           0 :         pxRedline = new SwXRedline(rRedline, rDoc);
     128           0 :     return pxRedline;
     129             : }
     130             : 
     131           0 : SwXRedlineEnumeration::SwXRedlineEnumeration(SwDoc& rDoc) :
     132             :     pDoc(&rDoc),
     133           0 :     nCurrentIndex(0)
     134             : {
     135           0 :     pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
     136           0 : }
     137             : 
     138           0 : SwXRedlineEnumeration::~SwXRedlineEnumeration()
     139             : {
     140           0 : }
     141             : 
     142           0 : sal_Bool SwXRedlineEnumeration::hasMoreElements(void) throw( uno::RuntimeException, std::exception )
     143             : {
     144           0 :     if(!pDoc)
     145           0 :         throw uno::RuntimeException();
     146           0 :     return pDoc->GetRedlineTbl().size() > nCurrentIndex;
     147             : }
     148             : 
     149           0 : uno::Any SwXRedlineEnumeration::nextElement(void)
     150             :     throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     151             : {
     152           0 :     if(!pDoc)
     153           0 :         throw uno::RuntimeException();
     154           0 :     const SwRedlineTbl& rRedTbl = pDoc->GetRedlineTbl();
     155           0 :     if( rRedTbl.size() <= nCurrentIndex )
     156           0 :         throw container::NoSuchElementException();
     157           0 :     uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTbl[nCurrentIndex++], *pDoc );
     158           0 :     uno::Any aRet;
     159           0 :     aRet <<= xRet;
     160           0 :     return aRet;
     161             : }
     162             : 
     163           0 : OUString SwXRedlineEnumeration::getImplementationName(void) throw( uno::RuntimeException, std::exception )
     164             : {
     165           0 :     return OUString("SwXRedlineEnumeration");
     166             : }
     167             : 
     168           0 : sal_Bool SwXRedlineEnumeration::supportsService(const OUString& ServiceName) throw( uno::RuntimeException, std::exception )
     169             : {
     170           0 :     return cppu::supportsService(this, ServiceName);
     171             : }
     172             : 
     173           0 : uno::Sequence< OUString > SwXRedlineEnumeration::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
     174             : {
     175           0 :     return uno::Sequence< OUString >();
     176             : }
     177             : 
     178           0 : void SwXRedlineEnumeration::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
     179             : {
     180           0 :     ClientModify(this, pOld, pNew);
     181           0 :     if(!GetRegisteredIn())
     182           0 :         pDoc = 0;
     183           0 : }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10