LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/fields - postithelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 73 67.1 %
Date: 2013-07-09 Functions: 8 10 80.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 <postithelper.hxx>
      21             : #include <PostItMgr.hxx>
      22             : #include <AnnotationWin.hxx>
      23             : 
      24             : #include <fmtfld.hxx>
      25             : #include <txtfld.hxx>
      26             : #include <docufld.hxx>
      27             : #include <ndtxt.hxx>
      28             : #include <cntfrm.hxx>
      29             : #include <pagefrm.hxx>
      30             : #include <rootfrm.hxx>
      31             : #include <txtfrm.hxx>
      32             : #include <tabfrm.hxx>
      33             : #include <IDocumentRedlineAccess.hxx>
      34             : #include <redline.hxx>
      35             : #include <scriptinfo.hxx>
      36             : #include <editeng/charhiddenitem.hxx>
      37             : #include <switerator.hxx>
      38             : 
      39             : class Point;
      40             : 
      41             : namespace {
      42             : 
      43             : struct LayoutInfoOrder
      44             : {
      45           0 :     bool operator()( const SwLayoutInfo& rLayoutInfo,
      46             :                      const SwLayoutInfo& rNewLayoutInfo )
      47             :     {
      48           0 :         if ( rLayoutInfo.mnPageNumber != rNewLayoutInfo.mnPageNumber )
      49             :         {
      50             :             // corresponding <SwFrm> instances are on different pages
      51           0 :             return rLayoutInfo.mnPageNumber < rNewLayoutInfo.mnPageNumber;
      52             :         }
      53             :         else
      54             :         {
      55             :             // corresponding <SwFrm> instances are in different repeating table header rows
      56             :             OSL_ENSURE( rLayoutInfo.mpAnchorFrm->FindTabFrm(),
      57             :                     "<LayoutInfoOrder::operator()> - table frame not found" );
      58             :             OSL_ENSURE( rNewLayoutInfo.mpAnchorFrm->FindTabFrm(),
      59             :                     "<LayoutInfoOrder::operator()> - table frame not found" );
      60           0 :             const SwTabFrm* pLayoutInfoTabFrm( rLayoutInfo.mpAnchorFrm->FindTabFrm() );
      61           0 :             const SwTabFrm* pNewLayoutInfoTabFrm( rNewLayoutInfo.mpAnchorFrm->FindTabFrm() );
      62           0 :             const SwTabFrm* pTmpTabFrm( pNewLayoutInfoTabFrm );
      63           0 :             while ( pTmpTabFrm && pTmpTabFrm->GetFollow() )
      64             :             {
      65           0 :                 pTmpTabFrm = static_cast<const SwTabFrm*>(pTmpTabFrm->GetFollow()->GetFrm());
      66           0 :                 if ( pTmpTabFrm == pLayoutInfoTabFrm )
      67             :                 {
      68           0 :                     return false;
      69             :                 }
      70             :             }
      71           0 :             return true;
      72             :         }
      73             :     }
      74             : };
      75             : 
      76             : } // eof anonymous namespace
      77             : 
      78          54 : SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLayoutInfo >& rInfo, SwPosition& rPos )
      79             : {
      80          54 :     SwLayoutStatus aRet = INVISIBLE;
      81          54 :     const SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode();
      82          54 :     SwCntntNode* pNode = rPos.nNode.GetNode().GetCntntNode();   // getfirstcontentnode // getnext...
      83          54 :     if( !pNode )
      84           0 :         return aRet;
      85          54 :     SwIterator<SwTxtFrm,SwCntntNode> aIter( *pNode );
      86         108 :     for( SwTxtFrm* pTxtFrm = aIter.First(); pTxtFrm; pTxtFrm = aIter.Next() )
      87             :     {
      88          54 :         if( !pTxtFrm->IsFollow() )
      89             :         {
      90          54 :             pTxtFrm = ((SwTxtFrm*)pTxtFrm)->GetFrmAtPos( rPos );
      91          54 :         SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0;
      92             :         // #i103490#
      93          54 :             if ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
      94             :             {
      95          46 :                 SwLayoutInfo aInfo;
      96          46 :                 pTxtFrm->GetCharRect( aInfo.mPosition, rPos, 0 );
      97          46 :                 aInfo.mpAnchorFrm = pTxtFrm;
      98          46 :                 aInfo.mPageFrame = pPage->Frm();
      99          46 :                 aInfo.mPagePrtArea = pPage->Prt();
     100          46 :                 aInfo.mPagePrtArea.Pos() += aInfo.mPageFrame.Pos();
     101          46 :                 aInfo.mnPageNumber = pPage->GetPhyPageNum();
     102          46 :                 aInfo.meSidebarPosition = pPage->SidebarPosition();
     103          46 :                 aInfo.mRedlineAuthor = 0;
     104             : 
     105          46 :                 if( aRet == INVISIBLE )
     106             :                 {
     107          46 :                     aRet = VISIBLE;
     108          46 :                     const IDocumentRedlineAccess* pIDRA = pNode->getIDocumentRedlineAccess();
     109          46 :                     if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
     110             :                     {
     111          46 :                         const SwRedline* pRedline = pIDRA->GetRedline( rPos, 0 );
     112          46 :                         if( pRedline )
     113             :                         {
     114           0 :                             if( nsRedlineType_t::REDLINE_INSERT == pRedline->GetType() )
     115           0 :                                 aRet = INSERTED;
     116           0 :                             else if( nsRedlineType_t::REDLINE_DELETE == pRedline->GetType() )
     117           0 :                                 aRet = DELETED;
     118           0 :                             aInfo.mRedlineAuthor = pRedline->GetAuthor();
     119             :                         }
     120             :                     }
     121             :                 }
     122             : 
     123             :                 {
     124             :                     std::vector< SwLayoutInfo >::iterator aInsPosIter =
     125             :                                 std::lower_bound( rInfo.begin(), rInfo.end(),
     126          46 :                                                   aInfo, LayoutInfoOrder() );
     127             : 
     128          46 :                     rInfo.insert( aInsPosIter, aInfo );
     129             :                 }
     130             :             }
     131             :         }
     132             :     }
     133          54 :     return ((aRet==VISIBLE) && SwScriptInfo::IsInHiddenRange( *pTxtNode , rPos.nContent.GetIndex()) ) ? HIDDEN : aRet;
     134             : }
     135             : 
     136        3345 : long SwPostItHelper::getLayoutHeight( const SwRootFrm* pRoot )
     137             : {
     138        3345 :     long nRet = pRoot ? pRoot->Frm().Height() : 0;
     139        3345 :     return nRet;
     140             : }
     141             : 
     142         120 : void SwPostItHelper::setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode )
     143             : {
     144         120 :     if( pRoot )
     145             :     {
     146         120 :         pRoot->SetSidebarChanged();
     147         120 :         if( bBrowseMode )
     148          75 :             pRoot->InvalidateBrowseWidth();
     149             :     }
     150         120 : }
     151             : 
     152           0 : unsigned long SwPostItHelper::getPageInfo( SwRect& rPageFrm, const SwRootFrm* pRoot, const Point& rPoint )
     153             : {
     154           0 :     unsigned long nRet = 0;
     155           0 :     const SwFrm* pPage = pRoot->GetPageAtPos( rPoint, 0, true );
     156           0 :     if( pPage )
     157             :     {
     158           0 :         nRet = pPage->GetPhyPageNum();
     159           0 :         rPageFrm = pPage->Frm();
     160             :     }
     161           0 :     return nRet;
     162             : }
     163             : 
     164          54 : SwPosition SwAnnotationItem::GetAnchorPosition() const
     165             : {
     166          54 :     SwTxtFld* pFld = pFmtFld->GetTxtFld();
     167          54 :     SwTxtNode* pTNd = pFld->GetpTxtNode();
     168             : 
     169          54 :     SwPosition aPos( *pTNd );
     170          54 :     aPos.nContent.Assign( pTNd, *pFld->GetStart() );
     171          54 :     return aPos;
     172             : }
     173             : 
     174          54 : bool SwAnnotationItem::UseElement()
     175             : {
     176          54 :     return pFmtFld->IsFldInDoc();
     177             : }
     178             : 
     179           9 : sw::sidebarwindows::SwSidebarWin* SwAnnotationItem::GetSidebarWindow(
     180             :                                                             SwEditWin& rEditWin,
     181             :                                                             WinBits nBits,
     182             :                                                             SwPostItMgr& aMgr,
     183             :                                                             SwPostItBits aBits)
     184             : {
     185             :     return new sw::annotation::SwAnnotationWin( rEditWin, nBits,
     186             :                                                 aMgr, aBits,
     187             :                                                 *this,
     188           9 :                                                 pFmtFld );
     189          99 : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10