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