From 1acb3fa596bac16a168b22d4070db9f6423881d8 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 9 Jul 2010 10:55:23 +0200 Subject: cws tl83: #i113004# crash when spell checking in sd fixed --- sw/source/core/edit/edlingu.cxx | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index d99293071048..c9ab4a591383 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -1318,8 +1318,12 @@ void SwEditShell::MoveContinuationPosToEndOfCheckedSentence() void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bRecheck) { + // Note: rNewPortions.size() == 0 is valid and happens when the whole + // sentence got removed in the dialog + ASSERT( pSpellIter, "SpellIter missing" ); - if(pSpellIter) + if(pSpellIter && + pSpellIter->GetLastPortions().size() > 0) // no portions -> no text to be changed { const SpellPortions& rLastPortions = pSpellIter->GetLastPortions(); const SpellContentPositions rLastPositions = pSpellIter->GetLastPositions(); @@ -1330,9 +1334,6 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, // iterate over the new portions, beginning at the end to take advantage of the previously // saved content positions - if(!rLastPortions.size()) - return; - pDoc->StartUndo( UNDO_OVERWRITE, NULL ); StartAction(); @@ -1344,6 +1345,10 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, sal_uInt32 nRedlinePortions = lcl_CountRedlines(rLastPortions); if((rLastPortions.size() - nRedlinePortions) == rNewPortions.size()) { + DBG_ASSERT( rNewPortions.size() > 0, "rNewPortions should not be empty here" ); + DBG_ASSERT( rLastPortions.size() > 0, "rLastPortions should not be empty here" ); + DBG_ASSERT( rLastPositions.size() > 0, "rLastPositions should not be empty here" ); + //the simple case: the same number of elements on both sides //each changed element has to be applied to the corresponding source element svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.end(); @@ -1357,8 +1362,17 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, //jump over redline portions while(aCurrentOldPortion->bIsHidden) { - --aCurrentOldPortion; - --aCurrentOldPosition; + if (aCurrentOldPortion != rLastPortions.begin() && + aCurrentOldPosition != rLastPositions.begin()) + { + --aCurrentOldPortion; + --aCurrentOldPosition; + } + else + { + DBG_ASSERT( 0, "ApplyChangedSentence: iterator positions broken" ); + break; + } } if ( !pCrsr->HasMark() ) pCrsr->SetMark(); @@ -1398,6 +1412,8 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, } else { + DBG_ASSERT( rLastPositions.size() > 0, "rLastPositions should not be empty here" ); + //select the complete sentence SpellContentPositions::const_iterator aCurrentEndPosition = rLastPositions.end(); --aCurrentEndPosition; -- cgit From 4c8d9dbc46403017cf09723d903e1b49296b9e48 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 23 Jul 2010 17:21:05 +0200 Subject: cws tl83: #i113276# changes to Greek symbol set because of new OpenSymbol font --- starmath/inc/symbol.hxx | 12 ++++++++++++ starmath/source/dialog.cxx | 3 +++ starmath/source/document.cxx | 6 +----- starmath/source/edit.cxx | 8 ++++++++ starmath/source/mathmlexport.cxx | 1 - starmath/source/mathmlimport.cxx | 1 - starmath/source/symbol.cxx | 35 ++++++++++++++++++++++++++++++++++- starmath/source/types.cxx | 2 +- starmath/source/view.cxx | 3 +-- 9 files changed, 60 insertions(+), 11 deletions(-) mode change 100755 => 100644 starmath/source/view.cxx diff --git a/starmath/inc/symbol.hxx b/starmath/inc/symbol.hxx index 503859485095..51e8ad0b8642 100644 --- a/starmath/inc/symbol.hxx +++ b/starmath/inc/symbol.hxx @@ -38,7 +38,10 @@ #include #include #include +#include +#include +#include "unomodel.hxx" #include "utility.hxx" #include "smmod.hxx" @@ -133,6 +136,15 @@ typedef std::map< String, SmSym, lt_String > SymbolMap_t; // vector of pointers to the actual symbols in the above container typedef std::vector< const SmSym * > SymbolPtrVec_t; +struct lt_SmSymPtr : public std::binary_function< const SmSym *, const SmSym *, bool > +{ + bool operator() ( const SmSym *pSym1, const SmSym *pSym2 ) + { + return pSym1->GetCharacter() < pSym2->GetCharacter(); + } +}; + + class SmSymbolManager : public SfxListener { SymbolMap_t m_aSymbols; diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 037f2fc1dff8..6067daa797dc 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -1600,6 +1600,9 @@ BOOL SmSymbolDialog::SelectSymbolSet(const XubString &rSymbolSetName) aSymbolSetName = rSymbolSetName; aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName ); + // sort symbols by Unicode position (useful for displaying Greek characters alphabetically) + std::sort( aSymbolSet.begin(), aSymbolSet.end(), lt_SmSymPtr() ); + aSymbolSetDisplay.SetSymbolSet( aSymbolSet ); if (aSymbolSet.size() > 0) SelectSymbol(0); diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 49739af72972..86d23af0161b 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -1123,13 +1123,9 @@ void SmDocShell::Execute(SfxRequest& rReq) case SID_TEXT: { - const SfxStringItem& rItem = - (const SfxStringItem&)rReq.GetArgs()->Get(SID_TEXT); - + const SfxStringItem& rItem = (const SfxStringItem&)rReq.GetArgs()->Get(SID_TEXT); if (GetText() != rItem.GetValue()) - { SetText(rItem.GetValue()); - } } break; diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index f7093f9c3815..fe849a36e358 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -251,7 +251,10 @@ IMPL_LINK( SmEditWindow, ModifyTimerHdl, Timer *, EMPTYARG /*pTimer*/ ) { SmModule *pp = SM_MOD(); if (pp->GetConfig()->IsAutoRedraw()) + { Flush(); + aModifyTimer.Stop(); + } return 0; } @@ -917,7 +920,10 @@ void SmEditWindow::InsertText(const String& Text) { DBG_ASSERT( pEditView, "EditView missing" ); if (pEditView) + { pEditView->InsertText(Text); + aModifyTimer.Start(); + } } void SmEditWindow::Flush() @@ -928,9 +934,11 @@ void SmEditWindow::Flush() pEditEngine->ClearModifyFlag(); SmViewShell *pViewSh = rCmdBox.GetView(); if (pViewSh) + { pViewSh->GetViewFrame()->GetDispatcher()->Execute( SID_TEXT, SFX_CALLMODE_STANDARD, new SfxStringItem(SID_TEXT, GetText()), 0L); + } } if (aCursorMoveTimer.IsActive()) diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index 36eb9d3884b5..bec69eb01b95 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -75,7 +75,6 @@ #include #include "mathmlexport.hxx" -#include "mathtype.hxx" #include #include #include diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index dd90caaf6d45..36c009757eac 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -71,7 +71,6 @@ one go*/ #include #include "mathmlimport.hxx" -#include "mathtype.hxx" #include #include #include diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx index e248f9726629..5208ce3644ce 100644 --- a/starmath/source/symbol.cxx +++ b/starmath/source/symbol.cxx @@ -290,6 +290,28 @@ void SmSymbolManager::Load() DBG_ERROR( "no symbol set found" ); m_bModified = false; } + + // now add a %i... symbol to the 'iGreek' set for every symbol found in the 'Greek' set. + SmLocalizedSymbolData aLocalizedData; + const String aGreekSymbolSetName( aLocalizedData.GetUiSymbolSetName( A2OU("Greek") ) ); + const SymbolPtrVec_t aGreekSymbols( GetSymbolSet( aGreekSymbolSetName ) ); + String aSymbolSetName( (sal_Unicode) 'i' ); + aSymbolSetName += aGreekSymbolSetName; + size_t nSymbols = aGreekSymbols.size(); + for (size_t i = 0; i < nSymbols; ++i) + { + // make the new symbol a copy but with ITALIC_NORMAL, and add it to iGreek + const SmSym &rSym = *aGreekSymbols[i]; + Font aFont( rSym.GetFace() ); + DBG_ASSERT( aFont.GetItalic() == ITALIC_NONE, "expected Font with ITALIC_NONE, failed." ); + aFont.SetItalic( ITALIC_NORMAL ); + String aSymbolName( (sal_Unicode)'i' ); + aSymbolName += rSym.GetName(); + SmSym aSymbol( aSymbolName, aFont, rSym.GetCharacter(), + aSymbolSetName, TRUE /*bIsPredefined*/ ); + + AddOrReplaceSymbol( aSymbol ); + } } void SmSymbolManager::Save() @@ -314,10 +336,21 @@ void SmSymbolManager::Save() } DBG_ASSERT(pSym - pSymbols == nSaveSymbolCnt, "wrong number of symbols" ); #endif + + // prepare to skip symbols from iGreek on saving + SmLocalizedSymbolData aLocalizedData; + String aSymbolSetName( (sal_Unicode) 'i' ); + aSymbolSetName += aLocalizedData.GetUiSymbolSetName( A2OU("Greek") ); + SymbolPtrVec_t aTmp( GetSymbols() ); std::vector< SmSym > aSymbols; for (size_t i = 0; i < aTmp.size(); ++i) - aSymbols.push_back( *aTmp[i] ); + { + // skip symbols from iGreek set since those symbols always get added + // by computational means in SmSymbolManager::Load + if (aTmp[i]->GetSymbolSetName() != aSymbolSetName) + aSymbols.push_back( *aTmp[i] ); + } rCfg.SetSymbols( aSymbols ); #if 0 delete [] pSymbols; diff --git a/starmath/source/types.cxx b/starmath/source/types.cxx index a861db5a0c79..e63d46c79e9b 100644 --- a/starmath/source/types.cxx +++ b/starmath/source/types.cxx @@ -38,7 +38,7 @@ sal_Unicode ConvertMathPrivateUseAreaToUnicode( sal_Unicode cChar ) if (IsInPrivateUseArea( cChar )) { DBG_ASSERT( 0, "Error: private use area characters should no longer be in use!" ); - cRes = (sal_Unicode) '&'; // just some character that should easily be notice as odd in the context + cRes = (sal_Unicode) '@'; // just some character that should easily be notice as odd in the context } return cRes; } diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx old mode 100755 new mode 100644 index 886d409931b2..0087595703ca --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1545,8 +1545,7 @@ void SmViewShell::Execute(SfxRequest& rReq) case SID_INSERTTEXT: { const SfxStringItem& rItem = - (const SfxStringItem&)rReq.GetArgs()->Get(SID_INSERTTEXT); - + (const SfxStringItem&)rReq.GetArgs()->Get(SID_INSERTTEXT); if (pWin) pWin->InsertText(rItem.GetValue()); break; -- cgit From cdce29a326c834a269b33dff27e74ed34c82c7df Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 28 Jul 2010 09:46:36 +0200 Subject: cws tl83: #i113276# default layout for 'Greek' characters changed; added new property 'GreekCharStyle' --- starmath/inc/format.hxx | 4 ++ starmath/inc/node.hxx | 23 +++-------- starmath/source/cfgitem.cxx | 7 ++++ starmath/source/document.cxx | 30 +++++++++----- starmath/source/format.cxx | 7 +++- starmath/source/node.cxx | 96 ++++++++++++++++++++++++++++++++++++++------ starmath/source/parse.cxx | 4 +- starmath/source/unomodel.cxx | 16 ++++++++ 8 files changed, 144 insertions(+), 43 deletions(-) mode change 100644 => 100755 starmath/inc/format.hxx mode change 100644 => 100755 starmath/source/node.cxx mode change 100755 => 100644 starmath/source/parse.cxx mode change 100755 => 100644 starmath/source/unomodel.cxx diff --git a/starmath/inc/format.hxx b/starmath/inc/format.hxx old mode 100644 new mode 100755 index f632131d834f..4d13ea48185e --- 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 old mode 100644 new mode 100755 index 4601b2f84fec..2747d994a7eb --- 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 #include #include @@ -38,23 +45,14 @@ #include #include - -#include "node.hxx" -#include -#include "symbol.hxx" -#include "smmod.hxx" -#include -#include -#ifndef _MATHTYPE_HXX -#include "mathtype.hxx" -#endif - #include #include // 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 old mode 100755 new mode 100644 index 15971d0c38af..d12f3df07400 --- 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 old mode 100755 new mode 100644 index 013831f6e44e..9d008f326d2f --- 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(); -- cgit From b1554766bf429bb1270e4aabb63f8cb91e819ebc Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 28 Jul 2010 15:40:32 +0200 Subject: cws tl83: warning-free code --- starmath/source/cfgitem.cxx | 1 - starmath/source/makefile.mk | 20 ++------------------ starmath/source/node.cxx | 6 +++--- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 8066b88fd80d..43c0fbe27dd0 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -42,7 +42,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::beans; -#define A2OU(x) rtl::OUString::createFromAscii( x ) static const char* aRootName = "Office.Math"; diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk index 596060397e18..a409e55d2462 100644 --- a/starmath/source/makefile.mk +++ b/starmath/source/makefile.mk @@ -36,6 +36,8 @@ LIBTARGET=NO # --- Settings ----------------------------------------------------- +ENABLE_EXCEPTIONS=TRUE + .INCLUDE : settings.mk # --- Files -------------------------------------------------------- @@ -84,24 +86,6 @@ SLOFILES = \ $(SLO1FILES) \ $(SLO2FILES) -EXCEPTIONSFILES = \ - $(SLO)$/register.obj \ - $(SLO)$/accessibility.obj \ - $(SLO)$/cfgitem.obj \ - $(SLO)$/dialog.obj \ - $(SLO)$/document.obj \ - $(SLO)$/node.obj \ - $(SLO)$/parse.obj \ - $(SLO)$/mathmlimport.obj \ - $(SLO)$/mathmlexport.obj \ - $(SLO)$/mathtype.obj \ - $(SLO)$/smdll.obj \ - $(SLO)$/view.obj \ - $(SLO)$/unomodel.obj \ - $(SLO)$/smdetect.obj \ - $(SLO)$/symbol.obj \ - $(SLO)$/unodoc.obj - LIB1TARGET = \ $(SLB)$/$(TARGET).lib diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 2747d994a7eb..b986a046b205 100755 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -2886,12 +2886,12 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell bItalic = true; else if (nStyle == 2) { - String aText( GetText() ); - if (aText.Len() > 0) + String aTmp( GetText() ); + if (aTmp.Len() > 0) { const sal_Unicode cUppercaseAlpha = 0x0391; const sal_Unicode cUppercaseOmega = 0x03A9; - sal_Unicode cChar = aText.GetBuffer()[0]; + sal_Unicode cChar = aTmp.GetBuffer()[0]; // uppercase letters should be straight and lowercase letters italic bItalic = !(cUppercaseAlpha <= cChar && cChar <= cUppercaseOmega); } -- cgit From 705af29850ea12bd23783ec2a6937a2bb0c25f12 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 29 Jul 2010 13:51:02 +0200 Subject: cws tl83: #i113276# auto-update for right context menu and 'Elements' window fixed --- starmath/source/dialog.cxx | 1 + starmath/source/edit.cxx | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 6067daa797dc..0dc58c8ed640 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -1485,6 +1485,7 @@ IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton ) { XubString aText ('%'); aText += pSym->GetName(); + aText += (sal_Unicode)' '; rViewSh.GetViewFrame()->GetDispatcher()->Execute( SID_INSERTTEXT, SFX_CALLMODE_STANDARD, diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index fe849a36e358..020376c05dfb 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -251,10 +251,8 @@ IMPL_LINK( SmEditWindow, ModifyTimerHdl, Timer *, EMPTYARG /*pTimer*/ ) { SmModule *pp = SM_MOD(); if (pp->GetConfig()->IsAutoRedraw()) - { Flush(); - aModifyTimer.Stop(); - } + aModifyTimer.Stop(); return 0; } @@ -282,6 +280,7 @@ IMPL_LINK(SmEditWindow, CursorMoveTimerHdl, Timer *, EMPTYARG /*pTimer*/) aOldSelection = aNewSelection; } } + aCursorMoveTimer.Stop(); return 0; } @@ -438,7 +437,7 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt) SmViewShell *pView = GetView(); if ( pView && !pView->KeyInput(rKEvt) ) { - /* fuert bei F1 (Hilfe) zum Zerstoeren von this! */ + /* fuert bei F1 (Hilfe) zum Zerstoeren von this! */ Flush(); if ( aModifyTimer.IsActive() ) aModifyTimer.Stop(); @@ -737,6 +736,9 @@ void SmEditWindow::InsertCommand(USHORT nCommand) pEditView->SetSelection(aSelection); } + aModifyTimer.Start(); + aCursorMoveTimer.Start(); + GrabFocus(); } } @@ -923,6 +925,7 @@ void SmEditWindow::InsertText(const String& Text) { pEditView->InsertText(Text); aModifyTimer.Start(); + aCursorMoveTimer.Start(); } } -- cgit