xref: /aoo42x/main/sw/source/ui/inc/glosdoc.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _GLOSDOC_HXX
24 #define _GLOSDOC_HXX
25 
26 #include <tools/string.hxx>
27 #include <svl/svarray.hxx>
28 #include <com/sun/star/text/XAutoTextGroup.hpp>
29 
30 class SwTextBlocks;
31 class SvStrings;
32 class SwDocShell;
33 
34 #ifndef SW_DECL_SWDOCSHELL_DEFINED
35 #define SW_DECL_SWDOCSHELL_DEFINED
36 #include <tools/ref.hxx>
37 SV_DECL_REF( SwDocShell )
38 #endif
39 #include <cppuhelper/weakref.hxx>
40 
41 #ifndef INCLUDED_VECTOR
42 #include <vector>
43 #define INCLUDED_VECTOR
44 #endif
45 #include "swdllapi.h"
46 
47 typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextGroup > AutoTextGroupRef;
48 typedef ::std::vector< AutoTextGroupRef > UnoAutoTextGroups;
49 
50 typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextEntry > AutoTextEntryRef;
51 typedef ::std::vector< AutoTextEntryRef > UnoAutoTextEntries;
52 
53 #define GLOS_DELIM (sal_Unicode)'*'
54 
55 // CLASS -----------------------------------------------------------------
56 class SW_DLLPUBLIC SwGlossaries
57 {
58 	UnoAutoTextGroups       m_aGlossaryGroups;
59 	UnoAutoTextEntries      m_aGlossaryEntries;
60 
61     String                  m_aPath;
62     String                  m_sOldErrPath;
63     String                  m_sErrPath;
64     SvStrings               *m_pPathArr;
65     SvStrings               *m_pGlosArr;
66     sal_Bool                    m_bError;
67 
68 	SW_DLLPRIVATE SwTextBlocks*	GetGlosDoc(const String &rName, sal_Bool bCreate = sal_True) const;
69 	SW_DLLPRIVATE SvStrings	    *GetNameList();
70 
71 	// implementation in unoatxt.cxx
72 	SW_DLLPRIVATE void RemoveFileFromList( const String& rGroup );
73 	SW_DLLPRIVATE void InvalidateUNOOjects();
74 
75 public:
76 	SwGlossaries();
77 	~SwGlossaries();
78 
79 	/** returns the cached AutoTextGroup (if any) for the given group name
80 
81 		@precond
82 			If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
83 
84 		@param _rGroupName
85 			the name of the glossaries group
86 		@param _bCreate
87 			if <TRUE/>, the group is created if it does not yet exist
88 	*/
89 	::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >
90 							GetAutoTextGroup(
91 								const ::rtl::OUString& _rGroupName,
92 								bool _bCreate = false
93 							);
94 
95 	/** returns the cached AutoTextEntry (if any) for the given group/with the given name
96 
97 		@precond
98 			If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.
99 
100 		@param _rGroupAccessName
101 			the name to access the group
102 		@param _rGroupName
103 			the name of the glossaries group, as to be passed to the entry
104 		@param _rEntryName
105 			the name of the auto text entry
106 		@param _bCreate
107 			if <TRUE/>, the entry is created if it does not yet exist
108 	*/
109 	::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >
110 							GetAutoTextEntry(
111 								const String& _rCompleteGroupName,
112 								const ::rtl::OUString& _rGroupName,
113 								const ::rtl::OUString& _rEntryName,
114 								bool _bCreate = false
115 							);
116 
117 	sal_uInt16					GetGroupCnt();
118 	String					GetGroupName(sal_uInt16	);
119 	String					GetGroupTitle( const String& rGroupName );
120 
121 	sal_Bool 			FindGroupName(String & rGroup);
122 
123 	SwTextBlocks*	GetGroupDoc(const String &rName,
124 								sal_Bool bCreate = sal_False) const;
GetDefGroupDoc() const125 	SwTextBlocks*	GetDefGroupDoc() const {return GetGroupDoc(GetDefName());}
126 	void			PutGroupDoc(SwTextBlocks *pBlock);
127 	static String 	GetDefName();
128 	static String	GetExtension();
129 
130 	String 			GetCompleteGroupName( const ::rtl::OUString& GroupName );
131 
132 	sal_Bool			NewGroupDoc(String &rGroupName, const String& rTitle);
133 	sal_Bool			RenameGroupDoc(const String& sOldGroup, String& sNewGroup, const String& rNewTitle);
134 	sal_Bool			DelGroupDoc(const String &);
135 	SwDocShellRef	EditGroupDoc(const String &rGrpName, const String& rShortName, sal_Bool bShow = sal_True );
136 	void 			SaveGroupDoc(const String &rGrpName, const String& rLongName );
137 	void			UpdateGlosPath(sal_Bool bFull);
138 	void			ShowError();
IsGlosPathErr()139     inline sal_uLong    IsGlosPathErr() { return m_bError; }
GetPathArray() const140     const SvStrings*    GetPathArray() const {return m_pPathArr;}
141 };
142 
143 
144 #endif // _GLOSDOC_HXX
145