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