Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <unotools/localedatawrapper.hxx>
30 : : #include <viewsh.hxx>
31 : : #include <initui.hxx>
32 : : #include <edtwin.hxx>
33 : : #include <shellres.hxx>
34 : : #include <fldbas.hxx>
35 : : #include <glosdoc.hxx>
36 : : #include <gloslst.hxx>
37 : :
38 : : #include <utlui.hrc>
39 : : #include <initui.hrc>
40 : : #include <comcore.hrc>
41 : : #include <authfld.hxx>
42 : : #include <dbmgr.hxx>
43 : : #include <unotools/syslocale.hxx>
44 : :
45 : : #include <unomid.h>
46 : :
47 : : /*--------------------------------------------------------------------
48 : : Beschreibung: globale Pointer
49 : : --------------------------------------------------------------------*/
50 : :
51 : : SwGlossaries* pGlossaries = 0;
52 : :
53 : : // Liefert alle benoetigten Pfade. Wird durch UI initialisiert
54 : : SwGlossaryList* pGlossaryList = 0;
55 : :
56 : : String* pOldGrfCat = 0;
57 : : String* pOldTabCat = 0;
58 : : String* pOldFrmCat = 0;
59 : : String* pOldDrwCat = 0;
60 : : String* pCurrGlosGroup = 0;
61 : :
62 : 0 : String* GetOldGrfCat()
63 : : {
64 : 0 : return pOldGrfCat;
65 : : }
66 : 0 : String* GetOldTabCat()
67 : : {
68 : 0 : return pOldTabCat;
69 : : }
70 : 0 : String* GetOldFrmCat()
71 : : {
72 : 0 : return pOldFrmCat;
73 : : }
74 : 0 : String* GetOldDrwCat()
75 : : {
76 : 0 : return pOldDrwCat;
77 : : }
78 : 0 : String* GetCurrGlosGroup()
79 : : {
80 : 0 : return pCurrGlosGroup;
81 : : }
82 : 0 : void SetCurrGlosGroup(String* pStr)
83 : : {
84 : 0 : pCurrGlosGroup = pStr;
85 : 0 : }
86 : :
87 : : std::vector<String>* pDBNameList = 0;
88 : :
89 : : std::vector<String>* pAuthFieldNameList = 0;
90 : : std::vector<String>* pAuthFieldTypeList = 0;
91 : :
92 : : /*--------------------------------------------------------------------
93 : : Beschreibung: UI beenden
94 : : --------------------------------------------------------------------*/
95 : :
96 : 73 : void _FinitUI()
97 : : {
98 : 73 : SwNewDBMgr::RemoveDbtoolsClient();
99 [ + - ]: 73 : delete ViewShell::GetShellRes();
100 : 73 : ViewShell::SetShellRes( 0 );
101 : :
102 : 73 : SwEditWin::_FinitStaticData();
103 : :
104 [ + + ]: 73 : DELETEZ(pGlossaries);
105 : :
106 [ + + ]: 73 : delete SwFieldType::pFldNames;
107 : :
108 [ - + ]: 73 : delete pOldGrfCat;
109 [ - + ]: 73 : delete pOldTabCat;
110 [ - + ]: 73 : delete pOldFrmCat;
111 [ - + ]: 73 : delete pOldDrwCat;
112 [ - + ]: 73 : delete pCurrGlosGroup;
113 [ + - ]: 73 : delete pDBNameList;
114 [ - + ]: 73 : delete pGlossaryList;
115 [ - + ]: 73 : delete pAuthFieldNameList;
116 [ - + ]: 73 : delete pAuthFieldTypeList;
117 : :
118 : :
119 : 73 : }
120 : : /*--------------------------------------------------------------------
121 : : Beschreibung: Initialisierung
122 : : --------------------------------------------------------------------*/
123 : :
124 : :
125 : 73 : void _InitUI()
126 : : {
127 : : // ShellResource gibt der CORE die Moeglichkeit mit Resourcen zu arbeiten
128 [ + - ]: 73 : ViewShell::SetShellRes( new ShellResource );
129 [ + - ]: 73 : pDBNameList = new std::vector<String>;
130 : 73 : SwEditWin::_InitStaticData();
131 : 73 : }
132 : :
133 : :
134 : 76 : ShellResource::ShellResource()
135 : : : Resource( SW_RES(RID_SW_SHELLRES) ),
136 : : aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR ) ),
137 : : aPostItPage( SW_RES( STR_POSTIT_PAGE ) ),
138 : : aPostItLine( SW_RES( STR_POSTIT_LINE ) ),
139 : :
140 : : aCalc_Syntax( SW_RES( STR_CALC_SYNTAX ) ),
141 : : aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ),
142 : : aCalc_Brack( SW_RES( STR_CALC_BRACK ) ),
143 : : aCalc_Pow( SW_RES( STR_CALC_POW ) ),
144 : : aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ),
145 : : aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ),
146 : : aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ),
147 : : aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ),
148 : : aCalc_Error( SW_RES( STR_CALC_ERROR ) ),
149 : :
150 : : aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP ) ),
151 : : aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN ) ),
152 : : // #i81002#
153 : : aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND ) ),
154 : : aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT ) ),
155 : : aStrNone( SW_RES( STR_TEMPLATE_NONE )),
156 : : aFixedStr( SW_RES( STR_FIELD_FIXED )),
157 : : sDurationFormat( SW_RES( STR_DURATION_FORMAT )),
158 : :
159 : : aTOXIndexName( SW_RES(STR_TOI)),
160 : : aTOXUserName( SW_RES(STR_TOU)),
161 : : aTOXContentName( SW_RES(STR_TOC)),
162 : : aTOXIllustrationsName( SW_RES(STR_TOX_ILL)),
163 : : aTOXObjectsName( SW_RES(STR_TOX_OBJ)),
164 : : aTOXTablesName( SW_RES(STR_TOX_TBL)),
165 : : aTOXAuthoritiesName( SW_RES(STR_TOX_AUTH)),
166 : : aHyperlinkClick( SW_RES( STR_HYPERLINK_CLICK)),
167 : : pAutoFmtNameLst(0),
168 : : sPageDescFirstName( SW_RES(STR_PAGEDESC_FIRSTNAME)),
169 : : sPageDescFollowName( SW_RES(STR_PAGEDESC_FOLLOWNAME)),
170 [ + - ][ + - ]: 76 : sPageDescName( SW_RES(STR_PAGEDESC_NAME))
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
171 : : {
172 : 76 : const sal_uInt16 nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN;
173 : :
174 : 76 : KeyCode aCode( KEY_SPACE );
175 : 76 : KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
176 [ + - ]: 76 : String aModStr( aModifiedCode.GetName() );
177 [ + - ][ + - ]: 76 : aModStr.SearchAndReplace( aCode.GetName(), String() );
[ + - ][ + - ]
[ + - ]
178 [ + - ][ + - ]: 76 : aModStr.SearchAndReplaceAllAscii( "+", String() );
[ + - ]
179 [ + - ]: 76 : aHyperlinkClick.SearchAndReplaceAllAscii( "%s", aModStr );
180 : :
181 [ + + ]: 760 : for(sal_uInt16 i = 0; i < nCount; ++i)
182 [ + - ][ + - ]: 684 : aDocInfoLst.push_back(String(SW_RESSTR(FLD_DOCINFO_BEGIN + i)));
[ + - ][ + - ]
183 : :
184 [ + - ][ + - ]: 76 : FreeResource();
185 : 76 : }
186 : :
187 [ + - ][ + - ]: 76 : ShellResource::~ShellResource()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
188 : : {
189 [ - + ]: 76 : delete pAutoFmtNameLst;
190 : 76 : }
191 : :
192 : 21 : String ShellResource::GetPageDescName( sal_uInt16 nNo, PageNameMode eMode )
193 : : {
194 : 21 : String sRet;
195 : :
196 [ + + + - ]: 21 : switch (eMode)
197 : : {
198 : : case NORMAL_PAGE:
199 [ + - ]: 9 : sRet = sPageDescName;
200 : 9 : break;
201 : : case FIRST_PAGE:
202 [ + - ]: 9 : sRet = sPageDescFirstName;
203 : 9 : break;
204 : : case FOLLOW_PAGE:
205 [ + - ]: 3 : sRet = sPageDescFollowName;
206 : 3 : break;
207 : : }
208 : :
209 [ + - ][ + - ]: 21 : sRet.SearchAndReplaceAscii( "$(ARG1)", String::CreateFromInt32( nNo ));
[ + - ]
210 : 21 : return sRet;
211 : : }
212 : :
213 : :
214 : 8 : SwGlossaries* GetGlossaries()
215 : : {
216 [ + + ]: 8 : if (!pGlossaries)
217 [ + - ]: 2 : pGlossaries = new SwGlossaries;
218 : 8 : return (pGlossaries);
219 : : }
220 : :
221 : 0 : sal_Bool HasGlossaryList()
222 : : {
223 : 0 : return pGlossaryList != 0;
224 : : }
225 : :
226 : 0 : SwGlossaryList* GetGlossaryList()
227 : : {
228 [ # # ]: 0 : if(!pGlossaryList)
229 [ # # ]: 0 : pGlossaryList = new SwGlossaryList();
230 : :
231 : 0 : return pGlossaryList;
232 : : }
233 : :
234 : 0 : struct ImpAutoFmtNameListLoader : public Resource
235 : : {
236 : : ImpAutoFmtNameListLoader( std::vector<String>& rLst );
237 : : };
238 : :
239 : 0 : void ShellResource::_GetAutoFmtNameLst() const
240 : : {
241 : 0 : std::vector<String>* pLst(pAutoFmtNameLst);
242 [ # # ][ # # ]: 0 : pLst = new std::vector<String>;
243 [ # # ]: 0 : pLst->reserve(STR_AUTOFMTREDL_END);
244 [ # # ]: 0 : ImpAutoFmtNameListLoader aTmp( *pLst );
245 : 0 : }
246 : :
247 : 0 : ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector<String>& rLst )
248 [ # # ]: 0 : : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) )
249 : : {
250 [ # # ]: 0 : for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n )
251 : : {
252 [ # # ]: 0 : String p(ResId(n + 1, *pSwResMgr));
253 [ # # ]: 0 : if(STR_AUTOFMTREDL_TYPO == n)
254 : : {
255 : : #ifdef WNT
256 : : //fuer Windows Sonderbehandlung, da MS hier ein paar Zeichen im Dialogfont vergessen hat
257 : : p.SearchAndReplace(rtl::OUString("%1"), rtl::OUString(",,"));
258 : : p.SearchAndReplace(rtl::OUString("%2"), rtl::OUString("''"));
259 : : #else
260 [ # # ]: 0 : const SvtSysLocale aSysLocale;
261 [ # # ]: 0 : const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData();
262 : : //unter richtigen Betriebssystemen funktioniert es auch so
263 [ # # ][ # # ]: 0 : p.SearchAndReplace(rtl::OUString("%1"), rLclD.getDoubleQuotationMarkStart());
[ # # ][ # # ]
[ # # ][ # # ]
264 [ # # ][ # # ]: 0 : p.SearchAndReplace(rtl::OUString("%2"), rLclD.getDoubleQuotationMarkEnd());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
265 : : #endif
266 : : }
267 [ # # ][ # # ]: 0 : rLst.insert(rLst.begin() + n, p);
268 [ # # ]: 0 : }
269 [ # # ]: 0 : FreeResource();
270 : 0 : }
271 : :
272 : 0 : const String& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType)
273 : : {
274 [ # # ]: 0 : if(!pAuthFieldNameList)
275 : : {
276 [ # # ]: 0 : pAuthFieldNameList = new std::vector<String>;
277 : 0 : pAuthFieldNameList->reserve(AUTH_FIELD_END);
278 [ # # ]: 0 : for(sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
279 [ # # ][ # # ]: 0 : pAuthFieldNameList->push_back(String(SW_RES(STR_AUTH_FIELD_START + i)));
[ # # ]
280 : : }
281 : 0 : return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)];
282 : : }
283 : :
284 : 0 : const String& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
285 : : {
286 [ # # ]: 0 : if(!pAuthFieldTypeList)
287 : : {
288 [ # # ]: 0 : pAuthFieldTypeList = new std::vector<String>;
289 : 0 : pAuthFieldTypeList->reserve(AUTH_TYPE_END);
290 [ # # ]: 0 : for(sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i)
291 [ # # ][ # # ]: 0 : pAuthFieldTypeList->push_back(String(SW_RES(STR_AUTH_TYPE_START + i)));
[ # # ]
292 : : }
293 : 0 : return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
294 : : }
295 : :
296 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|