LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoredlines.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 11 83 13.3 %
Date: 2015-06-13 12:38:46 Functions: 6 23 26.1 %
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 <IDocumentStylePoolAccess.hxx>
      33             : #include <docary.hxx>
      34             : #include <redline.hxx>
      35             : #include <calbck.hxx>
      36             : 
      37             : using namespace ::com::sun::star;
      38             : 
      39          54 : SwXRedlines::SwXRedlines(SwDoc* _pDoc) :
      40          54 :     SwUnoCollection(_pDoc)
      41             : {
      42          54 : }
      43             : 
      44         108 : SwXRedlines::~SwXRedlines()
      45             : {
      46         108 : }
      47             : 
      48           0 : sal_Int32 SwXRedlines::getCount(  ) throw(uno::RuntimeException, std::exception)
      49             : {
      50           0 :     SolarMutexGuard aGuard;
      51           0 :     if(!IsValid())
      52           0 :         throw uno::RuntimeException();
      53           0 :     const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
      54           0 :     return rRedTable.size();
      55             : }
      56             : 
      57           0 : uno::Any SwXRedlines::getByIndex(sal_Int32 nIndex)
      58             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
      59             : {
      60           0 :     SolarMutexGuard aGuard;
      61           0 :     if(!IsValid())
      62           0 :         throw uno::RuntimeException();
      63           0 :     const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
      64           0 :     uno::Any aRet;
      65           0 :     if ((rRedTable.size() > static_cast<size_t>(nIndex)) && (nIndex >= 0))
      66             :     {
      67           0 :         uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nIndex], *GetDoc() );
      68           0 :         aRet <<= xRet;
      69             :     }
      70             :     else
      71           0 :         throw lang::IndexOutOfBoundsException();
      72           0 :     return aRet;
      73             : }
      74             : 
      75           0 : uno::Reference< container::XEnumeration >  SwXRedlines::createEnumeration()
      76             :     throw( uno::RuntimeException, std::exception )
      77             : {
      78           0 :     SolarMutexGuard aGuard;
      79           0 :     if(!IsValid())
      80           0 :         throw uno::RuntimeException();
      81           0 :     return uno::Reference< container::XEnumeration >(new SwXRedlineEnumeration(*GetDoc()));
      82             : }
      83             : 
      84           0 : uno::Type SwXRedlines::getElementType(  ) throw(uno::RuntimeException, std::exception)
      85             : {
      86           0 :     return cppu::UnoType<beans::XPropertySet>::get();
      87             : }
      88             : 
      89         146 : sal_Bool SwXRedlines::hasElements(  ) throw(uno::RuntimeException, std::exception)
      90             : {
      91         146 :     SolarMutexGuard aGuard;
      92         146 :     if(!IsValid())
      93           0 :         throw uno::RuntimeException();
      94         146 :     const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
      95         146 :     return rRedTable.size() > 0;
      96             : }
      97             : 
      98           0 : OUString SwXRedlines::getImplementationName() throw( uno::RuntimeException, std::exception )
      99             : {
     100           0 :     return OUString("SwXRedlines");
     101             : }
     102             : 
     103           0 : sal_Bool SwXRedlines::supportsService(const OUString& ServiceName)
     104             :     throw( uno::RuntimeException, std::exception )
     105             : {
     106           0 :     return cppu::supportsService(this, ServiceName);
     107             : }
     108             : 
     109           0 : uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames()
     110             :     throw( uno::RuntimeException, std::exception )
     111             : {
     112             :     OSL_FAIL("not implemented");
     113           0 :     return uno::Sequence< OUString >();
     114             : }
     115             : 
     116           0 : beans::XPropertySet*    SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
     117             : {
     118           0 :     SwPageDesc* pStdDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD);
     119           0 :     SwIterator<SwXRedline,SwPageDesc> aIter(*pStdDesc);
     120           0 :     SwXRedline* pxRedline = aIter.First();
     121           0 :     while(pxRedline)
     122             :     {
     123           0 :         if(pxRedline->GetRedline() == &rRedline)
     124           0 :             break;
     125           0 :         pxRedline = aIter.Next();
     126             :     }
     127           0 :     if( !pxRedline )
     128           0 :         pxRedline = new SwXRedline(rRedline, rDoc);
     129           0 :     return pxRedline;
     130             : }
     131             : 
     132           0 : SwXRedlineEnumeration::SwXRedlineEnumeration(SwDoc& rDoc) :
     133             :     pDoc(&rDoc),
     134           0 :     nCurrentIndex(0)
     135             : {
     136           0 :     pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
     137           0 : }
     138             : 
     139           0 : SwXRedlineEnumeration::~SwXRedlineEnumeration()
     140             : {
     141           0 : }
     142             : 
     143           0 : sal_Bool SwXRedlineEnumeration::hasMoreElements() throw( uno::RuntimeException, std::exception )
     144             : {
     145           0 :     if(!pDoc)
     146           0 :         throw uno::RuntimeException();
     147           0 :     return pDoc->getIDocumentRedlineAccess().GetRedlineTable().size() > nCurrentIndex;
     148             : }
     149             : 
     150           0 : uno::Any SwXRedlineEnumeration::nextElement()
     151             :     throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     152             : {
     153           0 :     if(!pDoc)
     154           0 :         throw uno::RuntimeException();
     155           0 :     const SwRedlineTable& rRedTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
     156           0 :     if( rRedTable.size() <= nCurrentIndex )
     157           0 :         throw container::NoSuchElementException();
     158           0 :     uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nCurrentIndex++], *pDoc );
     159           0 :     uno::Any aRet;
     160           0 :     aRet <<= xRet;
     161           0 :     return aRet;
     162             : }
     163             : 
     164           0 : OUString SwXRedlineEnumeration::getImplementationName() throw( uno::RuntimeException, std::exception )
     165             : {
     166           0 :     return OUString("SwXRedlineEnumeration");
     167             : }
     168             : 
     169           0 : sal_Bool SwXRedlineEnumeration::supportsService(const OUString& ServiceName) throw( uno::RuntimeException, std::exception )
     170             : {
     171           0 :     return cppu::supportsService(this, ServiceName);
     172             : }
     173             : 
     174           0 : uno::Sequence< OUString > SwXRedlineEnumeration::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
     175             : {
     176           0 :     return uno::Sequence< OUString >();
     177             : }
     178             : 
     179           0 : void SwXRedlineEnumeration::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
     180             : {
     181           0 :     ClientModify(this, pOld, pNew);
     182           0 :     if(!GetRegisteredIn())
     183           0 :         pDoc = 0;
     184         177 : }
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11