Files
libreoffice/starmath/source/dialog.cxx

2373 lines
73 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/app.hxx>
#include <vcl/builder.hxx>
#include <vcl/layout.hxx>
2000-09-18 16:07:07 +00:00
#include <vcl/msgbox.hxx>
#include <svtools/ctrltool.hxx>
#include <sfx2/printer.hxx>
#include <vcl/help.hxx>
2000-09-18 16:07:07 +00:00
#include <vcl/waitobj.hxx>
#include <vcl/settings.hxx>
#include <vcl/wall.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/dispatch.hxx>
#include <sfx2/sfx.hrc>
#include <osl/diagnose.h>
#include <svx/ucsubset.hxx>
2000-09-18 16:07:07 +00:00
#include "dialog.hxx"
#include "starmath.hrc"
#include "config.hxx"
2000-09-18 16:07:07 +00:00
#include "smmod.hxx"
#include "symbol.hxx"
#include "view.hxx"
#include "document.hxx"
#include "unomodel.hxx"
// 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
class SmFontStyles
2000-09-18 16:07:07 +00:00
{
OUString aNormal;
OUString aBold;
OUString aItalic;
OUString aBoldItalic;
OUString aEmpty;
public:
SmFontStyles();
sal_uInt16 GetCount() const { return 4; }
const OUString& GetStyleName( const vcl::Font &rFont ) const;
const OUString& GetStyleName( sal_uInt16 nIdx ) const;
2000-09-18 16:07:07 +00:00
};
SmFontStyles::SmFontStyles() :
aNormal ( ResId( RID_FONTREGULAR, *SM_MOD()->GetResMgr() ) ),
aBold ( ResId( RID_FONTBOLD, *SM_MOD()->GetResMgr() ) ),
aItalic ( ResId( RID_FONTITALIC, *SM_MOD()->GetResMgr() ) )
{
aBoldItalic = aBold;
aBoldItalic += ", ";
aBoldItalic += aItalic;
}
const OUString& SmFontStyles::GetStyleName( const vcl::Font &rFont ) const
{
//! compare also SmSpecialNode::Prepare
bool bBold = IsBold( rFont ),
bItalic = IsItalic( rFont );
if (bBold && bItalic)
return aBoldItalic;
else if (bItalic)
return aItalic;
else if (bBold)
return aBold;
return aNormal;
}
const OUString& SmFontStyles::GetStyleName( sal_uInt16 nIdx ) const
{
// 0 = "normal", 1 = "italic",
// 2 = "bold", 3 = "bold italic"
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE( nIdx < GetCount(), "index out of range" );
#endif
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
const SmFontStyles & GetFontStyles()
2000-09-18 16:07:07 +00:00
{
static const SmFontStyles aImpl;
return aImpl;
2000-09-18 16:07:07 +00:00
}
2000-09-18 16:07:07 +00:00
void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont)
2000-09-18 16:07:07 +00:00
{
// Find index related to StyleName. For an empty StyleName it's assumed to be
// 0 (neither bold nor italic).
sal_uInt16 nIndex = 0;
if (!rStyleName.isEmpty())
2000-09-18 16:07:07 +00:00
{
sal_uInt16 i;
const SmFontStyles &rStyles = GetFontStyles();
for (i = 0; i < rStyles.GetCount(); ++i)
if (rStyleName == rStyles.GetStyleName(i))
2000-09-18 16:07:07 +00:00
break;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(i < rStyles.GetCount(), "style-name unknown");
#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);
}
/**************************************************************************/
IMPL_LINK_INLINE_START( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, EMPTYARG/*pButton*/ )
2000-09-18 16:07:07 +00:00
{
m_pZoom->Enable(m_pSizeZoomed->IsChecked());
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK_INLINE_END( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, pButton )
SmPrintOptionsTabPage::SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions)
: SfxTabPage(pParent, "SmathSettings", "modules/smath/ui/smathsettings.ui", &rOptions)
2000-09-18 16:07:07 +00:00
{
get( m_pTitle, "title");
get( m_pText, "text");
get( m_pFrame, "frame");
get( m_pSizeNormal, "sizenormal");
get( m_pSizeScaled, "sizescaled");
get( m_pSizeZoomed, "sizezoomed");
get( m_pZoom, "zoom");
get( m_pNoRightSpaces, "norightspaces");
get( m_pSaveOnlyUsedSymbols, "saveonlyusedsymbols");
m_pSizeNormal->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
m_pSizeScaled->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
m_pSizeZoomed->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
2000-09-18 16:07:07 +00:00
Reset(&rOptions);
2000-09-18 16:07:07 +00:00
}
bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet)
2000-09-18 16:07:07 +00:00
{
sal_uInt16 nPrintSize;
if (m_pSizeNormal->IsChecked())
2000-09-18 16:07:07 +00:00
nPrintSize = PRINT_SIZE_NORMAL;
else if (m_pSizeScaled->IsChecked())
2000-09-18 16:07:07 +00:00
nPrintSize = PRINT_SIZE_SCALED;
else
nPrintSize = PRINT_SIZE_ZOOMED;
rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTSIZE), (sal_uInt16) nPrintSize));
rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), (sal_uInt16) m_pZoom->GetValue()));
rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), m_pTitle->IsChecked()));
rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), m_pText->IsChecked()));
rSet->Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), m_pFrame->IsChecked()));
rSet->Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), m_pNoRightSpaces->IsChecked()));
rSet->Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), m_pSaveOnlyUsedSymbols->IsChecked()));
2000-09-18 16:07:07 +00:00
return true;
2000-09-18 16:07:07 +00:00
}
void SmPrintOptionsTabPage::Reset(const SfxItemSet* rSet)
2000-09-18 16:07:07 +00:00
{
SmPrintSize ePrintSize = (SmPrintSize)((const SfxUInt16Item &)rSet->Get(GetWhich(SID_PRINTSIZE))).GetValue();
2000-09-18 16:07:07 +00:00
m_pSizeNormal->Check(ePrintSize == PRINT_SIZE_NORMAL);
m_pSizeScaled->Check(ePrintSize == PRINT_SIZE_SCALED);
m_pSizeZoomed->Check(ePrintSize == PRINT_SIZE_ZOOMED);
2000-09-18 16:07:07 +00:00
m_pZoom->Enable(m_pSizeZoomed->IsChecked());
2000-09-18 16:07:07 +00:00
m_pZoom->SetValue(((const SfxUInt16Item &)rSet->Get(GetWhich(SID_PRINTZOOM))).GetValue());
2000-09-18 16:07:07 +00:00
m_pTitle->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_PRINTTITLE))).GetValue());
m_pText->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_PRINTTEXT))).GetValue());
m_pFrame->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_PRINTFRAME))).GetValue());
m_pNoRightSpaces->Check(((const SfxBoolItem &)rSet->Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue());
m_pSaveOnlyUsedSymbols->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));
}
/**************************************************************************/
void SmShowFont::Paint(const Rectangle& rRect )
2000-09-18 16:07:07 +00:00
{
Window::Paint( rRect );
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);
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSmShowFont(Window* pParent, VclBuilder::stringmap &rMap)
{
WinBits nWinStyle = 0;
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
return new SmShowFont(pParent, nWinStyle);
}
Size SmShowFont::GetOptimalSize() const
{
return LogicToPixel(Size(111 , 31), MapMode(MAP_APPFONT));
}
2000-09-18 16:07:07 +00:00
void SmShowFont::SetFont(const vcl::Font& rFont)
2000-09-18 16:07:07 +00:00
{
Color aTxtColor( GetTextColor() );
vcl::Font aFont (rFont);
2000-09-18 16:07:07 +00:00
Invalidate();
aFont.SetSize(Size(0, 24));
aFont.SetAlign(ALIGN_TOP);
Window::SetFont(aFont);
// keep old text color (new font may have different color)
SetTextColor( aTxtColor );
2000-09-18 16:07:07 +00:00
}
IMPL_LINK_INLINE_START( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
2000-09-18 16:07:07 +00:00
{
Face.SetName(pComboBox->GetText());
m_pShowFont->SetFont(Face);
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK_INLINE_END( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
IMPL_LINK( SmFontDialog, FontModifyHdl, ComboBox *, pComboBox )
{
// if font is available in list then use it
sal_Int32 nPos = pComboBox->GetEntryPos( pComboBox->GetText() );
if (COMBOBOX_ENTRY_NOTFOUND != nPos)
{
FontSelectHdl( pComboBox );
}
return 0;
}
2000-09-18 16:07:07 +00:00
IMPL_LINK( SmFontDialog, AttrChangeHdl, CheckBox *, EMPTYARG /*pCheckBox*/ )
2000-09-18 16:07:07 +00:00
{
if (m_pBoldCheckBox->IsChecked())
2000-09-18 16:07:07 +00:00
Face.SetWeight(FontWeight(WEIGHT_BOLD));
else
Face.SetWeight(FontWeight(WEIGHT_NORMAL));
if (m_pItalicCheckBox->IsChecked())
2000-09-18 16:07:07 +00:00
Face.SetItalic(ITALIC_NORMAL);
else
Face.SetItalic(ITALIC_NONE);
m_pShowFont->SetFont(Face);
2000-09-18 16:07:07 +00:00
return 0;
}
void SmFontDialog::SetFont(const vcl::Font &rFont)
2000-09-18 16:07:07 +00:00
{
Face = rFont;
m_pFontBox->SetText( Face.GetName() );
m_pBoldCheckBox->Check( IsBold( Face ) );
m_pItalicCheckBox->Check( IsItalic( Face ) );
2000-09-18 16:07:07 +00:00
m_pShowFont->SetFont(Face);
2000-09-18 16:07:07 +00:00
}
SmFontDialog::SmFontDialog(Window * pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes)
: ModalDialog(pParent, "FontDialog", "modules/smath/ui/fontdialog.ui")
{
get(m_pFontBox, "font");
m_pFontBox->set_height_request(8 * m_pFontBox->GetTextHeight());
get(m_pAttrFrame, "attrframe");
get(m_pBoldCheckBox, "bold");
get(m_pItalicCheckBox, "italic");
get(m_pShowFont, "preview");
2000-09-18 16:07:07 +00:00
{
WaitObject aWait( this );
FontList aFontList( pFntListDevice );
2000-09-18 16:07:07 +00:00
sal_uInt16 nCount = aFontList.GetFontNameCount();
for (sal_uInt16 i = 0; i < nCount; ++i)
m_pFontBox->InsertEntry( aFontList.GetFontName(i).GetName() );
2000-09-18 16:07:07 +00:00
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);
Face.SetTransparent(true);
2000-09-18 16:07:07 +00:00
InitColor_Impl();
// preview like controls should have a 2D look
m_pShowFont->SetBorderStyle( WINDOW_BORDER_MONO );
2000-09-18 16:07:07 +00:00
}
m_pFontBox->SetSelectHdl(LINK(this, SmFontDialog, FontSelectHdl));
m_pFontBox->SetModifyHdl(LINK(this, SmFontDialog, FontModifyHdl));
m_pBoldCheckBox->SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
m_pItalicCheckBox->SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
if (bHideCheckboxes)
{
m_pBoldCheckBox->Check( false );
m_pBoldCheckBox->Enable( false );
m_pItalicCheckBox->Check( false );
m_pItalicCheckBox->Enable( false );
m_pAttrFrame->Show(false);
}
2000-09-18 16:07:07 +00:00
}
namespace
{
void getColors(Window &rRef, ColorData &rBgCol, ColorData &rTxtCol)
{
const StyleSettings &rS = rRef.GetSettings().GetStyleSettings();
if (rS.GetHighContrastMode())
{
rBgCol = rS.GetFieldColor().GetColor();
rTxtCol = rS.GetFieldTextColor().GetColor();
}
else
{
rBgCol = COL_WHITE;
rTxtCol = COL_BLACK;
}
}
}
void SmFontDialog::InitColor_Impl()
{
ColorData nBgCol, nTxtCol;
getColors(*this, nBgCol, nTxtCol);
2002-05-03 13:35:00 +00:00
Color aTmpColor( nBgCol );
Wallpaper aWall( aTmpColor );
Color aTxtColor( nTxtCol );
m_pShowFont->SetBackground( aWall );
m_pShowFont->SetTextColor( aTxtColor );
}
void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
InitColor_Impl();
ModalDialog::DataChanged( rDCEvt );
}
class SaveDefaultsQuery : public MessageDialog
{
public:
SaveDefaultsQuery(Window *pParent)
: MessageDialog(pParent, "SaveDefaultsDialog",
"modules/smath/ui/savedefaultsdialog.ui")
{
}
};
2000-09-18 16:07:07 +00:00
IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
2000-09-18 16:07:07 +00:00
{
if (SaveDefaultsQuery(this).Execute() == RET_YES)
2000-09-18 16:07:07 +00:00
{
SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt );
2000-09-18 16:07:07 +00:00
}
return 0;
}
SmFontSizeDialog::SmFontSizeDialog(Window * pParent)
: ModalDialog(pParent, "FontSizeDialog", "modules/smath/ui/fontsizedialog.ui")
2000-09-18 16:07:07 +00:00
{
get(m_pTextSize, "spinB_text");
get(m_pIndexSize, "spinB_index");
get(m_pFunctionSize, "spinB_function");
get(m_pOperatorSize, "spinB_operator");
get(m_pBorderSize, "spinB_limit");
get(m_pBaseSize, "spinB_baseSize");
get(m_pDefaultButton, "default");
m_pDefaultButton->SetClickHdl(LINK(this, SmFontSizeDialog, DefaultButtonClickHdl));
2000-09-18 16:07:07 +00:00
}
void SmFontSizeDialog::ReadFrom(const SmFormat &rFormat)
{
//! aufpassen: richtig runden!
m_pBaseSize->SetValue( SmRoundFraction(
2000-09-18 16:07:07 +00:00
Sm100th_mmToPts( rFormat.GetBaseSize().Height() ) ) );
m_pTextSize->SetValue( rFormat.GetRelSize(SIZ_TEXT) );
m_pIndexSize->SetValue( rFormat.GetRelSize(SIZ_INDEX) );
m_pFunctionSize->SetValue( rFormat.GetRelSize(SIZ_FUNCTION) );
m_pOperatorSize->SetValue( rFormat.GetRelSize(SIZ_OPERATOR) );
m_pBorderSize->SetValue( rFormat.GetRelSize(SIZ_LIMITS) );
2000-09-18 16:07:07 +00:00
}
void SmFontSizeDialog::WriteTo(SmFormat &rFormat) const
{
rFormat.SetBaseSize( Size(0, SmPtsTo100th_mm( static_cast< long >(m_pBaseSize->GetValue()))) );
2000-09-18 16:07:07 +00:00
rFormat.SetRelSize(SIZ_TEXT, (sal_uInt16) m_pTextSize->GetValue());
rFormat.SetRelSize(SIZ_INDEX, (sal_uInt16) m_pIndexSize->GetValue());
rFormat.SetRelSize(SIZ_FUNCTION, (sal_uInt16) m_pFunctionSize->GetValue());
rFormat.SetRelSize(SIZ_OPERATOR, (sal_uInt16) m_pOperatorSize->GetValue());
rFormat.SetRelSize(SIZ_LIMITS, (sal_uInt16) m_pBorderSize->GetValue());
2000-09-18 16:07:07 +00:00
const Size aTmp (rFormat.GetBaseSize());
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;
bool bHideCheckboxes = false;
2000-09-18 16:07:07 +00:00
switch (pMenu->GetCurItemId())
{
case 1: pActiveListBox = m_pVariableFont; break;
case 2: pActiveListBox = m_pFunctionFont; break;
case 3: pActiveListBox = m_pNumberFont; break;
case 4: pActiveListBox = m_pTextFont; break;
case 5: pActiveListBox = m_pSerifFont; bHideCheckboxes = true; break;
case 6: pActiveListBox = m_pSansFont; bHideCheckboxes = true; break;
case 7: pActiveListBox = m_pFixedFont; bHideCheckboxes = true; break;
2000-09-18 16:07:07 +00:00
default:pActiveListBox = NULL;
}
if (pActiveListBox)
{
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;
}
IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
2000-09-18 16:07:07 +00:00
{
if (SaveDefaultsQuery(this).Execute() == RET_YES)
2000-09-18 16:07:07 +00:00
{
SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt, true );
2000-09-18 16:07:07 +00:00
}
return 0;
}
IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton )
SmFontTypeDialog::SmFontTypeDialog(Window * pParent, OutputDevice *pFntListDevice)
: ModalDialog(pParent, "FontsDialog", "modules/smath/ui/fonttypedialog.ui"),
pFontListDev (pFntListDevice)
2000-09-18 16:07:07 +00:00
{
get(m_pVariableFont, "variableCB");
get(m_pFunctionFont, "functionCB");
get(m_pNumberFont, "numberCB");
get(m_pTextFont, "textCB");
get(m_pSerifFont, "serifCB");
get(m_pSansFont, "sansCB");
get(m_pFixedFont, "fixedCB");
get(m_pMenuButton, "modify");
get(m_pDefaultButton, "default");
2000-09-18 16:07:07 +00:00
m_pDefaultButton->SetClickHdl(LINK(this, SmFontTypeDialog, DefaultButtonClickHdl));
2000-09-18 16:07:07 +00:00
m_pMenuButton->GetPopupMenu()->SetSelectHdl(LINK(this, SmFontTypeDialog, MenuSelectHdl));
2000-09-18 16:07:07 +00:00
}
void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat)
{
SmModule *pp = SM_MOD();
2000-09-18 16:07:07 +00:00
*m_pVariableFont = pp->GetConfig()->GetFontPickList(FNT_VARIABLE);
*m_pFunctionFont = pp->GetConfig()->GetFontPickList(FNT_FUNCTION);
*m_pNumberFont = pp->GetConfig()->GetFontPickList(FNT_NUMBER);
*m_pTextFont = pp->GetConfig()->GetFontPickList(FNT_TEXT);
*m_pSerifFont = pp->GetConfig()->GetFontPickList(FNT_SERIF);
*m_pSansFont = pp->GetConfig()->GetFontPickList(FNT_SANS);
*m_pFixedFont = pp->GetConfig()->GetFontPickList(FNT_FIXED);
m_pVariableFont->Insert( rFormat.GetFont(FNT_VARIABLE) );
m_pFunctionFont->Insert( rFormat.GetFont(FNT_FUNCTION) );
m_pNumberFont->Insert( rFormat.GetFont(FNT_NUMBER) );
m_pTextFont->Insert( rFormat.GetFont(FNT_TEXT) );
m_pSerifFont->Insert( rFormat.GetFont(FNT_SERIF) );
m_pSansFont->Insert( rFormat.GetFont(FNT_SANS) );
m_pFixedFont->Insert( rFormat.GetFont(FNT_FIXED) );
2000-09-18 16:07:07 +00:00
}
void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const
{
SmModule *pp = SM_MOD();
2000-09-18 16:07:07 +00:00
pp->GetConfig()->GetFontPickList(FNT_VARIABLE) = *m_pVariableFont;
pp->GetConfig()->GetFontPickList(FNT_FUNCTION) = *m_pFunctionFont;
pp->GetConfig()->GetFontPickList(FNT_NUMBER) = *m_pNumberFont;
pp->GetConfig()->GetFontPickList(FNT_TEXT) = *m_pTextFont;
pp->GetConfig()->GetFontPickList(FNT_SERIF) = *m_pSerifFont;
pp->GetConfig()->GetFontPickList(FNT_SANS) = *m_pSansFont;
pp->GetConfig()->GetFontPickList(FNT_FIXED) = *m_pFixedFont;
rFormat.SetFont( FNT_VARIABLE, m_pVariableFont->Get(0) );
rFormat.SetFont( FNT_FUNCTION, m_pFunctionFont->Get(0) );
rFormat.SetFont( FNT_NUMBER, m_pNumberFont->Get(0) );
rFormat.SetFont( FNT_TEXT, m_pTextFont->Get(0) );
rFormat.SetFont( FNT_SERIF, m_pSerifFont->Get(0) );
rFormat.SetFont( FNT_SANS, m_pSansFont->Get(0) );
rFormat.SetFont( FNT_FIXED, m_pFixedFont->Get(0) );
2000-09-18 16:07:07 +00:00
rFormat.RequestApplyChanges();
}
/**************************************************************************/
struct FieldMinMax
{
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 }}
};
SmCategoryDesc::SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCategoryIdx)
2000-09-18 16:07:07 +00:00
{
++nCategoryIdx;
FixedText* pTitle = rBuilder.get<FixedText>(OString::number(nCategoryIdx)+"title");
if (pTitle)
2000-09-18 16:07:07 +00:00
{
Name = pTitle->GetText();
}
for (int i = 0; i < 4; ++i)
{
FixedText* pLabel = rBuilder.get<FixedText>(OString::number(nCategoryIdx)+"label"+OString::number(i+1));
2000-09-18 16:07:07 +00:00
if (pLabel)
2000-09-18 16:07:07 +00:00
{
Strings [i] = new OUString(pLabel->GetText());
FixedImage* pImage = rBuilder.get<FixedImage>(OString::number(nCategoryIdx)+"image"+OString::number(i+1));
Graphics [i] = new Image(pImage->GetImage());
2000-09-18 16:07:07 +00:00
}
else
{
Strings [i] = 0;
Graphics [i] = 0;
}
const FieldMinMax& rMinMax = pMinMaxData[ nCategoryIdx-1 ][i];
Value[i] = Minimum[i] = rMinMax.nMin;
Maximum[i] = rMinMax.nMax;
2000-09-18 16:07:07 +00:00
}
}
SmCategoryDesc::~SmCategoryDesc()
{
for (int i = 0; i < 4; ++i)
2000-09-18 16:07:07 +00:00
{
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])
{
sal_uInt16 i;
2000-09-18 16:07:07 +00:00
if (pControl == m_pMetricField1)
2000-09-18 16:07:07 +00:00
i = 0;
else if (pControl == m_pMetricField2)
2000-09-18 16:07:07 +00:00
i = 1;
else if (pControl == m_pMetricField3)
2000-09-18 16:07:07 +00:00
i = 2;
else if (pControl == m_pMetricField4)
2000-09-18 16:07:07 +00:00
i = 3;
else
return 0;
m_pBitmap->SetImage(*(Categories[nActiveCategory]->GetGraphic(i)));
2000-09-18 16:07:07 +00:00
}
return 0;
}
IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu )
{
SetCategory(pMenu->GetCurItemId() - 1);
return 0;
}
IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
2000-09-18 16:07:07 +00:00
{
if (SaveDefaultsQuery(this).Execute() == RET_YES)
2000-09-18 16:07:07 +00:00
{
SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt );
2000-09-18 16:07:07 +00:00
}
return 0;
}
IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox )
{
if (pCheckBox == m_pCheckBox1)
2000-09-18 16:07:07 +00:00
{
m_pCheckBox1->Toggle();
2000-09-18 16:07:07 +00:00
bool bChecked = m_pCheckBox1->IsChecked();
m_pFixedText4->Enable( bChecked );
m_pMetricField4->Enable( bChecked );
2000-09-18 16:07:07 +00:00
}
return 0;
}
void SmDistanceDialog::SetHelpId(MetricField &rField, const OString& sHelpId)
2000-09-18 16:07:07 +00:00
{
const OUString aEmptyText;
2000-09-18 16:07:07 +00: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)
{
pSubEdit->SetHelpId(sHelpId);
2000-09-18 16:07:07 +00:00
pSubEdit->SetHelpText(aEmptyText);
}
}
void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
2000-09-18 16:07:07 +00:00
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(/*0 <= nCategory &&*/ nCategory < NOCATEGORIES,
"Sm: wrong category number in SmDistanceDialog");
#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.
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(NOCATEGORIES == 10, "Sm : array doesn't fit into the number of categories");
#endif
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 Conflicts: starmath/inc/applicat.hxx starmath/inc/dialog.hxx starmath/inc/document.hxx starmath/inc/edit.hxx starmath/inc/format.hxx starmath/inc/node.hxx starmath/inc/parse.hxx starmath/inc/rect.hxx starmath/inc/smdll.hxx starmath/inc/smmod.hxx starmath/inc/starmath.hrc starmath/inc/symbol.hxx starmath/inc/toolbox.hxx starmath/inc/utility.hxx starmath/inc/view.hxx starmath/prj/build.lst starmath/qa/cppunit/version.map starmath/sdi/smslots.sdi starmath/source/accessibility.cxx starmath/source/cfgitem.cxx starmath/source/cfgitem.hxx starmath/source/config.cxx starmath/source/dialog.cxx starmath/source/document.cxx starmath/source/edit.cxx starmath/source/format.cxx starmath/source/makefile.mk starmath/source/math_pch.cxx starmath/source/mathmlexport.cxx starmath/source/mathmlimport.cxx starmath/source/mathtype.cxx starmath/source/node.cxx starmath/source/parse.cxx starmath/source/rect.cxx starmath/source/register.cxx starmath/source/smdetect.cxx starmath/source/smdll.cxx starmath/source/smmod.cxx starmath/source/smres.src starmath/source/symbol.cxx starmath/source/toolbox.cxx starmath/source/unomodel.cxx starmath/source/utility.cxx starmath/source/view.cxx sw/JunitTest_sw_unoapi.mk sw/Library_swd.mk sw/Makefile sw/inc/IDocumentFieldsAccess.hxx sw/inc/IDocumentSettingAccess.hxx sw/inc/IDocumentUndoRedo.hxx sw/inc/IShellCursorSupplier.hxx sw/inc/SwUndoField.hxx sw/inc/acmplwrd.hxx sw/inc/authfld.hxx sw/inc/bparr.hxx sw/inc/calbck.hxx sw/inc/calc.hxx sw/inc/ccoll.hxx sw/inc/cellatr.hxx sw/inc/cellfml.hxx sw/inc/chpfld.hxx sw/inc/cmdid.h sw/inc/crsrsh.hxx sw/inc/crstate.hxx sw/inc/dbfld.hxx sw/inc/dbmgr.hxx sw/inc/dcontact.hxx sw/inc/ddefld.hxx sw/inc/doc.hxx sw/inc/docary.hxx sw/inc/docsh.hxx sw/inc/docstat.hxx sw/inc/docstyle.hxx sw/inc/docufld.hxx sw/inc/editsh.hxx sw/inc/errhdl.hxx sw/inc/expfld.hxx sw/inc/fchrfmt.hxx sw/inc/fesh.hxx sw/inc/fldbas.hxx sw/inc/flddat.hxx sw/inc/flddropdown.hxx sw/inc/flypos.hxx sw/inc/fmtanchr.hxx sw/inc/fmtautofmt.hxx sw/inc/fmtclds.hxx sw/inc/fmtcnct.hxx sw/inc/fmtcol.hxx sw/inc/fmtfsize.hxx sw/inc/fmtftn.hxx sw/inc/fmtftntx.hxx sw/inc/fmthdft.hxx sw/inc/fmtinfmt.hxx sw/inc/fmtline.hxx sw/inc/fmtornt.hxx sw/inc/fmtpdsc.hxx sw/inc/fmtruby.hxx sw/inc/fmtsrnd.hxx sw/inc/fmturl.hxx sw/inc/fmtwrapinfluenceonobjpos.hxx sw/inc/format.hxx sw/inc/frmatr.hxx sw/inc/frmfmt.hxx sw/inc/grfatr.hxx sw/inc/helpid.h sw/inc/hintids.hxx sw/inc/hints.hxx sw/inc/htmltbl.hxx sw/inc/inetfld.hxx sw/inc/io.hxx sw/inc/iodetect.hxx sw/inc/itabenum.hxx sw/inc/ndarr.hxx sw/inc/ndgrf.hxx sw/inc/ndindex.hxx sw/inc/ndnotxt.hxx sw/inc/ndole.hxx sw/inc/ndtxt.hxx sw/inc/ndtyp.hxx sw/inc/node.hxx sw/inc/numrule.hxx sw/inc/pagedesc.hxx sw/inc/pagepreviewlayout.hxx sw/inc/pam.hxx sw/inc/paratr.hxx sw/inc/poolfmt.awk sw/inc/poolfmt.hxx sw/inc/printdata.hxx sw/inc/reffld.hxx sw/inc/shellio.hxx sw/inc/shellres.hxx sw/inc/swabstdlg.hxx sw/inc/swatrset.hxx sw/inc/swerror.h sw/inc/swprtopt.hxx sw/inc/swtable.hxx sw/inc/swtypes.hxx sw/inc/tblafmt.hxx sw/inc/tgrditem.hxx sw/inc/tox.hxx sw/inc/undobj.hxx sw/inc/unocoll.hxx sw/inc/unoframe.hxx sw/inc/unoprnms.hxx sw/inc/usrfld.hxx sw/inc/viewopt.hxx sw/inc/viewsh.hxx sw/inc/viscrs.hxx sw/prj/build.lst sw/qa/complex/accessibility/makefile.mk sw/qa/core/Test-BigPtrArray.cxx sw/qa/core/makefile.mk sw/sdi/makefile.mk sw/source/core/access/makefile.mk sw/source/core/access/textmarkuphelper.cxx sw/source/core/attr/calbck.cxx sw/source/core/attr/cellatr.cxx sw/source/core/attr/fmtwrapinfluenceonobjpos.cxx sw/source/core/attr/format.cxx sw/source/core/attr/hints.cxx sw/source/core/bastyp/calc.cxx sw/source/core/bastyp/init.cxx sw/source/core/bastyp/makefile.mk sw/source/core/bastyp/swcache.cxx sw/source/core/crsr/bookmrk.cxx sw/source/core/crsr/callnk.cxx sw/source/core/crsr/crsrsh.cxx sw/source/core/crsr/crstrvl.cxx sw/source/core/crsr/findattr.cxx sw/source/core/crsr/findcoll.cxx sw/source/core/crsr/makefile.mk sw/source/core/crsr/pam.cxx sw/source/core/crsr/swcrsr.cxx sw/source/core/crsr/trvltbl.cxx sw/source/core/crsr/unocrsr.cxx sw/source/core/crsr/viscrs.cxx sw/source/core/doc/acmplwrd.cxx sw/source/core/doc/doc.cxx sw/source/core/doc/docbm.cxx sw/source/core/doc/doccomp.cxx sw/source/core/doc/docdesc.cxx sw/source/core/doc/docdraw.cxx sw/source/core/doc/docedt.cxx sw/source/core/doc/docfld.cxx sw/source/core/doc/docfly.cxx sw/source/core/doc/docfmt.cxx sw/source/core/doc/docftn.cxx sw/source/core/doc/docglbl.cxx sw/source/core/doc/docglos.cxx sw/source/core/doc/doclay.cxx sw/source/core/doc/docnew.cxx sw/source/core/doc/docnum.cxx sw/source/core/doc/docredln.cxx sw/source/core/doc/docruby.cxx sw/source/core/doc/docsort.cxx sw/source/core/doc/docstat.cxx sw/source/core/doc/doctxm.cxx sw/source/core/doc/fmtcol.cxx sw/source/core/doc/gctable.cxx sw/source/core/doc/htmltbl.cxx sw/source/core/doc/makefile.mk sw/source/core/doc/number.cxx sw/source/core/doc/poolfmt.cxx sw/source/core/doc/tblafmt.cxx sw/source/core/doc/tblcpy.cxx sw/source/core/doc/tblrwcl.cxx sw/source/core/docnode/makefile.mk sw/source/core/docnode/ndcopy.cxx sw/source/core/docnode/ndnum.cxx sw/source/core/docnode/ndsect.cxx sw/source/core/docnode/ndtbl.cxx sw/source/core/docnode/ndtbl1.cxx sw/source/core/docnode/node.cxx sw/source/core/docnode/node2lay.cxx sw/source/core/docnode/nodes.cxx sw/source/core/docnode/section.cxx sw/source/core/docnode/swbaslnk.cxx sw/source/core/draw/dcontact.cxx sw/source/core/draw/dflyobj.cxx sw/source/core/draw/drawdoc.cxx sw/source/core/draw/dview.cxx sw/source/core/draw/makefile.mk sw/source/core/edit/autofmt.cxx sw/source/core/edit/edattr.cxx sw/source/core/edit/eddel.cxx sw/source/core/edit/edfcol.cxx sw/source/core/edit/edfld.cxx sw/source/core/edit/edfldexp.cxx sw/source/core/edit/edfmt.cxx sw/source/core/edit/edglss.cxx sw/source/core/edit/editsh.cxx sw/source/core/edit/edlingu.cxx sw/source/core/edit/ednumber.cxx sw/source/core/edit/edsect.cxx sw/source/core/edit/edtab.cxx sw/source/core/edit/edtox.cxx sw/source/core/edit/edundo.cxx sw/source/core/edit/makefile.mk sw/source/core/except/dbgloop.cxx sw/source/core/except/errhdl.cxx sw/source/core/fields/authfld.cxx sw/source/core/fields/cellfml.cxx sw/source/core/fields/chpfld.cxx sw/source/core/fields/dbfld.cxx sw/source/core/fields/ddefld.cxx sw/source/core/fields/ddetbl.cxx sw/source/core/fields/docufld.cxx sw/source/core/fields/expfld.cxx sw/source/core/fields/fldbas.cxx sw/source/core/fields/flddat.cxx sw/source/core/fields/flddropdown.cxx sw/source/core/fields/macrofld.cxx sw/source/core/fields/makefile.mk sw/source/core/fields/reffld.cxx sw/source/core/fields/scrptfld.cxx sw/source/core/fields/tblcalc.cxx sw/source/core/fields/usrfld.cxx sw/source/core/frmedt/fecopy.cxx sw/source/core/frmedt/fedesc.cxx sw/source/core/frmedt/fefly1.cxx sw/source/core/frmedt/feshview.cxx sw/source/core/frmedt/fetab.cxx sw/source/core/frmedt/fews.cxx sw/source/core/frmedt/makefile.mk sw/source/core/frmedt/tblsel.cxx sw/source/core/graphic/grfatr.cxx sw/source/core/inc/SwUndoFmt.hxx sw/source/core/inc/SwUndoTOXChange.hxx sw/source/core/inc/anchoredobjectposition.hxx sw/source/core/inc/dbgloop.hxx sw/source/core/inc/drawfont.hxx sw/source/core/inc/flowfrm.hxx sw/source/core/inc/frame.hxx sw/source/core/inc/frmtool.hxx sw/source/core/inc/layact.hxx sw/source/core/inc/layfrm.hxx sw/source/core/inc/notxtfrm.hxx sw/source/core/inc/rolbck.hxx sw/source/core/inc/rootfrm.hxx sw/source/core/inc/scriptinfo.hxx sw/source/core/inc/swblocks.hxx sw/source/core/inc/swcache.hxx sw/source/core/inc/tabfrm.hxx sw/source/core/inc/txmsrt.hxx sw/source/core/inc/undoflystrattr.hxx sw/source/core/inc/viewimp.hxx sw/source/core/layout/atrfrm.cxx sw/source/core/layout/calcmove.cxx sw/source/core/layout/dbg_lay.cxx sw/source/core/layout/findfrm.cxx sw/source/core/layout/flowfrm.cxx sw/source/core/layout/fly.cxx sw/source/core/layout/flycnt.cxx sw/source/core/layout/flyincnt.cxx sw/source/core/layout/flylay.cxx sw/source/core/layout/frmtool.cxx sw/source/core/layout/ftnfrm.cxx sw/source/core/layout/layact.cxx sw/source/core/layout/laycache.cxx sw/source/core/layout/makefile.mk sw/source/core/layout/objectformatter.cxx sw/source/core/layout/pagechg.cxx sw/source/core/layout/pagedesc.cxx sw/source/core/layout/paintfrm.cxx sw/source/core/layout/sectfrm.cxx sw/source/core/layout/tabfrm.cxx sw/source/core/layout/trvlfrm.cxx sw/source/core/layout/unusedf.cxx sw/source/core/layout/wsfrm.cxx sw/source/core/makefile.mk sw/source/core/objectpositioning/anchoredobjectposition.cxx sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx sw/source/core/objectpositioning/makefile.mk sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx sw/source/core/ole/ndole.cxx sw/source/core/para/makefile.mk sw/source/core/para/paratr.cxx sw/source/core/sw3io/makefile.mk sw/source/core/sw3io/sw3convert.cxx sw/source/core/swg/SwXMLTextBlocks.cxx sw/source/core/swg/makefile.mk sw/source/core/swg/swblocks.cxx sw/source/core/table/swnewtable.cxx sw/source/core/table/swtable.cxx sw/source/core/text/EnhancedPDFExportHelper.cxx sw/source/core/text/atrstck.cxx sw/source/core/text/frmcrsr.cxx sw/source/core/text/frmform.cxx sw/source/core/text/itrcrsr.cxx sw/source/core/text/itrform2.cxx sw/source/core/text/makefile.mk sw/source/core/text/porlay.cxx sw/source/core/text/pormulti.cxx sw/source/core/text/txtfld.cxx sw/source/core/text/txtfrm.cxx sw/source/core/text/txtio.cxx sw/source/core/tox/makefile.mk sw/source/core/tox/txmsrt.cxx sw/source/core/txtnode/fmtatr2.cxx sw/source/core/txtnode/fntcache.cxx sw/source/core/txtnode/fntcap.cxx sw/source/core/txtnode/makefile.mk sw/source/core/txtnode/ndhints.cxx sw/source/core/txtnode/ndtxt.cxx sw/source/core/txtnode/swfont.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txtatr2.cxx sw/source/core/txtnode/txtedt.cxx sw/source/core/undo/SwUndoField.cxx sw/source/core/undo/SwUndoPageDesc.cxx sw/source/core/undo/SwUndoTOXChange.cxx sw/source/core/undo/docundo.cxx sw/source/core/undo/makefile.mk sw/source/core/undo/rolbck.cxx sw/source/core/undo/unbkmk.cxx sw/source/core/undo/undel.cxx sw/source/core/undo/undobj.cxx sw/source/core/undo/undobj1.cxx sw/source/core/undo/unfmco.cxx sw/source/core/undo/unins.cxx sw/source/core/undo/unnum.cxx sw/source/core/undo/unoutl.cxx sw/source/core/undo/unredln.cxx sw/source/core/undo/unsect.cxx sw/source/core/undo/unsort.cxx sw/source/core/undo/unspnd.cxx sw/source/core/undo/untbl.cxx sw/source/core/unocore/makefile.mk sw/source/core/unocore/swunohelper.cxx sw/source/core/unocore/unobkm.cxx sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unocrsrhelper.cxx sw/source/core/unocore/unodraw.cxx sw/source/core/unocore/unofield.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unomap.cxx sw/source/core/unocore/unoprnms.cxx sw/source/core/unocore/unoredlines.cxx sw/source/core/unocore/unosett.cxx sw/source/core/unocore/unosrch.cxx sw/source/core/unocore/unostyle.cxx sw/source/core/unocore/unotbl.cxx sw/source/core/view/vdraw.cxx sw/source/core/view/viewimp.cxx sw/source/core/view/viewpg.cxx sw/source/core/view/viewsh.cxx sw/source/core/view/vnew.cxx sw/source/core/view/vprint.cxx sw/source/filter/ascii/ascatr.cxx sw/source/filter/ascii/makefile.mk sw/source/filter/ascii/wrtasc.cxx sw/source/filter/basflt/fltini.cxx sw/source/filter/basflt/iodetect.cxx sw/source/filter/basflt/makefile.mk sw/source/filter/html/SwAppletImpl.cxx sw/source/filter/html/css1atr.cxx sw/source/filter/html/htmlatr.cxx sw/source/filter/html/htmlbas.cxx sw/source/filter/html/htmlcss1.cxx sw/source/filter/html/htmlfly.cxx sw/source/filter/html/htmlftn.cxx sw/source/filter/html/htmlgrin.cxx sw/source/filter/html/htmlnum.cxx sw/source/filter/html/htmlplug.cxx sw/source/filter/html/htmltab.cxx sw/source/filter/html/makefile.mk sw/source/filter/html/parcss1.cxx sw/source/filter/html/svxcss1.cxx sw/source/filter/html/swhtml.cxx sw/source/filter/inc/msfilter.hxx sw/source/filter/inc/wrtswtbl.hxx sw/source/filter/rtf/makefile.mk sw/source/filter/rtf/rtffly.cxx sw/source/filter/rtf/rtfnum.cxx sw/source/filter/rtf/rtftbl.cxx sw/source/filter/rtf/swparrtf.cxx sw/source/filter/rtf/swparrtf.hxx sw/source/filter/writer/makefile.mk sw/source/filter/writer/writer.cxx sw/source/filter/writer/wrt_fn.cxx sw/source/filter/writer/wrtswtbl.cxx sw/source/filter/ww1/fltshell.cxx sw/source/filter/ww1/makefile.mk sw/source/filter/ww1/w1class.cxx sw/source/filter/ww1/w1class.hxx sw/source/filter/ww1/w1filter.cxx sw/source/filter/ww1/w1par.cxx sw/source/filter/ww1/w1sprm.cxx sw/source/filter/ww1/w1struct.hxx sw/source/filter/ww8/README-rtf.txt sw/source/filter/ww8/attributeoutputbase.hxx sw/source/filter/ww8/docxattributeoutput.cxx sw/source/filter/ww8/docxattributeoutput.hxx sw/source/filter/ww8/docxexport.cxx sw/source/filter/ww8/docxexport.hxx sw/source/filter/ww8/docxexportfilter.cxx sw/source/filter/ww8/dump/dump8.cxx sw/source/filter/ww8/dump/dump8a.cxx sw/source/filter/ww8/dump/msvbasic.cxx sw/source/filter/ww8/dump/msvbasic.hxx sw/source/filter/ww8/dump/ww8darr.cxx sw/source/filter/ww8/dump/ww8darr.hxx sw/source/filter/ww8/dump/ww8dout.cxx sw/source/filter/ww8/dump/ww8dout.hxx sw/source/filter/ww8/dump/ww8scan.cxx sw/source/filter/ww8/dump/ww8scan.hxx sw/source/filter/ww8/dump/ww8struc.hxx sw/source/filter/ww8/makefile.mk sw/source/filter/ww8/rtfattributeoutput.cxx sw/source/filter/ww8/rtfattributeoutput.hxx sw/source/filter/ww8/rtfexport.cxx sw/source/filter/ww8/rtfexport.hxx sw/source/filter/ww8/rtfexportfilter.cxx sw/source/filter/ww8/rtfexportfilter.hxx sw/source/filter/ww8/rtfimportfilter.cxx sw/source/filter/ww8/rtfimportfilter.hxx sw/source/filter/ww8/rtfsdrexport.cxx sw/source/filter/ww8/rtfsdrexport.hxx sw/source/filter/ww8/writerhelper.cxx sw/source/filter/ww8/writerwordglue.cxx sw/source/filter/ww8/wrtw8esh.cxx sw/source/filter/ww8/wrtw8nds.cxx sw/source/filter/ww8/wrtw8num.cxx sw/source/filter/ww8/wrtw8sty.cxx sw/source/filter/ww8/wrtww8.cxx sw/source/filter/ww8/wrtww8.hxx sw/source/filter/ww8/wrtww8gr.cxx sw/source/filter/ww8/ww8atr.cxx sw/source/filter/ww8/ww8attributeoutput.hxx sw/source/filter/ww8/ww8graf.cxx sw/source/filter/ww8/ww8graf.hxx sw/source/filter/ww8/ww8graf2.cxx sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.hxx sw/source/filter/ww8/ww8par2.cxx sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par5.cxx sw/source/filter/ww8/ww8par6.cxx sw/source/filter/ww8/ww8scan.cxx sw/source/filter/ww8/ww8scan.hxx sw/source/filter/ww8/ww8struc.hxx sw/source/filter/xml/makefile.mk sw/source/filter/xml/xmlimpit.cxx sw/source/filter/xml/xmltble.cxx sw/source/filter/xml/xmltbli.cxx sw/source/ui/app/appenv.cxx sw/source/ui/app/apphdl.cxx sw/source/ui/app/applab.cxx sw/source/ui/app/appopt.cxx sw/source/ui/app/docsh.cxx sw/source/ui/app/docsh2.cxx sw/source/ui/app/docshini.cxx sw/source/ui/app/docst.cxx sw/source/ui/app/docstyle.cxx sw/source/ui/app/makefile.mk sw/source/ui/app/mn.src sw/source/ui/app/swmodul1.cxx sw/source/ui/cctrl/makefile.mk sw/source/ui/cctrl/swlbox.cxx sw/source/ui/chrdlg/break.cxx sw/source/ui/chrdlg/ccoll.cxx sw/source/ui/chrdlg/chardlg.cxx sw/source/ui/chrdlg/drpcps.cxx sw/source/ui/chrdlg/makefile.mk sw/source/ui/chrdlg/numpara.cxx sw/source/ui/chrdlg/pardlg.cxx sw/source/ui/chrdlg/swuiccoll.cxx sw/source/ui/config/barcfg.cxx sw/source/ui/config/caption.cxx sw/source/ui/config/cfgitems.cxx sw/source/ui/config/fontcfg.cxx sw/source/ui/config/mailconfigpage.cxx sw/source/ui/config/makefile.mk sw/source/ui/config/modcfg.cxx sw/source/ui/config/optcomp.cxx sw/source/ui/config/optload.cxx sw/source/ui/config/optpage.cxx sw/source/ui/config/prtopt.cxx sw/source/ui/config/uinums.cxx sw/source/ui/config/usrpref.cxx sw/source/ui/config/viewopt.cxx sw/source/ui/dbui/dbinsdlg.cxx sw/source/ui/dbui/dbmgr.cxx sw/source/ui/dbui/dbtree.cxx sw/source/ui/dbui/makefile.mk sw/source/ui/dbui/mmaddressblockpage.cxx sw/source/ui/dbui/mmdocselectpage.cxx sw/source/ui/dbui/mmoutputpage.cxx sw/source/ui/dbui/swdbtoolsclient.cxx sw/source/ui/dialog/abstract.cxx sw/source/ui/dialog/ascfldlg.cxx sw/source/ui/dialog/macassgn.cxx sw/source/ui/dialog/makefile.mk sw/source/ui/dialog/regionsw.cxx sw/source/ui/dialog/swdlgfact.cxx sw/source/ui/dialog/swdlgfact.hxx sw/source/ui/dialog/uiregionsw.cxx sw/source/ui/dochdl/gloshdl.cxx sw/source/ui/dochdl/makefile.mk sw/source/ui/dochdl/swdtflvr.cxx sw/source/ui/docvw/PostItMgr.cxx sw/source/ui/docvw/SidebarWin.cxx sw/source/ui/docvw/edtdd.cxx sw/source/ui/docvw/edtwin.cxx sw/source/ui/docvw/edtwin2.cxx sw/source/ui/docvw/edtwin3.cxx sw/source/ui/docvw/makefile.mk sw/source/ui/docvw/romenu.cxx sw/source/ui/docvw/romenu.hxx sw/source/ui/docvw/srcedtw.cxx sw/source/ui/envelp/envfmt.cxx sw/source/ui/envelp/envimg.cxx sw/source/ui/envelp/envlop1.cxx sw/source/ui/envelp/envprt.cxx sw/source/ui/envelp/label1.cxx sw/source/ui/envelp/labfmt.cxx sw/source/ui/envelp/labprt.cxx sw/source/ui/envelp/mailmrge.cxx sw/source/ui/envelp/makefile.mk sw/source/ui/fldui/flddb.cxx sw/source/ui/fldui/flddinf.cxx sw/source/ui/fldui/flddok.cxx sw/source/ui/fldui/fldedt.cxx sw/source/ui/fldui/fldfunc.cxx sw/source/ui/fldui/fldmgr.cxx sw/source/ui/fldui/fldpage.cxx sw/source/ui/fldui/fldref.cxx sw/source/ui/fldui/fldtdlg.cxx sw/source/ui/fldui/fldvar.cxx sw/source/ui/fldui/fldwrap.cxx sw/source/ui/fldui/inpdlg.cxx sw/source/ui/fldui/makefile.mk sw/source/ui/fmtui/makefile.mk sw/source/ui/fmtui/tmpdlg.cxx sw/source/ui/frmdlg/colmgr.cxx sw/source/ui/frmdlg/column.cxx sw/source/ui/frmdlg/cption.cxx sw/source/ui/frmdlg/frmdlg.cxx sw/source/ui/frmdlg/frmmgr.cxx sw/source/ui/frmdlg/frmpage.cxx sw/source/ui/frmdlg/makefile.mk sw/source/ui/frmdlg/wrap.cxx sw/source/ui/globdoc/makefile.mk sw/source/ui/inc/bmpwin.hxx sw/source/ui/inc/colmgr.hxx sw/source/ui/inc/column.hxx sw/source/ui/inc/envimg.hxx sw/source/ui/inc/envlop.hxx sw/source/ui/inc/frmpage.hxx sw/source/ui/inc/inputwin.hxx sw/source/ui/inc/javaedit.hxx sw/source/ui/inc/num.hxx sw/source/ui/inc/optpage.hxx sw/source/ui/inc/regionsw.hxx sw/source/ui/inc/split.hxx sw/source/ui/inc/swlbox.hxx sw/source/ui/inc/swmn_tmpl.hrc sw/source/ui/inc/swuiidxmrk.hxx sw/source/ui/inc/tabsh.hxx sw/source/ui/inc/toxmgr.hxx sw/source/ui/inc/uiitems.hxx sw/source/ui/inc/view.hxx sw/source/ui/inc/workctrl.hxx sw/source/ui/inc/wrap.hxx sw/source/ui/inc/wrtsh.hxx sw/source/ui/index/cnttab.cxx sw/source/ui/index/makefile.mk sw/source/ui/index/toxmgr.cxx sw/source/ui/lingu/hhcwrp.cxx sw/source/ui/lingu/makefile.mk sw/source/ui/lingu/olmenu.cxx sw/source/ui/misc/bookmark.cxx sw/source/ui/misc/docfnote.cxx sw/source/ui/misc/glosbib.cxx sw/source/ui/misc/glosdoc.cxx sw/source/ui/misc/glshell.cxx sw/source/ui/misc/insfnote.cxx sw/source/ui/misc/linenum.cxx sw/source/ui/misc/makefile.mk sw/source/ui/misc/num.cxx sw/source/ui/misc/numberingtypelistbox.cxx sw/source/ui/misc/outline.cxx sw/source/ui/misc/pgfnote.cxx sw/source/ui/misc/pggrid.cxx sw/source/ui/misc/redlndlg.cxx sw/source/ui/misc/srtdlg.cxx sw/source/ui/misc/swmodalredlineacceptdlg.cxx sw/source/ui/ribbar/conarc.cxx sw/source/ui/ribbar/drawbase.cxx sw/source/ui/ribbar/inputwin.cxx sw/source/ui/ribbar/inputwin.src sw/source/ui/ribbar/makefile.mk sw/source/ui/ribbar/tbxanchr.cxx sw/source/ui/ribbar/workctrl.cxx sw/source/ui/ribbar/workctrl.src sw/source/ui/shells/annotsh.cxx sw/source/ui/shells/basesh.cxx sw/source/ui/shells/beziersh.cxx sw/source/ui/shells/drawdlg.cxx sw/source/ui/shells/drwbassh.cxx sw/source/ui/shells/drwtxtex.cxx sw/source/ui/shells/drwtxtsh.cxx sw/source/ui/shells/frmsh.cxx sw/source/ui/shells/grfsh.cxx sw/source/ui/shells/grfshex.cxx sw/source/ui/shells/makefile.mk sw/source/ui/shells/tabsh.cxx sw/source/ui/shells/textfld.cxx sw/source/ui/shells/textglos.cxx sw/source/ui/shells/textsh.cxx sw/source/ui/shells/textsh1.cxx sw/source/ui/shells/txtattr.cxx sw/source/ui/shells/txtcrsr.cxx sw/source/ui/shells/txtnum.cxx sw/source/ui/table/convert.cxx sw/source/ui/table/instable.cxx sw/source/ui/table/makefile.mk sw/source/ui/table/swtablerep.cxx sw/source/ui/table/tabledlg.cxx sw/source/ui/table/tablemgr.cxx sw/source/ui/table/tablepg.hxx sw/source/ui/table/tautofmt.cxx sw/source/ui/uiview/formatclipboard.cxx sw/source/ui/uiview/makefile.mk sw/source/ui/uiview/pview.cxx sw/source/ui/uiview/pview.src sw/source/ui/uiview/scroll.cxx sw/source/ui/uiview/srcview.cxx sw/source/ui/uiview/swcli.cxx sw/source/ui/uiview/uivwimp.cxx sw/source/ui/uiview/view.cxx sw/source/ui/uiview/view1.cxx sw/source/ui/uiview/view2.cxx sw/source/ui/uiview/viewcoll.cxx sw/source/ui/uiview/viewdlg2.cxx sw/source/ui/uiview/viewling.cxx sw/source/ui/uiview/viewmdi.cxx sw/source/ui/uiview/viewport.cxx sw/source/ui/uiview/viewprt.cxx sw/source/ui/uiview/viewsrch.cxx sw/source/ui/uiview/viewtab.cxx sw/source/ui/uno/SwXDocumentSettings.cxx sw/source/ui/uno/SwXPrintPreviewSettings.cxx sw/source/ui/uno/SwXPrintPreviewSettings.hxx sw/source/ui/uno/unoatxt.cxx sw/source/ui/uno/unomod.cxx sw/source/ui/uno/unotxdoc.cxx sw/source/ui/uno/unotxvw.cxx sw/source/ui/utlui/attrdesc.cxx sw/source/ui/utlui/content.cxx sw/source/ui/utlui/glbltree.cxx sw/source/ui/utlui/initui.cxx sw/source/ui/utlui/makefile.mk sw/source/ui/utlui/navipi.cxx sw/source/ui/utlui/navipi.src sw/source/ui/utlui/numfmtlb.cxx sw/source/ui/utlui/prcntfld.cxx sw/source/ui/utlui/uiitems.cxx sw/source/ui/utlui/uitool.cxx sw/source/ui/utlui/unotools.cxx sw/source/ui/utlui/viewlayoutctrl.cxx sw/source/ui/utlui/zoomctrl.cxx sw/source/ui/vba/makefile.mk sw/source/ui/vba/service.cxx sw/source/ui/web/makefile.mk sw/source/ui/wrtsh/makefile.mk sw/source/ui/wrtsh/wrtsh1.cxx sw/source/ui/wrtsh/wrtsh2.cxx sw/source/ui/wrtsh/wrtsh4.cxx sw/source/ui/wrtsh/wrtundo.cxx sw/util/hidother.src sw/util/makefile.mk sw/util/msword.map
2011-03-14 16:51:14 +00:00
static const char * aCatMf2Hid[10][4] =
2000-09-18 16:07:07 +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
Window * const aWin[4][2] =
2000-09-18 16:07:07 +00:00
{
{ m_pFixedText1, m_pMetricField1 },
{ m_pFixedText2, m_pMetricField2 },
{ m_pFixedText3, m_pMetricField3 },
{ m_pFixedText4, m_pMetricField4 }
2000-09-18 16:07:07 +00:00
};
SmCategoryDesc *pCat;
// 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];
pCat->SetValue(0, (sal_uInt16) m_pMetricField1->GetValue());
pCat->SetValue(1, (sal_uInt16) m_pMetricField2->GetValue());
pCat->SetValue(2, (sal_uInt16) m_pMetricField3->GetValue());
pCat->SetValue(3, (sal_uInt16) m_pMetricField4->GetValue());
2000-09-18 16:07:07 +00:00
if (nActiveCategory == 5)
bScaleAllBrackets = m_pCheckBox1->IsChecked();
2000-09-18 16:07:07 +00:00
m_pMenuButton->GetPopupMenu()->CheckItem(nActiveCategory + 1, false);
2000-09-18 16:07:07 +00:00
}
// activation/deactivation of the associated controls depending on the chosen category
bool bActive;
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];
// 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);
// set measurement unit and number of decimal places
2000-09-18 16:07:07 +00:00
FieldUnit eUnit;
sal_uInt16 nDigits;
2000-09-18 16:07:07 +00:00
if (nCategory < 9)
{
eUnit = FUNIT_PERCENT;
2000-09-18 16:07:07 +00:00
nDigits = 0;
}
else
{
eUnit = FUNIT_100TH_MM;
nDigits = 2;
}
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]);
}
}
// 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;
m_pCheckBox1->Show(bActive);
m_pCheckBox1->Enable(bActive);
2000-09-18 16:07:07 +00:00
if (bActive)
{
m_pCheckBox1->Check( bScaleAllBrackets );
2000-09-18 16:07:07 +00:00
bool bChecked = m_pCheckBox1->IsChecked();
m_pFixedText4->Enable( bChecked );
m_pMetricField4->Enable( bChecked );
2000-09-18 16:07:07 +00:00
}
m_pMenuButton->GetPopupMenu()->CheckItem(nCategory + 1, true);
m_pFrame->set_label(Categories[nCategory]->GetName());
2000-09-18 16:07:07 +00:00
nActiveCategory = nCategory;
m_pMetricField1->GrabFocus();
2000-09-18 16:07:07 +00:00
Invalidate();
Update();
}
SmDistanceDialog::SmDistanceDialog(Window *pParent)
: ModalDialog(pParent, "SpacingDialog",
"modules/smath/ui/spacingdialog.ui")
{
get(m_pFrame, "template");
get(m_pFixedText1, "label1");
get(m_pMetricField1, "spinbutton1");
get(m_pFixedText2, "label2");
get(m_pMetricField2, "spinbutton2");
get(m_pFixedText3, "label3");
get(m_pMetricField3, "spinbutton3");
get(m_pCheckBox1, "checkbutton");
get(m_pFixedText4, "label4");
get(m_pMetricField4, "spinbutton4");
get(m_pMenuButton, "category");
get(m_pDefaultButton, "default");
get(m_pBitmap, "image");
for (sal_uInt16 i = 0; i < NOCATEGORIES; ++i)
Categories[i] = new SmCategoryDesc(*this, i);
2000-09-18 16:07:07 +00:00
nActiveCategory = CATEGORY_NONE;
bScaleAllBrackets = false;
2000-09-18 16:07:07 +00:00
// preview like controls should have a 2D look
m_pBitmap->SetBorderStyle( WINDOW_BORDER_MONO );
2001-06-15 05:42:09 +00:00
m_pMetricField1->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pMetricField2->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pMetricField3->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pMetricField4->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pCheckBox1->SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
2000-09-18 16:07:07 +00:00
m_pMenuButton->GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
2000-09-18 16:07:07 +00:00
m_pDefaultButton->SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
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*/
{
// 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();
}
IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
2000-09-18 16:07:07 +00:00
{
if (SaveDefaultsQuery(this).Execute() == RET_YES)
2000-09-18 16:07:07 +00:00
{
SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt );
2000-09-18 16:07:07 +00:00
}
return 0;
}
SmAlignDialog::SmAlignDialog(Window * pParent)
: ModalDialog(pParent, "AlignmentDialog",
"modules/smath/ui/alignmentdialog.ui")
{
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:
m_pLeft->Check(true);
m_pCenter->Check(false);
m_pRight->Check(false);
2000-09-18 16:07:07 +00:00
break;
case AlignCenter:
m_pLeft->Check(false);
m_pCenter->Check(true);
m_pRight->Check(false);
2000-09-18 16:07:07 +00:00
break;
case AlignRight:
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
{
if (m_pLeft->IsChecked())
2000-09-18 16:07:07 +00:00
rFormat.SetHorAlign(AlignLeft);
else if (m_pRight->IsChecked())
2000-09-18 16:07:07 +00:00
rFormat.SetHorAlign(AlignRight);
else
rFormat.SetHorAlign(AlignCenter);
rFormat.RequestApplyChanges();
}
SmShowSymbolSetWindow::SmShowSymbolSetWindow(Window *pParent, WinBits nStyle)
: Control(pParent, nStyle)
, m_pVScrollBar(0)
, nLen(0)
, nRows(0)
, nColumns(0)
, nXOffset(0)
, nYOffset(0)
, nSelectSymbol(SYMBOL_NONE)
{
ColorData nBgCol, nTxtCol;
getColors(*this, nBgCol, nTxtCol);
2000-09-18 16:07:07 +00:00
Color aTmpColor( nBgCol );
Wallpaper aWall( aTmpColor );
Color aTxtColor( nTxtCol );
SetBackground( aWall );
SetTextColor( aTxtColor );
}
2000-09-18 16:07:07 +00: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);
// set MapUnit for which 'nLen' has been calculated
2000-09-18 16:07:07 +00:00
SetMapMode(MapMode(MAP_PIXEL));
sal_uInt16 v = sal::static_int_cast< sal_uInt16 >((m_pVScrollBar->GetThumbPos() * nColumns));
size_t nSymbols = aSymbolSet.size();
2000-09-18 16:07:07 +00:00
Color aTxtColor( GetTextColor() );
for (sal_uInt16 i = v; i < nSymbols ; i++)
2000-09-18 16:07:07 +00:00
{
SmSym aSymbol (*aSymbolSet[i]);
vcl::Font aFont (aSymbol.GetFace());
aFont.SetAlign(ALIGN_TOP);
2000-09-18 16:07:07 +00: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);
// keep text color
SetTextColor( aTxtColor );
2000-09-18 16:07:07 +00:00
int nIV = i - v;
sal_UCS4 cChar = aSymbol.GetCharacter();
OUString aText(&cChar, 1);
Size aSize( GetTextWidth( aText ), GetTextHeight());
2000-09-18 16:07:07 +00: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)
{
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();
}
void SmShowSymbolSetWindow::MouseButtonDown(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
GrabFocus();
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()))
{
long nPos = (aPoint.Y() / nLen) * nColumns + (aPoint.X() / nLen) +
m_pVScrollBar->GetThumbPos() * nColumns;
SelectSymbol( sal::static_int_cast< sal_uInt16 >(nPos) );
2000-09-18 16:07:07 +00:00
aSelectHdlLink.Call(this);
if (rMEvt.GetClicks() > 1)
aDblClickHdlLink.Call(this);
2000-09-18 16:07:07 +00:00
}
}
void SmShowSymbolSetWindow::KeyInput(const KeyEvent& rKEvt)
2000-09-18 16:07:07 +00:00
{
sal_uInt16 n = nSelectSymbol;
2000-09-18 16:07:07 +00:00
if (n != SYMBOL_NONE)
{
switch (rKEvt.GetKeyCode().GetCode())
{
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;
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;
if (n >= aSymbolSet.size())
2000-09-18 16:07:07 +00:00
n = nSelectSymbol;
// adjust scrollbar
if ((n < (sal_uInt16) (m_pVScrollBar->GetThumbPos() * nColumns)) ||
(n >= (sal_uInt16) ((m_pVScrollBar->GetThumbPos() + nRows) * nColumns)))
2000-09-18 16:07:07 +00:00
{
m_pVScrollBar->SetThumbPos(n / nColumns);
2000-09-18 16:07:07 +00:00
Invalidate();
Update();
}
SelectSymbol(n);
aSelectHdlLink.Call(this);
}
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
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
{
aSymbolWindow.set_hexpand(true);
aSymbolWindow.set_vexpand(true);
aSymbolWindow.setScrollbar(&aVScrollBar);
aSymbolWindow.calccols();
aSymbolWindow.Show();
}
2000-09-18 16:07:07 +00: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
void SmShowSymbolSetWindow::calccols()
{
// Height of 16pt in pixels (matching 'aOutputSize')
nLen = LogicToPixel(Size(0, 16), MapMode(MAP_POINT)).Height();
2000-09-18 16:07:07 +00:00
Size aOutputSize = GetOutputSizePixel();
2000-09-18 16:07:07 +00:00
nColumns = aOutputSize.Width() / nLen;
if (nColumns > 2 && nColumns % 2 != 0)
--nColumns;
nRows = aOutputSize.Height() / nLen;
nColumns = std::max<long>(1, nColumns);
nRows = std::max<long>(1, nRows);
2000-09-18 16:07:07 +00:00
nXOffset = (aOutputSize.Width() - (nColumns * nLen)) / 2;
nYOffset = (aOutputSize.Height() - (nRows * nLen)) / 2;
2000-09-18 16:07:07 +00:00
SetScrollBarRange();
2000-09-18 16:07:07 +00: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
void SmShowSymbolSetWindow::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet)
2000-09-18 16:07:07 +00:00
{
aSymbolSet = rSymbolSet;
SetScrollBarRange();
}
void SmShowSymbolSetWindow::SetScrollBarRange()
{
if (aSymbolSet.size() > static_cast<size_t>(nColumns * nRows))
2000-09-18 16:07:07 +00: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
{
m_pVScrollBar->SetRange(Range(0,0));
m_pVScrollBar->Enable (false);
2000-09-18 16:07:07 +00:00
}
Invalidate();
}
void SmShowSymbolSetWindow::SelectSymbol(sal_uInt16 nSymbol)
2000-09-18 16:07:07 +00:00
{
int v = (int) (m_pVScrollBar->GetThumbPos() * nColumns);
2000-09-18 16:07:07 +00:00
if (nSelectSymbol != SYMBOL_NONE)
Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
((nSelectSymbol - v) / nColumns) * nLen)),
2000-09-18 16:07:07 +00:00
Size(nLen, nLen)));
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)
Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
((nSelectSymbol - v) / nColumns) * nLen)),
2000-09-18 16:07:07 +00:00
Size(nLen, nLen)));
Update();
}
void SmShowSymbolSetWindow::Resize()
{
Control::Resize();
calccols();
}
IMPL_LINK( SmShowSymbolSetWindow, ScrollHdl, ScrollBar*, EMPTYARG /*pScrollBar*/)
2000-09-18 16:07:07 +00:00
{
Invalidate();
return 0;
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSmShowSymbol(Window *pParent, VclBuilder::stringmap &rMap)
{
WinBits nWinStyle = 0;
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
return new SmShowSymbol(pParent, nWinStyle);
}
void SmShowSymbol::Resize()
{
Control::Resize();
Invalidate();
}
void SmShowSymbol::setFontSize(vcl::Font &rFont) const
{
rFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
}
2000-09-18 16:07:07 +00:00
void SmShowSymbol::Paint(const Rectangle &rRect)
2000-09-18 16:07:07 +00:00
{
Control::Paint( rRect );
vcl::Font aFont(GetFont());
setFontSize(aFont);
SetFont(aFont);
const OUString &rText = GetText();
2000-09-18 16:07:07 +00:00
Size aTextSize(GetTextWidth(rText), GetTextHeight());
DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
(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)
{
vcl::Font aFont (pSymbol->GetFace());
setFontSize(aFont);
aFont.SetAlign(ALIGN_BASELINE);
2000-09-18 16:07:07 +00:00
SetFont(aFont);
sal_UCS4 cChar = pSymbol->GetCharacter();
OUString aText(&cChar, 1);
SetText( aText );
2000-09-18 16:07:07 +00: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();
}
2000-09-18 16:07:07 +00:00
void SmSymbolDialog::FillSymbolSets(bool bDeleteText)
// 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
{
m_pSymbolSets->Clear();
2000-09-18 16:07:07 +00:00
if (bDeleteText)
m_pSymbolSets->SetNoSelection();
2000-09-18 16:07:07 +00:00
std::set< OUString > aSybolSetNames( rSymbolMgr.GetSymbolSetNames() );
std::set< OUString >::const_iterator aIt( aSybolSetNames.begin() );
for ( ; aIt != aSybolSetNames.end(); ++aIt)
m_pSymbolSets->InsertEntry( *aIt );
2000-09-18 16:07:07 +00:00
}
IMPL_LINK_NOARG( SmSymbolDialog, SymbolSetChangeHdl )
2000-09-18 16:07:07 +00:00
{
SelectSymbolSet(m_pSymbolSets->GetSelectEntry());
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK_NOARG( SmSymbolDialog, SymbolChangeHdl )
2000-09-18 16:07:07 +00:00
{
SelectSymbol(m_pSymbolSetDisplay->GetSelectSymbol());
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK_NOARG(SmSymbolDialog, EditClickHdl)
2000-09-18 16:07:07 +00:00
{
SmSymDefineDialog *pDialog = new SmSymDefineDialog(this, pFontListDev, rSymbolMgr);
2000-09-18 16:07:07 +00:00
// set current symbol and SymbolSet for the new dialog
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);
// remember old SymbolSet
OUString aOldSymbolSet (m_pSymbolSets->GetSelectEntry());
2000-09-18 16:07:07 +00:00
sal_uInt16 nSymPos = GetSelectedSymbol();
// adapt dialog to data of the SymbolSet manager, which might have changed
if (pDialog->Execute() == RET_OK && rSymbolMgr.IsModified())
{
rSymbolMgr.Save();
2000-09-18 16:07:07 +00:00
FillSymbolSets();
}
2000-09-18 16:07:07 +00:00
// if the old SymbolSet doesn't exist anymore, go to the first one SymbolSet (if one exists)
if (!SelectSymbolSet(aOldSymbolSet) && m_pSymbolSets->GetEntryCount() > 0)
SelectSymbolSet(m_pSymbolSets->GetEntry(0));
else
{
// just update display of current symbol set
assert(aSymSetName == aSymSetName); //unexpected change in symbol set name
aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName );
m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet );
}
if (nSymPos >= aSymbolSet.size())
nSymPos = static_cast< sal_uInt16 >(aSymbolSet.size()) - 1;
SelectSymbol( nSymPos );
2000-09-18 16:07:07 +00:00
delete pDialog;
return 0;
}
IMPL_LINK_NOARG( SmSymbolDialog, SymbolDblClickHdl )
2000-09-18 16:07:07 +00:00
{
GetClickHdl(m_pGetBtn);
2000-09-18 16:07:07 +00:00
EndDialog(RET_OK);
return 0;
}
IMPL_LINK_NOARG( SmSymbolDialog, GetClickHdl )
2000-09-18 16:07:07 +00:00
{
const SmSym *pSym = GetSymbol();
if (pSym)
{
OUStringBuffer aText;
aText.append('%').append(pSym->GetName()).append(' ');
2000-09-18 16:07:07 +00:00
rViewSh.GetViewFrame()->GetDispatcher()->Execute(
SID_INSERTSYMBOL, SFX_CALLMODE_STANDARD,
new SfxStringItem(SID_INSERTSYMBOL, aText.makeStringAndClear()), 0L);
2000-09-18 16:07:07 +00:00
}
return 0;
}
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
,
2000-09-18 16:07:07 +00:00
rViewSh (rViewShell),
rSymbolMgr (rMgr),
pFontListDev (pFntListDevice)
2000-09-18 16:07:07 +00: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
aSymbolSetName = OUString();
aSymbolSet.clear();
2000-09-18 16:07:07 +00:00
FillSymbolSets();
if (m_pSymbolSets->GetEntryCount() > 0)
SelectSymbolSet(m_pSymbolSets->GetEntry(0));
2000-09-18 16:07:07 +00:00
InitColor_Impl();
// preview like controls should have a 2D look
m_pSymbolDisplay->SetBorderStyle( WINDOW_BORDER_MONO );
2000-09-18 16:07:07 +00: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));
}
void SmSymbolDialog::InitColor_Impl()
{
ColorData nBgCol, nTxtCol;
getColors(*this, nBgCol, nTxtCol);
2002-05-03 13:35:00 +00:00
Color aTmpColor( nBgCol );
Wallpaper aWall( aTmpColor );
Color aTxtColor( nTxtCol );
m_pSymbolDisplay->SetBackground( aWall );
m_pSymbolDisplay->SetTextColor( aTxtColor );
m_pSymbolSetDisplay->SetBackground( aWall );
m_pSymbolSetDisplay->SetTextColor( aTxtColor );
}
void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
InitColor_Impl();
ModalDialog::DataChanged( rDCEvt );
}
bool SmSymbolDialog::SelectSymbolSet(const OUString &rSymbolSetName)
2000-09-18 16:07:07 +00:00
{
bool bRet = false;
sal_Int32 nPos = m_pSymbolSets->GetEntryPos(rSymbolSetName);
2000-09-18 16:07:07 +00:00
aSymbolSetName = OUString();
aSymbolSet.clear();
2000-09-18 16:07:07 +00:00
if (nPos != LISTBOX_ENTRY_NOTFOUND)
{
m_pSymbolSets->SelectEntryPos(nPos);
2000-09-18 16:07:07 +00:00
aSymbolSetName = rSymbolSetName;
aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName );
// sort symbols by Unicode position (useful for displaying Greek characters alphabetically)
std::sort( aSymbolSet.begin(), aSymbolSet.end(), lt_SmSymPtr() );
m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet );
if (aSymbolSet.size() > 0)
2000-09-18 16:07:07 +00:00
SelectSymbol(0);
bRet = true;
2000-09-18 16:07:07 +00:00
}
else
m_pSymbolSets->SetNoSelection();
2000-09-18 16:07:07 +00:00
return bRet;
}
void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo)
2000-09-18 16:07:07 +00:00
{
const SmSym *pSym = NULL;
if (!aSymbolSetName.isEmpty() && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size()))
pSym = aSymbolSet[ nSymbolNo ];
2000-09-18 16:07:07 +00: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
{
sal_uInt16 nSymbolNo = m_pSymbolSetDisplay->GetSelectSymbol();
bool bValid = !aSymbolSetName.isEmpty() && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size());
return bValid ? aSymbolSet[ nSymbolNo ] : NULL;
2000-09-18 16:07:07 +00:00
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSmShowChar(Window *pParent, VclBuilder::stringmap &rMap)
{
WinBits nWinStyle = 0;
2000-09-18 16:07:07 +00:00
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
return new SmShowChar(pParent, nWinStyle);
}
2000-09-18 16:07:07 +00:00
void SmShowChar::Paint(const Rectangle &rRect)
2000-09-18 16:07:07 +00:00
{
Control::Paint( rRect );
2000-09-18 16:07:07 +00:00
OUString aText( GetText() );
if (!aText.isEmpty())
2000-09-18 16:07:07 +00: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,
(GetOutputSize().Height() * 7/10)), aText);
2000-09-18 16:07:07 +00:00
}
}
void SmShowChar::SetSymbol( const SmSym *pSym )
2000-09-18 16:07:07 +00:00
{
if (pSym)
SetSymbol( pSym->GetCharacter(), pSym->GetFace() );
2000-09-18 16:07:07 +00:00
}
void SmShowChar::SetSymbol( sal_UCS4 cChar, const vcl::Font &rFont )
2000-09-18 16:07:07 +00:00
{
vcl::Font aFont( rFont );
aFont.SetSize( Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3) );
aFont.SetAlign(ALIGN_BASELINE);
SetFont(aFont);
aFont.SetTransparent(true);
2000-09-18 16:07:07 +00:00
OUString aText(&cChar, 1);
SetText( aText );
2000-09-18 16:07:07 +00:00
Invalidate();
}
void SmShowChar::Resize()
{
Control::Resize();
const OUString &rText = GetText();
if (rText.isEmpty())
return;
sal_Int32 nStrIndex = 0;
sal_UCS4 cChar = rText.iterateCodePoints(&nStrIndex);
SetSymbol(cChar, GetFont()); //force recalculation of size
}
2000-09-18 16:07:07 +00:00
void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, bool bDeleteText)
2000-09-18 16:07:07 +00:00
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(&rComboBox == pOldSymbols || &rComboBox == pSymbols,
"Sm : wrong ComboBox");
#endif
2000-09-18 16:07:07 +00:00
rComboBox.Clear();
if (bDeleteText)
rComboBox.SetText(OUString());
2000-09-18 16:07:07 +00:00
ComboBox &rBox = &rComboBox == pOldSymbols ? *pOldSymbolSets : *pSymbolSets;
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
}
void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, bool bDeleteText)
2000-09-18 16:07:07 +00:00
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(&rComboBox == pOldSymbolSets || &rComboBox == pSymbolSets,
2000-09-18 16:07:07 +00:00
"Sm : falsche ComboBox");
#endif
2000-09-18 16:07:07 +00:00
rComboBox.Clear();
if (bDeleteText)
rComboBox.SetText(OUString());
2000-09-18 16:07:07 +00:00
const std::set< OUString > aSymbolSetNames( aSymbolMgrCopy.GetSymbolSetNames() );
std::set< OUString >::const_iterator aIt( aSymbolSetNames.begin() );
for ( ; aIt != aSymbolSetNames.end(); ++aIt)
rComboBox.InsertEntry( *aIt );
2000-09-18 16:07:07 +00:00
}
void SmSymDefineDialog::FillFonts(bool bDelete)
2000-09-18 16:07:07 +00:00
{
pFonts->Clear();
2000-09-18 16:07:07 +00:00
if (bDelete)
pFonts->SetNoSelection();
2000-09-18 16:07:07 +00: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.
if (pFontList)
{
sal_uInt16 nCount = pFontList->GetFontNameCount();
for (sal_uInt16 i = 0; i < nCount; i++)
pFonts->InsertEntry( pFontList->GetFontName(i).GetName() );
}
2000-09-18 16:07:07 +00:00
}
void SmSymDefineDialog::FillStyles(bool bDeleteText)
2000-09-18 16:07:07 +00:00
{
pStyles->Clear();
2000-09-18 16:07:07 +00:00
if (bDeleteText)
pStyles->SetText(OUString());
2000-09-18 16:07:07 +00:00
OUString aText (pFonts->GetSelectEntry());
if (!aText.isEmpty())
2000-09-18 16:07:07 +00:00
{
// use own StyleNames
const SmFontStyles &rStyles = GetFontStyles();
for (sal_uInt16 i = 0; i < rStyles.GetCount(); i++)
pStyles->InsertEntry( rStyles.GetStyleName(i) );
2000-09-18 16:07:07 +00:00
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pStyles->GetEntryCount() > 0, "Sm : no styles available");
#endif
pStyles->SetText( pStyles->GetEntry(0) );
2000-09-18 16:07:07 +00:00
}
}
SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox)
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(&rComboBox == pOldSymbols || &rComboBox == pSymbols,
"Sm : wrong combobox");
#endif
return aSymbolMgrCopy.GetSymbolByName(rComboBox.GetText());
2000-09-18 16:07:07 +00:00
}
IMPL_LINK( SmSymDefineDialog, OldSymbolChangeHdl, ComboBox *, EMPTYARG pComboBox )
2000-09-18 16:07:07 +00:00
{
(void) pComboBox;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pComboBox == pOldSymbols, "Sm : wrong argument");
#endif
SelectSymbol(*pOldSymbols, pOldSymbols->GetText(), false);
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK( SmSymDefineDialog, OldSymbolSetChangeHdl, ComboBox *, EMPTYARG pComboBox )
2000-09-18 16:07:07 +00:00
{
(void) pComboBox;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pComboBox == pOldSymbolSets, "Sm : wrong argument");
#endif
SelectSymbolSet(*pOldSymbolSets, pOldSymbolSets->GetText(), false);
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK( SmSymDefineDialog, ModifyHdl, ComboBox *, pComboBox )
{
// remember cursor position for later restoring of it
2000-09-18 16:07:07 +00:00
Selection aSelection (pComboBox->GetSelection());
if (pComboBox == pSymbols)
SelectSymbol(*pSymbols, pSymbols->GetText(), false);
else if (pComboBox == pSymbolSets)
SelectSymbolSet(*pSymbolSets, pSymbolSets->GetText(), false);
else if (pComboBox == pOldSymbols)
// allow only names from the list
SelectSymbol(*pOldSymbols, pOldSymbols->GetText(), true);
else if (pComboBox == pOldSymbolSets)
// allow only names from the list
SelectSymbolSet(*pOldSymbolSets, pOldSymbolSets->GetText(), true);
else if (pComboBox == pStyles)
// allow only names from the list (that's the case here anyway)
SelectStyle(pStyles->GetText(), true);
2000-09-18 16:07:07 +00:00
else
SAL_WARN("starmath", "wrong combobox argument");
2000-09-18 16:07:07 +00:00
pComboBox->SetSelection(aSelection);
UpdateButtons();
return 0;
}
IMPL_LINK( SmSymDefineDialog, FontChangeHdl, ListBox *, EMPTYARG pListBox )
2000-09-18 16:07:07 +00:00
{
(void) pListBox;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pListBox == pFonts, "Sm : wrong argument");
#endif
2000-09-18 16:07:07 +00:00
SelectFont(pFonts->GetSelectEntry());
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK( SmSymDefineDialog, SubsetChangeHdl, ListBox *, EMPTYARG pListBox )
{
(void) pListBox;
sal_Int32 nPos = pFontsSubsetLB->GetSelectEntryPos();
if (LISTBOX_ENTRY_NOTFOUND != nPos)
{
const Subset* pSubset = reinterpret_cast<const Subset*> (pFontsSubsetLB->GetEntryData( nPos ));
if (pSubset)
{
pCharsetDisplay->SelectCharacter( pSubset->GetRangeMin() );
}
}
return 0;
}
IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox )
2000-09-18 16:07:07 +00:00
{
(void) pComboBox;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pComboBox == pStyles, "Sm : falsches Argument");
#endif
2000-09-18 16:07:07 +00:00
SelectStyle(pStyles->GetText());
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK_NOARG(SmSymDefineDialog, CharHighlightHdl)
2000-09-18 16:07:07 +00:00
{
sal_UCS4 cChar = pCharsetDisplay->GetSelectCharacter();
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE( pSubsetMap, "SubsetMap missing" );
#endif
if (pSubsetMap)
{
const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
if (pSubset)
pFontsSubsetLB->SelectEntry( pSubset->GetName() );
else
pFontsSubsetLB->SetNoSelection();
}
pSymbolDisplay->SetSymbol( cChar, pCharsetDisplay->GetFont() );
UpdateButtons();
// display Unicode position as symbol name while iterating over characters
const OUString aHex(OUString::number(cChar, 16 ).toAsciiUpperCase());
const OUString aPattern( (aHex.getLength() > 4) ? OUString("Ux000000") : OUString("Ux0000") );
OUString aUnicodePos( aPattern.copy( 0, aPattern.getLength() - aHex.getLength() ) );
aUnicodePos += aHex;
pSymbols->SetText( aUnicodePos );
pSymbolName->SetText( aUnicodePos );
2000-09-18 16:07:07 +00:00
return 0;
}
IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton )
2000-09-18 16:07:07 +00:00
{
(void) pButton;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pButton == pAddBtn, "Sm : wrong argument");
OSL_ENSURE(pAddBtn->IsEnabled(), "Sm : requirements met ??");
#endif
2000-09-18 16:07:07 +00:00
// add symbol
const SmSym aNewSymbol( pSymbols->GetText(), pCharsetDisplay->GetFont(),
pCharsetDisplay->GetSelectCharacter(), pSymbolSets->GetText() );
//OSL_ENSURE( aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL, "symbol already exists" );
aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol );
// update display of new symbol
pSymbolDisplay->SetSymbol( &aNewSymbol );
pSymbolName->SetText( aNewSymbol.GetName() );
pSymbolSetName->SetText( aNewSymbol.GetSymbolSetName() );
// update list box entries
FillSymbolSets(*pOldSymbolSets, false);
FillSymbolSets(*pSymbolSets, false);
FillSymbols(*pOldSymbols ,false);
FillSymbols(*pSymbols ,false);
2000-09-18 16:07:07 +00:00
UpdateButtons();
return 0;
}
IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
2000-09-18 16:07:07 +00:00
{
(void) pButton;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pButton == pChangeBtn, "Sm : wrong argument");
OSL_ENSURE(pChangeBtn->IsEnabled(), "Sm : requirements met ??");
#endif
2000-09-18 16:07:07 +00:00
// get new Sybol to use
//! get font from symbol-disp lay since charset-display does not keep
2014-04-11 08:52:49 +02:00
//! the bold attribute.
const SmSym aNewSymbol( pSymbols->GetText(), pCharsetDisplay->GetFont(),
pCharsetDisplay->GetSelectCharacter(), pSymbolSets->GetText() );
2000-09-18 16:07:07 +00:00
// remove old symbol if the name was changed then add new one
const bool bNameChanged = pOldSymbols->GetText() != pSymbols->GetText();
if (bNameChanged)
aSymbolMgrCopy.RemoveSymbol( pOldSymbols->GetText() );
aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol, true );
2000-09-18 16:07:07 +00:00
// clear display for original symbol if necessary
if (bNameChanged)
SetOrigSymbol(NULL, OUString());
// update display of new symbol
pSymbolDisplay->SetSymbol( &aNewSymbol );
pSymbolName->SetText( aNewSymbol.GetName() );
pSymbolSetName->SetText( aNewSymbol.GetSymbolSetName() );
// update list box entries
FillSymbolSets(*pOldSymbolSets, false);
FillSymbolSets(*pSymbolSets, false);
FillSymbols(*pOldSymbols ,false);
FillSymbols(*pSymbols ,false);
2000-09-18 16:07:07 +00:00
UpdateButtons();
return 0;
}
IMPL_LINK( SmSymDefineDialog, DeleteClickHdl, Button *, EMPTYARG pButton )
2000-09-18 16:07:07 +00:00
{
(void) pButton;
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(pButton == pDeleteBtn, "Sm : wrong argument");
OSL_ENSURE(pDeleteBtn->IsEnabled(), "Sm : requirements met ??");
#endif
2000-09-18 16:07:07 +00:00
if (pOrigSymbol)
{
aSymbolMgrCopy.RemoveSymbol( pOrigSymbol->GetName() );
// clear display for original symbol
SetOrigSymbol(NULL, OUString());
2000-09-18 16:07:07 +00:00
// update list box entries
FillSymbolSets(*pOldSymbolSets, false);
FillSymbolSets(*pSymbolSets, false);
FillSymbols(*pOldSymbols ,false);
FillSymbols(*pSymbols ,false);
2000-09-18 16:07:07 +00:00
}
UpdateButtons();
return 0;
}
void SmSymDefineDialog::UpdateButtons()
{
bool bAdd = false,
bChange = false,
bDelete = false;
OUString aTmpSymbolName (pSymbols->GetText()),
aTmpSymbolSetName (pSymbolSets->GetText());
2000-09-18 16:07:07 +00:00
if (aTmpSymbolName.getLength() > 0 && aTmpSymbolSetName.getLength() > 0)
2000-09-18 16:07:07 +00:00
{
// are all settings equal?
//! (Font-, Style- und SymbolSet name comparison is not case sensitive)
bool bEqual = pOrigSymbol
&& aTmpSymbolSetName.equalsIgnoreAsciiCase(pOldSymbolSetName->GetText())
&& aTmpSymbolName.equals(pOrigSymbol->GetName())
&& pFonts->GetSelectEntry().equalsIgnoreAsciiCase(
pOrigSymbol->GetFace().GetName())
&& pStyles->GetText().equalsIgnoreAsciiCase(
GetFontStyles().GetStyleName(pOrigSymbol->GetFace()))
&& pCharsetDisplay->GetSelectCharacter() == pOrigSymbol->GetCharacter();
2000-09-18 16:07:07 +00:00
// only add it if there isn't already a symbol with the same name
bAdd = aSymbolMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL;
2000-09-18 16:07:07 +00:00
// only delete it if all settings are equal
2000-09-18 16:07:07 +00:00
bDelete = pOrigSymbol != NULL;
// only change it if the old symbol exists and the new one is different
bChange = pOrigSymbol && !bEqual;
}
2000-09-18 16:07:07 +00:00
pAddBtn ->Enable(bAdd);
pChangeBtn->Enable(bChange);
pDeleteBtn->Enable(bDelete);
2000-09-18 16:07:07 +00:00
}
SmSymDefineDialog::SmSymDefineDialog(Window * pParent,
OutputDevice *pFntListDevice, SmSymbolManager &rMgr) :
ModalDialog (pParent, "EditSymbols", "modules/smath/ui/symdefinedialog.ui"),
rSymbolMgr (rMgr),
pSubsetMap (NULL),
pFontList (NULL)
2000-09-18 16:07:07 +00:00
{
get(pOldSymbols, "oldSymbols");
get(pOldSymbolSets, "oldSymbolSets");
get(pCharsetDisplay, "charsetDisplay");
get(pSymbols, "symbols");
get(pSymbolSets, "symbolSets");
get(pFonts, "fonts");
get(pFontsSubsetLB, "fontsSubsetLB");
get(pStyles, "styles");
get(pOldSymbolName, "oldSymbolName");
get(pOldSymbolDisplay, "oldSymbolDisplay");
get(pOldSymbolSetName, "oldSymbolSetName");
get(pSymbolName, "symbolName");
get(pSymbolDisplay, "symbolDisplay");
get(pSymbolSetName, "symbolSetName");
get(pAddBtn, "add");
get(pChangeBtn, "modify");
get(pDeleteBtn, "delete");
pFontList = new FontList( pFntListDevice );
2000-09-18 16:07:07 +00:00
pOrigSymbol = 0;
// 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
pOldSymbols->EnableAutocomplete( false, true );
pSymbols->EnableAutocomplete( false, true );
2000-09-18 16:07:07 +00:00
FillFonts();
if (pFonts->GetEntryCount() > 0)
SelectFont(pFonts->GetEntry(0));
2000-09-18 16:07:07 +00:00
InitColor_Impl();
2000-09-18 16:07:07 +00:00
SetSymbolSetManager(rSymbolMgr);
2000-09-18 16:07:07 +00:00
pOldSymbols ->SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolChangeHdl));
pOldSymbolSets ->SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolSetChangeHdl));
pSymbolSets ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
pOldSymbolSets ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
pSymbols ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
pOldSymbols ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
pStyles ->SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
pFonts ->SetSelectHdl(LINK(this, SmSymDefineDialog, FontChangeHdl));
pFontsSubsetLB ->SetSelectHdl(LINK(this, SmSymDefineDialog, SubsetChangeHdl));
pStyles ->SetSelectHdl(LINK(this, SmSymDefineDialog, StyleChangeHdl));
pAddBtn ->SetClickHdl (LINK(this, SmSymDefineDialog, AddClickHdl));
pChangeBtn ->SetClickHdl (LINK(this, SmSymDefineDialog, ChangeClickHdl));
pDeleteBtn ->SetClickHdl (LINK(this, SmSymDefineDialog, DeleteClickHdl));
pCharsetDisplay ->SetHighlightHdl( LINK( this, SmSymDefineDialog, CharHighlightHdl ) );
// preview like controls should have a 2D look
pOldSymbolDisplay->SetBorderStyle( WINDOW_BORDER_MONO );
pSymbolDisplay ->SetBorderStyle( WINDOW_BORDER_MONO );
2000-09-18 16:07:07 +00:00
}
SmSymDefineDialog::~SmSymDefineDialog()
{
delete pSubsetMap;
delete pOrigSymbol;
2000-09-18 16:07:07 +00:00
}
void SmSymDefineDialog::InitColor_Impl()
{
#if OSL_DEBUG_LEVEL > 1
Color aBC( GetDisplayBackground().GetColor() );
#endif
ColorData nBgCol = COL_WHITE,
nTxtCol = COL_BLACK;
bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
if (bHighContrast)
{
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 );
Color aTxtColor( nTxtCol );
pCharsetDisplay ->SetBackground( aWall );
pCharsetDisplay ->SetTextColor( aTxtColor );
pOldSymbolDisplay->SetBackground( aWall );
pOldSymbolDisplay->SetTextColor( aTxtColor );
pSymbolDisplay ->SetBackground( aWall );
pSymbolDisplay ->SetTextColor( aTxtColor );
}
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();
// apply changes if dialog was closed by clicking OK
if (aSymbolMgrCopy.IsModified() && nResult == RET_OK)
rSymbolMgr = aSymbolMgrCopy;
2000-09-18 16:07:07 +00:00
return nResult;
}
void SmSymDefineDialog::SetSymbolSetManager(const SmSymbolManager &rMgr)
2000-09-18 16:07:07 +00:00
{
aSymbolMgrCopy = rMgr;
2000-09-18 16:07:07 +00:00
// Set the modified flag of the copy to false so that
// we can check later on if anything has been changed
aSymbolMgrCopy.SetModified(false);
2000-09-18 16:07:07 +00:00
FillSymbolSets(*pOldSymbolSets);
if (pOldSymbolSets->GetEntryCount() > 0)
SelectSymbolSet(pOldSymbolSets->GetEntry(0));
FillSymbolSets(*pSymbolSets);
if (pSymbolSets->GetEntryCount() > 0)
SelectSymbolSet(pSymbolSets->GetEntry(0));
FillSymbols(*pOldSymbols);
if (pOldSymbols->GetEntryCount() > 0)
SelectSymbol(pOldSymbols->GetEntry(0));
FillSymbols(*pSymbols);
if (pSymbols->GetEntryCount() > 0)
SelectSymbol(pSymbols->GetEntry(0));
2000-09-18 16:07:07 +00:00
UpdateButtons();
}
bool SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox,
const OUString &rSymbolSetName, bool bDeleteText)
2000-09-18 16:07:07 +00:00
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(&rComboBox == pOldSymbolSets || &rComboBox == pSymbolSets,
"Sm : wrong ComboBox");
#endif
2000-09-18 16:07:07 +00:00
// trim SymbolName (no leading and trailing blanks)
OUString aNormName (rSymbolSetName);
aNormName = comphelper::string::stripStart(aNormName, ' ');
aNormName = comphelper::string::stripEnd(aNormName, ' ');
// and remove possible deviations within the input
2000-09-18 16:07:07 +00:00
rComboBox.SetText(aNormName);
bool bRet = false;
sal_Int32 nPos = rComboBox.GetEntryPos(aNormName);
2000-09-18 16:07:07 +00:00
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
{
rComboBox.SetText(rComboBox.GetEntry(nPos));
bRet = true;
2000-09-18 16:07:07 +00:00
}
else if (bDeleteText)
rComboBox.SetText(OUString());
2000-09-18 16:07:07 +00:00
bool bIsOld = &rComboBox == pOldSymbolSets;
2000-09-18 16:07:07 +00:00
// setting the SymbolSet name at the associated display
FixedText &rFT = bIsOld ? *pOldSymbolSetName : *pSymbolSetName;
2000-09-18 16:07:07 +00:00
rFT.SetText(rComboBox.GetText());
// set the symbol name which belongs to the SymbolSet at the associated combobox
ComboBox &rCB = bIsOld ? *pOldSymbols : *pSymbols;
FillSymbols(rCB, false);
2000-09-18 16:07:07 +00:00
// display a valid respectively no symbol when changing the SymbolSets
2000-09-18 16:07:07 +00:00
if (bIsOld)
{
OUString aTmpOldSymbolName;
if (pOldSymbols->GetEntryCount() > 0)
aTmpOldSymbolName = pOldSymbols->GetEntry(0);
SelectSymbol(*pOldSymbols, aTmpOldSymbolName, true);
2000-09-18 16:07:07 +00:00
}
UpdateButtons();
return bRet;
}
void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol,
const OUString &rSymbolSetName)
2000-09-18 16:07:07 +00:00
{
// clear old symbol
delete pOrigSymbol;
pOrigSymbol = 0;
2000-09-18 16:07:07 +00:00
OUString aSymName,
aSymSetName;
2000-09-18 16:07:07 +00:00
if (pSymbol)
{
// set new symbol
pOrigSymbol = new SmSym( *pSymbol );
2000-09-18 16:07:07 +00:00
aSymName = pSymbol->GetName();
aSymSetName = rSymbolSetName;
pOldSymbolDisplay->SetSymbol( pSymbol );
2000-09-18 16:07:07 +00:00
}
else
{ // delete displayed symbols
pOldSymbolDisplay->SetText(OUString());
pOldSymbolDisplay->Invalidate();
2000-09-18 16:07:07 +00:00
}
pOldSymbolName->SetText(aSymName);
pOldSymbolSetName->SetText(aSymSetName);
2000-09-18 16:07:07 +00:00
}
bool SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox,
const OUString &rSymbolName, bool bDeleteText)
2000-09-18 16:07:07 +00:00
{
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE(&rComboBox == pOldSymbols || &rComboBox == pSymbols,
"Sm : wrong ComboBox");
#endif
2000-09-18 16:07:07 +00:00
// trim SymbolName (no blanks)
OUString aNormName(comphelper::string::remove(rSymbolName, ' '));
// and remove possible deviations within the input
2000-09-18 16:07:07 +00:00
rComboBox.SetText(aNormName);
bool bRet = false;
sal_Int32 nPos = rComboBox.GetEntryPos(aNormName);
2000-09-18 16:07:07 +00:00
bool bIsOld = &rComboBox == pOldSymbols;
2000-09-18 16:07:07 +00:00
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
{
rComboBox.SetText(rComboBox.GetEntry(nPos));
if (!bIsOld)
{
const SmSym *pSymbol = GetSymbol(*pSymbols);
2000-09-18 16:07:07 +00:00
if (pSymbol)
{
// choose font and style accordingly
const vcl::Font &rFont = pSymbol->GetFace();
SelectFont(rFont.GetName(), false);
SelectStyle(GetFontStyles().GetStyleName(rFont), false);
2000-09-18 16:07:07 +00: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
pCharsetDisplay->SetFont(rFont);
pSymbolDisplay->SetFont(rFont);
2000-09-18 16:07:07 +00:00
// select associated character
2000-09-18 16:07:07 +00:00
SelectChar(pSymbol->GetCharacter());
// 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
pSymbols->SetText( pSymbol->GetName() );
2000-09-18 16:07:07 +00:00
}
}
bRet = true;
2000-09-18 16:07:07 +00:00
}
else if (bDeleteText)
rComboBox.SetText(OUString());
2000-09-18 16:07:07 +00:00
if (bIsOld)
{
// 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;
OUString aTmpOldSymbolSetName;
2000-09-18 16:07:07 +00:00
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
{
pOldSymbol = aSymbolMgrCopy.GetSymbolByName(aNormName);
aTmpOldSymbolSetName = pOldSymbolSets->GetText();
2000-09-18 16:07:07 +00:00
}
SetOrigSymbol(pOldSymbol, aTmpOldSymbolSetName);
2000-09-18 16:07:07 +00:00
}
else
pSymbolName->SetText(rComboBox.GetText());
2000-09-18 16:07:07 +00:00
UpdateButtons();
return bRet;
}
void SmSymDefineDialog::SetFont(const OUString &rFontName, const OUString &rStyleName)
2000-09-18 16:07:07 +00:00
{
// get Font (FontInfo) matching name and style
vcl::FontInfo aFI;
if (pFontList)
aFI = pFontList->Get(rFontName, WEIGHT_NORMAL, ITALIC_NONE);
2000-09-18 16:07:07 +00:00
SetFontStyle(rStyleName, aFI);
pCharsetDisplay->SetFont(aFI);
pSymbolDisplay->SetFont(aFI);
// update subset listbox for new font's unicode subsets
FontCharMap aFontCharMap;
pCharsetDisplay->GetFontCharMap( aFontCharMap );
if (pSubsetMap)
delete pSubsetMap;
pSubsetMap = new SubsetMap( &aFontCharMap );
2011-01-24 01:49:58 +01:00
pFontsSubsetLB->Clear();
bool bFirst = true;
const Subset* pSubset;
while( NULL != (pSubset = pSubsetMap->GetNextSubset( bFirst )) )
{
sal_uInt16 nPos = pFontsSubsetLB->InsertEntry( pSubset->GetName());
pFontsSubsetLB->SetEntryData( nPos, (void *) pSubset );
// subset must live at least as long as the selected font !!!
if( bFirst )
pFontsSubsetLB->SelectEntryPos( nPos );
bFirst = false;
}
if( bFirst )
pFontsSubsetLB->SetNoSelection();
pFontsSubsetLB->Enable( !bFirst );
2000-09-18 16:07:07 +00:00
}
bool SmSymDefineDialog::SelectFont(const OUString &rFontName, bool bApplyFont)
2000-09-18 16:07:07 +00:00
{
bool bRet = false;
sal_Int32 nPos = pFonts->GetEntryPos(rFontName);
2000-09-18 16:07:07 +00:00
if (nPos != LISTBOX_ENTRY_NOTFOUND)
{
pFonts->SelectEntryPos(nPos);
if (pStyles->GetEntryCount() > 0)
SelectStyle(pStyles->GetEntry(0));
2000-09-18 16:07:07 +00:00
if (bApplyFont)
{
SetFont(pFonts->GetSelectEntry(), pStyles->GetText());
bRet = true;
pSymbolDisplay->SetSymbol( pCharsetDisplay->GetSelectCharacter(), pCharsetDisplay->GetFont() );
}
bRet = true;
2000-09-18 16:07:07 +00:00
}
else
pFonts->SetNoSelection();
2000-09-18 16:07:07 +00:00
FillStyles();
UpdateButtons();
return bRet;
}
bool SmSymDefineDialog::SelectStyle(const OUString &rStyleName, bool bApplyFont)
2000-09-18 16:07:07 +00:00
{
bool bRet = false;
sal_Int32 nPos = pStyles->GetEntryPos(rStyleName);
2000-09-18 16:07:07 +00:00
// if the style is not available take the first available one (if existent)
if (nPos == COMBOBOX_ENTRY_NOTFOUND && pStyles->GetEntryCount() > 0)
2000-09-18 16:07:07 +00:00
nPos = 0;
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
{
pStyles->SetText(pStyles->GetEntry(nPos));
2000-09-18 16:07:07 +00:00
if (bApplyFont)
{
SetFont(pFonts->GetSelectEntry(), pStyles->GetText());
bRet = true;
pSymbolDisplay->SetSymbol( pCharsetDisplay->GetSelectCharacter(), pCharsetDisplay->GetFont() );
}
bRet = true;
2000-09-18 16:07:07 +00:00
}
else
pStyles->SetText(OUString());
2000-09-18 16:07:07 +00:00
UpdateButtons();
return bRet;
}
void SmSymDefineDialog::SelectChar(sal_Unicode cChar)
2000-09-18 16:07:07 +00:00
{
pCharsetDisplay->SelectCharacter( cChar );
pSymbolDisplay->SetSymbol( cChar, pCharsetDisplay->GetFont() );
2000-09-18 16:07:07 +00:00
UpdateButtons();
}
/**************************************************************************/
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */