LCOV - code coverage report
Current view: top level - libreoffice/writerfilter/source/doctok - XNoteHelperImpl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2012-12-27 Functions: 0 18 0.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             : #ifndef INCLUDED_X_NOTE_HELPER_IMPL_HXX
      21             : #define INCLUDED_X_NOTE_HELPER_IMPL_HXX
      22             : 
      23             : namespace writerfilter {
      24             : namespace doctok
      25             : {
      26             : template <class T>
      27           0 : sal_uInt32 XNoteHelper<T>::getCount() const
      28             : {
      29           0 :     sal_uInt32 nResult = 0;
      30             : 
      31           0 :     if (mpCps.get() != NULL && mpCps->getCount() > 8)
      32           0 :         nResult = ( mpCps->getCount() / 4) - 2;
      33             : 
      34           0 :     return nResult;
      35             : }
      36             : 
      37             : template <class T>
      38           0 : CpAndFc XNoteHelper<T>::getCpAndFc(sal_uInt32 nPos)
      39             : {
      40             :     // There are getCount() + 1 entries in mpOffsets => greater
      41           0 :     if (nPos > getCount())
      42           0 :         throw ExceptionNotFound("getCpAndFc");
      43             : 
      44           0 :     Cp aCp(mCpAndFcOffset.getCp() + mpCps->getU32(nPos * 4));
      45           0 :     Fc aFc(mpPieceTable->cp2fc(aCp));
      46           0 :     CpAndFc aCpAndFc(aCp, aFc, meType);
      47             : 
      48           0 :     return aCpAndFc;
      49             : }
      50             : 
      51             : template <class T>
      52           0 : CpAndFc XNoteHelper<T>::getRefCpAndFc(sal_uInt32 nPos)
      53             : {
      54             :     // There are getCount() entries in mpRefs => greater or equal
      55           0 :     if (nPos >= getCount())
      56           0 :         throw ExceptionNotFound("");
      57             : 
      58           0 :     Cp aCp(mpRefs->getFc(nPos));
      59           0 :     Fc aFc(mpPieceTable->cp2fc(aCp));
      60           0 :     CpAndFc aCpAndFc(aCp, aFc, meType);
      61             : 
      62           0 :     return aCpAndFc;
      63             : }
      64             : 
      65             : template <class T>
      66             : writerfilter::Reference<Stream>::Pointer_t
      67           0 : XNoteHelper<T>::get(sal_uInt32 nPos)
      68             : {
      69             :     // There are getCount() entries => greater or equal
      70           0 :     if (nPos >= getCount())
      71           0 :         throw ExceptionNotFound("get");
      72             : 
      73           0 :     writerfilter::Reference<Stream>::Pointer_t pResult;
      74             : 
      75           0 :     CpAndFc aCpAndFcStart(getCpAndFc(nPos));
      76           0 :     CpAndFc aCpAndFcEnd(getCpAndFc(nPos + 1));
      77             : 
      78           0 :     if (aCpAndFcStart < aCpAndFcEnd)
      79           0 :         pResult = writerfilter::Reference<Stream>::Pointer_t
      80             :             (new WW8DocumentImpl(*mpDocument, aCpAndFcStart, aCpAndFcEnd));
      81             : 
      82           0 :     return pResult;
      83             : }
      84             : 
      85             : template <class T>
      86           0 : sal_uInt32 XNoteHelper<T>::getIndexOfCpAndFc(const CpAndFc & rCpAndFc)
      87             : {
      88           0 :    sal_uInt32 nResult = getCount();
      89             : 
      90           0 :    sal_uInt32 n = nResult;
      91           0 :    while (n > 0)
      92             :    {
      93           0 :        --n;
      94             : 
      95           0 :        Cp aCp(mpRefs->getFc(n));
      96           0 :        Fc aFc(mpPieceTable->cp2fc(aCp));
      97           0 :        CpAndFc aCpAndFc(aCp, aFc, meType);
      98             : 
      99           0 :        if (aCpAndFc <= rCpAndFc)
     100             :        {
     101           0 :            nResult = n;
     102             :            break;
     103             :        }
     104             :     }
     105             : 
     106           0 :     return nResult;
     107             : }
     108             : 
     109             : template <class T>
     110             : writerfilter::Reference<Stream>::Pointer_t
     111           0 : XNoteHelper<T>::get(const CpAndFc & rCpAndFc)
     112             : {
     113           0 :     writerfilter::Reference<Stream>::Pointer_t pResult;
     114             : 
     115           0 :     sal_uInt32 n = getIndexOfCpAndFc(rCpAndFc);
     116             : 
     117           0 :     if (n < getCount())
     118           0 :         pResult = get(n);
     119             : 
     120           0 :     return pResult;
     121             : }
     122             : 
     123             : template <class T>
     124             : T *
     125           0 : XNoteHelper<T>::getRef(sal_uInt32 nIndex)
     126             : {
     127           0 :     return mpRefs->getEntryPointer(nIndex);
     128             : }
     129             : 
     130             : template <class T>
     131             : T *
     132           0 : XNoteHelper<T>::getRef(const CpAndFc & rCpAndFc)
     133             : {
     134           0 :     T * pResult = NULL;
     135             : 
     136           0 :     sal_uInt32 n = getIndexOfCpAndFc(rCpAndFc);
     137             : 
     138           0 :     if (n < getCount())
     139             :     {
     140           0 :         pResult = getRef(n);
     141             :     }
     142             : 
     143           0 :     return pResult;
     144             : }
     145             : 
     146             : template <class T>
     147           0 : void XNoteHelper<T>::init()
     148             : {
     149           0 :     for (sal_uInt32 n = 0; n < getCount(); ++n)
     150             :     {
     151           0 :         CpAndFc aCpAndFc(getCpAndFc(n));
     152           0 :         mpDocument->insertCpAndFc(aCpAndFc);
     153             : 
     154           0 :         CpAndFc aCpAndFcRef(getRefCpAndFc(n));
     155           0 :         mpDocument->insertCpAndFc(aCpAndFcRef);
     156             :     }
     157           0 : }
     158             : }}
     159             : 
     160             : #endif // INCLUDED_X_NOTE_HELPER_IMPL_HXX
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10