Line data Source code
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 <tools/globname.hxx>
21 : #include <vcl/status.hxx>
22 : #include <sfx2/msg.hxx>
23 : #include <sfx2/app.hxx>
24 : #include <sfx2/objface.hxx>
25 : #include <svl/whiter.hxx>
26 : #include <sfx2/request.hxx>
27 : #include <sfx2/sfx.hrc>
28 : #include <sfx2/viewsh.hxx>
29 : #include <vcl/wrkwin.hxx>
30 : #include <svx/svxids.hrc>
31 : #include <vcl/msgbox.hxx>
32 : #include <vcl/virdev.hxx>
33 : #include <unotools/syslocale.hxx>
34 : #include <tools/rtti.hxx>
35 : #include "smmod.hxx"
36 : #include "symbol.hxx"
37 : #include "config.hxx"
38 : #include "dialog.hxx"
39 : #include "edit.hxx"
40 : #include "view.hxx"
41 : #include "starmath.hrc"
42 : #include "svx/modctrl.hxx"
43 :
44 102 : TYPEINIT1( SmModule, SfxModule );
45 :
46 : #define SmModule
47 : #include "smslots.hxx"
48 :
49 : #include <svx/xmlsecctrl.hxx>
50 :
51 :
52 :
53 4429 : SmResId::SmResId( sal_uInt16 nId )
54 4429 : : ResId(nId, *SM_MOD()->GetResMgr())
55 : {
56 4429 : }
57 :
58 :
59 :
60 14 : SmLocalizedSymbolData::SmLocalizedSymbolData() :
61 : Resource( SmResId(RID_LOCALIZED_NAMES) ),
62 : aUiSymbolNamesAry ( SmResId(RID_UI_SYMBOL_NAMES) ),
63 : aExportSymbolNamesAry ( SmResId(RID_EXPORT_SYMBOL_NAMES) ),
64 : aUiSymbolSetNamesAry ( SmResId(RID_UI_SYMBOLSET_NAMES) ),
65 14 : aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES) )
66 : {
67 14 : FreeResource();
68 14 : }
69 :
70 :
71 7 : SmLocalizedSymbolData::~SmLocalizedSymbolData()
72 : {
73 7 : }
74 :
75 :
76 462 : const OUString SmLocalizedSymbolData::GetUiSymbolName( const OUString &rExportName ) const
77 : {
78 462 : OUString aRes;
79 :
80 462 : const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
81 462 : const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
82 462 : const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
83 462 : sal_uInt32 nCount = rExportNames.Count();
84 15477 : for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
85 : {
86 15477 : if (rExportNames.GetString(i).equals(rExportName))
87 : {
88 462 : aRes = rUiNames.GetString(i);
89 462 : break;
90 : }
91 : }
92 :
93 462 : return aRes;
94 : }
95 :
96 :
97 0 : const OUString SmLocalizedSymbolData::GetExportSymbolName( const OUString &rUiName ) const
98 : {
99 0 : OUString aRes;
100 :
101 0 : const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
102 0 : const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
103 0 : const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
104 0 : sal_uInt32 nCount = rUiNames.Count();
105 0 : for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
106 : {
107 0 : if (rUiNames.GetString(i).equals(rUiName))
108 : {
109 0 : aRes = rExportNames.GetString(i);
110 0 : break;
111 : }
112 : }
113 :
114 0 : return aRes;
115 : }
116 :
117 :
118 469 : const OUString SmLocalizedSymbolData::GetUiSymbolSetName( const OUString &rExportName ) const
119 : {
120 469 : OUString aRes;
121 :
122 469 : const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
123 469 : const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
124 469 : const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
125 469 : sal_uInt32 nCount = rExportNames.Count();
126 553 : for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
127 : {
128 553 : if (rExportNames.GetString(i).equals(rExportName))
129 : {
130 469 : aRes = rUiNames.GetString(i);
131 469 : break;
132 : }
133 : }
134 :
135 469 : return aRes;
136 : }
137 :
138 :
139 130 : const OUString SmLocalizedSymbolData::GetExportSymbolSetName( const OUString &rUiName ) const
140 : {
141 130 : OUString aRes;
142 :
143 130 : const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
144 130 : const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
145 130 : const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
146 130 : sal_uInt32 nCount = rUiNames.Count();
147 154 : for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
148 : {
149 154 : if (rUiNames.GetString(i).equals(rUiName))
150 : {
151 130 : aRes = rExportNames.GetString(i);
152 130 : break;
153 : }
154 : }
155 :
156 130 : return aRes;
157 : }
158 :
159 :
160 :
161 380 : SFX_IMPL_INTERFACE(SmModule, SfxModule, SmResId(RID_APPLICATION))
162 : {
163 9 : SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR));
164 9 : }
165 :
166 :
167 9 : SmModule::SmModule(SfxObjectFactory* pObjFact) :
168 : SfxModule(SfxApplication::CreateResManager("sm"), false, pObjFact, NULL),
169 : pColorConfig( 0 ),
170 : pConfig( 0 ),
171 : pLocSymbolData( 0 ),
172 : pSysLocale( 0 ),
173 9 : pVirtualDev( 0 )
174 : {
175 9 : SetName(OUString("StarMath"));
176 :
177 9 : SvxModifyControl::RegisterControl(SID_DOC_MODIFIED, this);
178 9 : }
179 :
180 :
181 6 : SmModule::~SmModule()
182 : {
183 2 : delete pConfig;
184 2 : if (pColorConfig)
185 2 : pColorConfig->RemoveListener(this);
186 2 : delete pColorConfig;
187 2 : delete pLocSymbolData;
188 2 : delete pSysLocale;
189 2 : delete pVirtualDev;
190 4 : }
191 :
192 9 : void SmModule::_CreateSysLocale() const
193 : {
194 9 : SmModule* pThis = (SmModule*)this;
195 9 : pThis->pSysLocale = new SvtSysLocale;
196 9 : }
197 :
198 9 : void SmModule::_CreateVirtualDev() const
199 : {
200 9 : SmModule* pThis = (SmModule*)this;
201 9 : pThis->pVirtualDev = new VirtualDevice;
202 9 : pThis->pVirtualDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
203 9 : }
204 :
205 11 : void SmModule::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg )
206 : {
207 : //invalidate all graphic and edit windows
208 11 : const TypeId aSmViewTypeId = TYPE(SmViewShell);
209 11 : SfxViewShell* pViewShell = SfxViewShell::GetFirst();
210 23 : while (pViewShell)
211 : {
212 1 : if ((pViewShell->IsA(aSmViewTypeId)))
213 : {
214 0 : SmViewShell *pSmView = (SmViewShell *) pViewShell;
215 0 : pSmView->GetGraphicWindow().ApplyColorConfigValues( rColorCfg );
216 0 : SmEditWindow *pEditWin = pSmView->GetEditWindow();
217 0 : if (pEditWin)
218 0 : pEditWin->ApplyColorConfigValues( rColorCfg );
219 : }
220 1 : pViewShell = SfxViewShell::GetNext( *pViewShell );
221 : }
222 11 : }
223 :
224 51096 : svtools::ColorConfig & SmModule::GetColorConfig()
225 : {
226 51096 : if(!pColorConfig)
227 : {
228 9 : pColorConfig = new svtools::ColorConfig;
229 9 : ApplyColorConfigValues( *pColorConfig );
230 9 : pColorConfig->AddListener(this);
231 : }
232 51096 : return *pColorConfig;
233 : }
234 :
235 2 : void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
236 : {
237 2 : ApplyColorConfigValues(*pColorConfig);
238 2 : }
239 :
240 4285 : SmConfig * SmModule::GetConfig()
241 : {
242 4285 : if(!pConfig)
243 9 : pConfig = new SmConfig;
244 4285 : return pConfig;
245 : }
246 :
247 2676 : SmSymbolManager & SmModule::GetSymbolManager()
248 : {
249 2676 : return GetConfig()->GetSymbolManager();
250 : }
251 :
252 2115 : SmLocalizedSymbolData & SmModule::GetLocSymbolData() const
253 : {
254 2115 : if (!pLocSymbolData)
255 7 : ((SmModule *) this)->pLocSymbolData = new SmLocalizedSymbolData;
256 2115 : return *pLocSymbolData;
257 : }
258 :
259 0 : void SmModule::GetState(SfxItemSet &rSet)
260 : {
261 0 : SfxWhichIter aIter(rSet);
262 :
263 0 : for (sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich())
264 0 : switch (nWh)
265 : {
266 : case SID_CONFIGEVENT :
267 0 : rSet.DisableItem(SID_CONFIGEVENT);
268 0 : break;
269 0 : }
270 0 : }
271 :
272 0 : SfxItemSet* SmModule::CreateItemSet( sal_uInt16 nId )
273 : {
274 0 : SfxItemSet* pRet = 0;
275 0 : if(nId == SID_SM_EDITOPTIONS)
276 : {
277 0 : pRet = new SfxItemSet(GetPool(),
278 : //TP_SMPRINT
279 : SID_PRINTSIZE, SID_PRINTSIZE,
280 : SID_PRINTZOOM, SID_PRINTZOOM,
281 : SID_PRINTTITLE, SID_PRINTTITLE,
282 : SID_PRINTTEXT, SID_PRINTTEXT,
283 : SID_PRINTFRAME, SID_PRINTFRAME,
284 : SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
285 : SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
286 0 : 0 );
287 :
288 0 : GetConfig()->ConfigToItemSet(*pRet);
289 : }
290 0 : return pRet;
291 : }
292 0 : void SmModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
293 : {
294 0 : if(nId == SID_SM_EDITOPTIONS)
295 : {
296 0 : GetConfig()->ItemSetToConfig(rSet);
297 : }
298 0 : }
299 0 : SfxTabPage* SmModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
300 : {
301 0 : SfxTabPage* pRet = 0;
302 0 : if(nId == SID_SM_TP_PRINTOPTIONS)
303 0 : pRet = SmPrintOptionsTabPage::Create( pParent, rSet );
304 0 : return pRet;
305 :
306 27 : }
307 :
308 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|