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