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