LCOV - code coverage report
Current view: top level - sw/source/core/fields - postithelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 0.0 %
Date: 2014-04-14 Functions: 0 7 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             : #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             :     bool operator()( const SwLayoutInfo& rLayoutInfo,
      46             :                      const SwLayoutInfo& rNewLayoutInfo )
      47             :     {
      48             :         if ( rLayoutInfo.mnPageNumber != rNewLayoutInfo.mnPageNumber )
      49             :         {
      50             :             // corresponding <SwFrm> instances are on different pages
      51             :             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             :             const SwTabFrm* pLayoutInfoTabFrm( rLayoutInfo.mpAnchorFrm->FindTabFrm() );
      61             :             const SwTabFrm* pNewLayoutInfoTabFrm( rNewLayoutInfo.mpAnchorFrm->FindTabFrm() );
      62             :             const SwTabFrm* pTmpTabFrm( pNewLayoutInfoTabFrm );
      63             :             while ( pTmpTabFrm && pTmpTabFrm->GetFollow() )
      64             :             {
      65             :                 pTmpTabFrm = static_cast<const SwTabFrm*>(pTmpTabFrm->GetFollow()->GetFrm());
      66             :                 if ( pTmpTabFrm == pLayoutInfoTabFrm )
      67             :                 {
      68             :                     return false;
      69             :                 }
      70             :             }
      71             :             return true;
      72             :         }
      73             :     }
      74             : };
      75             : 
      76             : } // eof anonymous namespace
      77             : 
      78           0 : SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos(
      79             :     SwLayoutInfo& o_rInfo,
      80             :     const SwPosition& rAnchorPos,
      81             :     const SwPosition* pAnnotationStartPos )
      82             : {
      83           0 :     SwLayoutStatus aRet = INVISIBLE;
      84           0 :     SwTxtNode* pTxtNode = rAnchorPos.nNode.GetNode().GetTxtNode();
      85           0 :     if ( pTxtNode == NULL )
      86           0 :         return aRet;
      87             : 
      88           0 :     SwIterator<SwTxtFrm,SwCntntNode> aIter( *pTxtNode );
      89           0 :     for( SwTxtFrm* pTxtFrm = aIter.First(); pTxtFrm != NULL; pTxtFrm = aIter.Next() )
      90             :     {
      91           0 :         if( !pTxtFrm->IsFollow() )
      92             :         {
      93           0 :             pTxtFrm = pTxtFrm->GetFrmAtPos( rAnchorPos );
      94           0 :             SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0;
      95           0 :             if ( pPage != NULL && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
      96             :             {
      97           0 :                 aRet = VISIBLE;
      98             : 
      99           0 :                 o_rInfo.mpAnchorFrm = pTxtFrm;
     100           0 :                 pTxtFrm->GetCharRect( o_rInfo.mPosition, rAnchorPos, 0 );
     101           0 :                 if ( pAnnotationStartPos != NULL )
     102             :                 {
     103           0 :                     o_rInfo.mnStartNodeIdx = pAnnotationStartPos->nNode.GetIndex();
     104           0 :                     o_rInfo.mnStartContent = pAnnotationStartPos->nContent.GetIndex();
     105             :                 }
     106             :                 else
     107             :                 {
     108           0 :                     o_rInfo.mnStartNodeIdx = 0;
     109           0 :                     o_rInfo.mnStartContent = -1;
     110             :                 }
     111           0 :                 o_rInfo.mPageFrame = pPage->Frm();
     112           0 :                 o_rInfo.mPagePrtArea = pPage->Prt();
     113           0 :                 o_rInfo.mPagePrtArea.Pos() += o_rInfo.mPageFrame.Pos();
     114           0 :                 o_rInfo.mnPageNumber = pPage->GetPhyPageNum();
     115           0 :                 o_rInfo.meSidebarPosition = pPage->SidebarPosition();
     116           0 :                 o_rInfo.mRedlineAuthor = 0;
     117             : 
     118           0 :                 const IDocumentRedlineAccess* pIDRA = pTxtNode->getIDocumentRedlineAccess();
     119           0 :                 if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
     120             :                 {
     121           0 :                     const SwRangeRedline* pRedline = pIDRA->GetRedline( rAnchorPos, 0 );
     122           0 :                     if( pRedline )
     123             :                     {
     124           0 :                         if( nsRedlineType_t::REDLINE_INSERT == pRedline->GetType() )
     125           0 :                             aRet = INSERTED;
     126           0 :                         else if( nsRedlineType_t::REDLINE_DELETE == pRedline->GetType() )
     127           0 :                             aRet = DELETED;
     128           0 :                         o_rInfo.mRedlineAuthor = pRedline->GetAuthor();
     129             :                     }
     130             :                 }
     131             :             }
     132             :         }
     133             :     }
     134             : 
     135           0 :     return ( (aRet==VISIBLE) && SwScriptInfo::IsInHiddenRange( *pTxtNode , rAnchorPos.nContent.GetIndex()) )
     136             :              ? HIDDEN
     137           0 :              : aRet;
     138             : }
     139             : 
     140           0 : long SwPostItHelper::getLayoutHeight( const SwRootFrm* pRoot )
     141             : {
     142           0 :     long nRet = pRoot ? pRoot->Frm().Height() : 0;
     143           0 :     return nRet;
     144             : }
     145             : 
     146           0 : void SwPostItHelper::setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode )
     147             : {
     148           0 :     if( pRoot )
     149             :     {
     150           0 :         pRoot->SetSidebarChanged();
     151           0 :         if( bBrowseMode )
     152           0 :             pRoot->InvalidateBrowseWidth();
     153             :     }
     154           0 : }
     155             : 
     156           0 : unsigned long SwPostItHelper::getPageInfo( SwRect& rPageFrm, const SwRootFrm* pRoot, const Point& rPoint )
     157             : {
     158           0 :     unsigned long nRet = 0;
     159           0 :     const SwFrm* pPage = pRoot->GetPageAtPos( rPoint, 0, true );
     160           0 :     if( pPage )
     161             :     {
     162           0 :         nRet = pPage->GetPhyPageNum();
     163           0 :         rPageFrm = pPage->Frm();
     164             :     }
     165           0 :     return nRet;
     166             : }
     167             : 
     168           0 : SwPosition SwAnnotationItem::GetAnchorPosition() const
     169             : {
     170           0 :     SwTxtFld* pTxtFld = mrFmtFld.GetTxtFld();
     171           0 :     SwTxtNode* pTxtNode = pTxtFld->GetpTxtNode();
     172             : 
     173           0 :     SwPosition aPos( *pTxtNode );
     174           0 :     aPos.nContent.Assign( pTxtNode, *(pTxtFld->GetStart()) );
     175           0 :     return aPos;
     176             : }
     177             : 
     178           0 : bool SwAnnotationItem::UseElement()
     179             : {
     180           0 :     return mrFmtFld.IsFldInDoc();
     181             : }
     182             : 
     183           0 : sw::sidebarwindows::SwSidebarWin* SwAnnotationItem::GetSidebarWindow(
     184             :                                                             SwEditWin& rEditWin,
     185             :                                                             WinBits nBits,
     186             :                                                             SwPostItMgr& aMgr,
     187             :                                                             SwPostItBits aBits)
     188             : {
     189             :     return new sw::annotation::SwAnnotationWin( rEditWin, nBits,
     190             :                                                 aMgr, aBits,
     191             :                                                 *this,
     192           0 :                                                 &mrFmtFld );
     193             : }
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10