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 <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>
41 #include "starmath.hrc"
42 #include "svx/modctrl.hxx"
44 TYPEINIT1( SmModule
, SfxModule
);
47 #include "smslots.hxx"
49 #include <svx/xmlsecctrl.hxx>
53 SmResId::SmResId( sal_uInt16 nId
)
54 : ResId(nId
, *SM_MOD()->GetResMgr())
58 /////////////////////////////////////////////////////////////////
60 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 aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES
) ),
68 n50NamesLang ( LANGUAGE_NONE
),
69 n60NamesLang ( LANGUAGE_NONE
)
75 SmLocalizedSymbolData::~SmLocalizedSymbolData()
82 const String
SmLocalizedSymbolData::GetUiSymbolName( const String
&rExportName
) const
86 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
87 const ResStringArray
&rUiNames
= rData
.GetUiSymbolNamesArray();
88 const ResStringArray
&rExportNames
= rData
.GetExportSymbolNamesArray();
89 sal_uInt16 nCount
= sal::static_int_cast
< xub_StrLen
>(rExportNames
.Count());
90 for (sal_uInt16 i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
92 if (rExportNames
.GetString(i
).equals(rExportName
))
94 aRes
= rUiNames
.GetString(i
);
103 const String
SmLocalizedSymbolData::GetExportSymbolName( const String
&rUiName
) const
107 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
108 const ResStringArray
&rUiNames
= rData
.GetUiSymbolNamesArray();
109 const ResStringArray
&rExportNames
= rData
.GetExportSymbolNamesArray();
110 sal_uInt16 nCount
= sal::static_int_cast
< xub_StrLen
>(rUiNames
.Count());
111 for (sal_uInt16 i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
113 if (rUiNames
.GetString(i
).equals(rUiName
))
115 aRes
= rExportNames
.GetString(i
);
124 const String
SmLocalizedSymbolData::GetUiSymbolSetName( const String
&rExportName
) const
128 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
129 const ResStringArray
&rUiNames
= rData
.GetUiSymbolSetNamesArray();
130 const ResStringArray
&rExportNames
= rData
.GetExportSymbolSetNamesArray();
131 sal_uInt16 nCount
= sal::static_int_cast
< xub_StrLen
>(rExportNames
.Count());
132 for (sal_uInt16 i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
134 if (rExportNames
.GetString(i
).equals(rExportName
))
136 aRes
= rUiNames
.GetString(i
);
145 const String
SmLocalizedSymbolData::GetExportSymbolSetName( const String
&rUiName
) const
149 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
150 const ResStringArray
&rUiNames
= rData
.GetUiSymbolSetNamesArray();
151 const ResStringArray
&rExportNames
= rData
.GetExportSymbolSetNamesArray();
152 sal_uInt16 nCount
= sal::static_int_cast
< xub_StrLen
>(rUiNames
.Count());
153 for (sal_uInt16 i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
155 if (rUiNames
.GetString(i
).equals(rUiName
))
157 aRes
= rExportNames
.GetString(i
);
166 const ResStringArray
* SmLocalizedSymbolData::Get50NamesArray( LanguageType nLang
)
168 if (nLang
!= n50NamesLang
)
173 case LANGUAGE_FRENCH
: nRID
= RID_FRENCH_50_NAMES
; break;
174 case LANGUAGE_ITALIAN
: nRID
= RID_ITALIAN_50_NAMES
; break;
175 case LANGUAGE_SWEDISH
: nRID
= RID_SWEDISH_50_NAMES
; break;
176 case LANGUAGE_SPANISH
: nRID
= RID_SPANISH_50_NAMES
; break;
177 default : nRID
= -1; break;
181 n50NamesLang
= nLang
;
183 p50NamesAry
= new SmNamesArray( n50NamesLang
, nRID
);
186 return p50NamesAry
? &p50NamesAry
->GetNamesArray() : 0;
190 const ResStringArray
* SmLocalizedSymbolData::Get60NamesArray( LanguageType nLang
)
192 if (nLang
!= n60NamesLang
)
197 case LANGUAGE_FRENCH
: nRID
= RID_FRENCH_60_NAMES
; break;
198 case LANGUAGE_ITALIAN
: nRID
= RID_ITALIAN_60_NAMES
; break;
199 case LANGUAGE_SWEDISH
: nRID
= RID_SWEDISH_60_NAMES
; break;
200 case LANGUAGE_SPANISH
: nRID
= RID_SPANISH_60_NAMES
; break;
201 default : nRID
= -1; break;
205 n60NamesLang
= nLang
;
207 p60NamesAry
= new SmNamesArray( n60NamesLang
, nRID
);
210 return p60NamesAry
? &p60NamesAry
->GetNamesArray() : 0;
213 /////////////////////////////////////////////////////////////////
215 SFX_IMPL_INTERFACE(SmModule
, SfxModule
, SmResId(RID_APPLICATION
))
217 SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR
));
221 SmModule::SmModule(SfxObjectFactory
* pObjFact
) :
222 SfxModule(SfxApplication::CreateResManager("sm"), sal_False
, pObjFact
, NULL
),
229 SetName(OUString("StarMath"));
231 SvxModifyControl::RegisterControl(SID_DOC_MODIFIED
, this);
235 SmModule::~SmModule()
239 pColorConfig
->RemoveListener(this);
241 delete pLocSymbolData
;
246 void SmModule::_CreateSysLocale() const
248 SmModule
* pThis
= (SmModule
*)this;
249 pThis
->pSysLocale
= new SvtSysLocale
;
252 void SmModule::_CreateVirtualDev() const
254 SmModule
* pThis
= (SmModule
*)this;
255 pThis
->pVirtualDev
= new VirtualDevice
;
256 pThis
->pVirtualDev
->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1
);
259 void SmModule::ApplyColorConfigValues( const svtools::ColorConfig
&rColorCfg
)
261 //invalidate all graphic and edit windows
262 const TypeId aSmViewTypeId
= TYPE(SmViewShell
);
263 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
266 if ((pViewShell
->IsA(aSmViewTypeId
)))
268 SmViewShell
*pSmView
= (SmViewShell
*) pViewShell
;
269 pSmView
->GetGraphicWindow().ApplyColorConfigValues( rColorCfg
);
270 SmEditWindow
*pEditWin
= pSmView
->GetEditWindow();
272 pEditWin
->ApplyColorConfigValues( rColorCfg
);
274 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
278 svtools::ColorConfig
& SmModule::GetColorConfig()
282 pColorConfig
= new svtools::ColorConfig
;
283 ApplyColorConfigValues( *pColorConfig
);
284 pColorConfig
->AddListener(this);
286 return *pColorConfig
;
289 void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster
*, sal_uInt32
)
291 ApplyColorConfigValues(*pColorConfig
);
294 SmConfig
* SmModule::GetConfig()
297 pConfig
= new SmConfig
;
301 SmSymbolManager
& SmModule::GetSymbolManager()
303 return GetConfig()->GetSymbolManager();
306 SmLocalizedSymbolData
& SmModule::GetLocSymbolData() const
309 ((SmModule
*) this)->pLocSymbolData
= new SmLocalizedSymbolData
;
310 return *pLocSymbolData
;
313 void SmModule::GetState(SfxItemSet
&rSet
)
315 SfxWhichIter
aIter(rSet
);
317 for (sal_uInt16 nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich())
320 case SID_CONFIGEVENT
:
321 rSet
.DisableItem(SID_CONFIGEVENT
);
326 SfxItemSet
* SmModule::CreateItemSet( sal_uInt16 nId
)
328 SfxItemSet
* pRet
= 0;
329 if(nId
== SID_SM_EDITOPTIONS
)
331 pRet
= new SfxItemSet(GetPool(),
333 SID_PRINTSIZE
, SID_PRINTSIZE
,
334 SID_PRINTZOOM
, SID_PRINTZOOM
,
335 SID_PRINTTITLE
, SID_PRINTTITLE
,
336 SID_PRINTTEXT
, SID_PRINTTEXT
,
337 SID_PRINTFRAME
, SID_PRINTFRAME
,
338 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
339 SID_SAVE_ONLY_USED_SYMBOLS
, SID_SAVE_ONLY_USED_SYMBOLS
,
342 GetConfig()->ConfigToItemSet(*pRet
);
346 void SmModule::ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
)
348 if(nId
== SID_SM_EDITOPTIONS
)
350 GetConfig()->ItemSetToConfig(rSet
);
353 SfxTabPage
* SmModule::CreateTabPage( sal_uInt16 nId
, Window
* pParent
, const SfxItemSet
& rSet
)
355 SfxTabPage
* pRet
= 0;
356 if(nId
== SID_SM_TP_PRINTOPTIONS
)
357 pRet
= SmPrintOptionsTabPage::Create( pParent
, rSet
);
362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */