diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-11-19 09:51:15 +0100 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-11-19 09:51:15 +0100 |
commit | 8bf24a92b0e97a52412e4e12fb7223e36c1efcdf (patch) | |
tree | 4efc960be1036db23b718fa5393ad9ea4672e68e /starmath/source/dialog.cxx | |
parent | cws tl84: #i114767# Math: added option to save only used symbols (diff) | |
parent | #i10000# some additional fixes for CWS vmiklos01 (diff) | |
download | core-8bf24a92b0e97a52412e4e12fb7223e36c1efcdf.tar.gz core-8bf24a92b0e97a52412e4e12fb7223e36c1efcdf.zip |
cws tl84: merge with DEV300_m93
Diffstat (limited to 'starmath/source/dialog.cxx')
-rwxr-xr-x | starmath/source/dialog.cxx | 130 |
1 files changed, 73 insertions, 57 deletions
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index c04642ec0e9f..15a644fcfba5 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; //////////////////////////////////////// // @@ -767,7 +768,7 @@ IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox ) } -void SmDistanceDialog::SetHelpId(MetricField &rField, ULONG nHelpId) +void SmDistanceDialog::SetHelpId(MetricField &rField, const rtl::OString& sHelpId) { //! HelpID's die auf diese Weise explizit gesetzt werden, muessen im //! util Verzeichnis im File "hidother.src" mit Hilfe von "hidspecial" @@ -778,7 +779,7 @@ void SmDistanceDialog::SetHelpId(MetricField &rField, ULONG nHelpId) DBG_ASSERT(aEmptyText.Len() == 0, "Sm: Ooops..."); #endif - rField.SetHelpId(nHelpId); + rField.SetHelpId(sHelpId); rField.SetHelpText(aEmptyText); // since MetricField inherits from SpinField which has a sub Edit field @@ -786,7 +787,8 @@ void SmDistanceDialog::SetHelpId(MetricField &rField, ULONG nHelpId) // for it too. Edit *pSubEdit = rField.GetSubEdit(); if (pSubEdit) - { pSubEdit->SetHelpId(nHelpId); + { + pSubEdit->SetHelpId(sHelpId); pSubEdit->SetHelpText(aEmptyText); } } @@ -804,7 +806,7 @@ void SmDistanceDialog::SetCategory(USHORT nCategory) #if OSL_DEBUG_LEVEL > 1 DBG_ASSERT(NOCATEGORIES == 10, "Sm : Array passt nicht zu Anzahl der Kategorien"); #endif - ULONG __READONLY_DATA aCatMf2Hid[10][4] = + const char* __READONLY_DATA aCatMf2Hid[10][4] = { { HID_SMA_DEFAULT_DIST, HID_SMA_LINE_DIST, HID_SMA_ROOT_DIST, 0 }, { HID_SMA_SUP_DIST, HID_SMA_SUB_DIST , 0, 0 }, @@ -1160,11 +1162,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) @@ -1336,7 +1340,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); } @@ -1353,17 +1357,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. @@ -1486,7 +1487,7 @@ IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton ) const SmSym *pSym = GetSymbol(); if (pSym) { - XubString aText ('%'); + String aText ('%'); aText += pSym->GetName(); aText += (sal_Unicode)' '; @@ -1647,42 +1648,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) @@ -1869,7 +1871,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" ); @@ -1883,9 +1885,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; } @@ -1899,16 +1910,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() ); @@ -1935,10 +1943,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(); @@ -1952,8 +1958,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() ); @@ -2086,8 +2091,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) @@ -2273,8 +2278,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 @@ -2328,6 +2332,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() ); } } @@ -2384,7 +2392,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 ) @@ -2404,7 +2412,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 @@ -2431,7 +2443,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 @@ -2446,7 +2462,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(); } |