Kaydet (Commit) 889d495c authored tarafından Thomas Lange [tl]'s avatar Thomas Lange [tl]

cws tl82: #i74049# math symbols should be able to handle 20 bit Unicode characters (surrogates)

üst 3ed4c287
......@@ -30,9 +30,7 @@
#include <vcl/image.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#ifndef _SV_BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#include <vcl/image.hxx>
#include <sfx2/tabdlg.hxx>
#include <vcl/combobox.hxx>
......@@ -403,8 +401,8 @@ public:
{
}
void SetChar(xub_Unicode aChar);
void SetFont(const Font &rFont);
void SetSymbol( const SmSym *pSym );
void SetSymbol( sal_UCS4 cChar, const Font &rFont );
};
////////////////////////////////////////////////////////////////////////////////
......
......@@ -79,24 +79,24 @@ class SmSym
String m_aName;
String m_aExportName;
String m_aSetName;
sal_Unicode m_cChar;
sal_UCS4 m_cChar;
BOOL m_bPredefined;
BOOL m_bDocSymbol;
public:
SmSym();
SmSym(const String& rName, const Font& rFont, sal_Unicode cChar,
SmSym(const String& rName, const Font& rFont, sal_UCS4 cChar,
const String& rSet, BOOL bIsPredefined = FALSE);
SmSym(const SmSym& rSymbol);
SmSym& operator = (const SmSym& rSymbol);
const Font& GetFace() const { return m_aFace; }
sal_Unicode GetCharacter() const { return m_cChar; }
sal_UCS4 GetCharacter() const { return m_cChar; }
const String& GetName() const { return m_aName; }
void SetFace( const Font& rFont ) { m_aFace = rFont; }
void SetCharacter( sal_Unicode cChar ) { m_cChar = cChar; }
void SetCharacter( sal_UCS4 cChar ) { m_cChar = cChar; }
//! since the symbol name is also used as key in the map it should not be possible to change the name
//! because ten the key would not be the same as its supposed copy here
......
......@@ -42,10 +42,6 @@ class String;
#define C2S(cChar) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))
/////////////////////////////////////////////////////////////////
const ByteString ExportString( const String& rString );
const String ImportString( const ByteString& rByteString );
/////////////////////////////////////////////////////////////////
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -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
......
......@@ -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 ;
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment