diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-07-28 09:46:36 +0200 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-07-28 09:46:36 +0200 |
commit | cdce29a326c834a269b33dff27e74ed34c82c7df (patch) | |
tree | 10bf4341658abdfc6b4ec9d7b3739551852aea0d /starmath | |
parent | 4c8d9dbc46403017cf09723d903e1b49296b9e48 (diff) |
cws tl83: #i113276# default layout for 'Greek' characters changed; added new property 'GreekCharStyle'
Diffstat (limited to 'starmath')
-rwxr-xr-x[-rw-r--r--] | starmath/inc/format.hxx | 4 | ||||
-rw-r--r-- | starmath/inc/node.hxx | 23 | ||||
-rw-r--r-- | starmath/source/cfgitem.cxx | 7 | ||||
-rw-r--r-- | starmath/source/document.cxx | 30 | ||||
-rw-r--r-- | starmath/source/format.cxx | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | starmath/source/node.cxx | 96 | ||||
-rw-r--r--[-rwxr-xr-x] | starmath/source/parse.cxx | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | starmath/source/unomodel.cxx | 16 |
8 files changed, 144 insertions, 43 deletions
diff --git a/starmath/inc/format.hxx b/starmath/inc/format.hxx index f632131d834f..4d13ea48185e 100644..100755 --- a/starmath/inc/format.hxx +++ b/starmath/inc/format.hxx @@ -109,6 +109,7 @@ class SmFormat : public SfxBroadcaster USHORT vSize[SIZ_END + 1]; USHORT vDist[DIS_END + 1]; SmHorAlign eHorAlign; + INT16 nGreekCharStyle; BOOL bIsTextmode, bScaleNormalBrackets; @@ -138,6 +139,9 @@ public: BOOL IsTextmode() const { return bIsTextmode; } void SetTextmode(BOOL bVal) { bIsTextmode = bVal; } + INT16 GetGreekCharStyle() const { return nGreekCharStyle; } + void SetGreekCharStyle(INT16 nVal) { nGreekCharStyle = nVal; } + BOOL IsScaleNormalBrackets() const { return bScaleNormalBrackets; } void SetScaleNormalBrackets(BOOL bVal) { bScaleNormalBrackets = bVal; } diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 6ef89ea5ec1b..92c9d4621292 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -311,19 +311,10 @@ class SmTextNode : public SmVisibleNode USHORT nFontDesc; protected: - SmTextNode(SmNodeType eNodeType, const SmToken &rNodeToken, USHORT nFontDescP) - : SmVisibleNode(eNodeType, rNodeToken) - { - nFontDesc = nFontDescP; - } + SmTextNode(SmNodeType eNodeType, const SmToken &rNodeToken, USHORT nFontDescP ); public: - SmTextNode(const SmToken &rNodeToken, USHORT nFontDescP) - : SmVisibleNode(NTEXT, rNodeToken) - { - nFontDesc = nFontDescP; - } - + SmTextNode(const SmToken &rNodeToken, USHORT nFontDescP ); USHORT GetFontDesc() const { return nFontDesc; } void SetText(const XubString &rText) { aText = rText; } @@ -347,15 +338,13 @@ public: class SmSpecialNode : public SmTextNode { + bool bIsFromGreekSymbolSet; + protected: - SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, USHORT _nFontDesc) - : SmTextNode(eNodeType, rNodeToken, _nFontDesc) - {} + SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, USHORT _nFontDesc); public: - SmSpecialNode(const SmToken &rNodeToken) - : SmTextNode(NSPECIAL, rNodeToken, FNT_MATH) //! default Font nicht immer richtig - {} + SmSpecialNode(const SmToken &rNodeToken); virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell); virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat); diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index bf62157a30d3..8066b88fd80d 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -127,6 +127,7 @@ static const char * aMathPropNames[] = static const char * aFormatPropNames[] = { "StandardFormat/Textmode", + "StandardFormat/GreekCharStyle", "StandardFormat/ScaleNormalBracket", "StandardFormat/HorizontalAlignment", "StandardFormat/BaseSize", @@ -994,6 +995,10 @@ void SmMathConfig::LoadFormat() if (pVal->hasValue() && (*pVal >>= bTmp)) pFormat->SetTextmode( bTmp ); ++pVal; + // StandardFormat/GreekCharStyle + if (pVal->hasValue() && (*pVal >>= nTmp16)) + pFormat->SetGreekCharStyle( nTmp16 ); + ++pVal; // StandardFormat/ScaleNormalBracket if (pVal->hasValue() && (*pVal >>= bTmp)) pFormat->SetScaleNormalBrackets( bTmp ); @@ -1069,6 +1074,8 @@ void SmMathConfig::SaveFormat() // StandardFormat/Textmode *pValue++ <<= (BOOL) pFormat->IsTextmode(); + // StandardFormat/GreekCharStyle + *pValue++ <<= (INT16) pFormat->GetGreekCharStyle(); // StandardFormat/ScaleNormalBracket *pValue++ <<= (BOOL) pFormat->IsScaleNormalBrackets(); // StandardFormat/HorizontalAlignment diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 86d23af0161b..ab1382b97879 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -131,9 +131,9 @@ void SmDocShell::SFX_NOTIFY(SfxBroadcaster&, const TypeId&, { case HINT_FORMATCHANGED: SetFormulaArranged(FALSE); - nModifyCount++; //! merkwuerdig... - // ohne dies wird die Grafik letztlich - // nicht geupdatet + + nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState + Repaint(); break; } @@ -211,11 +211,19 @@ void SmDocShell::SetFormat(SmFormat& rFormat) RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetFormat" ); aFormat = rFormat; - SetFormulaArranged(FALSE); - SmViewShell *pViewSh = SmGetActiveView(); - if (pViewSh) - pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_GAPHIC_SM); - SetModified(TRUE); + SetFormulaArranged( FALSE ); + SetModified( TRUE ); + + nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState + + // don't use SmGetActiveView since the view shell might not be active (0 pointer) + // if for example the Basic Macro dialog currently has the focus. Thus: + SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this ); + while (pFrm) + { + pFrm->GetBindings().Invalidate(SID_GAPHIC_SM); + pFrm = SfxViewFrame::GetNext( *pFrm, this ); + } } String SmDocShell::GetAccessibleText() @@ -241,7 +249,7 @@ void SmDocShell::Parse() delete pTree; ReplaceBadChars(); pTree = aInterpreter.Parse(aText); - nModifyCount++; + nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState SetFormulaArranged( FALSE ); } @@ -1218,6 +1226,10 @@ void SmDocShell::GetState(SfxItemSet &rSet) break; case SID_GAPHIC_SM: + //! very old (pre UNO) and ugly hack to invalidate the SmGraphicWindow. + //! If nModifyCount gets changed then the call below will implicitly notify + //! SmGraphicController::StateChanged and there the window gets invalidated. + //! Thus all the 'nModifyCount++' before invalidating this slot. rSet.Put(SfxInt16Item(SID_GAPHIC_SM, nModifyCount)); break; diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx index 18aaed4c841c..e92d1a5e97aa 100644 --- a/starmath/source/format.cxx +++ b/starmath/source/format.cxx @@ -112,8 +112,9 @@ SmFormat::SmFormat() { nVersion = SM_FMT_VERSION_NOW; - eHorAlign = AlignCenter; - bIsTextmode = bScaleNormalBrackets = FALSE; + eHorAlign = AlignCenter; + nGreekCharStyle = 0; + bIsTextmode = bScaleNormalBrackets = FALSE; vSize[SIZ_TEXT] = 100; vSize[SIZ_INDEX] = 60; @@ -191,6 +192,7 @@ SmFormat & SmFormat::operator = (const SmFormat &rFormat) SetVersion (rFormat.GetVersion()); SetHorAlign(rFormat.GetHorAlign()); SetTextmode(rFormat.IsTextmode()); + SetGreekCharStyle(rFormat.GetGreekCharStyle()); SetScaleNormalBrackets(rFormat.IsScaleNormalBrackets()); USHORT i; @@ -212,6 +214,7 @@ BOOL SmFormat::operator == (const SmFormat &rFormat) const { BOOL bRes = aBaseSize == rFormat.aBaseSize && eHorAlign == rFormat.eHorAlign && + nGreekCharStyle == rFormat.nGreekCharStyle && bIsTextmode == rFormat.bIsTextmode && bScaleNormalBrackets == rFormat.bScaleNormalBrackets; diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 4601b2f84fec..2747d994a7eb 100644..100755 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -28,7 +28,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_starmath.hxx" -#define APPEND(str,ascii) str.AppendAscii(RTL_CONSTASCII_STRINGPARAM(ascii)) +#include "node.hxx" +#include "rect.hxx" +#include "symbol.hxx" +#include "smmod.hxx" +#include "document.hxx" +#include "view.hxx" +#include "mathtype.hxx" + #include <tools/gen.hxx> #include <tools/fract.hxx> #include <rtl/math.hxx> @@ -38,23 +45,14 @@ #include <vcl/outdev.hxx> #include <sfx2/module.hxx> - -#include "node.hxx" -#include <rect.hxx> -#include "symbol.hxx" -#include "smmod.hxx" -#include <document.hxx> -#include <view.hxx> -#ifndef _MATHTYPE_HXX -#include "mathtype.hxx" -#endif - #include <math.h> #include <float.h> // define this to draw rectangles for debugging //#define SM_RECT_DEBUG +#define APPEND(str,ascii) str.AppendAscii(RTL_CONSTASCII_STRINGPARAM(ascii)) + //////////////////////////////////////// // SmTmpDevice // Allows for font and color changes. The original settings will be restored @@ -2355,6 +2353,20 @@ void SmRectangleNode::Draw(OutputDevice &rDev, const Point &rPosition) const /**************************************************************************/ +SmTextNode::SmTextNode( SmNodeType eNodeType, const SmToken &rNodeToken, USHORT nFontDescP ) : + SmVisibleNode(eNodeType, rNodeToken) +{ + nFontDesc = nFontDescP; +} + + +SmTextNode::SmTextNode( const SmToken &rNodeToken, USHORT nFontDescP ) : + SmVisibleNode(NTEXT, rNodeToken) +{ + nFontDesc = nFontDescP; +} + + void SmTextNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) { SmNode::Prepare(rFormat, rDocShell); @@ -2798,6 +2810,36 @@ void SmAttributNode::CreateTextFromNode(String &rText) /**************************************************************************/ +bool lcl_IsFromGreekSymbolSet( const String &rTokenText ) +{ + bool bRes = false; + + // valid symbol name needs to have a '%' at pos 0 and at least an additonal char + if (rTokenText.Len() > 2 && rTokenText.GetBuffer()[0] == (sal_Unicode)'%') + { + String aName( rTokenText.Copy(1) ); + SmSym *pSymbol = SM_MOD()->GetSymbolManager().GetSymbolByName( aName ); + if (pSymbol && GetExportSymbolSetName( pSymbol->GetSymbolSetName() ).EqualsAscii( "Greek" ) ) + bRes = true; + } + + return bRes; +} + + +SmSpecialNode::SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, USHORT _nFontDesc) : + SmTextNode(eNodeType, rNodeToken, _nFontDesc) +{ + bIsFromGreekSymbolSet = lcl_IsFromGreekSymbolSet( rNodeToken.aText ); +} + + +SmSpecialNode::SmSpecialNode(const SmToken &rNodeToken) : + SmTextNode(NSPECIAL, rNodeToken, FNT_MATH) //! default Font nicht immer richtig +{ + bIsFromGreekSymbolSet = lcl_IsFromGreekSymbolSet( rNodeToken.aText ); +} + void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) { @@ -2806,7 +2848,8 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell const SmSym *pSym; SmModule *pp = SM_MOD(); - if (NULL != (pSym = pp->GetSymbolManager().GetSymbolByName(GetToken().aText))) + String aName( GetToken().aText.Copy(1) ); + if (NULL != (pSym = pp->GetSymbolManager().GetSymbolByName( aName ))) { SetText( pSym->GetCharacter() ); GetFont() = pSym->GetFace(); @@ -2832,6 +2875,33 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell SetAttribut(ATTR_BOLD); Flags() |= FLG_FONT; + + if (bIsFromGreekSymbolSet) + { + DBG_ASSERT( GetText().Len() == 1, "a symbol should only consist of 1 char!" ); + bool bItalic = false; + INT16 nStyle = rFormat.GetGreekCharStyle(); + DBG_ASSERT( nStyle >= 0 && nStyle <= 2, "unexpected value for GreekCharStyle" ); + if (nStyle == 1) + bItalic = true; + else if (nStyle == 2) + { + String aText( GetText() ); + if (aText.Len() > 0) + { + const sal_Unicode cUppercaseAlpha = 0x0391; + const sal_Unicode cUppercaseOmega = 0x03A9; + sal_Unicode cChar = aText.GetBuffer()[0]; + // uppercase letters should be straight and lowercase letters italic + bItalic = !(cUppercaseAlpha <= cChar && cChar <= cUppercaseOmega); + } + } + + if (bItalic) + Attributes() |= ATTR_ITALIC; + else + Attributes() &= ~ATTR_ITALIC;; + } }; diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 15971d0c38af..d12f3df07400 100755..100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -741,14 +741,14 @@ void SmParser::NextToken() CurToken.nLevel = 5; CurToken.aText = String(); CurToken.nRow = sal::static_int_cast< xub_StrLen >(Row); - CurToken.nCol = nTmpStart - ColOff + 1; + CurToken.nCol = nTmpStart - ColOff; if (aTmpRes.TokenType & KParseType::IDENTNAME) { xub_StrLen n = sal::static_int_cast< xub_StrLen >(aTmpRes.EndPos - nTmpStart); CurToken.eType = TSPECIAL; - CurToken.aText = BufferString.Copy( sal::static_int_cast< xub_StrLen >(nTmpStart), n ); + CurToken.aText = BufferString.Copy( sal::static_int_cast< xub_StrLen >(nTmpStart-1), n+1 ); DBG_ASSERT( aTmpRes.EndPos > rnEndPos, "empty identifier" ); diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 013831f6e44e..9d008f326d2f 100755..100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -203,6 +203,7 @@ enum SmModelPropertyHandles HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS, HANDLE_RELATIVE_FONT_HEIGHT_LIMITS, HANDLE_IS_TEXT_MODE, + HANDLE_GREEK_CHAR_STYLE, HANDLE_ALIGNMENT, HANDLE_RELATIVE_SPACING, HANDLE_RELATIVE_LINE_SPACING, @@ -273,6 +274,7 @@ PropertySetInfo * lcl_createModelPropertyInfo () { RTL_CONSTASCII_STRINGPARAM( "Formula" ), HANDLE_FORMULA , &::getCppuType((const OUString*)0), PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM( "IsScaleAllBrackets" ), HANDLE_IS_SCALE_ALL_BRACKETS , &::getBooleanCppuType(), PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM( "IsTextMode" ), HANDLE_IS_TEXT_MODE , &::getBooleanCppuType(), PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM( "GreekCharStyle" ), HANDLE_GREEK_CHAR_STYLE, &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM( "LeftMargin" ), HANDLE_LEFT_MARGIN , &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, DIS_LEFTSPACE }, { RTL_CONSTASCII_STRINGPARAM( "PrinterName" ), HANDLE_PRINTER_NAME , &::getCppuType((const OUString*)0), PROPERTY_NONE, 0 }, { RTL_CONSTASCII_STRINGPARAM( "PrinterSetup" ), HANDLE_PRINTER_SETUP , &::getCppuType((const Sequence < sal_Int8 >*)0), PROPERTY_NONE, 0 }, @@ -593,6 +595,16 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* } break; + case HANDLE_GREEK_CHAR_STYLE : + { + sal_Int16 nVal = 0; + *pValues >>= nVal; + if (nVal < 0 || nVal > 2) + throw IllegalArgumentException(); + aFormat.SetGreekCharStyle( nVal ); + } + break; + case HANDLE_ALIGNMENT : { // SmHorAlign uses the same values as HorizontalAlignment @@ -824,6 +836,10 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu } break; + case HANDLE_GREEK_CHAR_STYLE : + *pValue <<= (sal_Int16)aFormat.GetGreekCharStyle(); + break; + case HANDLE_ALIGNMENT : // SmHorAlign uses the same values as HorizontalAlignment *pValue <<= (sal_Int16)aFormat.GetHorAlign(); |