2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: format.cxx,v $
|
|
|
|
*
|
2005-05-03 12:52:11 +00:00
|
|
|
* $Revision: 1.10 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-05-03 12:52:11 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2005-05-03 13:52:11 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
2000-11-02 14:07:16 +00:00
|
|
|
#ifndef _STREAM_HXX
|
|
|
|
#include <tools/stream.hxx>
|
|
|
|
#endif
|
2001-08-16 08:20:48 +00:00
|
|
|
#ifndef _SV_SVAPP_HXX
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_SCRIPTTYPEITEM_HXX
|
|
|
|
#include <svx/scripttypeitem.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifndef FORMAT_HXX
|
|
|
|
#include "format.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-08-16 08:20:48 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Latin default-fonts
|
|
|
|
static const USHORT aLatinDefFnts[FNT_END] =
|
|
|
|
{
|
|
|
|
DEFAULTFONT_SERIF, // FNT_VARIABLE
|
|
|
|
DEFAULTFONT_SERIF, // FNT_FUNCTION
|
|
|
|
DEFAULTFONT_SERIF, // FNT_NUMBER
|
|
|
|
DEFAULTFONT_SERIF, // FNT_TEXT
|
|
|
|
DEFAULTFONT_SERIF, // FNT_SERIF
|
|
|
|
DEFAULTFONT_SANS, // FNT_SANS
|
|
|
|
DEFAULTFONT_FIXED // FNT_FIXED
|
|
|
|
//StarSymbol, // FNT_MATH
|
|
|
|
};
|
|
|
|
|
|
|
|
// CJK default-fonts
|
|
|
|
//! we use non-asian fonts for variables, functions and numbers since they
|
|
|
|
//! look better and even in asia only latin letters will be used for those.
|
|
|
|
//! At least that's what I was told...
|
|
|
|
static const USHORT aCJKDefFnts[FNT_END] =
|
|
|
|
{
|
|
|
|
DEFAULTFONT_SERIF, // FNT_VARIABLE
|
|
|
|
DEFAULTFONT_SERIF, // FNT_FUNCTION
|
|
|
|
DEFAULTFONT_SERIF, // FNT_NUMBER
|
|
|
|
DEFAULTFONT_CJK_TEXT, // FNT_TEXT
|
|
|
|
DEFAULTFONT_CJK_TEXT, // FNT_SERIF
|
|
|
|
DEFAULTFONT_CJK_DISPLAY, // FNT_SANS
|
|
|
|
DEFAULTFONT_CJK_TEXT // FNT_FIXED
|
|
|
|
//StarSymbol, // FNT_MATH
|
|
|
|
};
|
|
|
|
|
|
|
|
// CTL default-fonts
|
|
|
|
static const USHORT aCTLDefFnts[FNT_END] =
|
|
|
|
{
|
|
|
|
DEFAULTFONT_CTL_TEXT, // FNT_VARIABLE
|
|
|
|
DEFAULTFONT_CTL_TEXT, // FNT_FUNCTION
|
|
|
|
DEFAULTFONT_CTL_TEXT, // FNT_NUMBER
|
|
|
|
DEFAULTFONT_CTL_TEXT, // FNT_TEXT
|
|
|
|
DEFAULTFONT_CTL_TEXT, // FNT_SERIF
|
|
|
|
DEFAULTFONT_CTL_TEXT, // FNT_SANS
|
|
|
|
DEFAULTFONT_CTL_TEXT // FNT_FIXED
|
|
|
|
//StarSymbol, // FNT_MATH
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
String GetDefaultFontName( LanguageType nLang, USHORT nIdent )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( FNT_BEGIN <= nIdent && nIdent <= FNT_END,
|
|
|
|
"index out opd range" );
|
|
|
|
|
|
|
|
if (FNT_MATH == nIdent)
|
|
|
|
return String::CreateFromAscii( FNTNAME_MATH );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const USHORT *pTable;
|
2003-04-17 09:21:46 +00:00
|
|
|
switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) )
|
2001-08-16 08:20:48 +00:00
|
|
|
{
|
|
|
|
case SCRIPTTYPE_LATIN : pTable = aLatinDefFnts; break;
|
|
|
|
case SCRIPTTYPE_ASIAN : pTable = aCJKDefFnts; break;
|
|
|
|
case SCRIPTTYPE_COMPLEX : pTable = aCTLDefFnts; break;
|
|
|
|
default :
|
|
|
|
pTable = aLatinDefFnts;
|
|
|
|
DBG_ERROR( "unknown script-type" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return Application::GetDefaultDevice()->GetDefaultFont(
|
|
|
|
pTable[ nIdent ], nLang,
|
|
|
|
DEFAULTFONT_FLAGS_ONLYONE ).GetName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SmFormat::SmFormat()
|
|
|
|
: aBaseSize(0, SmPtsTo100th_mm(12))
|
|
|
|
{
|
|
|
|
nVersion = SM_FMT_VERSION_NOW;
|
|
|
|
|
|
|
|
eHorAlign = AlignCenter;
|
|
|
|
bIsTextmode = bScaleNormalBrackets = FALSE;
|
|
|
|
|
|
|
|
vSize[SIZ_TEXT] = 100;
|
|
|
|
vSize[SIZ_INDEX] = 60;
|
|
|
|
vSize[SIZ_FUNCTION] =
|
|
|
|
vSize[SIZ_OPERATOR] = 100;
|
|
|
|
vSize[SIZ_LIMITS] = 60;
|
|
|
|
|
|
|
|
vDist[DIS_HORIZONTAL] = 10;
|
|
|
|
vDist[DIS_VERTICAL] = 5;
|
|
|
|
vDist[DIS_ROOT] = 0;
|
|
|
|
vDist[DIS_SUPERSCRIPT] =
|
|
|
|
vDist[DIS_SUBSCRIPT] = 20;
|
|
|
|
vDist[DIS_NUMERATOR] =
|
|
|
|
vDist[DIS_DENOMINATOR] = 0;
|
|
|
|
vDist[DIS_FRACTION] = 10;
|
|
|
|
vDist[DIS_STROKEWIDTH] = 5;
|
|
|
|
vDist[DIS_UPPERLIMIT] =
|
|
|
|
vDist[DIS_LOWERLIMIT] = 0;
|
|
|
|
vDist[DIS_BRACKETSIZE] =
|
|
|
|
vDist[DIS_BRACKETSPACE] = 5;
|
|
|
|
vDist[DIS_MATRIXROW] = 3;
|
|
|
|
vDist[DIS_MATRIXCOL] = 30;
|
|
|
|
vDist[DIS_ORNAMENTSIZE] =
|
|
|
|
vDist[DIS_ORNAMENTSPACE] = 0;
|
|
|
|
vDist[DIS_OPERATORSIZE] = 50;
|
|
|
|
vDist[DIS_OPERATORSPACE] = 20;
|
|
|
|
vDist[DIS_LEFTSPACE] =
|
|
|
|
vDist[DIS_RIGHTSPACE] = 100;
|
|
|
|
vDist[DIS_TOPSPACE] =
|
|
|
|
vDist[DIS_BOTTOMSPACE] =
|
|
|
|
vDist[DIS_NORMALBRACKETSIZE] = 0;
|
|
|
|
|
|
|
|
vFont[FNT_VARIABLE] =
|
|
|
|
vFont[FNT_FUNCTION] =
|
|
|
|
vFont[FNT_NUMBER] =
|
|
|
|
vFont[FNT_TEXT] =
|
|
|
|
vFont[FNT_SERIF] = SmFace(C2S(FNTNAME_TIMES), aBaseSize);
|
|
|
|
vFont[FNT_SANS] = SmFace(C2S(FNTNAME_HELV), aBaseSize);
|
|
|
|
vFont[FNT_FIXED] = SmFace(C2S(FNTNAME_COUR), aBaseSize);
|
|
|
|
vFont[FNT_MATH] = SmFace(C2S(FNTNAME_MATH), aBaseSize);
|
|
|
|
|
2001-08-08 10:22:18 +00:00
|
|
|
vFont[FNT_MATH].SetCharSet( RTL_TEXTENCODING_UNICODE );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
vFont[FNT_VARIABLE].SetItalic(ITALIC_NORMAL);
|
|
|
|
vFont[FNT_FUNCTION].SetItalic(ITALIC_NONE);
|
2005-05-03 12:52:11 +00:00
|
|
|
vFont[FNT_NUMBER] .SetItalic(ITALIC_NONE);
|
|
|
|
vFont[FNT_TEXT] .SetItalic(ITALIC_NONE);
|
|
|
|
vFont[FNT_SERIF] .SetItalic(ITALIC_NONE);
|
|
|
|
vFont[FNT_SANS] .SetItalic(ITALIC_NONE);
|
|
|
|
vFont[FNT_FIXED] .SetItalic(ITALIC_NONE);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
for ( USHORT i = FNT_BEGIN; i <= FNT_END; i++ )
|
|
|
|
{
|
2002-04-18 10:50:42 +00:00
|
|
|
SmFace &rFace = vFont[i];
|
|
|
|
rFace.SetTransparent( TRUE );
|
|
|
|
rFace.SetAlign( ALIGN_BASELINE );
|
|
|
|
rFace.SetColor( COL_AUTO );
|
2001-08-16 08:20:48 +00:00
|
|
|
bDefaultFont[i] = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-16 08:20:48 +00:00
|
|
|
void SmFormat::SetFont(USHORT nIdent, const SmFace &rFont, BOOL bDefault )
|
2001-05-02 15:58:48 +00:00
|
|
|
{
|
|
|
|
vFont[nIdent] = rFont;
|
|
|
|
vFont[nIdent].SetTransparent( TRUE );
|
|
|
|
vFont[nIdent].SetAlign( ALIGN_BASELINE );
|
2001-08-16 08:20:48 +00:00
|
|
|
|
|
|
|
bDefaultFont[nIdent] = bDefault;
|
2001-05-02 15:58:48 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SmFormat & SmFormat::operator = (const SmFormat &rFormat)
|
|
|
|
{
|
|
|
|
SetBaseSize(rFormat.GetBaseSize());
|
|
|
|
SetVersion (rFormat.GetVersion());
|
|
|
|
SetHorAlign(rFormat.GetHorAlign());
|
|
|
|
SetTextmode(rFormat.IsTextmode());
|
|
|
|
SetScaleNormalBrackets(rFormat.IsScaleNormalBrackets());
|
|
|
|
|
|
|
|
USHORT i;
|
|
|
|
for (i = FNT_BEGIN; i <= FNT_END; i++)
|
2001-08-16 08:20:48 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFont(i, rFormat.GetFont(i));
|
2001-08-16 08:20:48 +00:00
|
|
|
SetDefaultFont(i, rFormat.IsDefaultFont(i));
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
for (i = SIZ_BEGIN; i <= SIZ_END; i++)
|
|
|
|
SetRelSize(i, rFormat.GetRelSize(i));
|
|
|
|
for (i = DIS_BEGIN; i <= DIS_END; i++)
|
|
|
|
SetDistance(i, rFormat.GetDistance(i));
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-02 15:58:48 +00:00
|
|
|
BOOL SmFormat::operator == (const SmFormat &rFormat) const
|
|
|
|
{
|
|
|
|
BOOL bRes = aBaseSize == rFormat.aBaseSize &&
|
|
|
|
eHorAlign == rFormat.eHorAlign &&
|
|
|
|
bIsTextmode == rFormat.bIsTextmode &&
|
|
|
|
bScaleNormalBrackets == rFormat.bScaleNormalBrackets;
|
|
|
|
|
|
|
|
USHORT i;
|
|
|
|
for (i = 0; i <= SIZ_END && bRes; ++i)
|
|
|
|
{
|
|
|
|
if (vSize[i] != rFormat.vSize[i])
|
|
|
|
bRes = FALSE;
|
|
|
|
}
|
|
|
|
for (i = 0; i <= DIS_END && bRes; ++i)
|
|
|
|
{
|
|
|
|
if (vDist[i] != rFormat.vDist[i])
|
|
|
|
bRes = FALSE;
|
|
|
|
}
|
|
|
|
for (i = 0; i <= FNT_END && bRes; ++i)
|
|
|
|
{
|
2001-08-16 08:20:48 +00:00
|
|
|
if (vFont[i] != rFormat.vFont[i] ||
|
|
|
|
bDefaultFont[i] != rFormat.bDefaultFont[i])
|
2001-05-02 15:58:48 +00:00
|
|
|
bRes = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|