LCOV - code coverage report
Current view: top level - accessibility/source/extended - textwindowaccessibility.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 963 0.0 %
Date: 2012-08-25 Functions: 0 120 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1567 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <accessibility/extended/textwindowaccessibility.hxx>
      31                 :            : #include "comphelper/accessibleeventnotifier.hxx"
      32                 :            : #include "unotools/accessiblerelationsethelper.hxx"
      33                 :            : #include <unotools/accessiblestatesethelper.hxx>
      34                 :            : #include <vcl/window.hxx>
      35                 :            : #include <toolkit/helper/convert.hxx>
      36                 :            : 
      37                 :            : #include <algorithm>
      38                 :            : #include <vector>
      39                 :            : #include <boost/unordered_map.hpp>
      40                 :            : 
      41                 :            : namespace css = ::com::sun::star;
      42                 :            : 
      43                 :            : namespace accessibility
      44                 :            : {
      45                 :            : 
      46                 :            : // Both ::osl::Mutex and ParagraphBase implement acquire and release, and thus
      47                 :            : // ::rtl::Reference< Paragraph > does not work.  So ParagraphImpl was factored
      48                 :            : // out and ::rtl::Reference< ParagraphImpl > is used instead.
      49 [ #  # ][ #  # ]:          0 : class Paragraph: private ::osl::Mutex, public ParagraphImpl
      50                 :            : {
      51                 :            : public:
      52                 :          0 :     inline Paragraph(::rtl::Reference< Document > const & rDocument,
      53                 :            :                      Paragraphs::size_type nNumber):
      54         [ #  # ]:          0 :         ParagraphImpl(rDocument, nNumber, *this) {}
      55                 :            : };
      56                 :            : 
      57                 :          0 : void SfxListenerGuard::startListening(::SfxBroadcaster & rNotifier)
      58                 :            : {
      59                 :            :     OSL_ENSURE(m_pNotifier == 0, "called more than once");
      60                 :          0 :     m_pNotifier = &rNotifier;
      61                 :          0 :     m_rListener.StartListening(*m_pNotifier, true);
      62                 :          0 : }
      63                 :            : 
      64                 :          0 : void SfxListenerGuard::endListening()
      65                 :            : {
      66         [ #  # ]:          0 :     if (m_pNotifier != 0)
      67                 :            :     {
      68                 :          0 :         m_rListener.EndListening(*m_pNotifier);
      69                 :          0 :         m_pNotifier = 0;
      70                 :            :     }
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : void WindowListenerGuard::startListening(::Window & rNotifier)
      74                 :            : {
      75                 :            :     OSL_ENSURE(m_pNotifier == 0, "called more than once");
      76                 :          0 :     m_pNotifier = &rNotifier;
      77                 :          0 :     m_pNotifier->AddEventListener(m_aListener);
      78                 :          0 : }
      79                 :            : 
      80                 :          0 : void WindowListenerGuard::endListening()
      81                 :            : {
      82         [ #  # ]:          0 :     if (m_pNotifier != 0)
      83                 :            :     {
      84                 :          0 :         m_pNotifier->RemoveEventListener(m_aListener);
      85                 :          0 :         m_pNotifier = 0;
      86                 :            :     }
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : ParagraphImpl::ParagraphImpl(::rtl::Reference< Document > const & rDocument,
      90                 :            :                              Paragraphs::size_type nNumber,
      91                 :            :                              ::osl::Mutex & rMutex):
      92                 :            :     ParagraphBase(rMutex),
      93                 :            :     m_xDocument(rDocument),
      94                 :            :     m_nNumber(nNumber),
      95         [ #  # ]:          0 :     m_nClientId(0)
      96                 :            : {
      97         [ #  # ]:          0 :     m_aParagraphText = m_xDocument->retrieveParagraphText(this);
      98                 :          0 : }
      99                 :            : 
     100                 :            : void
     101                 :          0 : ParagraphImpl::numberChanged(bool bIncremented)
     102                 :            : {
     103         [ #  # ]:          0 :     if (bIncremented)
     104                 :          0 :         ++m_nNumber;
     105                 :            :     else
     106                 :          0 :         --m_nNumber;
     107                 :          0 : }
     108                 :            : 
     109                 :          0 : void ParagraphImpl::textChanged()
     110                 :            : {
     111         [ #  # ]:          0 :     ::rtl::OUString aParagraphText = implGetText();
     112                 :          0 :     ::css::uno::Any aOldValue, aNewValue;
     113 [ #  # ][ #  # ]:          0 :     if ( implInitTextChangedEvent( m_aParagraphText, aParagraphText, aOldValue, aNewValue ) )
     114                 :            :     {
     115                 :          0 :         m_aParagraphText = aParagraphText;
     116                 :            :         notifyEvent(::css::accessibility::AccessibleEventId::
     117                 :            :                     TEXT_CHANGED,
     118         [ #  # ]:          0 :                     aOldValue, aNewValue);
     119                 :          0 :     }
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : void ParagraphImpl::notifyEvent(::sal_Int16 nEventId,
     123                 :            :                                 ::css::uno::Any const & rOldValue,
     124                 :            :                                 ::css::uno::Any const & rNewValue)
     125                 :            : {
     126         [ #  # ]:          0 :     if (m_nClientId)
     127                 :            :         comphelper::AccessibleEventNotifier::addEvent( m_nClientId, ::css::accessibility::AccessibleEventObject(
     128                 :            :                              static_cast< ::cppu::OWeakObject * >(this),
     129 [ #  # ][ #  # ]:          0 :                              nEventId, rNewValue, rOldValue) );
                 [ #  # ]
     130                 :          0 : }
     131                 :            : 
     132                 :            : // virtual
     133                 :            : ::css::uno::Reference< ::css::accessibility::XAccessibleContext > SAL_CALL
     134                 :          0 : ParagraphImpl::getAccessibleContext() throw (::css::uno::RuntimeException)
     135                 :            : {
     136                 :          0 :     checkDisposed();
     137                 :          0 :     return this;
     138                 :            : }
     139                 :            : 
     140                 :            : // virtual
     141                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getAccessibleChildCount()
     142                 :            :     throw (::css::uno::RuntimeException)
     143                 :            : {
     144                 :          0 :     checkDisposed();
     145                 :          0 :     return 0;
     146                 :            : }
     147                 :            : 
     148                 :            : // virtual
     149                 :            : ::css::uno::Reference< ::css::accessibility::XAccessible > SAL_CALL
     150                 :          0 : ParagraphImpl::getAccessibleChild(::sal_Int32)
     151                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     152                 :            :            ::css::uno::RuntimeException)
     153                 :            : {
     154                 :          0 :     checkDisposed();
     155                 :            :     throw ::css::lang::IndexOutOfBoundsException(
     156                 :            :         ::rtl::OUString(
     157                 :            :             RTL_CONSTASCII_USTRINGPARAM(
     158                 :            :                 "textwindowaccessibility.cxx:"
     159                 :            :                 " ParagraphImpl::getAccessibleChild")),
     160 [ #  # ][ #  # ]:          0 :         static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
     161                 :            : }
     162                 :            : 
     163                 :            : // virtual
     164                 :            : ::css::uno::Reference< ::css::accessibility::XAccessible > SAL_CALL
     165                 :          0 : ParagraphImpl::getAccessibleParent()
     166                 :            :     throw (::css::uno::RuntimeException)
     167                 :            : {
     168                 :          0 :     checkDisposed();
     169                 :          0 :     return m_xDocument->getAccessible();
     170                 :            : }
     171                 :            : 
     172                 :            : // virtual
     173                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getAccessibleIndexInParent()
     174                 :            :     throw (::css::uno::RuntimeException)
     175                 :            : {
     176                 :          0 :     checkDisposed();
     177                 :          0 :     return m_xDocument->retrieveParagraphIndex(this);
     178                 :            : }
     179                 :            : 
     180                 :            : // virtual
     181                 :          0 : ::sal_Int16 SAL_CALL ParagraphImpl::getAccessibleRole()
     182                 :            :     throw (::css::uno::RuntimeException)
     183                 :            : {
     184                 :          0 :     checkDisposed();
     185                 :          0 :     return ::css::accessibility::AccessibleRole::PARAGRAPH;
     186                 :            : }
     187                 :            : 
     188                 :            : // virtual
     189                 :          0 : ::rtl::OUString SAL_CALL ParagraphImpl::getAccessibleDescription()
     190                 :            :     throw (::css::uno::RuntimeException)
     191                 :            : {
     192                 :          0 :     checkDisposed();
     193                 :          0 :     return ::rtl::OUString();
     194                 :            : }
     195                 :            : 
     196                 :            : // virtual
     197                 :          0 : ::rtl::OUString SAL_CALL ParagraphImpl::getAccessibleName()
     198                 :            :     throw (::css::uno::RuntimeException)
     199                 :            : {
     200                 :          0 :     checkDisposed();
     201                 :          0 :     return ::rtl::OUString();
     202                 :            : }
     203                 :            : 
     204                 :            : // virtual
     205                 :            : ::css::uno::Reference< ::css::accessibility::XAccessibleRelationSet >
     206                 :          0 : SAL_CALL ParagraphImpl::getAccessibleRelationSet()
     207                 :            :     throw (::css::uno::RuntimeException)
     208                 :            : {
     209                 :          0 :     checkDisposed();
     210                 :          0 :     return m_xDocument->retrieveParagraphRelationSet( this );
     211                 :            : }
     212                 :            : 
     213                 :            : // virtual
     214                 :            : ::css::uno::Reference< ::css::accessibility::XAccessibleStateSet >
     215                 :          0 : SAL_CALL ParagraphImpl::getAccessibleStateSet()
     216                 :            :     throw (::css::uno::RuntimeException)
     217                 :            : {
     218                 :          0 :     checkDisposed();
     219                 :            : 
     220                 :            :     // FIXME  Notification of changes (STATE_CHANGED) missing when
     221                 :            :     // m_rView.IsReadOnly() changes:
     222                 :            :     return new ::utl::AccessibleStateSetHelper(
     223 [ #  # ][ #  # ]:          0 :         m_xDocument->retrieveParagraphState(this));
     224                 :            : }
     225                 :            : 
     226                 :            : // virtual
     227                 :          0 : ::css::lang::Locale SAL_CALL ParagraphImpl::getLocale()
     228                 :            :     throw (::css::accessibility::IllegalAccessibleComponentStateException,
     229                 :            :            ::css::uno::RuntimeException)
     230                 :            : {
     231                 :          0 :     checkDisposed();
     232                 :          0 :     return m_xDocument->retrieveLocale();
     233                 :            : }
     234                 :            : 
     235                 :            : // virtual
     236                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::containsPoint(::css::awt::Point const & rPoint)
     237                 :            :     throw (::css::uno::RuntimeException)
     238                 :            : {
     239         [ #  # ]:          0 :     checkDisposed();
     240                 :            :     ::css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this,
     241         [ #  # ]:          0 :                                                                      false));
     242                 :            :     return rPoint.X >= 0 && rPoint.X < aRect.Width
     243 [ #  # ][ #  # ]:          0 :         && rPoint.Y >= 0 && rPoint.Y < aRect.Height;
         [ #  # ][ #  # ]
     244                 :            : }
     245                 :            : 
     246                 :            : // virtual
     247                 :            : ::css::uno::Reference< ::css::accessibility::XAccessible > SAL_CALL
     248                 :          0 : ParagraphImpl::getAccessibleAtPoint(::css::awt::Point const &)
     249                 :            :     throw (::css::uno::RuntimeException)
     250                 :            : {
     251                 :          0 :     checkDisposed();
     252                 :          0 :     return 0;
     253                 :            : }
     254                 :            : 
     255                 :            : // virtual
     256                 :          0 : ::css::awt::Rectangle SAL_CALL ParagraphImpl::getBounds()
     257                 :            :     throw (::css::uno::RuntimeException)
     258                 :            : {
     259                 :          0 :     checkDisposed();
     260                 :          0 :     return m_xDocument->retrieveParagraphBounds(this, false);
     261                 :            : }
     262                 :            : 
     263                 :            : // virtual
     264                 :          0 : ::css::awt::Point SAL_CALL ParagraphImpl::getLocation()
     265                 :            :     throw (::css::uno::RuntimeException)
     266                 :            : {
     267         [ #  # ]:          0 :     checkDisposed();
     268                 :            :     ::css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this,
     269         [ #  # ]:          0 :                                                                      false));
     270                 :          0 :     return ::css::awt::Point(aRect.X, aRect.Y);
     271                 :            : }
     272                 :            : 
     273                 :            : // virtual
     274                 :          0 : ::css::awt::Point SAL_CALL ParagraphImpl::getLocationOnScreen()
     275                 :            :     throw (::css::uno::RuntimeException)
     276                 :            : {
     277         [ #  # ]:          0 :     checkDisposed();
     278                 :            :     ::css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this,
     279         [ #  # ]:          0 :                                                                      true));
     280                 :          0 :     return ::css::awt::Point(aRect.X, aRect.Y);
     281                 :            : }
     282                 :            : 
     283                 :            : // virtual
     284                 :          0 : ::css::awt::Size SAL_CALL ParagraphImpl::getSize()
     285                 :            :     throw (::css::uno::RuntimeException)
     286                 :            : {
     287         [ #  # ]:          0 :     checkDisposed();
     288                 :            :     ::css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this,
     289         [ #  # ]:          0 :                                                                      false));
     290                 :          0 :     return ::css::awt::Size(aRect.Width, aRect.Height);
     291                 :            : }
     292                 :            : 
     293                 :            : // virtual
     294                 :          0 : void SAL_CALL ParagraphImpl::grabFocus() throw (::css::uno::RuntimeException)
     295                 :            : {
     296                 :          0 :     checkDisposed();
     297                 :          0 :     Window* pWindow = m_xDocument->GetWindow();
     298         [ #  # ]:          0 :     if ( pWindow )
     299                 :            :     {
     300                 :          0 :         pWindow->GrabFocus();
     301                 :            :     }
     302                 :            :     try
     303                 :            :     {
     304         [ #  # ]:          0 :         m_xDocument->changeParagraphSelection(this, 0, 0);
     305                 :            :     }
     306                 :          0 :     catch (const ::css::lang::IndexOutOfBoundsException & rEx)
     307                 :            :     {
     308                 :            :         OSL_TRACE(
     309                 :            :             "textwindowaccessibility.cxx: ParagraphImpl::grabFocus:"
     310                 :            :             " caught unexpected %s\n",
     311                 :            :             ::rtl::OUStringToOString(rEx.Message, RTL_TEXTENCODING_UTF8).
     312                 :            :             getStr());
     313                 :            :     }
     314         [ #  # ]:          0 : }
     315                 :            : 
     316                 :            : // virtual
     317                 :          0 : ::css::uno::Any SAL_CALL ParagraphImpl::getAccessibleKeyBinding()
     318                 :            :     throw (::css::uno::RuntimeException)
     319                 :            : {
     320                 :          0 :     checkDisposed();
     321                 :          0 :     return ::css::uno::Any();
     322                 :            : }
     323                 :            : 
     324                 :            : // virtual
     325                 :          0 : ::css::util::Color SAL_CALL ParagraphImpl::getForeground()
     326                 :            :     throw (::css::uno::RuntimeException)
     327                 :            : {
     328                 :          0 :     return 0; // TODO
     329                 :            : }
     330                 :            : 
     331                 :            : // virtual
     332                 :          0 : ::css::util::Color SAL_CALL ParagraphImpl::getBackground()
     333                 :            :     throw (::css::uno::RuntimeException)
     334                 :            : {
     335                 :          0 :     return 0; // TODO
     336                 :            : }
     337                 :            : 
     338                 :            : // virtual
     339                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getCaretPosition()
     340                 :            :     throw (::css::uno::RuntimeException)
     341                 :            : {
     342                 :          0 :     checkDisposed();
     343                 :          0 :     return m_xDocument->retrieveParagraphCaretPosition(this);
     344                 :            : }
     345                 :            : 
     346                 :            : // virtual
     347                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::setCaretPosition(::sal_Int32 nIndex)
     348                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     349                 :            :            ::css::uno::RuntimeException)
     350                 :            : {
     351                 :          0 :     checkDisposed();
     352                 :          0 :     m_xDocument->changeParagraphSelection(this, nIndex, nIndex);
     353                 :          0 :     return true;
     354                 :            : }
     355                 :            : 
     356                 :            : // virtual
     357                 :          0 : ::sal_Unicode SAL_CALL ParagraphImpl::getCharacter(::sal_Int32 nIndex)
     358                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     359                 :            :            ::css::uno::RuntimeException)
     360                 :            : {
     361                 :          0 :     checkDisposed();
     362                 :          0 :     return OCommonAccessibleText::getCharacter(nIndex);
     363                 :            : }
     364                 :            : 
     365                 :            : // virtual
     366                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue > SAL_CALL
     367                 :          0 : ParagraphImpl::getCharacterAttributes(::sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes)
     368                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     369                 :            :            ::css::uno::RuntimeException)
     370                 :            : {
     371                 :          0 :     checkDisposed();
     372                 :          0 :     return m_xDocument->retrieveCharacterAttributes( this, nIndex, aRequestedAttributes );
     373                 :            : }
     374                 :            : 
     375                 :            : // virtual
     376                 :            : ::css::awt::Rectangle SAL_CALL
     377                 :          0 : ParagraphImpl::getCharacterBounds(::sal_Int32 nIndex)
     378                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     379                 :            :            ::css::uno::RuntimeException)
     380                 :            : {
     381         [ #  # ]:          0 :     checkDisposed();
     382         [ #  # ]:          0 :     ::css::awt::Rectangle aBounds(m_xDocument->retrieveCharacterBounds(this, nIndex));
     383         [ #  # ]:          0 :     ::css::awt::Rectangle aParaBounds(m_xDocument->retrieveParagraphBounds(this, false));
     384                 :          0 :     aBounds.X -= aParaBounds.X;
     385                 :          0 :     aBounds.Y -= aParaBounds.Y;
     386                 :          0 :     return aBounds;
     387                 :            : }
     388                 :            : 
     389                 :            : // virtual
     390                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getCharacterCount()
     391                 :            :     throw (::css::uno::RuntimeException)
     392                 :            : {
     393                 :          0 :     checkDisposed();
     394                 :          0 :     return OCommonAccessibleText::getCharacterCount();
     395                 :            : }
     396                 :            : 
     397                 :            : // virtual
     398                 :            : ::sal_Int32 SAL_CALL
     399                 :          0 : ParagraphImpl::getIndexAtPoint(::css::awt::Point const & rPoint)
     400                 :            :     throw (::css::uno::RuntimeException)
     401                 :            : {
     402         [ #  # ]:          0 :     checkDisposed();
     403                 :          0 :     ::css::awt::Point aPoint(rPoint);
     404         [ #  # ]:          0 :     ::css::awt::Rectangle aParaBounds(m_xDocument->retrieveParagraphBounds(this, false));
     405                 :          0 :     aPoint.X += aParaBounds.X;
     406                 :          0 :     aPoint.Y += aParaBounds.Y;
     407         [ #  # ]:          0 :     return m_xDocument->retrieveCharacterIndex(this, aPoint);
     408                 :            : }
     409                 :            : 
     410                 :            : // virtual
     411                 :          0 : ::rtl::OUString SAL_CALL ParagraphImpl::getSelectedText()
     412                 :            :     throw (::css::uno::RuntimeException)
     413                 :            : {
     414                 :          0 :     checkDisposed();
     415                 :            : 
     416                 :          0 :     return OCommonAccessibleText::getSelectedText();
     417                 :            : }
     418                 :            : 
     419                 :            : // virtual
     420                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getSelectionStart()
     421                 :            :     throw (::css::uno::RuntimeException)
     422                 :            : {
     423                 :          0 :     checkDisposed();
     424                 :          0 :     return OCommonAccessibleText::getSelectionStart();
     425                 :            : }
     426                 :            : 
     427                 :            : // virtual
     428                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getSelectionEnd()
     429                 :            :     throw (::css::uno::RuntimeException)
     430                 :            : {
     431                 :          0 :     checkDisposed();
     432                 :          0 :     return OCommonAccessibleText::getSelectionEnd();
     433                 :            : }
     434                 :            : 
     435                 :            : // virtual
     436                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::setSelection(::sal_Int32 nStartIndex,
     437                 :            :                                                 ::sal_Int32 nEndIndex)
     438                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     439                 :            :            ::css::uno::RuntimeException)
     440                 :            : {
     441                 :          0 :     checkDisposed();
     442                 :          0 :     m_xDocument->changeParagraphSelection(this, nStartIndex, nEndIndex);
     443                 :          0 :     return true;
     444                 :            : }
     445                 :            : 
     446                 :            : // virtual
     447                 :          0 : ::rtl::OUString SAL_CALL ParagraphImpl::getText()
     448                 :            :     throw (::css::uno::RuntimeException)
     449                 :            : {
     450                 :          0 :     checkDisposed();
     451                 :          0 :     return OCommonAccessibleText::getText();
     452                 :            : }
     453                 :            : 
     454                 :            : // virtual
     455                 :          0 : ::rtl::OUString SAL_CALL ParagraphImpl::getTextRange(::sal_Int32 nStartIndex,
     456                 :            :                                                      ::sal_Int32 nEndIndex)
     457                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     458                 :            :            ::css::uno::RuntimeException)
     459                 :            : {
     460                 :          0 :     checkDisposed();
     461                 :          0 :     return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex);
     462                 :            : }
     463                 :            : 
     464                 :            : // virtual
     465                 :          0 : ::com::sun::star::accessibility::TextSegment SAL_CALL ParagraphImpl::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     466                 :            : {
     467                 :          0 :     checkDisposed();
     468                 :          0 :     return OCommonAccessibleText::getTextAtIndex(nIndex, aTextType);
     469                 :            : }
     470                 :            : 
     471                 :            : // virtual
     472                 :          0 : ::com::sun::star::accessibility::TextSegment SAL_CALL ParagraphImpl::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     473                 :            : {
     474                 :          0 :     checkDisposed();
     475                 :          0 :     return OCommonAccessibleText::getTextBeforeIndex(nIndex, aTextType);
     476                 :            : }
     477                 :            : 
     478                 :            : // virtual
     479                 :          0 : ::com::sun::star::accessibility::TextSegment SAL_CALL ParagraphImpl::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     480                 :            : {
     481                 :          0 :     checkDisposed();
     482                 :          0 :     return OCommonAccessibleText::getTextBehindIndex(nIndex, aTextType);
     483                 :            : }
     484                 :            : 
     485                 :            : // virtual
     486                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::copyText(::sal_Int32 nStartIndex,
     487                 :            :                                             ::sal_Int32 nEndIndex)
     488                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     489                 :            :            ::css::uno::RuntimeException)
     490                 :            : {
     491                 :          0 :     checkDisposed();
     492                 :          0 :     m_xDocument->copyParagraphText(this, nStartIndex, nEndIndex);
     493                 :          0 :     return true;
     494                 :            : }
     495                 :            : 
     496                 :            : // virtual
     497                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::cutText(::sal_Int32 nStartIndex,
     498                 :            :                                            ::sal_Int32 nEndIndex)
     499                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     500                 :            :            ::css::uno::RuntimeException)
     501                 :            : {
     502                 :          0 :     checkDisposed();
     503                 :            :     m_xDocument->changeParagraphText(this, nStartIndex, nEndIndex, true, false,
     504         [ #  # ]:          0 :                                      ::rtl::OUString());
     505                 :          0 :     return true;
     506                 :            : }
     507                 :            : 
     508                 :            : // virtual
     509                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::pasteText(::sal_Int32 nIndex)
     510                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     511                 :            :            ::css::uno::RuntimeException)
     512                 :            : {
     513                 :          0 :     checkDisposed();
     514                 :            :     m_xDocument->changeParagraphText(this, nIndex, nIndex, false, true,
     515         [ #  # ]:          0 :                                      ::rtl::OUString());
     516                 :          0 :     return true;
     517                 :            : }
     518                 :            : 
     519                 :            : // virtual
     520                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::deleteText(::sal_Int32 nStartIndex,
     521                 :            :                                           ::sal_Int32 nEndIndex)
     522                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     523                 :            :            ::css::uno::RuntimeException)
     524                 :            : {
     525                 :          0 :     checkDisposed();
     526                 :            :     m_xDocument->changeParagraphText(this, nStartIndex, nEndIndex, false, false,
     527         [ #  # ]:          0 :                                      ::rtl::OUString());
     528                 :          0 :     return true;
     529                 :            : }
     530                 :            : 
     531                 :            : // virtual
     532                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::insertText(::rtl::OUString const & rText,
     533                 :            :                                               ::sal_Int32 nIndex)
     534                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     535                 :            :            ::css::uno::RuntimeException)
     536                 :            : {
     537                 :          0 :     checkDisposed();
     538                 :          0 :     m_xDocument->changeParagraphText(this, nIndex, nIndex, false, false, rText);
     539                 :          0 :     return true;
     540                 :            : }
     541                 :            : 
     542                 :            : // virtual
     543                 :            : ::sal_Bool SAL_CALL
     544                 :          0 : ParagraphImpl::replaceText(::sal_Int32 nStartIndex, ::sal_Int32 nEndIndex,
     545                 :            :                            ::rtl::OUString const & rReplacement)
     546                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     547                 :            :            ::css::uno::RuntimeException)
     548                 :            : {
     549                 :          0 :     checkDisposed();
     550                 :            :     m_xDocument->changeParagraphText(this, nStartIndex, nEndIndex, false, false,
     551                 :          0 :                                      rReplacement);
     552                 :          0 :     return true;
     553                 :            : }
     554                 :            : 
     555                 :            : // virtual
     556                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::setAttributes(
     557                 :            :     ::sal_Int32 nStartIndex, ::sal_Int32 nEndIndex,
     558                 :            :     ::css::uno::Sequence< ::css::beans::PropertyValue > const & rAttributeSet)
     559                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     560                 :            :            ::css::uno::RuntimeException)
     561                 :            : {
     562                 :          0 :     checkDisposed();
     563                 :            :     m_xDocument->changeParagraphAttributes(this, nStartIndex, nEndIndex,
     564                 :          0 :                                            rAttributeSet);
     565                 :          0 :     return true;
     566                 :            : }
     567                 :            : 
     568                 :            : // virtual
     569                 :          0 : ::sal_Bool SAL_CALL ParagraphImpl::setText(::rtl::OUString const & rText)
     570                 :            :     throw (::css::uno::RuntimeException)
     571                 :            : {
     572                 :          0 :     checkDisposed();
     573                 :          0 :     m_xDocument->changeParagraphText(this, rText);
     574                 :          0 :     return true;
     575                 :            : }
     576                 :            : 
     577                 :            : // virtual
     578                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue > SAL_CALL
     579                 :          0 : ParagraphImpl::getDefaultAttributes(const ::css::uno::Sequence< ::rtl::OUString >& RequestedAttributes)
     580                 :            :     throw (::css::uno::RuntimeException)
     581                 :            : {
     582                 :          0 :     checkDisposed();
     583                 :          0 :     return m_xDocument->retrieveDefaultAttributes( this, RequestedAttributes );
     584                 :            : }
     585                 :            : 
     586                 :            : // virtual
     587                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue > SAL_CALL
     588                 :          0 : ParagraphImpl::getRunAttributes(::sal_Int32 Index, const ::css::uno::Sequence< ::rtl::OUString >& RequestedAttributes)
     589                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     590                 :            :            ::css::uno::RuntimeException)
     591                 :            : {
     592                 :          0 :     checkDisposed();
     593                 :          0 :     return m_xDocument->retrieveRunAttributes( this, Index, RequestedAttributes );
     594                 :            : }
     595                 :            : 
     596                 :            : // virtual
     597                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getLineNumberAtIndex( ::sal_Int32 nIndex )
     598                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     599                 :            :            ::css::uno::RuntimeException)
     600                 :            : {
     601         [ #  # ]:          0 :     checkDisposed();
     602                 :            : 
     603                 :          0 :     ::sal_Int32 nLineNo = -1;
     604         [ #  # ]:          0 :     m_xDocument->retrieveParagraphLineBoundary( this, nIndex, &nLineNo );
     605                 :            : 
     606                 :          0 :     return nLineNo;
     607                 :            : }
     608                 :            : 
     609                 :            : // virtual
     610                 :          0 : ::css::accessibility::TextSegment SAL_CALL ParagraphImpl::getTextAtLineNumber( ::sal_Int32 nLineNo )
     611                 :            :     throw (::css::lang::IndexOutOfBoundsException,
     612                 :            :            ::css::uno::RuntimeException)
     613                 :            : {
     614         [ #  # ]:          0 :     checkDisposed();
     615                 :            : 
     616                 :            :     ::css::i18n::Boundary aBoundary =
     617         [ #  # ]:          0 :         m_xDocument->retrieveParagraphBoundaryOfLine( this, nLineNo );
     618                 :            : 
     619                 :          0 :     return ::css::accessibility::TextSegment( getTextRange(aBoundary.startPos, aBoundary.endPos),
     620         [ #  # ]:          0 :         aBoundary.startPos, aBoundary.endPos);
     621                 :            : }
     622                 :            : 
     623                 :            : // virtual
     624                 :          0 : ::css::accessibility::TextSegment SAL_CALL ParagraphImpl::getTextAtLineWithCaret(  )
     625                 :            :     throw (::css::uno::RuntimeException)
     626                 :            : {
     627                 :          0 :     checkDisposed();
     628                 :            : 
     629                 :          0 :     sal_Int32 nLineNo = getNumberOfLineWithCaret();
     630                 :            : 
     631                 :            :     try {
     632                 :            :         return ( nLineNo >= 0 ) ?
     633                 :          0 :             getTextAtLineNumber( nLineNo ) :
     634 [ #  # ][ #  # ]:          0 :             ::css::accessibility::TextSegment();
     635         [ #  # ]:          0 :     } catch (const ::css::lang::IndexOutOfBoundsException&) {
     636                 :            :         throw ::css::uno::RuntimeException(
     637                 :            :             ::rtl::OUString(
     638                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
     639                 :            :                     "textwindowaccessibility.cxx:"
     640                 :            :                     " ParagraphImpl::getTextAtLineWithCaret") ),
     641   [ #  #  #  #  :          0 :             static_cast< ::css::uno::XWeak * >( this ) );
                   #  # ]
     642                 :            :     }
     643                 :            : }
     644                 :            : 
     645                 :            : // virtual
     646                 :          0 : ::sal_Int32 SAL_CALL ParagraphImpl::getNumberOfLineWithCaret(  )
     647                 :            :     throw (::css::uno::RuntimeException)
     648                 :            : {
     649                 :          0 :     checkDisposed();
     650                 :          0 :     return m_xDocument->retrieveParagraphLineWithCursor(this);
     651                 :            : }
     652                 :            : 
     653                 :            : 
     654                 :            : // virtual
     655                 :          0 : void SAL_CALL ParagraphImpl::addEventListener(
     656                 :            :     ::css::uno::Reference<
     657                 :            :     ::css::accessibility::XAccessibleEventListener > const & rListener)
     658                 :            :     throw (::css::uno::RuntimeException)
     659                 :            : {
     660         [ #  # ]:          0 :     if (rListener.is())
     661                 :            :     {
     662         [ #  # ]:          0 :         ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
     663 [ #  # ][ #  # ]:          0 :         if (rBHelper.bDisposed || rBHelper.bInDispose)
     664                 :            :         {
     665         [ #  # ]:          0 :             aGuard.clear();
     666         [ #  # ]:          0 :             rListener->disposing(::css::lang::EventObject(
     667 [ #  # ][ #  # ]:          0 :                                     static_cast< ::cppu::OWeakObject * >(this)));
         [ #  # ][ #  # ]
     668                 :            :         }
     669                 :            :         else
     670                 :            :         {
     671         [ #  # ]:          0 :             if (!m_nClientId)
     672         [ #  # ]:          0 :                 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
     673         [ #  # ]:          0 :             comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, rListener );
     674         [ #  # ]:          0 :         }
     675                 :            :     }
     676                 :          0 : }
     677                 :            : 
     678                 :            : // virtual
     679                 :          0 : void SAL_CALL ParagraphImpl::removeEventListener(
     680                 :            :     ::css::uno::Reference<
     681                 :            :     ::css::accessibility::XAccessibleEventListener > const & rListener)
     682                 :            :     throw (::css::uno::RuntimeException)
     683                 :            : {
     684                 :          0 :     comphelper::AccessibleEventNotifier::TClientId nId = 0;
     685                 :            :     {
     686         [ #  # ]:          0 :         ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
     687 [ #  # ][ #  # ]:          0 :         if (rListener.is() && m_nClientId != 0
         [ #  # ][ #  # ]
     688         [ #  # ]:          0 :             && comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, rListener ) == 0)
     689                 :            :         {
     690                 :          0 :             nId = m_nClientId;
     691                 :          0 :             m_nClientId = 0;
     692         [ #  # ]:          0 :         }
     693                 :            :     }
     694         [ #  # ]:          0 :     if (nId != 0)
     695                 :            :     {
     696                 :            :         // no listeners anymore
     697                 :            :         // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     698                 :            :         // and at least to us not firing any events anymore, in case somebody calls
     699                 :            :         // NotifyAccessibleEvent, again
     700                 :          0 :         comphelper::AccessibleEventNotifier::revokeClient(nId);
     701                 :            :     }
     702                 :          0 : }
     703                 :            : 
     704                 :            : // virtual
     705                 :          0 : void SAL_CALL ParagraphImpl::disposing()
     706                 :            : {
     707                 :          0 :     comphelper::AccessibleEventNotifier::TClientId nId = 0;
     708                 :            :     {
     709         [ #  # ]:          0 :         ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
     710                 :          0 :         nId = m_nClientId;
     711         [ #  # ]:          0 :         m_nClientId = 0;
     712                 :            :     }
     713         [ #  # ]:          0 :     if (nId != 0)
     714         [ #  # ]:          0 :         comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(nId, *this);
     715                 :          0 : }
     716                 :            : 
     717                 :            : // virtual
     718                 :          0 : ::rtl::OUString ParagraphImpl::implGetText()
     719                 :            : {
     720                 :          0 :     return m_xDocument->retrieveParagraphText(this);
     721                 :            : }
     722                 :            : 
     723                 :            : // virtual
     724                 :          0 : ::css::lang::Locale ParagraphImpl::implGetLocale()
     725                 :            : {
     726                 :          0 :     return m_xDocument->retrieveLocale();
     727                 :            : }
     728                 :            : 
     729                 :            : // virtual
     730                 :          0 : void ParagraphImpl::implGetSelection(::sal_Int32 & rStartIndex,
     731                 :            :                                      ::sal_Int32 & rEndIndex)
     732                 :            : {
     733                 :          0 :     m_xDocument->retrieveParagraphSelection(this, &rStartIndex, &rEndIndex);
     734                 :          0 : }
     735                 :            : 
     736                 :            : // virtual
     737                 :          0 : void ParagraphImpl::implGetParagraphBoundary( ::css::i18n::Boundary& rBoundary,
     738                 :            :                                               ::sal_Int32 nIndex )
     739                 :            : {
     740         [ #  # ]:          0 :     ::rtl::OUString sText( implGetText() );
     741                 :          0 :     ::sal_Int32 nLength = sText.getLength();
     742                 :            : 
     743 [ #  # ][ #  # ]:          0 :     if ( implIsValidIndex( nIndex, nLength ) )
     744                 :            :     {
     745                 :          0 :         rBoundary.startPos = 0;
     746                 :          0 :         rBoundary.endPos = nLength;
     747                 :            :     }
     748                 :            :     else
     749                 :            :     {
     750                 :          0 :         rBoundary.startPos = nIndex;
     751                 :          0 :         rBoundary.endPos = nIndex;
     752                 :          0 :     }
     753                 :          0 : }
     754                 :            : 
     755                 :            : // virtual
     756                 :          0 : void ParagraphImpl::implGetLineBoundary( ::css::i18n::Boundary& rBoundary,
     757                 :            :                                          ::sal_Int32 nIndex )
     758                 :            : {
     759         [ #  # ]:          0 :     ::rtl::OUString sText( implGetText() );
     760                 :          0 :     ::sal_Int32 nLength = sText.getLength();
     761                 :            : 
     762 [ #  # ][ #  # ]:          0 :     if ( implIsValidIndex( nIndex, nLength ) || nIndex == nLength )
         [ #  # ][ #  # ]
     763                 :            :     {
     764                 :            :         ::css::i18n::Boundary aBoundary =
     765         [ #  # ]:          0 :             m_xDocument->retrieveParagraphLineBoundary( this, nIndex );
     766                 :          0 :         rBoundary.startPos = aBoundary.startPos;
     767                 :          0 :         rBoundary.endPos = aBoundary.endPos;
     768                 :            :     }
     769                 :            :     else
     770                 :            :     {
     771                 :          0 :         rBoundary.startPos = nIndex;
     772                 :          0 :         rBoundary.endPos = nIndex;
     773                 :          0 :     }
     774                 :          0 : }
     775                 :            : 
     776                 :            : 
     777                 :          0 : void ParagraphImpl::checkDisposed()
     778                 :            : {
     779         [ #  # ]:          0 :     ::osl::MutexGuard aGuard(rBHelper.rMutex);
     780 [ #  # ][ #  # ]:          0 :     if (!(rBHelper.bDisposed || rBHelper.bInDispose))
     781                 :          0 :         return;
     782                 :            :     throw ::css::lang::DisposedException(
     783 [ #  # ][ #  # ]:          0 :         ::rtl::OUString(), static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
     784                 :            : }
     785                 :            : 
     786                 :          0 : Document::Document(::VCLXWindow * pVclXWindow, ::TextEngine & rEngine,
     787                 :            :                    ::TextView & rView, bool bCompoundControlChild):
     788                 :            :     VCLXAccessibleComponent(pVclXWindow),
     789                 :            :     m_xAccessible(pVclXWindow),
     790                 :            :     m_rEngine(rEngine),
     791                 :            :     m_rView(rView),
     792                 :            :     m_aEngineListener(*this),
     793                 :            :     m_aViewListener(LINK(this, Document, WindowEventHandler)),
     794 [ #  # ][ #  # ]:          0 :     m_bCompoundControlChild(bCompoundControlChild)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     795                 :          0 : {}
     796                 :            : 
     797                 :          0 : ::css::lang::Locale Document::retrieveLocale()
     798                 :            : {
     799 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
     800 [ #  # ][ #  # ]:          0 :     return m_rEngine.GetLocale();
     801                 :            : }
     802                 :            : 
     803                 :          0 : ::sal_Int32 Document::retrieveParagraphIndex(ParagraphImpl const * pParagraph)
     804                 :            : {
     805         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     806                 :            : 
     807                 :            :     // If a client holds on to a Paragraph that is no longer visible, it can
     808                 :            :     // happen that this Paragraph lies outside the range from m_aVisibleBegin
     809                 :            :     // to m_aVisibleEnd.  In that case, return -1 instead of a valid index:
     810                 :          0 :     Paragraphs::iterator aPara(m_xParagraphs->begin()
     811         [ #  # ]:          0 :                                + pParagraph->getNumber());
     812 [ #  # ][ #  # ]:          0 :     return aPara < m_aVisibleBegin || aPara >= m_aVisibleEnd
     813 [ #  # ][ #  # ]:          0 :         ? -1 : static_cast< ::sal_Int32 >(aPara - m_aVisibleBegin);
         [ #  # ][ #  # ]
     814                 :            :         // XXX  numeric overflow
     815                 :            : }
     816                 :            : 
     817                 :          0 : ::sal_Int64 Document::retrieveParagraphState(ParagraphImpl const * pParagraph)
     818                 :            : {
     819         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     820                 :            : 
     821                 :            :     // If a client holds on to a Paragraph that is no longer visible, it can
     822                 :            :     // happen that this Paragraph lies outside the range from m_aVisibleBegin
     823                 :            :     // to m_aVisibleEnd.  In that case, it is neither VISIBLE nor SHOWING:
     824                 :            :     ::sal_Int64 nState
     825                 :            :           = (static_cast< ::sal_Int64 >(1)
     826                 :            :              << ::css::accessibility::AccessibleStateType::ENABLED)
     827                 :            :           | (static_cast< ::sal_Int64 >(1)
     828                 :            :              << ::css::accessibility::AccessibleStateType::SENSITIVE)
     829                 :            :           | (static_cast< ::sal_Int64 >(1)
     830                 :            :              << ::css::accessibility::AccessibleStateType::FOCUSABLE)
     831                 :            :           | (static_cast< ::sal_Int64 >(1)
     832                 :          0 :              << ::css::accessibility::AccessibleStateType::MULTI_LINE);
     833 [ #  # ][ #  # ]:          0 :     if (!m_rView.IsReadOnly())
     834                 :            :         nState |= (static_cast< ::sal_Int64 >(1)
     835                 :          0 :                    << ::css::accessibility::AccessibleStateType::EDITABLE);
     836                 :          0 :     Paragraphs::iterator aPara(m_xParagraphs->begin()
     837         [ #  # ]:          0 :                                + pParagraph->getNumber());
     838 [ #  # ][ #  # ]:          0 :     if (aPara >= m_aVisibleBegin && aPara < m_aVisibleEnd)
         [ #  # ][ #  # ]
                 [ #  # ]
     839                 :            :     {
     840                 :            :         nState
     841                 :            :             |= (static_cast< ::sal_Int64 >(1)
     842                 :            :                 << ::css::accessibility::AccessibleStateType::VISIBLE)
     843                 :            :             | (static_cast< ::sal_Int64 >(1)
     844                 :          0 :                << ::css::accessibility::AccessibleStateType::SHOWING);
     845 [ #  # ][ #  # ]:          0 :         if (aPara == m_aFocused)
     846                 :            :             nState |= (static_cast< ::sal_Int64 >(1)
     847                 :          0 :                        << ::css::accessibility::AccessibleStateType::FOCUSED);
     848                 :            :     }
     849         [ #  # ]:          0 :     return nState;
     850                 :            : };
     851                 :            : 
     852                 :            : ::css::awt::Rectangle
     853                 :          0 : Document::retrieveParagraphBounds(ParagraphImpl const * pParagraph,
     854                 :            :                                   bool bAbsolute)
     855                 :            : {
     856 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
     857         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     858                 :            : 
     859                 :            :     // If a client holds on to a Paragraph that is no longer visible (as it
     860                 :            :     // scrolled out the top of the view), it can happen that this Paragraph
     861                 :            :     // lies before m_aVisibleBegin.  In that case, calculate the vertical
     862                 :            :     // position of the Paragraph starting at paragraph 0, otherwise optimize
     863                 :            :     // and start at m_aVisibleBegin:
     864                 :          0 :     Paragraphs::iterator aPara(m_xParagraphs->begin()
     865         [ #  # ]:          0 :                                + pParagraph->getNumber());
     866                 :            :     ::sal_Int32 nPos;
     867                 :          0 :     Paragraphs::iterator aIt;
     868 [ #  # ][ #  # ]:          0 :     if (aPara < m_aVisibleBegin)
     869                 :            :     {
     870                 :          0 :         nPos = 0;
     871                 :          0 :         aIt = m_xParagraphs->begin();
     872                 :            :     }
     873                 :            :     else
     874                 :            :     {
     875                 :          0 :         nPos = m_nViewOffset - m_nVisibleBeginOffset;
     876                 :          0 :         aIt = m_aVisibleBegin;
     877                 :            :     }
     878 [ #  # ][ #  # ]:          0 :     for (; aIt != aPara; ++aIt)
     879                 :          0 :         nPos += aIt->getHeight();
     880                 :            : 
     881                 :          0 :     Point aOrig(0, 0);
     882         [ #  # ]:          0 :     if (bAbsolute)
     883 [ #  # ][ #  # ]:          0 :         aOrig = m_rView.GetWindow()->OutputToAbsoluteScreenPixel(aOrig);
     884                 :            : 
     885                 :            :     return ::css::awt::Rectangle(
     886                 :          0 :         static_cast< ::sal_Int32 >(aOrig.X()),
     887                 :          0 :         static_cast< ::sal_Int32 >(aOrig.Y()) + nPos - m_nViewOffset,
     888 [ #  # ][ #  # ]:          0 :         m_rView.GetWindow()->GetOutputSizePixel().Width(), aPara->getHeight());
                 [ #  # ]
     889                 :            :         // XXX  numeric overflow (3x)
     890                 :            : }
     891                 :            : 
     892                 :            : ::rtl::OUString
     893                 :          0 : Document::retrieveParagraphText(ParagraphImpl const * pParagraph)
     894                 :            : {
     895 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
     896         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     897 [ #  # ][ #  # ]:          0 :     return m_rEngine.GetText(static_cast< ::sal_uLong >(pParagraph->getNumber()));
         [ #  # ][ #  # ]
                 [ #  # ]
     898                 :            :         // numeric overflow cannot happen here
     899                 :            : }
     900                 :            : 
     901                 :          0 : void Document::retrieveParagraphSelection(ParagraphImpl const * pParagraph,
     902                 :            :                                           ::sal_Int32 * pBegin,
     903                 :            :                                           ::sal_Int32 * pEnd)
     904                 :            : {
     905 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
     906         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     907         [ #  # ]:          0 :     ::TextSelection const & rSelection = m_rView.GetSelection();
     908                 :          0 :     Paragraphs::size_type nNumber = pParagraph->getNumber();
     909                 :          0 :     TextPaM aStartPaM( rSelection.GetStart() );
     910                 :          0 :     TextPaM aEndPaM( rSelection.GetEnd() );
     911                 :          0 :     TextPaM aMinPaM( ::std::min( aStartPaM, aEndPaM ) );
     912                 :          0 :     TextPaM aMaxPaM( ::std::max( aStartPaM, aEndPaM ) );
     913                 :            : 
     914 [ #  # ][ #  # ]:          0 :     if ( nNumber >= aMinPaM.GetPara() && nNumber <= aMaxPaM.GetPara() )
                 [ #  # ]
     915                 :            :     {
     916                 :          0 :         *pBegin = nNumber > aMinPaM.GetPara()
     917                 :            :             ? 0
     918         [ #  # ]:          0 :             : static_cast< ::sal_Int32 >( aMinPaM.GetIndex() );
     919                 :            :             // XXX numeric overflow
     920                 :          0 :         *pEnd = nNumber < aMaxPaM.GetPara()
     921 [ #  # ][ #  # ]:          0 :             ? static_cast< ::sal_Int32 >( m_rEngine.GetText(static_cast< ::sal_uLong >(nNumber)).Len() )
         [ #  # ][ #  # ]
     922         [ #  # ]:          0 :             : static_cast< ::sal_Int32 >( aMaxPaM.GetIndex() );
     923                 :            :             // XXX  numeric overflow (3x)
     924                 :            : 
     925         [ #  # ]:          0 :         if ( aStartPaM > aEndPaM )
     926                 :          0 :             ::std::swap( *pBegin, *pEnd );
     927                 :            :     }
     928                 :            :     else
     929                 :            :     {
     930                 :          0 :         *pBegin = 0;
     931                 :          0 :         *pEnd = 0;
     932 [ #  # ][ #  # ]:          0 :     }
     933                 :          0 : }
     934                 :            : 
     935                 :          0 : ::sal_Int32 Document::retrieveParagraphCaretPosition(ParagraphImpl const * pParagraph)
     936                 :            : {
     937 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
     938         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     939         [ #  # ]:          0 :     ::TextSelection const & rSelection = m_rView.GetSelection();
     940                 :          0 :     Paragraphs::size_type nNumber = pParagraph->getNumber();
     941                 :          0 :     TextPaM aEndPaM( rSelection.GetEnd() );
     942                 :            : 
     943                 :          0 :     return aEndPaM.GetPara() == nNumber
     944 [ #  # ][ #  # ]:          0 :         ? static_cast< ::sal_Int32 >(aEndPaM.GetIndex()) : -1;
                 [ #  # ]
     945                 :            : }
     946                 :            : 
     947                 :            : ::css::awt::Rectangle
     948                 :          0 : Document::retrieveCharacterBounds(ParagraphImpl const * pParagraph,
     949                 :            :                                   ::sal_Int32 nIndex)
     950                 :            : {
     951 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
     952         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
     953                 :          0 :     ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
     954 [ #  # ][ #  # ]:          0 :     sal_Int32 nLength = m_rEngine.GetText(nNumber).Len();
     955                 :            :         // XXX  numeric overflow
     956 [ #  # ][ #  # ]:          0 :     if (nIndex < 0 || nIndex > nLength)
     957                 :            :         throw ::css::lang::IndexOutOfBoundsException(
     958                 :            :             ::rtl::OUString(
     959                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
     960                 :            :                     "textwindowaccessibility.cxx:"
     961                 :            :                     " Document::retrieveCharacterAttributes")),
     962 [ #  # ][ #  # ]:          0 :             static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
     963                 :          0 :     ::css::awt::Rectangle aBounds( 0, 0, 0, 0 );
     964         [ #  # ]:          0 :     if ( nIndex == nLength )
     965                 :            :     {
     966                 :            :         aBounds = AWTRectangle(
     967                 :            :             m_rEngine.PaMtoEditCursor(::TextPaM(nNumber,
     968 [ #  # ][ #  # ]:          0 :                                                 static_cast< ::sal_uInt16 >(nIndex))));
     969                 :            :     }
     970                 :            :     else
     971                 :            :     {
     972                 :            :         ::Rectangle aLeft(
     973                 :            :             m_rEngine.PaMtoEditCursor(::TextPaM(nNumber,
     974         [ #  # ]:          0 :                                                 static_cast< ::sal_uInt16 >(nIndex))));
     975                 :            :             // XXX  numeric overflow
     976                 :            :         ::Rectangle aRight(
     977                 :            :             m_rEngine.PaMtoEditCursor(::TextPaM(nNumber,
     978                 :            :                                                 static_cast< ::sal_uInt16 >(nIndex)
     979         [ #  # ]:          0 :                                                 + 1)));
     980                 :            :             // XXX  numeric overflow (2x)
     981                 :            :         // FIXME  If the vertical extends of the two cursors do not match, assume
     982                 :            :         // nIndex is the last character on the line; the bounding box will then
     983                 :            :         // extend to m_rEnginge.GetMaxTextWidth():
     984                 :          0 :         ::sal_Int32 nWidth = (aLeft.Top() == aRight.Top()
     985                 :          0 :                             && aLeft.Bottom() == aRight.Bottom())
     986                 :          0 :             ? static_cast< ::sal_Int32 >(aRight.Left() - aLeft.Left())
     987                 :          0 :             : static_cast< ::sal_Int32 >(m_rEngine.GetMaxTextWidth()
     988   [ #  #  #  # ]:          0 :                                         - aLeft.Left());
     989                 :            :             // XXX  numeric overflow (4x)
     990                 :          0 :         aBounds = ::css::awt::Rectangle(static_cast< ::sal_Int32 >(aLeft.Left()),
     991                 :          0 :                                         static_cast< ::sal_Int32 >(aLeft.Top() - m_nViewOffset),
     992                 :            :                                         nWidth,
     993                 :          0 :                                         static_cast< ::sal_Int32 >(aLeft.Bottom()
     994                 :          0 :                                                                     - aLeft.Top()));
     995                 :            :             // XXX  numeric overflow (4x)
     996                 :            :     }
     997 [ #  # ][ #  # ]:          0 :     return aBounds;
     998                 :            : }
     999                 :            : 
    1000                 :          0 : ::sal_Int32 Document::retrieveCharacterIndex(ParagraphImpl const * pParagraph,
    1001                 :            :                                              ::css::awt::Point const & rPoint)
    1002                 :            : {
    1003 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1004         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
    1005                 :          0 :     ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1006                 :            :         // XXX  numeric overflow
    1007                 :            :     ::TextPaM aPaM(m_rEngine.GetPaM(::Point(static_cast< long >(rPoint.X),
    1008         [ #  # ]:          0 :                                             static_cast< long >(rPoint.Y))));
    1009                 :            :         // XXX  numeric overflow (2x)
    1010                 :          0 :     return aPaM.GetPara() == nNumber
    1011 [ #  # ][ #  # ]:          0 :         ? static_cast< ::sal_Int32 >(aPaM.GetIndex()) : -1;
                 [ #  # ]
    1012                 :            :         // XXX  numeric overflow
    1013                 :            : }
    1014                 :            : 
    1015                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue >
    1016                 :          0 : Document::retrieveCharacterAttributes(
    1017                 :            :     ParagraphImpl const * pParagraph, ::sal_Int32 nIndex,
    1018                 :            :     const ::css::uno::Sequence< ::rtl::OUString >& aRequestedAttributes)
    1019                 :            : {
    1020 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1021         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
    1022                 :          0 :     ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1023                 :            :         // XXX  numeric overflow
    1024 [ #  # ][ #  # ]:          0 :     if (nIndex < 0 || nIndex >= m_rEngine.GetText(nNumber).Len())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1025                 :            :         throw ::css::lang::IndexOutOfBoundsException(
    1026                 :            :             ::rtl::OUString(
    1027                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
    1028                 :            :                     "textwindowaccessibility.cxx:"
    1029                 :            :                     " Document::retrieveCharacterAttributes")),
    1030 [ #  # ][ #  # ]:          0 :             static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
    1031                 :            : 
    1032                 :            :     // retrieve default attributes
    1033         [ #  # ]:          0 :     tPropValMap aCharAttrSeq;
    1034                 :          0 :     retrieveDefaultAttributesImpl( pParagraph, aRequestedAttributes, aCharAttrSeq );
    1035                 :            : 
    1036                 :            :     // retrieve run attributes
    1037         [ #  # ]:          0 :     tPropValMap aRunAttrSeq;
    1038         [ #  # ]:          0 :     retrieveRunAttributesImpl( pParagraph, nIndex, aRequestedAttributes, aRunAttrSeq );
    1039                 :            : 
    1040                 :            :     // merge default and run attributes
    1041 [ #  # ][ #  # ]:          0 :     for ( tPropValMap::const_iterator aRunIter  = aRunAttrSeq.begin();
    1042         [ #  # ]:          0 :           aRunIter != aRunAttrSeq.end();
    1043                 :            :           ++aRunIter )
    1044                 :            :     {
    1045 [ #  # ][ #  # ]:          0 :         aCharAttrSeq[ aRunIter->first ] = aRunIter->second;
                 [ #  # ]
    1046                 :            :     }
    1047                 :            : 
    1048 [ #  # ][ #  # ]:          0 :     return convertHashMapToSequence( aCharAttrSeq );
         [ #  # ][ #  # ]
                 [ #  # ]
    1049                 :            : }
    1050                 :            : 
    1051                 :          0 : void Document::retrieveDefaultAttributesImpl(
    1052                 :            :     ParagraphImpl const * pParagraph,
    1053                 :            :     const ::css::uno::Sequence< ::rtl::OUString >& RequestedAttributes,
    1054                 :            :     tPropValMap& rDefAttrSeq)
    1055                 :            : {
    1056                 :            :     // default attributes are not supported by text engine
    1057                 :            :     (void) pParagraph;
    1058                 :            :     (void) RequestedAttributes;
    1059                 :            :     (void) rDefAttrSeq;
    1060                 :          0 : }
    1061                 :            : 
    1062                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue >
    1063                 :          0 : Document::retrieveDefaultAttributes(
    1064                 :            :     ParagraphImpl const * pParagraph,
    1065                 :            :     const ::css::uno::Sequence< ::rtl::OUString >& RequestedAttributes)
    1066                 :            : {
    1067 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard( getExternalLock() );
    1068         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard( GetMutex() );
    1069                 :            : 
    1070         [ #  # ]:          0 :     tPropValMap aDefAttrSeq;
    1071                 :          0 :     retrieveDefaultAttributesImpl( pParagraph, RequestedAttributes, aDefAttrSeq );
    1072 [ #  # ][ #  # ]:          0 :     return convertHashMapToSequence( aDefAttrSeq );
         [ #  # ][ #  # ]
    1073                 :            : }
    1074                 :            : 
    1075                 :            : // static
    1076                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue >
    1077                 :          0 : Document::convertHashMapToSequence(tPropValMap& rAttrSeq)
    1078                 :            : {
    1079                 :          0 :     ::css::uno::Sequence< ::css::beans::PropertyValue > aValues( rAttrSeq.size() );
    1080         [ #  # ]:          0 :     ::css::beans::PropertyValue* pValues = aValues.getArray();
    1081                 :          0 :     ::sal_Int32 i = 0;
    1082 [ #  # ][ #  # ]:          0 :     for ( tPropValMap::const_iterator aIter  = rAttrSeq.begin();
    1083         [ #  # ]:          0 :           aIter != rAttrSeq.end();
    1084                 :            :           ++aIter )
    1085                 :            :     {
    1086         [ #  # ]:          0 :         pValues[i] = aIter->second;
    1087                 :          0 :         ++i;
    1088                 :            :     }
    1089                 :          0 :     return aValues;
    1090                 :            : }
    1091                 :            : 
    1092                 :          0 : void Document::retrieveRunAttributesImpl(
    1093                 :            :     ParagraphImpl const * pParagraph, ::sal_Int32 Index,
    1094                 :            :     const ::css::uno::Sequence< ::rtl::OUString >& RequestedAttributes,
    1095                 :            :     tPropValMap& rRunAttrSeq)
    1096                 :            : {
    1097                 :          0 :     ::sal_uLong nNumber = static_cast< ::sal_uLong >( pParagraph->getNumber() );
    1098                 :          0 :     ::TextPaM aPaM( nNumber, static_cast< ::sal_uInt16 >( Index ) );
    1099                 :            :         // XXX  numeric overflow
    1100                 :            :     // FIXME  TEXTATTR_HYPERLINK ignored:
    1101                 :            :     ::TextAttribFontColor const * pColor
    1102                 :            :           = static_cast< ::TextAttribFontColor const * >(
    1103         [ #  # ]:          0 :               m_rEngine.FindAttrib( aPaM, TEXTATTR_FONTCOLOR ) );
    1104                 :            :     ::TextAttribFontWeight const * pWeight
    1105                 :            :           = static_cast< ::TextAttribFontWeight const * >(
    1106         [ #  # ]:          0 :               m_rEngine.FindAttrib( aPaM, TEXTATTR_FONTWEIGHT ) );
    1107         [ #  # ]:          0 :     tPropValMap aRunAttrSeq;
    1108         [ #  # ]:          0 :     if ( pColor )
    1109                 :            :     {
    1110                 :          0 :         ::css::beans::PropertyValue aPropVal;
    1111                 :            :         aPropVal.Name =
    1112         [ #  # ]:          0 :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) );
    1113                 :          0 :         aPropVal.Handle = -1;
    1114         [ #  # ]:          0 :         aPropVal.Value = mapFontColor( pColor->GetColor() );
    1115                 :          0 :         aPropVal.State = ::css::beans::PropertyState_DIRECT_VALUE;
    1116         [ #  # ]:          0 :         aRunAttrSeq[ aPropVal.Name ] = aPropVal;
    1117                 :            :     }
    1118         [ #  # ]:          0 :     if ( pWeight )
    1119                 :            :     {
    1120                 :          0 :         ::css::beans::PropertyValue aPropVal;
    1121                 :            :         aPropVal.Name =
    1122         [ #  # ]:          0 :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) );
    1123                 :          0 :         aPropVal.Handle = -1;
    1124         [ #  # ]:          0 :         aPropVal.Value = mapFontWeight( pWeight->getFontWeight() );
    1125                 :          0 :         aPropVal.State = ::css::beans::PropertyState_DIRECT_VALUE;
    1126         [ #  # ]:          0 :         aRunAttrSeq[ aPropVal.Name ] = aPropVal;
    1127                 :            :     }
    1128         [ #  # ]:          0 :     if ( RequestedAttributes.getLength() == 0 )
    1129                 :            :     {
    1130         [ #  # ]:          0 :         rRunAttrSeq = aRunAttrSeq;
    1131                 :            :     }
    1132                 :            :     else
    1133                 :            :     {
    1134                 :          0 :         const ::rtl::OUString* pReqAttrs = RequestedAttributes.getConstArray();
    1135                 :          0 :         const ::sal_Int32 nLength = RequestedAttributes.getLength();
    1136         [ #  # ]:          0 :         for ( ::sal_Int32 i = 0; i < nLength; ++i )
    1137                 :            :         {
    1138         [ #  # ]:          0 :             tPropValMap::iterator aIter = aRunAttrSeq.find( pReqAttrs[i] );
    1139 [ #  # ][ #  # ]:          0 :             if ( aIter != aRunAttrSeq.end() )
    1140                 :            :             {
    1141 [ #  # ][ #  # ]:          0 :                 rRunAttrSeq[ (*aIter).first ] = (*aIter).second;
                 [ #  # ]
    1142                 :            :             }
    1143                 :            :         }
    1144         [ #  # ]:          0 :     }
    1145                 :          0 : }
    1146                 :            : 
    1147                 :            : ::css::uno::Sequence< ::css::beans::PropertyValue >
    1148                 :          0 : Document::retrieveRunAttributes(
    1149                 :            :     ParagraphImpl const * pParagraph, ::sal_Int32 Index,
    1150                 :            :     const ::css::uno::Sequence< ::rtl::OUString >& RequestedAttributes)
    1151                 :            : {
    1152 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard( getExternalLock() );
    1153         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard( GetMutex() );
    1154                 :          0 :     ::sal_uLong nNumber = static_cast< ::sal_uLong >( pParagraph->getNumber() );
    1155                 :            :         // XXX  numeric overflow
    1156 [ #  # ][ #  # ]:          0 :     if ( Index < 0 || Index >= m_rEngine.GetText(nNumber).Len() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1157                 :            :         throw ::css::lang::IndexOutOfBoundsException(
    1158                 :            :             ::rtl::OUString(
    1159                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
    1160                 :            :                     "textwindowaccessibility.cxx:"
    1161                 :            :                     " Document::retrieveRunAttributes") ),
    1162 [ #  # ][ #  # ]:          0 :             static_cast< ::css::uno::XWeak * >( this ) );
                 [ #  # ]
    1163                 :            : 
    1164         [ #  # ]:          0 :     tPropValMap aRunAttrSeq;
    1165         [ #  # ]:          0 :     retrieveRunAttributesImpl( pParagraph, Index, RequestedAttributes, aRunAttrSeq );
    1166 [ #  # ][ #  # ]:          0 :     return convertHashMapToSequence( aRunAttrSeq );
         [ #  # ][ #  # ]
    1167                 :            : }
    1168                 :            : 
    1169                 :          0 : void Document::changeParagraphText(ParagraphImpl * pParagraph,
    1170                 :            :                                    ::rtl::OUString const & rText)
    1171                 :            : {
    1172 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1173                 :            :     {
    1174         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard(GetMutex());
    1175                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1176                 :            :             // XXX  numeric overflow
    1177         [ #  # ]:          0 :         changeParagraphText(nNumber, 0, m_rEngine.GetTextLen(nNumber), false,
    1178 [ #  # ][ #  # ]:          0 :                             false, rText);
    1179         [ #  # ]:          0 :     }
    1180                 :          0 : }
    1181                 :            : 
    1182                 :          0 : void Document::changeParagraphText(ParagraphImpl * pParagraph,
    1183                 :            :                                    ::sal_Int32 nBegin, ::sal_Int32 nEnd,
    1184                 :            :                                    bool bCut, bool bPaste,
    1185                 :            :                                    ::rtl::OUString const & rText)
    1186                 :            : {
    1187 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1188                 :            :     {
    1189         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard(GetMutex());
    1190                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1191                 :            :             // XXX  numeric overflow
    1192   [ #  #  #  # ]:          0 :         if (nBegin < 0 || nBegin > nEnd
         [ #  # ][ #  # ]
    1193 [ #  # ][ #  # ]:          0 :             || nEnd > m_rEngine.GetText(nNumber).Len())
         [ #  # ][ #  # ]
    1194                 :            :             throw ::css::lang::IndexOutOfBoundsException(
    1195                 :            :                 ::rtl::OUString(
    1196                 :            :                     RTL_CONSTASCII_USTRINGPARAM(
    1197                 :            :                         "textwindowaccessibility.cxx:"
    1198                 :            :                         " Document::changeParagraphText")),
    1199 [ #  # ][ #  # ]:          0 :                 static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
    1200                 :            :         changeParagraphText(nNumber, static_cast< ::sal_uInt16 >(nBegin),
    1201 [ #  # ][ #  # ]:          0 :                             static_cast< ::sal_uInt16 >(nEnd), bCut, bPaste, rText);
    1202                 :            :             // XXX  numeric overflow (2x)
    1203         [ #  # ]:          0 :     }
    1204                 :          0 : }
    1205                 :            : 
    1206                 :          0 : void Document::copyParagraphText(ParagraphImpl const * pParagraph,
    1207                 :            :                                  ::sal_Int32 nBegin, ::sal_Int32 nEnd)
    1208                 :            : {
    1209 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1210                 :            :     {
    1211         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard(GetMutex());
    1212                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1213                 :            :             // XXX  numeric overflow
    1214   [ #  #  #  # ]:          0 :         if (nBegin < 0 || nBegin > nEnd
         [ #  # ][ #  # ]
    1215 [ #  # ][ #  # ]:          0 :             || nEnd > m_rEngine.GetText(nNumber).Len())
         [ #  # ][ #  # ]
    1216                 :            :             throw ::css::lang::IndexOutOfBoundsException(
    1217                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
    1218                 :            :                                     "textwindowaccessibility.cxx:"
    1219                 :            :                                     " Document::copyParagraphText")),
    1220 [ #  # ][ #  # ]:          0 :                 static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
    1221                 :            :         m_rView.SetSelection(
    1222                 :            :             ::TextSelection(::TextPaM(nNumber, static_cast< ::sal_uInt16 >(nBegin)),
    1223 [ #  # ][ #  # ]:          0 :                             ::TextPaM(nNumber, static_cast< ::sal_uInt16 >(nEnd))));
    1224                 :            :             // XXX  numeric overflow (2x)
    1225 [ #  # ][ #  # ]:          0 :         m_rView.Copy();
    1226         [ #  # ]:          0 :     }
    1227                 :          0 : }
    1228                 :            : 
    1229                 :          0 : void Document::changeParagraphAttributes(
    1230                 :            :     ParagraphImpl * pParagraph, ::sal_Int32 nBegin, ::sal_Int32 nEnd,
    1231                 :            :     ::css::uno::Sequence< ::css::beans::PropertyValue > const & rAttributeSet)
    1232                 :            : {
    1233 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1234                 :            :     {
    1235         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard(GetMutex());
    1236                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1237                 :            :         // XXX  numeric overflow
    1238   [ #  #  #  # ]:          0 :         if (nBegin < 0 || nBegin > nEnd
         [ #  # ][ #  # ]
    1239 [ #  # ][ #  # ]:          0 :             || nEnd > m_rEngine.GetText(nNumber).Len())
         [ #  # ][ #  # ]
    1240                 :            :             throw ::css::lang::IndexOutOfBoundsException(
    1241                 :            :                 ::rtl::OUString(
    1242                 :            :                     RTL_CONSTASCII_USTRINGPARAM(
    1243                 :            :                         "textwindowaccessibility.cxx:"
    1244                 :            :                         " Document::changeParagraphAttributes")),
    1245 [ #  # ][ #  # ]:          0 :                 static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
    1246                 :            : 
    1247                 :            :         // FIXME  The new attributes are added to any attributes already set,
    1248                 :            :         // they do not replace the old attributes as required by
    1249                 :            :         // XAccessibleEditableText.setAttributes:
    1250         [ #  # ]:          0 :         for (::sal_Int32 i = 0; i < rAttributeSet.getLength(); ++i)
    1251         [ #  # ]:          0 :             if ( rAttributeSet[i].Name == "CharColor" )
    1252                 :            :                 m_rEngine.SetAttrib(::TextAttribFontColor(
    1253                 :          0 :                                         mapFontColor(rAttributeSet[i].Value)),
    1254                 :            :                                     nNumber, static_cast< ::sal_uInt16 >(nBegin),
    1255 [ #  # ][ #  # ]:          0 :                                     static_cast< ::sal_uInt16 >(nEnd));
                 [ #  # ]
    1256                 :            :                     // XXX  numeric overflow (2x)
    1257         [ #  # ]:          0 :             else if ( rAttributeSet[i].Name == "CharWeight" )
    1258                 :            :                 m_rEngine.SetAttrib(::TextAttribFontWeight(
    1259                 :          0 :                                         mapFontWeight(rAttributeSet[i].Value)),
    1260                 :            :                                     nNumber, static_cast< ::sal_uInt16 >(nBegin),
    1261 [ #  # ][ #  # ]:          0 :                                     static_cast< ::sal_uInt16 >(nEnd));
         [ #  # ][ #  # ]
    1262                 :            :                     // XXX  numeric overflow (2x)
    1263         [ #  # ]:          0 :     }
    1264                 :          0 : }
    1265                 :            : 
    1266                 :          0 : void Document::changeParagraphSelection(ParagraphImpl * pParagraph,
    1267                 :            :                                         ::sal_Int32 nBegin, ::sal_Int32 nEnd)
    1268                 :            : {
    1269 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1270                 :            :     {
    1271         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard(GetMutex());
    1272                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >(pParagraph->getNumber());
    1273                 :            :             // XXX  numeric overflow
    1274   [ #  #  #  # ]:          0 :         if (nBegin < 0 || nBegin > nEnd
         [ #  # ][ #  # ]
    1275 [ #  # ][ #  # ]:          0 :             || nEnd > m_rEngine.GetText(nNumber).Len())
         [ #  # ][ #  # ]
    1276                 :            :             throw ::css::lang::IndexOutOfBoundsException(
    1277                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
    1278                 :            :                                     "textwindowaccessibility.cxx:"
    1279                 :            :                                     " Document::changeParagraphSelection")),
    1280 [ #  # ][ #  # ]:          0 :                 static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
    1281                 :            :         m_rView.SetSelection(
    1282                 :            :             ::TextSelection(::TextPaM(nNumber, static_cast< ::sal_uInt16 >(nBegin)),
    1283 [ #  # ][ #  # ]:          0 :                             ::TextPaM(nNumber, static_cast< ::sal_uInt16 >(nEnd))));
                 [ #  # ]
    1284                 :            :             // XXX  numeric overflow (2x)
    1285         [ #  # ]:          0 :     }
    1286                 :          0 : }
    1287                 :            : 
    1288                 :            : ::css::i18n::Boundary
    1289                 :          0 : Document::retrieveParagraphLineBoundary( ParagraphImpl const * pParagraph,
    1290                 :            :                                          ::sal_Int32 nIndex, ::sal_Int32 *pLineNo )
    1291                 :            : {
    1292                 :          0 :     ::css::i18n::Boundary aBoundary;
    1293                 :          0 :     aBoundary.startPos = nIndex;
    1294                 :          0 :     aBoundary.endPos = nIndex;
    1295                 :            : 
    1296 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard( getExternalLock() );
    1297                 :            :     {
    1298         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard( GetMutex() );
    1299                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >( pParagraph->getNumber() );
    1300 [ #  # ][ #  # ]:          0 :         if ( nIndex < 0 || nIndex > m_rEngine.GetText( nNumber ).Len() )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1301                 :            :             throw ::css::lang::IndexOutOfBoundsException(
    1302                 :            :                 ::rtl::OUString(
    1303                 :            :                     RTL_CONSTASCII_USTRINGPARAM(
    1304                 :            :                         "textwindowaccessibility.cxx:"
    1305                 :            :                         " Document::retrieveParagraphLineBoundary" ) ),
    1306 [ #  # ][ #  # ]:          0 :                 static_cast< ::css::uno::XWeak * >( this ) );
                 [ #  # ]
    1307                 :          0 :         ::sal_Int32 nLineStart = 0;
    1308                 :          0 :         ::sal_Int32 nLineEnd = 0;
    1309         [ #  # ]:          0 :         ::sal_uInt16 nLineCount = m_rEngine.GetLineCount( nNumber );
    1310         [ #  # ]:          0 :         for ( ::sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine )
    1311                 :            :         {
    1312                 :            :             ::sal_Int32 nLineLength = static_cast< ::sal_Int32 >(
    1313         [ #  # ]:          0 :                 m_rEngine.GetLineLen( nNumber, nLine ) );
    1314                 :          0 :             nLineStart = nLineEnd;
    1315                 :          0 :             nLineEnd += nLineLength;
    1316 [ #  # ][ #  # ]:          0 :             if ( nIndex >= nLineStart && ( ( nLine == nLineCount - 1 ) ? nIndex <= nLineEnd : nIndex < nLineEnd ) )
                 [ #  # ]
    1317                 :            :             {
    1318                 :          0 :                 aBoundary.startPos = nLineStart;
    1319                 :          0 :                 aBoundary.endPos = nLineEnd;
    1320         [ #  # ]:          0 :                 if( pLineNo )
    1321                 :          0 :                     pLineNo[0] = nLine;
    1322                 :          0 :                 break;
    1323                 :            :             }
    1324         [ #  # ]:          0 :         }
    1325                 :            :     }
    1326                 :            : 
    1327         [ #  # ]:          0 :     return aBoundary;
    1328                 :            : }
    1329                 :            : 
    1330                 :            : ::css::i18n::Boundary
    1331                 :          0 : Document::retrieveParagraphBoundaryOfLine( ParagraphImpl const * pParagraph,
    1332                 :            :                                            ::sal_Int32 nLineNo )
    1333                 :            : {
    1334                 :          0 :     ::css::i18n::Boundary aBoundary;
    1335                 :          0 :     aBoundary.startPos = 0;
    1336                 :          0 :     aBoundary.endPos = 0;
    1337                 :            : 
    1338 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard( getExternalLock() );
    1339                 :            :     {
    1340         [ #  # ]:          0 :         ::osl::MutexGuard aInternalGuard( GetMutex() );
    1341                 :          0 :         ::sal_uLong nNumber = static_cast< ::sal_uLong >( pParagraph->getNumber() );
    1342 [ #  # ][ #  # ]:          0 :         if ( nLineNo >= m_rEngine.GetLineCount( nNumber ) )
    1343                 :            :             throw ::css::lang::IndexOutOfBoundsException(
    1344                 :            :                 ::rtl::OUString(
    1345                 :            :                     RTL_CONSTASCII_USTRINGPARAM(
    1346                 :            :                         "textwindowaccessibility.cxx:"
    1347                 :            :                         " Document::retrieveParagraphBoundaryOfLine" ) ),
    1348 [ #  # ][ #  # ]:          0 :                 static_cast< ::css::uno::XWeak * >( this ) );
                 [ #  # ]
    1349                 :          0 :         ::sal_Int32 nLineStart = 0;
    1350                 :          0 :         ::sal_Int32 nLineEnd = 0;
    1351         [ #  # ]:          0 :         for ( ::sal_uInt16 nLine = 0; nLine <= nLineNo; ++nLine )
    1352                 :            :         {
    1353                 :            :             ::sal_Int32 nLineLength = static_cast< ::sal_Int32 >(
    1354         [ #  # ]:          0 :                 m_rEngine.GetLineLen( nNumber, nLine ) );
    1355                 :          0 :             nLineStart = nLineEnd;
    1356                 :          0 :             nLineEnd += nLineLength;
    1357                 :            :         }
    1358                 :            : 
    1359                 :          0 :         aBoundary.startPos = nLineStart;
    1360         [ #  # ]:          0 :         aBoundary.endPos = nLineEnd;
    1361                 :            :     }
    1362                 :            : 
    1363         [ #  # ]:          0 :     return aBoundary;
    1364                 :            : }
    1365                 :            : 
    1366                 :          0 : sal_Int32 Document::retrieveParagraphLineWithCursor( ParagraphImpl const * pParagraph )
    1367                 :            : {
    1368 [ #  # ][ #  # ]:          0 :     ::osl::Guard< ::comphelper::IMutex > aExternalGuard(getExternalLock());
    1369         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard(GetMutex());
    1370         [ #  # ]:          0 :     ::TextSelection const & rSelection = m_rView.GetSelection();
    1371                 :          0 :     Paragraphs::size_type nNumber = pParagraph->getNumber();
    1372                 :          0 :     TextPaM aEndPaM( rSelection.GetEnd() );
    1373                 :            : 
    1374                 :          0 :     return aEndPaM.GetPara() == nNumber
    1375 [ #  # ][ #  # ]:          0 :         ? m_rView.GetLineNumberOfCursorInSelection() : -1;
         [ #  # ][ #  # ]
    1376                 :            : }
    1377                 :            : 
    1378                 :            : 
    1379                 :            : ::css::uno::Reference< ::css::accessibility::XAccessibleRelationSet >
    1380                 :          0 : Document::retrieveParagraphRelationSet( ParagraphImpl const * pParagraph )
    1381                 :            : {
    1382         [ #  # ]:          0 :     ::osl::MutexGuard aInternalGuard( GetMutex() );
    1383                 :            : 
    1384         [ #  # ]:          0 :     ::utl::AccessibleRelationSetHelper* pRelationSetHelper = new ::utl::AccessibleRelationSetHelper();
    1385 [ #  # ][ #  # ]:          0 :     ::css::uno::Reference< ::css::accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper;
    1386                 :            : 
    1387         [ #  # ]:          0 :     Paragraphs::iterator aPara( m_xParagraphs->begin() + pParagraph->getNumber() );
    1388                 :            : 
    1389 [ #  # ][ #  # ]:          0 :     if ( aPara > m_aVisibleBegin && aPara < m_aVisibleEnd )
         [ #  # ][ #  # ]
                 [ #  # ]
    1390                 :            :     {
    1391         [ #  # ]:          0 :         ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > > aSequence(1);
    1392 [ #  # ][ #  # ]:          0 :         aSequence[0] = getAccessibleChild( aPara - 1 );
         [ #  # ][ #  # ]
    1393         [ #  # ]:          0 :         ::css::accessibility::AccessibleRelation aRelation( ::css::accessibility::AccessibleRelationType::CONTENT_FLOWS_FROM, aSequence );
    1394 [ #  # ][ #  # ]:          0 :         pRelationSetHelper->AddRelation( aRelation );
                 [ #  # ]
    1395                 :            :     }
    1396                 :            : 
    1397 [ #  # ][ #  # ]:          0 :     if ( aPara >= m_aVisibleBegin && aPara < m_aVisibleEnd -1 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1398                 :            :     {
    1399         [ #  # ]:          0 :         ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > > aSequence(1);
    1400 [ #  # ][ #  # ]:          0 :         aSequence[0] = getAccessibleChild( aPara + 1 );
         [ #  # ][ #  # ]
    1401         [ #  # ]:          0 :         ::css::accessibility::AccessibleRelation aRelation( ::css::accessibility::AccessibleRelationType::CONTENT_FLOWS_TO, aSequence );
    1402 [ #  # ][ #  # ]:          0 :         pRelationSetHelper->AddRelation( aRelation );
                 [ #  # ]
    1403                 :            :     }
    1404                 :            : 
    1405         [ #  # ]:          0 :     return xSet;
    1406                 :            : }
    1407                 :            : 
    1408                 :          0 : void Document::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
    1409                 :            : {
    1410         [ #  # ]:          0 :     switch ( rVclWindowEvent.GetId() )
    1411                 :            :     {
    1412                 :            :         case VCLEVENT_WINDOW_GETFOCUS:
    1413                 :            :         case VCLEVENT_WINDOW_LOSEFOCUS:
    1414                 :            :         {
    1415                 :            :             // #107179# if our parent is a compound control (e.g. MultiLineEdit),
    1416                 :            :             // suppress the window focus events here
    1417         [ #  # ]:          0 :             if ( !m_bCompoundControlChild )
    1418                 :          0 :                 VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
    1419                 :            :         }
    1420                 :          0 :         break;
    1421                 :            :         default:
    1422                 :          0 :             VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
    1423                 :            :     }
    1424                 :          0 : }
    1425                 :            : 
    1426                 :            : // virtual
    1427                 :          0 : ::sal_Int32 SAL_CALL Document::getAccessibleChildCount()
    1428                 :            :     throw (::css::uno::RuntimeException)
    1429                 :            : {
    1430         [ #  # ]:          0 :     ::comphelper::OExternalLockGuard aGuard(this);
    1431         [ #  # ]:          0 :     init();
    1432 [ #  # ][ #  # ]:          0 :     return m_aVisibleEnd - m_aVisibleBegin;
    1433                 :            : }
    1434                 :            : 
    1435                 :            : // virtual
    1436                 :            : ::css::uno::Reference< ::css::accessibility::XAccessible > SAL_CALL
    1437                 :          0 : Document::getAccessibleChild(::sal_Int32 i)
    1438                 :            :     throw (::css::lang::IndexOutOfBoundsException,
    1439                 :            :            ::css::uno::RuntimeException)
    1440                 :            : {
    1441         [ #  # ]:          0 :     ::comphelper::OExternalLockGuard aGuard(this);
    1442         [ #  # ]:          0 :     init();
    1443 [ #  # ][ #  # ]:          0 :     if (i < 0 || i >= m_aVisibleEnd - m_aVisibleBegin)
         [ #  # ][ #  # ]
    1444                 :            :         throw ::css::lang::IndexOutOfBoundsException(
    1445                 :            :             ::rtl::OUString(
    1446                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
    1447                 :            :                     "textwindowaccessibility.cxx:"
    1448                 :            :                     " Document::getAccessibleChild")),
    1449 [ #  # ][ #  # ]:          0 :             static_cast< ::css::uno::XWeak * >(this));
                 [ #  # ]
    1450                 :            :     return getAccessibleChild(m_aVisibleBegin
    1451 [ #  # ][ #  # ]:          0 :                               + static_cast< Paragraphs::size_type >(i));
                 [ #  # ]
    1452                 :            : }
    1453                 :            : 
    1454                 :            : // virtual
    1455                 :          0 : ::sal_Int16 SAL_CALL Document::getAccessibleRole()
    1456                 :            :     throw (::css::uno::RuntimeException)
    1457                 :            : {
    1458                 :          0 :     return ::css::accessibility::AccessibleRole::TEXT_FRAME;
    1459                 :            : }
    1460                 :            : 
    1461                 :            : // virtual
    1462                 :            : ::css::uno::Reference< ::css::accessibility::XAccessible > SAL_CALL
    1463                 :          0 : Document::getAccessibleAtPoint(::css::awt::Point const & rPoint)
    1464                 :            :     throw (::css::uno::RuntimeException)
    1465                 :            : {
    1466         [ #  # ]:          0 :     ::comphelper::OExternalLockGuard aGuard(this);
    1467         [ #  # ]:          0 :     init();
    1468   [ #  #  #  # ]:          0 :     if (rPoint.X >= 0
         [ #  # ][ #  # ]
                 [ #  # ]
    1469 [ #  # ][ #  # ]:          0 :         && rPoint.X < m_rView.GetWindow()->GetOutputSizePixel().Width()
                 [ #  # ]
    1470                 :            :         && rPoint.Y >= 0 && rPoint.Y < m_nViewHeight)
    1471                 :            :     {
    1472                 :          0 :         ::sal_Int32 nOffset = m_nViewOffset + rPoint.Y; // XXX  numeric overflow
    1473                 :          0 :         ::sal_Int32 nPos = m_nViewOffset - m_nVisibleBeginOffset;
    1474 [ #  # ][ #  # ]:          0 :         for (Paragraphs::iterator aIt(m_aVisibleBegin); aIt != m_aVisibleEnd;
    1475                 :            :              ++aIt)
    1476                 :            :         {
    1477                 :          0 :             nPos += aIt->getHeight(); // XXX  numeric overflow
    1478         [ #  # ]:          0 :             if (nOffset < nPos)
    1479         [ #  # ]:          0 :                 return getAccessibleChild(aIt);
    1480                 :            :         }
    1481                 :            :     }
    1482 [ #  # ][ #  # ]:          0 :     return 0;
    1483                 :            : }
    1484                 :            : 
    1485                 :            : // virtual
    1486                 :          0 : void SAL_CALL Document::disposing()
    1487                 :            : {
    1488                 :          0 :     m_aEngineListener.endListening();
    1489                 :          0 :     m_aViewListener.endListening();
    1490         [ #  # ]:          0 :     if (m_xParagraphs.get() != 0)
    1491                 :          0 :         disposeParagraphs();
    1492                 :          0 :     VCLXAccessibleComponent::disposing();
    1493                 :          0 : }
    1494                 :            : 
    1495                 :            : // virtual
    1496                 :          0 : void Document::Notify(::SfxBroadcaster &, ::SfxHint const & rHint)
    1497                 :            : {
    1498         [ #  # ]:          0 :     if (rHint.ISA(::TextHint))
    1499                 :            :     {
    1500                 :            :         ::TextHint const & rTextHint
    1501                 :          0 :               = static_cast< ::TextHint const & >(rHint);
    1502   [ #  #  #  #  :          0 :         switch (rTextHint.GetId())
                      # ]
    1503                 :            :         {
    1504                 :            :         case TEXT_HINT_PARAINSERTED:
    1505                 :            :         case TEXT_HINT_PARAREMOVED:
    1506                 :            :             // TEXT_HINT_PARAINSERTED and TEXT_HINT_PARAREMOVED are sent at
    1507                 :            :             // "unsafe" times (when the text engine has not yet re-formatted its
    1508                 :            :             // content), so that for example calling ::TextEngine::GetTextHeight
    1509                 :            :             // from within the code that handles TEXT_HINT_PARAINSERTED causes
    1510                 :            :             // trouble within the text engine.  Therefore, these hints are just
    1511                 :            :             // buffered until a following ::TextEngine::FormatDoc causes a
    1512                 :            :             // TEXT_HINT_TEXTFORMATTED to come in:
    1513                 :            :         case TEXT_HINT_FORMATPARA:
    1514                 :            :             // ::TextEngine::FormatDoc sends a sequence of
    1515                 :            :             // TEXT_HINT_FORMATPARAs, followed by an optional
    1516                 :            :             // TEXT_HINT_TEXTHEIGHTCHANGED, followed in all cases by one
    1517                 :            :             // TEXT_HINT_TEXTFORMATTED.  Only the TEXT_HINT_FORMATPARAs contain
    1518                 :            :             // the the numbers of the affected paragraphs, but they are sent
    1519                 :            :             // before the changes are applied.  Therefore, TEXT_HINT_FORMATPARAs
    1520                 :            :             // are just buffered until another hint comes in:
    1521                 :            :             {
    1522         [ #  # ]:          0 :                 ::osl::MutexGuard aInternalGuard(GetMutex());
    1523 [ #  # ][ #  # ]:          0 :                 if (!isAlive())
    1524                 :            :                     break;
    1525                 :            : 
    1526         [ #  # ]:          0 :                 m_aParagraphNotifications.push(rTextHint);
    1527         [ #  # ]:          0 :                 break;
    1528                 :            :             }
    1529                 :            :         case TEXT_HINT_TEXTFORMATTED:
    1530                 :            :         case TEXT_HINT_TEXTHEIGHTCHANGED:
    1531                 :            :         case TEXT_HINT_MODIFIED:
    1532                 :            :             {
    1533         [ #  # ]:          0 :                 ::osl::MutexGuard aInternalGuard(GetMutex());
    1534 [ #  # ][ #  # ]:          0 :                 if (!isAlive())
    1535                 :            :                     break;
    1536         [ #  # ]:          0 :                 handleParagraphNotifications();
    1537         [ #  # ]:          0 :                 break;
    1538                 :            :             }
    1539                 :            :         case TEXT_HINT_VIEWSCROLLED:
    1540                 :            :             {
    1541         [ #  # ]:          0 :                 ::osl::MutexGuard aInternalGuard(GetMutex());
    1542 [ #  # ][ #  # ]:          0 :                 if (!isAlive())
    1543                 :            :                     break;
    1544         [ #  # ]:          0 :                 handleParagraphNotifications();
    1545                 :            : 
    1546                 :            :                 ::sal_Int32 nOffset = static_cast< ::sal_Int32 >(
    1547         [ #  # ]:          0 :                     m_rView.GetStartDocPos().Y());
    1548                 :            :                     // XXX  numeric overflow
    1549         [ #  # ]:          0 :                 if (nOffset != m_nViewOffset)
    1550                 :            :                 {
    1551                 :          0 :                     m_nViewOffset = nOffset;
    1552                 :            : 
    1553                 :            :                     Paragraphs::iterator aOldVisibleBegin(
    1554                 :          0 :                         m_aVisibleBegin);
    1555                 :          0 :                     Paragraphs::iterator aOldVisibleEnd(m_aVisibleEnd);
    1556                 :            : 
    1557         [ #  # ]:          0 :                     determineVisibleRange();
    1558                 :            : 
    1559                 :            :                     notifyVisibleRangeChanges(aOldVisibleBegin,
    1560                 :            :                                                 aOldVisibleEnd,
    1561         [ #  # ]:          0 :                                                 m_xParagraphs->end());
    1562                 :            :                 }
    1563         [ #  # ]:          0 :                 break;
    1564                 :            :             }
    1565                 :            :         case TEXT_HINT_VIEWSELECTIONCHANGED:
    1566                 :            :             {
    1567         [ #  # ]:          0 :                 ::osl::MutexGuard aInternalGuard(GetMutex());
    1568 [ #  # ][ #  # ]:          0 :                 if (!isAlive())
    1569                 :            :                     break;
    1570                 :            : 
    1571 [ #  # ][ #  # ]:          0 :                 if (m_aParagraphNotifications.empty())
    1572                 :            :                 {
    1573         [ #  # ]:          0 :                     handleSelectionChangeNotification();
    1574                 :            :                 }
    1575                 :            :                 else
    1576                 :            :                 {
    1577                 :            :                     // TEXT_HINT_VIEWSELECTIONCHANGED is sometimes sent at
    1578                 :            :                     // "unsafe" times (when the text engine has not yet re-
    1579                 :            :                     // formatted its content), so that for example calling
    1580                 :            :                     // ::TextEngine::GetTextHeight from within the code that
    1581                 :            :                     // handles a previous TEXT_HINT_PARAINSERTED causes
    1582                 :            :                     // trouble within the text engine.  Therefore, these
    1583                 :            :                     // hints are just buffered (along with
    1584                 :            :                     // TEXT_HINT_PARAINSERTED/REMOVED/FORMATPARA) until a
    1585                 :            :                     // following ::TextEngine::FormatDoc causes a
    1586                 :            :                     // TEXT_HINT_TEXTFORMATTED to come in:
    1587                 :          0 :                     m_bSelectionChangedNotification = true;
    1588                 :            :                 }
    1589         [ #  # ]:          0 :                 break;
    1590                 :            :             }
    1591                 :            :         }
    1592                 :            :     }
    1593                 :          0 : }
    1594                 :            : 
    1595                 :          0 : IMPL_LINK(Document, WindowEventHandler, ::VclSimpleEvent *, pEvent)
    1596                 :            : {
    1597   [ #  #  #  # ]:          0 :     switch (pEvent->GetId())
    1598                 :            :     {
    1599                 :            :     case VCLEVENT_WINDOW_RESIZE:
    1600                 :            :         {
    1601         [ #  # ]:          0 :             ::osl::MutexGuard aInternalGuard(GetMutex());
    1602 [ #  # ][ #  # ]:          0 :             if (!isAlive())
    1603                 :            :                 break;
    1604                 :            : 
    1605                 :            :             ::sal_Int32 nHeight = static_cast< ::sal_Int32 >(
    1606         [ #  # ]:          0 :                 m_rView.GetWindow()->GetOutputSizePixel().Height());
    1607                 :            :                 // XXX  numeric overflow
    1608         [ #  # ]:          0 :             if (nHeight != m_nViewHeight)
    1609                 :            :             {
    1610                 :          0 :                 m_nViewHeight = nHeight;
    1611                 :            : 
    1612                 :          0 :                 Paragraphs::iterator aOldVisibleBegin(m_aVisibleBegin);
    1613                 :          0 :                 Paragraphs::iterator aOldVisibleEnd(m_aVisibleEnd);
    1614                 :            : 
    1615         [ #  # ]:          0 :                 determineVisibleRange();
    1616                 :            : 
    1617                 :            :                 notifyVisibleRangeChanges(aOldVisibleBegin, aOldVisibleEnd,
    1618         [ #  # ]:          0 :                                             m_xParagraphs->end());
    1619                 :            :             }
    1620         [ #  # ]:          0 :             break;
    1621                 :            :         }
    1622                 :            :     case VCLEVENT_WINDOW_GETFOCUS:
    1623                 :            :         {
    1624         [ #  # ]:          0 :             ::osl::MutexGuard aInternalGuard(GetMutex());
    1625 [ #  # ][ #  # ]:          0 :             if (!isAlive())
    1626                 :            :                 break;
    1627                 :            : 
    1628 [ #  # ][ #  # ]:          0 :             if (m_aFocused >= m_aVisibleBegin && m_aFocused < m_aVisibleEnd)
         [ #  # ][ #  # ]
                 [ #  # ]
    1629                 :            :             {
    1630                 :            :                 ::rtl::Reference< ParagraphImpl > xParagraph(
    1631         [ #  # ]:          0 :                     getParagraph(m_aFocused));
    1632         [ #  # ]:          0 :                 if (xParagraph.is())
    1633                 :            :                     xParagraph->notifyEvent(
    1634                 :            :                         ::css::accessibility::AccessibleEventId::
    1635                 :            :                         STATE_CHANGED,
    1636                 :            :                         ::css::uno::Any(),
    1637                 :            :                         ::css::uno::makeAny(
    1638                 :            :                             ::css::accessibility::AccessibleStateType::
    1639 [ #  # ][ #  # ]:          0 :                             FOCUSED));
    1640                 :            :             }
    1641         [ #  # ]:          0 :             break;
    1642                 :            :         }
    1643                 :            :     case VCLEVENT_WINDOW_LOSEFOCUS:
    1644                 :            :         {
    1645         [ #  # ]:          0 :             ::osl::MutexGuard aInternalGuard(GetMutex());
    1646 [ #  # ][ #  # ]:          0 :             if (!isAlive())
    1647                 :            :                 break;
    1648                 :            : 
    1649 [ #  # ][ #  # ]:          0 :             if (m_aFocused >= m_aVisibleBegin && m_aFocused < m_aVisibleEnd)
         [ #  # ][ #  # ]
                 [ #  # ]
    1650                 :            :             {
    1651                 :            :                 ::rtl::Reference< ParagraphImpl > xParagraph(
    1652         [ #  # ]:          0 :                     getParagraph(m_aFocused));
    1653         [ #  # ]:          0 :                 if (xParagraph.is())
    1654                 :            :                     xParagraph->notifyEvent(
    1655                 :            :                         ::css::accessibility::AccessibleEventId::
    1656                 :            :                         STATE_CHANGED,
    1657                 :            :                         ::css::uno::makeAny(
    1658                 :            :                             ::css::accessibility::AccessibleStateType::
    1659                 :            :                             FOCUSED),
    1660 [ #  # ][ #  # ]:          0 :                         ::css::uno::Any());
    1661                 :            :             }
    1662         [ #  # ]:          0 :             break;
    1663                 :            :         }
    1664                 :            :     }
    1665                 :          0 :     return 0;
    1666                 :            : }
    1667                 :            : 
    1668                 :          0 : void Document::init()
    1669                 :            : {
    1670         [ #  # ]:          0 :     if (m_xParagraphs.get() == 0)
    1671                 :            :     {
    1672         [ #  # ]:          0 :         ::sal_uLong nCount = m_rEngine.GetParagraphCount();
    1673                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1674 [ #  # ][ #  # ]:          0 :         ::std::auto_ptr< Paragraphs > p(new Paragraphs);
    1675                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1676         [ #  # ]:          0 :         p->reserve(static_cast< Paragraphs::size_type >(nCount));
    1677                 :            :             // numeric overflow is harmless here
    1678         [ #  # ]:          0 :         for (::sal_uLong i = 0; i < nCount; ++i)
    1679                 :            :             p->push_back(ParagraphInfo(static_cast< ::sal_Int32 >(
    1680 [ #  # ][ #  # ]:          0 :                                            m_rEngine.GetTextHeight(i))));
         [ #  # ][ #  # ]
    1681                 :            :                 // XXX  numeric overflow
    1682                 :            :         m_nViewOffset = static_cast< ::sal_Int32 >(
    1683         [ #  # ]:          0 :             m_rView.GetStartDocPos().Y()); // XXX  numeric overflow
    1684                 :            :         m_nViewHeight = static_cast< ::sal_Int32 >(
    1685         [ #  # ]:          0 :             m_rView.GetWindow()->GetOutputSizePixel().Height());
    1686                 :            :             // XXX  numeric overflow
    1687                 :          0 :         m_xParagraphs = p;
    1688         [ #  # ]:          0 :         determineVisibleRange();
    1689                 :          0 :         m_nSelectionFirstPara = -1;
    1690                 :          0 :         m_nSelectionFirstPos = -1;
    1691                 :          0 :         m_nSelectionLastPara = -1;
    1692                 :          0 :         m_nSelectionLastPos = -1;
    1693                 :          0 :         m_aFocused = m_xParagraphs->end();
    1694                 :          0 :         m_bSelectionChangedNotification = false;
    1695         [ #  # ]:          0 :         m_aEngineListener.startListening(m_rEngine);
    1696 [ #  # ][ #  # ]:          0 :         m_aViewListener.startListening(*m_rView.GetWindow());
    1697                 :            :     }
    1698                 :          0 : }
    1699                 :            : 
    1700                 :            : ::rtl::Reference< ParagraphImpl >
    1701                 :          0 : Document::getParagraph(Paragraphs::iterator const & rIt)
    1702                 :            : {
    1703                 :            :     return static_cast< ParagraphImpl * >(
    1704                 :            :         ::css::uno::Reference< ::css::accessibility::XAccessible >(
    1705 [ #  # ][ #  # ]:          0 :             rIt->getParagraph()).get());
    1706                 :            : }
    1707                 :            : 
    1708                 :            : ::css::uno::Reference< ::css::accessibility::XAccessible >
    1709                 :          0 : Document::getAccessibleChild(Paragraphs::iterator const & rIt)
    1710                 :            : {
    1711                 :            :     ::css::uno::Reference< ::css::accessibility::XAccessible > xParagraph(
    1712                 :          0 :         rIt->getParagraph());
    1713         [ #  # ]:          0 :     if (!xParagraph.is())
    1714                 :            :     {
    1715 [ #  # ][ #  # ]:          0 :         xParagraph = new Paragraph(this, rIt - m_xParagraphs->begin());
         [ #  # ][ #  # ]
    1716         [ #  # ]:          0 :         rIt->setParagraph(xParagraph);
    1717                 :            :     }
    1718                 :          0 :     return xParagraph;
    1719                 :            : }
    1720                 :            : 
    1721                 :          0 : void Document::determineVisibleRange()
    1722                 :            : {
    1723                 :          0 :     Paragraphs::iterator const aEnd = m_xParagraphs->end();
    1724                 :            : 
    1725                 :          0 :     m_aVisibleBegin = aEnd;
    1726                 :          0 :     m_aVisibleEnd = aEnd;
    1727                 :          0 :     m_nVisibleBeginOffset = 0;
    1728                 :            : 
    1729                 :          0 :     ::sal_Int32 nPos = 0;
    1730 [ #  # ][ #  # ]:          0 :     for (Paragraphs::iterator aIt = m_xParagraphs->begin(); m_aVisibleEnd == aEnd && aIt != aEnd; ++aIt)
         [ #  # ][ #  # ]
                 [ #  # ]
    1731                 :            :     {
    1732                 :          0 :         ::sal_Int32 const nOldPos = nPos;
    1733                 :          0 :         nPos += aIt->getHeight(); // XXX  numeric overflow
    1734 [ #  # ][ #  # ]:          0 :         if (m_aVisibleBegin == aEnd)
    1735                 :            :         {
    1736         [ #  # ]:          0 :             if (nPos >= m_nViewOffset)
    1737                 :            :             {
    1738                 :          0 :                 m_aVisibleBegin = aIt;
    1739                 :          0 :                 m_nVisibleBeginOffset = m_nViewOffset - nOldPos;
    1740                 :            :             }
    1741                 :            :         }
    1742                 :            :         else
    1743                 :            :         {
    1744         [ #  # ]:          0 :             if (nPos >= m_nViewOffset + m_nViewHeight) // XXX  numeric overflow
    1745                 :            :             {
    1746                 :          0 :                 m_aVisibleEnd = aIt;
    1747                 :            :             }
    1748                 :            :         }
    1749                 :            :     }
    1750                 :            : 
    1751                 :            :     OSL_POSTCOND(
    1752                 :            :             (m_aVisibleBegin == m_xParagraphs->end() && m_aVisibleEnd == m_xParagraphs->end() && m_nVisibleBeginOffset == 0)
    1753                 :            :             || (m_aVisibleBegin < m_aVisibleEnd && m_nVisibleBeginOffset >= 0),
    1754                 :            :             "invalid visible range");
    1755                 :          0 : }
    1756                 :            : 
    1757                 :          0 : void Document::notifyVisibleRangeChanges(
    1758                 :            :     Paragraphs::iterator const & rOldVisibleBegin,
    1759                 :            :     Paragraphs::iterator const & rOldVisibleEnd,
    1760                 :            :     Paragraphs::iterator const & rInserted)
    1761                 :            : {
    1762                 :            :     // XXX  Replace this code that determines which paragraphs have changed from
    1763                 :            :     // invisible to visible or vice versa with a better algorithm.
    1764 [ #  # ][ #  # ]:          0 :     {for (Paragraphs::iterator aIt(rOldVisibleBegin); aIt != rOldVisibleEnd;
    1765                 :            :           ++aIt)
    1766 [ #  # ][ #  # ]:          0 :         if (aIt != rInserted
         [ #  # ][ #  # ]
                 [ #  # ]
    1767 [ #  # ][ #  # ]:          0 :             && (aIt < m_aVisibleBegin || aIt >= m_aVisibleEnd))
    1768                 :            :             NotifyAccessibleEvent(
    1769                 :            :                 ::css::accessibility::AccessibleEventId::
    1770                 :            :                 CHILD,
    1771                 :            :                 ::css::uno::makeAny(getAccessibleChild(aIt)),
    1772 [ #  # ][ #  # ]:          0 :                 ::css::uno::Any());
                 [ #  # ]
    1773                 :            :     }
    1774 [ #  # ][ #  # ]:          0 :     {for (Paragraphs::iterator aIt(m_aVisibleBegin); aIt != m_aVisibleEnd;
    1775                 :            :           ++aIt)
    1776 [ #  # ][ #  # ]:          0 :         if (aIt == rInserted
         [ #  # ][ #  # ]
                 [ #  # ]
    1777 [ #  # ][ #  # ]:          0 :             || aIt < rOldVisibleBegin || aIt >= rOldVisibleEnd)
    1778                 :            :             NotifyAccessibleEvent(
    1779                 :            :                 ::css::accessibility::AccessibleEventId::
    1780                 :            :                 CHILD,
    1781                 :            :                 ::css::uno::Any(),
    1782 [ #  # ][ #  # ]:          0 :                 ::css::uno::makeAny(getAccessibleChild(aIt)));
                 [ #  # ]
    1783                 :            :     }
    1784                 :          0 : }
    1785                 :            : 
    1786                 :            : void
    1787                 :          0 : Document::changeParagraphText(::sal_uLong nNumber, ::sal_uInt16 nBegin, ::sal_uInt16 nEnd,
    1788                 :            :                               bool bCut, bool bPaste,
    1789                 :            :                               ::rtl::OUString const & rText)
    1790                 :            : {
    1791                 :            :     m_rView.SetSelection(::TextSelection(::TextPaM(nNumber, nBegin),
    1792 [ #  # ][ #  # ]:          0 :                                          ::TextPaM(nNumber, nEnd)));
    1793         [ #  # ]:          0 :     if (bCut)
    1794                 :          0 :         m_rView.Cut();
    1795         [ #  # ]:          0 :     else if (nBegin != nEnd)
    1796                 :          0 :         m_rView.DeleteSelected();
    1797         [ #  # ]:          0 :     if (bPaste)
    1798                 :          0 :         m_rView.Paste();
    1799         [ #  # ]:          0 :     else if (!rText.isEmpty())
    1800         [ #  # ]:          0 :         m_rView.InsertText(rText);
    1801                 :          0 : }
    1802                 :            : 
    1803                 :          0 : void Document::handleParagraphNotifications()
    1804                 :            : {
    1805         [ #  # ]:          0 :     while (!m_aParagraphNotifications.empty())
    1806                 :            :     {
    1807 [ #  # ][ #  # ]:          0 :         ::TextHint aHint(m_aParagraphNotifications.front());
    1808         [ #  # ]:          0 :         m_aParagraphNotifications.pop();
    1809   [ #  #  #  # ]:          0 :         switch (aHint.GetId())
    1810                 :            :         {
    1811                 :            :         case TEXT_HINT_PARAINSERTED:
    1812                 :            :             {
    1813                 :          0 :                 ::sal_uLong n = aHint.GetValue();
    1814                 :            :                 OSL_ENSURE(n <= m_xParagraphs->size(),
    1815                 :            :                            "bad TEXT_HINT_PARAINSERTED event");
    1816                 :            : 
    1817                 :            :                 // Save the values of old iterators (the iterators themselves
    1818                 :            :                 // will get invalidated), and adjust the old values so that they
    1819                 :            :                 // reflect the insertion of the new paragraph:
    1820                 :            :                 Paragraphs::size_type nOldVisibleBegin
    1821         [ #  # ]:          0 :                     = m_aVisibleBegin - m_xParagraphs->begin();
    1822                 :            :                 Paragraphs::size_type nOldVisibleEnd
    1823         [ #  # ]:          0 :                     = m_aVisibleEnd - m_xParagraphs->begin();
    1824                 :            :                 Paragraphs::size_type nOldFocused
    1825         [ #  # ]:          0 :                     = m_aFocused - m_xParagraphs->begin();
    1826         [ #  # ]:          0 :                 if (n <= nOldVisibleBegin)
    1827                 :          0 :                     ++nOldVisibleBegin; // XXX  numeric overflow
    1828         [ #  # ]:          0 :                 if (n <= nOldVisibleEnd)
    1829                 :          0 :                     ++nOldVisibleEnd; // XXX  numeric overflow
    1830         [ #  # ]:          0 :                 if (n <= nOldFocused)
    1831                 :          0 :                     ++nOldFocused; // XXX  numeric overflow
    1832         [ #  # ]:          0 :                 if (sal::static_int_cast<sal_Int32>(n) <= m_nSelectionFirstPara)
    1833                 :          0 :                     ++m_nSelectionFirstPara; // XXX  numeric overflow
    1834         [ #  # ]:          0 :                 if (sal::static_int_cast<sal_Int32>(n) <= m_nSelectionLastPara)
    1835                 :          0 :                     ++m_nSelectionLastPara; // XXX  numeric overflow
    1836                 :            : 
    1837                 :            :                 Paragraphs::iterator aIns(
    1838                 :            :                     m_xParagraphs->insert(
    1839                 :          0 :                         m_xParagraphs->begin() + n,
    1840                 :            :                         ParagraphInfo(static_cast< ::sal_Int32 >(
    1841         [ #  # ]:          0 :                                           m_rEngine.GetTextHeight(n)))));
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    1842                 :            :                     // XXX  numeric overflow (2x)
    1843                 :            : 
    1844         [ #  # ]:          0 :                 determineVisibleRange();
    1845         [ #  # ]:          0 :                 m_aFocused = m_xParagraphs->begin() + nOldFocused;
    1846                 :            : 
    1847                 :          0 :                 for (Paragraphs::iterator aIt(aIns);;)
    1848                 :            :                 {
    1849                 :          0 :                     ++aIt;
    1850 [ #  # ][ #  # ]:          0 :                     if (aIt == m_xParagraphs->end())
    1851                 :            :                         break;
    1852                 :            :                     ::rtl::Reference< ParagraphImpl > xParagraph(
    1853         [ #  # ]:          0 :                         getParagraph(aIt));
    1854         [ #  # ]:          0 :                     if (xParagraph.is())
    1855                 :          0 :                         xParagraph->numberChanged(true);
    1856                 :          0 :                 }
    1857                 :            : 
    1858                 :            :                 notifyVisibleRangeChanges(
    1859                 :          0 :                     m_xParagraphs->begin() + nOldVisibleBegin,
    1860   [ #  #  #  # ]:          0 :                     m_xParagraphs->begin() + nOldVisibleEnd, aIns);
                 [ #  # ]
    1861                 :            :                 break;
    1862                 :            :             }
    1863                 :            :         case TEXT_HINT_PARAREMOVED:
    1864                 :            :             {
    1865                 :          0 :                 ::sal_uLong n = aHint.GetValue();
    1866         [ #  # ]:          0 :                 if (n == TEXT_PARA_ALL)
    1867                 :            :                 {
    1868 [ #  # ][ #  # ]:          0 :                     {for (Paragraphs::iterator aIt(m_aVisibleBegin);
    1869                 :          0 :                           aIt != m_aVisibleEnd; ++aIt)
    1870                 :            :                         NotifyAccessibleEvent(
    1871                 :            :                             ::css::accessibility::AccessibleEventId::
    1872                 :            :                             CHILD,
    1873                 :            :                             ::css::uno::makeAny(getAccessibleChild(aIt)),
    1874 [ #  # ][ #  # ]:          0 :                             ::css::uno::Any());
                 [ #  # ]
    1875                 :            :                     }
    1876         [ #  # ]:          0 :                     disposeParagraphs();
    1877                 :          0 :                     m_xParagraphs->clear();
    1878         [ #  # ]:          0 :                     determineVisibleRange();
    1879                 :          0 :                     m_nSelectionFirstPara = -1;
    1880                 :          0 :                     m_nSelectionFirstPos = -1;
    1881                 :          0 :                     m_nSelectionLastPara = -1;
    1882                 :          0 :                     m_nSelectionLastPos = -1;
    1883                 :          0 :                     m_aFocused = m_xParagraphs->end();
    1884                 :            :                 }
    1885                 :            :                 else
    1886                 :            :                 {
    1887                 :            :                     OSL_ENSURE(n < m_xParagraphs->size(),
    1888                 :            :                                "Bad TEXT_HINT_PARAREMOVED event");
    1889                 :            : 
    1890         [ #  # ]:          0 :                     Paragraphs::iterator aIt(m_xParagraphs->begin() + n);
    1891                 :            :                         // numeric overflow cannot occur
    1892                 :            : 
    1893                 :            :                     // Save the values of old iterators (the iterators
    1894                 :            :                     // themselves will get invalidated), and adjust the old
    1895                 :            :                     // values so that they reflect the removal of the paragraph:
    1896                 :            :                     Paragraphs::size_type nOldVisibleBegin
    1897         [ #  # ]:          0 :                         = m_aVisibleBegin - m_xParagraphs->begin();
    1898                 :            :                     Paragraphs::size_type nOldVisibleEnd
    1899         [ #  # ]:          0 :                         = m_aVisibleEnd - m_xParagraphs->begin();
    1900                 :            :                     bool bWasVisible
    1901 [ #  # ][ #  # ]:          0 :                         = nOldVisibleBegin <= n && n < nOldVisibleEnd;
    1902                 :            :                     Paragraphs::size_type nOldFocused
    1903         [ #  # ]:          0 :                         = m_aFocused - m_xParagraphs->begin();
    1904         [ #  # ]:          0 :                     bool bWasFocused = aIt == m_aFocused;
    1905         [ #  # ]:          0 :                     if (n < nOldVisibleBegin)
    1906                 :          0 :                         --nOldVisibleBegin;
    1907         [ #  # ]:          0 :                     if (n < nOldVisibleEnd)
    1908                 :          0 :                         --nOldVisibleEnd;
    1909         [ #  # ]:          0 :                     if (n < nOldFocused)
    1910                 :          0 :                         --nOldFocused;
    1911         [ #  # ]:          0 :                     if (sal::static_int_cast<sal_Int32>(n) < m_nSelectionFirstPara)
    1912                 :          0 :                         --m_nSelectionFirstPara;
    1913         [ #  # ]:          0 :                     else if (sal::static_int_cast<sal_Int32>(n) == m_nSelectionFirstPara)
    1914                 :            :                     {
    1915         [ #  # ]:          0 :                         if (m_nSelectionFirstPara == m_nSelectionLastPara)
    1916                 :            :                         {
    1917                 :          0 :                             m_nSelectionFirstPara = -1;
    1918                 :          0 :                             m_nSelectionFirstPos = -1;
    1919                 :          0 :                             m_nSelectionLastPara = -1;
    1920                 :          0 :                             m_nSelectionLastPos = -1;
    1921                 :            :                         }
    1922                 :            :                         else
    1923                 :            :                         {
    1924                 :          0 :                             ++m_nSelectionFirstPara;
    1925                 :          0 :                             m_nSelectionFirstPos = 0;
    1926                 :            :                         }
    1927                 :            :                     }
    1928         [ #  # ]:          0 :                     if (sal::static_int_cast<sal_Int32>(n) < m_nSelectionLastPara)
    1929                 :          0 :                         --m_nSelectionLastPara;
    1930         [ #  # ]:          0 :                     else if (sal::static_int_cast<sal_Int32>(n) == m_nSelectionLastPara)
    1931                 :            :                     {
    1932                 :            :                         OSL_ENSURE(m_nSelectionFirstPara < m_nSelectionLastPara,
    1933                 :            :                                    "logic error");
    1934                 :          0 :                         --m_nSelectionLastPara;
    1935                 :          0 :                         m_nSelectionLastPos = 0x7FFFFFFF;
    1936                 :            :                     }
    1937                 :            : 
    1938                 :            :                     ::css::uno::Reference< ::css::accessibility::XAccessible >
    1939                 :          0 :                           xStrong;
    1940         [ #  # ]:          0 :                     if (bWasVisible)
    1941 [ #  # ][ #  # ]:          0 :                         xStrong = getAccessibleChild(aIt);
    1942                 :            :                     ::css::uno::WeakReference<
    1943                 :            :                           ::css::accessibility::XAccessible > xWeak(
    1944         [ #  # ]:          0 :                               aIt->getParagraph());
    1945         [ #  # ]:          0 :                     aIt = m_xParagraphs->erase(aIt);
    1946                 :            : 
    1947         [ #  # ]:          0 :                     determineVisibleRange();
    1948                 :          0 :                     m_aFocused = bWasFocused ? m_xParagraphs->end()
    1949 [ #  # ][ #  # ]:          0 :                         : m_xParagraphs->begin() + nOldFocused;
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1950                 :            : 
    1951 [ #  # ][ #  # ]:          0 :                     for (; aIt != m_xParagraphs->end(); ++aIt)
    1952                 :            :                     {
    1953                 :            :                         ::rtl::Reference< ParagraphImpl > xParagraph(
    1954         [ #  # ]:          0 :                             getParagraph(aIt));
    1955         [ #  # ]:          0 :                         if (xParagraph.is())
    1956                 :          0 :                             xParagraph->numberChanged(false);
    1957                 :          0 :                     }
    1958                 :            : 
    1959         [ #  # ]:          0 :                     if (bWasVisible)
    1960                 :            :                         NotifyAccessibleEvent(
    1961                 :            :                             ::css::accessibility::AccessibleEventId::
    1962                 :            :                             CHILD,
    1963                 :            :                             ::css::uno::makeAny(xStrong),
    1964 [ #  # ][ #  # ]:          0 :                             ::css::uno::Any());
    1965                 :            : 
    1966                 :            :                     ::css::uno::Reference< ::css::lang::XComponent > xComponent(
    1967 [ #  # ][ #  # ]:          0 :                         xWeak.get(), ::css::uno::UNO_QUERY);
    1968         [ #  # ]:          0 :                     if (xComponent.is())
    1969 [ #  # ][ #  # ]:          0 :                         xComponent->dispose();
    1970                 :            : 
    1971                 :            :                     notifyVisibleRangeChanges(
    1972                 :          0 :                         m_xParagraphs->begin() + nOldVisibleBegin,
    1973                 :          0 :                         m_xParagraphs->begin() + nOldVisibleEnd,
    1974   [ #  #  #  # ]:          0 :                         m_xParagraphs->end());
         [ #  # ][ #  # ]
    1975                 :            :                 }
    1976                 :          0 :                 break;
    1977                 :            :             }
    1978                 :            :         case TEXT_HINT_FORMATPARA:
    1979                 :            :             {
    1980                 :          0 :                 ::sal_uLong n = aHint.GetValue();
    1981                 :            :                 OSL_ENSURE(n < m_xParagraphs->size(),
    1982                 :            :                            "Bad TEXT_HINT_FORMATPARA event");
    1983                 :            : 
    1984                 :          0 :                 (*m_xParagraphs)[static_cast< Paragraphs::size_type >(n)].
    1985                 :            :                     changeHeight(static_cast< ::sal_Int32 >(
    1986         [ #  # ]:          0 :                                      m_rEngine.GetTextHeight(n)));
    1987                 :            :                     // XXX  numeric overflow
    1988                 :          0 :                 Paragraphs::iterator aOldVisibleBegin(m_aVisibleBegin);
    1989                 :          0 :                 Paragraphs::iterator aOldVisibleEnd(m_aVisibleEnd);
    1990         [ #  # ]:          0 :                 determineVisibleRange();
    1991                 :            :                 notifyVisibleRangeChanges(aOldVisibleBegin, aOldVisibleEnd,
    1992         [ #  # ]:          0 :                                           m_xParagraphs->end());
    1993                 :            : 
    1994         [ #  # ]:          0 :                 if (n < m_xParagraphs->size())
    1995                 :            :                 {
    1996         [ #  # ]:          0 :                     Paragraphs::iterator aIt(m_xParagraphs->begin() + n);
    1997         [ #  # ]:          0 :                     ::rtl::Reference< ParagraphImpl > xParagraph(getParagraph(aIt));
    1998         [ #  # ]:          0 :                     if (xParagraph.is())
    1999         [ #  # ]:          0 :                         xParagraph->textChanged();
    2000                 :            :                 }
    2001                 :            :                 break;
    2002                 :            :             }
    2003                 :            :         default:
    2004                 :            :             OSL_FAIL( "bad buffered hint");
    2005                 :          0 :             break;
    2006                 :            :         }
    2007         [ #  # ]:          0 :     }
    2008         [ #  # ]:          0 :     if (m_bSelectionChangedNotification)
    2009                 :            :     {
    2010                 :          0 :         m_bSelectionChangedNotification = false;
    2011                 :          0 :         handleSelectionChangeNotification();
    2012                 :            :     }
    2013                 :          0 : }
    2014                 :            : 
    2015                 :          0 : void Document::handleSelectionChangeNotification()
    2016                 :            : {
    2017         [ #  # ]:          0 :     ::TextSelection const & rSelection = m_rView.GetSelection();
    2018                 :            :     OSL_ENSURE(rSelection.GetStart().GetPara() < m_xParagraphs->size()
    2019                 :            :                && rSelection.GetEnd().GetPara() < m_xParagraphs->size(),
    2020                 :            :                "bad TEXT_HINT_VIEWSELECTIONCHANGED event");
    2021                 :            :     ::sal_Int32 nNewFirstPara
    2022                 :          0 :           = static_cast< ::sal_Int32 >(rSelection.GetStart().GetPara());
    2023                 :            :     ::sal_Int32 nNewFirstPos
    2024                 :          0 :           = static_cast< ::sal_Int32 >(rSelection.GetStart().GetIndex());
    2025                 :            :         // XXX  numeric overflow
    2026                 :            :     ::sal_Int32 nNewLastPara
    2027                 :          0 :           = static_cast< ::sal_Int32 >(rSelection.GetEnd().GetPara());
    2028                 :            :     ::sal_Int32 nNewLastPos
    2029                 :          0 :           = static_cast< ::sal_Int32 >(rSelection.GetEnd().GetIndex());
    2030                 :            :         // XXX  numeric overflow
    2031                 :            : 
    2032                 :            :     // Lose focus:
    2033         [ #  # ]:          0 :     Paragraphs::iterator aIt(m_xParagraphs->begin() + nNewLastPara);
    2034 [ #  # ][ #  # ]:          0 :     if (m_aFocused != m_xParagraphs->end() && m_aFocused != aIt
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2035 [ #  # ][ #  # ]:          0 :         && m_aFocused >= m_aVisibleBegin && m_aFocused < m_aVisibleEnd)
    2036                 :            :     {
    2037         [ #  # ]:          0 :         ::rtl::Reference< ParagraphImpl > xParagraph(getParagraph(m_aFocused));
    2038         [ #  # ]:          0 :         if (xParagraph.is())
    2039                 :            :             xParagraph->notifyEvent(
    2040                 :            :                 ::css::accessibility::AccessibleEventId::
    2041                 :            :                 STATE_CHANGED,
    2042                 :            :                 ::css::uno::makeAny(
    2043                 :            :                     ::css::accessibility::AccessibleStateType::FOCUSED),
    2044 [ #  # ][ #  # ]:          0 :                 ::css::uno::Any());
    2045                 :            :     }
    2046                 :            : 
    2047                 :            :     // Gain focus and update cursor position:
    2048 [ #  # ][ #  # ]:          0 :     if (aIt >= m_aVisibleBegin && aIt < m_aVisibleEnd
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2049         [ #  # ]:          0 :         && (aIt != m_aFocused
    2050                 :            :             || nNewLastPara != m_nSelectionLastPara
    2051                 :            :             || nNewLastPos != m_nSelectionLastPos))
    2052                 :            :     {
    2053         [ #  # ]:          0 :         ::rtl::Reference< ParagraphImpl > xParagraph(getParagraph(aIt));
    2054         [ #  # ]:          0 :         if (xParagraph.is())
    2055                 :            :         {
    2056 [ #  # ][ #  # ]:          0 :             if (aIt != m_aFocused)
    2057                 :            :                 xParagraph->notifyEvent(
    2058                 :            :                     ::css::accessibility::AccessibleEventId::
    2059                 :            :                     STATE_CHANGED,
    2060                 :            :                     ::css::uno::Any(),
    2061                 :            :                     ::css::uno::makeAny(
    2062 [ #  # ][ #  # ]:          0 :                         ::css::accessibility::AccessibleStateType::FOCUSED));
    2063 [ #  # ][ #  # ]:          0 :             if (nNewLastPara != m_nSelectionLastPara
    2064                 :            :                 || nNewLastPos != m_nSelectionLastPos)
    2065                 :            :                 xParagraph->notifyEvent(
    2066                 :            :                     ::css::accessibility::AccessibleEventId::
    2067                 :            :                     CARET_CHANGED,
    2068                 :            :                     ::css::uno::makeAny< ::sal_Int32 >(
    2069                 :            :                         nNewLastPara == m_nSelectionLastPara
    2070                 :            :                         ? m_nSelectionLastPos : 0),
    2071 [ #  # ][ #  # ]:          0 :                     ::css::uno::makeAny(nNewLastPos));
         [ #  # ][ #  # ]
    2072                 :          0 :         }
    2073                 :            :     }
    2074                 :          0 :     m_aFocused = aIt;
    2075                 :            : 
    2076                 :            :     // Update both old and new selection.  (Regardless of how the two selections
    2077                 :            :     // look like, there will always be two ranges to the left and right of the
    2078                 :            :     // overlap---the overlap and/or the range to the right of it possibly being
    2079                 :            :     // empty.  Only for these two ranges notifications have to be sent.)
    2080                 :            : 
    2081                 :          0 :     TextPaM aOldTextStart( static_cast< sal_uLong >( m_nSelectionFirstPara ), static_cast< sal_uInt16 >( m_nSelectionFirstPos ) );
    2082                 :          0 :     TextPaM aOldTextEnd( static_cast< sal_uLong >( m_nSelectionLastPara ), static_cast< sal_uInt16 >( m_nSelectionLastPos ) );
    2083                 :          0 :     TextPaM aNewTextStart( static_cast< sal_uLong >( nNewFirstPara ), static_cast< sal_uInt16 >( nNewFirstPos ) );
    2084                 :          0 :     TextPaM aNewTextEnd( static_cast< sal_uLong >( nNewLastPara ), static_cast< sal_uInt16 >( nNewLastPos ) );
    2085                 :            : 
    2086                 :            :     // justify selections
    2087                 :          0 :     justifySelection( aOldTextStart, aOldTextEnd );
    2088                 :          0 :     justifySelection( aNewTextStart, aNewTextEnd );
    2089                 :            : 
    2090                 :            :     sal_Int32 nFirst1;
    2091                 :            :     sal_Int32 nLast1;
    2092                 :            :     sal_Int32 nFirst2;
    2093                 :            :     sal_Int32 nLast2;
    2094                 :            : 
    2095         [ #  # ]:          0 :     if ( m_nSelectionFirstPara == -1 )
    2096                 :            :     {
    2097                 :            :         // old selection not initialized yet => notify events only for new selection (if not empty)
    2098                 :          0 :         nFirst1 = aNewTextStart.GetPara();
    2099         [ #  # ]:          0 :         nLast1 = aNewTextEnd.GetPara() + ( aNewTextStart != aNewTextEnd ? 1 : 0 );
    2100                 :          0 :         nFirst2 = 0;
    2101                 :          0 :         nLast2 = 0;
    2102                 :            :     }
    2103 [ #  # ][ #  # ]:          0 :     else if ( aOldTextStart == aOldTextEnd && aNewTextStart == aNewTextEnd )
                 [ #  # ]
    2104                 :            :     {
    2105                 :            :         // old and new selection empty => no events
    2106                 :          0 :         nFirst1 = 0;
    2107                 :          0 :         nLast1 = 0;
    2108                 :          0 :         nFirst2 = 0;
    2109                 :          0 :         nLast2 = 0;
    2110                 :            :     }
    2111 [ #  # ][ #  # ]:          0 :     else if ( aOldTextStart != aOldTextEnd && aNewTextStart == aNewTextEnd )
                 [ #  # ]
    2112                 :            :     {
    2113                 :            :         // old selection not empty + new selection empty => notify events only for old selection
    2114                 :          0 :         nFirst1 = aOldTextStart.GetPara();
    2115                 :          0 :         nLast1 = aOldTextEnd.GetPara() + 1;
    2116                 :          0 :         nFirst2 = 0;
    2117                 :          0 :         nLast2 = 0;
    2118                 :            :     }
    2119 [ #  # ][ #  # ]:          0 :     else if ( aOldTextStart == aOldTextEnd && aNewTextStart != aNewTextEnd )
                 [ #  # ]
    2120                 :            :     {
    2121                 :            :         // old selection empty + new selection not empty => notify events only for new selection
    2122                 :          0 :         nFirst1 = aNewTextStart.GetPara();
    2123                 :          0 :         nLast1 = aNewTextEnd.GetPara() + 1;
    2124                 :          0 :         nFirst2 = 0;
    2125                 :          0 :         nLast2 = 0;
    2126                 :            :     }
    2127                 :            :     else
    2128                 :            :     {
    2129                 :            :         // old and new selection not empty => notify events for the two ranges left and right of the overlap
    2130         [ #  # ]:          0 :         ::std::vector< TextPaM > aTextPaMs(4);
    2131                 :          0 :         aTextPaMs[0] = aOldTextStart;
    2132                 :          0 :         aTextPaMs[1] = aOldTextEnd;
    2133                 :          0 :         aTextPaMs[2] = aNewTextStart;
    2134                 :          0 :         aTextPaMs[3] = aNewTextEnd;
    2135         [ #  # ]:          0 :         ::std::sort( aTextPaMs.begin(), aTextPaMs.end() );
    2136                 :            : 
    2137                 :          0 :         nFirst1 = aTextPaMs[0].GetPara();
    2138         [ #  # ]:          0 :         nLast1 = aTextPaMs[1].GetPara() + ( aTextPaMs[0] != aTextPaMs[1] ? 1 : 0 );
    2139                 :            : 
    2140                 :          0 :         nFirst2 = aTextPaMs[2].GetPara();
    2141         [ #  # ]:          0 :         nLast2 = aTextPaMs[3].GetPara() + ( aTextPaMs[2] != aTextPaMs[3] ? 1 : 0 );
    2142                 :            : 
    2143                 :            :         // adjust overlapping ranges
    2144         [ #  # ]:          0 :         if ( nLast1 > nFirst2 )
    2145                 :          0 :             nLast1 = nFirst2;
    2146                 :            :     }
    2147                 :            : 
    2148                 :            :     // notify selection changes
    2149         [ #  # ]:          0 :     notifySelectionChange( nFirst1, nLast1 );
    2150         [ #  # ]:          0 :     notifySelectionChange( nFirst2, nLast2 );
    2151                 :            : 
    2152                 :          0 :     m_nSelectionFirstPara = nNewFirstPara;
    2153                 :          0 :     m_nSelectionFirstPos = nNewFirstPos;
    2154                 :          0 :     m_nSelectionLastPara = nNewLastPara;
    2155                 :          0 :     m_nSelectionLastPos = nNewLastPos;
    2156                 :          0 : }
    2157                 :            : 
    2158                 :          0 : void Document::notifySelectionChange( sal_Int32 nFirst, sal_Int32 nLast )
    2159                 :            : {
    2160         [ #  # ]:          0 :     if ( nFirst < nLast )
    2161                 :            :     {
    2162 [ #  # ][ #  # ]:          0 :         Paragraphs::iterator aEnd( ::std::min( m_xParagraphs->begin() + nLast, m_aVisibleEnd ) );
    2163 [ #  # ][ #  # ]:          0 :         for ( Paragraphs::iterator aIt = ::std::max( m_xParagraphs->begin() + nFirst, m_aVisibleBegin ); aIt < aEnd; ++aIt )
         [ #  # ][ #  # ]
    2164                 :            :         {
    2165         [ #  # ]:          0 :             ::rtl::Reference< ParagraphImpl > xParagraph( getParagraph( aIt ) );
    2166         [ #  # ]:          0 :             if ( xParagraph.is() )
    2167                 :            :             {
    2168                 :            :                 xParagraph->notifyEvent(
    2169                 :            :                     ::css::accessibility::AccessibleEventId::SELECTION_CHANGED,
    2170         [ #  # ]:          0 :                     ::css::uno::Any(), ::css::uno::Any() );
    2171                 :            :                 xParagraph->notifyEvent(
    2172                 :            :                     ::css::accessibility::AccessibleEventId::TEXT_SELECTION_CHANGED,
    2173         [ #  # ]:          0 :                     ::css::uno::Any(), ::css::uno::Any() );
    2174                 :            :             }
    2175                 :          0 :         }
    2176                 :            :     }
    2177                 :          0 : }
    2178                 :            : 
    2179                 :          0 : void Document::justifySelection( TextPaM& rTextStart, TextPaM& rTextEnd )
    2180                 :            : {
    2181         [ #  # ]:          0 :     if ( rTextStart > rTextEnd )
    2182                 :            :     {
    2183                 :          0 :         TextPaM aTextPaM( rTextStart );
    2184                 :          0 :         rTextStart = rTextEnd;
    2185                 :          0 :         rTextEnd = aTextPaM;
    2186                 :            :     }
    2187                 :          0 : }
    2188                 :            : 
    2189                 :          0 : void Document::disposeParagraphs()
    2190                 :            : {
    2191 [ #  # ][ #  # ]:          0 :     for (Paragraphs::iterator aIt(m_xParagraphs->begin());
    2192                 :          0 :          aIt != m_xParagraphs->end(); ++aIt)
    2193                 :            :     {
    2194                 :            :         ::css::uno::Reference< ::css::lang::XComponent > xComponent(
    2195 [ #  # ][ #  # ]:          0 :             aIt->getParagraph().get(), ::css::uno::UNO_QUERY);
    2196         [ #  # ]:          0 :         if (xComponent.is())
    2197 [ #  # ][ #  # ]:          0 :             xComponent->dispose();
    2198                 :          0 :     }
    2199                 :          0 : }
    2200                 :            : 
    2201                 :            : // static
    2202                 :          0 : ::css::uno::Any Document::mapFontColor(::Color const & rColor)
    2203                 :            : {
    2204                 :            :     return ::css::uno::makeAny(
    2205         [ #  # ]:          0 :         static_cast< ::sal_Int32 >(COLORDATA_RGB(rColor.GetColor())));
    2206                 :            :         // FIXME  keep transparency?
    2207                 :            : }
    2208                 :            : 
    2209                 :            : // static
    2210                 :          0 : ::Color Document::mapFontColor(::css::uno::Any const & rColor)
    2211                 :            : {
    2212                 :          0 :     ::sal_Int32 nColor = 0;
    2213                 :          0 :     rColor >>= nColor;
    2214                 :          0 :     return ::Color(static_cast< ::ColorData >(nColor));
    2215                 :            : }
    2216                 :            : 
    2217                 :            : // static
    2218                 :          0 : ::css::uno::Any Document::mapFontWeight(::FontWeight nWeight)
    2219                 :            : {
    2220                 :            :     // Map from ::FontWeight to ::css:awt::FontWeight, depends on order of
    2221                 :            :     // elements in ::FontWeight (vcl/vclenum.hxx):
    2222                 :            :     static float const aWeight[]
    2223                 :            :         = { ::css::awt::FontWeight::DONTKNOW, // WEIGHT_DONTKNOW
    2224                 :            :             ::css::awt::FontWeight::THIN, // WEIGHT_THIN
    2225                 :            :             ::css::awt::FontWeight::ULTRALIGHT, // WEIGHT_ULTRALIGHT
    2226                 :            :             ::css::awt::FontWeight::LIGHT, // WEIGHT_LIGHT
    2227                 :            :             ::css::awt::FontWeight::SEMILIGHT, // WEIGHT_SEMILIGHT
    2228                 :            :             ::css::awt::FontWeight::NORMAL, // WEIGHT_NORMAL
    2229                 :            :             ::css::awt::FontWeight::NORMAL, // WEIGHT_MEDIUM
    2230                 :            :             ::css::awt::FontWeight::SEMIBOLD, // WEIGHT_SEMIBOLD
    2231                 :            :             ::css::awt::FontWeight::BOLD, // WEIGHT_BOLD
    2232                 :            :             ::css::awt::FontWeight::ULTRABOLD, // WEIGHT_ULTRABOLD
    2233                 :            :             ::css::awt::FontWeight::BLACK }; // WEIGHT_BLACK
    2234                 :          0 :     return ::css::uno::makeAny(aWeight[nWeight]);
    2235                 :            : }
    2236                 :            : 
    2237                 :            : // static
    2238                 :          0 : ::FontWeight Document::mapFontWeight(::css::uno::Any const & rWeight)
    2239                 :            : {
    2240                 :          0 :     float nWeight = ::css::awt::FontWeight::NORMAL;
    2241                 :          0 :     rWeight >>= nWeight;
    2242                 :            :     return nWeight <= ::css::awt::FontWeight::DONTKNOW ? WEIGHT_DONTKNOW
    2243                 :            :         : nWeight <= ::css::awt::FontWeight::THIN ? WEIGHT_THIN
    2244                 :            :         : nWeight <= ::css::awt::FontWeight::ULTRALIGHT ? WEIGHT_ULTRALIGHT
    2245                 :            :         : nWeight <= ::css::awt::FontWeight::LIGHT ? WEIGHT_LIGHT
    2246                 :            :         : nWeight <= ::css::awt::FontWeight::SEMILIGHT ? WEIGHT_SEMILIGHT
    2247                 :            :         : nWeight <= ::css::awt::FontWeight::NORMAL ? WEIGHT_NORMAL
    2248                 :            :         : nWeight <= ::css::awt::FontWeight::SEMIBOLD ? WEIGHT_SEMIBOLD
    2249                 :            :         : nWeight <= ::css::awt::FontWeight::BOLD ? WEIGHT_BOLD
    2250                 :            :         : nWeight <= ::css::awt::FontWeight::ULTRABOLD ? WEIGHT_ULTRABOLD
    2251 [ #  # ][ #  # ]:          0 :         : WEIGHT_BLACK;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2252                 :            : }
    2253                 :            : 
    2254                 :            : }
    2255                 :            : 
    2256                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10