LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unotext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 822 1258 65.3 %
Date: 2012-08-25 Functions: 76 99 76.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1091 2823 38.6 %

           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 <stdlib.h>
      31                 :            : 
      32                 :            : #include <memory>
      33                 :            : #include <iostream>
      34                 :            : 
      35                 :            : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      36                 :            : #include <com/sun/star/text/ControlCharacter.hpp>
      37                 :            : #include <com/sun/star/text/TableColumnSeparator.hpp>
      38                 :            : 
      39                 :            : #include <osl/mutex.hxx>
      40                 :            : #include <vcl/svapp.hxx>
      41                 :            : #include <comphelper/sequence.hxx>
      42                 :            : #include <comphelper/servicehelper.hxx>
      43                 :            : 
      44                 :            : #include <cmdid.h>
      45                 :            : #include <unotextbodyhf.hxx>
      46                 :            : #include <unotext.hxx>
      47                 :            : #include <unotextrange.hxx>
      48                 :            : #include <unotextcursor.hxx>
      49                 :            : #include <unosection.hxx>
      50                 :            : #include <unobookmark.hxx>
      51                 :            : #include <unorefmark.hxx>
      52                 :            : #include <unoport.hxx>
      53                 :            : #include <unotbl.hxx>
      54                 :            : #include <unoidx.hxx>
      55                 :            : #include <unoframe.hxx>
      56                 :            : #include <unofield.hxx>
      57                 :            : #include <unometa.hxx>
      58                 :            : #include <unodraw.hxx>
      59                 :            : #include <unoredline.hxx>
      60                 :            : #include <unomap.hxx>
      61                 :            : #include <unoprnms.hxx>
      62                 :            : #include <unoparagraph.hxx>
      63                 :            : #include <unocrsrhelper.hxx>
      64                 :            : #include <docsh.hxx>
      65                 :            : #include <docary.hxx>
      66                 :            : #include <doc.hxx>
      67                 :            : #include <IDocumentUndoRedo.hxx>
      68                 :            : #include <redline.hxx>
      69                 :            : #include <swundo.hxx>
      70                 :            : #include <section.hxx>
      71                 :            : #include <IMark.hxx>
      72                 :            : #include <fmtanchr.hxx>
      73                 :            : #include <fmtcntnt.hxx>
      74                 :            : #include <crsskip.hxx>
      75                 :            : #include <ndtxt.hxx>
      76                 :            : 
      77                 :            : 
      78                 :            : using namespace ::com::sun::star;
      79                 :            : using ::rtl::OUString;
      80                 :            : 
      81                 :            : 
      82                 :            : const sal_Char cInvalidObject[] = "this object is invalid";
      83                 :            : 
      84                 :            : /******************************************************************
      85                 :            :  * SwXText
      86                 :            :  ******************************************************************/
      87                 :            : class SwXText::Impl
      88                 :            : {
      89                 :            : 
      90                 :            : public:
      91                 :            :     SwXText &                   m_rThis;
      92                 :            :     SfxItemPropertySet const&   m_rPropSet;
      93                 :            :     const enum CursorType       m_eType;
      94                 :            :     SwDoc *                     m_pDoc;
      95                 :            :     bool                        m_bIsValid;
      96                 :            : 
      97                 :       3073 :     Impl(   SwXText & rThis,
      98                 :            :             SwDoc *const pDoc, const enum CursorType eType)
      99                 :            :         : m_rThis(rThis)
     100                 :       3073 :         , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT))
     101                 :            :         , m_eType(eType)
     102                 :            :         , m_pDoc(pDoc)
     103                 :       6146 :         , m_bIsValid(0 != pDoc)
     104                 :            :     {
     105                 :       3073 :     }
     106                 :            : 
     107                 :            :     uno::Reference< text::XTextRange >
     108                 :            :         finishOrAppendParagraph(
     109                 :            :             const bool bFinish,
     110                 :            :             const uno::Sequence< beans::PropertyValue >&
     111                 :            :                 rCharacterAndParagraphProperties)
     112                 :            :         throw (lang::IllegalArgumentException, uno::RuntimeException);
     113                 :            : 
     114                 :            :     sal_Int16 ComparePositions(
     115                 :            :             const uno::Reference<text::XTextRange>& xPos1,
     116                 :            :             const uno::Reference<text::XTextRange>& xPos2)
     117                 :            :         throw (lang::IllegalArgumentException, uno::RuntimeException);
     118                 :            : 
     119                 :            :     bool CheckForOwnMember(const SwPaM & rPaM)
     120                 :            :         throw (lang::IllegalArgumentException, uno::RuntimeException);
     121                 :            : 
     122                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     123                 :            :     void ConvertCell(
     124                 :            :             const bool bFirstCell,
     125                 :            :             const uno::Sequence< uno::Reference< text::XTextRange > > & rCell,
     126                 :            :             ::std::vector<SwNodeRange> & rRowNodes,
     127                 :            :             ::std::auto_ptr< SwPaM > & rpFirstPaM,
     128                 :            :             SwPaM & rLastPaM,
     129                 :            :             bool & rbExcept);
     130                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     131                 :            : 
     132                 :            : };
     133                 :            : 
     134                 :       3073 : SwXText::SwXText(SwDoc *const pDoc, const enum CursorType eType)
     135 [ +  - ][ +  - ]:       3073 :     : m_pImpl( new SwXText::Impl(*this, pDoc, eType) )
     136                 :            : {
     137                 :       3073 : }
     138                 :            : 
     139         [ +  - ]:       2989 : SwXText::~SwXText()
     140                 :            : {
     141         [ -  + ]:       2989 : }
     142                 :            : 
     143                 :      12985 : const SwDoc * SwXText::GetDoc() const
     144                 :            : {
     145                 :      12985 :     return m_pImpl->m_pDoc;
     146                 :            : }
     147                 :      81950 :       SwDoc * SwXText::GetDoc()
     148                 :            : {
     149                 :      81950 :     return m_pImpl->m_pDoc;
     150                 :            : }
     151                 :            : 
     152                 :      15211 : bool SwXText::IsValid() const
     153                 :            : {
     154                 :      15211 :     return m_pImpl->m_bIsValid;
     155                 :            : }
     156                 :            : 
     157                 :        182 : void SwXText::Invalidate()
     158                 :            : {
     159                 :        182 :     m_pImpl->m_bIsValid = false;
     160                 :        182 : }
     161                 :            : 
     162                 :        271 : void SwXText::SetDoc(SwDoc *const pDoc)
     163                 :            : {
     164                 :            :     OSL_ENSURE(!m_pImpl->m_pDoc || !pDoc,
     165                 :            :         "SwXText::SetDoc: already have a doc?");
     166                 :        271 :     m_pImpl->m_pDoc = pDoc;
     167                 :        271 :     m_pImpl->m_bIsValid = (0 != pDoc);
     168                 :        271 : }
     169                 :            : 
     170                 :            : void
     171                 :          0 : SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &)
     172                 :            : {
     173                 :          0 : }
     174                 :            : 
     175                 :       6447 : bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool)
     176                 :            :     throw (lang::IllegalArgumentException, uno::RuntimeException)
     177                 :            : {
     178                 :            :     OSL_ENSURE(CURSOR_META != m_pImpl->m_eType, "should not be called!");
     179                 :       6447 :     return false;
     180                 :            : }
     181                 :            : 
     182                 :      12985 : const SwStartNode *SwXText::GetStartNode() const
     183                 :            : {
     184                 :      12985 :     return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode();
     185                 :            : }
     186                 :            : 
     187                 :            : uno::Reference< text::XTextCursor >
     188                 :       2151 : SwXText::CreateCursor() throw (uno::RuntimeException)
     189                 :            : {
     190                 :       2151 :     uno::Reference< text::XTextCursor >  xRet;
     191 [ +  - ][ +  - ]:       2151 :     if(IsValid())
     192                 :            :     {
     193 [ +  - ][ +  - ]:       2151 :         SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
     194         [ +  - ]:       2151 :         SwPosition aPos(rNode);
     195                 :            :         xRet = static_cast<text::XWordCursor*>(
     196 [ +  - ][ +  - ]:       2151 :                 new SwXTextCursor(*GetDoc(), this, m_pImpl->m_eType, aPos));
         [ +  - ][ +  - ]
                 [ +  - ]
     197 [ +  - ][ +  - ]:       2151 :         xRet->gotoStart(sal_False);
                 [ +  - ]
     198                 :            :     }
     199                 :       2151 :     return xRet;
     200                 :            : }
     201                 :            : 
     202                 :            : uno::Any SAL_CALL
     203                 :       4923 : SwXText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException)
     204                 :            : {
     205                 :       4923 :     uno::Any aRet;
     206 [ +  + ][ +  - ]:       4923 :     if (rType == text::XText::static_type())
     207                 :            :     {
     208 [ +  - ][ +  - ]:         77 :         aRet <<= uno::Reference< text::XText >(this);
     209                 :            :     }
     210 [ +  - ][ +  + ]:       4846 :     else if (rType == text::XSimpleText::static_type())
     211                 :            :     {
     212 [ +  - ][ +  - ]:          6 :         aRet <<= uno::Reference< text::XSimpleText >(this);
     213                 :            :     }
     214 [ +  - ][ +  + ]:       4840 :     else if (rType == text::XTextRange::static_type())
     215                 :            :     {
     216 [ +  - ][ +  - ]:         20 :         aRet <<= uno::Reference< text::XTextRange>(this);
     217                 :            :     }
     218 [ +  - ][ +  + ]:       4820 :     else if (rType == text::XTextRangeCompare::static_type())
     219                 :            :     {
     220 [ +  - ][ +  - ]:         10 :         aRet <<= uno::Reference< text::XTextRangeCompare >(this);
     221                 :            :     }
     222 [ +  - ][ -  + ]:       4810 :     else if (rType == lang::XTypeProvider::static_type())
     223                 :            :     {
     224 [ #  # ][ #  # ]:          0 :         aRet <<= uno::Reference< lang::XTypeProvider >(this);
     225                 :            :     }
     226 [ +  - ][ +  + ]:       4810 :     else if (rType == text::XRelativeTextContentInsert::static_type())
     227                 :            :     {
     228 [ +  - ][ +  - ]:         10 :         aRet <<= uno::Reference< text::XRelativeTextContentInsert >(this);
     229                 :            :     }
     230 [ +  - ][ -  + ]:       4800 :     else if (rType == text::XRelativeTextContentRemove::static_type())
     231                 :            :     {
     232 [ #  # ][ #  # ]:          0 :         aRet <<= uno::Reference< text::XRelativeTextContentRemove >(this);
     233                 :            :     }
     234 [ +  - ][ +  + ]:       4800 :     else if (rType == beans::XPropertySet::static_type())
     235                 :            :     {
     236 [ +  - ][ +  - ]:         25 :         aRet <<= uno::Reference< beans::XPropertySet >(this);
     237                 :            :     }
     238 [ +  - ][ +  + ]:       4775 :     else if (rType == lang::XUnoTunnel::static_type())
     239                 :            :     {
     240 [ +  - ][ +  - ]:        737 :         aRet <<= uno::Reference< lang::XUnoTunnel >(this);
     241                 :            :     }
     242 [ +  - ][ +  + ]:       4038 :     else if (rType == text::XTextAppendAndConvert::static_type())
     243                 :            :     {
     244 [ +  - ][ +  - ]:       1037 :         aRet <<= uno::Reference< text::XTextAppendAndConvert >(this);
     245                 :            :     }
     246 [ +  - ][ +  + ]:       3001 :     else if (rType == text::XTextAppend::static_type())
     247                 :            :     {
     248 [ +  - ][ +  - ]:        530 :         aRet <<= uno::Reference< text::XTextAppend >(this);
     249                 :            :     }
     250 [ +  - ][ -  + ]:       2471 :     else if (rType == text::XTextPortionAppend::static_type())
     251                 :            :     {
     252 [ #  # ][ #  # ]:          0 :         aRet <<= uno::Reference< text::XTextPortionAppend >(this);
     253                 :            :     }
     254 [ +  - ][ -  + ]:       2471 :     else if (rType == text::XParagraphAppend::static_type())
     255                 :            :     {
     256 [ #  # ][ #  # ]:          0 :         aRet <<= uno::Reference< text::XParagraphAppend >(this);
     257                 :            :     }
     258 [ +  - ][ -  + ]:       2471 :     else if (rType == text::XTextConvert::static_type() )
     259                 :            :     {
     260 [ #  # ][ #  # ]:          0 :         aRet <<= uno::Reference< text::XTextConvert >(this);
     261                 :            :     }
     262 [ +  - ][ -  + ]:       2471 :     else if (rType == text::XTextContentAppend::static_type())
     263                 :            :     {
     264 [ #  # ][ #  # ]:          0 :         aRet <<= uno::Reference< text::XTextContentAppend >(this);
     265                 :            :     }
     266 [ +  - ][ +  + ]:       2471 :     else if(rType == text::XTextCopy::static_type())
     267                 :            :     {
     268 [ +  - ][ +  - ]:         18 :         aRet <<= uno::Reference< text::XTextCopy >( this );
     269                 :            :     }
     270                 :       4923 :     return aRet;
     271                 :            : }
     272                 :            : 
     273                 :            : uno::Sequence< uno::Type > SAL_CALL
     274                 :          0 : SwXText::getTypes() throw (uno::RuntimeException)
     275                 :            : {
     276                 :          0 :     uno::Sequence< uno::Type > aRet(12);
     277         [ #  # ]:          0 :     uno::Type* pTypes = aRet.getArray();
     278         [ #  # ]:          0 :     pTypes[0] = text::XText::static_type();
     279         [ #  # ]:          0 :     pTypes[1] = text::XTextRangeCompare::static_type();
     280         [ #  # ]:          0 :     pTypes[2] = text::XRelativeTextContentInsert::static_type();
     281         [ #  # ]:          0 :     pTypes[3] = text::XRelativeTextContentRemove::static_type();
     282         [ #  # ]:          0 :     pTypes[4] = lang::XUnoTunnel::static_type();
     283         [ #  # ]:          0 :     pTypes[5] = beans::XPropertySet::static_type();
     284         [ #  # ]:          0 :     pTypes[6] = text::XTextPortionAppend::static_type();
     285         [ #  # ]:          0 :     pTypes[7] = text::XParagraphAppend::static_type();
     286         [ #  # ]:          0 :     pTypes[8] = text::XTextContentAppend::static_type();
     287         [ #  # ]:          0 :     pTypes[9] = text::XTextConvert::static_type();
     288         [ #  # ]:          0 :     pTypes[10] = text::XTextAppend::static_type();
     289         [ #  # ]:          0 :     pTypes[11] = text::XTextAppendAndConvert::static_type();
     290                 :            : 
     291                 :          0 :     return aRet;
     292                 :            : }
     293                 :            : 
     294                 :            : // belongs the range in the text ? insert it then.
     295                 :            : void SAL_CALL
     296                 :       6042 : SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
     297                 :            :     const OUString& rString, sal_Bool bAbsorb)
     298                 :            : throw (uno::RuntimeException)
     299                 :            : {
     300         [ +  - ]:       6042 :     SolarMutexGuard aGuard;
     301                 :            : 
     302         [ +  + ]:       6042 :     if (!xTextRange.is())
     303                 :            :     {
     304         [ +  - ]:          2 :         throw uno::RuntimeException();
     305                 :            :     }
     306 [ +  - ][ -  + ]:       6040 :     if (!GetDoc())
     307                 :            :     {
     308         [ #  # ]:          0 :         throw uno::RuntimeException();
     309                 :            :     }
     310                 :            :     const uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange,
     311         [ +  - ]:       6040 :             uno::UNO_QUERY);
     312                 :            :     SwXTextRange *const pRange =
     313         [ +  - ]:       6040 :         ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
     314                 :            :     OTextCursorHelper *const pCursor =
     315         [ +  - ]:       6040 :         ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
     316 [ -  + ][ #  # ]:      12080 :     if ((!pRange  || pRange ->GetDoc() != GetDoc()) &&
         [ #  # ][ #  # ]
         [ +  - ][ -  + ]
                 [ -  + ]
     317 [ +  - ][ +  - ]:       6040 :         (!pCursor || pCursor->GetDoc() != GetDoc()))
     318                 :            :     {
     319         [ #  # ]:          0 :         throw uno::RuntimeException();
     320                 :            :     }
     321                 :            : 
     322         [ +  - ]:       6040 :     const SwStartNode *const pOwnStartNode = GetStartNode();
     323 [ +  - ][ +  - ]:       6040 :     SwPaM aPam(GetDoc()->GetNodes());
         [ +  - ][ +  - ]
                 [ +  - ]
     324                 :       6040 :     const SwPaM * pPam(0);
     325         [ +  - ]:       6040 :     if (pCursor)
     326                 :            :     {
     327         [ +  - ]:       6040 :         pPam = pCursor->GetPaM();
     328                 :            :     }
     329                 :            :     else // pRange
     330                 :            :     {
     331 [ #  # ][ #  # ]:          0 :         if (pRange->GetPositions(aPam))
     332                 :            :         {
     333                 :          0 :             pPam = &aPam;
     334                 :            :         }
     335                 :            :     }
     336         [ -  + ]:       6040 :     if (!pPam)
     337                 :            :     {
     338         [ #  # ]:          0 :         throw uno::RuntimeException();
     339                 :            :     }
     340                 :            : 
     341                 :       6040 :     const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode());
     342 [ +  - ][ +  + ]:       6389 :     while (pTmp && pTmp->IsSectionNode())
                 [ +  + ]
     343                 :            :     {
     344                 :        349 :         pTmp = pTmp->StartOfSectionNode();
     345                 :            :     }
     346 [ +  - ][ -  + ]:       6040 :     if (!pOwnStartNode || (pOwnStartNode != pTmp))
     347                 :            :     {
     348         [ #  # ]:          0 :         throw uno::RuntimeException();
     349                 :            :     }
     350                 :            : 
     351                 :       6040 :     bool bForceExpandHints( false );
     352         [ +  + ]:       6040 :     if (CURSOR_META == m_pImpl->m_eType)
     353                 :            :     {
     354                 :            :         try
     355                 :            :         {
     356         [ +  + ]:          6 :             bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb);
     357                 :            :         }
     358         [ -  + ]:          4 :         catch (const lang::IllegalArgumentException& iae)
     359                 :            :         {
     360                 :            :             // stupid method not allowed to throw iae
     361 [ -  + ][ -  + ]:          2 :             throw uno::RuntimeException(iae.Message, 0);
     362                 :            :         }
     363                 :            :     }
     364         [ +  + ]:       6038 :     if (bAbsorb)
     365                 :            :     {
     366                 :            :         //!! scan for CR characters and inserting the paragraph breaks
     367                 :            :         //!! has to be done in the called function.
     368                 :            :         //!! Implemented in SwXTextRange::DeleteAndInsert
     369         [ +  - ]:        179 :         if (pCursor)
     370                 :            :         {
     371                 :            :             SwXTextCursor * const pTextCursor(
     372         [ -  + ]:        179 :                 dynamic_cast<SwXTextCursor*>(pCursor) );
     373         [ +  - ]:        179 :             if (pTextCursor)
     374                 :            :             {
     375         [ +  - ]:        179 :                 pTextCursor->DeleteAndInsert(rString, bForceExpandHints);
     376                 :            :             }
     377                 :            :             else
     378                 :            :             {
     379 [ #  # ][ #  # ]:          0 :                 xTextRange->setString(rString);
     380                 :            :             }
     381                 :            :         }
     382                 :            :         else
     383                 :            :         {
     384         [ #  # ]:          0 :             pRange->DeleteAndInsert(rString, bForceExpandHints);
     385                 :            :         }
     386                 :            :     }
     387                 :            :     else
     388                 :            :     {
     389                 :            :         // create a PaM positioned before the parameter PaM,
     390                 :            :         // so the text is inserted before
     391 [ +  - ][ +  - ]:       5859 :         UnoActionContext aContext(GetDoc());
     392 [ +  - ][ +  - ]:       5859 :         SwPaM aInsertPam(*pPam->Start());
     393 [ +  - ][ +  - ]:       5859 :         ::sw::GroupUndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
                 [ +  - ]
     394                 :            :         SwUnoCursorHelper::DocInsertStringSplitCR(
     395 [ +  - ][ +  - ]:       5859 :             *GetDoc(), aInsertPam, rString, bForceExpandHints );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     396 [ +  - ][ +  - ]:       6042 :     }
     397                 :       6038 : }
     398                 :            : 
     399                 :            : void SAL_CALL
     400                 :       1517 : SwXText::insertControlCharacter(
     401                 :            :         const uno::Reference< text::XTextRange > & xTextRange,
     402                 :            :         sal_Int16 nControlCharacter, sal_Bool bAbsorb)
     403                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
     404                 :            : {
     405         [ +  - ]:       1517 :     SolarMutexGuard aGuard;
     406                 :            : 
     407         [ +  + ]:       1517 :     if (!xTextRange.is())
     408                 :            :     {
     409         [ +  - ]:          2 :         throw lang::IllegalArgumentException();
     410                 :            :     }
     411 [ +  - ][ -  + ]:       1515 :     if (!GetDoc())
     412                 :            :     {
     413         [ #  # ]:          0 :         throw uno::RuntimeException();
     414                 :            :     }
     415                 :            : 
     416 [ +  - ][ +  - ]:       1515 :     SwUnoInternalPaM aPam(*GetDoc());
     417 [ +  - ][ -  + ]:       1515 :     if (!::sw::XTextRangeToSwPaM(aPam, xTextRange))
     418                 :            :     {
     419         [ #  # ]:          0 :         throw uno::RuntimeException();
     420                 :            :     }
     421         [ +  + ]:       1515 :     const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb));
     422                 :            : 
     423                 :            :     const enum IDocumentContentOperations::InsertFlags nInsertFlags =
     424                 :            :         (bForceExpandHints)
     425                 :            :         ? static_cast<IDocumentContentOperations::InsertFlags>(
     426                 :            :                 IDocumentContentOperations::INS_FORCEHINTEXPAND |
     427                 :            :                 IDocumentContentOperations::INS_EMPTYEXPAND)
     428         [ +  + ]:       1513 :         : IDocumentContentOperations::INS_EMPTYEXPAND;
     429                 :            : 
     430 [ +  - ][ +  - ]:       1513 :     SwPaM aTmp(*aPam.Start());
     431 [ -  + ][ #  # ]:       1513 :     if (bAbsorb && aPam.HasMark())
                 [ -  + ]
     432                 :            :     {
     433         [ #  # ]:          0 :         m_pImpl->m_pDoc->DeleteAndJoin(aPam);
     434                 :            :     }
     435                 :            : 
     436                 :       1513 :     sal_Unicode cIns = 0;
     437   [ +  +  +  -  :       1513 :     switch (nControlCharacter)
                +  -  - ]
     438                 :            :     {
     439                 :            :         case text::ControlCharacter::PARAGRAPH_BREAK :
     440                 :            :             // a table cell now becomes an ordinary text cell!
     441         [ +  - ]:        436 :             m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode );
     442         [ +  - ]:        436 :             m_pImpl->m_pDoc->SplitNode( *aTmp.GetPoint(), sal_False );
     443                 :        436 :             break;
     444                 :            :         case text::ControlCharacter::APPEND_PARAGRAPH:
     445                 :            :         {
     446         [ +  - ]:        925 :             m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode );
     447         [ +  - ]:        925 :             m_pImpl->m_pDoc->AppendTxtNode( *aTmp.GetPoint() );
     448                 :            : 
     449                 :            :             const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
     450         [ +  - ]:        925 :                     xTextRange, uno::UNO_QUERY);
     451                 :            :             SwXTextRange *const pRange =
     452         [ +  - ]:        925 :                 ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
     453                 :            :             OTextCursorHelper *const pCursor =
     454                 :            :                 ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(
     455         [ +  - ]:        925 :                             xRangeTunnel);
     456         [ -  + ]:        925 :             if (pRange)
     457                 :            :             {
     458         [ #  # ]:          0 :                 pRange->SetPositions(aTmp);
     459                 :            :             }
     460         [ +  - ]:        925 :             else if (pCursor)
     461                 :            :             {
     462         [ +  - ]:        925 :                 SwPaM *const pCrsr = pCursor->GetPaM();
     463         [ +  - ]:        925 :                 *pCrsr->GetPoint() = *aTmp.GetPoint();
     464         [ +  - ]:        925 :                 pCrsr->DeleteMark();
     465                 :        925 :             }
     466                 :            :         }
     467                 :        925 :         break;
     468                 :        148 :         case text::ControlCharacter::LINE_BREAK:  cIns = 10;              break;
     469                 :          0 :         case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
     470                 :          4 :         case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break;
     471                 :          0 :         case text::ControlCharacter::HARD_SPACE:  cIns = CHAR_HARDBLANK;  break;
     472                 :            :     }
     473         [ +  + ]:       1513 :     if (cIns)
     474                 :            :     {
     475 [ +  - ][ +  - ]:        152 :         m_pImpl->m_pDoc->InsertString( aTmp, rtl::OUString(cIns), nInsertFlags );
                 [ +  - ]
     476                 :            :     }
     477                 :            : 
     478         [ -  + ]:       1513 :     if (bAbsorb)
     479                 :            :     {
     480                 :            :         const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
     481         [ #  # ]:          0 :                 xTextRange, uno::UNO_QUERY);
     482                 :            :         SwXTextRange *const pRange =
     483         [ #  # ]:          0 :             ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
     484                 :            :         OTextCursorHelper *const pCursor =
     485         [ #  # ]:          0 :             ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
     486                 :            : 
     487         [ #  # ]:          0 :         SwCursor aCrsr(*aTmp.GetPoint(),0,false);
     488         [ #  # ]:          0 :         SwUnoCursorHelper::SelectPam(aCrsr, true);
     489         [ #  # ]:          0 :         aCrsr.Left(1, CRSR_SKIP_CHARS, sal_False, sal_False);
     490                 :            :         //hier muss der uebergebene PaM umgesetzt werden:
     491         [ #  # ]:          0 :         if (pRange)
     492                 :            :         {
     493         [ #  # ]:          0 :             pRange->SetPositions(aCrsr);
     494                 :            :         }
     495                 :            :         else
     496                 :            :         {
     497         [ #  # ]:          0 :             SwPaM *const pUnoCrsr = pCursor->GetPaM();
     498         [ #  # ]:          0 :             *pUnoCrsr->GetPoint() = *aCrsr.GetPoint();
     499         [ #  # ]:          0 :             if (aCrsr.HasMark())
     500                 :            :             {
     501         [ #  # ]:          0 :                 pUnoCrsr->SetMark();
     502         [ #  # ]:          0 :                 *pUnoCrsr->GetMark() = *aCrsr.GetMark();
     503                 :            :             }
     504                 :            :             else
     505                 :            :             {
     506         [ #  # ]:          0 :                 pUnoCrsr->DeleteMark();
     507                 :            :             }
     508         [ #  # ]:          0 :         }
     509 [ +  - ][ +  - ]:       1517 :     }
                 [ +  - ]
     510                 :       1513 : }
     511                 :            : 
     512                 :            : void SAL_CALL
     513                 :       5038 : SwXText::insertTextContent(
     514                 :            :         const uno::Reference< text::XTextRange > & xRange,
     515                 :            :         const uno::Reference< text::XTextContent > & xContent,
     516                 :            :         sal_Bool bAbsorb)
     517                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
     518                 :            : {
     519         [ +  - ]:       5038 :     SolarMutexGuard aGuard;
     520                 :            : 
     521         [ +  + ]:       5038 :     if (!xRange.is())
     522                 :            :     {
     523         [ +  - ]:          2 :         lang::IllegalArgumentException aIllegal;
     524         [ +  - ]:          2 :         aIllegal.Message = C2U("first parameter invalid;");
     525         [ +  - ]:          2 :         throw aIllegal;
     526                 :            :     }
     527         [ +  + ]:       5036 :     if (!xContent.is())
     528                 :            :     {
     529         [ +  - ]:         16 :         lang::IllegalArgumentException aIllegal;
     530         [ +  - ]:         16 :         aIllegal.Message += C2U("second parameter invalid");
     531         [ +  - ]:         16 :         throw aIllegal;
     532                 :            :     }
     533 [ +  - ][ -  + ]:       5020 :     if(!GetDoc())
     534                 :            :     {
     535         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     536         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     537         [ #  # ]:          0 :         throw aRuntime;
     538                 :            :     }
     539                 :            : 
     540 [ +  - ][ +  - ]:       5020 :     SwUnoInternalPaM aPam(*GetDoc());
     541 [ +  - ][ -  + ]:       5020 :     if (!::sw::XTextRangeToSwPaM(aPam, xRange))
     542                 :            :     {
     543         [ #  # ]:          0 :         lang::IllegalArgumentException aIllegal;
     544         [ #  # ]:          0 :         aIllegal.Message = C2U("first parameter invalid");
     545         [ #  # ]:          0 :         throw aIllegal;
     546                 :            :     }
     547                 :            :     // first test if the range is at the right position, then call
     548                 :            :     // xContent->attach
     549         [ +  - ]:       5020 :     const SwStartNode* pOwnStartNode = GetStartNode();
     550                 :       5020 :     SwStartNodeType eSearchNodeType = SwNormalStartNode;
     551   [ +  +  +  +  :       5020 :     switch (m_pImpl->m_eType)
                   -  + ]
     552                 :            :     {
     553                 :          4 :         case CURSOR_FRAME:      eSearchNodeType = SwFlyStartNode;       break;
     554                 :          4 :         case CURSOR_TBLTEXT:    eSearchNodeType = SwTableBoxStartNode;  break;
     555                 :          6 :         case CURSOR_FOOTNOTE:   eSearchNodeType = SwFootnoteStartNode;  break;
     556                 :         13 :         case CURSOR_HEADER:     eSearchNodeType = SwHeaderStartNode;    break;
     557                 :          0 :         case CURSOR_FOOTER:     eSearchNodeType = SwFooterStartNode;    break;
     558                 :            :         //case CURSOR_INVALID:
     559                 :            :         //case CURSOR_BODY:
     560                 :            :         default:
     561                 :       4993 :             break;
     562                 :            :     }
     563                 :            : 
     564                 :            :     const SwStartNode* pTmp =
     565         [ +  - ]:       5020 :         aPam.GetNode()->FindSttNodeByType(eSearchNodeType);
     566                 :            : 
     567                 :            :     // ignore SectionNodes
     568 [ +  - ][ +  + ]:       5058 :     while (pTmp && pTmp->IsSectionNode())
                 [ +  + ]
     569                 :            :     {
     570                 :         38 :         pTmp = pTmp->StartOfSectionNode();
     571                 :            :     }
     572                 :            :     // if the document starts with a section
     573         [ -  + ]:       5020 :     while (pOwnStartNode->IsSectionNode())
     574                 :            :     {
     575                 :          0 :         pOwnStartNode = pOwnStartNode->StartOfSectionNode();
     576                 :            :     }
     577                 :            :     // this checks if (this) and xRange are in the same text::XText interface
     578         [ -  + ]:       5020 :     if (pOwnStartNode != pTmp)
     579                 :            :     {
     580         [ #  # ]:          0 :         uno::RuntimeException aRunException;
     581         [ #  # ]:          0 :         aRunException.Message = C2U("text interface and cursor not related");
     582         [ #  # ]:          0 :         throw aRunException;
     583                 :            :     }
     584                 :            : 
     585         [ +  + ]:       5020 :     const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb));
     586                 :            : 
     587                 :            :     // special treatment for Contents that do not replace the range, but
     588                 :            :     // instead are "overlaid"
     589                 :            :     const uno::Reference<lang::XUnoTunnel> xContentTunnel(xContent,
     590         [ +  - ]:       5018 :             uno::UNO_QUERY);
     591         [ -  + ]:       5018 :     if (!xContentTunnel.is())
     592                 :            :     {
     593         [ #  # ]:          0 :         lang::IllegalArgumentException aArgException;
     594                 :            :         aArgException.Message =
     595         [ #  # ]:          0 :             C2U("text content does not support lang::XUnoTunnel");
     596         [ #  # ]:          0 :         throw aArgException;
     597                 :            :     }
     598                 :            :     SwXDocumentIndexMark *const pDocumentIndexMark =
     599         [ +  - ]:       5018 :         ::sw::UnoTunnelGetImplementation<SwXDocumentIndexMark>(xContentTunnel);
     600                 :            :     SwXTextSection *const pSection =
     601         [ +  - ]:       5018 :         ::sw::UnoTunnelGetImplementation<SwXTextSection>(xContentTunnel);
     602                 :            :     SwXBookmark *const pBookmark =
     603         [ +  - ]:       5018 :         ::sw::UnoTunnelGetImplementation<SwXBookmark>(xContentTunnel);
     604                 :            :     SwXReferenceMark *const pReferenceMark =
     605         [ +  - ]:       5018 :         ::sw::UnoTunnelGetImplementation<SwXReferenceMark>(xContentTunnel);
     606                 :            :     SwXMeta *const pMeta =
     607         [ +  - ]:       5018 :         ::sw::UnoTunnelGetImplementation<SwXMeta>(xContentTunnel);
     608                 :            :     SwXTextField* pTextField =
     609         [ +  - ]:       5018 :         ::sw::UnoTunnelGetImplementation<SwXTextField>(xContentTunnel);
     610 [ +  + ][ +  - ]:       5018 :     if (pTextField && pTextField->GetServiceId() != SW_SERVICE_FIELDTYPE_ANNOTATION)
         [ +  + ][ +  + ]
     611                 :         85 :         pTextField = 0;
     612                 :            : 
     613                 :            :     const bool bAttribute = pBookmark || pDocumentIndexMark
     614 [ +  + ][ +  + ]:       5018 :         || pSection || pReferenceMark || pMeta || pTextField;
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
     615                 :            : 
     616 [ +  + ][ +  + ]:       5018 :     if (bAbsorb && !bAttribute)
     617                 :            :     {
     618 [ +  - ][ +  - ]:         36 :         xRange->setString(aEmptyStr);
                 [ +  - ]
     619                 :            :     }
     620                 :            :     uno::Reference< text::XTextRange > xTempRange =
     621 [ +  + ][ +  + ]:       5018 :         (bAttribute && bAbsorb) ? xRange : xRange->getStart();
         [ +  - ][ +  - ]
     622         [ +  + ]:       5018 :     if (bForceExpandHints)
     623                 :            :     {
     624                 :            :         // if necessary, replace xTempRange with a new SwXTextCursor
     625         [ +  - ]:         40 :         PrepareForAttach(xTempRange, aPam);
     626                 :            :     }
     627 [ +  - ][ +  + ]:       5038 :     xContent->attach(xTempRange);
         [ +  - ][ +  - ]
     628                 :       4958 : }
     629                 :            : 
     630                 :            : void SAL_CALL
     631                 :         10 : SwXText::insertTextContentBefore(
     632                 :            :     const uno::Reference< text::XTextContent>& xNewContent,
     633                 :            :     const uno::Reference< text::XTextContent>& xSuccessor)
     634                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
     635                 :            : {
     636         [ +  - ]:         10 :     SolarMutexGuard aGuard;
     637                 :            : 
     638 [ +  - ][ -  + ]:         10 :     if(!GetDoc())
     639                 :            :     {
     640         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     641         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     642         [ #  # ]:          0 :         throw aRuntime;
     643                 :            :     }
     644                 :            : 
     645                 :            :     const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent,
     646         [ +  - ]:         10 :             uno::UNO_QUERY);
     647                 :            :     SwXParagraph *const pPara =
     648         [ +  - ]:         10 :             ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel);
     649 [ +  - ][ +  - ]:         10 :     if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is())
         [ +  - ][ -  + ]
                 [ -  + ]
     650                 :            :     {
     651         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     652                 :            :     }
     653                 :            : 
     654                 :         10 :     sal_Bool bRet = sal_False;
     655                 :            :     const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
     656         [ +  - ]:         10 :             uno::UNO_QUERY);
     657                 :            :     SwXTextSection *const pXSection =
     658         [ +  - ]:         10 :             ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
     659                 :            :     SwXTextTable *const pXTable =
     660         [ +  - ]:         10 :             ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel);
     661         [ +  + ]:         10 :     SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
     662                 :         10 :     SwTxtNode * pTxtNode = 0;
     663 [ +  + ][ +  - ]:         10 :     if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
         [ +  - ][ +  + ]
     664                 :            :     {
     665         [ +  - ]:          6 :         SwTable *const pTable = SwTable::FindTable( pTableFmt );
     666         [ +  - ]:          6 :         SwTableNode *const pTblNode = pTable->GetTableNode();
     667                 :            : 
     668         [ +  - ]:          6 :         const SwNodeIndex aTblIdx( *pTblNode, -1 );
     669         [ +  - ]:          6 :         SwPosition aBefore(aTblIdx);
     670 [ +  - ][ +  - ]:          6 :         bRet = GetDoc()->AppendTxtNode( aBefore );
     671 [ +  - ][ +  - ]:          6 :         pTxtNode = aBefore.nNode.GetNode().GetTxtNode();
     672                 :            :     }
     673 [ +  - ][ +  - ]:          8 :     else if (pXSection && pXSection->GetFmt() &&
         [ +  - ][ +  - ]
                 [ +  - ]
     674 [ +  - ][ +  - ]:          4 :             pXSection->GetFmt()->GetDoc() == GetDoc())
     675                 :            :     {
     676         [ +  - ]:          4 :         SwSectionFmt *const pSectFmt = pXSection->GetFmt();
     677         [ +  - ]:          4 :         SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
     678                 :            : 
     679         [ +  - ]:          4 :         const SwNodeIndex aSectIdx( *pSectNode, -1 );
     680         [ +  - ]:          4 :         SwPosition aBefore(aSectIdx);
     681 [ +  - ][ +  - ]:          4 :         bRet = GetDoc()->AppendTxtNode( aBefore );
     682 [ +  - ][ +  - ]:          4 :         pTxtNode = aBefore.nNode.GetNode().GetTxtNode();
     683                 :            :     }
     684 [ +  - ][ -  + ]:         10 :     if (!bRet || !pTxtNode)
     685                 :            :     {
     686         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     687                 :            :     }
     688 [ +  - ][ +  - ]:         10 :     pPara->attachToText(*this, *pTxtNode);
     689                 :         10 : }
     690                 :            : 
     691                 :            : void SAL_CALL
     692                 :         10 : SwXText::insertTextContentAfter(
     693                 :            :     const uno::Reference< text::XTextContent>& xNewContent,
     694                 :            :     const uno::Reference< text::XTextContent>& xPredecessor)
     695                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
     696                 :            : {
     697         [ +  - ]:         10 :     SolarMutexGuard aGuard;
     698                 :            : 
     699 [ +  - ][ -  + ]:         10 :     if(!GetDoc())
     700                 :            :     {
     701         [ #  # ]:          0 :         throw uno::RuntimeException();
     702                 :            :     }
     703                 :            : 
     704                 :            :     const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent,
     705         [ +  - ]:         10 :             uno::UNO_QUERY);
     706                 :            :     SwXParagraph *const pPara =
     707         [ +  - ]:         10 :             ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel);
     708 [ +  - ][ +  - ]:         10 :     if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is())
         [ +  - ][ -  + ]
                 [ -  + ]
     709                 :            :     {
     710         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     711                 :            :     }
     712                 :            : 
     713                 :            :     const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
     714         [ +  - ]:         10 :             uno::UNO_QUERY);
     715                 :            :     SwXTextSection *const pXSection =
     716         [ +  - ]:         10 :             ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
     717                 :            :     SwXTextTable *const pXTable =
     718         [ +  - ]:         10 :             ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel);
     719         [ +  + ]:         10 :     SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
     720                 :         10 :     sal_Bool bRet = sal_False;
     721                 :         10 :     SwTxtNode * pTxtNode = 0;
     722 [ +  + ][ +  - ]:         10 :     if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
         [ +  - ][ +  + ]
     723                 :            :     {
     724         [ +  - ]:          6 :         SwTable *const pTable = SwTable::FindTable( pTableFmt );
     725         [ +  - ]:          6 :         SwTableNode *const pTblNode = pTable->GetTableNode();
     726                 :            : 
     727                 :          6 :         SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode();
     728         [ +  - ]:          6 :         SwPosition aTableEnd(*pTableEnd);
     729 [ +  - ][ +  - ]:          6 :         bRet = GetDoc()->AppendTxtNode( aTableEnd );
     730         [ +  - ]:          6 :         pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode();
     731                 :            :     }
     732 [ +  - ][ +  - ]:          8 :     else if (pXSection && pXSection->GetFmt() &&
         [ +  - ][ +  - ]
                 [ +  - ]
     733 [ +  - ][ +  - ]:          4 :             pXSection->GetFmt()->GetDoc() == GetDoc())
     734                 :            :     {
     735         [ +  - ]:          4 :         SwSectionFmt *const pSectFmt = pXSection->GetFmt();
     736         [ +  - ]:          4 :         SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
     737                 :          4 :         SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
     738         [ +  - ]:          4 :         SwPosition aEnd(*pEnd);
     739 [ +  - ][ +  - ]:          4 :         bRet = GetDoc()->AppendTxtNode( aEnd );
     740         [ +  - ]:          4 :         pTxtNode = aEnd.nNode.GetNode().GetTxtNode();
     741                 :            :     }
     742 [ +  - ][ -  + ]:         10 :     if (!bRet || !pTxtNode)
     743                 :            :     {
     744         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     745                 :            :     }
     746 [ +  - ][ +  - ]:         10 :     pPara->attachToText(*this, *pTxtNode);
     747                 :         10 : }
     748                 :            : 
     749                 :            : void SAL_CALL
     750                 :          0 : SwXText::removeTextContentBefore(
     751                 :            :     const uno::Reference< text::XTextContent>& xSuccessor)
     752                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
     753                 :            : {
     754         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     755                 :            : 
     756 [ #  # ][ #  # ]:          0 :     if(!GetDoc())
     757                 :            :     {
     758         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     759         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     760         [ #  # ]:          0 :         throw aRuntime;
     761                 :            :     }
     762                 :            : 
     763                 :          0 :     sal_Bool bRet = sal_False;
     764                 :            :     const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
     765         [ #  # ]:          0 :             uno::UNO_QUERY);
     766                 :            :     SwXTextSection *const pXSection =
     767         [ #  # ]:          0 :             ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
     768                 :            :     SwXTextTable *const pXTable =
     769         [ #  # ]:          0 :             ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel);
     770         [ #  # ]:          0 :     SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
     771 [ #  # ][ #  # ]:          0 :     if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
         [ #  # ][ #  # ]
     772                 :            :     {
     773         [ #  # ]:          0 :         SwTable *const pTable = SwTable::FindTable( pTableFmt );
     774         [ #  # ]:          0 :         SwTableNode *const pTblNode = pTable->GetTableNode();
     775                 :            : 
     776         [ #  # ]:          0 :         const SwNodeIndex aTblIdx( *pTblNode, -1 );
     777         [ #  # ]:          0 :         if(aTblIdx.GetNode().IsTxtNode())
     778                 :            :         {
     779         [ #  # ]:          0 :             SwPaM aBefore(aTblIdx);
     780 [ #  # ][ #  # ]:          0 :             bRet = GetDoc()->DelFullPara( aBefore );
                 [ #  # ]
     781         [ #  # ]:          0 :         }
     782                 :            :     }
     783 [ #  # ][ #  # ]:          0 :     else if (pXSection && pXSection->GetFmt() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     784 [ #  # ][ #  # ]:          0 :             pXSection->GetFmt()->GetDoc() == GetDoc())
     785                 :            :     {
     786         [ #  # ]:          0 :         SwSectionFmt *const pSectFmt = pXSection->GetFmt();
     787         [ #  # ]:          0 :         SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
     788                 :            : 
     789         [ #  # ]:          0 :         const SwNodeIndex aSectIdx(  *pSectNode, -1 );
     790         [ #  # ]:          0 :         if(aSectIdx.GetNode().IsTxtNode())
     791                 :            :         {
     792         [ #  # ]:          0 :             SwPaM aBefore(aSectIdx);
     793 [ #  # ][ #  # ]:          0 :             bRet = GetDoc()->DelFullPara( aBefore );
                 [ #  # ]
     794         [ #  # ]:          0 :         }
     795                 :            :     }
     796         [ #  # ]:          0 :     if(!bRet)
     797                 :            :     {
     798         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     799         [ #  # ]:          0 :     }
     800                 :          0 : }
     801                 :            : 
     802                 :            : void SAL_CALL
     803                 :          0 : SwXText::removeTextContentAfter(
     804                 :            :         const uno::Reference< text::XTextContent>& xPredecessor)
     805                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
     806                 :            : {
     807         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     808                 :            : 
     809 [ #  # ][ #  # ]:          0 :     if(!GetDoc())
     810                 :            :     {
     811         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     812         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     813         [ #  # ]:          0 :         throw aRuntime;
     814                 :            :     }
     815                 :            : 
     816                 :          0 :     sal_Bool bRet = sal_False;
     817                 :            :     const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
     818         [ #  # ]:          0 :             uno::UNO_QUERY);
     819                 :            :     SwXTextSection *const pXSection =
     820         [ #  # ]:          0 :             ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
     821                 :            :     SwXTextTable *const pXTable =
     822         [ #  # ]:          0 :             ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel);
     823         [ #  # ]:          0 :     SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0;
     824 [ #  # ][ #  # ]:          0 :     if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
         [ #  # ][ #  # ]
     825                 :            :     {
     826         [ #  # ]:          0 :         SwTable *const pTable = SwTable::FindTable( pTableFmt );
     827         [ #  # ]:          0 :         SwTableNode *const pTblNode = pTable->GetTableNode();
     828                 :          0 :         SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode();
     829                 :            : 
     830         [ #  # ]:          0 :         const SwNodeIndex aTblIdx( *pTableEnd, 1 );
     831         [ #  # ]:          0 :         if(aTblIdx.GetNode().IsTxtNode())
     832                 :            :         {
     833         [ #  # ]:          0 :             SwPaM aPaM(aTblIdx);
     834 [ #  # ][ #  # ]:          0 :             bRet = GetDoc()->DelFullPara( aPaM );
                 [ #  # ]
     835         [ #  # ]:          0 :         }
     836                 :            :     }
     837 [ #  # ][ #  # ]:          0 :     else if (pXSection && pXSection->GetFmt() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     838 [ #  # ][ #  # ]:          0 :             pXSection->GetFmt()->GetDoc() == GetDoc())
     839                 :            :     {
     840         [ #  # ]:          0 :         SwSectionFmt *const pSectFmt = pXSection->GetFmt();
     841         [ #  # ]:          0 :         SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
     842                 :          0 :         SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
     843         [ #  # ]:          0 :         const SwNodeIndex aSectIdx(  *pEnd, 1 );
     844         [ #  # ]:          0 :         if(aSectIdx.GetNode().IsTxtNode())
     845                 :            :         {
     846         [ #  # ]:          0 :             SwPaM aAfter(aSectIdx);
     847 [ #  # ][ #  # ]:          0 :             bRet = GetDoc()->DelFullPara( aAfter );
                 [ #  # ]
     848         [ #  # ]:          0 :         }
     849                 :            :     }
     850         [ #  # ]:          0 :     if(!bRet)
     851                 :            :     {
     852         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
     853         [ #  # ]:          0 :     }
     854                 :          0 : }
     855                 :            : 
     856                 :            : void SAL_CALL
     857                 :         18 : SwXText::removeTextContent(
     858                 :            :         const uno::Reference< text::XTextContent > & xContent)
     859                 :            : throw (container::NoSuchElementException, uno::RuntimeException)
     860                 :            : {
     861                 :            :     // forward: need no solar mutex here
     862         [ +  + ]:         18 :     if(!xContent.is())
     863                 :            :     {
     864         [ +  - ]:          2 :         uno::RuntimeException aRuntime;
     865         [ +  - ]:          2 :         aRuntime.Message = C2U("first parameter invalid");
     866         [ +  - ]:          2 :         throw aRuntime;
     867                 :            :     }
     868                 :         16 :     xContent->dispose();
     869                 :         16 : }
     870                 :            : 
     871                 :            : uno::Reference< text::XText > SAL_CALL
     872                 :         47 : SwXText::getText() throw (uno::RuntimeException)
     873                 :            : {
     874         [ +  - ]:         47 :     SolarMutexGuard aGuard;
     875                 :            : 
     876         [ +  - ]:         47 :     const uno::Reference< text::XText > xRet(this);
     877         [ +  - ]:         47 :     return xRet;
     878                 :            : }
     879                 :            : 
     880                 :            : uno::Reference< text::XTextRange > SAL_CALL
     881                 :        105 : SwXText::getStart() throw (uno::RuntimeException)
     882                 :            : {
     883         [ +  - ]:        105 :     SolarMutexGuard aGuard;
     884                 :            : 
     885         [ +  - ]:        105 :     const uno::Reference< text::XTextCursor > xRef = CreateCursor();
     886         [ -  + ]:        105 :     if(!xRef.is())
     887                 :            :     {
     888         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     889         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     890         [ #  # ]:          0 :         throw aRuntime;
     891                 :            :     }
     892 [ +  - ][ +  - ]:        105 :     xRef->gotoStart(sal_False);
     893         [ +  - ]:        105 :     const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);
     894         [ +  - ]:        105 :     return xRet;
     895                 :            : }
     896                 :            : 
     897                 :            : uno::Reference< text::XTextRange > SAL_CALL
     898                 :        722 : SwXText::getEnd() throw (uno::RuntimeException)
     899                 :            : {
     900         [ +  - ]:        722 :     SolarMutexGuard aGuard;
     901                 :            : 
     902         [ +  - ]:        722 :     const uno::Reference< text::XTextCursor > xRef = CreateCursor();
     903         [ -  + ]:        722 :     if(!xRef.is())
     904                 :            :     {
     905         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     906         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     907         [ #  # ]:          0 :         throw aRuntime;
     908                 :            :     }
     909 [ +  - ][ +  - ]:        722 :     xRef->gotoEnd(sal_False);
     910         [ +  - ]:        722 :     const uno::Reference< text::XTextRange >  xRet(xRef, uno::UNO_QUERY);
     911         [ +  - ]:        722 :     return xRet;
     912                 :            : }
     913                 :            : 
     914                 :        598 : OUString SAL_CALL SwXText::getString() throw (uno::RuntimeException)
     915                 :            : {
     916         [ +  - ]:        598 :     SolarMutexGuard aGuard;
     917                 :            : 
     918         [ +  - ]:        598 :     const uno::Reference< text::XTextCursor > xRet = CreateCursor();
     919         [ -  + ]:        598 :     if(!xRet.is())
     920                 :            :     {
     921         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     922         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     923         [ #  # ]:          0 :         throw aRuntime;
     924                 :            :     }
     925 [ +  - ][ +  - ]:        598 :     xRet->gotoEnd(sal_True);
     926 [ +  - ][ +  - ]:        598 :     return xRet->getString();
                 [ +  - ]
     927                 :            : }
     928                 :            : 
     929                 :            : void SAL_CALL
     930                 :        356 : SwXText::setString(const OUString& rString) throw (uno::RuntimeException)
     931                 :            : {
     932         [ +  - ]:        356 :     SolarMutexGuard aGuard;
     933                 :            : 
     934 [ +  - ][ -  + ]:        356 :     if (!GetDoc())
     935                 :            :     {
     936         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     937         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     938         [ #  # ]:          0 :         throw aRuntime;
     939                 :            :     }
     940                 :            : 
     941         [ +  - ]:        356 :     const SwStartNode* pStartNode = GetStartNode();
     942         [ -  + ]:        356 :     if (!pStartNode)
     943                 :            :     {
     944         [ #  # ]:          0 :         throw uno::RuntimeException();
     945                 :            :     }
     946                 :            : 
     947 [ +  - ][ +  - ]:        356 :     GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL);
                 [ +  - ]
     948                 :            :     //insert an empty paragraph at the start and at the end to ensure that
     949                 :            :     //all tables and sections can be removed by the selecting text::XTextCursor
     950         [ +  + ]:        356 :     if (CURSOR_META != m_pImpl->m_eType)
     951                 :            :     {
     952         [ +  - ]:        302 :         SwPosition aStartPos(*pStartNode);
     953                 :        302 :         const SwEndNode* pEnd = pStartNode->EndOfSectionNode();
     954         [ +  - ]:        302 :         SwNodeIndex aEndIdx(*pEnd);
     955         [ +  - ]:        302 :         aEndIdx--;
     956                 :            :         //the inserting of nodes should only be done if really necessary
     957                 :            :         //to prevent #97924# (removes paragraph attributes when setting the text
     958                 :            :         //e.g. of a table cell
     959                 :        302 :         sal_Bool bInsertNodes = sal_False;
     960         [ +  - ]:        302 :         SwNodeIndex aStartIdx(*pStartNode);
     961         [ +  + ]:        318 :         do
     962                 :            :         {
     963         [ +  - ]:        318 :             aStartIdx++;
     964                 :        318 :             SwNode& rCurrentNode = aStartIdx.GetNode();
     965         [ -  + ]:        636 :             if(rCurrentNode.GetNodeType() == ND_SECTIONNODE
           [ +  -  -  + ]
     966                 :        318 :                 ||rCurrentNode.GetNodeType() == ND_TABLENODE)
     967                 :            :             {
     968                 :          0 :                 bInsertNodes = sal_True;
     969                 :          0 :                 break;
     970                 :            :             }
     971                 :            :         }
     972                 :        318 :         while(aStartIdx < aEndIdx);
     973         [ -  + ]:        302 :         if(bInsertNodes)
     974                 :            :         {
     975 [ #  # ][ #  # ]:          0 :             GetDoc()->AppendTxtNode( aStartPos );
     976         [ #  # ]:          0 :             SwPosition aEndPos(aEndIdx.GetNode());
     977         [ #  # ]:          0 :             SwPaM aPam(aEndPos);
     978 [ #  # ][ #  # ]:          0 :             GetDoc()->AppendTxtNode( *aPam.Start() );
         [ #  # ][ #  # ]
                 [ #  # ]
     979 [ +  - ][ +  - ]:        302 :         }
                 [ +  - ]
     980                 :            :     }
     981                 :            : 
     982         [ +  - ]:        356 :     const uno::Reference< text::XTextCursor > xRet = CreateCursor();
     983         [ -  + ]:        356 :     if(!xRet.is())
     984                 :            :     {
     985 [ #  # ][ #  # ]:          0 :         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
                 [ #  # ]
     986         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
     987         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
     988         [ #  # ]:          0 :         throw aRuntime;
     989                 :            :     }
     990 [ +  - ][ +  - ]:        356 :     xRet->gotoEnd(sal_True);
     991 [ +  - ][ +  - ]:        356 :     xRet->setString(rString);
     992 [ +  - ][ +  - ]:        356 :     GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
         [ +  - ][ +  - ]
     993                 :        356 : }
     994                 :            : 
     995                 :            : //FIXME why is CheckForOwnMember duplicated in some insert methods?
     996                 :            : //  Description: Checks if pRange/pCursor are member of the same text interface.
     997                 :            : //              Only one of the pointers has to be set!
     998                 :         40 : bool SwXText::Impl::CheckForOwnMember(
     999                 :            :     const SwPaM & rPaM)
    1000                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1001                 :            : {
    1002         [ +  - ]:         40 :     const uno::Reference<text::XTextCursor> xOwnCursor(m_rThis.CreateCursor());
    1003                 :            : 
    1004         [ +  - ]:         40 :     const uno::Reference<lang::XUnoTunnel> xTunnel(xOwnCursor, uno::UNO_QUERY);
    1005                 :            :     OTextCursorHelper *const pOwnCursor =
    1006         [ +  - ]:         40 :             ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xTunnel);
    1007                 :            :     OSL_ENSURE(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? ");
    1008                 :            :     const SwStartNode* pOwnStartNode =
    1009         [ +  - ]:         40 :         pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode();
    1010                 :         40 :     SwStartNodeType eSearchNodeType = SwNormalStartNode;
    1011   [ +  +  +  +  :         40 :     switch (m_eType)
                   -  + ]
    1012                 :            :     {
    1013                 :          8 :         case CURSOR_FRAME:      eSearchNodeType = SwFlyStartNode;       break;
    1014                 :          8 :         case CURSOR_TBLTEXT:    eSearchNodeType = SwTableBoxStartNode;  break;
    1015                 :          8 :         case CURSOR_FOOTNOTE:   eSearchNodeType = SwFootnoteStartNode;  break;
    1016                 :          8 :         case CURSOR_HEADER:     eSearchNodeType = SwHeaderStartNode;    break;
    1017                 :          0 :         case CURSOR_FOOTER:     eSearchNodeType = SwFooterStartNode;    break;
    1018                 :            :         //case CURSOR_INVALID:
    1019                 :            :         //case CURSOR_BODY:
    1020                 :            :         default:
    1021                 :            :             ;
    1022                 :            :     }
    1023                 :            : 
    1024                 :         40 :     SwNode const*const pSrcNode(rPaM.GetNode());
    1025         [ -  + ]:         40 :     if (!pSrcNode) { return false; }
    1026         [ +  - ]:         40 :     const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType);
    1027                 :            : 
    1028                 :            :     //SectionNodes ueberspringen
    1029 [ +  - ][ -  + ]:         40 :     while(pTmp && pTmp->IsSectionNode())
                 [ -  + ]
    1030                 :            :     {
    1031                 :          0 :         pTmp = pTmp->StartOfSectionNode();
    1032                 :            :     }
    1033                 :            : 
    1034                 :            :     //if the document starts with a section
    1035         [ -  + ]:         40 :     while(pOwnStartNode->IsSectionNode())
    1036                 :            :     {
    1037                 :          0 :         pOwnStartNode = pOwnStartNode->StartOfSectionNode();
    1038                 :            :     }
    1039                 :            : 
    1040                 :            :     //this checks if (this) and xRange are in the same text::XText interface
    1041                 :         40 :     return (pOwnStartNode == pTmp);
    1042                 :            : }
    1043                 :            : 
    1044                 :            : sal_Int16
    1045                 :         20 : SwXText::Impl::ComparePositions(
    1046                 :            :     const uno::Reference<text::XTextRange>& xPos1,
    1047                 :            :     const uno::Reference<text::XTextRange>& xPos2)
    1048                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1049                 :            : {
    1050         [ +  - ]:         20 :     SwUnoInternalPaM aPam1(*m_pDoc);
    1051         [ +  - ]:         20 :     SwUnoInternalPaM aPam2(*m_pDoc);
    1052                 :            : 
    1053 [ +  - ][ +  - ]:         40 :     if (!::sw::XTextRangeToSwPaM(aPam1, xPos1) ||
         [ -  + ][ -  + ]
    1054         [ +  - ]:         20 :         !::sw::XTextRangeToSwPaM(aPam2, xPos2))
    1055                 :            :     {
    1056         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
    1057                 :            :     }
    1058 [ +  - ][ +  - ]:         20 :     if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2))
         [ +  - ][ -  + ]
                 [ -  + ]
    1059                 :            :     {
    1060         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
    1061                 :            :     }
    1062                 :            : 
    1063                 :         20 :     sal_Int16 nCompare = 0;
    1064         [ +  - ]:         20 :     SwPosition const*const pStart1 = aPam1.Start();
    1065         [ +  - ]:         20 :     SwPosition const*const pStart2 = aPam2.Start();
    1066 [ +  - ][ +  - ]:         20 :     if (*pStart1 < *pStart2)
    1067                 :            :     {
    1068                 :         20 :         nCompare = 1;
    1069                 :            :     }
    1070 [ #  # ][ #  # ]:          0 :     else if (*pStart1 > *pStart2)
    1071                 :            :     {
    1072                 :          0 :         nCompare = -1;
    1073                 :            :     }
    1074                 :            :     else
    1075                 :            :     {
    1076                 :            :         OSL_ENSURE(*pStart1 == *pStart2,
    1077                 :            :                 "SwPositions should be equal here");
    1078                 :          0 :         nCompare = 0;
    1079                 :            :     }
    1080                 :            : 
    1081 [ +  - ][ +  - ]:         20 :     return nCompare;
    1082                 :            : }
    1083                 :            : 
    1084                 :            : sal_Int16 SAL_CALL
    1085                 :         10 : SwXText::compareRegionStarts(
    1086                 :            :     const uno::Reference<text::XTextRange>& xRange1,
    1087                 :            :     const uno::Reference<text::XTextRange>& xRange2)
    1088                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1089                 :            : {
    1090         [ +  - ]:         10 :     SolarMutexGuard aGuard;
    1091                 :            : 
    1092 [ +  - ][ -  + ]:         10 :     if (!xRange1.is() || !xRange2.is())
                 [ -  + ]
    1093                 :            :     {
    1094         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
    1095                 :            :     }
    1096 [ +  - ][ +  - ]:         10 :     const uno::Reference<text::XTextRange> xStart1 = xRange1->getStart();
    1097 [ +  - ][ +  - ]:         10 :     const uno::Reference<text::XTextRange> xStart2 = xRange2->getStart();
    1098                 :            : 
    1099 [ +  - ][ +  - ]:         10 :     return m_pImpl->ComparePositions(xStart1, xStart2);
    1100                 :            : }
    1101                 :            : 
    1102                 :            : sal_Int16 SAL_CALL
    1103                 :         10 : SwXText::compareRegionEnds(
    1104                 :            :     const uno::Reference<text::XTextRange>& xRange1,
    1105                 :            :     const uno::Reference<text::XTextRange>& xRange2)
    1106                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1107                 :            : {
    1108         [ +  - ]:         10 :     SolarMutexGuard aGuard;
    1109                 :            : 
    1110 [ +  - ][ -  + ]:         10 :     if (!xRange1.is() || !xRange2.is())
                 [ -  + ]
    1111                 :            :     {
    1112         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
    1113                 :            :     }
    1114 [ +  - ][ +  - ]:         10 :     uno::Reference<text::XTextRange> xEnd1 = xRange1->getEnd();
    1115 [ +  - ][ +  - ]:         10 :     uno::Reference<text::XTextRange> xEnd2 = xRange2->getEnd();
    1116                 :            : 
    1117 [ +  - ][ +  - ]:         10 :     return m_pImpl->ComparePositions(xEnd1, xEnd2);
    1118                 :            : }
    1119                 :            : 
    1120                 :            : uno::Reference< beans::XPropertySetInfo > SAL_CALL
    1121                 :         29 : SwXText::getPropertySetInfo() throw(uno::RuntimeException)
    1122                 :            : {
    1123         [ +  - ]:         29 :     SolarMutexGuard g;
    1124                 :            : 
    1125                 :            :     static uno::Reference< beans::XPropertySetInfo > xInfo =
    1126 [ +  + ][ +  - ]:         29 :         m_pImpl->m_rPropSet.getPropertySetInfo();
         [ +  - ][ #  # ]
    1127         [ +  - ]:         29 :     return xInfo;
    1128                 :            : }
    1129                 :            : 
    1130                 :            : void SAL_CALL
    1131                 :          0 : SwXText::setPropertyValue(const ::rtl::OUString& /*aPropertyName*/,
    1132                 :            :         const uno::Any& /*aValue*/)
    1133                 :            : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
    1134                 :            :     lang::IllegalArgumentException, lang::WrappedTargetException,
    1135                 :            :     uno::RuntimeException)
    1136                 :            : {
    1137         [ #  # ]:          0 :     throw lang::IllegalArgumentException();
    1138                 :            : }
    1139                 :            : 
    1140                 :            : uno::Any SAL_CALL
    1141                 :         62 : SwXText::getPropertyValue(
    1142                 :            :     const ::rtl::OUString& rPropertyName)
    1143                 :            : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1144                 :            :         uno::RuntimeException)
    1145                 :            : {
    1146         [ +  - ]:         62 :     SolarMutexGuard aGuard;
    1147                 :            : 
    1148 [ +  - ][ -  + ]:         62 :     if(!IsValid())
    1149                 :            :     {
    1150         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1151                 :            :     }
    1152                 :            : 
    1153                 :            :     SfxItemPropertySimpleEntry const*const pEntry =
    1154         [ +  - ]:         62 :         m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
    1155         [ -  + ]:         62 :     if (!pEntry)
    1156                 :            :     {
    1157         [ #  # ]:          0 :         beans::UnknownPropertyException aExcept;
    1158         [ #  # ]:          0 :         aExcept.Message = C2U("Unknown property: ");
    1159                 :          0 :         aExcept.Message += rPropertyName;
    1160         [ #  # ]:          0 :         throw aExcept;
    1161                 :            :     }
    1162                 :            : 
    1163                 :         62 :     uno::Any aRet;
    1164         [ +  + ]:         62 :     switch (pEntry->nWID)
    1165                 :            :     {
    1166                 :            : //          no code necessary - the redline is always located at the end node
    1167                 :            : //            case FN_UNO_REDLINE_NODE_START:
    1168                 :            : //            break;
    1169                 :            :         case FN_UNO_REDLINE_NODE_END:
    1170                 :            :         {
    1171 [ +  - ][ +  - ]:         31 :             const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
    1172                 :         31 :             const sal_uInt16 nRedTblCount = rRedTbl.size();
    1173         [ -  + ]:         31 :             if (nRedTblCount > 0)
    1174                 :            :             {
    1175         [ #  # ]:          0 :                 SwStartNode const*const pStartNode = GetStartNode();
    1176                 :          0 :                 const sal_uLong nOwnIndex = pStartNode->EndOfSectionIndex();
    1177         [ #  # ]:          0 :                 for (sal_uInt16 nRed = 0; nRed < nRedTblCount; nRed++)
    1178                 :            :                 {
    1179         [ #  # ]:          0 :                     SwRedline const*const pRedline = rRedTbl[nRed];
    1180         [ #  # ]:          0 :                     SwPosition const*const pRedStart = pRedline->Start();
    1181         [ #  # ]:          0 :                     const SwNodeIndex nRedNode = pRedStart->nNode;
    1182         [ #  # ]:          0 :                     if (nOwnIndex == nRedNode.GetIndex())
    1183                 :            :                     {
    1184                 :            :                         aRet <<= SwXRedlinePortion::CreateRedlineProperties(
    1185 [ #  # ][ #  # ]:          0 :                                 *pRedline, sal_True);
    1186                 :            :                         break;
    1187                 :            :                     }
    1188 [ #  # ][ #  # ]:          0 :                 }
    1189                 :            :             }
    1190                 :            :         }
    1191                 :         31 :         break;
    1192                 :            :     }
    1193         [ +  - ]:         62 :     return aRet;
    1194                 :            : }
    1195                 :            : 
    1196                 :            : void SAL_CALL
    1197                 :          0 : SwXText::addPropertyChangeListener(
    1198                 :            :         const ::rtl::OUString& /*rPropertyName*/,
    1199                 :            :         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
    1200                 :            : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1201                 :            :     uno::RuntimeException)
    1202                 :            : {
    1203                 :            :     OSL_FAIL("SwXText::addPropertyChangeListener(): not implemented");
    1204                 :          0 : }
    1205                 :            : 
    1206                 :            : void SAL_CALL
    1207                 :          0 : SwXText::removePropertyChangeListener(
    1208                 :            :         const ::rtl::OUString& /*rPropertyName*/,
    1209                 :            :         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
    1210                 :            : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1211                 :            :     uno::RuntimeException)
    1212                 :            : {
    1213                 :            :     OSL_FAIL("SwXText::removePropertyChangeListener(): not implemented");
    1214                 :          0 : }
    1215                 :            : 
    1216                 :            : void SAL_CALL
    1217                 :          0 : SwXText::addVetoableChangeListener(
    1218                 :            :         const ::rtl::OUString& /*rPropertyName*/,
    1219                 :            :         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
    1220                 :            : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1221                 :            :     uno::RuntimeException)
    1222                 :            : {
    1223                 :            :     OSL_FAIL("SwXText::addVetoableChangeListener(): not implemented");
    1224                 :          0 : }
    1225                 :            : 
    1226                 :            : void SAL_CALL
    1227                 :          0 : SwXText::removeVetoableChangeListener(
    1228                 :            :         const ::rtl::OUString& /*rPropertyName*/,
    1229                 :            :         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
    1230                 :            : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1231                 :            :         uno::RuntimeException)
    1232                 :            : {
    1233                 :            :     OSL_FAIL("SwXText::removeVetoableChangeListener(): not implemented");
    1234                 :          0 : }
    1235                 :            : 
    1236                 :            : namespace
    1237                 :            : {
    1238                 :            :     class theSwXTextUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextUnoTunnelId > {};
    1239                 :            : }
    1240                 :            : 
    1241                 :      18618 : const uno::Sequence< sal_Int8 > & SwXText::getUnoTunnelId()
    1242                 :            : {
    1243                 :      18618 :     return theSwXTextUnoTunnelId::get().getSeq();
    1244                 :            : }
    1245                 :            : 
    1246                 :            : sal_Int64 SAL_CALL
    1247                 :       1310 : SwXText::getSomething(const uno::Sequence< sal_Int8 >& rId)
    1248                 :            : throw (uno::RuntimeException)
    1249                 :            : {
    1250                 :       1310 :     return ::sw::UnoTunnelImpl<SwXText>(rId, this);
    1251                 :            : }
    1252                 :            : 
    1253                 :            : uno::Reference< text::XTextRange > SAL_CALL
    1254                 :          0 : SwXText::appendParagraph(
    1255                 :            :         const uno::Sequence< beans::PropertyValue > & rProperties)
    1256                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1257                 :            : {
    1258         [ #  # ]:          0 :     SolarMutexGuard g;
    1259                 :            : 
    1260 [ #  # ][ #  # ]:          0 :     return m_pImpl->finishOrAppendParagraph(false, rProperties);
    1261                 :            : }
    1262                 :            : 
    1263                 :            : uno::Reference< text::XTextRange > SAL_CALL
    1264                 :       1474 : SwXText::finishParagraph(
    1265                 :            :         const uno::Sequence< beans::PropertyValue > & rProperties)
    1266                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1267                 :            : {
    1268         [ +  - ]:       1474 :     SolarMutexGuard g;
    1269                 :            : 
    1270 [ +  - ][ +  - ]:       1474 :     return m_pImpl->finishOrAppendParagraph(true, rProperties);
    1271                 :            : }
    1272                 :            : 
    1273                 :            : uno::Reference< text::XTextRange >
    1274                 :       1474 : SwXText::Impl::finishOrAppendParagraph(
    1275                 :            :         const bool bFinish,
    1276                 :            :         const uno::Sequence< beans::PropertyValue > & rProperties)
    1277                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1278                 :            : {
    1279         [ -  + ]:       1474 :     if (!m_bIsValid)
    1280                 :            :     {
    1281         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1282                 :            :     }
    1283                 :            : 
    1284         [ +  - ]:       1474 :     const SwStartNode* pStartNode = m_rThis.GetStartNode();
    1285         [ -  + ]:       1474 :     if(!pStartNode)
    1286                 :            :     {
    1287         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1288                 :            :     }
    1289                 :            : 
    1290                 :       1474 :     uno::Reference< text::XTextRange > xRet;
    1291                 :       1474 :     bool bIllegalException = false;
    1292                 :       1474 :     bool bRuntimeException = false;
    1293                 :       1474 :     ::rtl::OUString sMessage;
    1294 [ +  - ][ +  - ]:       1474 :     m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_START , NULL);
    1295                 :            :     // find end node, go backward - don't skip tables because the new
    1296                 :            :     // paragraph has to be the last node
    1297                 :            :     //aPam.Move( fnMoveBackward, fnGoNode );
    1298                 :            :     SwPosition aInsertPosition(
    1299 [ +  - ][ +  - ]:       1474 :             SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) );
                 [ +  - ]
    1300         [ +  - ]:       1474 :     SwPaM aPam(aInsertPosition);
    1301         [ +  - ]:       1474 :     m_pDoc->AppendTxtNode( *aPam.GetPoint() );
    1302                 :            :     // remove attributes from the previous paragraph
    1303 [ +  - ][ +  - ]:       1474 :     m_pDoc->ResetAttrs(aPam);
              [ #  #  # ]
    1304                 :            :     // in case of finishParagraph the PaM needs to be moved to the
    1305                 :            :     // previous paragraph
    1306         [ +  - ]:       1474 :     if (bFinish)
    1307                 :            :     {
    1308         [ +  - ]:       1474 :         aPam.Move( fnMoveBackward, fnGoNode );
    1309                 :            :     }
    1310         [ +  + ]:       1474 :     if (rProperties.getLength())
    1311                 :            :     {
    1312                 :            :         // now set the properties
    1313                 :            :         SfxItemPropertySet const*const pParaPropSet =
    1314         [ +  - ]:       1465 :             aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
    1315                 :            :         const SfxItemPropertyMap &rParagraphMap =
    1316                 :       1465 :             pParaPropSet->getPropertyMap();
    1317                 :            : 
    1318                 :       1465 :         const beans::PropertyValue* pValues = rProperties.getConstArray();
    1319                 :            : 
    1320         [ +  + ]:       7741 :         for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp)
    1321                 :            :         {
    1322 [ +  - ][ -  + ]:       6276 :             if (!rParagraphMap.getByName(pValues[nProp].Name))
    1323                 :            :             {
    1324                 :          0 :                 bIllegalException = true;
    1325                 :          0 :                 break;
    1326                 :            :             }
    1327                 :            :             try
    1328                 :            :             {
    1329                 :            :                 SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet,
    1330         [ +  - ]:       6276 :                     pValues[nProp].Name, pValues[nProp].Value);
    1331                 :            :             }
    1332         [ #  # ]:          0 :             catch (const lang::IllegalArgumentException& rIllegal)
    1333                 :            :             {
    1334                 :          0 :                 sMessage = rIllegal.Message;
    1335                 :          0 :                 bIllegalException = true;
    1336                 :            :                 break;
    1337                 :            :             }
    1338         [ #  # ]:          0 :             catch (const uno::RuntimeException& rRuntime)
    1339                 :            :             {
    1340                 :          0 :                 sMessage = rRuntime.Message;
    1341                 :          0 :                 bRuntimeException = true;
    1342                 :            :                 break;
    1343                 :            :             }
    1344                 :            :         }
    1345                 :            :     }
    1346 [ +  - ][ +  - ]:       1474 :     m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
    1347 [ +  - ][ -  + ]:       1474 :     if (bIllegalException || bRuntimeException)
    1348                 :            :     {
    1349 [ #  # ][ #  # ]:          0 :         m_pDoc->GetIDocumentUndoRedo().Undo();
    1350         [ #  # ]:          0 :         if (bIllegalException)
    1351                 :            :         {
    1352         [ #  # ]:          0 :             lang::IllegalArgumentException aEx;
    1353                 :          0 :             aEx.Message = sMessage;
    1354         [ #  # ]:          0 :             throw aEx;
    1355                 :            :         }
    1356                 :            :         else // if(bRuntimeException)
    1357                 :            :         {
    1358         [ #  # ]:          0 :             uno::RuntimeException aEx;
    1359                 :          0 :             aEx.Message = sMessage;
    1360         [ #  # ]:          0 :             throw aEx;
    1361                 :            :         }
    1362                 :            :     }
    1363         [ +  - ]:       1474 :     SwTxtNode *const pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() );
    1364                 :            :     OSL_ENSURE(pTxtNode, "no SwTxtNode?");
    1365         [ +  - ]:       1474 :     if (pTxtNode)
    1366                 :            :     {
    1367                 :            :         xRet.set(SwXParagraph::CreateXParagraph(*m_pDoc, *pTxtNode, &m_rThis),
    1368 [ +  - ][ +  - ]:       1474 :                 uno::UNO_QUERY);
                 [ +  - ]
    1369                 :            :     }
    1370                 :            : 
    1371 [ +  - ][ +  - ]:       1474 :     return xRet;
    1372                 :            : }
    1373                 :            : 
    1374                 :            : /*-------------------------------------------------------------------------
    1375                 :            :     Append text portions at the end of the last paragraph of the text
    1376                 :            :     interface. Support of import filters.
    1377                 :            :   -----------------------------------------------------------------------*/
    1378                 :            : uno::Reference< text::XTextRange > SAL_CALL
    1379                 :       1417 : SwXText::appendTextPortion(
    1380                 :            :         const ::rtl::OUString& rText,
    1381                 :            :         const uno::Sequence< beans::PropertyValue > &
    1382                 :            :             rCharacterAndParagraphProperties)
    1383                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1384                 :            : {
    1385         [ +  - ]:       1417 :     SolarMutexGuard aGuard;
    1386                 :            : 
    1387 [ +  - ][ -  + ]:       1417 :     if(!IsValid())
    1388                 :            :     {
    1389         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1390                 :            :     }
    1391                 :       1417 :     uno::Reference< text::XTextRange > xRet;
    1392         [ +  - ]:       1417 :     const uno::Reference< text::XTextCursor > xTextCursor = CreateCursor();
    1393 [ +  - ][ +  - ]:       1417 :     xTextCursor->gotoEnd(sal_False);
    1394                 :            : 
    1395                 :            :     const uno::Reference< lang::XUnoTunnel > xRangeTunnel(
    1396         [ +  - ]:       1417 :             xTextCursor, uno::UNO_QUERY_THROW );
    1397                 :            :     SwXTextCursor *const pTextCursor =
    1398         [ +  - ]:       1417 :         ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xRangeTunnel);
    1399                 :            : 
    1400                 :       1417 :     bool bIllegalException = false;
    1401                 :       1417 :     bool bRuntimeException = false;
    1402                 :       1417 :     ::rtl::OUString sMessage;
    1403 [ +  - ][ +  - ]:       1417 :     m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
    1404                 :            : 
    1405                 :            : //        SwPaM aPam(*pStartNode->EndOfSectionNode());
    1406                 :            :     //aPam.Move( fnMoveBackward, fnGoNode );
    1407         [ +  - ]:       1417 :     SwUnoCrsr *const pCursor = pTextCursor->GetCursor();
    1408         [ +  - ]:       1417 :     pCursor->MovePara( fnParaCurr, fnParaEnd );
    1409 [ +  - ][ +  - ]:       1417 :     m_pImpl->m_pDoc->DontExpandFmt( *pCursor->Start() );
    1410                 :            : 
    1411         [ +  - ]:       1417 :     if (!rText.isEmpty())
    1412                 :            :     {
    1413                 :       1417 :         const xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex();
    1414                 :            :         SwUnoCursorHelper::DocInsertStringSplitCR(
    1415 [ +  - ][ +  -  :       1417 :             *m_pImpl->m_pDoc, *pCursor, rText, false);
                #  #  # ]
                 [ +  - ]
    1416         [ +  - ]:       1417 :         SwUnoCursorHelper::SelectPam(*pCursor, true);
    1417         [ +  - ]:       1417 :         pCursor->GetPoint()->nContent = nContentPos;
    1418                 :            :     }
    1419                 :            : 
    1420         [ +  + ]:       1417 :     if (rCharacterAndParagraphProperties.getLength())
    1421                 :            :     {
    1422                 :            :         const SfxItemPropertyMap &rCursorMap =
    1423                 :            :             aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)
    1424         [ +  - ]:        708 :                 ->getPropertyMap();
    1425                 :            :         beans::PropertyValue const*const pValues =
    1426                 :        708 :             rCharacterAndParagraphProperties.getConstArray();
    1427                 :            :         SfxItemPropertySet const*const pCursorPropSet =
    1428         [ +  - ]:        708 :             aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR);
    1429                 :        708 :         const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength());
    1430         [ +  + ]:       8466 :         for (sal_Int32 nProp = 0; nProp < nLen; ++nProp)
    1431                 :            :         {
    1432 [ +  - ][ -  + ]:       7758 :             if (!rCursorMap.getByName( pValues[nProp].Name ))
    1433                 :            :             {
    1434                 :          0 :                 bIllegalException = true;
    1435                 :          0 :                 break;
    1436                 :            :             }
    1437                 :            :             try
    1438                 :            :             {
    1439                 :            :                 SwUnoCursorHelper::SetPropertyValue(
    1440                 :            :                     *pCursor, *pCursorPropSet,
    1441                 :      15516 :                     pValues[nProp].Name, pValues[nProp].Value,
    1442         [ +  - ]:       7758 :                     nsSetAttrMode::SETATTR_NOFORMATATTR);
    1443                 :            :             }
    1444         [ #  # ]:          0 :             catch (const lang::IllegalArgumentException& rIllegal)
    1445                 :            :             {
    1446                 :          0 :                 sMessage = rIllegal.Message;
    1447                 :          0 :                 bIllegalException = true;
    1448                 :            :                 break;
    1449                 :            :             }
    1450         [ #  # ]:          0 :             catch (const uno::RuntimeException& rRuntime)
    1451                 :            :             {
    1452                 :          0 :                 sMessage = rRuntime.Message;
    1453                 :          0 :                 bRuntimeException = true;
    1454                 :            :                 break;
    1455                 :            :             }
    1456                 :            :         }
    1457                 :            :     }
    1458 [ +  - ][ +  - ]:       1417 :     m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
    1459 [ +  - ][ -  + ]:       1417 :     if (bIllegalException || bRuntimeException)
    1460                 :            :     {
    1461 [ #  # ][ #  # ]:          0 :         m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
    1462         [ #  # ]:          0 :         if (bIllegalException)
    1463                 :            :         {
    1464         [ #  # ]:          0 :             lang::IllegalArgumentException aEx;
    1465                 :          0 :             aEx.Message = sMessage;
    1466         [ #  # ]:          0 :             throw aEx;
    1467                 :            :         }
    1468                 :            :         else //if(bRuntimeException)
    1469                 :            :         {
    1470         [ #  # ]:          0 :             uno::RuntimeException aEx;
    1471                 :          0 :             aEx.Message = sMessage;
    1472         [ #  # ]:          0 :             throw aEx;
    1473                 :            :         }
    1474                 :            :     }
    1475 [ +  - ][ +  - ]:       1417 :     xRet = new SwXTextRange(*pCursor, this);
         [ +  - ][ +  - ]
    1476         [ +  - ]:       1417 :     return xRet;
    1477                 :            : }
    1478                 :            : 
    1479                 :            : /*-------------------------------------------------------------------------
    1480                 :            :     enable appending text contents like graphic objects, shapes and so on
    1481                 :            :     to support import filters
    1482                 :            :   -----------------------------------------------------------------------*/
    1483                 :            : uno::Reference< text::XTextRange > SAL_CALL
    1484                 :        549 : SwXText::appendTextContent(
    1485                 :            :     const uno::Reference< text::XTextContent >& xTextContent,
    1486                 :            :     const uno::Sequence< beans::PropertyValue >&
    1487                 :            :         rCharacterAndParagraphProperties)
    1488                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1489                 :            : {
    1490         [ +  - ]:        549 :     SolarMutexGuard aGuard;
    1491                 :            : 
    1492 [ +  - ][ -  + ]:        549 :     if (!IsValid())
    1493                 :            :     {
    1494         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1495                 :            :     }
    1496         [ +  - ]:        549 :     SwStartNode const*const pStartNode = GetStartNode();
    1497         [ -  + ]:        549 :     if(!pStartNode)
    1498                 :            :     {
    1499         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1500                 :            :     }
    1501                 :            : 
    1502                 :        549 :     uno::Reference< text::XTextRange > xRet;
    1503 [ +  - ][ +  - ]:        549 :     m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
    1504                 :            :     // find end node, go backward - don't skip tables because the
    1505                 :            :     // new paragraph has to be the last node
    1506         [ +  - ]:        549 :     SwPaM aPam(*pStartNode->EndOfSectionNode());
    1507         [ +  - ]:        549 :     aPam.Move( fnMoveBackward, fnGoNode );
    1508                 :            :     // set cursor to the end of the last text node
    1509 [ +  - ][ +  - ]:        549 :     SwCursor aCursor( *aPam.Start(), 0, false );
    1510 [ +  - ][ +  - ]:        549 :     xRet = new SwXTextRange(aCursor, this);
         [ +  - ][ +  - ]
    1511         [ +  - ]:        549 :     aCursor.MovePara( fnParaCurr, fnParaEnd );
    1512 [ +  - ][ +  - ]:        549 :     m_pImpl->m_pDoc->DontExpandFmt( *aCursor.Start() );
    1513                 :            :     // now attach the text content here
    1514         [ +  + ]:        549 :     insertTextContent( xRet, xTextContent, false );
    1515                 :            :     // now apply the properties to the anchor
    1516         [ +  + ]:        489 :     if (rCharacterAndParagraphProperties.getLength())
    1517                 :            :     {
    1518                 :            :         try
    1519                 :            :         {
    1520                 :          9 :             const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength());
    1521                 :            :             const uno::Reference< beans::XPropertySet > xAnchor(
    1522 [ +  - ][ +  - ]:          9 :                 xTextContent->getAnchor(), uno::UNO_QUERY);
                 [ +  - ]
    1523         [ +  - ]:          9 :             if (xAnchor.is())
    1524                 :            :             {
    1525         [ +  + ]:         51 :                 for (sal_Int32 nElement = 0; nElement < nLen; ++nElement)
    1526                 :            :                 {
    1527         [ +  - ]:         42 :                     xAnchor->setPropertyValue(
    1528                 :         42 :                         rCharacterAndParagraphProperties[nElement].Name,
    1529         [ +  - ]:         84 :                         rCharacterAndParagraphProperties[nElement].Value);
    1530                 :            :                 }
    1531                 :          9 :             }
    1532                 :            :         }
    1533         [ #  # ]:          0 :         catch (const uno::Exception&)
    1534                 :            :         {
    1535         [ #  # ]:          0 :             throw uno::RuntimeException();
    1536                 :            :         }
    1537                 :            :     }
    1538 [ +  - ][ +  - ]:        489 :     m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
    1539 [ +  - ][ +  - ]:        549 :     return xRet;
                 [ +  - ]
    1540                 :            : }
    1541                 :            : 
    1542                 :            : // move previously appended paragraphs into a text frames
    1543                 :            : // to support import filters
    1544                 :            : uno::Reference< text::XTextContent > SAL_CALL
    1545                 :         15 : SwXText::convertToTextFrame(
    1546                 :            :     const uno::Reference< text::XTextRange >& xStart,
    1547                 :            :     const uno::Reference< text::XTextRange >& xEnd,
    1548                 :            :     const uno::Sequence< beans::PropertyValue >& rFrameProperties)
    1549                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    1550                 :            : {
    1551         [ +  - ]:         15 :     SolarMutexGuard aGuard;
    1552                 :            : 
    1553 [ +  - ][ -  + ]:         15 :     if(!IsValid())
    1554                 :            :     {
    1555         [ #  # ]:          0 :         throw  uno::RuntimeException();
    1556                 :            :     }
    1557                 :         15 :     uno::Reference< text::XTextContent > xRet;
    1558 [ +  - ][ +  - ]:         15 :     SwUnoInternalPaM aStartPam(*GetDoc());
    1559                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1560 [ +  - ][ +  - ]:         15 :     std::auto_ptr< SwUnoInternalPaM > pEndPam(new SwUnoInternalPaM(*GetDoc()));
                 [ +  - ]
    1561                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    1562 [ +  - ][ -  + ]:         30 :     if (!::sw::XTextRangeToSwPaM(aStartPam, xStart) ||
         [ -  + ][ +  - ]
    1563         [ +  - ]:         15 :         !::sw::XTextRangeToSwPaM(*pEndPam, xEnd))
    1564                 :            :     {
    1565         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
    1566                 :            :     }
    1567                 :            : 
    1568                 :            :     const uno::Reference<lang::XUnoTunnel> xStartRangeTunnel(xStart,
    1569         [ +  - ]:         15 :             uno::UNO_QUERY);
    1570                 :            :     SwXTextRange *const pStartRange =
    1571         [ +  - ]:         15 :         ::sw::UnoTunnelGetImplementation<SwXTextRange>(xStartRangeTunnel);
    1572                 :            :     const uno::Reference<lang::XUnoTunnel> xEndRangeTunnel(xEnd,
    1573         [ +  - ]:         15 :             uno::UNO_QUERY);
    1574                 :            :     SwXTextRange *const pEndRange   =
    1575         [ +  - ]:         15 :         ::sw::UnoTunnelGetImplementation<SwXTextRange>(xEndRangeTunnel);
    1576                 :            :     // bookmarks have to be removed before the referenced text node
    1577                 :            :     // is deleted in DelFullPara
    1578         [ +  - ]:         15 :     if (pStartRange)
    1579                 :            :     {
    1580         [ +  - ]:         15 :         pStartRange->Invalidate();
    1581                 :            :     }
    1582         [ +  + ]:         15 :     if (pEndRange)
    1583                 :            :     {
    1584         [ +  - ]:         12 :         pEndRange->Invalidate();
    1585                 :            :     }
    1586                 :            : 
    1587 [ +  - ][ +  - ]:         15 :     m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
    1588                 :         15 :     bool bIllegalException = false;
    1589                 :         15 :     bool bRuntimeException = false;
    1590                 :         15 :     ::rtl::OUString sMessage;
    1591                 :         15 :     SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode();
    1592 [ +  - ][ -  + ]:         15 :     while (pStartStartNode && pStartStartNode->IsSectionNode())
                 [ -  + ]
    1593                 :            :     {
    1594                 :          0 :         pStartStartNode = pStartStartNode->StartOfSectionNode();
    1595                 :            :     }
    1596                 :         15 :     SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode();
    1597 [ +  - ][ -  + ]:         15 :     while (pEndStartNode && pEndStartNode->IsSectionNode())
                 [ -  + ]
    1598                 :            :     {
    1599                 :          0 :         pEndStartNode = pEndStartNode->StartOfSectionNode();
    1600                 :            :     }
    1601                 :         15 :     bool bParaAfterInserted = false;
    1602                 :         15 :     bool bParaBeforeInserted = false;
    1603 [ +  - ][ +  - ]:         15 :     if (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode())
         [ -  + ][ -  + ]
    1604                 :            :     {
    1605                 :            :         // todo: if the start/end is in a table then insert a paragraph
    1606                 :            :         // before/after, move the start/end nodes, then convert and
    1607                 :            :         // remove the addtional paragraphs in the end
    1608         [ #  # ]:          0 :         if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode)
    1609                 :            :         {
    1610         [ #  # ]:          0 :             SwTableNode *const pStartTableNode(pStartStartNode->FindTableNode());
    1611         [ #  # ]:          0 :             const SwNodeIndex aTblIdx(  *pStartTableNode, -1 );
    1612         [ #  # ]:          0 :             SwPosition aBefore(aTblIdx);
    1613 [ #  # ][ #  # ]:          0 :             bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore );
    1614         [ #  # ]:          0 :             aStartPam.DeleteMark();
    1615         [ #  # ]:          0 :             *aStartPam.GetPoint() = aBefore;
    1616 [ #  # ][ #  # ]:          0 :             pStartStartNode = aStartPam.GetNode()->StartOfSectionNode();
    1617                 :            :         }
    1618         [ #  # ]:          0 :         if (pEndStartNode->GetStartNodeType() == SwTableBoxStartNode)
    1619                 :            :         {
    1620         [ #  # ]:          0 :             SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode();
    1621                 :          0 :             SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode();
    1622         [ #  # ]:          0 :             SwPosition aTableEnd(*pTableEnd);
    1623 [ #  # ][ #  # ]:          0 :             bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd );
    1624         [ #  # ]:          0 :             pEndPam->DeleteMark();
    1625         [ #  # ]:          0 :             *pEndPam->GetPoint() = aTableEnd;
    1626         [ #  # ]:          0 :             pEndStartNode = pEndPam->GetNode()->StartOfSectionNode();
    1627                 :            :         }
    1628                 :            :         // now we should have the positions in the same hierarchy
    1629 [ #  # ][ #  # ]:          0 :         if ((pStartStartNode != pEndStartNode) ||
                 [ #  # ]
    1630         [ #  # ]:          0 :             (pStartStartNode != GetStartNode()))
    1631                 :            :         {
    1632                 :            :             // if not - remove the additional paragraphs and throw
    1633         [ #  # ]:          0 :             if (bParaBeforeInserted)
    1634                 :            :             {
    1635         [ #  # ]:          0 :                 SwCursor aDelete(*aStartPam.GetPoint(), 0, false);
    1636         [ #  # ]:          0 :                 aDelete.MovePara(fnParaCurr, fnParaStart);
    1637         [ #  # ]:          0 :                 aDelete.SetMark();
    1638         [ #  # ]:          0 :                 aDelete.MovePara(fnParaCurr, fnParaEnd);
    1639 [ #  # ][ #  # ]:          0 :                 GetDoc()->DelFullPara(aDelete);
                 [ #  # ]
    1640                 :            :             }
    1641         [ #  # ]:          0 :             if (bParaAfterInserted)
    1642                 :            :             {
    1643         [ #  # ]:          0 :                 SwCursor aDelete(*pEndPam->GetPoint(), 0, false);
    1644         [ #  # ]:          0 :                 aDelete.MovePara(fnParaCurr, fnParaStart);
    1645         [ #  # ]:          0 :                 aDelete.SetMark();
    1646         [ #  # ]:          0 :                 aDelete.MovePara(fnParaCurr, fnParaEnd);
    1647 [ #  # ][ #  # ]:          0 :                 GetDoc()->DelFullPara(aDelete);
                 [ #  # ]
    1648                 :            :             }
    1649         [ #  # ]:          0 :             throw lang::IllegalArgumentException();
    1650                 :            :         }
    1651                 :            :     }
    1652                 :            : 
    1653                 :            :     // make a selection from aStartPam to a EndPam
    1654         [ +  - ]:         15 :     SwSelBoxes aBoxes;
    1655         [ +  - ]:         15 :     SfxItemSet aFrameItemSet(m_pImpl->m_pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1);
    1656                 :            :     // If there is no content in the frame the shape is in
    1657                 :            :     // it gets deleted in the DelFullPara call below,
    1658                 :            :     // In this case insert a tmp text node ( we delete it later )
    1659 [ +  - ][ +  - ]:         27 :     if ( aStartPam.Start()->nNode == pEndPam->Start()->nNode
           [ +  +  +  - ]
                 [ +  + ]
    1660 [ +  - ][ +  - ]:         12 :     && aStartPam.End()->nNode == pEndPam->End()->nNode )
    1661                 :            :     {
    1662 [ +  - ][ +  - ]:         12 :         SwPosition aEnd(*aStartPam.End());
    1663 [ +  - ][ +  - ]:         12 :         bParaAfterInserted = GetDoc()->AppendTxtNode( aEnd );
    1664         [ +  - ]:         12 :         pEndPam->DeleteMark();
    1665 [ +  - ][ +  - ]:         12 :         *pEndPam->GetPoint() = aEnd;
    1666                 :            :     }
    1667         [ +  - ]:         15 :     aStartPam.SetMark();
    1668 [ +  - ][ +  - ]:         15 :     *aStartPam.End() = *pEndPam->End();
                 [ +  - ]
    1669                 :         15 :     pEndPam.reset(0);
    1670                 :            : 
    1671                 :            :     // see if there are frames already anchored to this node
    1672         [ +  - ]:         15 :     std::vector<SwFrmFmt*> aAnchoredFrames;
    1673         [ +  + ]:         48 :     for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrmFmts()->size(); ++i)
    1674                 :            :     {
    1675         [ +  - ]:         33 :         SwFrmFmt* pFrmFmt = (*m_pImpl->m_pDoc->GetSpzFrmFmts())[i];
    1676         [ +  - ]:         33 :         const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
    1677   [ +  +  +  + ]:         54 :         if (FLY_AT_PARA == rAnchor.GetAnchorId() &&
                 [ +  + ]
    1678         [ +  - ]:         21 :                 aStartPam.GetNode()->GetIndex() == rAnchor.GetCntntAnchor()->nNode.GetIndex())
    1679         [ +  - ]:         18 :             aAnchoredFrames.push_back(pFrmFmt);
    1680                 :            :     }
    1681                 :            : 
    1682 [ +  - ][ +  - ]:         15 :     SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc);
    1683 [ +  - ][ +  - ]:         15 :     const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame;
    1684         [ +  - ]:         15 :     pNewFrame->SetSelection( aStartPam );
    1685                 :            :     try
    1686                 :            :     {
    1687                 :         15 :         const beans::PropertyValue* pValues = rFrameProperties.getConstArray();
    1688         [ +  + ]:        339 :         for (sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp)
    1689                 :            :         {
    1690                 :            :             pNewFrame->SwXFrame::setPropertyValue(
    1691         [ +  - ]:        324 :                     pValues[nProp].Name, pValues[nProp].Value);
    1692                 :            :         }
    1693                 :            : 
    1694                 :            :         {   // has to be in a block to remove the SwIndexes before
    1695                 :            :             // DelFullPara is called
    1696                 :            :             const uno::Reference< text::XTextRange> xInsertTextRange =
    1697 [ +  - ][ +  - ]:         15 :                 new SwXTextRange(aStartPam, this);
         [ +  - ][ +  - ]
    1698         [ +  - ]:         15 :             aStartPam.DeleteMark(); // mark position node may be deleted!
    1699         [ +  - ]:         15 :             pNewFrame->attach( xInsertTextRange );
    1700 [ +  - ][ +  - ]:         15 :             pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName());
         [ +  - ][ +  - ]
    1701                 :            :         }
    1702                 :            : 
    1703                 :         15 :         SwTxtNode *const pTxtNode(aStartPam.GetNode()->GetTxtNode());
    1704                 :            :         OSL_ASSERT(pTxtNode);
    1705 [ +  - ][ +  - ]:         15 :         if (!pTxtNode || !pTxtNode->Len()) // don't remove if it contains text!
         [ +  - ][ +  - ]
    1706                 :            :         {
    1707                 :            :             {   // has to be in a block to remove the SwIndexes before
    1708                 :            :                 // DelFullPara is called
    1709         [ +  - ]:         15 :                 SwPaM aMovePam( *aStartPam.GetNode() );
    1710 [ +  - ][ +  - ]:         15 :                 if (aMovePam.Move( fnMoveForward, fnGoCntnt ))
    1711                 :            :                 {
    1712                 :            :                     // move the anchor to the next paragraph
    1713 [ +  - ][ +  - ]:         15 :                     SwFmtAnchor aNewAnchor(pNewFrame->GetFrmFmt()->GetAnchor());
                 [ +  - ]
    1714 [ +  - ][ +  - ]:         15 :                     aNewAnchor.SetAnchor( aMovePam.Start() );
    1715                 :         15 :                     m_pImpl->m_pDoc->SetAttr(
    1716   [ +  -  +  - ]:         30 :                         aNewAnchor, *pNewFrame->GetFrmFmt() );
    1717                 :            : 
    1718                 :            :                     // also move frames anchored to us
    1719 [ +  - ][ +  - ]:         33 :                     for (std::vector<SwFrmFmt*>::iterator i = aAnchoredFrames.begin(); i != aAnchoredFrames.end(); ++i)
                 [ +  + ]
    1720                 :            :                     {
    1721                 :            :                         // copy the anchor to the next paragraph
    1722 [ +  - ][ +  - ]:         18 :                         SwFmtAnchor aAnchor((*i)->GetAnchor());
                 [ +  - ]
    1723 [ +  - ][ +  - ]:         18 :                         aAnchor.SetAnchor(aMovePam.Start());
    1724 [ +  - ][ +  - ]:         18 :                         m_pImpl->m_pDoc->SetAttr(aAnchor, *(*i));
    1725 [ +  - ][ +  - ]:         33 :                     }
    1726   [ +  -  #  #  :         15 :                 }
                      # ]
    1727                 :            :             }
    1728         [ +  - ]:         15 :             m_pImpl->m_pDoc->DelFullPara(aStartPam);
    1729                 :            :         }
    1730                 :            :     }
    1731         [ #  # ]:          0 :     catch (const lang::IllegalArgumentException& rIllegal)
    1732                 :            :     {
    1733                 :          0 :         sMessage = rIllegal.Message;
    1734                 :          0 :         bIllegalException = true;
    1735                 :            :     }
    1736         [ #  # ]:          0 :     catch (const uno::RuntimeException& rRuntime)
    1737                 :            :     {
    1738                 :          0 :         sMessage = rRuntime.Message;
    1739                 :          0 :         bRuntimeException = true;
    1740                 :            :     }
    1741 [ +  - ][ +  - ]:         15 :     xRet = pNewFrame;
    1742 [ +  - ][ +  + ]:         15 :     if (bParaBeforeInserted || bParaAfterInserted)
    1743                 :            :     {
    1744                 :            :         const uno::Reference<text::XTextCursor> xFrameTextCursor =
    1745         [ +  - ]:         12 :             pNewFrame->createTextCursor();
    1746                 :            :         const uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor,
    1747         [ +  - ]:         12 :                 uno::UNO_QUERY);
    1748                 :            :         SwXTextCursor *const pFrameCursor =
    1749         [ +  - ]:         12 :             ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xTunnel);
    1750         [ -  + ]:         12 :         if (bParaBeforeInserted)
    1751                 :            :         {
    1752                 :            :             // todo: remove paragraph before frame
    1753 [ #  # ][ #  # ]:          0 :             m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM());
    1754                 :            :         }
    1755         [ +  - ]:         12 :         if (bParaAfterInserted)
    1756                 :            :         {
    1757 [ +  - ][ +  - ]:         12 :             xFrameTextCursor->gotoEnd(sal_False);
    1758         [ +  - ]:         12 :             if (!bParaBeforeInserted)
    1759 [ +  - ][ +  - ]:         12 :                 m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM());
    1760                 :            :             else
    1761                 :            :             {
    1762                 :            :                 // In case the frame has a table only, the cursor points to the end of the first cell of the table.
    1763 [ #  # ][ #  # ]:          0 :                 SwPaM aPaM(*pFrameCursor->GetPaM()->GetNode()->FindSttNodeByType(SwFlyStartNode)->EndOfSectionNode());
                 [ #  # ]
    1764                 :            :                 // Now we have the end of the frame -- the node before that will be the paragraph we want to remove.
    1765         [ #  # ]:          0 :                 aPaM.GetPoint()->nNode--;
    1766 [ #  # ][ #  # ]:          0 :                 m_pImpl->m_pDoc->DelFullPara(aPaM);
    1767                 :            :             }
    1768                 :         12 :         }
    1769                 :            :     }
    1770                 :            : 
    1771 [ +  - ][ +  - ]:         15 :     m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
    1772 [ +  - ][ -  + ]:         15 :     if (bIllegalException || bRuntimeException)
    1773                 :            :     {
    1774 [ #  # ][ #  # ]:          0 :         m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
    1775         [ #  # ]:          0 :         if (bIllegalException)
    1776                 :            :         {
    1777         [ #  # ]:          0 :             lang::IllegalArgumentException aEx;
    1778                 :          0 :             aEx.Message = sMessage;
    1779         [ #  # ]:          0 :             throw aEx;
    1780                 :            :         }
    1781                 :            :         else //if(bRuntimeException)
    1782                 :            :         {
    1783         [ #  # ]:          0 :             uno::RuntimeException aEx;
    1784                 :          0 :             aEx.Message = sMessage;
    1785         [ #  # ]:          0 :             throw aEx;
    1786                 :            :         }
    1787                 :            :     }
    1788 [ +  - ][ +  - ]:         15 :     return xRet;
         [ +  - ][ +  - ]
    1789                 :            : }
    1790                 :            : 
    1791                 :            : /*-------------------------------------------------------------------------
    1792                 :            :     Move previously imported paragraphs into a new text table.
    1793                 :            :   -----------------------------------------------------------------------*/
    1794                 :          0 : struct VerticallyMergedCell
    1795                 :            : {
    1796                 :            :     std::vector<uno::Reference< beans::XPropertySet > > aCells;
    1797                 :            :     sal_Int32                                           nLeftPosition;
    1798                 :            :     bool                                                bOpen;
    1799                 :            : 
    1800                 :          0 :     VerticallyMergedCell(uno::Reference< beans::XPropertySet > const& rxCell,
    1801                 :            :             const sal_Int32 nLeft)
    1802                 :            :         : nLeftPosition( nLeft )
    1803                 :          0 :         , bOpen( true )
    1804                 :            :     {
    1805         [ #  # ]:          0 :         aCells.push_back( rxCell );
    1806                 :          0 :     }
    1807                 :            : };
    1808                 :            : 
    1809                 :            : #define COL_POS_FUZZY 2
    1810                 :            : 
    1811                 :          0 : static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 )
    1812                 :            : {
    1813 [ #  # ][ #  # ]:          0 :     return abs( nPos1 - nPos2 ) < COL_POS_FUZZY;
    1814                 :            : }
    1815                 :            : 
    1816                 :            : SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1817                 :        436 : void SwXText::Impl::ConvertCell(
    1818                 :            :     const bool bFirstCell,
    1819                 :            :     const uno::Sequence< uno::Reference< text::XTextRange > > & rCell,
    1820                 :            :     ::std::vector<SwNodeRange> & rRowNodes,
    1821                 :            :     ::std::auto_ptr< SwPaM > & rpFirstPaM,
    1822                 :            :     SwPaM & rLastPaM,
    1823                 :            :     bool & rbExcept)
    1824                 :            : {
    1825         [ -  + ]:        436 :     if (rCell.getLength() != 2)
    1826                 :            :     {
    1827                 :            :         throw lang::IllegalArgumentException(
    1828                 :            :                 rtl::OUString::createFromAscii( "rCell needs to contain 2 elements" ),
    1829 [ #  # ][ #  # ]:          0 :                 uno::Reference< text::XTextCopy >( &m_rThis ), sal_Int16( 2 ) );
    1830                 :            :     }
    1831                 :        436 :     const uno::Reference<text::XTextRange> xStartRange = rCell[0];
    1832                 :        436 :     const uno::Reference<text::XTextRange> xEndRange = rCell[1];
    1833         [ +  - ]:        436 :     SwUnoInternalPaM aStartCellPam(*m_pDoc);
    1834         [ +  - ]:        436 :     SwUnoInternalPaM aEndCellPam(*m_pDoc);
    1835                 :            : 
    1836                 :            :     // !!! TODO - PaMs in tables and sections do not work here -
    1837                 :            :     //     the same applies to PaMs in frames !!!
    1838                 :            : 
    1839 [ +  - ][ +  - ]:        872 :     if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) ||
         [ -  + ][ -  + ]
    1840         [ +  - ]:        436 :         !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange))
    1841                 :            :     {
    1842                 :            :         throw lang::IllegalArgumentException(
    1843                 :            :                 rtl::OUString::createFromAscii( "Start or End range cannot be resolved to a SwPaM" ),
    1844 [ #  # ][ #  # ]:          0 :                 uno::Reference< text::XTextCopy >( &m_rThis ), sal_Int16( 2 ) );
    1845                 :            :     }
    1846                 :            : 
    1847         [ +  - ]:        436 :     SwNodeRange aTmpRange(aStartCellPam.Start()->nNode,
    1848 [ +  - ][ +  - ]:        872 :                           aEndCellPam.End()->nNode);
    1849                 :            :     SwNodeRange * pCorrectedRange =
    1850 [ +  - ][ +  - ]:        436 :         m_pDoc->GetNodes().ExpandRangeForTableBox(aTmpRange);
    1851                 :            : 
    1852         [ -  + ]:        436 :     if (pCorrectedRange != NULL)
    1853                 :            :     {
    1854         [ #  # ]:          0 :         SwPaM aNewStartPaM(pCorrectedRange->aStart, 0);
    1855         [ #  # ]:          0 :         aStartCellPam = aNewStartPaM;
    1856                 :            : 
    1857                 :          0 :         xub_StrLen nEndLen = 0;
    1858                 :          0 :         SwTxtNode * pTxtNode = pCorrectedRange->aEnd.GetNode().GetTxtNode();
    1859         [ #  # ]:          0 :         if (pTxtNode != NULL)
    1860         [ #  # ]:          0 :             nEndLen = pTxtNode->Len();
    1861                 :            : 
    1862         [ #  # ]:          0 :         SwPaM aNewEndPaM(pCorrectedRange->aEnd, nEndLen);
    1863 [ #  # ][ #  # ]:          0 :         aEndCellPam = aNewEndPaM;
                 [ #  # ]
    1864                 :            :     }
    1865                 :            : 
    1866                 :            :     /** check the nodes between start and end
    1867                 :            :         it is allowed to have pairs of StartNode/EndNodes
    1868                 :            :      */
    1869 [ +  - ][ +  - ]:        436 :     if (aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode)
                 [ -  + ]
    1870                 :            :     {
    1871                 :            :         // increment on each StartNode and decrement on each EndNode
    1872                 :            :         // we must reach zero at the end and must not go below zero
    1873                 :          0 :         long nOpenNodeBlock = 0;
    1874 [ #  # ][ #  # ]:          0 :         SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode;
    1875 [ #  # ][ #  # ]:          0 :         while (aCellIndex < aEndCellPam.End()->nNode.GetIndex())
    1876                 :            :         {
    1877         [ #  # ]:          0 :             if (aCellIndex.GetNode().IsStartNode())
    1878                 :            :             {
    1879                 :          0 :                 ++nOpenNodeBlock;
    1880                 :            :             }
    1881         [ #  # ]:          0 :             else if (aCellIndex.GetNode().IsEndNode())
    1882                 :            :             {
    1883                 :          0 :                 --nOpenNodeBlock;
    1884                 :            :             }
    1885         [ #  # ]:          0 :             if (nOpenNodeBlock < 0)
    1886                 :            :             {
    1887                 :          0 :                 rbExcept = true;
    1888                 :          0 :                 break;
    1889                 :            :             }
    1890         [ #  # ]:          0 :             ++aCellIndex;
    1891                 :            :         }
    1892         [ #  # ]:          0 :         if (nOpenNodeBlock != 0)
    1893                 :            :         {
    1894                 :          0 :             rbExcept = true;
    1895                 :        436 :             return;
    1896 [ #  # ][ #  # ]:          0 :         }
    1897                 :            :     }
    1898                 :            : 
    1899                 :            :     /** The vector<vector> NodeRanges has to contain consecutive nodes.
    1900                 :            :         In rTableRanges the ranges don't need to be full paragraphs but
    1901                 :            :         they have to follow each other. To process the ranges they
    1902                 :            :         have to be aligned on paragraph borders by inserting paragraph
    1903                 :            :         breaks. Non-consecutive ranges must initiate an exception.
    1904                 :            :      */
    1905         [ +  + ]:        436 :     if (bFirstCell)
    1906                 :            :     {
    1907                 :            :         // align the beginning - if necessary
    1908 [ +  - ][ -  + ]:         72 :         if (aStartCellPam.Start()->nContent.GetIndex())
    1909                 :            :         {
    1910 [ #  # ][ #  # ]:          0 :             m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False);
    1911                 :            :         }
    1912                 :            :     }
    1913                 :            :     else
    1914                 :            :     {
    1915                 :            :         // check the predecessor
    1916         [ +  - ]:        364 :         const sal_uLong nLastNodeIndex = rLastPaM.End()->nNode.GetIndex();
    1917                 :            :         const sal_uLong nStartCellNodeIndex =
    1918         [ +  - ]:        364 :             aStartCellPam.Start()->nNode.GetIndex();
    1919         [ +  - ]:        364 :         const sal_uLong nLastNodeEndIndex = rLastPaM.End()->nNode.GetIndex();
    1920         [ -  + ]:        364 :         if (nLastNodeIndex == nStartCellNodeIndex)
    1921                 :            :         {
    1922                 :            :             // same node as predecessor then equal nContent?
    1923 [ #  # ][ #  # ]:          0 :             if (rLastPaM.End()->nContent != aStartCellPam.Start()->nContent)
                 [ #  # ]
    1924                 :            :             {
    1925                 :          0 :                 rbExcept = true;
    1926                 :            :             }
    1927                 :            :             else
    1928                 :            :             {
    1929 [ #  # ][ #  # ]:          0 :                 m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False);
    1930                 :            :             }
    1931                 :            :         }
    1932         [ -  + ]:        364 :         else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1))
    1933                 :            :         {
    1934                 :            :             // next paragraph - now the content index of the new should be 0
    1935                 :            :             // and of the old one should be equal to the text length
    1936                 :            :             // but if it isn't we don't care - the cell is being inserted on
    1937                 :            :             // the node border anyway
    1938                 :            :         }
    1939                 :            :         else
    1940                 :            :         {
    1941                 :          0 :             rbExcept = true;
    1942                 :            :         }
    1943                 :            :     }
    1944                 :            :     // now check if there's a need to insert another paragraph break
    1945 [ +  - ][ -  + ]:        872 :     if (aEndCellPam.End()->nContent.GetIndex() <
    1946 [ +  - ][ +  - ]:        436 :             aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len())
    1947                 :            :     {
    1948 [ #  # ][ #  # ]:          0 :         m_pDoc->SplitNode(*aEndCellPam.End(), sal_False);
    1949                 :            :         // take care that the new start/endcell is moved to the right position
    1950                 :            :         // aStartCellPam has to point to the start of the new (previous) node
    1951                 :            :         // aEndCellPam has to point to the end of the new (previous) node
    1952         [ #  # ]:          0 :         aStartCellPam.DeleteMark();
    1953         [ #  # ]:          0 :         aStartCellPam.Move(fnMoveBackward, fnGoNode);
    1954         [ #  # ]:          0 :         aStartCellPam.GetPoint()->nContent = 0;
    1955         [ #  # ]:          0 :         aEndCellPam.DeleteMark();
    1956         [ #  # ]:          0 :         aEndCellPam.Move(fnMoveBackward, fnGoNode);
    1957                 :          0 :         aEndCellPam.GetPoint()->nContent =
    1958   [ #  #  #  # ]:          0 :             aEndCellPam.GetNode()->GetTxtNode()->Len();
    1959                 :            :     }
    1960                 :            : 
    1961 [ +  - ][ +  - ]:        436 :     *rLastPaM.GetPoint() = *aEndCellPam.Start();
    1962         [ -  + ]:        436 :     if (aStartCellPam.HasMark())
    1963                 :            :     {
    1964         [ #  # ]:          0 :         rLastPaM.SetMark();
    1965 [ #  # ][ #  # ]:          0 :         *rLastPaM.GetMark() = *aEndCellPam.End();
    1966                 :            :     }
    1967                 :            :     else
    1968                 :            :     {
    1969         [ +  - ]:        436 :         rLastPaM.DeleteMark();
    1970                 :            :     }
    1971                 :            : 
    1972         [ +  - ]:        436 :     SwNodeRange aCellRange(aStartCellPam.Start()->nNode,
    1973 [ +  - ][ +  - ]:        872 :             aEndCellPam.End()->nNode);
    1974         [ +  - ]:        436 :     rRowNodes.push_back(aCellRange);
    1975         [ +  + ]:        436 :     if (bFirstCell)
    1976                 :            :     {
    1977 [ +  - ][ +  - ]:         72 :         rpFirstPaM.reset(new SwPaM(*aStartCellPam.Start()));
                 [ +  - ]
    1978 [ +  - ][ +  - ]:        436 :     }
         [ -  + ][ +  - ]
         [ -  + ][ +  - ]
         [ -  + ][ -  + ]
                 [ +  - ]
    1979                 :            : }
    1980                 :            : SAL_WNODEPRECATED_DECLARATIONS_POP
    1981                 :            : 
    1982                 :            : typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators;
    1983                 :            : 
    1984                 :            : static void
    1985                 :         79 : lcl_ApplyRowProperties(
    1986                 :            :     uno::Sequence<beans::PropertyValue> const& rRowProperties,
    1987                 :            :     uno::Any const& rRow,
    1988                 :            :     TableColumnSeparators & rRowSeparators)
    1989                 :            : {
    1990                 :         79 :     uno::Reference< beans::XPropertySet > xRow;
    1991         [ +  - ]:         79 :     rRow >>= xRow;
    1992                 :         79 :     const beans::PropertyValue* pProperties = rRowProperties.getConstArray();
    1993         [ +  + ]:        253 :     for (sal_Int32 nProperty = 0; nProperty < rRowProperties.getLength();
    1994                 :            :          ++nProperty)
    1995                 :            :     {
    1996         [ +  + ]:        174 :         if ( pProperties[ nProperty ].Name == "TableColumnSeparators" )
    1997                 :            :         {
    1998                 :            :             // add the separators to access the cell's positions
    1999                 :            :             // for vertical merging later
    2000         [ +  - ]:         79 :             TableColumnSeparators aSeparators;
    2001         [ +  - ]:         79 :             pProperties[ nProperty ].Value >>= aSeparators;
    2002 [ +  - ][ +  - ]:         79 :             rRowSeparators = aSeparators;
    2003                 :            :         }
    2004         [ +  - ]:        174 :         xRow->setPropertyValue(
    2005         [ +  - ]:        174 :             pProperties[ nProperty ].Name, pProperties[ nProperty ].Value);
    2006                 :         79 :     }
    2007                 :         79 : }
    2008                 :            : 
    2009                 :            : #if OSL_DEBUG_LEVEL > 0
    2010                 :            : //-->debug cell properties of all rows
    2011                 :            : static void
    2012                 :            : lcl_DebugCellProperties(
    2013                 :            :     const uno::Sequence< uno::Sequence< uno::Sequence<
    2014                 :            :         beans::PropertyValue > > >& rCellProperties)
    2015                 :            : {
    2016                 :            :     ::rtl::OUString sNames;
    2017                 :            :     for (sal_Int32  nDebugRow = 0; nDebugRow < rCellProperties.getLength();
    2018                 :            :          ++nDebugRow)
    2019                 :            :     {
    2020                 :            :         const uno::Sequence< beans::PropertyValues > aDebugCurrentRow =
    2021                 :            :             rCellProperties[nDebugRow];
    2022                 :            :         sal_Int32 nDebugCells = aDebugCurrentRow.getLength();
    2023                 :            :         (void) nDebugCells;
    2024                 :            :         for (sal_Int32  nDebugCell = 0; nDebugCell < nDebugCells;
    2025                 :            :              ++nDebugCell)
    2026                 :            :         {
    2027                 :            :             const uno::Sequence< beans::PropertyValue >&
    2028                 :            :                 rDebugCellProperties = aDebugCurrentRow[nDebugCell];
    2029                 :            :             const sal_Int32 nDebugCellProperties =
    2030                 :            :                 rDebugCellProperties.getLength();
    2031                 :            :             for (sal_Int32  nDebugProperty = 0;
    2032                 :            :                  nDebugProperty < nDebugCellProperties; ++nDebugProperty)
    2033                 :            :             {
    2034                 :            :                 const ::rtl::OUString sName =
    2035                 :            :                     rDebugCellProperties[nDebugProperty].Name;
    2036                 :            :                 sNames += sName;
    2037                 :            :                 sNames += ::rtl::OUString('-');
    2038                 :            :             }
    2039                 :            :             sNames += ::rtl::OUString('+');
    2040                 :            :         }
    2041                 :            :         sNames += ::rtl::OUString('|');
    2042                 :            :     }
    2043                 :            :     (void)sNames;
    2044                 :            : }
    2045                 :            : //--<
    2046                 :            : #endif
    2047                 :            : 
    2048                 :            : static void
    2049                 :        436 : lcl_ApplyCellProperties(
    2050                 :            :     const sal_Int32 nCell,
    2051                 :            :     TableColumnSeparators const& rRowSeparators,
    2052                 :            :     const uno::Sequence< beans::PropertyValue >& rCellProperties,
    2053                 :            :     uno::Reference< uno::XInterface > xCell,
    2054                 :            :     ::std::vector<VerticallyMergedCell> & rMergedCells)
    2055                 :            : {
    2056                 :        436 :     const sal_Int32 nCellProperties = rCellProperties.getLength();
    2057         [ +  - ]:        436 :     const uno::Reference< beans::XPropertySet > xCellPS(xCell, uno::UNO_QUERY);
    2058         [ +  + ]:       3817 :     for (sal_Int32 nProperty = 0; nProperty < nCellProperties; ++nProperty)
    2059                 :            :     {
    2060                 :       3381 :         const OUString & rName  = rCellProperties[nProperty].Name;
    2061                 :       3381 :         const uno::Any & rValue = rCellProperties[nProperty].Value;
    2062         [ -  + ]:       3381 :         if ( rName == "VerticalMerge" )
    2063                 :            :         {
    2064                 :            :             // determine left border position
    2065                 :            :             // add the cell to a queue of merged cells
    2066                 :          0 :             sal_Bool bMerge = sal_False;
    2067                 :          0 :             rValue >>= bMerge;
    2068                 :          0 :             sal_Int32 nLeftPos = -1;
    2069         [ #  # ]:          0 :             if (!nCell)
    2070                 :            :             {
    2071                 :          0 :                 nLeftPos = 0;
    2072                 :            :             }
    2073         [ #  # ]:          0 :             else if (rRowSeparators.getLength() >= nCell)
    2074                 :            :             {
    2075                 :            :                 const text::TableColumnSeparator* pSeparators =
    2076                 :          0 :                     rRowSeparators.getConstArray();
    2077                 :          0 :                 nLeftPos = pSeparators[nCell - 1].Position;
    2078                 :            :             }
    2079         [ #  # ]:          0 :             if (bMerge)
    2080                 :            :             {
    2081                 :            :                 // 'close' all the cell with the same left position
    2082                 :            :                 // if separate vertical merges in the same column exist
    2083         [ #  # ]:          0 :                 if (rMergedCells.size())
    2084                 :            :                 {
    2085                 :            :                     std::vector<VerticallyMergedCell>::iterator aMergedIter =
    2086                 :          0 :                         rMergedCells.begin();
    2087 [ #  # ][ #  # ]:          0 :                     while (aMergedIter != rMergedCells.end())
    2088                 :            :                     {
    2089         [ #  # ]:          0 :                         if (lcl_SimilarPosition(aMergedIter->nLeftPosition,
    2090                 :          0 :                                     nLeftPos))
    2091                 :            :                         {
    2092                 :          0 :                             aMergedIter->bOpen = false;
    2093                 :            :                         }
    2094                 :          0 :                         ++aMergedIter;
    2095                 :            :                     }
    2096                 :            :                 }
    2097                 :            :                 // add the new group of merged cells
    2098 [ #  # ][ #  # ]:          0 :                 rMergedCells.push_back(VerticallyMergedCell(xCellPS, nLeftPos));
    2099                 :            :             }
    2100                 :            :             else
    2101                 :            :             {
    2102                 :            :                 // find the cell that
    2103                 :            :                 OSL_ENSURE(rMergedCells.size(),
    2104                 :            :                         "the first merged cell is missing");
    2105         [ #  # ]:          0 :                 if (rMergedCells.size())
    2106                 :            :                 {
    2107                 :            :                     std::vector<VerticallyMergedCell>::iterator aMergedIter =
    2108                 :          0 :                         rMergedCells.begin();
    2109                 :            : #if OSL_DEBUG_LEVEL > 0
    2110                 :            :                     bool bDbgFound = false;
    2111                 :            : #endif
    2112 [ #  # ][ #  # ]:          0 :                     while (aMergedIter != rMergedCells.end())
    2113                 :            :                     {
    2114   [ #  #  #  # ]:          0 :                         if (aMergedIter->bOpen &&
                 [ #  # ]
    2115                 :          0 :                             lcl_SimilarPosition(aMergedIter->nLeftPosition,
    2116                 :          0 :                                 nLeftPos))
    2117                 :            :                         {
    2118         [ #  # ]:          0 :                             aMergedIter->aCells.push_back( xCellPS );
    2119                 :            : #if OSL_DEBUG_LEVEL > 0
    2120                 :            :                             bDbgFound = true;
    2121                 :            : #endif
    2122                 :            :                         }
    2123                 :          0 :                         ++aMergedIter;
    2124                 :            :                     }
    2125                 :            : #if OSL_DEBUG_LEVEL > 0
    2126                 :            :                     OSL_ENSURE( bDbgFound,
    2127                 :            :                             "couldn't find first vertically merged cell" );
    2128                 :            : #endif
    2129                 :            :                 }
    2130                 :            :             }
    2131                 :            :         }
    2132                 :            :         else
    2133                 :            :         {
    2134                 :            :             try
    2135                 :            :             {
    2136 [ +  - ][ +  - ]:       3381 :                 xCellPS->setPropertyValue(rName, rValue);
    2137                 :            :             }
    2138   [ #  #  #  # ]:          0 :             catch (const uno::Exception&)
    2139                 :            :             {
    2140                 :            :                 // Apply the paragraph and char properties to the cell's content
    2141                 :            :                 const uno::Reference< text::XText > xCellText(xCell,
    2142         [ #  # ]:          0 :                         uno::UNO_QUERY);
    2143                 :            :                 const uno::Reference< text::XTextCursor > xCellCurs =
    2144   [ #  #  #  # ]:          0 :                     xCellText->createTextCursor();
    2145   [ #  #  #  # ]:          0 :                 xCellCurs->gotoStart( sal_False );
    2146   [ #  #  #  # ]:          0 :                 xCellCurs->gotoEnd( sal_True );
    2147                 :            :                 const uno::Reference< beans::XPropertySet > xCellTextProps(
    2148         [ #  # ]:          0 :                         xCellCurs, uno::UNO_QUERY);
    2149   [ #  #  #  # ]:          0 :                 xCellTextProps->setPropertyValue(rName, rValue);
    2150                 :            :             }
    2151                 :            :         }
    2152                 :        436 :     }
    2153                 :        436 : }
    2154                 :            : 
    2155                 :            : static void
    2156                 :         72 : lcl_MergeCells(::std::vector<VerticallyMergedCell> & rMergedCells)
    2157                 :            : {
    2158         [ -  + ]:         72 :     if (rMergedCells.size())
    2159                 :            :     {
    2160                 :            :         std::vector<VerticallyMergedCell>::iterator aMergedIter =
    2161                 :          0 :             rMergedCells.begin();
    2162 [ #  # ][ #  # ]:          0 :         while (aMergedIter != rMergedCells.end())
    2163                 :            :         {
    2164                 :            :             sal_Int32 nCellCount =
    2165                 :          0 :                 static_cast<sal_Int32>(aMergedIter->aCells.size());
    2166                 :            :             std::vector<uno::Reference< beans::XPropertySet > >::iterator
    2167                 :          0 :                 aCellIter = aMergedIter->aCells.begin();
    2168                 :          0 :             bool bFirstCell = true;
    2169                 :            :             // the first of the cells gets the number of cells set as RowSpan
    2170                 :            :             // the others get the inverted number of remaining merged cells
    2171                 :            :             // (3,-2,-1)
    2172 [ #  # ][ #  # ]:          0 :             while (aCellIter != aMergedIter->aCells.end())
    2173                 :            :             {
    2174         [ #  # ]:          0 :                 (*aCellIter)->setPropertyValue(
    2175         [ #  # ]:          0 :                     rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)),
    2176 [ #  # ][ #  # ]:          0 :                     uno::makeAny(nCellCount));
    2177         [ #  # ]:          0 :                 if (bFirstCell)
    2178                 :            :                 {
    2179                 :          0 :                     nCellCount *= -1;
    2180                 :          0 :                     bFirstCell = false;
    2181                 :            :                 }
    2182                 :          0 :                 ++nCellCount;
    2183                 :          0 :                 ++aCellIter;
    2184                 :            :             }
    2185                 :          0 :             ++aMergedIter;
    2186                 :            :         }
    2187                 :            :     }
    2188                 :         72 : }
    2189                 :            : 
    2190                 :            : uno::Reference< text::XTextTable > SAL_CALL
    2191                 :         72 : SwXText::convertToTable(
    2192                 :            :     const uno::Sequence< uno::Sequence< uno::Sequence<
    2193                 :            :         uno::Reference< text::XTextRange > > > >& rTableRanges,
    2194                 :            :     const uno::Sequence< uno::Sequence< uno::Sequence<
    2195                 :            :         beans::PropertyValue > > >& rCellProperties,
    2196                 :            :     const uno::Sequence< uno::Sequence< beans::PropertyValue > >&
    2197                 :            :         rRowProperties,
    2198                 :            :     const uno::Sequence< beans::PropertyValue >& rTableProperties)
    2199                 :            : throw (lang::IllegalArgumentException, uno::RuntimeException)
    2200                 :            : {
    2201         [ +  - ]:         72 :     SolarMutexGuard aGuard;
    2202                 :            : 
    2203 [ +  - ][ -  + ]:         72 :     if(!IsValid())
    2204                 :            :     {
    2205         [ #  # ]:          0 :         throw  uno::RuntimeException();
    2206                 :            :     }
    2207                 :            : 
    2208                 :            :     //at first collect the text ranges as SwPaMs
    2209                 :            :     const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >*
    2210                 :         72 :         pTableRanges = rTableRanges.getConstArray();
    2211                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    2212                 :         72 :     std::auto_ptr < SwPaM > pFirstPaM;
    2213                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    2214         [ +  - ]:         72 :     std::vector< std::vector<SwNodeRange> > aTableNodes;
    2215                 :         72 :     bool bExcept = false;
    2216 [ +  - ][ +  - ]:         72 :     SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes());
         [ +  - ][ +  - ]
    2217 [ +  - ][ +  + ]:        151 :     for (sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength());
                 [ +  + ]
    2218                 :            :             ++nRow)
    2219                 :            :     {
    2220         [ +  - ]:         79 :         std::vector<SwNodeRange> aRowNodes;
    2221                 :            :         const uno::Sequence< uno::Reference< text::XTextRange > >* pRow =
    2222                 :         79 :             pTableRanges[nRow].getConstArray();
    2223                 :         79 :         const sal_Int32 nCells(pTableRanges[nRow].getLength());
    2224                 :            : 
    2225         [ +  + ]:        515 :         for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
    2226                 :            :         {
    2227                 :        436 :             m_pImpl->ConvertCell((nCell == 0) && (nRow == 0), pRow[nCell],
    2228 [ +  + ][ +  + ]:        436 :                 aRowNodes, pFirstPaM, aLastPaM, bExcept);
                 [ +  - ]
    2229                 :            :         }
    2230         [ +  - ]:         79 :         aTableNodes.push_back(aRowNodes);
    2231                 :         79 :     }
    2232                 :            : 
    2233         [ -  + ]:         72 :     if(bExcept)
    2234                 :            :     {
    2235 [ #  # ][ #  # ]:          0 :         m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
    2236         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
    2237                 :            :     }
    2238                 :            : 
    2239                 :            :     std::vector< TableColumnSeparators >
    2240         [ +  - ]:         72 :         aRowSeparators(rRowProperties.getLength());
    2241         [ +  - ]:         72 :     std::vector<VerticallyMergedCell> aMergedCells;
    2242                 :            : 
    2243         [ +  - ]:         72 :     SwTable const*const pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes );
    2244                 :            : 
    2245         [ -  + ]:         72 :     if (!pTable)
    2246                 :          0 :         return uno::Reference< text::XTextTable >();
    2247                 :            : 
    2248 [ +  - ][ -  + ]:        192 :     SwXTextTable *const pTextTable = new SwXTextTable( *pTable->GetFrmFmt() );
    2249 [ +  - ][ +  - ]:         72 :     const uno::Reference< text::XTextTable > xRet = pTextTable;
    2250 [ +  - ][ +  - ]:         72 :     const uno::Reference< beans::XPropertySet > xPrSet = pTextTable;
    2251                 :            :     // set properties to the table
    2252                 :            :     // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException
    2253                 :            :     try
    2254                 :            :     {
    2255                 :            :         //apply table properties
    2256                 :            :         const beans::PropertyValue* pTableProperties =
    2257                 :         72 :             rTableProperties.getConstArray();
    2258         [ +  + ]:        624 :         for (sal_Int32 nProperty = 0; nProperty < rTableProperties.getLength();
    2259                 :            :              ++nProperty)
    2260                 :            :         {
    2261                 :            :             try
    2262                 :            :             {
    2263         [ +  - ]:        552 :                 xPrSet->setPropertyValue( pTableProperties[nProperty].Name,
    2264         [ +  + ]:        552 :                         pTableProperties[nProperty].Value );
    2265                 :            :             }
    2266         [ +  - ]:        120 :             catch (const uno::Exception& e)
    2267                 :            :             {
    2268                 :            : #if DEBUG
    2269                 :            :                 std::clog << "Exception when setting property: ";
    2270                 :            :                 std::clog << rtl::OUStringToOString(
    2271                 :            :                     pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8)
    2272                 :            :                     .getStr();
    2273                 :            :                 std::clog << ". Message: ";
    2274                 :            :                 std::clog << rtl::OUStringToOString( e.Message,
    2275                 :            :                     RTL_TEXTENCODING_UTF8 ).getStr();
    2276                 :            :                 std::clog << std::endl;
    2277                 :            : #else
    2278                 :            :                 (void)e;
    2279                 :            : #endif
    2280                 :            :             }
    2281                 :            :         }
    2282                 :            : 
    2283                 :            :         //apply row properties
    2284 [ +  - ][ +  - ]:         72 :         const uno::Reference< table::XTableRows >  xRows = xRet->getRows();
    2285                 :            : 
    2286                 :            :         const beans::PropertyValues* pRowProperties =
    2287                 :         72 :             rRowProperties.getConstArray();
    2288 [ +  - ][ +  - ]:        151 :         for (sal_Int32 nRow = 0; nRow < xRows->getCount(); ++nRow)
                 [ +  + ]
    2289                 :            :         {
    2290         [ -  + ]:         79 :             if( nRow >= rRowProperties.getLength())
    2291                 :            :             {
    2292                 :          0 :                 break;
    2293                 :            :             }
    2294                 :         79 :             lcl_ApplyRowProperties(pRowProperties[nRow],
    2295 [ +  - ][ +  - ]:         79 :                 xRows->getByIndex(nRow), aRowSeparators[nRow]);
                 [ +  - ]
    2296                 :            :         }
    2297                 :            : 
    2298                 :            : #if OSL_DEBUG_LEVEL > 0
    2299                 :            :         lcl_DebugCellProperties(rCellProperties);
    2300                 :            : #endif
    2301                 :            : 
    2302                 :            :         //apply cell properties
    2303         [ +  + ]:        151 :         for (sal_Int32 nRow = 0; nRow < rCellProperties.getLength(); ++nRow)
    2304                 :            :         {
    2305                 :            :             const uno::Sequence< beans::PropertyValues > aCurrentRow =
    2306         [ +  - ]:         79 :                 rCellProperties[nRow];
    2307                 :         79 :             sal_Int32 nCells = aCurrentRow.getLength();
    2308         [ +  + ]:        515 :             for (sal_Int32  nCell = 0; nCell < nCells; ++nCell)
    2309                 :            :             {
    2310                 :            :                 lcl_ApplyCellProperties(nCell,
    2311                 :        436 :                     aRowSeparators[nRow], aCurrentRow[nCell],
    2312                 :        436 :                     pTextTable->getCellByPosition(nCell, nRow),
    2313 [ +  - ][ +  - ]:        872 :                     aMergedCells);
    2314                 :            :             }
    2315         [ +  - ]:         79 :         }
    2316                 :            :         // now that the cell properties are set the vertical merge values
    2317                 :            :         // have to be applied
    2318         [ +  - ]:         72 :         lcl_MergeCells(aMergedCells);
              [ #  #  # ]
    2319                 :            :     }
    2320         [ #  # ]:          0 :     catch (const lang::WrappedTargetException&)
    2321                 :            :     {
    2322                 :            :     }
    2323         [ #  # ]:          0 :     catch (const lang::IndexOutOfBoundsException&)
    2324                 :            :     {
    2325                 :            :     }
    2326                 :            : 
    2327 [ +  - ][ +  - ]:         72 :     return xRet;
                 [ +  - ]
    2328                 :            : }
    2329                 :            : 
    2330                 :            : 
    2331                 :            : void SAL_CALL
    2332                 :          9 : SwXText::copyText(
    2333                 :            :     const uno::Reference< text::XTextCopy >& xSource )
    2334                 :            : throw (uno::RuntimeException)
    2335                 :            : {
    2336         [ +  - ]:          9 :     SolarMutexGuard aGuard;
    2337                 :            : 
    2338         [ +  - ]:          9 :     uno::Reference< text::XText > const xText(xSource, uno::UNO_QUERY_THROW);
    2339                 :            :     uno::Reference< text::XTextCursor > const xCursor =
    2340 [ +  - ][ +  - ]:          9 :         xText->createTextCursor();
    2341 [ +  - ][ +  - ]:          9 :     xCursor->gotoEnd( sal_True );
    2342                 :            : 
    2343                 :            :     uno::Reference< lang::XUnoTunnel > const xCursorTunnel(xCursor,
    2344         [ +  - ]:          9 :         uno::UNO_QUERY_THROW);
    2345                 :            : 
    2346                 :            :     OTextCursorHelper *const pCursor =
    2347         [ +  - ]:          9 :         ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCursorTunnel);
    2348         [ -  + ]:          9 :     if (!pCursor)
    2349                 :            :     {
    2350         [ #  # ]:          0 :         throw uno::RuntimeException();
    2351                 :            :     }
    2352                 :            : 
    2353 [ +  - ][ +  - ]:          9 :     SwNodeIndex rNdIndex( *GetStartNode( ), 1 );
    2354         [ +  - ]:          9 :     SwPosition rPos( rNdIndex );
    2355 [ +  - ][ +  - ]:          9 :     m_pImpl->m_pDoc->CopyRange( *pCursor->GetPaM(), rPos, false );
         [ +  - ][ +  - ]
                 [ +  - ]
    2356                 :          9 : }
    2357                 :            : 
    2358                 :            : 
    2359                 :            : /******************************************************************
    2360                 :            :  * SwXBodyText
    2361                 :            :  ******************************************************************/
    2362                 :        891 : SwXBodyText::SwXBodyText(SwDoc *const pDoc)
    2363         [ +  - ]:        891 :     : SwXText(pDoc, CURSOR_BODY)
    2364                 :            : {
    2365                 :        891 : }
    2366                 :            : 
    2367         [ +  - ]:        807 : SwXBodyText::~SwXBodyText()
    2368                 :            : {
    2369         [ -  + ]:       1614 : }
    2370                 :            : 
    2371                 :            : OUString SAL_CALL
    2372                 :          0 : SwXBodyText::getImplementationName() throw (uno::RuntimeException)
    2373                 :            : {
    2374                 :          0 :     return C2U("SwXBodyText");
    2375                 :            : }
    2376                 :            : 
    2377                 :            : static char const*const g_ServicesBodyText[] =
    2378                 :            : {
    2379                 :            :     "com.sun.star.text.Text",
    2380                 :            : };
    2381                 :            : 
    2382                 :            : static const size_t g_nServicesBodyText(
    2383                 :            :     sizeof(g_ServicesBodyText)/sizeof(g_ServicesBodyText[0]));
    2384                 :            : 
    2385                 :          2 : sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName)
    2386                 :            : throw (uno::RuntimeException)
    2387                 :            : {
    2388                 :            :     return ::sw::SupportsServiceImpl(
    2389                 :          2 :             g_nServicesBodyText, g_ServicesBodyText, rServiceName);
    2390                 :            : }
    2391                 :            : 
    2392                 :            : uno::Sequence< OUString > SAL_CALL
    2393                 :          0 : SwXBodyText::getSupportedServiceNames() throw (uno::RuntimeException)
    2394                 :            : {
    2395                 :            :     return ::sw::GetSupportedServiceNamesImpl(
    2396                 :          0 :             g_nServicesBodyText, g_ServicesBodyText);
    2397                 :            : }
    2398                 :            : 
    2399                 :            : uno::Any SAL_CALL
    2400                 :       1547 : SwXBodyText::queryAggregation(const uno::Type& rType)
    2401                 :            : throw (uno::RuntimeException)
    2402                 :            : {
    2403                 :       1547 :     uno::Any aRet;
    2404 [ +  + ][ +  - ]:       1547 :     if (rType == container::XEnumerationAccess::static_type())
    2405                 :            :     {
    2406 [ +  - ][ +  - ]:       1015 :         aRet <<= uno::Reference< container::XEnumerationAccess >(this);
    2407                 :            :     }
    2408 [ +  - ][ +  + ]:        532 :     else if (rType == container::XElementAccess::static_type())
    2409                 :            :     {
    2410 [ +  - ][ +  - ]:          2 :         aRet <<= uno::Reference< container::XElementAccess >(this);
    2411                 :            :     }
    2412 [ +  - ][ +  + ]:        530 :     else if (rType == lang::XServiceInfo::static_type())
    2413                 :            :     {
    2414 [ +  - ][ +  - ]:          4 :         aRet <<= uno::Reference< lang::XServiceInfo >(this);
    2415                 :            :     }
    2416                 :            :     else
    2417                 :            :     {
    2418         [ +  - ]:        526 :         aRet = SwXText::queryInterface( rType );
    2419                 :            :     }
    2420 [ +  - ][ +  + ]:       1547 :     if(aRet.getValueType() == ::getCppuVoidType())
    2421                 :            :     {
    2422         [ +  - ]:        526 :         aRet = OWeakAggObject::queryAggregation( rType );
    2423                 :            :     }
    2424                 :       1547 :     return aRet;
    2425                 :            : }
    2426                 :            : 
    2427                 :            : uno::Sequence< uno::Type > SAL_CALL
    2428                 :          0 : SwXBodyText::getTypes() throw (uno::RuntimeException)
    2429                 :            : {
    2430         [ #  # ]:          0 :     const uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes();
    2431         [ #  # ]:          0 :     const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
    2432 [ #  # ][ #  # ]:          0 :     return ::comphelper::concatSequences(aTypes, aTextTypes);
                 [ #  # ]
    2433                 :            : }
    2434                 :            : 
    2435                 :            : namespace
    2436                 :            : {
    2437                 :            :     class theSwXBodyTextImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXBodyTextImplementationId> {};
    2438                 :            : }
    2439                 :            : 
    2440                 :            : uno::Sequence< sal_Int8 > SAL_CALL
    2441                 :          0 : SwXBodyText::getImplementationId() throw (uno::RuntimeException)
    2442                 :            : {
    2443                 :          0 :     return theSwXBodyTextImplementationId::get().getSeq();
    2444                 :            : }
    2445                 :            : 
    2446                 :            : uno::Any SAL_CALL
    2447                 :       3456 : SwXBodyText::queryInterface(const uno::Type& rType)
    2448                 :            : throw (uno::RuntimeException)
    2449                 :            : {
    2450         [ +  - ]:       3456 :     const uno::Any ret = SwXText::queryInterface(rType);
    2451         [ +  - ]:       3456 :     return (ret.getValueType() == ::getCppuVoidType())
    2452                 :            :         ?   SwXBodyText_Base::queryInterface(rType)
    2453 [ +  - ][ +  + ]:       3456 :         :   ret;
    2454                 :            : }
    2455                 :            : 
    2456                 :       6633 : SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables)
    2457                 :            : {
    2458 [ +  - ][ -  + ]:       6633 :     if(!IsValid())
    2459                 :            :     {
    2460                 :          0 :         return 0;
    2461                 :            :     }
    2462                 :            : 
    2463                 :            :     // the cursor has to skip tables contained in this text
    2464 [ +  - ][ +  - ]:       6633 :     SwPaM aPam(GetDoc()->GetNodes().GetEndOfContent());
                 [ +  - ]
    2465         [ +  - ]:       6633 :     aPam.Move( fnMoveBackward, fnGoDoc );
    2466         [ +  + ]:       6633 :     if (!bIgnoreTables)
    2467                 :            :     {
    2468         [ +  - ]:       6617 :         SwTableNode * pTblNode = aPam.GetNode()->FindTableNode();
    2469                 :       6617 :         SwCntntNode * pCont = 0;
    2470         [ +  + ]:       6670 :         while (pTblNode)
    2471                 :            :         {
    2472         [ +  - ]:         53 :             aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode();
    2473 [ +  - ][ +  - ]:         53 :             pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode);
                 [ +  - ]
    2474         [ +  - ]:         53 :             pTblNode = pCont->FindTableNode();
    2475                 :            :         }
    2476         [ +  + ]:       6617 :         if (pCont)
    2477                 :            :         {
    2478 [ +  - ][ +  - ]:         53 :             aPam.GetPoint()->nContent.Assign(pCont, 0);
    2479                 :            :         }
    2480                 :            :     }
    2481 [ +  - ][ +  - ]:       6633 :     return new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, *aPam.GetPoint());
         [ +  - ][ +  - ]
    2482                 :            : }
    2483                 :            : 
    2484                 :            : uno::Reference< text::XTextCursor > SAL_CALL
    2485                 :       6617 : SwXBodyText::createTextCursor() throw (uno::RuntimeException)
    2486                 :            : {
    2487         [ +  - ]:       6617 :     SolarMutexGuard aGuard;
    2488                 :            : 
    2489                 :            :     const uno::Reference< text::XTextCursor > xRef(
    2490 [ +  - ][ +  - ]:       6617 :             static_cast<text::XWordCursor*>(CreateTextCursor(false)) );
                 [ +  - ]
    2491         [ -  + ]:       6617 :     if (!xRef.is())
    2492                 :            :     {
    2493         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
    2494         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
    2495         [ #  # ]:          0 :         throw aRuntime;
    2496                 :            :     }
    2497         [ +  - ]:       6617 :     return xRef;
    2498                 :            : }
    2499                 :            : 
    2500                 :            : uno::Reference< text::XTextCursor > SAL_CALL
    2501                 :       2869 : SwXBodyText::createTextCursorByRange(
    2502                 :            :     const uno::Reference< text::XTextRange > & xTextPosition)
    2503                 :            : throw (uno::RuntimeException)
    2504                 :            : {
    2505         [ +  - ]:       2869 :     SolarMutexGuard aGuard;
    2506                 :            : 
    2507 [ +  - ][ -  + ]:       2869 :     if(!IsValid())
    2508                 :            :     {
    2509         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
    2510         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
    2511         [ #  # ]:          0 :         throw aRuntime;
    2512                 :            :     }
    2513                 :            : 
    2514                 :       2869 :     uno::Reference< text::XTextCursor >  aRef;
    2515 [ +  - ][ +  - ]:       2869 :     SwUnoInternalPaM aPam(*GetDoc());
    2516 [ +  - ][ +  - ]:       2869 :     if (::sw::XTextRangeToSwPaM(aPam, xTextPosition))
    2517                 :            :     {
    2518         [ -  + ]:       2869 :         if ( !aPam.GetNode()->GetTxtNode() )
    2519 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Invalid text range") ), uno::Reference< uno::XInterface >() );
    2520                 :            : 
    2521 [ +  - ][ +  - ]:       2869 :         SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
    2522                 :            : 
    2523                 :       2869 :         SwStartNode* p1 = aPam.GetNode()->StartOfSectionNode();
    2524                 :            :         //document starts with a section?
    2525         [ +  + ]:       2936 :         while(p1->IsSectionNode())
    2526                 :            :         {
    2527                 :         67 :             p1 = p1->StartOfSectionNode();
    2528                 :            :         }
    2529                 :       2869 :         SwStartNode *const p2 = rNode.StartOfSectionNode();
    2530                 :            : 
    2531         [ +  - ]:       2869 :         if(p1 == p2)
    2532                 :            :         {
    2533                 :            :             aRef = static_cast<text::XWordCursor*>(
    2534                 :       2869 :                     new SwXTextCursor(*GetDoc(), this, CURSOR_BODY,
    2535 [ +  - ][ +  - ]:       2869 :                         *aPam.GetPoint(), aPam.GetMark()));
         [ +  - ][ +  - ]
                 [ +  - ]
    2536                 :            :         }
    2537                 :            :     }
    2538         [ -  + ]:       2869 :     if(!aRef.is())
    2539                 :            :     {
    2540                 :            :         throw uno::RuntimeException( rtl::OUString::createFromAscii( "End of content node doesn't have the proper start node" ),
    2541 [ #  # ][ #  # ]:          0 :                uno::Reference< uno::XInterface >( *this ) );
    2542                 :            :     }
    2543 [ +  - ][ +  - ]:       2869 :     return aRef;
    2544                 :            : }
    2545                 :            : 
    2546                 :            : uno::Reference< container::XEnumeration > SAL_CALL
    2547                 :       1141 : SwXBodyText::createEnumeration()
    2548                 :            : throw (uno::RuntimeException)
    2549                 :            : {
    2550         [ +  - ]:       1141 :     SolarMutexGuard aGuard;
    2551                 :            : 
    2552 [ +  - ][ -  + ]:       1141 :     if (!IsValid())
    2553                 :            :     {
    2554         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
    2555         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
    2556         [ #  # ]:          0 :         throw aRuntime;
    2557                 :            :     }
    2558                 :            : 
    2559 [ +  - ][ +  - ]:       1141 :     SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
    2560         [ +  - ]:       1141 :     SwPosition aPos(rNode);
    2561                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    2562                 :            :     ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
    2563 [ +  - ][ +  - ]:       1141 :         GetDoc()->CreateUnoCrsr(aPos, sal_False));
    2564                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    2565         [ +  - ]:       1141 :     pUnoCursor->Move(fnMoveBackward, fnGoDoc);
    2566                 :            :     const uno::Reference< container::XEnumeration > xRet
    2567 [ +  - ][ +  - ]:       1141 :         = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY);
         [ +  - ][ +  - ]
                 [ +  - ]
    2568 [ +  - ][ +  - ]:       1141 :     return xRet;
                 [ +  - ]
    2569                 :            : }
    2570                 :            : 
    2571                 :            : uno::Type SAL_CALL
    2572                 :          2 : SwXBodyText::getElementType() throw (uno::RuntimeException)
    2573                 :            : {
    2574                 :          2 :     return text::XTextRange::static_type();
    2575                 :            : }
    2576                 :            : 
    2577                 :            : sal_Bool SAL_CALL
    2578                 :          2 : SwXBodyText::hasElements() throw (uno::RuntimeException)
    2579                 :            : {
    2580         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    2581                 :            : 
    2582 [ +  - ][ -  + ]:          2 :     if (!IsValid())
    2583                 :            :     {
    2584         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
    2585         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
    2586         [ #  # ]:          0 :         throw aRuntime;
    2587                 :            :     }
    2588                 :            : 
    2589         [ +  - ]:          2 :     return sal_True;
    2590                 :            : }
    2591                 :            : 
    2592                 :            : /******************************************************************
    2593                 :            :  *  SwXHeadFootText
    2594                 :            :  ******************************************************************/
    2595         [ -  + ]:        170 : class SwXHeadFootText::Impl
    2596                 :            :     : public SwClient
    2597                 :            : {
    2598                 :            : 
    2599                 :            : public:
    2600                 :            : 
    2601                 :            :     bool                        m_bIsHeader;
    2602                 :            : 
    2603                 :         85 :     Impl(   SwXHeadFootText & /*rThis*/,
    2604                 :            :             SwFrmFmt & rHeadFootFmt, const bool bIsHeader)
    2605                 :            :         : SwClient(& rHeadFootFmt)
    2606                 :         85 :         , m_bIsHeader(bIsHeader)
    2607                 :            :     {
    2608                 :         85 :     }
    2609                 :            : 
    2610                 :        344 :     SwFrmFmt * GetHeadFootFmt() const {
    2611                 :            :         return static_cast<SwFrmFmt*>(
    2612                 :        344 :                 const_cast<SwModify*>(GetRegisteredIn()));
    2613                 :            :     }
    2614                 :            : 
    2615                 :        249 :     SwFrmFmt & GetHeadFootFmtOrThrow() {
    2616                 :        249 :         SwFrmFmt *const pFmt( GetHeadFootFmt() );
    2617         [ -  + ]:        249 :         if (!pFmt) {
    2618                 :            :             throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
    2619 [ #  # ][ #  # ]:          0 :                     "SwXHeadFootText: disposed or invalid")), 0);
                 [ #  # ]
    2620                 :            :         }
    2621                 :        249 :         return *pFmt;
    2622                 :            :     }
    2623                 :            : protected:
    2624                 :            :     // SwClient
    2625                 :            :     virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
    2626                 :            : 
    2627                 :            : };
    2628                 :            : 
    2629                 :          2 : void SwXHeadFootText::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
    2630                 :            : {
    2631                 :          2 :     ClientModify(this, pOld, pNew);
    2632                 :          2 : }
    2633                 :            : 
    2634                 :        297 : bool SwXHeadFootText::IsXHeadFootText(SwClient *const pClient)
    2635                 :            : {
    2636 [ +  - ][ -  + ]:        297 :     return 0 != dynamic_cast<SwXHeadFootText::Impl*>(pClient);
    2637                 :            : }
    2638                 :            : 
    2639                 :            : uno::Reference< text::XText >
    2640                 :         85 : SwXHeadFootText::CreateXHeadFootText(
    2641                 :            :         SwFrmFmt & rHeadFootFmt, const bool bIsHeader)
    2642                 :            : {
    2643                 :            :     // re-use existing SwXHeadFootText
    2644                 :            :     // #i105557#: do not iterate over the registered clients: race condition
    2645                 :         85 :     uno::Reference< text::XText > xText(rHeadFootFmt.GetXObject(),
    2646         [ +  - ]:         85 :             uno::UNO_QUERY);
    2647         [ +  - ]:         85 :     if (!xText.is())
    2648                 :            :     {
    2649                 :            :         SwXHeadFootText *const pXHFT(
    2650         [ +  - ]:         85 :                 new SwXHeadFootText(rHeadFootFmt, bIsHeader));
    2651 [ +  - ][ +  - ]:         85 :         xText.set(pXHFT);
    2652         [ +  - ]:         85 :         rHeadFootFmt.SetXObject(xText);
    2653                 :            :     }
    2654                 :         85 :     return xText;
    2655                 :            : }
    2656                 :            : 
    2657                 :         85 : SwXHeadFootText::SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader)
    2658                 :            :     : SwXText(rHeadFootFmt.GetDoc(),
    2659                 :            :             (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER)
    2660 [ +  + ][ +  - ]:         85 :     , m_pImpl( new SwXHeadFootText::Impl(*this, rHeadFootFmt, bIsHeader) )
         [ +  - ][ +  - ]
    2661                 :            : {
    2662                 :         85 : }
    2663                 :            : 
    2664 [ +  - ][ +  - ]:         85 : SwXHeadFootText::~SwXHeadFootText()
    2665                 :            : {
    2666         [ -  + ]:        170 : }
    2667                 :            : 
    2668                 :            : OUString SAL_CALL
    2669                 :          0 : SwXHeadFootText::getImplementationName() throw (uno::RuntimeException)
    2670                 :            : {
    2671                 :          0 :     return C2U("SwXHeadFootText");
    2672                 :            : }
    2673                 :            : 
    2674                 :            : static char const*const g_ServicesHeadFootText[] =
    2675                 :            : {
    2676                 :            :     "com.sun.star.text.Text",
    2677                 :            : };
    2678                 :            : 
    2679                 :          2 : sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName)
    2680                 :            : throw (uno::RuntimeException)
    2681                 :            : {
    2682                 :            :     return ::sw::SupportsServiceImpl(
    2683                 :            :             SAL_N_ELEMENTS(g_ServicesHeadFootText),
    2684                 :          2 :             g_ServicesHeadFootText, rServiceName);
    2685                 :            : }
    2686                 :            : 
    2687                 :            : uno::Sequence< OUString > SAL_CALL
    2688                 :          0 : SwXHeadFootText::getSupportedServiceNames() throw (uno::RuntimeException)
    2689                 :            : {
    2690                 :            :     return ::sw::GetSupportedServiceNamesImpl(
    2691                 :            :             SAL_N_ELEMENTS(g_ServicesHeadFootText),
    2692                 :          0 :             g_ServicesHeadFootText);
    2693                 :            : }
    2694                 :            : 
    2695                 :         95 : const SwStartNode *SwXHeadFootText::GetStartNode() const
    2696                 :            : {
    2697                 :         95 :     const SwStartNode *pSttNd = 0;
    2698                 :         95 :     SwFrmFmt *const pHeadFootFmt = m_pImpl->GetHeadFootFmt();
    2699         [ +  - ]:         95 :     if(pHeadFootFmt)
    2700                 :            :     {
    2701                 :         95 :         const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt();
    2702         [ +  - ]:         95 :         if( rFlyCntnt.GetCntntIdx() )
    2703                 :            :         {
    2704                 :         95 :             pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode();
    2705                 :            :         }
    2706                 :            :     }
    2707                 :         95 :     return pSttNd;
    2708                 :            : }
    2709                 :            : 
    2710                 :            : uno::Reference< text::XTextCursor >
    2711                 :         83 : SwXHeadFootText::CreateCursor() throw (uno::RuntimeException)
    2712                 :            : {
    2713                 :         83 :     return createTextCursor();
    2714                 :            : }
    2715                 :            : 
    2716                 :            : uno::Sequence< uno::Type > SAL_CALL
    2717                 :          0 : SwXHeadFootText::getTypes() throw (uno::RuntimeException)
    2718                 :            : {
    2719         [ #  # ]:          0 :     const uno::Sequence< uno::Type > aTypes = SwXHeadFootText_Base::getTypes();
    2720         [ #  # ]:          0 :     const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
    2721 [ #  # ][ #  # ]:          0 :     return ::comphelper::concatSequences(aTypes, aTextTypes);
                 [ #  # ]
    2722                 :            : }
    2723                 :            : 
    2724                 :            : namespace
    2725                 :            : {
    2726                 :            :     class theSwXHeadFootTextImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXHeadFootTextImplementationId > {};
    2727                 :            : }
    2728                 :            : 
    2729                 :            : uno::Sequence< sal_Int8 > SAL_CALL
    2730                 :          0 : SwXHeadFootText::getImplementationId() throw (uno::RuntimeException)
    2731                 :            : {
    2732                 :          0 :     return theSwXHeadFootTextImplementationId::get().getSeq();
    2733                 :            : }
    2734                 :            : 
    2735                 :            : uno::Any SAL_CALL
    2736                 :        209 : SwXHeadFootText::queryInterface(const uno::Type& rType)
    2737                 :            : throw (uno::RuntimeException)
    2738                 :            : {
    2739         [ +  - ]:        209 :     const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType);
    2740         [ +  - ]:        209 :     return (ret.getValueType() == ::getCppuVoidType())
    2741                 :            :         ?   SwXText::queryInterface(rType)
    2742 [ +  - ][ +  + ]:        209 :         :   ret;
    2743                 :            : }
    2744                 :            : 
    2745                 :            : uno::Reference< text::XTextCursor > SAL_CALL
    2746                 :        215 : SwXHeadFootText::createTextCursor() throw (uno::RuntimeException)
    2747                 :            : {
    2748         [ +  - ]:        215 :     SolarMutexGuard aGuard;
    2749                 :            : 
    2750         [ +  - ]:        215 :     SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() );
    2751                 :            : 
    2752                 :        215 :     uno::Reference< text::XTextCursor > xRet;
    2753         [ +  - ]:        215 :     const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt();
    2754                 :        215 :     const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode();
    2755         [ +  - ]:        215 :     SwPosition aPos(rNode);
    2756                 :        215 :     SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this,
    2757 [ +  - ][ +  - ]:        215 :             (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos);
         [ +  + ][ +  - ]
    2758         [ +  - ]:        215 :     SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
    2759         [ +  - ]:        215 :     pUnoCrsr->Move(fnMoveForward, fnGoNode);
    2760                 :            : 
    2761                 :            :     // save current start node to be able to check if there is content
    2762                 :            :     // after the table - otherwise the cursor would be in the body text!
    2763                 :            :     SwStartNode const*const pOwnStartNode = rNode.FindSttNodeByType(
    2764 [ +  + ][ +  - ]:        215 :             (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
    2765                 :            :     // is there a table here?
    2766         [ +  - ]:        215 :     SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode();
    2767                 :        215 :     SwCntntNode* pCont = 0;
    2768         [ +  + ]:        218 :     while (pTblNode)
    2769                 :            :     {
    2770         [ +  - ]:          3 :         pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode();
    2771 [ +  - ][ +  - ]:          3 :         pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode);
                 [ +  - ]
    2772         [ +  - ]:          3 :         pTblNode = pCont->FindTableNode();
    2773                 :            :     }
    2774         [ +  + ]:        215 :     if (pCont)
    2775                 :            :     {
    2776 [ +  - ][ +  - ]:          3 :         pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0);
    2777                 :            :     }
    2778                 :            :     SwStartNode const*const pNewStartNode =
    2779                 :            :         pUnoCrsr->GetNode()->FindSttNodeByType(
    2780 [ +  + ][ +  - ]:        215 :             (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
    2781 [ +  - ][ -  + ]:        215 :     if (!pNewStartNode || (pNewStartNode != pOwnStartNode))
    2782                 :            :     {
    2783         [ #  # ]:          0 :         uno::RuntimeException aExcept;
    2784         [ #  # ]:          0 :         aExcept.Message = S2U("no text available");
    2785         [ #  # ]:          0 :         throw aExcept;
    2786                 :            :     }
    2787 [ +  - ][ +  - ]:        215 :     xRet = static_cast<text::XWordCursor*>(pXCursor);
    2788 [ +  - ][ +  - ]:        215 :     return xRet;
    2789                 :            : }
    2790                 :            : 
    2791                 :            : uno::Reference< text::XTextCursor > SAL_CALL
    2792                 :         32 : SwXHeadFootText::createTextCursorByRange(
    2793                 :            :     const uno::Reference< text::XTextRange > & xTextPosition)
    2794                 :            : throw (uno::RuntimeException)
    2795                 :            : {
    2796         [ +  - ]:         32 :     SolarMutexGuard aGuard;
    2797                 :            : 
    2798         [ +  - ]:         32 :     SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() );
    2799                 :            : 
    2800 [ +  - ][ +  - ]:         32 :     SwUnoInternalPaM aPam(*GetDoc());
    2801 [ +  - ][ -  + ]:         32 :     if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition))
    2802                 :            :     {
    2803         [ #  # ]:          0 :         uno::RuntimeException aRuntime;
    2804         [ #  # ]:          0 :         aRuntime.Message = C2U(cInvalidObject);
    2805         [ #  # ]:          0 :         throw aRuntime;
    2806                 :            :     }
    2807                 :            : 
    2808                 :         32 :     uno::Reference< text::XTextCursor >  xRet;
    2809         [ +  - ]:         32 :     SwNode& rNode = rHeadFootFmt.GetCntnt().GetCntntIdx()->GetNode();
    2810         [ +  - ]:         32 :     SwPosition aPos(rNode);
    2811         [ +  - ]:         32 :     SwPaM aHFPam(aPos);
    2812         [ +  - ]:         32 :     aHFPam.Move(fnMoveForward, fnGoNode);
    2813                 :            :     SwStartNode *const pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType(
    2814 [ +  + ][ +  - ]:         32 :             (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
    2815                 :            :     SwStartNode *const p1 = aPam.GetNode()->FindSttNodeByType(
    2816 [ +  + ][ +  - ]:         32 :             (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
    2817         [ +  - ]:         32 :     if (p1 == pOwnStartNode)
    2818                 :            :     {
    2819                 :            :         xRet = static_cast<text::XWordCursor*>(
    2820                 :         32 :                 new SwXTextCursor(*GetDoc(), this,
    2821                 :         32 :                     (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER,
    2822         [ +  - ]:         64 :                     *aPam.GetPoint(), aPam.GetMark()));
           [ +  -  +  + ]
         [ +  - ][ +  - ]
                 [ +  - ]
    2823                 :            :     }
    2824 [ +  - ][ +  - ]:         32 :     return xRet;
         [ +  - ][ +  - ]
    2825                 :            : }
    2826                 :            : 
    2827                 :            : uno::Reference< container::XEnumeration > SAL_CALL
    2828                 :          2 : SwXHeadFootText::createEnumeration()
    2829                 :            : throw (uno::RuntimeException)
    2830                 :            : {
    2831         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    2832                 :            : 
    2833         [ +  - ]:          2 :     SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() );
    2834                 :            : 
    2835                 :          2 :     uno::Reference< container::XEnumeration >  aRef;
    2836         [ +  - ]:          2 :     const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt();
    2837                 :          2 :     const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode();
    2838         [ +  - ]:          2 :     SwPosition aPos(rNode);
    2839                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    2840                 :            :     ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
    2841 [ +  - ][ +  - ]:          2 :         GetDoc()->CreateUnoCrsr(aPos, sal_False));
    2842                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    2843         [ +  - ]:          2 :     pUnoCursor->Move(fnMoveForward, fnGoNode);
    2844                 :            :     aRef = new SwXParagraphEnumeration(this, pUnoCursor,
    2845 [ +  - ][ +  - ]:          2 :                 (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2846                 :            : 
    2847 [ +  - ][ +  - ]:          2 :     return aRef;
                 [ +  - ]
    2848                 :            : }
    2849                 :            : 
    2850                 :            : uno::Type SAL_CALL
    2851                 :          2 : SwXHeadFootText::getElementType() throw (uno::RuntimeException)
    2852                 :            : {
    2853                 :          2 :     return text::XTextRange::static_type();
    2854                 :            : }
    2855                 :            : 
    2856                 :          2 : sal_Bool SAL_CALL SwXHeadFootText::hasElements() throw (uno::RuntimeException)
    2857                 :            : {
    2858                 :          2 :     return sal_True;
    2859 [ +  - ][ +  - ]:        219 : }
    2860                 :            : 
    2861                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10