1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: smmod.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_starmath.hxx"
35 #include <tools/globname.hxx>
36 #include <vcl/status.hxx>
37 #include <sfx2/msg.hxx>
38 #include <sfx2/app.hxx>
39 #include <sfx2/objface.hxx>
40 #include <svtools/whiter.hxx>
41 #include <sfx2/request.hxx>
42 #include <sfx2/sfx.hrc>
43 #include <sfx2/viewsh.hxx>
44 #include <vcl/wrkwin.hxx>
45 #ifndef _SVX_SVXIDS_HRC //autogen
46 #include <svx/svxids.hrc>
48 #include <vcl/msgbox.hxx>
49 #include <vcl/virdev.hxx>
50 #include <svtools/syslocale.hxx>
51 #include <tools/rtti.hxx>
60 #include "starmath.hrc"
61 #include "svx/modctrl.hxx"
63 TYPEINIT1( SmModule
, SfxModule
);
66 #include "smslots.hxx"
68 #include <svx/xmlsecctrl.hxx>
72 SmResId::SmResId( USHORT nId
)
73 : ResId(nId
, *SM_MOD()->GetResMgr())
77 /////////////////////////////////////////////////////////////////
79 SmLocalizedSymbolData::SmLocalizedSymbolData() :
80 Resource( SmResId(RID_LOCALIZED_NAMES
) ),
81 aUiSymbolNamesAry ( SmResId(RID_UI_SYMBOL_NAMES
) ),
82 aExportSymbolNamesAry ( SmResId(RID_EXPORT_SYMBOL_NAMES
) ),
83 aUiSymbolSetNamesAry ( SmResId(RID_UI_SYMBOLSET_NAMES
) ),
84 aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES
) ),
87 n50NamesLang ( LANGUAGE_NONE
),
88 n60NamesLang ( LANGUAGE_NONE
)
94 SmLocalizedSymbolData::~SmLocalizedSymbolData()
101 const String
SmLocalizedSymbolData::GetUiSymbolName( const String
&rExportName
) const
105 const SmLocalizedSymbolData
&rData
= SM_MOD1()->GetLocSymbolData();
106 const ResStringArray
&rUiNames
= rData
.GetUiSymbolNamesArray();
107 const ResStringArray
&rExportNames
= rData
.GetExportSymbolNamesArray();
108 USHORT nCount
= sal::static_int_cast
< xub_StrLen
>(rExportNames
.Count());
109 for (USHORT i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
111 if (rExportName
== rExportNames
.GetString(i
))
113 aRes
= rUiNames
.GetString(i
);
122 const String
SmLocalizedSymbolData::GetExportSymbolName( const String
&rUiName
) const
126 const SmLocalizedSymbolData
&rData
= SM_MOD1()->GetLocSymbolData();
127 const ResStringArray
&rUiNames
= rData
.GetUiSymbolNamesArray();
128 const ResStringArray
&rExportNames
= rData
.GetExportSymbolNamesArray();
129 USHORT nCount
= sal::static_int_cast
< xub_StrLen
>(rUiNames
.Count());
130 for (USHORT i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
132 if (rUiName
== rUiNames
.GetString(i
))
134 aRes
= rExportNames
.GetString(i
);
143 const String
SmLocalizedSymbolData::GetUiSymbolSetName( const String
&rExportName
) const
147 const SmLocalizedSymbolData
&rData
= SM_MOD1()->GetLocSymbolData();
148 const ResStringArray
&rUiNames
= rData
.GetUiSymbolSetNamesArray();
149 const ResStringArray
&rExportNames
= rData
.GetExportSymbolSetNamesArray();
150 USHORT nCount
= sal::static_int_cast
< xub_StrLen
>(rExportNames
.Count());
151 for (USHORT i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
153 if (rExportName
== rExportNames
.GetString(i
))
155 aRes
= rUiNames
.GetString(i
);
164 const String
SmLocalizedSymbolData::GetExportSymbolSetName( const String
&rUiName
) const
168 const SmLocalizedSymbolData
&rData
= SM_MOD1()->GetLocSymbolData();
169 const ResStringArray
&rUiNames
= rData
.GetUiSymbolSetNamesArray();
170 const ResStringArray
&rExportNames
= rData
.GetExportSymbolSetNamesArray();
171 USHORT nCount
= sal::static_int_cast
< xub_StrLen
>(rUiNames
.Count());
172 for (USHORT i
= 0; i
< nCount
&& !aRes
.Len(); ++i
)
174 if (rUiName
== rUiNames
.GetString(i
))
176 aRes
= rExportNames
.GetString(i
);
185 const ResStringArray
* SmLocalizedSymbolData::Get50NamesArray( LanguageType nLang
)
187 if (nLang
!= n50NamesLang
)
192 case LANGUAGE_FRENCH
: nRID
= RID_FRENCH_50_NAMES
; break;
193 case LANGUAGE_ITALIAN
: nRID
= RID_ITALIAN_50_NAMES
; break;
194 case LANGUAGE_SWEDISH
: nRID
= RID_SWEDISH_50_NAMES
; break;
195 case LANGUAGE_SPANISH
: nRID
= RID_SPANISH_50_NAMES
; break;
196 default : nRID
= -1; break;
200 n50NamesLang
= nLang
;
202 p50NamesAry
= new SmNamesArray( n50NamesLang
, nRID
);
205 return p50NamesAry
? &p50NamesAry
->GetNamesArray() : 0;
209 const ResStringArray
* SmLocalizedSymbolData::Get60NamesArray( LanguageType nLang
)
211 if (nLang
!= n60NamesLang
)
216 case LANGUAGE_FRENCH
: nRID
= RID_FRENCH_60_NAMES
; break;
217 case LANGUAGE_ITALIAN
: nRID
= RID_ITALIAN_60_NAMES
; break;
218 case LANGUAGE_SWEDISH
: nRID
= RID_SWEDISH_60_NAMES
; break;
219 case LANGUAGE_SPANISH
: nRID
= RID_SPANISH_60_NAMES
; break;
220 default : nRID
= -1; break;
224 n60NamesLang
= nLang
;
226 p60NamesAry
= new SmNamesArray( n60NamesLang
, nRID
);
229 return p60NamesAry
? &p60NamesAry
->GetNamesArray() : 0;
232 /////////////////////////////////////////////////////////////////
234 SFX_IMPL_INTERFACE(SmModule
, SfxModule
, SmResId(RID_APPLICATION
))
236 SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR
));
240 SmModule::SmModule(SfxObjectFactory
* pObjFact
) :
241 SfxModule(SfxApplication::CreateResManager("sm"), FALSE
, pObjFact
, NULL
),
248 SetName( C2S("StarMath" ));
250 SvxModifyControl::RegisterControl(SID_DOC_MODIFIED
, this);
254 SmModule::~SmModule()
258 delete pLocSymbolData
;
263 void SmModule::_CreateSysLocale() const
265 SmModule
* pThis
= (SmModule
*)this;
266 pThis
->pSysLocale
= new SvtSysLocale
;
269 void SmModule::_CreateVirtualDev() const
271 SmModule
* pThis
= (SmModule
*)this;
272 pThis
->pVirtualDev
= new VirtualDevice
;
273 pThis
->pVirtualDev
->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1
);
276 void SmModule::ApplyColorConfigValues( const svtools::ColorConfig
&rColorCfg
)
278 //invalidate all graphic and edit windows
279 const TypeId aSmViewTypeId
= TYPE(SmViewShell
);
280 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
283 if ((pViewShell
->IsA(aSmViewTypeId
)))
285 SmViewShell
*pSmView
= (SmViewShell
*) pViewShell
;
286 pSmView
->GetGraphicWindow().ApplyColorConfigValues( rColorCfg
);
287 SmEditWindow
*pEditWin
= pSmView
->GetEditWindow();
289 pEditWin
->ApplyColorConfigValues( rColorCfg
);
291 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
295 svtools::ColorConfig
& SmModule::GetColorConfig()
299 pColorConfig
= new svtools::ColorConfig
;
300 ApplyColorConfigValues( *pColorConfig
);
301 StartListening( *pColorConfig
);
303 return *pColorConfig
;
306 void SmModule::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
&rHint
)
308 if (rHint
.ISA(SfxSimpleHint
))
310 ULONG nHintId
= ((SfxSimpleHint
&)rHint
).GetId();
311 if (SFX_HINT_COLORS_CHANGED
== nHintId
)
312 ApplyColorConfigValues(*pColorConfig
);
316 SmConfig
* SmModule::GetConfig()
319 pConfig
= new SmConfig
;
323 SmSymSetManager
& SmModule::GetSymSetManager()
325 return GetConfig()->GetSymSetManager();
328 SmLocalizedSymbolData
& SmModule::GetLocSymbolData() const
331 ((SmModule
*) this)->pLocSymbolData
= new SmLocalizedSymbolData
;
332 return *pLocSymbolData
;
335 void SmModule::GetState(SfxItemSet
&rSet
)
337 SfxWhichIter
aIter(rSet
);
339 for (USHORT nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich())
342 case SID_CONFIGEVENT
:
343 rSet
.DisableItem(SID_CONFIGEVENT
);
348 void SmModule::FillStatusBar(StatusBar
&rBar
)
350 rBar
.InsertItem(SID_TEXTSTATUS
, 300, SIB_LEFT
| SIB_IN
);
351 rBar
.InsertItem(SID_ATTR_ZOOM
, rBar
.GetTextWidth(C2S(" 100% ")));
352 rBar
.InsertItem(SID_MODIFYSTATUS
, rBar
.GetTextWidth(C2S(" * ")));
353 rBar
.InsertItem( SID_SIGNATURE
, XmlSecStatusBarControl::GetDefItemWidth( rBar
), SIB_USERDRAW
);
354 rBar
.SetHelpId(SID_SIGNATURE
, SID_SIGNATURE
);
358 /* -----------------15.02.99 12:45-------------------
360 * --------------------------------------------------*/
361 SfxItemSet
* SmModule::CreateItemSet( USHORT nId
)
363 SfxItemSet
* pRet
= 0;
364 if(nId
== SID_SM_EDITOPTIONS
)
366 pRet
= new SfxItemSet(GetPool(),
368 SID_PRINTSIZE
, SID_PRINTSIZE
,
369 SID_PRINTZOOM
, SID_PRINTZOOM
,
370 SID_PRINTTITLE
, SID_PRINTTITLE
,
371 SID_PRINTTEXT
, SID_PRINTTEXT
,
372 SID_PRINTFRAME
, SID_PRINTFRAME
,
373 SID_NO_RIGHT_SPACES
, SID_NO_RIGHT_SPACES
,
376 GetConfig()->ConfigToItemSet(*pRet
);
380 /* -----------------15.02.99 12:45-------------------
382 * --------------------------------------------------*/
383 void SmModule::ApplyItemSet( USHORT nId
, const SfxItemSet
& rSet
)
385 if(nId
== SID_SM_EDITOPTIONS
)
387 GetConfig()->ItemSetToConfig(rSet
);
390 /* -----------------15.02.99 12:45-------------------
392 * --------------------------------------------------*/
393 SfxTabPage
* SmModule::CreateTabPage( USHORT nId
, Window
* pParent
, const SfxItemSet
& rSet
)
395 SfxTabPage
* pRet
= 0;
396 if(nId
== SID_SM_TP_PRINTOPTIONS
)
397 pRet
= SmPrintOptionsTabPage::Create( pParent
, rSet
);