xref: /trunk/main/starmath/source/dialog.cxx (revision d107581f588b53ce11339a8a18091c0f86ec8bb4)
1*d107581fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d107581fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d107581fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d107581fSAndrew Rist  * distributed with this work for additional information
6*d107581fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d107581fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d107581fSAndrew Rist  * "License"); you may not use this file except in compliance
9*d107581fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*d107581fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*d107581fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d107581fSAndrew Rist  * software distributed under the License is distributed on an
15*d107581fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d107581fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d107581fSAndrew Rist  * specific language governing permissions and limitations
18*d107581fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*d107581fSAndrew Rist  *************************************************************/
21*d107581fSAndrew Rist 
22*d107581fSAndrew 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 
80cdf0e10cSrcweir     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 
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 
99cdf0e10cSrcweir 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 
116cdf0e10cSrcweir 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 
135cdf0e10cSrcweir const SmFontStyles & GetFontStyles()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     static const SmFontStyles aImpl;
138cdf0e10cSrcweir     return aImpl;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir /////////////////////////////////////////////////////////////////
142cdf0e10cSrcweir 
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 
168cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, EMPTYARG/*pButton*/ )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     aZoom.Enable(aSizeZoomed.IsChecked());
171cdf0e10cSrcweir     return 0;
172cdf0e10cSrcweir }
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 
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 
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 
243cdf0e10cSrcweir SfxTabPage* SmPrintOptionsTabPage::Create(Window* pWindow, const SfxItemSet& rSet)
244cdf0e10cSrcweir {
245cdf0e10cSrcweir     return (new SmPrintOptionsTabPage(pWindow, rSet));
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir /**************************************************************************/
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 
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 
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 
278cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir     Face.SetName(pComboBox->GetText());
281cdf0e10cSrcweir     aShowFont.SetFont(Face);
282cdf0e10cSrcweir     return 0;
283cdf0e10cSrcweir }
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 
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 
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 
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 
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 
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 
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 
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 
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 
480cdf0e10cSrcweir 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 
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 
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 }
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 
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 
602cdf0e10cSrcweir 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 
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 
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 
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 
730cdf0e10cSrcweir IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir     SetCategory(pMenu->GetCurItemId() - 1);
733cdf0e10cSrcweir     return 0;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 
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 
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 
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 
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         {
868cdf0e10cSrcweir             eUnit   = FUNIT_CUSTOM;
869cdf0e10cSrcweir             nDigits = 0;
870cdf0e10cSrcweir             pMF->SetCustomUnitText( '%' );
871cdf0e10cSrcweir         }
872cdf0e10cSrcweir         else
873cdf0e10cSrcweir         {
874cdf0e10cSrcweir             eUnit   = FUNIT_100TH_MM;
875cdf0e10cSrcweir             nDigits = 2;
876cdf0e10cSrcweir         }
877cdf0e10cSrcweir         pMF->SetUnit(eUnit);            //! veraendert den Wert
878cdf0e10cSrcweir         pMF->SetDecimalDigits(nDigits);
879cdf0e10cSrcweir 
880cdf0e10cSrcweir         if (bActive)
881cdf0e10cSrcweir         {
882cdf0e10cSrcweir             pCat = Categories[nCategory];
883cdf0e10cSrcweir             pFT->SetText(*pCat->GetString(i));
884cdf0e10cSrcweir 
885cdf0e10cSrcweir             pMF->SetMin(pCat->GetMinimum(i));
886cdf0e10cSrcweir             pMF->SetMax(pCat->GetMaximum(i));
887cdf0e10cSrcweir             pMF->SetValue(pCat->GetValue(i));
888cdf0e10cSrcweir 
889cdf0e10cSrcweir             SetHelpId(*pMF, aCatMf2Hid[nCategory][i]);
890cdf0e10cSrcweir         }
891cdf0e10cSrcweir     }
892cdf0e10cSrcweir     // nun noch die CheckBox und das zugehoerige MetricField genau dann aktivieren,
893cdf0e10cSrcweir     // falls es sich um das Klammer Menu handelt.
894cdf0e10cSrcweir     bActive = nCategory == 5;
895cdf0e10cSrcweir     aCheckBox1.Show(bActive);
896cdf0e10cSrcweir     aCheckBox1.Enable(bActive);
897cdf0e10cSrcweir     if (bActive)
898cdf0e10cSrcweir     {
899cdf0e10cSrcweir         aCheckBox1.Check( bScaleAllBrackets );
900cdf0e10cSrcweir 
901cdf0e10cSrcweir         sal_Bool bChecked = aCheckBox1.IsChecked();
902cdf0e10cSrcweir         aFixedText4  .Enable( bChecked );
903cdf0e10cSrcweir         aMetricField4.Enable( bChecked );
904cdf0e10cSrcweir     }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir     aMenuButton.GetPopupMenu()->CheckItem(nCategory + 1, sal_True);
907cdf0e10cSrcweir     aFixedLine.SetText(Categories[nCategory]->GetName());
908cdf0e10cSrcweir 
909cdf0e10cSrcweir     nActiveCategory = nCategory;
910cdf0e10cSrcweir 
911cdf0e10cSrcweir     aMetricField1.GrabFocus();
912cdf0e10cSrcweir     Invalidate();
913cdf0e10cSrcweir     Update();
914cdf0e10cSrcweir }
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 
917cdf0e10cSrcweir SmDistanceDialog::SmDistanceDialog(Window *pParent, sal_Bool bFreeRes)
918cdf0e10cSrcweir     : ModalDialog(pParent, SmResId(RID_DISTANCEDIALOG)),
919cdf0e10cSrcweir     aFixedText1    (this, SmResId(1)),
920cdf0e10cSrcweir     aMetricField1  (this, SmResId(1)),
921cdf0e10cSrcweir     aFixedText2    (this, SmResId(2)),
922cdf0e10cSrcweir     aMetricField2  (this, SmResId(2)),
923cdf0e10cSrcweir     aFixedText3    (this, SmResId(3)),
924cdf0e10cSrcweir     aMetricField3  (this, SmResId(3)),
925cdf0e10cSrcweir     aCheckBox1     (this, SmResId(1)),
926cdf0e10cSrcweir     aFixedText4    (this, SmResId(4)),
927cdf0e10cSrcweir     aMetricField4  (this, SmResId(4)),
928cdf0e10cSrcweir     aOKButton1     (this, SmResId(1)),
929cdf0e10cSrcweir     aCancelButton1 (this, SmResId(1)),
930cdf0e10cSrcweir     aMenuButton    (this, SmResId(1)),
931cdf0e10cSrcweir     aDefaultButton (this, SmResId(1)),
932cdf0e10cSrcweir     aBitmap        (this, SmResId(1)),
933cdf0e10cSrcweir     aFixedLine     (this, SmResId(1))
934cdf0e10cSrcweir {
935cdf0e10cSrcweir     for (sal_uInt16 i = 0; i < NOCATEGORIES; i++)
936cdf0e10cSrcweir         Categories[i] = new SmCategoryDesc(SmResId(i + 1), i);
937cdf0e10cSrcweir     nActiveCategory   = CATEGORY_NONE;
938cdf0e10cSrcweir     bScaleAllBrackets = sal_False;
939cdf0e10cSrcweir 
940cdf0e10cSrcweir     if (bFreeRes)
941cdf0e10cSrcweir         FreeResource();
942cdf0e10cSrcweir 
943cdf0e10cSrcweir     ApplyImages();
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     // preview like controls should have a 2D look
946cdf0e10cSrcweir     aBitmap.SetBorderStyle( WINDOW_BORDER_MONO );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     aMetricField1.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
949cdf0e10cSrcweir     aMetricField2.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
950cdf0e10cSrcweir     aMetricField3.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
951cdf0e10cSrcweir     aMetricField4.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
952cdf0e10cSrcweir     aCheckBox1.SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
953cdf0e10cSrcweir 
954cdf0e10cSrcweir     aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
955cdf0e10cSrcweir 
956cdf0e10cSrcweir     aDefaultButton.SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
957cdf0e10cSrcweir }
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 
960cdf0e10cSrcweir SmDistanceDialog::~SmDistanceDialog()
961cdf0e10cSrcweir {
962cdf0e10cSrcweir     for (int i = 0; i < NOCATEGORIES; i++)
963cdf0e10cSrcweir         DELETEZ(Categories[i]);
964cdf0e10cSrcweir }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir void SmDistanceDialog::ApplyImages()
967cdf0e10cSrcweir {
968cdf0e10cSrcweir     sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
969cdf0e10cSrcweir     for (int i = 0;  i < NOCATEGORIES;  ++i)
970cdf0e10cSrcweir     {
971cdf0e10cSrcweir         SmCategoryDesc *pCat = Categories[i];
972cdf0e10cSrcweir         if (pCat)
973cdf0e10cSrcweir             pCat->SetHighContrast( bHighContrast );
974cdf0e10cSrcweir     }
975cdf0e10cSrcweir }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir void SmDistanceDialog::DataChanged( const DataChangedEvent &rEvt )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir     if ( (rEvt.GetType() == DATACHANGED_SETTINGS) && (rEvt.GetFlags() & SETTINGS_STYLE) )
980cdf0e10cSrcweir             ApplyImages();
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     ModalDialog::DataChanged( rEvt );
983cdf0e10cSrcweir }
984cdf0e10cSrcweir 
985cdf0e10cSrcweir void SmDistanceDialog::ReadFrom(const SmFormat &rFormat)
986cdf0e10cSrcweir {
987cdf0e10cSrcweir     Categories[0]->SetValue(0, rFormat.GetDistance(DIS_HORIZONTAL));
988cdf0e10cSrcweir     Categories[0]->SetValue(1, rFormat.GetDistance(DIS_VERTICAL));
989cdf0e10cSrcweir     Categories[0]->SetValue(2, rFormat.GetDistance(DIS_ROOT));
990cdf0e10cSrcweir     Categories[1]->SetValue(0, rFormat.GetDistance(DIS_SUPERSCRIPT));
991cdf0e10cSrcweir     Categories[1]->SetValue(1, rFormat.GetDistance(DIS_SUBSCRIPT));
992cdf0e10cSrcweir     Categories[2]->SetValue(0, rFormat.GetDistance(DIS_NUMERATOR));
993cdf0e10cSrcweir     Categories[2]->SetValue(1, rFormat.GetDistance(DIS_DENOMINATOR));
994cdf0e10cSrcweir     Categories[3]->SetValue(0, rFormat.GetDistance(DIS_FRACTION));
995cdf0e10cSrcweir     Categories[3]->SetValue(1, rFormat.GetDistance(DIS_STROKEWIDTH));
996cdf0e10cSrcweir     Categories[4]->SetValue(0, rFormat.GetDistance(DIS_UPPERLIMIT));
997cdf0e10cSrcweir     Categories[4]->SetValue(1, rFormat.GetDistance(DIS_LOWERLIMIT));
998cdf0e10cSrcweir     Categories[5]->SetValue(0, rFormat.GetDistance(DIS_BRACKETSIZE));
999cdf0e10cSrcweir     Categories[5]->SetValue(1, rFormat.GetDistance(DIS_BRACKETSPACE));
1000cdf0e10cSrcweir     Categories[5]->SetValue(3, rFormat.GetDistance(DIS_NORMALBRACKETSIZE));
1001cdf0e10cSrcweir     Categories[6]->SetValue(0, rFormat.GetDistance(DIS_MATRIXROW));
1002cdf0e10cSrcweir     Categories[6]->SetValue(1, rFormat.GetDistance(DIS_MATRIXCOL));
1003cdf0e10cSrcweir     Categories[7]->SetValue(0, rFormat.GetDistance(DIS_ORNAMENTSIZE));
1004cdf0e10cSrcweir     Categories[7]->SetValue(1, rFormat.GetDistance(DIS_ORNAMENTSPACE));
1005cdf0e10cSrcweir     Categories[8]->SetValue(0, rFormat.GetDistance(DIS_OPERATORSIZE));
1006cdf0e10cSrcweir     Categories[8]->SetValue(1, rFormat.GetDistance(DIS_OPERATORSPACE));
1007cdf0e10cSrcweir     Categories[9]->SetValue(0, rFormat.GetDistance(DIS_LEFTSPACE));
1008cdf0e10cSrcweir     Categories[9]->SetValue(1, rFormat.GetDistance(DIS_RIGHTSPACE));
1009cdf0e10cSrcweir     Categories[9]->SetValue(2, rFormat.GetDistance(DIS_TOPSPACE));
1010cdf0e10cSrcweir     Categories[9]->SetValue(3, rFormat.GetDistance(DIS_BOTTOMSPACE));
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir     bScaleAllBrackets = rFormat.IsScaleNormalBrackets();
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir     // force update (even of category 0) by setting nActiveCategory to a
1015cdf0e10cSrcweir     // non-existent category number
1016cdf0e10cSrcweir     nActiveCategory = CATEGORY_NONE;
1017cdf0e10cSrcweir     SetCategory(0);
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir     // hmm... koennen die tatsaechlich unterschiedlich sein?
1024cdf0e10cSrcweir     // wenn nicht kann oben naemlich das const stehen!
1025cdf0e10cSrcweir     SetCategory(nActiveCategory);
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir     rFormat.SetDistance( DIS_HORIZONTAL,        Categories[0]->GetValue(0) );
1028cdf0e10cSrcweir     rFormat.SetDistance( DIS_VERTICAL,          Categories[0]->GetValue(1) );
1029cdf0e10cSrcweir     rFormat.SetDistance( DIS_ROOT,              Categories[0]->GetValue(2) );
1030cdf0e10cSrcweir     rFormat.SetDistance( DIS_SUPERSCRIPT,       Categories[1]->GetValue(0) );
1031cdf0e10cSrcweir     rFormat.SetDistance( DIS_SUBSCRIPT,         Categories[1]->GetValue(1) );
1032cdf0e10cSrcweir     rFormat.SetDistance( DIS_NUMERATOR,         Categories[2]->GetValue(0) );
1033cdf0e10cSrcweir     rFormat.SetDistance( DIS_DENOMINATOR,       Categories[2]->GetValue(1) );
1034cdf0e10cSrcweir     rFormat.SetDistance( DIS_FRACTION,          Categories[3]->GetValue(0) );
1035cdf0e10cSrcweir     rFormat.SetDistance( DIS_STROKEWIDTH,       Categories[3]->GetValue(1) );
1036cdf0e10cSrcweir     rFormat.SetDistance( DIS_UPPERLIMIT,        Categories[4]->GetValue(0) );
1037cdf0e10cSrcweir     rFormat.SetDistance( DIS_LOWERLIMIT,        Categories[4]->GetValue(1) );
1038cdf0e10cSrcweir     rFormat.SetDistance( DIS_BRACKETSIZE,       Categories[5]->GetValue(0) );
1039cdf0e10cSrcweir     rFormat.SetDistance( DIS_BRACKETSPACE,      Categories[5]->GetValue(1) );
1040cdf0e10cSrcweir     rFormat.SetDistance( DIS_MATRIXROW,         Categories[6]->GetValue(0) );
1041cdf0e10cSrcweir     rFormat.SetDistance( DIS_MATRIXCOL,         Categories[6]->GetValue(1) );
1042cdf0e10cSrcweir     rFormat.SetDistance( DIS_ORNAMENTSIZE,      Categories[7]->GetValue(0) );
1043cdf0e10cSrcweir     rFormat.SetDistance( DIS_ORNAMENTSPACE,     Categories[7]->GetValue(1) );
1044cdf0e10cSrcweir     rFormat.SetDistance( DIS_OPERATORSIZE,      Categories[8]->GetValue(0) );
1045cdf0e10cSrcweir     rFormat.SetDistance( DIS_OPERATORSPACE,     Categories[8]->GetValue(1) );
1046cdf0e10cSrcweir     rFormat.SetDistance( DIS_LEFTSPACE,         Categories[9]->GetValue(0) );
1047cdf0e10cSrcweir     rFormat.SetDistance( DIS_RIGHTSPACE,        Categories[9]->GetValue(1) );
1048cdf0e10cSrcweir     rFormat.SetDistance( DIS_TOPSPACE,          Categories[9]->GetValue(2) );
1049cdf0e10cSrcweir     rFormat.SetDistance( DIS_BOTTOMSPACE,       Categories[9]->GetValue(3) );
1050cdf0e10cSrcweir     rFormat.SetDistance( DIS_NORMALBRACKETSIZE, Categories[5]->GetValue(3) );
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir     rFormat.SetScaleNormalBrackets( bScaleAllBrackets );
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir     rFormat.RequestApplyChanges();
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir /**************************************************************************/
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir    QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     if (pQueryBox->Execute() == RET_YES)
1066cdf0e10cSrcweir     {
1067cdf0e10cSrcweir         SmModule *pp = SM_MOD();
1068cdf0e10cSrcweir         SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
1069cdf0e10cSrcweir         WriteTo( aFmt );
1070cdf0e10cSrcweir         pp->GetConfig()->SetStandardFormat( aFmt );
1071cdf0e10cSrcweir     }
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir     delete pQueryBox;
1074cdf0e10cSrcweir     return 0;
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir SmAlignDialog::SmAlignDialog(Window * pParent, sal_Bool bFreeRes)
1079cdf0e10cSrcweir     : ModalDialog(pParent, SmResId(RID_ALIGNDIALOG)),
1080cdf0e10cSrcweir     aLeft          (this, SmResId(1)),
1081cdf0e10cSrcweir     aCenter        (this, SmResId(2)),
1082cdf0e10cSrcweir     aRight         (this, SmResId(3)),
1083cdf0e10cSrcweir     aFixedLine1    (this, SmResId(1)),
1084cdf0e10cSrcweir     aOKButton1     (this, SmResId(1)),
1085cdf0e10cSrcweir     aCancelButton1 (this, SmResId(1)),
1086cdf0e10cSrcweir     aDefaultButton (this, SmResId(1))
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir     if (bFreeRes)
1089cdf0e10cSrcweir         FreeResource();
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir     aDefaultButton.SetClickHdl(LINK(this, SmAlignDialog, DefaultButtonClickHdl));
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir void SmAlignDialog::ReadFrom(const SmFormat &rFormat)
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir     switch (rFormat.GetHorAlign())
1098cdf0e10cSrcweir     {
1099cdf0e10cSrcweir         case AlignLeft:
1100cdf0e10cSrcweir             aLeft  .Check(sal_True);
1101cdf0e10cSrcweir             aCenter.Check(sal_False);
1102cdf0e10cSrcweir             aRight .Check(sal_False);
1103cdf0e10cSrcweir             break;
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir         case AlignCenter:
1106cdf0e10cSrcweir             aLeft  .Check(sal_False);
1107cdf0e10cSrcweir             aCenter.Check(sal_True);
1108cdf0e10cSrcweir             aRight .Check(sal_False);
1109cdf0e10cSrcweir             break;
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir         case AlignRight:
1112cdf0e10cSrcweir             aLeft  .Check(sal_False);
1113cdf0e10cSrcweir             aCenter.Check(sal_False);
1114cdf0e10cSrcweir             aRight .Check(sal_True);
1115cdf0e10cSrcweir             break;
1116cdf0e10cSrcweir     }
1117cdf0e10cSrcweir }
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir void SmAlignDialog::WriteTo(SmFormat &rFormat) const
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir     if (aLeft.IsChecked())
1123cdf0e10cSrcweir         rFormat.SetHorAlign(AlignLeft);
1124cdf0e10cSrcweir     else if (aRight.IsChecked())
1125cdf0e10cSrcweir         rFormat.SetHorAlign(AlignRight);
1126cdf0e10cSrcweir     else
1127cdf0e10cSrcweir         rFormat.SetHorAlign(AlignCenter);
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir     rFormat.RequestApplyChanges();
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir /**************************************************************************/
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir void SmShowSymbolSet::Paint(const Rectangle&)
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir     Push(PUSH_MAPMODE);
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir     // MapUnit einstellen fuer die 'nLen' berechnet wurde
1141cdf0e10cSrcweir     SetMapMode(MapMode(MAP_PIXEL));
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir     sal_uInt16 v        = sal::static_int_cast< sal_uInt16 >((aVScrollBar.GetThumbPos() * nColumns));
1144cdf0e10cSrcweir     size_t nSymbols = aSymbolSet.size();
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir     Color aTxtColor( GetTextColor() );
1147cdf0e10cSrcweir     for (sal_uInt16 i = v; i < nSymbols ; i++)
1148cdf0e10cSrcweir     {
1149cdf0e10cSrcweir         SmSym    aSymbol (*aSymbolSet[i]);
1150cdf0e10cSrcweir         Font     aFont   (aSymbol.GetFace());
1151cdf0e10cSrcweir         aFont.SetAlign(ALIGN_TOP);
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir         // etwas kleinere FontSize nehmen (als nLen) um etwas Luft zu haben
1154cdf0e10cSrcweir         // (hoffentlich auch genug fuer links und rechts!)
1155cdf0e10cSrcweir         aFont.SetSize(Size(0, nLen - (nLen / 3)));
1156cdf0e10cSrcweir         SetFont(aFont);
1157cdf0e10cSrcweir         // keep text color
1158cdf0e10cSrcweir         SetTextColor( aTxtColor );
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir         int   nIV   = i - v;
1161cdf0e10cSrcweir         sal_UCS4 cChar = aSymbol.GetCharacter();
1162cdf0e10cSrcweir         String aText( OUString( &cChar, 1 ) );
1163cdf0e10cSrcweir         Size  aSize( GetTextWidth( aText ), GetTextHeight());
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir         DrawText(Point((nIV % nColumns) * nLen + (nLen - aSize.Width()) / 2,
1166cdf0e10cSrcweir                        (nIV / nColumns) * nLen + (nLen - aSize.Height()) / 2),
1167cdf0e10cSrcweir                  aText);
1168cdf0e10cSrcweir     }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     if (nSelectSymbol != SYMBOL_NONE)
1171cdf0e10cSrcweir     {
1172cdf0e10cSrcweir         Invert(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen,
1173cdf0e10cSrcweir                                ((nSelectSymbol - v) / nColumns) * nLen),
1174cdf0e10cSrcweir                          Size(nLen, nLen)));
1175cdf0e10cSrcweir     }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir     Pop();
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir void SmShowSymbolSet::MouseButtonDown(const MouseEvent& rMEvt)
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir     GrabFocus();
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir     if (rMEvt.IsLeft() && Rectangle(Point(0, 0), aOutputSize).IsInside(rMEvt.GetPosPixel()))
1186cdf0e10cSrcweir     {
1187cdf0e10cSrcweir         long nPos = (rMEvt.GetPosPixel().Y() / nLen) * nColumns + (rMEvt.GetPosPixel().X() / nLen) +
1188cdf0e10cSrcweir                       aVScrollBar.GetThumbPos() * nColumns;
1189cdf0e10cSrcweir         SelectSymbol( sal::static_int_cast< sal_uInt16 >(nPos) );
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir         aSelectHdlLink.Call(this);
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir         if (rMEvt.GetClicks() > 1) aDblClickHdlLink.Call(this);
1194cdf0e10cSrcweir     }
1195cdf0e10cSrcweir     else Control::MouseButtonDown (rMEvt);
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir void SmShowSymbolSet::KeyInput(const KeyEvent& rKEvt)
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir     sal_uInt16 n = nSelectSymbol;
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir     if (n != SYMBOL_NONE)
1204cdf0e10cSrcweir     {
1205cdf0e10cSrcweir         switch (rKEvt.GetKeyCode().GetCode())
1206cdf0e10cSrcweir         {
1207cdf0e10cSrcweir             case KEY_DOWN:      n = n + nColumns;   break;
1208cdf0e10cSrcweir             case KEY_UP:        n = n - nColumns;   break;
1209cdf0e10cSrcweir             case KEY_LEFT:      n -= 1; break;
1210cdf0e10cSrcweir             case KEY_RIGHT:     n += 1; break;
1211cdf0e10cSrcweir             case KEY_HOME:      n  = 0; break;
1212cdf0e10cSrcweir             case KEY_END:       n  = static_cast< sal_uInt16 >(aSymbolSet.size() - 1);   break;
1213cdf0e10cSrcweir             case KEY_PAGEUP:    n -= nColumns * nRows;  break;
1214cdf0e10cSrcweir             case KEY_PAGEDOWN:  n += nColumns * nRows;  break;
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir             default:
1217cdf0e10cSrcweir                 Control::KeyInput(rKEvt);
1218cdf0e10cSrcweir                 return;
1219cdf0e10cSrcweir         }
1220cdf0e10cSrcweir     }
1221cdf0e10cSrcweir     else
1222cdf0e10cSrcweir         n = 0;
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir     if (n >= aSymbolSet.size())
1225cdf0e10cSrcweir         n = nSelectSymbol;
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir     // adjust scrollbar
1228cdf0e10cSrcweir     if ((n < (sal_uInt16) (aVScrollBar.GetThumbPos() * nColumns)) ||
1229cdf0e10cSrcweir         (n >= (sal_uInt16) ((aVScrollBar.GetThumbPos() + nRows) * nColumns)))
1230cdf0e10cSrcweir     {
1231cdf0e10cSrcweir         aVScrollBar.SetThumbPos(n / nColumns);
1232cdf0e10cSrcweir         Invalidate();
1233cdf0e10cSrcweir         Update();
1234cdf0e10cSrcweir     }
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir     SelectSymbol(n);
1237cdf0e10cSrcweir     aSelectHdlLink.Call(this);
1238cdf0e10cSrcweir }
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir SmShowSymbolSet::SmShowSymbolSet(Window *pParent, const ResId& rResId) :
1242cdf0e10cSrcweir     Control(pParent, rResId),
1243cdf0e10cSrcweir     aVScrollBar(this, WinBits(WB_VSCROLL))
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir     nSelectSymbol = SYMBOL_NONE;
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir     aOutputSize = GetOutputSizePixel();
1248cdf0e10cSrcweir     long nScrollBarWidth = aVScrollBar.GetSizePixel().Width(),
1249cdf0e10cSrcweir          nUseableWidth   = aOutputSize.Width() - nScrollBarWidth;
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir     // Hoehe von 16pt in Pixeln (passend zu 'aOutputSize')
1252cdf0e10cSrcweir     nLen = (sal_uInt16) LogicToPixel(Size(0, 16), MapMode(MAP_POINT)).Height();
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     nColumns = sal::static_int_cast< sal_uInt16 >(nUseableWidth / nLen);
1255cdf0e10cSrcweir     if (nColumns > 2  && nColumns % 2 != 0)
1256cdf0e10cSrcweir         nColumns--;
1257cdf0e10cSrcweir     nRows    = sal::static_int_cast< sal_uInt16 >(aOutputSize.Height() / nLen);
1258cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1259cdf0e10cSrcweir     DBG_ASSERT(nColumns > 0, "Sm : keine Spalten");
1260cdf0e10cSrcweir     DBG_ASSERT(nRows > 0, "Sm : keine Zeilen");
1261cdf0e10cSrcweir #endif
1262cdf0e10cSrcweir 
1263cdf0e10cSrcweir     // genau passend machen
1264cdf0e10cSrcweir     aOutputSize.Width()  = nColumns * nLen;
1265cdf0e10cSrcweir     aOutputSize.Height() = nRows * nLen;
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir     aVScrollBar.SetPosSizePixel(Point(aOutputSize.Width() + 1, -1),
1268cdf0e10cSrcweir                                 Size(nScrollBarWidth, aOutputSize.Height() + 2));
1269cdf0e10cSrcweir     aVScrollBar.Enable(sal_False);
1270cdf0e10cSrcweir     aVScrollBar.Show();
1271cdf0e10cSrcweir     aVScrollBar.SetScrollHdl(LINK(this, SmShowSymbolSet, ScrollHdl));
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     Size WindowSize (aOutputSize);
1274cdf0e10cSrcweir     WindowSize.Width() += nScrollBarWidth;
1275cdf0e10cSrcweir     SetOutputSizePixel(WindowSize);
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir }
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir void SmShowSymbolSet::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet)
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir     aSymbolSet = rSymbolSet;
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir     if (static_cast< sal_uInt16 >(aSymbolSet.size()) > (nColumns * nRows))
1285cdf0e10cSrcweir     {
1286cdf0e10cSrcweir         aVScrollBar.SetRange(Range(0, ((aSymbolSet.size() + (nColumns - 1)) / nColumns) - nRows));
1287cdf0e10cSrcweir         aVScrollBar.Enable(sal_True);
1288cdf0e10cSrcweir     }
1289cdf0e10cSrcweir     else
1290cdf0e10cSrcweir     {
1291cdf0e10cSrcweir         aVScrollBar.SetRange(Range(0,0));
1292cdf0e10cSrcweir         aVScrollBar.Enable (sal_False);
1293cdf0e10cSrcweir     }
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir     Invalidate();
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir void SmShowSymbolSet::SelectSymbol(sal_uInt16 nSymbol)
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir     int v = (int) (aVScrollBar.GetThumbPos() * nColumns);
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir     if (nSelectSymbol != SYMBOL_NONE)
1304cdf0e10cSrcweir         Invalidate(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen,
1305cdf0e10cSrcweir                                    ((nSelectSymbol - v) / nColumns) * nLen),
1306cdf0e10cSrcweir                              Size(nLen, nLen)));
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir     if (nSymbol < aSymbolSet.size())
1309cdf0e10cSrcweir         nSelectSymbol = nSymbol;
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir     if (aSymbolSet.size() == 0)
1312cdf0e10cSrcweir         nSelectSymbol = SYMBOL_NONE;
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir     if (nSelectSymbol != SYMBOL_NONE)
1315cdf0e10cSrcweir         Invalidate(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen,
1316cdf0e10cSrcweir                                    ((nSelectSymbol - v) / nColumns) * nLen),
1317cdf0e10cSrcweir                              Size(nLen, nLen)));
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir     Update();
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir IMPL_LINK( SmShowSymbolSet, ScrollHdl, ScrollBar*, EMPTYARG /*pScrollBar*/)
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir     Invalidate();
1326cdf0e10cSrcweir     return 0;
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir void SmShowSymbol::Paint(const Rectangle &rRect)
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir     Control::Paint( rRect );
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir     const XubString &rText = GetText();
1336cdf0e10cSrcweir     Size            aTextSize(GetTextWidth(rText), GetTextHeight());
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir     DrawText(Point((GetOutputSize().Width()  - aTextSize.Width())  / 2,
1339cdf0e10cSrcweir                    (GetOutputSize().Height() * 7/10)), rText);
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt)
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir     if (rMEvt.GetClicks() > 1)
1346cdf0e10cSrcweir         aDblClickHdlLink.Call(this);
1347cdf0e10cSrcweir     else
1348cdf0e10cSrcweir         Control::MouseButtonDown (rMEvt);
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir void SmShowSymbol::SetSymbol(const SmSym *pSymbol)
1353cdf0e10cSrcweir {
1354cdf0e10cSrcweir     if (pSymbol)
1355cdf0e10cSrcweir     {
1356cdf0e10cSrcweir         Font aFont (pSymbol->GetFace());
1357cdf0e10cSrcweir         aFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
1358cdf0e10cSrcweir         aFont.SetAlign(ALIGN_BASELINE);
1359cdf0e10cSrcweir         SetFont(aFont);
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir         sal_UCS4 cChar = pSymbol->GetCharacter();
1362cdf0e10cSrcweir         String aText( OUString( &cChar, 1 ) );
1363cdf0e10cSrcweir         SetText( aText );
1364cdf0e10cSrcweir     }
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir     // 'Invalidate' fuellt den background mit der background-Farbe.
1367cdf0e10cSrcweir     // Falls der NULL pointer uebergeben wurde reicht dies also zum loeschen
1368cdf0e10cSrcweir     // der Anzeige
1369cdf0e10cSrcweir     Invalidate();
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir void SmSymbolDialog::FillSymbolSets(sal_Bool bDeleteText)
1376cdf0e10cSrcweir     // fuellt die Eintraege der moeglichen 'SymbolsSet's im Dialog mit den
1377cdf0e10cSrcweir     // aktuellen Werten des SymbolSet Managers, selektiert aber keinen.
1378cdf0e10cSrcweir {
1379cdf0e10cSrcweir     aSymbolSets.Clear();
1380cdf0e10cSrcweir     if (bDeleteText)
1381cdf0e10cSrcweir         aSymbolSets.SetNoSelection();
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir     std::set< String >  aSybolSetNames( rSymbolMgr.GetSymbolSetNames() );
1384cdf0e10cSrcweir     std::set< String >::const_iterator aIt( aSybolSetNames.begin() );
1385cdf0e10cSrcweir     for ( ; aIt != aSybolSetNames.end(); ++aIt)
1386cdf0e10cSrcweir         aSymbolSets.InsertEntry( *aIt );
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, SymbolSetChangeHdl, ListBox *, EMPTYARG pListBox )
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir     (void) pListBox;
1393cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1394cdf0e10cSrcweir     DBG_ASSERT(pListBox == &aSymbolSets, "Sm : falsches Argument");
1395cdf0e10cSrcweir #endif
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir     SelectSymbolSet(aSymbolSets.GetSelectEntry());
1398cdf0e10cSrcweir     return 0;
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, SymbolChangeHdl, SmShowSymbolSet *, EMPTYARG pShowSymbolSet )
1403cdf0e10cSrcweir {
1404cdf0e10cSrcweir     (void) pShowSymbolSet;
1405cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1406cdf0e10cSrcweir     DBG_ASSERT(pShowSymbolSet == &aSymbolSetDisplay, "Sm : falsches Argument");
1407cdf0e10cSrcweir #endif
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir     SelectSymbol(aSymbolSetDisplay.GetSelectSymbol());
1410cdf0e10cSrcweir     return 0;
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, EditClickHdl, Button *, EMPTYARG pButton )
1414cdf0e10cSrcweir {
1415cdf0e10cSrcweir     (void) pButton;
1416cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1417cdf0e10cSrcweir     DBG_ASSERT(pButton == &aEditBtn, "Sm : falsches Argument");
1418cdf0e10cSrcweir #endif
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir     SmSymDefineDialog *pDialog = new SmSymDefineDialog(this, pFontListDev, rSymbolMgr);
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir     // aktuelles Symbol und SymbolSet am neuen Dialog setzen
1423cdf0e10cSrcweir     const XubString  aSymSetName (aSymbolSets.GetSelectEntry()),
1424cdf0e10cSrcweir                     aSymName    (aSymbolName.GetText());
1425cdf0e10cSrcweir     pDialog->SelectOldSymbolSet(aSymSetName);
1426cdf0e10cSrcweir     pDialog->SelectOldSymbol(aSymName);
1427cdf0e10cSrcweir     pDialog->SelectSymbolSet(aSymSetName);
1428cdf0e10cSrcweir     pDialog->SelectSymbol(aSymName);
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir     // altes SymbolSet merken
1431cdf0e10cSrcweir     XubString  aOldSymbolSet (aSymbolSets.GetSelectEntry());
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir     sal_uInt16 nSymPos = GetSelectedSymbol();
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir     // Dialog an evtl geaenderte Daten des SymbolSet Manager anpassen
1436cdf0e10cSrcweir     if (pDialog->Execute() == RET_OK  &&  rSymbolMgr.IsModified())
1437cdf0e10cSrcweir     {
1438cdf0e10cSrcweir         rSymbolMgr.Save();
1439cdf0e10cSrcweir         FillSymbolSets();
1440cdf0e10cSrcweir     }
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir     // wenn das alte SymbolSet nicht mehr existiert zum ersten gehen
1443cdf0e10cSrcweir     // (soweit eines vorhanden ist)
1444cdf0e10cSrcweir     if (!SelectSymbolSet(aOldSymbolSet)  &&  aSymbolSets.GetEntryCount() > 0)
1445cdf0e10cSrcweir         SelectSymbolSet(aSymbolSets.GetEntry(0));
1446cdf0e10cSrcweir     else
1447cdf0e10cSrcweir     {
1448cdf0e10cSrcweir         // just update display of current symbol set
1449cdf0e10cSrcweir         DBG_ASSERT( aSymSetName == aSymSetName, "unexpected change in symbol set name" );
1450cdf0e10cSrcweir         aSymbolSet      = rSymbolMgr.GetSymbolSet( aSymbolSetName );
1451cdf0e10cSrcweir         aSymbolSetDisplay.SetSymbolSet( aSymbolSet );
1452cdf0e10cSrcweir     }
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir     if (nSymPos >= aSymbolSet.size())
1455cdf0e10cSrcweir         nSymPos = static_cast< sal_uInt16 >(aSymbolSet.size()) - 1;
1456cdf0e10cSrcweir     SelectSymbol( nSymPos );
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir     delete pDialog;
1459cdf0e10cSrcweir     return 0;
1460cdf0e10cSrcweir }
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, SymbolDblClickHdl, SmShowSymbolSet *, EMPTYARG pShowSymbolSet )
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir     (void) pShowSymbolSet;
1466cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1467cdf0e10cSrcweir     DBG_ASSERT(pShowSymbolSet == &aSymbolSetDisplay, "Sm : falsches Argument");
1468cdf0e10cSrcweir #endif
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir     GetClickHdl(&aGetBtn);
1471cdf0e10cSrcweir     EndDialog(RET_OK);
1472cdf0e10cSrcweir     return 0;
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton )
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir     (void) pButton;
1479cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1480cdf0e10cSrcweir     DBG_ASSERT(pButton == &aGetBtn, "Sm : falscher Button");
1481cdf0e10cSrcweir #endif
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir     const SmSym *pSym = GetSymbol();
1484cdf0e10cSrcweir     if (pSym)
1485cdf0e10cSrcweir     {
1486cdf0e10cSrcweir         String  aText ('%');
1487cdf0e10cSrcweir         aText += pSym->GetName();
1488cdf0e10cSrcweir         aText += (sal_Unicode)' ';
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir         rViewSh.GetViewFrame()->GetDispatcher()->Execute(
1491cdf0e10cSrcweir                 SID_INSERTTEXT, SFX_CALLMODE_STANDARD,
1492cdf0e10cSrcweir                 new SfxStringItem(SID_INSERTTEXT, aText), 0L);
1493cdf0e10cSrcweir     }
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir     return 0;
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmSymbolDialog, CloseClickHdl, Button *, EMPTYARG pButton )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir     (void) pButton;
1502cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1503cdf0e10cSrcweir     DBG_ASSERT(pButton == &aCloseBtn, "Sm : falscher Button");
1504cdf0e10cSrcweir #endif
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir     EndDialog(sal_True);
1507cdf0e10cSrcweir     return 0;
1508cdf0e10cSrcweir }
1509cdf0e10cSrcweir IMPL_LINK_INLINE_END( SmSymbolDialog, CloseClickHdl, Button *, pButton )
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir SmSymbolDialog::SmSymbolDialog(Window *pParent, OutputDevice *pFntListDevice,
1513cdf0e10cSrcweir         SmSymbolManager &rMgr, SmViewShell &rViewShell, sal_Bool bFreeRes) :
1514cdf0e10cSrcweir     ModalDialog         (pParent, SmResId(RID_SYMBOLDIALOG)),
1515cdf0e10cSrcweir     aSymbolSetText      (this, SmResId(1)),
1516cdf0e10cSrcweir     aSymbolSets         (this, SmResId(1)),
1517cdf0e10cSrcweir     aSymbolSetDisplay   (this, SmResId(1)),
1518cdf0e10cSrcweir     aSymbolName         (this, SmResId(2)),
1519cdf0e10cSrcweir     aSymbolDisplay      (this, SmResId(2)),
1520cdf0e10cSrcweir     aGetBtn             (this, SmResId(2)),
1521cdf0e10cSrcweir     aCloseBtn           (this, SmResId(3)),
1522cdf0e10cSrcweir     aEditBtn            (this, SmResId(1)),
1523cdf0e10cSrcweir     rViewSh             (rViewShell),
1524cdf0e10cSrcweir     rSymbolMgr          (rMgr),
1525cdf0e10cSrcweir     pFontListDev        (pFntListDevice)
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir     if (bFreeRes)
1528cdf0e10cSrcweir         FreeResource();
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir     aSymbolSetName = String();
1531cdf0e10cSrcweir     aSymbolSet.clear();
1532cdf0e10cSrcweir     FillSymbolSets();
1533cdf0e10cSrcweir     if (aSymbolSets.GetEntryCount() > 0)
1534cdf0e10cSrcweir         SelectSymbolSet(aSymbolSets.GetEntry(0));
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir     InitColor_Impl();
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir     // preview like controls should have a 2D look
1539cdf0e10cSrcweir     aSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO );
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir     aSymbolSets      .SetSelectHdl  (LINK(this, SmSymbolDialog, SymbolSetChangeHdl));
1542cdf0e10cSrcweir     aSymbolSetDisplay.SetSelectHdl  (LINK(this, SmSymbolDialog, SymbolChangeHdl));
1543cdf0e10cSrcweir     aSymbolSetDisplay.SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
1544cdf0e10cSrcweir     aSymbolDisplay   .SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
1545cdf0e10cSrcweir     aCloseBtn        .SetClickHdl   (LINK(this, SmSymbolDialog, CloseClickHdl));
1546cdf0e10cSrcweir     aEditBtn         .SetClickHdl   (LINK(this, SmSymbolDialog, EditClickHdl));
1547cdf0e10cSrcweir     aGetBtn          .SetClickHdl   (LINK(this, SmSymbolDialog, GetClickHdl));
1548cdf0e10cSrcweir }
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir SmSymbolDialog::~SmSymbolDialog()
1552cdf0e10cSrcweir {
1553cdf0e10cSrcweir }
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir 
1556cdf0e10cSrcweir void SmSymbolDialog::InitColor_Impl()
1557cdf0e10cSrcweir {
1558cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1559cdf0e10cSrcweir     Color aBC( GetDisplayBackground().GetColor() );
1560cdf0e10cSrcweir #endif
1561cdf0e10cSrcweir     ColorData   nBgCol  = COL_WHITE,
1562cdf0e10cSrcweir                 nTxtCol = COL_BLACK;
1563cdf0e10cSrcweir     const StyleSettings &rS = GetSettings().GetStyleSettings();
1564cdf0e10cSrcweir     if (rS.GetHighContrastMode())
1565cdf0e10cSrcweir     {
1566cdf0e10cSrcweir         nBgCol  = rS.GetFieldColor().GetColor();
1567cdf0e10cSrcweir         nTxtCol = rS.GetFieldTextColor().GetColor();
1568cdf0e10cSrcweir     }
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir     Color aTmpColor( nBgCol );
1571cdf0e10cSrcweir     Wallpaper aWall( aTmpColor );
1572cdf0e10cSrcweir     Color aTxtColor( nTxtCol );
1573cdf0e10cSrcweir     aSymbolDisplay   .SetBackground( aWall );
1574cdf0e10cSrcweir     aSymbolDisplay   .SetTextColor( aTxtColor );
1575cdf0e10cSrcweir     aSymbolSetDisplay.SetBackground( aWall );
1576cdf0e10cSrcweir     aSymbolSetDisplay.SetTextColor( aTxtColor );
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt )
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS  &&
1583cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1584cdf0e10cSrcweir             InitColor_Impl();
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir     ModalDialog::DataChanged( rDCEvt );
1587cdf0e10cSrcweir }
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir sal_Bool SmSymbolDialog::SelectSymbolSet(const XubString &rSymbolSetName)
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir     sal_Bool    bRet = sal_False;
1593cdf0e10cSrcweir     sal_uInt16  nPos = aSymbolSets.GetEntryPos(rSymbolSetName);
1594cdf0e10cSrcweir 
1595cdf0e10cSrcweir     aSymbolSetName = String();
1596cdf0e10cSrcweir     aSymbolSet.clear();
1597cdf0e10cSrcweir     if (nPos != LISTBOX_ENTRY_NOTFOUND)
1598cdf0e10cSrcweir     {
1599cdf0e10cSrcweir         aSymbolSets.SelectEntryPos(nPos);
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir         aSymbolSetName  = rSymbolSetName;
1602cdf0e10cSrcweir         aSymbolSet      = rSymbolMgr.GetSymbolSet( aSymbolSetName );
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir         // sort symbols by Unicode position (useful for displaying Greek characters alphabetically)
1605cdf0e10cSrcweir         std::sort( aSymbolSet.begin(), aSymbolSet.end(), lt_SmSymPtr() );
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir         aSymbolSetDisplay.SetSymbolSet( aSymbolSet );
1608cdf0e10cSrcweir         if (aSymbolSet.size() > 0)
1609cdf0e10cSrcweir             SelectSymbol(0);
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir         bRet = sal_True;
1612cdf0e10cSrcweir     }
1613cdf0e10cSrcweir     else
1614cdf0e10cSrcweir         aSymbolSets.SetNoSelection();
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir     return bRet;
1617cdf0e10cSrcweir }
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir 
1620cdf0e10cSrcweir void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo)
1621cdf0e10cSrcweir {
1622cdf0e10cSrcweir     const SmSym *pSym = NULL;
1623cdf0e10cSrcweir     if (aSymbolSetName.Len() > 0  &&  nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size()))
1624cdf0e10cSrcweir         pSym = aSymbolSet[ nSymbolNo ];
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir     aSymbolSetDisplay.SelectSymbol(nSymbolNo);
1627cdf0e10cSrcweir     aSymbolDisplay.SetSymbol(pSym);
1628cdf0e10cSrcweir     aSymbolName.SetText(pSym ? pSym->GetName() : XubString());
1629cdf0e10cSrcweir }
1630cdf0e10cSrcweir 
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir const SmSym * SmSymbolDialog::GetSymbol() const
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir     sal_uInt16 nSymbolNo = aSymbolSetDisplay.GetSelectSymbol();
1635cdf0e10cSrcweir     bool bValid = aSymbolSetName.Len() > 0  &&  nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size());
1636cdf0e10cSrcweir     return bValid ? aSymbolSet[ nSymbolNo ] : NULL;
1637cdf0e10cSrcweir }
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir void SmShowChar::Paint(const Rectangle &rRect)
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir     Control::Paint( rRect );
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir     OUString aText( GetText() );
1648cdf0e10cSrcweir     if (aText.getLength() > 0)
1649cdf0e10cSrcweir     {
1650cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1651cdf0e10cSrcweir         sal_Int32 nPos = 0;
1652cdf0e10cSrcweir         sal_UCS4 cChar = aText.iterateCodePoints( &nPos );
1653cdf0e10cSrcweir         (void) cChar;
1654cdf0e10cSrcweir #endif
1655cdf0e10cSrcweir         Size aTextSize(GetTextWidth(aText), GetTextHeight());
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir         DrawText(Point((GetOutputSize().Width()  - aTextSize.Width())  / 2,
1658cdf0e10cSrcweir                        (GetOutputSize().Height() * 7/10)), aText);
1659cdf0e10cSrcweir     }
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir void SmShowChar::SetSymbol( const SmSym *pSym )
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir     if (pSym)
1666cdf0e10cSrcweir         SetSymbol( pSym->GetCharacter(), pSym->GetFace() );
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir void SmShowChar::SetSymbol( sal_UCS4 cChar, const Font &rFont )
1671cdf0e10cSrcweir {
1672cdf0e10cSrcweir     Font aFont( rFont );
1673cdf0e10cSrcweir     aFont.SetSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3) );
1674cdf0e10cSrcweir     aFont.SetAlign(ALIGN_BASELINE);
1675cdf0e10cSrcweir     SetFont(aFont);
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir     String aText( OUString( &cChar, 1) );
1678cdf0e10cSrcweir     SetText( aText );
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir     Invalidate();
1681cdf0e10cSrcweir }
1682cdf0e10cSrcweir 
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, sal_Bool bDeleteText)
1687cdf0e10cSrcweir {
1688cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1689cdf0e10cSrcweir     DBG_ASSERT(&rComboBox == &aOldSymbols  ||  &rComboBox == &aSymbols,
1690cdf0e10cSrcweir         "Sm : falsche ComboBox");
1691cdf0e10cSrcweir #endif
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir     rComboBox.Clear();
1694cdf0e10cSrcweir     if (bDeleteText)
1695cdf0e10cSrcweir         rComboBox.SetText(XubString());
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir     ComboBox &rBox = &rComboBox == &aOldSymbols ? aOldSymbolSets : aSymbolSets;
1698cdf0e10cSrcweir     SymbolPtrVec_t aSymSet( aSymbolMgrCopy.GetSymbolSet( rBox.GetText() ) );
1699cdf0e10cSrcweir     for (size_t i = 0;  i < aSymSet.size();  ++i)
1700cdf0e10cSrcweir         rComboBox.InsertEntry( aSymSet[i]->GetName() );
1701cdf0e10cSrcweir }
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, sal_Bool bDeleteText)
1705cdf0e10cSrcweir {
1706cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1707cdf0e10cSrcweir     DBG_ASSERT(&rComboBox == &aOldSymbolSets  ||  &rComboBox == &aSymbolSets,
1708cdf0e10cSrcweir         "Sm : falsche ComboBox");
1709cdf0e10cSrcweir #endif
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir     rComboBox.Clear();
1712cdf0e10cSrcweir     if (bDeleteText)
1713cdf0e10cSrcweir         rComboBox.SetText(XubString());
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir     const std::set< String >  aSymbolSetNames( aSymbolMgrCopy.GetSymbolSetNames() );
1716cdf0e10cSrcweir     std::set< String >::const_iterator aIt( aSymbolSetNames.begin() );
1717cdf0e10cSrcweir     for ( ;  aIt != aSymbolSetNames.end();  ++aIt)
1718cdf0e10cSrcweir         rComboBox.InsertEntry( *aIt );
1719cdf0e10cSrcweir }
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir void SmSymDefineDialog::FillFonts(sal_Bool bDelete)
1723cdf0e10cSrcweir {
1724cdf0e10cSrcweir     aFonts.Clear();
1725cdf0e10cSrcweir     if (bDelete)
1726cdf0e10cSrcweir         aFonts.SetNoSelection();
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir     // alle Fonts der 'FontList' in die Fontliste aufnehmen
1729cdf0e10cSrcweir     // von denen mit gleichen Namen jedoch nur einen (denn der Style wird
1730cdf0e10cSrcweir     // ueber die 'FontStyleBox' gewaehlt und nicht auch noch hier)
1731cdf0e10cSrcweir     if (pFontList)
1732cdf0e10cSrcweir     {
1733cdf0e10cSrcweir         sal_uInt16  nCount = pFontList->GetFontNameCount();
1734cdf0e10cSrcweir         for (sal_uInt16 i = 0;  i < nCount;  i++)
1735cdf0e10cSrcweir             aFonts.InsertEntry( pFontList->GetFontName(i).GetName() );
1736cdf0e10cSrcweir     }
1737cdf0e10cSrcweir }
1738cdf0e10cSrcweir 
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir void SmSymDefineDialog::FillStyles(sal_Bool bDeleteText)
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir     aStyles.Clear();
1743cdf0e10cSrcweir     if (bDeleteText)
1744cdf0e10cSrcweir         aStyles.SetText(XubString());
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir     XubString aText (aFonts.GetSelectEntry());
1747cdf0e10cSrcweir     if (aText.Len() != 0)
1748cdf0e10cSrcweir     {
1749cdf0e10cSrcweir         //aStyles.Fill(aText, &aFontList);
1750cdf0e10cSrcweir         // eigene StyleName's verwenden
1751cdf0e10cSrcweir         const SmFontStyles &rStyles = GetFontStyles();
1752cdf0e10cSrcweir         for (sal_uInt16 i = 0;  i < rStyles.GetCount();  i++)
1753cdf0e10cSrcweir             aStyles.InsertEntry( rStyles.GetStyleName(i) );
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1756cdf0e10cSrcweir         DBG_ASSERT(aStyles.GetEntryCount() > 0, "Sm : keine Styles vorhanden");
1757cdf0e10cSrcweir #endif
1758cdf0e10cSrcweir         aStyles.SetText( aStyles.GetEntry(0) );
1759cdf0e10cSrcweir     }
1760cdf0e10cSrcweir }
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox)
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1766cdf0e10cSrcweir     DBG_ASSERT(&rComboBox == &aOldSymbols  ||  &rComboBox == &aSymbols,
1767cdf0e10cSrcweir         "Sm : falsche ComboBox");
1768cdf0e10cSrcweir #endif
1769cdf0e10cSrcweir     return aSymbolMgrCopy.GetSymbolByName(rComboBox.GetText());
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir 
1773cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, OldSymbolChangeHdl, ComboBox *, EMPTYARG pComboBox )
1774cdf0e10cSrcweir {
1775cdf0e10cSrcweir     (void) pComboBox;
1776cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1777cdf0e10cSrcweir     DBG_ASSERT(pComboBox == &aOldSymbols, "Sm : falsches Argument");
1778cdf0e10cSrcweir #endif
1779cdf0e10cSrcweir     SelectSymbol(aOldSymbols, aOldSymbols.GetText(), sal_False);
1780cdf0e10cSrcweir     return 0;
1781cdf0e10cSrcweir }
1782cdf0e10cSrcweir 
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, OldSymbolSetChangeHdl, ComboBox *, EMPTYARG pComboBox )
1785cdf0e10cSrcweir {
1786cdf0e10cSrcweir     (void) pComboBox;
1787cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1788cdf0e10cSrcweir     DBG_ASSERT(pComboBox == &aOldSymbolSets, "Sm : falsches Argument");
1789cdf0e10cSrcweir #endif
1790cdf0e10cSrcweir     SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), sal_False);
1791cdf0e10cSrcweir     return 0;
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, ModifyHdl, ComboBox *, pComboBox )
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir     // merken der Cursorposition zum wiederherstellen derselben
1798cdf0e10cSrcweir     Selection  aSelection (pComboBox->GetSelection());
1799cdf0e10cSrcweir 
1800cdf0e10cSrcweir     if (pComboBox == &aSymbols)
1801cdf0e10cSrcweir         SelectSymbol(aSymbols, aSymbols.GetText(), sal_False);
1802cdf0e10cSrcweir     else if (pComboBox == &aSymbolSets)
1803cdf0e10cSrcweir         SelectSymbolSet(aSymbolSets, aSymbolSets.GetText(), sal_False);
1804cdf0e10cSrcweir     else if (pComboBox == &aOldSymbols)
1805cdf0e10cSrcweir         // nur Namen aus der Liste erlauben
1806cdf0e10cSrcweir         SelectSymbol(aOldSymbols, aOldSymbols.GetText(), sal_True);
1807cdf0e10cSrcweir     else if (pComboBox == &aOldSymbolSets)
1808cdf0e10cSrcweir         // nur Namen aus der Liste erlauben
1809cdf0e10cSrcweir         SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), sal_True);
1810cdf0e10cSrcweir     else if (pComboBox == &aStyles)
1811cdf0e10cSrcweir         // nur Namen aus der Liste erlauben (ist hier eh immer der Fall)
1812cdf0e10cSrcweir         SelectStyle(aStyles.GetText(), sal_True);
1813cdf0e10cSrcweir     else
1814cdf0e10cSrcweir     {
1815cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1816cdf0e10cSrcweir         DBG_ASSERT(0, "Sm : falsche ComboBox Argument");
1817cdf0e10cSrcweir #endif
1818cdf0e10cSrcweir     }
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir     pComboBox->SetSelection(aSelection);
1821cdf0e10cSrcweir 
1822cdf0e10cSrcweir     UpdateButtons();
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir     return 0;
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir 
1827cdf0e10cSrcweir 
1828cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, FontChangeHdl, ListBox *, EMPTYARG pListBox )
1829cdf0e10cSrcweir {
1830cdf0e10cSrcweir     (void) pListBox;
1831cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1832cdf0e10cSrcweir     DBG_ASSERT(pListBox == &aFonts, "Sm : falsches Argument");
1833cdf0e10cSrcweir #endif
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir     SelectFont(aFonts.GetSelectEntry());
1836cdf0e10cSrcweir     return 0;
1837cdf0e10cSrcweir }
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir 
1840cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, SubsetChangeHdl, ListBox *, EMPTYARG pListBox )
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir     (void) pListBox;
1843cdf0e10cSrcweir     sal_uInt16 nPos = aFontsSubsetLB.GetSelectEntryPos();
1844cdf0e10cSrcweir     if (LISTBOX_ENTRY_NOTFOUND != nPos)
1845cdf0e10cSrcweir     {
1846cdf0e10cSrcweir         const Subset* pSubset = reinterpret_cast<const Subset*> (aFontsSubsetLB.GetEntryData( nPos ));
1847cdf0e10cSrcweir         if (pSubset)
1848cdf0e10cSrcweir         {
1849cdf0e10cSrcweir             aCharsetDisplay.SelectCharacter( pSubset->GetRangeMin() );
1850cdf0e10cSrcweir         }
1851cdf0e10cSrcweir     }
1852cdf0e10cSrcweir     return 0;
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir 
1856cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox )
1857cdf0e10cSrcweir {
1858cdf0e10cSrcweir     (void) pComboBox;
1859cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1860cdf0e10cSrcweir     DBG_ASSERT(pComboBox == &aStyles, "Sm : falsches Argument");
1861cdf0e10cSrcweir #endif
1862cdf0e10cSrcweir 
1863cdf0e10cSrcweir     SelectStyle(aStyles.GetText());
1864cdf0e10cSrcweir     return 0;
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, CharHighlightHdl, Control *, EMPTYARG )
1869cdf0e10cSrcweir {
1870cdf0e10cSrcweir    sal_UCS4 cChar = aCharsetDisplay.GetSelectCharacter();
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1873cdf0e10cSrcweir     DBG_ASSERT( pSubsetMap, "SubsetMap missing" );
1874cdf0e10cSrcweir #endif
1875cdf0e10cSrcweir     if (pSubsetMap)
1876cdf0e10cSrcweir     {
1877cdf0e10cSrcweir         const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
1878cdf0e10cSrcweir         if (pSubset)
1879cdf0e10cSrcweir             aFontsSubsetLB.SelectEntry( pSubset->GetName() );
1880cdf0e10cSrcweir         else
1881cdf0e10cSrcweir             aFontsSubsetLB.SetNoSelection();
1882cdf0e10cSrcweir     }
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir     aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() );
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir     UpdateButtons();
1887cdf0e10cSrcweir 
1888cdf0e10cSrcweir     // display Unicode position as symbol name while iterating over characters
1889cdf0e10cSrcweir     const String aHex( String::CreateFromInt64( cChar, 16 ).ToUpperAscii() );
1890cdf0e10cSrcweir     const String aPattern( A2OU( aHex.Len() > 4 ? "Ux000000" : "Ux0000" ) );
1891cdf0e10cSrcweir     String aUnicodePos( aPattern.Copy( 0, aPattern.Len() - aHex.Len() ) );
1892cdf0e10cSrcweir     aUnicodePos += aHex;
1893cdf0e10cSrcweir     aSymbols.SetText( aUnicodePos );
1894cdf0e10cSrcweir     aSymbolName.SetText( aUnicodePos );
1895cdf0e10cSrcweir 
1896cdf0e10cSrcweir     return 0;
1897cdf0e10cSrcweir }
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir 
1900cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton )
1901cdf0e10cSrcweir {
1902cdf0e10cSrcweir     (void) pButton;
1903cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1904cdf0e10cSrcweir     DBG_ASSERT(pButton == &aAddBtn, "Sm : falsches Argument");
1905cdf0e10cSrcweir     DBG_ASSERT(aAddBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??");
1906cdf0e10cSrcweir #endif
1907cdf0e10cSrcweir 
1908cdf0e10cSrcweir     // add symbol
1909cdf0e10cSrcweir     const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(),
1910cdf0e10cSrcweir             aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() );
1911cdf0e10cSrcweir     //DBG_ASSERT( aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL, "symbol already exists" );
1912cdf0e10cSrcweir     aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol );
1913cdf0e10cSrcweir 
1914cdf0e10cSrcweir     // update display of new symbol
1915cdf0e10cSrcweir     aSymbolDisplay.SetSymbol( &aNewSymbol );
1916cdf0e10cSrcweir     aSymbolName.SetText( aNewSymbol.GetName() );
1917cdf0e10cSrcweir     aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() );
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir     // update list box entries
1920cdf0e10cSrcweir     FillSymbolSets(aOldSymbolSets, sal_False);
1921cdf0e10cSrcweir     FillSymbolSets(aSymbolSets,    sal_False);
1922cdf0e10cSrcweir     FillSymbols(aOldSymbols ,sal_False);
1923cdf0e10cSrcweir     FillSymbols(aSymbols    ,sal_False);
1924cdf0e10cSrcweir 
1925cdf0e10cSrcweir     UpdateButtons();
1926cdf0e10cSrcweir 
1927cdf0e10cSrcweir     return 0;
1928cdf0e10cSrcweir }
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
1932cdf0e10cSrcweir {
1933cdf0e10cSrcweir     (void) pButton;
1934cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1935cdf0e10cSrcweir     DBG_ASSERT(pButton == &aChangeBtn, "Sm : falsches Argument");
1936cdf0e10cSrcweir     DBG_ASSERT(aChangeBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??");
1937cdf0e10cSrcweir #endif
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir     // get new Sybol to use
1940cdf0e10cSrcweir     //! get font from symbol-disp lay since charset-display does not keep
1941cdf0e10cSrcweir     //! the bold attribut.
1942cdf0e10cSrcweir     const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(),
1943cdf0e10cSrcweir             aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() );
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir     // remove old symbol if the name was changed then add new one
1946cdf0e10cSrcweir //    const bool bSetNameChanged    = aOldSymbolSets.GetText() != aSymbolSets.GetText();
1947cdf0e10cSrcweir     const bool bNameChanged       = aOldSymbols.GetText() != aSymbols.GetText();
1948cdf0e10cSrcweir     if (bNameChanged)
1949cdf0e10cSrcweir         aSymbolMgrCopy.RemoveSymbol( aOldSymbols.GetText() );
1950cdf0e10cSrcweir     aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol, true );
1951cdf0e10cSrcweir 
1952cdf0e10cSrcweir     // clear display for original symbol if necessary
1953cdf0e10cSrcweir     if (bNameChanged)
1954cdf0e10cSrcweir         SetOrigSymbol(NULL, XubString());
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir     // update display of new symbol
1957cdf0e10cSrcweir     aSymbolDisplay.SetSymbol( &aNewSymbol );
1958cdf0e10cSrcweir     aSymbolName.SetText( aNewSymbol.GetName() );
1959cdf0e10cSrcweir     aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() );
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir     // update list box entries
1962cdf0e10cSrcweir     FillSymbolSets(aOldSymbolSets, sal_False);
1963cdf0e10cSrcweir     FillSymbolSets(aSymbolSets,    sal_False);
1964cdf0e10cSrcweir     FillSymbols(aOldSymbols ,sal_False);
1965cdf0e10cSrcweir     FillSymbols(aSymbols    ,sal_False);
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir     UpdateButtons();
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir     return 0;
1970cdf0e10cSrcweir }
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir 
1973cdf0e10cSrcweir IMPL_LINK( SmSymDefineDialog, DeleteClickHdl, Button *, EMPTYARG pButton )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir     (void) pButton;
1976cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1977cdf0e10cSrcweir     DBG_ASSERT(pButton == &aDeleteBtn, "Sm : falsches Argument");
1978cdf0e10cSrcweir     DBG_ASSERT(aDeleteBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??");
1979cdf0e10cSrcweir #endif
1980cdf0e10cSrcweir 
1981cdf0e10cSrcweir     if (pOrigSymbol)
1982cdf0e10cSrcweir     {
1983cdf0e10cSrcweir         aSymbolMgrCopy.RemoveSymbol( pOrigSymbol->GetName() );
1984cdf0e10cSrcweir 
1985cdf0e10cSrcweir         // clear display for original symbol
1986cdf0e10cSrcweir         SetOrigSymbol(NULL, XubString());
1987cdf0e10cSrcweir 
1988cdf0e10cSrcweir         // update list box entries
1989cdf0e10cSrcweir         FillSymbolSets(aOldSymbolSets, sal_False);
1990cdf0e10cSrcweir         FillSymbolSets(aSymbolSets,    sal_False);
1991cdf0e10cSrcweir         FillSymbols(aOldSymbols ,sal_False);
1992cdf0e10cSrcweir         FillSymbols(aSymbols    ,sal_False);
1993cdf0e10cSrcweir     }
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir     UpdateButtons();
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir     return 0;
1998cdf0e10cSrcweir }
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir void SmSymDefineDialog::UpdateButtons()
2002cdf0e10cSrcweir {
2003cdf0e10cSrcweir     sal_Bool  bAdd    = sal_False,
2004cdf0e10cSrcweir           bChange = sal_False,
2005cdf0e10cSrcweir           bDelete = sal_False,
2006cdf0e10cSrcweir           bEqual;
2007cdf0e10cSrcweir     XubString aTmpSymbolName    (aSymbols.GetText()),
2008cdf0e10cSrcweir               aTmpSymbolSetName (aSymbolSets.GetText());
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir     if (aTmpSymbolName.Len() > 0  &&  aTmpSymbolSetName.Len() > 0)
2011cdf0e10cSrcweir     {
2012cdf0e10cSrcweir         // alle Einstellungen gleich?
2013cdf0e10cSrcweir         //! (Font-, Style- und SymbolSet Name werden nicht case sensitiv verglichen)
2014cdf0e10cSrcweir         bEqual = pOrigSymbol
2015cdf0e10cSrcweir                     && aTmpSymbolSetName.EqualsIgnoreCaseAscii(aOldSymbolSetName.GetText())
2016cdf0e10cSrcweir                     && aTmpSymbolName.Equals(pOrigSymbol->GetName())
2017cdf0e10cSrcweir                     && aFonts.GetSelectEntry().EqualsIgnoreCaseAscii(
2018cdf0e10cSrcweir                             pOrigSymbol->GetFace().GetName())
2019cdf0e10cSrcweir                     && aStyles.GetText().EqualsIgnoreCaseAscii(
2020cdf0e10cSrcweir                             GetFontStyles().GetStyleName(pOrigSymbol->GetFace()))
2021cdf0e10cSrcweir                     && aCharsetDisplay.GetSelectCharacter() == pOrigSymbol->GetCharacter();
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir         // hinzufuegen nur wenn es noch kein Symbol desgleichen Namens gibt
2024cdf0e10cSrcweir         bAdd    = aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL;
2025cdf0e10cSrcweir 
2026cdf0e10cSrcweir         // loeschen nur wenn alle Einstellungen gleich sind
2027cdf0e10cSrcweir         bDelete = pOrigSymbol != NULL;
2028cdf0e10cSrcweir 
2029cdf0e10cSrcweir         // aendern wenn bei gleichem Namen mindestens eine Einstellung anders ist
2030cdf0e10cSrcweir         // oder wenn es noch kein Symbol des neuen Namens gibt (wuerde implizites
2031cdf0e10cSrcweir         // loeschen des bereits vorhandenen Symbols erfordern)
2032cdf0e10cSrcweir //        sal_Bool  bEqualName = pOrigSymbol && aTmpSymbolName == pOrigSymbol->GetName();
2033cdf0e10cSrcweir //      bChange = pOrigSymbol && ( (bEqualName && !bEqual) || (!bEqualName && bAdd) );
2034cdf0e10cSrcweir 
2035cdf0e10cSrcweir         // aendern nur falls altes Symbol vorhanden und am neuen etwas anders ist
2036cdf0e10cSrcweir         bChange = pOrigSymbol && !bEqual;
2037cdf0e10cSrcweir }
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir     aAddBtn   .Enable(bAdd);
2040cdf0e10cSrcweir     aChangeBtn.Enable(bChange);
2041cdf0e10cSrcweir     aDeleteBtn.Enable(bDelete);
2042cdf0e10cSrcweir }
2043cdf0e10cSrcweir 
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir SmSymDefineDialog::SmSymDefineDialog(Window * pParent,
2046cdf0e10cSrcweir         OutputDevice *pFntListDevice, SmSymbolManager &rMgr, sal_Bool bFreeRes) :
2047cdf0e10cSrcweir     ModalDialog         (pParent, SmResId(RID_SYMDEFINEDIALOG)),
2048cdf0e10cSrcweir     aOldSymbolText      (this, SmResId(1)),
2049cdf0e10cSrcweir     aOldSymbols         (this, SmResId(1)),
2050cdf0e10cSrcweir     aOldSymbolSetText   (this, SmResId(2)),
2051cdf0e10cSrcweir     aOldSymbolSets      (this, SmResId(2)),
2052cdf0e10cSrcweir     aCharsetDisplay     (this, SmResId(1)),
2053cdf0e10cSrcweir     aSymbolText         (this, SmResId(9)),
2054cdf0e10cSrcweir     aSymbols            (this, SmResId(4)),
2055cdf0e10cSrcweir     aSymbolSetText      (this, SmResId(10)),
2056cdf0e10cSrcweir     aSymbolSets         (this, SmResId(5)),
2057cdf0e10cSrcweir     aFontText           (this, SmResId(3)),
2058cdf0e10cSrcweir     aFonts              (this, SmResId(1)),
2059cdf0e10cSrcweir     aFontsSubsetFT      (this, SmResId( FT_FONTS_SUBSET )),
2060cdf0e10cSrcweir     aFontsSubsetLB      (this, SmResId( LB_FONTS_SUBSET )),
2061cdf0e10cSrcweir     aStyleText          (this, SmResId(4)),
2062cdf0e10cSrcweir     aStyles             (this, SmResId(3)),
2063cdf0e10cSrcweir     aOldSymbolName      (this, SmResId(7)),
2064cdf0e10cSrcweir     aOldSymbolDisplay   (this, SmResId(3)),
2065cdf0e10cSrcweir     aOldSymbolSetName   (this, SmResId(8)),
2066cdf0e10cSrcweir     aSymbolName         (this, SmResId(5)),
2067cdf0e10cSrcweir     aSymbolDisplay      (this, SmResId(2)),
2068cdf0e10cSrcweir     aSymbolSetName      (this, SmResId(6)),
2069cdf0e10cSrcweir     aOkBtn              (this, SmResId(1)),
2070cdf0e10cSrcweir     aCancelBtn          (this, SmResId(1)),
2071cdf0e10cSrcweir     aAddBtn             (this, SmResId(1)),
2072cdf0e10cSrcweir     aChangeBtn          (this, SmResId(2)),
2073cdf0e10cSrcweir     aDeleteBtn          (this, SmResId(3)),
2074cdf0e10cSrcweir     aRightArrow         (this, SmResId(1)),
2075cdf0e10cSrcweir     aRigthArrow_Im      (SmResId(1)),
2076cdf0e10cSrcweir     aRigthArrow_Im_HC   (SmResId(2)),   // hi-contrast version
2077cdf0e10cSrcweir     rSymbolMgr          (rMgr),
2078cdf0e10cSrcweir     pSubsetMap          (NULL),
2079cdf0e10cSrcweir     pFontList           (NULL)
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir     if (bFreeRes)
2082cdf0e10cSrcweir         FreeResource();
2083cdf0e10cSrcweir 
2084cdf0e10cSrcweir     pFontList = new FontList( pFntListDevice );
2085cdf0e10cSrcweir 
2086cdf0e10cSrcweir     pOrigSymbol = 0;
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir     // auto completion is troublesome since that symbols character also gets automatically selected in the
2089cdf0e10cSrcweir     // display and if the user previously selected a character to define/redefine that one this is bad
2090cdf0e10cSrcweir     aOldSymbols.EnableAutocomplete( sal_False, sal_True );
2091cdf0e10cSrcweir     aSymbols   .EnableAutocomplete( sal_False, sal_True );
2092cdf0e10cSrcweir 
2093cdf0e10cSrcweir     FillFonts();
2094cdf0e10cSrcweir     if (aFonts.GetEntryCount() > 0)
2095cdf0e10cSrcweir         SelectFont(aFonts.GetEntry(0));
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir     InitColor_Impl();
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir     SetSymbolSetManager(rSymbolMgr);
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir     aOldSymbols    .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolChangeHdl));
2102cdf0e10cSrcweir     aOldSymbolSets .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolSetChangeHdl));
2103cdf0e10cSrcweir     aSymbolSets    .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
2104cdf0e10cSrcweir     aOldSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
2105cdf0e10cSrcweir     aSymbols       .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
2106cdf0e10cSrcweir     aOldSymbols    .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
2107cdf0e10cSrcweir     aStyles        .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
2108cdf0e10cSrcweir     aFonts         .SetSelectHdl(LINK(this, SmSymDefineDialog, FontChangeHdl));
2109cdf0e10cSrcweir     aFontsSubsetLB .SetSelectHdl(LINK(this, SmSymDefineDialog, SubsetChangeHdl));
2110cdf0e10cSrcweir     aStyles        .SetSelectHdl(LINK(this, SmSymDefineDialog, StyleChangeHdl));
2111cdf0e10cSrcweir     aAddBtn        .SetClickHdl (LINK(this, SmSymDefineDialog, AddClickHdl));
2112cdf0e10cSrcweir     aChangeBtn     .SetClickHdl (LINK(this, SmSymDefineDialog, ChangeClickHdl));
2113cdf0e10cSrcweir     aDeleteBtn     .SetClickHdl (LINK(this, SmSymDefineDialog, DeleteClickHdl));
2114cdf0e10cSrcweir     aCharsetDisplay.SetHighlightHdl( LINK( this, SmSymDefineDialog, CharHighlightHdl ) );
2115cdf0e10cSrcweir 
2116cdf0e10cSrcweir     // preview like controls should have a 2D look
2117cdf0e10cSrcweir     aOldSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO );
2118cdf0e10cSrcweir     aSymbolDisplay   .SetBorderStyle( WINDOW_BORDER_MONO );
2119cdf0e10cSrcweir }
2120cdf0e10cSrcweir 
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir SmSymDefineDialog::~SmSymDefineDialog()
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir     delete pSubsetMap;
2125cdf0e10cSrcweir     delete pOrigSymbol;
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir void SmSymDefineDialog::InitColor_Impl()
2129cdf0e10cSrcweir {
2130cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2131cdf0e10cSrcweir     Color aBC( GetDisplayBackground().GetColor() );
2132cdf0e10cSrcweir #endif
2133cdf0e10cSrcweir     ColorData   nBgCol  = COL_WHITE,
2134cdf0e10cSrcweir                 nTxtCol = COL_BLACK;
2135cdf0e10cSrcweir     sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
2136cdf0e10cSrcweir     if (bHighContrast)
2137cdf0e10cSrcweir     {
2138cdf0e10cSrcweir         const StyleSettings &rS = GetSettings().GetStyleSettings();
2139cdf0e10cSrcweir         nBgCol  = rS.GetFieldColor().GetColor();
2140cdf0e10cSrcweir         nTxtCol = rS.GetFieldTextColor().GetColor();
2141cdf0e10cSrcweir     }
2142cdf0e10cSrcweir 
2143cdf0e10cSrcweir     Color aTmpColor( nBgCol );
2144cdf0e10cSrcweir     Wallpaper aWall( aTmpColor );
2145cdf0e10cSrcweir     Color aTxtColor( nTxtCol );
2146cdf0e10cSrcweir     aCharsetDisplay  .SetBackground( aWall );
2147cdf0e10cSrcweir     aCharsetDisplay  .SetTextColor( aTxtColor );
2148cdf0e10cSrcweir     aOldSymbolDisplay.SetBackground( aWall );
2149cdf0e10cSrcweir     aOldSymbolDisplay.SetTextColor( aTxtColor );
2150cdf0e10cSrcweir     aSymbolDisplay   .SetBackground( aWall );
2151cdf0e10cSrcweir     aSymbolDisplay   .SetTextColor( aTxtColor );
2152cdf0e10cSrcweir 
2153cdf0e10cSrcweir     const Image &rArrowRight = bHighContrast ? aRigthArrow_Im_HC : aRigthArrow_Im;
2154cdf0e10cSrcweir     aRightArrow.SetImage( rArrowRight );
2155cdf0e10cSrcweir }
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir void SmSymDefineDialog::DataChanged( const DataChangedEvent& rDCEvt )
2159cdf0e10cSrcweir {
2160cdf0e10cSrcweir     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS  &&
2161cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
2162cdf0e10cSrcweir             InitColor_Impl();
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir     ModalDialog::DataChanged( rDCEvt );
2165cdf0e10cSrcweir }
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir 
2168cdf0e10cSrcweir short SmSymDefineDialog::Execute()
2169cdf0e10cSrcweir {
2170cdf0e10cSrcweir     short nResult = ModalDialog::Execute();
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir     // Aenderungen uebernehmen falls Dialog mit OK beendet wurde
2173cdf0e10cSrcweir     if (aSymbolMgrCopy.IsModified()  &&  nResult == RET_OK)
2174cdf0e10cSrcweir         rSymbolMgr = aSymbolMgrCopy;
2175cdf0e10cSrcweir 
2176cdf0e10cSrcweir     return nResult;
2177cdf0e10cSrcweir }
2178cdf0e10cSrcweir 
2179cdf0e10cSrcweir 
2180cdf0e10cSrcweir void SmSymDefineDialog::SetSymbolSetManager(const SmSymbolManager &rMgr)
2181cdf0e10cSrcweir {
2182cdf0e10cSrcweir     aSymbolMgrCopy = rMgr;
2183cdf0e10cSrcweir #ifdef DEBUG
2184cdf0e10cSrcweir //        sal_uInt16 nS = aSymbolMgrCopy.GetSymbolSetCount();
2185cdf0e10cSrcweir #endif
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir     // Das modified Flag der Kopie auf sal_False setzen, damit man spaeter damit
2188cdf0e10cSrcweir     // testen kann ob sich was geaendert hat.
2189cdf0e10cSrcweir     aSymbolMgrCopy.SetModified(sal_False);
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir     FillSymbolSets(aOldSymbolSets);
2192cdf0e10cSrcweir     if (aOldSymbolSets.GetEntryCount() > 0)
2193cdf0e10cSrcweir         SelectSymbolSet(aOldSymbolSets.GetEntry(0));
2194cdf0e10cSrcweir     FillSymbolSets(aSymbolSets);
2195cdf0e10cSrcweir     if (aSymbolSets.GetEntryCount() > 0)
2196cdf0e10cSrcweir         SelectSymbolSet(aSymbolSets.GetEntry(0));
2197cdf0e10cSrcweir     FillSymbols(aOldSymbols);
2198cdf0e10cSrcweir     if (aOldSymbols.GetEntryCount() > 0)
2199cdf0e10cSrcweir         SelectSymbol(aOldSymbols.GetEntry(0));
2200cdf0e10cSrcweir     FillSymbols(aSymbols);
2201cdf0e10cSrcweir     if (aSymbols.GetEntryCount() > 0)
2202cdf0e10cSrcweir         SelectSymbol(aSymbols.GetEntry(0));
2203cdf0e10cSrcweir 
2204cdf0e10cSrcweir     UpdateButtons();
2205cdf0e10cSrcweir }
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox,
2209cdf0e10cSrcweir         const XubString &rSymbolSetName, sal_Bool bDeleteText)
2210cdf0e10cSrcweir {
2211cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2212cdf0e10cSrcweir     DBG_ASSERT(&rComboBox == &aOldSymbolSets  ||  &rComboBox == &aSymbolSets,
2213cdf0e10cSrcweir         "Sm : falsche ComboBox");
2214cdf0e10cSrcweir #endif
2215cdf0e10cSrcweir 
2216cdf0e10cSrcweir     // 'Normalisieren' des SymbolNamens (ohne leading und trailing Leerzeichen)
2217cdf0e10cSrcweir     XubString  aNormName (rSymbolSetName);
2218cdf0e10cSrcweir     aNormName.EraseLeadingChars(' ');
2219cdf0e10cSrcweir     aNormName.EraseTrailingChars(' ');
2220cdf0e10cSrcweir     // und evtl Abweichungen in der Eingabe beseitigen
2221cdf0e10cSrcweir     rComboBox.SetText(aNormName);
2222cdf0e10cSrcweir 
2223cdf0e10cSrcweir     sal_Bool   bRet = sal_False;
2224cdf0e10cSrcweir     sal_uInt16 nPos = rComboBox.GetEntryPos(aNormName);
2225cdf0e10cSrcweir 
2226cdf0e10cSrcweir     if (nPos != COMBOBOX_ENTRY_NOTFOUND)
2227cdf0e10cSrcweir     {
2228cdf0e10cSrcweir         rComboBox.SetText(rComboBox.GetEntry(nPos));
2229cdf0e10cSrcweir         bRet = sal_True;
2230cdf0e10cSrcweir     }
2231cdf0e10cSrcweir     else if (bDeleteText)
2232cdf0e10cSrcweir         rComboBox.SetText(XubString());
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir     sal_Bool  bIsOld = &rComboBox == &aOldSymbolSets;
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir     // setzen des SymbolSet Namens an der zugehoerigen Darstellung
2237cdf0e10cSrcweir     FixedText &rFT = bIsOld ? aOldSymbolSetName : aSymbolSetName;
2238cdf0e10cSrcweir     rFT.SetText(rComboBox.GetText());
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir     // setzen der zum SymbolSet gehoerenden Symbol Namen an der zugehoerigen
2241cdf0e10cSrcweir     // Auswahbox
2242cdf0e10cSrcweir     ComboBox  &rCB = bIsOld ? aOldSymbols : aSymbols;
2243cdf0e10cSrcweir     FillSymbols(rCB, sal_False);
2244cdf0e10cSrcweir 
2245cdf0e10cSrcweir     // bei Wechsel des SymbolSets fuer das alte Zeichen ein gueltiges
2246cdf0e10cSrcweir     // Symbol bzw keins zur Anzeige bringen
2247cdf0e10cSrcweir     if (bIsOld)
2248cdf0e10cSrcweir     {
2249cdf0e10cSrcweir         XubString  aTmpOldSymbolName;
2250cdf0e10cSrcweir         if (aOldSymbols.GetEntryCount() > 0)
2251cdf0e10cSrcweir             aTmpOldSymbolName = aOldSymbols.GetEntry(0);
2252cdf0e10cSrcweir         SelectSymbol(aOldSymbols, aTmpOldSymbolName, sal_True);
2253cdf0e10cSrcweir     }
2254cdf0e10cSrcweir 
2255cdf0e10cSrcweir     UpdateButtons();
2256cdf0e10cSrcweir 
2257cdf0e10cSrcweir     return bRet;
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir 
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol,
2262cdf0e10cSrcweir                                       const XubString &rSymbolSetName)
2263cdf0e10cSrcweir {
2264cdf0e10cSrcweir     // clear old symbol
2265cdf0e10cSrcweir     delete pOrigSymbol;
2266cdf0e10cSrcweir     pOrigSymbol = 0;
2267cdf0e10cSrcweir 
2268cdf0e10cSrcweir     XubString   aSymName,
2269cdf0e10cSrcweir                 aSymSetName;
2270cdf0e10cSrcweir     if (pSymbol)
2271cdf0e10cSrcweir     {
2272cdf0e10cSrcweir         // set new symbol
2273cdf0e10cSrcweir         pOrigSymbol = new SmSym( *pSymbol );
2274cdf0e10cSrcweir 
2275cdf0e10cSrcweir         aSymName    = pSymbol->GetName();
2276cdf0e10cSrcweir         aSymSetName = rSymbolSetName;
2277cdf0e10cSrcweir         aOldSymbolDisplay.SetSymbol( pSymbol );
2278cdf0e10cSrcweir     }
2279cdf0e10cSrcweir     else
2280cdf0e10cSrcweir     {   // loeschen des angezeigten Symbols
2281cdf0e10cSrcweir         aOldSymbolDisplay.SetText(XubString());
2282cdf0e10cSrcweir         aOldSymbolDisplay.Invalidate();
2283cdf0e10cSrcweir     }
2284cdf0e10cSrcweir     aOldSymbolName   .SetText(aSymName);
2285cdf0e10cSrcweir     aOldSymbolSetName.SetText(aSymSetName);
2286cdf0e10cSrcweir }
2287cdf0e10cSrcweir 
2288cdf0e10cSrcweir 
2289cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox,
2290cdf0e10cSrcweir         const XubString &rSymbolName, sal_Bool bDeleteText)
2291cdf0e10cSrcweir {
2292cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
2293cdf0e10cSrcweir     DBG_ASSERT(&rComboBox == &aOldSymbols  ||  &rComboBox == &aSymbols,
2294cdf0e10cSrcweir         "Sm : falsche ComboBox");
2295cdf0e10cSrcweir #endif
2296cdf0e10cSrcweir 
2297cdf0e10cSrcweir     // 'Normalisieren' des SymbolNamens (ohne Leerzeichen)
2298cdf0e10cSrcweir     XubString  aNormName (rSymbolName);
2299cdf0e10cSrcweir     aNormName.EraseAllChars(' ');
2300cdf0e10cSrcweir     // und evtl Abweichungen in der Eingabe beseitigen
2301cdf0e10cSrcweir     rComboBox.SetText(aNormName);
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir     sal_Bool   bRet = sal_False;
2304cdf0e10cSrcweir     sal_uInt16 nPos = rComboBox.GetEntryPos(aNormName);
2305cdf0e10cSrcweir 
2306cdf0e10cSrcweir     sal_Bool  bIsOld = &rComboBox == &aOldSymbols;
2307cdf0e10cSrcweir 
2308cdf0e10cSrcweir     if (nPos != COMBOBOX_ENTRY_NOTFOUND)
2309cdf0e10cSrcweir     {
2310cdf0e10cSrcweir         rComboBox.SetText(rComboBox.GetEntry(nPos));
2311cdf0e10cSrcweir 
2312cdf0e10cSrcweir         if (!bIsOld)
2313cdf0e10cSrcweir         {
2314cdf0e10cSrcweir             const SmSym *pSymbol = GetSymbol(aSymbols);
2315cdf0e10cSrcweir             if (pSymbol)
2316cdf0e10cSrcweir             {
2317cdf0e10cSrcweir                 // Font und Style entsprechend waehlen
2318cdf0e10cSrcweir                 const Font &rFont = pSymbol->GetFace();
2319cdf0e10cSrcweir                 SelectFont(rFont.GetName(), sal_False);
2320cdf0e10cSrcweir                 SelectStyle(GetFontStyles().GetStyleName(rFont), sal_False);
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir                 // da das setzen des Fonts ueber den Style Namen des SymbolsFonts nicht
2323cdf0e10cSrcweir                 // so gut klappt (er kann zB leer sein obwohl der Font selbst 'bold' und
2324cdf0e10cSrcweir                 // 'italic' ist!). Setzen wir hier den Font wie er zum Symbol gehoert
2325cdf0e10cSrcweir                 // zu Fuss.
2326cdf0e10cSrcweir                 aCharsetDisplay.SetFont(rFont);
2327cdf0e10cSrcweir                 aSymbolDisplay.SetFont(rFont);
2328cdf0e10cSrcweir 
2329cdf0e10cSrcweir                 // das zugehoerige Zeichen auswaehlen
2330cdf0e10cSrcweir                 SelectChar(pSymbol->GetCharacter());
2331cdf0e10cSrcweir 
2332cdf0e10cSrcweir                 // since SelectChar will also set the unicode point as text in the
2333cdf0e10cSrcweir                 // symbols box, we have to set the symbol name again to get that one displayed
2334cdf0e10cSrcweir                 aSymbols.SetText( pSymbol->GetName() );
2335cdf0e10cSrcweir             }
2336cdf0e10cSrcweir         }
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir         bRet = sal_True;
2339cdf0e10cSrcweir     }
2340cdf0e10cSrcweir     else if (bDeleteText)
2341cdf0e10cSrcweir         rComboBox.SetText(XubString());
2342cdf0e10cSrcweir 
2343cdf0e10cSrcweir     if (bIsOld)
2344cdf0e10cSrcweir     {
2345cdf0e10cSrcweir         // bei Wechsel des alten Symbols nur vorhandene anzeigen sonst keins
2346cdf0e10cSrcweir         const SmSym *pOldSymbol = NULL;
2347cdf0e10cSrcweir         XubString     aTmpOldSymbolSetName;
2348cdf0e10cSrcweir         if (nPos != COMBOBOX_ENTRY_NOTFOUND)
2349cdf0e10cSrcweir         {
2350cdf0e10cSrcweir             pOldSymbol        = aSymbolMgrCopy.GetSymbolByName(aNormName);
2351cdf0e10cSrcweir             aTmpOldSymbolSetName = aOldSymbolSets.GetText();
2352cdf0e10cSrcweir         }
2353cdf0e10cSrcweir         SetOrigSymbol(pOldSymbol, aTmpOldSymbolSetName);
2354cdf0e10cSrcweir     }
2355cdf0e10cSrcweir     else
2356cdf0e10cSrcweir         aSymbolName.SetText(rComboBox.GetText());
2357cdf0e10cSrcweir 
2358cdf0e10cSrcweir     UpdateButtons();
2359cdf0e10cSrcweir 
2360cdf0e10cSrcweir     return bRet;
2361cdf0e10cSrcweir }
2362cdf0e10cSrcweir 
2363cdf0e10cSrcweir 
2364cdf0e10cSrcweir void SmSymDefineDialog::SetFont(const XubString &rFontName, const XubString &rStyleName)
2365cdf0e10cSrcweir {
2366cdf0e10cSrcweir     // Font (FontInfo) passend zu Namen und Style holen
2367cdf0e10cSrcweir     FontInfo aFI;
2368cdf0e10cSrcweir     if (pFontList)
2369cdf0e10cSrcweir         aFI = pFontList->Get(rFontName, WEIGHT_NORMAL, ITALIC_NONE);
2370cdf0e10cSrcweir     SetFontStyle(rStyleName, aFI);
2371cdf0e10cSrcweir 
2372cdf0e10cSrcweir     aCharsetDisplay.SetFont(aFI);
2373cdf0e10cSrcweir     aSymbolDisplay.SetFont(aFI);
2374cdf0e10cSrcweir 
2375cdf0e10cSrcweir     // update subset listbox for new font's unicode subsets
2376cdf0e10cSrcweir     FontCharMap aFontCharMap;
2377cdf0e10cSrcweir     aCharsetDisplay.GetFontCharMap( aFontCharMap );
2378cdf0e10cSrcweir     if (pSubsetMap)
2379cdf0e10cSrcweir         delete pSubsetMap;
2380cdf0e10cSrcweir     pSubsetMap = new SubsetMap( &aFontCharMap );
2381cdf0e10cSrcweir     //
2382cdf0e10cSrcweir     aFontsSubsetLB.Clear();
2383cdf0e10cSrcweir     bool bFirst = true;
2384cdf0e10cSrcweir     const Subset* pSubset;
2385cdf0e10cSrcweir     while( NULL != (pSubset = pSubsetMap->GetNextSubset( bFirst )) )
2386cdf0e10cSrcweir     {
2387cdf0e10cSrcweir         sal_uInt16 nPos = aFontsSubsetLB.InsertEntry( pSubset->GetName());
2388cdf0e10cSrcweir         aFontsSubsetLB.SetEntryData( nPos, (void *) pSubset );
2389cdf0e10cSrcweir         // subset must live at least as long as the selected font !!!
2390cdf0e10cSrcweir         if( bFirst )
2391cdf0e10cSrcweir             aFontsSubsetLB.SelectEntryPos( nPos );
2392cdf0e10cSrcweir         bFirst = false;
2393cdf0e10cSrcweir     }
2394cdf0e10cSrcweir     if( bFirst )
2395cdf0e10cSrcweir         aFontsSubsetLB.SetNoSelection();
2396cdf0e10cSrcweir     aFontsSubsetLB.Enable( !bFirst );
2397cdf0e10cSrcweir }
2398cdf0e10cSrcweir 
2399cdf0e10cSrcweir 
2400cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectFont(const XubString &rFontName, sal_Bool bApplyFont)
2401cdf0e10cSrcweir {
2402cdf0e10cSrcweir     sal_Bool   bRet = sal_False;
2403cdf0e10cSrcweir     sal_uInt16 nPos = aFonts.GetEntryPos(rFontName);
2404cdf0e10cSrcweir 
2405cdf0e10cSrcweir     if (nPos != LISTBOX_ENTRY_NOTFOUND)
2406cdf0e10cSrcweir     {
2407cdf0e10cSrcweir         aFonts.SelectEntryPos(nPos);
2408cdf0e10cSrcweir         if (aStyles.GetEntryCount() > 0)
2409cdf0e10cSrcweir             SelectStyle(aStyles.GetEntry(0));
2410cdf0e10cSrcweir         if (bApplyFont)
2411cdf0e10cSrcweir         {
2412cdf0e10cSrcweir             SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
2413cdf0e10cSrcweir             // update preview to use new font
2414cdf0e10cSrcweir             aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() );
2415cdf0e10cSrcweir         }
2416cdf0e10cSrcweir         bRet = sal_True;
2417cdf0e10cSrcweir     }
2418cdf0e10cSrcweir     else
2419cdf0e10cSrcweir         aFonts.SetNoSelection();
2420cdf0e10cSrcweir     FillStyles();
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir     UpdateButtons();
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir     return bRet;
2425cdf0e10cSrcweir }
2426cdf0e10cSrcweir 
2427cdf0e10cSrcweir 
2428cdf0e10cSrcweir sal_Bool SmSymDefineDialog::SelectStyle(const XubString &rStyleName, sal_Bool bApplyFont)
2429cdf0e10cSrcweir {
2430cdf0e10cSrcweir     sal_Bool   bRet = sal_False;
2431cdf0e10cSrcweir     sal_uInt16 nPos = aStyles.GetEntryPos(rStyleName);
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir     // falls der Style nicht zur Auswahl steht nehmen wir den erst moeglichen
2434cdf0e10cSrcweir     // (sofern vorhanden)
2435cdf0e10cSrcweir     if (nPos == COMBOBOX_ENTRY_NOTFOUND  &&  aStyles.GetEntryCount() > 0)
2436cdf0e10cSrcweir         nPos = 0;
2437cdf0e10cSrcweir 
2438cdf0e10cSrcweir     if (nPos != COMBOBOX_ENTRY_NOTFOUND)
2439cdf0e10cSrcweir     {
2440cdf0e10cSrcweir         aStyles.SetText(aStyles.GetEntry(nPos));
2441cdf0e10cSrcweir         if (bApplyFont)
2442cdf0e10cSrcweir         {
2443cdf0e10cSrcweir             SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
2444cdf0e10cSrcweir             // update preview to use new font
2445cdf0e10cSrcweir             aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() );
2446cdf0e10cSrcweir         }
2447cdf0e10cSrcweir         bRet = sal_True;
2448cdf0e10cSrcweir     }
2449cdf0e10cSrcweir     else
2450cdf0e10cSrcweir         aStyles.SetText(XubString());
2451cdf0e10cSrcweir 
2452cdf0e10cSrcweir     UpdateButtons();
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir     return bRet;
2455cdf0e10cSrcweir }
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir 
2458cdf0e10cSrcweir void SmSymDefineDialog::SelectChar(xub_Unicode cChar)
2459cdf0e10cSrcweir {
2460cdf0e10cSrcweir     aCharsetDisplay.SelectCharacter( cChar );
2461cdf0e10cSrcweir     aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() );
2462cdf0e10cSrcweir 
2463cdf0e10cSrcweir     UpdateButtons();
2464cdf0e10cSrcweir }
2465cdf0e10cSrcweir 
2466cdf0e10cSrcweir 
2467cdf0e10cSrcweir /**************************************************************************/
2468cdf0e10cSrcweir 
2469