summaryrefslogtreecommitdiff
path: root/starmath/source/dialog.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'starmath/source/dialog.cxx')
-rwxr-xr-x[-rw-r--r--]starmath/source/dialog.cxx121
1 files changed, 68 insertions, 53 deletions
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 0dc58c8ed640..ee1de4b5dbbb 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)
@@ -1333,7 +1336,7 @@ void SmShowSymbol::Paint(const Rectangle &rRect)
Size aTextSize(GetTextWidth(rText), GetTextHeight());
DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
- (GetOutputSize().Height() - aTextSize.Height()) / 2), rText);
+ (GetOutputSize().Height() * 7/10)), rText);
}
@@ -1350,17 +1353,14 @@ void SmShowSymbol::SetSymbol(const SmSym *pSymbol)
{
if (pSymbol)
{
- Color aTxtColor( GetTextColor() );
-
Font aFont (pSymbol->GetFace());
aFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
- aFont.SetAlign(ALIGN_TOP);
+ aFont.SetAlign(ALIGN_BASELINE);
SetFont(aFont);
- // 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,7 +1483,7 @@ IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton )
const SmSym *pSym = GetSymbol();
if (pSym)
{
- XubString aText ('%');
+ String aText ('%');
aText += pSym->GetName();
aText += (sal_Unicode)' ';
@@ -1644,42 +1644,43 @@ 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() * 7/10)), 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 );
+ aFont.SetSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3) );
+ aFont.SetAlign(ALIGN_BASELINE);
+ SetFont(aFont);
- Font aFont (rFont);
- Size aSize (Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
-
- aFont.SetSize(aSize);
- aFont.SetAlign(ALIGN_TOP);
- aFont.SetTransparent(TRUE);
- Control::SetFont(aFont);
-
- // 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)
@@ -1866,7 +1867,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" );
@@ -1880,9 +1881,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;
}
@@ -1896,16 +1906,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() );
@@ -1932,10 +1939,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();
@@ -1949,8 +1954,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() );
@@ -2083,8 +2087,8 @@ SmSymDefineDialog::SmSymDefineDialog(Window * pParent,
// auto completion is troublesome since that symbols character also gets automatically selected in the
// display and if the user previously selected a character to define/redefine that one this is bad
- aOldSymbols.EnableAutocomplete( FALSE, TRUE );
- aSymbols .EnableAutocomplete( FALSE, TRUE );
+ aOldSymbols.EnableAutocomplete( FALSE, TRUE );
+ aSymbols .EnableAutocomplete( FALSE, TRUE );
FillFonts();
if (aFonts.GetEntryCount() > 0)
@@ -2270,8 +2274,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
@@ -2325,6 +2328,10 @@ BOOL SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox,
// das zugehoerige Zeichen auswaehlen
SelectChar(pSymbol->GetCharacter());
+
+ // since SelectChar will also set the unicode point as text in the
+ // symbols box, we have to set the symbol name again to get that one displayed
+ aSymbols.SetText( pSymbol->GetName() );
}
}
@@ -2381,7 +2388,7 @@ void SmSymDefineDialog::SetFont(const XubString &rFontName, const XubString &rSt
aFontsSubsetLB.SetEntryData( nPos, (void *) pSubset );
// subset must live at least as long as the selected font !!!
if( bFirst )
- aFontsSubsetLB.SelectEntryPos( nPos );
+ aFontsSubsetLB.SelectEntryPos( nPos );
bFirst = false;
}
if( bFirst )
@@ -2401,7 +2408,11 @@ BOOL SmSymDefineDialog::SelectFont(const XubString &rFontName, BOOL bApplyFont)
if (aStyles.GetEntryCount() > 0)
SelectStyle(aStyles.GetEntry(0));
if (bApplyFont)
+ {
SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
+ // update preview to use new font
+ aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() );
+ }
bRet = TRUE;
}
else
@@ -2428,7 +2439,11 @@ BOOL SmSymDefineDialog::SelectStyle(const XubString &rStyleName, BOOL bApplyFont
{
aStyles.SetText(aStyles.GetEntry(nPos));
if (bApplyFont)
+ {
SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
+ // update preview to use new font
+ aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() );
+ }
bRet = TRUE;
}
else
@@ -2443,7 +2458,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();
}