2010-10-14 01:30:41 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 06:43:55 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 06:43:55 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 06:43:55 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 06:43:55 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 06:43:55 -05:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2008-04-10 06:43:55 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 01:53:05 -05:00
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2000-11-02 08:07:16 -06:00
|
|
|
#include <tools/stream.hxx>
|
2001-08-16 03:20:48 -05:00
|
|
|
#include <vcl/svapp.hxx>
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/scripttypeitem.hxx>
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "format.hxx"
|
|
|
|
|
2001-08-16 03:20:48 -05:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Latin default-fonts
|
2011-01-14 10:19:25 -06:00
|
|
|
static const sal_uInt16 aLatinDefFnts[FNT_END] =
|
2001-08-16 03:20:48 -05:00
|
|
|
{
|
|
|
|
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
|
2009-11-12 08:30:38 -06:00
|
|
|
//OpenSymbol, // FNT_MATH
|
2001-08-16 03:20:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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...
|
2011-01-14 10:19:25 -06:00
|
|
|
static const sal_uInt16 aCJKDefFnts[FNT_END] =
|
2001-08-16 03:20:48 -05:00
|
|
|
{
|
|
|
|
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
|
2009-11-12 08:30:38 -06:00
|
|
|
//OpenSymbol, // FNT_MATH
|
2001-08-16 03:20:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// CTL default-fonts
|
2011-01-14 10:19:25 -06:00
|
|
|
static const sal_uInt16 aCTLDefFnts[FNT_END] =
|
2001-08-16 03:20:48 -05:00
|
|
|
{
|
|
|
|
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
|
2009-11-12 08:30:38 -06:00
|
|
|
//OpenSymbol, // FNT_MATH
|
2001-08-16 03:20:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-14 10:19:25 -06:00
|
|
|
String GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent )
|
2001-08-16 03:20:48 -05:00
|
|
|
{
|
2010-10-07 05:02:05 -05:00
|
|
|
OSL_ENSURE( /*FNT_BEGIN <= nIdent &&*/ nIdent <= FNT_END,
|
2001-08-16 03:20:48 -05:00
|
|
|
"index out opd range" );
|
|
|
|
|
|
|
|
if (FNT_MATH == nIdent)
|
|
|
|
return String::CreateFromAscii( FNTNAME_MATH );
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 10:19:25 -06:00
|
|
|
const sal_uInt16 *pTable;
|
2003-04-17 04:21:46 -05:00
|
|
|
switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) )
|
2001-08-16 03:20:48 -05:00
|
|
|
{
|
|
|
|
case SCRIPTTYPE_LATIN : pTable = aLatinDefFnts; break;
|
|
|
|
case SCRIPTTYPE_ASIAN : pTable = aCJKDefFnts; break;
|
|
|
|
case SCRIPTTYPE_COMPLEX : pTable = aCTLDefFnts; break;
|
|
|
|
default :
|
|
|
|
pTable = aLatinDefFnts;
|
2011-03-01 12:09:12 -06:00
|
|
|
OSL_FAIL( "unknown script-type" );
|
2001-08-16 03:20:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return Application::GetDefaultDevice()->GetDefaultFont(
|
|
|
|
pTable[ nIdent ], nLang,
|
|
|
|
DEFAULTFONT_FLAGS_ONLYONE ).GetName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
SmFormat::SmFormat()
|
|
|
|
: aBaseSize(0, SmPtsTo100th_mm(12))
|
|
|
|
{
|
|
|
|
nVersion = SM_FMT_VERSION_NOW;
|
|
|
|
|
2010-07-28 02:46:36 -05:00
|
|
|
eHorAlign = AlignCenter;
|
|
|
|
nGreekCharStyle = 0;
|
2010-11-05 19:33:05 -05:00
|
|
|
bIsTextmode = bScaleNormalBrackets = false;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
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 05:22:18 -05:00
|
|
|
vFont[FNT_MATH].SetCharSet( RTL_TEXTENCODING_UNICODE );
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
vFont[FNT_VARIABLE].SetItalic(ITALIC_NORMAL);
|
|
|
|
vFont[FNT_FUNCTION].SetItalic(ITALIC_NONE);
|
2005-05-03 07:52:11 -05: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 11:07:07 -05:00
|
|
|
|
2011-01-14 10:19:25 -06:00
|
|
|
for ( sal_uInt16 i = FNT_BEGIN; i <= FNT_END; i++ )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2002-04-18 05:50:42 -05:00
|
|
|
SmFace &rFace = vFont[i];
|
2010-11-05 19:33:05 -05:00
|
|
|
rFace.SetTransparent( true );
|
2002-04-18 05:50:42 -05:00
|
|
|
rFace.SetAlign( ALIGN_BASELINE );
|
|
|
|
rFace.SetColor( COL_AUTO );
|
2010-11-05 19:33:05 -05:00
|
|
|
bDefaultFont[i] = false;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-14 11:51:14 -05:00
|
|
|
void SmFormat::SetFont(sal_uInt16 nIdent, const SmFace &rFont, bool bDefault )
|
2001-05-02 10:58:48 -05:00
|
|
|
{
|
|
|
|
vFont[nIdent] = rFont;
|
2010-11-05 19:33:05 -05:00
|
|
|
vFont[nIdent].SetTransparent( true );
|
2001-05-02 10:58:48 -05:00
|
|
|
vFont[nIdent].SetAlign( ALIGN_BASELINE );
|
2001-08-16 03:20:48 -05:00
|
|
|
|
|
|
|
bDefaultFont[nIdent] = bDefault;
|
2001-05-02 10:58:48 -05:00
|
|
|
}
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
SmFormat & SmFormat::operator = (const SmFormat &rFormat)
|
|
|
|
{
|
|
|
|
SetBaseSize(rFormat.GetBaseSize());
|
|
|
|
SetVersion (rFormat.GetVersion());
|
|
|
|
SetHorAlign(rFormat.GetHorAlign());
|
|
|
|
SetTextmode(rFormat.IsTextmode());
|
2010-07-28 02:46:36 -05:00
|
|
|
SetGreekCharStyle(rFormat.GetGreekCharStyle());
|
2000-09-18 11:07:07 -05:00
|
|
|
SetScaleNormalBrackets(rFormat.IsScaleNormalBrackets());
|
|
|
|
|
2011-01-14 10:19:25 -06:00
|
|
|
sal_uInt16 i;
|
2000-09-18 11:07:07 -05:00
|
|
|
for (i = FNT_BEGIN; i <= FNT_END; i++)
|
2001-08-16 03:20:48 -05:00
|
|
|
{
|
2000-09-18 11:07:07 -05:00
|
|
|
SetFont(i, rFormat.GetFont(i));
|
2001-08-16 03:20:48 -05:00
|
|
|
SetDefaultFont(i, rFormat.IsDefaultFont(i));
|
|
|
|
}
|
2000-09-18 11:07:07 -05: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-05 19:33:05 -05:00
|
|
|
bool SmFormat::operator == (const SmFormat &rFormat) const
|
2001-05-02 10:58:48 -05:00
|
|
|
{
|
2010-11-05 19:33:05 -05:00
|
|
|
bool bRes = aBaseSize == rFormat.aBaseSize &&
|
2001-05-02 10:58:48 -05:00
|
|
|
eHorAlign == rFormat.eHorAlign &&
|
2010-07-28 02:46:36 -05:00
|
|
|
nGreekCharStyle == rFormat.nGreekCharStyle &&
|
2001-05-02 10:58:48 -05:00
|
|
|
bIsTextmode == rFormat.bIsTextmode &&
|
|
|
|
bScaleNormalBrackets == rFormat.bScaleNormalBrackets;
|
|
|
|
|
2011-01-14 10:19:25 -06:00
|
|
|
sal_uInt16 i;
|
2001-05-02 10:58:48 -05:00
|
|
|
for (i = 0; i <= SIZ_END && bRes; ++i)
|
|
|
|
{
|
|
|
|
if (vSize[i] != rFormat.vSize[i])
|
2010-11-05 19:33:05 -05:00
|
|
|
bRes = false;
|
2001-05-02 10:58:48 -05:00
|
|
|
}
|
|
|
|
for (i = 0; i <= DIS_END && bRes; ++i)
|
|
|
|
{
|
|
|
|
if (vDist[i] != rFormat.vDist[i])
|
2010-11-05 19:33:05 -05:00
|
|
|
bRes = false;
|
2001-05-02 10:58:48 -05:00
|
|
|
}
|
|
|
|
for (i = 0; i <= FNT_END && bRes; ++i)
|
|
|
|
{
|
2001-08-16 03:20:48 -05:00
|
|
|
if (vFont[i] != rFormat.vFont[i] ||
|
|
|
|
bDefaultFont[i] != rFormat.bDefaultFont[i])
|
2010-11-05 19:33:05 -05:00
|
|
|
bRes = false;
|
2001-05-02 10:58:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 01:30:41 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|