update dev300-m58
[ooovba.git] / sw / source / ui / utlui / initui.cxx
blob9f90efe028401392a7bcfef5f8e3c633aab5c7da
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: initui.cxx,v $
10 * $Revision: 1.18 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <unotools/localedatawrapper.hxx>
36 #include <viewsh.hxx>
37 #include <initui.hxx>
38 #include <edtwin.hxx>
39 #include <shellres.hxx>
40 #include <fldbas.hxx>
41 #include <glosdoc.hxx>
42 #include <gloslst.hxx>
44 #ifndef _UTLUI_HRC
45 #include <utlui.hrc>
46 #endif
47 #ifndef _INITUI_HRC
48 #include <initui.hrc>
49 #endif
50 #ifndef _COMCORE_HRC
51 #include <comcore.hrc>
52 #endif
53 #include <authfld.hxx>
54 #ifndef _DBMGR_HXX
55 #include <dbmgr.hxx>
56 #endif
57 #include <svtools/syslocale.hxx>
59 #include <unomid.h>
61 /*--------------------------------------------------------------------
62 Beschreibung: globale Pointer
63 --------------------------------------------------------------------*/
65 SwGlossaries* pGlossaries = 0;
67 // Liefert alle benoetigten Pfade. Wird durch UI initialisiert
68 SwGlossaryList* pGlossaryList = 0;
70 String* pOldGrfCat = 0;
71 String* pOldTabCat = 0;
72 String* pOldFrmCat = 0;
73 String* pOldDrwCat = 0;
74 String* pCurrGlosGroup = 0;
76 String* GetOldGrfCat()
78 return pOldGrfCat;
80 String* GetOldTabCat()
82 return pOldTabCat;
84 String* GetOldFrmCat()
86 return pOldFrmCat;
88 String* GetOldDrwCat()
90 return pOldDrwCat;
92 String* GetCurrGlosGroup()
94 return pCurrGlosGroup;
96 void SetCurrGlosGroup(String* pStr)
98 pCurrGlosGroup = pStr;
101 SvStringsDtor* pDBNameList = 0;
103 SvStringsDtor* pAuthFieldNameList = 0;
104 SvStringsDtor* pAuthFieldTypeList = 0;
106 /*--------------------------------------------------------------------
107 Beschreibung: UI beenden
108 --------------------------------------------------------------------*/
110 void _FinitUI()
112 SwNewDBMgr::RemoveDbtoolsClient();
113 delete ViewShell::GetShellRes();
114 ViewShell::SetShellRes( 0 );
116 SwEditWin::_FinitStaticData();
118 DELETEZ(pGlossaries);
120 delete SwFieldType::pFldNames;
122 delete pOldGrfCat;
123 delete pOldTabCat;
124 delete pOldFrmCat;
125 delete pOldDrwCat;
126 delete pCurrGlosGroup;
127 delete pDBNameList;
128 delete pGlossaryList;
129 delete pAuthFieldNameList;
130 delete pAuthFieldTypeList;
134 /*--------------------------------------------------------------------
135 Beschreibung: Initialisierung
136 --------------------------------------------------------------------*/
139 void _InitUI()
141 // ShellResource gibt der CORE die Moeglichkeit mit Resourcen zu arbeiten
142 ViewShell::SetShellRes( new ShellResource );
143 pDBNameList = new SvStringsDtor( 5, 5 );
144 SwEditWin::_InitStaticData();
148 ShellResource::ShellResource()
149 : Resource( SW_RES(RID_SW_SHELLRES) ),
150 aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR ) ),
151 aPostItPage( SW_RES( STR_POSTIT_PAGE ) ),
152 aPostItLine( SW_RES( STR_POSTIT_LINE ) ),
154 aCalc_Syntax( SW_RES( STR_CALC_SYNTAX ) ),
155 aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ),
156 aCalc_Brack( SW_RES( STR_CALC_BRACK ) ),
157 aCalc_Pow( SW_RES( STR_CALC_POW ) ),
158 aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ),
159 aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ),
160 aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ),
161 aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ),
162 aCalc_Error( SW_RES( STR_CALC_ERROR ) ),
164 aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP ) ),
165 aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN ) ),
166 // --> OD 2007-09-13 #i81002#
167 aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND ) ),
168 // <--
169 aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT ) ),
170 aStrNone( SW_RES( STR_TEMPLATE_NONE )),
171 aFixedStr( SW_RES( STR_FIELD_FIXED )),
173 aTOXIndexName( SW_RES(STR_TOI)),
174 aTOXUserName( SW_RES(STR_TOU)),
175 aTOXContentName( SW_RES(STR_TOC)),
176 aTOXIllustrationsName( SW_RES(STR_TOX_ILL)),
177 aTOXObjectsName( SW_RES(STR_TOX_OBJ)),
178 aTOXTablesName( SW_RES(STR_TOX_TBL)),
179 aTOXAuthoritiesName( SW_RES(STR_TOX_AUTH)),
180 aHyperlinkClick( SW_RES( STR_HYPERLINK_CLICK)),
181 pAutoFmtNameLst(0),
182 sPageDescFirstName( SW_RES(STR_PAGEDESC_FIRSTNAME)),
183 sPageDescFollowName( SW_RES(STR_PAGEDESC_FOLLOWNAME)),
184 sPageDescName( SW_RES(STR_PAGEDESC_NAME))
186 const USHORT nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN;
188 KeyCode aCode( KEY_SPACE );
189 KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
190 String aModStr( aModifiedCode.GetName() );
191 aModStr.SearchAndReplace( aCode.GetName(), String() );
192 aModStr.SearchAndReplaceAllAscii( "+", String() );
193 aHyperlinkClick.SearchAndReplaceAllAscii( "%s", aModStr );
195 for(USHORT i = 0; i < nCount; ++i)
197 String* pNew = new SW_RESSTR(FLD_DOCINFO_BEGIN + i);
198 aDocInfoLst.Insert(pNew, aDocInfoLst.Count());
201 FreeResource();
204 ShellResource::~ShellResource()
206 if( pAutoFmtNameLst )
207 delete pAutoFmtNameLst, pAutoFmtNameLst = 0;
210 String ShellResource::GetPageDescName( USHORT nNo, BOOL bIsFirst, BOOL bFollow )
212 String sRet( bIsFirst ? sPageDescFirstName
213 : bFollow ? sPageDescFollowName
214 : sPageDescName );
215 sRet.SearchAndReplaceAscii( "$(ARG1)", String::CreateFromInt32( nNo ));
216 return sRet;
220 SwGlossaries* GetGlossaries()
222 if (!pGlossaries)
223 pGlossaries = new SwGlossaries;
224 return (pGlossaries);
227 BOOL HasGlossaryList()
229 return pGlossaryList != 0;
232 SwGlossaryList* GetGlossaryList()
234 if(!pGlossaryList)
235 pGlossaryList = new SwGlossaryList();
237 return pGlossaryList;
240 struct ImpAutoFmtNameListLoader : public Resource
242 ImpAutoFmtNameListLoader( SvStringsDtor& rLst );
245 void ShellResource::_GetAutoFmtNameLst() const
247 SvStringsDtor** ppLst = (SvStringsDtor**)&pAutoFmtNameLst;
248 *ppLst = new SvStringsDtor( STR_AUTOFMTREDL_END );
249 ImpAutoFmtNameListLoader aTmp( **ppLst );
252 ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( SvStringsDtor& rLst )
253 : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) )
255 for( USHORT n = 0; n < STR_AUTOFMTREDL_END; ++n )
257 String* p = new String( ResId( n + 1, *pSwResMgr) );
258 if(STR_AUTOFMTREDL_TYPO == n)
260 #ifdef WNT
261 //fuer Windows Sonderbehandlung, da MS hier ein paar Zeichen im Dialogfont vergessen hat
262 p->SearchAndReplace(C2S("%1"), C2S(",,"));
263 p->SearchAndReplace(C2S("%2"), C2S("''"));
264 #else
265 const LocaleDataWrapper& rLclD = SvtSysLocale().GetLocaleData();
266 //unter richtigen Betriebssystemen funktioniert es auch so
267 p->SearchAndReplace(C2S("%1"), rLclD.getDoubleQuotationMarkStart());
268 p->SearchAndReplace(C2S("%2"), rLclD.getDoubleQuotationMarkEnd());
269 #endif
271 rLst.Insert( p, n );
273 FreeResource();
275 /* -----------------16.09.99 12:28-------------------
277 --------------------------------------------------*/
278 const String& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
280 if(!pAuthFieldNameList)
282 pAuthFieldNameList = new SvStringsDtor(AUTH_FIELD_END, 1);
283 for(USHORT i = 0; i < AUTH_FIELD_END; i++)
285 String* pTmp = new String(SW_RES(STR_AUTH_FIELD_START + i));
286 pAuthFieldNameList->Insert(pTmp, pAuthFieldNameList->Count());
289 return *pAuthFieldNameList->GetObject( static_cast< USHORT >(eType) );
291 /* -----------------16.09.99 12:29-------------------
293 --------------------------------------------------*/
294 const String& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
296 if(!pAuthFieldTypeList)
298 pAuthFieldTypeList = new SvStringsDtor(AUTH_TYPE_END, 1);
299 for(USHORT i = 0; i < AUTH_TYPE_END; i++)
300 pAuthFieldTypeList->Insert(
301 new String(SW_RES(STR_AUTH_TYPE_START + i)),
302 pAuthFieldTypeList->Count());
304 return *pAuthFieldTypeList->GetObject( static_cast< USHORT >(eType) );