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