xref: /AOO41X/main/sw/source/core/swg/swblocks.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
29cdf0e10cSrcweir #include <sot/storage.hxx>
30cdf0e10cSrcweir #include <tools/urlobj.hxx>
31cdf0e10cSrcweir #ifndef SVTOOLS_FSTATHELPER_HXX
32cdf0e10cSrcweir #include <svl/fstathelper.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <svl/macitem.hxx>
35cdf0e10cSrcweir #include <unotools/charclass.hxx>
36cdf0e10cSrcweir #include <frmfmt.hxx>
37cdf0e10cSrcweir #include <doc.hxx>
38cdf0e10cSrcweir #include <docary.hxx>
39cdf0e10cSrcweir #include <pam.hxx>
40cdf0e10cSrcweir #include <shellio.hxx>
41cdf0e10cSrcweir #include <swblocks.hxx>
42cdf0e10cSrcweir #include <ndtxt.hxx>
43cdf0e10cSrcweir #include <mdiexp.hxx>		// Progress
44cdf0e10cSrcweir #include <SwXMLTextBlocks.hxx>
45cdf0e10cSrcweir #ifndef _DOCSH_HXX
46cdf0e10cSrcweir #include <docsh.hxx>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #include <swunohelper.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #ifndef _STATSTR_HRC
51cdf0e10cSrcweir #include <statstr.hrc>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #include <swerror.h>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT( SwBlockNames, SwBlockName* );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // Hash-Code errechnen (muss nicht eindeutig sein)
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
Hash(const String & r)62cdf0e10cSrcweir sal_uInt16 SwImpBlocks::Hash( const String& r )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	sal_uInt16 n = 0;
65cdf0e10cSrcweir 	xub_StrLen nLen = r.Len();
66cdf0e10cSrcweir 	if( nLen > 8 )
67cdf0e10cSrcweir 		nLen = 8;
68cdf0e10cSrcweir 	const sal_Unicode* p = r.GetBuffer();
69cdf0e10cSrcweir 	while( nLen-- )
70cdf0e10cSrcweir 		n = ( n << 1 ) + *p++;
71cdf0e10cSrcweir 	return n;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
SwBlockName(const String & rShort,const String & rLong,long n)75cdf0e10cSrcweir SwBlockName::SwBlockName( const String& rShort, const String& rLong, long n )
76cdf0e10cSrcweir 	: nPos( n ), aShort( rShort ), aLong( rLong ), aPackageName (rShort),
77cdf0e10cSrcweir 	bIsOnlyTxtFlagInit( sal_False ), bIsOnlyTxt( sal_False )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	nHashS = SwImpBlocks::Hash( rShort );
80cdf0e10cSrcweir 	nHashL = SwImpBlocks::Hash( rLong );
81cdf0e10cSrcweir }
SwBlockName(const String & rShort,const String & rLong,const String & rPackageName)82cdf0e10cSrcweir SwBlockName::SwBlockName( const String& rShort, const String& rLong, const String& rPackageName)
83cdf0e10cSrcweir 	: nPos( 0 ), aShort( rShort ), aLong( rLong ), aPackageName (rPackageName),
84cdf0e10cSrcweir 	bIsOnlyTxtFlagInit( sal_False ), bIsOnlyTxt( sal_False )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	nHashS = SwImpBlocks::Hash( rShort );
87cdf0e10cSrcweir 	nHashL = SwImpBlocks::Hash( rLong );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // Ist die angegebene Datei ein Storage oder gibt es sie nicht?
92cdf0e10cSrcweir 
GetFileType(const String & rFile)93cdf0e10cSrcweir short SwImpBlocks::GetFileType( const String& rFile )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	if( !FStatHelper::IsDocument( rFile ) )
96cdf0e10cSrcweir 		return SWBLK_NO_FILE;
97cdf0e10cSrcweir 	if( SwXMLTextBlocks::IsFileUCBStorage( rFile ) )
98cdf0e10cSrcweir 		return SWBLK_XML;
99cdf0e10cSrcweir 	if( SvStorage::IsStorageFile( rFile ) )
100cdf0e10cSrcweir 		return SWBLK_SW3;
101cdf0e10cSrcweir     //otherwise return NONE
102cdf0e10cSrcweir     return SWBLK_NONE;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
SwImpBlocks(const String & rFile,sal_Bool)106cdf0e10cSrcweir SwImpBlocks::SwImpBlocks( const String& rFile, sal_Bool )
107cdf0e10cSrcweir 	: aFile( rFile ), pDoc( 0 ), nCur( (sal_uInt16)-1 ),
108cdf0e10cSrcweir     bReadOnly( sal_True ), bInPutMuchBlocks( sal_False )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	FStatHelper::GetModifiedDateTimeOfFile( rFile,
111cdf0e10cSrcweir 											&aDateModified, &aTimeModified );
112cdf0e10cSrcweir 	INetURLObject aObj(rFile);
113cdf0e10cSrcweir 	aObj.setExtension( aEmptyStr );
114cdf0e10cSrcweir 	aName = aObj.GetBase();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
~SwImpBlocks()118cdf0e10cSrcweir SwImpBlocks::~SwImpBlocks()
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	aNames.DeleteAndDestroy( 0, aNames.Count() );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // Loeschen des Inhaltes des Dokuments
ClearDoc()124cdf0e10cSrcweir void SwImpBlocks::ClearDoc()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	pDoc->ClearDoc();
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
GetDocForConversion(sal_uInt16 n)129cdf0e10cSrcweir sal_uLong SwImpBlocks::GetDocForConversion( sal_uInt16 n )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	return GetDoc( n );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir // Erzeugen eines PaMs, der das ganze Dokument umfasst
MakePaM()135cdf0e10cSrcweir SwPaM* SwImpBlocks::MakePaM()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	SwPaM* pPam = new SwPaM( pDoc->GetNodes().GetEndOfContent() );
138cdf0e10cSrcweir 	pPam->Move( fnMoveBackward, fnGoDoc );
139cdf0e10cSrcweir 	pPam->SetMark();
140cdf0e10cSrcweir 	pPam->Move( fnMoveForward, fnGoDoc );
141cdf0e10cSrcweir 	pPam->Exchange();
142cdf0e10cSrcweir 	return pPam;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
GetCount() const146cdf0e10cSrcweir sal_uInt16 SwImpBlocks::GetCount() const
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	return aNames.Count();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir // Case Insensitive
GetIndex(const String & rShort) const152cdf0e10cSrcweir sal_uInt16 SwImpBlocks::GetIndex( const String& rShort ) const
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	String s( GetAppCharClass().upper( rShort ) );
155cdf0e10cSrcweir 	sal_uInt16 nHash = Hash( s );
156cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < aNames.Count(); i++ )
157cdf0e10cSrcweir 	{
158cdf0e10cSrcweir 		SwBlockName* pName = aNames[ i ];
159cdf0e10cSrcweir 		if( pName->nHashS == nHash
160cdf0e10cSrcweir 		 && pName->aShort == s )
161cdf0e10cSrcweir 			return i;
162cdf0e10cSrcweir 	}
163cdf0e10cSrcweir 	return (sal_uInt16) -1;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
GetLongIndex(const String & rLong) const167cdf0e10cSrcweir sal_uInt16 SwImpBlocks::GetLongIndex( const String& rLong ) const
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	sal_uInt16 nHash = Hash( rLong );
170cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < aNames.Count(); i++ )
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		SwBlockName* pName = aNames[ i ];
173cdf0e10cSrcweir 		if( pName->nHashL == nHash
174cdf0e10cSrcweir 		 && pName->aLong == rLong )
175cdf0e10cSrcweir 			return i;
176cdf0e10cSrcweir 	}
177cdf0e10cSrcweir 	return (sal_uInt16) -1;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
GetShortName(sal_uInt16 n) const181cdf0e10cSrcweir const String& SwImpBlocks::GetShortName( sal_uInt16 n ) const
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	if( n < aNames.Count() )
184cdf0e10cSrcweir 		return aNames[ n ]->aShort;
185cdf0e10cSrcweir 	return aEmptyStr;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
GetLongName(sal_uInt16 n) const189cdf0e10cSrcweir const String& SwImpBlocks::GetLongName( sal_uInt16 n ) const
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	if( n < aNames.Count() )
192cdf0e10cSrcweir 		return aNames[ n ]->aLong;
193cdf0e10cSrcweir 	return aEmptyStr;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
GetPackageName(sal_uInt16 n) const196cdf0e10cSrcweir const String& SwImpBlocks::GetPackageName( sal_uInt16 n ) const
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 	if( n < aNames.Count() )
199cdf0e10cSrcweir 		return aNames[ n ]->aPackageName;
200cdf0e10cSrcweir 	return aEmptyStr;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
AddName(const String & rShort,const String & rLong,sal_Bool bOnlyTxt)203cdf0e10cSrcweir void SwImpBlocks::AddName( const String& rShort, const String& rLong,
204cdf0e10cSrcweir 							sal_Bool bOnlyTxt )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	sal_uInt16 nIdx = GetIndex( rShort );
207cdf0e10cSrcweir 	if( nIdx != (sal_uInt16) -1 )
208cdf0e10cSrcweir 		aNames.DeleteAndDestroy( nIdx );
209cdf0e10cSrcweir 	SwBlockName* pNew = new SwBlockName( rShort, rLong, 0L );
210cdf0e10cSrcweir 	pNew->bIsOnlyTxtFlagInit = sal_True;
211cdf0e10cSrcweir 	pNew->bIsOnlyTxt = bOnlyTxt;
212cdf0e10cSrcweir 	aNames.C40_PTR_INSERT( SwBlockName, pNew );
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 
IsFileChanged() const217cdf0e10cSrcweir sal_Bool SwImpBlocks::IsFileChanged() const
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	Date aTempDateModified( aDateModified );
220cdf0e10cSrcweir 	Time aTempTimeModified( aTimeModified );
221cdf0e10cSrcweir 	return FStatHelper::GetModifiedDateTimeOfFile( aFile,
222cdf0e10cSrcweir 							&aTempDateModified, &aTempTimeModified ) &&
223cdf0e10cSrcweir 		  ( aDateModified != aTempDateModified ||
224cdf0e10cSrcweir 			aTimeModified != aTempTimeModified );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 
Touch()228cdf0e10cSrcweir void SwImpBlocks::Touch()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	FStatHelper::GetModifiedDateTimeOfFile( aFile,
231cdf0e10cSrcweir 											&aDateModified, &aTimeModified );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
IsOnlyTextBlock(const String &) const234cdf0e10cSrcweir sal_Bool SwImpBlocks::IsOnlyTextBlock( const String& ) const
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	return sal_False;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
GetMacroTable(sal_uInt16,SvxMacroTableDtor &,sal_Bool)239cdf0e10cSrcweir sal_uLong SwImpBlocks::GetMacroTable( sal_uInt16, SvxMacroTableDtor&, sal_Bool )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	return 0;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
SetMacroTable(sal_uInt16,const SvxMacroTableDtor &,sal_Bool)244cdf0e10cSrcweir sal_uLong SwImpBlocks::SetMacroTable( sal_uInt16 ,
245cdf0e10cSrcweir 								const SvxMacroTableDtor& , sal_Bool )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir 	return 0;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir 
PutMuchEntries(sal_Bool)250cdf0e10cSrcweir sal_Bool SwImpBlocks::PutMuchEntries( sal_Bool )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	return sal_False;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
SwTextBlocks(const String & rFile)258cdf0e10cSrcweir SwTextBlocks::SwTextBlocks( const String& rFile )
259cdf0e10cSrcweir 	: pImp( 0 ), nErr( 0 )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir 	INetURLObject aObj(rFile);
262cdf0e10cSrcweir 	String sFileName = aObj.GetMainURL( INetURLObject::NO_DECODE );
263cdf0e10cSrcweir 	switch( SwImpBlocks::GetFileType( rFile ) )
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir     //case SWBLK_SW2:     pImp = new Sw2TextBlocks( sFileName );  break;
266cdf0e10cSrcweir     //case SWBLK_SW3:     pImp = new Sw3TextBlocks( sFileName );  break;
267cdf0e10cSrcweir 	case SWBLK_XML:		pImp = new SwXMLTextBlocks( sFileName ); break;
268cdf0e10cSrcweir 	case SWBLK_NO_FILE:	pImp = new SwXMLTextBlocks( sFileName ); break;
269cdf0e10cSrcweir 	}
270cdf0e10cSrcweir 	if( !pImp )
271cdf0e10cSrcweir 		nErr = ERR_SWG_FILE_FORMAT_ERROR;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
~SwTextBlocks()274cdf0e10cSrcweir SwTextBlocks::~SwTextBlocks()
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	delete pImp;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
GetName()279cdf0e10cSrcweir const String& SwTextBlocks::GetName()
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	return pImp ? pImp->aName : aEmptyStr;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 
SetName(const String & r)285cdf0e10cSrcweir void SwTextBlocks::SetName( const String& r )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir 	if( pImp )
288cdf0e10cSrcweir 		pImp->SetName( r );
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 
IsOld() const292cdf0e10cSrcweir sal_Bool SwTextBlocks::IsOld() const
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	if (pImp)
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir 		short nType = pImp->GetFileType();
297cdf0e10cSrcweir 		if (SWBLK_SW3 == nType || SWBLK_SW2 == nType )
298cdf0e10cSrcweir 			return sal_True;
299cdf0e10cSrcweir 	}
300cdf0e10cSrcweir 	return sal_False;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 
304cdf0e10cSrcweir /*
305cdf0e10cSrcweir sal_uLong SwTextBlocks::ConvertToNew()
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	// Wir nehmen die aktuelle Datei, benennen diese in .BAK um
308cdf0e10cSrcweir 	// und kreieren den neuen Storage
309cdf0e10cSrcweir 	if( IsOld() )
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		// Erst mal muessen wir die Datei freigeben
312cdf0e10cSrcweir 		short nType = pImp->GetFileType();
313cdf0e10cSrcweir 		Sw2TextBlocks *pTwo = NULL;
314cdf0e10cSrcweir 		Sw3TextBlocks *pThree = NULL;
315cdf0e10cSrcweir 		SwImpBlocks *pOld = NULL;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 		pImp->nCur = (sal_uInt16) -1;
318cdf0e10cSrcweir 		String aName( pImp->aFile );
319cdf0e10cSrcweir 		delete pImp; pImp = NULL;
320cdf0e10cSrcweir 		// Jetzt wird umbenannt
321cdf0e10cSrcweir 		INetURLObject aOldFull( aName );
322cdf0e10cSrcweir 		INetURLObject aNewFull( aName );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 		aOldFull.SetExtension( String::CreateFromAscii("bak") );
325cdf0e10cSrcweir 		String aOld( aOldFull.GetMainURL( INetURLObject::NO_DECODE ) );
326cdf0e10cSrcweir 		String aNew( aNewFull.GetMainURL( INetURLObject::NO_DECODE ) );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 		sal_Bool bError = !SWUnoHelper::UCB_CopyFile( aNew, aOld, sal_True );
329cdf0e10cSrcweir 		if( bError )
330cdf0e10cSrcweir 		{
331cdf0e10cSrcweir 			if (nType == SWBLK_SW2)
332cdf0e10cSrcweir 				pImp = new Sw2TextBlocks( aOld );
333cdf0e10cSrcweir 			else
334cdf0e10cSrcweir 				pImp = new Sw3TextBlocks( aOld );
335cdf0e10cSrcweir 			return nErr = ERR_SWG_CANNOT_WRITE;
336cdf0e10cSrcweir 		}
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 		// Die Datei ist erfolgreich umbenannt. Jetzt wird der Storage
339cdf0e10cSrcweir 		// aufgesetzt
340cdf0e10cSrcweir 		if (nType == SWBLK_SW2)
341cdf0e10cSrcweir 			pOld = pTwo = new Sw2TextBlocks( aOld );
342cdf0e10cSrcweir 		else
343cdf0e10cSrcweir 			pOld = pThree = new Sw3TextBlocks( aOld );
344cdf0e10cSrcweir 		SwXMLTextBlocks* pNew = new SwXMLTextBlocks( aName );
345cdf0e10cSrcweir 		pNew->SetName ( pOld->GetName());
346cdf0e10cSrcweir 		// Wir kopieren den Doc-Ptr in das alte System
347cdf0e10cSrcweir 		// den alten SvPersist heben wir uns aber auf,
348cdf0e10cSrcweir 		// da dieser die ganze Zeit leben bleibt
349cdf0e10cSrcweir 		// und lesen die Dateivorlagen erneut ein
350cdf0e10cSrcweir 		SvPersist* pPersist2 = pOld->pDoc->GetPersist();
351cdf0e10cSrcweir 		if (SWBLK_SW2 == nType )
352cdf0e10cSrcweir 		{
353cdf0e10cSrcweir 			delete pOld->pDoc;
354cdf0e10cSrcweir 			pOld->pDoc = pNew->pDoc;nLinkCt
355cdf0e10cSrcweir 			nErr = pTwo->LoadDoc();
356cdf0e10cSrcweir 		}
357cdf0e10cSrcweir 		else
358cdf0e10cSrcweir 		{
359cdf0e10cSrcweir 			nErr = pThree->OpenFile ( sal_True );
360cdf0e10cSrcweir 			// Within this call, Sw3IoImp::SetDoc calls RemoveLink
361cdf0e10cSrcweir 			// on the old document, and deletes it if the
362cdf0e10cSrcweir 			// ref count is now zero
363cdf0e10cSrcweir 			pThree->SetDoc ( pNew->pDoc );
364cdf0e10cSrcweir 			pOld->pDoc->AddLink();
365cdf0e10cSrcweir 		}
366cdf0e10cSrcweir 		if( !nErr && 0 == ( nErr = pNew->OpenFile( sal_False )) )
367cdf0e10cSrcweir 		{
368cdf0e10cSrcweir 			nErr = pNew->SetConvertMode( sal_True );
369cdf0e10cSrcweir 			// jetzt werden die Bausteine einfach umkopiert!
370cdf0e10cSrcweir 			if( !nErr )
371cdf0e10cSrcweir 			{
372cdf0e10cSrcweir 				if (SWBLK_SW2 == nType)
373cdf0e10cSrcweir 					pTwo->StatLineStartPercent();
374cdf0e10cSrcweir 				sal_uInt16 nCount = pOld->GetCount();
375cdf0e10cSrcweir 				for( sal_uInt16 i = 0; i < nCount; i++ )
376cdf0e10cSrcweir 				{
377cdf0e10cSrcweir 					pNew->ClearDoc();
378cdf0e10cSrcweir 					String aShort( pOld->GetShortName( i ) );
379cdf0e10cSrcweir 					String aLong( pOld->GetLongName( i ) );
380cdf0e10cSrcweir 					pNew->AddName( aShort, aLong );
381cdf0e10cSrcweir 					if ( SWBLK_SW3 == nType && pThree->IsOnlyTextBlock(aShort) )
382cdf0e10cSrcweir 					{
383cdf0e10cSrcweir 						String sText;
384cdf0e10cSrcweir 						pThree->GetText( aShort, sText );
385cdf0e10cSrcweir 						pNew->PutText( aShort, aLong, sText );
386cdf0e10cSrcweir 					}
387cdf0e10cSrcweir 					else
388cdf0e10cSrcweir 					{
389cdf0e10cSrcweir 						if (SWBLK_SW2 == nType )
390cdf0e10cSrcweir 						{
391cdf0e10cSrcweir 							// I think this is how it should work (!!!!!!) mtg
392cdf0e10cSrcweir 							pNew->pDoc->SetPersist( pPersist2 );
393cdf0e10cSrcweir 						}
394cdf0e10cSrcweir 						nErr = pOld->GetDocForConversion( i );
395cdf0e10cSrcweir 						if( nErr )
396cdf0e10cSrcweir 							break;
397cdf0e10cSrcweir 						nErr = pNew->BeginPutDoc( aShort, aLong );
398cdf0e10cSrcweir 						if( nErr )
399cdf0e10cSrcweir 							break;
400cdf0e10cSrcweir 						nErr = pNew->PutDoc();
401cdf0e10cSrcweir 						if( nErr )
402cdf0e10cSrcweir 							break;
403cdf0e10cSrcweir 					}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 					// convert macros, too
406cdf0e10cSrcweir 					SvxMacroTableDtor aMacroTable;
407cdf0e10cSrcweir 					pOld->GetMacroTable( i, aMacroTable, sal_True );
408cdf0e10cSrcweir 					pNew->SetMacroTable( i, aMacroTable, sal_True );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 					if (SWBLK_SW2 == nType )
411cdf0e10cSrcweir 						pNew->pDoc->SetPersist( 0 );
412cdf0e10cSrcweir 				}
413cdf0e10cSrcweir 				if (SWBLK_SW2 == nType )
414cdf0e10cSrcweir 					::EndProgress( pOld->pDoc->GetDocShell() );
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir 			if( !nErr )
417cdf0e10cSrcweir 				nErr = pNew->SetConvertMode( sal_False );
418cdf0e10cSrcweir 		}
419cdf0e10cSrcweir 		if ( SWBLK_SW3 == nType )
420cdf0e10cSrcweir 		{
421cdf0e10cSrcweir 			pThree->CloseFile();
422cdf0e10cSrcweir 		}
423cdf0e10cSrcweir 		else
424cdf0e10cSrcweir 		{
425cdf0e10cSrcweir 			// Haben wir es geschafft?
426cdf0e10cSrcweir 			pOld->pDoc = NULL;
427cdf0e10cSrcweir 		}
428cdf0e10cSrcweir 		pNew->ClearDoc();
429cdf0e10cSrcweir 		if( !nErr )
430cdf0e10cSrcweir 		{
431cdf0e10cSrcweir 			delete pOld;
432cdf0e10cSrcweir 			pImp = pNew;
433cdf0e10cSrcweir 			SWUnoHelper::UCB_DeleteFile( aOld );
434cdf0e10cSrcweir 			pNew->MakeBlockList();
435cdf0e10cSrcweir 		}
436cdf0e10cSrcweir 		else
437cdf0e10cSrcweir 		{
438cdf0e10cSrcweir 			delete pOld; delete pNew;
439cdf0e10cSrcweir 			SWUnoHelper::UCB_DeleteFile( aNew );
440cdf0e10cSrcweir 			SWUnoHelper::UCB_CopyFile( aOld, aNew, sal_True );
441cdf0e10cSrcweir 			if ( SWBLK_SW2 == nType )
442cdf0e10cSrcweir 				pImp = new Sw2TextBlocks( aOld );
443cdf0e10cSrcweir 			else
444cdf0e10cSrcweir 				pImp = new Sw3TextBlocks( aOld );
445cdf0e10cSrcweir 		}
446cdf0e10cSrcweir 		pNew->CloseFile();
447cdf0e10cSrcweir 		FStatHelper::GetModifiedDateTimeOfFile( aNew,
448cdf0e10cSrcweir 							&pImp->aDateModified, &pImp->aTimeModified );
449cdf0e10cSrcweir 	}
450cdf0e10cSrcweir 	return nErr;
451cdf0e10cSrcweir } */
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 
GetCount() const454cdf0e10cSrcweir sal_uInt16 SwTextBlocks::GetCount() const
455cdf0e10cSrcweir {
456cdf0e10cSrcweir 	return pImp ? pImp->GetCount() : 0;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 
GetIndex(const String & r) const460cdf0e10cSrcweir sal_uInt16 SwTextBlocks::GetIndex( const String& r ) const
461cdf0e10cSrcweir {
462cdf0e10cSrcweir 	return pImp ? pImp->GetIndex( r ) : (sal_uInt16) -1;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 
GetLongIndex(const String & r) const466cdf0e10cSrcweir sal_uInt16 SwTextBlocks::GetLongIndex( const String& r ) const
467cdf0e10cSrcweir {
468cdf0e10cSrcweir 	return pImp ? (sal_uInt16)(pImp->GetLongIndex( r )) : (sal_uInt16) -1;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir 
GetShortName(sal_uInt16 n) const472cdf0e10cSrcweir const String& SwTextBlocks::GetShortName( sal_uInt16 n ) const
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	if( pImp )
475cdf0e10cSrcweir 		return pImp->GetShortName( n );
476cdf0e10cSrcweir 	return aEmptyStr;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 
GetLongName(sal_uInt16 n) const480cdf0e10cSrcweir const String& SwTextBlocks::GetLongName( sal_uInt16 n ) const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir 	if( pImp )
483cdf0e10cSrcweir 		return pImp->GetLongName( n );
484cdf0e10cSrcweir 	return aEmptyStr;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 
Delete(sal_uInt16 n)488cdf0e10cSrcweir sal_Bool SwTextBlocks::Delete( sal_uInt16 n )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir 	if( pImp && !pImp->bInPutMuchBlocks )
491cdf0e10cSrcweir 	{
492cdf0e10cSrcweir 		if( pImp->IsFileChanged() )
493cdf0e10cSrcweir 			nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
494cdf0e10cSrcweir 		else if( 0 == (nErr = pImp->OpenFile( sal_False ) ))
495cdf0e10cSrcweir 		{
496cdf0e10cSrcweir 			nErr = pImp->Delete( n );
497cdf0e10cSrcweir 			if( !nErr )
498cdf0e10cSrcweir 				pImp->aNames.DeleteAndDestroy( n );
499cdf0e10cSrcweir 			if( n == pImp->nCur )
500cdf0e10cSrcweir 				pImp->nCur = (sal_uInt16) -1;
501cdf0e10cSrcweir 			if( !nErr )
502cdf0e10cSrcweir 				nErr = pImp->MakeBlockList();
503cdf0e10cSrcweir 		}
504cdf0e10cSrcweir 		pImp->CloseFile();
505cdf0e10cSrcweir 		pImp->Touch();
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 		return sal_Bool( nErr == 0 );
508cdf0e10cSrcweir 	}
509cdf0e10cSrcweir 	return sal_False;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 
Rename(sal_uInt16 n,const String * s,const String * l)513cdf0e10cSrcweir sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const String* s, const String* l )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir 	sal_uInt16 nIdx = (sal_uInt16)-1;
516cdf0e10cSrcweir 	if( pImp && !pImp->bInPutMuchBlocks )
517cdf0e10cSrcweir 	{
518cdf0e10cSrcweir 		pImp->nCur = nIdx;
519cdf0e10cSrcweir 		String aNew, aLong;
520cdf0e10cSrcweir 		if( s )
521cdf0e10cSrcweir 			aNew = aLong = *s;
522cdf0e10cSrcweir 		if( l )
523cdf0e10cSrcweir 			aLong = *l;
524cdf0e10cSrcweir 		if( !aNew.Len() )
525cdf0e10cSrcweir 		{
526cdf0e10cSrcweir 			ASSERT( !this, "Kein Kurzname in Rename angegeben" );
527cdf0e10cSrcweir 			nErr = ERR_SWG_INTERNAL_ERROR; return (sal_uInt16) -1;
528cdf0e10cSrcweir 		}
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 		if( pImp->IsFileChanged() )
531cdf0e10cSrcweir 			nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
532cdf0e10cSrcweir 		else if( 0 == (	nErr = pImp->OpenFile( sal_False )))
533cdf0e10cSrcweir 		{
534cdf0e10cSrcweir 			// Vorher den neuen Eintrag in die Liste setzen!
535cdf0e10cSrcweir 			GetAppCharClass().toUpper( aNew );
536cdf0e10cSrcweir  			nErr = pImp->Rename( n, aNew, aLong );
537cdf0e10cSrcweir 			if( !nErr )
538cdf0e10cSrcweir 			{
539cdf0e10cSrcweir 				sal_Bool bOnlyTxt = pImp->aNames[ n ]->bIsOnlyTxt;
540cdf0e10cSrcweir 				pImp->aNames.DeleteAndDestroy( n );
541cdf0e10cSrcweir 				pImp->AddName( aNew, aLong, bOnlyTxt );
542cdf0e10cSrcweir 				nErr = pImp->MakeBlockList();
543cdf0e10cSrcweir 			}
544cdf0e10cSrcweir 		}
545cdf0e10cSrcweir 		pImp->CloseFile();
546cdf0e10cSrcweir 		pImp->Touch();
547cdf0e10cSrcweir 		if( !nErr )
548cdf0e10cSrcweir 			nIdx = pImp->GetIndex( aNew );
549cdf0e10cSrcweir 	}
550cdf0e10cSrcweir 	return nIdx;
551cdf0e10cSrcweir }
552cdf0e10cSrcweir 
CopyBlock(SwTextBlocks & rSource,String & rSrcShort,const String & rLong)553cdf0e10cSrcweir sal_uLong SwTextBlocks::CopyBlock( SwTextBlocks& rSource, String& rSrcShort,
554cdf0e10cSrcweir 								const String& rLong )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir 	sal_Bool bIsOld = sal_False;
557cdf0e10cSrcweir 	if (rSource.pImp)
558cdf0e10cSrcweir 	{
559cdf0e10cSrcweir 		short nType = rSource.pImp->GetFileType();
560cdf0e10cSrcweir 		if (SWBLK_SW2 == nType || SWBLK_SW3 == nType )
561cdf0e10cSrcweir 			bIsOld = sal_True;
562cdf0e10cSrcweir 	}
563cdf0e10cSrcweir 	if( bIsOld ) //rSource.IsOld() )
564cdf0e10cSrcweir 		nErr = ERR_SWG_OLD_GLOSSARY;
565cdf0e10cSrcweir 	else if( pImp->bInPutMuchBlocks )
566cdf0e10cSrcweir 		nErr = ERR_SWG_INTERNAL_ERROR;
567cdf0e10cSrcweir 	else
568cdf0e10cSrcweir 		nErr = pImp->CopyBlock(*rSource.pImp, rSrcShort, rLong);
569cdf0e10cSrcweir 	return nErr;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir 
BeginGetDoc(sal_uInt16 n)572cdf0e10cSrcweir sal_Bool SwTextBlocks::BeginGetDoc( sal_uInt16 n )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir 	if( pImp && !pImp->bInPutMuchBlocks )
575cdf0e10cSrcweir 	{
576cdf0e10cSrcweir // diese Optimierierung darf es nicht mehr geben. OLE-Objecte muessen auf
577cdf0e10cSrcweir // ihre SubStorages zugreifem koennen!
578cdf0e10cSrcweir //		if( n == pImp->nCur )
579cdf0e10cSrcweir //			return sal_True;
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 		if( pImp->IsFileChanged() )
582cdf0e10cSrcweir 			nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
583cdf0e10cSrcweir 		else if( 0 == (	nErr = pImp->OpenFile( sal_True )))
584cdf0e10cSrcweir 		{
585cdf0e10cSrcweir 			pImp->ClearDoc();
586cdf0e10cSrcweir 			nErr = pImp->GetDoc( n );
587cdf0e10cSrcweir 			if( nErr )
588cdf0e10cSrcweir 				pImp->nCur = (sal_uInt16)-1;
589cdf0e10cSrcweir 			else
590cdf0e10cSrcweir 				pImp->nCur = n;
591cdf0e10cSrcweir 		}
592cdf0e10cSrcweir 		return sal_Bool( nErr == 0 );
593cdf0e10cSrcweir 	}
594cdf0e10cSrcweir 	return sal_False;
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 
EndGetDoc()598cdf0e10cSrcweir void SwTextBlocks::EndGetDoc()
599cdf0e10cSrcweir {
600cdf0e10cSrcweir 	if( pImp && !pImp->bInPutMuchBlocks )
601cdf0e10cSrcweir 		pImp->CloseFile();
602cdf0e10cSrcweir }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 
BeginPutDoc(const String & s,const String & l)605cdf0e10cSrcweir sal_Bool SwTextBlocks::BeginPutDoc( const String& s, const String& l )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir 	if( pImp )
608cdf0e10cSrcweir 	{
609cdf0e10cSrcweir 		sal_Bool bOk = pImp->bInPutMuchBlocks;
610cdf0e10cSrcweir 		if( !bOk )
611cdf0e10cSrcweir 		{
612cdf0e10cSrcweir 			if( pImp->IsFileChanged() )
613cdf0e10cSrcweir 				nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
614cdf0e10cSrcweir 			else
615cdf0e10cSrcweir 				nErr = pImp->OpenFile( sal_False );
616cdf0e10cSrcweir 			bOk = 0 == nErr;
617cdf0e10cSrcweir 		}
618cdf0e10cSrcweir 		if( bOk )
619cdf0e10cSrcweir 		{
620cdf0e10cSrcweir 			String aNew( s );
621cdf0e10cSrcweir 			GetAppCharClass().toUpper( aNew );
622cdf0e10cSrcweir 			nErr = pImp->BeginPutDoc( aNew, l );
623cdf0e10cSrcweir 		}
624cdf0e10cSrcweir 		if( nErr )
625cdf0e10cSrcweir 			pImp->CloseFile();
626cdf0e10cSrcweir 	}
627cdf0e10cSrcweir 	return 0 == nErr;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 
PutDoc()631cdf0e10cSrcweir sal_uInt16 SwTextBlocks::PutDoc()
632cdf0e10cSrcweir {
633cdf0e10cSrcweir 	sal_uInt16 nIdx = (sal_uInt16)-1;
634cdf0e10cSrcweir 	if( pImp )
635cdf0e10cSrcweir 	{
636cdf0e10cSrcweir 		nErr = pImp->PutDoc();
637cdf0e10cSrcweir 		if( !nErr )
638cdf0e10cSrcweir 		{
639cdf0e10cSrcweir 			pImp->nCur = GetIndex( pImp->aShort );
640cdf0e10cSrcweir 			if( pImp->nCur != (sal_uInt16) -1 )
641cdf0e10cSrcweir 				pImp->aNames[ pImp->nCur ]->aLong = pImp->aLong;
642cdf0e10cSrcweir 			else
643cdf0e10cSrcweir 			{
644cdf0e10cSrcweir 				pImp->AddName( pImp->aShort, pImp->aLong );
645cdf0e10cSrcweir 				pImp->nCur = pImp->GetIndex( pImp->aShort );
646cdf0e10cSrcweir 			}
647cdf0e10cSrcweir 			if( !pImp->bInPutMuchBlocks )
648cdf0e10cSrcweir 				nErr = pImp->MakeBlockList();
649cdf0e10cSrcweir 		}
650cdf0e10cSrcweir 		if( !pImp->bInPutMuchBlocks )
651cdf0e10cSrcweir 		{
652cdf0e10cSrcweir 			pImp->CloseFile();
653cdf0e10cSrcweir 			pImp->Touch();
654cdf0e10cSrcweir 		}
655cdf0e10cSrcweir 		nIdx = pImp->nCur;
656cdf0e10cSrcweir 	}
657cdf0e10cSrcweir 	return nIdx;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir 
PutText(const String & rShort,const String & rName,const String & rTxt)660cdf0e10cSrcweir sal_uInt16 SwTextBlocks::PutText( const String& rShort, const String& rName,
661cdf0e10cSrcweir 							  const String& rTxt )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir 	sal_uInt16 nIdx = (sal_uInt16) -1;
664cdf0e10cSrcweir 	if( pImp )
665cdf0e10cSrcweir 	{
666cdf0e10cSrcweir 		sal_Bool bOk = pImp->bInPutMuchBlocks;
667cdf0e10cSrcweir 		if( !bOk )
668cdf0e10cSrcweir 		{
669cdf0e10cSrcweir 			if( pImp->IsFileChanged() )
670cdf0e10cSrcweir 				nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
671cdf0e10cSrcweir 			else
672cdf0e10cSrcweir 				nErr = pImp->OpenFile( sal_False );
673cdf0e10cSrcweir 			bOk = 0 == nErr;
674cdf0e10cSrcweir 		}
675cdf0e10cSrcweir 		if( bOk )
676cdf0e10cSrcweir 		{
677cdf0e10cSrcweir 			String aNew( rShort );
678cdf0e10cSrcweir 			GetAppCharClass().toUpper( aNew );
679cdf0e10cSrcweir 			nErr = pImp->PutText( aNew, rName, rTxt );
680cdf0e10cSrcweir 			pImp->nCur = (sal_uInt16) -1;
681cdf0e10cSrcweir 			if( !nErr )
682cdf0e10cSrcweir 			{
683cdf0e10cSrcweir 				nIdx = GetIndex( pImp->aShort );
684cdf0e10cSrcweir 				if( nIdx != (sal_uInt16) -1 )
685cdf0e10cSrcweir 					pImp->aNames[ nIdx ]->aLong = rName;
686cdf0e10cSrcweir 				else
687cdf0e10cSrcweir 				{
688cdf0e10cSrcweir 					pImp->AddName( pImp->aShort, rName, sal_True );
689cdf0e10cSrcweir 					nIdx = pImp->GetIndex( pImp->aShort );
690cdf0e10cSrcweir 				}
691cdf0e10cSrcweir 				if( !pImp->bInPutMuchBlocks )
692cdf0e10cSrcweir 					nErr = pImp->MakeBlockList();
693cdf0e10cSrcweir 			}
694cdf0e10cSrcweir 		}
695cdf0e10cSrcweir 		if( !pImp->bInPutMuchBlocks )
696cdf0e10cSrcweir 		{
697cdf0e10cSrcweir 			pImp->CloseFile();
698cdf0e10cSrcweir 			pImp->Touch();
699cdf0e10cSrcweir 		}
700cdf0e10cSrcweir 	}
701cdf0e10cSrcweir 	return nIdx;
702cdf0e10cSrcweir }
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 
GetDoc()705cdf0e10cSrcweir SwDoc* SwTextBlocks::GetDoc()
706cdf0e10cSrcweir {
707cdf0e10cSrcweir 	if( pImp )
708cdf0e10cSrcweir 		return pImp->pDoc;
709cdf0e10cSrcweir 	return 0;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 
ClearDoc()713cdf0e10cSrcweir void SwTextBlocks::ClearDoc()
714cdf0e10cSrcweir {
715cdf0e10cSrcweir 	if( pImp )
716cdf0e10cSrcweir 		pImp->ClearDoc();
717cdf0e10cSrcweir 	pImp->nCur = (sal_uInt16) -1;
718cdf0e10cSrcweir }
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 
GetFileName() const721cdf0e10cSrcweir const String& SwTextBlocks::GetFileName() const
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	return pImp->GetFileName();
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 
IsReadOnly() const727cdf0e10cSrcweir sal_Bool SwTextBlocks::IsReadOnly() const
728cdf0e10cSrcweir {
729cdf0e10cSrcweir 	return pImp->bReadOnly;
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
IsOnlyTextBlock(sal_uInt16 nIdx) const732cdf0e10cSrcweir sal_Bool SwTextBlocks::IsOnlyTextBlock( sal_uInt16 nIdx ) const
733cdf0e10cSrcweir {
734cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
735cdf0e10cSrcweir 	if( pImp && !pImp->bInPutMuchBlocks )
736cdf0e10cSrcweir 	{
737cdf0e10cSrcweir 		SwBlockName* pBlkNm = pImp->aNames[ nIdx ];
738cdf0e10cSrcweir 		if( !pBlkNm->bIsOnlyTxtFlagInit &&
739cdf0e10cSrcweir 			!pImp->IsFileChanged() && !pImp->OpenFile( sal_True ) )
740cdf0e10cSrcweir 		{
741cdf0e10cSrcweir 			pBlkNm->bIsOnlyTxt = pImp->IsOnlyTextBlock( pBlkNm->aShort );
742cdf0e10cSrcweir 			pBlkNm->bIsOnlyTxtFlagInit = sal_True;
743cdf0e10cSrcweir 			pImp->CloseFile();
744cdf0e10cSrcweir 		}
745cdf0e10cSrcweir 		bRet = pBlkNm->bIsOnlyTxt;
746cdf0e10cSrcweir 	}
747cdf0e10cSrcweir 	return bRet;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir 
IsOnlyTextBlock(const String & rShort) const750cdf0e10cSrcweir sal_Bool SwTextBlocks::IsOnlyTextBlock( const String& rShort ) const
751cdf0e10cSrcweir {
752cdf0e10cSrcweir 	sal_uInt16 nIdx = pImp->GetIndex( rShort );
753cdf0e10cSrcweir 	if( USHRT_MAX != nIdx )
754cdf0e10cSrcweir 	{
755cdf0e10cSrcweir 		if( pImp->aNames[ nIdx ]->bIsOnlyTxtFlagInit )
756cdf0e10cSrcweir 			return pImp->aNames[ nIdx ]->bIsOnlyTxt;
757cdf0e10cSrcweir 		return IsOnlyTextBlock( nIdx );
758cdf0e10cSrcweir 	}
759cdf0e10cSrcweir 
760cdf0e10cSrcweir 	ASSERT( !this, "ungueltiger Name" );
761cdf0e10cSrcweir 	return sal_False;
762cdf0e10cSrcweir }
763cdf0e10cSrcweir 
GetMacroTable(sal_uInt16 nIdx,SvxMacroTableDtor & rMacroTbl)764cdf0e10cSrcweir sal_Bool SwTextBlocks::GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir     sal_Bool bRet = sal_True;
767cdf0e10cSrcweir     if ( pImp && !pImp->bInPutMuchBlocks )
768cdf0e10cSrcweir         bRet = ( 0 == pImp->GetMacroTable( nIdx, rMacroTbl ) );
769cdf0e10cSrcweir     return bRet;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
SetMacroTable(sal_uInt16 nIdx,const SvxMacroTableDtor & rMacroTbl)772cdf0e10cSrcweir sal_Bool SwTextBlocks::SetMacroTable( sal_uInt16 nIdx,
773cdf0e10cSrcweir 								const SvxMacroTableDtor& rMacroTbl )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     sal_Bool bRet = sal_True;
776cdf0e10cSrcweir 	if ( pImp && !pImp->bInPutMuchBlocks )
777cdf0e10cSrcweir 		bRet = ( 0 == pImp->SetMacroTable( nIdx, rMacroTbl ) );
778cdf0e10cSrcweir     return bRet;
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
StartPutMuchBlockEntries()781cdf0e10cSrcweir sal_Bool SwTextBlocks::StartPutMuchBlockEntries()
782cdf0e10cSrcweir {
783cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
784cdf0e10cSrcweir 	if( !IsOld() && pImp )
785cdf0e10cSrcweir 		bRet = pImp->PutMuchEntries( sal_True );
786cdf0e10cSrcweir 	return bRet;
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
EndPutMuchBlockEntries()789cdf0e10cSrcweir void SwTextBlocks::EndPutMuchBlockEntries()
790cdf0e10cSrcweir {
791cdf0e10cSrcweir 	if( pImp )
792cdf0e10cSrcweir 		pImp->PutMuchEntries( sal_False );
793cdf0e10cSrcweir }
794cdf0e10cSrcweir 
795cdf0e10cSrcweir /*-- 20.09.2004 10:25:33---------------------------------------------------
796cdf0e10cSrcweir 
797cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetBaseURL() const798cdf0e10cSrcweir String    SwTextBlocks::GetBaseURL() const
799cdf0e10cSrcweir {
800cdf0e10cSrcweir     String sRet;
801cdf0e10cSrcweir     if(pImp)
802cdf0e10cSrcweir         sRet = pImp->GetBaseURL();
803cdf0e10cSrcweir     return sRet;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir /*-- 20.09.2004 10:25:33---------------------------------------------------
806cdf0e10cSrcweir 
807cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetBaseURL(const String & rURL)808cdf0e10cSrcweir void SwTextBlocks::SetBaseURL( const String& rURL )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir     if(pImp)
811cdf0e10cSrcweir         pImp->SetBaseURL(rURL);
812cdf0e10cSrcweir }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 
815