1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_starmath.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #define SMDLL 1 33*cdf0e10cSrcweir #include "tools/rcid.h" 34*cdf0e10cSrcweir #include <svl/eitem.hxx> 35*cdf0e10cSrcweir #include <svl/intitem.hxx> 36*cdf0e10cSrcweir #include <svl/stritem.hxx> 37*cdf0e10cSrcweir #include <sfx2/app.hxx> 38*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 39*cdf0e10cSrcweir #include <svtools/ctrltool.hxx> 40*cdf0e10cSrcweir #include <sfx2/printer.hxx> 41*cdf0e10cSrcweir #include <vcl/sound.hxx> 42*cdf0e10cSrcweir #include <vcl/sndstyle.hxx> 43*cdf0e10cSrcweir #include <vcl/waitobj.hxx> 44*cdf0e10cSrcweir #include <vcl/settings.hxx> 45*cdf0e10cSrcweir #include <vcl/wall.hxx> 46*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 47*cdf0e10cSrcweir #include <sfx2/sfx.hrc> 48*cdf0e10cSrcweir #include <tools/string.hxx> 49*cdf0e10cSrcweir #include <tools/debug.hxx> 50*cdf0e10cSrcweir #include <svx/ucsubset.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include "dialog.hxx" 54*cdf0e10cSrcweir #include "starmath.hrc" 55*cdf0e10cSrcweir #include "config.hxx" 56*cdf0e10cSrcweir #include "dialog.hrc" 57*cdf0e10cSrcweir #include "smmod.hxx" 58*cdf0e10cSrcweir #include "symbol.hxx" 59*cdf0e10cSrcweir #include "view.hxx" 60*cdf0e10cSrcweir #include "document.hxx" 61*cdf0e10cSrcweir #include "unomodel.hxx" 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir using ::rtl::OUString; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //////////////////////////////////////// 67*cdf0e10cSrcweir // 68*cdf0e10cSrcweir // Da der FontStyle besser ueber die Attribute gesetzt/abgefragt wird als ueber 69*cdf0e10cSrcweir // den StyleName bauen wir uns hier unsere eigene Uebersetzung 70*cdf0e10cSrcweir // Attribute <-> StyleName 71*cdf0e10cSrcweir // 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir class SmFontStyles 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir String aNormal; 76*cdf0e10cSrcweir String aBold; 77*cdf0e10cSrcweir String aItalic; 78*cdf0e10cSrcweir String aBoldItalic; 79*cdf0e10cSrcweir String aEmpty; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir public: 82*cdf0e10cSrcweir SmFontStyles(); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir sal_uInt16 GetCount() const { return 4; } 85*cdf0e10cSrcweir const String & GetStyleName( const Font &rFont ) const; 86*cdf0e10cSrcweir const String & GetStyleName( sal_uInt16 nIdx ) const; 87*cdf0e10cSrcweir }; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir SmFontStyles::SmFontStyles() : 91*cdf0e10cSrcweir aNormal ( ResId( RID_FONTREGULAR, *SM_MOD()->GetResMgr() ) ), 92*cdf0e10cSrcweir aBold ( ResId( RID_FONTBOLD, *SM_MOD()->GetResMgr() ) ), 93*cdf0e10cSrcweir aItalic ( ResId( RID_FONTITALIC, *SM_MOD()->GetResMgr() ) ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir // SM_MOD()->GetResMgr().FreeResource(); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir aBoldItalic = aBold; 98*cdf0e10cSrcweir aBoldItalic.AppendAscii( ", " ); 99*cdf0e10cSrcweir aBoldItalic += aItalic; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir const String & SmFontStyles::GetStyleName( const Font &rFont ) const 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir //! compare also SmSpecialNode::Prepare 106*cdf0e10cSrcweir sal_Bool bBold = IsBold( rFont ), 107*cdf0e10cSrcweir bItalic = IsItalic( rFont ); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir if (bBold && bItalic) 110*cdf0e10cSrcweir return aBoldItalic; 111*cdf0e10cSrcweir else if (bItalic) 112*cdf0e10cSrcweir return aItalic; 113*cdf0e10cSrcweir else if (bBold) 114*cdf0e10cSrcweir return aBold; 115*cdf0e10cSrcweir else 116*cdf0e10cSrcweir return aNormal; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir const String & SmFontStyles::GetStyleName( sal_uInt16 nIdx ) const 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir // 0 = "normal", 1 = "italic", 123*cdf0e10cSrcweir // 2 = "bold", 3 = "bold italic" 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 126*cdf0e10cSrcweir DBG_ASSERT( nIdx < GetCount(), "index out of range" ); 127*cdf0e10cSrcweir #endif 128*cdf0e10cSrcweir switch (nIdx) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir case 0 : return aNormal; 131*cdf0e10cSrcweir case 1 : return aItalic; 132*cdf0e10cSrcweir case 2 : return aBold; 133*cdf0e10cSrcweir case 3 : return aBoldItalic; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir return aEmpty; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir const SmFontStyles & GetFontStyles() 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir static const SmFontStyles aImpl; 142*cdf0e10cSrcweir return aImpl; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////// 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir void SetFontStyle(const XubString &rStyleName, Font &rFont) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir // finden des Index passend zum StyleName fuer den leeren StyleName wird 150*cdf0e10cSrcweir // 0 (nicht bold nicht italic) angenommen. 151*cdf0e10cSrcweir sal_uInt16 nIndex = 0; 152*cdf0e10cSrcweir if (rStyleName.Len()) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir sal_uInt16 i; 155*cdf0e10cSrcweir const SmFontStyles &rStyles = GetFontStyles(); 156*cdf0e10cSrcweir for (i = 0; i < rStyles.GetCount(); i++) 157*cdf0e10cSrcweir if (rStyleName.CompareTo( rStyles.GetStyleName(i) ) == COMPARE_EQUAL) 158*cdf0e10cSrcweir break; 159*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 160*cdf0e10cSrcweir DBG_ASSERT(i < rStyles.GetCount(), "style-name unknown"); 161*cdf0e10cSrcweir #endif 162*cdf0e10cSrcweir nIndex = i; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir rFont.SetItalic((nIndex & 0x1) ? ITALIC_NORMAL : ITALIC_NONE); 166*cdf0e10cSrcweir rFont.SetWeight((nIndex & 0x2) ? WEIGHT_BOLD : WEIGHT_NORMAL); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir /**************************************************************************/ 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, EMPTYARG/*pButton*/ ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir aZoom.Enable(aSizeZoomed.IsChecked()); 175*cdf0e10cSrcweir return 0; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, pButton ) 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir SmPrintOptionsTabPage::SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions) 181*cdf0e10cSrcweir : SfxTabPage(pParent, SmResId(RID_PRINTOPTIONPAGE), rOptions), 182*cdf0e10cSrcweir aFixedLine1 (this, SmResId( FL_PRINTOPTIONS )), 183*cdf0e10cSrcweir aTitle (this, SmResId( CB_TITLEROW )), 184*cdf0e10cSrcweir aText (this, SmResId( CB_EQUATION_TEXT )), 185*cdf0e10cSrcweir aFrame (this, SmResId( CB_FRAME )), 186*cdf0e10cSrcweir aFixedLine2 (this, SmResId( FL_PRINT_FORMAT )), 187*cdf0e10cSrcweir aSizeNormal (this, SmResId( RB_ORIGINAL_SIZE )), 188*cdf0e10cSrcweir aSizeScaled (this, SmResId( RB_FIT_TO_PAGE )), 189*cdf0e10cSrcweir aSizeZoomed (this, SmResId( RB_ZOOM )), 190*cdf0e10cSrcweir aZoom (this, SmResId( MF_ZOOM )), 191*cdf0e10cSrcweir aFixedLine3 (this, SmResId( FL_MISC_OPTIONS )), 192*cdf0e10cSrcweir aNoRightSpaces (this, SmResId( CB_IGNORE_SPACING )), 193*cdf0e10cSrcweir aSaveOnlyUsedSymbols (this, SmResId( CB_SAVE_ONLY_USED_SYMBOLS )) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir FreeResource(); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir aSizeNormal.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); 198*cdf0e10cSrcweir aSizeScaled.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); 199*cdf0e10cSrcweir aSizeZoomed.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir Reset(rOptions); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir sal_Bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet& rSet) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir sal_uInt16 nPrintSize; 208*cdf0e10cSrcweir if (aSizeNormal.IsChecked()) 209*cdf0e10cSrcweir nPrintSize = PRINT_SIZE_NORMAL; 210*cdf0e10cSrcweir else if (aSizeScaled.IsChecked()) 211*cdf0e10cSrcweir nPrintSize = PRINT_SIZE_SCALED; 212*cdf0e10cSrcweir else 213*cdf0e10cSrcweir nPrintSize = PRINT_SIZE_ZOOMED; 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir rSet.Put(SfxUInt16Item(GetWhich(SID_PRINTSIZE), (sal_uInt16) nPrintSize)); 216*cdf0e10cSrcweir rSet.Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), (sal_uInt16) aZoom.GetValue())); 217*cdf0e10cSrcweir rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), aTitle.IsChecked())); 218*cdf0e10cSrcweir rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), aText.IsChecked())); 219*cdf0e10cSrcweir rSet.Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), aFrame.IsChecked())); 220*cdf0e10cSrcweir rSet.Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), aNoRightSpaces.IsChecked())); 221*cdf0e10cSrcweir rSet.Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), aSaveOnlyUsedSymbols.IsChecked())); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir return sal_True; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir void SmPrintOptionsTabPage::Reset(const SfxItemSet& rSet) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir SmPrintSize ePrintSize = (SmPrintSize)((const SfxUInt16Item &)rSet.Get(GetWhich(SID_PRINTSIZE))).GetValue(); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir aSizeNormal.Check(ePrintSize == PRINT_SIZE_NORMAL); 232*cdf0e10cSrcweir aSizeScaled.Check(ePrintSize == PRINT_SIZE_SCALED); 233*cdf0e10cSrcweir aSizeZoomed.Check(ePrintSize == PRINT_SIZE_ZOOMED); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir aZoom.Enable(aSizeZoomed.IsChecked()); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir aZoom.SetValue(((const SfxUInt16Item &)rSet.Get(GetWhich(SID_PRINTZOOM))).GetValue()); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir aTitle.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTITLE))).GetValue()); 240*cdf0e10cSrcweir aText.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTEXT))).GetValue()); 241*cdf0e10cSrcweir aFrame.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTFRAME))).GetValue()); 242*cdf0e10cSrcweir aNoRightSpaces.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue()); 243*cdf0e10cSrcweir aSaveOnlyUsedSymbols.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue()); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir SfxTabPage* SmPrintOptionsTabPage::Create(Window* pWindow, const SfxItemSet& rSet) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir return (new SmPrintOptionsTabPage(pWindow, rSet)); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir /**************************************************************************/ 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir void SmShowFont::Paint(const Rectangle& rRect ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir Control::Paint( rRect ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir XubString Text (GetFont().GetName()); 260*cdf0e10cSrcweir Size TextSize(GetTextWidth(Text), GetTextHeight()); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir DrawText(Point((GetOutputSize().Width() - TextSize.Width()) / 2, 263*cdf0e10cSrcweir (GetOutputSize().Height() - TextSize.Height()) / 2), Text); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir void SmShowFont::SetFont(const Font& rFont) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir Color aTxtColor( GetTextColor() ); 270*cdf0e10cSrcweir Font aFont (rFont); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir Invalidate(); 273*cdf0e10cSrcweir aFont.SetSize(Size(0, 24)); 274*cdf0e10cSrcweir aFont.SetAlign(ALIGN_TOP); 275*cdf0e10cSrcweir Control::SetFont(aFont); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir // keep old text color (new font may have different color) 278*cdf0e10cSrcweir SetTextColor( aTxtColor ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir Face.SetName(pComboBox->GetText()); 285*cdf0e10cSrcweir aShowFont.SetFont(Face); 286*cdf0e10cSrcweir return 0; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox ) 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir IMPL_LINK( SmFontDialog, FontModifyHdl, ComboBox *, pComboBox ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir // if font is available in list then use it 294*cdf0e10cSrcweir sal_uInt16 nPos = pComboBox->GetEntryPos( pComboBox->GetText() ); 295*cdf0e10cSrcweir if (COMBOBOX_ENTRY_NOTFOUND != nPos) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir FontSelectHdl( pComboBox ); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir return 0; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir IMPL_LINK( SmFontDialog, AttrChangeHdl, CheckBox *, EMPTYARG /*pCheckBox*/ ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir if (aBoldCheckBox.IsChecked()) 306*cdf0e10cSrcweir Face.SetWeight(FontWeight(WEIGHT_BOLD)); 307*cdf0e10cSrcweir else 308*cdf0e10cSrcweir Face.SetWeight(FontWeight(WEIGHT_NORMAL)); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir if (aItalicCheckBox.IsChecked()) 311*cdf0e10cSrcweir Face.SetItalic(ITALIC_NORMAL); 312*cdf0e10cSrcweir else 313*cdf0e10cSrcweir Face.SetItalic(ITALIC_NONE); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir aShowFont.SetFont(Face); 316*cdf0e10cSrcweir return 0; 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir void SmFontDialog::SetFont(const Font &rFont) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir Face = rFont; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir aFontBox.SetText( Face.GetName() ); 325*cdf0e10cSrcweir aBoldCheckBox.Check( IsBold( Face ) ); 326*cdf0e10cSrcweir aItalicCheckBox.Check( IsItalic( Face ) ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir aShowFont.SetFont(Face); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir SmFontDialog::SmFontDialog(Window * pParent, 333*cdf0e10cSrcweir OutputDevice *pFntListDevice, sal_Bool bHideCheckboxes, sal_Bool bFreeRes) 334*cdf0e10cSrcweir : ModalDialog(pParent,SmResId(RID_FONTDIALOG)), 335*cdf0e10cSrcweir aFixedText1 (this, SmResId(1)), 336*cdf0e10cSrcweir aFontBox (this, SmResId(1)), 337*cdf0e10cSrcweir aBoldCheckBox (this, SmResId(1)), 338*cdf0e10cSrcweir aItalicCheckBox (this, SmResId(2)), 339*cdf0e10cSrcweir aOKButton1 (this, SmResId(1)), 340*cdf0e10cSrcweir aCancelButton1 (this, SmResId(1)), 341*cdf0e10cSrcweir aShowFont (this, SmResId(1)), 342*cdf0e10cSrcweir aFixedText2 (this, SmResId(2)) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir if (bFreeRes) 345*cdf0e10cSrcweir FreeResource(); 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir WaitObject( this ); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir FontList aFontList( pFntListDevice ); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir sal_uInt16 nCount = aFontList.GetFontNameCount(); 353*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount; i++) 354*cdf0e10cSrcweir aFontBox.InsertEntry( aFontList.GetFontName(i).GetName() ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir Face.SetSize(Size(0, 24)); 357*cdf0e10cSrcweir Face.SetWeight(WEIGHT_NORMAL); 358*cdf0e10cSrcweir Face.SetItalic(ITALIC_NONE); 359*cdf0e10cSrcweir Face.SetFamily(FAMILY_DONTKNOW); 360*cdf0e10cSrcweir Face.SetPitch(PITCH_DONTKNOW); 361*cdf0e10cSrcweir Face.SetCharSet(RTL_TEXTENCODING_DONTKNOW); 362*cdf0e10cSrcweir Face.SetTransparent(sal_True); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir InitColor_Impl(); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir // preview like controls should have a 2D look 367*cdf0e10cSrcweir aShowFont.SetBorderStyle( WINDOW_BORDER_MONO ); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir aFontBox.SetSelectHdl(LINK(this, SmFontDialog, FontSelectHdl)); 371*cdf0e10cSrcweir aFontBox.SetModifyHdl(LINK(this, SmFontDialog, FontModifyHdl)); 372*cdf0e10cSrcweir aBoldCheckBox.SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl)); 373*cdf0e10cSrcweir aItalicCheckBox.SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl)); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir if (bHideCheckboxes) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir aBoldCheckBox.Check( sal_False ); 378*cdf0e10cSrcweir aBoldCheckBox.Enable( sal_False ); 379*cdf0e10cSrcweir aBoldCheckBox.Show( sal_False ); 380*cdf0e10cSrcweir aItalicCheckBox.Check( sal_False ); 381*cdf0e10cSrcweir aItalicCheckBox.Enable( sal_False ); 382*cdf0e10cSrcweir aItalicCheckBox.Show( sal_False ); 383*cdf0e10cSrcweir aFixedText2.Show( sal_False ); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir Size aSize( aFontBox.GetSizePixel() ); 386*cdf0e10cSrcweir long nComboBoxBottom = aFontBox.GetPosPixel().Y() + aFontBox.GetSizePixel().Height(); 387*cdf0e10cSrcweir long nCheckBoxBottom = aItalicCheckBox.GetPosPixel().Y() + aItalicCheckBox.GetSizePixel().Height(); 388*cdf0e10cSrcweir aSize.Height() += nCheckBoxBottom - nComboBoxBottom; 389*cdf0e10cSrcweir aFontBox.SetSizePixel( aSize ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir void SmFontDialog::InitColor_Impl() 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 396*cdf0e10cSrcweir Color aBC( GetDisplayBackground().GetColor() ); 397*cdf0e10cSrcweir #endif 398*cdf0e10cSrcweir ColorData nBgCol = COL_WHITE, 399*cdf0e10cSrcweir nTxtCol = COL_BLACK; 400*cdf0e10cSrcweir const StyleSettings &rS = GetSettings().GetStyleSettings(); 401*cdf0e10cSrcweir if (rS.GetHighContrastMode()) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir nBgCol = rS.GetFieldColor().GetColor(); 404*cdf0e10cSrcweir nTxtCol = rS.GetFieldTextColor().GetColor(); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir Color aTmpColor( nBgCol ); 408*cdf0e10cSrcweir Wallpaper aWall( aTmpColor ); 409*cdf0e10cSrcweir Color aTxtColor( nTxtCol ); 410*cdf0e10cSrcweir aShowFont.SetBackground( aWall ); 411*cdf0e10cSrcweir aShowFont.SetTextColor( aTxtColor ); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && 418*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 419*cdf0e10cSrcweir InitColor_Impl(); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir ModalDialog::DataChanged( rDCEvt ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir /**************************************************************************/ 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir if (pQueryBox->Execute() == RET_YES) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir SmModule *pp = SM_MOD(); 434*cdf0e10cSrcweir SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); 435*cdf0e10cSrcweir WriteTo( aFmt ); 436*cdf0e10cSrcweir pp->GetConfig()->SetStandardFormat( aFmt ); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir delete pQueryBox; 440*cdf0e10cSrcweir return 0; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir SmFontSizeDialog::SmFontSizeDialog(Window * pParent, sal_Bool bFreeRes) 445*cdf0e10cSrcweir : ModalDialog(pParent, SmResId(RID_FONTSIZEDIALOG)), 446*cdf0e10cSrcweir aFixedText1(this, SmResId(1)), 447*cdf0e10cSrcweir aBaseSize(this, SmResId(1)), 448*cdf0e10cSrcweir aFixedText4(this, SmResId(4)), 449*cdf0e10cSrcweir aTextSize(this, SmResId(4)), 450*cdf0e10cSrcweir aFixedText5(this, SmResId(5)), 451*cdf0e10cSrcweir aIndexSize(this, SmResId(5)), 452*cdf0e10cSrcweir aFixedText6(this, SmResId(6)), 453*cdf0e10cSrcweir aFunctionSize(this, SmResId(6)), 454*cdf0e10cSrcweir aFixedText7(this, SmResId(7)), 455*cdf0e10cSrcweir aOperatorSize(this, SmResId(7)), 456*cdf0e10cSrcweir aFixedText8(this, SmResId(8)), 457*cdf0e10cSrcweir aBorderSize(this, SmResId(8)), 458*cdf0e10cSrcweir aFixedLine1(this, SmResId(1)), 459*cdf0e10cSrcweir aOKButton1(this, SmResId(1)), 460*cdf0e10cSrcweir aCancelButton1(this, SmResId(1)), 461*cdf0e10cSrcweir aDefaultButton(this, SmResId(1)) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir if (bFreeRes) 464*cdf0e10cSrcweir FreeResource(); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir aDefaultButton.SetClickHdl(LINK(this, SmFontSizeDialog, DefaultButtonClickHdl)); 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir void SmFontSizeDialog::ReadFrom(const SmFormat &rFormat) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir //! aufpassen: richtig runden! 473*cdf0e10cSrcweir aBaseSize.SetValue( SmRoundFraction( 474*cdf0e10cSrcweir Sm100th_mmToPts( rFormat.GetBaseSize().Height() ) ) ); 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir aTextSize .SetValue( rFormat.GetRelSize(SIZ_TEXT) ); 477*cdf0e10cSrcweir aIndexSize .SetValue( rFormat.GetRelSize(SIZ_INDEX) ); 478*cdf0e10cSrcweir aFunctionSize.SetValue( rFormat.GetRelSize(SIZ_FUNCTION) ); 479*cdf0e10cSrcweir aOperatorSize.SetValue( rFormat.GetRelSize(SIZ_OPERATOR) ); 480*cdf0e10cSrcweir aBorderSize .SetValue( rFormat.GetRelSize(SIZ_LIMITS) ); 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir void SmFontSizeDialog::WriteTo(SmFormat &rFormat) const 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir rFormat.SetBaseSize( Size(0, SmPtsTo100th_mm( static_cast< long >(aBaseSize.GetValue()))) ); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir rFormat.SetRelSize(SIZ_TEXT, (sal_uInt16) aTextSize .GetValue()); 489*cdf0e10cSrcweir rFormat.SetRelSize(SIZ_INDEX, (sal_uInt16) aIndexSize .GetValue()); 490*cdf0e10cSrcweir rFormat.SetRelSize(SIZ_FUNCTION, (sal_uInt16) aFunctionSize.GetValue()); 491*cdf0e10cSrcweir rFormat.SetRelSize(SIZ_OPERATOR, (sal_uInt16) aOperatorSize.GetValue()); 492*cdf0e10cSrcweir rFormat.SetRelSize(SIZ_LIMITS, (sal_uInt16) aBorderSize .GetValue()); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir const Size aTmp (rFormat.GetBaseSize()); 495*cdf0e10cSrcweir for (sal_uInt16 i = FNT_BEGIN; i <= FNT_END; i++) 496*cdf0e10cSrcweir rFormat.SetFontSize(i, aTmp); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir rFormat.RequestApplyChanges(); 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir /**************************************************************************/ 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir SmFontPickListBox *pActiveListBox; 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir sal_Bool bHideCheckboxes = sal_False; 510*cdf0e10cSrcweir switch (pMenu->GetCurItemId()) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir case 1: pActiveListBox = &aVariableFont; break; 513*cdf0e10cSrcweir case 2: pActiveListBox = &aFunctionFont; break; 514*cdf0e10cSrcweir case 3: pActiveListBox = &aNumberFont; break; 515*cdf0e10cSrcweir case 4: pActiveListBox = &aTextFont; break; 516*cdf0e10cSrcweir case 5: pActiveListBox = &aSerifFont; bHideCheckboxes = sal_True; break; 517*cdf0e10cSrcweir case 6: pActiveListBox = &aSansFont; bHideCheckboxes = sal_True; break; 518*cdf0e10cSrcweir case 7: pActiveListBox = &aFixedFont; bHideCheckboxes = sal_True; break; 519*cdf0e10cSrcweir default:pActiveListBox = NULL; 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir if (pActiveListBox) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir SmFontDialog *pFontDialog = new SmFontDialog(this, pFontListDev, bHideCheckboxes); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir pActiveListBox->WriteTo(*pFontDialog); 527*cdf0e10cSrcweir if (pFontDialog->Execute() == RET_OK) 528*cdf0e10cSrcweir pActiveListBox->ReadFrom(*pFontDialog); 529*cdf0e10cSrcweir delete pFontDialog; 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir return 0; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); 538*cdf0e10cSrcweir if (pQueryBox->Execute() == RET_YES) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir SmModule *pp = SM_MOD(); 541*cdf0e10cSrcweir SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); 542*cdf0e10cSrcweir WriteTo( aFmt ); 543*cdf0e10cSrcweir pp->GetConfig()->SetStandardFormat( aFmt, sal_True ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir delete pQueryBox; 547*cdf0e10cSrcweir return 0; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton ) 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir SmFontTypeDialog::SmFontTypeDialog(Window * pParent, OutputDevice *pFntListDevice, sal_Bool bFreeRes) 553*cdf0e10cSrcweir : ModalDialog(pParent, SmResId(RID_FONTTYPEDIALOG)), 554*cdf0e10cSrcweir aFixedText1 (this, SmResId(1)), 555*cdf0e10cSrcweir aVariableFont (this, SmResId(1)), 556*cdf0e10cSrcweir aFixedText2 (this, SmResId(2)), 557*cdf0e10cSrcweir aFunctionFont (this, SmResId(2)), 558*cdf0e10cSrcweir aFixedText3 (this, SmResId(3)), 559*cdf0e10cSrcweir aNumberFont (this, SmResId(3)), 560*cdf0e10cSrcweir aFixedText4 (this, SmResId(4)), 561*cdf0e10cSrcweir aTextFont (this, SmResId(4)), 562*cdf0e10cSrcweir aFixedText5 (this, SmResId(5)), 563*cdf0e10cSrcweir aSerifFont (this, SmResId(5)), 564*cdf0e10cSrcweir aFixedText6 (this, SmResId(6)), 565*cdf0e10cSrcweir aSansFont (this, SmResId(6)), 566*cdf0e10cSrcweir aFixedText7 (this, SmResId(7)), 567*cdf0e10cSrcweir aFixedFont (this, SmResId(7)), 568*cdf0e10cSrcweir aFixedLine1 (this, SmResId(1)), 569*cdf0e10cSrcweir aFixedLine2 (this, SmResId(2)), 570*cdf0e10cSrcweir aOKButton1 (this, SmResId(1)), 571*cdf0e10cSrcweir aCancelButton1 (this, SmResId(1)), 572*cdf0e10cSrcweir aMenuButton (this, SmResId(1)), 573*cdf0e10cSrcweir aDefaultButton (this, SmResId(2)), 574*cdf0e10cSrcweir pFontListDev (pFntListDevice) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir if (bFreeRes) 577*cdf0e10cSrcweir FreeResource(); 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir aDefaultButton.SetClickHdl(LINK(this, SmFontTypeDialog, DefaultButtonClickHdl)); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmFontTypeDialog, MenuSelectHdl)); 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir SmModule *pp = SM_MOD(); 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir aVariableFont = pp->GetConfig()->GetFontPickList(FNT_VARIABLE); 589*cdf0e10cSrcweir aFunctionFont = pp->GetConfig()->GetFontPickList(FNT_FUNCTION); 590*cdf0e10cSrcweir aNumberFont = pp->GetConfig()->GetFontPickList(FNT_NUMBER); 591*cdf0e10cSrcweir aTextFont = pp->GetConfig()->GetFontPickList(FNT_TEXT); 592*cdf0e10cSrcweir aSerifFont = pp->GetConfig()->GetFontPickList(FNT_SERIF); 593*cdf0e10cSrcweir aSansFont = pp->GetConfig()->GetFontPickList(FNT_SANS); 594*cdf0e10cSrcweir aFixedFont = pp->GetConfig()->GetFontPickList(FNT_FIXED); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir aVariableFont.Insert( rFormat.GetFont(FNT_VARIABLE) ); 597*cdf0e10cSrcweir aFunctionFont.Insert( rFormat.GetFont(FNT_FUNCTION) ); 598*cdf0e10cSrcweir aNumberFont .Insert( rFormat.GetFont(FNT_NUMBER) ); 599*cdf0e10cSrcweir aTextFont .Insert( rFormat.GetFont(FNT_TEXT) ); 600*cdf0e10cSrcweir aSerifFont .Insert( rFormat.GetFont(FNT_SERIF) ); 601*cdf0e10cSrcweir aSansFont .Insert( rFormat.GetFont(FNT_SANS) ); 602*cdf0e10cSrcweir aFixedFont .Insert( rFormat.GetFont(FNT_FIXED) ); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir SmModule *pp = SM_MOD(); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_VARIABLE) = aVariableFont; 611*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_FUNCTION) = aFunctionFont; 612*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_NUMBER) = aNumberFont; 613*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_TEXT) = aTextFont; 614*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_SERIF) = aSerifFont; 615*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_SANS) = aSansFont; 616*cdf0e10cSrcweir pp->GetConfig()->GetFontPickList(FNT_FIXED) = aFixedFont; 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir rFormat.SetFont( FNT_VARIABLE, aVariableFont.Get(0) ); 619*cdf0e10cSrcweir rFormat.SetFont( FNT_FUNCTION, aFunctionFont.Get(0) ); 620*cdf0e10cSrcweir rFormat.SetFont( FNT_NUMBER, aNumberFont .Get(0) ); 621*cdf0e10cSrcweir rFormat.SetFont( FNT_TEXT, aTextFont .Get(0) ); 622*cdf0e10cSrcweir rFormat.SetFont( FNT_SERIF, aSerifFont .Get(0) ); 623*cdf0e10cSrcweir rFormat.SetFont( FNT_SANS, aSansFont .Get(0) ); 624*cdf0e10cSrcweir rFormat.SetFont( FNT_FIXED, aFixedFont .Get(0) ); 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir rFormat.RequestApplyChanges(); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir /**************************************************************************/ 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir struct FieldMinMax 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir sal_uInt16 nMin, nMax; 634*cdf0e10cSrcweir }; 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir // Data for min and max values of the 4 metric fields 637*cdf0e10cSrcweir // for each of the 10 categories 638*cdf0e10cSrcweir static const FieldMinMax pMinMaxData[10][4] = 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir // 0 641*cdf0e10cSrcweir {{ 0, 200 }, { 0, 200 }, { 0, 100 }, { 0, 0 }}, 642*cdf0e10cSrcweir // 1 643*cdf0e10cSrcweir {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }}, 644*cdf0e10cSrcweir // 2 645*cdf0e10cSrcweir {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }}, 646*cdf0e10cSrcweir // 3 647*cdf0e10cSrcweir {{ 0, 100 }, { 1, 100 }, { 0, 0 }, { 0, 0 }}, 648*cdf0e10cSrcweir // 4 649*cdf0e10cSrcweir {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }}, 650*cdf0e10cSrcweir // 5 651*cdf0e10cSrcweir {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 100 }}, 652*cdf0e10cSrcweir // 6 653*cdf0e10cSrcweir {{ 0, 300 }, { 0, 300 }, { 0, 0 }, { 0, 0 }}, 654*cdf0e10cSrcweir // 7 655*cdf0e10cSrcweir {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }}, 656*cdf0e10cSrcweir // 8 657*cdf0e10cSrcweir {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }}, 658*cdf0e10cSrcweir // 9 659*cdf0e10cSrcweir {{ 0, 10000 }, { 0, 10000 }, { 0, 10000 }, { 0, 10000 }} 660*cdf0e10cSrcweir }; 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir SmCategoryDesc::SmCategoryDesc(const ResId& rResId, sal_uInt16 nCategoryIdx) : 663*cdf0e10cSrcweir Resource(rResId), 664*cdf0e10cSrcweir bIsHighContrast(sal_False) 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir if (IsAvailableRes(ResId(1,*rResId.GetResMgr()).SetRT(RSC_STRING))) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir Name = XubString(ResId(1,*rResId.GetResMgr())); 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir int i; 671*cdf0e10cSrcweir for (i = 0; i < 4; i++) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir int nI2 = i + 2; 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir if (IsAvailableRes(ResId(nI2,*rResId.GetResMgr()).SetRT(RSC_STRING))) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir Strings [i] = new XubString(ResId(nI2,*rResId.GetResMgr())); 678*cdf0e10cSrcweir Graphics [i] = new Bitmap(ResId(10*nI2,*rResId.GetResMgr())); 679*cdf0e10cSrcweir GraphicsH[i] = new Bitmap(ResId(10*nI2+1,*rResId.GetResMgr())); 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir else 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir Strings [i] = 0; 684*cdf0e10cSrcweir Graphics [i] = 0; 685*cdf0e10cSrcweir GraphicsH[i] = 0; 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir for (i = 0; i < 4; i++) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir const FieldMinMax &rMinMax = pMinMaxData[ nCategoryIdx ][i]; 692*cdf0e10cSrcweir Value[i] = Minimum[i] = rMinMax.nMin; 693*cdf0e10cSrcweir Maximum[i] = rMinMax.nMax; 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir FreeResource(); 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir SmCategoryDesc::~SmCategoryDesc() 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir for (int i = 0; i < 4; i++) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir delete Strings [i]; 706*cdf0e10cSrcweir delete Graphics [i]; 707*cdf0e10cSrcweir delete GraphicsH[i]; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir /**************************************************************************/ 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir IMPL_LINK( SmDistanceDialog, GetFocusHdl, Control *, pControl ) 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir if (Categories[nActiveCategory]) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir sal_uInt16 i; 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir if (pControl == &aMetricField1) 720*cdf0e10cSrcweir i = 0; 721*cdf0e10cSrcweir else if (pControl == &aMetricField2) 722*cdf0e10cSrcweir i = 1; 723*cdf0e10cSrcweir else if (pControl == &aMetricField3) 724*cdf0e10cSrcweir i = 2; 725*cdf0e10cSrcweir else if (pControl == &aMetricField4) 726*cdf0e10cSrcweir i = 3; 727*cdf0e10cSrcweir else 728*cdf0e10cSrcweir return 0; 729*cdf0e10cSrcweir aBitmap.SetBitmap(*(Categories[nActiveCategory]->GetGraphic(i))); 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir return 0; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu ) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir SetCategory(pMenu->GetCurItemId() - 1); 737*cdf0e10cSrcweir return 0; 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) 742*cdf0e10cSrcweir { 743*cdf0e10cSrcweir QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir if (pQueryBox->Execute() == RET_YES) 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir SmModule *pp = SM_MOD(); 748*cdf0e10cSrcweir SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); 749*cdf0e10cSrcweir WriteTo( aFmt ); 750*cdf0e10cSrcweir pp->GetConfig()->SetStandardFormat( aFmt ); 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir delete pQueryBox; 753*cdf0e10cSrcweir return 0; 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox ) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir if (pCheckBox == &aCheckBox1) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir aCheckBox1.Toggle(); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir sal_Bool bChecked = aCheckBox1.IsChecked(); 764*cdf0e10cSrcweir aFixedText4 .Enable( bChecked ); 765*cdf0e10cSrcweir aMetricField4.Enable( bChecked ); 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir return 0; 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir void SmDistanceDialog::SetHelpId(MetricField &rField, const rtl::OString& sHelpId) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir //! HelpID's die auf diese Weise explizit gesetzt werden, muessen im 774*cdf0e10cSrcweir //! util Verzeichnis im File "hidother.src" mit Hilfe von "hidspecial" 775*cdf0e10cSrcweir //! definiert werden! 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir const XubString aEmptyText; 778*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 779*cdf0e10cSrcweir DBG_ASSERT(aEmptyText.Len() == 0, "Sm: Ooops..."); 780*cdf0e10cSrcweir #endif 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir rField.SetHelpId(sHelpId); 783*cdf0e10cSrcweir rField.SetHelpText(aEmptyText); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir // since MetricField inherits from SpinField which has a sub Edit field 786*cdf0e10cSrcweir // (which is actually the one we modify) we have to set the help-id 787*cdf0e10cSrcweir // for it too. 788*cdf0e10cSrcweir Edit *pSubEdit = rField.GetSubEdit(); 789*cdf0e10cSrcweir if (pSubEdit) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir pSubEdit->SetHelpId(sHelpId); 792*cdf0e10cSrcweir pSubEdit->SetHelpText(aEmptyText); 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir void SmDistanceDialog::SetCategory(sal_uInt16 nCategory) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 800*cdf0e10cSrcweir DBG_ASSERT(/*0 <= nCategory &&*/ nCategory < NOCATEGORIES, 801*cdf0e10cSrcweir "Sm: falsche Kategorienummer in SmDistanceDialog"); 802*cdf0e10cSrcweir #endif 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir // array to convert category- and metricfield-number in help ids. 805*cdf0e10cSrcweir // 0 is used in case of unused combinations. 806*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 807*cdf0e10cSrcweir DBG_ASSERT(NOCATEGORIES == 10, "Sm : Array passt nicht zu Anzahl der Kategorien"); 808*cdf0e10cSrcweir #endif 809*cdf0e10cSrcweir const char* __READONLY_DATA aCatMf2Hid[10][4] = 810*cdf0e10cSrcweir { 811*cdf0e10cSrcweir { HID_SMA_DEFAULT_DIST, HID_SMA_LINE_DIST, HID_SMA_ROOT_DIST, 0 }, 812*cdf0e10cSrcweir { HID_SMA_SUP_DIST, HID_SMA_SUB_DIST , 0, 0 }, 813*cdf0e10cSrcweir { HID_SMA_NUMERATOR_DIST, HID_SMA_DENOMINATOR_DIST, 0, 0 }, 814*cdf0e10cSrcweir { HID_SMA_FRACLINE_EXCWIDTH, HID_SMA_FRACLINE_LINEWIDTH, 0, 0 }, 815*cdf0e10cSrcweir { HID_SMA_UPPERLIMIT_DIST, HID_SMA_LOWERLIMIT_DIST, 0, 0 }, 816*cdf0e10cSrcweir { HID_SMA_BRACKET_EXCHEIGHT, HID_SMA_BRACKET_DIST, 0, HID_SMA_BRACKET_EXCHEIGHT2 }, 817*cdf0e10cSrcweir { HID_SMA_MATRIXROW_DIST, HID_SMA_MATRIXCOL_DIST, 0, 0 }, 818*cdf0e10cSrcweir { HID_SMA_ATTRIBUT_DIST, HID_SMA_INTERATTRIBUT_DIST, 0, 0 }, 819*cdf0e10cSrcweir { HID_SMA_OPERATOR_EXCHEIGHT, HID_SMA_OPERATOR_DIST, 0, 0 }, 820*cdf0e10cSrcweir { HID_SMA_LEFTBORDER_DIST, HID_SMA_RIGHTBORDER_DIST, HID_SMA_UPPERBORDER_DIST, HID_SMA_LOWERBORDER_DIST } 821*cdf0e10cSrcweir }; 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir // array to help iterate over the controls 824*cdf0e10cSrcweir Window * __READONLY_DATA aWin[4][2] = 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir { &aFixedText1, &aMetricField1 }, 827*cdf0e10cSrcweir { &aFixedText2, &aMetricField2 }, 828*cdf0e10cSrcweir { &aFixedText3, &aMetricField3 }, 829*cdf0e10cSrcweir { &aFixedText4, &aMetricField4 } 830*cdf0e10cSrcweir }; 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir SmCategoryDesc *pCat; 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir // merken der (evtl neuen) Einstellungen der aktiven SmCategoryDesc 835*cdf0e10cSrcweir // bevor zu der neuen gewechselt wird. 836*cdf0e10cSrcweir if (nActiveCategory != CATEGORY_NONE) 837*cdf0e10cSrcweir { 838*cdf0e10cSrcweir pCat = Categories[nActiveCategory]; 839*cdf0e10cSrcweir pCat->SetValue(0, (sal_uInt16) aMetricField1.GetValue()); 840*cdf0e10cSrcweir pCat->SetValue(1, (sal_uInt16) aMetricField2.GetValue()); 841*cdf0e10cSrcweir pCat->SetValue(2, (sal_uInt16) aMetricField3.GetValue()); 842*cdf0e10cSrcweir pCat->SetValue(3, (sal_uInt16) aMetricField4.GetValue()); 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir if (nActiveCategory == 5) 845*cdf0e10cSrcweir bScaleAllBrackets = aCheckBox1.IsChecked(); 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir aMenuButton.GetPopupMenu()->CheckItem(nActiveCategory + 1, sal_False); 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir // aktivieren/deaktivieren der zugehoerigen Controls in Abhaengigkeit von der 851*cdf0e10cSrcweir // gewaehlten Kategorie. 852*cdf0e10cSrcweir sal_Bool bActive; 853*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < 4; i++) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir FixedText *pFT = (FixedText * const) aWin[i][0]; 856*cdf0e10cSrcweir MetricField *pMF = (MetricField * const) aWin[i][1]; 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir // Um feststellen welche Controls aktiv sein sollen wird das 859*cdf0e10cSrcweir // vorhandensein einer zugehoerigen HelpID ueberprueft. 860*cdf0e10cSrcweir bActive = aCatMf2Hid[nCategory][i] != 0; 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir pFT->Show(bActive); 863*cdf0e10cSrcweir pFT->Enable(bActive); 864*cdf0e10cSrcweir pMF->Show(bActive); 865*cdf0e10cSrcweir pMF->Enable(bActive); 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir // setzen von Masseinheit und Anzahl der Nachkommastellen 868*cdf0e10cSrcweir FieldUnit eUnit; 869*cdf0e10cSrcweir sal_uInt16 nDigits; 870*cdf0e10cSrcweir if (nCategory < 9) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir eUnit = FUNIT_CUSTOM; 873*cdf0e10cSrcweir nDigits = 0; 874*cdf0e10cSrcweir pMF->SetCustomUnitText( '%' ); 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir else 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir eUnit = FUNIT_100TH_MM; 879*cdf0e10cSrcweir nDigits = 2; 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir pMF->SetUnit(eUnit); //! veraendert den Wert 882*cdf0e10cSrcweir pMF->SetDecimalDigits(nDigits); 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir if (bActive) 885*cdf0e10cSrcweir { 886*cdf0e10cSrcweir pCat = Categories[nCategory]; 887*cdf0e10cSrcweir pFT->SetText(*pCat->GetString(i)); 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir pMF->SetMin(pCat->GetMinimum(i)); 890*cdf0e10cSrcweir pMF->SetMax(pCat->GetMaximum(i)); 891*cdf0e10cSrcweir pMF->SetValue(pCat->GetValue(i)); 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir SetHelpId(*pMF, aCatMf2Hid[nCategory][i]); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir // nun noch die CheckBox und das zugehoerige MetricField genau dann aktivieren, 897*cdf0e10cSrcweir // falls es sich um das Klammer Menu handelt. 898*cdf0e10cSrcweir bActive = nCategory == 5; 899*cdf0e10cSrcweir aCheckBox1.Show(bActive); 900*cdf0e10cSrcweir aCheckBox1.Enable(bActive); 901*cdf0e10cSrcweir if (bActive) 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir aCheckBox1.Check( bScaleAllBrackets ); 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir sal_Bool bChecked = aCheckBox1.IsChecked(); 906*cdf0e10cSrcweir aFixedText4 .Enable( bChecked ); 907*cdf0e10cSrcweir aMetricField4.Enable( bChecked ); 908*cdf0e10cSrcweir } 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir aMenuButton.GetPopupMenu()->CheckItem(nCategory + 1, sal_True); 911*cdf0e10cSrcweir aFixedLine.SetText(Categories[nCategory]->GetName()); 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir nActiveCategory = nCategory; 914*cdf0e10cSrcweir 915*cdf0e10cSrcweir aMetricField1.GrabFocus(); 916*cdf0e10cSrcweir Invalidate(); 917*cdf0e10cSrcweir Update(); 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir 921*cdf0e10cSrcweir SmDistanceDialog::SmDistanceDialog(Window *pParent, sal_Bool bFreeRes) 922*cdf0e10cSrcweir : ModalDialog(pParent, SmResId(RID_DISTANCEDIALOG)), 923*cdf0e10cSrcweir aFixedText1 (this, SmResId(1)), 924*cdf0e10cSrcweir aMetricField1 (this, SmResId(1)), 925*cdf0e10cSrcweir aFixedText2 (this, SmResId(2)), 926*cdf0e10cSrcweir aMetricField2 (this, SmResId(2)), 927*cdf0e10cSrcweir aFixedText3 (this, SmResId(3)), 928*cdf0e10cSrcweir aMetricField3 (this, SmResId(3)), 929*cdf0e10cSrcweir aCheckBox1 (this, SmResId(1)), 930*cdf0e10cSrcweir aFixedText4 (this, SmResId(4)), 931*cdf0e10cSrcweir aMetricField4 (this, SmResId(4)), 932*cdf0e10cSrcweir aOKButton1 (this, SmResId(1)), 933*cdf0e10cSrcweir aCancelButton1 (this, SmResId(1)), 934*cdf0e10cSrcweir aMenuButton (this, SmResId(1)), 935*cdf0e10cSrcweir aDefaultButton (this, SmResId(1)), 936*cdf0e10cSrcweir aBitmap (this, SmResId(1)), 937*cdf0e10cSrcweir aFixedLine (this, SmResId(1)) 938*cdf0e10cSrcweir { 939*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < NOCATEGORIES; i++) 940*cdf0e10cSrcweir Categories[i] = new SmCategoryDesc(SmResId(i + 1), i); 941*cdf0e10cSrcweir nActiveCategory = CATEGORY_NONE; 942*cdf0e10cSrcweir bScaleAllBrackets = sal_False; 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir if (bFreeRes) 945*cdf0e10cSrcweir FreeResource(); 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir ApplyImages(); 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir // preview like controls should have a 2D look 950*cdf0e10cSrcweir aBitmap.SetBorderStyle( WINDOW_BORDER_MONO ); 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir aMetricField1.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl)); 953*cdf0e10cSrcweir aMetricField2.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl)); 954*cdf0e10cSrcweir aMetricField3.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl)); 955*cdf0e10cSrcweir aMetricField4.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl)); 956*cdf0e10cSrcweir aCheckBox1.SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl)); 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl)); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir aDefaultButton.SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl)); 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir SmDistanceDialog::~SmDistanceDialog() 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir for (int i = 0; i < NOCATEGORIES; i++) 967*cdf0e10cSrcweir DELETEZ(Categories[i]); 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir void SmDistanceDialog::ApplyImages() 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 973*cdf0e10cSrcweir for (int i = 0; i < NOCATEGORIES; ++i) 974*cdf0e10cSrcweir { 975*cdf0e10cSrcweir SmCategoryDesc *pCat = Categories[i]; 976*cdf0e10cSrcweir if (pCat) 977*cdf0e10cSrcweir pCat->SetHighContrast( bHighContrast ); 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir void SmDistanceDialog::DataChanged( const DataChangedEvent &rEvt ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir if ( (rEvt.GetType() == DATACHANGED_SETTINGS) && (rEvt.GetFlags() & SETTINGS_STYLE) ) 984*cdf0e10cSrcweir ApplyImages(); 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir ModalDialog::DataChanged( rEvt ); 987*cdf0e10cSrcweir } 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir void SmDistanceDialog::ReadFrom(const SmFormat &rFormat) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir Categories[0]->SetValue(0, rFormat.GetDistance(DIS_HORIZONTAL)); 992*cdf0e10cSrcweir Categories[0]->SetValue(1, rFormat.GetDistance(DIS_VERTICAL)); 993*cdf0e10cSrcweir Categories[0]->SetValue(2, rFormat.GetDistance(DIS_ROOT)); 994*cdf0e10cSrcweir Categories[1]->SetValue(0, rFormat.GetDistance(DIS_SUPERSCRIPT)); 995*cdf0e10cSrcweir Categories[1]->SetValue(1, rFormat.GetDistance(DIS_SUBSCRIPT)); 996*cdf0e10cSrcweir Categories[2]->SetValue(0, rFormat.GetDistance(DIS_NUMERATOR)); 997*cdf0e10cSrcweir Categories[2]->SetValue(1, rFormat.GetDistance(DIS_DENOMINATOR)); 998*cdf0e10cSrcweir Categories[3]->SetValue(0, rFormat.GetDistance(DIS_FRACTION)); 999*cdf0e10cSrcweir Categories[3]->SetValue(1, rFormat.GetDistance(DIS_STROKEWIDTH)); 1000*cdf0e10cSrcweir Categories[4]->SetValue(0, rFormat.GetDistance(DIS_UPPERLIMIT)); 1001*cdf0e10cSrcweir Categories[4]->SetValue(1, rFormat.GetDistance(DIS_LOWERLIMIT)); 1002*cdf0e10cSrcweir Categories[5]->SetValue(0, rFormat.GetDistance(DIS_BRACKETSIZE)); 1003*cdf0e10cSrcweir Categories[5]->SetValue(1, rFormat.GetDistance(DIS_BRACKETSPACE)); 1004*cdf0e10cSrcweir Categories[5]->SetValue(3, rFormat.GetDistance(DIS_NORMALBRACKETSIZE)); 1005*cdf0e10cSrcweir Categories[6]->SetValue(0, rFormat.GetDistance(DIS_MATRIXROW)); 1006*cdf0e10cSrcweir Categories[6]->SetValue(1, rFormat.GetDistance(DIS_MATRIXCOL)); 1007*cdf0e10cSrcweir Categories[7]->SetValue(0, rFormat.GetDistance(DIS_ORNAMENTSIZE)); 1008*cdf0e10cSrcweir Categories[7]->SetValue(1, rFormat.GetDistance(DIS_ORNAMENTSPACE)); 1009*cdf0e10cSrcweir Categories[8]->SetValue(0, rFormat.GetDistance(DIS_OPERATORSIZE)); 1010*cdf0e10cSrcweir Categories[8]->SetValue(1, rFormat.GetDistance(DIS_OPERATORSPACE)); 1011*cdf0e10cSrcweir Categories[9]->SetValue(0, rFormat.GetDistance(DIS_LEFTSPACE)); 1012*cdf0e10cSrcweir Categories[9]->SetValue(1, rFormat.GetDistance(DIS_RIGHTSPACE)); 1013*cdf0e10cSrcweir Categories[9]->SetValue(2, rFormat.GetDistance(DIS_TOPSPACE)); 1014*cdf0e10cSrcweir Categories[9]->SetValue(3, rFormat.GetDistance(DIS_BOTTOMSPACE)); 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir bScaleAllBrackets = rFormat.IsScaleNormalBrackets(); 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir // force update (even of category 0) by setting nActiveCategory to a 1019*cdf0e10cSrcweir // non-existent category number 1020*cdf0e10cSrcweir nActiveCategory = CATEGORY_NONE; 1021*cdf0e10cSrcweir SetCategory(0); 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir 1025*cdf0e10cSrcweir void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/ 1026*cdf0e10cSrcweir { 1027*cdf0e10cSrcweir // hmm... koennen die tatsaechlich unterschiedlich sein? 1028*cdf0e10cSrcweir // wenn nicht kann oben naemlich das const stehen! 1029*cdf0e10cSrcweir SetCategory(nActiveCategory); 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir rFormat.SetDistance( DIS_HORIZONTAL, Categories[0]->GetValue(0) ); 1032*cdf0e10cSrcweir rFormat.SetDistance( DIS_VERTICAL, Categories[0]->GetValue(1) ); 1033*cdf0e10cSrcweir rFormat.SetDistance( DIS_ROOT, Categories[0]->GetValue(2) ); 1034*cdf0e10cSrcweir rFormat.SetDistance( DIS_SUPERSCRIPT, Categories[1]->GetValue(0) ); 1035*cdf0e10cSrcweir rFormat.SetDistance( DIS_SUBSCRIPT, Categories[1]->GetValue(1) ); 1036*cdf0e10cSrcweir rFormat.SetDistance( DIS_NUMERATOR, Categories[2]->GetValue(0) ); 1037*cdf0e10cSrcweir rFormat.SetDistance( DIS_DENOMINATOR, Categories[2]->GetValue(1) ); 1038*cdf0e10cSrcweir rFormat.SetDistance( DIS_FRACTION, Categories[3]->GetValue(0) ); 1039*cdf0e10cSrcweir rFormat.SetDistance( DIS_STROKEWIDTH, Categories[3]->GetValue(1) ); 1040*cdf0e10cSrcweir rFormat.SetDistance( DIS_UPPERLIMIT, Categories[4]->GetValue(0) ); 1041*cdf0e10cSrcweir rFormat.SetDistance( DIS_LOWERLIMIT, Categories[4]->GetValue(1) ); 1042*cdf0e10cSrcweir rFormat.SetDistance( DIS_BRACKETSIZE, Categories[5]->GetValue(0) ); 1043*cdf0e10cSrcweir rFormat.SetDistance( DIS_BRACKETSPACE, Categories[5]->GetValue(1) ); 1044*cdf0e10cSrcweir rFormat.SetDistance( DIS_MATRIXROW, Categories[6]->GetValue(0) ); 1045*cdf0e10cSrcweir rFormat.SetDistance( DIS_MATRIXCOL, Categories[6]->GetValue(1) ); 1046*cdf0e10cSrcweir rFormat.SetDistance( DIS_ORNAMENTSIZE, Categories[7]->GetValue(0) ); 1047*cdf0e10cSrcweir rFormat.SetDistance( DIS_ORNAMENTSPACE, Categories[7]->GetValue(1) ); 1048*cdf0e10cSrcweir rFormat.SetDistance( DIS_OPERATORSIZE, Categories[8]->GetValue(0) ); 1049*cdf0e10cSrcweir rFormat.SetDistance( DIS_OPERATORSPACE, Categories[8]->GetValue(1) ); 1050*cdf0e10cSrcweir rFormat.SetDistance( DIS_LEFTSPACE, Categories[9]->GetValue(0) ); 1051*cdf0e10cSrcweir rFormat.SetDistance( DIS_RIGHTSPACE, Categories[9]->GetValue(1) ); 1052*cdf0e10cSrcweir rFormat.SetDistance( DIS_TOPSPACE, Categories[9]->GetValue(2) ); 1053*cdf0e10cSrcweir rFormat.SetDistance( DIS_BOTTOMSPACE, Categories[9]->GetValue(3) ); 1054*cdf0e10cSrcweir rFormat.SetDistance( DIS_NORMALBRACKETSIZE, Categories[5]->GetValue(3) ); 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir rFormat.SetScaleNormalBrackets( bScaleAllBrackets ); 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir rFormat.RequestApplyChanges(); 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir /**************************************************************************/ 1063*cdf0e10cSrcweir 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir if (pQueryBox->Execute() == RET_YES) 1070*cdf0e10cSrcweir { 1071*cdf0e10cSrcweir SmModule *pp = SM_MOD(); 1072*cdf0e10cSrcweir SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); 1073*cdf0e10cSrcweir WriteTo( aFmt ); 1074*cdf0e10cSrcweir pp->GetConfig()->SetStandardFormat( aFmt ); 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir 1077*cdf0e10cSrcweir delete pQueryBox; 1078*cdf0e10cSrcweir return 0; 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir SmAlignDialog::SmAlignDialog(Window * pParent, sal_Bool bFreeRes) 1083*cdf0e10cSrcweir : ModalDialog(pParent, SmResId(RID_ALIGNDIALOG)), 1084*cdf0e10cSrcweir aLeft (this, SmResId(1)), 1085*cdf0e10cSrcweir aCenter (this, SmResId(2)), 1086*cdf0e10cSrcweir aRight (this, SmResId(3)), 1087*cdf0e10cSrcweir aFixedLine1 (this, SmResId(1)), 1088*cdf0e10cSrcweir aOKButton1 (this, SmResId(1)), 1089*cdf0e10cSrcweir aCancelButton1 (this, SmResId(1)), 1090*cdf0e10cSrcweir aDefaultButton (this, SmResId(1)) 1091*cdf0e10cSrcweir { 1092*cdf0e10cSrcweir if (bFreeRes) 1093*cdf0e10cSrcweir FreeResource(); 1094*cdf0e10cSrcweir 1095*cdf0e10cSrcweir aDefaultButton.SetClickHdl(LINK(this, SmAlignDialog, DefaultButtonClickHdl)); 1096*cdf0e10cSrcweir } 1097*cdf0e10cSrcweir 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir void SmAlignDialog::ReadFrom(const SmFormat &rFormat) 1100*cdf0e10cSrcweir { 1101*cdf0e10cSrcweir switch (rFormat.GetHorAlign()) 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir case AlignLeft: 1104*cdf0e10cSrcweir aLeft .Check(sal_True); 1105*cdf0e10cSrcweir aCenter.Check(sal_False); 1106*cdf0e10cSrcweir aRight .Check(sal_False); 1107*cdf0e10cSrcweir break; 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir case AlignCenter: 1110*cdf0e10cSrcweir aLeft .Check(sal_False); 1111*cdf0e10cSrcweir aCenter.Check(sal_True); 1112*cdf0e10cSrcweir aRight .Check(sal_False); 1113*cdf0e10cSrcweir break; 1114*cdf0e10cSrcweir 1115*cdf0e10cSrcweir case AlignRight: 1116*cdf0e10cSrcweir aLeft .Check(sal_False); 1117*cdf0e10cSrcweir aCenter.Check(sal_False); 1118*cdf0e10cSrcweir aRight .Check(sal_True); 1119*cdf0e10cSrcweir break; 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir } 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir void SmAlignDialog::WriteTo(SmFormat &rFormat) const 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir if (aLeft.IsChecked()) 1127*cdf0e10cSrcweir rFormat.SetHorAlign(AlignLeft); 1128*cdf0e10cSrcweir else if (aRight.IsChecked()) 1129*cdf0e10cSrcweir rFormat.SetHorAlign(AlignRight); 1130*cdf0e10cSrcweir else 1131*cdf0e10cSrcweir rFormat.SetHorAlign(AlignCenter); 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir rFormat.RequestApplyChanges(); 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir /**************************************************************************/ 1138*cdf0e10cSrcweir 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir void SmShowSymbolSet::Paint(const Rectangle&) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir Push(PUSH_MAPMODE); 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir // MapUnit einstellen fuer die 'nLen' berechnet wurde 1145*cdf0e10cSrcweir SetMapMode(MapMode(MAP_PIXEL)); 1146*cdf0e10cSrcweir 1147*cdf0e10cSrcweir sal_uInt16 v = sal::static_int_cast< sal_uInt16 >((aVScrollBar.GetThumbPos() * nColumns)); 1148*cdf0e10cSrcweir size_t nSymbols = aSymbolSet.size(); 1149*cdf0e10cSrcweir 1150*cdf0e10cSrcweir Color aTxtColor( GetTextColor() ); 1151*cdf0e10cSrcweir for (sal_uInt16 i = v; i < nSymbols ; i++) 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir SmSym aSymbol (*aSymbolSet[i]); 1154*cdf0e10cSrcweir Font aFont (aSymbol.GetFace()); 1155*cdf0e10cSrcweir aFont.SetAlign(ALIGN_TOP); 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir // etwas kleinere FontSize nehmen (als nLen) um etwas Luft zu haben 1158*cdf0e10cSrcweir // (hoffentlich auch genug fuer links und rechts!) 1159*cdf0e10cSrcweir aFont.SetSize(Size(0, nLen - (nLen / 3))); 1160*cdf0e10cSrcweir SetFont(aFont); 1161*cdf0e10cSrcweir // keep text color 1162*cdf0e10cSrcweir SetTextColor( aTxtColor ); 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir int nIV = i - v; 1165*cdf0e10cSrcweir sal_UCS4 cChar = aSymbol.GetCharacter(); 1166*cdf0e10cSrcweir String aText( OUString( &cChar, 1 ) ); 1167*cdf0e10cSrcweir Size aSize( GetTextWidth( aText ), GetTextHeight()); 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir DrawText(Point((nIV % nColumns) * nLen + (nLen - aSize.Width()) / 2, 1170*cdf0e10cSrcweir (nIV / nColumns) * nLen + (nLen - aSize.Height()) / 2), 1171*cdf0e10cSrcweir aText); 1172*cdf0e10cSrcweir } 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir if (nSelectSymbol != SYMBOL_NONE) 1175*cdf0e10cSrcweir { 1176*cdf0e10cSrcweir Invert(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen, 1177*cdf0e10cSrcweir ((nSelectSymbol - v) / nColumns) * nLen), 1178*cdf0e10cSrcweir Size(nLen, nLen))); 1179*cdf0e10cSrcweir } 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir Pop(); 1182*cdf0e10cSrcweir } 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir void SmShowSymbolSet::MouseButtonDown(const MouseEvent& rMEvt) 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir GrabFocus(); 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir if (rMEvt.IsLeft() && Rectangle(Point(0, 0), aOutputSize).IsInside(rMEvt.GetPosPixel())) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir long nPos = (rMEvt.GetPosPixel().Y() / nLen) * nColumns + (rMEvt.GetPosPixel().X() / nLen) + 1192*cdf0e10cSrcweir aVScrollBar.GetThumbPos() * nColumns; 1193*cdf0e10cSrcweir SelectSymbol( sal::static_int_cast< sal_uInt16 >(nPos) ); 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir aSelectHdlLink.Call(this); 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir if (rMEvt.GetClicks() > 1) aDblClickHdlLink.Call(this); 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir else Control::MouseButtonDown (rMEvt); 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir void SmShowSymbolSet::KeyInput(const KeyEvent& rKEvt) 1204*cdf0e10cSrcweir { 1205*cdf0e10cSrcweir sal_uInt16 n = nSelectSymbol; 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir if (n != SYMBOL_NONE) 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir switch (rKEvt.GetKeyCode().GetCode()) 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir case KEY_DOWN: n = n + nColumns; break; 1212*cdf0e10cSrcweir case KEY_UP: n = n - nColumns; break; 1213*cdf0e10cSrcweir case KEY_LEFT: n -= 1; break; 1214*cdf0e10cSrcweir case KEY_RIGHT: n += 1; break; 1215*cdf0e10cSrcweir case KEY_HOME: n = 0; break; 1216*cdf0e10cSrcweir case KEY_END: n = static_cast< sal_uInt16 >(aSymbolSet.size() - 1); break; 1217*cdf0e10cSrcweir case KEY_PAGEUP: n -= nColumns * nRows; break; 1218*cdf0e10cSrcweir case KEY_PAGEDOWN: n += nColumns * nRows; break; 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir default: 1221*cdf0e10cSrcweir Control::KeyInput(rKEvt); 1222*cdf0e10cSrcweir return; 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir else 1226*cdf0e10cSrcweir n = 0; 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir if (n >= aSymbolSet.size()) 1229*cdf0e10cSrcweir n = nSelectSymbol; 1230*cdf0e10cSrcweir 1231*cdf0e10cSrcweir // adjust scrollbar 1232*cdf0e10cSrcweir if ((n < (sal_uInt16) (aVScrollBar.GetThumbPos() * nColumns)) || 1233*cdf0e10cSrcweir (n >= (sal_uInt16) ((aVScrollBar.GetThumbPos() + nRows) * nColumns))) 1234*cdf0e10cSrcweir { 1235*cdf0e10cSrcweir aVScrollBar.SetThumbPos(n / nColumns); 1236*cdf0e10cSrcweir Invalidate(); 1237*cdf0e10cSrcweir Update(); 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir 1240*cdf0e10cSrcweir SelectSymbol(n); 1241*cdf0e10cSrcweir aSelectHdlLink.Call(this); 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir SmShowSymbolSet::SmShowSymbolSet(Window *pParent, const ResId& rResId) : 1246*cdf0e10cSrcweir Control(pParent, rResId), 1247*cdf0e10cSrcweir aVScrollBar(this, WinBits(WB_VSCROLL)) 1248*cdf0e10cSrcweir { 1249*cdf0e10cSrcweir nSelectSymbol = SYMBOL_NONE; 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir aOutputSize = GetOutputSizePixel(); 1252*cdf0e10cSrcweir long nScrollBarWidth = aVScrollBar.GetSizePixel().Width(), 1253*cdf0e10cSrcweir nUseableWidth = aOutputSize.Width() - nScrollBarWidth; 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir // Hoehe von 16pt in Pixeln (passend zu 'aOutputSize') 1256*cdf0e10cSrcweir nLen = (sal_uInt16) LogicToPixel(Size(0, 16), MapMode(MAP_POINT)).Height(); 1257*cdf0e10cSrcweir 1258*cdf0e10cSrcweir nColumns = sal::static_int_cast< sal_uInt16 >(nUseableWidth / nLen); 1259*cdf0e10cSrcweir if (nColumns > 2 && nColumns % 2 != 0) 1260*cdf0e10cSrcweir nColumns--; 1261*cdf0e10cSrcweir nRows = sal::static_int_cast< sal_uInt16 >(aOutputSize.Height() / nLen); 1262*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1263*cdf0e10cSrcweir DBG_ASSERT(nColumns > 0, "Sm : keine Spalten"); 1264*cdf0e10cSrcweir DBG_ASSERT(nRows > 0, "Sm : keine Zeilen"); 1265*cdf0e10cSrcweir #endif 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir // genau passend machen 1268*cdf0e10cSrcweir aOutputSize.Width() = nColumns * nLen; 1269*cdf0e10cSrcweir aOutputSize.Height() = nRows * nLen; 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir aVScrollBar.SetPosSizePixel(Point(aOutputSize.Width() + 1, -1), 1272*cdf0e10cSrcweir Size(nScrollBarWidth, aOutputSize.Height() + 2)); 1273*cdf0e10cSrcweir aVScrollBar.Enable(sal_False); 1274*cdf0e10cSrcweir aVScrollBar.Show(); 1275*cdf0e10cSrcweir aVScrollBar.SetScrollHdl(LINK(this, SmShowSymbolSet, ScrollHdl)); 1276*cdf0e10cSrcweir 1277*cdf0e10cSrcweir Size WindowSize (aOutputSize); 1278*cdf0e10cSrcweir WindowSize.Width() += nScrollBarWidth; 1279*cdf0e10cSrcweir SetOutputSizePixel(WindowSize); 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir } 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir void SmShowSymbolSet::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) 1285*cdf0e10cSrcweir { 1286*cdf0e10cSrcweir aSymbolSet = rSymbolSet; 1287*cdf0e10cSrcweir 1288*cdf0e10cSrcweir if (static_cast< sal_uInt16 >(aSymbolSet.size()) > (nColumns * nRows)) 1289*cdf0e10cSrcweir { 1290*cdf0e10cSrcweir aVScrollBar.SetRange(Range(0, ((aSymbolSet.size() + (nColumns - 1)) / nColumns) - nRows)); 1291*cdf0e10cSrcweir aVScrollBar.Enable(sal_True); 1292*cdf0e10cSrcweir } 1293*cdf0e10cSrcweir else 1294*cdf0e10cSrcweir { 1295*cdf0e10cSrcweir aVScrollBar.SetRange(Range(0,0)); 1296*cdf0e10cSrcweir aVScrollBar.Enable (sal_False); 1297*cdf0e10cSrcweir } 1298*cdf0e10cSrcweir 1299*cdf0e10cSrcweir Invalidate(); 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir void SmShowSymbolSet::SelectSymbol(sal_uInt16 nSymbol) 1304*cdf0e10cSrcweir { 1305*cdf0e10cSrcweir int v = (int) (aVScrollBar.GetThumbPos() * nColumns); 1306*cdf0e10cSrcweir 1307*cdf0e10cSrcweir if (nSelectSymbol != SYMBOL_NONE) 1308*cdf0e10cSrcweir Invalidate(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen, 1309*cdf0e10cSrcweir ((nSelectSymbol - v) / nColumns) * nLen), 1310*cdf0e10cSrcweir Size(nLen, nLen))); 1311*cdf0e10cSrcweir 1312*cdf0e10cSrcweir if (nSymbol < aSymbolSet.size()) 1313*cdf0e10cSrcweir nSelectSymbol = nSymbol; 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir if (aSymbolSet.size() == 0) 1316*cdf0e10cSrcweir nSelectSymbol = SYMBOL_NONE; 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir if (nSelectSymbol != SYMBOL_NONE) 1319*cdf0e10cSrcweir Invalidate(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen, 1320*cdf0e10cSrcweir ((nSelectSymbol - v) / nColumns) * nLen), 1321*cdf0e10cSrcweir Size(nLen, nLen))); 1322*cdf0e10cSrcweir 1323*cdf0e10cSrcweir Update(); 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir 1327*cdf0e10cSrcweir IMPL_LINK( SmShowSymbolSet, ScrollHdl, ScrollBar*, EMPTYARG /*pScrollBar*/) 1328*cdf0e10cSrcweir { 1329*cdf0e10cSrcweir Invalidate(); 1330*cdf0e10cSrcweir return 0; 1331*cdf0e10cSrcweir } 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir void SmShowSymbol::Paint(const Rectangle &rRect) 1336*cdf0e10cSrcweir { 1337*cdf0e10cSrcweir Control::Paint( rRect ); 1338*cdf0e10cSrcweir 1339*cdf0e10cSrcweir const XubString &rText = GetText(); 1340*cdf0e10cSrcweir Size aTextSize(GetTextWidth(rText), GetTextHeight()); 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2, 1343*cdf0e10cSrcweir (GetOutputSize().Height() * 7/10)), rText); 1344*cdf0e10cSrcweir } 1345*cdf0e10cSrcweir 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt) 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir if (rMEvt.GetClicks() > 1) 1350*cdf0e10cSrcweir aDblClickHdlLink.Call(this); 1351*cdf0e10cSrcweir else 1352*cdf0e10cSrcweir Control::MouseButtonDown (rMEvt); 1353*cdf0e10cSrcweir } 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir 1356*cdf0e10cSrcweir void SmShowSymbol::SetSymbol(const SmSym *pSymbol) 1357*cdf0e10cSrcweir { 1358*cdf0e10cSrcweir if (pSymbol) 1359*cdf0e10cSrcweir { 1360*cdf0e10cSrcweir Font aFont (pSymbol->GetFace()); 1361*cdf0e10cSrcweir aFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3)); 1362*cdf0e10cSrcweir aFont.SetAlign(ALIGN_BASELINE); 1363*cdf0e10cSrcweir SetFont(aFont); 1364*cdf0e10cSrcweir 1365*cdf0e10cSrcweir sal_UCS4 cChar = pSymbol->GetCharacter(); 1366*cdf0e10cSrcweir String aText( OUString( &cChar, 1 ) ); 1367*cdf0e10cSrcweir SetText( aText ); 1368*cdf0e10cSrcweir } 1369*cdf0e10cSrcweir 1370*cdf0e10cSrcweir // 'Invalidate' fuellt den background mit der background-Farbe. 1371*cdf0e10cSrcweir // Falls der NULL pointer uebergeben wurde reicht dies also zum loeschen 1372*cdf0e10cSrcweir // der Anzeige 1373*cdf0e10cSrcweir Invalidate(); 1374*cdf0e10cSrcweir } 1375*cdf0e10cSrcweir 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 1378*cdf0e10cSrcweir 1379*cdf0e10cSrcweir void SmSymbolDialog::FillSymbolSets(sal_Bool bDeleteText) 1380*cdf0e10cSrcweir // fuellt die Eintraege der moeglichen 'SymbolsSet's im Dialog mit den 1381*cdf0e10cSrcweir // aktuellen Werten des SymbolSet Managers, selektiert aber keinen. 1382*cdf0e10cSrcweir { 1383*cdf0e10cSrcweir aSymbolSets.Clear(); 1384*cdf0e10cSrcweir if (bDeleteText) 1385*cdf0e10cSrcweir aSymbolSets.SetNoSelection(); 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir std::set< String > aSybolSetNames( rSymbolMgr.GetSymbolSetNames() ); 1388*cdf0e10cSrcweir std::set< String >::const_iterator aIt( aSybolSetNames.begin() ); 1389*cdf0e10cSrcweir for ( ; aIt != aSybolSetNames.end(); ++aIt) 1390*cdf0e10cSrcweir aSymbolSets.InsertEntry( *aIt ); 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir 1393*cdf0e10cSrcweir 1394*cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, SymbolSetChangeHdl, ListBox *, EMPTYARG pListBox ) 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir (void) pListBox; 1397*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1398*cdf0e10cSrcweir DBG_ASSERT(pListBox == &aSymbolSets, "Sm : falsches Argument"); 1399*cdf0e10cSrcweir #endif 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir SelectSymbolSet(aSymbolSets.GetSelectEntry()); 1402*cdf0e10cSrcweir return 0; 1403*cdf0e10cSrcweir } 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir 1406*cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, SymbolChangeHdl, SmShowSymbolSet *, EMPTYARG pShowSymbolSet ) 1407*cdf0e10cSrcweir { 1408*cdf0e10cSrcweir (void) pShowSymbolSet; 1409*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1410*cdf0e10cSrcweir DBG_ASSERT(pShowSymbolSet == &aSymbolSetDisplay, "Sm : falsches Argument"); 1411*cdf0e10cSrcweir #endif 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir SelectSymbol(aSymbolSetDisplay.GetSelectSymbol()); 1414*cdf0e10cSrcweir return 0; 1415*cdf0e10cSrcweir } 1416*cdf0e10cSrcweir 1417*cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, EditClickHdl, Button *, EMPTYARG pButton ) 1418*cdf0e10cSrcweir { 1419*cdf0e10cSrcweir (void) pButton; 1420*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1421*cdf0e10cSrcweir DBG_ASSERT(pButton == &aEditBtn, "Sm : falsches Argument"); 1422*cdf0e10cSrcweir #endif 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir SmSymDefineDialog *pDialog = new SmSymDefineDialog(this, pFontListDev, rSymbolMgr); 1425*cdf0e10cSrcweir 1426*cdf0e10cSrcweir // aktuelles Symbol und SymbolSet am neuen Dialog setzen 1427*cdf0e10cSrcweir const XubString aSymSetName (aSymbolSets.GetSelectEntry()), 1428*cdf0e10cSrcweir aSymName (aSymbolName.GetText()); 1429*cdf0e10cSrcweir pDialog->SelectOldSymbolSet(aSymSetName); 1430*cdf0e10cSrcweir pDialog->SelectOldSymbol(aSymName); 1431*cdf0e10cSrcweir pDialog->SelectSymbolSet(aSymSetName); 1432*cdf0e10cSrcweir pDialog->SelectSymbol(aSymName); 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir // altes SymbolSet merken 1435*cdf0e10cSrcweir XubString aOldSymbolSet (aSymbolSets.GetSelectEntry()); 1436*cdf0e10cSrcweir 1437*cdf0e10cSrcweir sal_uInt16 nSymPos = GetSelectedSymbol(); 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir // Dialog an evtl geaenderte Daten des SymbolSet Manager anpassen 1440*cdf0e10cSrcweir if (pDialog->Execute() == RET_OK && rSymbolMgr.IsModified()) 1441*cdf0e10cSrcweir { 1442*cdf0e10cSrcweir rSymbolMgr.Save(); 1443*cdf0e10cSrcweir FillSymbolSets(); 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir // wenn das alte SymbolSet nicht mehr existiert zum ersten gehen 1447*cdf0e10cSrcweir // (soweit eines vorhanden ist) 1448*cdf0e10cSrcweir if (!SelectSymbolSet(aOldSymbolSet) && aSymbolSets.GetEntryCount() > 0) 1449*cdf0e10cSrcweir SelectSymbolSet(aSymbolSets.GetEntry(0)); 1450*cdf0e10cSrcweir else 1451*cdf0e10cSrcweir { 1452*cdf0e10cSrcweir // just update display of current symbol set 1453*cdf0e10cSrcweir DBG_ASSERT( aSymSetName == aSymSetName, "unexpected change in symbol set name" ); 1454*cdf0e10cSrcweir aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName ); 1455*cdf0e10cSrcweir aSymbolSetDisplay.SetSymbolSet( aSymbolSet ); 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir if (nSymPos >= aSymbolSet.size()) 1459*cdf0e10cSrcweir nSymPos = static_cast< sal_uInt16 >(aSymbolSet.size()) - 1; 1460*cdf0e10cSrcweir SelectSymbol( nSymPos ); 1461*cdf0e10cSrcweir 1462*cdf0e10cSrcweir delete pDialog; 1463*cdf0e10cSrcweir return 0; 1464*cdf0e10cSrcweir } 1465*cdf0e10cSrcweir 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, SymbolDblClickHdl, SmShowSymbolSet *, EMPTYARG pShowSymbolSet ) 1468*cdf0e10cSrcweir { 1469*cdf0e10cSrcweir (void) pShowSymbolSet; 1470*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1471*cdf0e10cSrcweir DBG_ASSERT(pShowSymbolSet == &aSymbolSetDisplay, "Sm : falsches Argument"); 1472*cdf0e10cSrcweir #endif 1473*cdf0e10cSrcweir 1474*cdf0e10cSrcweir GetClickHdl(&aGetBtn); 1475*cdf0e10cSrcweir EndDialog(RET_OK); 1476*cdf0e10cSrcweir return 0; 1477*cdf0e10cSrcweir } 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir 1480*cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton ) 1481*cdf0e10cSrcweir { 1482*cdf0e10cSrcweir (void) pButton; 1483*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1484*cdf0e10cSrcweir DBG_ASSERT(pButton == &aGetBtn, "Sm : falscher Button"); 1485*cdf0e10cSrcweir #endif 1486*cdf0e10cSrcweir 1487*cdf0e10cSrcweir const SmSym *pSym = GetSymbol(); 1488*cdf0e10cSrcweir if (pSym) 1489*cdf0e10cSrcweir { 1490*cdf0e10cSrcweir String aText ('%'); 1491*cdf0e10cSrcweir aText += pSym->GetName(); 1492*cdf0e10cSrcweir aText += (sal_Unicode)' '; 1493*cdf0e10cSrcweir 1494*cdf0e10cSrcweir rViewSh.GetViewFrame()->GetDispatcher()->Execute( 1495*cdf0e10cSrcweir SID_INSERTTEXT, SFX_CALLMODE_STANDARD, 1496*cdf0e10cSrcweir new SfxStringItem(SID_INSERTTEXT, aText), 0L); 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir 1499*cdf0e10cSrcweir return 0; 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmSymbolDialog, CloseClickHdl, Button *, EMPTYARG pButton ) 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir (void) pButton; 1506*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1507*cdf0e10cSrcweir DBG_ASSERT(pButton == &aCloseBtn, "Sm : falscher Button"); 1508*cdf0e10cSrcweir #endif 1509*cdf0e10cSrcweir 1510*cdf0e10cSrcweir EndDialog(sal_True); 1511*cdf0e10cSrcweir return 0; 1512*cdf0e10cSrcweir } 1513*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SmSymbolDialog, CloseClickHdl, Button *, pButton ) 1514*cdf0e10cSrcweir 1515*cdf0e10cSrcweir 1516*cdf0e10cSrcweir SmSymbolDialog::SmSymbolDialog(Window *pParent, OutputDevice *pFntListDevice, 1517*cdf0e10cSrcweir SmSymbolManager &rMgr, SmViewShell &rViewShell, sal_Bool bFreeRes) : 1518*cdf0e10cSrcweir ModalDialog (pParent, SmResId(RID_SYMBOLDIALOG)), 1519*cdf0e10cSrcweir aSymbolSetText (this, SmResId(1)), 1520*cdf0e10cSrcweir aSymbolSets (this, SmResId(1)), 1521*cdf0e10cSrcweir aSymbolSetDisplay (this, SmResId(1)), 1522*cdf0e10cSrcweir aSymbolName (this, SmResId(2)), 1523*cdf0e10cSrcweir aSymbolDisplay (this, SmResId(2)), 1524*cdf0e10cSrcweir aGetBtn (this, SmResId(2)), 1525*cdf0e10cSrcweir aCloseBtn (this, SmResId(3)), 1526*cdf0e10cSrcweir aEditBtn (this, SmResId(1)), 1527*cdf0e10cSrcweir rViewSh (rViewShell), 1528*cdf0e10cSrcweir rSymbolMgr (rMgr), 1529*cdf0e10cSrcweir pFontListDev (pFntListDevice) 1530*cdf0e10cSrcweir { 1531*cdf0e10cSrcweir if (bFreeRes) 1532*cdf0e10cSrcweir FreeResource(); 1533*cdf0e10cSrcweir 1534*cdf0e10cSrcweir aSymbolSetName = String(); 1535*cdf0e10cSrcweir aSymbolSet.clear(); 1536*cdf0e10cSrcweir FillSymbolSets(); 1537*cdf0e10cSrcweir if (aSymbolSets.GetEntryCount() > 0) 1538*cdf0e10cSrcweir SelectSymbolSet(aSymbolSets.GetEntry(0)); 1539*cdf0e10cSrcweir 1540*cdf0e10cSrcweir InitColor_Impl(); 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir // preview like controls should have a 2D look 1543*cdf0e10cSrcweir aSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO ); 1544*cdf0e10cSrcweir 1545*cdf0e10cSrcweir aSymbolSets .SetSelectHdl (LINK(this, SmSymbolDialog, SymbolSetChangeHdl)); 1546*cdf0e10cSrcweir aSymbolSetDisplay.SetSelectHdl (LINK(this, SmSymbolDialog, SymbolChangeHdl)); 1547*cdf0e10cSrcweir aSymbolSetDisplay.SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl)); 1548*cdf0e10cSrcweir aSymbolDisplay .SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl)); 1549*cdf0e10cSrcweir aCloseBtn .SetClickHdl (LINK(this, SmSymbolDialog, CloseClickHdl)); 1550*cdf0e10cSrcweir aEditBtn .SetClickHdl (LINK(this, SmSymbolDialog, EditClickHdl)); 1551*cdf0e10cSrcweir aGetBtn .SetClickHdl (LINK(this, SmSymbolDialog, GetClickHdl)); 1552*cdf0e10cSrcweir } 1553*cdf0e10cSrcweir 1554*cdf0e10cSrcweir 1555*cdf0e10cSrcweir SmSymbolDialog::~SmSymbolDialog() 1556*cdf0e10cSrcweir { 1557*cdf0e10cSrcweir } 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir void SmSymbolDialog::InitColor_Impl() 1561*cdf0e10cSrcweir { 1562*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1563*cdf0e10cSrcweir Color aBC( GetDisplayBackground().GetColor() ); 1564*cdf0e10cSrcweir #endif 1565*cdf0e10cSrcweir ColorData nBgCol = COL_WHITE, 1566*cdf0e10cSrcweir nTxtCol = COL_BLACK; 1567*cdf0e10cSrcweir const StyleSettings &rS = GetSettings().GetStyleSettings(); 1568*cdf0e10cSrcweir if (rS.GetHighContrastMode()) 1569*cdf0e10cSrcweir { 1570*cdf0e10cSrcweir nBgCol = rS.GetFieldColor().GetColor(); 1571*cdf0e10cSrcweir nTxtCol = rS.GetFieldTextColor().GetColor(); 1572*cdf0e10cSrcweir } 1573*cdf0e10cSrcweir 1574*cdf0e10cSrcweir Color aTmpColor( nBgCol ); 1575*cdf0e10cSrcweir Wallpaper aWall( aTmpColor ); 1576*cdf0e10cSrcweir Color aTxtColor( nTxtCol ); 1577*cdf0e10cSrcweir aSymbolDisplay .SetBackground( aWall ); 1578*cdf0e10cSrcweir aSymbolDisplay .SetTextColor( aTxtColor ); 1579*cdf0e10cSrcweir aSymbolSetDisplay.SetBackground( aWall ); 1580*cdf0e10cSrcweir aSymbolSetDisplay.SetTextColor( aTxtColor ); 1581*cdf0e10cSrcweir } 1582*cdf0e10cSrcweir 1583*cdf0e10cSrcweir 1584*cdf0e10cSrcweir void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt ) 1585*cdf0e10cSrcweir { 1586*cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && 1587*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1588*cdf0e10cSrcweir InitColor_Impl(); 1589*cdf0e10cSrcweir 1590*cdf0e10cSrcweir ModalDialog::DataChanged( rDCEvt ); 1591*cdf0e10cSrcweir } 1592*cdf0e10cSrcweir 1593*cdf0e10cSrcweir 1594*cdf0e10cSrcweir sal_Bool SmSymbolDialog::SelectSymbolSet(const XubString &rSymbolSetName) 1595*cdf0e10cSrcweir { 1596*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1597*cdf0e10cSrcweir sal_uInt16 nPos = aSymbolSets.GetEntryPos(rSymbolSetName); 1598*cdf0e10cSrcweir 1599*cdf0e10cSrcweir aSymbolSetName = String(); 1600*cdf0e10cSrcweir aSymbolSet.clear(); 1601*cdf0e10cSrcweir if (nPos != LISTBOX_ENTRY_NOTFOUND) 1602*cdf0e10cSrcweir { 1603*cdf0e10cSrcweir aSymbolSets.SelectEntryPos(nPos); 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir aSymbolSetName = rSymbolSetName; 1606*cdf0e10cSrcweir aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName ); 1607*cdf0e10cSrcweir 1608*cdf0e10cSrcweir // sort symbols by Unicode position (useful for displaying Greek characters alphabetically) 1609*cdf0e10cSrcweir std::sort( aSymbolSet.begin(), aSymbolSet.end(), lt_SmSymPtr() ); 1610*cdf0e10cSrcweir 1611*cdf0e10cSrcweir aSymbolSetDisplay.SetSymbolSet( aSymbolSet ); 1612*cdf0e10cSrcweir if (aSymbolSet.size() > 0) 1613*cdf0e10cSrcweir SelectSymbol(0); 1614*cdf0e10cSrcweir 1615*cdf0e10cSrcweir bRet = sal_True; 1616*cdf0e10cSrcweir } 1617*cdf0e10cSrcweir else 1618*cdf0e10cSrcweir aSymbolSets.SetNoSelection(); 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir return bRet; 1621*cdf0e10cSrcweir } 1622*cdf0e10cSrcweir 1623*cdf0e10cSrcweir 1624*cdf0e10cSrcweir void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo) 1625*cdf0e10cSrcweir { 1626*cdf0e10cSrcweir const SmSym *pSym = NULL; 1627*cdf0e10cSrcweir if (aSymbolSetName.Len() > 0 && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size())) 1628*cdf0e10cSrcweir pSym = aSymbolSet[ nSymbolNo ]; 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir aSymbolSetDisplay.SelectSymbol(nSymbolNo); 1631*cdf0e10cSrcweir aSymbolDisplay.SetSymbol(pSym); 1632*cdf0e10cSrcweir aSymbolName.SetText(pSym ? pSym->GetName() : XubString()); 1633*cdf0e10cSrcweir } 1634*cdf0e10cSrcweir 1635*cdf0e10cSrcweir 1636*cdf0e10cSrcweir const SmSym * SmSymbolDialog::GetSymbol() const 1637*cdf0e10cSrcweir { 1638*cdf0e10cSrcweir sal_uInt16 nSymbolNo = aSymbolSetDisplay.GetSelectSymbol(); 1639*cdf0e10cSrcweir bool bValid = aSymbolSetName.Len() > 0 && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size()); 1640*cdf0e10cSrcweir return bValid ? aSymbolSet[ nSymbolNo ] : NULL; 1641*cdf0e10cSrcweir } 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir 1644*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir void SmShowChar::Paint(const Rectangle &rRect) 1648*cdf0e10cSrcweir { 1649*cdf0e10cSrcweir Control::Paint( rRect ); 1650*cdf0e10cSrcweir 1651*cdf0e10cSrcweir OUString aText( GetText() ); 1652*cdf0e10cSrcweir if (aText.getLength() > 0) 1653*cdf0e10cSrcweir { 1654*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1655*cdf0e10cSrcweir sal_Int32 nPos = 0; 1656*cdf0e10cSrcweir sal_UCS4 cChar = aText.iterateCodePoints( &nPos ); 1657*cdf0e10cSrcweir (void) cChar; 1658*cdf0e10cSrcweir #endif 1659*cdf0e10cSrcweir Size aTextSize(GetTextWidth(aText), GetTextHeight()); 1660*cdf0e10cSrcweir 1661*cdf0e10cSrcweir DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2, 1662*cdf0e10cSrcweir (GetOutputSize().Height() * 7/10)), aText); 1663*cdf0e10cSrcweir } 1664*cdf0e10cSrcweir } 1665*cdf0e10cSrcweir 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir void SmShowChar::SetSymbol( const SmSym *pSym ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir if (pSym) 1670*cdf0e10cSrcweir SetSymbol( pSym->GetCharacter(), pSym->GetFace() ); 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir void SmShowChar::SetSymbol( sal_UCS4 cChar, const Font &rFont ) 1675*cdf0e10cSrcweir { 1676*cdf0e10cSrcweir Font aFont( rFont ); 1677*cdf0e10cSrcweir aFont.SetSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3) ); 1678*cdf0e10cSrcweir aFont.SetAlign(ALIGN_BASELINE); 1679*cdf0e10cSrcweir SetFont(aFont); 1680*cdf0e10cSrcweir 1681*cdf0e10cSrcweir String aText( OUString( &cChar, 1) ); 1682*cdf0e10cSrcweir SetText( aText ); 1683*cdf0e10cSrcweir 1684*cdf0e10cSrcweir Invalidate(); 1685*cdf0e10cSrcweir } 1686*cdf0e10cSrcweir 1687*cdf0e10cSrcweir 1688*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 1689*cdf0e10cSrcweir 1690*cdf0e10cSrcweir void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, sal_Bool bDeleteText) 1691*cdf0e10cSrcweir { 1692*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1693*cdf0e10cSrcweir DBG_ASSERT(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols, 1694*cdf0e10cSrcweir "Sm : falsche ComboBox"); 1695*cdf0e10cSrcweir #endif 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir rComboBox.Clear(); 1698*cdf0e10cSrcweir if (bDeleteText) 1699*cdf0e10cSrcweir rComboBox.SetText(XubString()); 1700*cdf0e10cSrcweir 1701*cdf0e10cSrcweir ComboBox &rBox = &rComboBox == &aOldSymbols ? aOldSymbolSets : aSymbolSets; 1702*cdf0e10cSrcweir SymbolPtrVec_t aSymSet( aSymbolMgrCopy.GetSymbolSet( rBox.GetText() ) ); 1703*cdf0e10cSrcweir for (size_t i = 0; i < aSymSet.size(); ++i) 1704*cdf0e10cSrcweir rComboBox.InsertEntry( aSymSet[i]->GetName() ); 1705*cdf0e10cSrcweir } 1706*cdf0e10cSrcweir 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, sal_Bool bDeleteText) 1709*cdf0e10cSrcweir { 1710*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1711*cdf0e10cSrcweir DBG_ASSERT(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets, 1712*cdf0e10cSrcweir "Sm : falsche ComboBox"); 1713*cdf0e10cSrcweir #endif 1714*cdf0e10cSrcweir 1715*cdf0e10cSrcweir rComboBox.Clear(); 1716*cdf0e10cSrcweir if (bDeleteText) 1717*cdf0e10cSrcweir rComboBox.SetText(XubString()); 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir const std::set< String > aSymbolSetNames( aSymbolMgrCopy.GetSymbolSetNames() ); 1720*cdf0e10cSrcweir std::set< String >::const_iterator aIt( aSymbolSetNames.begin() ); 1721*cdf0e10cSrcweir for ( ; aIt != aSymbolSetNames.end(); ++aIt) 1722*cdf0e10cSrcweir rComboBox.InsertEntry( *aIt ); 1723*cdf0e10cSrcweir } 1724*cdf0e10cSrcweir 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir void SmSymDefineDialog::FillFonts(sal_Bool bDelete) 1727*cdf0e10cSrcweir { 1728*cdf0e10cSrcweir aFonts.Clear(); 1729*cdf0e10cSrcweir if (bDelete) 1730*cdf0e10cSrcweir aFonts.SetNoSelection(); 1731*cdf0e10cSrcweir 1732*cdf0e10cSrcweir // alle Fonts der 'FontList' in die Fontliste aufnehmen 1733*cdf0e10cSrcweir // von denen mit gleichen Namen jedoch nur einen (denn der Style wird 1734*cdf0e10cSrcweir // ueber die 'FontStyleBox' gewaehlt und nicht auch noch hier) 1735*cdf0e10cSrcweir if (pFontList) 1736*cdf0e10cSrcweir { 1737*cdf0e10cSrcweir sal_uInt16 nCount = pFontList->GetFontNameCount(); 1738*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount; i++) 1739*cdf0e10cSrcweir aFonts.InsertEntry( pFontList->GetFontName(i).GetName() ); 1740*cdf0e10cSrcweir } 1741*cdf0e10cSrcweir } 1742*cdf0e10cSrcweir 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir void SmSymDefineDialog::FillStyles(sal_Bool bDeleteText) 1745*cdf0e10cSrcweir { 1746*cdf0e10cSrcweir aStyles.Clear(); 1747*cdf0e10cSrcweir if (bDeleteText) 1748*cdf0e10cSrcweir aStyles.SetText(XubString()); 1749*cdf0e10cSrcweir 1750*cdf0e10cSrcweir XubString aText (aFonts.GetSelectEntry()); 1751*cdf0e10cSrcweir if (aText.Len() != 0) 1752*cdf0e10cSrcweir { 1753*cdf0e10cSrcweir //aStyles.Fill(aText, &aFontList); 1754*cdf0e10cSrcweir // eigene StyleName's verwenden 1755*cdf0e10cSrcweir const SmFontStyles &rStyles = GetFontStyles(); 1756*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < rStyles.GetCount(); i++) 1757*cdf0e10cSrcweir aStyles.InsertEntry( rStyles.GetStyleName(i) ); 1758*cdf0e10cSrcweir 1759*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1760*cdf0e10cSrcweir DBG_ASSERT(aStyles.GetEntryCount() > 0, "Sm : keine Styles vorhanden"); 1761*cdf0e10cSrcweir #endif 1762*cdf0e10cSrcweir aStyles.SetText( aStyles.GetEntry(0) ); 1763*cdf0e10cSrcweir } 1764*cdf0e10cSrcweir } 1765*cdf0e10cSrcweir 1766*cdf0e10cSrcweir 1767*cdf0e10cSrcweir SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox) 1768*cdf0e10cSrcweir { 1769*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1770*cdf0e10cSrcweir DBG_ASSERT(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols, 1771*cdf0e10cSrcweir "Sm : falsche ComboBox"); 1772*cdf0e10cSrcweir #endif 1773*cdf0e10cSrcweir return aSymbolMgrCopy.GetSymbolByName(rComboBox.GetText()); 1774*cdf0e10cSrcweir } 1775*cdf0e10cSrcweir 1776*cdf0e10cSrcweir 1777*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, OldSymbolChangeHdl, ComboBox *, EMPTYARG pComboBox ) 1778*cdf0e10cSrcweir { 1779*cdf0e10cSrcweir (void) pComboBox; 1780*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1781*cdf0e10cSrcweir DBG_ASSERT(pComboBox == &aOldSymbols, "Sm : falsches Argument"); 1782*cdf0e10cSrcweir #endif 1783*cdf0e10cSrcweir SelectSymbol(aOldSymbols, aOldSymbols.GetText(), sal_False); 1784*cdf0e10cSrcweir return 0; 1785*cdf0e10cSrcweir } 1786*cdf0e10cSrcweir 1787*cdf0e10cSrcweir 1788*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, OldSymbolSetChangeHdl, ComboBox *, EMPTYARG pComboBox ) 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir (void) pComboBox; 1791*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1792*cdf0e10cSrcweir DBG_ASSERT(pComboBox == &aOldSymbolSets, "Sm : falsches Argument"); 1793*cdf0e10cSrcweir #endif 1794*cdf0e10cSrcweir SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), sal_False); 1795*cdf0e10cSrcweir return 0; 1796*cdf0e10cSrcweir } 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir 1799*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, ModifyHdl, ComboBox *, pComboBox ) 1800*cdf0e10cSrcweir { 1801*cdf0e10cSrcweir // merken der Cursorposition zum wiederherstellen derselben 1802*cdf0e10cSrcweir Selection aSelection (pComboBox->GetSelection()); 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir if (pComboBox == &aSymbols) 1805*cdf0e10cSrcweir SelectSymbol(aSymbols, aSymbols.GetText(), sal_False); 1806*cdf0e10cSrcweir else if (pComboBox == &aSymbolSets) 1807*cdf0e10cSrcweir SelectSymbolSet(aSymbolSets, aSymbolSets.GetText(), sal_False); 1808*cdf0e10cSrcweir else if (pComboBox == &aOldSymbols) 1809*cdf0e10cSrcweir // nur Namen aus der Liste erlauben 1810*cdf0e10cSrcweir SelectSymbol(aOldSymbols, aOldSymbols.GetText(), sal_True); 1811*cdf0e10cSrcweir else if (pComboBox == &aOldSymbolSets) 1812*cdf0e10cSrcweir // nur Namen aus der Liste erlauben 1813*cdf0e10cSrcweir SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), sal_True); 1814*cdf0e10cSrcweir else if (pComboBox == &aStyles) 1815*cdf0e10cSrcweir // nur Namen aus der Liste erlauben (ist hier eh immer der Fall) 1816*cdf0e10cSrcweir SelectStyle(aStyles.GetText(), sal_True); 1817*cdf0e10cSrcweir else 1818*cdf0e10cSrcweir { 1819*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1820*cdf0e10cSrcweir DBG_ASSERT(0, "Sm : falsche ComboBox Argument"); 1821*cdf0e10cSrcweir #endif 1822*cdf0e10cSrcweir } 1823*cdf0e10cSrcweir 1824*cdf0e10cSrcweir pComboBox->SetSelection(aSelection); 1825*cdf0e10cSrcweir 1826*cdf0e10cSrcweir UpdateButtons(); 1827*cdf0e10cSrcweir 1828*cdf0e10cSrcweir return 0; 1829*cdf0e10cSrcweir } 1830*cdf0e10cSrcweir 1831*cdf0e10cSrcweir 1832*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, FontChangeHdl, ListBox *, EMPTYARG pListBox ) 1833*cdf0e10cSrcweir { 1834*cdf0e10cSrcweir (void) pListBox; 1835*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1836*cdf0e10cSrcweir DBG_ASSERT(pListBox == &aFonts, "Sm : falsches Argument"); 1837*cdf0e10cSrcweir #endif 1838*cdf0e10cSrcweir 1839*cdf0e10cSrcweir SelectFont(aFonts.GetSelectEntry()); 1840*cdf0e10cSrcweir return 0; 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir 1844*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, SubsetChangeHdl, ListBox *, EMPTYARG pListBox ) 1845*cdf0e10cSrcweir { 1846*cdf0e10cSrcweir (void) pListBox; 1847*cdf0e10cSrcweir sal_uInt16 nPos = aFontsSubsetLB.GetSelectEntryPos(); 1848*cdf0e10cSrcweir if (LISTBOX_ENTRY_NOTFOUND != nPos) 1849*cdf0e10cSrcweir { 1850*cdf0e10cSrcweir const Subset* pSubset = reinterpret_cast<const Subset*> (aFontsSubsetLB.GetEntryData( nPos )); 1851*cdf0e10cSrcweir if (pSubset) 1852*cdf0e10cSrcweir { 1853*cdf0e10cSrcweir aCharsetDisplay.SelectCharacter( pSubset->GetRangeMin() ); 1854*cdf0e10cSrcweir } 1855*cdf0e10cSrcweir } 1856*cdf0e10cSrcweir return 0; 1857*cdf0e10cSrcweir } 1858*cdf0e10cSrcweir 1859*cdf0e10cSrcweir 1860*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox ) 1861*cdf0e10cSrcweir { 1862*cdf0e10cSrcweir (void) pComboBox; 1863*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1864*cdf0e10cSrcweir DBG_ASSERT(pComboBox == &aStyles, "Sm : falsches Argument"); 1865*cdf0e10cSrcweir #endif 1866*cdf0e10cSrcweir 1867*cdf0e10cSrcweir SelectStyle(aStyles.GetText()); 1868*cdf0e10cSrcweir return 0; 1869*cdf0e10cSrcweir } 1870*cdf0e10cSrcweir 1871*cdf0e10cSrcweir 1872*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, CharHighlightHdl, Control *, EMPTYARG ) 1873*cdf0e10cSrcweir { 1874*cdf0e10cSrcweir sal_UCS4 cChar = aCharsetDisplay.GetSelectCharacter(); 1875*cdf0e10cSrcweir 1876*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1877*cdf0e10cSrcweir DBG_ASSERT( pSubsetMap, "SubsetMap missing" ); 1878*cdf0e10cSrcweir #endif 1879*cdf0e10cSrcweir if (pSubsetMap) 1880*cdf0e10cSrcweir { 1881*cdf0e10cSrcweir const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar ); 1882*cdf0e10cSrcweir if (pSubset) 1883*cdf0e10cSrcweir aFontsSubsetLB.SelectEntry( pSubset->GetName() ); 1884*cdf0e10cSrcweir else 1885*cdf0e10cSrcweir aFontsSubsetLB.SetNoSelection(); 1886*cdf0e10cSrcweir } 1887*cdf0e10cSrcweir 1888*cdf0e10cSrcweir aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() ); 1889*cdf0e10cSrcweir 1890*cdf0e10cSrcweir UpdateButtons(); 1891*cdf0e10cSrcweir 1892*cdf0e10cSrcweir // display Unicode position as symbol name while iterating over characters 1893*cdf0e10cSrcweir const String aHex( String::CreateFromInt64( cChar, 16 ).ToUpperAscii() ); 1894*cdf0e10cSrcweir const String aPattern( A2OU( aHex.Len() > 4 ? "Ux000000" : "Ux0000" ) ); 1895*cdf0e10cSrcweir String aUnicodePos( aPattern.Copy( 0, aPattern.Len() - aHex.Len() ) ); 1896*cdf0e10cSrcweir aUnicodePos += aHex; 1897*cdf0e10cSrcweir aSymbols.SetText( aUnicodePos ); 1898*cdf0e10cSrcweir aSymbolName.SetText( aUnicodePos ); 1899*cdf0e10cSrcweir 1900*cdf0e10cSrcweir return 0; 1901*cdf0e10cSrcweir } 1902*cdf0e10cSrcweir 1903*cdf0e10cSrcweir 1904*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton ) 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir (void) pButton; 1907*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1908*cdf0e10cSrcweir DBG_ASSERT(pButton == &aAddBtn, "Sm : falsches Argument"); 1909*cdf0e10cSrcweir DBG_ASSERT(aAddBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??"); 1910*cdf0e10cSrcweir #endif 1911*cdf0e10cSrcweir 1912*cdf0e10cSrcweir // add symbol 1913*cdf0e10cSrcweir const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(), 1914*cdf0e10cSrcweir aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() ); 1915*cdf0e10cSrcweir //DBG_ASSERT( aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL, "symbol already exists" ); 1916*cdf0e10cSrcweir aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol ); 1917*cdf0e10cSrcweir 1918*cdf0e10cSrcweir // update display of new symbol 1919*cdf0e10cSrcweir aSymbolDisplay.SetSymbol( &aNewSymbol ); 1920*cdf0e10cSrcweir aSymbolName.SetText( aNewSymbol.GetName() ); 1921*cdf0e10cSrcweir aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() ); 1922*cdf0e10cSrcweir 1923*cdf0e10cSrcweir // update list box entries 1924*cdf0e10cSrcweir FillSymbolSets(aOldSymbolSets, sal_False); 1925*cdf0e10cSrcweir FillSymbolSets(aSymbolSets, sal_False); 1926*cdf0e10cSrcweir FillSymbols(aOldSymbols ,sal_False); 1927*cdf0e10cSrcweir FillSymbols(aSymbols ,sal_False); 1928*cdf0e10cSrcweir 1929*cdf0e10cSrcweir UpdateButtons(); 1930*cdf0e10cSrcweir 1931*cdf0e10cSrcweir return 0; 1932*cdf0e10cSrcweir } 1933*cdf0e10cSrcweir 1934*cdf0e10cSrcweir 1935*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton ) 1936*cdf0e10cSrcweir { 1937*cdf0e10cSrcweir (void) pButton; 1938*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1939*cdf0e10cSrcweir DBG_ASSERT(pButton == &aChangeBtn, "Sm : falsches Argument"); 1940*cdf0e10cSrcweir DBG_ASSERT(aChangeBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??"); 1941*cdf0e10cSrcweir #endif 1942*cdf0e10cSrcweir 1943*cdf0e10cSrcweir // get new Sybol to use 1944*cdf0e10cSrcweir //! get font from symbol-disp lay since charset-display does not keep 1945*cdf0e10cSrcweir //! the bold attribut. 1946*cdf0e10cSrcweir const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(), 1947*cdf0e10cSrcweir aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() ); 1948*cdf0e10cSrcweir 1949*cdf0e10cSrcweir // remove old symbol if the name was changed then add new one 1950*cdf0e10cSrcweir // const bool bSetNameChanged = aOldSymbolSets.GetText() != aSymbolSets.GetText(); 1951*cdf0e10cSrcweir const bool bNameChanged = aOldSymbols.GetText() != aSymbols.GetText(); 1952*cdf0e10cSrcweir if (bNameChanged) 1953*cdf0e10cSrcweir aSymbolMgrCopy.RemoveSymbol( aOldSymbols.GetText() ); 1954*cdf0e10cSrcweir aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol, true ); 1955*cdf0e10cSrcweir 1956*cdf0e10cSrcweir // clear display for original symbol if necessary 1957*cdf0e10cSrcweir if (bNameChanged) 1958*cdf0e10cSrcweir SetOrigSymbol(NULL, XubString()); 1959*cdf0e10cSrcweir 1960*cdf0e10cSrcweir // update display of new symbol 1961*cdf0e10cSrcweir aSymbolDisplay.SetSymbol( &aNewSymbol ); 1962*cdf0e10cSrcweir aSymbolName.SetText( aNewSymbol.GetName() ); 1963*cdf0e10cSrcweir aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() ); 1964*cdf0e10cSrcweir 1965*cdf0e10cSrcweir // update list box entries 1966*cdf0e10cSrcweir FillSymbolSets(aOldSymbolSets, sal_False); 1967*cdf0e10cSrcweir FillSymbolSets(aSymbolSets, sal_False); 1968*cdf0e10cSrcweir FillSymbols(aOldSymbols ,sal_False); 1969*cdf0e10cSrcweir FillSymbols(aSymbols ,sal_False); 1970*cdf0e10cSrcweir 1971*cdf0e10cSrcweir UpdateButtons(); 1972*cdf0e10cSrcweir 1973*cdf0e10cSrcweir return 0; 1974*cdf0e10cSrcweir } 1975*cdf0e10cSrcweir 1976*cdf0e10cSrcweir 1977*cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, DeleteClickHdl, Button *, EMPTYARG pButton ) 1978*cdf0e10cSrcweir { 1979*cdf0e10cSrcweir (void) pButton; 1980*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1981*cdf0e10cSrcweir DBG_ASSERT(pButton == &aDeleteBtn, "Sm : falsches Argument"); 1982*cdf0e10cSrcweir DBG_ASSERT(aDeleteBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??"); 1983*cdf0e10cSrcweir #endif 1984*cdf0e10cSrcweir 1985*cdf0e10cSrcweir if (pOrigSymbol) 1986*cdf0e10cSrcweir { 1987*cdf0e10cSrcweir aSymbolMgrCopy.RemoveSymbol( pOrigSymbol->GetName() ); 1988*cdf0e10cSrcweir 1989*cdf0e10cSrcweir // clear display for original symbol 1990*cdf0e10cSrcweir SetOrigSymbol(NULL, XubString()); 1991*cdf0e10cSrcweir 1992*cdf0e10cSrcweir // update list box entries 1993*cdf0e10cSrcweir FillSymbolSets(aOldSymbolSets, sal_False); 1994*cdf0e10cSrcweir FillSymbolSets(aSymbolSets, sal_False); 1995*cdf0e10cSrcweir FillSymbols(aOldSymbols ,sal_False); 1996*cdf0e10cSrcweir FillSymbols(aSymbols ,sal_False); 1997*cdf0e10cSrcweir } 1998*cdf0e10cSrcweir 1999*cdf0e10cSrcweir UpdateButtons(); 2000*cdf0e10cSrcweir 2001*cdf0e10cSrcweir return 0; 2002*cdf0e10cSrcweir } 2003*cdf0e10cSrcweir 2004*cdf0e10cSrcweir 2005*cdf0e10cSrcweir void SmSymDefineDialog::UpdateButtons() 2006*cdf0e10cSrcweir { 2007*cdf0e10cSrcweir sal_Bool bAdd = sal_False, 2008*cdf0e10cSrcweir bChange = sal_False, 2009*cdf0e10cSrcweir bDelete = sal_False, 2010*cdf0e10cSrcweir bEqual; 2011*cdf0e10cSrcweir XubString aTmpSymbolName (aSymbols.GetText()), 2012*cdf0e10cSrcweir aTmpSymbolSetName (aSymbolSets.GetText()); 2013*cdf0e10cSrcweir 2014*cdf0e10cSrcweir if (aTmpSymbolName.Len() > 0 && aTmpSymbolSetName.Len() > 0) 2015*cdf0e10cSrcweir { 2016*cdf0e10cSrcweir // alle Einstellungen gleich? 2017*cdf0e10cSrcweir //! (Font-, Style- und SymbolSet Name werden nicht case sensitiv verglichen) 2018*cdf0e10cSrcweir bEqual = pOrigSymbol 2019*cdf0e10cSrcweir && aTmpSymbolSetName.EqualsIgnoreCaseAscii(aOldSymbolSetName.GetText()) 2020*cdf0e10cSrcweir && aTmpSymbolName.Equals(pOrigSymbol->GetName()) 2021*cdf0e10cSrcweir && aFonts.GetSelectEntry().EqualsIgnoreCaseAscii( 2022*cdf0e10cSrcweir pOrigSymbol->GetFace().GetName()) 2023*cdf0e10cSrcweir && aStyles.GetText().EqualsIgnoreCaseAscii( 2024*cdf0e10cSrcweir GetFontStyles().GetStyleName(pOrigSymbol->GetFace())) 2025*cdf0e10cSrcweir && aCharsetDisplay.GetSelectCharacter() == pOrigSymbol->GetCharacter(); 2026*cdf0e10cSrcweir 2027*cdf0e10cSrcweir // hinzufuegen nur wenn es noch kein Symbol desgleichen Namens gibt 2028*cdf0e10cSrcweir bAdd = aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL; 2029*cdf0e10cSrcweir 2030*cdf0e10cSrcweir // loeschen nur wenn alle Einstellungen gleich sind 2031*cdf0e10cSrcweir bDelete = pOrigSymbol != NULL; 2032*cdf0e10cSrcweir 2033*cdf0e10cSrcweir // aendern wenn bei gleichem Namen mindestens eine Einstellung anders ist 2034*cdf0e10cSrcweir // oder wenn es noch kein Symbol des neuen Namens gibt (wuerde implizites 2035*cdf0e10cSrcweir // loeschen des bereits vorhandenen Symbols erfordern) 2036*cdf0e10cSrcweir // sal_Bool bEqualName = pOrigSymbol && aTmpSymbolName == pOrigSymbol->GetName(); 2037*cdf0e10cSrcweir // bChange = pOrigSymbol && ( (bEqualName && !bEqual) || (!bEqualName && bAdd) ); 2038*cdf0e10cSrcweir 2039*cdf0e10cSrcweir // aendern nur falls altes Symbol vorhanden und am neuen etwas anders ist 2040*cdf0e10cSrcweir bChange = pOrigSymbol && !bEqual; 2041*cdf0e10cSrcweir } 2042*cdf0e10cSrcweir 2043*cdf0e10cSrcweir aAddBtn .Enable(bAdd); 2044*cdf0e10cSrcweir aChangeBtn.Enable(bChange); 2045*cdf0e10cSrcweir aDeleteBtn.Enable(bDelete); 2046*cdf0e10cSrcweir } 2047*cdf0e10cSrcweir 2048*cdf0e10cSrcweir 2049*cdf0e10cSrcweir SmSymDefineDialog::SmSymDefineDialog(Window * pParent, 2050*cdf0e10cSrcweir OutputDevice *pFntListDevice, SmSymbolManager &rMgr, sal_Bool bFreeRes) : 2051*cdf0e10cSrcweir ModalDialog (pParent, SmResId(RID_SYMDEFINEDIALOG)), 2052*cdf0e10cSrcweir aOldSymbolText (this, SmResId(1)), 2053*cdf0e10cSrcweir aOldSymbols (this, SmResId(1)), 2054*cdf0e10cSrcweir aOldSymbolSetText (this, SmResId(2)), 2055*cdf0e10cSrcweir aOldSymbolSets (this, SmResId(2)), 2056*cdf0e10cSrcweir aCharsetDisplay (this, SmResId(1)), 2057*cdf0e10cSrcweir aSymbolText (this, SmResId(9)), 2058*cdf0e10cSrcweir aSymbols (this, SmResId(4)), 2059*cdf0e10cSrcweir aSymbolSetText (this, SmResId(10)), 2060*cdf0e10cSrcweir aSymbolSets (this, SmResId(5)), 2061*cdf0e10cSrcweir aFontText (this, SmResId(3)), 2062*cdf0e10cSrcweir aFonts (this, SmResId(1)), 2063*cdf0e10cSrcweir aFontsSubsetFT (this, SmResId( FT_FONTS_SUBSET )), 2064*cdf0e10cSrcweir aFontsSubsetLB (this, SmResId( LB_FONTS_SUBSET )), 2065*cdf0e10cSrcweir aStyleText (this, SmResId(4)), 2066*cdf0e10cSrcweir aStyles (this, SmResId(3)), 2067*cdf0e10cSrcweir aOldSymbolName (this, SmResId(7)), 2068*cdf0e10cSrcweir aOldSymbolDisplay (this, SmResId(3)), 2069*cdf0e10cSrcweir aOldSymbolSetName (this, SmResId(8)), 2070*cdf0e10cSrcweir aSymbolName (this, SmResId(5)), 2071*cdf0e10cSrcweir aSymbolDisplay (this, SmResId(2)), 2072*cdf0e10cSrcweir aSymbolSetName (this, SmResId(6)), 2073*cdf0e10cSrcweir aOkBtn (this, SmResId(1)), 2074*cdf0e10cSrcweir aCancelBtn (this, SmResId(1)), 2075*cdf0e10cSrcweir aAddBtn (this, SmResId(1)), 2076*cdf0e10cSrcweir aChangeBtn (this, SmResId(2)), 2077*cdf0e10cSrcweir aDeleteBtn (this, SmResId(3)), 2078*cdf0e10cSrcweir aRightArrow (this, SmResId(1)), 2079*cdf0e10cSrcweir aRigthArrow_Im (SmResId(1)), 2080*cdf0e10cSrcweir aRigthArrow_Im_HC (SmResId(2)), // hi-contrast version 2081*cdf0e10cSrcweir rSymbolMgr (rMgr), 2082*cdf0e10cSrcweir pSubsetMap (NULL), 2083*cdf0e10cSrcweir pFontList (NULL) 2084*cdf0e10cSrcweir { 2085*cdf0e10cSrcweir if (bFreeRes) 2086*cdf0e10cSrcweir FreeResource(); 2087*cdf0e10cSrcweir 2088*cdf0e10cSrcweir pFontList = new FontList( pFntListDevice ); 2089*cdf0e10cSrcweir 2090*cdf0e10cSrcweir pOrigSymbol = 0; 2091*cdf0e10cSrcweir 2092*cdf0e10cSrcweir // auto completion is troublesome since that symbols character also gets automatically selected in the 2093*cdf0e10cSrcweir // display and if the user previously selected a character to define/redefine that one this is bad 2094*cdf0e10cSrcweir aOldSymbols.EnableAutocomplete( sal_False, sal_True ); 2095*cdf0e10cSrcweir aSymbols .EnableAutocomplete( sal_False, sal_True ); 2096*cdf0e10cSrcweir 2097*cdf0e10cSrcweir FillFonts(); 2098*cdf0e10cSrcweir if (aFonts.GetEntryCount() > 0) 2099*cdf0e10cSrcweir SelectFont(aFonts.GetEntry(0)); 2100*cdf0e10cSrcweir 2101*cdf0e10cSrcweir InitColor_Impl(); 2102*cdf0e10cSrcweir 2103*cdf0e10cSrcweir SetSymbolSetManager(rSymbolMgr); 2104*cdf0e10cSrcweir 2105*cdf0e10cSrcweir aOldSymbols .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolChangeHdl)); 2106*cdf0e10cSrcweir aOldSymbolSets .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolSetChangeHdl)); 2107*cdf0e10cSrcweir aSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl)); 2108*cdf0e10cSrcweir aOldSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl)); 2109*cdf0e10cSrcweir aSymbols .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl)); 2110*cdf0e10cSrcweir aOldSymbols .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl)); 2111*cdf0e10cSrcweir aStyles .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl)); 2112*cdf0e10cSrcweir aFonts .SetSelectHdl(LINK(this, SmSymDefineDialog, FontChangeHdl)); 2113*cdf0e10cSrcweir aFontsSubsetLB .SetSelectHdl(LINK(this, SmSymDefineDialog, SubsetChangeHdl)); 2114*cdf0e10cSrcweir aStyles .SetSelectHdl(LINK(this, SmSymDefineDialog, StyleChangeHdl)); 2115*cdf0e10cSrcweir aAddBtn .SetClickHdl (LINK(this, SmSymDefineDialog, AddClickHdl)); 2116*cdf0e10cSrcweir aChangeBtn .SetClickHdl (LINK(this, SmSymDefineDialog, ChangeClickHdl)); 2117*cdf0e10cSrcweir aDeleteBtn .SetClickHdl (LINK(this, SmSymDefineDialog, DeleteClickHdl)); 2118*cdf0e10cSrcweir aCharsetDisplay.SetHighlightHdl( LINK( this, SmSymDefineDialog, CharHighlightHdl ) ); 2119*cdf0e10cSrcweir 2120*cdf0e10cSrcweir // preview like controls should have a 2D look 2121*cdf0e10cSrcweir aOldSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO ); 2122*cdf0e10cSrcweir aSymbolDisplay .SetBorderStyle( WINDOW_BORDER_MONO ); 2123*cdf0e10cSrcweir } 2124*cdf0e10cSrcweir 2125*cdf0e10cSrcweir 2126*cdf0e10cSrcweir SmSymDefineDialog::~SmSymDefineDialog() 2127*cdf0e10cSrcweir { 2128*cdf0e10cSrcweir delete pSubsetMap; 2129*cdf0e10cSrcweir delete pOrigSymbol; 2130*cdf0e10cSrcweir } 2131*cdf0e10cSrcweir 2132*cdf0e10cSrcweir void SmSymDefineDialog::InitColor_Impl() 2133*cdf0e10cSrcweir { 2134*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 2135*cdf0e10cSrcweir Color aBC( GetDisplayBackground().GetColor() ); 2136*cdf0e10cSrcweir #endif 2137*cdf0e10cSrcweir ColorData nBgCol = COL_WHITE, 2138*cdf0e10cSrcweir nTxtCol = COL_BLACK; 2139*cdf0e10cSrcweir sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 2140*cdf0e10cSrcweir if (bHighContrast) 2141*cdf0e10cSrcweir { 2142*cdf0e10cSrcweir const StyleSettings &rS = GetSettings().GetStyleSettings(); 2143*cdf0e10cSrcweir nBgCol = rS.GetFieldColor().GetColor(); 2144*cdf0e10cSrcweir nTxtCol = rS.GetFieldTextColor().GetColor(); 2145*cdf0e10cSrcweir } 2146*cdf0e10cSrcweir 2147*cdf0e10cSrcweir Color aTmpColor( nBgCol ); 2148*cdf0e10cSrcweir Wallpaper aWall( aTmpColor ); 2149*cdf0e10cSrcweir Color aTxtColor( nTxtCol ); 2150*cdf0e10cSrcweir aCharsetDisplay .SetBackground( aWall ); 2151*cdf0e10cSrcweir aCharsetDisplay .SetTextColor( aTxtColor ); 2152*cdf0e10cSrcweir aOldSymbolDisplay.SetBackground( aWall ); 2153*cdf0e10cSrcweir aOldSymbolDisplay.SetTextColor( aTxtColor ); 2154*cdf0e10cSrcweir aSymbolDisplay .SetBackground( aWall ); 2155*cdf0e10cSrcweir aSymbolDisplay .SetTextColor( aTxtColor ); 2156*cdf0e10cSrcweir 2157*cdf0e10cSrcweir const Image &rArrowRight = bHighContrast ? aRigthArrow_Im_HC : aRigthArrow_Im; 2158*cdf0e10cSrcweir aRightArrow.SetImage( rArrowRight ); 2159*cdf0e10cSrcweir } 2160*cdf0e10cSrcweir 2161*cdf0e10cSrcweir 2162*cdf0e10cSrcweir void SmSymDefineDialog::DataChanged( const DataChangedEvent& rDCEvt ) 2163*cdf0e10cSrcweir { 2164*cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && 2165*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 2166*cdf0e10cSrcweir InitColor_Impl(); 2167*cdf0e10cSrcweir 2168*cdf0e10cSrcweir ModalDialog::DataChanged( rDCEvt ); 2169*cdf0e10cSrcweir } 2170*cdf0e10cSrcweir 2171*cdf0e10cSrcweir 2172*cdf0e10cSrcweir short SmSymDefineDialog::Execute() 2173*cdf0e10cSrcweir { 2174*cdf0e10cSrcweir short nResult = ModalDialog::Execute(); 2175*cdf0e10cSrcweir 2176*cdf0e10cSrcweir // Aenderungen uebernehmen falls Dialog mit OK beendet wurde 2177*cdf0e10cSrcweir if (aSymbolMgrCopy.IsModified() && nResult == RET_OK) 2178*cdf0e10cSrcweir rSymbolMgr = aSymbolMgrCopy; 2179*cdf0e10cSrcweir 2180*cdf0e10cSrcweir return nResult; 2181*cdf0e10cSrcweir } 2182*cdf0e10cSrcweir 2183*cdf0e10cSrcweir 2184*cdf0e10cSrcweir void SmSymDefineDialog::SetSymbolSetManager(const SmSymbolManager &rMgr) 2185*cdf0e10cSrcweir { 2186*cdf0e10cSrcweir aSymbolMgrCopy = rMgr; 2187*cdf0e10cSrcweir #ifdef DEBUG 2188*cdf0e10cSrcweir // sal_uInt16 nS = aSymbolMgrCopy.GetSymbolSetCount(); 2189*cdf0e10cSrcweir #endif 2190*cdf0e10cSrcweir 2191*cdf0e10cSrcweir // Das modified Flag der Kopie auf sal_False setzen, damit man spaeter damit 2192*cdf0e10cSrcweir // testen kann ob sich was geaendert hat. 2193*cdf0e10cSrcweir aSymbolMgrCopy.SetModified(sal_False); 2194*cdf0e10cSrcweir 2195*cdf0e10cSrcweir FillSymbolSets(aOldSymbolSets); 2196*cdf0e10cSrcweir if (aOldSymbolSets.GetEntryCount() > 0) 2197*cdf0e10cSrcweir SelectSymbolSet(aOldSymbolSets.GetEntry(0)); 2198*cdf0e10cSrcweir FillSymbolSets(aSymbolSets); 2199*cdf0e10cSrcweir if (aSymbolSets.GetEntryCount() > 0) 2200*cdf0e10cSrcweir SelectSymbolSet(aSymbolSets.GetEntry(0)); 2201*cdf0e10cSrcweir FillSymbols(aOldSymbols); 2202*cdf0e10cSrcweir if (aOldSymbols.GetEntryCount() > 0) 2203*cdf0e10cSrcweir SelectSymbol(aOldSymbols.GetEntry(0)); 2204*cdf0e10cSrcweir FillSymbols(aSymbols); 2205*cdf0e10cSrcweir if (aSymbols.GetEntryCount() > 0) 2206*cdf0e10cSrcweir SelectSymbol(aSymbols.GetEntry(0)); 2207*cdf0e10cSrcweir 2208*cdf0e10cSrcweir UpdateButtons(); 2209*cdf0e10cSrcweir } 2210*cdf0e10cSrcweir 2211*cdf0e10cSrcweir 2212*cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox, 2213*cdf0e10cSrcweir const XubString &rSymbolSetName, sal_Bool bDeleteText) 2214*cdf0e10cSrcweir { 2215*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 2216*cdf0e10cSrcweir DBG_ASSERT(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets, 2217*cdf0e10cSrcweir "Sm : falsche ComboBox"); 2218*cdf0e10cSrcweir #endif 2219*cdf0e10cSrcweir 2220*cdf0e10cSrcweir // 'Normalisieren' des SymbolNamens (ohne leading und trailing Leerzeichen) 2221*cdf0e10cSrcweir XubString aNormName (rSymbolSetName); 2222*cdf0e10cSrcweir aNormName.EraseLeadingChars(' '); 2223*cdf0e10cSrcweir aNormName.EraseTrailingChars(' '); 2224*cdf0e10cSrcweir // und evtl Abweichungen in der Eingabe beseitigen 2225*cdf0e10cSrcweir rComboBox.SetText(aNormName); 2226*cdf0e10cSrcweir 2227*cdf0e10cSrcweir sal_Bool bRet = sal_False; 2228*cdf0e10cSrcweir sal_uInt16 nPos = rComboBox.GetEntryPos(aNormName); 2229*cdf0e10cSrcweir 2230*cdf0e10cSrcweir if (nPos != COMBOBOX_ENTRY_NOTFOUND) 2231*cdf0e10cSrcweir { 2232*cdf0e10cSrcweir rComboBox.SetText(rComboBox.GetEntry(nPos)); 2233*cdf0e10cSrcweir bRet = sal_True; 2234*cdf0e10cSrcweir } 2235*cdf0e10cSrcweir else if (bDeleteText) 2236*cdf0e10cSrcweir rComboBox.SetText(XubString()); 2237*cdf0e10cSrcweir 2238*cdf0e10cSrcweir sal_Bool bIsOld = &rComboBox == &aOldSymbolSets; 2239*cdf0e10cSrcweir 2240*cdf0e10cSrcweir // setzen des SymbolSet Namens an der zugehoerigen Darstellung 2241*cdf0e10cSrcweir FixedText &rFT = bIsOld ? aOldSymbolSetName : aSymbolSetName; 2242*cdf0e10cSrcweir rFT.SetText(rComboBox.GetText()); 2243*cdf0e10cSrcweir 2244*cdf0e10cSrcweir // setzen der zum SymbolSet gehoerenden Symbol Namen an der zugehoerigen 2245*cdf0e10cSrcweir // Auswahbox 2246*cdf0e10cSrcweir ComboBox &rCB = bIsOld ? aOldSymbols : aSymbols; 2247*cdf0e10cSrcweir FillSymbols(rCB, sal_False); 2248*cdf0e10cSrcweir 2249*cdf0e10cSrcweir // bei Wechsel des SymbolSets fuer das alte Zeichen ein gueltiges 2250*cdf0e10cSrcweir // Symbol bzw keins zur Anzeige bringen 2251*cdf0e10cSrcweir if (bIsOld) 2252*cdf0e10cSrcweir { 2253*cdf0e10cSrcweir XubString aTmpOldSymbolName; 2254*cdf0e10cSrcweir if (aOldSymbols.GetEntryCount() > 0) 2255*cdf0e10cSrcweir aTmpOldSymbolName = aOldSymbols.GetEntry(0); 2256*cdf0e10cSrcweir SelectSymbol(aOldSymbols, aTmpOldSymbolName, sal_True); 2257*cdf0e10cSrcweir } 2258*cdf0e10cSrcweir 2259*cdf0e10cSrcweir UpdateButtons(); 2260*cdf0e10cSrcweir 2261*cdf0e10cSrcweir return bRet; 2262*cdf0e10cSrcweir } 2263*cdf0e10cSrcweir 2264*cdf0e10cSrcweir 2265*cdf0e10cSrcweir void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol, 2266*cdf0e10cSrcweir const XubString &rSymbolSetName) 2267*cdf0e10cSrcweir { 2268*cdf0e10cSrcweir // clear old symbol 2269*cdf0e10cSrcweir delete pOrigSymbol; 2270*cdf0e10cSrcweir pOrigSymbol = 0; 2271*cdf0e10cSrcweir 2272*cdf0e10cSrcweir XubString aSymName, 2273*cdf0e10cSrcweir aSymSetName; 2274*cdf0e10cSrcweir if (pSymbol) 2275*cdf0e10cSrcweir { 2276*cdf0e10cSrcweir // set new symbol 2277*cdf0e10cSrcweir pOrigSymbol = new SmSym( *pSymbol ); 2278*cdf0e10cSrcweir 2279*cdf0e10cSrcweir aSymName = pSymbol->GetName(); 2280*cdf0e10cSrcweir aSymSetName = rSymbolSetName; 2281*cdf0e10cSrcweir aOldSymbolDisplay.SetSymbol( pSymbol ); 2282*cdf0e10cSrcweir } 2283*cdf0e10cSrcweir else 2284*cdf0e10cSrcweir { // loeschen des angezeigten Symbols 2285*cdf0e10cSrcweir aOldSymbolDisplay.SetText(XubString()); 2286*cdf0e10cSrcweir aOldSymbolDisplay.Invalidate(); 2287*cdf0e10cSrcweir } 2288*cdf0e10cSrcweir aOldSymbolName .SetText(aSymName); 2289*cdf0e10cSrcweir aOldSymbolSetName.SetText(aSymSetName); 2290*cdf0e10cSrcweir } 2291*cdf0e10cSrcweir 2292*cdf0e10cSrcweir 2293*cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox, 2294*cdf0e10cSrcweir const XubString &rSymbolName, sal_Bool bDeleteText) 2295*cdf0e10cSrcweir { 2296*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 2297*cdf0e10cSrcweir DBG_ASSERT(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols, 2298*cdf0e10cSrcweir "Sm : falsche ComboBox"); 2299*cdf0e10cSrcweir #endif 2300*cdf0e10cSrcweir 2301*cdf0e10cSrcweir // 'Normalisieren' des SymbolNamens (ohne Leerzeichen) 2302*cdf0e10cSrcweir XubString aNormName (rSymbolName); 2303*cdf0e10cSrcweir aNormName.EraseAllChars(' '); 2304*cdf0e10cSrcweir // und evtl Abweichungen in der Eingabe beseitigen 2305*cdf0e10cSrcweir rComboBox.SetText(aNormName); 2306*cdf0e10cSrcweir 2307*cdf0e10cSrcweir sal_Bool bRet = sal_False; 2308*cdf0e10cSrcweir sal_uInt16 nPos = rComboBox.GetEntryPos(aNormName); 2309*cdf0e10cSrcweir 2310*cdf0e10cSrcweir sal_Bool bIsOld = &rComboBox == &aOldSymbols; 2311*cdf0e10cSrcweir 2312*cdf0e10cSrcweir if (nPos != COMBOBOX_ENTRY_NOTFOUND) 2313*cdf0e10cSrcweir { 2314*cdf0e10cSrcweir rComboBox.SetText(rComboBox.GetEntry(nPos)); 2315*cdf0e10cSrcweir 2316*cdf0e10cSrcweir if (!bIsOld) 2317*cdf0e10cSrcweir { 2318*cdf0e10cSrcweir const SmSym *pSymbol = GetSymbol(aSymbols); 2319*cdf0e10cSrcweir if (pSymbol) 2320*cdf0e10cSrcweir { 2321*cdf0e10cSrcweir // Font und Style entsprechend waehlen 2322*cdf0e10cSrcweir const Font &rFont = pSymbol->GetFace(); 2323*cdf0e10cSrcweir SelectFont(rFont.GetName(), sal_False); 2324*cdf0e10cSrcweir SelectStyle(GetFontStyles().GetStyleName(rFont), sal_False); 2325*cdf0e10cSrcweir 2326*cdf0e10cSrcweir // da das setzen des Fonts ueber den Style Namen des SymbolsFonts nicht 2327*cdf0e10cSrcweir // so gut klappt (er kann zB leer sein obwohl der Font selbst 'bold' und 2328*cdf0e10cSrcweir // 'italic' ist!). Setzen wir hier den Font wie er zum Symbol gehoert 2329*cdf0e10cSrcweir // zu Fuss. 2330*cdf0e10cSrcweir aCharsetDisplay.SetFont(rFont); 2331*cdf0e10cSrcweir aSymbolDisplay.SetFont(rFont); 2332*cdf0e10cSrcweir 2333*cdf0e10cSrcweir // das zugehoerige Zeichen auswaehlen 2334*cdf0e10cSrcweir SelectChar(pSymbol->GetCharacter()); 2335*cdf0e10cSrcweir 2336*cdf0e10cSrcweir // since SelectChar will also set the unicode point as text in the 2337*cdf0e10cSrcweir // symbols box, we have to set the symbol name again to get that one displayed 2338*cdf0e10cSrcweir aSymbols.SetText( pSymbol->GetName() ); 2339*cdf0e10cSrcweir } 2340*cdf0e10cSrcweir } 2341*cdf0e10cSrcweir 2342*cdf0e10cSrcweir bRet = sal_True; 2343*cdf0e10cSrcweir } 2344*cdf0e10cSrcweir else if (bDeleteText) 2345*cdf0e10cSrcweir rComboBox.SetText(XubString()); 2346*cdf0e10cSrcweir 2347*cdf0e10cSrcweir if (bIsOld) 2348*cdf0e10cSrcweir { 2349*cdf0e10cSrcweir // bei Wechsel des alten Symbols nur vorhandene anzeigen sonst keins 2350*cdf0e10cSrcweir const SmSym *pOldSymbol = NULL; 2351*cdf0e10cSrcweir XubString aTmpOldSymbolSetName; 2352*cdf0e10cSrcweir if (nPos != COMBOBOX_ENTRY_NOTFOUND) 2353*cdf0e10cSrcweir { 2354*cdf0e10cSrcweir pOldSymbol = aSymbolMgrCopy.GetSymbolByName(aNormName); 2355*cdf0e10cSrcweir aTmpOldSymbolSetName = aOldSymbolSets.GetText(); 2356*cdf0e10cSrcweir } 2357*cdf0e10cSrcweir SetOrigSymbol(pOldSymbol, aTmpOldSymbolSetName); 2358*cdf0e10cSrcweir } 2359*cdf0e10cSrcweir else 2360*cdf0e10cSrcweir aSymbolName.SetText(rComboBox.GetText()); 2361*cdf0e10cSrcweir 2362*cdf0e10cSrcweir UpdateButtons(); 2363*cdf0e10cSrcweir 2364*cdf0e10cSrcweir return bRet; 2365*cdf0e10cSrcweir } 2366*cdf0e10cSrcweir 2367*cdf0e10cSrcweir 2368*cdf0e10cSrcweir void SmSymDefineDialog::SetFont(const XubString &rFontName, const XubString &rStyleName) 2369*cdf0e10cSrcweir { 2370*cdf0e10cSrcweir // Font (FontInfo) passend zu Namen und Style holen 2371*cdf0e10cSrcweir FontInfo aFI; 2372*cdf0e10cSrcweir if (pFontList) 2373*cdf0e10cSrcweir aFI = pFontList->Get(rFontName, WEIGHT_NORMAL, ITALIC_NONE); 2374*cdf0e10cSrcweir SetFontStyle(rStyleName, aFI); 2375*cdf0e10cSrcweir 2376*cdf0e10cSrcweir aCharsetDisplay.SetFont(aFI); 2377*cdf0e10cSrcweir aSymbolDisplay.SetFont(aFI); 2378*cdf0e10cSrcweir 2379*cdf0e10cSrcweir // update subset listbox for new font's unicode subsets 2380*cdf0e10cSrcweir FontCharMap aFontCharMap; 2381*cdf0e10cSrcweir aCharsetDisplay.GetFontCharMap( aFontCharMap ); 2382*cdf0e10cSrcweir if (pSubsetMap) 2383*cdf0e10cSrcweir delete pSubsetMap; 2384*cdf0e10cSrcweir pSubsetMap = new SubsetMap( &aFontCharMap ); 2385*cdf0e10cSrcweir // 2386*cdf0e10cSrcweir aFontsSubsetLB.Clear(); 2387*cdf0e10cSrcweir bool bFirst = true; 2388*cdf0e10cSrcweir const Subset* pSubset; 2389*cdf0e10cSrcweir while( NULL != (pSubset = pSubsetMap->GetNextSubset( bFirst )) ) 2390*cdf0e10cSrcweir { 2391*cdf0e10cSrcweir sal_uInt16 nPos = aFontsSubsetLB.InsertEntry( pSubset->GetName()); 2392*cdf0e10cSrcweir aFontsSubsetLB.SetEntryData( nPos, (void *) pSubset ); 2393*cdf0e10cSrcweir // subset must live at least as long as the selected font !!! 2394*cdf0e10cSrcweir if( bFirst ) 2395*cdf0e10cSrcweir aFontsSubsetLB.SelectEntryPos( nPos ); 2396*cdf0e10cSrcweir bFirst = false; 2397*cdf0e10cSrcweir } 2398*cdf0e10cSrcweir if( bFirst ) 2399*cdf0e10cSrcweir aFontsSubsetLB.SetNoSelection(); 2400*cdf0e10cSrcweir aFontsSubsetLB.Enable( !bFirst ); 2401*cdf0e10cSrcweir } 2402*cdf0e10cSrcweir 2403*cdf0e10cSrcweir 2404*cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectFont(const XubString &rFontName, sal_Bool bApplyFont) 2405*cdf0e10cSrcweir { 2406*cdf0e10cSrcweir sal_Bool bRet = sal_False; 2407*cdf0e10cSrcweir sal_uInt16 nPos = aFonts.GetEntryPos(rFontName); 2408*cdf0e10cSrcweir 2409*cdf0e10cSrcweir if (nPos != LISTBOX_ENTRY_NOTFOUND) 2410*cdf0e10cSrcweir { 2411*cdf0e10cSrcweir aFonts.SelectEntryPos(nPos); 2412*cdf0e10cSrcweir if (aStyles.GetEntryCount() > 0) 2413*cdf0e10cSrcweir SelectStyle(aStyles.GetEntry(0)); 2414*cdf0e10cSrcweir if (bApplyFont) 2415*cdf0e10cSrcweir { 2416*cdf0e10cSrcweir SetFont(aFonts.GetSelectEntry(), aStyles.GetText()); 2417*cdf0e10cSrcweir // update preview to use new font 2418*cdf0e10cSrcweir aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() ); 2419*cdf0e10cSrcweir } 2420*cdf0e10cSrcweir bRet = sal_True; 2421*cdf0e10cSrcweir } 2422*cdf0e10cSrcweir else 2423*cdf0e10cSrcweir aFonts.SetNoSelection(); 2424*cdf0e10cSrcweir FillStyles(); 2425*cdf0e10cSrcweir 2426*cdf0e10cSrcweir UpdateButtons(); 2427*cdf0e10cSrcweir 2428*cdf0e10cSrcweir return bRet; 2429*cdf0e10cSrcweir } 2430*cdf0e10cSrcweir 2431*cdf0e10cSrcweir 2432*cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectStyle(const XubString &rStyleName, sal_Bool bApplyFont) 2433*cdf0e10cSrcweir { 2434*cdf0e10cSrcweir sal_Bool bRet = sal_False; 2435*cdf0e10cSrcweir sal_uInt16 nPos = aStyles.GetEntryPos(rStyleName); 2436*cdf0e10cSrcweir 2437*cdf0e10cSrcweir // falls der Style nicht zur Auswahl steht nehmen wir den erst moeglichen 2438*cdf0e10cSrcweir // (sofern vorhanden) 2439*cdf0e10cSrcweir if (nPos == COMBOBOX_ENTRY_NOTFOUND && aStyles.GetEntryCount() > 0) 2440*cdf0e10cSrcweir nPos = 0; 2441*cdf0e10cSrcweir 2442*cdf0e10cSrcweir if (nPos != COMBOBOX_ENTRY_NOTFOUND) 2443*cdf0e10cSrcweir { 2444*cdf0e10cSrcweir aStyles.SetText(aStyles.GetEntry(nPos)); 2445*cdf0e10cSrcweir if (bApplyFont) 2446*cdf0e10cSrcweir { 2447*cdf0e10cSrcweir SetFont(aFonts.GetSelectEntry(), aStyles.GetText()); 2448*cdf0e10cSrcweir // update preview to use new font 2449*cdf0e10cSrcweir aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() ); 2450*cdf0e10cSrcweir } 2451*cdf0e10cSrcweir bRet = sal_True; 2452*cdf0e10cSrcweir } 2453*cdf0e10cSrcweir else 2454*cdf0e10cSrcweir aStyles.SetText(XubString()); 2455*cdf0e10cSrcweir 2456*cdf0e10cSrcweir UpdateButtons(); 2457*cdf0e10cSrcweir 2458*cdf0e10cSrcweir return bRet; 2459*cdf0e10cSrcweir } 2460*cdf0e10cSrcweir 2461*cdf0e10cSrcweir 2462*cdf0e10cSrcweir void SmSymDefineDialog::SelectChar(xub_Unicode cChar) 2463*cdf0e10cSrcweir { 2464*cdf0e10cSrcweir aCharsetDisplay.SelectCharacter( cChar ); 2465*cdf0e10cSrcweir aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() ); 2466*cdf0e10cSrcweir 2467*cdf0e10cSrcweir UpdateButtons(); 2468*cdf0e10cSrcweir } 2469*cdf0e10cSrcweir 2470*cdf0e10cSrcweir 2471*cdf0e10cSrcweir /**************************************************************************/ 2472*cdf0e10cSrcweir 2473