xref: /trunk/main/sw/source/ui/inc/glosdoc.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _GLOSDOC_HXX
28 #define _GLOSDOC_HXX
29 
30 #include <tools/string.hxx>
31 #include <svl/svarray.hxx>
32 #include <com/sun/star/text/XAutoTextGroup.hpp>
33 
34 class SwTextBlocks;
35 class SvStrings;
36 class SwDocShell;
37 
38 #ifndef SW_DECL_SWDOCSHELL_DEFINED
39 #define SW_DECL_SWDOCSHELL_DEFINED
40 #include <tools/ref.hxx>
41 SV_DECL_REF( SwDocShell )
42 #endif
43 #include <cppuhelper/weakref.hxx>
44 
45 #ifndef INCLUDED_VECTOR
46 #include <vector>
47 #define INCLUDED_VECTOR
48 #endif
49 #include "swdllapi.h"
50 
51 typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextGroup > AutoTextGroupRef;
52 typedef ::std::vector< AutoTextGroupRef > UnoAutoTextGroups;
53 
54 typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextEntry > AutoTextEntryRef;
55 typedef ::std::vector< AutoTextEntryRef > UnoAutoTextEntries;
56 
57 #define GLOS_DELIM (sal_Unicode)'*'
58 
59 // CLASS -----------------------------------------------------------------
60 class SW_DLLPUBLIC SwGlossaries
61 {
62 	UnoAutoTextGroups       m_aGlossaryGroups;
63 	UnoAutoTextEntries      m_aGlossaryEntries;
64 
65     String                  m_aPath;
66     String                  m_sOldErrPath;
67     String                  m_sErrPath;
68     SvStrings               *m_pPathArr;
69     SvStrings               *m_pGlosArr;
70     sal_Bool                    m_bError;
71 
72 	SW_DLLPRIVATE SwTextBlocks*	GetGlosDoc(const String &rName, sal_Bool bCreate = sal_True) const;
73 	SW_DLLPRIVATE SvStrings	    *GetNameList();
74 
75 	// implementation in unoatxt.cxx
76 	SW_DLLPRIVATE void RemoveFileFromList( const String& rGroup );
77 	SW_DLLPRIVATE void InvalidateUNOOjects();
78 
79 public:
80 	SwGlossaries();
81 	~SwGlossaries();
82 
83 	/** returns the cached AutoTextGroup (if any) for the given group name
84 
85 		@precond
86 			If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
87 
88 		@param _rGroupName
89 			the name of the glossaries group
90 		@param _bCreate
91 			if <TRUE/>, the group is created if it does not yet exist
92 	*/
93 	::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >
94 							GetAutoTextGroup(
95 								const ::rtl::OUString& _rGroupName,
96 								bool _bCreate = false
97 							);
98 
99 	/** returns the cached AutoTextEntry (if any) for the given group/with the given name
100 
101 		@precond
102 			If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
103 
104 		@param _rGroupAccessName
105 			the name to access the group
106 		@param _rGroupName
107 			the name of the glossaries group, as to be passed to the entry
108 		@param _rEntryName
109 			the name of the auto text entry
110 		@param _bCreate
111 			if <TRUE/>, the entry is created if it does not yet exist
112 	*/
113 	::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >
114 							GetAutoTextEntry(
115 								const String& _rCompleteGroupName,
116 								const ::rtl::OUString& _rGroupName,
117 								const ::rtl::OUString& _rEntryName,
118 								bool _bCreate = false
119 							);
120 
121 	sal_uInt16					GetGroupCnt();
122 	String					GetGroupName(sal_uInt16	);
123 	String					GetGroupTitle( const String& rGroupName );
124 
125 	sal_Bool 			FindGroupName(String & rGroup);
126 
127 	SwTextBlocks*	GetGroupDoc(const String &rName,
128 								sal_Bool bCreate = sal_False) const;
129 	SwTextBlocks*	GetDefGroupDoc() const {return GetGroupDoc(GetDefName());}
130 	void			PutGroupDoc(SwTextBlocks *pBlock);
131 	static String 	GetDefName();
132 	static String	GetExtension();
133 
134 	String 			GetCompleteGroupName( const ::rtl::OUString& GroupName );
135 
136 	sal_Bool			NewGroupDoc(String &rGroupName, const String& rTitle);
137 	sal_Bool			RenameGroupDoc(const String& sOldGroup, String& sNewGroup, const String& rNewTitle);
138 	sal_Bool			DelGroupDoc(const String &);
139 	SwDocShellRef	EditGroupDoc(const String &rGrpName, const String& rShortName, sal_Bool bShow = sal_True );
140 	void 			SaveGroupDoc(const String &rGrpName, const String& rLongName );
141 	void			UpdateGlosPath(sal_Bool bFull);
142 	void			ShowError();
143     inline sal_uLong    IsGlosPathErr() { return m_bError; }
144     const SvStrings*    GetPathArray() const {return m_pPathArr;}
145 };
146 
147 
148 #endif // _GLOSDOC_HXX
149