bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / utlui / initui.cxx
blobdda31eb4b604c717fa34418b81ee6af48cb8a610
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <unotools/localedatawrapper.hxx>
21 #include <viewsh.hxx>
22 #include <initui.hxx>
23 #include <edtwin.hxx>
24 #include <shellres.hxx>
25 #include <fldbas.hxx>
26 #include <glosdoc.hxx>
27 #include <gloslst.hxx>
29 #include <utlui.hrc>
30 #include <initui.hrc>
31 #include <comcore.hrc>
32 #include <authfld.hxx>
33 #include <dbmgr.hxx>
34 #include <unotools/syslocale.hxx>
36 #include <unomid.h>
38 // Global Pointer
40 SwGlossaries* pGlossaries = 0;
42 // Provides all needed paths. Is initialized by UI.
43 SwGlossaryList* pGlossaryList = 0;
45 String* pOldGrfCat = 0;
46 String* pOldTabCat = 0;
47 String* pOldFrmCat = 0;
48 String* pOldDrwCat = 0;
49 String* pCurrGlosGroup = 0;
51 String* GetOldGrfCat()
53 return pOldGrfCat;
55 String* GetOldTabCat()
57 return pOldTabCat;
59 String* GetOldFrmCat()
61 return pOldFrmCat;
63 String* GetOldDrwCat()
65 return pOldDrwCat;
67 String* GetCurrGlosGroup()
69 return pCurrGlosGroup;
71 void SetCurrGlosGroup(String* pStr)
73 pCurrGlosGroup = pStr;
76 std::vector<String>* pDBNameList = 0;
78 std::vector<String>* pAuthFieldNameList = 0;
79 std::vector<String>* pAuthFieldTypeList = 0;
81 // Finish UI
83 void _FinitUI()
85 SwNewDBMgr::RemoveDbtoolsClient();
86 delete ViewShell::GetShellRes();
87 ViewShell::SetShellRes( 0 );
89 SwEditWin::_FinitStaticData();
91 DELETEZ(pGlossaries);
93 delete SwFieldType::pFldNames;
95 delete pOldGrfCat;
96 delete pOldTabCat;
97 delete pOldFrmCat;
98 delete pOldDrwCat;
99 delete pCurrGlosGroup;
100 delete pDBNameList;
101 delete pGlossaryList;
102 delete pAuthFieldNameList;
103 delete pAuthFieldTypeList;
107 // Initialise
109 void _InitUI()
111 // ShellResource gives the CORE the possibility to work with resources.
112 ViewShell::SetShellRes( new ShellResource );
113 pDBNameList = new std::vector<String>;
114 SwEditWin::_InitStaticData();
117 ShellResource::ShellResource()
118 : Resource( SW_RES(RID_SW_SHELLRES) ),
119 aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR ) ),
120 aPostItPage( SW_RES( STR_POSTIT_PAGE ) ),
121 aPostItLine( SW_RES( STR_POSTIT_LINE ) ),
123 aCalc_Syntax( SW_RES( STR_CALC_SYNTAX ) ),
124 aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ),
125 aCalc_Brack( SW_RES( STR_CALC_BRACK ) ),
126 aCalc_Pow( SW_RES( STR_CALC_POW ) ),
127 aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ),
128 aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ),
129 aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ),
130 aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ),
131 aCalc_Error( SW_RES( STR_CALC_ERROR ) ),
133 aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP ) ),
134 aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN ) ),
135 // #i81002#
136 aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND ) ),
137 aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT ) ),
138 aStrNone( SW_RES( STR_TEMPLATE_NONE )),
139 aFixedStr( SW_RES( STR_FIELD_FIXED )),
140 sDurationFormat( SW_RES( STR_DURATION_FORMAT )),
142 aTOXIndexName( SW_RES(STR_TOI)),
143 aTOXUserName( SW_RES(STR_TOU)),
144 aTOXContentName( SW_RES(STR_TOC)),
145 aTOXIllustrationsName( SW_RES(STR_TOX_ILL)),
146 aTOXObjectsName( SW_RES(STR_TOX_OBJ)),
147 aTOXTablesName( SW_RES(STR_TOX_TBL)),
148 aTOXAuthoritiesName( SW_RES(STR_TOX_AUTH)),
149 aHyperlinkClick( SW_RES( STR_HYPERLINK_CLICK)),
150 pAutoFmtNameLst(0),
151 sPageDescFirstName( SW_RES(STR_PAGEDESC_FIRSTNAME)),
152 sPageDescFollowName( SW_RES(STR_PAGEDESC_FOLLOWNAME)),
153 sPageDescName( SW_RES(STR_PAGEDESC_NAME))
155 const sal_uInt16 nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN;
157 KeyCode aCode( KEY_SPACE );
158 KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
159 String aModStr( aModifiedCode.GetName() );
160 aModStr.SearchAndReplace( aCode.GetName(), String() );
161 aModStr.SearchAndReplaceAllAscii( "+", String() );
162 aHyperlinkClick.SearchAndReplaceAllAscii( "%s", aModStr );
164 for(sal_uInt16 i = 0; i < nCount; ++i)
165 aDocInfoLst.push_back(String(SW_RESSTR(FLD_DOCINFO_BEGIN + i)));
167 FreeResource();
170 ShellResource::~ShellResource()
172 delete pAutoFmtNameLst;
175 String ShellResource::GetPageDescName( sal_uInt16 nNo, PageNameMode eMode )
177 String sRet;
179 switch (eMode)
181 case NORMAL_PAGE:
182 sRet = sPageDescName;
183 break;
184 case FIRST_PAGE:
185 sRet = sPageDescFirstName;
186 break;
187 case FOLLOW_PAGE:
188 sRet = sPageDescFollowName;
189 break;
192 sRet.SearchAndReplaceAscii( "$(ARG1)", OUString::number( nNo ));
193 return sRet;
197 SwGlossaries* GetGlossaries()
199 if (!pGlossaries)
200 pGlossaries = new SwGlossaries;
201 return (pGlossaries);
204 bool HasGlossaryList()
206 return pGlossaryList != 0;
209 SwGlossaryList* GetGlossaryList()
211 if(!pGlossaryList)
212 pGlossaryList = new SwGlossaryList();
214 return pGlossaryList;
217 struct ImpAutoFmtNameListLoader : public Resource
219 ImpAutoFmtNameListLoader( std::vector<String>& rLst );
222 void ShellResource::_GetAutoFmtNameLst() const
224 assert(!pAutoFmtNameLst);
225 pAutoFmtNameLst = new std::vector<String>;
226 pAutoFmtNameLst->reserve(STR_AUTOFMTREDL_END);
227 ImpAutoFmtNameListLoader aTmp(*pAutoFmtNameLst);
230 ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector<String>& rLst )
231 : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) )
233 for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n )
235 String p(ResId(n + 1, *pSwResMgr));
236 if(STR_AUTOFMTREDL_TYPO == n)
238 #ifdef WNT
239 // For Windows, a special treatment is necessary because MS has
240 // forgotten some characters in the dialog font here.
241 p.SearchAndReplace(OUString("%1"), OUString(",,"));
242 p.SearchAndReplace(OUString("%2"), OUString("''"));
243 #else
244 const SvtSysLocale aSysLocale;
245 const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
246 // With real operating systems it also works without special handling.
247 p.SearchAndReplace(OUString("%1"), rLclD.getDoubleQuotationMarkStart());
248 p.SearchAndReplace(OUString("%2"), rLclD.getDoubleQuotationMarkEnd());
249 #endif
251 rLst.insert(rLst.begin() + n, p);
253 FreeResource();
256 const String& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
258 if(!pAuthFieldNameList)
260 pAuthFieldNameList = new std::vector<String>;
261 pAuthFieldNameList->reserve(AUTH_FIELD_END);
262 for(sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
263 pAuthFieldNameList->push_back(String(SW_RES(STR_AUTH_FIELD_START + i)));
265 return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)];
268 const String& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
270 if(!pAuthFieldTypeList)
272 pAuthFieldTypeList = new std::vector<String>;
273 pAuthFieldTypeList->reserve(AUTH_TYPE_END);
274 for(sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i)
275 pAuthFieldTypeList->push_back(String(SW_RES(STR_AUTH_TYPE_START + i)));
277 return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */