xref: /aoo42x/main/sw/source/ui/inc/glosdoc.hxx (revision cdf0e10c)
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 #ifndef _GLOSDOC_HXX
28*cdf0e10cSrcweir #define _GLOSDOC_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <tools/string.hxx>
31*cdf0e10cSrcweir #include <svl/svarray.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/text/XAutoTextGroup.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir class SwTextBlocks;
35*cdf0e10cSrcweir class SvStrings;
36*cdf0e10cSrcweir class SwDocShell;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #ifndef SW_DECL_SWDOCSHELL_DEFINED
39*cdf0e10cSrcweir #define SW_DECL_SWDOCSHELL_DEFINED
40*cdf0e10cSrcweir #include <tools/ref.hxx>
41*cdf0e10cSrcweir SV_DECL_REF( SwDocShell )
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #ifndef INCLUDED_VECTOR
46*cdf0e10cSrcweir #include <vector>
47*cdf0e10cSrcweir #define INCLUDED_VECTOR
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir #include "swdllapi.h"
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextGroup > AutoTextGroupRef;
52*cdf0e10cSrcweir typedef ::std::vector< AutoTextGroupRef > UnoAutoTextGroups;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextEntry > AutoTextEntryRef;
55*cdf0e10cSrcweir typedef ::std::vector< AutoTextEntryRef > UnoAutoTextEntries;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #define GLOS_DELIM (sal_Unicode)'*'
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // CLASS -----------------------------------------------------------------
60*cdf0e10cSrcweir class SW_DLLPUBLIC SwGlossaries
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir 	UnoAutoTextGroups       m_aGlossaryGroups;
63*cdf0e10cSrcweir 	UnoAutoTextEntries      m_aGlossaryEntries;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     String                  m_aPath;
66*cdf0e10cSrcweir     String                  m_sOldErrPath;
67*cdf0e10cSrcweir     String                  m_sErrPath;
68*cdf0e10cSrcweir     SvStrings               *m_pPathArr;
69*cdf0e10cSrcweir     SvStrings               *m_pGlosArr;
70*cdf0e10cSrcweir     sal_Bool                    m_bError;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 	SW_DLLPRIVATE SwTextBlocks*	GetGlosDoc(const String &rName, sal_Bool bCreate = sal_True) const;
73*cdf0e10cSrcweir 	SW_DLLPRIVATE SvStrings	    *GetNameList();
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	// implementation in unoatxt.cxx
76*cdf0e10cSrcweir 	SW_DLLPRIVATE void RemoveFileFromList( const String& rGroup );
77*cdf0e10cSrcweir 	SW_DLLPRIVATE void InvalidateUNOOjects();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir public:
80*cdf0e10cSrcweir 	SwGlossaries();
81*cdf0e10cSrcweir 	~SwGlossaries();
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	/** returns the cached AutoTextGroup (if any) for the given group name
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 		@precond
86*cdf0e10cSrcweir 			If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 		@param _rGroupName
89*cdf0e10cSrcweir 			the name of the glossaries group
90*cdf0e10cSrcweir 		@param _bCreate
91*cdf0e10cSrcweir 			if <TRUE/>, the group is created if it does not yet exist
92*cdf0e10cSrcweir 	*/
93*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >
94*cdf0e10cSrcweir 							GetAutoTextGroup(
95*cdf0e10cSrcweir 								const ::rtl::OUString& _rGroupName,
96*cdf0e10cSrcweir 								bool _bCreate = false
97*cdf0e10cSrcweir 							);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	/** returns the cached AutoTextEntry (if any) for the given group/with the given name
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 		@precond
102*cdf0e10cSrcweir 			If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		@param _rGroupAccessName
105*cdf0e10cSrcweir 			the name to access the group
106*cdf0e10cSrcweir 		@param _rGroupName
107*cdf0e10cSrcweir 			the name of the glossaries group, as to be passed to the entry
108*cdf0e10cSrcweir 		@param _rEntryName
109*cdf0e10cSrcweir 			the name of the auto text entry
110*cdf0e10cSrcweir 		@param _bCreate
111*cdf0e10cSrcweir 			if <TRUE/>, the entry is created if it does not yet exist
112*cdf0e10cSrcweir 	*/
113*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >
114*cdf0e10cSrcweir 							GetAutoTextEntry(
115*cdf0e10cSrcweir 								const String& _rCompleteGroupName,
116*cdf0e10cSrcweir 								const ::rtl::OUString& _rGroupName,
117*cdf0e10cSrcweir 								const ::rtl::OUString& _rEntryName,
118*cdf0e10cSrcweir 								bool _bCreate = false
119*cdf0e10cSrcweir 							);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	sal_uInt16					GetGroupCnt();
122*cdf0e10cSrcweir 	String					GetGroupName(sal_uInt16	);
123*cdf0e10cSrcweir 	String					GetGroupTitle( const String& rGroupName );
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	sal_Bool 			FindGroupName(String & rGroup);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	SwTextBlocks*	GetGroupDoc(const String &rName,
128*cdf0e10cSrcweir 								sal_Bool bCreate = sal_False) const;
129*cdf0e10cSrcweir 	SwTextBlocks*	GetDefGroupDoc() const {return GetGroupDoc(GetDefName());}
130*cdf0e10cSrcweir 	void			PutGroupDoc(SwTextBlocks *pBlock);
131*cdf0e10cSrcweir 	static String 	GetDefName();
132*cdf0e10cSrcweir 	static String	GetExtension();
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	String 			GetCompleteGroupName( const ::rtl::OUString& GroupName );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	sal_Bool			NewGroupDoc(String &rGroupName, const String& rTitle);
137*cdf0e10cSrcweir 	sal_Bool			RenameGroupDoc(const String& sOldGroup, String& sNewGroup, const String& rNewTitle);
138*cdf0e10cSrcweir 	sal_Bool			DelGroupDoc(const String &);
139*cdf0e10cSrcweir 	SwDocShellRef	EditGroupDoc(const String &rGrpName, const String& rShortName, sal_Bool bShow = sal_True );
140*cdf0e10cSrcweir 	void 			SaveGroupDoc(const String &rGrpName, const String& rLongName );
141*cdf0e10cSrcweir 	void			UpdateGlosPath(sal_Bool bFull);
142*cdf0e10cSrcweir 	void			ShowError();
143*cdf0e10cSrcweir     inline sal_uLong    IsGlosPathErr() { return m_bError; }
144*cdf0e10cSrcweir     const SvStrings*    GetPathArray() const {return m_pPathArr;}
145*cdf0e10cSrcweir };
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir #endif // _GLOSDOC_HXX
149