Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / utlui / initui.cxx
blobf24cded867f56710ad6ae3fb80026ccfe7d4c658
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <libxml/xmlwriter.h>
22 #include <unotools/localedatawrapper.hxx>
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>
36 // Global Pointer
38 static std::unique_ptr<SwGlossaries> pGlossaries;
40 // Provides all needed paths. Is initialized by UI.
41 static SwGlossaryList* pGlossaryList = nullptr;
43 namespace
45 OUString CurrGlosGroup;
48 const OUString& GetCurrGlosGroup()
50 return CurrGlosGroup;
53 void SetCurrGlosGroup(const OUString& sStr)
55 CurrGlosGroup = sStr;
58 namespace
61 std::vector<OUString>* pAuthFieldNameList = nullptr;
62 std::vector<OUString>* pAuthFieldTypeList = nullptr;
66 // Finish UI
68 void FinitUI()
70 delete SwViewShell::GetShellRes();
71 SwViewShell::SetShellRes( nullptr );
73 SwEditWin::FinitStaticData();
75 pGlossaries.reset();
77 delete SwFieldType::s_pFieldNames;
79 delete pGlossaryList;
80 delete pAuthFieldNameList;
81 delete pAuthFieldTypeList;
85 // Initialise
87 void InitUI()
89 // ShellResource gives the CORE the possibility to work with resources.
90 SwViewShell::SetShellRes( new ShellResource );
91 SwEditWin::InitStaticData();
94 const TranslateId FLD_DOCINFO_ARY[] =
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
107 ShellResource::ShellResource()
108 : aPostItAuthor( SwResId( STR_POSTIT_AUTHOR ) ),
109 aPostItPage( SwResId( STR_POSTIT_PAGE ) ),
110 aPostItLine( SwResId( STR_POSTIT_LINE ) ),
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 ) ),
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 )),
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))
138 for (auto const& aID : FLD_DOCINFO_ARY)
139 aDocInfoLst.push_back(SwResId(aID));
142 OUString ShellResource::GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
144 OUString sRet;
146 switch (eMode)
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;
159 return sRet.replaceFirst( "$(ARG1)", OUString::number( nNo ));
162 SwGlossaries* GetGlossaries()
164 if (!pGlossaries)
165 pGlossaries.reset( new SwGlossaries );
166 return pGlossaries.get();
169 bool HasGlossaryList()
171 return pGlossaryList != nullptr;
174 SwGlossaryList* GetGlossaryList()
176 if(!pGlossaryList)
177 pGlossaryList = new SwGlossaryList();
179 return pGlossaryList;
182 void ShellResource::GetAutoFormatNameLst_() const
184 assert(!mxAutoFormatNameLst);
185 mxAutoFormatNameLst.emplace();
186 mxAutoFormatNameLst->reserve(STR_AUTOFMTREDL_END);
188 static_assert(SAL_N_ELEMENTS(RID_SHELLRES_AUTOFMTSTRS) == STR_AUTOFMTREDL_END);
189 for (sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n)
191 OUString p(SwResId(RID_SHELLRES_AUTOFMTSTRS[n]));
192 if (STR_AUTOFMTREDL_TYPO == n)
194 const SvtSysLocale aSysLocale;
195 const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
196 p = p.replaceFirst("%1", rLclD.getDoubleQuotationMarkStart());
197 p = p.replaceFirst("%2", rLclD.getDoubleQuotationMarkEnd());
199 mxAutoFormatNameLst->push_back(p);
203 namespace
205 const TranslateId STR_AUTH_FIELD_ARY[] =
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 STR_AUTH_FIELD_TARGET_TYPE,
240 STR_AUTH_FIELD_TARGET_URL,
244 OUString const & SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
246 if(!pAuthFieldNameList)
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]));
253 return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)];
256 const TranslateId STR_AUTH_TYPE_ARY[] =
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
282 OUString const & SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
284 if(!pAuthFieldTypeList)
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]));
291 return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
294 void SwAuthorityFieldType::dumpAsXml(xmlTextWriterPtr pWriter) const
296 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwAuthorityFieldType"));
297 SwFieldType::dumpAsXml(pWriter);
299 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("DataArr"));
300 for (const auto& xAuthEntry : m_DataArr)
302 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("AuthEntry"));
303 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", xAuthEntry.get());
304 (void)xmlTextWriterEndElement(pWriter);
306 (void)xmlTextWriterEndElement(pWriter);
308 (void)xmlTextWriterEndElement(pWriter);
311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */