Kaydet (Commit) d15d274d authored tarafından Andreas Martens's avatar Andreas Martens

Fix #86705#: Preview for Asian and Latin Unicode characters

üst 5a1dade2
......@@ -2,9 +2,9 @@
*
* $RCSfile: chardlg.cxx,v $
*
* $Revision: 1.52 $
* $Revision: 1.53 $
*
* last change: $Author: os $ $Date: 2001-07-12 10:02:15 $
* last change: $Author: ama $ $Date: 2001-07-19 07:43:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -500,12 +500,16 @@ const FontList* SvxCharNamePage::GetFontList() const
void SvxCharNamePage::UpdatePreview_Impl()
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
// Size
Size aSize = rFont.GetSize();
aSize.Width() = 0;
Size aCJKSize = rCJKFont.GetSize();
aCJKSize.Width() = 0;
// Font
const FontList* pFontList = GetFontList();
FontInfo aFontInfo( pFontList->Get( m_pWestFontNameLB->GetText(), m_pWestFontStyleLB->GetText() ) );
// Size
FontInfo aCJKFontInfo( pFontList->Get( m_aEastFontNameLB.GetText(), m_aEastFontStyleLB.GetText() ) );
if ( m_pWestFontSizeLB->IsRelative() )
{
......@@ -530,6 +534,25 @@ void SvxCharNamePage::UpdatePreview_Impl()
aSize.Height() = 200; // default 10pt
aFontInfo.SetSize( aSize );
if ( m_aEastFontSizeLB.IsRelative() )
{
DBG_ASSERT( GetItemSet().GetParent(), "No parent set" );
USHORT nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT );
const SvxFontHeightItem& rOldItem = (SvxFontHeightItem&)GetItemSet().GetParent()->Get( nWhich );
long nHeight;
if ( m_aEastFontSizeLB.IsPtRelative() )
nHeight = rOldItem.GetHeight() + PointToTwips( m_aEastFontSizeLB.GetValue() / 10 );
else
nHeight = rOldItem.GetHeight() * m_aEastFontSizeLB.GetValue() / 100;
aCJKSize.Height() =
ItemToControl( nHeight, GetItemSet().GetPool()->GetMetric( nWhich ), SFX_FUNIT_TWIP );
}
else if ( m_aEastFontSizeLB.GetText().Len() )
aCJKSize.Height() = PointToTwips( m_aEastFontSizeLB.GetValue() / 10 );
else
aCJKSize.Height() = 200; // default 10pt
aCJKFontInfo.SetSize( aCJKSize );
rFont.SetFamily( aFontInfo.GetFamily() );
rFont.SetName( aFontInfo.GetName() );
rFont.SetStyleName( aFontInfo.GetStyleName() );
......@@ -539,6 +562,15 @@ void SvxCharNamePage::UpdatePreview_Impl()
rFont.SetItalic( aFontInfo.GetItalic() );
rFont.SetSize( aFontInfo.GetSize() );
rCJKFont.SetFamily( aCJKFontInfo.GetFamily() );
rCJKFont.SetName( aCJKFontInfo.GetName() );
rCJKFont.SetStyleName( aCJKFontInfo.GetStyleName() );
rCJKFont.SetPitch( aCJKFontInfo.GetPitch() );
rCJKFont.SetCharSet( aCJKFontInfo.GetCharSet() );
rCJKFont.SetWeight( aCJKFontInfo.GetWeight() );
rCJKFont.SetItalic( aCJKFontInfo.GetItalic() );
rCJKFont.SetSize( aCJKFontInfo.GetSize() );
m_aPreviewWin.Invalidate();
m_aFontTypeFT.SetText( pFontList->GetFontMapText( aFontInfo ) );
}
......@@ -1010,9 +1042,11 @@ void SvxCharNamePage::ResetColor_Impl( const SfxItemSet& rSet )
case SFX_ITEM_SET:
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
Color aColor = rItem.GetValue();
rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
m_aPreviewWin.Invalidate();
USHORT nSelPos = m_aColorLB.GetEntryPos( aColor );
if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) )
......@@ -1102,12 +1136,14 @@ IMPL_LINK( SvxCharNamePage, FontModifyHdl_Impl, void*, pBox )
IMPL_LINK( SvxCharNamePage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox )
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
Color aSelectedColor;
if ( pBox->GetSelectEntry() == m_pImpl->m_aTransparentText )
aSelectedColor = Color( COL_TRANSPARENT );
else
aSelectedColor = pBox->GetSelectEntryColor();
rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
m_aPreviewWin.Invalidate();
return 0;
}
......@@ -1117,6 +1153,7 @@ IMPL_LINK( SvxCharNamePage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox )
void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
// Underline
USHORT nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
......@@ -1125,10 +1162,14 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
rFont.SetUnderline( eUnderline );
rCJKFont.SetUnderline( eUnderline );
m_aPreviewWin.SetTextLineColor( rItem.GetColor() );
}
else
{
rFont.SetUnderline( UNDERLINE_NONE );
rCJKFont.SetUnderline( UNDERLINE_NONE );
}
// Strikeout
nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
......@@ -1137,9 +1178,13 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
rFont.SetStrikeout( eStrikeout );
rCJKFont.SetStrikeout( eStrikeout );
}
else
{
rFont.SetStrikeout( STRIKEOUT_NONE );
rCJKFont.SetStrikeout( STRIKEOUT_NONE );
}
// WordLineMode
nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
......@@ -1147,6 +1192,7 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
{
const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
rFont.SetWordLineMode( rItem.GetValue() );
rCJKFont.SetWordLineMode( rItem.GetValue() );
}
// Emphasis
......@@ -1156,6 +1202,7 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
FontEmphasisMark eMark = rItem.GetEmphasisMark();
rFont.SetEmphasisMark( eMark );
rCJKFont.SetEmphasisMark( eMark );
}
// Relief
nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
......@@ -1163,6 +1210,7 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
{
const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich );
rFont.SetRelief( (FontRelief)rItem.GetValue() );
rCJKFont.SetRelief( (FontRelief)rItem.GetValue() );
}
// Effects
......@@ -1173,6 +1221,7 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich );
SvxCaseMap eCaseMap = (SvxCaseMap)rItem.GetValue();
rFont.SetCaseMap( eCaseMap );
rCJKFont.SetCaseMap( eCaseMap );
}
// Outline
......@@ -1181,6 +1230,7 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
{
const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich );
rFont.SetOutline( rItem.GetValue() );
rCJKFont.SetOutline( rItem.GetValue() );
}
// Shadow
......@@ -1189,6 +1239,7 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
{
const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich );
rFont.SetShadow( rItem.GetValue() );
rCJKFont.SetShadow( rItem.GetValue() );
}
nWhich = GetWhich(m_pImpl->m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR);
......@@ -1197,10 +1248,15 @@ void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
const SvxBrushItem& rBrush = (const SvxBrushItem&)( rSet.Get( nWhich ) );
const Color& rColor = rBrush.GetColor();
rFont.SetFillColor(rColor);
rCJKFont.SetFillColor(rColor);
rFont.SetTransparent(rColor.GetTransparency() > 0);
rCJKFont.SetTransparent(rColor.GetTransparency() > 0);
}
else
{
rFont.SetTransparent(TRUE);
rCJKFont.SetTransparent(TRUE);
}
if(!m_pImpl->m_bPreviewBackgroundToCharacter)
{
......@@ -1437,27 +1493,38 @@ void SvxCharEffectsPage::Initialize()
void SvxCharEffectsPage::UpdatePreview_Impl()
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
USHORT nPos = m_aUnderlineLB.GetSelectEntryPos();
FontUnderline eUnderline = (FontUnderline)(ULONG)m_aUnderlineLB.GetEntryData( nPos );
nPos = m_aStrikeoutLB.GetSelectEntryPos();
FontStrikeout eStrikeout = (FontStrikeout)(ULONG)m_aStrikeoutLB.GetEntryData( nPos );
rFont.SetUnderline( eUnderline );
rCJKFont.SetUnderline( eUnderline );
m_aPreviewWin.SetTextLineColor( m_aColorLB.GetSelectEntryColor() );
rFont.SetStrikeout( eStrikeout );
rCJKFont.SetStrikeout( eStrikeout );
nPos = m_aPositionLB.GetSelectEntryPos();
BOOL bUnder = ( CHRDLG_POSITION_UNDER == (ULONG)m_aPositionLB.GetEntryData( nPos ) );
FontEmphasisMark eMark = (FontEmphasisMark)m_aEmphasisLB.GetSelectEntryPos();
eMark |= bUnder ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
rFont.SetEmphasisMark( eMark );
rCJKFont.SetEmphasisMark( eMark );
USHORT nRelief = m_aReliefLB.GetSelectEntryPos();
if(LISTBOX_ENTRY_NOTFOUND != nRelief)
{
rFont.SetRelief( (FontRelief)nRelief );
rCJKFont.SetRelief( (FontRelief)nRelief );
}
rFont.SetOutline( StateToAttr( m_aOutlineBtn.GetState() ) );
rCJKFont.SetOutline( rFont.IsOutline() );
rFont.SetShadow( StateToAttr( m_aShadowBtn.GetState() ) );
rCJKFont.SetShadow( rFont.IsShadow() );
USHORT nCapsPos = m_aEffects2LB.GetSelectEntryPos();
if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
{
rFont.SetCaseMap( (SvxCaseMap)nCapsPos );
rCJKFont.SetCaseMap( (SvxCaseMap)nCapsPos );
}
m_aPreviewWin.Invalidate();
}
......@@ -1532,6 +1599,7 @@ void SvxCharEffectsPage::ActivatePage( const SfxItemSet& rSet )
BOOL bInReset = FALSE; //!!!!
SfxItemState eState = bInReset ? SFX_ITEM_DEFAULT : SFX_ITEM_SET;
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
// Font
USHORT nWhich = GetWhich( SID_ATTR_CHAR_FONT );
......@@ -1545,6 +1613,16 @@ void SvxCharEffectsPage::ActivatePage( const SfxItemSet& rSet )
rFont.SetCharSet( pFontItem->GetCharSet() );
rFont.SetStyleName( pFontItem->GetStyleName() );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
{
pFontItem = (const SvxFontItem*)&rSet.Get( nWhich );
rCJKFont.SetFamily( pFontItem->GetFamily() );
rCJKFont.SetName( pFontItem->GetFamilyName() );
rCJKFont.SetPitch( pFontItem->GetPitch() );
rCJKFont.SetCharSet( pFontItem->GetCharSet() );
rCJKFont.SetStyleName( pFontItem->GetStyleName() );
}
// Style
nWhich = GetWhich( SID_ATTR_CHAR_POSTURE );
......@@ -1553,12 +1631,25 @@ void SvxCharEffectsPage::ActivatePage( const SfxItemSet& rSet )
const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
rFont.SetItalic( (FontItalic)rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE );
if ( rSet.GetItemState( nWhich ) >= eState )
{
const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
rCJKFont.SetItalic( (FontItalic)rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
rFont.SetWeight( (FontWeight)rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
rCJKFont.SetWeight( (FontWeight)rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
// Size
nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT );
......@@ -1575,6 +1666,19 @@ void SvxCharEffectsPage::ActivatePage( const SfxItemSet& rSet )
else
// as default 12pt
rFont.SetSize( Size( 0, 240 ) );
nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
MapUnit eUnit = (MapUnit)rSet.GetPool()->GetMetric( nWhich );
SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
Size aSize( rCJKFont.GetSize() );
long nH = LogicToLogic( rItem.GetHeight(), eUnit, MAP_TWIP );
aSize.Height() = nH;
aSize.Width() = 0;
rCJKFont.SetSize( aSize );
}
else
rCJKFont.SetSize( Size( 0, 240 ) );
// Color
nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
......@@ -1583,6 +1687,7 @@ void SvxCharEffectsPage::ActivatePage( const SfxItemSet& rSet )
const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
Color aCol( rItem.GetValue() );
rFont.SetColor( COL_AUTO == aCol.GetColor() ? Color(COL_BLACK) : aCol);
rCJKFont.SetColor( COL_AUTO == aCol.GetColor() ? Color(COL_BLACK) : aCol);
}
nWhich = GetWhich(m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR);
......@@ -1591,10 +1696,15 @@ void SvxCharEffectsPage::ActivatePage( const SfxItemSet& rSet )
const SvxBrushItem& rBrush = (const SvxBrushItem&)( rSet.Get( nWhich ) );
const Color& rColor = rBrush.GetColor();
rFont.SetFillColor(rColor);
rCJKFont.SetFillColor(rColor);
rFont.SetTransparent(rColor.GetTransparency() > 0);
rCJKFont.SetTransparent(rColor.GetTransparency() > 0);
}
else
{
rFont.SetTransparent(TRUE);
rCJKFont.SetTransparent(TRUE);
}
if(!m_bPreviewBackgroundToCharacter)
{
......@@ -1642,11 +1752,13 @@ USHORT* SvxCharEffectsPage::GetRanges()
void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
BOOL bEnable = FALSE;
// Underline
USHORT nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
rFont.SetUnderline( UNDERLINE_NONE );
rCJKFont.SetUnderline( UNDERLINE_NONE );
m_aUnderlineLB.SelectEntryPos( 0 );
SfxItemState eState = rSet.GetItemState( nWhich );
......@@ -1659,6 +1771,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
rFont.SetUnderline( eUnderline );
rCJKFont.SetUnderline( eUnderline );
if ( eUnderline != UNDERLINE_NONE )
{
......@@ -1699,6 +1812,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
// Strikeout
nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
rFont.SetStrikeout( STRIKEOUT_NONE );
rCJKFont.SetStrikeout( STRIKEOUT_NONE );
m_aStrikeoutLB.SelectEntryPos( 0 );
eState = rSet.GetItemState( nWhich );
......@@ -1711,6 +1825,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
rFont.SetStrikeout( eStrikeout );
rCJKFont.SetStrikeout( eStrikeout );
if ( eStrikeout != STRIKEOUT_NONE )
{
......@@ -1734,6 +1849,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
{
const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
rFont.SetWordLineMode( rItem.GetValue() );
rCJKFont.SetWordLineMode( rItem.GetValue() );
m_aIndividualWordsBtn.Check( rItem.GetValue() );
m_aIndividualWordsBtn.Enable( bEnable );
}
......@@ -1746,6 +1862,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
FontEmphasisMark eMark = rItem.GetEmphasisMark();
rFont.SetEmphasisMark( eMark );
rCJKFont.SetEmphasisMark( eMark );
m_aEmphasisLB.SelectEntryPos( (USHORT)( eMark & EMPHASISMARK_STYLE ) );
eMark &= ~EMPHASISMARK_STYLE;
......@@ -2206,6 +2323,7 @@ void SvxCharPositionPage::Initialize()
SetExchangeSupport();
m_aPreviewWin.GetFont().SetSize( Size( 0, 240 ) );
m_aPreviewWin.GetCJKFont().SetSize( Size( 0, 240 ) );
m_aNormalPosBtn.Check();
PositionHdl_Impl( &m_aNormalPosBtn );
......@@ -2242,9 +2360,13 @@ void SvxCharPositionPage::Initialize()
void SvxCharPositionPage::UpdatePreview_Impl( BYTE nProp, BYTE nEscProp, short nEsc )
{
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
rFont.SetPropr( nProp );
rCJKFont.SetPropr( nProp );
rFont.SetProprRel( nEscProp );
rCJKFont.SetProprRel( nEscProp );
rFont.SetEscapement( nEsc );
rCJKFont.SetEscapement( nEsc );
m_aPreviewWin.Invalidate();
}
......@@ -2413,7 +2535,9 @@ IMPL_LINK( SvxCharPositionPage, KerningModifyHdl_Impl, MetricField*, EMPTYARG )
nKern *= -1;
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
rFont.SetFixKerning( (short)nKern );
rCJKFont.SetFixKerning( (short)nKern );
m_aPreviewWin.Invalidate();
return 0;
}
......@@ -2457,6 +2581,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
BOOL bInReset = FALSE; //!!!!
SfxItemState eState = bInReset ? SFX_ITEM_DEFAULT : SFX_ITEM_SET;
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
// Font
USHORT nWhich = GetWhich( SID_ATTR_CHAR_FONT );
......@@ -2470,6 +2595,16 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
rFont.SetCharSet( pFontItem->GetCharSet() );
rFont.SetStyleName( pFontItem->GetStyleName() );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
{
pFontItem = (const SvxFontItem*)&rSet.Get( nWhich );
rCJKFont.SetFamily( pFontItem->GetFamily() );
rCJKFont.SetName( pFontItem->GetFamilyName() );
rCJKFont.SetPitch( pFontItem->GetPitch() );
rCJKFont.SetCharSet( pFontItem->GetCharSet() );
rCJKFont.SetStyleName( pFontItem->GetStyleName() );
}
// Style
nWhich = GetWhich( SID_ATTR_CHAR_POSTURE );
......@@ -2478,12 +2613,24 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
rFont.SetItalic( (FontItalic)rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE );
if ( rSet.GetItemState( nWhich ) >= eState )
{
const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
rCJKFont.SetItalic( (FontItalic)rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
rFont.SetWeight( (FontWeight)rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
rCJKFont.SetWeight( (FontWeight)rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
// Size
nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT );
......@@ -2500,6 +2647,19 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
else
// as default 12pt
rFont.SetSize( Size( 0, 240 ) );
nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
MapUnit eUnit = (MapUnit)rSet.GetPool()->GetMetric( nWhich );
SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
Size aSize( rCJKFont.GetSize() );
long nH = LogicToLogic( rItem.GetHeight(), eUnit, MAP_TWIP );
aSize.Height() = nH;
aSize.Width() = 0;
rCJKFont.SetSize( aSize );
}
else
rCJKFont.SetSize( Size( 0, 240 ) );
// Color
nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
......@@ -2508,6 +2668,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
Color aCol( rItem.GetValue() );
rFont.SetColor( COL_AUTO == aCol.GetColor() ? Color(COL_BLACK) : aCol);
rCJKFont.SetColor( COL_AUTO == aCol.GetColor() ? Color(COL_BLACK) : aCol);
}
// Underline
......@@ -2517,10 +2678,14 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
rFont.SetUnderline( eUnderline );
rCJKFont.SetUnderline( eUnderline );
m_aPreviewWin.SetTextLineColor( rItem.GetColor() );
}
else
{
rFont.SetUnderline( UNDERLINE_NONE );
rCJKFont.SetUnderline( UNDERLINE_NONE );
}
// Strikeout
nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
......@@ -2529,9 +2694,13 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
rFont.SetStrikeout( eStrikeout );
rCJKFont.SetStrikeout( eStrikeout );
}
else
{
rFont.SetStrikeout( STRIKEOUT_NONE );
rCJKFont.SetStrikeout( STRIKEOUT_NONE );
}
// WordLineMode
nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
......@@ -2539,6 +2708,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
rFont.SetWordLineMode( rItem.GetValue() );
rCJKFont.SetWordLineMode( rItem.GetValue() );
}
// Emphasis
......@@ -2548,6 +2718,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
FontEmphasisMark eMark = rItem.GetEmphasisMark();
rFont.SetEmphasisMark( eMark );
rCJKFont.SetEmphasisMark( eMark );
}
// Relief
nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
......@@ -2555,6 +2726,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich );
rFont.SetRelief( (FontRelief)rItem.GetValue() );
rCJKFont.SetRelief( (FontRelief)rItem.GetValue() );
}
// Effects
......@@ -2565,6 +2737,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich );
SvxCaseMap eCaseMap = (SvxCaseMap)rItem.GetValue();
rFont.SetCaseMap( eCaseMap );
rCJKFont.SetCaseMap( eCaseMap );
}
// Outline
......@@ -2573,6 +2746,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich );
rFont.SetOutline( rItem.GetValue() );
rCJKFont.SetOutline( rItem.GetValue() );
}
// Shadow
......@@ -2581,6 +2755,7 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich );
rFont.SetShadow( rItem.GetValue() );
rCJKFont.SetShadow( rItem.GetValue() );
}
nWhich = GetWhich(m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR);
......@@ -2589,10 +2764,15 @@ void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
const SvxBrushItem& rBrush = (const SvxBrushItem&)( rSet.Get( nWhich ) );
const Color& rColor = rBrush.GetColor();
rFont.SetFillColor(rColor);
rCJKFont.SetFillColor(rColor);
rFont.SetTransparent(rColor.GetTransparency() > 0);
rCJKFont.SetTransparent(rColor.GetTransparency() > 0);
}
else
{
rFont.SetTransparent(TRUE);
rCJKFont.SetTransparent(TRUE);
}
if(!m_bPreviewBackgroundToCharacter)
{
......@@ -2663,6 +2843,7 @@ void SvxCharPositionPage::Reset( const SfxItemSet& rSet )
m_aFontSizeEdit.Disable();
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
USHORT nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
......@@ -2728,6 +2909,9 @@ void SvxCharPositionPage::Reset( const SfxItemSet& rSet )
rFont.SetPropr( nProp );
rFont.SetProprRel( nEscProp );
rFont.SetEscapement( nEsc );
rCJKFont.SetPropr( nProp );
rCJKFont.SetProprRel( nEscProp );
rCJKFont.SetEscapement( nEsc );
// Kerning
nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
......@@ -2744,6 +2928,7 @@ void SvxCharPositionPage::Reset( const SfxItemSet& rSet )
// Kerning am Font setzen, vorher in Twips umrechnen
long nKern = LogicToLogic( rItem.GetValue(), (MapUnit)eUnit, MAP_TWIP );
rFont.SetFixKerning( (short)nKern );
rCJKFont.SetFixKerning( (short)nKern );
if ( nKerning > 0 )
{
......@@ -3082,7 +3267,9 @@ void SvxCharTwoLinesPage::Initialize()
m_aEndBracketLB.SetSelectHdl( aLink );
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
rFont.SetSize( Size( 0, 220 ) );
rCJKFont.SetSize( Size( 0, 220 ) );
}
// -----------------------------------------------------------------------
......@@ -3161,6 +3348,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
BOOL bInReset = FALSE; //!!!!
SfxItemState eState = bInReset ? SFX_ITEM_DEFAULT : SFX_ITEM_SET;
SvxFont& rFont = m_aPreviewWin.GetFont();
SvxFont& rCJKFont = m_aPreviewWin.GetCJKFont();
// Font
USHORT nWhich = GetWhich( SID_ATTR_CHAR_FONT );
......@@ -3174,6 +3362,16 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
rFont.SetCharSet( pFontItem->GetCharSet() );
rFont.SetStyleName( pFontItem->GetStyleName() );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
{
pFontItem = (const SvxFontItem*)&rSet.Get( nWhich );
rCJKFont.SetFamily( pFontItem->GetFamily() );
rCJKFont.SetName( pFontItem->GetFamilyName() );
rCJKFont.SetPitch( pFontItem->GetPitch() );
rCJKFont.SetCharSet( pFontItem->GetCharSet() );
rCJKFont.SetStyleName( pFontItem->GetStyleName() );
}
// Style
nWhich = GetWhich( SID_ATTR_CHAR_POSTURE );
......@@ -3182,12 +3380,25 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
rFont.SetItalic( (FontItalic)rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE );
if ( rSet.GetItemState( nWhich ) >= eState )
{
const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
rCJKFont.SetItalic( (FontItalic)rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
rFont.SetWeight( (FontWeight)rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
rCJKFont.SetWeight( (FontWeight)rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
// Size
nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT );
......@@ -3204,6 +3415,19 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
else
// as default 12pt
rFont.SetSize( Size( 0, 240 ) );
nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT );
if ( rSet.GetItemState( nWhich ) >= eState )
{
MapUnit eUnit = (MapUnit)rSet.GetPool()->GetMetric( nWhich );
SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
Size aSize( rFont.GetSize() );
long nH = LogicToLogic( rItem.GetHeight(), eUnit, MAP_TWIP );
aSize.Height() = nH;
aSize.Width() = 0;
rCJKFont.SetSize( aSize );
}
else
rCJKFont.SetSize( Size( 0, 240 ) );
// Color
nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
......@@ -3212,6 +3436,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
Color aCol( rItem.GetValue() );
rFont.SetColor( COL_AUTO == aCol.GetColor() ? Color(COL_BLACK) : aCol);
rCJKFont.SetColor( COL_AUTO == aCol.GetColor() ? Color(COL_BLACK) : aCol);
}
// Underline
......@@ -3221,10 +3446,14 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
rFont.SetUnderline( eUnderline );
rCJKFont.SetUnderline( eUnderline );
m_aPreviewWin.SetTextLineColor( rItem.GetColor() );
}
else
{
rFont.SetUnderline( UNDERLINE_NONE );
rCJKFont.SetUnderline( UNDERLINE_NONE );
}
// Strikeout
nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
......@@ -3233,9 +3462,13 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
rFont.SetStrikeout( eStrikeout );
rCJKFont.SetStrikeout( eStrikeout );
}
else
{
rFont.SetStrikeout( STRIKEOUT_NONE );
rCJKFont.SetStrikeout( STRIKEOUT_NONE );
}
// WordLineMode
nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
......@@ -3243,6 +3476,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
rFont.SetWordLineMode( rItem.GetValue() );
rCJKFont.SetWordLineMode( rItem.GetValue() );
}
// Emphasis
......@@ -3252,6 +3486,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
FontEmphasisMark eMark = rItem.GetEmphasisMark();
rFont.SetEmphasisMark( eMark );
rCJKFont.SetEmphasisMark( eMark );
}
// Relief
......@@ -3260,6 +3495,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich );
rFont.SetRelief( (FontRelief)rItem.GetValue() );
rCJKFont.SetRelief( (FontRelief)rItem.GetValue() );
}
// Effects
......@@ -3270,6 +3506,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich );
SvxCaseMap eCaseMap = (SvxCaseMap)rItem.GetValue();
rFont.SetCaseMap( eCaseMap );
rCJKFont.SetCaseMap( eCaseMap );
}
// Outline
......@@ -3278,6 +3515,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich );
rFont.SetOutline( rItem.GetValue() );
rCJKFont.SetOutline( rItem.GetValue() );
}
// Shadow
......@@ -3286,6 +3524,7 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
{
const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich );
rFont.SetShadow( rItem.GetValue() );
rCJKFont.SetShadow( rItem.GetValue() );
}
nWhich = GetWhich(m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR);
if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
......@@ -3293,10 +3532,15 @@ void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
const SvxBrushItem& rBrush = (const SvxBrushItem&)( rSet.Get( nWhich ) );
const Color& rColor = rBrush.GetColor();
rFont.SetFillColor(rColor);
rCJKFont.SetFillColor(rColor);
rFont.SetTransparent(rColor.GetTransparency() > 0);
rCJKFont.SetTransparent(rColor.GetTransparency() > 0);
}
else
{
rFont.SetTransparent(TRUE);
rCJKFont.SetTransparent(TRUE);
}
if(!m_bPreviewBackgroundToCharacter)
{
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: fntctrl.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: os $ $Date: 2001-07-10 11:22:24 $
* last change: $Author: ama $ $Date: 2001-07-19 07:42:36 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -73,32 +73,265 @@
#ifndef _SV_SVAPP_HXX //autogen
#include <vcl/svapp.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include <com/sun/star/uno/Reference.h>
#endif
#ifndef _COM_SUN_STAR_I18N_XBREAKITERATOR_HPP_
#include <com/sun/star/i18n/XBreakIterator.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
#include <com/sun/star/i18n/ScriptType.hdl>
#endif
#ifndef _SVSTDARR_HXX
#define _SVSTDARR_USHORTS
#define _SVSTDARR_ULONGS
#define _SVSTDARR_XUB_STRLEN
#include <svtools/svstdarr.hxx>
#endif
#pragma hdrstop
#include "fntctrl.hxx"
#include "dialogs.hrc"
// struct FontPrevWin_Impl -----------------------------------------------
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::i18n;
// class FontPrevWin_Impl -----------------------------------------------
struct FontPrevWin_Impl
class FontPrevWin_Impl
{
BOOL bSelection : 1,
bGetSelection : 1,
bUseResText : 1;
friend class SvxFontPrevWindow;
Reference < XBreakIterator > xBreak;
SvULongs aTextWidth;
SvXub_StrLens aScriptChg;
SvUShorts aScriptType;
SvxFont aCJKFont;
String aText;
String aScriptText;
Color* pColor;
Color* pBackColor;
String aText;
BOOL bTwoLines;
long nAscent;
sal_Unicode cStartBracket;
sal_Unicode cEndBracket;
BOOL bSelection : 1,
bGetSelection : 1,
bUseResText : 1,
bTwoLines : 1;
void _CheckScript();
public:
FontPrevWin_Impl() :
bSelection( FALSE ), bGetSelection( FALSE ), bUseResText( FALSE ), pColor( NULL ),
pBackColor( 0 ),
bTwoLines(FALSE), cStartBracket(0), cEndBracket(0) {}
cStartBracket(0), cEndBracket(0), pColor( NULL ), pBackColor( 0 ),
bSelection( FALSE ), bGetSelection( FALSE ), bUseResText( FALSE ),
bTwoLines( FALSE ) {}
void CheckScript() { if( aText != aScriptText ) _CheckScript(); }
Size CalcTextSize( OutputDevice* pWin, OutputDevice* pPrt, SvxFont &rFont );
void DrawPrev( OutputDevice* pWin, Printer* pPrt, Point &rPt,
SvxFont &rFont );
};
// class FontPrevWin_Impl -----------------------------------------------
/*-----------------19.7.2001 08:44------------------
* void FontPrevWin_Impl::_CheckScript()
* evalutates the scripttypes of the actual string.
* Afterwards the positions of script change are notified in aScriptChg,
* the scripttypes in aScriptType.
* The aTextWidth array will be filled with zero.
* --------------------------------------------------*/
void FontPrevWin_Impl::_CheckScript()
{
aScriptText = aText;
USHORT nCnt = aScriptChg.Count();
if( nCnt )
{
aScriptChg.Remove( 0, nCnt );
aScriptType.Remove( 0, nCnt );
aTextWidth.Remove( 0, nCnt );
nCnt = 0;
}
if( !xBreak.is() )
{
Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
Reference < XInterface > xI = xMSF->createInstance(
::rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) );
if ( xI.is() )
{
Any x = xI->queryInterface( ::getCppuType((const Reference< XBreakIterator >*)0) );
x >>= xBreak;
}
}
if( xBreak.is() )
{
USHORT nScript = xBreak->getScriptType( aText, 0 );
USHORT nChg = 0;
if( ScriptType::WEAK == nScript )
{
nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript );
if( nChg < aText.Len() )
nScript = xBreak->getScriptType( aText, nChg );
else
nScript = ScriptType::LATIN;
}
do
{
nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript );
aScriptChg.Insert( nChg, nCnt );
aScriptType.Insert( nScript, nCnt );
aTextWidth.Insert( ULONG(0), nCnt++ );
if( nChg < aText.Len() )
nScript = xBreak->getScriptType( aText, nChg );
else
break;
} while( TRUE );
}
}
/*-----------------19.7.2001 08:48------------------
* Size FontPrevWin_Impl::CalcTextSize(..)
* fills the aTextWidth array with the text width of every part
* of the actual string without a script change inside.
* For Latin parts the given rFont will be used,
* for Asian parts the aCJKFont.
* The returned size contains the whole string.
* The member nAscent is calculated to the maximal ascent of all used fonts.
* --------------------------------------------------*/
Size FontPrevWin_Impl::CalcTextSize( OutputDevice* pWin, OutputDevice* pPrinter,
SvxFont &rFont )
{
USHORT nScript;
USHORT nIdx = 0;
xub_StrLen nStart = 0;
xub_StrLen nEnd;
USHORT nCnt = aScriptChg.Count();
if( nCnt )
{
nEnd = aScriptChg[ nIdx ];
nScript = aScriptType[ nIdx ];
}
else
{
nEnd = aText.Len();
nScript = ScriptType::LATIN;
}
long nTxtWidth = 0;
long nCJKHeight = 0;
long nHeight = 0;
nAscent = 0;
long nCJKAscent = 0;
do
{
SvxFont& rFnt = (nScript==ScriptType::ASIAN) ? aCJKFont : rFont;
ULONG nWidth = rFnt.GetTxtSize( pPrinter, aText, nStart, nEnd-nStart ).
Width();
aTextWidth[ nIdx++ ] = nWidth;
nTxtWidth += nWidth;
if( nScript==ScriptType::ASIAN )
{
if( !nCJKHeight )
{
pWin->SetFont( aCJKFont );
FontMetric aMetric( pWin->GetFontMetric() );
nCJKHeight = aMetric.GetLineHeight();
nCJKAscent = aMetric.GetAscent();
}
}
else
{
if( !nHeight )
{
pWin->SetFont( rFont );
FontMetric aMetric( pWin->GetFontMetric() );
nHeight = aMetric.GetLineHeight();
nAscent = aMetric.GetAscent();
}
}
if( nEnd < aText.Len() && nIdx < nCnt )
{
nStart = nEnd;
nEnd = aScriptChg[ nIdx ];
nScript = aScriptType[ nIdx ];
}
else
break;
}
while( TRUE );
nHeight -= nAscent;
nCJKHeight -= nCJKAscent;
if( nHeight < nCJKHeight )
nHeight = nCJKHeight;
if( nAscent < nCJKAscent )
nAscent = nCJKAscent;
nHeight += nAscent;
Size aTxtSize( nTxtWidth, nHeight );
return aTxtSize;
}
/*-----------------19.7.2001 08:54------------------
* void FontPrevWin_Impl::DrawPrev(..)
* calls SvxFont::DrawPrev(..) for every part of the string without a script
* change inside, for Asian parts the aCJKFont will be used, otherwise the
* given rFont.
* --------------------------------------------------*/
void FontPrevWin_Impl::DrawPrev( OutputDevice* pWin, Printer* pPrinter,
Point &rPt, SvxFont &rFont )
{
Font aOldFont = pPrinter->GetFont();
USHORT nScript;
USHORT nIdx = 0;
xub_StrLen nStart = 0;
xub_StrLen nEnd;
USHORT nCnt = aScriptChg.Count();
if( nCnt )
{
nEnd = aScriptChg[ nIdx ];
nScript = aScriptType[ nIdx ];
}
else
{
nEnd = aText.Len();
nScript = ScriptType::LATIN;
}
do
{
SvxFont& rFnt = (nScript==ScriptType::ASIAN) ? aCJKFont : rFont;
pPrinter->SetFont( rFnt );
rFnt.DrawPrev( pWin, pPrinter, rPt, aText, nStart, nEnd - nStart );
rPt.X() += aTextWidth[ nIdx++ ];
if( nEnd < aText.Len() && nIdx < nCnt )
{
nStart = nEnd;
nEnd = aScriptChg[ nIdx ];
nScript = aScriptType[ nIdx ];
}
else
break;
}
while( TRUE );
pPrinter->SetFont( aOldFont );
}
// class SvxFontPrevWindow -----------------------------------------------
void SvxFontPrevWindow::InitSettings( BOOL bForeground, BOOL bBackground )
......@@ -145,7 +378,9 @@ SvxFontPrevWindow::SvxFontPrevWindow( Window* pParent, const ResId& rId ) :
}
SetMapMode( MapMode( MAP_TWIP ) );
aFont.SetTransparent(TRUE);
pImpl->aCJKFont.SetTransparent(TRUE);
aFont.SetAlign(ALIGN_BASELINE);
pImpl->aCJKFont.SetAlign(ALIGN_BASELINE);
InitSettings( TRUE, TRUE );
SetBorderStyle( WINDOW_BORDER_MONO );
}
......@@ -164,6 +399,13 @@ SvxFontPrevWindow::~SvxFontPrevWindow()
// -----------------------------------------------------------------------
SvxFont& SvxFontPrevWindow::GetCJKFont()
{
return pImpl->aCJKFont;
}
// -----------------------------------------------------------------------
void SvxFontPrevWindow::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
......@@ -245,20 +487,17 @@ void SvxFontPrevWindow::Paint( const Rectangle& rRect )
if ( pImpl->aText.Len() > 15 )
pImpl->aText.Erase( pImpl->aText.Search( sal_Unicode( ' ' ), 16 ) );
}
Window::SetFont(aFont);
Font aOldFont = pPrinter->GetFont();
pPrinter->SetFont( aFont );
Size aTxtSize( aFont.GetTxtSize( pPrinter, pImpl->aText ) );
pPrinter->SetFont( aOldFont );
pImpl->CheckScript();
Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, aFont );
const Size aLogSize( GetOutputSize() );
FontMetric aMetric(GetFontMetric());
aTxtSize.Height() = aMetric.GetLineHeight();
long nX = aLogSize.Width() / 2 - aTxtSize.Width() / 2;
long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2;
if ( nY + aMetric.GetAscent() > aLogSize.Height() )
nY = aLogSize.Height() - aMetric.GetAscent();
if ( nY + pImpl->nAscent > aLogSize.Height() )
nY = aLogSize.Height() - pImpl->nAscent;
if ( pImpl->pBackColor )
{
......@@ -283,13 +522,23 @@ void SvxFontPrevWindow::Paint( const Rectangle& rRect )
SetFillColor( aFillCol );
}
long nStdAscent = aMetric.GetAscent();
long nStdAscent = pImpl->nAscent;
nY += nStdAscent;
if(pImpl->bTwoLines)
{
SvxFont aSmallFont(aFont);
aSmallFont.SetHeight(aSmallFont.GetHeight() * 60 / 100);
Size aSize( aSmallFont.GetSize() );
aSize.Height() = ( aSize.Height() * 3 ) / 5;
aSize.Width() = ( aSize.Width() * 3 ) / 5;
aSmallFont.SetSize( aSize );
aSize = pImpl->aCJKFont.GetSize();
{
Size aTmpSize;
aTmpSize.Height() = ( aSize.Height() * 3 ) / 5;
aTmpSize.Width() = ( aSize.Width() * 3 ) / 5;
pImpl->aCJKFont.SetSize( aTmpSize );
}
long nStartBracketWidth = 0;
long nEndBracketWidth = 0;
......@@ -304,7 +553,7 @@ void SvxFontPrevWindow::Paint( const Rectangle& rRect )
String sBracket(pImpl->cEndBracket);
nEndBracketWidth = aFont.GetTxtSize( pPrinter, sBracket ).Width();
}
nTextWidth = aSmallFont.GetTxtSize( pPrinter, pImpl->aText ).Width();
nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width();
long nResultWidth = nStartBracketWidth;
nResultWidth += nEndBracketWidth;
nResultWidth += nTextWidth;
......@@ -313,9 +562,7 @@ void SvxFontPrevWindow::Paint( const Rectangle& rRect )
DrawLine( Point( 0, nY ), Point( nX, nY ) );
DrawLine( Point( nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) );
Window::SetFont(aSmallFont);
FontMetric aSmallMetric(GetFontMetric());
long nSmallAscent = aSmallMetric.GetAscent();
long nSmallAscent = pImpl->nAscent;
long nOffset = (nStdAscent - nSmallAscent ) / 2;
if(pImpl->cStartBracket)
......@@ -325,24 +572,22 @@ void SvxFontPrevWindow::Paint( const Rectangle& rRect )
nX += nStartBracketWidth;
}
Window::SetFont(aFont);
aSmallFont.DrawPrev( this, pPrinter, Point( nX, nY - nSmallAscent - 2 ), pImpl->aText );
aSmallFont.DrawPrev( this, pPrinter, Point( nX, nY ), pImpl->aText );
pImpl->DrawPrev( this, pPrinter, Point( nX, nY - nSmallAscent - 2 ), aSmallFont );
pImpl->DrawPrev( this, pPrinter, Point( nX, nY ), aSmallFont );
nX += nTextWidth;
Window::SetFont(aFont);
if(pImpl->cEndBracket)
{
String sBracket(pImpl->cEndBracket);
aFont.DrawPrev( this, pPrinter, Point( nX + 1, nY - nOffset - 4), sBracket );
}
pImpl->aCJKFont.SetSize( aSize );
}
else
{
DrawLine( Point( 0, nY ), Point( nX, nY ) );
DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) );
aFont.DrawPrev( this, pPrinter, Point( nX, nY ), pImpl->aText );
pImpl->DrawPrev( this, pPrinter, Point( nX, nY ), aFont );
}
}
/* -----------------------------04.12.00 16:26--------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment