xref: /AOO41X/main/sw/source/ui/uno/unoatxt.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #define _SVSTDARR_STRINGS
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
35*cdf0e10cSrcweir #include <vos/mutex.hxx>
36*cdf0e10cSrcweir #include <tools/debug.hxx>
37*cdf0e10cSrcweir #include <vcl/svapp.hxx>
38*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
39*cdf0e10cSrcweir #include <svtools/unoevent.hxx>
40*cdf0e10cSrcweir #include <svl/urihelper.hxx>
41*cdf0e10cSrcweir #include <sfx2/event.hxx>
42*cdf0e10cSrcweir #include <swtypes.hxx>
43*cdf0e10cSrcweir #include <glosdoc.hxx>
44*cdf0e10cSrcweir #include <shellio.hxx>
45*cdf0e10cSrcweir #include <initui.hxx>
46*cdf0e10cSrcweir #include <gloslst.hxx>
47*cdf0e10cSrcweir #include <unoatxt.hxx>
48*cdf0e10cSrcweir #include <unomap.hxx>
49*cdf0e10cSrcweir #include <unomid.h>
50*cdf0e10cSrcweir #include <unotextbodyhf.hxx>
51*cdf0e10cSrcweir #include <unotextrange.hxx>
52*cdf0e10cSrcweir #include <TextCursorHelper.hxx>
53*cdf0e10cSrcweir #include <swevent.hxx>
54*cdf0e10cSrcweir #include <doc.hxx>
55*cdf0e10cSrcweir #include <unocrsr.hxx>
56*cdf0e10cSrcweir #include <IMark.hxx>
57*cdf0e10cSrcweir #include <unoprnms.hxx>
58*cdf0e10cSrcweir #include <docsh.hxx>
59*cdf0e10cSrcweir #include <swunodef.hxx>
60*cdf0e10cSrcweir #include <swmodule.hxx>
61*cdf0e10cSrcweir #include <svl/smplhint.hxx>
62*cdf0e10cSrcweir #include <svl/macitem.hxx>
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #include <editeng/acorrcfg.hxx>
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #include <memory>
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir SV_IMPL_REF ( SwDocShell )
70*cdf0e10cSrcweir using namespace ::com::sun::star;
71*cdf0e10cSrcweir using ::rtl::OUString;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir /******************************************************************
74*cdf0e10cSrcweir  *
75*cdf0e10cSrcweir  ******************************************************************/
76*cdf0e10cSrcweir /* -----------------30.03.99 14:31-------------------
77*cdf0e10cSrcweir  *
78*cdf0e10cSrcweir  * --------------------------------------------------*/
79*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance(
80*cdf0e10cSrcweir     const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir 	//the module may not be loaded
83*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
84*cdf0e10cSrcweir 	SwDLL::Init();
85*cdf0e10cSrcweir 	static uno::Reference< uno::XInterface > xAText = (cppu::OWeakObject*)new SwXAutoTextContainer();;
86*cdf0e10cSrcweir 	return xAText;
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir /* -----------------------------17.04.01 13:17--------------------------------
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
91*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw()
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     OUString sService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AutoTextContainer"));
94*cdf0e10cSrcweir     const uno::Sequence< OUString > aSeq( &sService, 1 );
95*cdf0e10cSrcweir 	return aSeq;
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir /* -----------------------------17.04.01 13:18--------------------------------
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
100*cdf0e10cSrcweir OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw()
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     return OUString( RTL_CONSTASCII_USTRINGPARAM("SwXAutoTextContainer" ) );
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir /*-- 21.12.98 12:42:16---------------------------------------------------
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
108*cdf0e10cSrcweir SwXAutoTextContainer::SwXAutoTextContainer()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir 	pGlossaries = ::GetGlossaries();
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir /*-- 21.12.98 12:42:17---------------------------------------------------
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
116*cdf0e10cSrcweir SwXAutoTextContainer::~SwXAutoTextContainer()
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir /*-- 21.12.98 12:42:17---------------------------------------------------
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
123*cdf0e10cSrcweir sal_Int32 SwXAutoTextContainer::getCount(void) throw( uno::RuntimeException )
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	return pGlossaries->GetGroupCnt();
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir /*-- 21.12.98 12:42:18---------------------------------------------------
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
130*cdf0e10cSrcweir uno::Any SwXAutoTextContainer::getByIndex(sal_Int32 nIndex)
131*cdf0e10cSrcweir 	throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
134*cdf0e10cSrcweir 	uno::Any aRet;
135*cdf0e10cSrcweir 	sal_uInt16 nCount = pGlossaries->GetGroupCnt();
136*cdf0e10cSrcweir 	if ( 0 <= nIndex && nIndex < nCount )
137*cdf0e10cSrcweir         aRet = getByName(pGlossaries->GetGroupName( static_cast< sal_uInt16 >(nIndex) ));
138*cdf0e10cSrcweir 	else
139*cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
140*cdf0e10cSrcweir 	return aRet;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir /*-- 21.12.98 12:42:18---------------------------------------------------
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
145*cdf0e10cSrcweir uno::Type SwXAutoTextContainer::getElementType(void) throw( uno::RuntimeException )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	return ::getCppuType((const uno::Reference<text::XAutoTextGroup>*)0);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir /*-- 21.12.98 12:42:18---------------------------------------------------
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
153*cdf0e10cSrcweir sal_Bool SwXAutoTextContainer::hasElements(void) throw( uno::RuntimeException )
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir 	//zumindest Standard sollte es immer geben!
156*cdf0e10cSrcweir 	return sal_True;
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir /*-- 21.12.98 12:42:18---------------------------------------------------
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
161*cdf0e10cSrcweir uno::Any SwXAutoTextContainer::getByName(const OUString& GroupName)
162*cdf0e10cSrcweir 	throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	uno::Reference< text::XAutoTextGroup > xGroup;
167*cdf0e10cSrcweir 	if ( pGlossaries && hasByName( GroupName ) )	// group name already known?
168*cdf0e10cSrcweir 		// sal_True = create group if not already available
169*cdf0e10cSrcweir         xGroup = pGlossaries->GetAutoTextGroup( GroupName, sal_True );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	if ( !xGroup.is() )
172*cdf0e10cSrcweir 		throw container::NoSuchElementException();
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 	return makeAny( xGroup );
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir /*-- 21.12.98 12:42:19---------------------------------------------------
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
179*cdf0e10cSrcweir uno::Sequence< OUString > SwXAutoTextContainer::getElementNames(void) throw( uno::RuntimeException )
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
182*cdf0e10cSrcweir 	sal_uInt16 nCount = pGlossaries->GetGroupCnt();
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	uno::Sequence< OUString > aGroupNames(nCount);
185*cdf0e10cSrcweir 	OUString *pArr = aGroupNames.getArray();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; i++ )
188*cdf0e10cSrcweir 	{
189*cdf0e10cSrcweir 		// Die Namen werden ohne Pfad-Extension weitergegeben
190*cdf0e10cSrcweir 		String sGroupName(pGlossaries->GetGroupName(i));
191*cdf0e10cSrcweir 		pArr[i] = sGroupName.GetToken(0, GLOS_DELIM);
192*cdf0e10cSrcweir 	}
193*cdf0e10cSrcweir 	return aGroupNames;
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir /*-- 21.12.98 12:42:19---------------------------------------------------
196*cdf0e10cSrcweir 	findet Gruppennamen mit und ohne Pfadindex
197*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
198*cdf0e10cSrcweir sal_Bool SwXAutoTextContainer::hasByName(const OUString& Name)
199*cdf0e10cSrcweir 	throw( uno::RuntimeException )
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
202*cdf0e10cSrcweir 	String sGroupName( pGlossaries->GetCompleteGroupName( Name ) );
203*cdf0e10cSrcweir 	if(sGroupName.Len())
204*cdf0e10cSrcweir 		return sal_True;
205*cdf0e10cSrcweir 	return sal_False;
206*cdf0e10cSrcweir }
207*cdf0e10cSrcweir /*-- 21.12.98 12:42:19---------------------------------------------------
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
210*cdf0e10cSrcweir uno::Reference< text::XAutoTextGroup >  SwXAutoTextContainer::insertNewByName(
211*cdf0e10cSrcweir 	const OUString& aGroupName)
212*cdf0e10cSrcweir 	throw( lang::IllegalArgumentException, container::ElementExistException, uno::RuntimeException )
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
215*cdf0e10cSrcweir 	if(hasByName(aGroupName))
216*cdf0e10cSrcweir 		throw container::ElementExistException();
217*cdf0e10cSrcweir 	//check for non-ASCII characters
218*cdf0e10cSrcweir 	if(!aGroupName.getLength())
219*cdf0e10cSrcweir 	{
220*cdf0e10cSrcweir 		lang::IllegalArgumentException aIllegal;
221*cdf0e10cSrcweir 		aIllegal.Message = C2U("group name must not be empty");
222*cdf0e10cSrcweir 		throw aIllegal;
223*cdf0e10cSrcweir 	}
224*cdf0e10cSrcweir 	for(sal_Int32 nPos = 0; nPos < aGroupName.getLength(); nPos++)
225*cdf0e10cSrcweir 	{
226*cdf0e10cSrcweir 		sal_Unicode cChar = aGroupName[nPos];
227*cdf0e10cSrcweir 		if(	((cChar >= 'A') && (cChar <= 'Z')) ||
228*cdf0e10cSrcweir             ((cChar >= 'a') && (cChar <= 'z')) ||
229*cdf0e10cSrcweir             ((cChar >= '0') && (cChar <= '9')) ||
230*cdf0e10cSrcweir             (cChar == '_') ||
231*cdf0e10cSrcweir             (cChar == 0x20) ||
232*cdf0e10cSrcweir             (cChar == GLOS_DELIM) )
233*cdf0e10cSrcweir         {
234*cdf0e10cSrcweir 			continue;
235*cdf0e10cSrcweir 		}
236*cdf0e10cSrcweir 		lang::IllegalArgumentException aIllegal;
237*cdf0e10cSrcweir         aIllegal.Message = C2U("group name must contain a-z, A-z, '_', ' ' only");
238*cdf0e10cSrcweir 		throw aIllegal;
239*cdf0e10cSrcweir 	}
240*cdf0e10cSrcweir 	String sGroup(aGroupName);
241*cdf0e10cSrcweir 	if(STRING_NOTFOUND == sGroup.Search(GLOS_DELIM))
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		sGroup += GLOS_DELIM;
244*cdf0e10cSrcweir 		sGroup += UniString::CreateFromInt32(0);
245*cdf0e10cSrcweir 	}
246*cdf0e10cSrcweir 	pGlossaries->NewGroupDoc(sGroup, sGroup.GetToken(0, GLOS_DELIM));
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 	uno::Reference< text::XAutoTextGroup > xGroup = pGlossaries->GetAutoTextGroup( sGroup, true );
249*cdf0e10cSrcweir 	DBG_ASSERT( xGroup.is(), "SwXAutoTextContainer::insertNewByName: no UNO object created? How this?" );
250*cdf0e10cSrcweir 		// we just inserted the group into the glossaries, so why doesn't it exist?
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	return xGroup;
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir /*-- 21.12.98 12:42:19---------------------------------------------------
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
257*cdf0e10cSrcweir void SwXAutoTextContainer::removeByName(const OUString& aGroupName)
258*cdf0e10cSrcweir 	throw( container::NoSuchElementException, uno::RuntimeException )
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
261*cdf0e10cSrcweir 	//zunaechst den Namen mit Pfad-Extension finden
262*cdf0e10cSrcweir 	String sGroupName = pGlossaries->GetCompleteGroupName( aGroupName );
263*cdf0e10cSrcweir 	if(!sGroupName.Len())
264*cdf0e10cSrcweir 		throw container::NoSuchElementException();
265*cdf0e10cSrcweir 	pGlossaries->DelGroupDoc(sGroupName);
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
270*cdf0e10cSrcweir OUString SwXAutoTextContainer::getImplementationName(void) throw( uno::RuntimeException )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir     return SwXAutoTextContainer_getImplementationName();
273*cdf0e10cSrcweir }
274*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
277*cdf0e10cSrcweir sal_Bool SwXAutoTextContainer::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir     const uno::Sequence< OUString > aNames = SwXAutoTextContainer_getSupportedServiceNames();
280*cdf0e10cSrcweir     for(sal_Int32 nService = 0; nService < aNames.getLength(); nService++)
281*cdf0e10cSrcweir     {
282*cdf0e10cSrcweir         if(aNames.getConstArray()[nService] == rServiceName)
283*cdf0e10cSrcweir             return sal_True;
284*cdf0e10cSrcweir     }
285*cdf0e10cSrcweir     return sal_False;
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
290*cdf0e10cSrcweir uno::Sequence< OUString > SwXAutoTextContainer::getSupportedServiceNames(void) throw( uno::RuntimeException )
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     return SwXAutoTextContainer_getSupportedServiceNames();
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir /******************************************************************
295*cdf0e10cSrcweir  *
296*cdf0e10cSrcweir  ******************************************************************/
297*cdf0e10cSrcweir /* -----------------------------10.03.00 18:02--------------------------------
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
300*cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXAutoTextGroup::getUnoTunnelId()
301*cdf0e10cSrcweir {
302*cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
303*cdf0e10cSrcweir 	return aSeq;
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir /* -----------------------------10.03.00 18:04--------------------------------
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
308*cdf0e10cSrcweir sal_Int64 SAL_CALL SwXAutoTextGroup::getSomething( const uno::Sequence< sal_Int8 >& rId )
309*cdf0e10cSrcweir 	throw(uno::RuntimeException)
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     if( rId.getLength() == 16
312*cdf0e10cSrcweir         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
313*cdf0e10cSrcweir 										rId.getConstArray(), 16 ) )
314*cdf0e10cSrcweir     {
315*cdf0e10cSrcweir             return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
316*cdf0e10cSrcweir     }
317*cdf0e10cSrcweir 	return 0;
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir /*-- 21.12.98 12:42:24---------------------------------------------------
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
323*cdf0e10cSrcweir SwXAutoTextGroup::SwXAutoTextGroup(const OUString& rName,
324*cdf0e10cSrcweir 			SwGlossaries*	pGlos) :
325*cdf0e10cSrcweir     pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_AUTO_TEXT_GROUP)),
326*cdf0e10cSrcweir     pGlossaries(pGlos),
327*cdf0e10cSrcweir 	sName(rName),
328*cdf0e10cSrcweir     m_sGroupName(rName)
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir 	DBG_ASSERT( -1 != rName.indexOf( GLOS_DELIM ),
331*cdf0e10cSrcweir 		"SwXAutoTextGroup::SwXAutoTextGroup: to be constructed with a complete name only!" );
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir /*-- 21.12.98 12:42:24---------------------------------------------------
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
337*cdf0e10cSrcweir SwXAutoTextGroup::~SwXAutoTextGroup()
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir /*-- 21.12.98 12:42:24---------------------------------------------------
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
343*cdf0e10cSrcweir /*-- 21.12.98 12:42:25---------------------------------------------------
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
346*cdf0e10cSrcweir uno::Sequence< OUString > SwXAutoTextGroup::getTitles(void) throw( uno::RuntimeException )
347*cdf0e10cSrcweir {
348*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
349*cdf0e10cSrcweir 	sal_uInt16 nCount = 0;
350*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
351*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
352*cdf0e10cSrcweir 		nCount = pGlosGroup->GetCount();
353*cdf0e10cSrcweir 	else
354*cdf0e10cSrcweir 		throw uno::RuntimeException();
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	uno::Sequence< OUString > aEntryTitles(nCount);
357*cdf0e10cSrcweir 	OUString *pArr = aEntryTitles.getArray();
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; i++ )
360*cdf0e10cSrcweir 		pArr[i] = pGlosGroup->GetLongName(i);
361*cdf0e10cSrcweir 	delete pGlosGroup;
362*cdf0e10cSrcweir 	return aEntryTitles;
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir /*-- 21.12.98 12:42:25---------------------------------------------------
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
367*cdf0e10cSrcweir void SwXAutoTextGroup::renameByName(const OUString& aElementName,
368*cdf0e10cSrcweir 	const OUString& aNewElementName, const OUString& aNewElementTitle)
369*cdf0e10cSrcweir 	throw( lang::IllegalArgumentException, container::ElementExistException, io::IOException,
370*cdf0e10cSrcweir 													 uno::RuntimeException)
371*cdf0e10cSrcweir {
372*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
373*cdf0e10cSrcweir 	// throw exception only if the programmatic name is to be changed into an existing name
374*cdf0e10cSrcweir 	if(aNewElementName != aElementName && hasByName(aNewElementName))
375*cdf0e10cSrcweir 		throw container::ElementExistException();
376*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
377*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
378*cdf0e10cSrcweir 	{
379*cdf0e10cSrcweir 		sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName);
380*cdf0e10cSrcweir 		if(USHRT_MAX == nIdx)
381*cdf0e10cSrcweir 			throw lang::IllegalArgumentException();
382*cdf0e10cSrcweir 		String aNewShort( aNewElementName);
383*cdf0e10cSrcweir 		String aNewName( aNewElementTitle);
384*cdf0e10cSrcweir 		sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort );
385*cdf0e10cSrcweir 		sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName );
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 		if( nIdx != USHRT_MAX &&
388*cdf0e10cSrcweir 				(nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&&
389*cdf0e10cSrcweir 					(nOldIdx == USHRT_MAX || nOldIdx == nIdx ))
390*cdf0e10cSrcweir 		{
391*cdf0e10cSrcweir 			pGlosGroup->Rename( nIdx, &aNewShort, &aNewName );
392*cdf0e10cSrcweir 			if(pGlosGroup->GetError() != 0)
393*cdf0e10cSrcweir 				throw io::IOException();
394*cdf0e10cSrcweir 		}
395*cdf0e10cSrcweir 		delete pGlosGroup;
396*cdf0e10cSrcweir 	}
397*cdf0e10cSrcweir 	else
398*cdf0e10cSrcweir 		throw uno::RuntimeException();
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextRange* pxRange)
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	ASSERT( pInsDoc, "kein Ins.Dokument"  );
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir 	SwNodes& rNds = pInsDoc->GetNodes();
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
408*cdf0e10cSrcweir 	SwCntntNode * pNd = aIdx.GetNode().GetCntntNode();
409*cdf0e10cSrcweir 	SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() ));
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir     bool bRet = false;
412*cdf0e10cSrcweir 	pInsDoc->LockExpFlds();
413*cdf0e10cSrcweir 	{
414*cdf0e10cSrcweir         SwDoc *const pDoc((pxCursor) ? pxCursor->GetDoc() : pxRange->GetDoc());
415*cdf0e10cSrcweir         SwPaM aPam(pDoc->GetNodes());
416*cdf0e10cSrcweir         SwPaM * pPam(0);
417*cdf0e10cSrcweir         if(pxCursor)
418*cdf0e10cSrcweir         {
419*cdf0e10cSrcweir             pPam = pxCursor->GetPaM();
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir         else
422*cdf0e10cSrcweir         {
423*cdf0e10cSrcweir             if (pxRange->GetPositions(aPam))
424*cdf0e10cSrcweir             {
425*cdf0e10cSrcweir                 pPam = & aPam;
426*cdf0e10cSrcweir             }
427*cdf0e10cSrcweir         }
428*cdf0e10cSrcweir         if (!pPam) { return false; }
429*cdf0e10cSrcweir         bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet;
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	pInsDoc->UnlockExpFlds();
433*cdf0e10cSrcweir 	if( !pInsDoc->IsExpFldsLocked() )
434*cdf0e10cSrcweir 		pInsDoc->UpdateExpFlds(NULL, true);
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 	return bRet;
437*cdf0e10cSrcweir }
438*cdf0e10cSrcweir /*-- 21.12.98 12:42:25---------------------------------------------------
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
441*cdf0e10cSrcweir uno::Reference< text::XAutoTextEntry >  SwXAutoTextGroup::insertNewByName(const OUString& aName,
442*cdf0e10cSrcweir 		const OUString& aTitle, const uno::Reference< text::XTextRange > & xTextRange)
443*cdf0e10cSrcweir 		throw( container::ElementExistException, uno::RuntimeException )
444*cdf0e10cSrcweir {
445*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
446*cdf0e10cSrcweir 	if(hasByName(aName))
447*cdf0e10cSrcweir 		throw container::ElementExistException();
448*cdf0e10cSrcweir 	if(!xTextRange.is())
449*cdf0e10cSrcweir 		throw uno::RuntimeException();
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
452*cdf0e10cSrcweir 	String sShortName(aName);
453*cdf0e10cSrcweir 	String sLongName(aTitle);
454*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
455*cdf0e10cSrcweir 	{
456*cdf0e10cSrcweir         /*if( pGlosGroup->IsOld() && pGlosGroup->ConvertToNew())
457*cdf0e10cSrcweir 		{
458*cdf0e10cSrcweir             throw uno::RuntimeException();
459*cdf0e10cSrcweir         } */
460*cdf0e10cSrcweir 		uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
461*cdf0e10cSrcweir 		SwXTextRange* pxRange = 0;
462*cdf0e10cSrcweir 		OTextCursorHelper* pxCursor = 0;
463*cdf0e10cSrcweir 		if(xRangeTunnel.is())
464*cdf0e10cSrcweir 		{
465*cdf0e10cSrcweir             pxRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
466*cdf0e10cSrcweir                                     SwXTextRange::getUnoTunnelId()));
467*cdf0e10cSrcweir             pxCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
468*cdf0e10cSrcweir                                     OTextCursorHelper::getUnoTunnelId()));
469*cdf0e10cSrcweir 		}
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 		String sOnlyTxt;
472*cdf0e10cSrcweir 		String* pOnlyTxt = 0;
473*cdf0e10cSrcweir 		sal_Bool bNoAttr = !pxCursor && !pxRange;
474*cdf0e10cSrcweir 		if(bNoAttr)
475*cdf0e10cSrcweir 		{
476*cdf0e10cSrcweir 			sOnlyTxt = UniString(xTextRange->getString());
477*cdf0e10cSrcweir 			pOnlyTxt = &sOnlyTxt;
478*cdf0e10cSrcweir 		}
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 		const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 		SwDoc* pGDoc = pGlosGroup->GetDoc();
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir 		// Bis es eine Option dafuer gibt, base util::URL loeschen
485*cdf0e10cSrcweir 		if(pCfg->IsSaveRelFile())
486*cdf0e10cSrcweir 		{
487*cdf0e10cSrcweir             INetURLObject aTemp(pGlosGroup->GetFileName());
488*cdf0e10cSrcweir             pGlosGroup->SetBaseURL( aTemp.GetMainURL(INetURLObject::NO_DECODE));
489*cdf0e10cSrcweir 		}
490*cdf0e10cSrcweir 		else
491*cdf0e10cSrcweir             pGlosGroup->SetBaseURL( aEmptyStr );
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 		sal_uInt16 nRet;
494*cdf0e10cSrcweir 		if( pOnlyTxt )
495*cdf0e10cSrcweir 			nRet = pGlosGroup->PutText( sShortName, sLongName, *pOnlyTxt );
496*cdf0e10cSrcweir 		else
497*cdf0e10cSrcweir 		{
498*cdf0e10cSrcweir 			pGlosGroup->ClearDoc();
499*cdf0e10cSrcweir 			if( pGlosGroup->BeginPutDoc( sShortName, sLongName ) )
500*cdf0e10cSrcweir 			{
501*cdf0e10cSrcweir 				pGDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
502*cdf0e10cSrcweir 				lcl_CopySelToDoc( pGDoc, pxCursor, pxRange );
503*cdf0e10cSrcweir 				pGDoc->SetRedlineMode_intern((RedlineMode_t)( 0 ));
504*cdf0e10cSrcweir 				nRet = pGlosGroup->PutDoc();
505*cdf0e10cSrcweir 			}
506*cdf0e10cSrcweir 			else
507*cdf0e10cSrcweir 				nRet = (sal_uInt16) -1;
508*cdf0e10cSrcweir 		}
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 		if(nRet == (sal_uInt16) -1 )
511*cdf0e10cSrcweir 		{
512*cdf0e10cSrcweir 			throw uno::RuntimeException();
513*cdf0e10cSrcweir 		}
514*cdf0e10cSrcweir 		pGlossaries->PutGroupDoc( pGlosGroup );
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 	uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, sShortName, true );
518*cdf0e10cSrcweir 	DBG_ASSERT( xEntry.is(), "SwXAutoTextGroup::insertNewByName: no UNO object created? How this?" );
519*cdf0e10cSrcweir 		// we just inserted the entry into the group, so why doesn't it exist?
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	return xEntry;
522*cdf0e10cSrcweir }
523*cdf0e10cSrcweir /*-- 21.12.98 12:42:25---------------------------------------------------
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
526*cdf0e10cSrcweir void SwXAutoTextGroup::removeByName(const OUString& aEntryName) throw( container::NoSuchElementException, uno::RuntimeException )
527*cdf0e10cSrcweir {
528*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
529*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
530*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
531*cdf0e10cSrcweir 	{
532*cdf0e10cSrcweir 		sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName);
533*cdf0e10cSrcweir 		if ( nIdx != USHRT_MAX )
534*cdf0e10cSrcweir 			pGlosGroup->Delete(nIdx);
535*cdf0e10cSrcweir 		delete pGlosGroup;
536*cdf0e10cSrcweir 	}
537*cdf0e10cSrcweir 	else
538*cdf0e10cSrcweir 		throw container::NoSuchElementException();
539*cdf0e10cSrcweir }
540*cdf0e10cSrcweir /*-- 21.12.98 12:42:25---------------------------------------------------
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
543*cdf0e10cSrcweir OUString SwXAutoTextGroup::getName(void) throw( uno::RuntimeException )
544*cdf0e10cSrcweir {
545*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
546*cdf0e10cSrcweir 	return sName;
547*cdf0e10cSrcweir }
548*cdf0e10cSrcweir /*-- 21.12.98 12:42:25---------------------------------------------------
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
551*cdf0e10cSrcweir void SwXAutoTextGroup::setName(const OUString& rName) throw( uno::RuntimeException )
552*cdf0e10cSrcweir {
553*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
554*cdf0e10cSrcweir 	if( !pGlossaries )
555*cdf0e10cSrcweir 		throw uno::RuntimeException();
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir     sal_Int32 nNewDelimPos = rName.lastIndexOf( GLOS_DELIM );
558*cdf0e10cSrcweir     sal_Int32 nOldDelimPos = sName.lastIndexOf( GLOS_DELIM );
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir     OUString aNewSuffix;
561*cdf0e10cSrcweir     if (nNewDelimPos > -1)
562*cdf0e10cSrcweir         aNewSuffix = rName.copy( nNewDelimPos + 1 );
563*cdf0e10cSrcweir     OUString aOldSuffix;
564*cdf0e10cSrcweir     if (nOldDelimPos > -1)
565*cdf0e10cSrcweir         aOldSuffix = sName.copy( nOldDelimPos + 1 );
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 	sal_Int32 nNewNumeric = aNewSuffix.toInt32();
568*cdf0e10cSrcweir 	sal_Int32 nOldNumeric = aOldSuffix.toInt32();
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir     OUString aNewPrefix( (nNewDelimPos > 1) ? rName.copy( 0, nNewDelimPos ) : rName );
571*cdf0e10cSrcweir     OUString aOldPrefix( (nOldDelimPos > 1) ? sName.copy( 0, nOldDelimPos ) : sName );
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir 	if ( sName == rName ||
574*cdf0e10cSrcweir 	   ( nNewNumeric == nOldNumeric && aNewPrefix == aOldPrefix ) )
575*cdf0e10cSrcweir 		return;
576*cdf0e10cSrcweir 	String sNewGroup(rName);
577*cdf0e10cSrcweir 	if(STRING_NOTFOUND == sNewGroup.Search(GLOS_DELIM))
578*cdf0e10cSrcweir 	{
579*cdf0e10cSrcweir 		sNewGroup += GLOS_DELIM;
580*cdf0e10cSrcweir 		sNewGroup += UniString::CreateFromInt32(0);
581*cdf0e10cSrcweir 	}
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 	//the name must be saved, the group may be invalidated while in RenameGroupDoc()
584*cdf0e10cSrcweir 	SwGlossaries* pTempGlossaries = pGlossaries;
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 	String sPreserveTitle( pGlossaries->GetGroupTitle( sName ) );
587*cdf0e10cSrcweir 	if ( !pGlossaries->RenameGroupDoc( sName, sNewGroup, sPreserveTitle ) )
588*cdf0e10cSrcweir 		throw uno::RuntimeException();
589*cdf0e10cSrcweir 	else
590*cdf0e10cSrcweir 	{
591*cdf0e10cSrcweir 		sName = rName;
592*cdf0e10cSrcweir 		m_sGroupName = sNewGroup;
593*cdf0e10cSrcweir 		pGlossaries = pTempGlossaries;
594*cdf0e10cSrcweir 	}
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir /*-- 21.12.98 12:42:26---------------------------------------------------
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
599*cdf0e10cSrcweir sal_Int32 SwXAutoTextGroup::getCount(void) throw( uno::RuntimeException )
600*cdf0e10cSrcweir {
601*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
602*cdf0e10cSrcweir 	int nCount = 0;
603*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
604*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
605*cdf0e10cSrcweir 		nCount = pGlosGroup->GetCount();
606*cdf0e10cSrcweir 	else
607*cdf0e10cSrcweir 		throw uno::RuntimeException();
608*cdf0e10cSrcweir 	delete pGlosGroup;
609*cdf0e10cSrcweir 	return nCount;
610*cdf0e10cSrcweir }
611*cdf0e10cSrcweir /*-- 21.12.98 12:42:26---------------------------------------------------
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
614*cdf0e10cSrcweir uno::Any SwXAutoTextGroup::getByIndex(sal_Int32 nIndex)
615*cdf0e10cSrcweir 	throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
616*cdf0e10cSrcweir {
617*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
618*cdf0e10cSrcweir 	uno::Any aRet;
619*cdf0e10cSrcweir 	sal_uInt16 nCount = 0;
620*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
621*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
622*cdf0e10cSrcweir 		nCount = pGlosGroup->GetCount();
623*cdf0e10cSrcweir 	else
624*cdf0e10cSrcweir 		throw uno::RuntimeException();
625*cdf0e10cSrcweir 	if(0 <= nIndex && nIndex < nCount)
626*cdf0e10cSrcweir 		aRet = getByName(pGlosGroup->GetShortName((sal_uInt16) nIndex));
627*cdf0e10cSrcweir 	else
628*cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
629*cdf0e10cSrcweir 	delete pGlosGroup;
630*cdf0e10cSrcweir 	return aRet;
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir /*-- 21.12.98 12:42:26---------------------------------------------------
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
635*cdf0e10cSrcweir uno::Type SwXAutoTextGroup::getElementType(void) throw( uno::RuntimeException )
636*cdf0e10cSrcweir {
637*cdf0e10cSrcweir 	return ::getCppuType((uno::Reference<text::XAutoTextEntry>*)0);
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir }
640*cdf0e10cSrcweir /*-- 21.12.98 12:42:26---------------------------------------------------
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
643*cdf0e10cSrcweir sal_Bool SwXAutoTextGroup::hasElements(void) throw( uno::RuntimeException )
644*cdf0e10cSrcweir {
645*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
646*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
647*cdf0e10cSrcweir 	sal_uInt16 nCount = 0;
648*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
649*cdf0e10cSrcweir 		nCount = pGlosGroup->GetCount();
650*cdf0e10cSrcweir 	else
651*cdf0e10cSrcweir 		throw uno::RuntimeException();
652*cdf0e10cSrcweir 	delete pGlosGroup;
653*cdf0e10cSrcweir 	return nCount > 0;
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir }
656*cdf0e10cSrcweir /*-- 21.12.98 12:42:27---------------------------------------------------
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
659*cdf0e10cSrcweir uno::Any SwXAutoTextGroup::getByName(const OUString& _rName)
660*cdf0e10cSrcweir 	throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
661*cdf0e10cSrcweir {
662*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
663*cdf0e10cSrcweir 	uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, _rName, true );
664*cdf0e10cSrcweir 	DBG_ASSERT( xEntry.is(), "SwXAutoTextGroup::getByName: GetAutoTextEntry is fractious!" );
665*cdf0e10cSrcweir 		// we told it to create the object, so why didn't it?
666*cdf0e10cSrcweir 	return makeAny( xEntry );
667*cdf0e10cSrcweir }
668*cdf0e10cSrcweir /*-- 21.12.98 12:42:27---------------------------------------------------
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
671*cdf0e10cSrcweir uno::Sequence< OUString > SwXAutoTextGroup::getElementNames(void)
672*cdf0e10cSrcweir 	throw( uno::RuntimeException )
673*cdf0e10cSrcweir {
674*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
675*cdf0e10cSrcweir 	sal_uInt16 nCount = 0;
676*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
677*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
678*cdf0e10cSrcweir 		nCount = pGlosGroup->GetCount();
679*cdf0e10cSrcweir 	else
680*cdf0e10cSrcweir 		throw uno::RuntimeException();
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir 	uno::Sequence< OUString > aEntryNames(nCount);
683*cdf0e10cSrcweir 	OUString *pArr = aEntryNames.getArray();
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; i++ )
686*cdf0e10cSrcweir 		pArr[i] = pGlosGroup->GetShortName(i);
687*cdf0e10cSrcweir 	delete pGlosGroup;
688*cdf0e10cSrcweir 	return aEntryNames;
689*cdf0e10cSrcweir }
690*cdf0e10cSrcweir /*-- 21.12.98 12:42:27---------------------------------------------------
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
693*cdf0e10cSrcweir sal_Bool SwXAutoTextGroup::hasByName(const OUString& rName)
694*cdf0e10cSrcweir 	throw( uno::RuntimeException )
695*cdf0e10cSrcweir {
696*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
697*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
698*cdf0e10cSrcweir 	sal_uInt16 nCount = 0;
699*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
700*cdf0e10cSrcweir     if(pGlosGroup && !pGlosGroup->GetError())
701*cdf0e10cSrcweir 		nCount = pGlosGroup->GetCount();
702*cdf0e10cSrcweir 	else
703*cdf0e10cSrcweir 		throw uno::RuntimeException();
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < nCount; i++ )
706*cdf0e10cSrcweir 	{
707*cdf0e10cSrcweir 		String sCompare(pGlosGroup->GetShortName(i));
708*cdf0e10cSrcweir 		if(COMPARE_EQUAL == sCompare.CompareIgnoreCaseToAscii(String(rName)))
709*cdf0e10cSrcweir 		{
710*cdf0e10cSrcweir 			bRet = sal_True;
711*cdf0e10cSrcweir 			break;
712*cdf0e10cSrcweir 		}
713*cdf0e10cSrcweir 	}
714*cdf0e10cSrcweir 	delete pGlosGroup;
715*cdf0e10cSrcweir 	return bRet;
716*cdf0e10cSrcweir }
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir /*-- 09.02.00 15:33:30---------------------------------------------------
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
721*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo >  SwXAutoTextGroup::getPropertySetInfo(void)
722*cdf0e10cSrcweir 	throw( uno::RuntimeException )
723*cdf0e10cSrcweir {
724*cdf0e10cSrcweir     static uno::Reference< beans::XPropertySetInfo >  xRet = pPropSet->getPropertySetInfo();
725*cdf0e10cSrcweir 	return xRet;
726*cdf0e10cSrcweir }
727*cdf0e10cSrcweir /*-- 09.02.00 15:33:31---------------------------------------------------
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
730*cdf0e10cSrcweir void SwXAutoTextGroup::setPropertyValue(
731*cdf0e10cSrcweir 	const OUString& rPropertyName, const uno::Any& aValue)
732*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, beans::PropertyVetoException,
733*cdf0e10cSrcweir  		lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
734*cdf0e10cSrcweir {
735*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
736*cdf0e10cSrcweir     const SfxItemPropertySimpleEntry*   pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName );
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir     if(!pEntry)
739*cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
742*cdf0e10cSrcweir     if(!pGlosGroup || pGlosGroup->GetError())
743*cdf0e10cSrcweir 		throw uno::RuntimeException();
744*cdf0e10cSrcweir     switch(pEntry->nWID)
745*cdf0e10cSrcweir 	{
746*cdf0e10cSrcweir 		case  WID_GROUP_TITLE:
747*cdf0e10cSrcweir 		{
748*cdf0e10cSrcweir             OUString sNewTitle;
749*cdf0e10cSrcweir             aValue >>= sNewTitle;
750*cdf0e10cSrcweir             if(!sNewTitle.getLength())
751*cdf0e10cSrcweir 				throw lang::IllegalArgumentException();
752*cdf0e10cSrcweir             sal_Bool bChanged = !sNewTitle.equals(pGlosGroup->GetName());
753*cdf0e10cSrcweir 			pGlosGroup->SetName(sNewTitle);
754*cdf0e10cSrcweir 			if(bChanged && HasGlossaryList())
755*cdf0e10cSrcweir 				GetGlossaryList()->ClearGroups();
756*cdf0e10cSrcweir 		}
757*cdf0e10cSrcweir 		break;
758*cdf0e10cSrcweir 	}
759*cdf0e10cSrcweir 	delete pGlosGroup;
760*cdf0e10cSrcweir }
761*cdf0e10cSrcweir /*-- 09.02.00 15:33:31---------------------------------------------------
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
764*cdf0e10cSrcweir uno::Any SwXAutoTextGroup::getPropertyValue(const OUString& rPropertyName)
765*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
766*cdf0e10cSrcweir {
767*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
768*cdf0e10cSrcweir     const SfxItemPropertySimpleEntry*   pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir     if(!pEntry)
771*cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
772*cdf0e10cSrcweir 	SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
773*cdf0e10cSrcweir     if(!pGlosGroup  || pGlosGroup->GetError())
774*cdf0e10cSrcweir 		throw uno::RuntimeException();
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	uno::Any aAny;
777*cdf0e10cSrcweir     switch(pEntry->nWID)
778*cdf0e10cSrcweir 	{
779*cdf0e10cSrcweir 		case  WID_GROUP_PATH:
780*cdf0e10cSrcweir 			aAny <<= OUString(pGlosGroup->GetFileName());
781*cdf0e10cSrcweir 		break;
782*cdf0e10cSrcweir 		case  WID_GROUP_TITLE:
783*cdf0e10cSrcweir 			aAny <<= OUString(pGlosGroup->GetName());
784*cdf0e10cSrcweir 		break;
785*cdf0e10cSrcweir 	}
786*cdf0e10cSrcweir 	delete pGlosGroup;
787*cdf0e10cSrcweir 	return aAny;
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir /*-- 09.02.00 15:33:31---------------------------------------------------
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
792*cdf0e10cSrcweir void SwXAutoTextGroup::addPropertyChangeListener(
793*cdf0e10cSrcweir     const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
794*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
795*cdf0e10cSrcweir {
796*cdf0e10cSrcweir }
797*cdf0e10cSrcweir /*-- 09.02.00 15:33:31---------------------------------------------------
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
800*cdf0e10cSrcweir void SwXAutoTextGroup::removePropertyChangeListener(
801*cdf0e10cSrcweir     const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
802*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
803*cdf0e10cSrcweir {
804*cdf0e10cSrcweir }
805*cdf0e10cSrcweir /*-- 09.02.00 15:33:32---------------------------------------------------
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
808*cdf0e10cSrcweir void SwXAutoTextGroup::addVetoableChangeListener(
809*cdf0e10cSrcweir     const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
810*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
811*cdf0e10cSrcweir {
812*cdf0e10cSrcweir }
813*cdf0e10cSrcweir /*-- 09.02.00 15:33:32---------------------------------------------------
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
816*cdf0e10cSrcweir void SwXAutoTextGroup::removeVetoableChangeListener(
817*cdf0e10cSrcweir     const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
818*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
819*cdf0e10cSrcweir {
820*cdf0e10cSrcweir }
821*cdf0e10cSrcweir /*-- 21.12.98 12:42:27---------------------------------------------------
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
824*cdf0e10cSrcweir void SwXAutoTextGroup::Invalidate()
825*cdf0e10cSrcweir {
826*cdf0e10cSrcweir 	pGlossaries = 0;
827*cdf0e10cSrcweir 	sName = aEmptyStr;
828*cdf0e10cSrcweir 	m_sGroupName = aEmptyStr;
829*cdf0e10cSrcweir }
830*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
833*cdf0e10cSrcweir OUString SwXAutoTextGroup::getImplementationName(void) throw( uno::RuntimeException )
834*cdf0e10cSrcweir {
835*cdf0e10cSrcweir 	return C2U("SwXAutoTextGroup");
836*cdf0e10cSrcweir }
837*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
840*cdf0e10cSrcweir sal_Bool SwXAutoTextGroup::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
841*cdf0e10cSrcweir {
842*cdf0e10cSrcweir 	return C2U("com.sun.star.text.AutoTextGroup") == rServiceName;
843*cdf0e10cSrcweir }
844*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
847*cdf0e10cSrcweir uno::Sequence< OUString > SwXAutoTextGroup::getSupportedServiceNames(void) throw( uno::RuntimeException )
848*cdf0e10cSrcweir {
849*cdf0e10cSrcweir 	uno::Sequence< OUString > aRet(1);
850*cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
851*cdf0e10cSrcweir 	pArray[0] = C2U("com.sun.star.text.AutoTextGroup");
852*cdf0e10cSrcweir 	return aRet;
853*cdf0e10cSrcweir }
854*cdf0e10cSrcweir /******************************************************************
855*cdf0e10cSrcweir  *
856*cdf0e10cSrcweir  ******************************************************************/
857*cdf0e10cSrcweir /* -----------------------------10.03.00 18:02--------------------------------
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
860*cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXAutoTextEntry::getUnoTunnelId()
861*cdf0e10cSrcweir {
862*cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
863*cdf0e10cSrcweir 	return aSeq;
864*cdf0e10cSrcweir }
865*cdf0e10cSrcweir /* -----------------------------10.03.00 18:04--------------------------------
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
868*cdf0e10cSrcweir sal_Int64 SAL_CALL SwXAutoTextEntry::getSomething( const uno::Sequence< sal_Int8 >& rId )
869*cdf0e10cSrcweir 	throw(uno::RuntimeException)
870*cdf0e10cSrcweir {
871*cdf0e10cSrcweir     if( rId.getLength() == 16
872*cdf0e10cSrcweir         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
873*cdf0e10cSrcweir 										rId.getConstArray(), 16 ) )
874*cdf0e10cSrcweir     {
875*cdf0e10cSrcweir             return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
876*cdf0e10cSrcweir     }
877*cdf0e10cSrcweir 	return 0;
878*cdf0e10cSrcweir }
879*cdf0e10cSrcweir /*-- 21.12.98 12:42:33---------------------------------------------------
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
882*cdf0e10cSrcweir SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const String& rGroupName,
883*cdf0e10cSrcweir 											const String& rEntryName) :
884*cdf0e10cSrcweir 	pGlossaries(pGlss),
885*cdf0e10cSrcweir 	sGroupName(rGroupName),
886*cdf0e10cSrcweir 	sEntryName(rEntryName),
887*cdf0e10cSrcweir 	pBodyText ( NULL )
888*cdf0e10cSrcweir {
889*cdf0e10cSrcweir }
890*cdf0e10cSrcweir /*-- 21.12.98 12:42:33---------------------------------------------------
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
893*cdf0e10cSrcweir SwXAutoTextEntry::~SwXAutoTextEntry()
894*cdf0e10cSrcweir {
895*cdf0e10cSrcweir 	{
896*cdf0e10cSrcweir 	    ::vos::OGuard aGuard(Application::GetSolarMutex());
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir 		// ensure that any pending modifications are written
899*cdf0e10cSrcweir 		implFlushDocument( true );
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir 		//! Bug #96559
902*cdf0e10cSrcweir 		// DocShell must be cleared before mutex is lost.
903*cdf0e10cSrcweir 		// Needs to be done explicitly since xDocSh is a class member.
904*cdf0e10cSrcweir 		// Thus, an own block here, guarded by the SolarMutex
905*cdf0e10cSrcweir 	}
906*cdf0e10cSrcweir }
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir //---------------------------------------------------------------------
909*cdf0e10cSrcweir //--- 03.03.2003 13:24:58 -----------------------------------------------
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir void SwXAutoTextEntry::implFlushDocument( bool _bCloseDoc )
912*cdf0e10cSrcweir {
913*cdf0e10cSrcweir 	if ( xDocSh.Is() )
914*cdf0e10cSrcweir 	{
915*cdf0e10cSrcweir 		if ( xDocSh->GetDoc()->IsModified () )
916*cdf0e10cSrcweir 			xDocSh->Save();
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir         if ( _bCloseDoc )
919*cdf0e10cSrcweir 		{
920*cdf0e10cSrcweir 			// stop listening at the document
921*cdf0e10cSrcweir 			EndListening( *&xDocSh );
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir 			xDocSh->DoClose();
924*cdf0e10cSrcweir 			xDocSh.Clear();
925*cdf0e10cSrcweir 		}
926*cdf0e10cSrcweir 	}
927*cdf0e10cSrcweir }
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir //-----------------------------------------------------------------------
930*cdf0e10cSrcweir //--- 03.03.2003 15:51:52 -----------------------------------------------
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint )
933*cdf0e10cSrcweir {
934*cdf0e10cSrcweir 	if ( &_rBC == &xDocSh )
935*cdf0e10cSrcweir 	{	// it's our document
936*cdf0e10cSrcweir 		if ( _rHint.ISA( SfxSimpleHint ) )
937*cdf0e10cSrcweir 		{
938*cdf0e10cSrcweir             if ( SFX_HINT_DEINITIALIZING == static_cast< const SfxSimpleHint& >( _rHint ).GetId() )
939*cdf0e10cSrcweir 			{
940*cdf0e10cSrcweir 				// our document is dying (possibly because we're shuting down, and the document was notified
941*cdf0e10cSrcweir 				// earlier than we are?)
942*cdf0e10cSrcweir 				// stop listening at the docu
943*cdf0e10cSrcweir 				EndListening( *&xDocSh );
944*cdf0e10cSrcweir 				// and release our reference
945*cdf0e10cSrcweir 				xDocSh.Clear();
946*cdf0e10cSrcweir 			}
947*cdf0e10cSrcweir 		}
948*cdf0e10cSrcweir         else if(_rHint.ISA(SfxEventHint))
949*cdf0e10cSrcweir         {
950*cdf0e10cSrcweir             if(SFX_EVENT_PREPARECLOSEDOC == static_cast< const SfxEventHint& >( _rHint ).GetEventId())
951*cdf0e10cSrcweir             {
952*cdf0e10cSrcweir                 implFlushDocument( sal_False );
953*cdf0e10cSrcweir                 xBodyText = 0;
954*cdf0e10cSrcweir                 xDocSh.Clear();
955*cdf0e10cSrcweir             }
956*cdf0e10cSrcweir         }
957*cdf0e10cSrcweir 	}
958*cdf0e10cSrcweir }
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir void SwXAutoTextEntry::GetBodyText ()
961*cdf0e10cSrcweir {
962*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir 	xDocSh = pGlossaries->EditGroupDoc ( sGroupName, sEntryName, sal_False );
965*cdf0e10cSrcweir 	DBG_ASSERT( xDocSh.Is(), "SwXAutoTextEntry::GetBodyText: unexpected: no doc returned by EditGroupDoc!" );
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir 	// start listening at the document
968*cdf0e10cSrcweir 	StartListening( *&xDocSh );
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir 	pBodyText = new SwXBodyText ( xDocSh->GetDoc() );
971*cdf0e10cSrcweir 	xBodyText = uno::Reference < lang::XServiceInfo > ( *pBodyText, uno::UNO_QUERY);
972*cdf0e10cSrcweir }
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir uno::Reference< text::XTextCursor >  SwXAutoTextEntry::createTextCursor(void) throw( uno::RuntimeException )
975*cdf0e10cSrcweir {
976*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
977*cdf0e10cSrcweir 	EnsureBodyText();
978*cdf0e10cSrcweir 	return pBodyText->createTextCursor();
979*cdf0e10cSrcweir }
980*cdf0e10cSrcweir /*-- 21.12.98 12:42:34---------------------------------------------------
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
983*cdf0e10cSrcweir uno::Reference< text::XTextCursor >  SwXAutoTextEntry::createTextCursorByRange(
984*cdf0e10cSrcweir 	const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException )
985*cdf0e10cSrcweir {
986*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
987*cdf0e10cSrcweir 	EnsureBodyText();
988*cdf0e10cSrcweir 	return pBodyText->createTextCursorByRange ( aTextPosition );
989*cdf0e10cSrcweir }
990*cdf0e10cSrcweir /*-- 21.12.98 12:42:34---------------------------------------------------
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
993*cdf0e10cSrcweir void SwXAutoTextEntry::insertString(const uno::Reference< text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb) throw( uno::RuntimeException )
994*cdf0e10cSrcweir {
995*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
996*cdf0e10cSrcweir 	EnsureBodyText();
997*cdf0e10cSrcweir 	pBodyText->insertString ( xRange, aString, bAbsorb );
998*cdf0e10cSrcweir }
999*cdf0e10cSrcweir /*-- 21.12.98 12:42:34---------------------------------------------------
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1002*cdf0e10cSrcweir void SwXAutoTextEntry::insertControlCharacter(const uno::Reference< text::XTextRange > & xRange,
1003*cdf0e10cSrcweir 	sal_Int16 nControlCharacter, sal_Bool bAbsorb)
1004*cdf0e10cSrcweir 		throw( lang::IllegalArgumentException, uno::RuntimeException )
1005*cdf0e10cSrcweir {
1006*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1007*cdf0e10cSrcweir 	EnsureBodyText();
1008*cdf0e10cSrcweir 	pBodyText->insertControlCharacter ( xRange, nControlCharacter, bAbsorb );
1009*cdf0e10cSrcweir }
1010*cdf0e10cSrcweir /*-- 21.12.98 12:42:34---------------------------------------------------
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1013*cdf0e10cSrcweir void SwXAutoTextEntry::insertTextContent(
1014*cdf0e10cSrcweir 	const uno::Reference< text::XTextRange > & xRange,
1015*cdf0e10cSrcweir 	const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb)
1016*cdf0e10cSrcweir 		throw( lang::IllegalArgumentException, uno::RuntimeException )
1017*cdf0e10cSrcweir {
1018*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1019*cdf0e10cSrcweir 	EnsureBodyText();
1020*cdf0e10cSrcweir 	pBodyText->insertTextContent ( xRange, xContent, bAbsorb );
1021*cdf0e10cSrcweir }
1022*cdf0e10cSrcweir /*-- 21.12.98 12:42:34---------------------------------------------------
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1025*cdf0e10cSrcweir void SwXAutoTextEntry::removeTextContent(
1026*cdf0e10cSrcweir 	const uno::Reference< text::XTextContent > & xContent)
1027*cdf0e10cSrcweir 		throw( container::NoSuchElementException, uno::RuntimeException )
1028*cdf0e10cSrcweir {
1029*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1030*cdf0e10cSrcweir 	EnsureBodyText();
1031*cdf0e10cSrcweir 	pBodyText->removeTextContent ( xContent );
1032*cdf0e10cSrcweir }
1033*cdf0e10cSrcweir /*-- 21.12.98 12:42:35---------------------------------------------------
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1036*cdf0e10cSrcweir uno::Reference< text::XText >  SwXAutoTextEntry::getText(void) throw( uno::RuntimeException )
1037*cdf0e10cSrcweir {
1038*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1039*cdf0e10cSrcweir 	uno::Reference< text::XText >  xRet =  (text::XText*)this;
1040*cdf0e10cSrcweir 	return xRet;
1041*cdf0e10cSrcweir }
1042*cdf0e10cSrcweir /*-- 21.12.98 12:42:35---------------------------------------------------
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1045*cdf0e10cSrcweir uno::Reference< text::XTextRange >  SwXAutoTextEntry::getStart(void) throw( uno::RuntimeException )
1046*cdf0e10cSrcweir {
1047*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1048*cdf0e10cSrcweir 	EnsureBodyText();
1049*cdf0e10cSrcweir 	return pBodyText->getStart();
1050*cdf0e10cSrcweir }
1051*cdf0e10cSrcweir /*-- 21.12.98 12:42:36---------------------------------------------------
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1054*cdf0e10cSrcweir uno::Reference< text::XTextRange >  SwXAutoTextEntry::getEnd(void) throw( uno::RuntimeException )
1055*cdf0e10cSrcweir {
1056*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1057*cdf0e10cSrcweir 	EnsureBodyText();
1058*cdf0e10cSrcweir 	return pBodyText->getEnd();
1059*cdf0e10cSrcweir }
1060*cdf0e10cSrcweir /*-- 21.12.98 12:42:36---------------------------------------------------
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1063*cdf0e10cSrcweir OUString SwXAutoTextEntry::getString(void) throw( uno::RuntimeException )
1064*cdf0e10cSrcweir {
1065*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1066*cdf0e10cSrcweir 	EnsureBodyText();
1067*cdf0e10cSrcweir 	return pBodyText->getString();
1068*cdf0e10cSrcweir }
1069*cdf0e10cSrcweir /*-- 21.12.98 12:42:36---------------------------------------------------
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1072*cdf0e10cSrcweir void SwXAutoTextEntry::setString(const OUString& aString) throw( uno::RuntimeException )
1073*cdf0e10cSrcweir {
1074*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1075*cdf0e10cSrcweir 	EnsureBodyText();
1076*cdf0e10cSrcweir 	pBodyText->setString( aString );
1077*cdf0e10cSrcweir }
1078*cdf0e10cSrcweir /* -----------------15.07.99 10:11-------------------
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir  --------------------------------------------------*/
1081*cdf0e10cSrcweir void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextRange)throw( uno::RuntimeException )
1082*cdf0e10cSrcweir {
1083*cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1084*cdf0e10cSrcweir 
1085*cdf0e10cSrcweir 	// ensure that any pending modifications are written
1086*cdf0e10cSrcweir 	// reason is that we're holding the _copy_ of the auto text, while the real auto text
1087*cdf0e10cSrcweir 	// is stored somewhere. And below, we're not working with our copy, but only tell the target
1088*cdf0e10cSrcweir 	// TextRange to work with the stored version.
1089*cdf0e10cSrcweir 	// #96380# - 2003-03-03 - fs@openoffice.org
1090*cdf0e10cSrcweir 	implFlushDocument( false );
1091*cdf0e10cSrcweir 		// TODO: think about if we should pass "true" here
1092*cdf0e10cSrcweir 		// The difference would be that when the next modification is made to this instance here, then
1093*cdf0e10cSrcweir 		// we would be forced to open the document again, instead of working on our current copy.
1094*cdf0e10cSrcweir 		// This means that we would reflect any changes which were done to the AutoText by foreign instances
1095*cdf0e10cSrcweir 		// in the meantime
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir 	uno::Reference<lang::XUnoTunnel> xTunnel( xTextRange, uno::UNO_QUERY);
1098*cdf0e10cSrcweir 	SwXTextRange* pRange = 0;
1099*cdf0e10cSrcweir 	OTextCursorHelper* pCursor = 0;
1100*cdf0e10cSrcweir 	SwXText *pText = 0;
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir 	if(xTunnel.is())
1103*cdf0e10cSrcweir 	{
1104*cdf0e10cSrcweir 		pRange = reinterpret_cast < SwXTextRange* >
1105*cdf0e10cSrcweir 				( xTunnel->getSomething( SwXTextRange::getUnoTunnelId() ) );
1106*cdf0e10cSrcweir 		pCursor = reinterpret_cast < OTextCursorHelper*>
1107*cdf0e10cSrcweir 				( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
1108*cdf0e10cSrcweir 		pText = reinterpret_cast < SwXText* >
1109*cdf0e10cSrcweir 				( xTunnel->getSomething( SwXText::getUnoTunnelId() ) );
1110*cdf0e10cSrcweir 	}
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir 	SwDoc* pDoc = 0;
1113*cdf0e10cSrcweir     if (pRange)
1114*cdf0e10cSrcweir 		pDoc = pRange->GetDoc();
1115*cdf0e10cSrcweir 	else if ( pCursor )
1116*cdf0e10cSrcweir 		pDoc = pCursor->GetDoc();
1117*cdf0e10cSrcweir 	else if ( pText && pText->GetDoc() )
1118*cdf0e10cSrcweir 	{
1119*cdf0e10cSrcweir 		xTunnel = uno::Reference < lang::XUnoTunnel > (pText->getStart(), uno::UNO_QUERY);
1120*cdf0e10cSrcweir 		if (xTunnel.is())
1121*cdf0e10cSrcweir 		{
1122*cdf0e10cSrcweir 			pCursor = reinterpret_cast < OTextCursorHelper* >
1123*cdf0e10cSrcweir 				( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
1124*cdf0e10cSrcweir 			if (pCursor)
1125*cdf0e10cSrcweir 				pDoc = pText->GetDoc();
1126*cdf0e10cSrcweir 		}
1127*cdf0e10cSrcweir 	}
1128*cdf0e10cSrcweir 
1129*cdf0e10cSrcweir 	if(!pDoc)
1130*cdf0e10cSrcweir 		throw uno::RuntimeException();
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir     SwPaM InsertPaM(pDoc->GetNodes());
1133*cdf0e10cSrcweir     if (pRange)
1134*cdf0e10cSrcweir     {
1135*cdf0e10cSrcweir         if (!pRange->GetPositions(InsertPaM))
1136*cdf0e10cSrcweir         {
1137*cdf0e10cSrcweir             throw uno::RuntimeException();
1138*cdf0e10cSrcweir         }
1139*cdf0e10cSrcweir     }
1140*cdf0e10cSrcweir     else
1141*cdf0e10cSrcweir     {
1142*cdf0e10cSrcweir         InsertPaM = *pCursor->GetPaM();
1143*cdf0e10cSrcweir     }
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir     ::std::auto_ptr<SwTextBlocks> pBlock(pGlossaries->GetGroupDoc(sGroupName));
1146*cdf0e10cSrcweir     const bool bResult = pBlock.get() && !pBlock->GetError()
1147*cdf0e10cSrcweir                     && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM);
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir 	if(!bResult)
1150*cdf0e10cSrcweir 		throw uno::RuntimeException();
1151*cdf0e10cSrcweir }
1152*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1155*cdf0e10cSrcweir OUString SwXAutoTextEntry::getImplementationName(void) throw( uno::RuntimeException )
1156*cdf0e10cSrcweir {
1157*cdf0e10cSrcweir 	return C2U("SwXAutoTextEntry");
1158*cdf0e10cSrcweir }
1159*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1162*cdf0e10cSrcweir sal_Bool SwXAutoTextEntry::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1163*cdf0e10cSrcweir {
1164*cdf0e10cSrcweir 	return C2U("com.sun.star.text.AutoTextEntry") == rServiceName;
1165*cdf0e10cSrcweir }
1166*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1169*cdf0e10cSrcweir uno::Sequence< OUString > SwXAutoTextEntry::getSupportedServiceNames(void) throw( uno::RuntimeException )
1170*cdf0e10cSrcweir {
1171*cdf0e10cSrcweir 	uno::Sequence< OUString > aRet(1);
1172*cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
1173*cdf0e10cSrcweir 	pArray[0] = C2U("com.sun.star.text.AutoTextEntry");
1174*cdf0e10cSrcweir 	return aRet;
1175*cdf0e10cSrcweir }
1176*cdf0e10cSrcweir /* -----------------------------06.04.00 11:11--------------------------------
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1179*cdf0e10cSrcweir uno::Reference< container::XNameReplace > SwXAutoTextEntry::getEvents()
1180*cdf0e10cSrcweir 	throw( uno::RuntimeException )
1181*cdf0e10cSrcweir {
1182*cdf0e10cSrcweir 	return new SwAutoTextEventDescriptor( *this );
1183*cdf0e10cSrcweir }
1184*cdf0e10cSrcweir /* -----------------------------30.01.01 18:40--------------------------------
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1187*cdf0e10cSrcweir const struct SvEventDescription aAutotextEvents[] =
1188*cdf0e10cSrcweir {
1189*cdf0e10cSrcweir 	{ SW_EVENT_START_INS_GLOSSARY,	"OnInsertStart" },
1190*cdf0e10cSrcweir 	{ SW_EVENT_END_INS_GLOSSARY,	"OnInsertDone" },
1191*cdf0e10cSrcweir 	{ 0, NULL }
1192*cdf0e10cSrcweir };
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir /* -----------------------------30.01.01 18:40--------------------------------
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1197*cdf0e10cSrcweir SwAutoTextEventDescriptor::SwAutoTextEventDescriptor(
1198*cdf0e10cSrcweir 	SwXAutoTextEntry& rAutoText ) :
1199*cdf0e10cSrcweir 		SvBaseEventDescriptor(aAutotextEvents),
1200*cdf0e10cSrcweir 		sSwAutoTextEventDescriptor(RTL_CONSTASCII_USTRINGPARAM(
1201*cdf0e10cSrcweir 			"SwAutoTextEventDescriptor")),
1202*cdf0e10cSrcweir 		rAutoTextEntry(rAutoText)
1203*cdf0e10cSrcweir {
1204*cdf0e10cSrcweir }
1205*cdf0e10cSrcweir /* -----------------------------30.01.01 18:40--------------------------------
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1208*cdf0e10cSrcweir SwAutoTextEventDescriptor::~SwAutoTextEventDescriptor()
1209*cdf0e10cSrcweir {
1210*cdf0e10cSrcweir }
1211*cdf0e10cSrcweir /* -----------------------------30.01.01 18:40--------------------------------
1212*cdf0e10cSrcweir 
1213*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1214*cdf0e10cSrcweir OUString SwAutoTextEventDescriptor::getImplementationName()
1215*cdf0e10cSrcweir 	throw( uno::RuntimeException )
1216*cdf0e10cSrcweir {
1217*cdf0e10cSrcweir 	return sSwAutoTextEventDescriptor;
1218*cdf0e10cSrcweir }
1219*cdf0e10cSrcweir /* -----------------------------30.01.01 18:40--------------------------------
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1222*cdf0e10cSrcweir void SwAutoTextEventDescriptor::replaceByName(
1223*cdf0e10cSrcweir 	const sal_uInt16 nEvent,
1224*cdf0e10cSrcweir 	const SvxMacro& rMacro)
1225*cdf0e10cSrcweir 			throw(
1226*cdf0e10cSrcweir 				lang::IllegalArgumentException,
1227*cdf0e10cSrcweir 				container::NoSuchElementException,
1228*cdf0e10cSrcweir 				lang::WrappedTargetException,
1229*cdf0e10cSrcweir 				uno::RuntimeException)
1230*cdf0e10cSrcweir {
1231*cdf0e10cSrcweir 	DBG_ASSERT( NULL != rAutoTextEntry.GetGlossaries(),
1232*cdf0e10cSrcweir 				"Strangely enough, the AutoText vanished!" );
1233*cdf0e10cSrcweir 	DBG_ASSERT( (nEvent == SW_EVENT_END_INS_GLOSSARY) ||
1234*cdf0e10cSrcweir 				(nEvent == SW_EVENT_START_INS_GLOSSARY) ,
1235*cdf0e10cSrcweir 				"Unknown event ID" );
1236*cdf0e10cSrcweir 
1237*cdf0e10cSrcweir 	const SwGlossaries* pGlossaries = rAutoTextEntry.GetGlossaries();
1238*cdf0e10cSrcweir 	SwTextBlocks* pBlocks =
1239*cdf0e10cSrcweir 		pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() );
1240*cdf0e10cSrcweir 	DBG_ASSERT( NULL != pBlocks,
1241*cdf0e10cSrcweir 			    "can't get autotext group; SwAutoTextEntry has illegal name?");
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir     if( pBlocks && !pBlocks->GetError())
1244*cdf0e10cSrcweir 	{
1245*cdf0e10cSrcweir 		sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
1246*cdf0e10cSrcweir 		if( nIndex != USHRT_MAX )
1247*cdf0e10cSrcweir 		{
1248*cdf0e10cSrcweir 			SvxMacroTableDtor aMacroTable;
1249*cdf0e10cSrcweir 			if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
1250*cdf0e10cSrcweir 			{
1251*cdf0e10cSrcweir 				SvxMacro* pNewMacro = new SvxMacro(rMacro);
1252*cdf0e10cSrcweir 				aMacroTable.Replace( nEvent, pNewMacro );
1253*cdf0e10cSrcweir 				pBlocks->SetMacroTable( nIndex, aMacroTable );
1254*cdf0e10cSrcweir 			}
1255*cdf0e10cSrcweir 		}
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir 		delete pBlocks;
1258*cdf0e10cSrcweir 	}
1259*cdf0e10cSrcweir 	// else: ignore
1260*cdf0e10cSrcweir }
1261*cdf0e10cSrcweir /* -----------------------------30.01.01 18:40--------------------------------
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1264*cdf0e10cSrcweir void SwAutoTextEventDescriptor::getByName(
1265*cdf0e10cSrcweir 	SvxMacro& rMacro,
1266*cdf0e10cSrcweir 	const sal_uInt16 nEvent )
1267*cdf0e10cSrcweir 			throw(
1268*cdf0e10cSrcweir 				container::NoSuchElementException,
1269*cdf0e10cSrcweir 				lang::WrappedTargetException,
1270*cdf0e10cSrcweir 				uno::RuntimeException)
1271*cdf0e10cSrcweir {
1272*cdf0e10cSrcweir 	DBG_ASSERT( NULL != rAutoTextEntry.GetGlossaries(), "no AutoText" );
1273*cdf0e10cSrcweir 	DBG_ASSERT( (nEvent == SW_EVENT_END_INS_GLOSSARY) ||
1274*cdf0e10cSrcweir 				(nEvent == SW_EVENT_START_INS_GLOSSARY) ,
1275*cdf0e10cSrcweir 				"Unknown event ID" );
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir 	const SwGlossaries* pGlossaries = rAutoTextEntry.GetGlossaries();
1278*cdf0e10cSrcweir 	SwTextBlocks* pBlocks =
1279*cdf0e10cSrcweir 		pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() );
1280*cdf0e10cSrcweir 	DBG_ASSERT( NULL != pBlocks,
1281*cdf0e10cSrcweir 			    "can't get autotext group; SwAutoTextEntry has illegal name?");
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir 	// return empty macro, unless macro is found
1284*cdf0e10cSrcweir     OUString sEmptyStr;
1285*cdf0e10cSrcweir     SvxMacro aEmptyMacro(sEmptyStr, sEmptyStr);
1286*cdf0e10cSrcweir 	rMacro = aEmptyMacro;
1287*cdf0e10cSrcweir 
1288*cdf0e10cSrcweir     if ( pBlocks &&  !pBlocks->GetError())
1289*cdf0e10cSrcweir 	{
1290*cdf0e10cSrcweir 		sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
1291*cdf0e10cSrcweir 		if( nIndex != USHRT_MAX )
1292*cdf0e10cSrcweir 		{
1293*cdf0e10cSrcweir 			SvxMacroTableDtor aMacroTable;
1294*cdf0e10cSrcweir 			if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
1295*cdf0e10cSrcweir 			{
1296*cdf0e10cSrcweir 				SvxMacro *pMacro = aMacroTable.Get( nEvent );
1297*cdf0e10cSrcweir 				if( pMacro )
1298*cdf0e10cSrcweir 					rMacro = *pMacro;
1299*cdf0e10cSrcweir 			}
1300*cdf0e10cSrcweir 		}
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir 		delete pBlocks;
1303*cdf0e10cSrcweir 	}
1304*cdf0e10cSrcweir }
1305*cdf0e10cSrcweir 
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir 
1308*cdf0e10cSrcweir 
1309