LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/swg - swblocks.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 239 332 72.0 %
Date: 2013-07-09 Functions: 38 54 70.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/docfilt.hxx>
      21             : #include <sot/storage.hxx>
      22             : #include <tools/urlobj.hxx>
      23             : #include <svl/fstathelper.hxx>
      24             : #include <svl/macitem.hxx>
      25             : #include <unotools/charclass.hxx>
      26             : #include <frmfmt.hxx>
      27             : #include <doc.hxx>
      28             : #include <docary.hxx>
      29             : #include <pam.hxx>
      30             : #include <shellio.hxx>
      31             : #include <swblocks.hxx>
      32             : #include <ndtxt.hxx>
      33             : #include <mdiexp.hxx>       // Progress
      34             : #include <SwXMLTextBlocks.hxx>
      35             : #include <docsh.hxx>
      36             : #include <swunohelper.hxx>
      37             : 
      38             : #include <statstr.hrc>
      39             : #include <swerror.h>
      40             : 
      41             : //////////////////////////////////////////////////////////////////////////
      42             : 
      43             : // Hash-Code errechnen (muss nicht eindeutig sein)
      44             : 
      45             : 
      46         178 : sal_uInt16 SwImpBlocks::Hash( const String& r )
      47             : {
      48         178 :     sal_uInt16 n = 0;
      49         178 :     xub_StrLen nLen = r.Len();
      50         178 :     if( nLen > 8 )
      51         178 :         nLen = 8;
      52         178 :     const sal_Unicode* p = r.GetBuffer();
      53        1780 :     while( nLen-- )
      54        1424 :         n = ( n << 1 ) + *p++;
      55         178 :     return n;
      56             : }
      57             : 
      58             : 
      59           0 : SwBlockName::SwBlockName( const String& rShort, const String& rLong )
      60             :     : aShort( rShort ), aLong( rLong ), aPackageName (rShort),
      61           0 :     bIsOnlyTxtFlagInit( sal_False ), bIsOnlyTxt( sal_False )
      62             : {
      63           0 :     nHashS = SwImpBlocks::Hash( rShort );
      64           0 :     nHashL = SwImpBlocks::Hash( rLong );
      65           0 : }
      66          41 : SwBlockName::SwBlockName( const String& rShort, const String& rLong, const String& rPackageName)
      67             :     : aShort( rShort ), aLong( rLong ), aPackageName (rPackageName),
      68          41 :     bIsOnlyTxtFlagInit( sal_False ), bIsOnlyTxt( sal_False )
      69             : {
      70          41 :     nHashS = SwImpBlocks::Hash( rShort );
      71          41 :     nHashL = SwImpBlocks::Hash( rLong );
      72          41 : }
      73             : 
      74             : 
      75             : // Ist die angegebene Datei ein Storage oder gibt es sie nicht?
      76             : 
      77          59 : short SwImpBlocks::GetFileType( const String& rFile )
      78             : {
      79          59 :     if( !FStatHelper::IsDocument( rFile ) )
      80           2 :         return SWBLK_NO_FILE;
      81          57 :     if( SwXMLTextBlocks::IsFileUCBStorage( rFile ) )
      82          57 :         return SWBLK_XML;
      83           0 :     if( SvStorage::IsStorageFile( rFile ) )
      84           0 :         return SWBLK_SW3;
      85             :     //otherwise return NONE
      86           0 :     return SWBLK_NONE;
      87             : }
      88             : 
      89             : 
      90          59 : SwImpBlocks::SwImpBlocks( const String& rFile, sal_Bool )
      91             :     : aFile( rFile ),
      92             :     aDateModified( Date::EMPTY ),
      93             :     aTimeModified( Time::EMPTY ),
      94             :     pDoc( 0 ), nCur( (sal_uInt16)-1 ),
      95          59 :     bReadOnly( sal_True ), bInPutMuchBlocks( sal_False )
      96             : {
      97             :     FStatHelper::GetModifiedDateTimeOfFile( rFile,
      98          59 :                                             &aDateModified, &aTimeModified );
      99          59 :     INetURLObject aObj(rFile);
     100          59 :     aObj.setExtension( aEmptyStr );
     101          59 :     aName = aObj.GetBase();
     102          59 : }
     103             : 
     104             : 
     105         116 : SwImpBlocks::~SwImpBlocks()
     106             : {
     107          58 :     aNames.DeleteAndDestroyAll();
     108          58 : }
     109             : 
     110             : // Loeschen des Inhaltes des Dokuments
     111           0 : void SwImpBlocks::ClearDoc()
     112             : {
     113           0 :     pDoc->ClearDoc();
     114           0 : }
     115             : 
     116             : // Erzeugen eines PaMs, der das ganze Dokument umfasst
     117           1 : SwPaM* SwImpBlocks::MakePaM()
     118             : {
     119           1 :     SwPaM* pPam = new SwPaM( pDoc->GetNodes().GetEndOfContent() );
     120           1 :     pPam->Move( fnMoveBackward, fnGoDoc );
     121           1 :     pPam->SetMark();
     122           1 :     pPam->Move( fnMoveForward, fnGoDoc );
     123           1 :     pPam->Exchange();
     124           1 :     return pPam;
     125             : }
     126             : 
     127             : 
     128          44 : sal_uInt16 SwImpBlocks::GetCount() const
     129             : {
     130          44 :     return aNames.size();
     131             : }
     132             : 
     133             : // Case Insensitive
     134          95 : sal_uInt16 SwImpBlocks::GetIndex( const String& rShort ) const
     135             : {
     136          95 :     String s( GetAppCharClass().uppercase( rShort ) );
     137          95 :     sal_uInt16 nHash = Hash( s );
     138         108 :     for( sal_uInt16 i = 0; i < aNames.size(); i++ )
     139             :     {
     140          42 :         const SwBlockName* pName = aNames[ i ];
     141          84 :         if( pName->nHashS == nHash
     142          42 :          && pName->aShort == s )
     143          29 :             return i;
     144             :     }
     145          66 :     return (sal_uInt16) -1;
     146             : }
     147             : 
     148             : 
     149           1 : sal_uInt16 SwImpBlocks::GetLongIndex( const String& rLong ) const
     150             : {
     151           1 :     sal_uInt16 nHash = Hash( rLong );
     152           2 :     for( sal_uInt16 i = 0; i < aNames.size(); i++ )
     153             :     {
     154           1 :         const SwBlockName* pName = aNames[ i ];
     155           2 :         if( pName->nHashL == nHash
     156           1 :          && pName->aLong == rLong )
     157           0 :             return i;
     158             :     }
     159           1 :     return (sal_uInt16) -1;
     160             : }
     161             : 
     162             : 
     163          19 : const String& SwImpBlocks::GetShortName( sal_uInt16 n ) const
     164             : {
     165          19 :     if( n < aNames.size() )
     166          19 :         return aNames[n]->aShort;
     167           0 :     return aEmptyStr;
     168             : }
     169             : 
     170             : 
     171          15 : const String& SwImpBlocks::GetLongName( sal_uInt16 n ) const
     172             : {
     173          15 :     if( n < aNames.size() )
     174          15 :         return aNames[n]->aLong;
     175           0 :     return aEmptyStr;
     176             : }
     177             : 
     178          14 : OUString SwImpBlocks::GetPackageName( sal_uInt16 n ) const
     179             : {
     180          14 :     if( n < aNames.size() )
     181          14 :         return aNames[n]->aPackageName;
     182           0 :     return OUString();
     183             : }
     184             : 
     185           0 : void SwImpBlocks::AddName( const String& rShort, const String& rLong,
     186             :                             sal_Bool bOnlyTxt )
     187             : {
     188           0 :     sal_uInt16 nIdx = GetIndex( rShort );
     189           0 :     if( nIdx != (sal_uInt16) -1 )
     190             :     {
     191           0 :         delete aNames[nIdx];
     192           0 :         aNames.erase( aNames.begin() + nIdx );
     193             :     }
     194           0 :     SwBlockName* pNew = new SwBlockName( rShort, rLong );
     195           0 :     pNew->bIsOnlyTxtFlagInit = sal_True;
     196           0 :     pNew->bIsOnlyTxt = bOnlyTxt;
     197           0 :     aNames.insert( pNew );
     198           0 : }
     199             : 
     200             : 
     201             : 
     202          17 : sal_Bool SwImpBlocks::IsFileChanged() const
     203             : {
     204          17 :     Date aTempDateModified( aDateModified );
     205          17 :     Time aTempTimeModified( aTimeModified );
     206             :     return FStatHelper::GetModifiedDateTimeOfFile( aFile,
     207          68 :                             &aTempDateModified, &aTempTimeModified ) &&
     208          34 :           ( aDateModified != aTempDateModified ||
     209          51 :             aTimeModified != aTempTimeModified );
     210             : }
     211             : 
     212             : 
     213          15 : void SwImpBlocks::Touch()
     214             : {
     215             :     FStatHelper::GetModifiedDateTimeOfFile( aFile,
     216          15 :                                             &aDateModified, &aTimeModified );
     217          15 : }
     218             : 
     219           0 : sal_Bool SwImpBlocks::IsOnlyTextBlock( const String& ) const
     220             : {
     221           0 :     return sal_False;
     222             : }
     223             : 
     224           0 : sal_uLong SwImpBlocks::GetMacroTable( sal_uInt16, SvxMacroTableDtor&, sal_Bool )
     225             : {
     226           0 :     return 0;
     227             : }
     228             : 
     229           0 : sal_uLong SwImpBlocks::SetMacroTable( sal_uInt16 ,
     230             :                                 const SvxMacroTableDtor& , sal_Bool )
     231             : {
     232           0 :     return 0;
     233             : }
     234             : 
     235           0 : sal_Bool SwImpBlocks::PutMuchEntries( sal_Bool )
     236             : {
     237           0 :     return sal_False;
     238             : }
     239             : 
     240             : ////////////////////////////////////////////////////////////////////////////
     241             : 
     242             : 
     243          59 : SwTextBlocks::SwTextBlocks( const String& rFile )
     244          59 :     : pImp( 0 ), nErr( 0 )
     245             : {
     246          59 :     INetURLObject aObj(rFile);
     247         118 :     String sFileName = aObj.GetMainURL( INetURLObject::NO_DECODE );
     248          59 :     switch( SwImpBlocks::GetFileType( rFile ) )
     249             :     {
     250          57 :     case SWBLK_XML:     pImp = new SwXMLTextBlocks( sFileName ); break;
     251           2 :     case SWBLK_NO_FILE: pImp = new SwXMLTextBlocks( sFileName ); break;
     252             :     }
     253          59 :     if( !pImp )
     254          59 :         nErr = ERR_SWG_FILE_FORMAT_ERROR;
     255          59 : }
     256             : 
     257          58 : SwTextBlocks::~SwTextBlocks()
     258             : {
     259          58 :     delete pImp;
     260          58 : }
     261             : 
     262          59 : const String& SwTextBlocks::GetName()
     263             : {
     264          59 :     return pImp ? pImp->aName : aEmptyStr;
     265             : }
     266             : 
     267             : 
     268           4 : void SwTextBlocks::SetName( const String& r )
     269             : {
     270           4 :     if( pImp )
     271           4 :         pImp->SetName( r );
     272           4 : }
     273             : 
     274             : 
     275           0 : sal_Bool SwTextBlocks::IsOld() const
     276             : {
     277           0 :     if (pImp)
     278             :     {
     279           0 :         short nType = pImp->GetFileType();
     280           0 :         if (SWBLK_SW3 == nType || SWBLK_SW2 == nType )
     281           0 :             return sal_True;
     282             :     }
     283           0 :     return sal_False;
     284             : }
     285             : 
     286             : 
     287          27 : sal_uInt16 SwTextBlocks::GetCount() const
     288             : {
     289          27 :     return pImp ? pImp->GetCount() : 0;
     290             : }
     291             : 
     292             : 
     293          31 : sal_uInt16 SwTextBlocks::GetIndex( const String& r ) const
     294             : {
     295          31 :     return pImp ? pImp->GetIndex( r ) : (sal_uInt16) -1;
     296             : }
     297             : 
     298             : 
     299           1 : sal_uInt16 SwTextBlocks::GetLongIndex( const String& r ) const
     300             : {
     301           1 :     return pImp ? (sal_uInt16)(pImp->GetLongIndex( r )) : (sal_uInt16) -1;
     302             : }
     303             : 
     304             : 
     305           9 : const String& SwTextBlocks::GetShortName( sal_uInt16 n ) const
     306             : {
     307           9 :     if( pImp )
     308           9 :         return pImp->GetShortName( n );
     309           0 :     return aEmptyStr;
     310             : }
     311             : 
     312             : 
     313           5 : const String& SwTextBlocks::GetLongName( sal_uInt16 n ) const
     314             : {
     315           5 :     if( pImp )
     316           5 :         return pImp->GetLongName( n );
     317           0 :     return aEmptyStr;
     318             : }
     319             : 
     320             : 
     321           5 : sal_Bool SwTextBlocks::Delete( sal_uInt16 n )
     322             : {
     323           5 :     if( pImp && !pImp->bInPutMuchBlocks )
     324             :     {
     325           5 :         if( pImp->IsFileChanged() )
     326           0 :             nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
     327           5 :         else if( 0 == (nErr = pImp->OpenFile( sal_False ) ))
     328             :         {
     329           5 :             nErr = pImp->Delete( n );
     330           5 :             if( !nErr )
     331             :             {
     332           5 :                 delete pImp->aNames[n];
     333           5 :                 pImp->aNames.erase( pImp->aNames.begin() + n );
     334             :             }
     335           5 :             if( n == pImp->nCur )
     336           0 :                 pImp->nCur = (sal_uInt16) -1;
     337           5 :             if( !nErr )
     338           5 :                 nErr = pImp->MakeBlockList();
     339             :         }
     340           5 :         pImp->CloseFile();
     341           5 :         pImp->Touch();
     342             : 
     343           5 :         return sal_Bool( nErr == 0 );
     344             :     }
     345           0 :     return sal_False;
     346             : }
     347             : 
     348             : 
     349           1 : sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const String* s, const String* l )
     350             : {
     351           1 :     sal_uInt16 nIdx = (sal_uInt16)-1;
     352           1 :     if( pImp && !pImp->bInPutMuchBlocks )
     353             :     {
     354           1 :         pImp->nCur = nIdx;
     355           2 :         String aNew, aLong;
     356           1 :         if( s )
     357           1 :             aNew = aLong = *s;
     358           1 :         if( l )
     359           1 :             aLong = *l;
     360           1 :         if( !aNew.Len() )
     361             :         {
     362             :             OSL_ENSURE( !this, "Kein Kurzname in Rename angegeben" );
     363           0 :             nErr = ERR_SWG_INTERNAL_ERROR; return (sal_uInt16) -1;
     364             :         }
     365             : 
     366           1 :         if( pImp->IsFileChanged() )
     367           0 :             nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
     368           1 :         else if( 0 == ( nErr = pImp->OpenFile( sal_False )))
     369             :         {
     370             :             // Vorher den neuen Eintrag in die Liste setzen!
     371           1 :             aNew = GetAppCharClass().uppercase( aNew );
     372           1 :              nErr = pImp->Rename( n, aNew, aLong );
     373           1 :             if( !nErr )
     374             :             {
     375           1 :                 sal_Bool bOnlyTxt = pImp->aNames[ n ]->bIsOnlyTxt;
     376           1 :                 delete pImp->aNames[n];
     377           1 :                 pImp->aNames.erase( pImp->aNames.begin() + n );
     378           1 :                 pImp->AddName( aNew, aLong, bOnlyTxt );
     379           1 :                 nErr = pImp->MakeBlockList();
     380             :             }
     381             :         }
     382           1 :         pImp->CloseFile();
     383           1 :         pImp->Touch();
     384           1 :         if( !nErr )
     385           2 :             nIdx = pImp->GetIndex( aNew );
     386             :     }
     387           1 :     return nIdx;
     388             : }
     389             : 
     390           0 : sal_uLong SwTextBlocks::CopyBlock( SwTextBlocks& rSource, String& rSrcShort,
     391             :                                 const String& rLong )
     392             : {
     393           0 :     bool bIsOld = false;
     394           0 :     if (rSource.pImp)
     395             :     {
     396           0 :         short nType = rSource.pImp->GetFileType();
     397           0 :         if (SWBLK_SW2 == nType || SWBLK_SW3 == nType )
     398           0 :             bIsOld = true;
     399             :     }
     400           0 :     if( bIsOld ) //rSource.IsOld() )
     401           0 :         nErr = ERR_SWG_OLD_GLOSSARY;
     402           0 :     else if( pImp->bInPutMuchBlocks )
     403           0 :         nErr = ERR_SWG_INTERNAL_ERROR;
     404             :     else
     405           0 :         nErr = pImp->CopyBlock(*rSource.pImp, rSrcShort, rLong);
     406           0 :     return nErr;
     407             : }
     408             : 
     409           4 : sal_Bool SwTextBlocks::BeginGetDoc( sal_uInt16 n )
     410             : {
     411           4 :     if( pImp && !pImp->bInPutMuchBlocks )
     412             :     {
     413             : // diese Optimierierung darf es nicht mehr geben. OLE-Objecte muessen auf
     414             : // ihre SubStorages zugreifem koennen!
     415             : //      if( n == pImp->nCur )
     416             : //          return sal_True;
     417             : 
     418           4 :         if( pImp->IsFileChanged() )
     419           0 :             nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
     420           4 :         else if( 0 == ( nErr = pImp->OpenFile( sal_True )))
     421             :         {
     422           4 :             pImp->ClearDoc();
     423           4 :             nErr = pImp->GetDoc( n );
     424           4 :             if( nErr )
     425           0 :                 pImp->nCur = (sal_uInt16)-1;
     426             :             else
     427           4 :                 pImp->nCur = n;
     428             :         }
     429           4 :         return sal_Bool( nErr == 0 );
     430             :     }
     431           0 :     return sal_False;
     432             : }
     433             : 
     434             : 
     435           4 : void SwTextBlocks::EndGetDoc()
     436             : {
     437           4 :     if( pImp && !pImp->bInPutMuchBlocks )
     438           4 :         pImp->CloseFile();
     439           4 : }
     440             : 
     441             : 
     442           1 : sal_Bool SwTextBlocks::BeginPutDoc( const String& s, const String& l )
     443             : {
     444           1 :     if( pImp )
     445             :     {
     446           1 :         sal_Bool bOk = pImp->bInPutMuchBlocks;
     447           1 :         if( !bOk )
     448             :         {
     449           1 :             if( pImp->IsFileChanged() )
     450           0 :                 nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
     451             :             else
     452           1 :                 nErr = pImp->OpenFile( sal_False );
     453           1 :             bOk = 0 == nErr;
     454             :         }
     455           1 :         if( bOk )
     456             :         {
     457           1 :             String aNew = GetAppCharClass().uppercase(s);
     458           1 :             nErr = pImp->BeginPutDoc( aNew, l );
     459             :         }
     460           1 :         if( nErr )
     461           0 :             pImp->CloseFile();
     462             :     }
     463           1 :     return 0 == nErr;
     464             : }
     465             : 
     466             : 
     467           1 : sal_uInt16 SwTextBlocks::PutDoc()
     468             : {
     469           1 :     sal_uInt16 nIdx = (sal_uInt16)-1;
     470           1 :     if( pImp )
     471             :     {
     472           1 :         nErr = pImp->PutDoc();
     473           1 :         if( !nErr )
     474             :         {
     475           1 :             pImp->nCur = GetIndex( pImp->aShort );
     476           1 :             if( pImp->nCur != (sal_uInt16) -1 )
     477           0 :                 pImp->aNames[ pImp->nCur ]->aLong = pImp->aLong;
     478             :             else
     479             :             {
     480           1 :                 pImp->AddName( pImp->aShort, pImp->aLong );
     481           1 :                 pImp->nCur = pImp->GetIndex( pImp->aShort );
     482             :             }
     483           1 :             if( !pImp->bInPutMuchBlocks )
     484           1 :                 nErr = pImp->MakeBlockList();
     485             :         }
     486           1 :         if( !pImp->bInPutMuchBlocks )
     487             :         {
     488           1 :             pImp->CloseFile();
     489           1 :             pImp->Touch();
     490             :         }
     491           1 :         nIdx = pImp->nCur;
     492             :     }
     493           1 :     return nIdx;
     494             : }
     495             : 
     496           6 : sal_uInt16 SwTextBlocks::PutText( const String& rShort, const String& rName,
     497             :                               const String& rTxt )
     498             : {
     499           6 :     sal_uInt16 nIdx = (sal_uInt16) -1;
     500           6 :     if( pImp )
     501             :     {
     502           6 :         sal_Bool bOk = pImp->bInPutMuchBlocks;
     503           6 :         if( !bOk )
     504             :         {
     505           6 :             if( pImp->IsFileChanged() )
     506           0 :                 nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
     507             :             else
     508           6 :                 nErr = pImp->OpenFile( sal_False );
     509           6 :             bOk = 0 == nErr;
     510             :         }
     511           6 :         if( bOk )
     512             :         {
     513           6 :             String aNew = GetAppCharClass().uppercase( rShort );
     514           6 :             nErr = pImp->PutText( aNew, rName, rTxt );
     515           6 :             pImp->nCur = (sal_uInt16) -1;
     516           6 :             if( !nErr )
     517             :             {
     518           6 :                 nIdx = GetIndex( pImp->aShort );
     519           6 :                 if( nIdx != (sal_uInt16) -1 )
     520           1 :                     pImp->aNames[ nIdx ]->aLong = rName;
     521             :                 else
     522             :                 {
     523           5 :                     pImp->AddName( pImp->aShort, rName, sal_True );
     524           5 :                     nIdx = pImp->GetIndex( pImp->aShort );
     525             :                 }
     526           6 :                 if( !pImp->bInPutMuchBlocks )
     527           6 :                     nErr = pImp->MakeBlockList();
     528           6 :             }
     529             :         }
     530           6 :         if( !pImp->bInPutMuchBlocks )
     531             :         {
     532           6 :             pImp->CloseFile();
     533           6 :             pImp->Touch();
     534             :         }
     535             :     }
     536           6 :     return nIdx;
     537             : }
     538             : 
     539             : 
     540          11 : SwDoc* SwTextBlocks::GetDoc()
     541             : {
     542          11 :     if( pImp )
     543          11 :         return pImp->pDoc;
     544           0 :     return 0;
     545             : }
     546             : 
     547             : 
     548           1 : void SwTextBlocks::ClearDoc()
     549             : {
     550           1 :     if( pImp )
     551           1 :         pImp->ClearDoc();
     552           1 :     pImp->nCur = (sal_uInt16) -1;
     553           1 : }
     554             : 
     555             : 
     556           0 : const String& SwTextBlocks::GetFileName() const
     557             : {
     558           0 :     return pImp->GetFileName();
     559             : }
     560             : 
     561             : 
     562           0 : sal_Bool SwTextBlocks::IsReadOnly() const
     563             : {
     564           0 :     return pImp->bReadOnly;
     565             : }
     566             : 
     567           4 : sal_Bool SwTextBlocks::IsOnlyTextBlock( sal_uInt16 nIdx ) const
     568             : {
     569           4 :     sal_Bool bRet = sal_False;
     570           4 :     if( pImp && !pImp->bInPutMuchBlocks )
     571             :     {
     572           4 :         SwBlockName* pBlkNm = const_cast<SwBlockName*>( pImp->aNames[ nIdx ] );
     573           8 :         if( !pBlkNm->bIsOnlyTxtFlagInit &&
     574           4 :             !pImp->IsFileChanged() && !pImp->OpenFile( sal_True ) )
     575             :         {
     576           0 :             pBlkNm->bIsOnlyTxt = pImp->IsOnlyTextBlock( pBlkNm->aShort );
     577           0 :             pBlkNm->bIsOnlyTxtFlagInit = sal_True;
     578           0 :             pImp->CloseFile();
     579             :         }
     580           4 :         bRet = pBlkNm->bIsOnlyTxt;
     581             :     }
     582           4 :     return bRet;
     583             : }
     584             : 
     585           2 : sal_Bool SwTextBlocks::IsOnlyTextBlock( const String& rShort ) const
     586             : {
     587           2 :     sal_uInt16 nIdx = pImp->GetIndex( rShort );
     588           2 :     if( USHRT_MAX != nIdx )
     589             :     {
     590           1 :         if( pImp->aNames[ nIdx ]->bIsOnlyTxtFlagInit )
     591           1 :             return pImp->aNames[ nIdx ]->bIsOnlyTxt;
     592           0 :         return IsOnlyTextBlock( nIdx );
     593             :     }
     594             : 
     595             :     OSL_ENSURE( !this, "ungueltiger Name" );
     596           1 :     return sal_False;
     597             : }
     598             : 
     599           1 : sal_Bool SwTextBlocks::GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl )
     600             : {
     601           1 :     sal_Bool bRet = sal_True;
     602           1 :     if ( pImp && !pImp->bInPutMuchBlocks )
     603           1 :         bRet = ( 0 == pImp->GetMacroTable( nIdx, rMacroTbl ) );
     604           1 :     return bRet;
     605             : }
     606             : 
     607           0 : sal_Bool SwTextBlocks::SetMacroTable( sal_uInt16 nIdx,
     608             :                                 const SvxMacroTableDtor& rMacroTbl )
     609             : {
     610           0 :     sal_Bool bRet = sal_True;
     611           0 :     if ( pImp && !pImp->bInPutMuchBlocks )
     612           0 :         bRet = ( 0 == pImp->SetMacroTable( nIdx, rMacroTbl ) );
     613           0 :     return bRet;
     614             : }
     615             : 
     616           0 : sal_Bool SwTextBlocks::StartPutMuchBlockEntries()
     617             : {
     618           0 :     sal_Bool bRet = sal_False;
     619           0 :     if( !IsOld() && pImp )
     620           0 :         bRet = pImp->PutMuchEntries( sal_True );
     621           0 :     return bRet;
     622             : }
     623             : 
     624           0 : void SwTextBlocks::EndPutMuchBlockEntries()
     625             : {
     626           0 :     if( pImp )
     627           0 :         pImp->PutMuchEntries( sal_False );
     628           0 : }
     629             : 
     630           0 : String    SwTextBlocks::GetBaseURL() const
     631             : {
     632           0 :     String sRet;
     633           0 :     if(pImp)
     634           0 :         sRet = pImp->GetBaseURL();
     635           0 :     return sRet;
     636             : }
     637             : 
     638           7 : void SwTextBlocks::SetBaseURL( const String& rURL )
     639             : {
     640           7 :     if(pImp)
     641           7 :         pImp->SetBaseURL(rURL);
     642         106 : }
     643             : 
     644             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10