1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <unotools/localedatawrapper.hxx>
24 #include <shellres.hxx>
26 #include <glosdoc.hxx>
27 #include <gloslst.hxx>
31 #include <comcore.hrc>
32 #include <authfld.hxx>
34 #include <unotools/syslocale.hxx>
40 SwGlossaries
* pGlossaries
= 0;
42 // Provides all needed paths. Is initialized by UI.
43 SwGlossaryList
* pGlossaryList
= 0;
45 String
* pOldGrfCat
= 0;
46 String
* pOldTabCat
= 0;
47 String
* pOldFrmCat
= 0;
48 String
* pOldDrwCat
= 0;
49 String
* pCurrGlosGroup
= 0;
51 String
* GetOldGrfCat()
55 String
* GetOldTabCat()
59 String
* GetOldFrmCat()
63 String
* GetOldDrwCat()
67 String
* GetCurrGlosGroup()
69 return pCurrGlosGroup
;
71 void SetCurrGlosGroup(String
* pStr
)
73 pCurrGlosGroup
= pStr
;
76 std::vector
<String
>* pDBNameList
= 0;
78 std::vector
<String
>* pAuthFieldNameList
= 0;
79 std::vector
<String
>* pAuthFieldTypeList
= 0;
85 SwNewDBMgr::RemoveDbtoolsClient();
86 delete ViewShell::GetShellRes();
87 ViewShell::SetShellRes( 0 );
89 SwEditWin::_FinitStaticData();
93 delete SwFieldType::pFldNames
;
99 delete pCurrGlosGroup
;
101 delete pGlossaryList
;
102 delete pAuthFieldNameList
;
103 delete pAuthFieldTypeList
;
111 // ShellResource gives the CORE the possibility to work with resources.
112 ViewShell::SetShellRes( new ShellResource
);
113 pDBNameList
= new std::vector
<String
>;
114 SwEditWin::_InitStaticData();
117 ShellResource::ShellResource()
118 : Resource( SW_RES(RID_SW_SHELLRES
) ),
119 aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR
) ),
120 aPostItPage( SW_RES( STR_POSTIT_PAGE
) ),
121 aPostItLine( SW_RES( STR_POSTIT_LINE
) ),
123 aCalc_Syntax( SW_RES( STR_CALC_SYNTAX
) ),
124 aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV
) ),
125 aCalc_Brack( SW_RES( STR_CALC_BRACK
) ),
126 aCalc_Pow( SW_RES( STR_CALC_POW
) ),
127 aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND
) ),
128 aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW
) ),
129 aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME
) ),
130 aCalc_Default( SW_RES( STR_CALC_DEFAULT
) ),
131 aCalc_Error( SW_RES( STR_CALC_ERROR
) ),
133 aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP
) ),
134 aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN
) ),
136 aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND
) ),
137 aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT
) ),
138 aStrNone( SW_RES( STR_TEMPLATE_NONE
)),
139 aFixedStr( SW_RES( STR_FIELD_FIXED
)),
140 sDurationFormat( SW_RES( STR_DURATION_FORMAT
)),
142 aTOXIndexName( SW_RES(STR_TOI
)),
143 aTOXUserName( SW_RES(STR_TOU
)),
144 aTOXContentName( SW_RES(STR_TOC
)),
145 aTOXIllustrationsName( SW_RES(STR_TOX_ILL
)),
146 aTOXObjectsName( SW_RES(STR_TOX_OBJ
)),
147 aTOXTablesName( SW_RES(STR_TOX_TBL
)),
148 aTOXAuthoritiesName( SW_RES(STR_TOX_AUTH
)),
149 aHyperlinkClick( SW_RES( STR_HYPERLINK_CLICK
)),
151 sPageDescFirstName( SW_RES(STR_PAGEDESC_FIRSTNAME
)),
152 sPageDescFollowName( SW_RES(STR_PAGEDESC_FOLLOWNAME
)),
153 sPageDescName( SW_RES(STR_PAGEDESC_NAME
))
155 const sal_uInt16 nCount
= FLD_DOCINFO_END
- FLD_DOCINFO_BEGIN
;
157 KeyCode
aCode( KEY_SPACE
);
158 KeyCode
aModifiedCode( KEY_SPACE
, KEY_MOD1
);
159 String
aModStr( aModifiedCode
.GetName() );
160 aModStr
.SearchAndReplace( aCode
.GetName(), String() );
161 aModStr
.SearchAndReplaceAllAscii( "+", String() );
162 aHyperlinkClick
.SearchAndReplaceAllAscii( "%s", aModStr
);
164 for(sal_uInt16 i
= 0; i
< nCount
; ++i
)
165 aDocInfoLst
.push_back(String(SW_RESSTR(FLD_DOCINFO_BEGIN
+ i
)));
170 ShellResource::~ShellResource()
172 delete pAutoFmtNameLst
;
175 String
ShellResource::GetPageDescName( sal_uInt16 nNo
, PageNameMode eMode
)
182 sRet
= sPageDescName
;
185 sRet
= sPageDescFirstName
;
188 sRet
= sPageDescFollowName
;
192 sRet
.SearchAndReplaceAscii( "$(ARG1)", OUString::number( nNo
));
197 SwGlossaries
* GetGlossaries()
200 pGlossaries
= new SwGlossaries
;
201 return (pGlossaries
);
204 bool HasGlossaryList()
206 return pGlossaryList
!= 0;
209 SwGlossaryList
* GetGlossaryList()
212 pGlossaryList
= new SwGlossaryList();
214 return pGlossaryList
;
217 struct ImpAutoFmtNameListLoader
: public Resource
219 ImpAutoFmtNameListLoader( std::vector
<String
>& rLst
);
222 void ShellResource::_GetAutoFmtNameLst() const
224 assert(!pAutoFmtNameLst
);
225 pAutoFmtNameLst
= new std::vector
<String
>;
226 pAutoFmtNameLst
->reserve(STR_AUTOFMTREDL_END
);
227 ImpAutoFmtNameListLoader
aTmp(*pAutoFmtNameLst
);
230 ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector
<String
>& rLst
)
231 : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS
, *pSwResMgr
) )
233 for( sal_uInt16 n
= 0; n
< STR_AUTOFMTREDL_END
; ++n
)
235 String
p(ResId(n
+ 1, *pSwResMgr
));
236 if(STR_AUTOFMTREDL_TYPO
== n
)
239 // For Windows, a special treatment is necessary because MS has
240 // forgotten some characters in the dialog font here.
241 p
.SearchAndReplace(OUString("%1"), OUString(",,"));
242 p
.SearchAndReplace(OUString("%2"), OUString("''"));
244 const SvtSysLocale aSysLocale
;
245 const LocaleDataWrapper
& rLclD
= aSysLocale
.GetLocaleData();
246 // With real operating systems it also works without special handling.
247 p
.SearchAndReplace(OUString("%1"), rLclD
.getDoubleQuotationMarkStart());
248 p
.SearchAndReplace(OUString("%2"), rLclD
.getDoubleQuotationMarkEnd());
251 rLst
.insert(rLst
.begin() + n
, p
);
256 const String
& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType
)
258 if(!pAuthFieldNameList
)
260 pAuthFieldNameList
= new std::vector
<String
>;
261 pAuthFieldNameList
->reserve(AUTH_FIELD_END
);
262 for(sal_uInt16 i
= 0; i
< AUTH_FIELD_END
; ++i
)
263 pAuthFieldNameList
->push_back(String(SW_RES(STR_AUTH_FIELD_START
+ i
)));
265 return (*pAuthFieldNameList
)[static_cast< sal_uInt16
>(eType
)];
268 const String
& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType
)
270 if(!pAuthFieldTypeList
)
272 pAuthFieldTypeList
= new std::vector
<String
>;
273 pAuthFieldTypeList
->reserve(AUTH_TYPE_END
);
274 for(sal_uInt16 i
= 0; i
< AUTH_TYPE_END
; ++i
)
275 pAuthFieldTypeList
->push_back(String(SW_RES(STR_AUTH_TYPE_START
+ i
)));
277 return (*pAuthFieldTypeList
)[static_cast< sal_uInt16
>(eType
)];
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */