summaryrefslogtreecommitdiff
path: root/starmath/source
diff options
context:
space:
mode:
authorThomas Lange <tl@openoffice.org>2001-05-02 15:58:48 +0000
committerThomas Lange <tl@openoffice.org>2001-05-02 15:58:48 +0000
commit8a4e3ca13cbc1d8c8d685b7bc706be7f335d999c (patch)
tree7e1cc4b01048106fe33ca9a506be303d76666649 /starmath/source
parenta5d680de2a79f61024587175bc19bf09bacb857e (diff)
Math configuration and Symbol/SymbolSet/SymbolSetManager
Diffstat (limited to 'starmath/source')
-rw-r--r--starmath/source/config.cxx244
-rw-r--r--starmath/source/dialog.cxx113
-rw-r--r--starmath/source/document.cxx100
-rw-r--r--starmath/source/format.cxx39
-rw-r--r--starmath/source/makefile.mk14
-rw-r--r--starmath/source/parse.cxx11
-rw-r--r--starmath/source/smdll.cxx6
-rw-r--r--starmath/source/smmod.cxx29
-rw-r--r--starmath/source/symbol.cxx435
-rw-r--r--starmath/source/toolbox.cxx6
-rw-r--r--starmath/source/view.cxx8
11 files changed, 413 insertions, 592 deletions
diff --git a/starmath/source/config.cxx b/starmath/source/config.cxx
index 8f1bfdcb0e..25b4f2a75e 100644
--- a/starmath/source/config.cxx
+++ b/starmath/source/config.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: config.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: mib $ $Date: 2001-02-06 16:02:19 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -106,193 +106,59 @@
#include "starmath.hrc"
#endif
-#define DEFSYMFILE "starmath$(lang).sms"
-#define CONFIGVERSION (INT16)0x0001;
+/////////////////////////////////////////////////////////////////
-
-SmConfig::SmConfig() :
- SfxConfigItem(SMCONFIGITEM)
+SmConfig::SmConfig()
{
- UseDefault();
- StartListening(aStandardFormat);
}
SmConfig::~SmConfig()
{
- EndListening(aStandardFormat);
-}
-
-
-void SmConfig::SFX_NOTIFY(SfxBroadcaster &, const TypeId &,
- const SfxHint &rHint, const TypeId &)
-{
- switch (((SfxSimpleHint &) rHint).GetId())
- {
- case HINT_FORMATCHANGED:
- SetModified(TRUE);
- SetDefault (FALSE);
- break;
- }
-}
-
-
-void SmConfig::ConfigChangedAction()
-{
- SetModified(TRUE);
- SetDefault(FALSE);
- //Broadcast(SfxSimpleHint(HINT_CONFIGCHANGED));
-}
-
-
-void SmConfig::SetValueIfNE(BOOL &rItem, const BOOL bVal)
- // "Set 'Modified' and 'Value' if not equal"
-{
- if (rItem != bVal)
- { rItem = bVal;
- ConfigChangedAction();
- }
-}
-
-
-void SmConfig::SetSymbolFile(const String &rText)
-{
- if (aSymbolFile != rText)
- {
- aSymbolFile = rText;
- ConfigChangedAction();
- }
-}
-
-
-int SmConfig::Load(SvStream &rStream)
-{
- // Da die Fileformat Version in ConfigItems nur einen Defaultwert hat setzen
- // wir diesen hier auf die aktuelle Version, damit beim folgenden (impliziten)
- // einlesen des 'SmFormat' Objekts aus dem Stream dieses entsprechend
- // reagieren kann.
- rStream.SetVersion(SOFFICE_FILEFORMAT_50);
-
- rStream >> *this;
- SetDefault(FALSE);
- return SfxConfigItem::ERR_OK;
-}
-
-
-BOOL SmConfig::Store(SvStream &rStream)
-{
- rStream << *this;
- return TRUE;
-}
-
-/**************************************************************************/
-
-void SmConfig::UseDefault()
-{
- SfxConfigItem::UseDefault(); // this implicitly calls 'SetDefault(TRUE)'
-
- bToolBoxVisible = bCmdBoxWindow = bAutoRedraw = bFormulaCursor =
- bPrintTitle = bPrintText = bPrintFrame = bWarnNoSymbols =
- bNoRightSpaces = TRUE;
-
- aSymbolFile = C2S(DEFSYMFILE);
- SvtPathOptions aOpt;
- aOpt.SearchFile( aSymbolFile, SvtPathOptions::PATH_USERCONFIG );
-
- ePrintSize = PRINT_SIZE_NORMAL;
- nPrintZoom = 100;
-}
-
-/**************************************************************************/
-
-String SmConfig::GetName() const
-{
- return C2S("StarMath");
}
-/**************************************************************************/
void SmConfig::ItemSetToConfig(const SfxItemSet &rSet)
{
const SfxPoolItem *pItem = NULL;
- BOOL bModified = FALSE;
- String aSymbolFile;
-
- if (rSet.GetItemState(SID_SYMBOLFILE, TRUE, &pItem) == SFX_ITEM_SET)
- { aSymbolFile = ((const SfxStringItem *) pItem)->GetValue();
- DBG_ASSERT(aSymbolFile.Len() > 0, "Symboldatei nicht angegeben !");
-
- if (aSymbolFile != aSymbolFile)
- {
- SfxModule *p = SM_MOD1();
- SmModule *pp = (SmModule *) p;
-
- pp->GetConfig()->SetWarnNoSymbols(TRUE);
- aSymbolFile = aSymbolFile;
-
- bModified = TRUE;
- }
- }
UINT16 nU16;
+ BOOL bVal;
if (rSet.GetItemState(SID_PRINTSIZE, TRUE, &pItem) == SFX_ITEM_SET)
{ nU16 = ((const SfxUInt16Item *) pItem)->GetValue();
- if (ePrintSize != nU16)
- { ePrintSize = (SmPrintSize) nU16;
- bModified = TRUE;
- }
+ SetPrintSize( (SmPrintSize) nU16 );
}
if (rSet.GetItemState(SID_PRINTZOOM, TRUE, &pItem) == SFX_ITEM_SET)
{ nU16 = ((const SfxUInt16Item *) pItem)->GetValue();
- if (nPrintZoom != nU16)
- { nPrintZoom = (USHORT) nU16;
- bModified = TRUE;
- }
+ SetPrintZoomFactor( nU16 );
}
-
- BOOL bVal;
if (rSet.GetItemState(SID_PRINTTITLE, TRUE, &pItem) == SFX_ITEM_SET)
{ bVal = ((const SfxBoolItem *) pItem)->GetValue();
- if (bPrintTitle != bVal)
- { bPrintTitle = bVal;
- bModified = TRUE;
- }
+ SetPrintTitle( bVal );
}
if (rSet.GetItemState(SID_PRINTTEXT, TRUE, &pItem) == SFX_ITEM_SET)
{ bVal = ((const SfxBoolItem *) pItem)->GetValue();
- if (bPrintText != bVal)
- { bPrintText = bVal;
- bModified = TRUE;
- }
+ SetPrintFormulaText( bVal );
}
if (rSet.GetItemState(SID_PRINTFRAME, TRUE, &pItem) == SFX_ITEM_SET)
{ bVal = ((const SfxBoolItem *) pItem)->GetValue();
- if (bPrintFrame != bVal)
- { bPrintFrame = bVal;
- bModified = TRUE;
- }
+ SetPrintFrame( bVal );
}
if (rSet.GetItemState(SID_AUTOREDRAW, TRUE, &pItem) == SFX_ITEM_SET)
{ bVal = ((const SfxBoolItem *) pItem)->GetValue();
- if (bAutoRedraw != bVal)
- { bAutoRedraw = bVal;
- bModified = TRUE;
- }
+ SetAutoRedraw( bVal );
}
if (rSet.GetItemState(SID_NO_RIGHT_SPACES, TRUE, &pItem) == SFX_ITEM_SET)
{ bVal = ((const SfxBoolItem *) pItem)->GetValue();
- if (bNoRightSpaces != bVal)
- { bNoRightSpaces = bVal;
- bModified = TRUE;
+ if (IsIgnoreSpacesRight() != bVal)
+ {
+ SetIgnoreSpacesRight( bVal );
// (angezeigte) Formeln müssen entsprechen neu formatiert werden.
// Das erreichen wir mit:
Broadcast(SfxSimpleHint(HINT_FORMATCHANGED));
}
}
-
- if (bModified)
- ConfigChangedAction();
}
@@ -300,85 +166,19 @@ void SmConfig::ConfigToItemSet(SfxItemSet &rSet) const
{
const SfxItemPool *pPool = rSet.GetPool();
- rSet.Put(SfxStringItem(pPool->GetWhich(SID_SYMBOLFILE),
- aSymbolFile));
-
rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTSIZE),
- (UINT16) ePrintSize));
+ (UINT16) GetPrintSize()));
rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM),
- (UINT16) nPrintZoom));
+ (UINT16) GetPrintZoomFactor()));
- rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), bPrintTitle));
- rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), bPrintText));
- rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), bPrintFrame));
- rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), bAutoRedraw));
- rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), bNoRightSpaces));
+ rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle()));
+ rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), IsPrintFormulaText()));
+ rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame()));
+ rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw()));
+ rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight()));
}
-/**************************************************************************/
-
-
-SvStream & operator << (SvStream &rStream, const SmConfig &rConfig)
-{
- rStream << CONFIGVERSION;
-
- UINT16 nFlags = rConfig.bPrintTitle
- | (rConfig.bPrintText << 1)
- | (rConfig.bPrintFrame << 2)
- | (rConfig.bWarnNoSymbols << 3)
- | (rConfig.bToolBoxVisible << 4)
- | (rConfig.bCmdBoxWindow << 5)
- | (rConfig.bAutoRedraw << 6)
- | (rConfig.bFormulaCursor << 7)
- | (rConfig.bNoRightSpaces << 8);
-
- rStream << nFlags;
-
- rStream << (INT16) rConfig.ePrintSize;
- rStream << (INT16) rConfig.nPrintZoom;
-
- rStream.WriteByteString(rConfig.aSymbolFile, gsl_getSystemTextEncoding());
- rStream << rConfig.aStandardFormat;
-
- for (int i = 0; i < 7; i++)
- rStream << rConfig.vFontPickList[i];
-
- return rStream;
-}
-
-
-SvStream & operator >> (SvStream &rStream, SmConfig &rConfig)
-{
- INT16 nVer;
- rStream >> nVer;
-
- UINT16 nFlags;
- rStream >> nFlags;
-
- rConfig.bPrintTitle = nFlags & 0x01;
- rConfig.bPrintText = (nFlags >> 1) & 0x01;
- rConfig.bPrintFrame = (nFlags >> 2) & 0x01;
- rConfig.bWarnNoSymbols = (nFlags >> 3) & 0x01;
- rConfig.bToolBoxVisible = (nFlags >> 4) & 0x01;
- rConfig.bCmdBoxWindow = (nFlags >> 5) & 0x01;
- rConfig.bAutoRedraw = (nFlags >> 6) & 0x01;
- rConfig.bFormulaCursor = (nFlags >> 7) & 0x01;
- rConfig.bNoRightSpaces = (nFlags >> 8) & 0x01;
-
- INT16 nI16;
- rStream >> nI16;
- rConfig.ePrintSize = (SmPrintSize) nI16;
- rStream >> nI16;
- rConfig.nPrintZoom = (USHORT) nI16;
-
- rStream.ReadByteString(rConfig.aSymbolFile, gsl_getSystemTextEncoding());
- rStream >> rConfig.aStandardFormat;
-
- for (int i = 0; i < 7; i++)
- rStream >> rConfig.vFontPickList[i];
-
- return rStream;
-}
+/////////////////////////////////////////////////////////////////
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 16189e6477..f81e2fe10e 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dialog.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tl $ $Date: 2001-02-07 12:46:52 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -294,75 +294,6 @@ SfxTabPage* SmPrintOptionsTabPage::Create(Window* pWindow, const SfxItemSet& rSe
/**************************************************************************/
-#ifdef NEVER
-SmExtraOptionsTabPage::SmExtraOptionsTabPage(const SfxItemSet& rInSet, Window * pParent, BOOL bFreeRes)
- : SfxTabPage(pParent, SmResId(RID_EXTRAOPTIONPAGE), rInSet),
- aAutoRedraw (this, ResId(1)),
- aFixedText1 (this, ResId(1)),
- aSymbolFile (this, ResId(2), 32),
- aBrowseButton (this, ResId(1))
-{
- if (bFreeRes)
- FreeResource();
-
- aBrowseButton.SetClickHdl(LINK(this, SmExtraOptionsTabPage, SymClickHdl));
-}
-
-
-IMPL_LINK( SmExtraOptionsTabPage, SymClickHdl, PushButton *, pPushButton )
-{
- SfxSimpleFileDialog *pFileDialog =
- new SfxSimpleFileDialog(this, WinBits(WB_OPEN | WB_3DLOOK));
-
-#ifdef MAC
- pFileDialog->AddFilter(SmResId(RID_SYMBOLFILESSTR), SmResId(RID_FILESYMTYP));
- pFileDialog->AddFilter(SmResId(RID_ALLFILESSTR), "****");
-
- pFileDialog->SetCurFilter(SmResId(RID_SYMBOLFILESSTR));
-#else
- pFileDialog->AddFilter(SmResId(RID_SYMBOLFILESSTR), C2S("*.sms"));
- pFileDialog->AddFilter(SmResId(RID_ALLFILESSTR), C2S("*.*"));
-
- pFileDialog->SetCurFilter(SmResId(RID_SYMBOLFILESSTR));
-
- pFileDialog->SetDefaultExt(C2S("*.sms"));
-#endif
-
- pFileDialog->SetPath(aSymbolFile.GetText());
-
- if (pFileDialog->Execute() == RET_OK)
- aSymbolFile.SetText(pFileDialog->GetPath());
-
- delete pFileDialog;
- return 0;
-}
-
-
-BOOL SmExtraOptionsTabPage::FillItemSet(SfxItemSet& rOutSet)
-{
- rOutSet.Put(SfxBoolItem(GetWhich(SID_AUTOREDRAW), aAutoRedraw.IsChecked()));
- rOutSet.Put(SfxStringItem(GetWhich(SID_SYMBOLFILE), aSymbolFile.GetText()));
-
- return (TRUE);
-}
-
-
-void SmExtraOptionsTabPage::Reset(const SfxItemSet& rOutSet)
-{
- aAutoRedraw.Check(((const SfxBoolItem&)rOutSet.Get(GetWhich(SID_AUTOREDRAW))).GetValue());
- aSymbolFile.SetText(((const SfxStringItem&)rOutSet.Get(GetWhich(SID_SYMBOLFILE))).GetValue());
-}
-
-
-SfxTabPage* SmExtraOptionsTabPage::Create(Window* pWindow, const SfxItemSet& rSet)
-{
- return (new SmExtraOptionsTabPage(rSet, pWindow));
-}
-#endif //NEVER
-
-/**************************************************************************/
-
-
void SmShowFont::Paint(const Rectangle&)
{
XubString Text (GetFont().GetName());
@@ -494,7 +425,9 @@ IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, pButton )
if (pQueryBox->Execute() == RET_YES)
{
SmModule *pp = SM_MOD1();
- WriteTo(pp->GetConfig()->GetFormat());
+ SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
+ WriteTo( aFmt );
+ pp->GetConfig()->SetStandardFormat( aFmt );
}
delete pQueryBox;
@@ -598,7 +531,9 @@ IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButt
if (pQueryBox->Execute() == RET_YES)
{
SmModule *pp = SM_MOD1();
- WriteTo(pp->GetConfig()->GetFormat());
+ SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
+ WriteTo( aFmt );
+ pp->GetConfig()->SetStandardFormat( aFmt );
}
delete pQueryBox;
@@ -801,7 +736,9 @@ IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, pButton )
if (pQueryBox->Execute() == RET_YES)
{
SmModule *pp = SM_MOD1();
- WriteTo(pp->GetConfig()->GetFormat());
+ SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
+ WriteTo( aFmt );
+ pp->GetConfig()->SetStandardFormat( aFmt );
}
delete pQueryBox;
return 0;
@@ -1093,7 +1030,9 @@ IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, pButton )
if (pQueryBox->Execute() == RET_YES)
{
SmModule *pp = SM_MOD1();
- WriteTo(pp->GetConfig()->GetFormat());
+ SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
+ WriteTo( aFmt );
+ pp->GetConfig()->SetStandardFormat( aFmt );
}
delete pQueryBox;
@@ -1390,7 +1329,7 @@ void SmSymbolDialog::FillSymbolSets(BOOL bDeleteText)
if (bDeleteText)
aSymbolSets.SetNoSelection();
- USHORT nNumSymSets = rSymSetMgr.GetCount();
+ USHORT nNumSymSets = rSymSetMgr.GetSymbolSetCount();
for (USHORT i = 0; i < nNumSymSets; i++)
aSymbolSets.InsertEntry(rSymSetMgr.GetSymbolSet(i)->GetName());
}
@@ -1521,6 +1460,12 @@ SmSymbolDialog::SmSymbolDialog(Window *pParent, SmSymSetManager &rMgr, BOOL bFre
}
+SmSymbolDialog::~SmSymbolDialog()
+{
+ rSymSetMgr.Save();
+}
+
+
BOOL SmSymbolDialog::SelectSymbolSet(const XubString &rSymbolSetName)
{
BOOL bRet = FALSE;
@@ -1764,7 +1709,7 @@ void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, BOOL bDeleteText)
if (bDeleteText)
rComboBox.SetText(XubString());
- USHORT nNumSymSets = aSymSetMgrCopy.GetCount();
+ USHORT nNumSymSets = aSymSetMgrCopy.GetSymbolSetCount();
for (USHORT i = 0; i < nNumSymSets; i++)
rComboBox.InsertEntry(aSymSetMgrCopy.GetSymbolSet(i)->GetName());
}
@@ -1919,7 +1864,8 @@ IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, pButton )
// Symbol ins SymbolSet einfügen
SmSym *pSym = new SmSym(aSymbols.GetText(), aCharsetDisplay.GetFont(),
- aCharsetDisplay.GetSelectChar());
+ aCharsetDisplay.GetSelectChar(),
+ aSymbolSets.GetText());
pSymSet->AddSymbol(pSym);
// update der Hash Tabelle erzwingen (damit aAddBtn disabled wird).
@@ -2156,7 +2102,7 @@ short SmSymDefineDialog::Execute()
// leere SymbolSets aus dem Ergebnis entfernen.
// Dabei von hinten durch das array iterieren, da beim löschen die
// Elemente aufrücken.
- USHORT nSymbolSets = aSymSetMgrCopy.GetCount();
+ USHORT nSymbolSets = aSymSetMgrCopy.GetSymbolSetCount();
for (int i = nSymbolSets - 1; i >= 0; i--)
if (aSymSetMgrCopy.GetSymbolSet(i)->GetCount() == 0)
aSymSetMgrCopy.DeleteSymbolSet(i);
@@ -2410,12 +2356,3 @@ void SmSymDefineDialog::SelectChar(xub_Unicode cChar)
/**************************************************************************/
-#ifdef NEVER
-SfxTabPage* SmGeneralTabPage::Create(Window* pWindow, const SfxItemSet& rSet)
-{
- return new SmGeneralTabPage(pWindow, rSet);
-}
-#endif NEVER
-
-
-
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 080eff0ab8..9ac09dfaa4 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: document.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: tl $ $Date: 2001-04-19 14:47:39 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -273,19 +273,6 @@ void SmDocShell::SFX_NOTIFY(SfxBroadcaster&, const TypeId&,
{
switch (((SfxSimpleHint&)rHint).GetId())
{
- case HINT_CONFIGCHANGED:
- {
- SmModule *pp = SM_MOD1();
-
- if (pp->GetConfig()->IsAutoRedraw())
- { nModifyCount++; //! merkwrdig...
- // ohne dies wird die Grafik letztlich
- // nicht geupdatet
- Resize();
- }
- break;
- }
-
case HINT_FORMATCHANGED:
SetFormulaArranged(FALSE);
nModifyCount++; //! merkwrdig...
@@ -298,14 +285,7 @@ void SmDocShell::SFX_NOTIFY(SfxBroadcaster&, const TypeId&,
void SmDocShell::LoadSymbols()
{
- SmModule *pp = SM_MOD1();
- String sURL( pp->GetConfig()->GetSymbolFile() );
-
- SvtPathOptions aOpt;
- sURL = aOpt.SubstituteVariable( sURL );
- if( !FStatHelper::IsDocument( sURL ) )
- aOpt.SearchFile( sURL, SvtPathOptions::PATH_USERCONFIG );
- GetSymSetManager().Load( sURL );
+ GetSymSetManager().Load();
}
@@ -643,7 +623,7 @@ SmDocShell::SmDocShell(SfxObjectCreateMode eMode) :
SetPool(&SFX_APP()->GetPool());
SmModule *pp = SM_MOD1();
- aFormat = pp->GetConfig()->GetFormat();
+ aFormat = pp->GetConfig()->GetStandardFormat();
StartListening(aFormat);
StartListening(*pp->GetConfig());
@@ -665,8 +645,6 @@ SmDocShell::~SmDocShell()
EndListening(aFormat);
EndListening(*pp->GetConfig());
- SaveSymbols();
-
delete pEditEngine;
delete pEditEngineItemPool;
delete pTree;
@@ -894,7 +872,9 @@ void SmDocShell::ImplSave( SvStorageStreamRef xStrm )
<< 'T';
xStrm->WriteByteString(exString);
*xStrm << 'F' << aFormat
- << 'S' << GetSymSetManager().GetAccessedSymbols()
+ << 'S';
+ xStrm->WriteByteString( ExportString(C2S("unknown")) );
+ *xStrm << (USHORT) 0
<< '\0';
}
@@ -1090,10 +1070,7 @@ BOOL SmDocShell::ImportSM20File(SvStream *pStream, BOOL bInsert)
case 'S':
pSymbolSet = new SmSymSet();
ReadSM20SymSet(pStream, pSymbolSet);
- if (!bInsert)
- GetSymSetManager().AppendExtraSymbolSet(pSymbolSet);
- else
- delete pSymbolSet;
+ delete pSymbolSet;
break;
default:
@@ -1127,46 +1104,6 @@ void SmDocShell::Execute(SfxRequest& rReq)
break;
}
- case SID_SYMBOLS_LOAD:
- {
- SmModule *pp = SM_MOD1();
-
- SfxSimpleFileDialog *pFileDialog =
- new SfxSimpleFileDialog(0, WinBits(WB_OPEN | WB_3DLOOK));
-
-#ifdef MAC
- pFileDialog->AddFilter(SmResId(RID_SYMBOLFILESSTR), SmResId(RID_FILESYMTYP));
- pFileDialog->AddFilter(SmResId(RID_ALLFILESSTR), C2S("****"));
-
- pFileDialog->SetCurFilter(SmResId(RID_SYMBOLFILESSTR));
-#else
- String aExt( C2S("*.sms" ));
- pFileDialog->AddFilter(SmResId(RID_SYMBOLFILESSTR), aExt);
- pFileDialog->AddFilter(SmResId(RID_ALLFILESSTR), C2S("*.*"));
- pFileDialog->SetCurFilter(SmResId(RID_SYMBOLFILESSTR));
- pFileDialog->SetDefaultExt(aExt);
-#endif
-
- pFileDialog->SetPath(pp->GetConfig()->GetSymbolFile());
-
- if ( RET_OK == pFileDialog->Execute() )
- {
- // save old symbols and sets if necessary
- if (GetSymSetManager().IsModified())
- GetSymSetManager().Save();
- // load new symbols and sets from file
- INetURLObject aURLObj;
- aURLObj.SetSmartProtocol( INET_PROT_FILE );
- aURLObj.SetSmartURL( pFileDialog->GetPath() );
- GetSymSetManager().Load( aURLObj.GetMainURL() );
- // make that file the new default symbolfile
- SM_MOD1()->GetConfig()->SetSymbolFile( pFileDialog->GetPath() );
- }
-
- delete pFileDialog;
- }
- break;
-
case SID_AUTO_REDRAW :
{
SmModule *pp = SM_MOD1();
@@ -1321,16 +1258,19 @@ void SmDocShell::Execute(SfxRequest& rReq)
pAlignDialog->ReadFrom(GetFormat());
if (pAlignDialog->Execute() == RET_OK)
{
- SmFormat& rOldFormat = GetFormat();
+ SmFormat aOldFormat(GetFormat());
pAlignDialog->WriteTo(GetFormat());
+
SmModule *pp = SM_MOD1();
- pAlignDialog->WriteTo(pp->GetConfig()->GetFormat());
+ SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
+ pAlignDialog->WriteTo( aFmt );
+ pp->GetConfig()->SetStandardFormat( aFmt );
SfxUndoManager *pUndoMgr = GetUndoManager();
if (pUndoMgr)
pUndoMgr->AddUndoAction(
- new SmFormatAction(this, rOldFormat, GetFormat()));
+ new SmFormatAction(this, aOldFormat, GetFormat()));
if (aText.Len ())
{
@@ -1594,7 +1534,6 @@ BOOL SmDocShell::Try3x (SvStorage *pStor,
long lTime;
ULONG lDate;
String aBuffer;
- SmSymSet *pSymbolSet;
*pSvStream >> lIdent >> lVersion;
@@ -1638,10 +1577,10 @@ BOOL SmDocShell::Try3x (SvStorage *pStor,
case 'S':
{
- pSymbolSet = new SmSymSet();
- *pSvStream >> *pSymbolSet;
-
- GetSymSetManager().AppendExtraSymbolSet(pSymbolSet);
+ String aTmp;
+ USHORT n;
+ pSvStream->ReadByteString(aTmp, gsl_getSystemTextEncoding());
+ *pSvStream >> n;
break;
}
@@ -1738,8 +1677,7 @@ BOOL SmDocShell::Try2x (SvStorage *pStor,
{
pSymbolSet = new SmSymSet();
ReadSM20SymSet(pSvStream, pSymbolSet);
-
- GetSymSetManager().AppendExtraSymbolSet(pSymbolSet);
+ delete pSymbolSet;
break;
}
diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx
index 9422416318..bce35f8832 100644
--- a/starmath/source/format.cxx
+++ b/starmath/source/format.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: format.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tl $ $Date: 2000-11-02 15:07:16 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -129,6 +129,13 @@ SmFormat::SmFormat()
}
+void SmFormat::SetFont(USHORT nIdent, const SmFace &rFont)
+{
+ vFont[nIdent] = rFont;
+ vFont[nIdent].SetTransparent( TRUE );
+ vFont[nIdent].SetAlign( ALIGN_BASELINE );
+}
+
SmFormat & SmFormat::operator = (const SmFormat &rFormat)
{
SetBaseSize(rFormat.GetBaseSize());
@@ -149,6 +156,34 @@ SmFormat & SmFormat::operator = (const SmFormat &rFormat)
}
+BOOL SmFormat::operator == (const SmFormat &rFormat) const
+{
+ BOOL bRes = aBaseSize == rFormat.aBaseSize &&
+ eHorAlign == rFormat.eHorAlign &&
+ bIsTextmode == rFormat.bIsTextmode &&
+ bScaleNormalBrackets == rFormat.bScaleNormalBrackets;
+
+ USHORT i;
+ for (i = 0; i <= SIZ_END && bRes; ++i)
+ {
+ if (vSize[i] != rFormat.vSize[i])
+ bRes = FALSE;
+ }
+ for (i = 0; i <= DIS_END && bRes; ++i)
+ {
+ if (vDist[i] != rFormat.vDist[i])
+ bRes = FALSE;
+ }
+ for (i = 0; i <= FNT_END && bRes; ++i)
+ {
+ if (vFont[i] != rFormat.vFont[i])
+ bRes = FALSE;
+ }
+
+ return bRes;
+}
+
+
SvStream & operator << (SvStream &rStream, const SmFormat &rFormat)
{
//Da hier keinerlei Kompatibilit„t vorgesehen ist muessen wir leider
diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk
index 4ddd184983..fc78e3f879 100644
--- a/starmath/source/makefile.mk
+++ b/starmath/source/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.5 $
+# $Revision: 1.6 $
#
-# last change: $Author: as $ $Date: 2001-03-19 13:02:50 $
+# last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -91,14 +91,16 @@ SMDLL=TRUE
SRS2NAME =smres
SRC2FILES = smres.src \
+ symbol.src \
commands.src
SLOFILES = \
- $(SLO)$/register.obj \
- $(SLO)$/typemap.obj \
+ $(SLO)$/register.obj \
+ $(SLO)$/typemap.obj \
$(SLO)$/symbol.obj \
$(SLO)$/toolbox.obj \
$(SLO)$/action.obj \
+ $(SLO)$/cfgitem.obj \
$(SLO)$/config.obj \
$(SLO)$/dialog.obj \
$(SLO)$/document.obj \
@@ -109,7 +111,7 @@ SLOFILES = \
$(SLO)$/parse.obj \
$(SLO)$/utility.obj \
$(SLO)$/smdll.obj \
- $(SLO)$/smmod.obj \
+ $(SLO)$/smmod.obj \
$(SLO)$/view.obj \
$(SLO)$/edit.obj \
$(SLO)$/rect.obj \
@@ -117,7 +119,7 @@ SLOFILES = \
$(SLO)$/xchar.obj
EXCEPTIONSFILES = \
- $(SLO)$/register.obj \
+ $(SLO)$/register.obj \
$(SLO)$/mathml.obj \
$(SLO)$/unomodel.obj
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 1a1e197393..8a38871b0b 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: parse.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tl $ $Date: 2001-04-25 15:13:15 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -722,7 +722,10 @@ void SmParser::NextToken()
CurToken.nRow = Row;
CurToken.nCol = nTmpStart - ColOff + 1;
- rnEndPos = aTmpRes.EndPos;
+ if (aTmpRes.EndPos > rnEndPos)
+ rnEndPos = aTmpRes.EndPos;
+ else
+ ++rnEndPos;
}
break;
case '[':
@@ -1314,7 +1317,7 @@ void SmParser::Blank()
// Blanks am Zeilenende ignorieren wenn die entsprechende Option gesetzt ist
if (CurToken.eType == TNEWLINE || CurToken.eType == TEND
- && SM_MOD1()->GetConfig()->IsNoRightSpaces())
+ && SM_MOD1()->GetConfig()->IsIgnoreSpacesRight())
pBlankNode->Clear();
NodeStack.Push(pBlankNode);
diff --git a/starmath/source/smdll.cxx b/starmath/source/smdll.cxx
index e1b1bbb977..3b5c892ad7 100644
--- a/starmath/source/smdll.cxx
+++ b/starmath/source/smdll.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: smdll.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tl $ $Date: 2001-02-13 08:00:47 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -147,8 +147,6 @@ void SmDLL::Init()
SmToolBoxWrapper::RegisterChildWindow(TRUE);
SmCmdBoxWrapper::RegisterChildWindow(TRUE);
-
- ((SmModule*) *ppShlPtr)->InitManager ();
}
/*************************************************************************
diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx
index 6c942786cd..b734ba1745 100644
--- a/starmath/source/smmod.cxx
+++ b/starmath/source/smmod.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: smmod.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:57:26 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,25 +124,32 @@ SFX_IMPL_INTERFACE(SmModule, SfxModule, SmResId(RID_APPLICATION))
SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR));
}
+
SmModule::SmModule(SvFactory* pObjFact) :
SmModuleDummy(SFX_APP()->CreateResManager("sm"), FALSE, pObjFact)
{
SetName( C2S("StarMath" ));
- pConfig = new SmConfig;
- pConfig->Initialize();
-
- pSymSetManager = new SmSymSetManager;
- pRectCache = new SmRectCache;
+ pConfig = 0;
+ pRectCache = new SmRectCache;
}
+
SmModule::~SmModule()
{
delete pConfig;
- delete pSymSetManager;
delete pRectCache;
}
+
+SmConfig * SmModule::GetConfig()
+{
+ if(!pConfig)
+ pConfig = new SmConfig;
+ return pConfig;
+}
+
+
void SmModule::GetState(SfxItemSet &rSet)
{
SfxWhichIter aIter(rSet);
@@ -172,12 +179,6 @@ void SmModule::Free()
{
}
-void SmModule::InitManager()
-{
- pSymSetManager->Init();
-}
-
-
SfxModule *SmModuleDummy::Load()
{
diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx
index 2f4fe4f3f5..a51b5d14fa 100644
--- a/starmath/source/symbol.cxx
+++ b/starmath/source/symbol.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: symbol.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tl $ $Date: 2001-04-09 09:48:32 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,12 +61,18 @@
#pragma hdrstop
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
#ifndef _UCBHELPER_CONTENT_HXX
#include <ucbhelper/content.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
+#ifndef _SV_RESARY_HXX
+#include <vcl/resary.hxx>
+#endif
#ifndef _SFXDISPATCH_HXX //autogen
#include <sfx2/dispatch.hxx>
#endif
@@ -79,6 +85,7 @@
#include "utility.hxx"
#include "dialog.hxx"
#include "config.hxx"
+#include "cfgitem.hxx"
#include "smmod.hxx"
#include "starmath.hrc"
@@ -104,6 +111,8 @@ using namespace ::rtl;
#define SF_IDENT 0x30334D53L
+SV_IMPL_PTRARR( SymbolArray, SmSym * );
+
/**************************************************************************/
/*
**
@@ -113,6 +122,74 @@ using namespace ::rtl;
long SF_Ident = SF_IDENT;
+/**************************************************************************/
+
+class SmMathConfigResource : public Resource
+{
+ ResStringArray aUiSymbolNamesAry;
+ ResStringArray aExportSymbolNamesAry;
+
+public:
+ SmMathConfigResource();
+
+ ResStringArray& GetUiSymbolNamesArray() { return aUiSymbolNamesAry; }
+ ResStringArray& GetExportSymbolNamesArray() { return aExportSymbolNamesAry; }
+};
+
+
+SmMathConfigResource::SmMathConfigResource() :
+ Resource( SmResId(RID_LOCALIZED_SYMBOL_NAMES) ),
+ aUiSymbolNamesAry ( ResId(RID_UI_SYMBOL_NAMES) ),
+ aExportSymbolNamesAry ( ResId(RID_EXPORT_SYMBOL_NAMES) )
+{
+ FreeResource();
+}
+
+/**************************************************************************/
+
+String GetExportSymbolName( const String &rUiSymbolName )
+{
+ String aRes;
+
+ SmMathConfigResource aCfgRes;
+ ResStringArray &rUiNames = aCfgRes.GetUiSymbolNamesArray();
+ ResStringArray &rExportNames = aCfgRes.GetExportSymbolNamesArray();
+ USHORT nCount = rUiNames.Count();
+
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ if (rUiSymbolName == rUiNames.GetString(i))
+ {
+ aRes = rExportNames.GetString(i);
+ break;
+ }
+ }
+
+ return aRes;
+}
+
+
+String GetUiSymbolName( const String &rExportSymbolName )
+{
+ String aRes;
+
+ SmMathConfigResource aCfgRes;
+ ResStringArray &rUiNames = aCfgRes.GetUiSymbolNamesArray();
+ ResStringArray &rExportNames = aCfgRes.GetExportSymbolNamesArray();
+ USHORT nCount = rExportNames.Count();
+
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ if (rExportSymbolName == rExportNames.GetString(i))
+ {
+ aRes = rUiNames.GetString(i);
+ break;
+ }
+ }
+
+ return aRes;
+}
+
/**************************************************************************/
/*
@@ -125,26 +202,40 @@ SmSym::SmSym() :
Name(C2S("unknown")),
Character('\0'),
pHashNext(0),
- pSymSetManager(0)
+ pSymSetManager(0),
+ bPredefined(FALSE),
+ bDocSymbol(FALSE),
+ aSetName(C2S("unknown"))
{
+ aExportName = Name;
Face.SetTransparent(TRUE);
}
+
SmSym::SmSym(const SmSym& rSymbol)
{
- Name = rSymbol.Name;
- Face = rSymbol.Face;
- Character = rSymbol.Character;
+ Name = rSymbol.Name;
+ Face = rSymbol.Face;
+ Character = rSymbol.Character;
+ aSetName = rSymbol.aSetName;
+ bPredefined = rSymbol.bPredefined;
+ bDocSymbol = rSymbol.bDocSymbol;
+ aExportName = rSymbol.aExportName;
pHashNext = 0;
pSymSetManager = 0;
}
-SmSym::SmSym(const String& rName, const Font& rFont, sal_Unicode aChar)
+
+SmSym::SmSym(const String& rName, const Font& rFont, sal_Unicode aChar,
+ const String& rSet, BOOL bIsPredefined)
{
- Name = rName;
- Face = rFont;
- Character = aChar;
+ Name = aExportName = rName;
+ Face = rFont;
+ Character = aChar;
+ aSetName = rSet;
+ bPredefined = bIsPredefined;
+ bDocSymbol = FALSE;
pHashNext = 0;
pSymSetManager = 0;
@@ -153,9 +244,13 @@ SmSym::SmSym(const String& rName, const Font& rFont, sal_Unicode aChar)
SmSym& SmSym::operator = (const SmSym& rSymbol)
{
- Name = rSymbol.Name;
- Face = rSymbol.Face;
- Character = rSymbol.Character;
+ Name = rSymbol.Name;
+ Face = rSymbol.Face;
+ Character = rSymbol.Character;
+ aSetName = rSymbol.aSetName;
+ bPredefined = rSymbol.bPredefined;
+ bDocSymbol = rSymbol.bDocSymbol;
+ aExportName = rSymbol.aExportName;
pHashNext = 0;
@@ -360,40 +455,40 @@ SvStream& operator >> (SvStream& rStream, SmSymSet& rSymbolSet)
/**************************************************************************/
+
+static osl::Mutex & lcl_GetSymSetMgrMutex()
+{
+ static osl::Mutex aMutex;
+ return aMutex;
+}
+
+
void SmSymSetManager::SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType)
{
- if (((SfxSimpleHint&)rHint).GetId() == HINT_CONFIGCHANGED)
- {
- SmViewShell *pViewSh = SmGetActiveView();
- if (pViewSh)
- {
- SfxDispatcher &rDis = *pViewSh->GetViewFrame()->GetDispatcher();
- rDis.Execute(SID_SAVESYMBOLS);
- rDis.Execute(SID_LOADSYMBOLS);
- }
- }
}
+
UINT32 SmSymSetManager::GetHashIndex(const String& rSymbolName)
{
UINT32 x = 0;
for (xub_StrLen i = 0; i < rSymbolName.Len(); i++)
x += x * rSymbolName.GetChar(i);
- return x % NoHashEntries;
+ return x % pImpl->NoHashEntries;
}
+
void SmSymSetManager::EnterHashTable(SmSymSet& rSymbolSet)
{
for (int i = 0; i < rSymbolSet.GetCount(); i++)
{
int j = GetHashIndex(rSymbolSet.GetSymbol(i).GetName());
- if (HashEntries[j] == 0)
- HashEntries[j] = rSymbolSet.SymbolList.GetObject(i);
+ if (pImpl->HashEntries[j] == 0)
+ pImpl->HashEntries[j] = rSymbolSet.SymbolList.GetObject(i);
else
{
- SmSym *p = HashEntries[j];
+ SmSym *p = pImpl->HashEntries[j];
while (p->pHashNext)
p = p->pHashNext;
p->pHashNext = rSymbolSet.SymbolList.GetObject(i);
@@ -404,12 +499,12 @@ void SmSymSetManager::EnterHashTable(SmSymSet& rSymbolSet)
void SmSymSetManager::FillHashTable()
{
- if (HashEntries)
+ if (pImpl->HashEntries)
{
- memset(HashEntries, 0, NoHashEntries * sizeof(SmSym *));
+ memset( pImpl->HashEntries, 0, pImpl->NoHashEntries * sizeof(SmSym *) );
- for (int i = 0; i < NoSymbolSets; i++)
- EnterHashTable(*GetSymbolSet(i));
+ for (UINT32 i = 0; i < pImpl->NoSymbolSets; i++)
+ EnterHashTable( *GetSymbolSet( (USHORT) i ) );
}
}
@@ -419,67 +514,53 @@ void SmSymSetManager::Init()
StartListening(*pp->GetConfig());
}
+
void SmSymSetManager::Exit()
{
SmModule *pp = SM_MOD1();
EndListening(*pp->GetConfig());
}
-SmSymSetManager::SmSymSetManager(UINT32 HashTableSize)
+
+SmSymSetManager::SmSymSetManager(USHORT HashTableSize)
{
- SymbolSets.Clear();
- NoSymbolSets = 0;
- NoHashEntries = HashTableSize;
- HashEntries = new SmSym *[NoHashEntries];
- memset(HashEntries, 0, sizeof(SmSym *) * NoHashEntries);
- Modified = FALSE;
+ pImpl = new SmSymSetManager_Impl;
+ pImpl->SymbolSets.Clear();
+ pImpl->NoSymbolSets = 0;
+ pImpl->NoHashEntries = HashTableSize;
+ pImpl->HashEntries = new SmSym *[pImpl->NoHashEntries];
+ memset( pImpl->HashEntries, 0, sizeof(SmSym *) * pImpl->NoHashEntries );
+ pImpl->Modified = FALSE;
}
SmSymSetManager::SmSymSetManager(const SmSymSetManager& rSymbolSetManager)
{
- SymbolSets.Clear();
- NoSymbolSets = 0;
- NoHashEntries = rSymbolSetManager.NoHashEntries;
- HashEntries = new SmSym *[NoHashEntries];
- memset(HashEntries, 0, sizeof(SmSym *) * NoHashEntries);
-
- for (int i = 0; i < rSymbolSetManager.GetCount(); i++)
- AddSymbolSet(new SmSymSet(*rSymbolSetManager.GetSymbolSet(i)));
-
- Modified = rSymbolSetManager.Modified;
}
SmSymSetManager::~SmSymSetManager()
{
- for (int i = 0; i< NoSymbolSets; i++)
- delete SymbolSets.Get(i);
-
- delete HashEntries;
+ USHORT i;
+ for (i = 0; i< pImpl->NoSymbolSets; i++)
+ delete pImpl->SymbolSets.Get(i);
+ delete pImpl->HashEntries;
+
+ delete pImpl;
+ pImpl = 0;
}
+
SmSymSetManager& SmSymSetManager::operator = (const SmSymSetManager& rSymbolSetManager)
{
- int i;
- for (i = 0; i< NoSymbolSets; i++)
- delete SymbolSets.Get(i);
-
- SymbolSets.Clear();
- NoSymbolSets = 0;
-
- for (i = 0; i < rSymbolSetManager.GetCount(); i++)
- AddSymbolSet(new SmSymSet(*rSymbolSetManager.GetSymbolSet(i)));
-
- Modified = rSymbolSetManager.Modified;
-
return *this;
}
+
USHORT SmSymSetManager::AddSymbolSet(SmSymSet* pSymbolSet)
{
- if (NoSymbolSets >= SymbolSets.GetSize())
- SymbolSets.SetSize(NoSymbolSets + 1);
+ if (pImpl->NoSymbolSets >= pImpl->SymbolSets.GetSize())
+ pImpl->SymbolSets.SetSize(pImpl->NoSymbolSets + 1);
- SymbolSets.Put(NoSymbolSets++, pSymbolSet);
+ pImpl->SymbolSets.Put(pImpl->NoSymbolSets++, pSymbolSet);
pSymbolSet->pSymSetManager = this;
@@ -487,9 +568,9 @@ USHORT SmSymSetManager::AddSymbolSet(SmSymSet* pSymbolSet)
pSymbolSet->SymbolList.GetObject(i)->pSymSetManager = this;
FillHashTable();
- Modified = TRUE;
+ pImpl->Modified = TRUE;
- return NoSymbolSets - 1;
+ return (USHORT) (pImpl->NoSymbolSets - 1);
}
void SmSymSetManager::ChangeSymbolSet(SmSymSet* pSymbolSet)
@@ -497,156 +578,182 @@ void SmSymSetManager::ChangeSymbolSet(SmSymSet* pSymbolSet)
if (pSymbolSet)
{
FillHashTable();
- Modified = TRUE;
+ pImpl->Modified = TRUE;
}
}
void SmSymSetManager::DeleteSymbolSet(USHORT SymbolSetNo)
{
- delete SymbolSets.Get(SymbolSetNo);
- NoSymbolSets--;
+ delete pImpl->SymbolSets.Get(SymbolSetNo);
+ pImpl->NoSymbolSets--;
- for (int i = SymbolSetNo; i < NoSymbolSets; i++)
- SymbolSets.Put(i, SymbolSets.Get(i + 1));
+ for (UINT32 i = SymbolSetNo; i < pImpl->NoSymbolSets; i++)
+ pImpl->SymbolSets.Put(i, pImpl->SymbolSets.Get(i + 1));
FillHashTable();
- Modified = TRUE;
+ pImpl->Modified = TRUE;
}
USHORT SmSymSetManager::GetSymbolSetPos(const String& rSymbolSetName) const
{
- for (USHORT i = 0; i < NoSymbolSets; i++)
- if (SymbolSets.Get(i)->GetName() == rSymbolSetName)
+ for (USHORT i = 0; i < pImpl->NoSymbolSets; i++)
+ if (pImpl->SymbolSets.Get(i)->GetName() == rSymbolSetName)
return (i);
return SYMBOLSET_NONE;
}
-
SmSym *SmSymSetManager::GetSymbol(const String& rSymbolName)
{
- SmSym *p = HashEntries[GetHashIndex(rSymbolName)];
- while (p)
+ SmSym *pSym = pImpl->HashEntries[GetHashIndex(rSymbolName)];
+ while (pSym)
{
- if (p->Name == rSymbolName)
+ if (pSym->Name == rSymbolName)
break;
- p = p->pHashNext;
+ pSym = pSym->pHashNext;
}
- return p;
+
+ return pSym;
}
-void SmSymSetManager::Load( const String &rURL )
+
+void SmSymSetManager::AddReplaceSymbol( const SmSym &rSymbol )
{
- if( aStreamName != rURL )
+ SmSym *pSym = GetSymbol( rSymbol.GetName() );
+ if (pSym)
+ {
+ *pSym = rSymbol;
+ }
+ else
{
- for (int i = 0; i< NoSymbolSets; i++)
- delete SymbolSets.Get(i);
+ USHORT nPos = GetSymbolSetPos( rSymbol.GetSetName() );
+ if (SYMBOLSET_NONE == nPos)
+ {
+ AddSymbolSet( new SmSymSet( rSymbol.GetSetName() ) );
+ nPos = GetSymbolSetPos( rSymbol.GetSetName() );
+ }
+ DBG_ASSERT( nPos != SYMBOLSET_NONE, "SymbolSet not found");
+ GetSymbolSet( nPos )->AddSymbol( new SmSym( rSymbol ) );
+ }
+ SetModified( TRUE );
+}
- SymbolSets.Clear();
- NoSymbolSets = 0;
- aStreamName = rURL;
+USHORT SmSymSetManager::GetSymbolCount() const
+{
+ USHORT nRes = 0;
+ USHORT nSets = GetSymbolSetCount();
+ for (USHORT i = 0; i < nSets; ++i)
+ nRes += GetSymbolSet(i)->GetCount();
+ return nRes;
+}
+
- // get stream to use
- SfxMedium aMedium( aStreamName,
- STREAM_READ | STREAM_SHARE_DENYWRITE, FALSE );
- aMedium.SetTransferPriority( SFX_TFPRIO_SYNCHRON );
- SvStream *pStream = aMedium.GetInStream();
+const SmSym * SmSymSetManager::GetSymbol( USHORT nPos ) const
+{
+ const SmSym *pRes = 0;
- if( pStream && !pStream->GetError() )
- {
- *pStream >> *this;
- Modified = FALSE;
- }
+ INT16 nIdx = 0;
+ USHORT nSets = GetSymbolSetCount();
+ USHORT i = 0;
+ while (i < nSets && !pRes)
+ {
+ USHORT nEntries = GetSymbolSet(i)->GetCount();
+ if (nPos < nIdx + nEntries)
+ pRes = &GetSymbolSet(i)->GetSymbol( nPos - nIdx );
else
- {
- SmModule *pp = SM_MOD1();
-
- if ( pp->GetConfig()->IsWarnNoSymbols() )
- {
- ErrorBox aErrorBox( NULL, SmResId( RID_READSYMBOLERROR ) );
- String aString( aErrorBox.GetMessText() );
- aString.SearchAndReplaceAscii( "%FILE%", aStreamName );
- aErrorBox.SetMessText( aString );
- aErrorBox.Execute();
-
- Modified = FALSE;
- pp->GetConfig()->SetWarnNoSymbols(FALSE);
- }
- }
+ nIdx += nEntries;
+ ++i;
}
+
+ return pRes;
}
-void SmSymSetManager::Save()
+
+void SmSymSetManager::Load()
{
- if (Modified)
- {
- SfxMedium aMedium( aStreamName,
- STREAM_WRITE | STREAM_TRUNC | STREAM_SHARE_DENYALL, FALSE );
- SvStream *pStream = aMedium.GetOutStream();
+ SmMathConfig &rCfg = *SM_MOD1()->GetConfig();
- if( pStream && !pStream->GetError() )
+ USHORT nCount = rCfg.GetSymbolCount();
+ USHORT i;
+ for (i = 0; i < nCount; ++i)
+ {
+ const SmSym *pSym = rCfg.GetSymbol(i);
+ if (pSym)
{
- *pStream << *this;
- Modified = FALSE;
+ const String &rSetName = pSym->GetSetName();
+ if (SYMBOLSET_NONE == GetSymbolSetPos( rSetName ))
+ AddSymbolSet( new SmSymSet( rSetName ) );
+ USHORT nSetPos = GetSymbolSetPos( rSetName );
+ SmSymSet *pSymSet = GetSymbolSet( nSetPos );
+ if (pSymSet)
+ {
+ pSymSet->AddSymbol( new SmSym( *pSym ) );
+ }
}
- else
- {
- ErrorBox aErrorBox( NULL, SmResId(RID_WRITESYMBOLERROR));
- String aString (aErrorBox.GetMessText());
- USHORT nPos = aString.SearchAscii("%FILE%");
+ }
+ // build HashTables
+ nCount = GetSymbolSetCount();
+ for (i = 0; i < nCount; ++i)
+ ChangeSymbolSet( GetSymbolSet( i ) );
- aString.Erase(nPos, 6);
- aString.Insert(aStreamName, nPos);
- aErrorBox.SetMessText(aString);
+
+ if (0 == nCount)
+ {
+ SmModule *pp = SM_MOD1();
+ if ( pp->GetConfig()->IsNoSymbolsWarning() )
+ {
+ ErrorBox aErrorBox( NULL, SmResId( RID_READSYMBOLERROR ) );
+ String aString( aErrorBox.GetMessText() );
+ aString.SearchAndReplaceAscii( "%FILE%", pImpl->aStreamName );
+ aErrorBox.SetMessText( aString );
aErrorBox.Execute();
+
+ pImpl->Modified = FALSE;
+ pp->GetConfig()->SetNoSymbolsWarning(FALSE);
}
- aMedium.Commit();
}
}
-
-SvStream& operator << (SvStream& rStream, SmSymSetManager& rSymbolSetManager)
+void SmSymSetManager::Save()
{
- rStream << (long)SF_IDENT << (USHORT) rSymbolSetManager.NoSymbolSets;
+ SmMathConfig &rCfg = *SM_MOD1()->GetConfig();
- for (int i = 0; i < rSymbolSetManager.NoSymbolSets; i++)
- rStream << *rSymbolSetManager.GetSymbolSet(i);
+ // get number of Symbols
+ USHORT nSymbolCount = 0;
+ USHORT nSetCount = GetSymbolSetCount();
+ USHORT i;
+ for (i = 0; i < nSetCount; ++i)
+ nSymbolCount += GetSymbolSet( i )->GetCount();
- return rStream;
-}
-
-SvStream& operator >> (SvStream& rStream, SmSymSetManager& rSymbolSetManager)
-{
- rStream >> SF_Ident;
- if (SF_Ident == SF_IDENT || SF_Ident == SF_SM20IDENT)
+ if (nSymbolCount)
{
- USHORT n;
- rStream >> n;
-
- if (rSymbolSetManager.HashEntries)
- memset(rSymbolSetManager.HashEntries, 0,
- rSymbolSetManager.NoHashEntries * sizeof(SmSym *));
-
- for (int i = 0; i < n; i++)
+ USHORT nSaveSymbolCnt = 0;
+ const SmSym **pSymbols = new const SmSym* [ nSymbolCount ];
+ const SmSym **pSym = pSymbols;
+ for (i = 0; i < nSetCount; ++i)
{
- SmSymSet *pSymbolSet;
-
- if ((pSymbolSet = new SmSymSet) == 0)
- break;
-
- rStream >> *pSymbolSet;
- rSymbolSetManager.AddSymbolSet(pSymbolSet);
+ const SmSymSet *pSymSet = GetSymbolSet( i );
+ USHORT n = pSymSet->GetCount();
+ for (USHORT j = 0; j < n; ++j)
+ {
+ const SmSym &rSym = pSymSet->GetSymbol( j );
+ if (!rSym.IsDocSymbol())
+ {
+ *pSym++ = &rSym;
+ ++nSaveSymbolCnt;
+ }
+ }
}
+ DBG_ASSERT(pSym - pSymbols == nSaveSymbolCnt, "wrong number of symbols" );
+ rCfg.ReplaceSymbols( pSymbols, nSaveSymbolCnt );
+ delete pSymbols;
}
-
- SF_Ident = SF_IDENT;
-
- return rStream;
}
+
void ReadSM20SymSet(SvStream *pStream, SmSymSet *pSymbolSet)
{
SF_Ident = SF_SM20IDENT;
diff --git a/starmath/source/toolbox.cxx b/starmath/source/toolbox.cxx
index 6f0163c4b3..80f1778f47 100644
--- a/starmath/source/toolbox.cxx
+++ b/starmath/source/toolbox.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: toolbox.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:57:27 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -251,7 +251,7 @@ IMPL_LINK_INLINE_END( SmToolBoxWindow, CmdSelectHdl, ToolBox*, pToolBox)
void SmToolBoxWindow::ShowWindows()
{
- if ( SM_MOD1()->GetConfig()->IsToolBoxVisible() )
+ if ( SM_MOD1()->GetConfig()->IsToolboxVisible() )
Show();
}
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index ce85d827c4..7997df1302 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: view.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tl $ $Date: 2001-03-08 09:27:43 $
+ * last change: $Author: tl $ $Date: 2001-05-02 16:58:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1055,7 +1055,7 @@ USHORT SmViewShell::Print(SfxProgress &rProgress, PrintDialog *pPrintDialog)
}
// output text on bottom
- if (pp->GetConfig()->IsPrintText())
+ if (pp->GetConfig()->IsPrintFormulaText())
{
// Font aFont(FAMILY_DONTKNOW, Size(0, 600));
Font aFont;
@@ -1116,7 +1116,7 @@ USHORT SmViewShell::Print(SfxProgress &rProgress, PrintDialog *pPrintDialog)
case PRINT_SIZE_ZOOMED:
{
SmModule *pp = SM_MOD1();
- Fraction aFraction (pp->GetConfig()->GetPrintZoom(), 100);
+ Fraction aFraction (pp->GetConfig()->GetPrintZoomFactor(), 100);
OutputMapMode = MapMode(MAP_100TH_MM, aZeroPoint, aFraction, aFraction);
break;