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>
35
36// Global Pointer
37
38static std::unique_ptr<SwGlossaries> pGlossaries;
39
40// Provides all needed paths. Is initialized by UI.
41static SwGlossaryList* pGlossaryList = nullptr;
42
43namespace
44{
45OUString CurrGlosGroup;
46}
47
48const OUString& GetCurrGlosGroup()
49{
50 return CurrGlosGroup;
51}
52
53void SetCurrGlosGroup(const OUString& sStr)
54{
55 CurrGlosGroup = sStr;
56}
57
58namespace
59{
60
61std::vector<OUString>* pAuthFieldNameList = nullptr;
62std::vector<OUString>* pAuthFieldTypeList = nullptr;
63
64}
65
66// Finish UI
67
68void FinitUI()
69{
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
87void 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)
140}
141
142OUString 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)
178
179 return pGlossaryList;
180}
181
183{
184 assert(!mxAutoFormatNameLst);
185 mxAutoFormatNameLst.emplace();
187
188 static_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
203namespace
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: */
struct _xmlTextWriter * xmlTextWriterPtr
const OUString & getDoubleQuotationMarkStart() const
const OUString & getDoubleQuotationMarkEnd() const
const LocaleDataWrapper & GetLocaleData() const
static OUString const & GetAuthFieldName(ToxAuthorityField eType)
Definition: initui.cxx:242
static OUString const & GetAuthTypeName(ToxAuthorityType eType)
Definition: initui.cxx:280
SwAuthDataArr m_DataArr
Definition: authfld.hxx:65
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: initui.cxx:292
static void FinitStaticData()
Definition: edtwin.cxx:6156
static void InitStaticData()
Definition: edtwin.cxx:6151
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:155
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:248
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2650
static void SetShellRes(ShellResource *pRes)
Definition: viewsh.hxx:443
#define STR_AUTOFMTREDL_END
Definition: comcore.hxx:47
#define STR_AUTOFMTREDL_TYPO
Definition: comcore.hxx:27
DocumentType eType
static std::unique_ptr< SwGlossaries > pGlossaries
Definition: initui.cxx:38
SwGlossaries * GetGlossaries()
Definition: initui.cxx:162
const OUString & GetCurrGlosGroup()
Definition: initui.cxx:48
static SwGlossaryList * pGlossaryList
Definition: initui.cxx:41
void SetCurrGlosGroup(const OUString &sStr)
Definition: initui.cxx:53
const TranslateId STR_AUTH_TYPE_ARY[]
Definition: initui.cxx:254
const TranslateId FLD_DOCINFO_ARY[]
Definition: initui.cxx:94
void InitUI()
Definition: initui.cxx:87
void FinitUI()
Definition: initui.cxx:68
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:174
bool HasGlossaryList()
Definition: initui.cxx:169
Mode eMode
void * p
sal_Int64 n
#define SAL_N_ELEMENTS(arr)
int i
OUString sPageDescFirstName
Definition: shellres.hxx:83
OUString GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
Definition: initui.cxx:142
OUString sPageDescFollowName
Definition: shellres.hxx:84
void GetAutoFormatNameLst_() const
Definition: initui.cxx:182
OUString sPageDescName
Definition: shellres.hxx:85
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:62
std::optional< std::vector< OUString > > mxAutoFormatNameLst
Definition: shellres.hxx:82
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
ToxAuthorityField
Definition: toxe.hxx:83
@ AUTH_FIELD_END
Definition: toxe.hxx:118
ToxAuthorityType
Definition: toxe.hxx:53
@ AUTH_TYPE_END
Definition: toxe.hxx:78