LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/swg - swblocks.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 334 0.0 %
Date: 2012-12-27 Functions: 0 53 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10