2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-04 15:25:45 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "tools/rcid.h"
|
2011-11-18 21:03:31 +00:00
|
|
|
#include <comphelper/string.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/eitem.hxx>
|
|
|
|
#include <svl/intitem.hxx>
|
|
|
|
#include <svl/stritem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/app.hxx>
|
2013-05-22 12:07:21 +01:00
|
|
|
#include <vcl/builder.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <svtools/ctrltool.hxx>
|
|
|
|
#include <sfx2/printer.hxx>
|
2012-04-01 10:17:21 +05:30
|
|
|
#include <vcl/help.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/waitobj.hxx>
|
2002-04-24 09:15:41 +00:00
|
|
|
#include <vcl/settings.hxx>
|
|
|
|
#include <vcl/wall.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/sfx.hrc>
|
2010-10-07 11:02:05 +01:00
|
|
|
#include <osl/diagnose.h>
|
2001-07-23 07:56:32 +00:00
|
|
|
#include <svx/ucsubset.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "dialog.hxx"
|
|
|
|
#include "starmath.hrc"
|
2010-08-03 11:29:55 +02:00
|
|
|
#include "config.hxx"
|
2001-02-07 11:46:52 +00:00
|
|
|
#include "dialog.hrc"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "smmod.hxx"
|
|
|
|
#include "symbol.hxx"
|
|
|
|
#include "view.hxx"
|
|
|
|
#include "document.hxx"
|
2010-08-03 11:29:55 +02:00
|
|
|
#include "unomodel.hxx"
|
|
|
|
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// Since it's better to set/query the FontStyle via its attributes rather
|
|
|
|
// than via the StyleName we create a way to translate
|
2000-09-18 16:07:07 +00:00
|
|
|
// Attribute <-> StyleName
|
|
|
|
|
2001-08-09 11:24:29 +00:00
|
|
|
class SmFontStyles
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aNormal;
|
|
|
|
OUString aBold;
|
|
|
|
OUString aItalic;
|
|
|
|
OUString aBoldItalic;
|
|
|
|
OUString aEmpty;
|
2001-08-09 11:24:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SmFontStyles();
|
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 GetCount() const { return 4; }
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString& GetStyleName( const Font &rFont ) const;
|
|
|
|
const OUString& GetStyleName( sal_uInt16 nIdx ) const;
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2001-08-09 11:24:29 +00:00
|
|
|
|
|
|
|
SmFontStyles::SmFontStyles() :
|
2007-04-26 07:14:32 +00:00
|
|
|
aNormal ( ResId( RID_FONTREGULAR, *SM_MOD()->GetResMgr() ) ),
|
|
|
|
aBold ( ResId( RID_FONTBOLD, *SM_MOD()->GetResMgr() ) ),
|
|
|
|
aItalic ( ResId( RID_FONTITALIC, *SM_MOD()->GetResMgr() ) )
|
2001-08-09 11:24:29 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
aBoldItalic = aBold;
|
2012-10-12 14:48:34 +01:00
|
|
|
aBoldItalic += ", ";
|
2001-08-09 11:24:29 +00:00
|
|
|
aBoldItalic += aItalic;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString& SmFontStyles::GetStyleName( const Font &rFont ) const
|
2001-08-09 11:24:29 +00:00
|
|
|
{
|
2001-10-04 11:25:13 +00:00
|
|
|
//! compare also SmSpecialNode::Prepare
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bBold = IsBold( rFont ),
|
2005-05-03 12:51:22 +00:00
|
|
|
bItalic = IsItalic( rFont );
|
2001-10-04 11:25:13 +00:00
|
|
|
|
2001-08-09 11:24:29 +00:00
|
|
|
if (bBold && bItalic)
|
|
|
|
return aBoldItalic;
|
|
|
|
else if (bItalic)
|
|
|
|
return aItalic;
|
|
|
|
else if (bBold)
|
|
|
|
return aBold;
|
2012-10-12 14:48:34 +01:00
|
|
|
return aNormal;
|
2001-08-09 11:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString& SmFontStyles::GetStyleName( sal_uInt16 nIdx ) const
|
2001-08-09 11:24:29 +00:00
|
|
|
{
|
|
|
|
// 0 = "normal", 1 = "italic",
|
|
|
|
// 2 = "bold", 3 = "bold italic"
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE( nIdx < GetCount(), "index out of range" );
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2001-08-09 11:24:29 +00:00
|
|
|
switch (nIdx)
|
|
|
|
{
|
|
|
|
case 0 : return aNormal;
|
|
|
|
case 1 : return aItalic;
|
|
|
|
case 2 : return aBold;
|
|
|
|
case 3 : return aBoldItalic;
|
|
|
|
}
|
|
|
|
return aEmpty;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2001-08-09 11:24:29 +00:00
|
|
|
const SmFontStyles & GetFontStyles()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-09 11:24:29 +00:00
|
|
|
static const SmFontStyles aImpl;
|
|
|
|
return aImpl;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-08-09 11:24:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
void SetFontStyle(const OUString &rStyleName, Font &rFont)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// Find index related to StyleName. For an empty StyleName it's assumed to be
|
|
|
|
// 0 (neither bold nor italic).
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nIndex = 0;
|
2012-10-12 14:48:34 +01:00
|
|
|
if (!rStyleName.isEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 i;
|
2001-08-09 11:24:29 +00:00
|
|
|
const SmFontStyles &rStyles = GetFontStyles();
|
2012-10-12 14:48:34 +01:00
|
|
|
for (i = 0; i < rStyles.GetCount(); ++i)
|
|
|
|
if (rStyleName == rStyles.GetStyleName(i))
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(i < rStyles.GetCount(), "style-name unknown");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
nIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
rFont.SetItalic((nIndex & 0x1) ? ITALIC_NORMAL : ITALIC_NONE);
|
|
|
|
rFont.SetWeight((nIndex & 0x2) ? WEIGHT_BOLD : WEIGHT_NORMAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
IMPL_LINK_INLINE_START( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, EMPTYARG/*pButton*/ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aZoom.Enable(aSizeZoomed.IsChecked());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, pButton )
|
|
|
|
|
|
|
|
|
|
|
|
SmPrintOptionsTabPage::SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions)
|
|
|
|
: SfxTabPage(pParent, SmResId(RID_PRINTOPTIONPAGE), rOptions),
|
2007-04-26 07:14:32 +00:00
|
|
|
aFixedLine1 (this, SmResId( FL_PRINTOPTIONS )),
|
|
|
|
aTitle (this, SmResId( CB_TITLEROW )),
|
|
|
|
aText (this, SmResId( CB_EQUATION_TEXT )),
|
|
|
|
aFrame (this, SmResId( CB_FRAME )),
|
|
|
|
aFixedLine2 (this, SmResId( FL_PRINT_FORMAT )),
|
|
|
|
aSizeNormal (this, SmResId( RB_ORIGINAL_SIZE )),
|
|
|
|
aSizeScaled (this, SmResId( RB_FIT_TO_PAGE )),
|
|
|
|
aSizeZoomed (this, SmResId( RB_ZOOM )),
|
|
|
|
aZoom (this, SmResId( MF_ZOOM )),
|
2010-10-13 11:39:15 +02:00
|
|
|
aFixedLine3 (this, SmResId( FL_MISC_OPTIONS )),
|
|
|
|
aNoRightSpaces (this, SmResId( CB_IGNORE_SPACING )),
|
|
|
|
aSaveOnlyUsedSymbols (this, SmResId( CB_SAVE_ONLY_USED_SYMBOLS ))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
aSizeNormal.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
|
|
|
|
aSizeScaled.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
|
|
|
|
aSizeZoomed.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
|
|
|
|
|
|
|
|
Reset(rOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_Bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet& rSet)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPrintSize;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (aSizeNormal.IsChecked())
|
|
|
|
nPrintSize = PRINT_SIZE_NORMAL;
|
|
|
|
else if (aSizeScaled.IsChecked())
|
|
|
|
nPrintSize = PRINT_SIZE_SCALED;
|
|
|
|
else
|
|
|
|
nPrintSize = PRINT_SIZE_ZOOMED;
|
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
rSet.Put(SfxUInt16Item(GetWhich(SID_PRINTSIZE), (sal_uInt16) nPrintSize));
|
|
|
|
rSet.Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), (sal_uInt16) aZoom.GetValue()));
|
2000-09-18 16:07:07 +00:00
|
|
|
rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), aTitle.IsChecked()));
|
|
|
|
rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), aText.IsChecked()));
|
|
|
|
rSet.Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), aFrame.IsChecked()));
|
|
|
|
rSet.Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), aNoRightSpaces.IsChecked()));
|
2010-10-13 11:39:15 +02:00
|
|
|
rSet.Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), aSaveOnlyUsedSymbols.IsChecked()));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmPrintOptionsTabPage::Reset(const SfxItemSet& rSet)
|
|
|
|
{
|
|
|
|
SmPrintSize ePrintSize = (SmPrintSize)((const SfxUInt16Item &)rSet.Get(GetWhich(SID_PRINTSIZE))).GetValue();
|
|
|
|
|
|
|
|
aSizeNormal.Check(ePrintSize == PRINT_SIZE_NORMAL);
|
|
|
|
aSizeScaled.Check(ePrintSize == PRINT_SIZE_SCALED);
|
|
|
|
aSizeZoomed.Check(ePrintSize == PRINT_SIZE_ZOOMED);
|
|
|
|
|
|
|
|
aZoom.Enable(aSizeZoomed.IsChecked());
|
|
|
|
|
|
|
|
aZoom.SetValue(((const SfxUInt16Item &)rSet.Get(GetWhich(SID_PRINTZOOM))).GetValue());
|
|
|
|
|
|
|
|
aTitle.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTITLE))).GetValue());
|
|
|
|
aText.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTEXT))).GetValue());
|
|
|
|
aFrame.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTFRAME))).GetValue());
|
|
|
|
aNoRightSpaces.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue());
|
2010-10-13 11:39:15 +02:00
|
|
|
aSaveOnlyUsedSymbols.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SfxTabPage* SmPrintOptionsTabPage::Create(Window* pWindow, const SfxItemSet& rSet)
|
|
|
|
{
|
|
|
|
return (new SmPrintOptionsTabPage(pWindow, rSet));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
void SmShowFont::Paint(const Rectangle& rRect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-24 09:15:41 +00:00
|
|
|
Control::Paint( rRect );
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString Text (GetFont().GetName());
|
2000-09-18 16:07:07 +00:00
|
|
|
Size TextSize(GetTextWidth(Text), GetTextHeight());
|
|
|
|
|
|
|
|
DrawText(Point((GetOutputSize().Width() - TextSize.Width()) / 2,
|
|
|
|
(GetOutputSize().Height() - TextSize.Height()) / 2), Text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmShowFont::SetFont(const Font& rFont)
|
|
|
|
{
|
2002-04-24 09:15:41 +00:00
|
|
|
Color aTxtColor( GetTextColor() );
|
2000-09-18 16:07:07 +00:00
|
|
|
Font aFont (rFont);
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
aFont.SetSize(Size(0, 24));
|
|
|
|
aFont.SetAlign(ALIGN_TOP);
|
|
|
|
Control::SetFont(aFont);
|
2002-04-24 09:15:41 +00:00
|
|
|
|
|
|
|
// keep old text color (new font may have different color)
|
|
|
|
SetTextColor( aTxtColor );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-16 09:58:40 +00:00
|
|
|
IMPL_LINK_INLINE_START( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Face.SetName(pComboBox->GetText());
|
|
|
|
aShowFont.SetFont(Face);
|
|
|
|
return 0;
|
|
|
|
}
|
2000-10-16 09:58:40 +00:00
|
|
|
IMPL_LINK_INLINE_END( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SmFontDialog, FontModifyHdl, ComboBox *, pComboBox )
|
|
|
|
{
|
|
|
|
// if font is available in list then use it
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = pComboBox->GetEntryPos( pComboBox->GetText() );
|
2000-10-16 09:58:40 +00:00
|
|
|
if (COMBOBOX_ENTRY_NOTFOUND != nPos)
|
|
|
|
{
|
|
|
|
FontSelectHdl( pComboBox );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
IMPL_LINK( SmFontDialog, AttrChangeHdl, CheckBox *, EMPTYARG /*pCheckBox*/ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (aBoldCheckBox.IsChecked())
|
|
|
|
Face.SetWeight(FontWeight(WEIGHT_BOLD));
|
|
|
|
else
|
|
|
|
Face.SetWeight(FontWeight(WEIGHT_NORMAL));
|
|
|
|
|
|
|
|
if (aItalicCheckBox.IsChecked())
|
|
|
|
Face.SetItalic(ITALIC_NORMAL);
|
|
|
|
else
|
|
|
|
Face.SetItalic(ITALIC_NONE);
|
|
|
|
|
|
|
|
aShowFont.SetFont(Face);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmFontDialog::SetFont(const Font &rFont)
|
|
|
|
{
|
|
|
|
Face = rFont;
|
|
|
|
|
2005-05-03 12:51:22 +00:00
|
|
|
aFontBox.SetText( Face.GetName() );
|
|
|
|
aBoldCheckBox.Check( IsBold( Face ) );
|
|
|
|
aItalicCheckBox.Check( IsItalic( Face ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aShowFont.SetFont(Face);
|
|
|
|
}
|
|
|
|
|
2012-04-01 10:17:21 +05:30
|
|
|
IMPL_LINK( SmFontDialog, HelpButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
|
|
|
{
|
|
|
|
// start help system
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if( pHelp )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pHelp->Start( OUString( "HID_SMA_FONTDIALOG" ), &aHelpButton1 );
|
2012-04-01 10:17:21 +05:30
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-01-31 17:33:08 +00:00
|
|
|
SmFontDialog::SmFontDialog(Window * pParent,
|
2010-11-06 01:33:05 +01:00
|
|
|
OutputDevice *pFntListDevice, bool bHideCheckboxes, bool bFreeRes)
|
2000-09-18 16:07:07 +00:00
|
|
|
: ModalDialog(pParent,SmResId(RID_FONTDIALOG)),
|
2007-04-26 07:14:32 +00:00
|
|
|
aFixedText1 (this, SmResId(1)),
|
|
|
|
aFontBox (this, SmResId(1)),
|
|
|
|
aBoldCheckBox (this, SmResId(1)),
|
|
|
|
aItalicCheckBox (this, SmResId(2)),
|
|
|
|
aOKButton1 (this, SmResId(1)),
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1 (this, SmResId(1)),
|
2007-04-26 07:14:32 +00:00
|
|
|
aCancelButton1 (this, SmResId(1)),
|
|
|
|
aShowFont (this, SmResId(1)),
|
|
|
|
aFixedText2 (this, SmResId(2))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bFreeRes)
|
|
|
|
FreeResource();
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1.SetClickHdl(LINK(this, SmFontDialog, HelpButtonClickHdl));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
{
|
2012-09-11 10:32:21 +02:00
|
|
|
WaitObject aWait( this );
|
2006-01-31 17:33:08 +00:00
|
|
|
|
|
|
|
FontList aFontList( pFntListDevice );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nCount = aFontList.GetFontNameCount();
|
|
|
|
for (sal_uInt16 i = 0; i < nCount; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
aFontBox.InsertEntry( aFontList.GetFontName(i).GetName() );
|
|
|
|
|
|
|
|
Face.SetSize(Size(0, 24));
|
|
|
|
Face.SetWeight(WEIGHT_NORMAL);
|
|
|
|
Face.SetItalic(ITALIC_NONE);
|
|
|
|
Face.SetFamily(FAMILY_DONTKNOW);
|
|
|
|
Face.SetPitch(PITCH_DONTKNOW);
|
|
|
|
Face.SetCharSet(RTL_TEXTENCODING_DONTKNOW);
|
2010-11-06 01:33:05 +01:00
|
|
|
Face.SetTransparent(true);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
InitColor_Impl();
|
|
|
|
|
|
|
|
// preview like controls should have a 2D look
|
2001-06-15 05:42:09 +00:00
|
|
|
aShowFont.SetBorderStyle( WINDOW_BORDER_MONO );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 09:58:40 +00:00
|
|
|
aFontBox.SetSelectHdl(LINK(this, SmFontDialog, FontSelectHdl));
|
|
|
|
aFontBox.SetModifyHdl(LINK(this, SmFontDialog, FontModifyHdl));
|
2000-09-18 16:07:07 +00:00
|
|
|
aBoldCheckBox.SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
|
|
|
|
aItalicCheckBox.SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
|
2005-05-03 12:51:22 +00:00
|
|
|
|
|
|
|
if (bHideCheckboxes)
|
|
|
|
{
|
2010-11-06 01:33:05 +01:00
|
|
|
aBoldCheckBox.Check( false );
|
|
|
|
aBoldCheckBox.Enable( false );
|
|
|
|
aBoldCheckBox.Show( false );
|
|
|
|
aItalicCheckBox.Check( false );
|
|
|
|
aItalicCheckBox.Enable( false );
|
|
|
|
aItalicCheckBox.Show( false );
|
|
|
|
aFixedText2.Show( false );
|
2005-05-03 12:51:22 +00:00
|
|
|
|
|
|
|
Size aSize( aFontBox.GetSizePixel() );
|
|
|
|
long nComboBoxBottom = aFontBox.GetPosPixel().Y() + aFontBox.GetSizePixel().Height();
|
|
|
|
long nCheckBoxBottom = aItalicCheckBox.GetPosPixel().Y() + aItalicCheckBox.GetSizePixel().Height();
|
|
|
|
aSize.Height() += nCheckBoxBottom - nComboBoxBottom;
|
|
|
|
aFontBox.SetSizePixel( aSize );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
namespace
|
2002-04-24 09:15:41 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
void getColors(Window &rRef, ColorData &rBgCol, ColorData &rTxtCol)
|
2002-04-24 09:15:41 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
const StyleSettings &rS = rRef.GetSettings().GetStyleSettings();
|
|
|
|
if (rS.GetHighContrastMode())
|
|
|
|
{
|
|
|
|
rBgCol = rS.GetFieldColor().GetColor();
|
|
|
|
rTxtCol = rS.GetFieldTextColor().GetColor();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rBgCol = COL_WHITE;
|
|
|
|
rTxtCol = COL_BLACK;
|
|
|
|
}
|
2002-04-24 09:15:41 +00:00
|
|
|
}
|
2013-05-22 12:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SmFontDialog::InitColor_Impl()
|
|
|
|
{
|
|
|
|
ColorData nBgCol, nTxtCol;
|
|
|
|
getColors(*this, nBgCol, nTxtCol);
|
2002-04-24 09:15:41 +00:00
|
|
|
|
2002-05-03 13:35:00 +00:00
|
|
|
Color aTmpColor( nBgCol );
|
|
|
|
Wallpaper aWall( aTmpColor );
|
2002-04-24 09:15:41 +00:00
|
|
|
Color aTxtColor( nTxtCol );
|
|
|
|
aShowFont.SetBackground( aWall );
|
|
|
|
aShowFont.SetTextColor( aTxtColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
InitColor_Impl();
|
|
|
|
|
|
|
|
ModalDialog::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
|
|
|
|
|
|
|
|
if (pQueryBox->Execute() == RET_YES)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmModule *pp = SM_MOD();
|
2001-05-02 15:58:48 +00:00
|
|
|
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
|
|
|
|
WriteTo( aFmt );
|
|
|
|
pp->GetConfig()->SetStandardFormat( aFmt );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete pQueryBox;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-01 10:17:21 +05:30
|
|
|
IMPL_LINK( SmFontSizeDialog, HelpButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
|
|
|
{
|
|
|
|
// start help system
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if( pHelp )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pHelp->Start( OUString( "HID_SMA_FONTSIZEDIALOG" ), &aHelpButton1 );
|
2012-04-01 10:17:21 +05:30
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
SmFontSizeDialog::SmFontSizeDialog(Window * pParent, bool bFreeRes)
|
2000-09-18 16:07:07 +00:00
|
|
|
: ModalDialog(pParent, SmResId(RID_FONTSIZEDIALOG)),
|
2007-04-26 07:14:32 +00:00
|
|
|
aFixedText1(this, SmResId(1)),
|
|
|
|
aBaseSize(this, SmResId(1)),
|
|
|
|
aFixedText4(this, SmResId(4)),
|
|
|
|
aTextSize(this, SmResId(4)),
|
|
|
|
aFixedText5(this, SmResId(5)),
|
|
|
|
aIndexSize(this, SmResId(5)),
|
|
|
|
aFixedText6(this, SmResId(6)),
|
|
|
|
aFunctionSize(this, SmResId(6)),
|
|
|
|
aFixedText7(this, SmResId(7)),
|
|
|
|
aOperatorSize(this, SmResId(7)),
|
|
|
|
aFixedText8(this, SmResId(8)),
|
|
|
|
aBorderSize(this, SmResId(8)),
|
|
|
|
aFixedLine1(this, SmResId(1)),
|
|
|
|
aOKButton1(this, SmResId(1)),
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1(this, SmResId(1)),
|
2007-04-26 07:14:32 +00:00
|
|
|
aCancelButton1(this, SmResId(1)),
|
|
|
|
aDefaultButton(this, SmResId(1))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bFreeRes)
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
aDefaultButton.SetClickHdl(LINK(this, SmFontSizeDialog, DefaultButtonClickHdl));
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1.SetClickHdl(LINK(this, SmFontSizeDialog, HelpButtonClickHdl));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmFontSizeDialog::ReadFrom(const SmFormat &rFormat)
|
|
|
|
{
|
|
|
|
//! aufpassen: richtig runden!
|
|
|
|
aBaseSize.SetValue( SmRoundFraction(
|
|
|
|
Sm100th_mmToPts( rFormat.GetBaseSize().Height() ) ) );
|
|
|
|
|
|
|
|
aTextSize .SetValue( rFormat.GetRelSize(SIZ_TEXT) );
|
|
|
|
aIndexSize .SetValue( rFormat.GetRelSize(SIZ_INDEX) );
|
|
|
|
aFunctionSize.SetValue( rFormat.GetRelSize(SIZ_FUNCTION) );
|
|
|
|
aOperatorSize.SetValue( rFormat.GetRelSize(SIZ_OPERATOR) );
|
|
|
|
aBorderSize .SetValue( rFormat.GetRelSize(SIZ_LIMITS) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmFontSizeDialog::WriteTo(SmFormat &rFormat) const
|
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
rFormat.SetBaseSize( Size(0, SmPtsTo100th_mm( static_cast< long >(aBaseSize.GetValue()))) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
rFormat.SetRelSize(SIZ_TEXT, (sal_uInt16) aTextSize .GetValue());
|
|
|
|
rFormat.SetRelSize(SIZ_INDEX, (sal_uInt16) aIndexSize .GetValue());
|
|
|
|
rFormat.SetRelSize(SIZ_FUNCTION, (sal_uInt16) aFunctionSize.GetValue());
|
|
|
|
rFormat.SetRelSize(SIZ_OPERATOR, (sal_uInt16) aOperatorSize.GetValue());
|
|
|
|
rFormat.SetRelSize(SIZ_LIMITS, (sal_uInt16) aBorderSize .GetValue());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
const Size aTmp (rFormat.GetBaseSize());
|
2011-01-14 17:19:25 +01:00
|
|
|
for (sal_uInt16 i = FNT_BEGIN; i <= FNT_END; i++)
|
2001-08-16 08:20:48 +00:00
|
|
|
rFormat.SetFontSize(i, aTmp);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
rFormat.RequestApplyChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu )
|
|
|
|
{
|
|
|
|
SmFontPickListBox *pActiveListBox;
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bHideCheckboxes = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
switch (pMenu->GetCurItemId())
|
|
|
|
{
|
|
|
|
case 1: pActiveListBox = &aVariableFont; break;
|
|
|
|
case 2: pActiveListBox = &aFunctionFont; break;
|
|
|
|
case 3: pActiveListBox = &aNumberFont; break;
|
|
|
|
case 4: pActiveListBox = &aTextFont; break;
|
2010-11-06 01:33:05 +01:00
|
|
|
case 5: pActiveListBox = &aSerifFont; bHideCheckboxes = true; break;
|
|
|
|
case 6: pActiveListBox = &aSansFont; bHideCheckboxes = true; break;
|
|
|
|
case 7: pActiveListBox = &aFixedFont; bHideCheckboxes = true; break;
|
2000-09-18 16:07:07 +00:00
|
|
|
default:pActiveListBox = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pActiveListBox)
|
|
|
|
{
|
2006-01-31 17:33:08 +00:00
|
|
|
SmFontDialog *pFontDialog = new SmFontDialog(this, pFontListDev, bHideCheckboxes);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pActiveListBox->WriteTo(*pFontDialog);
|
|
|
|
if (pFontDialog->Execute() == RET_OK)
|
|
|
|
pActiveListBox->ReadFrom(*pFontDialog);
|
|
|
|
delete pFontDialog;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
|
|
|
|
if (pQueryBox->Execute() == RET_YES)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmModule *pp = SM_MOD();
|
2001-05-02 15:58:48 +00:00
|
|
|
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
|
|
|
|
WriteTo( aFmt );
|
2010-11-06 01:33:05 +01:00
|
|
|
pp->GetConfig()->SetStandardFormat( aFmt, true );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete pQueryBox;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton )
|
|
|
|
|
2012-04-01 10:17:21 +05:30
|
|
|
IMPL_LINK( SmFontTypeDialog, HelpButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
|
|
|
{
|
|
|
|
// start help system
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if( pHelp )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pHelp->Start( OUString( "HID_SMA_FONTTYPEDIALOG" ), &aHelpButton1 );
|
2012-04-01 10:17:21 +05:30
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
SmFontTypeDialog::SmFontTypeDialog(Window * pParent, OutputDevice *pFntListDevice, bool bFreeRes)
|
2000-09-18 16:07:07 +00:00
|
|
|
: ModalDialog(pParent, SmResId(RID_FONTTYPEDIALOG)),
|
2007-04-26 07:14:32 +00:00
|
|
|
aFixedText1 (this, SmResId(1)),
|
|
|
|
aVariableFont (this, SmResId(1)),
|
|
|
|
aFixedText2 (this, SmResId(2)),
|
|
|
|
aFunctionFont (this, SmResId(2)),
|
|
|
|
aFixedText3 (this, SmResId(3)),
|
|
|
|
aNumberFont (this, SmResId(3)),
|
|
|
|
aFixedText4 (this, SmResId(4)),
|
|
|
|
aTextFont (this, SmResId(4)),
|
|
|
|
aFixedText5 (this, SmResId(5)),
|
|
|
|
aSerifFont (this, SmResId(5)),
|
|
|
|
aFixedText6 (this, SmResId(6)),
|
|
|
|
aSansFont (this, SmResId(6)),
|
|
|
|
aFixedText7 (this, SmResId(7)),
|
|
|
|
aFixedFont (this, SmResId(7)),
|
|
|
|
aFixedLine1 (this, SmResId(1)),
|
|
|
|
aFixedLine2 (this, SmResId(2)),
|
|
|
|
aOKButton1 (this, SmResId(1)),
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1 (this, SmResId(1)),
|
2007-04-26 07:14:32 +00:00
|
|
|
aCancelButton1 (this, SmResId(1)),
|
|
|
|
aMenuButton (this, SmResId(1)),
|
|
|
|
aDefaultButton (this, SmResId(2)),
|
2006-01-31 17:33:08 +00:00
|
|
|
pFontListDev (pFntListDevice)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bFreeRes)
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
aDefaultButton.SetClickHdl(LINK(this, SmFontTypeDialog, DefaultButtonClickHdl));
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1.SetClickHdl(LINK(this, SmFontTypeDialog, HelpButtonClickHdl));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmFontTypeDialog, MenuSelectHdl));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmModule *pp = SM_MOD();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aVariableFont = pp->GetConfig()->GetFontPickList(FNT_VARIABLE);
|
|
|
|
aFunctionFont = pp->GetConfig()->GetFontPickList(FNT_FUNCTION);
|
|
|
|
aNumberFont = pp->GetConfig()->GetFontPickList(FNT_NUMBER);
|
|
|
|
aTextFont = pp->GetConfig()->GetFontPickList(FNT_TEXT);
|
|
|
|
aSerifFont = pp->GetConfig()->GetFontPickList(FNT_SERIF);
|
|
|
|
aSansFont = pp->GetConfig()->GetFontPickList(FNT_SANS);
|
|
|
|
aFixedFont = pp->GetConfig()->GetFontPickList(FNT_FIXED);
|
|
|
|
|
|
|
|
aVariableFont.Insert( rFormat.GetFont(FNT_VARIABLE) );
|
|
|
|
aFunctionFont.Insert( rFormat.GetFont(FNT_FUNCTION) );
|
|
|
|
aNumberFont .Insert( rFormat.GetFont(FNT_NUMBER) );
|
|
|
|
aTextFont .Insert( rFormat.GetFont(FNT_TEXT) );
|
|
|
|
aSerifFont .Insert( rFormat.GetFont(FNT_SERIF) );
|
|
|
|
aSansFont .Insert( rFormat.GetFont(FNT_SANS) );
|
|
|
|
aFixedFont .Insert( rFormat.GetFont(FNT_FIXED) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmModule *pp = SM_MOD();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_VARIABLE) = aVariableFont;
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_FUNCTION) = aFunctionFont;
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_NUMBER) = aNumberFont;
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_TEXT) = aTextFont;
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_SERIF) = aSerifFont;
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_SANS) = aSansFont;
|
|
|
|
pp->GetConfig()->GetFontPickList(FNT_FIXED) = aFixedFont;
|
|
|
|
|
|
|
|
rFormat.SetFont( FNT_VARIABLE, aVariableFont.Get(0) );
|
|
|
|
rFormat.SetFont( FNT_FUNCTION, aFunctionFont.Get(0) );
|
|
|
|
rFormat.SetFont( FNT_NUMBER, aNumberFont .Get(0) );
|
|
|
|
rFormat.SetFont( FNT_TEXT, aTextFont .Get(0) );
|
|
|
|
rFormat.SetFont( FNT_SERIF, aSerifFont .Get(0) );
|
|
|
|
rFormat.SetFont( FNT_SANS, aSansFont .Get(0) );
|
|
|
|
rFormat.SetFont( FNT_FIXED, aFixedFont .Get(0) );
|
|
|
|
|
|
|
|
rFormat.RequestApplyChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
struct FieldMinMax
|
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nMin, nMax;
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Data for min and max values of the 4 metric fields
|
|
|
|
// for each of the 10 categories
|
|
|
|
static const FieldMinMax pMinMaxData[10][4] =
|
|
|
|
{
|
|
|
|
// 0
|
|
|
|
{{ 0, 200 }, { 0, 200 }, { 0, 100 }, { 0, 0 }},
|
|
|
|
// 1
|
|
|
|
{{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 2
|
|
|
|
{{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 3
|
|
|
|
{{ 0, 100 }, { 1, 100 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 4
|
|
|
|
{{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 5
|
|
|
|
{{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 100 }},
|
|
|
|
// 6
|
|
|
|
{{ 0, 300 }, { 0, 300 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 7
|
|
|
|
{{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 8
|
|
|
|
{{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
|
|
|
|
// 9
|
|
|
|
{{ 0, 10000 }, { 0, 10000 }, { 0, 10000 }, { 0, 10000 }}
|
|
|
|
};
|
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
SmCategoryDesc::SmCategoryDesc(const ResId& rResId, sal_uInt16 nCategoryIdx) :
|
2010-11-16 16:16:52 +00:00
|
|
|
Resource(rResId)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-04-26 07:14:32 +00:00
|
|
|
if (IsAvailableRes(ResId(1,*rResId.GetResMgr()).SetRT(RSC_STRING)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-04-29 23:36:57 +01:00
|
|
|
Name = ResId(1,*rResId.GetResMgr()).toString();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
int nI2 = i + 2;
|
|
|
|
|
2007-04-26 07:14:32 +00:00
|
|
|
if (IsAvailableRes(ResId(nI2,*rResId.GetResMgr()).SetRT(RSC_STRING)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Strings [i] = new OUString(ResId(nI2,*rResId.GetResMgr()).toString());
|
2007-04-26 07:14:32 +00:00
|
|
|
Graphics [i] = new Bitmap(ResId(10*nI2,*rResId.GetResMgr()));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-24 11:12:46 +00:00
|
|
|
Strings [i] = 0;
|
|
|
|
Graphics [i] = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
const FieldMinMax &rMinMax = pMinMaxData[ nCategoryIdx ][i];
|
|
|
|
Value[i] = Minimum[i] = rMinMax.nMin;
|
|
|
|
Maximum[i] = rMinMax.nMax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeResource();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SmCategoryDesc::~SmCategoryDesc()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2002-05-24 11:50:39 +00:00
|
|
|
delete Strings [i];
|
|
|
|
delete Graphics [i];
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
IMPL_LINK( SmDistanceDialog, GetFocusHdl, Control *, pControl )
|
|
|
|
{
|
|
|
|
if (Categories[nActiveCategory])
|
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 i;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (pControl == &aMetricField1)
|
|
|
|
i = 0;
|
|
|
|
else if (pControl == &aMetricField2)
|
|
|
|
i = 1;
|
|
|
|
else if (pControl == &aMetricField3)
|
|
|
|
i = 2;
|
|
|
|
else if (pControl == &aMetricField4)
|
|
|
|
i = 3;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
aBitmap.SetBitmap(*(Categories[nActiveCategory]->GetGraphic(i)));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu )
|
|
|
|
{
|
|
|
|
SetCategory(pMenu->GetCurItemId() - 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
|
|
|
|
|
|
|
|
if (pQueryBox->Execute() == RET_YES)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmModule *pp = SM_MOD();
|
2001-05-02 15:58:48 +00:00
|
|
|
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
|
|
|
|
WriteTo( aFmt );
|
|
|
|
pp->GetConfig()->SetStandardFormat( aFmt );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
delete pQueryBox;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-01 10:17:21 +05:30
|
|
|
IMPL_LINK( SmDistanceDialog, HelpButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
|
|
|
{
|
|
|
|
// start help system
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if( pHelp )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pHelp->Start( OUString( "HID_SMA_DISTANCEDIALOG" ), &aHelpButton1 );
|
2012-04-01 10:17:21 +05:30
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox )
|
|
|
|
{
|
|
|
|
if (pCheckBox == &aCheckBox1)
|
|
|
|
{
|
|
|
|
aCheckBox1.Toggle();
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bChecked = aCheckBox1.IsChecked();
|
2000-09-18 16:07:07 +00:00
|
|
|
aFixedText4 .Enable( bChecked );
|
|
|
|
aMetricField4.Enable( bChecked );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SmDistanceDialog::SetHelpId(MetricField &rField, const OString& sHelpId)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString aEmptyText;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-07-10 18:21:24 +02:00
|
|
|
rField.SetHelpId(sHelpId);
|
2000-09-18 16:07:07 +00:00
|
|
|
rField.SetHelpText(aEmptyText);
|
|
|
|
|
|
|
|
// since MetricField inherits from SpinField which has a sub Edit field
|
|
|
|
// (which is actually the one we modify) we have to set the help-id
|
|
|
|
// for it too.
|
|
|
|
Edit *pSubEdit = rField.GetSubEdit();
|
|
|
|
if (pSubEdit)
|
2010-06-04 13:46:22 +02:00
|
|
|
{
|
2010-07-10 18:21:24 +02:00
|
|
|
pSubEdit->SetHelpId(sHelpId);
|
2000-09-18 16:07:07 +00:00
|
|
|
pSubEdit->SetHelpText(aEmptyText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(/*0 <= nCategory &&*/ nCategory < NOCATEGORIES,
|
|
|
|
"Sm: wrong category number in SmDistanceDialog");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// array to convert category- and metricfield-number in help ids.
|
|
|
|
// 0 is used in case of unused combinations.
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(NOCATEGORIES == 10, "Sm : array doesn't fit into the number of categories");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2011-03-14 16:51:14 +00:00
|
|
|
static const char * aCatMf2Hid[10][4] =
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
{ HID_SMA_DEFAULT_DIST, HID_SMA_LINE_DIST, HID_SMA_ROOT_DIST, 0 },
|
|
|
|
{ HID_SMA_SUP_DIST, HID_SMA_SUB_DIST , 0, 0 },
|
|
|
|
{ HID_SMA_NUMERATOR_DIST, HID_SMA_DENOMINATOR_DIST, 0, 0 },
|
|
|
|
{ HID_SMA_FRACLINE_EXCWIDTH, HID_SMA_FRACLINE_LINEWIDTH, 0, 0 },
|
|
|
|
{ HID_SMA_UPPERLIMIT_DIST, HID_SMA_LOWERLIMIT_DIST, 0, 0 },
|
|
|
|
{ HID_SMA_BRACKET_EXCHEIGHT, HID_SMA_BRACKET_DIST, 0, HID_SMA_BRACKET_EXCHEIGHT2 },
|
|
|
|
{ HID_SMA_MATRIXROW_DIST, HID_SMA_MATRIXCOL_DIST, 0, 0 },
|
|
|
|
{ HID_SMA_ATTRIBUT_DIST, HID_SMA_INTERATTRIBUT_DIST, 0, 0 },
|
|
|
|
{ HID_SMA_OPERATOR_EXCHEIGHT, HID_SMA_OPERATOR_DIST, 0, 0 },
|
|
|
|
{ HID_SMA_LEFTBORDER_DIST, HID_SMA_RIGHTBORDER_DIST, HID_SMA_UPPERBORDER_DIST, HID_SMA_LOWERBORDER_DIST }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// array to help iterate over the controls
|
2010-12-12 10:15:19 +01:00
|
|
|
Window * const aWin[4][2] =
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
{ &aFixedText1, &aMetricField1 },
|
|
|
|
{ &aFixedText2, &aMetricField2 },
|
|
|
|
{ &aFixedText3, &aMetricField3 },
|
|
|
|
{ &aFixedText4, &aMetricField4 }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SmCategoryDesc *pCat;
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// remember the (maybe new) settings of the active SmCategoryDesc
|
|
|
|
// before switching to the new one
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nActiveCategory != CATEGORY_NONE)
|
|
|
|
{
|
|
|
|
pCat = Categories[nActiveCategory];
|
2011-01-14 17:19:25 +01:00
|
|
|
pCat->SetValue(0, (sal_uInt16) aMetricField1.GetValue());
|
|
|
|
pCat->SetValue(1, (sal_uInt16) aMetricField2.GetValue());
|
|
|
|
pCat->SetValue(2, (sal_uInt16) aMetricField3.GetValue());
|
|
|
|
pCat->SetValue(3, (sal_uInt16) aMetricField4.GetValue());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nActiveCategory == 5)
|
|
|
|
bScaleAllBrackets = aCheckBox1.IsChecked();
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
aMenuButton.GetPopupMenu()->CheckItem(nActiveCategory + 1, false);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// activation/deactivation of the associated controls depending on the chosen category
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bActive;
|
2011-01-14 17:19:25 +01:00
|
|
|
for (sal_uInt16 i = 0; i < 4; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
FixedText *pFT = (FixedText * const) aWin[i][0];
|
|
|
|
MetricField *pMF = (MetricField * const) aWin[i][1];
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// To determine which Controls should be active, the existence
|
|
|
|
// of an associated HelpID is checked
|
2000-09-18 16:07:07 +00:00
|
|
|
bActive = aCatMf2Hid[nCategory][i] != 0;
|
|
|
|
|
|
|
|
pFT->Show(bActive);
|
|
|
|
pFT->Enable(bActive);
|
|
|
|
pMF->Show(bActive);
|
|
|
|
pMF->Enable(bActive);
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// set measurement unit and number of decimal places
|
2000-09-18 16:07:07 +00:00
|
|
|
FieldUnit eUnit;
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nDigits;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nCategory < 9)
|
|
|
|
{
|
|
|
|
eUnit = FUNIT_CUSTOM;
|
|
|
|
nDigits = 0;
|
2013-04-07 12:06:47 +02:00
|
|
|
pMF->SetCustomUnitText(OUString('%'));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eUnit = FUNIT_100TH_MM;
|
|
|
|
nDigits = 2;
|
|
|
|
}
|
2012-08-03 10:22:14 +02:00
|
|
|
pMF->SetUnit(eUnit); // changes the value
|
2000-09-18 16:07:07 +00:00
|
|
|
pMF->SetDecimalDigits(nDigits);
|
|
|
|
|
|
|
|
if (bActive)
|
|
|
|
{
|
|
|
|
pCat = Categories[nCategory];
|
|
|
|
pFT->SetText(*pCat->GetString(i));
|
|
|
|
|
|
|
|
pMF->SetMin(pCat->GetMinimum(i));
|
|
|
|
pMF->SetMax(pCat->GetMaximum(i));
|
|
|
|
pMF->SetValue(pCat->GetValue(i));
|
|
|
|
|
|
|
|
SetHelpId(*pMF, aCatMf2Hid[nCategory][i]);
|
|
|
|
}
|
|
|
|
}
|
2012-08-03 10:22:14 +02:00
|
|
|
// activate the CheckBox and the associated MetricField if we're dealing with the brackets menu
|
2000-09-18 16:07:07 +00:00
|
|
|
bActive = nCategory == 5;
|
|
|
|
aCheckBox1.Show(bActive);
|
|
|
|
aCheckBox1.Enable(bActive);
|
|
|
|
if (bActive)
|
|
|
|
{
|
|
|
|
aCheckBox1.Check( bScaleAllBrackets );
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bChecked = aCheckBox1.IsChecked();
|
2000-09-18 16:07:07 +00:00
|
|
|
aFixedText4 .Enable( bChecked );
|
|
|
|
aMetricField4.Enable( bChecked );
|
|
|
|
}
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
aMenuButton.GetPopupMenu()->CheckItem(nCategory + 1, true);
|
2001-06-15 05:42:09 +00:00
|
|
|
aFixedLine.SetText(Categories[nCategory]->GetName());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
nActiveCategory = nCategory;
|
|
|
|
|
|
|
|
aMetricField1.GrabFocus();
|
|
|
|
Invalidate();
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
SmDistanceDialog::SmDistanceDialog(Window *pParent, bool bFreeRes)
|
2000-09-18 16:07:07 +00:00
|
|
|
: ModalDialog(pParent, SmResId(RID_DISTANCEDIALOG)),
|
2007-05-31 09:04:48 +00:00
|
|
|
aFixedText1 (this, SmResId(1)),
|
|
|
|
aMetricField1 (this, SmResId(1)),
|
|
|
|
aFixedText2 (this, SmResId(2)),
|
|
|
|
aMetricField2 (this, SmResId(2)),
|
|
|
|
aFixedText3 (this, SmResId(3)),
|
|
|
|
aMetricField3 (this, SmResId(3)),
|
|
|
|
aCheckBox1 (this, SmResId(1)),
|
|
|
|
aFixedText4 (this, SmResId(4)),
|
|
|
|
aMetricField4 (this, SmResId(4)),
|
|
|
|
aOKButton1 (this, SmResId(1)),
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1 (this, SmResId(1)),
|
2007-05-31 09:04:48 +00:00
|
|
|
aCancelButton1 (this, SmResId(1)),
|
|
|
|
aMenuButton (this, SmResId(1)),
|
|
|
|
aDefaultButton (this, SmResId(1)),
|
|
|
|
aBitmap (this, SmResId(1)),
|
|
|
|
aFixedLine (this, SmResId(1))
|
2007-05-25 11:33:41 +00:00
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
for (sal_uInt16 i = 0; i < NOCATEGORIES; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
Categories[i] = new SmCategoryDesc(SmResId(i + 1), i);
|
|
|
|
nActiveCategory = CATEGORY_NONE;
|
2010-11-06 01:33:05 +01:00
|
|
|
bScaleAllBrackets = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bFreeRes)
|
|
|
|
FreeResource();
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
// preview like controls should have a 2D look
|
2001-06-15 05:42:09 +00:00
|
|
|
aBitmap.SetBorderStyle( WINDOW_BORDER_MONO );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
aMetricField1.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
|
|
|
|
aMetricField2.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
|
|
|
|
aMetricField3.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
|
|
|
|
aMetricField4.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
|
|
|
|
aCheckBox1.SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
|
|
|
|
|
|
|
|
aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
|
|
|
|
|
|
|
|
aDefaultButton.SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpButton1.SetClickHdl(LINK(this, SmDistanceDialog, HelpButtonClickHdl));
|
2002-05-24 11:12:46 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
SmDistanceDialog::~SmDistanceDialog()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < NOCATEGORIES; i++)
|
|
|
|
DELETEZ(Categories[i]);
|
|
|
|
}
|
|
|
|
|
2002-05-24 11:12:46 +00:00
|
|
|
void SmDistanceDialog::DataChanged( const DataChangedEvent &rEvt )
|
|
|
|
{
|
|
|
|
ModalDialog::DataChanged( rEvt );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void SmDistanceDialog::ReadFrom(const SmFormat &rFormat)
|
|
|
|
{
|
|
|
|
Categories[0]->SetValue(0, rFormat.GetDistance(DIS_HORIZONTAL));
|
|
|
|
Categories[0]->SetValue(1, rFormat.GetDistance(DIS_VERTICAL));
|
|
|
|
Categories[0]->SetValue(2, rFormat.GetDistance(DIS_ROOT));
|
|
|
|
Categories[1]->SetValue(0, rFormat.GetDistance(DIS_SUPERSCRIPT));
|
|
|
|
Categories[1]->SetValue(1, rFormat.GetDistance(DIS_SUBSCRIPT));
|
|
|
|
Categories[2]->SetValue(0, rFormat.GetDistance(DIS_NUMERATOR));
|
|
|
|
Categories[2]->SetValue(1, rFormat.GetDistance(DIS_DENOMINATOR));
|
|
|
|
Categories[3]->SetValue(0, rFormat.GetDistance(DIS_FRACTION));
|
|
|
|
Categories[3]->SetValue(1, rFormat.GetDistance(DIS_STROKEWIDTH));
|
|
|
|
Categories[4]->SetValue(0, rFormat.GetDistance(DIS_UPPERLIMIT));
|
|
|
|
Categories[4]->SetValue(1, rFormat.GetDistance(DIS_LOWERLIMIT));
|
|
|
|
Categories[5]->SetValue(0, rFormat.GetDistance(DIS_BRACKETSIZE));
|
|
|
|
Categories[5]->SetValue(1, rFormat.GetDistance(DIS_BRACKETSPACE));
|
|
|
|
Categories[5]->SetValue(3, rFormat.GetDistance(DIS_NORMALBRACKETSIZE));
|
|
|
|
Categories[6]->SetValue(0, rFormat.GetDistance(DIS_MATRIXROW));
|
|
|
|
Categories[6]->SetValue(1, rFormat.GetDistance(DIS_MATRIXCOL));
|
|
|
|
Categories[7]->SetValue(0, rFormat.GetDistance(DIS_ORNAMENTSIZE));
|
|
|
|
Categories[7]->SetValue(1, rFormat.GetDistance(DIS_ORNAMENTSPACE));
|
|
|
|
Categories[8]->SetValue(0, rFormat.GetDistance(DIS_OPERATORSIZE));
|
|
|
|
Categories[8]->SetValue(1, rFormat.GetDistance(DIS_OPERATORSPACE));
|
|
|
|
Categories[9]->SetValue(0, rFormat.GetDistance(DIS_LEFTSPACE));
|
|
|
|
Categories[9]->SetValue(1, rFormat.GetDistance(DIS_RIGHTSPACE));
|
|
|
|
Categories[9]->SetValue(2, rFormat.GetDistance(DIS_TOPSPACE));
|
|
|
|
Categories[9]->SetValue(3, rFormat.GetDistance(DIS_BOTTOMSPACE));
|
|
|
|
|
|
|
|
bScaleAllBrackets = rFormat.IsScaleNormalBrackets();
|
|
|
|
|
|
|
|
// force update (even of category 0) by setting nActiveCategory to a
|
|
|
|
// non-existent category number
|
|
|
|
nActiveCategory = CATEGORY_NONE;
|
|
|
|
SetCategory(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/
|
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// TODO can they actually be different?
|
|
|
|
// if that's not the case 'const' could be used above!
|
2000-09-18 16:07:07 +00:00
|
|
|
SetCategory(nActiveCategory);
|
|
|
|
|
|
|
|
rFormat.SetDistance( DIS_HORIZONTAL, Categories[0]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_VERTICAL, Categories[0]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_ROOT, Categories[0]->GetValue(2) );
|
|
|
|
rFormat.SetDistance( DIS_SUPERSCRIPT, Categories[1]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_SUBSCRIPT, Categories[1]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_NUMERATOR, Categories[2]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_DENOMINATOR, Categories[2]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_FRACTION, Categories[3]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_STROKEWIDTH, Categories[3]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_UPPERLIMIT, Categories[4]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_LOWERLIMIT, Categories[4]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_BRACKETSIZE, Categories[5]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_BRACKETSPACE, Categories[5]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_MATRIXROW, Categories[6]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_MATRIXCOL, Categories[6]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_ORNAMENTSIZE, Categories[7]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_ORNAMENTSPACE, Categories[7]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_OPERATORSIZE, Categories[8]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_OPERATORSPACE, Categories[8]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_LEFTSPACE, Categories[9]->GetValue(0) );
|
|
|
|
rFormat.SetDistance( DIS_RIGHTSPACE, Categories[9]->GetValue(1) );
|
|
|
|
rFormat.SetDistance( DIS_TOPSPACE, Categories[9]->GetValue(2) );
|
|
|
|
rFormat.SetDistance( DIS_BOTTOMSPACE, Categories[9]->GetValue(3) );
|
|
|
|
rFormat.SetDistance( DIS_NORMALBRACKETSIZE, Categories[5]->GetValue(3) );
|
|
|
|
|
|
|
|
rFormat.SetScaleNormalBrackets( bScaleAllBrackets );
|
|
|
|
|
|
|
|
rFormat.RequestApplyChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
|
|
|
|
|
|
|
|
if (pQueryBox->Execute() == RET_YES)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmModule *pp = SM_MOD();
|
2001-05-02 15:58:48 +00:00
|
|
|
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
|
|
|
|
WriteTo( aFmt );
|
|
|
|
pp->GetConfig()->SetStandardFormat( aFmt );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete pQueryBox;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 11:27:10 +01:00
|
|
|
SmAlignDialog::SmAlignDialog(Window * pParent)
|
|
|
|
: ModalDialog(pParent, "AlignmentDialog",
|
|
|
|
"modules/smath/ui/alignmentdialog.ui")
|
2012-04-01 10:17:21 +05:30
|
|
|
{
|
2013-05-22 11:27:10 +01:00
|
|
|
get(m_pLeft, "left");
|
|
|
|
get(m_pCenter, "center");
|
|
|
|
get(m_pRight, "right");
|
|
|
|
get(m_pDefaultButton, "default");
|
|
|
|
m_pDefaultButton->SetClickHdl(LINK(this, SmAlignDialog, DefaultButtonClickHdl));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmAlignDialog::ReadFrom(const SmFormat &rFormat)
|
|
|
|
{
|
|
|
|
switch (rFormat.GetHorAlign())
|
|
|
|
{
|
|
|
|
case AlignLeft:
|
2013-05-22 11:27:10 +01:00
|
|
|
m_pLeft->Check(true);
|
|
|
|
m_pCenter->Check(false);
|
|
|
|
m_pRight->Check(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AlignCenter:
|
2013-05-22 11:27:10 +01:00
|
|
|
m_pLeft->Check(false);
|
|
|
|
m_pCenter->Check(true);
|
|
|
|
m_pRight->Check(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AlignRight:
|
2013-05-22 11:27:10 +01:00
|
|
|
m_pLeft->Check(false);
|
|
|
|
m_pCenter->Check(false);
|
|
|
|
m_pRight->Check(true);
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmAlignDialog::WriteTo(SmFormat &rFormat) const
|
|
|
|
{
|
2013-05-22 11:27:10 +01:00
|
|
|
if (m_pLeft->IsChecked())
|
2000-09-18 16:07:07 +00:00
|
|
|
rFormat.SetHorAlign(AlignLeft);
|
2013-05-22 11:27:10 +01:00
|
|
|
else if (m_pRight->IsChecked())
|
2000-09-18 16:07:07 +00:00
|
|
|
rFormat.SetHorAlign(AlignRight);
|
|
|
|
else
|
|
|
|
rFormat.SetHorAlign(AlignCenter);
|
|
|
|
|
|
|
|
rFormat.RequestApplyChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
SmShowSymbolSetWindow::SmShowSymbolSetWindow(Window *pParent, WinBits nStyle)
|
|
|
|
: Control(pParent, nStyle)
|
|
|
|
, m_pVScrollBar(0)
|
|
|
|
, nSelectSymbol(SYMBOL_NONE)
|
|
|
|
{
|
|
|
|
ColorData nBgCol, nTxtCol;
|
|
|
|
getColors(*this, nBgCol, nTxtCol);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Color aTmpColor( nBgCol );
|
|
|
|
Wallpaper aWall( aTmpColor );
|
|
|
|
Color aTxtColor( nTxtCol );
|
|
|
|
SetBackground( aWall );
|
|
|
|
SetTextColor( aTxtColor );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Point SmShowSymbolSetWindow::OffsetPoint(const Point &rPoint) const
|
|
|
|
{
|
|
|
|
return Point(rPoint.X() + nXOffset, rPoint.Y() + nYOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SmShowSymbolSetWindow::Paint(const Rectangle&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Push(PUSH_MAPMODE);
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// set MapUnit for which 'nLen' has been calculated
|
2000-09-18 16:07:07 +00:00
|
|
|
SetMapMode(MapMode(MAP_PIXEL));
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
sal_uInt16 v = sal::static_int_cast< sal_uInt16 >((m_pVScrollBar->GetThumbPos() * nColumns));
|
2009-09-28 10:46:54 +00:00
|
|
|
size_t nSymbols = aSymbolSet.size();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
Color aTxtColor( GetTextColor() );
|
2011-01-14 17:19:25 +01:00
|
|
|
for (sal_uInt16 i = v; i < nSymbols ; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmSym aSymbol (*aSymbolSet[i]);
|
2000-09-18 16:07:07 +00:00
|
|
|
Font aFont (aSymbol.GetFace());
|
2002-05-24 12:27:00 +00:00
|
|
|
aFont.SetAlign(ALIGN_TOP);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// taking a FontSize which is a bit smaller (compared to nLen) in order to have a buffer
|
|
|
|
// (hopefully enough for left and right, too)
|
2000-09-18 16:07:07 +00:00
|
|
|
aFont.SetSize(Size(0, nLen - (nLen / 3)));
|
|
|
|
SetFont(aFont);
|
2002-04-24 09:15:41 +00:00
|
|
|
// keep text color
|
|
|
|
SetTextColor( aTxtColor );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
int nIV = i - v;
|
2010-08-03 11:29:55 +02:00
|
|
|
sal_UCS4 cChar = aSymbol.GetCharacter();
|
2012-10-22 15:08:50 +04:00
|
|
|
OUString aText(&cChar, 1);
|
2010-08-03 11:29:55 +02:00
|
|
|
Size aSize( GetTextWidth( aText ), GetTextHeight());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Point aPoint((nIV % nColumns) * nLen + (nLen - aSize.Width()) / 2,
|
|
|
|
(nIV / nColumns) * nLen + (nLen - aSize.Height()) / 2);
|
|
|
|
|
|
|
|
DrawText(OffsetPoint(aPoint), aText);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nSelectSymbol != SYMBOL_NONE)
|
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
Point aPoint(((nSelectSymbol - v) % nColumns) * nLen,
|
|
|
|
((nSelectSymbol - v) / nColumns) * nLen);
|
|
|
|
|
|
|
|
Invert(Rectangle(OffsetPoint(aPoint), Size(nLen, nLen)));
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::MouseButtonDown(const MouseEvent& rMEvt)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
GrabFocus();
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Size aOutputSize(nColumns * nLen, nRows * nLen);
|
|
|
|
Point aPoint(rMEvt.GetPosPixel());
|
|
|
|
aPoint.X() -= nXOffset;
|
|
|
|
aPoint.Y() -= nYOffset;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (rMEvt.IsLeft() && Rectangle(Point(0, 0), aOutputSize).IsInside(rMEvt.GetPosPixel()))
|
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
long nPos = (aPoint.Y() / nLen) * nColumns + (aPoint.X() / nLen) +
|
|
|
|
m_pVScrollBar->GetThumbPos() * nColumns;
|
2011-01-14 17:19:25 +01:00
|
|
|
SelectSymbol( sal::static_int_cast< sal_uInt16 >(nPos) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aSelectHdlLink.Call(this);
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
if (rMEvt.GetClicks() > 1)
|
|
|
|
aDblClickHdlLink.Call(this);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::KeyInput(const KeyEvent& rKEvt)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 n = nSelectSymbol;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (n != SYMBOL_NONE)
|
|
|
|
{
|
|
|
|
switch (rKEvt.GetKeyCode().GetCode())
|
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
case KEY_DOWN: n = n + nColumns; break;
|
|
|
|
case KEY_UP: n = n - nColumns; break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case KEY_LEFT: n -= 1; break;
|
|
|
|
case KEY_RIGHT: n += 1; break;
|
|
|
|
case KEY_HOME: n = 0; break;
|
2011-01-14 17:19:25 +01:00
|
|
|
case KEY_END: n = static_cast< sal_uInt16 >(aSymbolSet.size() - 1); break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case KEY_PAGEUP: n -= nColumns * nRows; break;
|
|
|
|
case KEY_PAGEDOWN: n += nColumns * nRows; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Control::KeyInput(rKEvt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
n = 0;
|
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
if (n >= aSymbolSet.size())
|
2000-09-18 16:07:07 +00:00
|
|
|
n = nSelectSymbol;
|
|
|
|
|
|
|
|
// adjust scrollbar
|
2013-05-22 12:07:21 +01:00
|
|
|
if ((n < (sal_uInt16) (m_pVScrollBar->GetThumbPos() * nColumns)) ||
|
|
|
|
(n >= (sal_uInt16) ((m_pVScrollBar->GetThumbPos() + nRows) * nColumns)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pVScrollBar->SetThumbPos(n / nColumns);
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectSymbol(n);
|
|
|
|
aSelectHdlLink.Call(this);
|
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::setScrollbar(ScrollBar *pVScrollBar)
|
|
|
|
{
|
|
|
|
m_pVScrollBar = pVScrollBar;
|
|
|
|
m_pVScrollBar->Enable(false);
|
|
|
|
m_pVScrollBar->Show();
|
|
|
|
m_pVScrollBar->SetScrollHdl(LINK(this, SmShowSymbolSetWindow, ScrollHdl));
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
SmShowSymbolSet::SmShowSymbolSet(Window *pParent)
|
|
|
|
: VclHBox(pParent, false, 6)
|
|
|
|
, aSymbolWindow(this, WB_TABSTOP)
|
|
|
|
, aVScrollBar(this, WinBits(WB_VSCROLL))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
aSymbolWindow.set_hexpand(true);
|
|
|
|
aSymbolWindow.set_vexpand(true);
|
|
|
|
aSymbolWindow.setScrollbar(&aVScrollBar);
|
|
|
|
aSymbolWindow.calccols();
|
|
|
|
aSymbolWindow.Show();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSmShowSymbolSet(Window *pParent, VclBuilder::stringmap &)
|
|
|
|
{
|
|
|
|
return new SmShowSymbolSet(pParent);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::calccols()
|
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// Height of 16pt in pixels (matching 'aOutputSize')
|
2011-01-14 17:19:25 +01:00
|
|
|
nLen = (sal_uInt16) LogicToPixel(Size(0, 16), MapMode(MAP_POINT)).Height();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Size aOutputSize = GetOutputSizePixel();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
nColumns = sal::static_int_cast< sal_uInt16 >(aOutputSize.Width() / nLen);
|
|
|
|
if (nColumns > 2 && nColumns % 2 != 0)
|
|
|
|
--nColumns;
|
|
|
|
nRows = sal::static_int_cast< sal_uInt16 >(aOutputSize.Height() / nLen);
|
|
|
|
nColumns = std::max<sal_uInt16>(1, nColumns);
|
|
|
|
nRows = std::max<sal_uInt16>(1, nRows);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
nXOffset = (aOutputSize.Width() - (nColumns * nLen)) / 2;
|
|
|
|
nYOffset = (aOutputSize.Height() - (nRows * nLen)) / 2;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
SetScrollBarRange();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Size SmShowSymbolSetWindow::GetOptimalSize() const
|
|
|
|
{
|
|
|
|
Window *pParent = GetParent();
|
|
|
|
return Size(pParent->approximate_char_width() * 24, pParent->GetTextHeight() * 8);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aSymbolSet = rSymbolSet;
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
SetScrollBarRange();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SmShowSymbolSetWindow::SetScrollBarRange()
|
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
if (static_cast< sal_uInt16 >(aSymbolSet.size()) > (nColumns * nRows))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pVScrollBar->SetRange(Range(0, ((aSymbolSet.size() + (nColumns - 1)) / nColumns) - nRows));
|
|
|
|
m_pVScrollBar->Enable(true);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pVScrollBar->SetRange(Range(0,0));
|
|
|
|
m_pVScrollBar->Enable (false);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::SelectSymbol(sal_uInt16 nSymbol)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
int v = (int) (m_pVScrollBar->GetThumbPos() * nColumns);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nSelectSymbol != SYMBOL_NONE)
|
2013-05-22 12:07:21 +01:00
|
|
|
Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
|
|
|
|
((nSelectSymbol - v) / nColumns) * nLen)),
|
2000-09-18 16:07:07 +00:00
|
|
|
Size(nLen, nLen)));
|
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
if (nSymbol < aSymbolSet.size())
|
2000-09-18 16:07:07 +00:00
|
|
|
nSelectSymbol = nSymbol;
|
|
|
|
|
2012-02-19 16:59:40 +04:00
|
|
|
if (aSymbolSet.empty())
|
2000-09-18 16:07:07 +00:00
|
|
|
nSelectSymbol = SYMBOL_NONE;
|
|
|
|
|
|
|
|
if (nSelectSymbol != SYMBOL_NONE)
|
2013-05-22 12:07:21 +01:00
|
|
|
Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
|
|
|
|
((nSelectSymbol - v) / nColumns) * nLen)),
|
2000-09-18 16:07:07 +00:00
|
|
|
Size(nLen, nLen)));
|
|
|
|
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
void SmShowSymbolSetWindow::Resize()
|
|
|
|
{
|
|
|
|
Control::Resize();
|
|
|
|
calccols();
|
|
|
|
}
|
2002-04-24 09:15:41 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
IMPL_LINK( SmShowSymbolSetWindow, ScrollHdl, ScrollBar*, EMPTYARG /*pScrollBar*/)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSmShowSymbol(Window *pParent, VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
WinBits nWinBits = 0;
|
|
|
|
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(OString("border"));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
|
|
|
if (toBool(aFind->second))
|
|
|
|
nWinBits |= WB_BORDER;
|
|
|
|
rMap.erase(aFind);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new SmShowSymbol(pParent, nWinBits);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SmShowSymbol::Resize()
|
|
|
|
{
|
|
|
|
Control::Resize();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SmShowSymbol::setFontSize(Font &rFont) const
|
|
|
|
{
|
|
|
|
rFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
void SmShowSymbol::Paint(const Rectangle &rRect)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-24 09:15:41 +00:00
|
|
|
Control::Paint( rRect );
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
Font aFont(GetFont());
|
|
|
|
setFontSize(aFont);
|
|
|
|
SetFont(aFont);
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString &rText = GetText();
|
2000-09-18 16:07:07 +00:00
|
|
|
Size aTextSize(GetTextWidth(rText), GetTextHeight());
|
|
|
|
|
|
|
|
DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
|
2010-08-05 10:31:58 +02:00
|
|
|
(GetOutputSize().Height() * 7/10)), rText);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt)
|
|
|
|
{
|
|
|
|
if (rMEvt.GetClicks() > 1)
|
|
|
|
aDblClickHdlLink.Call(this);
|
|
|
|
else
|
|
|
|
Control::MouseButtonDown (rMEvt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmShowSymbol::SetSymbol(const SmSym *pSymbol)
|
|
|
|
{
|
|
|
|
if (pSymbol)
|
|
|
|
{
|
|
|
|
Font aFont (pSymbol->GetFace());
|
2013-05-22 12:07:21 +01:00
|
|
|
setFontSize(aFont);
|
2010-08-05 10:31:58 +02:00
|
|
|
aFont.SetAlign(ALIGN_BASELINE);
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFont(aFont);
|
|
|
|
|
2010-08-03 11:29:55 +02:00
|
|
|
sal_UCS4 cChar = pSymbol->GetCharacter();
|
2012-10-22 15:08:50 +04:00
|
|
|
OUString aText(&cChar, 1);
|
2010-08-03 11:29:55 +02:00
|
|
|
SetText( aText );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// 'Invalidate' fills the background with the background color.
|
|
|
|
// If a NULL pointer has been passed that's already enough to clear the display
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
void SmSymbolDialog::FillSymbolSets(bool bDeleteText)
|
2012-08-03 10:22:14 +02:00
|
|
|
// populate the entries of possible SymbolsSets in the dialog with
|
|
|
|
// current values of the SymbolSet manager but selects none of those
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSets->Clear();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bDeleteText)
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSets->SetNoSelection();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
std::set< OUString > aSybolSetNames( rSymbolMgr.GetSymbolSetNames() );
|
|
|
|
std::set< OUString >::const_iterator aIt( aSybolSetNames.begin() );
|
2009-09-28 10:46:54 +00:00
|
|
|
for ( ; aIt != aSybolSetNames.end(); ++aIt)
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSets->InsertEntry( *aIt );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
IMPL_LINK_NOARG( SmSymbolDialog, SymbolSetChangeHdl )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
SelectSymbolSet(m_pSymbolSets->GetSelectEntry());
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
IMPL_LINK_NOARG( SmSymbolDialog, SymbolChangeHdl )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
SelectSymbol(m_pSymbolSetDisplay->GetSelectSymbol());
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
IMPL_LINK_NOARG(SmSymbolDialog, EditClickHdl)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
SmSymDefineDialog *pDialog = new SmSymDefineDialog(this, pFontListDev, rSymbolMgr);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// set current symbol and SymbolSet for the new dialog
|
2013-05-22 12:07:21 +01:00
|
|
|
const OUString aSymSetName (m_pSymbolSets->GetSelectEntry()),
|
|
|
|
aSymName (m_pSymbolName->GetText());
|
2000-09-18 16:07:07 +00:00
|
|
|
pDialog->SelectOldSymbolSet(aSymSetName);
|
|
|
|
pDialog->SelectOldSymbol(aSymName);
|
|
|
|
pDialog->SelectSymbolSet(aSymSetName);
|
|
|
|
pDialog->SelectSymbol(aSymName);
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// remember old SymbolSet
|
2013-05-22 12:07:21 +01:00
|
|
|
OUString aOldSymbolSet (m_pSymbolSets->GetSelectEntry());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nSymPos = GetSelectedSymbol();
|
2001-10-05 08:05:48 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// adapt dialog to data of the SymbolSet manager, which might have changed
|
2009-09-28 10:46:54 +00:00
|
|
|
if (pDialog->Execute() == RET_OK && rSymbolMgr.IsModified())
|
2005-10-05 14:00:06 +00:00
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
rSymbolMgr.Save();
|
2000-09-18 16:07:07 +00:00
|
|
|
FillSymbolSets();
|
2005-10-05 14:00:06 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// if the old SymbolSet doesn't exist anymore, go to the first one SymbolSet (if one exists)
|
2013-05-22 12:07:21 +01:00
|
|
|
if (!SelectSymbolSet(aOldSymbolSet) && m_pSymbolSets->GetEntryCount() > 0)
|
|
|
|
SelectSymbolSet(m_pSymbolSets->GetEntry(0));
|
2009-09-28 10:46:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// just update display of current symbol set
|
2013-05-22 12:07:21 +01:00
|
|
|
assert(aSymSetName == aSymSetName); //unexpected change in symbol set name
|
|
|
|
aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName );
|
|
|
|
m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet );
|
2010-01-06 12:22:41 +01:00
|
|
|
}
|
2009-09-28 10:46:54 +00:00
|
|
|
|
|
|
|
if (nSymPos >= aSymbolSet.size())
|
2011-01-14 17:19:25 +01:00
|
|
|
nSymPos = static_cast< sal_uInt16 >(aSymbolSet.size()) - 1;
|
2001-10-05 08:05:48 +00:00
|
|
|
SelectSymbol( nSymPos );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pDialog;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
IMPL_LINK_NOARG( SmSymbolDialog, SymbolDblClickHdl )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
GetClickHdl(m_pGetBtn);
|
2000-09-18 16:07:07 +00:00
|
|
|
EndDialog(RET_OK);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
IMPL_LINK_NOARG( SmSymbolDialog, GetClickHdl )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const SmSym *pSym = GetSymbol();
|
|
|
|
if (pSym)
|
|
|
|
{
|
2012-10-22 15:08:50 +04:00
|
|
|
OUStringBuffer aText;
|
|
|
|
aText.append('%').append(pSym->GetName()).append(' ');
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-05-05 07:00:16 +00:00
|
|
|
rViewSh.GetViewFrame()->GetDispatcher()->Execute(
|
2010-10-01 22:04:50 +02:00
|
|
|
SID_INSERTSYMBOL, SFX_CALLMODE_STANDARD,
|
2012-10-22 15:08:50 +04:00
|
|
|
new SfxStringItem(SID_INSERTSYMBOL, aText.makeStringAndClear()), 0L);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
SmSymbolDialog::SmSymbolDialog(Window *pParent, OutputDevice *pFntListDevice,
|
|
|
|
SmSymbolManager &rMgr, SmViewShell &rViewShell)
|
|
|
|
: ModalDialog(pParent, "CatalogDialog",
|
|
|
|
"modules/smath/ui/catalogdialog.ui")
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
,
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-05-05 07:00:16 +00:00
|
|
|
rViewSh (rViewShell),
|
2009-09-28 10:46:54 +00:00
|
|
|
rSymbolMgr (rMgr),
|
2006-01-31 17:33:08 +00:00
|
|
|
pFontListDev (pFntListDevice)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
get(m_pSymbolSets, "symbolset");
|
|
|
|
m_pSymbolSets->SetStyle(m_pSymbolSets->GetStyle()|WB_SORT);
|
|
|
|
get(m_pSymbolName, "symbolname");
|
|
|
|
get(m_pGetBtn, "insert");
|
|
|
|
get(m_pEditBtn, "edit");
|
|
|
|
get(m_pSymbolSetDisplay, "symbolsetdisplay");
|
|
|
|
get(m_pSymbolDisplay, "preview");
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
aSymbolSetName = OUString();
|
2009-09-28 10:46:54 +00:00
|
|
|
aSymbolSet.clear();
|
2000-09-18 16:07:07 +00:00
|
|
|
FillSymbolSets();
|
2013-05-22 12:07:21 +01:00
|
|
|
if (m_pSymbolSets->GetEntryCount() > 0)
|
|
|
|
SelectSymbolSet(m_pSymbolSets->GetEntry(0));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
InitColor_Impl();
|
|
|
|
|
|
|
|
// preview like controls should have a 2D look
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolDisplay->SetBorderStyle( WINDOW_BORDER_MONO );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSets->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolSetChangeHdl));
|
|
|
|
m_pSymbolSetDisplay->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolChangeHdl));
|
|
|
|
m_pSymbolSetDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
|
|
|
|
m_pSymbolDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
|
|
|
|
m_pEditBtn->SetClickHdl(LINK(this, SmSymbolDialog, EditClickHdl));
|
|
|
|
m_pGetBtn->SetClickHdl(LINK(this, SmSymbolDialog, GetClickHdl));
|
2001-05-02 15:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
void SmSymbolDialog::InitColor_Impl()
|
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
ColorData nBgCol, nTxtCol;
|
|
|
|
getColors(*this, nBgCol, nTxtCol);
|
2002-04-24 09:15:41 +00:00
|
|
|
|
2002-05-03 13:35:00 +00:00
|
|
|
Color aTmpColor( nBgCol );
|
|
|
|
Wallpaper aWall( aTmpColor );
|
2002-04-24 09:15:41 +00:00
|
|
|
Color aTxtColor( nTxtCol );
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolDisplay->SetBackground( aWall );
|
|
|
|
m_pSymbolDisplay->SetTextColor( aTxtColor );
|
|
|
|
m_pSymbolSetDisplay->SetBackground( aWall );
|
|
|
|
m_pSymbolSetDisplay->SetTextColor( aTxtColor );
|
2002-04-24 09:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
InitColor_Impl();
|
|
|
|
|
|
|
|
ModalDialog::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
bool SmSymbolDialog::SelectSymbolSet(const OUString &rSymbolSetName)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bRet = false;
|
2013-05-22 12:07:21 +01:00
|
|
|
sal_uInt16 nPos = m_pSymbolSets->GetEntryPos(rSymbolSetName);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
aSymbolSetName = OUString();
|
2009-09-28 10:46:54 +00:00
|
|
|
aSymbolSet.clear();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nPos != LISTBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSets->SelectEntryPos(nPos);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
aSymbolSetName = rSymbolSetName;
|
|
|
|
aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName );
|
|
|
|
|
2010-07-23 17:21:05 +02:00
|
|
|
// sort symbols by Unicode position (useful for displaying Greek characters alphabetically)
|
|
|
|
std::sort( aSymbolSet.begin(), aSymbolSet.end(), lt_SmSymPtr() );
|
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet );
|
2009-09-28 10:46:54 +00:00
|
|
|
if (aSymbolSet.size() > 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
SelectSymbol(0);
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bRet = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSets->SetNoSelection();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 17:19:25 +01:00
|
|
|
void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const SmSym *pSym = NULL;
|
2012-04-02 19:58:58 -03:00
|
|
|
if (!aSymbolSetName.isEmpty() && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size()))
|
2009-09-28 10:46:54 +00:00
|
|
|
pSym = aSymbolSet[ nSymbolNo ];
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-22 12:07:21 +01:00
|
|
|
m_pSymbolSetDisplay->SelectSymbol(nSymbolNo);
|
|
|
|
m_pSymbolDisplay->SetSymbol(pSym);
|
|
|
|
m_pSymbolName->SetText(pSym ? pSym->GetName() : OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const SmSym * SmSymbolDialog::GetSymbol() const
|
|
|
|
{
|
2013-05-22 12:07:21 +01:00
|
|
|
sal_uInt16 nSymbolNo = m_pSymbolSetDisplay->GetSelectSymbol();
|
2012-04-02 19:58:58 -03:00
|
|
|
bool bValid = !aSymbolSetName.isEmpty() && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size());
|
2009-09-28 10:46:54 +00:00
|
|
|
return bValid ? aSymbolSet[ nSymbolNo ] : NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
void SmShowChar::Paint(const Rectangle &rRect)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-24 09:15:41 +00:00
|
|
|
Control::Paint( rRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-08-03 11:29:55 +02:00
|
|
|
OUString aText( GetText() );
|
2012-01-11 11:37:33 -02:00
|
|
|
if (!aText.isEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-08-03 11:29:55 +02:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
sal_Int32 nPos = 0;
|
|
|
|
sal_UCS4 cChar = aText.iterateCodePoints( &nPos );
|
|
|
|
(void) cChar;
|
|
|
|
#endif
|
|
|
|
Size aTextSize(GetTextWidth(aText), GetTextHeight());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
|
2010-08-05 10:31:58 +02:00
|
|
|
(GetOutputSize().Height() * 7/10)), aText);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 11:29:55 +02:00
|
|
|
void SmShowChar::SetSymbol( const SmSym *pSym )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-08-03 11:29:55 +02:00
|
|
|
if (pSym)
|
|
|
|
SetSymbol( pSym->GetCharacter(), pSym->GetFace() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 11:29:55 +02:00
|
|
|
void SmShowChar::SetSymbol( sal_UCS4 cChar, const Font &rFont )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-08-03 11:29:55 +02:00
|
|
|
Font aFont( rFont );
|
2010-08-05 10:31:58 +02:00
|
|
|
aFont.SetSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3) );
|
|
|
|
aFont.SetAlign(ALIGN_BASELINE);
|
|
|
|
SetFont(aFont);
|
2010-11-06 01:33:05 +01:00
|
|
|
aFont.SetTransparent(true);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-22 15:08:50 +04:00
|
|
|
OUString aText(&cChar, 1);
|
2010-08-03 11:29:55 +02:00
|
|
|
SetText( aText );
|
2002-04-24 09:15:41 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:29:55 +02:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, bool bDeleteText)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols,
|
|
|
|
"Sm : wrong ComboBox");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
rComboBox.Clear();
|
|
|
|
if (bDeleteText)
|
2013-04-07 12:06:47 +02:00
|
|
|
rComboBox.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
ComboBox &rBox = &rComboBox == &aOldSymbols ? aOldSymbolSets : aSymbolSets;
|
|
|
|
SymbolPtrVec_t aSymSet( aSymbolMgrCopy.GetSymbolSet( rBox.GetText() ) );
|
|
|
|
for (size_t i = 0; i < aSymSet.size(); ++i)
|
|
|
|
rComboBox.InsertEntry( aSymSet[i]->GetName() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, bool bDeleteText)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets,
|
2000-09-18 16:07:07 +00:00
|
|
|
"Sm : falsche ComboBox");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
rComboBox.Clear();
|
|
|
|
if (bDeleteText)
|
2013-04-07 12:06:47 +02:00
|
|
|
rComboBox.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
const std::set< OUString > aSymbolSetNames( aSymbolMgrCopy.GetSymbolSetNames() );
|
|
|
|
std::set< OUString >::const_iterator aIt( aSymbolSetNames.begin() );
|
2009-09-28 10:46:54 +00:00
|
|
|
for ( ; aIt != aSymbolSetNames.end(); ++aIt)
|
|
|
|
rComboBox.InsertEntry( *aIt );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
void SmSymDefineDialog::FillFonts(bool bDelete)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aFonts.Clear();
|
|
|
|
if (bDelete)
|
|
|
|
aFonts.SetNoSelection();
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// Include all fonts of FontList into the font list.
|
|
|
|
// If there are duplicates, only include one entry of each font since the style will be
|
|
|
|
// already selected using the FontStyleBox.
|
2006-01-31 17:33:08 +00:00
|
|
|
if (pFontList)
|
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nCount = pFontList->GetFontNameCount();
|
|
|
|
for (sal_uInt16 i = 0; i < nCount; i++)
|
2006-01-31 17:33:08 +00:00
|
|
|
aFonts.InsertEntry( pFontList->GetFontName(i).GetName() );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
void SmSymDefineDialog::FillStyles(bool bDeleteText)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aStyles.Clear();
|
|
|
|
if (bDeleteText)
|
2013-04-07 12:06:47 +02:00
|
|
|
aStyles.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aText (aFonts.GetSelectEntry());
|
|
|
|
if (!aText.isEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// use own StyleNames
|
2001-08-09 11:24:29 +00:00
|
|
|
const SmFontStyles &rStyles = GetFontStyles();
|
2011-01-14 17:19:25 +01:00
|
|
|
for (sal_uInt16 i = 0; i < rStyles.GetCount(); i++)
|
2001-08-09 11:24:29 +00:00
|
|
|
aStyles.InsertEntry( rStyles.GetStyleName(i) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(aStyles.GetEntryCount() > 0, "Sm : no styles available");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
aStyles.SetText( aStyles.GetEntry(0) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox)
|
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols,
|
|
|
|
"Sm : wrong combobox");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2009-09-28 10:46:54 +00:00
|
|
|
return aSymbolMgrCopy.GetSymbolByName(rComboBox.GetText());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, OldSymbolChangeHdl, ComboBox *, EMPTYARG pComboBox )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pComboBox;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pComboBox == &aOldSymbols, "Sm : wrong argument");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbol(aOldSymbols, aOldSymbols.GetText(), false);
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, OldSymbolSetChangeHdl, ComboBox *, EMPTYARG pComboBox )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pComboBox;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pComboBox == &aOldSymbolSets, "Sm : wrong argument");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), false);
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SmSymDefineDialog, ModifyHdl, ComboBox *, pComboBox )
|
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// remember cursor position for later restoring of it
|
2000-09-18 16:07:07 +00:00
|
|
|
Selection aSelection (pComboBox->GetSelection());
|
|
|
|
|
|
|
|
if (pComboBox == &aSymbols)
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbol(aSymbols, aSymbols.GetText(), false);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (pComboBox == &aSymbolSets)
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbolSet(aSymbolSets, aSymbolSets.GetText(), false);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (pComboBox == &aOldSymbols)
|
2012-08-03 10:22:14 +02:00
|
|
|
// allow only names from the list
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbol(aOldSymbols, aOldSymbols.GetText(), true);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (pComboBox == &aOldSymbolSets)
|
2012-08-03 10:22:14 +02:00
|
|
|
// allow only names from the list
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), true);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (pComboBox == &aStyles)
|
2012-08-03 10:22:14 +02:00
|
|
|
// allow only names from the list (that's the case here anyway)
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectStyle(aStyles.GetText(), true);
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2007-05-25 11:33:41 +00:00
|
|
|
{
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-03-12 12:11:06 +01:00
|
|
|
OSL_FAIL("Sm : wrong combobox argument");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pComboBox->SetSelection(aSelection);
|
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, FontChangeHdl, ListBox *, EMPTYARG pListBox )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pListBox;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pListBox == &aFonts, "Sm : wrong argument");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SelectFont(aFonts.GetSelectEntry());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, SubsetChangeHdl, ListBox *, EMPTYARG pListBox )
|
2001-07-23 07:56:32 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pListBox;
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = aFontsSubsetLB.GetSelectEntryPos();
|
2001-07-23 07:56:32 +00:00
|
|
|
if (LISTBOX_ENTRY_NOTFOUND != nPos)
|
|
|
|
{
|
|
|
|
const Subset* pSubset = reinterpret_cast<const Subset*> (aFontsSubsetLB.GetEntryData( nPos ));
|
|
|
|
if (pSubset)
|
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
aCharsetDisplay.SelectCharacter( pSubset->GetRangeMin() );
|
2001-07-23 07:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pComboBox;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pComboBox == &aStyles, "Sm : falsches Argument");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SelectStyle(aStyles.GetText());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SmSymDefineDialog, CharHighlightHdl)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-08-03 11:29:55 +02:00
|
|
|
sal_UCS4 cChar = aCharsetDisplay.GetSelectCharacter();
|
2001-07-23 07:56:32 +00:00
|
|
|
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE( pSubsetMap, "SubsetMap missing" );
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2001-07-23 07:56:32 +00:00
|
|
|
if (pSubsetMap)
|
|
|
|
{
|
|
|
|
const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
|
|
|
|
if (pSubset)
|
|
|
|
aFontsSubsetLB.SelectEntry( pSubset->GetName() );
|
2001-07-30 09:51:29 +00:00
|
|
|
else
|
|
|
|
aFontsSubsetLB.SetNoSelection();
|
2001-07-23 07:56:32 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 11:29:55 +02:00
|
|
|
aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() );
|
|
|
|
|
2001-07-17 07:28:21 +00:00
|
|
|
UpdateButtons();
|
2010-08-03 11:29:55 +02:00
|
|
|
|
|
|
|
// display Unicode position as symbol name while iterating over characters
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString aHex(OUString::valueOf(static_cast<sal_Int64>(cChar), 16 ).toAsciiUpperCase());
|
2012-10-22 15:08:50 +04:00
|
|
|
const OUString aPattern( (aHex.getLength() > 4) ? OUString("Ux000000") : OUString("Ux0000") );
|
|
|
|
OUString aUnicodePos( aPattern.copy( 0, aPattern.getLength() - aHex.getLength() ) );
|
2010-08-03 11:29:55 +02:00
|
|
|
aUnicodePos += aHex;
|
|
|
|
aSymbols.SetText( aUnicodePos );
|
|
|
|
aSymbolName.SetText( aUnicodePos );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pButton;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pButton == &aAddBtn, "Sm : wrong argument");
|
|
|
|
OSL_ENSURE(aAddBtn.IsEnabled(), "Sm : requirements met ??");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
// add symbol
|
2010-05-07 09:35:48 +02:00
|
|
|
const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(),
|
2010-08-03 11:29:55 +02:00
|
|
|
aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() );
|
2010-10-07 11:02:05 +01:00
|
|
|
//OSL_ENSURE( aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL, "symbol already exists" );
|
2010-05-07 09:35:48 +02:00
|
|
|
aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol );
|
|
|
|
|
|
|
|
// update display of new symbol
|
2010-08-03 11:29:55 +02:00
|
|
|
aSymbolDisplay.SetSymbol( &aNewSymbol );
|
2010-05-07 09:35:48 +02:00
|
|
|
aSymbolName.SetText( aNewSymbol.GetName() );
|
|
|
|
aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() );
|
2009-09-28 10:46:54 +00:00
|
|
|
|
|
|
|
// update list box entries
|
2010-11-06 01:33:05 +01:00
|
|
|
FillSymbolSets(aOldSymbolSets, false);
|
|
|
|
FillSymbolSets(aSymbolSets, false);
|
|
|
|
FillSymbols(aOldSymbols ,false);
|
|
|
|
FillSymbols(aSymbols ,false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pButton;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pButton == &aChangeBtn, "Sm : wrong argument");
|
|
|
|
OSL_ENSURE(aChangeBtn.IsEnabled(), "Sm : requirements met ??");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
// get new Sybol to use
|
|
|
|
//! get font from symbol-disp lay since charset-display does not keep
|
2001-10-04 11:25:13 +00:00
|
|
|
//! the bold attribut.
|
2010-05-07 09:35:48 +02:00
|
|
|
const SmSym aNewSymbol( aSymbols.GetText(), aCharsetDisplay.GetFont(),
|
2010-08-03 11:29:55 +02:00
|
|
|
aCharsetDisplay.GetSelectCharacter(), aSymbolSets.GetText() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
// remove old symbol if the name was changed then add new one
|
2010-05-07 09:35:48 +02:00
|
|
|
const bool bNameChanged = aOldSymbols.GetText() != aSymbols.GetText();
|
|
|
|
if (bNameChanged)
|
2009-09-28 10:46:54 +00:00
|
|
|
aSymbolMgrCopy.RemoveSymbol( aOldSymbols.GetText() );
|
|
|
|
aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol, true );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-05-07 09:35:48 +02:00
|
|
|
// clear display for original symbol if necessary
|
|
|
|
if (bNameChanged)
|
2013-04-07 12:06:47 +02:00
|
|
|
SetOrigSymbol(NULL, OUString());
|
2010-05-07 09:35:48 +02:00
|
|
|
|
|
|
|
// update display of new symbol
|
2010-08-03 11:29:55 +02:00
|
|
|
aSymbolDisplay.SetSymbol( &aNewSymbol );
|
2010-05-07 09:35:48 +02:00
|
|
|
aSymbolName.SetText( aNewSymbol.GetName() );
|
|
|
|
aSymbolSetName.SetText( aNewSymbol.GetSymbolSetName() );
|
2009-09-28 10:46:54 +00:00
|
|
|
|
|
|
|
// update list box entries
|
2010-11-06 01:33:05 +01:00
|
|
|
FillSymbolSets(aOldSymbolSets, false);
|
|
|
|
FillSymbolSets(aSymbolSets, false);
|
|
|
|
FillSymbols(aOldSymbols ,false);
|
|
|
|
FillSymbols(aSymbols ,false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-09 09:52:52 +00:00
|
|
|
IMPL_LINK( SmSymDefineDialog, DeleteClickHdl, Button *, EMPTYARG pButton )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-11-09 09:52:52 +00:00
|
|
|
(void) pButton;
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(pButton == &aDeleteBtn, "Sm : wrong argument");
|
|
|
|
OSL_ENSURE(aDeleteBtn.IsEnabled(), "Sm : requirements met ??");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (pOrigSymbol)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
aSymbolMgrCopy.RemoveSymbol( pOrigSymbol->GetName() );
|
|
|
|
|
|
|
|
// clear display for original symbol
|
2013-04-07 12:06:47 +02:00
|
|
|
SetOrigSymbol(NULL, OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
// update list box entries
|
2010-11-06 01:33:05 +01:00
|
|
|
FillSymbolSets(aOldSymbolSets, false);
|
|
|
|
FillSymbolSets(aSymbolSets, false);
|
|
|
|
FillSymbols(aOldSymbols ,false);
|
|
|
|
FillSymbols(aSymbols ,false);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmSymDefineDialog::UpdateButtons()
|
|
|
|
{
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bAdd = false,
|
|
|
|
bChange = false,
|
2010-12-23 12:45:41 +00:00
|
|
|
bDelete = false;
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aTmpSymbolName (aSymbols.GetText()),
|
2007-05-25 11:33:41 +00:00
|
|
|
aTmpSymbolSetName (aSymbolSets.GetText());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
if (aTmpSymbolName.getLength() > 0 && aTmpSymbolSetName.getLength() > 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// are all settings equal?
|
|
|
|
//! (Font-, Style- und SymbolSet name comparison is not case sensitive)
|
2010-12-23 12:45:41 +00:00
|
|
|
bool bEqual = pOrigSymbol
|
2012-10-12 14:48:34 +01:00
|
|
|
&& aTmpSymbolSetName.equalsIgnoreAsciiCase(aOldSymbolSetName.GetText())
|
|
|
|
&& aTmpSymbolName.equals(pOrigSymbol->GetName())
|
2001-08-09 11:24:29 +00:00
|
|
|
&& aFonts.GetSelectEntry().EqualsIgnoreCaseAscii(
|
|
|
|
pOrigSymbol->GetFace().GetName())
|
2013-01-21 14:32:09 +01:00
|
|
|
&& aStyles.GetText().equalsIgnoreAsciiCase(
|
2001-08-09 11:24:29 +00:00
|
|
|
GetFontStyles().GetStyleName(pOrigSymbol->GetFace()))
|
2001-07-17 07:28:21 +00:00
|
|
|
&& aCharsetDisplay.GetSelectCharacter() == pOrigSymbol->GetCharacter();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// only add it if there isn't already a symbol with the same name
|
2009-09-28 10:46:54 +00:00
|
|
|
bAdd = aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// only delete it if all settings are equal
|
2000-09-18 16:07:07 +00:00
|
|
|
bDelete = pOrigSymbol != NULL;
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// only change it if the old symbol exists and the new one is different
|
2010-05-07 09:35:48 +02:00
|
|
|
bChange = pOrigSymbol && !bEqual;
|
2010-12-23 12:45:41 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aAddBtn .Enable(bAdd);
|
|
|
|
aChangeBtn.Enable(bChange);
|
|
|
|
aDeleteBtn.Enable(bDelete);
|
|
|
|
}
|
|
|
|
|
2012-04-01 10:17:21 +05:30
|
|
|
IMPL_LINK( SmSymDefineDialog, HelpButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
|
|
|
|
{
|
|
|
|
// start help system
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if( pHelp )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pHelp->Start( OUString( "HID_SMA_SYMDEFINEDIALOG" ), &aHelpBtn );
|
2012-04-01 10:17:21 +05:30
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-01-31 17:33:08 +00:00
|
|
|
SmSymDefineDialog::SmSymDefineDialog(Window * pParent,
|
2010-11-06 01:33:05 +01:00
|
|
|
OutputDevice *pFntListDevice, SmSymbolManager &rMgr, bool bFreeRes) :
|
2000-09-18 16:07:07 +00:00
|
|
|
ModalDialog (pParent, SmResId(RID_SYMDEFINEDIALOG)),
|
2007-05-31 09:04:48 +00:00
|
|
|
aOldSymbolText (this, SmResId(1)),
|
|
|
|
aOldSymbols (this, SmResId(1)),
|
|
|
|
aOldSymbolSetText (this, SmResId(2)),
|
|
|
|
aOldSymbolSets (this, SmResId(2)),
|
|
|
|
aCharsetDisplay (this, SmResId(1)),
|
|
|
|
aSymbolText (this, SmResId(9)),
|
|
|
|
aSymbols (this, SmResId(4)),
|
|
|
|
aSymbolSetText (this, SmResId(10)),
|
|
|
|
aSymbolSets (this, SmResId(5)),
|
|
|
|
aFontText (this, SmResId(3)),
|
|
|
|
aFonts (this, SmResId(1)),
|
|
|
|
aFontsSubsetFT (this, SmResId( FT_FONTS_SUBSET )),
|
|
|
|
aFontsSubsetLB (this, SmResId( LB_FONTS_SUBSET )),
|
|
|
|
aStyleText (this, SmResId(4)),
|
|
|
|
aStyles (this, SmResId(3)),
|
|
|
|
aOldSymbolName (this, SmResId(7)),
|
|
|
|
aOldSymbolDisplay (this, SmResId(3)),
|
|
|
|
aOldSymbolSetName (this, SmResId(8)),
|
|
|
|
aSymbolName (this, SmResId(5)),
|
|
|
|
aSymbolDisplay (this, SmResId(2)),
|
|
|
|
aSymbolSetName (this, SmResId(6)),
|
|
|
|
aOkBtn (this, SmResId(1)),
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpBtn (this, SmResId(1)),
|
2007-05-31 09:04:48 +00:00
|
|
|
aCancelBtn (this, SmResId(1)),
|
|
|
|
aAddBtn (this, SmResId(1)),
|
|
|
|
aChangeBtn (this, SmResId(2)),
|
|
|
|
aDeleteBtn (this, SmResId(3)),
|
|
|
|
aRightArrow (this, SmResId(1)),
|
2007-08-03 12:53:58 +00:00
|
|
|
aRigthArrow_Im (SmResId(1)),
|
2009-09-28 10:46:54 +00:00
|
|
|
rSymbolMgr (rMgr),
|
2001-07-23 07:56:32 +00:00
|
|
|
pSubsetMap (NULL),
|
2007-05-25 11:33:41 +00:00
|
|
|
pFontList (NULL)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bFreeRes)
|
|
|
|
FreeResource();
|
|
|
|
|
2012-04-01 10:17:21 +05:30
|
|
|
aHelpBtn.SetClickHdl(LINK(this, SmSymDefineDialog, HelpButtonClickHdl));
|
|
|
|
|
2006-01-31 17:33:08 +00:00
|
|
|
pFontList = new FontList( pFntListDevice );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pOrigSymbol = 0;
|
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
// auto completion is troublesome since that symbols character also gets automatically selected in the
|
|
|
|
// display and if the user previously selected a character to define/redefine that one this is bad
|
2010-11-06 01:33:05 +01:00
|
|
|
aOldSymbols.EnableAutocomplete( false, true );
|
|
|
|
aSymbols .EnableAutocomplete( false, true );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
FillFonts();
|
|
|
|
if (aFonts.GetEntryCount() > 0)
|
|
|
|
SelectFont(aFonts.GetEntry(0));
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
InitColor_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
SetSymbolSetManager(rSymbolMgr);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aOldSymbols .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolChangeHdl));
|
|
|
|
aOldSymbolSets .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolSetChangeHdl));
|
|
|
|
aSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
|
|
|
|
aOldSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
|
|
|
|
aSymbols .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
|
|
|
|
aOldSymbols .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
|
|
|
|
aStyles .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
|
|
|
|
aFonts .SetSelectHdl(LINK(this, SmSymDefineDialog, FontChangeHdl));
|
2001-07-23 07:56:32 +00:00
|
|
|
aFontsSubsetLB .SetSelectHdl(LINK(this, SmSymDefineDialog, SubsetChangeHdl));
|
2000-09-18 16:07:07 +00:00
|
|
|
aStyles .SetSelectHdl(LINK(this, SmSymDefineDialog, StyleChangeHdl));
|
|
|
|
aAddBtn .SetClickHdl (LINK(this, SmSymDefineDialog, AddClickHdl));
|
|
|
|
aChangeBtn .SetClickHdl (LINK(this, SmSymDefineDialog, ChangeClickHdl));
|
|
|
|
aDeleteBtn .SetClickHdl (LINK(this, SmSymDefineDialog, DeleteClickHdl));
|
2001-07-17 07:28:21 +00:00
|
|
|
aCharsetDisplay.SetHighlightHdl( LINK( this, SmSymDefineDialog, CharHighlightHdl ) );
|
2002-04-24 09:15:41 +00:00
|
|
|
|
|
|
|
// preview like controls should have a 2D look
|
|
|
|
aOldSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO );
|
|
|
|
aSymbolDisplay .SetBorderStyle( WINDOW_BORDER_MONO );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SmSymDefineDialog::~SmSymDefineDialog()
|
|
|
|
{
|
2001-07-23 07:56:32 +00:00
|
|
|
delete pSubsetMap;
|
2001-10-02 11:58:49 +00:00
|
|
|
delete pOrigSymbol;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-04-24 09:15:41 +00:00
|
|
|
void SmSymDefineDialog::InitColor_Impl()
|
|
|
|
{
|
2003-04-15 15:21:44 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2002-07-12 06:26:02 +00:00
|
|
|
Color aBC( GetDisplayBackground().GetColor() );
|
2002-04-24 09:15:41 +00:00
|
|
|
#endif
|
|
|
|
ColorData nBgCol = COL_WHITE,
|
|
|
|
nTxtCol = COL_BLACK;
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
|
2007-08-03 12:53:58 +00:00
|
|
|
if (bHighContrast)
|
2002-04-24 09:15:41 +00:00
|
|
|
{
|
|
|
|
const StyleSettings &rS = GetSettings().GetStyleSettings();
|
|
|
|
nBgCol = rS.GetFieldColor().GetColor();
|
|
|
|
nTxtCol = rS.GetFieldTextColor().GetColor();
|
|
|
|
}
|
|
|
|
|
2002-05-03 13:35:00 +00:00
|
|
|
Color aTmpColor( nBgCol );
|
|
|
|
Wallpaper aWall( aTmpColor );
|
2002-04-24 09:15:41 +00:00
|
|
|
Color aTxtColor( nTxtCol );
|
|
|
|
aCharsetDisplay .SetBackground( aWall );
|
|
|
|
aCharsetDisplay .SetTextColor( aTxtColor );
|
|
|
|
aOldSymbolDisplay.SetBackground( aWall );
|
|
|
|
aOldSymbolDisplay.SetTextColor( aTxtColor );
|
|
|
|
aSymbolDisplay .SetBackground( aWall );
|
|
|
|
aSymbolDisplay .SetTextColor( aTxtColor );
|
2007-08-03 12:53:58 +00:00
|
|
|
|
2010-11-16 16:16:52 +00:00
|
|
|
const Image &rArrowRight = aRigthArrow_Im;
|
2007-08-03 12:53:58 +00:00
|
|
|
aRightArrow.SetImage( rArrowRight );
|
2002-04-24 09:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmSymDefineDialog::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
InitColor_Impl();
|
|
|
|
|
|
|
|
ModalDialog::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
short SmSymDefineDialog::Execute()
|
|
|
|
{
|
|
|
|
short nResult = ModalDialog::Execute();
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// apply changes if dialog was closed by clicking OK
|
2009-09-28 10:46:54 +00:00
|
|
|
if (aSymbolMgrCopy.IsModified() && nResult == RET_OK)
|
|
|
|
rSymbolMgr = aSymbolMgrCopy;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return nResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-28 10:46:54 +00:00
|
|
|
void SmSymDefineDialog::SetSymbolSetManager(const SmSymbolManager &rMgr)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
aSymbolMgrCopy = rMgr;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// Set the modified flag of the copy to false so that
|
|
|
|
// we can check later on if anything has been changed
|
2010-11-06 01:33:05 +01:00
|
|
|
aSymbolMgrCopy.SetModified(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
FillSymbolSets(aOldSymbolSets);
|
|
|
|
if (aOldSymbolSets.GetEntryCount() > 0)
|
|
|
|
SelectSymbolSet(aOldSymbolSets.GetEntry(0));
|
|
|
|
FillSymbolSets(aSymbolSets);
|
|
|
|
if (aSymbolSets.GetEntryCount() > 0)
|
|
|
|
SelectSymbolSet(aSymbolSets.GetEntry(0));
|
|
|
|
FillSymbols(aOldSymbols);
|
|
|
|
if (aOldSymbols.GetEntryCount() > 0)
|
|
|
|
SelectSymbol(aOldSymbols.GetEntry(0));
|
|
|
|
FillSymbols(aSymbols);
|
|
|
|
if (aSymbols.GetEntryCount() > 0)
|
|
|
|
SelectSymbol(aSymbols.GetEntry(0));
|
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox,
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString &rSymbolSetName, bool bDeleteText)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets,
|
|
|
|
"Sm : wrong ComboBox");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// trim SymbolName (no leading and trailing blanks)
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aNormName (rSymbolSetName);
|
2011-11-22 23:40:24 +00:00
|
|
|
aNormName = comphelper::string::stripStart(aNormName, ' ');
|
|
|
|
aNormName = comphelper::string::stripEnd(aNormName, ' ');
|
2012-08-03 10:22:14 +02:00
|
|
|
// and remove possible deviations within the input
|
2000-09-18 16:07:07 +00:00
|
|
|
rComboBox.SetText(aNormName);
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bRet = false;
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = rComboBox.GetEntryPos(aNormName);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
|
|
|
rComboBox.SetText(rComboBox.GetEntry(nPos));
|
2010-11-06 01:33:05 +01:00
|
|
|
bRet = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (bDeleteText)
|
2013-04-07 12:06:47 +02:00
|
|
|
rComboBox.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bIsOld = &rComboBox == &aOldSymbolSets;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// setting the SymbolSet name at the associated display
|
2000-09-18 16:07:07 +00:00
|
|
|
FixedText &rFT = bIsOld ? aOldSymbolSetName : aSymbolSetName;
|
|
|
|
rFT.SetText(rComboBox.GetText());
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// set the symbol name which belongs to the SymbolSet at the associated combobox
|
2000-09-18 16:07:07 +00:00
|
|
|
ComboBox &rCB = bIsOld ? aOldSymbols : aSymbols;
|
2010-11-06 01:33:05 +01:00
|
|
|
FillSymbols(rCB, false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// display a valid respectively no symbol when changing the SymbolSets
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bIsOld)
|
|
|
|
{
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aTmpOldSymbolName;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (aOldSymbols.GetEntryCount() > 0)
|
2007-05-25 11:33:41 +00:00
|
|
|
aTmpOldSymbolName = aOldSymbols.GetEntry(0);
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectSymbol(aOldSymbols, aTmpOldSymbolName, true);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol,
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString &rSymbolSetName)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-10-02 11:58:49 +00:00
|
|
|
// clear old symbol
|
|
|
|
delete pOrigSymbol;
|
|
|
|
pOrigSymbol = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aSymName,
|
2001-10-02 11:58:49 +00:00
|
|
|
aSymSetName;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pSymbol)
|
|
|
|
{
|
2001-10-02 11:58:49 +00:00
|
|
|
// set new symbol
|
|
|
|
pOrigSymbol = new SmSym( *pSymbol );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
aSymName = pSymbol->GetName();
|
|
|
|
aSymSetName = rSymbolSetName;
|
2010-08-03 11:29:55 +02:00
|
|
|
aOldSymbolDisplay.SetSymbol( pSymbol );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2012-08-03 10:22:14 +02:00
|
|
|
{ // delete displayed symbols
|
2013-04-07 12:06:47 +02:00
|
|
|
aOldSymbolDisplay.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
aOldSymbolDisplay.Invalidate();
|
|
|
|
}
|
|
|
|
aOldSymbolName .SetText(aSymName);
|
|
|
|
aOldSymbolSetName.SetText(aSymSetName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox,
|
2012-10-12 14:48:34 +01:00
|
|
|
const OUString &rSymbolName, bool bDeleteText)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-05-25 11:33:41 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2010-10-07 11:02:05 +01:00
|
|
|
OSL_ENSURE(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols,
|
|
|
|
"Sm : wrong ComboBox");
|
2007-05-25 11:33:41 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// trim SymbolName (no blanks)
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aNormName(comphelper::string::remove(rSymbolName, ' '));
|
2012-08-03 10:22:14 +02:00
|
|
|
// and remove possible deviations within the input
|
2000-09-18 16:07:07 +00:00
|
|
|
rComboBox.SetText(aNormName);
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bRet = false;
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = rComboBox.GetEntryPos(aNormName);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bIsOld = &rComboBox == &aOldSymbols;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
|
|
|
rComboBox.SetText(rComboBox.GetEntry(nPos));
|
|
|
|
|
|
|
|
if (!bIsOld)
|
|
|
|
{
|
|
|
|
const SmSym *pSymbol = GetSymbol(aSymbols);
|
|
|
|
if (pSymbol)
|
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// choose font and style accordingly
|
2000-09-18 16:07:07 +00:00
|
|
|
const Font &rFont = pSymbol->GetFace();
|
2010-11-06 01:33:05 +01:00
|
|
|
SelectFont(rFont.GetName(), false);
|
|
|
|
SelectStyle(GetFontStyles().GetStyleName(rFont), false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// Since setting the Font via the Style name of the SymbolFonts doesn't
|
|
|
|
// work really well (e.g. it can be empty even though the font itself is
|
|
|
|
// bold or italic) we're manually setting the Font with respect to the Symbol
|
2000-09-18 16:07:07 +00:00
|
|
|
aCharsetDisplay.SetFont(rFont);
|
|
|
|
aSymbolDisplay.SetFont(rFont);
|
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// select associated character
|
2000-09-18 16:07:07 +00:00
|
|
|
SelectChar(pSymbol->GetCharacter());
|
2010-08-05 10:31:58 +02:00
|
|
|
|
|
|
|
// since SelectChar will also set the unicode point as text in the
|
|
|
|
// symbols box, we have to set the symbol name again to get that one displayed
|
|
|
|
aSymbols.SetText( pSymbol->GetName() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bRet = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (bDeleteText)
|
2013-04-07 12:06:47 +02:00
|
|
|
rComboBox.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bIsOld)
|
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// if there's a change of the old symbol, show only the available ones, otherwise show none
|
2000-09-18 16:07:07 +00:00
|
|
|
const SmSym *pOldSymbol = NULL;
|
2012-10-12 14:48:34 +01:00
|
|
|
OUString aTmpOldSymbolSetName;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
2009-09-28 10:46:54 +00:00
|
|
|
pOldSymbol = aSymbolMgrCopy.GetSymbolByName(aNormName);
|
|
|
|
aTmpOldSymbolSetName = aOldSymbolSets.GetText();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2009-09-28 10:46:54 +00:00
|
|
|
SetOrigSymbol(pOldSymbol, aTmpOldSymbolSetName);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aSymbolName.SetText(rComboBox.GetText());
|
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
void SmSymDefineDialog::SetFont(const OUString &rFontName, const OUString &rStyleName)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-08-03 10:22:14 +02:00
|
|
|
// get Font (FontInfo) matching name and style
|
2006-01-31 17:33:08 +00:00
|
|
|
FontInfo aFI;
|
|
|
|
if (pFontList)
|
|
|
|
aFI = pFontList->Get(rFontName, WEIGHT_NORMAL, ITALIC_NONE);
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFontStyle(rStyleName, aFI);
|
|
|
|
|
|
|
|
aCharsetDisplay.SetFont(aFI);
|
|
|
|
aSymbolDisplay.SetFont(aFI);
|
2001-07-23 07:56:32 +00:00
|
|
|
|
|
|
|
// update subset listbox for new font's unicode subsets
|
|
|
|
FontCharMap aFontCharMap;
|
|
|
|
aCharsetDisplay.GetFontCharMap( aFontCharMap );
|
|
|
|
if (pSubsetMap)
|
|
|
|
delete pSubsetMap;
|
|
|
|
pSubsetMap = new SubsetMap( &aFontCharMap );
|
2011-01-24 01:49:58 +01:00
|
|
|
|
2001-07-23 07:56:32 +00:00
|
|
|
aFontsSubsetLB.Clear();
|
2003-04-11 16:50:54 +00:00
|
|
|
bool bFirst = true;
|
|
|
|
const Subset* pSubset;
|
|
|
|
while( NULL != (pSubset = pSubsetMap->GetNextSubset( bFirst )) )
|
2001-07-23 07:56:32 +00:00
|
|
|
{
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = aFontsSubsetLB.InsertEntry( pSubset->GetName());
|
2003-04-11 16:50:54 +00:00
|
|
|
aFontsSubsetLB.SetEntryData( nPos, (void *) pSubset );
|
|
|
|
// subset must live at least as long as the selected font !!!
|
|
|
|
if( bFirst )
|
2010-08-05 10:31:58 +02:00
|
|
|
aFontsSubsetLB.SelectEntryPos( nPos );
|
2003-04-11 16:50:54 +00:00
|
|
|
bFirst = false;
|
2001-07-23 07:56:32 +00:00
|
|
|
}
|
2003-04-11 16:50:54 +00:00
|
|
|
if( bFirst )
|
|
|
|
aFontsSubsetLB.SetNoSelection();
|
|
|
|
aFontsSubsetLB.Enable( !bFirst );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
bool SmSymDefineDialog::SelectFont(const OUString &rFontName, bool bApplyFont)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bRet = false;
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = aFonts.GetEntryPos(rFontName);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nPos != LISTBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
|
|
|
aFonts.SelectEntryPos(nPos);
|
|
|
|
if (aStyles.GetEntryCount() > 0)
|
|
|
|
SelectStyle(aStyles.GetEntry(0));
|
|
|
|
if (bApplyFont)
|
2010-08-05 10:31:58 +02:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
|
2010-11-06 01:33:05 +01:00
|
|
|
bRet = true;
|
2010-08-05 10:31:58 +02:00
|
|
|
aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() );
|
|
|
|
}
|
2011-01-14 17:19:25 +01:00
|
|
|
bRet = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aFonts.SetNoSelection();
|
|
|
|
FillStyles();
|
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-12 14:48:34 +01:00
|
|
|
bool SmSymDefineDialog::SelectStyle(const OUString &rStyleName, bool bApplyFont)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bRet = false;
|
2011-01-14 17:19:25 +01:00
|
|
|
sal_uInt16 nPos = aStyles.GetEntryPos(rStyleName);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-08-03 10:22:14 +02:00
|
|
|
// if the style is not available take the first available one (if existent)
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nPos == COMBOBOX_ENTRY_NOTFOUND && aStyles.GetEntryCount() > 0)
|
|
|
|
nPos = 0;
|
|
|
|
|
|
|
|
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
|
|
|
aStyles.SetText(aStyles.GetEntry(nPos));
|
|
|
|
if (bApplyFont)
|
2010-08-05 10:31:58 +02:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
|
2010-11-06 01:33:05 +01:00
|
|
|
bRet = true;
|
2010-08-05 10:31:58 +02:00
|
|
|
aSymbolDisplay.SetSymbol( aCharsetDisplay.GetSelectCharacter(), aCharsetDisplay.GetFont() );
|
|
|
|
}
|
2011-01-14 17:19:25 +01:00
|
|
|
bRet = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2013-04-07 12:06:47 +02:00
|
|
|
aStyles.SetText(OUString());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-19 05:34:48 -05:00
|
|
|
void SmSymDefineDialog::SelectChar(sal_Unicode cChar)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-17 07:28:21 +00:00
|
|
|
aCharsetDisplay.SelectCharacter( cChar );
|
2010-08-03 11:29:55 +02:00
|
|
|
aSymbolDisplay.SetSymbol( cChar, aCharsetDisplay.GetFont() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
UpdateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|