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 <sfx2/objface.hxx>
21 #include <svl/whiter.hxx>
22 #include <sfx2/sfx.hrc>
23 #include <sfx2/viewsh.hxx>
24 #include <svx/svxids.hrc>
25 #include <vcl/virdev.hxx>
26 #include <unotools/syslocale.hxx>
29 #include "cfgitem.hxx"
33 #include "starmath.hrc"
34 #include "svx/modctrl.hxx"
38 #include "smslots.hxx"
40 SmResId::SmResId( sal_uInt16 nId
)
41 : ResId(nId
, *SM_MOD()->GetResMgr())
45 SmLocalizedSymbolData::SmLocalizedSymbolData() :
46 aUiSymbolNamesAry ( SmResId(RID_UI_SYMBOL_NAMES
) ),
47 aExportSymbolNamesAry ( SmResId(RID_EXPORT_SYMBOL_NAMES
) ),
48 aUiSymbolSetNamesAry ( SmResId(RID_UI_SYMBOLSET_NAMES
) ),
49 aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES
) )
53 SmLocalizedSymbolData::~SmLocalizedSymbolData()
57 const OUString
SmLocalizedSymbolData::GetUiSymbolName( const OUString
&rExportName
)
61 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
62 const ResStringArray
&rUiNames
= rData
.GetUiSymbolNamesArray();
63 const ResStringArray
&rExportNames
= rData
.GetExportSymbolNamesArray();
64 sal_uInt32 nCount
= rExportNames
.Count();
65 for (sal_uInt32 i
= 0; i
< nCount
; ++i
)
67 if (rExportNames
.GetString(i
).equals(rExportName
))
69 aRes
= rUiNames
.GetString(i
);
77 const OUString
SmLocalizedSymbolData::GetExportSymbolName( const OUString
&rUiName
)
81 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
82 const ResStringArray
&rUiNames
= rData
.GetUiSymbolNamesArray();
83 const ResStringArray
&rExportNames
= rData
.GetExportSymbolNamesArray();
84 sal_uInt32 nCount
= rUiNames
.Count();
85 for (sal_uInt32 i
= 0; i
< nCount
; ++i
)
87 if (rUiNames
.GetString(i
).equals(rUiName
))
89 aRes
= rExportNames
.GetString(i
);
97 const OUString
SmLocalizedSymbolData::GetUiSymbolSetName( const OUString
&rExportName
)
101 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
102 const ResStringArray
&rUiNames
= rData
.GetUiSymbolSetNamesArray();
103 const ResStringArray
&rExportNames
= rData
.GetExportSymbolSetNamesArray();
104 sal_uInt32 nCount
= rExportNames
.Count();
105 for (sal_uInt32 i
= 0; i
< nCount
; ++i
)
107 if (rExportNames
.GetString(i
).equals(rExportName
))
109 aRes
= rUiNames
.GetString(i
);
117 const OUString
SmLocalizedSymbolData::GetExportSymbolSetName( const OUString
&rUiName
)
121 const SmLocalizedSymbolData
&rData
= SM_MOD()->GetLocSymbolData();
122 const ResStringArray
&rUiNames
= rData
.GetUiSymbolSetNamesArray();
123 const ResStringArray
&rExportNames
= rData
.GetExportSymbolSetNamesArray();
124 sal_uInt32 nCount
= rUiNames
.Count();
125 for (sal_uInt32 i
= 0; i
< nCount
; ++i
)
127 if (rUiNames
.GetString(i
).equals(rUiName
))
129 aRes
= rExportNames
.GetString(i
);
137 SFX_IMPL_INTERFACE(SmModule
, SfxModule
)
139 void SmModule::InitInterface_Impl()
141 GetStaticInterface()->RegisterStatusBar(RID_STATUSBAR
);
144 SmModule::SmModule(SfxObjectFactory
* pObjFact
) :
145 SfxModule("sm", {pObjFact
})
149 SvxModifyControl::RegisterControl(SID_DOC_MODIFIED
, this);
152 SmModule::~SmModule()
155 mpColorConfig
->RemoveListener(this);
156 mpVirtualDev
.disposeAndClear();
159 void SmModule::ApplyColorConfigValues( const svtools::ColorConfig
&rColorCfg
)
161 //invalidate all graphic and edit windows
162 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
165 if ((dynamic_cast<const SmViewShell
*>(pViewShell
) != nullptr))
167 SmViewShell
*pSmView
= static_cast<SmViewShell
*>(pViewShell
);
168 pSmView
->GetGraphicWindow().ApplyColorConfigValues( rColorCfg
);
169 SmEditWindow
*pEditWin
= pSmView
->GetEditWindow();
171 pEditWin
->ApplyColorConfigValues( rColorCfg
);
173 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
177 svtools::ColorConfig
& SmModule::GetColorConfig()
181 mpColorConfig
.reset(new svtools::ColorConfig
);
182 ApplyColorConfigValues( *mpColorConfig
);
183 mpColorConfig
->AddListener(this);
185 return *mpColorConfig
;
188 void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
)
190 ApplyColorConfigValues(*mpColorConfig
);
193 SmMathConfig
* SmModule::GetConfig()
196 mpConfig
.reset(new SmMathConfig
);
197 return mpConfig
.get();
200 SmSymbolManager
& SmModule::GetSymbolManager()
202 return GetConfig()->GetSymbolManager();
205 SmLocalizedSymbolData
& SmModule::GetLocSymbolData()
207 if (!mpLocSymbolData
)
208 mpLocSymbolData
.reset(new SmLocalizedSymbolData
);
209 return *mpLocSymbolData
;
212 const SvtSysLocale
& SmModule::GetSysLocale()
215 mpSysLocale
.reset(new SvtSysLocale
);
219 VirtualDevice
&SmModule::GetDefaultVirtualDev()
223 mpVirtualDev
.reset( VclPtr
<VirtualDevice
>::Create() );
224 mpVirtualDev
->SetReferenceDevice( VirtualDevice::RefDevMode::MSO1
);
226 return *mpVirtualDev
;
229 void SmModule::GetState(SfxItemSet
&rSet
)
231 SfxWhichIter
aIter(rSet
);
233 for (sal_uInt16 nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich())
236 case SID_CONFIGEVENT
:
237 rSet
.DisableItem(SID_CONFIGEVENT
);
242 SfxItemSet
* SmModule::CreateItemSet( sal_uInt16 nId
)
244 SfxItemSet
* pRet
= nullptr;
245 if(nId
== SID_SM_EDITOPTIONS
)
247 pRet
= new SfxItemSet(GetPool(),
249 SID_PRINTSIZE
, SID_PRINTSIZE
,
250 SID_PRINTZOOM
, SID_PRINTZOOM
,
251 SID_PRINTTITLE
, SID_PRINTTITLE
,
252 SID_PRINTTEXT
, SID_PRINTTEXT
,
253 SID_PRINTFRAME
, SID_PRINTFRAME
,
254 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
255 SID_SAVE_ONLY_USED_SYMBOLS
, SID_SAVE_ONLY_USED_SYMBOLS
,
256 SID_AUTO_CLOSE_BRACKETS
, SID_AUTO_CLOSE_BRACKETS
,
259 GetConfig()->ConfigToItemSet(*pRet
);
264 void SmModule::ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
)
266 if(nId
== SID_SM_EDITOPTIONS
)
268 GetConfig()->ItemSetToConfig(rSet
);
272 VclPtr
<SfxTabPage
> SmModule::CreateTabPage( sal_uInt16 nId
, vcl::Window
* pParent
, const SfxItemSet
& rSet
)
274 VclPtr
<SfxTabPage
> pRet
;
275 if(nId
== SID_SM_TP_PRINTOPTIONS
)
276 pRet
= SmPrintOptionsTabPage::Create( pParent
, rSet
);
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */