LCOV - code coverage report
Current view: top level - sw/source/core/docnode - section.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 515 819 62.9 %
Date: 2012-08-25 Functions: 51 75 68.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 555 1517 36.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                 :            : #include <hintids.hxx>
      32                 :            : #include <svl/intitem.hxx>
      33                 :            : #include <svl/stritem.hxx>
      34                 :            : #include <sfx2/docfile.hxx>
      35                 :            : #include <sfx2/docfilt.hxx>
      36                 :            : #include <editeng/protitem.hxx>
      37                 :            : #include <sfx2/linkmgr.hxx>
      38                 :            : #include <tools/urlobj.hxx>
      39                 :            : #include <sfx2/sfxsids.hrc>
      40                 :            : #include <sfx2/fcontnr.hxx>
      41                 :            : #include <docary.hxx>
      42                 :            : #include <fmtcntnt.hxx>
      43                 :            : #include <fmtpdsc.hxx>
      44                 :            : #include <doc.hxx>
      45                 :            : #include <IDocumentUndoRedo.hxx>
      46                 :            : #include <node.hxx>
      47                 :            : #include <pam.hxx>
      48                 :            : #include <frmtool.hxx>
      49                 :            : #include <editsh.hxx>
      50                 :            : #include <hints.hxx>
      51                 :            : #include <docsh.hxx>
      52                 :            : #include <ndtxt.hxx>
      53                 :            : #include <section.hxx>
      54                 :            : #include <swserv.hxx>
      55                 :            : #include <shellio.hxx>
      56                 :            : #include <poolfmt.hxx>
      57                 :            : #include <expfld.hxx>
      58                 :            : #include <swbaslnk.hxx>
      59                 :            : #include <mvsave.hxx>
      60                 :            : #include <sectfrm.hxx>
      61                 :            : #include <fmtftntx.hxx>
      62                 :            : #include <ftnidx.hxx>
      63                 :            : #include <doctxm.hxx>
      64                 :            : #include <fmteiro.hxx>
      65                 :            : #include <swerror.h>
      66                 :            : #include <unosection.hxx>
      67                 :            : #include <switerator.hxx>
      68                 :            : #include <svl/smplhint.hxx>
      69                 :            : #include <algorithm>
      70                 :            : 
      71                 :            : using namespace ::com::sun::star;
      72                 :            : 
      73                 :            : 
      74 [ #  # ][ #  # ]:          0 : SV_IMPL_REF( SwServerObject )
         [ #  # ][ #  # ]
                 [ #  # ]
      75                 :            : 
      76                 :            : #define sSectionFmtNm aEmptyStr
      77                 :            : 
      78         [ -  + ]:          4 : class SwIntrnlSectRefLink : public SwBaseLink
      79                 :            : {
      80                 :            :     SwSectionFmt& rSectFmt;
      81                 :            : public:
      82                 :          2 :     SwIntrnlSectRefLink( SwSectionFmt& rFmt, sal_uInt16 nUpdateType, sal_uInt16 nFmt )
      83                 :            :         : SwBaseLink( nUpdateType, nFmt ),
      84                 :          2 :         rSectFmt( rFmt )
      85                 :          2 :     {}
      86                 :            : 
      87                 :            :     virtual void Closed();
      88                 :            :     virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
      89                 :            :         const String& rMimeType, const ::com::sun::star::uno::Any & rValue );
      90                 :            : 
      91                 :            :     virtual const SwNode* GetAnchor() const;
      92                 :            :     virtual sal_Bool IsInRange( sal_uLong nSttNd, sal_uLong nEndNd, xub_StrLen nStt = 0,
      93                 :            :                             xub_StrLen nEnd = STRING_NOTFOUND ) const;
      94                 :            : 
      95                 :          0 :     inline SwSectionNode* GetSectNode()
      96                 :            :     {
      97                 :          0 :         const SwNode* pSectNd( const_cast<SwIntrnlSectRefLink*>(this)->GetAnchor() );
      98         [ #  # ]:          0 :         return const_cast<SwSectionNode*>( dynamic_cast<const SwSectionNode*>( pSectNd ) );
      99                 :            :     }
     100                 :            : };
     101                 :            : 
     102                 :            : 
     103 [ +  + ][ +  + ]:       2572 : TYPEINIT1(SwSectionFmt,SwFrmFmt );
     104 [ +  + ][ +  + ]:      29401 : TYPEINIT1(SwSection,SwClient );
     105                 :            : 
     106                 :            : 
     107                 :        232 : SwSectionData::SwSectionData(SectionType const eType, String const& rName)
     108                 :            :     : m_eType(eType)
     109                 :            :     , m_sSectionName(rName)
     110                 :            :     , m_bHiddenFlag(false)
     111                 :            :     , m_bProtectFlag(false)
     112                 :            :     , m_bEditInReadonlyFlag(false) // edit in readonly sections
     113                 :            :     , m_bHidden(false)
     114                 :            :     , m_bCondHiddenFlag(true)
     115 [ +  - ][ +  - ]:        232 :     , m_bConnectFlag(true)
         [ +  - ][ +  - ]
     116                 :            : {
     117                 :        232 : }
     118                 :            : 
     119                 :            : // this must have the same semantics as operator=()
     120                 :        376 : SwSectionData::SwSectionData(SwSection const& rSection)
     121                 :        376 :     : m_eType(rSection.GetType())
     122                 :        376 :     , m_sSectionName(rSection.GetSectionName())
     123                 :        376 :     , m_sCondition(rSection.GetCondition())
     124         [ +  - ]:        376 :     , m_sLinkFileName(rSection.GetLinkFileName())
     125                 :        376 :     , m_sLinkFilePassword(rSection.GetLinkFilePassword())
     126                 :        376 :     , m_Password(rSection.GetPassword())
     127                 :        376 :     , m_bHiddenFlag(rSection.IsHiddenFlag())
     128         [ +  - ]:        376 :     , m_bProtectFlag(rSection.IsProtect())
     129                 :            :     // edit in readonly sections
     130         [ +  - ]:        376 :     , m_bEditInReadonlyFlag(rSection.IsEditInReadonly())
     131                 :        376 :     , m_bHidden(rSection.IsHidden())
     132                 :            :     , m_bCondHiddenFlag(true)
     133   [ +  -  +  -  :       2256 :     , m_bConnectFlag(rSection.IsConnectFlag())
           +  - ][ +  - ]
     134                 :            : {
     135                 :        376 : }
     136                 :            : 
     137                 :            : // this must have the same semantics as operator=()
     138                 :         44 : SwSectionData::SwSectionData(SwSectionData const& rOther)
     139                 :            :     : m_eType(rOther.m_eType)
     140                 :            :     , m_sSectionName(rOther.m_sSectionName)
     141                 :            :     , m_sCondition(rOther.m_sCondition)
     142                 :            :     , m_sLinkFileName(rOther.m_sLinkFileName)
     143                 :            :     , m_sLinkFilePassword(rOther.m_sLinkFilePassword)
     144                 :            :     , m_Password(rOther.m_Password)
     145                 :            :     , m_bHiddenFlag(rOther.m_bHiddenFlag)
     146                 :            :     , m_bProtectFlag(rOther.m_bProtectFlag)
     147                 :            :     // edit in readonly sections
     148                 :            :     , m_bEditInReadonlyFlag(rOther.m_bEditInReadonlyFlag)
     149                 :            :     , m_bHidden(rOther.m_bHidden)
     150                 :            :     , m_bCondHiddenFlag(true)
     151 [ +  - ][ +  - ]:         44 :     , m_bConnectFlag(rOther.m_bConnectFlag)
         [ +  - ][ +  - ]
     152                 :            : {
     153                 :         44 : }
     154                 :            : 
     155                 :            : // the semantics here are weird for reasons of backward compatibility
     156                 :        166 : SwSectionData & SwSectionData::operator= (SwSectionData const& rOther)
     157                 :            : {
     158                 :        166 :     m_eType = rOther.m_eType;
     159                 :        166 :     m_sSectionName = rOther.m_sSectionName;
     160                 :        166 :     m_sCondition = rOther.m_sCondition;
     161                 :        166 :     m_sLinkFileName = rOther.m_sLinkFileName;
     162                 :        166 :     m_sLinkFilePassword = rOther.m_sLinkFilePassword;
     163                 :        166 :     m_bConnectFlag = rOther.m_bConnectFlag;
     164                 :        166 :     m_Password = rOther.m_Password;
     165                 :            : 
     166                 :        166 :     m_bEditInReadonlyFlag = rOther.m_bEditInReadonlyFlag;
     167                 :        166 :     m_bProtectFlag = rOther.m_bProtectFlag;
     168                 :            : 
     169                 :        166 :     m_bHidden = rOther.m_bHidden;
     170                 :            :     // FIXME: old code did not assign m_bHiddenFlag ?
     171                 :            :     // FIXME: why should m_bCondHiddenFlag always default to true?
     172                 :        166 :     m_bCondHiddenFlag = true;
     173                 :            : 
     174                 :        166 :     return *this;
     175                 :            : }
     176                 :            : 
     177                 :            : // the semantics here are weird for reasons of backward compatibility
     178                 :        224 : bool SwSectionData::operator==(SwSectionData const& rOther) const
     179                 :            : {
     180                 :            :     return (m_eType == rOther.m_eType)
     181                 :        208 :         && (m_sSectionName == rOther.m_sSectionName)
     182                 :        194 :         && (m_sCondition == rOther.m_sCondition)
     183                 :            :         && (m_bHidden == rOther.m_bHidden)
     184                 :            :         && (m_bProtectFlag == rOther.m_bProtectFlag)
     185                 :            :         && (m_bEditInReadonlyFlag == rOther.m_bEditInReadonlyFlag)
     186                 :        178 :         && (m_sLinkFileName == rOther.m_sLinkFileName)
     187                 :        174 :         && (m_sLinkFilePassword == rOther.m_sLinkFilePassword)
     188   [ +  +  +  +  :        978 :         && (m_Password == rOther.m_Password);
           +  + ][ +  + ]
         [ +  + ][ +  +  
             +  +  +  - ]
                 [ +  - ]
     189                 :            :     // FIXME: old code ignored m_bCondHiddenFlag m_bHiddenFlag m_bConnectFlag
     190                 :            : }
     191                 :            : 
     192                 :            : // SwSection ===========================================================
     193                 :            : 
     194                 :        116 : SwSection::SwSection(
     195                 :            :         SectionType const eType, String const& rName, SwSectionFmt & rFormat)
     196                 :            :     : SwClient(& rFormat)
     197         [ +  - ]:        116 :     , m_Data(eType, rName)
     198                 :            : {
     199         [ +  - ]:        116 :     SwSection *const pParentSect = GetParent();
     200         [ +  + ]:        116 :     if( pParentSect )
     201                 :            :     {
     202         [ +  + ]:         36 :         if( pParentSect->IsHiddenFlag() )
     203                 :            :         {
     204         [ +  - ]:          2 :             SetHidden( true );
     205                 :            :         }
     206                 :            : 
     207                 :         36 :         m_Data.SetProtectFlag( pParentSect->IsProtectFlag() );
     208                 :            :         // edit in readonly sections
     209                 :         36 :         m_Data.SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() );
     210                 :            :     }
     211                 :            : 
     212         [ +  + ]:        116 :     if (!m_Data.IsProtectFlag())
     213                 :            :     {
     214         [ +  - ]:         88 :         m_Data.SetProtectFlag( rFormat.GetProtect().IsCntntProtected() );
     215                 :            :     }
     216                 :            : 
     217         [ +  - ]:        116 :     if (!m_Data.IsEditInReadonlyFlag()) // edit in readonly sections
     218                 :            :     {
     219         [ +  - ]:        116 :         m_Data.SetEditInReadonlyFlag( rFormat.GetEditInReadonly().GetValue() );
     220                 :            :     }
     221                 :        116 : }
     222                 :            : 
     223                 :            : 
     224 [ +  - ][ -  + ]:        116 : SwSection::~SwSection()
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
     225                 :            : {
     226                 :        116 :     SwSectionFmt* pFmt = GetFmt();
     227         [ -  + ]:        116 :     if( !pFmt )
     228                 :            :         return;
     229                 :            : 
     230                 :        116 :     SwDoc* pDoc = pFmt->GetDoc();
     231         [ +  + ]:        116 :     if( pDoc->IsInDtor() )
     232                 :            :     {
     233                 :            :         // dann melden wir noch schnell unser Format um ans dflt FrameFmt,
     234                 :            :         // damit es keine Abhaengigkeiten gibt
     235         [ +  + ]:        108 :         if( pFmt->DerivedFrom() != pDoc->GetDfltFrmFmt() )
     236         [ +  - ]:         32 :             pFmt->RegisterToFormat( *pDoc->GetDfltFrmFmt() );
     237                 :            :     }
     238                 :            :     else
     239                 :            :     {
     240         [ +  - ]:          8 :         pFmt->Remove( this );               // austragen,
     241                 :            : 
     242         [ -  + ]:          8 :         if (CONTENT_SECTION != m_Data.GetType())
     243                 :            :         {
     244 [ #  # ][ #  # ]:          0 :             pDoc->GetLinkManager().Remove( m_RefLink );
     245                 :            :         }
     246                 :            : 
     247         [ -  + ]:          8 :         if (m_RefObj.Is())
     248                 :            :         {
     249 [ #  # ][ #  # ]:          0 :             pDoc->GetLinkManager().RemoveServer( &m_RefObj );
     250                 :            :         }
     251                 :            : 
     252                 :            :         // ist die Section der letzte Client im Format, kann dieses
     253                 :            :         // geloescht werden
     254         [ +  - ]:          8 :         SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, pFmt );
     255         [ +  - ]:          8 :         pFmt->ModifyNotification( &aMsgHint, &aMsgHint );
     256         [ +  + ]:          8 :         if( !pFmt->GetDepends() )
     257                 :            :         {
     258                 :            :             // Bug: 28191 - nicht ins Undo aufnehmen, sollte schon vorher
     259                 :            :             //          geschehen sein!!
     260 [ +  - ][ +  - ]:          6 :             ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
     261 [ +  - ][ +  - ]:          6 :             pDoc->DelSectionFmt( pFmt );    // und loeschen
     262         [ +  - ]:          8 :         }
     263                 :            :     }
     264         [ -  + ]:        116 :     if (m_RefObj.Is())
     265                 :            :     {
     266         [ #  # ]:        116 :         m_RefObj->Closed();
     267                 :            :     }
     268         [ -  + ]:        194 : }
     269                 :            : 
     270                 :        166 : void SwSection::SetSectionData(SwSectionData const& rData)
     271                 :            : {
     272                 :        166 :     bool const bOldHidden( m_Data.IsHidden() );
     273                 :        166 :     m_Data = rData;
     274                 :            :     // next 2 may actually overwrite m_Data.m_b{Protect,EditInReadonly}Flag
     275                 :            :     // in Modify, which should result in same flag value as the old code!
     276                 :        166 :     SetProtect(m_Data.IsProtectFlag());
     277                 :        166 :     SetEditInReadonly(m_Data.IsEditInReadonlyFlag());
     278         [ +  + ]:        166 :     if (bOldHidden != m_Data.IsHidden()) // check if changed...
     279                 :            :     {
     280                 :          9 :         ImplSetHiddenFlag(m_Data.IsHidden(), m_Data.IsCondHidden());
     281                 :            :     }
     282                 :        166 : }
     283                 :            : 
     284                 :        224 : bool SwSection::DataEquals(SwSectionData const& rCmp) const
     285                 :            : {
     286                 :            :     // note that the old code compared the flags of the parameter with the
     287                 :            :     // format attributes of this; the following mess should do the same...
     288                 :        224 :     (void) GetLinkFileName(); // updates m_sLinkFileName
     289                 :        224 :     bool const bProtect(m_Data.IsProtectFlag());
     290                 :        224 :     bool const bEditInReadonly(m_Data.IsEditInReadonlyFlag());
     291                 :        224 :     const_cast<SwSection*>(this)->m_Data.SetProtectFlag(IsProtect());
     292                 :            :     const_cast<SwSection*>(this)->m_Data
     293                 :        224 :         .SetEditInReadonlyFlag(IsEditInReadonly());
     294                 :        224 :     bool const bResult( m_Data == rCmp );
     295                 :        224 :     const_cast<SwSection*>(this)->m_Data.SetProtectFlag(bProtect);
     296                 :        224 :     const_cast<SwSection*>(this)->m_Data.SetEditInReadonlyFlag(bEditInReadonly);
     297                 :        224 :     return bResult;
     298                 :            : }
     299                 :            : 
     300                 :            : 
     301                 :         26 : void SwSection::ImplSetHiddenFlag(bool const bTmpHidden, bool const bCondition)
     302                 :            : {
     303                 :         26 :     SwSectionFmt* pFmt = GetFmt();
     304                 :            :     OSL_ENSURE(pFmt, "ImplSetHiddenFlag: no format?");
     305         [ +  - ]:         26 :     if( pFmt )
     306                 :            :     {
     307 [ +  + ][ +  + ]:         26 :         const bool bHide = bTmpHidden && bCondition;
     308                 :            : 
     309         [ +  + ]:         26 :         if (bHide) // should be hidden
     310                 :            :         {
     311         [ +  - ]:          7 :             if (!m_Data.IsHiddenFlag()) // is not hidden
     312                 :            :             {
     313                 :            :                 // wie sieht es mit dem Parent aus, ist der versteckt ?
     314                 :            :                 // (eigentlich muesste das vom bHiddenFlag angezeigt werden!)
     315                 :            : 
     316                 :            :                 // erstmal allen Children sagen, das sie versteckt sind
     317         [ +  - ]:          7 :                 SwMsgPoolItem aMsgItem( RES_SECTION_HIDDEN );
     318         [ +  - ]:          7 :                 pFmt->ModifyNotification( &aMsgItem, &aMsgItem );
     319                 :            : 
     320                 :            :                 // alle Frames loeschen
     321 [ +  - ][ +  - ]:          7 :                 pFmt->DelFrms();
     322                 :            :             }
     323                 :            :         }
     324         [ +  + ]:         19 :         else if (m_Data.IsHiddenFlag()) // show Nodes again
     325                 :            :         {
     326                 :            :             // alle Frames sichtbar machen ( Children Sections werden vom
     327                 :            :             // MakeFrms beruecksichtigt). Aber nur wenn die ParentSection
     328                 :            :             // nichts dagegen hat !
     329                 :          7 :             SwSection* pParentSect = pFmt->GetParentSection();
     330 [ -  + ][ +  + ]:          7 :             if( !pParentSect || !pParentSect->IsHiddenFlag() )
                 [ +  + ]
     331                 :            :             {
     332                 :            :                 // erstmal allen Children sagen, das der Parent nicht mehr
     333                 :            :                 // versteckt ist
     334         [ +  - ]:          5 :                 SwMsgPoolItem aMsgItem( RES_SECTION_NOT_HIDDEN );
     335         [ +  - ]:          5 :                 pFmt->ModifyNotification( &aMsgItem, &aMsgItem );
     336                 :            : 
     337 [ +  - ][ +  - ]:          5 :                 pFmt->MakeFrms();
     338                 :            :             }
     339                 :            :         }
     340                 :            :     }
     341                 :         26 : }
     342                 :            : 
     343                 :        132 : sal_Bool SwSection::CalcHiddenFlag() const
     344                 :            : {
     345                 :        132 :     const SwSection* pSect = this;
     346         [ +  + ]:        168 :     do {
     347 [ +  + ][ -  + ]:        168 :         if( pSect->IsHidden() && pSect->IsCondHidden() )
                 [ -  + ]
     348                 :          0 :             return sal_True;
     349                 :            :     } while( 0 != ( pSect = pSect->GetParent()) );
     350                 :            : 
     351                 :        132 :     return sal_False;
     352                 :            : }
     353                 :            : 
     354                 :        948 : bool SwSection::IsProtect() const
     355                 :            : {
     356                 :        948 :     SwSectionFmt *const pFmt( GetFmt() );
     357                 :            :     OSL_ENSURE(pFmt, "SwSection::IsProtect: no format?");
     358                 :            :     return (pFmt)
     359                 :        948 :         ?   pFmt->GetProtect().IsCntntProtected()
     360         [ +  - ]:       1896 :         :   IsProtectFlag();
     361                 :            : }
     362                 :            : 
     363                 :            : // edit in readonly sections
     364                 :        674 : bool SwSection::IsEditInReadonly() const
     365                 :            : {
     366                 :        674 :     SwSectionFmt *const pFmt( GetFmt() );
     367                 :            :     OSL_ENSURE(pFmt, "SwSection::IsEditInReadonly: no format?");
     368                 :            :     return (pFmt)
     369                 :        674 :         ?   pFmt->GetEditInReadonly().GetValue()
     370         [ +  - ]:       1348 :         :   IsEditInReadonlyFlag();
     371                 :            : }
     372                 :            : 
     373                 :          2 : void SwSection::SetHidden(bool const bFlag)
     374                 :            : {
     375         [ -  + ]:          2 :     if (!m_Data.IsHidden() == !bFlag)
     376                 :          2 :         return;
     377                 :            : 
     378                 :          2 :     m_Data.SetHidden(bFlag);
     379                 :          2 :     ImplSetHiddenFlag(bFlag, m_Data.IsCondHidden());
     380                 :            : }
     381                 :            : 
     382                 :            : 
     383                 :        236 : void SwSection::SetProtect(bool const bFlag)
     384                 :            : {
     385                 :        236 :     SwSectionFmt *const pFormat( GetFmt() );
     386                 :            :     OSL_ENSURE(pFormat, "SwSection::SetProtect: no format?");
     387         [ +  - ]:        236 :     if (pFormat)
     388                 :            :     {
     389         [ +  - ]:        236 :         SvxProtectItem aItem( RES_PROTECT );
     390                 :        236 :         aItem.SetCntntProtect( (sal_Bool)bFlag );
     391 [ +  - ][ +  - ]:        236 :         pFormat->SetFmtAttr( aItem );
     392                 :            :         // note: this will call m_Data.SetProtectFlag via Modify!
     393                 :            :     }
     394                 :            :     else
     395                 :            :     {
     396                 :          0 :         m_Data.SetProtectFlag(bFlag);
     397                 :            :     }
     398                 :        236 : }
     399                 :            : 
     400                 :            : // edit in readonly sections
     401                 :        166 : void SwSection::SetEditInReadonly(bool const bFlag)
     402                 :            : {
     403                 :        166 :     SwSectionFmt *const pFormat( GetFmt() );
     404                 :            :     OSL_ENSURE(pFormat, "SwSection::SetEditInReadonly: no format?");
     405         [ +  - ]:        166 :     if (pFormat)
     406                 :            :     {
     407         [ +  - ]:        166 :         SwFmtEditInReadonly aItem;
     408                 :        166 :         aItem.SetValue( (sal_Bool)bFlag );
     409 [ +  - ][ +  - ]:        166 :         pFormat->SetFmtAttr( aItem );
     410                 :            :         // note: this will call m_Data.SetEditInReadonlyFlag via Modify!
     411                 :            :     }
     412                 :            :     else
     413                 :            :     {
     414                 :          0 :         m_Data.SetEditInReadonlyFlag(bFlag);
     415                 :            :     }
     416                 :        166 : }
     417                 :            : 
     418                 :        526 : void SwSection::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     419                 :            : {
     420                 :        526 :     bool bRemake = false;
     421                 :        526 :     bool bUpdateFtn = false;
     422 [ +  - ][ #  # ]:        526 :     switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 )
           [ +  +  +  +  
             +  -  +  +  
                      + ]
     423                 :            :     {
     424                 :            :     case RES_ATTRSET_CHG:
     425                 :            :         {
     426                 :        126 :             SfxItemSet* pNewSet = ((SwAttrSetChg*)pNew)->GetChgSet();
     427                 :        126 :             SfxItemSet* pOldSet = ((SwAttrSetChg*)pOld)->GetChgSet();
     428                 :            :             const SfxPoolItem* pItem;
     429                 :            : 
     430         [ -  + ]:        126 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
     431         [ +  - ]:        126 :                         RES_PROTECT, sal_False, &pItem ) )
     432                 :            :             {
     433                 :            :                 m_Data.SetProtectFlag( static_cast<SvxProtectItem const*>(pItem)
     434                 :          0 :                         ->IsCntntProtected() );
     435         [ #  # ]:          0 :                 pNewSet->ClearItem( RES_PROTECT );
     436         [ #  # ]:          0 :                 pOldSet->ClearItem( RES_PROTECT );
     437                 :            :             }
     438                 :            : 
     439                 :            :             // --> edit in readonly sections
     440         [ -  + ]:        126 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
     441         [ +  - ]:        126 :                         RES_EDIT_IN_READONLY, sal_False, &pItem ) )
     442                 :            :             {
     443                 :            :                 m_Data.SetEditInReadonlyFlag(
     444                 :          0 :                     static_cast<SwFmtEditInReadonly const*>(pItem)->GetValue());
     445         [ #  # ]:          0 :                 pNewSet->ClearItem( RES_EDIT_IN_READONLY );
     446         [ #  # ]:          0 :                 pOldSet->ClearItem( RES_EDIT_IN_READONLY );
     447                 :            :             }
     448                 :            : 
     449 [ +  - ][ -  + ]:        252 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
                 [ -  + ]
     450         [ +  - ]:        126 :                         RES_FTN_AT_TXTEND, sal_False, &pItem ) ||
     451                 :            :                 SFX_ITEM_SET == pNewSet->GetItemState(
     452         [ +  - ]:        126 :                         RES_END_AT_TXTEND, sal_False, &pItem ))
     453                 :            :             {
     454                 :          0 :                     bUpdateFtn = true;
     455                 :            :             }
     456                 :            : 
     457         [ +  - ]:        126 :             if( !pNewSet->Count() )
     458                 :            :                 return;
     459                 :            :         }
     460                 :        126 :         break;
     461                 :            : 
     462                 :            :     case RES_PROTECT:
     463         [ +  - ]:        186 :         if( pNew )
     464                 :            :         {
     465                 :            :             bool bNewFlag =
     466                 :        186 :                 static_cast<const SvxProtectItem*>(pNew)->IsCntntProtected();
     467         [ +  + ]:        186 :             if( !bNewFlag )
     468                 :            :             {
     469                 :            :                 // Abschalten: teste ob nicht vielleich ueber die Parents
     470                 :            :                 //              doch ein Schutzt besteht!
     471                 :        114 :                 const SwSection* pSect = this;
     472         [ +  + ]:        150 :                 do {
     473         [ +  + ]:        150 :                     if( pSect->IsProtect() )
     474                 :            :                     {
     475                 :         28 :                         bNewFlag = true;
     476                 :         28 :                         break;
     477                 :            :                     }
     478                 :        122 :                     pSect = pSect->GetParent();
     479                 :            :                 } while (pSect);
     480                 :            :             }
     481                 :            : 
     482                 :        186 :             m_Data.SetProtectFlag( bNewFlag );
     483                 :            :         }
     484                 :        186 :         return;
     485                 :            :     // edit in readonly sections
     486                 :            :     case RES_EDIT_IN_READONLY:
     487         [ +  - ]:        120 :         if( pNew )
     488                 :            :         {
     489                 :            :             const bool bNewFlag =
     490                 :        120 :                 static_cast<const SwFmtEditInReadonly*>(pNew)->GetValue();
     491                 :        120 :             m_Data.SetEditInReadonlyFlag( bNewFlag );
     492                 :            :         }
     493                 :        120 :         return;
     494                 :            : 
     495                 :            :     case RES_SECTION_HIDDEN:
     496                 :          7 :         m_Data.SetHiddenFlag(true);
     497                 :          7 :         return;
     498                 :            : 
     499                 :            :     case RES_SECTION_NOT_HIDDEN:
     500                 :            :     case RES_SECTION_RESETHIDDENFLAG:
     501 [ +  - ][ -  + ]:          5 :         m_Data.SetHiddenFlag( m_Data.IsHidden() && m_Data.IsCondHidden() );
     502                 :          5 :         return;
     503                 :            : 
     504                 :            :     case RES_COL:
     505                 :            :         /* wird ggf. vom Layout erledigt */
     506                 :          0 :         break;
     507                 :            : 
     508                 :            :     case RES_FTN_AT_TXTEND:
     509 [ +  - ][ +  - ]:         30 :         if( pNew && pOld )
     510                 :            :         {
     511                 :         30 :             bUpdateFtn = true;
     512                 :            :         }
     513                 :         30 :         break;
     514                 :            : 
     515                 :            :     case RES_END_AT_TXTEND:
     516 [ +  - ][ +  - ]:         34 :         if( pNew && pOld )
     517                 :            :         {
     518                 :         34 :             bUpdateFtn = true;
     519                 :            :         }
     520                 :         34 :         break;
     521                 :            : 
     522                 :            :     default:
     523                 :         18 :         CheckRegistration( pOld, pNew );
     524                 :         18 :         break;
     525                 :            :     }
     526                 :            : 
     527         [ -  + ]:        208 :     if( bRemake )
     528                 :            :     {
     529                 :          0 :         GetFmt()->DelFrms();
     530                 :          0 :         GetFmt()->MakeFrms();
     531                 :            :     }
     532                 :            : 
     533         [ +  + ]:        208 :     if( bUpdateFtn )
     534                 :            :     {
     535                 :         64 :         SwSectionNode* pSectNd = GetFmt()->GetSectionNode( sal_False );
     536         [ +  - ]:         64 :         if( pSectNd )
     537         [ +  - ]:        526 :             pSectNd->GetDoc()->GetFtnIdxs().UpdateFtn(SwNodeIndex( *pSectNd ));
     538                 :            :     }
     539                 :            : }
     540                 :            : 
     541                 :          0 : void SwSection::SetRefObject( SwServerObject* pObj )
     542                 :            : {
     543                 :          0 :     m_RefObj = pObj;
     544                 :          0 : }
     545                 :            : 
     546                 :            : 
     547                 :         30 : void SwSection::SetCondHidden(bool const bFlag)
     548                 :            : {
     549         [ +  + ]:         30 :     if (!m_Data.IsCondHidden() == !bFlag)
     550                 :         30 :         return;
     551                 :            : 
     552                 :         15 :     m_Data.SetCondHidden(bFlag);
     553                 :         15 :     ImplSetHiddenFlag(m_Data.IsHidden(), bFlag);
     554                 :            : }
     555                 :            : 
     556                 :            : 
     557                 :            : // setze/erfrage den gelinkten FileNamen
     558                 :        662 : const String& SwSection::GetLinkFileName() const
     559                 :            : {
     560         [ +  + ]:        662 :     if (m_RefLink.Is())
     561                 :            :     {
     562         [ +  - ]:        380 :         String sTmp;
     563      [ +  +  - ]:        380 :         switch (m_Data.GetType())
     564                 :            :         {
     565                 :            :         case DDE_LINK_SECTION:
     566 [ +  - ][ +  - ]:        298 :             sTmp = m_RefLink->GetLinkSourceName();
                 [ +  - ]
     567                 :        298 :             break;
     568                 :            : 
     569                 :            :         case FILE_LINK_SECTION:
     570                 :            :             {
     571 [ +  - ][ +  - ]:         82 :                 String sRange, sFilter;
     572 [ +  - ][ +  - ]:        164 :                 if (m_RefLink->GetLinkManager() &&
         [ +  - ][ +  - ]
     573                 :            :                     m_RefLink->GetLinkManager()->GetDisplayNames(
     574 [ +  - ][ +  - ]:         82 :                         m_RefLink, 0, &sTmp, &sRange, &sFilter ))
     575                 :            :                 {
     576 [ +  - ][ +  - ]:         82 :                     ( sTmp += sfx2::cTokenSeperator ) += sFilter;
     577 [ +  - ][ +  - ]:         82 :                     ( sTmp += sfx2::cTokenSeperator ) += sRange;
     578                 :            :                 }
     579 [ #  # ][ #  # ]:          0 :                 else if( GetFmt() && !GetFmt()->GetSectionNode() )
         [ #  # ][ #  # ]
     580                 :            :                 {
     581                 :            :                     // ist die Section im UndoNodesArray, dann steht
     582                 :            :                     // der Link nicht im LinkManager, kann also auch nicht
     583                 :            :                     // erfragt werden. Dann returne den akt. Namen
     584                 :         82 :                     return m_Data.GetLinkFileName();
     585 [ +  - ][ -  + ]:         82 :                 }
         [ +  - ][ +  - ]
     586                 :            :             }
     587                 :         82 :             break;
     588                 :          0 :         default: break;
     589                 :            :         }
     590 [ +  - ][ +  - ]:        380 :         const_cast<SwSection*>(this)->m_Data.SetLinkFileName(sTmp);
                 [ +  - ]
     591                 :            :     }
     592                 :        662 :     return m_Data.GetLinkFileName();
     593                 :            : }
     594                 :            : 
     595                 :            : 
     596                 :          0 : void SwSection::SetLinkFileName(const String& rNew, String const*const pPassWd)
     597                 :            : {
     598         [ #  # ]:          0 :     if (m_RefLink.Is())
     599                 :            :     {
     600                 :          0 :         m_RefLink->SetLinkSourceName( rNew );
     601                 :            :     }
     602                 :          0 :     m_Data.SetLinkFileName(rNew);
     603         [ #  # ]:          0 :     if( pPassWd )
     604                 :            :     {
     605                 :          0 :         SetLinkFilePassword( *pPassWd );
     606                 :            :     }
     607                 :          0 : }
     608                 :            : 
     609                 :            : // falls es ein gelinkter Bereich war, dann muessen alle
     610                 :            : // Child-Verknuepfungen sichtbar bemacht werden.
     611                 :          0 : void SwSection::MakeChildLinksVisible( const SwSectionNode& rSectNd )
     612                 :            : {
     613                 :            :     const SwNode* pNd;
     614                 :          0 :     const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->GetLinkManager().GetLinks();
     615         [ #  # ]:          0 :     for( sal_uInt16 n = rLnks.size(); n; )
     616                 :            :     {
     617                 :          0 :         ::sfx2::SvBaseLink* pBLnk = &(*rLnks[ --n ]);
     618   [ #  #  #  # ]:          0 :         if( pBLnk && !pBLnk->IsVisible() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     619                 :          0 :             pBLnk->ISA( SwBaseLink ) &&
     620                 :          0 :             0 != ( pNd = ((SwBaseLink*)pBLnk)->GetAnchor() ) )
     621                 :            :         {
     622                 :          0 :             pNd = pNd->StartOfSectionNode();    // falls SectionNode ist!
     623                 :            :             const SwSectionNode* pParent;
     624   [ #  #  #  # ]:          0 :             while( 0 != ( pParent = pNd->FindSectionNode() ) &&
         [ #  # ][ #  # ]
     625                 :          0 :                     ( CONTENT_SECTION == pParent->GetSection().GetType()
     626                 :            :                         || pNd == &rSectNd ))
     627                 :          0 :                     pNd = pParent->StartOfSectionNode();
     628                 :            : 
     629                 :            :             // steht nur noch in einer normalen Section, also
     630                 :            :             // wieder anzeigen
     631         [ #  # ]:          0 :             if( !pParent )
     632                 :          0 :                 pBLnk->SetVisible( sal_True );
     633                 :            :         }
     634                 :            :     }
     635                 :          0 : }
     636                 :            : 
     637                 :          0 : const SwTOXBase* SwSection::GetTOXBase() const
     638                 :            : {
     639                 :          0 :     const SwTOXBase* pRet = 0;
     640         [ #  # ]:          0 :     if( TOX_CONTENT_SECTION == GetType() )
     641 [ #  # ][ #  # ]:          0 :         pRet = PTR_CAST( SwTOXBaseSection, this );
     642                 :          0 :     return pRet;
     643                 :            : }
     644                 :            : 
     645                 :            : // SwSectionFmt ========================================================
     646                 :            : 
     647                 :        116 : SwSectionFmt::SwSectionFmt( SwSectionFmt* pDrvdFrm, SwDoc *pDoc )
     648         [ +  - ]:        116 :     : SwFrmFmt( pDoc->GetAttrPool(), sSectionFmtNm, pDrvdFrm )
     649                 :            : {
     650                 :        116 :     LockModify();
     651 [ +  - ][ +  - ]:        116 :     SetFmtAttr( *GetDfltAttr( RES_COL ) );
     652                 :        116 :     UnlockModify();
     653                 :        116 : }
     654                 :            : 
     655 [ +  - ][ +  - ]:        116 : SwSectionFmt::~SwSectionFmt()
     656                 :            : {
     657         [ +  + ]:        116 :     if( !GetDoc()->IsInDtor() )
     658                 :            :     {
     659                 :            :         SwSectionNode* pSectNd;
     660         [ +  - ]:          8 :         const SwNodeIndex* pIdx = GetCntnt( sal_False ).GetCntntIdx();
     661         [ +  - ]:         14 :         if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
           [ +  -  +  - ]
         [ +  + ][ +  + ]
     662                 :          6 :             0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
     663                 :            :         {
     664                 :          6 :             SwSection& rSect = pSectNd->GetSection();
     665                 :            :             // falls es ein gelinkter Bereich war, dann muessen alle
     666                 :            :             // Child-Verknuepfungen sichtbar bemacht werden.
     667         [ -  + ]:          6 :             if( rSect.IsConnected() )
     668         [ #  # ]:          0 :                 rSect.MakeChildLinksVisible( *pSectNd );
     669                 :            : 
     670                 :            :             // vorm loeschen der Nodes pruefe, ob wir uns nicht
     671                 :            :             // noch anzeigen muessen!
     672         [ -  + ]:          6 :             if( rSect.IsHiddenFlag() )
     673                 :            :             {
     674         [ #  # ]:          0 :                 SwSection* pParentSect = rSect.GetParent();
     675 [ #  # ][ #  # ]:          0 :                 if( !pParentSect || !pParentSect->IsHiddenFlag() )
                 [ #  # ]
     676                 :            :                 {
     677                 :            :                     // Nodes wieder anzeigen
     678         [ #  # ]:          0 :                     rSect.SetHidden(false);
     679                 :            :                 }
     680                 :            :             }
     681                 :            :             // mba: test iteration; objects are removed while iterating
     682                 :            :             // use hint which allows to specify, if the content shall be saved or not
     683 [ +  - ][ +  - ]:          6 :             CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_True ) );
                 [ +  - ]
     684                 :            : 
     685                 :            :             // hebe die Section doch mal auf
     686         [ +  - ]:          6 :             SwNodeRange aRg( *pSectNd, 0, *pSectNd->EndOfSectionNode() );
     687 [ +  - ][ +  - ]:          6 :             GetDoc()->GetNodes().SectionUp( &aRg );
                 [ +  - ]
     688                 :            :         }
     689                 :          8 :         LockModify();
     690         [ +  - ]:          8 :         ResetFmtAttr( RES_CNTNT );
     691                 :          8 :         UnlockModify();
     692                 :            :     }
     693         [ -  + ]:        232 : }
     694                 :            : 
     695                 :            : 
     696                 :       4048 : SwSection * SwSectionFmt::GetSection() const
     697                 :            : {
     698                 :       4048 :     return SwIterator<SwSection,SwSectionFmt>::FirstElement( *this );
     699                 :            : }
     700                 :            : 
     701                 :            : extern void lcl_DeleteFtn( SwSectionNode *pNd, sal_uLong nStt, sal_uLong nEnd );
     702                 :            : 
     703                 :            : //Vernichtet alle Frms in aDepend (Frms werden per PTR_CAST erkannt).
     704                 :         13 : void SwSectionFmt::DelFrms()
     705                 :            : {
     706                 :            :     SwSectionNode* pSectNd;
     707                 :         13 :     const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
     708   [ +  -  +  - ]:         24 :     if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
         [ +  + ][ +  + ]
     709                 :         11 :         0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
     710                 :            :     {
     711                 :            :         // First delete the <SwSectionFrm> of the <SwSectionFmt> instance
     712                 :            :         // mba: test iteration as objects are removed in iteration
     713                 :            :         // use hint which allows to specify, if the content shall be saved or not
     714 [ +  - ][ +  - ]:         11 :         CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_False ) );
                 [ +  - ]
     715                 :            : 
     716                 :            :         // Then delete frames of the nested <SwSectionFmt> instances
     717         [ +  - ]:         11 :         SwIterator<SwSectionFmt,SwSectionFmt> aIter( *this );
     718         [ +  - ]:         11 :         SwSectionFmt *pLast = aIter.First();
     719         [ +  + ]:         13 :         while ( pLast )
     720                 :            :         {
     721         [ +  - ]:          2 :             pLast->DelFrms();
     722         [ +  - ]:          2 :             pLast = aIter.Next();
     723                 :            :         }
     724                 :            : 
     725                 :         11 :         sal_uLong nEnde = pSectNd->EndOfSectionIndex();
     726                 :         11 :         sal_uLong nStart = pSectNd->GetIndex()+1;
     727 [ +  - ][ +  - ]:         11 :         lcl_DeleteFtn( pSectNd, nStart, nEnde );
     728                 :            :     }
     729         [ +  + ]:         13 :     if( pIdx )
     730                 :            :     {
     731                 :            :         //Hint fuer Pagedesc versenden. Das mueste eigntlich das Layout im
     732                 :            :         //Paste der Frames selbst erledigen, aber das fuehrt dann wiederum
     733                 :            :         //zu weiteren Folgefehlern, die mit Laufzeitkosten geloest werden
     734                 :            :         //muesten.
     735         [ +  - ]:         11 :         SwNodeIndex aNextNd( *pIdx );
     736 [ +  - ][ +  - ]:         11 :         SwCntntNode* pCNd = GetDoc()->GetNodes().GoNextSection( &aNextNd, sal_True, sal_False );
     737         [ +  - ]:         11 :         if( pCNd )
     738                 :            :         {
     739 [ +  - ][ +  - ]:         11 :             const SfxPoolItem& rItem = pCNd->GetSwAttrSet().Get( RES_PAGEDESC );
     740         [ +  - ]:         11 :             pCNd->ModifyNotification( (SfxPoolItem*)&rItem, (SfxPoolItem*)&rItem );
     741         [ +  - ]:         11 :         }
     742                 :            :     }
     743                 :         13 : }
     744                 :            : 
     745                 :            : 
     746                 :            : //Erzeugt die Ansichten
     747                 :          5 : void SwSectionFmt::MakeFrms()
     748                 :            : {
     749                 :            :     SwSectionNode* pSectNd;
     750                 :          5 :     const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
     751                 :            : 
     752   [ +  -  +  - ]:         10 :     if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
         [ +  - ][ +  - ]
     753                 :          5 :         0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
     754                 :            :     {
     755         [ +  - ]:          5 :         SwNodeIndex aIdx( *pIdx );
     756 [ +  - ][ +  - ]:          5 :         pSectNd->MakeFrms( &aIdx );
     757                 :            :     }
     758                 :          5 : }
     759                 :            : 
     760                 :        613 : void SwSectionFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     761                 :            : {
     762                 :        613 :     sal_Bool bClients = sal_False;
     763 [ +  - ][ #  # ]:        613 :     sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
     764   [ +  +  +  -  :        613 :     switch( nWhich )
                -  +  + ]
     765                 :            :     {
     766                 :            :     case RES_ATTRSET_CHG:
     767         [ +  + ]:        523 :         if( GetDepends() )
     768                 :            :         {
     769                 :        484 :             SfxItemSet* pNewSet = ((SwAttrSetChg*)pNew)->GetChgSet();
     770                 :        484 :             SfxItemSet* pOldSet = ((SwAttrSetChg*)pOld)->GetChgSet();
     771                 :            :             const SfxPoolItem *pItem;
     772         [ +  + ]:        484 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
     773         [ +  - ]:        484 :                                         RES_PROTECT, sal_False, &pItem ))
     774                 :            :             {
     775 [ +  - ][ +  - ]:        186 :                 ModifyBroadcast( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem );
     776         [ +  - ]:        186 :                 pNewSet->ClearItem( RES_PROTECT );
     777         [ +  - ]:        186 :                 pOldSet->ClearItem( RES_PROTECT );
     778                 :            :             }
     779                 :            : 
     780                 :            :             // --> edit in readonly sections
     781         [ +  + ]:        484 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
     782         [ +  - ]:        484 :                         RES_EDIT_IN_READONLY, sal_False, &pItem ) )
     783                 :            :             {
     784 [ +  - ][ +  - ]:        120 :                 ModifyBroadcast( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem );
     785         [ +  - ]:        120 :                 pNewSet->ClearItem( RES_EDIT_IN_READONLY );
     786         [ +  - ]:        120 :                 pOldSet->ClearItem( RES_EDIT_IN_READONLY );
     787                 :            :             }
     788                 :            : 
     789         [ +  + ]:        484 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
     790         [ +  - ]:        484 :                                     RES_FTN_AT_TXTEND, sal_False, &pItem ))
     791                 :            :             {
     792 [ +  - ][ +  - ]:         24 :                 ModifyBroadcast( (SfxPoolItem*)&pOldSet->Get( RES_FTN_AT_TXTEND ), (SfxPoolItem*)pItem );
                 [ +  - ]
     793         [ +  - ]:         24 :                 pNewSet->ClearItem( RES_FTN_AT_TXTEND );
     794         [ +  - ]:         24 :                 pOldSet->ClearItem( RES_FTN_AT_TXTEND );
     795                 :            :             }
     796         [ +  + ]:        484 :             if( SFX_ITEM_SET == pNewSet->GetItemState(
     797         [ +  - ]:        484 :                                     RES_END_AT_TXTEND, sal_False, &pItem ))
     798                 :            :             {
     799 [ +  - ][ +  - ]:         26 :                 ModifyBroadcast( (SfxPoolItem*)&pOldSet->Get( RES_END_AT_TXTEND ), (SfxPoolItem*)pItem );
                 [ +  - ]
     800         [ +  - ]:         26 :                 pNewSet->ClearItem( RES_END_AT_TXTEND );
     801         [ +  - ]:         26 :                 pOldSet->ClearItem( RES_END_AT_TXTEND );
     802                 :            :             }
     803         [ +  + ]:        484 :             if( !((SwAttrSetChg*)pOld)->GetChgSet()->Count() )
     804                 :            :                 return;
     805                 :            :         }
     806                 :        167 :         break;
     807                 :            : 
     808                 :            :     case RES_SECTION_RESETHIDDENFLAG:
     809                 :            :     case RES_FTN_AT_TXTEND:
     810                 :         14 :     case RES_END_AT_TXTEND : bClients = sal_True;
     811                 :            :                             // no break !!
     812                 :            :     case RES_SECTION_HIDDEN:
     813                 :            :     case RES_SECTION_NOT_HIDDEN:
     814                 :            :         {
     815                 :         26 :             SwSection* pSect = GetSection();
     816 [ +  + ][ +  +  :         38 :             if( pSect && ( bClients || ( RES_SECTION_HIDDEN == nWhich ?
             +  -  +  - ]
         [ +  - ][ +  - ]
     817                 :         12 :                             !pSect->IsHiddenFlag() : pSect->IsHiddenFlag() ) ) )
     818                 :            :             {
     819                 :         26 :                 ModifyBroadcast( pOld, pNew );
     820                 :            :             }
     821                 :            :         }
     822                 :         26 :         return ;
     823                 :            : 
     824                 :            : 
     825                 :            :     case RES_PROTECT:
     826                 :            :     case RES_EDIT_IN_READONLY: // edit in readonly sections
     827                 :            :         // diese Messages bis zum Ende des Baums durchreichen !
     828         [ #  # ]:          0 :         if( GetDepends() )
     829                 :            :         {
     830                 :          0 :             ModifyBroadcast( pOld, pNew );
     831                 :            :         }
     832                 :          0 :         return;     // das wars
     833                 :            : 
     834                 :            :     case RES_OBJECTDYING:
     835   [ #  #  #  # ]:          0 :         if( !GetDoc()->IsInDtor() &&
                 [ #  # ]
     836                 :          0 :             ((SwPtrMsgPoolItem *)pOld)->pObject == (void*)GetRegisteredIn() )
     837                 :            :         {
     838                 :            :             // mein Parent wird vernichtet, dann an den Parent vom Parent
     839                 :            :             // umhaengen und wieder aktualisieren
     840                 :          0 :             SwFrmFmt::Modify( pOld, pNew );     //  erst umhaengen !!!
     841                 :          0 :             UpdateParent();
     842                 :          0 :             return;
     843                 :            :         }
     844                 :          0 :         break;
     845                 :            : 
     846                 :            :     case RES_FMT_CHG:
     847   [ +  -  +  +  :         78 :         if( !GetDoc()->IsInDtor() &&
           -  + ][ -  + ]
     848                 :         38 :             ((SwFmtChg*)pNew)->pChangedFmt == (void*)GetRegisteredIn() &&
     849                 :          2 :             ((SwFmtChg*)pNew)->pChangedFmt->IsA( TYPE( SwSectionFmt )) )
     850                 :            :         {
     851                 :            :             // mein Parent wird veraendert, muss mich aktualisieren
     852                 :          0 :             SwFrmFmt::Modify( pOld, pNew );     //  erst umhaengen !!!
     853                 :          0 :             UpdateParent();
     854                 :          0 :             return;
     855                 :            :         }
     856                 :         38 :         break;
     857                 :            :     }
     858                 :        231 :     SwFrmFmt::Modify( pOld, pNew );
     859                 :            : 
     860 [ +  + ][ +  + ]:        231 :     if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
                 [ +  - ]
     861                 :            :     {   // invalidate cached uno object
     862         [ +  - ]:        613 :         SetXTextSection(uno::Reference<text::XTextSection>(0));
     863                 :            :     }
     864                 :            : }
     865                 :            : 
     866                 :            :         // erfrage vom Format Informationen
     867                 :          0 : sal_Bool SwSectionFmt::GetInfo( SfxPoolItem& rInfo ) const
     868                 :            : {
     869      [ #  #  # ]:          0 :     switch( rInfo.Which() )
     870                 :            :     {
     871                 :            :     case RES_FINDNEARESTNODE:
     872         [ #  # ]:          0 :         if( ((SwFmtPageDesc&)GetFmtAttr( RES_PAGEDESC )).GetPageDesc() )
     873                 :            :         {
     874                 :          0 :             const SwSectionNode* pNd = GetSectionNode();
     875         [ #  # ]:          0 :             if( pNd )
     876                 :          0 :                 ((SwFindNearestNode&)rInfo).CheckNode( *pNd );
     877                 :            :         }
     878                 :          0 :         return sal_True;
     879                 :            : 
     880                 :            :     case RES_CONTENT_VISIBLE:
     881                 :            :         {
     882                 :          0 :             SwFrm* pFrm = SwIterator<SwFrm,SwFmt>::FirstElement(*this);
     883                 :            :             // if the current section has no own frame search for the children
     884         [ #  # ]:          0 :             if(!pFrm)
     885                 :            :             {
     886         [ #  # ]:          0 :                 SwIterator<SwSectionFmt,SwSectionFmt> aFormatIter(*this);
     887         [ #  # ]:          0 :                 SwSectionFmt* pChild = aFormatIter.First();
     888 [ #  # ][ #  # ]:          0 :                 while(pChild && !pFrm)
                 [ #  # ]
     889                 :            :                 {
     890         [ #  # ]:          0 :                     pFrm = SwIterator<SwFrm,SwFmt>::FirstElement(*pChild);
     891         [ #  # ]:          0 :                     pChild = aFormatIter.Next();
     892         [ #  # ]:          0 :                 }
     893                 :            :             }
     894                 :          0 :             ((SwPtrMsgPoolItem&)rInfo).pObject = pFrm;
     895                 :            :         }
     896                 :          0 :         return sal_False;
     897                 :            :     }
     898                 :          0 :     return SwModify::GetInfo( rInfo );
     899                 :            : }
     900                 :            : 
     901                 :          0 : static bool lcl_SectionCmpPos( const SwSection *pFirst, const SwSection *pSecond)
     902                 :            : {
     903                 :          0 :     const SwSectionFmt* pFSectFmt = pFirst->GetFmt();
     904                 :          0 :     const SwSectionFmt* pSSectFmt = pSecond->GetFmt();
     905                 :            :     OSL_ENSURE( pFSectFmt && pSSectFmt &&
     906                 :            :             pFSectFmt->GetCntnt(sal_False).GetCntntIdx() &&
     907                 :            :             pSSectFmt->GetCntnt(sal_False).GetCntntIdx(),
     908                 :            :                 "ungueltige Sections" );
     909                 :          0 :     return pFSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex() <
     910                 :          0 :                   pSSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex();
     911                 :            : }
     912                 :            : 
     913                 :          0 : static bool lcl_SectionCmpNm( const SwSection *pFSect, const SwSection *pSSect)
     914                 :            : {
     915                 :            :     OSL_ENSURE( pFSect && pSSect, "ungueltige Sections" );
     916                 :            :     StringCompare const eCmp =
     917                 :          0 :         pFSect->GetSectionName().CompareTo( pSSect->GetSectionName() );
     918                 :          0 :     return eCmp == COMPARE_LESS;
     919                 :            : }
     920                 :            : 
     921                 :            :     // alle Sections, die von dieser abgeleitet sind
     922                 :         88 : sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
     923                 :            :                                         SectionSort eSort,
     924                 :            :                                         sal_Bool bAllSections ) const
     925                 :            : {
     926                 :         88 :     rArr.clear();
     927                 :            : 
     928         [ +  - ]:         88 :     if( GetDepends() )
     929                 :            :     {
     930         [ +  - ]:         88 :         SwIterator<SwSectionFmt,SwSectionFmt> aIter(*this);
     931                 :            :         const SwNodeIndex* pIdx;
     932 [ +  - ][ +  - ]:        146 :         for( SwSectionFmt* pLast = aIter.First(); pLast; pLast = aIter.Next() )
                 [ +  + ]
     933 [ +  - ][ +  - ]:        174 :             if( bAllSections ||
         [ +  - ][ +  - ]
     934         [ +  - ]:         58 :                 ( 0 != ( pIdx = pLast->GetCntnt(sal_False).
     935         [ +  - ]:         58 :                 GetCntntIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
     936                 :            :             {
     937         [ +  - ]:         58 :                 SwSection* pDummy = pLast->GetSection();
     938         [ +  - ]:         58 :                 rArr.push_back( pDummy );
     939                 :            :             }
     940                 :            : 
     941                 :            :         // noch eine Sortierung erwuenscht ?
     942         [ -  + ]:         88 :         if( 1 < rArr.size() )
     943   [ #  #  #  # ]:          0 :             switch( eSort )
     944                 :            :             {
     945                 :            :             case SORTSECT_NAME:
     946         [ #  # ]:          0 :                 std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpNm );
     947                 :          0 :                 break;
     948                 :            : 
     949                 :            :             case SORTSECT_POS:
     950         [ #  # ]:          0 :                 std::sort( rArr.begin(), rArr.end(), lcl_SectionCmpPos );
     951                 :          0 :                 break;
     952                 :          0 :             case SORTSECT_NOT: break;
     953         [ +  - ]:         88 :             }
     954                 :            :     }
     955                 :         88 :     return rArr.size();
     956                 :            : }
     957                 :            : 
     958                 :            :     // erfrage, ob sich die Section im Nodes-Array oder UndoNodes-Array
     959                 :            :     // befindet.
     960                 :       1054 : sal_Bool SwSectionFmt::IsInNodesArr() const
     961                 :            : {
     962                 :       1054 :     const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
     963 [ +  - ][ +  - ]:       1054 :     return pIdx && &pIdx->GetNodes() == &GetDoc()->GetNodes();
     964                 :            : }
     965                 :            : 
     966                 :            : 
     967                 :          0 : void SwSectionFmt::UpdateParent()       // Parent wurde veraendert
     968                 :            : {
     969         [ #  # ]:          0 :     if( !GetDepends() )
     970                 :          0 :         return;
     971                 :            : 
     972                 :          0 :     SwSection* pSection = 0;
     973                 :          0 :     const SvxProtectItem* pProtect(0);
     974                 :            :     // edit in readonly sections
     975                 :          0 :     const SwFmtEditInReadonly* pEditInReadonly = 0;
     976                 :          0 :     bool bIsHidden = false;
     977                 :            : 
     978         [ #  # ]:          0 :     SwClientIter aIter( *this );    // TODO
     979         [ #  # ]:          0 :     ::SwClient * pLast = aIter.GoStart();
     980         [ #  # ]:          0 :     if( pLast )     // konnte zum Anfang gesprungen werden ??
     981 [ #  # ][ #  # ]:          0 :         do {
     982 [ #  # ][ #  # ]:          0 :             if( pLast->IsA( TYPE(SwSectionFmt) ) )
                 [ #  # ]
     983                 :            :             {
     984         [ #  # ]:          0 :                 if( !pSection )
     985                 :            :                 {
     986         [ #  # ]:          0 :                     pSection = GetSection();
     987         [ #  # ]:          0 :                     if( GetRegisteredIn() )
     988                 :            :                     {
     989         [ #  # ]:          0 :                         const SwSection* pPS = GetParentSection();
     990         [ #  # ]:          0 :                         pProtect = &pPS->GetFmt()->GetProtect();
     991                 :            :                         // edit in readonly sections
     992         [ #  # ]:          0 :                         pEditInReadonly = &pPS->GetFmt()->GetEditInReadonly();
     993                 :          0 :                         bIsHidden = pPS->IsHiddenFlag();
     994                 :            :                     }
     995                 :            :                     else
     996                 :            :                     {
     997         [ #  # ]:          0 :                         pProtect = &GetProtect();
     998                 :            :                         // edit in readonly sections
     999         [ #  # ]:          0 :                         pEditInReadonly = &GetEditInReadonly();
    1000                 :          0 :                         bIsHidden = pSection->IsHidden();
    1001                 :            :                     }
    1002                 :            :                 }
    1003         [ #  # ]:          0 :                 if (!pProtect->IsCntntProtected() !=
    1004                 :          0 :                     !pSection->IsProtectFlag())
    1005                 :            :                 {
    1006                 :            :                     pLast->ModifyNotification( (SfxPoolItem*)pProtect,
    1007         [ #  # ]:          0 :                                     (SfxPoolItem*)pProtect );
    1008                 :            :                 }
    1009                 :            : 
    1010                 :            :                 // edit in readonly sections
    1011         [ #  # ]:          0 :                 if (!pEditInReadonly->GetValue() !=
    1012                 :          0 :                     !pSection->IsEditInReadonlyFlag())
    1013                 :            :                 {
    1014                 :            :                     pLast->ModifyNotification( (SfxPoolItem*)pEditInReadonly,
    1015         [ #  # ]:          0 :                                     (SfxPoolItem*)pEditInReadonly );
    1016                 :            :                 }
    1017                 :            : 
    1018         [ #  # ]:          0 :                 if( bIsHidden == pSection->IsHiddenFlag() )
    1019                 :            :                 {
    1020                 :            :                     SwMsgPoolItem aMsgItem( static_cast<sal_uInt16>(bIsHidden
    1021                 :            :                                 ? RES_SECTION_HIDDEN
    1022 [ #  # ][ #  # ]:          0 :                                 : RES_SECTION_NOT_HIDDEN ) );
    1023 [ #  # ][ #  # ]:          0 :                     pLast->ModifyNotification( &aMsgItem, &aMsgItem );
    1024                 :            :                 }
    1025                 :            :             }
    1026 [ #  # ][ #  # ]:          0 :             else if( !pSection &&
                 [ #  # ]
    1027 [ #  # ][ #  # ]:          0 :                     pLast->IsA( TYPE(SwSection) ) )
    1028                 :            :             {
    1029                 :          0 :                 pSection = (SwSection*)pLast;
    1030         [ #  # ]:          0 :                 if( GetRegisteredIn() )
    1031                 :            :                 {
    1032         [ #  # ]:          0 :                     const SwSection* pPS = GetParentSection();
    1033         [ #  # ]:          0 :                     pProtect = &pPS->GetFmt()->GetProtect();
    1034                 :            :                     // edit in readonly sections
    1035         [ #  # ]:          0 :                     pEditInReadonly = &pPS->GetFmt()->GetEditInReadonly();
    1036                 :          0 :                     bIsHidden = pPS->IsHiddenFlag();
    1037                 :            :                 }
    1038                 :            :                 else
    1039                 :            :                 {
    1040         [ #  # ]:          0 :                     pProtect = &GetProtect();
    1041                 :            :                     // edit in readonly sections
    1042         [ #  # ]:          0 :                     pEditInReadonly = &GetEditInReadonly();
    1043                 :          0 :                     bIsHidden = pSection->IsHidden();
    1044                 :            :                 }
    1045                 :            :             }
    1046         [ #  # ]:          0 :         } while( 0 != ( pLast = aIter++ ));
    1047                 :            : }
    1048                 :            : 
    1049                 :            : 
    1050                 :       1199 : SwSectionNode* SwSectionFmt::GetSectionNode(bool const bAlways)
    1051                 :            : {
    1052                 :       1199 :     const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
    1053 [ +  - ][ +  - ]:       1199 :     if( pIdx && ( bAlways || &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
         [ +  - ][ +  - ]
    1054                 :       1199 :         return pIdx->GetNode().GetSectionNode();
    1055                 :       1199 :     return 0;
    1056                 :            : }
    1057                 :            : 
    1058                 :            :     // ist die Section eine gueltige fuers GlobalDocument?
    1059                 :          0 : const SwSection* SwSectionFmt::GetGlobalDocSection() const
    1060                 :            : {
    1061                 :          0 :     const SwSectionNode* pNd = GetSectionNode();
    1062 [ #  # ][ #  #  :          0 :     if( pNd &&
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    1063                 :          0 :         ( FILE_LINK_SECTION == pNd->GetSection().GetType() ||
    1064                 :          0 :           TOX_CONTENT_SECTION == pNd->GetSection().GetType() ) &&
    1065                 :          0 :         pNd->GetIndex() > pNd->GetNodes().GetEndOfExtras().GetIndex() &&
    1066                 :          0 :         !pNd->StartOfSectionNode()->IsSectionNode() &&
    1067                 :          0 :         !pNd->StartOfSectionNode()->FindSectionNode() )
    1068                 :          0 :         return &pNd->GetSection();
    1069                 :          0 :     return 0;
    1070                 :            : }
    1071                 :            : 
    1072                 :            : // sw::Metadatable
    1073                 :         64 : ::sfx2::IXmlIdRegistry& SwSectionFmt::GetRegistry()
    1074                 :            : {
    1075                 :         64 :     return GetDoc()->GetXmlIdRegistry();
    1076                 :            : }
    1077                 :            : 
    1078                 :        130 : bool SwSectionFmt::IsInClipboard() const
    1079                 :            : {
    1080                 :        130 :     return GetDoc()->IsClipBoard();
    1081                 :            : }
    1082                 :            : 
    1083                 :        130 : bool SwSectionFmt::IsInUndo() const
    1084                 :            : {
    1085                 :        130 :     return !IsInNodesArr();
    1086                 :            : }
    1087                 :            : 
    1088                 :         64 : bool SwSectionFmt::IsInContent() const
    1089                 :            : {
    1090                 :         64 :     SwNodeIndex const*const pIdx = GetCntnt(sal_False).GetCntntIdx();
    1091                 :            :     OSL_ENSURE(pIdx, "SwSectionFmt::IsInContent: no index?");
    1092 [ +  - ][ +  - ]:         64 :     return (pIdx) ? !GetDoc()->IsInHeaderFooter(*pIdx) : true;
    1093                 :            : }
    1094                 :            : 
    1095                 :            : // n.b.: if the section format represents an index, then there is both a
    1096                 :            : // SwXDocumentIndex and a SwXTextSection instance for this single core object.
    1097                 :            : // these two can both implement XMetadatable and forward to the same core
    1098                 :            : // section format.  but here only one UNO object can be returned,
    1099                 :            : // so always return the text section.
    1100                 :            : uno::Reference< rdf::XMetadatable >
    1101                 :          0 : SwSectionFmt::MakeUnoObject()
    1102                 :            : {
    1103                 :          0 :     uno::Reference<rdf::XMetadatable> xMeta;
    1104         [ #  # ]:          0 :     SwSection *const pSection( GetSection() );
    1105         [ #  # ]:          0 :     if (pSection)
    1106                 :            :     {
    1107                 :            :         xMeta.set(  SwXTextSection::CreateXTextSection(this,
    1108                 :          0 :                         TOX_HEADER_SECTION == pSection->GetType()),
    1109 [ #  # ][ #  # ]:          0 :                     uno::UNO_QUERY );
    1110                 :            :     }
    1111                 :          0 :     return xMeta;
    1112                 :            : }
    1113                 :            : 
    1114                 :            : 
    1115                 :            : // Method to break section links inside a linked section
    1116                 :         14 : void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd )
    1117                 :            : {
    1118         [ -  + ]:         14 :     if ( !rSectNd.GetDoc() )
    1119                 :            :     {
    1120                 :            :         OSL_FAIL( "method <lcl_RemoveSectionLinksInSect(..)> - no Doc at SectionNode" );
    1121                 :          0 :         return;
    1122                 :            :     }
    1123                 :            : 
    1124         [ -  + ]:         14 :     if ( !rSectNd.GetSection().IsConnected() )
    1125                 :            :     {
    1126                 :            :         OSL_FAIL( "method <lcl_RemoveSectionLinksInSect(..)> - no Link at Section of SectionNode" );
    1127                 :          0 :         return;
    1128                 :            :     }
    1129                 :         14 :     const ::sfx2::SvBaseLink* pOwnLink( &(rSectNd.GetSection().GetBaseLink() ) );
    1130                 :         14 :     const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->GetLinkManager().GetLinks();
    1131         [ +  + ]:         28 :     for ( sal_uInt16 n = rLnks.size(); n > 0; )
    1132                 :            :     {
    1133         [ -  + ]:         14 :         SwIntrnlSectRefLink* pSectLnk = dynamic_cast<SwIntrnlSectRefLink*>(&(*rLnks[ --n ]));
    1134         [ +  - ]:         14 :         if ( pSectLnk && pSectLnk != pOwnLink &&
           [ -  +  #  # ]
                 [ -  + ]
    1135                 :          0 :              pSectLnk->IsInRange( rSectNd.GetIndex(), rSectNd.EndOfSectionIndex() ) )
    1136                 :            :         {
    1137                 :            :             // break the link of the corresponding section.
    1138                 :            :             // the link is also removed from the link manager
    1139                 :          0 :             pSectLnk->GetSectNode()->GetSection().BreakLink();
    1140                 :            : 
    1141                 :            :             // for robustness, because link is removed from the link manager
    1142         [ #  # ]:          0 :             if ( n > rLnks.size() )
    1143                 :            :             {
    1144                 :          0 :                 n = rLnks.size();
    1145                 :            :             }
    1146                 :            :         }
    1147                 :            :     }
    1148                 :            : }
    1149                 :            : 
    1150                 :         14 : void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
    1151                 :            : {
    1152                 :         14 :     SwDoc* pDoc = rSectNd.GetDoc();
    1153                 :         14 :     SwDocShell* pDShell = pDoc->GetDocShell();
    1154 [ -  + ][ +  - ]:         14 :     if( !pDShell || !pDShell->GetMedium() )
                 [ +  - ]
    1155                 :         14 :         return ;
    1156                 :            : 
    1157 [ +  - ][ +  - ]:         14 :     String sName( pDShell->GetMedium()->GetName() );
    1158                 :            :     SwBaseLink* pBLink;
    1159         [ +  - ]:         14 :     String sMimeType( SotExchange::GetFormatMimeType( FORMAT_FILE ));
    1160                 :         14 :     uno::Any aValue;
    1161 [ +  - ][ +  - ]:         14 :     aValue <<= ::rtl::OUString( sName );                        // beliebiger Name
    1162                 :            : 
    1163         [ +  - ]:         14 :     const ::sfx2::SvBaseLinks& rLnks = pDoc->GetLinkManager().GetLinks();
    1164         [ +  + ]:         28 :     for( sal_uInt16 n = rLnks.size(); n; )
    1165                 :            :     {
    1166                 :         14 :         ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
    1167   [ -  +  #  # ]:         14 :         if( pLnk && pLnk != &rUpdLnk &&
         [ #  # ][ #  # ]
         [ -  + ][ +  - ]
    1168                 :          0 :             OBJECT_CLIENT_FILE == pLnk->GetObjType() &&
    1169 [ #  # ][ #  # ]:          0 :             pLnk->ISA( SwBaseLink ) &&
    1170                 :            :             ( pBLink = (SwBaseLink*)pLnk )->IsInRange( rSectNd.GetIndex(),
    1171         [ #  # ]:          0 :                                                 rSectNd.EndOfSectionIndex() ) )
    1172                 :            :         {
    1173                 :            :             // liegt in dem Bereich: also updaten. Aber nur wenns nicht
    1174                 :            :             // im gleichen File liegt
    1175         [ #  # ]:          0 :             String sFName;
    1176 [ #  # ][ #  # ]:          0 :             pDoc->GetLinkManager().GetDisplayNames( pBLink, 0, &sFName, 0, 0 );
    1177 [ #  # ][ #  # ]:          0 :             if( sFName != sName )
    1178                 :            :             {
    1179         [ #  # ]:          0 :                 pBLink->DataChanged( sMimeType, aValue );
    1180                 :            : 
    1181                 :            :                 // ggfs. neu den Link-Pointer wieder suchen, damit nicht einer
    1182                 :            :                 // ausgelassen oder doppelt gerufen wird.
    1183 [ #  # ][ #  # ]:          0 :                 if( n >= rLnks.size() && 0 != ( n = rLnks.size() ))
                 [ #  # ]
    1184                 :          0 :                     --n;
    1185                 :            : 
    1186 [ #  # ][ #  # ]:          0 :                 if( n && pLnk != &(*rLnks[ n ]) )
                 [ #  # ]
    1187                 :            :                 {
    1188                 :            :                     // suchen - kann nur davor liegen!!
    1189         [ #  # ]:          0 :                     while( n )
    1190         [ #  # ]:          0 :                         if( pLnk == &(*rLnks[ --n ] ) )
    1191                 :          0 :                             break;
    1192                 :            :                 }
    1193         [ #  # ]:          0 :             }
    1194                 :            :         }
    1195 [ +  - ][ +  - ]:         14 :     }
    1196                 :            : }
    1197                 :            : 
    1198                 :            : 
    1199                 :            : // sucht sich die richtige DocShell raus oder erzeugt eine neue:
    1200                 :            : // Der Return-Wert gibt an, was mit der Shell zu geschehen hat:
    1201                 :            : //  0 - Fehler, konnte DocShell nicht finden
    1202                 :            : //  1 - DocShell ist ein existieren Document
    1203                 :            : //  2 - DocShell wurde neu angelegt, muss also wieder geschlossen werden ( will be assigned to xLockRef additionaly )
    1204                 :            : 
    1205                 :         10 : int lcl_FindDocShell( SfxObjectShellRef& xDocSh,
    1206                 :            :                         SfxObjectShellLock& xLockRef,
    1207                 :            :                         const String& rFileName,
    1208                 :            :                         const String& rPasswd,
    1209                 :            :                         String& rFilter,
    1210                 :            :                         sal_Int16 nVersion,
    1211                 :            :                         SwDocShell* pDestSh )
    1212                 :            : {
    1213         [ -  + ]:         10 :     if( !rFileName.Len() )
    1214                 :          0 :         return 0;
    1215                 :            : 
    1216                 :            :     // 1. existiert die Datei schon in der Liste aller Dokumente?
    1217 [ +  - ][ +  - ]:         10 :     INetURLObject aTmpObj( rFileName );
    1218 [ +  - ][ +  - ]:         10 :     aTmpObj.SetMark( aEmptyStr );
    1219                 :            : 
    1220                 :            :     // erstmal nur ueber die DocumentShells laufen und die mit dem
    1221                 :            :     // Namen heraussuchen:
    1222         [ +  - ]:         10 :     TypeId aType( TYPE(SwDocShell) );
    1223                 :            : 
    1224                 :         10 :     SfxObjectShell* pShell = pDestSh;
    1225                 :         10 :     sal_Bool bFirst = 0 != pShell;
    1226                 :            : 
    1227         [ -  + ]:         10 :     if( !bFirst )
    1228                 :            :         // keine DocShell uebergeben, also beginne mit der ersten aus der
    1229                 :            :         // DocShell Liste
    1230         [ #  # ]:          0 :         pShell = SfxObjectShell::GetFirst( &aType );
    1231                 :            : 
    1232         [ +  + ]:         18 :     while( pShell )
    1233                 :            :     {
    1234                 :            :         // die wollen wir haben
    1235                 :         14 :         SfxMedium* pMed = pShell->GetMedium();
    1236 [ +  - ][ +  - ]:         14 :         if( pMed && pMed->GetURLObject() == aTmpObj )
         [ +  + ][ +  + ]
                 [ +  - ]
    1237                 :            :         {
    1238                 :            :             const SfxPoolItem* pItem;
    1239 [ -  + ][ +  - ]:          6 :             if( ( SFX_ITEM_SET == pMed->GetItemSet()->GetItemState(
    1240 [ +  - ][ +  - ]:          6 :                                             SID_VERSION, sal_False, &pItem ) )
    1241                 :          0 :                     ? (nVersion == ((SfxInt16Item*)pItem)->GetValue())
    1242                 :            :                     : !nVersion )
    1243                 :            :             {
    1244                 :            :                 // gefunden also returnen
    1245         [ +  - ]:          6 :                 xDocSh = pShell;
    1246                 :          6 :                 return 1;
    1247                 :            :             }
    1248                 :            :         }
    1249                 :            : 
    1250         [ +  + ]:          8 :         if( bFirst )
    1251                 :            :         {
    1252                 :          4 :             bFirst = sal_False;
    1253         [ +  - ]:          4 :             pShell = SfxObjectShell::GetFirst( &aType );
    1254                 :            :         }
    1255                 :            :         else
    1256         [ +  - ]:          4 :             pShell = SfxObjectShell::GetNext( *pShell, &aType );
    1257                 :            :     }
    1258                 :            : 
    1259                 :            :     // 2. selbst die Date oeffnen
    1260                 :            :     SfxMedium* pMed = new SfxMedium( aTmpObj.GetMainURL(
    1261 [ +  - ][ +  - ]:          4 :                              INetURLObject::NO_DECODE ), STREAM_READ );
         [ +  - ][ +  - ]
                 [ +  - ]
    1262         [ +  - ]:          4 :     if( INET_PROT_FILE == aTmpObj.GetProtocol() )
    1263 [ +  - ][ +  - ]:          4 :         pMed->DownLoad();     // nur mal das Medium anfassen (DownLoaden)
    1264                 :            : 
    1265                 :          4 :     const SfxFilter* pSfxFlt = 0;
    1266 [ +  - ][ -  + ]:          4 :     if( !pMed->GetError() )
    1267                 :            :     {
    1268 [ #  # ][ #  # ]:          0 :         String sFactory(rtl::OUString::createFromAscii(SwDocShell::Factory().GetShortName()));
    1269         [ #  # ]:          0 :         SfxFilterMatcher aMatcher( sFactory );
    1270                 :            : 
    1271                 :            :         // kein Filter, dann suche ihn. Ansonsten teste, ob der angegebene
    1272                 :            :         // ein gueltiger ist
    1273         [ #  # ]:          0 :         if( rFilter.Len() )
    1274                 :            :         {
    1275         [ #  # ]:          0 :             pSfxFlt = aMatcher.GetFilter4FilterName( rFilter );
    1276                 :            :         }
    1277                 :            : 
    1278         [ #  # ]:          0 :         if( nVersion )
    1279 [ #  # ][ #  # ]:          0 :             pMed->GetItemSet()->Put( SfxInt16Item( SID_VERSION, nVersion ));
         [ #  # ][ #  # ]
    1280                 :            : 
    1281         [ #  # ]:          0 :         if( rPasswd.Len() )
    1282 [ #  # ][ #  # ]:          0 :             pMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
         [ #  # ][ #  # ]
    1283                 :            : 
    1284         [ #  # ]:          0 :         if( !pSfxFlt )
    1285         [ #  # ]:          0 :             aMatcher.DetectFilter( *pMed, &pSfxFlt, sal_False, sal_False );
    1286                 :            : 
    1287         [ #  # ]:          0 :         if( pSfxFlt )
    1288                 :            :         {
    1289                 :            :             // ohne Filter geht gar nichts
    1290         [ #  # ]:          0 :             pMed->SetFilter( pSfxFlt );
    1291                 :            : 
    1292                 :            :             // if the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure
    1293 [ #  # ][ #  # ]:          0 :             xLockRef = new SwDocShell( SFX_CREATE_MODE_INTERNAL );
                 [ #  # ]
    1294         [ #  # ]:          0 :             xDocSh = (SfxObjectShell*)xLockRef;
    1295 [ #  # ][ #  # ]:          0 :             if( xDocSh->DoLoad( pMed ) )
    1296                 :          0 :                 return 2;
    1297 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
    1298                 :            :     }
    1299                 :            : 
    1300         [ +  - ]:          4 :     if( !xDocSh.Is() )      // Medium muss noch geloescht werden
    1301 [ +  - ][ +  - ]:          4 :         delete pMed;
    1302                 :            : 
    1303         [ +  - ]:         10 :     return 0;   // das war wohl nichts
    1304                 :            : }
    1305                 :            : 
    1306                 :            : 
    1307                 :            : 
    1308                 :         20 : ::sfx2::SvBaseLink::UpdateResult SwIntrnlSectRefLink::DataChanged(
    1309                 :            :     const String& rMimeType, const uno::Any & rValue )
    1310                 :            : {
    1311         [ +  - ]:         20 :     SwSectionNode* pSectNd = rSectFmt.GetSectionNode( sal_False );
    1312                 :         20 :     SwDoc* pDoc = rSectFmt.GetDoc();
    1313                 :            : 
    1314         [ +  - ]:         20 :     sal_uLong nDataFormat = SotExchange::GetFormatIdFromMimeType( rMimeType );
    1315                 :            : 
    1316 [ +  - ][ +  - ]:         40 :     if( !pSectNd || !pDoc || pDoc->IsInDtor() || ChkNoDataFlag() ||
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
    1317         [ +  - ]:         20 :         sfx2::LinkManager::RegisterStatusInfoId() == nDataFormat )
    1318                 :            :     {
    1319                 :            :         // sollten wir schon wieder im Undo stehen?
    1320                 :          2 :         return SUCCESS;
    1321                 :            :     }
    1322                 :            : 
    1323                 :            :     //  #i38810# - Due to possible existing signatures, the
    1324                 :            :     // document has to be modified after updating a link.
    1325         [ +  - ]:         18 :     pDoc->SetModified();
    1326                 :            :     // set additional flag that links have been updated, in order to check this
    1327                 :            :     // during load.
    1328         [ +  - ]:         18 :     pDoc->SetLinksUpdated( sal_True );
    1329                 :            : 
    1330                 :            :     // Undo immer abschalten
    1331 [ +  - ][ +  - ]:         18 :     bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo();
    1332 [ +  - ][ +  - ]:         18 :     pDoc->GetIDocumentUndoRedo().DoUndo(false);
    1333         [ +  - ]:         18 :     sal_Bool bWasVisibleLinks = pDoc->IsVisibleLinks();
    1334         [ +  - ]:         18 :     pDoc->SetVisibleLinks( sal_False );
    1335                 :            : 
    1336                 :            :     SwPaM* pPam;
    1337                 :         18 :     ViewShell* pVSh = 0;
    1338         [ +  - ]:         18 :     SwEditShell* pESh = pDoc->GetEditShell( &pVSh );
    1339         [ +  - ]:         18 :     pDoc->LockExpFlds();
    1340                 :            :     {
    1341                 :            :         // am Anfang des Bereichs einen leeren TextNode einfuegen
    1342         [ +  - ]:         18 :         SwNodeIndex aIdx( *pSectNd, +1 );
    1343         [ +  - ]:         18 :         SwNodeIndex aEndIdx( *pSectNd->EndOfSectionNode() );
    1344         [ +  - ]:         18 :         SwTxtNode* pNewNd = pDoc->GetNodes().MakeTxtNode( aIdx,
    1345 [ +  - ][ +  - ]:         36 :                         pDoc->GetTxtCollFromPool( RES_POOLCOLL_TEXT ) );
    1346                 :            : 
    1347         [ +  - ]:         18 :         if( pESh )
    1348         [ +  - ]:         18 :             pESh->StartAllAction();
    1349         [ #  # ]:          0 :         else if( pVSh )
    1350         [ #  # ]:          0 :             pVSh->StartAction();
    1351                 :            : 
    1352 [ +  - ][ +  - ]:         18 :         SwPosition aPos( aIdx, SwIndex( pNewNd, 0 ));
         [ +  - ][ +  - ]
    1353         [ +  - ]:         18 :         aPos.nNode--;
    1354         [ +  - ]:         18 :         pDoc->CorrAbs( aIdx, aEndIdx, aPos, sal_True );
    1355                 :            : 
    1356 [ +  - ][ +  - ]:         18 :         pPam = new SwPaM( aPos );
    1357                 :            : 
    1358                 :            :         //und alles dahinter liegende loeschen
    1359         [ +  - ]:         18 :         aIdx--;
    1360         [ +  - ]:         18 :         DelFlyInRange( aIdx, aEndIdx );
    1361         [ +  - ]:         18 :         _DelBookmarks(aIdx, aEndIdx);
    1362         [ +  - ]:         18 :         aIdx++;
    1363                 :            : 
    1364 [ +  - ][ +  - ]:         18 :         pDoc->GetNodes().Delete( aIdx, aEndIdx.GetIndex() - aIdx.GetIndex() );
         [ +  - ][ +  - ]
                 [ +  - ]
    1365                 :            :     }
    1366                 :            : 
    1367                 :         18 :     SwSection& rSection = pSectNd->GetSection();
    1368                 :         18 :     rSection.SetConnectFlag(false);
    1369                 :            : 
    1370                 :         18 :     ::rtl::OUString sNewFileName;
    1371                 :         18 :     Reader* pRead = 0;
    1372   [ -  -  +  - ]:         18 :     switch( nDataFormat )
    1373                 :            :     {
    1374                 :            :     case FORMAT_STRING:
    1375                 :          0 :         pRead = ReadAscii;
    1376                 :          0 :         break;
    1377                 :            : 
    1378                 :            :     case FORMAT_RTF:
    1379         [ #  # ]:          0 :         pRead = SwReaderWriter::GetReader( READER_WRITER_RTF );
    1380                 :          0 :         break;
    1381                 :            : 
    1382                 :            :     case FORMAT_FILE:
    1383 [ +  - ][ +  - ]:         18 :         if( rValue.hasValue() && ( rValue >>= sNewFileName ) )
                 [ +  - ]
    1384                 :            :         {
    1385 [ +  - ][ +  - ]:         18 :             String sFilter, sRange, sFileName( sNewFileName );
                 [ +  - ]
    1386         [ +  - ]:         18 :             pDoc->GetLinkManager().GetDisplayNames( this, 0, &sFileName,
    1387         [ +  - ]:         18 :                                                     &sRange, &sFilter );
    1388                 :            : 
    1389                 :         18 :             RedlineMode_t eOldRedlineMode = nsRedlineMode_t::REDLINE_NONE;
    1390                 :         18 :             SfxObjectShellRef xDocSh;
    1391                 :         18 :             SfxObjectShellLock xLockRef;
    1392                 :            :             int nRet;
    1393         [ +  + ]:         18 :             if( !sFileName.Len() )
    1394                 :            :             {
    1395         [ +  - ]:          8 :                 xDocSh = pDoc->GetDocShell();
    1396                 :          8 :                 nRet = 1;
    1397                 :            :             }
    1398                 :            :             else
    1399                 :            :             {
    1400                 :            :                 nRet = lcl_FindDocShell( xDocSh, xLockRef, sFileName,
    1401                 :         10 :                                     rSection.GetLinkFilePassword(),
    1402         [ +  - ]:         20 :                                     sFilter, 0, pDoc->GetDocShell() );
    1403         [ +  + ]:         10 :                 if( nRet )
    1404                 :            :                 {
    1405                 :          6 :                     SwDoc* pSrcDoc = ((SwDocShell*)&xDocSh)->GetDoc();
    1406         [ +  - ]:          6 :                     eOldRedlineMode = pSrcDoc->GetRedlineMode();
    1407         [ +  - ]:          6 :                     pSrcDoc->SetRedlineMode( nsRedlineMode_t::REDLINE_SHOW_INSERT );
    1408                 :            :                 }
    1409                 :            :             }
    1410                 :            : 
    1411         [ +  + ]:         18 :             if( nRet )
    1412                 :            :             {
    1413                 :         14 :                 rSection.SetConnectFlag(true);
    1414                 :            : 
    1415         [ +  - ]:         14 :                 SwNodeIndex aSave( pPam->GetPoint()->nNode, -1 );
    1416                 :         14 :                 SwNodeRange* pCpyRg = 0;
    1417                 :            : 
    1418   [ +  -  +  - ]:         28 :                 if( xDocSh->GetMedium() &&
                 [ +  - ]
    1419                 :         14 :                     !rSection.GetLinkFilePassword().Len() )
    1420                 :            :                 {
    1421                 :            :                     const SfxPoolItem* pItem;
    1422         [ -  + ]:         14 :                     if( SFX_ITEM_SET == xDocSh->GetMedium()->GetItemSet()->
    1423 [ +  - ][ +  - ]:         14 :                         GetItemState( SID_PASSWORD, sal_False, &pItem ) )
    1424                 :            :                         rSection.SetLinkFilePassword(
    1425         [ #  # ]:         14 :                                 ((SfxStringItem*)pItem)->GetValue() );
    1426                 :            :                 }
    1427                 :            : 
    1428                 :         14 :                 SwDoc* pSrcDoc = ((SwDocShell*)&xDocSh)->GetDoc();
    1429                 :            : 
    1430         [ +  + ]:         14 :                 if( sRange.Len() )
    1431                 :            :                 {
    1432                 :            :                     // Rekursionen abfangen
    1433                 :         12 :                     sal_Bool bRecursion = sal_False;
    1434         [ +  - ]:         12 :                     if( pSrcDoc == pDoc )
    1435                 :            :                     {
    1436                 :            :                         SwServerObjectRef refObj( (SwServerObject*)
    1437 [ +  - ][ +  - ]:         12 :                                         pDoc->CreateLinkSource( sRange ));
    1438         [ -  + ]:         12 :                         if( refObj.Is() )
    1439                 :            :                         {
    1440         [ #  # ]:          0 :                             bRecursion = refObj->IsLinkInServer( this ) ||
    1441 [ #  # ][ #  # ]:          0 :                                         ChkNoDataFlag();
    1442         [ +  - ]:         12 :                         }
    1443                 :            :                     }
    1444                 :            : 
    1445                 :         12 :                     SwNodeIndex& rInsPos = pPam->GetPoint()->nNode;
    1446                 :            : 
    1447                 :         12 :                     SwPaM* pCpyPam = 0;
    1448 [ -  + ][ #  # ]:         24 :                     if( !bRecursion &&
         [ -  + ][ +  - ]
    1449         [ +  - ]:         12 :                         pSrcDoc->SelectServerObj( sRange, pCpyPam, pCpyRg )
    1450                 :            :                         && pCpyPam )
    1451                 :            :                     {
    1452   [ #  #  #  #  :          0 :                         if( pSrcDoc != pDoc ||
           #  # ][ #  # ]
    1453         [ #  # ]:          0 :                             pCpyPam->Start()->nNode > rInsPos ||
    1454         [ #  # ]:          0 :                             rInsPos >= pCpyPam->End()->nNode )
    1455                 :            :                         {
    1456                 :          0 :                             pSrcDoc->CopyRange( *pCpyPam, *pPam->GetPoint(),
    1457         [ #  # ]:          0 :                                     false );
    1458                 :            :                         }
    1459 [ #  # ][ #  # ]:          0 :                         delete pCpyPam;
    1460                 :            :                     }
    1461 [ -  + ][ #  #  :         12 :                     if( pCpyRg && pSrcDoc == pDoc &&
             #  #  #  # ]
                 [ -  + ]
    1462                 :          0 :                         pCpyRg->aStart < rInsPos && rInsPos < pCpyRg->aEnd )
    1463 [ #  # ][ #  # ]:         12 :                         delete pCpyRg, pCpyRg = 0;
    1464                 :            :                 }
    1465         [ -  + ]:          2 :                 else if( pSrcDoc != pDoc )
    1466         [ #  # ]:          0 :                     pCpyRg = new SwNodeRange( pSrcDoc->GetNodes().GetEndOfExtras(), 2,
    1467 [ #  # ][ #  # ]:          0 :                                           pSrcDoc->GetNodes().GetEndOfContent() );
                 [ #  # ]
    1468                 :            : 
    1469                 :            :                 // #i81653#
    1470                 :            :                 // Update links of extern linked document or extern linked
    1471                 :            :                 // document section, if section is protected.
    1472   [ -  +  #  # ]:         14 :                 if ( pSrcDoc != pDoc &&
                 [ -  + ]
    1473                 :          0 :                      rSection.IsProtectFlag() )
    1474                 :            :                 {
    1475 [ #  # ][ #  # ]:          0 :                     pSrcDoc->GetLinkManager().UpdateAllLinks( sal_False, sal_True, sal_False, 0 );
    1476                 :            :                 }
    1477                 :            : 
    1478         [ -  + ]:         14 :                 if( pCpyRg )
    1479                 :            :                 {
    1480                 :          0 :                     SwNodeIndex& rInsPos = pPam->GetPoint()->nNode;
    1481                 :          0 :                     sal_Bool bCreateFrm = rInsPos.GetIndex() <=
    1482         [ #  # ]:          0 :                                 pDoc->GetNodes().GetEndOfExtras().GetIndex() ||
    1483 [ #  # ][ #  # ]:          0 :                                 rInsPos.GetNode().FindTableNode();
                 [ #  # ]
    1484                 :            : 
    1485         [ #  # ]:          0 :                     SwTblNumFmtMerge aTNFM( *pSrcDoc, *pDoc );
    1486                 :            : 
    1487         [ #  # ]:          0 :                     pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, bCreateFrm );
    1488         [ #  # ]:          0 :                     aSave++;
    1489                 :            : 
    1490         [ #  # ]:          0 :                     if( !bCreateFrm )
    1491         [ #  # ]:          0 :                         ::MakeFrms( pDoc, aSave, rInsPos );
    1492                 :            : 
    1493                 :            :                     // den letzten Node noch loeschen, aber nur wenn
    1494                 :            :                     // erfolgreich kopiert werden konnte, also der Bereich
    1495                 :            :                     // mehr als 1 Node enthaelt
    1496         [ #  # ]:          0 :                     if( 2 < pSectNd->EndOfSectionIndex() - pSectNd->GetIndex() )
    1497                 :            :                     {
    1498         [ #  # ]:          0 :                         aSave = rInsPos;
    1499         [ #  # ]:          0 :                         pPam->Move( fnMoveBackward, fnGoNode );
    1500         [ #  # ]:          0 :                         pPam->SetMark();    // beide SwPositions ummelden!
    1501                 :            : 
    1502         [ #  # ]:          0 :                         pDoc->CorrAbs( aSave, *pPam->GetPoint(), 0, sal_True );
    1503 [ #  # ][ #  # ]:          0 :                         pDoc->GetNodes().Delete( aSave, 1 );
    1504                 :            :                     }
    1505 [ #  # ][ #  # ]:          0 :                     delete pCpyRg;
                 [ #  # ]
    1506                 :            :                 }
    1507                 :            : 
    1508         [ +  - ]:         14 :                 lcl_BreakSectionLinksInSect( *pSectNd );
    1509                 :            : 
    1510                 :            :                 // update alle Links in diesem Bereich
    1511 [ +  - ][ +  - ]:         14 :                 lcl_UpdateLinksInSect( *this, *pSectNd );
    1512                 :            :             }
    1513         [ +  + ]:         18 :             if( xDocSh.Is() )
    1514                 :            :             {
    1515         [ -  + ]:         14 :                 if( 2 == nRet )
    1516         [ #  # ]:          0 :                     xDocSh->DoClose();
    1517         [ +  - ]:         14 :                 else if( ((SwDocShell*)&xDocSh)->GetDoc() )
    1518                 :         14 :                     ((SwDocShell*)&xDocSh)->GetDoc()->SetRedlineMode(
    1519         [ +  - ]:         14 :                                 eOldRedlineMode );
    1520 [ +  - ][ +  - ]:         18 :             }
         [ +  - ][ +  - ]
                 [ +  - ]
    1521                 :            :         }
    1522                 :         18 :         break;
    1523                 :            :     }
    1524                 :            : 
    1525                 :            :     // !!!! DDE nur updaten wenn Shell vorhanden ist??
    1526         [ +  - ]:         18 :     uno::Sequence< sal_Int8 > aSeq;
    1527 [ -  + ][ #  # ]:         18 :     if( pRead && rValue.hasValue() && ( rValue >>= aSeq ) )
         [ #  # ][ #  # ]
                 [ -  + ]
    1528                 :            :     {
    1529         [ #  # ]:          0 :         if( pESh )
    1530                 :            :         {
    1531         [ #  # ]:          0 :             pESh->Push();
    1532         [ #  # ]:          0 :             SwPaM* pCrsr = pESh->GetCrsr();
    1533         [ #  # ]:          0 :             *pCrsr->GetPoint() = *pPam->GetPoint();
    1534 [ #  # ][ #  # ]:          0 :             delete pPam;
    1535                 :          0 :             pPam = pCrsr;
    1536                 :            :         }
    1537                 :            : 
    1538                 :          0 :         SvMemoryStream aStrm( (void*)aSeq.getConstArray(), aSeq.getLength(),
    1539         [ #  # ]:          0 :                                 STREAM_READ );
    1540         [ #  # ]:          0 :         aStrm.Seek( 0 );
    1541                 :            : 
    1542                 :            :         // TODO/MBA: it's impossible to set a BaseURL here!
    1543 [ #  # ][ #  # ]:          0 :         SwReader aTmpReader( aStrm, aEmptyStr, pDoc->GetDocShell()->GetMedium()->GetBaseURL(), *pPam );
         [ #  # ][ #  # ]
    1544                 :            : 
    1545 [ #  # ][ #  # ]:          0 :         if( !IsError( aTmpReader.Read( *pRead ) ))
    1546                 :            :         {
    1547                 :          0 :             rSection.SetConnectFlag(true);
    1548                 :            :         }
    1549                 :            : 
    1550         [ #  # ]:          0 :         if( pESh )
    1551                 :            :         {
    1552         [ #  # ]:          0 :             pESh->Pop( sal_False );
    1553                 :          0 :             pPam = 0;                   // pam is deleted before
    1554 [ #  # ][ #  # ]:          0 :         }
    1555                 :            :     }
    1556                 :            : 
    1557                 :            : 
    1558                 :            :     // remove all undo actions and turn undo on again
    1559 [ +  - ][ +  - ]:         18 :     pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
    1560 [ +  - ][ +  - ]:         18 :     pDoc->GetIDocumentUndoRedo().DoUndo(bWasUndo);
    1561         [ +  - ]:         18 :     pDoc->SetVisibleLinks( bWasVisibleLinks );
    1562                 :            : 
    1563         [ +  - ]:         18 :     pDoc->UnlockExpFlds();
    1564 [ +  - ][ +  - ]:         18 :     if( !pDoc->IsExpFldsLocked() )
    1565         [ +  - ]:         18 :         pDoc->UpdateExpFlds(NULL, true);
    1566                 :            : 
    1567         [ +  - ]:         18 :     if( pESh )
    1568         [ +  - ]:         18 :         pESh->EndAllAction();
    1569         [ #  # ]:          0 :     else if( pVSh )
    1570         [ #  # ]:          0 :         pVSh->EndAction();
    1571 [ +  - ][ +  - ]:         18 :     delete pPam;            // wurde am Anfang angelegt
    1572                 :            : 
    1573         [ +  - ]:         20 :     return SUCCESS;
    1574                 :            : }
    1575                 :            : 
    1576                 :            : 
    1577                 :          0 : void SwIntrnlSectRefLink::Closed()
    1578                 :            : {
    1579                 :          0 :     SwDoc* pDoc = rSectFmt.GetDoc();
    1580 [ #  # ][ #  # ]:          0 :     if( pDoc && !pDoc->IsInDtor() )
                 [ #  # ]
    1581                 :            :     {
    1582                 :            :         // Advise verabschiedet sich, den Bereich als nicht geschuetzt
    1583                 :            :         // kennzeichnen und das Flag umsetzen
    1584                 :            : 
    1585                 :          0 :         const SwSectionFmts& rFmts = pDoc->GetSections();
    1586         [ #  # ]:          0 :         for( sal_uInt16 n = rFmts.size(); n; )
    1587         [ #  # ]:          0 :             if( rFmts[ --n ] == &rSectFmt )
    1588                 :            :             {
    1589                 :            :                 ViewShell* pSh;
    1590         [ #  # ]:          0 :                 SwEditShell* pESh = pDoc->GetEditShell( &pSh );
    1591                 :            : 
    1592         [ #  # ]:          0 :                 if( pESh )
    1593         [ #  # ]:          0 :                     pESh->StartAllAction();
    1594                 :            :                 else
    1595         [ #  # ]:          0 :                     pSh->StartAction();
    1596                 :            : 
    1597 [ #  # ][ #  # ]:          0 :                 SwSectionData aSectionData(*rSectFmt.GetSection());
    1598                 :          0 :                 aSectionData.SetType( CONTENT_SECTION );
    1599         [ #  # ]:          0 :                 aSectionData.SetLinkFileName( aEmptyStr );
    1600                 :          0 :                 aSectionData.SetHidden( false );
    1601                 :          0 :                 aSectionData.SetProtectFlag( false );
    1602                 :            :                 // edit in readonly sections
    1603                 :          0 :                 aSectionData.SetEditInReadonlyFlag( false );
    1604                 :            : 
    1605                 :          0 :                 aSectionData.SetConnectFlag( false );
    1606                 :            : 
    1607         [ #  # ]:          0 :                 pDoc->UpdateSection( n, aSectionData );
    1608                 :            : 
    1609                 :            :                 // alle in der Section liegenden Links werden sichtbar
    1610         [ #  # ]:          0 :                 SwSectionNode* pSectNd = rSectFmt.GetSectionNode( sal_False );
    1611         [ #  # ]:          0 :                 if( pSectNd )
    1612         [ #  # ]:          0 :                     pSectNd->GetSection().MakeChildLinksVisible( *pSectNd );
    1613                 :            : 
    1614         [ #  # ]:          0 :                 if( pESh )
    1615         [ #  # ]:          0 :                     pESh->EndAllAction();
    1616                 :            :                 else
    1617         [ #  # ]:          0 :                     pSh->EndAction();
    1618         [ #  # ]:          0 :                 break;
    1619                 :            :             }
    1620                 :            :     }
    1621                 :          0 :     SvBaseLink::Closed();
    1622                 :          0 : }
    1623                 :            : 
    1624                 :            : 
    1625                 :         20 : void SwSection::CreateLink( LinkCreateType eCreateType )
    1626                 :            : {
    1627                 :         20 :     SwSectionFmt* pFmt = GetFmt();
    1628                 :            :     OSL_ENSURE(pFmt, "SwSection::CreateLink: no format?");
    1629 [ -  + ][ +  - ]:         20 :     if (!pFmt || (CONTENT_SECTION == m_Data.GetType()))
                 [ +  - ]
    1630                 :         20 :         return ;
    1631                 :            : 
    1632                 :         20 :     sal_uInt16 nUpdateType = sfx2::LINKUPDATE_ALWAYS;
    1633                 :            : 
    1634         [ +  + ]:         20 :     if (!m_RefLink.Is())
    1635                 :            :     {
    1636                 :            :         // create BaseLink
    1637 [ +  - ][ +  - ]:          2 :         m_RefLink = new SwIntrnlSectRefLink( *pFmt, nUpdateType, FORMAT_RTF );
                 [ +  - ]
    1638                 :            :     }
    1639                 :            :     else
    1640                 :            :     {
    1641 [ +  - ][ +  - ]:         18 :         pFmt->GetDoc()->GetLinkManager().Remove( m_RefLink );
    1642                 :            :     }
    1643                 :            : 
    1644                 :            :     SwIntrnlSectRefLink *const pLnk =
    1645                 :         20 :         static_cast<SwIntrnlSectRefLink*>(& m_RefLink);
    1646                 :            : 
    1647         [ +  - ]:         20 :     String sCmd( m_Data.GetLinkFileName() );
    1648                 :            :     xub_StrLen nPos;
    1649 [ +  - ][ -  + ]:         20 :     while( STRING_NOTFOUND != (nPos = sCmd.SearchAscii( "  " )) )
    1650         [ #  # ]:          0 :         sCmd.Erase( nPos, 1 );
    1651                 :            : 
    1652         [ +  - ]:         20 :     pLnk->SetUpdateMode( nUpdateType );
    1653         [ +  - ]:         20 :     pLnk->SetVisible( pFmt->GetDoc()->IsVisibleLinks() );
    1654                 :            : 
    1655      [ +  +  - ]:         20 :     switch (m_Data.GetType())
    1656                 :            :     {
    1657                 :            :     case DDE_LINK_SECTION:
    1658         [ +  - ]:         12 :         pLnk->SetLinkSourceName( sCmd );
    1659 [ +  - ][ +  - ]:         12 :         pFmt->GetDoc()->GetLinkManager().InsertDDELink( pLnk );
    1660                 :         12 :         break;
    1661                 :            :     case FILE_LINK_SECTION:
    1662                 :            :         {
    1663         [ +  - ]:          8 :             pLnk->SetContentType( FORMAT_FILE );
    1664         [ +  - ]:          8 :             String sFltr( sCmd.GetToken( 1, sfx2::cTokenSeperator ) );
    1665         [ +  - ]:          8 :             String sRange( sCmd.GetToken( 2, sfx2::cTokenSeperator ) );
    1666         [ +  - ]:          8 :             pFmt->GetDoc()->GetLinkManager().InsertFileLink( *pLnk,
    1667                 :          8 :                                 static_cast<sal_uInt16>(m_Data.GetType()),
    1668                 :            :                                 sCmd.GetToken( 0, sfx2::cTokenSeperator ),
    1669                 :          8 :                                 ( sFltr.Len() ? &sFltr : 0 ),
    1670 [ +  - ][ -  + ]:         24 :                                 ( sRange.Len() ? &sRange : 0 ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1671                 :            :         }
    1672                 :          8 :         break;
    1673                 :            :     default:
    1674                 :            :         OSL_ENSURE( !this, "Was ist das fuer ein Link?" );
    1675                 :            :     }
    1676                 :            : 
    1677   [ -  +  -  - ]:         20 :     switch( eCreateType )
    1678                 :            :     {
    1679                 :            :     case CREATE_CONNECT:            // Link gleich connecten
    1680         [ #  # ]:          0 :         pLnk->Connect();
    1681                 :          0 :         break;
    1682                 :            : 
    1683                 :            :     case CREATE_UPDATE:         // Link connecten und updaten
    1684         [ +  - ]:         20 :         pLnk->Update();
    1685                 :         20 :         break;
    1686                 :          0 :     case CREATE_NONE: break;
    1687         [ +  - ]:         20 :     }
    1688                 :            : }
    1689                 :            : 
    1690                 :          0 : void SwSection::BreakLink()
    1691                 :            : {
    1692                 :          0 :     const SectionType eCurrentType( GetType() );
    1693 [ #  # ][ #  # ]:          0 :     if ( eCurrentType == CONTENT_SECTION ||
                 [ #  # ]
    1694                 :            :          eCurrentType == TOX_HEADER_SECTION ||
    1695                 :            :          eCurrentType == TOX_CONTENT_SECTION )
    1696                 :            :     {
    1697                 :            :         // nothing to do
    1698                 :          0 :         return;
    1699                 :            :     }
    1700                 :            : 
    1701                 :            :     // release link, if it exists
    1702         [ #  # ]:          0 :     if (m_RefLink.Is())
    1703                 :            :     {
    1704                 :          0 :         SwSectionFmt *const pFormat( GetFmt() );
    1705                 :            :         OSL_ENSURE(pFormat, "SwSection::BreakLink: no format?");
    1706         [ #  # ]:          0 :         if (pFormat)
    1707                 :            :         {
    1708                 :          0 :             pFormat->GetDoc()->GetLinkManager().Remove( m_RefLink );
    1709                 :            :         }
    1710                 :          0 :         m_RefLink.Clear();
    1711                 :            :     }
    1712                 :            :     // change type
    1713                 :          0 :     SetType( CONTENT_SECTION );
    1714                 :            :     // reset linked file data
    1715                 :          0 :     SetLinkFileName( aEmptyStr );
    1716                 :          0 :     SetLinkFilePassword( aEmptyStr );
    1717                 :            : }
    1718                 :            : 
    1719                 :          0 : const SwNode* SwIntrnlSectRefLink::GetAnchor() const
    1720                 :            : {
    1721                 :          0 :     return rSectFmt.GetSectionNode( sal_False );
    1722                 :            : }
    1723                 :            : 
    1724                 :            : 
    1725                 :          0 : sal_Bool SwIntrnlSectRefLink::IsInRange( sal_uLong nSttNd, sal_uLong nEndNd,
    1726                 :            :                                      xub_StrLen , xub_StrLen ) const
    1727                 :            : {
    1728                 :          0 :     SwStartNode* pSttNd = rSectFmt.GetSectionNode( sal_False );
    1729                 :            :     return pSttNd &&
    1730                 :          0 :             nSttNd < pSttNd->GetIndex() &&
    1731         [ #  # ]:          0 :             pSttNd->EndOfSectionIndex() < nEndNd;
           [ #  #  #  # ]
    1732                 :            : }
    1733                 :            : 
    1734                 :          0 : sal_uInt16 SwSectionFmts::GetPos(const SwSectionFmt* p) const
    1735                 :            : {
    1736         [ #  # ]:          0 :     const_iterator it = std::find(begin(), end(), p);
    1737 [ #  # ][ #  # ]:          0 :     return it == end() ? USHRT_MAX : it - begin();
         [ #  # ][ #  # ]
                 [ #  # ]
    1738                 :            : }
    1739                 :            : 
    1740                 :         50 : bool SwSectionFmts::Contains(const SwSectionFmt* p) const
    1741                 :            : {
    1742 [ +  - ][ +  - ]:         50 :     return std::find(begin(), end(), p) != end();
    1743                 :            : }
    1744                 :            : 
    1745         [ +  - ]:       1458 : SwSectionFmts::~SwSectionFmts()
    1746                 :            : {
    1747 [ +  - ][ +  - ]:       1566 :     for(const_iterator it = begin(); it != end(); ++it)
                 [ +  + ]
    1748 [ +  - ][ +  - ]:        108 :         delete *it;
    1749         [ -  + ]:       2916 : }
    1750                 :            : 
    1751                 :            : 
    1752                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10