summaryrefslogtreecommitdiff
path: root/starmath/source
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2010-08-03 11:29:55 +0200
committerThomas Lange [tl] <tl@openoffice.org>2010-08-03 11:29:55 +0200
commit889d495cbf51e32db8e7d9e47a245235ada1590b (patch)
treea6769eac2b4530bdba5ae2327ff04c12a0213eec /starmath/source
parent3ed4c287784b42bb8ff26bcdcff1b13734815495 (diff)
cws tl82: #i74049# math symbols should be able to handle 20 bit Unicode characters (surrogates)
Diffstat (limited to 'starmath/source')
-rw-r--r--starmath/source/cfgitem.cxx6
-rwxr-xr-x[-rw-r--r--]starmath/source/dialog.cxx85
-rw-r--r--starmath/source/node.cxx21
-rwxr-xr-xstarmath/source/smres.src14
-rw-r--r--starmath/source/symbol.cxx2
-rw-r--r--starmath/source/utility.cxx2
6 files changed, 80 insertions, 50 deletions
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index bf62157a30d3..c0f9c18808b3 100644
--- a/starmath/source/cfgitem.cxx
+++ b/starmath/source/cfgitem.cxx
@@ -490,7 +490,7 @@ void SmMathConfig::ReadSymbol( SmSym &rSymbol,
{
const Any * pValue = aValues.getConstArray();
Font aFont;
- sal_Unicode cChar = '\0';
+ sal_UCS4 cChar = '\0';
String aSet;
BOOL bPredefined = FALSE;
@@ -500,7 +500,7 @@ void SmMathConfig::ReadSymbol( SmSym &rSymbol,
BOOL bOK = TRUE;
if (pValue->hasValue() && (*pValue >>= nTmp32))
- cChar = (sal_Unicode) nTmp32;
+ cChar = static_cast< sal_UCS4 >( nTmp32 );
else
bOK = FALSE;
++pValue;
@@ -624,7 +624,7 @@ void SmMathConfig::SetSymbols( const std::vector< SmSym > &rNewSymbols )
// Char
pVal->Name = aNodeNameDelim;
pVal->Name += *pName++;
- pVal->Value <<= (INT32) rSymbol.GetCharacter();
+ pVal->Value <<= static_cast< sal_UCS4 >( rSymbol.GetCharacter() );
pVal++;
// Set
pVal->Name = aNodeNameDelim;
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 037f2fc1dff8..bb80e9d65c5b 100644..100755
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -50,17 +50,18 @@
#include <svx/ucsubset.hxx>
-#include "config.hxx"
#include "dialog.hxx"
-#ifndef _STARMATH_HRC
#include "starmath.hrc"
-#endif
-
+#include "config.hxx"
#include "dialog.hrc"
#include "smmod.hxx"
#include "symbol.hxx"
#include "view.hxx"
#include "document.hxx"
+#include "unomodel.hxx"
+
+
+using ::rtl::OUString;
////////////////////////////////////////
//
@@ -1157,11 +1158,13 @@ void SmShowSymbolSet::Paint(const Rectangle&)
SetTextColor( aTxtColor );
int nIV = i - v;
- Size aSize(GetTextWidth(aSymbol.GetCharacter()), GetTextHeight());
+ sal_UCS4 cChar = aSymbol.GetCharacter();
+ String aText( OUString( &cChar, 1 ) );
+ Size aSize( GetTextWidth( aText ), GetTextHeight());
DrawText(Point((nIV % nColumns) * nLen + (nLen - aSize.Width()) / 2,
(nIV / nColumns) * nLen + (nLen - aSize.Height()) / 2),
- aSymbol.GetCharacter());
+ aText);
}
if (nSelectSymbol != SYMBOL_NONE)
@@ -1360,7 +1363,9 @@ void SmShowSymbol::SetSymbol(const SmSym *pSymbol)
// keep old text color (font may have different color set)
SetTextColor(aTxtColor);
- SetText(XubString(pSymbol->GetCharacter()));
+ sal_UCS4 cChar = pSymbol->GetCharacter();
+ String aText( OUString( &cChar, 1 ) );
+ SetText( aText );
}
// 'Invalidate' fuellt den background mit der background-Farbe.
@@ -1483,8 +1488,9 @@ IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton )
const SmSym *pSym = GetSymbol();
if (pSym)
{
- XubString aText ('%');
+ String aText ('%');
aText += pSym->GetName();
+ aText += (sal_Unicode)' ';
rViewSh.GetViewFrame()->GetDispatcher()->Execute(
SID_INSERTTEXT, SFX_CALLMODE_STANDARD,
@@ -1640,31 +1646,36 @@ void SmShowChar::Paint(const Rectangle &rRect)
{
Control::Paint( rRect );
- XubString Text (GetText ());
- if (Text.Len() > 0)
+ OUString aText( GetText() );
+ if (aText.getLength() > 0)
{
- Size aTextSize(GetTextWidth(Text), GetTextHeight());
+#if OSL_DEBUG_LEVEL > 1
+ sal_Int32 nPos = 0;
+ sal_UCS4 cChar = aText.iterateCodePoints( &nPos );
+ (void) cChar;
+#endif
+ Size aTextSize(GetTextWidth(aText), GetTextHeight());
DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
- (GetOutputSize().Height() - aTextSize.Height()) / 2), Text);
+ (GetOutputSize().Height() - aTextSize.Height()) / 2), aText);
}
}
-void SmShowChar::SetChar(xub_Unicode aChar)
+void SmShowChar::SetSymbol( const SmSym *pSym )
{
- SetText(XubString(aChar));
- Invalidate();
+ if (pSym)
+ SetSymbol( pSym->GetCharacter(), pSym->GetFace() );
}
-void SmShowChar::SetFont(const Font &rFont)
+void SmShowChar::SetSymbol( sal_UCS4 cChar, const Font &rFont )
{
Color aTxtColor( GetTextColor() );
- Font aFont (rFont);
- Size aSize (Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
+ Size aSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
+ Font aFont( rFont );
aFont.SetSize(aSize);
aFont.SetAlign(ALIGN_TOP);
aFont.SetTransparent(TRUE);
@@ -1673,9 +1684,13 @@ void SmShowChar::SetFont(const Font &rFont)
// keep text color (new font may have different one)
SetTextColor( aTxtColor );
+ String aText( OUString( &cChar, 1) );
+ SetText( aText );
+
Invalidate();
}
+
////////////////////////////////////////////////////////////////////////////////
void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, BOOL bDeleteText)
@@ -1862,7 +1877,7 @@ IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox )
IMPL_LINK( SmSymDefineDialog, CharHighlightHdl, Control *, EMPTYARG )
{
- sal_UCS4 cChar = aCharsetDisplay.GetSelectCharacter();
+ sal_UCS4 cChar = aCharsetDisplay.GetSelectCharacter();
#if OSL_DEBUG_LEVEL > 1
DBG_ASSERT( pSubsetMap, "SubsetMap missing" );
@@ -1876,9 +1891,18 @@ IMPL_LINK( SmSymDefineDialog, CharHighlightHdl, Control *, EMPTYARG )
aFontsSubsetLB.SetNoSelection();
}
- // TO_DO_UCS4 (#i74049): get rid of cast without loosing UCS4 functionality
- aSymbolDisplay.SetChar( sal::static_int_cast< sal_Unicode >(cChar) );
+ aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() );
+
UpdateButtons();
+
+ // display Unicode position as symbol name while iterating over characters
+ const String aHex( String::CreateFromInt64( cChar, 16 ).ToUpperAscii() );
+ const String aPattern( A2OU( aHex.Len() > 4 ? "Ux000000" : "Ux0000" ) );
+ String aUnicodePos( aPattern.Copy( 0, aPattern.Len() - aHex.Len() ) );
+ aUnicodePos += aHex;
+ aSymbols.SetText( aUnicodePos );
+ aSymbolName.SetText( aUnicodePos );
+
return 0;
}
@@ -1892,16 +1916,13 @@ IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton )
#endif
// add symbol
- // TO_DO_UCS4 (#i74049): get rid of cast without loosing UCS4 functionality
const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(),
- sal::static_int_cast< sal_Unicode >( aCharsetDisplay.GetSelectCharacter() ),
- aSymbolSets.GetText() );
+ aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() );
//DBG_ASSERT( aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL, "symbol already exists" );
aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol );
// update display of new symbol
- aSymbolDisplay.SetChar( aNewSymbol.GetCharacter() );
- aSymbolDisplay.SetFont( aNewSymbol.GetFace() );
+ aSymbolDisplay.SetSymbol( &aNewSymbol );
aSymbolName.SetText( aNewSymbol.GetName() );
aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() );
@@ -1928,10 +1949,8 @@ IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
// get new Sybol to use
//! get font from symbol-disp lay since charset-display does not keep
//! the bold attribut.
- // TO_DO_UCS4 (#i74049): get rid of cast without loosing UCS4 functionality
const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(),
- sal::static_int_cast< sal_Unicode >( aCharsetDisplay.GetSelectCharacter() ),
- aSymbolSets.GetText() );
+ aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() );
// remove old symbol if the name was changed then add new one
// const bool bSetNameChanged = aOldSymbolSets.GetText() != aSymbolSets.GetText();
@@ -1945,8 +1964,7 @@ IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
SetOrigSymbol(NULL, XubString());
// update display of new symbol
- aSymbolDisplay.SetChar( aNewSymbol.GetCharacter() );
- aSymbolDisplay.SetFont( aNewSymbol.GetFace() );
+ aSymbolDisplay.SetSymbol( &aNewSymbol );
aSymbolName.SetText( aNewSymbol.GetName() );
aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() );
@@ -2266,8 +2284,7 @@ void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol,
aSymName = pSymbol->GetName();
aSymSetName = rSymbolSetName;
- aOldSymbolDisplay.SetFont(pSymbol->GetFace());
- aOldSymbolDisplay.SetChar(pSymbol->GetCharacter());
+ aOldSymbolDisplay.SetSymbol( pSymbol );
}
else
{ // loeschen des angezeigten Symbols
@@ -2439,7 +2456,7 @@ BOOL SmSymDefineDialog::SelectStyle(const XubString &rStyleName, BOOL bApplyFont
void SmSymDefineDialog::SelectChar(xub_Unicode cChar)
{
aCharsetDisplay.SelectCharacter( cChar );
- aSymbolDisplay.SetChar( cChar );
+ aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() );
UpdateButtons();
}
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 4601b2f84fec..49a2948a3872 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -28,7 +28,6 @@
// 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 <tools/gen.hxx>
#include <tools/fract.hxx>
#include <rtl/math.hxx>
@@ -38,23 +37,27 @@
#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 APPEND(str,ascii) str.AppendAscii(RTL_CONSTASCII_STRINGPARAM(ascii))
+
// define this to draw rectangles for debugging
//#define SM_RECT_DEBUG
+
+using ::rtl::OUString;
+
+
////////////////////////////////////////
// SmTmpDevice
// Allows for font and color changes. The original settings will be restored
@@ -2459,6 +2462,12 @@ void SmTextNode::Draw(OutputDevice &rDev, const Point& rPosition) const
// auf Pixelkoordinaten runden
aPos = rDev.PixelToLogic( rDev.LogicToPixel(aPos) );
+#if OSL_DEBUG_LEVEL > 1
+ sal_Int32 nPos = 0;
+ sal_UCS4 cChar = OUString( aText ).iterateCodePoints( &nPos );
+ (void) cChar;
+#endif
+
rDev.DrawStretchText(aPos, GetWidth(), aText);
#ifdef SM_RECT_DEBUG
@@ -2808,7 +2817,9 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell
if (NULL != (pSym = pp->GetSymbolManager().GetSymbolByName(GetToken().aText)))
{
- SetText( pSym->GetCharacter() );
+ sal_UCS4 cChar = pSym->GetCharacter();
+ String aText( OUString( &cChar, 1 ) );
+ SetText( aText );
GetFont() = pSym->GetFace();
}
else
diff --git a/starmath/source/smres.src b/starmath/source/smres.src
index 7d3525bd2a29..6813c1e1c6a2 100755
--- a/starmath/source/smres.src
+++ b/starmath/source/smres.src
@@ -1147,7 +1147,7 @@ ModalDialog RID_SYMDEFINEDIALOG
ComboBox 1
{
Pos = MAP_APPFONT ( 59 , 6 ) ;
- Size = MAP_APPFONT ( 80 , 50 ) ;
+ Size = MAP_APPFONT ( 80 , 100 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
Sort = TRUE ;
@@ -1162,7 +1162,7 @@ ModalDialog RID_SYMDEFINEDIALOG
ComboBox 2
{
Pos = MAP_APPFONT ( 210 , 6 ) ;
- Size = MAP_APPFONT ( 80 , 50 ) ;
+ Size = MAP_APPFONT ( 80 , 100 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
Sort = TRUE ;
@@ -1186,7 +1186,7 @@ ModalDialog RID_SYMDEFINEDIALOG
ComboBox 4
{
Pos = MAP_APPFONT ( 80 , 115 ) ;
- Size = MAP_APPFONT ( 100 , 80 ) ;
+ Size = MAP_APPFONT ( 100 , 100 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
Sort = TRUE ;
@@ -1201,7 +1201,7 @@ ModalDialog RID_SYMDEFINEDIALOG
ComboBox 5
{
Pos = MAP_APPFONT ( 80 , 130 ) ;
- Size = MAP_APPFONT ( 100 , 50 ) ;
+ Size = MAP_APPFONT ( 100 , 100 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
Sort = TRUE ;
@@ -1217,7 +1217,7 @@ ModalDialog RID_SYMDEFINEDIALOG
{
Border = TRUE ;
Pos = MAP_APPFONT ( 80 , 145 ) ;
- Size = MAP_APPFONT ( 100 , 50 ) ;
+ Size = MAP_APPFONT ( 100 , 100 ) ;
TabStop = TRUE ;
Sort = TRUE ;
DropDown = TRUE ;
@@ -1233,7 +1233,7 @@ ModalDialog RID_SYMDEFINEDIALOG
{
Border = TRUE ;
Pos = MAP_APPFONT ( 80 , 160 ) ;
- Size = MAP_APPFONT ( 100 , 50 ) ;
+ Size = MAP_APPFONT ( 100 , 100 ) ;
TabStop = TRUE ;
Sort = FALSE ;
DropDown = TRUE ;
@@ -1249,7 +1249,7 @@ ModalDialog RID_SYMDEFINEDIALOG
{
Border = TRUE;
Pos = MAP_APPFONT ( 80 , 175 ) ;
- Size = MAP_APPFONT ( 100 , 50 ) ;
+ Size = MAP_APPFONT ( 100 , 100 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
Sort = FALSE ;
diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx
index e248f9726629..4e0580f40d2f 100644
--- a/starmath/source/symbol.cxx
+++ b/starmath/source/symbol.cxx
@@ -78,7 +78,7 @@ SmSym::SmSym(const SmSym& rSymbol)
}
-SmSym::SmSym(const String& rName, const Font& rFont, sal_Unicode cChar,
+SmSym::SmSym(const String& rName, const Font& rFont, sal_UCS4 cChar,
const String& rSet, BOOL bIsPredefined)
{
m_aName = m_aExportName = rName;
diff --git a/starmath/source/utility.cxx b/starmath/source/utility.cxx
index 0000bf5cf766..ff62e1631265 100644
--- a/starmath/source/utility.cxx
+++ b/starmath/source/utility.cxx
@@ -45,6 +45,8 @@
#include "smdll.hxx"
+////////////////////////////////////////////////////////////
+
// return pointer to active SmViewShell, if this is not possible
// return 0 instead.
//!! Since this method is based on the current focus it is somewhat