LCOV - code coverage report
Current view: top level - editeng/source/accessibility - AccessibleStringWrap.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 26 0.0 %
Date: 2014-04-14 Functions: 0 3 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             : 
      21             : #include <algorithm>
      22             : #include <tools/debug.hxx>
      23             : #include <vcl/outdev.hxx>
      24             : 
      25             : #include <editeng/svxfont.hxx>
      26             : #include <editeng/AccessibleStringWrap.hxx>
      27             : 
      28             : 
      29             : 
      30             : // AccessibleStringWrap implementation
      31             : 
      32             : 
      33             : 
      34           0 : AccessibleStringWrap::AccessibleStringWrap( OutputDevice& rDev, SvxFont& rFont, const OUString& rText ) :
      35             :     mrDev( rDev ),
      36             :     mrFont( rFont ),
      37           0 :     maText( rText )
      38             : {
      39           0 : }
      40             : 
      41           0 : void AccessibleStringWrap::GetCharacterBounds( sal_Int32 nIndex, Rectangle& rRect )
      42             : {
      43             :     DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
      44             :                "SvxAccessibleStringWrap::GetCharacterBounds: index value overflow");
      45             : 
      46           0 :     mrFont.SetPhysFont( &mrDev );
      47             : 
      48             :     // #108900# Handle virtual position one-past-the end of the string
      49           0 :     if( nIndex >= maText.getLength() )
      50             :     {
      51             :         // create a caret bounding rect that has the height of the
      52             :         // current font and is one pixel wide.
      53           0 :         rRect.Left() = mrDev.GetTextWidth(maText);
      54           0 :         rRect.Top() = 0;
      55           0 :         rRect.SetSize( Size(mrDev.GetTextHeight(), 1) );
      56             :     }
      57             :     else
      58             :     {
      59             :         sal_Int32 aXArray[2];
      60           0 :         mrDev.GetCaretPositions( maText, aXArray, static_cast< sal_uInt16 >(nIndex), 1 );
      61           0 :         rRect.Left() = 0;
      62           0 :         rRect.Top() = 0;
      63           0 :         rRect.SetSize( Size(mrDev.GetTextHeight(), labs(aXArray[0] - aXArray[1])) );
      64           0 :         rRect.Move( ::std::min(aXArray[0], aXArray[1]), 0 );
      65             :     }
      66             : 
      67           0 :     if( mrFont.IsVertical() )
      68             :     {
      69             :         // #101701# Rotate to vertical
      70           0 :         rRect = Rectangle( Point(-rRect.Top(), rRect.Left()),
      71           0 :                            Point(-rRect.Bottom(), rRect.Right()));
      72             :     }
      73           0 : }
      74             : 
      75           0 : sal_Int32 AccessibleStringWrap::GetIndexAtPoint( const Point& rPoint )
      76             : {
      77             :     // search for character bounding box containing given point
      78           0 :     Rectangle aRect;
      79           0 :     sal_Int32 i, nLen = maText.getLength();
      80           0 :     for( i=0; i<nLen; ++i )
      81             :     {
      82           0 :         GetCharacterBounds(i, aRect);
      83           0 :         if( aRect.IsInside(rPoint) )
      84           0 :             return i;
      85             :     }
      86             : 
      87           0 :     return -1;
      88             : }
      89             : 
      90             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10