LCOV - code coverage report
Current view: top level - starmath/source - dialog.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 1266 0.1 %
Date: 2014-11-03 Functions: 2 152 1.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "tools/rcid.h"
      21             : #include <comphelper/string.hxx>
      22             : #include <svl/eitem.hxx>
      23             : #include <svl/intitem.hxx>
      24             : #include <svl/stritem.hxx>
      25             : #include <sfx2/app.hxx>
      26             : #include <vcl/builder.hxx>
      27             : #include <vcl/layout.hxx>
      28             : #include <vcl/msgbox.hxx>
      29             : #include <svtools/ctrltool.hxx>
      30             : #include <sfx2/printer.hxx>
      31             : #include <vcl/help.hxx>
      32             : #include <vcl/waitobj.hxx>
      33             : #include <vcl/settings.hxx>
      34             : #include <vcl/wall.hxx>
      35             : #include <sfx2/dispatch.hxx>
      36             : #include <sfx2/sfx.hrc>
      37             : #include <osl/diagnose.h>
      38             : #include <svx/ucsubset.hxx>
      39             : 
      40             : 
      41             : #include "dialog.hxx"
      42             : #include "starmath.hrc"
      43             : #include "config.hxx"
      44             : #include "smmod.hxx"
      45             : #include "symbol.hxx"
      46             : #include "view.hxx"
      47             : #include "document.hxx"
      48             : #include "unomodel.hxx"
      49             : 
      50             : 
      51             : // Since it's better to set/query the FontStyle via its attributes rather
      52             : // than via the StyleName we create a way to translate
      53             : // Attribute <-> StyleName
      54             : 
      55           0 : class SmFontStyles
      56             : {
      57             :     OUString aNormal;
      58             :     OUString aBold;
      59             :     OUString aItalic;
      60             :     OUString aBoldItalic;
      61             :     OUString aEmpty;
      62             : 
      63             : public:
      64             :     SmFontStyles();
      65             : 
      66           0 :     sal_uInt16          GetCount() const    { return 4; }
      67             :     const OUString&  GetStyleName( const vcl::Font &rFont ) const;
      68             :     const OUString&  GetStyleName( sal_uInt16 nIdx ) const;
      69             : };
      70             : 
      71             : 
      72           0 : SmFontStyles::SmFontStyles() :
      73           0 :     aNormal ( ResId( RID_FONTREGULAR, *SM_MOD()->GetResMgr() ) ),
      74           0 :     aBold   ( ResId( RID_FONTBOLD,    *SM_MOD()->GetResMgr() ) ),
      75           0 :     aItalic ( ResId( RID_FONTITALIC,  *SM_MOD()->GetResMgr() ) )
      76             : {
      77             : 
      78           0 :     aBoldItalic = aBold;
      79           0 :     aBoldItalic += ", ";
      80           0 :     aBoldItalic += aItalic;
      81           0 : }
      82             : 
      83             : 
      84           0 : const OUString& SmFontStyles::GetStyleName( const vcl::Font &rFont ) const
      85             : {
      86             :     //! compare also SmSpecialNode::Prepare
      87           0 :     bool bBold   = IsBold( rFont ),
      88           0 :          bItalic = IsItalic( rFont );
      89             : 
      90           0 :     if (bBold && bItalic)
      91           0 :         return aBoldItalic;
      92           0 :     else if (bItalic)
      93           0 :         return aItalic;
      94           0 :     else if (bBold)
      95           0 :         return aBold;
      96           0 :     return aNormal;
      97             : }
      98             : 
      99             : 
     100           0 : const OUString& SmFontStyles::GetStyleName( sal_uInt16 nIdx ) const
     101             : {
     102             :     // 0 = "normal",  1 = "italic",
     103             :     // 2 = "bold",    3 = "bold italic"
     104             : 
     105             : #if OSL_DEBUG_LEVEL > 1
     106             :     OSL_ENSURE( nIdx < GetCount(), "index out of range" );
     107             : #endif
     108           0 :     switch (nIdx)
     109             :     {
     110           0 :         case 0 : return aNormal;
     111           0 :         case 1 : return aItalic;
     112           0 :         case 2 : return aBold;
     113           0 :         case 3 : return aBoldItalic;
     114             :     }
     115           0 :     return aEmpty;
     116             : }
     117             : 
     118             : 
     119           0 : const SmFontStyles & GetFontStyles()
     120             : {
     121           0 :     static const SmFontStyles aImpl;
     122           0 :     return aImpl;
     123             : }
     124             : 
     125             : 
     126             : 
     127           0 : void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont)
     128             : {
     129             :     // Find index related to StyleName. For an empty StyleName it's assumed to be
     130             :     // 0 (neither bold nor italic).
     131           0 :     sal_uInt16  nIndex = 0;
     132           0 :     if (!rStyleName.isEmpty())
     133             :     {
     134             :         sal_uInt16 i;
     135           0 :         const SmFontStyles &rStyles = GetFontStyles();
     136           0 :         for (i = 0;  i < rStyles.GetCount(); ++i)
     137           0 :             if (rStyleName == rStyles.GetStyleName(i))
     138           0 :                 break;
     139             : #if OSL_DEBUG_LEVEL > 1
     140             :         OSL_ENSURE(i < rStyles.GetCount(), "style-name unknown");
     141             : #endif
     142           0 :         nIndex = i;
     143             :     }
     144             : 
     145           0 :     rFont.SetItalic((nIndex & 0x1) ? ITALIC_NORMAL : ITALIC_NONE);
     146           0 :     rFont.SetWeight((nIndex & 0x2) ? WEIGHT_BOLD : WEIGHT_NORMAL);
     147           0 : }
     148             : 
     149             : 
     150             : /**************************************************************************/
     151             : 
     152           0 : IMPL_LINK_INLINE_START( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, EMPTYARG/*pButton*/ )
     153             : {
     154           0 :     m_pZoom->Enable(m_pSizeZoomed->IsChecked());
     155           0 :     return 0;
     156             : }
     157           0 : IMPL_LINK_INLINE_END( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, pButton )
     158             : 
     159             : 
     160           0 : SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window *pParent, const SfxItemSet &rOptions)
     161           0 :     : SfxTabPage(pParent, "SmathSettings", "modules/smath/ui/smathsettings.ui", &rOptions)
     162             : {
     163           0 :     get( m_pTitle,               "title");
     164           0 :     get( m_pText,                "text");
     165           0 :     get( m_pFrame,               "frame");
     166           0 :     get( m_pSizeNormal,          "sizenormal");
     167           0 :     get( m_pSizeScaled,          "sizescaled");
     168           0 :     get( m_pSizeZoomed,          "sizezoomed");
     169           0 :     get( m_pZoom,                "zoom");
     170           0 :     get( m_pNoRightSpaces,       "norightspaces");
     171           0 :     get( m_pSaveOnlyUsedSymbols, "saveonlyusedsymbols");
     172             : 
     173           0 :     m_pSizeNormal->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
     174           0 :     m_pSizeScaled->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
     175           0 :     m_pSizeZoomed->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
     176             : 
     177           0 :     Reset(&rOptions);
     178           0 : }
     179             : 
     180             : 
     181           0 : bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet)
     182             : {
     183             :     sal_uInt16  nPrintSize;
     184           0 :     if (m_pSizeNormal->IsChecked())
     185           0 :         nPrintSize = PRINT_SIZE_NORMAL;
     186           0 :     else if (m_pSizeScaled->IsChecked())
     187           0 :         nPrintSize = PRINT_SIZE_SCALED;
     188             :     else
     189           0 :         nPrintSize = PRINT_SIZE_ZOOMED;
     190             : 
     191           0 :     rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTSIZE), (sal_uInt16) nPrintSize));
     192           0 :     rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), (sal_uInt16) m_pZoom->GetValue()));
     193           0 :     rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), m_pTitle->IsChecked()));
     194           0 :     rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), m_pText->IsChecked()));
     195           0 :     rSet->Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), m_pFrame->IsChecked()));
     196           0 :     rSet->Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), m_pNoRightSpaces->IsChecked()));
     197           0 :     rSet->Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), m_pSaveOnlyUsedSymbols->IsChecked()));
     198             : 
     199           0 :     return true;
     200             : }
     201             : 
     202             : 
     203           0 : void SmPrintOptionsTabPage::Reset(const SfxItemSet* rSet)
     204             : {
     205           0 :     SmPrintSize ePrintSize = (SmPrintSize)((const SfxUInt16Item &)rSet->Get(GetWhich(SID_PRINTSIZE))).GetValue();
     206             : 
     207           0 :     m_pSizeNormal->Check(ePrintSize == PRINT_SIZE_NORMAL);
     208           0 :     m_pSizeScaled->Check(ePrintSize == PRINT_SIZE_SCALED);
     209           0 :     m_pSizeZoomed->Check(ePrintSize == PRINT_SIZE_ZOOMED);
     210             : 
     211           0 :     m_pZoom->Enable(m_pSizeZoomed->IsChecked());
     212             : 
     213           0 :     m_pZoom->SetValue(((const SfxUInt16Item &)rSet->Get(GetWhich(SID_PRINTZOOM))).GetValue());
     214             : 
     215           0 :     m_pTitle->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_PRINTTITLE))).GetValue());
     216           0 :     m_pText->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_PRINTTEXT))).GetValue());
     217           0 :     m_pFrame->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_PRINTFRAME))).GetValue());
     218           0 :     m_pNoRightSpaces->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue());
     219           0 :     m_pSaveOnlyUsedSymbols->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue());
     220           0 : }
     221             : 
     222             : 
     223           0 : SfxTabPage* SmPrintOptionsTabPage::Create(vcl::Window* pWindow, const SfxItemSet& rSet)
     224             : {
     225           0 :     return (new SmPrintOptionsTabPage(pWindow, rSet));
     226             : }
     227             : 
     228             : /**************************************************************************/
     229             : 
     230             : 
     231           0 : void SmShowFont::Paint(const Rectangle& rRect )
     232             : {
     233           0 :     Window::Paint( rRect );
     234             : 
     235           0 :     OUString   Text (GetFont().GetName());
     236           0 :     Size    TextSize(GetTextWidth(Text), GetTextHeight());
     237             : 
     238           0 :     DrawText(Point((GetOutputSize().Width()  - TextSize.Width())  / 2,
     239           0 :                    (GetOutputSize().Height() - TextSize.Height()) / 2), Text);
     240           0 : }
     241             : 
     242           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSmShowFont(vcl::Window* pParent, VclBuilder::stringmap &rMap)
     243             : {
     244           0 :     WinBits nWinStyle = 0;
     245             : 
     246           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     247           0 :     if (!sBorder.isEmpty())
     248           0 :         nWinStyle |= WB_BORDER;
     249             : 
     250           0 :     return new SmShowFont(pParent, nWinStyle);
     251             : }
     252             : 
     253           0 : Size SmShowFont::GetOptimalSize() const
     254             : {
     255           0 :     return LogicToPixel(Size(111 , 31), MapMode(MAP_APPFONT));
     256             : }
     257             : 
     258           0 : void SmShowFont::SetFont(const vcl::Font& rFont)
     259             : {
     260           0 :     Color aTxtColor( GetTextColor() );
     261           0 :     vcl::Font aFont (rFont);
     262             : 
     263           0 :     Invalidate();
     264           0 :     aFont.SetSize(Size(0, 24));
     265           0 :     aFont.SetAlign(ALIGN_TOP);
     266           0 :     Window::SetFont(aFont);
     267             : 
     268             :     // keep old text color (new font may have different color)
     269           0 :     SetTextColor( aTxtColor );
     270           0 : }
     271             : 
     272           0 : IMPL_LINK_INLINE_START( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
     273             : {
     274           0 :     Face.SetName(pComboBox->GetText());
     275           0 :     m_pShowFont->SetFont(Face);
     276           0 :     return 0;
     277             : }
     278           0 : IMPL_LINK_INLINE_END( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
     279             : 
     280             : 
     281           0 : IMPL_LINK( SmFontDialog, FontModifyHdl, ComboBox *, pComboBox )
     282             : {
     283             :     // if font is available in list then use it
     284           0 :     sal_Int32 nPos = pComboBox->GetEntryPos( pComboBox->GetText() );
     285           0 :     if (COMBOBOX_ENTRY_NOTFOUND != nPos)
     286             :     {
     287           0 :         FontSelectHdl( pComboBox );
     288             :     }
     289           0 :     return 0;
     290             : }
     291             : 
     292             : 
     293           0 : IMPL_LINK( SmFontDialog, AttrChangeHdl, CheckBox *, EMPTYARG /*pCheckBox*/ )
     294             : {
     295           0 :     if (m_pBoldCheckBox->IsChecked())
     296           0 :         Face.SetWeight(FontWeight(WEIGHT_BOLD));
     297             :     else
     298           0 :         Face.SetWeight(FontWeight(WEIGHT_NORMAL));
     299             : 
     300           0 :     if (m_pItalicCheckBox->IsChecked())
     301           0 :         Face.SetItalic(ITALIC_NORMAL);
     302             :     else
     303           0 :         Face.SetItalic(ITALIC_NONE);
     304             : 
     305           0 :     m_pShowFont->SetFont(Face);
     306           0 :     return 0;
     307             : }
     308             : 
     309             : 
     310           0 : void SmFontDialog::SetFont(const vcl::Font &rFont)
     311             : {
     312           0 :     Face = rFont;
     313             : 
     314           0 :     m_pFontBox->SetText( Face.GetName() );
     315           0 :     m_pBoldCheckBox->Check( IsBold( Face ) );
     316           0 :     m_pItalicCheckBox->Check( IsItalic( Face ) );
     317             : 
     318           0 :     m_pShowFont->SetFont(Face);
     319           0 : }
     320             : 
     321           0 : SmFontDialog::SmFontDialog(vcl::Window * pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes)
     322           0 :     : ModalDialog(pParent, "FontDialog", "modules/smath/ui/fontdialog.ui")
     323             : {
     324           0 :     get(m_pFontBox, "font");
     325           0 :     m_pFontBox->set_height_request(8 * m_pFontBox->GetTextHeight());
     326           0 :     get(m_pAttrFrame, "attrframe");
     327           0 :     get(m_pBoldCheckBox, "bold");
     328           0 :     get(m_pItalicCheckBox, "italic");
     329           0 :     get(m_pShowFont, "preview");
     330             : 
     331             :     {
     332           0 :         WaitObject aWait( this );
     333             : 
     334           0 :         FontList aFontList( pFntListDevice );
     335             : 
     336           0 :         sal_uInt16  nCount = aFontList.GetFontNameCount();
     337           0 :         for (sal_uInt16 i = 0;  i < nCount; ++i)
     338           0 :             m_pFontBox->InsertEntry( aFontList.GetFontName(i).GetName() );
     339             : 
     340           0 :         Face.SetSize(Size(0, 24));
     341           0 :         Face.SetWeight(WEIGHT_NORMAL);
     342           0 :         Face.SetItalic(ITALIC_NONE);
     343           0 :         Face.SetFamily(FAMILY_DONTKNOW);
     344           0 :         Face.SetPitch(PITCH_DONTKNOW);
     345           0 :         Face.SetCharSet(RTL_TEXTENCODING_DONTKNOW);
     346           0 :         Face.SetTransparent(true);
     347             : 
     348           0 :         InitColor_Impl();
     349             : 
     350             :         // preview like controls should have a 2D look
     351           0 :         m_pShowFont->SetBorderStyle( WindowBorderStyle::MONO );
     352             :     }
     353             : 
     354           0 :     m_pFontBox->SetSelectHdl(LINK(this, SmFontDialog, FontSelectHdl));
     355           0 :     m_pFontBox->SetModifyHdl(LINK(this, SmFontDialog, FontModifyHdl));
     356           0 :     m_pBoldCheckBox->SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
     357           0 :     m_pItalicCheckBox->SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
     358             : 
     359           0 :     if (bHideCheckboxes)
     360             :     {
     361           0 :         m_pBoldCheckBox->Check( false );
     362           0 :         m_pBoldCheckBox->Enable( false );
     363           0 :         m_pItalicCheckBox->Check( false );
     364           0 :         m_pItalicCheckBox->Enable( false );
     365           0 :         m_pAttrFrame->Show(false);
     366             :     }
     367           0 : }
     368             : 
     369             : namespace
     370             : {
     371           0 :     void getColors(vcl::Window &rRef, ColorData &rBgCol, ColorData &rTxtCol)
     372             :     {
     373           0 :         const StyleSettings &rS = rRef.GetSettings().GetStyleSettings();
     374           0 :         if (rS.GetHighContrastMode())
     375             :         {
     376           0 :             rBgCol  = rS.GetFieldColor().GetColor();
     377           0 :             rTxtCol = rS.GetFieldTextColor().GetColor();
     378             :         }
     379             :         else
     380             :         {
     381           0 :             rBgCol  = COL_WHITE;
     382           0 :             rTxtCol = COL_BLACK;
     383             :         }
     384           0 :     }
     385             : }
     386             : 
     387           0 : void SmFontDialog::InitColor_Impl()
     388             : {
     389             :     ColorData nBgCol, nTxtCol;
     390           0 :     getColors(*this, nBgCol, nTxtCol);
     391             : 
     392           0 :     Color aTmpColor( nBgCol );
     393           0 :     Wallpaper aWall( aTmpColor );
     394           0 :     Color aTxtColor( nTxtCol );
     395           0 :     m_pShowFont->SetBackground( aWall );
     396           0 :     m_pShowFont->SetTextColor( aTxtColor );
     397           0 : }
     398             : 
     399           0 : void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt )
     400             : {
     401           0 :     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS  &&
     402           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     403           0 :             InitColor_Impl();
     404             : 
     405           0 :     ModalDialog::DataChanged( rDCEvt );
     406           0 : }
     407             : 
     408           0 : class SaveDefaultsQuery : public MessageDialog
     409             : {
     410             : public:
     411           0 :     SaveDefaultsQuery(vcl::Window *pParent)
     412             :         : MessageDialog(pParent, "SaveDefaultsDialog",
     413           0 :             "modules/smath/ui/savedefaultsdialog.ui")
     414             :     {
     415           0 :     }
     416             : };
     417             : 
     418           0 : IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
     419             : {
     420           0 :     if (SaveDefaultsQuery(this).Execute() == RET_YES)
     421             :     {
     422           0 :         SmModule *pp = SM_MOD();
     423           0 :         SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
     424           0 :         WriteTo( aFmt );
     425           0 :         pp->GetConfig()->SetStandardFormat( aFmt );
     426             :     }
     427           0 :     return 0;
     428             : }
     429             : 
     430           0 : SmFontSizeDialog::SmFontSizeDialog(vcl::Window * pParent)
     431           0 :     : ModalDialog(pParent, "FontSizeDialog", "modules/smath/ui/fontsizedialog.ui")
     432             : {
     433           0 :     get(m_pTextSize, "spinB_text");
     434           0 :     get(m_pIndexSize, "spinB_index");
     435           0 :     get(m_pFunctionSize, "spinB_function");
     436           0 :     get(m_pOperatorSize, "spinB_operator");
     437           0 :     get(m_pBorderSize, "spinB_limit");
     438           0 :     get(m_pBaseSize, "spinB_baseSize");
     439           0 :     get(m_pDefaultButton, "default");
     440             : 
     441           0 :     m_pDefaultButton->SetClickHdl(LINK(this, SmFontSizeDialog, DefaultButtonClickHdl));
     442           0 : }
     443             : 
     444             : 
     445           0 : void SmFontSizeDialog::ReadFrom(const SmFormat &rFormat)
     446             : {
     447             :     //! aufpassen: richtig runden!
     448             :     m_pBaseSize->SetValue( SmRoundFraction(
     449           0 :         Sm100th_mmToPts( rFormat.GetBaseSize().Height() ) ) );
     450             : 
     451           0 :     m_pTextSize->SetValue( rFormat.GetRelSize(SIZ_TEXT) );
     452           0 :     m_pIndexSize->SetValue( rFormat.GetRelSize(SIZ_INDEX) );
     453           0 :     m_pFunctionSize->SetValue( rFormat.GetRelSize(SIZ_FUNCTION) );
     454           0 :     m_pOperatorSize->SetValue( rFormat.GetRelSize(SIZ_OPERATOR) );
     455           0 :     m_pBorderSize->SetValue( rFormat.GetRelSize(SIZ_LIMITS) );
     456           0 : }
     457             : 
     458             : 
     459           0 : void SmFontSizeDialog::WriteTo(SmFormat &rFormat) const
     460             : {
     461           0 :     rFormat.SetBaseSize( Size(0, SmPtsTo100th_mm( static_cast< long >(m_pBaseSize->GetValue()))) );
     462             : 
     463           0 :     rFormat.SetRelSize(SIZ_TEXT,     (sal_uInt16) m_pTextSize->GetValue());
     464           0 :     rFormat.SetRelSize(SIZ_INDEX,    (sal_uInt16) m_pIndexSize->GetValue());
     465           0 :     rFormat.SetRelSize(SIZ_FUNCTION, (sal_uInt16) m_pFunctionSize->GetValue());
     466           0 :     rFormat.SetRelSize(SIZ_OPERATOR, (sal_uInt16) m_pOperatorSize->GetValue());
     467           0 :     rFormat.SetRelSize(SIZ_LIMITS,   (sal_uInt16) m_pBorderSize->GetValue());
     468             : 
     469           0 :     const Size aTmp (rFormat.GetBaseSize());
     470           0 :     for (sal_uInt16  i = FNT_BEGIN;  i <= FNT_END;  i++)
     471           0 :         rFormat.SetFontSize(i, aTmp);
     472             : 
     473           0 :     rFormat.RequestApplyChanges();
     474           0 : }
     475             : 
     476             : 
     477             : /**************************************************************************/
     478             : 
     479             : 
     480           0 : IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu )
     481             : {
     482             :     SmFontPickListBox *pActiveListBox;
     483             : 
     484           0 :     bool bHideCheckboxes = false;
     485           0 :     switch (pMenu->GetCurItemId())
     486             :     {
     487           0 :         case 1: pActiveListBox = m_pVariableFont; break;
     488           0 :         case 2: pActiveListBox = m_pFunctionFont; break;
     489           0 :         case 3: pActiveListBox = m_pNumberFont;   break;
     490           0 :         case 4: pActiveListBox = m_pTextFont;     break;
     491           0 :         case 5: pActiveListBox = m_pSerifFont; bHideCheckboxes = true;   break;
     492           0 :         case 6: pActiveListBox = m_pSansFont;  bHideCheckboxes = true;   break;
     493           0 :         case 7: pActiveListBox = m_pFixedFont; bHideCheckboxes = true;   break;
     494           0 :         default:pActiveListBox = NULL;
     495             :     }
     496             : 
     497           0 :     if (pActiveListBox)
     498             :     {
     499           0 :         SmFontDialog *pFontDialog = new SmFontDialog(this, pFontListDev, bHideCheckboxes);
     500             : 
     501           0 :         pActiveListBox->WriteTo(*pFontDialog);
     502           0 :         if (pFontDialog->Execute() == RET_OK)
     503           0 :             pActiveListBox->ReadFrom(*pFontDialog);
     504           0 :         delete pFontDialog;
     505             :     }
     506           0 :     return 0;
     507             : }
     508             : 
     509             : 
     510           0 : IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
     511             : {
     512           0 :     if (SaveDefaultsQuery(this).Execute() == RET_YES)
     513             :     {
     514           0 :         SmModule *pp = SM_MOD();
     515           0 :         SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
     516           0 :         WriteTo( aFmt );
     517           0 :         pp->GetConfig()->SetStandardFormat( aFmt, true );
     518             :     }
     519           0 :     return 0;
     520             : }
     521           0 : IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton )
     522             : 
     523           0 : SmFontTypeDialog::SmFontTypeDialog(vcl::Window * pParent, OutputDevice *pFntListDevice)
     524             :     : ModalDialog(pParent, "FontsDialog", "modules/smath/ui/fonttypedialog.ui"),
     525           0 :     pFontListDev    (pFntListDevice)
     526             : {
     527           0 :     get(m_pVariableFont, "variableCB");
     528           0 :     get(m_pFunctionFont, "functionCB");
     529           0 :     get(m_pNumberFont, "numberCB");
     530           0 :     get(m_pTextFont, "textCB");
     531           0 :     get(m_pSerifFont, "serifCB");
     532           0 :     get(m_pSansFont, "sansCB");
     533           0 :     get(m_pFixedFont, "fixedCB");
     534           0 :     get(m_pMenuButton, "modify");
     535           0 :     get(m_pDefaultButton, "default");
     536             : 
     537           0 :     m_pDefaultButton->SetClickHdl(LINK(this, SmFontTypeDialog, DefaultButtonClickHdl));
     538             : 
     539           0 :     m_pMenuButton->GetPopupMenu()->SetSelectHdl(LINK(this, SmFontTypeDialog, MenuSelectHdl));
     540           0 : }
     541             : 
     542           0 : void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat)
     543             : {
     544           0 :     SmModule *pp = SM_MOD();
     545             : 
     546           0 :     *m_pVariableFont = pp->GetConfig()->GetFontPickList(FNT_VARIABLE);
     547           0 :     *m_pFunctionFont = pp->GetConfig()->GetFontPickList(FNT_FUNCTION);
     548           0 :     *m_pNumberFont   = pp->GetConfig()->GetFontPickList(FNT_NUMBER);
     549           0 :     *m_pTextFont     = pp->GetConfig()->GetFontPickList(FNT_TEXT);
     550           0 :     *m_pSerifFont    = pp->GetConfig()->GetFontPickList(FNT_SERIF);
     551           0 :     *m_pSansFont     = pp->GetConfig()->GetFontPickList(FNT_SANS);
     552           0 :     *m_pFixedFont    = pp->GetConfig()->GetFontPickList(FNT_FIXED);
     553             : 
     554           0 :     m_pVariableFont->Insert( rFormat.GetFont(FNT_VARIABLE) );
     555           0 :     m_pFunctionFont->Insert( rFormat.GetFont(FNT_FUNCTION) );
     556           0 :     m_pNumberFont->Insert( rFormat.GetFont(FNT_NUMBER) );
     557           0 :     m_pTextFont->Insert( rFormat.GetFont(FNT_TEXT) );
     558           0 :     m_pSerifFont->Insert( rFormat.GetFont(FNT_SERIF) );
     559           0 :     m_pSansFont->Insert( rFormat.GetFont(FNT_SANS) );
     560           0 :     m_pFixedFont->Insert( rFormat.GetFont(FNT_FIXED) );
     561           0 : }
     562             : 
     563             : 
     564           0 : void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const
     565             : {
     566           0 :     SmModule *pp = SM_MOD();
     567             : 
     568           0 :     pp->GetConfig()->GetFontPickList(FNT_VARIABLE) = *m_pVariableFont;
     569           0 :     pp->GetConfig()->GetFontPickList(FNT_FUNCTION) = *m_pFunctionFont;
     570           0 :     pp->GetConfig()->GetFontPickList(FNT_NUMBER)   = *m_pNumberFont;
     571           0 :     pp->GetConfig()->GetFontPickList(FNT_TEXT)     = *m_pTextFont;
     572           0 :     pp->GetConfig()->GetFontPickList(FNT_SERIF)    = *m_pSerifFont;
     573           0 :     pp->GetConfig()->GetFontPickList(FNT_SANS)     = *m_pSansFont;
     574           0 :     pp->GetConfig()->GetFontPickList(FNT_FIXED)    = *m_pFixedFont;
     575             : 
     576           0 :     rFormat.SetFont( FNT_VARIABLE, m_pVariableFont->Get(0) );
     577           0 :     rFormat.SetFont( FNT_FUNCTION, m_pFunctionFont->Get(0) );
     578           0 :     rFormat.SetFont( FNT_NUMBER,   m_pNumberFont->Get(0) );
     579           0 :     rFormat.SetFont( FNT_TEXT,     m_pTextFont->Get(0) );
     580           0 :     rFormat.SetFont( FNT_SERIF,    m_pSerifFont->Get(0) );
     581           0 :     rFormat.SetFont( FNT_SANS,     m_pSansFont->Get(0) );
     582           0 :     rFormat.SetFont( FNT_FIXED,    m_pFixedFont->Get(0) );
     583             : 
     584           0 :     rFormat.RequestApplyChanges();
     585           0 : }
     586             : 
     587             : /**************************************************************************/
     588             : 
     589             : struct FieldMinMax
     590             : {
     591             :     sal_uInt16 nMin, nMax;
     592             : };
     593             : 
     594             : // Data for min and max values of the 4 metric fields
     595             : // for each of the 10 categories
     596             : static const FieldMinMax pMinMaxData[10][4] =
     597             : {
     598             :     // 0
     599             :     {{ 0, 200 },    { 0, 200 },     { 0, 100 },     { 0, 0 }},
     600             :     // 1
     601             :     {{ 0, 100 },    { 0, 100 },     { 0, 0 },       { 0, 0 }},
     602             :     // 2
     603             :     {{ 0, 100 },    { 0, 100 },     { 0, 0 },       { 0, 0 }},
     604             :     // 3
     605             :     {{ 0, 100 },    { 1, 100 },     { 0, 0 },       { 0, 0 }},
     606             :     // 4
     607             :     {{ 0, 100 },    { 0, 100 },     { 0, 0 },       { 0, 0 }},
     608             :     // 5
     609             :     {{ 0, 100 },    { 0, 100 },     { 0, 0 },       { 0, 100 }},
     610             :     // 6
     611             :     {{ 0, 300 },    { 0, 300 },     { 0, 0 },       { 0, 0 }},
     612             :     // 7
     613             :     {{ 0, 100 },    { 0, 100 },     { 0, 0 },       { 0, 0 }},
     614             :     // 8
     615             :     {{ 0, 100 },    { 0, 100 },     { 0, 0 },       { 0, 0 }},
     616             :     // 9
     617             :     {{ 0, 10000 },  { 0, 10000 },   { 0, 10000 },   { 0, 10000 }}
     618             : };
     619             : 
     620           0 : SmCategoryDesc::SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCategoryIdx)
     621             : {
     622           0 :     ++nCategoryIdx;
     623           0 :     FixedText* pTitle = rBuilder.get<FixedText>(OString::number(nCategoryIdx)+"title");
     624           0 :     if (pTitle)
     625             :     {
     626           0 :         Name = pTitle->GetText();
     627             :     }
     628           0 :     for (int i = 0; i < 4; ++i)
     629             :     {
     630           0 :         FixedText* pLabel = rBuilder.get<FixedText>(OString::number(nCategoryIdx)+"label"+OString::number(i+1));
     631             : 
     632           0 :         if (pLabel)
     633             :         {
     634           0 :             Strings  [i] = new OUString(pLabel->GetText());
     635           0 :             FixedImage* pImage = rBuilder.get<FixedImage>(OString::number(nCategoryIdx)+"image"+OString::number(i+1));
     636           0 :             Graphics [i] = new Image(pImage->GetImage());
     637             :         }
     638             :         else
     639             :         {
     640           0 :             Strings  [i] = 0;
     641           0 :             Graphics [i] = 0;
     642             :         }
     643             : 
     644           0 :         const FieldMinMax& rMinMax = pMinMaxData[ nCategoryIdx-1 ][i];
     645           0 :         Value[i] = Minimum[i] = rMinMax.nMin;
     646           0 :         Maximum[i] = rMinMax.nMax;
     647             :     }
     648           0 : }
     649             : 
     650           0 : SmCategoryDesc::~SmCategoryDesc()
     651             : {
     652           0 :     for (int i = 0; i < 4; ++i)
     653             :     {
     654           0 :         delete Strings  [i];
     655           0 :         delete Graphics [i];
     656             :     }
     657           0 : }
     658             : 
     659             : /**************************************************************************/
     660             : 
     661           0 : IMPL_LINK( SmDistanceDialog, GetFocusHdl, Control *, pControl )
     662             : {
     663           0 :     if (Categories[nActiveCategory])
     664             :     {
     665             :         sal_uInt16  i;
     666             : 
     667           0 :         if (pControl == m_pMetricField1)
     668           0 :             i = 0;
     669           0 :         else if (pControl == m_pMetricField2)
     670           0 :             i = 1;
     671           0 :         else if (pControl == m_pMetricField3)
     672           0 :             i = 2;
     673           0 :         else if (pControl == m_pMetricField4)
     674           0 :             i = 3;
     675             :         else
     676           0 :             return 0;
     677           0 :         m_pBitmap->SetImage(*(Categories[nActiveCategory]->GetGraphic(i)));
     678             :     }
     679           0 :     return 0;
     680             : }
     681             : 
     682           0 : IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu )
     683             : {
     684           0 :     SetCategory(pMenu->GetCurItemId() - 1);
     685           0 :     return 0;
     686             : }
     687             : 
     688             : 
     689           0 : IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
     690             : {
     691           0 :     if (SaveDefaultsQuery(this).Execute() == RET_YES)
     692             :     {
     693           0 :         SmModule *pp = SM_MOD();
     694           0 :         SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
     695           0 :         WriteTo( aFmt );
     696           0 :         pp->GetConfig()->SetStandardFormat( aFmt );
     697             :     }
     698           0 :     return 0;
     699             : }
     700             : 
     701           0 : IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox )
     702             : {
     703           0 :     if (pCheckBox == m_pCheckBox1)
     704             :     {
     705           0 :         m_pCheckBox1->Toggle();
     706             : 
     707           0 :         bool bChecked = m_pCheckBox1->IsChecked();
     708           0 :         m_pFixedText4->Enable( bChecked );
     709           0 :         m_pMetricField4->Enable( bChecked );
     710             :     }
     711           0 :     return 0;
     712             : }
     713             : 
     714             : 
     715           0 : void SmDistanceDialog::SetHelpId(MetricField &rField, const OString& sHelpId)
     716             : {
     717           0 :     const OUString aEmptyText;
     718             : 
     719           0 :     rField.SetHelpId(sHelpId);
     720           0 :     rField.SetHelpText(aEmptyText);
     721             : 
     722             :     // since MetricField inherits from SpinField which has a sub Edit field
     723             :     // (which is actually the one we modify) we have to set the help-id
     724             :     // for it too.
     725           0 :     Edit *pSubEdit = rField.GetSubEdit();
     726           0 :     if (pSubEdit)
     727             :     {
     728           0 :         pSubEdit->SetHelpId(sHelpId);
     729           0 :         pSubEdit->SetHelpText(aEmptyText);
     730           0 :     }
     731           0 : }
     732             : 
     733             : 
     734           0 : void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
     735             : {
     736             : #if OSL_DEBUG_LEVEL > 1
     737             :     OSL_ENSURE(/*0 <= nCategory  &&*/  nCategory < NOCATEGORIES,
     738             :         "Sm: wrong category number in SmDistanceDialog");
     739             : #endif
     740             : 
     741             :     // array to convert category- and metricfield-number in help ids.
     742             :     // 0 is used in case of unused combinations.
     743             : #if OSL_DEBUG_LEVEL > 1
     744             :     OSL_ENSURE(NOCATEGORIES == 10, "Sm : array doesn't fit into the number of categories");
     745             : #endif
     746             :     static const char * aCatMf2Hid[10][4] =
     747             :     {
     748             :         { HID_SMA_DEFAULT_DIST,         HID_SMA_LINE_DIST,          HID_SMA_ROOT_DIST, 0 },
     749             :         { HID_SMA_SUP_DIST,             HID_SMA_SUB_DIST ,          0, 0 },
     750             :         { HID_SMA_NUMERATOR_DIST,       HID_SMA_DENOMINATOR_DIST,   0, 0 },
     751             :         { HID_SMA_FRACLINE_EXCWIDTH,    HID_SMA_FRACLINE_LINEWIDTH, 0, 0 },
     752             :         { HID_SMA_UPPERLIMIT_DIST,      HID_SMA_LOWERLIMIT_DIST,    0, 0 },
     753             :         { HID_SMA_BRACKET_EXCHEIGHT,    HID_SMA_BRACKET_DIST,       0, HID_SMA_BRACKET_EXCHEIGHT2 },
     754             :         { HID_SMA_MATRIXROW_DIST,       HID_SMA_MATRIXCOL_DIST,     0, 0 },
     755             :         { HID_SMA_ATTRIBUT_DIST,        HID_SMA_INTERATTRIBUT_DIST, 0, 0 },
     756             :         { HID_SMA_OPERATOR_EXCHEIGHT,   HID_SMA_OPERATOR_DIST,      0, 0 },
     757             :         { HID_SMA_LEFTBORDER_DIST,      HID_SMA_RIGHTBORDER_DIST,   HID_SMA_UPPERBORDER_DIST, HID_SMA_LOWERBORDER_DIST }
     758             :     };
     759             : 
     760             :     // array to help iterate over the controls
     761             :     vcl::Window * const  aWin[4][2] =
     762             :     {
     763             :         { m_pFixedText1, m_pMetricField1 },
     764             :         { m_pFixedText2, m_pMetricField2 },
     765             :         { m_pFixedText3, m_pMetricField3 },
     766             :         { m_pFixedText4, m_pMetricField4 }
     767           0 :     };
     768             : 
     769             :     SmCategoryDesc *pCat;
     770             : 
     771             :     // remember the (maybe new) settings of the active SmCategoryDesc
     772             :     // before switching to the new one
     773           0 :     if (nActiveCategory != CATEGORY_NONE)
     774             :     {
     775           0 :         pCat = Categories[nActiveCategory];
     776           0 :         pCat->SetValue(0, (sal_uInt16) m_pMetricField1->GetValue());
     777           0 :         pCat->SetValue(1, (sal_uInt16) m_pMetricField2->GetValue());
     778           0 :         pCat->SetValue(2, (sal_uInt16) m_pMetricField3->GetValue());
     779           0 :         pCat->SetValue(3, (sal_uInt16) m_pMetricField4->GetValue());
     780             : 
     781           0 :         if (nActiveCategory == 5)
     782           0 :             bScaleAllBrackets = m_pCheckBox1->IsChecked();
     783             : 
     784           0 :         m_pMenuButton->GetPopupMenu()->CheckItem(nActiveCategory + 1, false);
     785             :     }
     786             : 
     787             :     // activation/deactivation of the associated controls depending on the chosen category
     788             :     bool  bActive;
     789           0 :     for (sal_uInt16 i = 0;  i < 4;  i++)
     790             :     {
     791           0 :         FixedText   *pFT = (FixedText * const)   aWin[i][0];
     792           0 :         MetricField *pMF = (MetricField * const) aWin[i][1];
     793             : 
     794             :         // To determine which Controls should be active, the existence
     795             :         // of an associated HelpID is checked
     796           0 :         bActive = aCatMf2Hid[nCategory][i] != 0;
     797             : 
     798           0 :         pFT->Show(bActive);
     799           0 :         pFT->Enable(bActive);
     800           0 :         pMF->Show(bActive);
     801           0 :         pMF->Enable(bActive);
     802             : 
     803             :         // set measurement unit and number of decimal places
     804             :         FieldUnit  eUnit;
     805             :         sal_uInt16     nDigits;
     806           0 :         if (nCategory < 9)
     807             :         {
     808           0 :             eUnit = FUNIT_PERCENT;
     809           0 :             nDigits = 0;
     810             :         }
     811             :         else
     812             :         {
     813           0 :             eUnit   = FUNIT_100TH_MM;
     814           0 :             nDigits = 2;
     815             :         }
     816           0 :         pMF->SetUnit(eUnit);            // changes the value
     817           0 :         pMF->SetDecimalDigits(nDigits);
     818             : 
     819           0 :         if (bActive)
     820             :         {
     821           0 :             pCat = Categories[nCategory];
     822           0 :             pFT->SetText(*pCat->GetString(i));
     823             : 
     824           0 :             pMF->SetMin(pCat->GetMinimum(i));
     825           0 :             pMF->SetMax(pCat->GetMaximum(i));
     826           0 :             pMF->SetValue(pCat->GetValue(i));
     827             : 
     828           0 :             SetHelpId(*pMF, aCatMf2Hid[nCategory][i]);
     829             :         }
     830             :     }
     831             :     // activate the CheckBox and the associated MetricField if we're dealing with the brackets menu
     832           0 :     bActive = nCategory == 5;
     833           0 :     m_pCheckBox1->Show(bActive);
     834           0 :     m_pCheckBox1->Enable(bActive);
     835           0 :     if (bActive)
     836             :     {
     837           0 :         m_pCheckBox1->Check( bScaleAllBrackets );
     838             : 
     839           0 :         bool bChecked = m_pCheckBox1->IsChecked();
     840           0 :         m_pFixedText4->Enable( bChecked );
     841           0 :         m_pMetricField4->Enable( bChecked );
     842             :     }
     843             : 
     844           0 :     m_pMenuButton->GetPopupMenu()->CheckItem(nCategory + 1, true);
     845           0 :     m_pFrame->set_label(Categories[nCategory]->GetName());
     846             : 
     847           0 :     nActiveCategory = nCategory;
     848             : 
     849           0 :     m_pMetricField1->GrabFocus();
     850           0 :     Invalidate();
     851           0 :     Update();
     852           0 : }
     853             : 
     854             : 
     855           0 : SmDistanceDialog::SmDistanceDialog(vcl::Window *pParent)
     856             :     : ModalDialog(pParent, "SpacingDialog",
     857           0 :         "modules/smath/ui/spacingdialog.ui")
     858             : {
     859           0 :     get(m_pFrame, "template");
     860           0 :     get(m_pFixedText1, "label1");
     861           0 :     get(m_pMetricField1, "spinbutton1");
     862           0 :     get(m_pFixedText2, "label2");
     863           0 :     get(m_pMetricField2, "spinbutton2");
     864           0 :     get(m_pFixedText3, "label3");
     865           0 :     get(m_pMetricField3, "spinbutton3");
     866           0 :     get(m_pCheckBox1, "checkbutton");
     867           0 :     get(m_pFixedText4, "label4");
     868           0 :     get(m_pMetricField4, "spinbutton4");
     869           0 :     get(m_pMenuButton, "category");
     870           0 :     get(m_pDefaultButton, "default");
     871           0 :     get(m_pBitmap, "image");
     872             : 
     873           0 :     for (sal_uInt16 i = 0; i < NOCATEGORIES; ++i)
     874           0 :         Categories[i] = new SmCategoryDesc(*this, i);
     875           0 :     nActiveCategory   = CATEGORY_NONE;
     876           0 :     bScaleAllBrackets = false;
     877             : 
     878             :     // preview like controls should have a 2D look
     879           0 :     m_pBitmap->SetBorderStyle( WindowBorderStyle::MONO );
     880             : 
     881           0 :     m_pMetricField1->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
     882           0 :     m_pMetricField2->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
     883           0 :     m_pMetricField3->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
     884           0 :     m_pMetricField4->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
     885           0 :     m_pCheckBox1->SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
     886             : 
     887           0 :     m_pMenuButton->GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
     888             : 
     889           0 :     m_pDefaultButton->SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
     890           0 : }
     891             : 
     892             : 
     893           0 : SmDistanceDialog::~SmDistanceDialog()
     894             : {
     895           0 :     for (int i = 0; i < NOCATEGORIES; i++)
     896           0 :         DELETEZ(Categories[i]);
     897           0 : }
     898             : 
     899           0 : void SmDistanceDialog::DataChanged( const DataChangedEvent &rEvt )
     900             : {
     901           0 :     ModalDialog::DataChanged( rEvt );
     902           0 : }
     903             : 
     904           0 : void SmDistanceDialog::ReadFrom(const SmFormat &rFormat)
     905             : {
     906           0 :     Categories[0]->SetValue(0, rFormat.GetDistance(DIS_HORIZONTAL));
     907           0 :     Categories[0]->SetValue(1, rFormat.GetDistance(DIS_VERTICAL));
     908           0 :     Categories[0]->SetValue(2, rFormat.GetDistance(DIS_ROOT));
     909           0 :     Categories[1]->SetValue(0, rFormat.GetDistance(DIS_SUPERSCRIPT));
     910           0 :     Categories[1]->SetValue(1, rFormat.GetDistance(DIS_SUBSCRIPT));
     911           0 :     Categories[2]->SetValue(0, rFormat.GetDistance(DIS_NUMERATOR));
     912           0 :     Categories[2]->SetValue(1, rFormat.GetDistance(DIS_DENOMINATOR));
     913           0 :     Categories[3]->SetValue(0, rFormat.GetDistance(DIS_FRACTION));
     914           0 :     Categories[3]->SetValue(1, rFormat.GetDistance(DIS_STROKEWIDTH));
     915           0 :     Categories[4]->SetValue(0, rFormat.GetDistance(DIS_UPPERLIMIT));
     916           0 :     Categories[4]->SetValue(1, rFormat.GetDistance(DIS_LOWERLIMIT));
     917           0 :     Categories[5]->SetValue(0, rFormat.GetDistance(DIS_BRACKETSIZE));
     918           0 :     Categories[5]->SetValue(1, rFormat.GetDistance(DIS_BRACKETSPACE));
     919           0 :     Categories[5]->SetValue(3, rFormat.GetDistance(DIS_NORMALBRACKETSIZE));
     920           0 :     Categories[6]->SetValue(0, rFormat.GetDistance(DIS_MATRIXROW));
     921           0 :     Categories[6]->SetValue(1, rFormat.GetDistance(DIS_MATRIXCOL));
     922           0 :     Categories[7]->SetValue(0, rFormat.GetDistance(DIS_ORNAMENTSIZE));
     923           0 :     Categories[7]->SetValue(1, rFormat.GetDistance(DIS_ORNAMENTSPACE));
     924           0 :     Categories[8]->SetValue(0, rFormat.GetDistance(DIS_OPERATORSIZE));
     925           0 :     Categories[8]->SetValue(1, rFormat.GetDistance(DIS_OPERATORSPACE));
     926           0 :     Categories[9]->SetValue(0, rFormat.GetDistance(DIS_LEFTSPACE));
     927           0 :     Categories[9]->SetValue(1, rFormat.GetDistance(DIS_RIGHTSPACE));
     928           0 :     Categories[9]->SetValue(2, rFormat.GetDistance(DIS_TOPSPACE));
     929           0 :     Categories[9]->SetValue(3, rFormat.GetDistance(DIS_BOTTOMSPACE));
     930             : 
     931           0 :     bScaleAllBrackets = rFormat.IsScaleNormalBrackets();
     932             : 
     933             :     // force update (even of category 0) by setting nActiveCategory to a
     934             :     // non-existent category number
     935           0 :     nActiveCategory = CATEGORY_NONE;
     936           0 :     SetCategory(0);
     937           0 : }
     938             : 
     939             : 
     940           0 : void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/
     941             : {
     942             :     // TODO can they actually be different?
     943             :     // if that's not the case 'const' could be used above!
     944           0 :     SetCategory(nActiveCategory);
     945             : 
     946           0 :     rFormat.SetDistance( DIS_HORIZONTAL,        Categories[0]->GetValue(0) );
     947           0 :     rFormat.SetDistance( DIS_VERTICAL,          Categories[0]->GetValue(1) );
     948           0 :     rFormat.SetDistance( DIS_ROOT,              Categories[0]->GetValue(2) );
     949           0 :     rFormat.SetDistance( DIS_SUPERSCRIPT,       Categories[1]->GetValue(0) );
     950           0 :     rFormat.SetDistance( DIS_SUBSCRIPT,         Categories[1]->GetValue(1) );
     951           0 :     rFormat.SetDistance( DIS_NUMERATOR,         Categories[2]->GetValue(0) );
     952           0 :     rFormat.SetDistance( DIS_DENOMINATOR,       Categories[2]->GetValue(1) );
     953           0 :     rFormat.SetDistance( DIS_FRACTION,          Categories[3]->GetValue(0) );
     954           0 :     rFormat.SetDistance( DIS_STROKEWIDTH,       Categories[3]->GetValue(1) );
     955           0 :     rFormat.SetDistance( DIS_UPPERLIMIT,        Categories[4]->GetValue(0) );
     956           0 :     rFormat.SetDistance( DIS_LOWERLIMIT,        Categories[4]->GetValue(1) );
     957           0 :     rFormat.SetDistance( DIS_BRACKETSIZE,       Categories[5]->GetValue(0) );
     958           0 :     rFormat.SetDistance( DIS_BRACKETSPACE,      Categories[5]->GetValue(1) );
     959           0 :     rFormat.SetDistance( DIS_MATRIXROW,         Categories[6]->GetValue(0) );
     960           0 :     rFormat.SetDistance( DIS_MATRIXCOL,         Categories[6]->GetValue(1) );
     961           0 :     rFormat.SetDistance( DIS_ORNAMENTSIZE,      Categories[7]->GetValue(0) );
     962           0 :     rFormat.SetDistance( DIS_ORNAMENTSPACE,     Categories[7]->GetValue(1) );
     963           0 :     rFormat.SetDistance( DIS_OPERATORSIZE,      Categories[8]->GetValue(0) );
     964           0 :     rFormat.SetDistance( DIS_OPERATORSPACE,     Categories[8]->GetValue(1) );
     965           0 :     rFormat.SetDistance( DIS_LEFTSPACE,         Categories[9]->GetValue(0) );
     966           0 :     rFormat.SetDistance( DIS_RIGHTSPACE,        Categories[9]->GetValue(1) );
     967           0 :     rFormat.SetDistance( DIS_TOPSPACE,          Categories[9]->GetValue(2) );
     968           0 :     rFormat.SetDistance( DIS_BOTTOMSPACE,       Categories[9]->GetValue(3) );
     969           0 :     rFormat.SetDistance( DIS_NORMALBRACKETSIZE, Categories[5]->GetValue(3) );
     970             : 
     971           0 :     rFormat.SetScaleNormalBrackets( bScaleAllBrackets );
     972             : 
     973           0 :     rFormat.RequestApplyChanges();
     974           0 : }
     975             : 
     976           0 : IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
     977             : {
     978           0 :     if (SaveDefaultsQuery(this).Execute() == RET_YES)
     979             :     {
     980           0 :         SmModule *pp = SM_MOD();
     981           0 :         SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
     982           0 :         WriteTo( aFmt );
     983           0 :         pp->GetConfig()->SetStandardFormat( aFmt );
     984             :     }
     985           0 :     return 0;
     986             : }
     987             : 
     988           0 : SmAlignDialog::SmAlignDialog(vcl::Window * pParent)
     989             :     : ModalDialog(pParent, "AlignmentDialog",
     990           0 :         "modules/smath/ui/alignmentdialog.ui")
     991             : {
     992           0 :     get(m_pLeft, "left");
     993           0 :     get(m_pCenter, "center");
     994           0 :     get(m_pRight, "right");
     995           0 :     get(m_pDefaultButton, "default");
     996           0 :     m_pDefaultButton->SetClickHdl(LINK(this, SmAlignDialog, DefaultButtonClickHdl));
     997           0 : }
     998             : 
     999             : 
    1000           0 : void SmAlignDialog::ReadFrom(const SmFormat &rFormat)
    1001             : {
    1002           0 :     switch (rFormat.GetHorAlign())
    1003             :     {
    1004             :         case AlignLeft:
    1005           0 :             m_pLeft->Check(true);
    1006           0 :             m_pCenter->Check(false);
    1007           0 :             m_pRight->Check(false);
    1008           0 :             break;
    1009             : 
    1010             :         case AlignCenter:
    1011           0 :             m_pLeft->Check(false);
    1012           0 :             m_pCenter->Check(true);
    1013           0 :             m_pRight->Check(false);
    1014           0 :             break;
    1015             : 
    1016             :         case AlignRight:
    1017           0 :             m_pLeft->Check(false);
    1018           0 :             m_pCenter->Check(false);
    1019           0 :             m_pRight->Check(true);
    1020           0 :             break;
    1021             :     }
    1022           0 : }
    1023             : 
    1024             : 
    1025           0 : void SmAlignDialog::WriteTo(SmFormat &rFormat) const
    1026             : {
    1027           0 :     if (m_pLeft->IsChecked())
    1028           0 :         rFormat.SetHorAlign(AlignLeft);
    1029           0 :     else if (m_pRight->IsChecked())
    1030           0 :         rFormat.SetHorAlign(AlignRight);
    1031             :     else
    1032           0 :         rFormat.SetHorAlign(AlignCenter);
    1033             : 
    1034           0 :     rFormat.RequestApplyChanges();
    1035           0 : }
    1036             : 
    1037             : 
    1038           0 : SmShowSymbolSetWindow::SmShowSymbolSetWindow(vcl::Window *pParent, WinBits nStyle)
    1039             :     : Control(pParent, nStyle)
    1040             :     , m_pVScrollBar(0)
    1041             :     , nLen(0)
    1042             :     , nRows(0)
    1043             :     , nColumns(0)
    1044             :     , nXOffset(0)
    1045             :     , nYOffset(0)
    1046           0 :     , nSelectSymbol(SYMBOL_NONE)
    1047             : {
    1048             :     ColorData nBgCol, nTxtCol;
    1049           0 :     getColors(*this, nBgCol, nTxtCol);
    1050             : 
    1051           0 :     Color aTmpColor( nBgCol );
    1052           0 :     Wallpaper aWall( aTmpColor );
    1053           0 :     Color aTxtColor( nTxtCol );
    1054           0 :     SetBackground( aWall );
    1055           0 :     SetTextColor( aTxtColor );
    1056           0 : }
    1057             : 
    1058           0 : Point SmShowSymbolSetWindow::OffsetPoint(const Point &rPoint) const
    1059             : {
    1060           0 :     return Point(rPoint.X() + nXOffset, rPoint.Y() + nYOffset);
    1061             : }
    1062             : 
    1063           0 : void SmShowSymbolSetWindow::Paint(const Rectangle&)
    1064             : {
    1065           0 :     Push(PushFlags::MAPMODE);
    1066             : 
    1067             :     // set MapUnit for which 'nLen' has been calculated
    1068           0 :     SetMapMode(MapMode(MAP_PIXEL));
    1069             : 
    1070           0 :     sal_uInt16 v        = sal::static_int_cast< sal_uInt16 >((m_pVScrollBar->GetThumbPos() * nColumns));
    1071           0 :     size_t nSymbols = aSymbolSet.size();
    1072             : 
    1073           0 :     Color aTxtColor( GetTextColor() );
    1074           0 :     for (sal_uInt16 i = v; i < nSymbols ; i++)
    1075             :     {
    1076           0 :         SmSym     aSymbol (*aSymbolSet[i]);
    1077           0 :         vcl::Font aFont   (aSymbol.GetFace());
    1078           0 :         aFont.SetAlign(ALIGN_TOP);
    1079             : 
    1080             :         // taking a FontSize which is a bit smaller (compared to nLen) in order to have a buffer
    1081             :         // (hopefully enough for left and right, too)
    1082           0 :         aFont.SetSize(Size(0, nLen - (nLen / 3)));
    1083           0 :         SetFont(aFont);
    1084             :         // keep text color
    1085           0 :         SetTextColor( aTxtColor );
    1086             : 
    1087           0 :         int   nIV   = i - v;
    1088           0 :         sal_UCS4 cChar = aSymbol.GetCharacter();
    1089           0 :         OUString aText(&cChar, 1);
    1090           0 :         Size  aSize( GetTextWidth( aText ), GetTextHeight());
    1091             : 
    1092           0 :         Point aPoint((nIV % nColumns) * nLen + (nLen - aSize.Width()) / 2,
    1093           0 :                        (nIV / nColumns) * nLen + (nLen - aSize.Height()) / 2);
    1094             : 
    1095           0 :         DrawText(OffsetPoint(aPoint), aText);
    1096           0 :     }
    1097             : 
    1098           0 :     if (nSelectSymbol != SYMBOL_NONE)
    1099             :     {
    1100           0 :         Point aPoint(((nSelectSymbol - v) % nColumns) * nLen,
    1101           0 :                                  ((nSelectSymbol - v) / nColumns) * nLen);
    1102             : 
    1103           0 :         Invert(Rectangle(OffsetPoint(aPoint), Size(nLen, nLen)));
    1104             : 
    1105             :     }
    1106             : 
    1107           0 :     Pop();
    1108           0 : }
    1109             : 
    1110             : 
    1111           0 : void SmShowSymbolSetWindow::MouseButtonDown(const MouseEvent& rMEvt)
    1112             : {
    1113           0 :     GrabFocus();
    1114             : 
    1115           0 :     Size aOutputSize(nColumns * nLen, nRows * nLen);
    1116           0 :     Point aPoint(rMEvt.GetPosPixel());
    1117           0 :     aPoint.X() -= nXOffset;
    1118           0 :     aPoint.Y() -= nYOffset;
    1119             : 
    1120           0 :     if (rMEvt.IsLeft() && Rectangle(Point(0, 0), aOutputSize).IsInside(rMEvt.GetPosPixel()))
    1121             :     {
    1122           0 :         long nPos = (aPoint.Y() / nLen) * nColumns + (aPoint.X() / nLen) +
    1123           0 :                       m_pVScrollBar->GetThumbPos() * nColumns;
    1124           0 :         SelectSymbol( sal::static_int_cast< sal_uInt16 >(nPos) );
    1125             : 
    1126           0 :         aSelectHdlLink.Call(this);
    1127             : 
    1128           0 :         if (rMEvt.GetClicks() > 1)
    1129           0 :             aDblClickHdlLink.Call(this);
    1130             :     }
    1131           0 : }
    1132             : 
    1133             : 
    1134           0 : void SmShowSymbolSetWindow::KeyInput(const KeyEvent& rKEvt)
    1135             : {
    1136           0 :     sal_uInt16 n = nSelectSymbol;
    1137             : 
    1138           0 :     if (n != SYMBOL_NONE)
    1139             :     {
    1140           0 :         switch (rKEvt.GetKeyCode().GetCode())
    1141             :         {
    1142           0 :             case KEY_DOWN:      n = n + nColumns;   break;
    1143           0 :             case KEY_UP:        n = n - nColumns;   break;
    1144           0 :             case KEY_LEFT:      n -= 1; break;
    1145           0 :             case KEY_RIGHT:     n += 1; break;
    1146           0 :             case KEY_HOME:      n  = 0; break;
    1147           0 :             case KEY_END:       n  = static_cast< sal_uInt16 >(aSymbolSet.size() - 1);   break;
    1148           0 :             case KEY_PAGEUP:    n -= nColumns * nRows;  break;
    1149           0 :             case KEY_PAGEDOWN:  n += nColumns * nRows;  break;
    1150             : 
    1151             :             default:
    1152           0 :                 Control::KeyInput(rKEvt);
    1153           0 :                 return;
    1154             :         }
    1155             :     }
    1156             :     else
    1157           0 :         n = 0;
    1158             : 
    1159           0 :     if (n >= aSymbolSet.size())
    1160           0 :         n = nSelectSymbol;
    1161             : 
    1162             :     // adjust scrollbar
    1163           0 :     if ((n < (sal_uInt16) (m_pVScrollBar->GetThumbPos() * nColumns)) ||
    1164           0 :         (n >= (sal_uInt16) ((m_pVScrollBar->GetThumbPos() + nRows) * nColumns)))
    1165             :     {
    1166           0 :         m_pVScrollBar->SetThumbPos(n / nColumns);
    1167           0 :         Invalidate();
    1168           0 :         Update();
    1169             :     }
    1170             : 
    1171           0 :     SelectSymbol(n);
    1172           0 :     aSelectHdlLink.Call(this);
    1173             : }
    1174             : 
    1175           0 : void SmShowSymbolSetWindow::setScrollbar(ScrollBar *pVScrollBar)
    1176             : {
    1177           0 :     m_pVScrollBar = pVScrollBar;
    1178           0 :     m_pVScrollBar->Enable(false);
    1179           0 :     m_pVScrollBar->Show();
    1180           0 :     m_pVScrollBar->SetScrollHdl(LINK(this, SmShowSymbolSetWindow, ScrollHdl));
    1181           0 : }
    1182             : 
    1183           0 : SmShowSymbolSet::SmShowSymbolSet(vcl::Window *pParent)
    1184             :     : VclHBox(pParent, false, 6)
    1185             :     , aSymbolWindow(this, WB_TABSTOP)
    1186           0 :     , aVScrollBar(this, WinBits(WB_VSCROLL))
    1187             : {
    1188           0 :     aSymbolWindow.set_hexpand(true);
    1189           0 :     aSymbolWindow.set_vexpand(true);
    1190           0 :     aSymbolWindow.setScrollbar(&aVScrollBar);
    1191           0 :     aSymbolWindow.calccols();
    1192           0 :     aSymbolWindow.Show();
    1193           0 : }
    1194             : 
    1195           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSmShowSymbolSet(vcl::Window *pParent, VclBuilder::stringmap &)
    1196             : {
    1197           0 :     return new SmShowSymbolSet(pParent);
    1198             : }
    1199             : 
    1200           0 : void SmShowSymbolSetWindow::calccols()
    1201             : {
    1202             :     // Height of 16pt in pixels (matching 'aOutputSize')
    1203           0 :     nLen = LogicToPixel(Size(0, 16), MapMode(MAP_POINT)).Height();
    1204             : 
    1205           0 :     Size aOutputSize = GetOutputSizePixel();
    1206             : 
    1207           0 :     nColumns = aOutputSize.Width() / nLen;
    1208           0 :     if (nColumns > 2  && nColumns % 2 != 0)
    1209           0 :         --nColumns;
    1210           0 :     nRows = aOutputSize.Height() / nLen;
    1211           0 :     nColumns = std::max<long>(1, nColumns);
    1212           0 :     nRows = std::max<long>(1, nRows);
    1213             : 
    1214           0 :     nXOffset = (aOutputSize.Width() - (nColumns * nLen)) / 2;
    1215           0 :     nYOffset = (aOutputSize.Height() - (nRows * nLen)) / 2;
    1216             : 
    1217           0 :     SetScrollBarRange();
    1218           0 : }
    1219             : 
    1220           0 : Size SmShowSymbolSetWindow::GetOptimalSize() const
    1221             : {
    1222           0 :     vcl::Window *pParent = GetParent();
    1223           0 :     return Size(pParent->approximate_char_width() * 24, pParent->GetTextHeight() * 8);
    1224             : }
    1225             : 
    1226           0 : void SmShowSymbolSetWindow::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet)
    1227             : {
    1228           0 :     aSymbolSet = rSymbolSet;
    1229             : 
    1230           0 :     SetScrollBarRange();
    1231           0 : }
    1232             : 
    1233           0 : void SmShowSymbolSetWindow::SetScrollBarRange()
    1234             : {
    1235           0 :     if (aSymbolSet.size() > static_cast<size_t>(nColumns * nRows))
    1236             :     {
    1237           0 :         m_pVScrollBar->SetRange(Range(0, ((aSymbolSet.size() + (nColumns - 1)) / nColumns) - nRows));
    1238           0 :         m_pVScrollBar->Enable(true);
    1239             :     }
    1240             :     else
    1241             :     {
    1242           0 :         m_pVScrollBar->SetRange(Range(0,0));
    1243           0 :         m_pVScrollBar->Enable (false);
    1244             :     }
    1245             : 
    1246           0 :     Invalidate();
    1247           0 : }
    1248             : 
    1249           0 : void SmShowSymbolSetWindow::SelectSymbol(sal_uInt16 nSymbol)
    1250             : {
    1251           0 :     int v = (int) (m_pVScrollBar->GetThumbPos() * nColumns);
    1252             : 
    1253           0 :     if (nSelectSymbol != SYMBOL_NONE)
    1254           0 :         Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
    1255           0 :                                    ((nSelectSymbol - v) / nColumns) * nLen)),
    1256           0 :                              Size(nLen, nLen)));
    1257             : 
    1258           0 :     if (nSymbol < aSymbolSet.size())
    1259           0 :         nSelectSymbol = nSymbol;
    1260             : 
    1261           0 :     if (aSymbolSet.empty())
    1262           0 :         nSelectSymbol = SYMBOL_NONE;
    1263             : 
    1264           0 :     if (nSelectSymbol != SYMBOL_NONE)
    1265           0 :         Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
    1266           0 :                                    ((nSelectSymbol - v) / nColumns) * nLen)),
    1267           0 :                              Size(nLen, nLen)));
    1268             : 
    1269           0 :     Update();
    1270           0 : }
    1271             : 
    1272           0 : void SmShowSymbolSetWindow::Resize()
    1273             : {
    1274           0 :     Control::Resize();
    1275           0 :     calccols();
    1276           0 : }
    1277             : 
    1278           0 : IMPL_LINK( SmShowSymbolSetWindow, ScrollHdl, ScrollBar*, EMPTYARG /*pScrollBar*/)
    1279             : {
    1280           0 :     Invalidate();
    1281           0 :     return 0;
    1282             : }
    1283             : 
    1284           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSmShowSymbol(vcl::Window *pParent, VclBuilder::stringmap &rMap)
    1285             : {
    1286           0 :     WinBits nWinStyle = 0;
    1287             : 
    1288           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1289           0 :     if (!sBorder.isEmpty())
    1290           0 :         nWinStyle |= WB_BORDER;
    1291             : 
    1292           0 :     return new SmShowSymbol(pParent, nWinStyle);
    1293             : }
    1294             : 
    1295           0 : void SmShowSymbol::Resize()
    1296             : {
    1297           0 :     Control::Resize();
    1298           0 :     Invalidate();
    1299           0 : }
    1300             : 
    1301           0 : void SmShowSymbol::setFontSize(vcl::Font &rFont) const
    1302             : {
    1303           0 :     rFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
    1304           0 : }
    1305             : 
    1306           0 : void SmShowSymbol::Paint(const Rectangle &rRect)
    1307             : {
    1308           0 :     Control::Paint( rRect );
    1309             : 
    1310           0 :     vcl::Font aFont(GetFont());
    1311           0 :     setFontSize(aFont);
    1312           0 :     SetFont(aFont);
    1313             : 
    1314           0 :     const OUString &rText = GetText();
    1315           0 :     Size            aTextSize(GetTextWidth(rText), GetTextHeight());
    1316             : 
    1317           0 :     DrawText(Point((GetOutputSize().Width()  - aTextSize.Width())  / 2,
    1318           0 :                    (GetOutputSize().Height() * 7/10)), rText);
    1319           0 : }
    1320             : 
    1321             : 
    1322           0 : void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt)
    1323             : {
    1324           0 :     if (rMEvt.GetClicks() > 1)
    1325           0 :         aDblClickHdlLink.Call(this);
    1326             :     else
    1327           0 :         Control::MouseButtonDown (rMEvt);
    1328           0 : }
    1329             : 
    1330             : 
    1331           0 : void SmShowSymbol::SetSymbol(const SmSym *pSymbol)
    1332             : {
    1333           0 :     if (pSymbol)
    1334             :     {
    1335           0 :         vcl::Font aFont (pSymbol->GetFace());
    1336           0 :         setFontSize(aFont);
    1337           0 :         aFont.SetAlign(ALIGN_BASELINE);
    1338           0 :         SetFont(aFont);
    1339             : 
    1340           0 :         sal_UCS4 cChar = pSymbol->GetCharacter();
    1341           0 :         OUString aText(&cChar, 1);
    1342           0 :         SetText( aText );
    1343             :     }
    1344             : 
    1345             :     // 'Invalidate' fills the background with the background color.
    1346             :     // If a NULL pointer has been passed that's already enough to clear the display
    1347           0 :     Invalidate();
    1348           0 : }
    1349             : 
    1350             : 
    1351             : 
    1352             : 
    1353           0 : void SmSymbolDialog::FillSymbolSets(bool bDeleteText)
    1354             :     // populate the entries of possible SymbolsSets in the dialog with
    1355             :     // current values of the SymbolSet manager but selects none of those
    1356             : {
    1357           0 :     m_pSymbolSets->Clear();
    1358           0 :     if (bDeleteText)
    1359           0 :         m_pSymbolSets->SetNoSelection();
    1360             : 
    1361           0 :     std::set< OUString >  aSybolSetNames( rSymbolMgr.GetSymbolSetNames() );
    1362           0 :     std::set< OUString >::const_iterator aIt( aSybolSetNames.begin() );
    1363           0 :     for ( ; aIt != aSybolSetNames.end(); ++aIt)
    1364           0 :         m_pSymbolSets->InsertEntry( *aIt );
    1365           0 : }
    1366             : 
    1367             : 
    1368           0 : IMPL_LINK_NOARG( SmSymbolDialog, SymbolSetChangeHdl )
    1369             : {
    1370           0 :     SelectSymbolSet(m_pSymbolSets->GetSelectEntry());
    1371           0 :     return 0;
    1372             : }
    1373             : 
    1374             : 
    1375           0 : IMPL_LINK_NOARG( SmSymbolDialog, SymbolChangeHdl )
    1376             : {
    1377           0 :     SelectSymbol(m_pSymbolSetDisplay->GetSelectSymbol());
    1378           0 :     return 0;
    1379             : }
    1380             : 
    1381           0 : IMPL_LINK_NOARG(SmSymbolDialog, EditClickHdl)
    1382             : {
    1383           0 :     SmSymDefineDialog *pDialog = new SmSymDefineDialog(this, pFontListDev, rSymbolMgr);
    1384             : 
    1385             :     // set current symbol and SymbolSet for the new dialog
    1386           0 :     const OUString  aSymSetName (m_pSymbolSets->GetSelectEntry()),
    1387           0 :                     aSymName    (m_pSymbolName->GetText());
    1388           0 :     pDialog->SelectOldSymbolSet(aSymSetName);
    1389           0 :     pDialog->SelectOldSymbol(aSymName);
    1390           0 :     pDialog->SelectSymbolSet(aSymSetName);
    1391           0 :     pDialog->SelectSymbol(aSymName);
    1392             : 
    1393             :     // remember old SymbolSet
    1394           0 :     OUString  aOldSymbolSet (m_pSymbolSets->GetSelectEntry());
    1395             : 
    1396           0 :     sal_uInt16 nSymPos = GetSelectedSymbol();
    1397             : 
    1398             :     // adapt dialog to data of the SymbolSet manager, which might have changed
    1399           0 :     if (pDialog->Execute() == RET_OK  &&  rSymbolMgr.IsModified())
    1400             :     {
    1401           0 :         rSymbolMgr.Save();
    1402           0 :         FillSymbolSets();
    1403             :     }
    1404             : 
    1405             :     // if the old SymbolSet doesn't exist anymore, go to the first one SymbolSet (if one exists)
    1406           0 :     if (!SelectSymbolSet(aOldSymbolSet) && m_pSymbolSets->GetEntryCount() > 0)
    1407           0 :         SelectSymbolSet(m_pSymbolSets->GetEntry(0));
    1408             :     else
    1409             :     {
    1410             :         // just update display of current symbol set
    1411             :         assert(aSymSetName == aSymSetName); //unexpected change in symbol set name
    1412           0 :         aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName );
    1413           0 :         m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet );
    1414             :     }
    1415             : 
    1416           0 :     if (nSymPos >= aSymbolSet.size())
    1417           0 :         nSymPos = static_cast< sal_uInt16 >(aSymbolSet.size()) - 1;
    1418           0 :     SelectSymbol( nSymPos );
    1419             : 
    1420           0 :     delete pDialog;
    1421           0 :     return 0;
    1422             : }
    1423             : 
    1424             : 
    1425           0 : IMPL_LINK_NOARG( SmSymbolDialog, SymbolDblClickHdl )
    1426             : {
    1427           0 :     GetClickHdl(m_pGetBtn);
    1428           0 :     EndDialog(RET_OK);
    1429           0 :     return 0;
    1430             : }
    1431             : 
    1432             : 
    1433           0 : IMPL_LINK_NOARG( SmSymbolDialog, GetClickHdl )
    1434             : {
    1435           0 :     const SmSym *pSym = GetSymbol();
    1436           0 :     if (pSym)
    1437             :     {
    1438           0 :         OUStringBuffer aText;
    1439           0 :         aText.append('%').append(pSym->GetName()).append(' ');
    1440             : 
    1441             :         rViewSh.GetViewFrame()->GetDispatcher()->Execute(
    1442             :                 SID_INSERTSYMBOL, SfxCallMode::RECORD,
    1443           0 :                 new SfxStringItem(SID_INSERTSYMBOL, aText.makeStringAndClear()), 0L);
    1444             :     }
    1445             : 
    1446           0 :     return 0;
    1447             : }
    1448             : 
    1449             : 
    1450           0 : SmSymbolDialog::SmSymbolDialog(vcl::Window *pParent, OutputDevice *pFntListDevice,
    1451             :         SmSymbolManager &rMgr, SmViewShell &rViewShell)
    1452             :     : ModalDialog(pParent, "CatalogDialog",
    1453             :         "modules/smath/ui/catalogdialog.ui")
    1454             : 
    1455             :     ,
    1456             : 
    1457             :     rViewSh             (rViewShell),
    1458             :     rSymbolMgr          (rMgr),
    1459           0 :     pFontListDev        (pFntListDevice)
    1460             : {
    1461           0 :     get(m_pSymbolSets, "symbolset");
    1462           0 :     m_pSymbolSets->SetStyle(m_pSymbolSets->GetStyle()|WB_SORT);
    1463           0 :     get(m_pSymbolName, "symbolname");
    1464           0 :     get(m_pGetBtn, "insert");
    1465           0 :     get(m_pEditBtn, "edit");
    1466           0 :     get(m_pSymbolSetDisplay, "symbolsetdisplay");
    1467           0 :     get(m_pSymbolDisplay, "preview");
    1468             : 
    1469           0 :     aSymbolSetName = OUString();
    1470           0 :     aSymbolSet.clear();
    1471           0 :     FillSymbolSets();
    1472           0 :     if (m_pSymbolSets->GetEntryCount() > 0)
    1473           0 :         SelectSymbolSet(m_pSymbolSets->GetEntry(0));
    1474             : 
    1475           0 :     InitColor_Impl();
    1476             : 
    1477             :     // preview like controls should have a 2D look
    1478           0 :     m_pSymbolDisplay->SetBorderStyle( WindowBorderStyle::MONO );
    1479             : 
    1480           0 :     m_pSymbolSets->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolSetChangeHdl));
    1481           0 :     m_pSymbolSetDisplay->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolChangeHdl));
    1482           0 :     m_pSymbolSetDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
    1483           0 :     m_pSymbolDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
    1484           0 :     m_pEditBtn->SetClickHdl(LINK(this, SmSymbolDialog, EditClickHdl));
    1485           0 :     m_pGetBtn->SetClickHdl(LINK(this, SmSymbolDialog, GetClickHdl));
    1486           0 : }
    1487             : 
    1488             : 
    1489           0 : void SmSymbolDialog::InitColor_Impl()
    1490             : {
    1491             :     ColorData nBgCol, nTxtCol;
    1492           0 :     getColors(*this, nBgCol, nTxtCol);
    1493             : 
    1494           0 :     Color aTmpColor( nBgCol );
    1495           0 :     Wallpaper aWall( aTmpColor );
    1496           0 :     Color aTxtColor( nTxtCol );
    1497           0 :     m_pSymbolDisplay->SetBackground( aWall );
    1498           0 :     m_pSymbolDisplay->SetTextColor( aTxtColor );
    1499           0 :     m_pSymbolSetDisplay->SetBackground( aWall );
    1500           0 :     m_pSymbolSetDisplay->SetTextColor( aTxtColor );
    1501           0 : }
    1502             : 
    1503             : 
    1504           0 : void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt )
    1505             : {
    1506           0 :     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS  &&
    1507           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1508           0 :             InitColor_Impl();
    1509             : 
    1510           0 :     ModalDialog::DataChanged( rDCEvt );
    1511           0 : }
    1512             : 
    1513             : 
    1514           0 : bool SmSymbolDialog::SelectSymbolSet(const OUString &rSymbolSetName)
    1515             : {
    1516           0 :     bool    bRet = false;
    1517           0 :     sal_Int32  nPos = m_pSymbolSets->GetEntryPos(rSymbolSetName);
    1518             : 
    1519           0 :     aSymbolSetName = OUString();
    1520           0 :     aSymbolSet.clear();
    1521           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
    1522             :     {
    1523           0 :         m_pSymbolSets->SelectEntryPos(nPos);
    1524             : 
    1525           0 :         aSymbolSetName  = rSymbolSetName;
    1526           0 :         aSymbolSet      = rSymbolMgr.GetSymbolSet( aSymbolSetName );
    1527             : 
    1528             :         // sort symbols by Unicode position (useful for displaying Greek characters alphabetically)
    1529           0 :         std::sort( aSymbolSet.begin(), aSymbolSet.end(), lt_SmSymPtr() );
    1530             : 
    1531           0 :         m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet );
    1532           0 :         if (aSymbolSet.size() > 0)
    1533           0 :             SelectSymbol(0);
    1534             : 
    1535           0 :         bRet = true;
    1536             :     }
    1537             :     else
    1538           0 :         m_pSymbolSets->SetNoSelection();
    1539             : 
    1540           0 :     return bRet;
    1541             : }
    1542             : 
    1543             : 
    1544           0 : void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo)
    1545             : {
    1546           0 :     const SmSym *pSym = NULL;
    1547           0 :     if (!aSymbolSetName.isEmpty()  &&  nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size()))
    1548           0 :         pSym = aSymbolSet[ nSymbolNo ];
    1549             : 
    1550           0 :     m_pSymbolSetDisplay->SelectSymbol(nSymbolNo);
    1551           0 :     m_pSymbolDisplay->SetSymbol(pSym);
    1552           0 :     m_pSymbolName->SetText(pSym ? pSym->GetName() : OUString());
    1553           0 : }
    1554             : 
    1555             : 
    1556           0 : const SmSym * SmSymbolDialog::GetSymbol() const
    1557             : {
    1558           0 :     sal_uInt16 nSymbolNo = m_pSymbolSetDisplay->GetSelectSymbol();
    1559           0 :     bool bValid = !aSymbolSetName.isEmpty()  &&  nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size());
    1560           0 :     return bValid ? aSymbolSet[ nSymbolNo ] : NULL;
    1561             : }
    1562             : 
    1563             : 
    1564             : 
    1565           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSmShowChar(vcl::Window *pParent, VclBuilder::stringmap &rMap)
    1566             : {
    1567           0 :     WinBits nWinStyle = 0;
    1568             : 
    1569           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
    1570           0 :     if (!sBorder.isEmpty())
    1571           0 :         nWinStyle |= WB_BORDER;
    1572             : 
    1573           0 :     return new SmShowChar(pParent, nWinStyle);
    1574             : }
    1575             : 
    1576           0 : void SmShowChar::Paint(const Rectangle &rRect)
    1577             : {
    1578           0 :     Control::Paint( rRect );
    1579             : 
    1580           0 :     OUString aText( GetText() );
    1581           0 :     if (!aText.isEmpty())
    1582             :     {
    1583             : #if OSL_DEBUG_LEVEL > 1
    1584             :         sal_Int32 nPos = 0;
    1585             :         sal_UCS4 cChar = aText.iterateCodePoints( &nPos );
    1586             :         (void) cChar;
    1587             : #endif
    1588           0 :         Size aTextSize(GetTextWidth(aText), GetTextHeight());
    1589             : 
    1590           0 :         DrawText(Point((GetOutputSize().Width()  - aTextSize.Width())  / 2,
    1591           0 :                        (GetOutputSize().Height() * 7/10)), aText);
    1592           0 :     }
    1593           0 : }
    1594             : 
    1595             : 
    1596           0 : void SmShowChar::SetSymbol( const SmSym *pSym )
    1597             : {
    1598           0 :     if (pSym)
    1599           0 :         SetSymbol( pSym->GetCharacter(), pSym->GetFace() );
    1600           0 : }
    1601             : 
    1602             : 
    1603           0 : void SmShowChar::SetSymbol( sal_UCS4 cChar, const vcl::Font &rFont )
    1604             : {
    1605           0 :     vcl::Font aFont( rFont );
    1606           0 :     aFont.SetSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3) );
    1607           0 :     aFont.SetAlign(ALIGN_BASELINE);
    1608           0 :     SetFont(aFont);
    1609           0 :     aFont.SetTransparent(true);
    1610             : 
    1611           0 :     OUString aText(&cChar, 1);
    1612           0 :     SetText( aText );
    1613             : 
    1614           0 :     Invalidate();
    1615           0 : }
    1616             : 
    1617           0 : void SmShowChar::Resize()
    1618             : {
    1619           0 :     Control::Resize();
    1620           0 :     const OUString &rText = GetText();
    1621           0 :     if (rText.isEmpty())
    1622           0 :         return;
    1623           0 :     sal_Int32 nStrIndex = 0;
    1624           0 :     sal_UCS4 cChar = rText.iterateCodePoints(&nStrIndex);
    1625           0 :     SetSymbol(cChar, GetFont()); //force recalculation of size
    1626             : }
    1627             : 
    1628           0 : void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, bool bDeleteText)
    1629             : {
    1630             : #if OSL_DEBUG_LEVEL > 1
    1631             :     OSL_ENSURE(&rComboBox == pOldSymbols  ||  &rComboBox == pSymbols,
    1632             :         "Sm : wrong ComboBox");
    1633             : #endif
    1634             : 
    1635           0 :     rComboBox.Clear();
    1636           0 :     if (bDeleteText)
    1637           0 :         rComboBox.SetText(OUString());
    1638             : 
    1639           0 :     ComboBox &rBox = &rComboBox == pOldSymbols ? *pOldSymbolSets : *pSymbolSets;
    1640           0 :     SymbolPtrVec_t aSymSet( aSymbolMgrCopy.GetSymbolSet( rBox.GetText() ) );
    1641           0 :     for (size_t i = 0;  i < aSymSet.size();  ++i)
    1642           0 :         rComboBox.InsertEntry( aSymSet[i]->GetName() );
    1643           0 : }
    1644             : 
    1645             : 
    1646           0 : void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, bool bDeleteText)
    1647             : {
    1648             : #if OSL_DEBUG_LEVEL > 1
    1649             :     OSL_ENSURE(&rComboBox == pOldSymbolSets  ||  &rComboBox == pSymbolSets,
    1650             :         "Sm : falsche ComboBox");
    1651             : #endif
    1652             : 
    1653           0 :     rComboBox.Clear();
    1654           0 :     if (bDeleteText)
    1655           0 :         rComboBox.SetText(OUString());
    1656             : 
    1657           0 :     const std::set< OUString >  aSymbolSetNames( aSymbolMgrCopy.GetSymbolSetNames() );
    1658           0 :     std::set< OUString >::const_iterator aIt( aSymbolSetNames.begin() );
    1659           0 :     for ( ;  aIt != aSymbolSetNames.end();  ++aIt)
    1660           0 :         rComboBox.InsertEntry( *aIt );
    1661           0 : }
    1662             : 
    1663             : 
    1664           0 : void SmSymDefineDialog::FillFonts(bool bDelete)
    1665             : {
    1666           0 :     pFonts->Clear();
    1667           0 :     if (bDelete)
    1668           0 :         pFonts->SetNoSelection();
    1669             : 
    1670             :     // Include all fonts of FontList into the font list.
    1671             :     // If there are duplicates, only include one entry of each font since the style will be
    1672             :     // already selected using the FontStyleBox.
    1673           0 :     if (pFontList)
    1674             :     {
    1675           0 :         sal_uInt16  nCount = pFontList->GetFontNameCount();
    1676           0 :         for (sal_uInt16 i = 0;  i < nCount;  i++)
    1677           0 :             pFonts->InsertEntry( pFontList->GetFontName(i).GetName() );
    1678             :     }
    1679           0 : }
    1680             : 
    1681             : 
    1682           0 : void SmSymDefineDialog::FillStyles(bool bDeleteText)
    1683             : {
    1684           0 :     pStyles->Clear();
    1685           0 :     if (bDeleteText)
    1686           0 :         pStyles->SetText(OUString());
    1687             : 
    1688           0 :     OUString aText (pFonts->GetSelectEntry());
    1689           0 :     if (!aText.isEmpty())
    1690             :     {
    1691             :         // use own StyleNames
    1692           0 :         const SmFontStyles &rStyles = GetFontStyles();
    1693           0 :         for (sal_uInt16 i = 0;  i < rStyles.GetCount();  i++)
    1694           0 :             pStyles->InsertEntry( rStyles.GetStyleName(i) );
    1695             : 
    1696             : #if OSL_DEBUG_LEVEL > 1
    1697             :         OSL_ENSURE(pStyles->GetEntryCount() > 0, "Sm : no styles available");
    1698             : #endif
    1699           0 :         pStyles->SetText( pStyles->GetEntry(0) );
    1700           0 :     }
    1701           0 : }
    1702             : 
    1703             : 
    1704           0 : SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox)
    1705             : {
    1706             : #if OSL_DEBUG_LEVEL > 1
    1707             :     OSL_ENSURE(&rComboBox == pOldSymbols  ||  &rComboBox == pSymbols,
    1708             :         "Sm : wrong combobox");
    1709             : #endif
    1710           0 :     return aSymbolMgrCopy.GetSymbolByName(rComboBox.GetText());
    1711             : }
    1712             : 
    1713             : 
    1714           0 : IMPL_LINK( SmSymDefineDialog, OldSymbolChangeHdl, ComboBox *, EMPTYARG pComboBox )
    1715             : {
    1716             :     (void) pComboBox;
    1717             : #if OSL_DEBUG_LEVEL > 1
    1718             :     OSL_ENSURE(pComboBox == pOldSymbols, "Sm : wrong argument");
    1719             : #endif
    1720           0 :     SelectSymbol(*pOldSymbols, pOldSymbols->GetText(), false);
    1721           0 :     return 0;
    1722             : }
    1723             : 
    1724             : 
    1725           0 : IMPL_LINK( SmSymDefineDialog, OldSymbolSetChangeHdl, ComboBox *, EMPTYARG pComboBox )
    1726             : {
    1727             :     (void) pComboBox;
    1728             : #if OSL_DEBUG_LEVEL > 1
    1729             :     OSL_ENSURE(pComboBox == pOldSymbolSets, "Sm : wrong argument");
    1730             : #endif
    1731           0 :     SelectSymbolSet(*pOldSymbolSets, pOldSymbolSets->GetText(), false);
    1732           0 :     return 0;
    1733             : }
    1734             : 
    1735             : 
    1736           0 : IMPL_LINK( SmSymDefineDialog, ModifyHdl, ComboBox *, pComboBox )
    1737             : {
    1738             :     // remember cursor position for later restoring of it
    1739           0 :     Selection  aSelection (pComboBox->GetSelection());
    1740             : 
    1741           0 :     if (pComboBox == pSymbols)
    1742           0 :         SelectSymbol(*pSymbols, pSymbols->GetText(), false);
    1743           0 :     else if (pComboBox == pSymbolSets)
    1744           0 :         SelectSymbolSet(*pSymbolSets, pSymbolSets->GetText(), false);
    1745           0 :     else if (pComboBox == pOldSymbols)
    1746             :         // allow only names from the list
    1747           0 :         SelectSymbol(*pOldSymbols, pOldSymbols->GetText(), true);
    1748           0 :     else if (pComboBox == pOldSymbolSets)
    1749             :         // allow only names from the list
    1750           0 :         SelectSymbolSet(*pOldSymbolSets, pOldSymbolSets->GetText(), true);
    1751           0 :     else if (pComboBox == pStyles)
    1752             :         // allow only names from the list (that's the case here anyway)
    1753           0 :         SelectStyle(pStyles->GetText(), true);
    1754             :     else
    1755             :         SAL_WARN("starmath", "wrong combobox argument");
    1756             : 
    1757           0 :     pComboBox->SetSelection(aSelection);
    1758             : 
    1759           0 :     UpdateButtons();
    1760             : 
    1761           0 :     return 0;
    1762             : }
    1763             : 
    1764             : 
    1765           0 : IMPL_LINK( SmSymDefineDialog, FontChangeHdl, ListBox *, EMPTYARG pListBox )
    1766             : {
    1767             :     (void) pListBox;
    1768             : #if OSL_DEBUG_LEVEL > 1
    1769             :     OSL_ENSURE(pListBox == pFonts, "Sm : wrong argument");
    1770             : #endif
    1771             : 
    1772           0 :     SelectFont(pFonts->GetSelectEntry());
    1773           0 :     return 0;
    1774             : }
    1775             : 
    1776             : 
    1777           0 : IMPL_LINK( SmSymDefineDialog, SubsetChangeHdl, ListBox *, EMPTYARG pListBox )
    1778             : {
    1779             :     (void) pListBox;
    1780           0 :     sal_Int32 nPos = pFontsSubsetLB->GetSelectEntryPos();
    1781           0 :     if (LISTBOX_ENTRY_NOTFOUND != nPos)
    1782             :     {
    1783           0 :         const Subset* pSubset = reinterpret_cast<const Subset*> (pFontsSubsetLB->GetEntryData( nPos ));
    1784           0 :         if (pSubset)
    1785             :         {
    1786           0 :             pCharsetDisplay->SelectCharacter( pSubset->GetRangeMin() );
    1787             :         }
    1788             :     }
    1789           0 :     return 0;
    1790             : }
    1791             : 
    1792             : 
    1793           0 : IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox )
    1794             : {
    1795             :     (void) pComboBox;
    1796             : #if OSL_DEBUG_LEVEL > 1
    1797             :     OSL_ENSURE(pComboBox == pStyles, "Sm : falsches Argument");
    1798             : #endif
    1799             : 
    1800           0 :     SelectStyle(pStyles->GetText());
    1801           0 :     return 0;
    1802             : }
    1803             : 
    1804             : 
    1805           0 : IMPL_LINK_NOARG(SmSymDefineDialog, CharHighlightHdl)
    1806             : {
    1807           0 :    sal_UCS4 cChar = pCharsetDisplay->GetSelectCharacter();
    1808             : 
    1809             : #if OSL_DEBUG_LEVEL > 1
    1810             :     OSL_ENSURE( pSubsetMap, "SubsetMap missing" );
    1811             : #endif
    1812           0 :     if (pSubsetMap)
    1813             :     {
    1814           0 :         const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
    1815           0 :         if (pSubset)
    1816           0 :             pFontsSubsetLB->SelectEntry( pSubset->GetName() );
    1817             :         else
    1818           0 :             pFontsSubsetLB->SetNoSelection();
    1819             :     }
    1820             : 
    1821           0 :     pSymbolDisplay->SetSymbol( cChar, pCharsetDisplay->GetFont() );
    1822             : 
    1823           0 :     UpdateButtons();
    1824             : 
    1825             :     // display Unicode position as symbol name while iterating over characters
    1826           0 :     const OUString aHex(OUString::number(cChar, 16 ).toAsciiUpperCase());
    1827           0 :     const OUString aPattern( (aHex.getLength() > 4) ? OUString("Ux000000") : OUString("Ux0000") );
    1828           0 :     OUString aUnicodePos( aPattern.copy( 0, aPattern.getLength() - aHex.getLength() ) );
    1829           0 :     aUnicodePos += aHex;
    1830           0 :     pSymbols->SetText( aUnicodePos );
    1831           0 :     pSymbolName->SetText( aUnicodePos );
    1832             : 
    1833           0 :     return 0;
    1834             : }
    1835             : 
    1836             : 
    1837           0 : IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton )
    1838             : {
    1839             :     (void) pButton;
    1840             : #if OSL_DEBUG_LEVEL > 1
    1841             :     OSL_ENSURE(pButton == pAddBtn, "Sm : wrong argument");
    1842             :     OSL_ENSURE(pAddBtn->IsEnabled(), "Sm : requirements met ??");
    1843             : #endif
    1844             : 
    1845             :     // add symbol
    1846           0 :     const SmSym aNewSymbol( pSymbols->GetText(), pCharsetDisplay->GetFont(),
    1847           0 :             pCharsetDisplay->GetSelectCharacter(), pSymbolSets->GetText() );
    1848             :     //OSL_ENSURE( aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL, "symbol already exists" );
    1849           0 :     aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol );
    1850             : 
    1851             :     // update display of new symbol
    1852           0 :     pSymbolDisplay->SetSymbol( &aNewSymbol );
    1853           0 :     pSymbolName->SetText( aNewSymbol.GetName() );
    1854           0 :     pSymbolSetName->SetText( aNewSymbol.GetSymbolSetName() );
    1855             : 
    1856             :     // update list box entries
    1857           0 :     FillSymbolSets(*pOldSymbolSets, false);
    1858           0 :     FillSymbolSets(*pSymbolSets,    false);
    1859           0 :     FillSymbols(*pOldSymbols ,false);
    1860           0 :     FillSymbols(*pSymbols    ,false);
    1861             : 
    1862           0 :     UpdateButtons();
    1863             : 
    1864           0 :     return 0;
    1865             : }
    1866             : 
    1867             : 
    1868           0 : IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
    1869             : {
    1870             :     (void) pButton;
    1871             : #if OSL_DEBUG_LEVEL > 1
    1872             :     OSL_ENSURE(pButton == pChangeBtn, "Sm : wrong argument");
    1873             :     OSL_ENSURE(pChangeBtn->IsEnabled(), "Sm : requirements met ??");
    1874             : #endif
    1875             : 
    1876             :     // get new Sybol to use
    1877             :     //! get font from symbol-disp lay since charset-display does not keep
    1878             :     //! the bold attribute.
    1879           0 :     const SmSym aNewSymbol( pSymbols->GetText(), pCharsetDisplay->GetFont(),
    1880           0 :             pCharsetDisplay->GetSelectCharacter(), pSymbolSets->GetText() );
    1881             : 
    1882             :     // remove old symbol if the name was changed then add new one
    1883           0 :     const bool bNameChanged       = pOldSymbols->GetText() != pSymbols->GetText();
    1884           0 :     if (bNameChanged)
    1885           0 :         aSymbolMgrCopy.RemoveSymbol( pOldSymbols->GetText() );
    1886           0 :     aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol, true );
    1887             : 
    1888             :     // clear display for original symbol if necessary
    1889           0 :     if (bNameChanged)
    1890           0 :         SetOrigSymbol(NULL, OUString());
    1891             : 
    1892             :     // update display of new symbol
    1893           0 :     pSymbolDisplay->SetSymbol( &aNewSymbol );
    1894           0 :     pSymbolName->SetText( aNewSymbol.GetName() );
    1895           0 :     pSymbolSetName->SetText( aNewSymbol.GetSymbolSetName() );
    1896             : 
    1897             :     // update list box entries
    1898           0 :     FillSymbolSets(*pOldSymbolSets, false);
    1899           0 :     FillSymbolSets(*pSymbolSets,    false);
    1900           0 :     FillSymbols(*pOldSymbols ,false);
    1901           0 :     FillSymbols(*pSymbols    ,false);
    1902             : 
    1903           0 :     UpdateButtons();
    1904             : 
    1905           0 :     return 0;
    1906             : }
    1907             : 
    1908             : 
    1909           0 : IMPL_LINK( SmSymDefineDialog, DeleteClickHdl, Button *, EMPTYARG pButton )
    1910             : {
    1911             :     (void) pButton;
    1912             : #if OSL_DEBUG_LEVEL > 1
    1913             :     OSL_ENSURE(pButton == pDeleteBtn, "Sm : wrong argument");
    1914             :     OSL_ENSURE(pDeleteBtn->IsEnabled(), "Sm : requirements met ??");
    1915             : #endif
    1916             : 
    1917           0 :     if (pOrigSymbol)
    1918             :     {
    1919           0 :         aSymbolMgrCopy.RemoveSymbol( pOrigSymbol->GetName() );
    1920             : 
    1921             :         // clear display for original symbol
    1922           0 :         SetOrigSymbol(NULL, OUString());
    1923             : 
    1924             :         // update list box entries
    1925           0 :         FillSymbolSets(*pOldSymbolSets, false);
    1926           0 :         FillSymbolSets(*pSymbolSets,    false);
    1927           0 :         FillSymbols(*pOldSymbols ,false);
    1928           0 :         FillSymbols(*pSymbols    ,false);
    1929             :     }
    1930             : 
    1931           0 :     UpdateButtons();
    1932             : 
    1933           0 :     return 0;
    1934             : }
    1935             : 
    1936             : 
    1937           0 : void SmSymDefineDialog::UpdateButtons()
    1938             : {
    1939           0 :     bool  bAdd    = false,
    1940           0 :           bChange = false,
    1941           0 :           bDelete = false;
    1942           0 :     OUString aTmpSymbolName    (pSymbols->GetText()),
    1943           0 :               aTmpSymbolSetName (pSymbolSets->GetText());
    1944             : 
    1945           0 :     if (aTmpSymbolName.getLength() > 0  &&  aTmpSymbolSetName.getLength() > 0)
    1946             :     {
    1947             :         // are all settings equal?
    1948             :         //! (Font-, Style- und SymbolSet name comparison is not case sensitive)
    1949             :         bool bEqual = pOrigSymbol
    1950           0 :                     && aTmpSymbolSetName.equalsIgnoreAsciiCase(pOldSymbolSetName->GetText())
    1951           0 :                     && aTmpSymbolName.equals(pOrigSymbol->GetName())
    1952           0 :                     && pFonts->GetSelectEntry().equalsIgnoreAsciiCase(
    1953           0 :                             pOrigSymbol->GetFace().GetName())
    1954           0 :                     && pStyles->GetText().equalsIgnoreAsciiCase(
    1955           0 :                             GetFontStyles().GetStyleName(pOrigSymbol->GetFace()))
    1956           0 :                     && pCharsetDisplay->GetSelectCharacter() == pOrigSymbol->GetCharacter();
    1957             : 
    1958             :         // only add it if there isn't already a symbol with the same name
    1959           0 :         bAdd    = aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL;
    1960             : 
    1961             :         // only delete it if all settings are equal
    1962           0 :         bDelete = pOrigSymbol != NULL;
    1963             : 
    1964             :         // only change it if the old symbol exists and the new one is different
    1965           0 :         bChange = pOrigSymbol && !bEqual;
    1966             :     }
    1967             : 
    1968           0 :     pAddBtn   ->Enable(bAdd);
    1969           0 :     pChangeBtn->Enable(bChange);
    1970           0 :     pDeleteBtn->Enable(bDelete);
    1971           0 : }
    1972             : 
    1973           0 : SmSymDefineDialog::SmSymDefineDialog(vcl::Window * pParent,
    1974             :         OutputDevice *pFntListDevice, SmSymbolManager &rMgr) :
    1975             :     ModalDialog         (pParent, "EditSymbols", "modules/smath/ui/symdefinedialog.ui"),
    1976             :     rSymbolMgr          (rMgr),
    1977             :     pSubsetMap          (NULL),
    1978           0 :     pFontList           (NULL)
    1979             : {
    1980           0 :     get(pOldSymbols, "oldSymbols");
    1981           0 :     get(pOldSymbolSets, "oldSymbolSets");
    1982           0 :     get(pCharsetDisplay, "charsetDisplay");
    1983           0 :     get(pSymbols, "symbols");
    1984           0 :     get(pSymbolSets, "symbolSets");
    1985           0 :     get(pFonts, "fonts");
    1986           0 :     get(pFontsSubsetLB, "fontsSubsetLB");
    1987           0 :     get(pStyles, "styles");
    1988           0 :     get(pOldSymbolName, "oldSymbolName");
    1989           0 :     get(pOldSymbolDisplay, "oldSymbolDisplay");
    1990           0 :     get(pOldSymbolSetName, "oldSymbolSetName");
    1991           0 :     get(pSymbolName, "symbolName");
    1992           0 :     get(pSymbolDisplay, "symbolDisplay");
    1993           0 :     get(pSymbolSetName, "symbolSetName");
    1994           0 :     get(pAddBtn, "add");
    1995           0 :     get(pChangeBtn, "modify");
    1996           0 :     get(pDeleteBtn, "delete");
    1997             : 
    1998           0 :     pFontList = new FontList( pFntListDevice );
    1999             : 
    2000           0 :     pOrigSymbol = 0;
    2001             : 
    2002             :     // auto completion is troublesome since that symbols character also gets automatically selected in the
    2003             :     // display and if the user previously selected a character to define/redefine that one this is bad
    2004           0 :    pOldSymbols->EnableAutocomplete( false, true );
    2005           0 :    pSymbols->EnableAutocomplete( false, true );
    2006             : 
    2007           0 :     FillFonts();
    2008           0 :     if (pFonts->GetEntryCount() > 0)
    2009           0 :         SelectFont(pFonts->GetEntry(0));
    2010             : 
    2011           0 :     InitColor_Impl();
    2012             : 
    2013           0 :     SetSymbolSetManager(rSymbolMgr);
    2014             : 
    2015           0 :     pOldSymbols     ->SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolChangeHdl));
    2016           0 :     pOldSymbolSets  ->SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolSetChangeHdl));
    2017           0 :     pSymbolSets     ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
    2018           0 :     pOldSymbolSets  ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
    2019           0 :     pSymbols        ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
    2020           0 :     pOldSymbols     ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
    2021           0 :     pStyles         ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
    2022           0 :     pFonts          ->SetSelectHdl(LINK(this, SmSymDefineDialog, FontChangeHdl));
    2023           0 :     pFontsSubsetLB  ->SetSelectHdl(LINK(this, SmSymDefineDialog, SubsetChangeHdl));
    2024           0 :     pStyles         ->SetSelectHdl(LINK(this, SmSymDefineDialog, StyleChangeHdl));
    2025           0 :     pAddBtn         ->SetClickHdl (LINK(this, SmSymDefineDialog, AddClickHdl));
    2026           0 :     pChangeBtn      ->SetClickHdl (LINK(this, SmSymDefineDialog, ChangeClickHdl));
    2027           0 :     pDeleteBtn      ->SetClickHdl (LINK(this, SmSymDefineDialog, DeleteClickHdl));
    2028           0 :     pCharsetDisplay ->SetHighlightHdl( LINK( this, SmSymDefineDialog, CharHighlightHdl ) );
    2029             : 
    2030             :     // preview like controls should have a 2D look
    2031           0 :     pOldSymbolDisplay->SetBorderStyle( WindowBorderStyle::MONO );
    2032           0 :     pSymbolDisplay   ->SetBorderStyle( WindowBorderStyle::MONO );
    2033           0 : }
    2034             : 
    2035             : 
    2036           0 : SmSymDefineDialog::~SmSymDefineDialog()
    2037             : {
    2038           0 :     delete pSubsetMap;
    2039           0 :     delete pOrigSymbol;
    2040           0 : }
    2041             : 
    2042           0 : void SmSymDefineDialog::InitColor_Impl()
    2043             : {
    2044             : #if OSL_DEBUG_LEVEL > 1
    2045             :     Color aBC( GetDisplayBackground().GetColor() );
    2046             : #endif
    2047           0 :     ColorData   nBgCol  = COL_WHITE,
    2048           0 :                 nTxtCol = COL_BLACK;
    2049           0 :     bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
    2050           0 :     if (bHighContrast)
    2051             :     {
    2052           0 :         const StyleSettings &rS = GetSettings().GetStyleSettings();
    2053           0 :         nBgCol  = rS.GetFieldColor().GetColor();
    2054           0 :         nTxtCol = rS.GetFieldTextColor().GetColor();
    2055             :     }
    2056             : 
    2057           0 :     Color aTmpColor( nBgCol );
    2058           0 :     Wallpaper aWall( aTmpColor );
    2059           0 :     Color aTxtColor( nTxtCol );
    2060           0 :     pCharsetDisplay  ->SetBackground( aWall );
    2061           0 :     pCharsetDisplay  ->SetTextColor( aTxtColor );
    2062           0 :     pOldSymbolDisplay->SetBackground( aWall );
    2063           0 :     pOldSymbolDisplay->SetTextColor( aTxtColor );
    2064           0 :     pSymbolDisplay   ->SetBackground( aWall );
    2065           0 :     pSymbolDisplay   ->SetTextColor( aTxtColor );
    2066           0 : }
    2067             : 
    2068             : 
    2069           0 : void SmSymDefineDialog::DataChanged( const DataChangedEvent& rDCEvt )
    2070             : {
    2071           0 :     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS  &&
    2072           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    2073           0 :             InitColor_Impl();
    2074             : 
    2075           0 :     ModalDialog::DataChanged( rDCEvt );
    2076           0 : }
    2077             : 
    2078             : 
    2079           0 : short SmSymDefineDialog::Execute()
    2080             : {
    2081           0 :     short nResult = ModalDialog::Execute();
    2082             : 
    2083             :     // apply changes if dialog was closed by clicking OK
    2084           0 :     if (aSymbolMgrCopy.IsModified()  &&  nResult == RET_OK)
    2085           0 :         rSymbolMgr = aSymbolMgrCopy;
    2086             : 
    2087           0 :     return nResult;
    2088             : }
    2089             : 
    2090             : 
    2091           0 : void SmSymDefineDialog::SetSymbolSetManager(const SmSymbolManager &rMgr)
    2092             : {
    2093           0 :     aSymbolMgrCopy = rMgr;
    2094             : 
    2095             :     // Set the modified flag of the copy to false so that
    2096             :     // we can check later on if anything has been changed
    2097           0 :     aSymbolMgrCopy.SetModified(false);
    2098             : 
    2099           0 :     FillSymbolSets(*pOldSymbolSets);
    2100           0 :     if (pOldSymbolSets->GetEntryCount() > 0)
    2101           0 :         SelectSymbolSet(pOldSymbolSets->GetEntry(0));
    2102           0 :     FillSymbolSets(*pSymbolSets);
    2103           0 :     if (pSymbolSets->GetEntryCount() > 0)
    2104           0 :         SelectSymbolSet(pSymbolSets->GetEntry(0));
    2105           0 :     FillSymbols(*pOldSymbols);
    2106           0 :     if (pOldSymbols->GetEntryCount() > 0)
    2107           0 :         SelectSymbol(pOldSymbols->GetEntry(0));
    2108           0 :     FillSymbols(*pSymbols);
    2109           0 :     if (pSymbols->GetEntryCount() > 0)
    2110           0 :         SelectSymbol(pSymbols->GetEntry(0));
    2111             : 
    2112           0 :     UpdateButtons();
    2113           0 : }
    2114             : 
    2115             : 
    2116           0 : bool SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox,
    2117             :         const OUString &rSymbolSetName, bool bDeleteText)
    2118             : {
    2119             : #if OSL_DEBUG_LEVEL > 1
    2120             :     OSL_ENSURE(&rComboBox == pOldSymbolSets  ||  &rComboBox == pSymbolSets,
    2121             :         "Sm : wrong ComboBox");
    2122             : #endif
    2123             : 
    2124             :     // trim SymbolName (no leading and trailing blanks)
    2125           0 :     OUString  aNormName (rSymbolSetName);
    2126           0 :     aNormName = comphelper::string::stripStart(aNormName, ' ');
    2127           0 :     aNormName = comphelper::string::stripEnd(aNormName, ' ');
    2128             :     // and remove possible deviations within the input
    2129           0 :     rComboBox.SetText(aNormName);
    2130             : 
    2131           0 :     bool   bRet = false;
    2132           0 :     sal_Int32 nPos = rComboBox.GetEntryPos(aNormName);
    2133             : 
    2134           0 :     if (nPos != COMBOBOX_ENTRY_NOTFOUND)
    2135             :     {
    2136           0 :         rComboBox.SetText(rComboBox.GetEntry(nPos));
    2137           0 :         bRet = true;
    2138             :     }
    2139           0 :     else if (bDeleteText)
    2140           0 :         rComboBox.SetText(OUString());
    2141             : 
    2142           0 :     bool  bIsOld = &rComboBox == pOldSymbolSets;
    2143             : 
    2144             :     // setting the SymbolSet name at the associated display
    2145           0 :     FixedText &rFT = bIsOld ? *pOldSymbolSetName : *pSymbolSetName;
    2146           0 :     rFT.SetText(rComboBox.GetText());
    2147             : 
    2148             :     // set the symbol name which belongs to the SymbolSet at the associated combobox
    2149           0 :     ComboBox  &rCB = bIsOld ? *pOldSymbols : *pSymbols;
    2150           0 :     FillSymbols(rCB, false);
    2151             : 
    2152             :     // display a valid respectively no symbol when changing the SymbolSets
    2153           0 :     if (bIsOld)
    2154             :     {
    2155           0 :         OUString  aTmpOldSymbolName;
    2156           0 :         if (pOldSymbols->GetEntryCount() > 0)
    2157           0 :             aTmpOldSymbolName = pOldSymbols->GetEntry(0);
    2158           0 :         SelectSymbol(*pOldSymbols, aTmpOldSymbolName, true);
    2159             :     }
    2160             : 
    2161           0 :     UpdateButtons();
    2162             : 
    2163           0 :     return bRet;
    2164             : }
    2165             : 
    2166             : 
    2167           0 : void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol,
    2168             :                                       const OUString &rSymbolSetName)
    2169             : {
    2170             :     // clear old symbol
    2171           0 :     delete pOrigSymbol;
    2172           0 :     pOrigSymbol = 0;
    2173             : 
    2174           0 :     OUString   aSymName,
    2175           0 :                 aSymSetName;
    2176           0 :     if (pSymbol)
    2177             :     {
    2178             :         // set new symbol
    2179           0 :         pOrigSymbol = new SmSym( *pSymbol );
    2180             : 
    2181           0 :         aSymName    = pSymbol->GetName();
    2182           0 :         aSymSetName = rSymbolSetName;
    2183           0 :         pOldSymbolDisplay->SetSymbol( pSymbol );
    2184             :     }
    2185             :     else
    2186             :     {   // delete displayed symbols
    2187           0 :         pOldSymbolDisplay->SetText(OUString());
    2188           0 :         pOldSymbolDisplay->Invalidate();
    2189             :     }
    2190           0 :     pOldSymbolName->SetText(aSymName);
    2191           0 :     pOldSymbolSetName->SetText(aSymSetName);
    2192           0 : }
    2193             : 
    2194             : 
    2195           0 : bool SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox,
    2196             :         const OUString &rSymbolName, bool bDeleteText)
    2197             : {
    2198             : #if OSL_DEBUG_LEVEL > 1
    2199             :     OSL_ENSURE(&rComboBox == pOldSymbols  ||  &rComboBox == pSymbols,
    2200             :         "Sm : wrong ComboBox");
    2201             : #endif
    2202             : 
    2203             :     // trim SymbolName (no blanks)
    2204           0 :     OUString  aNormName(comphelper::string::remove(rSymbolName, ' '));
    2205             :     // and remove possible deviations within the input
    2206           0 :     rComboBox.SetText(aNormName);
    2207             : 
    2208           0 :     bool   bRet = false;
    2209           0 :     sal_Int32 nPos = rComboBox.GetEntryPos(aNormName);
    2210             : 
    2211           0 :     bool  bIsOld = &rComboBox == pOldSymbols;
    2212             : 
    2213           0 :     if (nPos != COMBOBOX_ENTRY_NOTFOUND)
    2214             :     {
    2215           0 :         rComboBox.SetText(rComboBox.GetEntry(nPos));
    2216             : 
    2217           0 :         if (!bIsOld)
    2218             :         {
    2219           0 :             const SmSym *pSymbol = GetSymbol(*pSymbols);
    2220           0 :             if (pSymbol)
    2221             :             {
    2222             :                 // choose font and style accordingly
    2223           0 :                 const vcl::Font &rFont = pSymbol->GetFace();
    2224           0 :                 SelectFont(rFont.GetName(), false);
    2225           0 :                 SelectStyle(GetFontStyles().GetStyleName(rFont), false);
    2226             : 
    2227             :                 // Since setting the Font via the Style name of the SymbolFonts doesn't
    2228             :                 // work really well (e.g. it can be empty even though the font itself is
    2229             :                 // bold or italic) we're manually setting the Font with respect to the Symbol
    2230           0 :                 pCharsetDisplay->SetFont(rFont);
    2231           0 :                 pSymbolDisplay->SetFont(rFont);
    2232             : 
    2233             :                 // select associated character
    2234           0 :                 SelectChar(pSymbol->GetCharacter());
    2235             : 
    2236             :                 // since SelectChar will also set the unicode point as text in the
    2237             :                 // symbols box, we have to set the symbol name again to get that one displayed
    2238           0 :                 pSymbols->SetText( pSymbol->GetName() );
    2239             :             }
    2240             :         }
    2241             : 
    2242           0 :         bRet = true;
    2243             :     }
    2244           0 :     else if (bDeleteText)
    2245           0 :         rComboBox.SetText(OUString());
    2246             : 
    2247           0 :     if (bIsOld)
    2248             :     {
    2249             :         // if there's a change of the old symbol, show only the available ones, otherwise show none
    2250           0 :         const SmSym *pOldSymbol = NULL;
    2251           0 :         OUString     aTmpOldSymbolSetName;
    2252           0 :         if (nPos != COMBOBOX_ENTRY_NOTFOUND)
    2253             :         {
    2254           0 :             pOldSymbol        = aSymbolMgrCopy.GetSymbolByName(aNormName);
    2255           0 :             aTmpOldSymbolSetName = pOldSymbolSets->GetText();
    2256             :         }
    2257           0 :         SetOrigSymbol(pOldSymbol, aTmpOldSymbolSetName);
    2258             :     }
    2259             :     else
    2260           0 :         pSymbolName->SetText(rComboBox.GetText());
    2261             : 
    2262           0 :     UpdateButtons();
    2263             : 
    2264           0 :     return bRet;
    2265             : }
    2266             : 
    2267             : 
    2268           0 : void SmSymDefineDialog::SetFont(const OUString &rFontName, const OUString &rStyleName)
    2269             : {
    2270             :     // get Font (FontInfo) matching name and style
    2271           0 :     vcl::FontInfo aFI;
    2272           0 :     if (pFontList)
    2273           0 :         aFI = pFontList->Get(rFontName, WEIGHT_NORMAL, ITALIC_NONE);
    2274           0 :     SetFontStyle(rStyleName, aFI);
    2275             : 
    2276           0 :     pCharsetDisplay->SetFont(aFI);
    2277           0 :     pSymbolDisplay->SetFont(aFI);
    2278             : 
    2279             :     // update subset listbox for new font's unicode subsets
    2280           0 :     FontCharMapPtr pFontCharMap;
    2281           0 :     pCharsetDisplay->GetFontCharMap( pFontCharMap );
    2282           0 :     if (pSubsetMap)
    2283           0 :         delete pSubsetMap;
    2284           0 :     pSubsetMap = new SubsetMap( pFontCharMap );
    2285             : 
    2286           0 :     pFontsSubsetLB->Clear();
    2287           0 :     bool bFirst = true;
    2288             :     const Subset* pSubset;
    2289           0 :     while( NULL != (pSubset = pSubsetMap->GetNextSubset( bFirst )) )
    2290             :     {
    2291           0 :         sal_uInt16 nPos = pFontsSubsetLB->InsertEntry( pSubset->GetName());
    2292           0 :         pFontsSubsetLB->SetEntryData( nPos, (void *) pSubset );
    2293             :         // subset must live at least as long as the selected font !!!
    2294           0 :         if( bFirst )
    2295           0 :             pFontsSubsetLB->SelectEntryPos( nPos );
    2296           0 :         bFirst = false;
    2297             :     }
    2298           0 :     if( bFirst )
    2299           0 :         pFontsSubsetLB->SetNoSelection();
    2300           0 :     pFontsSubsetLB->Enable( !bFirst );
    2301             : 
    2302           0 :     pFontCharMap = 0;
    2303           0 : }
    2304             : 
    2305             : 
    2306           0 : bool SmSymDefineDialog::SelectFont(const OUString &rFontName, bool bApplyFont)
    2307             : {
    2308           0 :     bool   bRet = false;
    2309           0 :     sal_Int32 nPos = pFonts->GetEntryPos(rFontName);
    2310             : 
    2311           0 :     if (nPos != LISTBOX_ENTRY_NOTFOUND)
    2312             :     {
    2313           0 :         pFonts->SelectEntryPos(nPos);
    2314           0 :         if (pStyles->GetEntryCount() > 0)
    2315           0 :             SelectStyle(pStyles->GetEntry(0));
    2316           0 :         if (bApplyFont)
    2317             :         {
    2318           0 :             SetFont(pFonts->GetSelectEntry(), pStyles->GetText());
    2319           0 :         bRet = true;
    2320           0 :             pSymbolDisplay->SetSymbol( pCharsetDisplay->GetSelectCharacter(), pCharsetDisplay->GetFont() );
    2321             :         }
    2322           0 :         bRet = true;
    2323             :     }
    2324             :     else
    2325           0 :         pFonts->SetNoSelection();
    2326           0 :     FillStyles();
    2327             : 
    2328           0 :     UpdateButtons();
    2329             : 
    2330           0 :     return bRet;
    2331             : }
    2332             : 
    2333             : 
    2334           0 : bool SmSymDefineDialog::SelectStyle(const OUString &rStyleName, bool bApplyFont)
    2335             : {
    2336           0 :     bool   bRet = false;
    2337           0 :     sal_Int32 nPos = pStyles->GetEntryPos(rStyleName);
    2338             : 
    2339             :     // if the style is not available take the first available one (if existent)
    2340           0 :     if (nPos == COMBOBOX_ENTRY_NOTFOUND  &&  pStyles->GetEntryCount() > 0)
    2341           0 :         nPos = 0;
    2342             : 
    2343           0 :     if (nPos != COMBOBOX_ENTRY_NOTFOUND)
    2344             :     {
    2345           0 :         pStyles->SetText(pStyles->GetEntry(nPos));
    2346           0 :         if (bApplyFont)
    2347             :         {
    2348           0 :             SetFont(pFonts->GetSelectEntry(), pStyles->GetText());
    2349           0 :         bRet = true;
    2350           0 :             pSymbolDisplay->SetSymbol( pCharsetDisplay->GetSelectCharacter(), pCharsetDisplay->GetFont() );
    2351             :         }
    2352           0 :         bRet = true;
    2353             :     }
    2354             :     else
    2355           0 :         pStyles->SetText(OUString());
    2356             : 
    2357           0 :     UpdateButtons();
    2358             : 
    2359           0 :     return bRet;
    2360             : }
    2361             : 
    2362             : 
    2363           0 : void SmSymDefineDialog::SelectChar(sal_Unicode cChar)
    2364             : {
    2365           0 :     pCharsetDisplay->SelectCharacter( cChar );
    2366           0 :     pSymbolDisplay->SetSymbol( cChar, pCharsetDisplay->GetFont() );
    2367             : 
    2368           0 :     UpdateButtons();
    2369          72 : }
    2370             : 
    2371             : 
    2372             : /**************************************************************************/
    2373             : 
    2374             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10