xref: /aoo4110/main/sw/source/ui/utlui/initui.cxx (revision b1cdbd2c)
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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <unotools/localedatawrapper.hxx>
29 #include <viewsh.hxx>
30 #include <initui.hxx>
31 #include <edtwin.hxx>
32 #include <shellres.hxx>
33 #include <fldbas.hxx>
34 #include <glosdoc.hxx>
35 #include <gloslst.hxx>
36 
37 #ifndef _UTLUI_HRC
38 #include <utlui.hrc>
39 #endif
40 #ifndef _INITUI_HRC
41 #include <initui.hrc>
42 #endif
43 #ifndef _COMCORE_HRC
44 #include <comcore.hrc>
45 #endif
46 #include <authfld.hxx>
47 #ifndef _DBMGR_HXX
48 #include <dbmgr.hxx>
49 #endif
50 #include <unotools/syslocale.hxx>
51 
52 #include <unomid.h>
53 
54 /*--------------------------------------------------------------------
55 	Beschreibung:	globale Pointer
56  --------------------------------------------------------------------*/
57 
58 SwGlossaries* 		pGlossaries = 0;
59 
60 // Liefert alle benoetigten Pfade. Wird durch UI initialisiert
61 SwGlossaryList*		pGlossaryList = 0;
62 
63 String* pOldGrfCat = 0;
64 String* pOldTabCat = 0;
65 String* pOldFrmCat = 0;
66 String* pOldDrwCat = 0;
67 String* pCurrGlosGroup = 0;
68 
GetOldGrfCat()69 String* GetOldGrfCat()
70 {
71 	return pOldGrfCat;
72 }
GetOldTabCat()73 String* GetOldTabCat()
74 {
75 	return pOldTabCat;
76 }
GetOldFrmCat()77 String* GetOldFrmCat()
78 {
79 	return pOldFrmCat;
80 }
GetOldDrwCat()81 String* GetOldDrwCat()
82 {
83 	return pOldDrwCat;
84 }
GetCurrGlosGroup()85 String* GetCurrGlosGroup()
86 {
87 	return pCurrGlosGroup;
88 }
SetCurrGlosGroup(String * pStr)89 void SetCurrGlosGroup(String* pStr)
90 {
91 	pCurrGlosGroup = pStr;
92 }
93 
94 SvStringsDtor* pDBNameList = 0;
95 
96 SvStringsDtor* 	pAuthFieldNameList = 0;
97 SvStringsDtor* 	pAuthFieldTypeList = 0;
98 
99 /*--------------------------------------------------------------------
100 	Beschreibung:	UI beenden
101  --------------------------------------------------------------------*/
102 
_FinitUI()103 void _FinitUI()
104 {
105     SwNewDBMgr::RemoveDbtoolsClient();
106     delete ViewShell::GetShellRes();
107 	ViewShell::SetShellRes( 0 );
108 
109 	SwEditWin::_FinitStaticData();
110 
111 	DELETEZ(pGlossaries);
112 
113 	delete SwFieldType::pFldNames;
114 
115 	delete pOldGrfCat;
116 	delete pOldTabCat;
117 	delete pOldFrmCat;
118 	delete pOldDrwCat;
119 	delete pCurrGlosGroup;
120 	delete pDBNameList;
121 	delete pGlossaryList;
122 	delete pAuthFieldNameList;
123 	delete pAuthFieldTypeList;
124 
125 
126 }
127 /*--------------------------------------------------------------------
128 	Beschreibung:	Initialisierung
129  --------------------------------------------------------------------*/
130 
131 
_InitUI()132 void _InitUI()
133 {
134 	// ShellResource gibt der CORE die Moeglichkeit mit Resourcen zu arbeiten
135 	ViewShell::SetShellRes( new ShellResource );
136 	pDBNameList = new SvStringsDtor( 5, 5 );
137 	SwEditWin::_InitStaticData();
138 }
139 
140 
ShellResource()141 ShellResource::ShellResource()
142 	: Resource( SW_RES(RID_SW_SHELLRES) ),
143     aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR ) ),
144 	aPostItPage( SW_RES( STR_POSTIT_PAGE ) ),
145 	aPostItLine( SW_RES( STR_POSTIT_LINE ) ),
146 
147     aCalc_Syntax( SW_RES( STR_CALC_SYNTAX ) ),
148 	aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ),
149 	aCalc_Brack( SW_RES( STR_CALC_BRACK ) ),
150 	aCalc_Pow( SW_RES( STR_CALC_POW ) ),
151 	aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ),
152 	aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ),
153 	aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ),
154 	aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ),
155 	aCalc_Error( SW_RES( STR_CALC_ERROR ) ),
156 
157     aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP ) ),
158 	aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN ) ),
159     // --> OD 2007-09-13 #i81002#
160     aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND ) ),
161     // <--
162 	aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT ) ),
163 	aStrNone( SW_RES( STR_TEMPLATE_NONE )),
164 	aFixedStr( SW_RES( STR_FIELD_FIXED )),
165     sDurationFormat( SW_RES( STR_DURATION_FORMAT )),
166 
167     aTOXIndexName(          SW_RES(STR_TOI)),
168 	aTOXUserName(			SW_RES(STR_TOU)),
169 	aTOXContentName(		SW_RES(STR_TOC)),
170 	aTOXIllustrationsName(	SW_RES(STR_TOX_ILL)),
171 	aTOXObjectsName(		SW_RES(STR_TOX_OBJ)),
172 	aTOXTablesName(			SW_RES(STR_TOX_TBL)),
173 	aTOXAuthoritiesName(	SW_RES(STR_TOX_AUTH)),
174     aHyperlinkClick( SW_RES( STR_HYPERLINK_CLICK)),
175     pAutoFmtNameLst(0),
176 	sPageDescFirstName(		SW_RES(STR_PAGEDESC_FIRSTNAME)),
177 	sPageDescFollowName(	SW_RES(STR_PAGEDESC_FOLLOWNAME)),
178     sPageDescName(          SW_RES(STR_PAGEDESC_NAME))
179 {
180 	const sal_uInt16 nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN;
181 
182     KeyCode aCode( KEY_SPACE );
183     KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
184     String aModStr( aModifiedCode.GetName() );
185     aModStr.SearchAndReplace( aCode.GetName(), String() );
186     aModStr.SearchAndReplaceAllAscii( "+", String() );
187     aHyperlinkClick.SearchAndReplaceAllAscii( "%s", aModStr );
188 
189 	for(sal_uInt16 i = 0; i < nCount; ++i)
190 	{
191 		String* pNew = new SW_RESSTR(FLD_DOCINFO_BEGIN + i);
192 		aDocInfoLst.Insert(pNew, aDocInfoLst.Count());
193 	}
194 
195 	FreeResource();
196 }
197 
~ShellResource()198 ShellResource::~ShellResource()
199 {
200 	if( pAutoFmtNameLst )
201 		delete pAutoFmtNameLst, pAutoFmtNameLst = 0;
202 }
203 
GetPageDescName(sal_uInt16 nNo,sal_Bool bIsFirst,sal_Bool bFollow)204 String ShellResource::GetPageDescName( sal_uInt16 nNo, sal_Bool bIsFirst, sal_Bool bFollow )
205 {
206 	String sRet( bIsFirst ? sPageDescFirstName
207 						  : bFollow ? sPageDescFollowName
208 						  			: sPageDescName );
209 	sRet.SearchAndReplaceAscii( "$(ARG1)", String::CreateFromInt32( nNo ));
210 	return sRet;
211 }
212 
213 
GetGlossaries()214 SwGlossaries* GetGlossaries()
215 {
216 	if (!pGlossaries)
217 		pGlossaries = new SwGlossaries;
218 	return (pGlossaries);
219 }
220 
HasGlossaryList()221 sal_Bool HasGlossaryList()
222 {
223 	return pGlossaryList != 0;
224 }
225 
GetGlossaryList()226 SwGlossaryList* GetGlossaryList()
227 {
228 	if(!pGlossaryList)
229 		pGlossaryList = new SwGlossaryList();
230 
231 	return pGlossaryList;
232 }
233 
234 struct ImpAutoFmtNameListLoader : public Resource
235 {
236 	ImpAutoFmtNameListLoader( SvStringsDtor& rLst );
237 };
238 
_GetAutoFmtNameLst() const239 void ShellResource::_GetAutoFmtNameLst() const
240 {
241 	SvStringsDtor** ppLst = (SvStringsDtor**)&pAutoFmtNameLst;
242 	*ppLst = new SvStringsDtor( STR_AUTOFMTREDL_END );
243 	ImpAutoFmtNameListLoader aTmp( **ppLst );
244 }
245 
ImpAutoFmtNameListLoader(SvStringsDtor & rLst)246 ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( SvStringsDtor& rLst )
247 	: Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) )
248 {
249 	for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n )
250 	{
251 		String* p = new String( ResId( n + 1, *pSwResMgr) );
252 		if(STR_AUTOFMTREDL_TYPO == n)
253 		{
254 #ifdef WNT
255 			//fuer Windows Sonderbehandlung, da MS hier ein paar Zeichen im Dialogfont vergessen hat
256 			p->SearchAndReplace(C2S("%1"), C2S(",,"));
257 			p->SearchAndReplace(C2S("%2"), C2S("''"));
258 #else
259             const SvtSysLocale aSysLocale;
260             const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
261 			//unter richtigen Betriebssystemen funktioniert es auch so
262 			p->SearchAndReplace(C2S("%1"), rLclD.getDoubleQuotationMarkStart());
263 			p->SearchAndReplace(C2S("%2"), rLclD.getDoubleQuotationMarkEnd());
264 #endif
265 		}
266 		rLst.Insert( p, n );
267 	}
268 	FreeResource();
269 }
270 /* -----------------16.09.99 12:28-------------------
271 
272  --------------------------------------------------*/
GetAuthFieldName(ToxAuthorityField eType)273 const String& 	SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
274 {
275 	if(!pAuthFieldNameList)
276 	{
277 		pAuthFieldNameList = new SvStringsDtor(AUTH_FIELD_END, 1);
278 		for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++)
279 		{
280 			String*  pTmp = new String(SW_RES(STR_AUTH_FIELD_START + i));
281 			pAuthFieldNameList->Insert(pTmp, pAuthFieldNameList->Count());
282 		}
283 	}
284     return *pAuthFieldNameList->GetObject( static_cast< sal_uInt16 >(eType) );
285 }
286 /* -----------------16.09.99 12:29-------------------
287 
288  --------------------------------------------------*/
GetAuthTypeName(ToxAuthorityType eType)289 const String& 	SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
290 {
291 	if(!pAuthFieldTypeList)
292 	{
293 		pAuthFieldTypeList = new SvStringsDtor(AUTH_TYPE_END, 1);
294 		for(sal_uInt16 i = 0; i < AUTH_TYPE_END; i++)
295 			pAuthFieldTypeList->Insert(
296 				new String(SW_RES(STR_AUTH_TYPE_START + i)),
297 									pAuthFieldTypeList->Count());
298 	}
299     return *pAuthFieldTypeList->GetObject( static_cast< sal_uInt16 >(eType) );
300 }
301 
302 
303 
304