diff options
-rw-r--r-- | starmath/inc/format.hxx | 14 | ||||
-rw-r--r-- | starmath/source/cfgitem.cxx | 144 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 9 | ||||
-rw-r--r-- | starmath/source/format.cxx | 105 |
4 files changed, 171 insertions, 101 deletions
diff --git a/starmath/inc/format.hxx b/starmath/inc/format.hxx index d9dec1a9aa16..85dac8a4c52b 100644 --- a/starmath/inc/format.hxx +++ b/starmath/inc/format.hxx @@ -2,9 +2,9 @@ * * $RCSfile: format.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: tl $ $Date: 2001-07-17 08:28:19 $ + * last change: $Author: tl $ $Date: 2001-08-16 09:19:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -145,9 +145,12 @@ enum SmHorAlign { AlignLeft, AlignCenter, AlignRight }; +String GetDefaultFontName( LanguageType nLang, USHORT nIdent ); + class SmFormat : public SfxBroadcaster { SmFace vFont[FNT_END + 1]; + BOOL bDefaultFont[FNT_END + 1]; Size aBaseSize; long nVersion; USHORT vSize[SIZ_END + 1]; @@ -164,8 +167,11 @@ public: void SetBaseSize(const Size &rSize) { aBaseSize = rSize; } const SmFace & GetFont(USHORT nIdent) const { return vFont[nIdent]; } - SmFace & Font (USHORT nIdent) { return vFont[nIdent]; } - void SetFont(USHORT nIdent, const SmFace &rFont); + void SetFont(USHORT nIdent, const SmFace &rFont, BOOL bDefault = FALSE); + void SetFontSize(USHORT nIdent, const Size &rSize) { vFont[nIdent].SetSize( rSize ); } + + void SetDefaultFont(USHORT nIdent, BOOL bVal) { bDefaultFont[nIdent] = bVal; } + BOOL IsDefaultFont(USHORT nIdent) const { return bDefaultFont[nIdent]; } USHORT GetRelSize(USHORT nIdent) const { return vSize[nIdent]; } void SetRelSize(USHORT nIdent, USHORT nVal) { vSize[nIdent] = nVal;} diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index a0b1c7baca22..d3014bd5ddf8 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cfgitem.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: tl $ $Date: 2001-08-08 11:22:18 $ + * last change: $Author: tl $ $Date: 2001-08-16 09:20:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,10 @@ #pragma hdrstop +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + #include "cfgitem.hxx" #include "starmath.hrc" @@ -818,7 +822,6 @@ void SmMathConfig::SaveFontFormatList() SmMathConfigItem aCfg( String::CreateFromAscii( aRootName ) ); Sequence< OUString > aNames = lcl_GetFontPropertyNames(); - const OUString *pNames = aNames.getConstArray(); INT32 nSymbolProps = aNames.getLength(); USHORT nCount = rFntFmtList.GetCount(); @@ -838,7 +841,7 @@ void SmMathConfig::SaveFontFormatList() aNodeNameDelim += aFntFmtId; aNodeNameDelim += aDelim; - const OUString *pName = pNames; + const OUString *pName = aNames.getConstArray();; // Name pVal->Name = aNodeNameDelim; @@ -992,56 +995,36 @@ void SmMathConfig::SaveOther() SmMathConfigItem aCfg( String::CreateFromAscii( aRootName )); - Sequence< OUString > aNames( aCfg.GetOtherPropertyNames() ); - const OUString *pNames = aNames.getConstArray(); - const OUString *pName = pNames; + const Sequence< OUString > aNames( aCfg.GetOtherPropertyNames() ); INT32 nProps = aNames.getLength(); - Sequence< PropertyValue > aValues( nProps ); - PropertyValue *pValues = aValues.getArray(); - PropertyValue *pVal = pValues; + Sequence< Any > aValues( nProps ); + Any *pValues = aValues.getArray(); + Any *pValue = pValues; // Print/Title - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bPrintTitle; - pVal++; + *pValue++ <<= (BOOL) pOther->bPrintTitle; // Print/FormulaText - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bPrintFormulaText; - pVal++; + *pValue++ <<= (BOOL) pOther->bPrintFormulaText; // Print/Frame - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bPrintFrame; - pVal++; + *pValue++ <<= (BOOL) pOther->bPrintFrame; // Print/Size - pVal->Name = *pNames++; - pVal->Value <<= (INT16) pOther->ePrintSize; - pVal++; + *pValue++ <<= (INT16) pOther->ePrintSize; // Print/ZoomFactor - pVal->Name = *pNames++; - pVal->Value <<= (INT16) pOther->nPrintZoomFactor; - pVal++; + *pValue++ <<= (INT16) pOther->nPrintZoomFactor; // Misc/NoSymbolsWarning - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bNoSymbolsWarning; - pVal++; + *pValue++ <<= (BOOL) pOther->bNoSymbolsWarning; // Misc/IgnoreSpacesRight - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bIgnoreSpacesRight; - pVal++; + *pValue++ <<= (BOOL) pOther->bIgnoreSpacesRight; // View/ToolboxVisible - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bToolboxVisible; - pVal++; + *pValue++ <<= (BOOL) pOther->bToolboxVisible; // View/AutoRedraw - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bAutoRedraw; - pVal++; + *pValue++ <<= (BOOL) pOther->bAutoRedraw; // View/FormulaCursor - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pOther->bFormulaCursor; - pVal++; - DBG_ASSERT( pVal - pValues == nProps, "property mismatch" ); + *pValue++ <<= (BOOL) pOther->bFormulaCursor; + + DBG_ASSERT( pValue - pValues == nProps, "property mismatch" ); + aCfg.PutProperties( aNames , aValues ); SetOtherModified( FALSE ); } @@ -1098,21 +1081,31 @@ void SmMathConfig::LoadFormat() ++pVal; } + LanguageType nLang = Application::GetSettings().GetUILanguage(); for (i = FNT_BEGIN; i < FNT_END; ++i) { Font aFnt; - + BOOL bUseDefaultFont = TRUE; if (pVal->hasValue() && (*pVal >>= aTmpStr)) { - const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr ); - DBG_ASSERT( pFntFmt, "unknown FontFormat" ); - if (pFntFmt) - aFnt = pFntFmt->GetFont(); + bUseDefaultFont = 0 == aTmpStr.getLength(); + if (bUseDefaultFont) + { + aFnt = pFormat->GetFont( i ); + aFnt.SetName( GetDefaultFontName( nLang, i ) ); + } + else + { + const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr ); + DBG_ASSERT( pFntFmt, "unknown FontFormat" ); + if (pFntFmt) + aFnt = pFntFmt->GetFont(); + } } ++pVal; aFnt.SetSize( pFormat->GetBaseSize() ); - pFormat->SetFont( i, aFnt ); + pFormat->SetFont( i, aFnt, bUseDefaultFont ); } DBG_ASSERT( pVal - pValues == nProps, "property mismatch" ); @@ -1128,59 +1121,46 @@ void SmMathConfig::SaveFormat() SmMathConfigItem aCfg( String::CreateFromAscii( aRootName )); - Sequence< OUString > aNames( aCfg.GetFormatPropertyNames() ); - const OUString *pNames = aNames.getConstArray(); - const OUString *pName = pNames; + const Sequence< OUString > aNames( aCfg.GetFormatPropertyNames() ); INT32 nProps = aNames.getLength(); - Sequence< PropertyValue > aValues( nProps ); - PropertyValue *pValues = aValues.getArray(); - PropertyValue *pVal = pValues; + Sequence< Any > aValues( nProps ); + Any *pValues = aValues.getArray(); + Any *pValue = pValues; // StandardFormat/Textmode - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pFormat->IsTextmode(); - pVal++; + *pValue++ <<= (BOOL) pFormat->IsTextmode(); // StandardFormat/ScaleNormalBracket - pVal->Name = *pNames++; - pVal->Value <<= (BOOL) pFormat->IsScaleNormalBrackets(); - pVal++; + *pValue++ <<= (BOOL) pFormat->IsScaleNormalBrackets(); // StandardFormat/HorizontalAlignment - pVal->Name = *pNames++; - pVal->Value <<= (INT16) pFormat->GetHorAlign(); - pVal++; + *pValue++ <<= (INT16) pFormat->GetHorAlign(); // StandardFormat/BaseSize - pVal->Name = *pNames++; - pVal->Value <<= (INT16) SmRoundFraction( Sm100th_mmToPts( + *pValue++ <<= (INT16) SmRoundFraction( Sm100th_mmToPts( pFormat->GetBaseSize().Height() ) ); - pVal++; USHORT i; for (i = SIZ_BEGIN; i <= SIZ_END; ++i) - { - pVal->Name = *pNames++; - pVal->Value <<= (INT16) pFormat->GetRelSize( i ); - ++pVal; - } + *pValue++ <<= (INT16) pFormat->GetRelSize( i ); for (i = DIS_BEGIN; i <= DIS_END; ++i) - { - pVal->Name = *pNames++; - pVal->Value <<= (INT16) pFormat->GetDistance( i ); - ++pVal; - } + *pValue++ <<= (INT16) pFormat->GetDistance( i ); for (i = FNT_BEGIN; i < FNT_END; ++i) { - SmFontFormat aFntFmt( pFormat->GetFont( i ) ); - String aFntFmtId( GetFontFormatList().GetFontFormatId( aFntFmt ) ); - DBG_ASSERT( aFntFmtId.Len(), "FontFormatId not found" ); + OUString aFntFmtId; - pVal->Name = *pNames++; - pVal->Value <<= OUString( aFntFmtId ); - ++pVal; + if (!pFormat->IsDefaultFont( i )) + { + SmFontFormat aFntFmt( pFormat->GetFont( i ) ); + aFntFmtId = GetFontFormatList().GetFontFormatId( aFntFmt, TRUE ); + DBG_ASSERT( aFntFmtId.getLength(), "FontFormatId not found" ); + } + + *pValue++ <<= aFntFmtId; } - DBG_ASSERT( pVal - pValues == nProps, "property mismatch" ); + + DBG_ASSERT( pValue - pValues == nProps, "property mismatch" ); + aCfg.PutProperties( aNames , aValues ); SetFormatModified( FALSE ); } diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index ca1c4e7b8dca..f23ea9ade336 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dialog.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: tl $ $Date: 2001-08-09 12:24:29 $ + * last change: $Author: tl $ $Date: 2001-08-16 09:20:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -538,7 +538,7 @@ void SmFontSizeDialog::WriteTo(SmFormat &rFormat) const const Size aTmp (rFormat.GetBaseSize()); for (USHORT i = FNT_BEGIN; i <= FNT_END; i++) - rFormat.Font(i).SetSize(aTmp); + rFormat.SetFontSize(i, aTmp); rFormat.RequestApplyChanges(); } @@ -666,9 +666,6 @@ void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const rFormat.SetFont( FNT_SANS, aSansFont .Get(0) ); rFormat.SetFont( FNT_FIXED, aFixedFont .Get(0) ); - for (USHORT i = FNT_BEGIN; i <= FNT_FIXED; i++) - rFormat.Font(i).SetTransparent(TRUE); - rFormat.RequestApplyChanges(); } diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx index fb34f69d10e0..3b4cb2af4ca4 100644 --- a/starmath/source/format.cxx +++ b/starmath/source/format.cxx @@ -2,9 +2,9 @@ * * $RCSfile: format.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tl $ $Date: 2001-08-08 11:22:18 $ + * last change: $Author: tl $ $Date: 2001-08-16 09:20:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,11 +64,90 @@ #ifndef _STREAM_HXX #include <tools/stream.hxx> #endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _SVX_SCRIPTTYPEITEM_HXX +#include <svx/scripttypeitem.hxx> +#endif #ifndef FORMAT_HXX #include "format.hxx" #endif +///////////////////////////////////////////////////////////////// + +// Latin default-fonts +static const USHORT aLatinDefFnts[FNT_END] = +{ + DEFAULTFONT_SERIF, // FNT_VARIABLE + DEFAULTFONT_SERIF, // FNT_FUNCTION + DEFAULTFONT_SERIF, // FNT_NUMBER + DEFAULTFONT_SERIF, // FNT_TEXT + DEFAULTFONT_SERIF, // FNT_SERIF + DEFAULTFONT_SANS, // FNT_SANS + DEFAULTFONT_FIXED // FNT_FIXED + //StarSymbol, // FNT_MATH +}; + +// CJK default-fonts +//! we use non-asian fonts for variables, functions and numbers since they +//! look better and even in asia only latin letters will be used for those. +//! At least that's what I was told... +static const USHORT aCJKDefFnts[FNT_END] = +{ + DEFAULTFONT_SERIF, // FNT_VARIABLE + DEFAULTFONT_SERIF, // FNT_FUNCTION + DEFAULTFONT_SERIF, // FNT_NUMBER + DEFAULTFONT_CJK_TEXT, // FNT_TEXT + DEFAULTFONT_CJK_TEXT, // FNT_SERIF + DEFAULTFONT_CJK_DISPLAY, // FNT_SANS + DEFAULTFONT_CJK_TEXT // FNT_FIXED + //StarSymbol, // FNT_MATH +}; + +// CTL default-fonts +static const USHORT aCTLDefFnts[FNT_END] = +{ + DEFAULTFONT_CTL_TEXT, // FNT_VARIABLE + DEFAULTFONT_CTL_TEXT, // FNT_FUNCTION + DEFAULTFONT_CTL_TEXT, // FNT_NUMBER + DEFAULTFONT_CTL_TEXT, // FNT_TEXT + DEFAULTFONT_CTL_TEXT, // FNT_SERIF + DEFAULTFONT_CTL_TEXT, // FNT_SANS + DEFAULTFONT_CTL_TEXT // FNT_FIXED + //StarSymbol, // FNT_MATH +}; + + +String GetDefaultFontName( LanguageType nLang, USHORT nIdent ) +{ + DBG_ASSERT( FNT_BEGIN <= nIdent && nIdent <= FNT_END, + "index out opd range" ); + + if (FNT_MATH == nIdent) + return String::CreateFromAscii( FNTNAME_MATH ); + else + { + const USHORT *pTable; + switch (GetScriptTypeOfLanguage( nLang )) + { + case SCRIPTTYPE_LATIN : pTable = aLatinDefFnts; break; + case SCRIPTTYPE_ASIAN : pTable = aCJKDefFnts; break; + case SCRIPTTYPE_COMPLEX : pTable = aCTLDefFnts; break; + default : + pTable = aLatinDefFnts; + DBG_ERROR( "unknown script-type" ); + } + + return Application::GetDefaultDevice()->GetDefaultFont( + pTable[ nIdent ], nLang, + DEFAULTFONT_FLAGS_ONLYONE ).GetName(); + } +} + +///////////////////////////////////////////////////////////////// + SmFormat::SmFormat() : aBaseSize(0, SmPtsTo100th_mm(12)) { @@ -127,15 +206,18 @@ SmFormat::SmFormat() { vFont[i].SetTransparent(TRUE); vFont[i].SetAlign(ALIGN_BASELINE); + bDefaultFont[i] = FALSE; } } -void SmFormat::SetFont(USHORT nIdent, const SmFace &rFont) +void SmFormat::SetFont(USHORT nIdent, const SmFace &rFont, BOOL bDefault ) { vFont[nIdent] = rFont; vFont[nIdent].SetTransparent( TRUE ); vFont[nIdent].SetAlign( ALIGN_BASELINE ); + + bDefaultFont[nIdent] = bDefault; } SmFormat & SmFormat::operator = (const SmFormat &rFormat) @@ -148,7 +230,10 @@ SmFormat & SmFormat::operator = (const SmFormat &rFormat) USHORT i; for (i = FNT_BEGIN; i <= FNT_END; i++) + { SetFont(i, rFormat.GetFont(i)); + SetDefaultFont(i, rFormat.IsDefaultFont(i)); + } for (i = SIZ_BEGIN; i <= SIZ_END; i++) SetRelSize(i, rFormat.GetRelSize(i)); for (i = DIS_BEGIN; i <= DIS_END; i++) @@ -178,7 +263,8 @@ BOOL SmFormat::operator == (const SmFormat &rFormat) const } for (i = 0; i <= FNT_END && bRes; ++i) { - if (vFont[i] != rFormat.vFont[i]) + if (vFont[i] != rFormat.vFont[i] || + bDefaultFont[i] != rFormat.bDefaultFont[i]) bRes = FALSE; } @@ -317,7 +403,7 @@ void SmFormat::ReadSM20Format(SvStream &rStream) rStream >> n; for (i = FNT_BEGIN; i <= FNT_FIXED; i++) - ReadSM20Font(rStream, Font(i)); + ReadSM20Font(rStream, vFont[i]); for (i = DIS_BEGIN; i <= DIS_OPERATORSPACE; i++) { rStream >> n; @@ -331,11 +417,12 @@ void SmFormat::ReadSM20Format(SvStream &rStream) const Size aTmp (GetBaseSize()); for (i = FNT_BEGIN; i <= FNT_FIXED; i++) { - Font(i).SetSize(aTmp); - Font(i).SetTransparent(TRUE); - Font(i).SetAlign(ALIGN_BASELINE); + SmFace &rFace = vFont[i]; + rFace.SetSize(aTmp); + rFace.SetTransparent(TRUE); + rFace.SetAlign(ALIGN_BASELINE); } - Font(FNT_MATH).SetSize(aTmp); + vFont[FNT_MATH].SetSize(aTmp); } |