LibreOffice Module sw (master)  1
initui.cxx
Go to the documentation of this file.
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 <config_features.h>
21 
23 #include <viewsh.hxx>
24 #include <initui.hxx>
25 #include <edtwin.hxx>
26 #include <shellres.hxx>
27 #include <fldbas.hxx>
28 #include <glosdoc.hxx>
29 #include <gloslst.hxx>
30 #include <comcore.hxx>
31 #include <strings.hrc>
32 #include <utlui.hrc>
33 #include <authfld.hxx>
34 #include <dbmgr.hxx>
35 #include <unotools/syslocale.hxx>
36 
37 #include <unomid.h>
38 
39 // Global Pointer
40 
41 static std::unique_ptr<SwGlossaries> pGlossaries;
42 
43 // Provides all needed paths. Is initialized by UI.
44 static SwGlossaryList* pGlossaryList = nullptr;
45 
46 namespace
47 {
48 OUString CurrGlosGroup;
49 }
50 
51 const OUString& GetCurrGlosGroup()
52 {
53  return CurrGlosGroup;
54 }
55 
56 void SetCurrGlosGroup(const OUString& sStr)
57 {
58  CurrGlosGroup = sStr;
59 }
60 
61 namespace
62 {
63 
64 std::vector<OUString>* pAuthFieldNameList = nullptr;
65 std::vector<OUString>* pAuthFieldTypeList = nullptr;
66 
67 }
68 
69 // Finish UI
70 
71 void FinitUI()
72 {
73  delete SwViewShell::GetShellRes();
74  SwViewShell::SetShellRes( nullptr );
75 
77 
78  pGlossaries.reset();
79 
81 
82  delete pGlossaryList;
83  delete pAuthFieldNameList;
84  delete pAuthFieldTypeList;
85 
86 }
87 
88 // Initialise
89 
90 void InitUI()
91 {
92  // ShellResource gives the CORE the possibility to work with resources.
95 }
96 
97 static const char* FLD_DOCINFO_ARY[] =
98 {
99  FLD_DOCINFO_TITEL,
100  FLD_DOCINFO_THEMA,
101  FLD_DOCINFO_KEYS,
102  FLD_DOCINFO_COMMENT,
103  FLD_DOCINFO_CREATE,
104  FLD_DOCINFO_CHANGE,
105  FLD_DOCINFO_PRINT,
106  FLD_DOCINFO_DOCNO,
107  FLD_DOCINFO_EDIT
108 };
109 
111  : aPostItAuthor( SwResId( STR_POSTIT_AUTHOR ) ),
112  aPostItPage( SwResId( STR_POSTIT_PAGE ) ),
113  aPostItLine( SwResId( STR_POSTIT_LINE ) ),
114 
115  aCalc_Syntax( SwResId( STR_CALC_SYNTAX ) ),
116  aCalc_ZeroDiv( SwResId( STR_CALC_ZERODIV ) ),
117  aCalc_Brack( SwResId( STR_CALC_BRACK ) ),
118  aCalc_Pow( SwResId( STR_CALC_POW ) ),
119  aCalc_Overflow( SwResId( STR_CALC_OVERFLOW ) ),
120  aCalc_Default( SwResId( STR_CALC_DEFAULT ) ),
121  aCalc_Error( SwResId( STR_CALC_ERROR ) ),
122 
123  // #i81002#
124  aGetRefField_RefItemNotFound( SwResId( STR_GETREFFLD_REFITEMNOTFOUND ) ),
125  aStrNone( SwResId( STR_TEMPLATE_NONE )),
126  aFixedStr( SwResId( STR_FIELD_FIXED )),
127  sDurationFormat( SwResId( STR_DURATION_FORMAT )),
128 
129  aTOXIndexName( SwResId(STR_TOI)),
130  aTOXUserName( SwResId(STR_TOU)),
131  aTOXContentName( SwResId(STR_TOC)),
132  aTOXIllustrationsName( SwResId(STR_TOX_ILL)),
133  aTOXObjectsName( SwResId(STR_TOX_OBJ)),
134  aTOXTablesName( SwResId(STR_TOX_TBL)),
135  aTOXAuthoritiesName( SwResId(STR_TOX_AUTH)),
136  aTOXCitationName( SwResId(STR_TOX_CITATION)),
137  sPageDescFirstName( SwResId(STR_PAGEDESC_FIRSTNAME)),
138  sPageDescFollowName( SwResId(STR_PAGEDESC_FOLLOWNAME)),
139  sPageDescName( SwResId(STR_PAGEDESC_NAME))
140 {
141  for (size_t i = 0; i < SAL_N_ELEMENTS(FLD_DOCINFO_ARY); ++i)
142  aDocInfoLst.push_back(SwResId(FLD_DOCINFO_ARY[i]));
143 }
144 
145 OUString ShellResource::GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
146 {
147  OUString sRet;
148 
149  switch (eMode)
150  {
151  case NORMAL_PAGE:
152  sRet = sPageDescName;
153  break;
154  case FIRST_PAGE:
155  sRet = sPageDescFirstName;
156  break;
157  case FOLLOW_PAGE:
158  sRet = sPageDescFollowName;
159  break;
160  }
161 
162  return sRet.replaceFirst( "$(ARG1)", OUString::number( nNo ));
163 }
164 
166 {
167  if (!pGlossaries)
168  pGlossaries.reset( new SwGlossaries );
169  return pGlossaries.get();
170 }
171 
173 {
174  return pGlossaryList != nullptr;
175 }
176 
178 {
179  if(!pGlossaryList)
180  pGlossaryList = new SwGlossaryList();
181 
182  return pGlossaryList;
183 }
184 
186 {
187  assert(!pAutoFormatNameLst);
188  pAutoFormatNameLst.reset( new std::vector<OUString> );
190 
191  assert(SAL_N_ELEMENTS(RID_SHELLRES_AUTOFMTSTRS) == STR_AUTOFMTREDL_END);
192  for (sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n)
193  {
194  OUString p(SwResId(RID_SHELLRES_AUTOFMTSTRS[n]));
195  if (STR_AUTOFMTREDL_TYPO == n)
196  {
197  const SvtSysLocale aSysLocale;
198  const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
199  p = p.replaceFirst("%1", rLclD.getDoubleQuotationMarkStart());
200  p = p.replaceFirst("%2", rLclD.getDoubleQuotationMarkEnd());
201  }
202  pAutoFormatNameLst->push_back(p);
203  }
204 }
205 
206 namespace
207 {
208  const char* STR_AUTH_FIELD_ARY[] =
209  {
210  STR_AUTH_FIELD_IDENTIFIER,
211  STR_AUTH_FIELD_AUTHORITY_TYPE,
212  STR_AUTH_FIELD_ADDRESS,
213  STR_AUTH_FIELD_ANNOTE,
214  STR_AUTH_FIELD_AUTHOR,
215  STR_AUTH_FIELD_BOOKTITLE,
216  STR_AUTH_FIELD_CHAPTER,
217  STR_AUTH_FIELD_EDITION,
218  STR_AUTH_FIELD_EDITOR,
219  STR_AUTH_FIELD_HOWPUBLISHED,
220  STR_AUTH_FIELD_INSTITUTION,
221  STR_AUTH_FIELD_JOURNAL,
222  STR_AUTH_FIELD_MONTH,
223  STR_AUTH_FIELD_NOTE,
224  STR_AUTH_FIELD_NUMBER,
225  STR_AUTH_FIELD_ORGANIZATIONS,
226  STR_AUTH_FIELD_PAGES,
227  STR_AUTH_FIELD_PUBLISHER,
228  STR_AUTH_FIELD_SCHOOL,
229  STR_AUTH_FIELD_SERIES,
230  STR_AUTH_FIELD_TITLE,
231  STR_AUTH_FIELD_TYPE,
232  STR_AUTH_FIELD_VOLUME,
233  STR_AUTH_FIELD_YEAR,
234  STR_AUTH_FIELD_URL,
235  STR_AUTH_FIELD_CUSTOM1,
236  STR_AUTH_FIELD_CUSTOM2,
237  STR_AUTH_FIELD_CUSTOM3,
238  STR_AUTH_FIELD_CUSTOM4,
239  STR_AUTH_FIELD_CUSTOM5,
240  STR_AUTH_FIELD_ISBN
241  };
242 }
243 
245 {
246  if(!pAuthFieldNameList)
247  {
248  pAuthFieldNameList = new std::vector<OUString>;
249  pAuthFieldNameList->reserve(AUTH_FIELD_END);
250  for (sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
251  pAuthFieldNameList->push_back(SwResId(STR_AUTH_FIELD_ARY[i]));
252  }
253  return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)];
254 }
255 
256 static const char* STR_AUTH_TYPE_ARY[] =
257 {
258  STR_AUTH_TYPE_ARTICLE,
259  STR_AUTH_TYPE_BOOK,
260  STR_AUTH_TYPE_BOOKLET,
261  STR_AUTH_TYPE_CONFERENCE,
262  STR_AUTH_TYPE_INBOOK,
263  STR_AUTH_TYPE_INCOLLECTION,
264  STR_AUTH_TYPE_INPROCEEDINGS,
265  STR_AUTH_TYPE_JOURNAL,
266  STR_AUTH_TYPE_MANUAL,
267  STR_AUTH_TYPE_MASTERSTHESIS,
268  STR_AUTH_TYPE_MISC,
269  STR_AUTH_TYPE_PHDTHESIS,
270  STR_AUTH_TYPE_PROCEEDINGS,
271  STR_AUTH_TYPE_TECHREPORT,
272  STR_AUTH_TYPE_UNPUBLISHED,
273  STR_AUTH_TYPE_EMAIL,
274  STR_AUTH_TYPE_WWW,
275  STR_AUTH_TYPE_CUSTOM1,
276  STR_AUTH_TYPE_CUSTOM2,
277  STR_AUTH_TYPE_CUSTOM3,
278  STR_AUTH_TYPE_CUSTOM4,
279  STR_AUTH_TYPE_CUSTOM5
280 };
281 
283 {
284  if(!pAuthFieldTypeList)
285  {
286  pAuthFieldTypeList = new std::vector<OUString>;
287  pAuthFieldTypeList->reserve(AUTH_TYPE_END);
288  for (sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i)
289  pAuthFieldTypeList->push_back(SwResId(STR_AUTH_TYPE_ARY[i]));
290  }
291  return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
292 }
293 
294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void GetAutoFormatNameLst_() const
Definition: initui.cxx:185
OUString const sPageDescFirstName
Definition: shellres.hxx:82
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2493
static const char * FLD_DOCINFO_ARY[]
Definition: initui.cxx:97
static void SetShellRes(ShellResource *pRes)
Definition: viewsh.hxx:436
OUString GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
Definition: initui.cxx:145
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:177
static OUString const & GetAuthTypeName(ToxAuthorityType eType)
Definition: initui.cxx:282
OUString const sPageDescFollowName
Definition: shellres.hxx:83
bool HasGlossaryList()
Definition: initui.cxx:172
const LocaleDataWrapper & GetLocaleData() const
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:241
#define STR_AUTOFMTREDL_TYPO
Definition: comcore.hxx:27
#define SAL_N_ELEMENTS(arr)
static OUString const & GetAuthFieldName(ToxAuthorityField eType)
Definition: initui.cxx:244
static SwGlossaryList * pGlossaryList
Definition: initui.cxx:44
static std::unique_ptr< SwGlossaries > pGlossaries
Definition: initui.cxx:41
int i
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:61
static const char * STR_AUTH_TYPE_ARY[]
Definition: initui.cxx:256
void SetCurrGlosGroup(const OUString &sStr)
Definition: initui.cxx:56
OUString SwResId(const char *pId)
Definition: swmodule.cxx:190
SwGlossaries * GetGlossaries()
Definition: initui.cxx:165
ToxAuthorityField
Definition: toxe.hxx:82
static void InitStaticData()
Definition: edtwin.cxx:5811
const OUString & getDoubleQuotationMarkEnd() const
void FinitUI()
Definition: initui.cxx:71
std::unique_ptr< std::vector< OUString > > pAutoFormatNameLst
Definition: shellres.hxx:81
#define STR_AUTOFMTREDL_END
Definition: comcore.hxx:46
const OUString & GetCurrGlosGroup()
Definition: initui.cxx:51
ToxAuthorityType
Definition: toxe.hxx:52
OUString const sPageDescName
Definition: shellres.hxx:84
const OUString & getDoubleQuotationMarkStart() const
static void FinitStaticData()
Definition: edtwin.cxx:5816
void InitUI()
Definition: initui.cxx:90