Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
28 :
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>
35 :
36 : #include <unomid.h>
37 :
38 : // Global Pointer
39 :
40 : SwGlossaries* pGlossaries = 0;
41 :
42 : // Provides all needed paths. Is initialized by UI.
43 : SwGlossaryList* pGlossaryList = 0;
44 :
45 : String* pOldGrfCat = 0;
46 : String* pOldTabCat = 0;
47 : String* pOldFrmCat = 0;
48 : String* pOldDrwCat = 0;
49 : String* pCurrGlosGroup = 0;
50 :
51 0 : String* GetOldGrfCat()
52 : {
53 0 : return pOldGrfCat;
54 : }
55 0 : String* GetOldTabCat()
56 : {
57 0 : return pOldTabCat;
58 : }
59 0 : String* GetOldFrmCat()
60 : {
61 0 : return pOldFrmCat;
62 : }
63 0 : String* GetOldDrwCat()
64 : {
65 0 : return pOldDrwCat;
66 : }
67 0 : String* GetCurrGlosGroup()
68 : {
69 0 : return pCurrGlosGroup;
70 : }
71 0 : void SetCurrGlosGroup(String* pStr)
72 : {
73 0 : pCurrGlosGroup = pStr;
74 0 : }
75 :
76 : std::vector<String>* pDBNameList = 0;
77 :
78 : std::vector<String>* pAuthFieldNameList = 0;
79 : std::vector<String>* pAuthFieldTypeList = 0;
80 :
81 : // Finish UI
82 :
83 33 : void _FinitUI()
84 : {
85 33 : SwNewDBMgr::RemoveDbtoolsClient();
86 33 : delete ViewShell::GetShellRes();
87 33 : ViewShell::SetShellRes( 0 );
88 :
89 33 : SwEditWin::_FinitStaticData();
90 :
91 33 : DELETEZ(pGlossaries);
92 :
93 33 : delete SwFieldType::pFldNames;
94 :
95 33 : delete pOldGrfCat;
96 33 : delete pOldTabCat;
97 33 : delete pOldFrmCat;
98 33 : delete pOldDrwCat;
99 33 : delete pCurrGlosGroup;
100 33 : delete pDBNameList;
101 33 : delete pGlossaryList;
102 33 : delete pAuthFieldNameList;
103 33 : delete pAuthFieldTypeList;
104 :
105 33 : }
106 :
107 : // Initialise
108 :
109 33 : void _InitUI()
110 : {
111 : // ShellResource gives the CORE the possibility to work with resources.
112 33 : ViewShell::SetShellRes( new ShellResource );
113 33 : pDBNameList = new std::vector<String>;
114 33 : SwEditWin::_InitStaticData();
115 33 : }
116 :
117 34 : 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 ) ),
122 :
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 ) ),
132 :
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 )),
141 :
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 34 : sPageDescName( SW_RES(STR_PAGEDESC_NAME))
154 : {
155 34 : const sal_uInt16 nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN;
156 :
157 34 : KeyCode aCode( KEY_SPACE );
158 34 : KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
159 34 : String aModStr( aModifiedCode.GetName() );
160 34 : aModStr.SearchAndReplace( aCode.GetName(), String() );
161 34 : aModStr.SearchAndReplaceAllAscii( "+", String() );
162 34 : aHyperlinkClick.SearchAndReplaceAllAscii( "%s", aModStr );
163 :
164 340 : for(sal_uInt16 i = 0; i < nCount; ++i)
165 306 : aDocInfoLst.push_back(String(SW_RESSTR(FLD_DOCINFO_BEGIN + i)));
166 :
167 34 : FreeResource();
168 34 : }
169 :
170 68 : ShellResource::~ShellResource()
171 : {
172 34 : delete pAutoFmtNameLst;
173 34 : }
174 :
175 11 : String ShellResource::GetPageDescName( sal_uInt16 nNo, PageNameMode eMode )
176 : {
177 11 : String sRet;
178 :
179 11 : switch (eMode)
180 : {
181 : case NORMAL_PAGE:
182 9 : sRet = sPageDescName;
183 9 : break;
184 : case FIRST_PAGE:
185 1 : sRet = sPageDescFirstName;
186 1 : break;
187 : case FOLLOW_PAGE:
188 1 : sRet = sPageDescFollowName;
189 1 : break;
190 : }
191 :
192 11 : sRet.SearchAndReplaceAscii( "$(ARG1)", OUString::number( nNo ));
193 11 : return sRet;
194 : }
195 :
196 :
197 4 : SwGlossaries* GetGlossaries()
198 : {
199 4 : if (!pGlossaries)
200 1 : pGlossaries = new SwGlossaries;
201 4 : return (pGlossaries);
202 : }
203 :
204 0 : bool HasGlossaryList()
205 : {
206 0 : return pGlossaryList != 0;
207 : }
208 :
209 0 : SwGlossaryList* GetGlossaryList()
210 : {
211 0 : if(!pGlossaryList)
212 0 : pGlossaryList = new SwGlossaryList();
213 :
214 0 : return pGlossaryList;
215 : }
216 :
217 0 : struct ImpAutoFmtNameListLoader : public Resource
218 : {
219 : ImpAutoFmtNameListLoader( std::vector<String>& rLst );
220 : };
221 :
222 0 : void ShellResource::_GetAutoFmtNameLst() const
223 : {
224 : assert(!pAutoFmtNameLst);
225 0 : pAutoFmtNameLst = new std::vector<String>;
226 0 : pAutoFmtNameLst->reserve(STR_AUTOFMTREDL_END);
227 0 : ImpAutoFmtNameListLoader aTmp(*pAutoFmtNameLst);
228 0 : }
229 :
230 0 : ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector<String>& rLst )
231 0 : : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) )
232 : {
233 0 : for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n )
234 : {
235 0 : String p(ResId(n + 1, *pSwResMgr));
236 0 : if(STR_AUTOFMTREDL_TYPO == n)
237 : {
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 0 : const SvtSysLocale aSysLocale;
245 0 : const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
246 : // With real operating systems it also works without special handling.
247 0 : p.SearchAndReplace(OUString("%1"), rLclD.getDoubleQuotationMarkStart());
248 0 : p.SearchAndReplace(OUString("%2"), rLclD.getDoubleQuotationMarkEnd());
249 : #endif
250 : }
251 0 : rLst.insert(rLst.begin() + n, p);
252 0 : }
253 0 : FreeResource();
254 0 : }
255 :
256 0 : const String& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
257 : {
258 0 : if(!pAuthFieldNameList)
259 : {
260 0 : pAuthFieldNameList = new std::vector<String>;
261 0 : pAuthFieldNameList->reserve(AUTH_FIELD_END);
262 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
263 0 : pAuthFieldNameList->push_back(String(SW_RES(STR_AUTH_FIELD_START + i)));
264 : }
265 0 : return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)];
266 : }
267 :
268 0 : const String& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
269 : {
270 0 : if(!pAuthFieldTypeList)
271 : {
272 0 : pAuthFieldTypeList = new std::vector<String>;
273 0 : pAuthFieldTypeList->reserve(AUTH_TYPE_END);
274 0 : for(sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i)
275 0 : pAuthFieldTypeList->push_back(String(SW_RES(STR_AUTH_TYPE_START + i)));
276 : }
277 0 : return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
278 99 : }
279 :
280 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|