This commit is contained in:
Green
2025-06-10 14:11:39 +03:00
parent 046b39478a
commit b04f9bda4a
5 changed files with 31 additions and 8 deletions

View File

@ -23,7 +23,6 @@
#include "Transform.h"
#define PARA_SPACING_SCALE 0.85
#define SPACING_SCALE_MS_WORD 1.21
namespace HWP
{

View File

@ -11,6 +11,8 @@ namespace HWP
#define DEFAULT_STYLE_NAME L"Style"
#define DEFAULT_SPACING 240
#define SPACING_SCALE_MS_WORD 1.21
#define ADD_COLOR(r, g, b, enum_value) {{r, g, b}, enum_value}
static const std::vector<std::pair<TColor, EHighlightColors>> s_arHighlightColors
@ -232,6 +234,8 @@ CRunnerStyle CStyleConverter::GenerateRunnerStyle(const CHWPRecordCharShape& oCh
oRunnerStyle.SetAscii(oCharShape.GetFontName(ELang::LATIN));
oRunnerStyle.SetEastAsia(oCharShape.GetFontName(ELang::HANGUL));
oRunnerStyle.SetRatio(oCharShape.GetRatio(ELang::LATIN));
oRunnerStyle.SetSpacing(static_cast<short>((double)oCharShape.GetSpacing(ELang::LATIN) * SPACING_SCALE_MS_WORD));
if (oCharShape.Bold())
oRunnerStyle.SetBold(true);
@ -439,6 +443,12 @@ void CStyleConverter::WriteRunnerProperties(const CRunnerStyle& oRunnerStyle, NS
if (oRunnerStyle.ColorIsSet())
oBuilder.WriteString(L"<w:color w:val=\"" + oRunnerStyle.GetColor().ToHEX() + L"\"/>");
if (oRunnerStyle.RatioIsSet() && 100 != oRunnerStyle.GetRatio())
oBuilder.WriteString(L"<w:w w:val=\"" + std::to_wstring(oRunnerStyle.GetRatio()) + L"\"/>");
if (oRunnerStyle.SpacingIsSet() && 0 != oRunnerStyle.GetSpacing())
oBuilder.WriteString(L"<w:spacing w:val=\"" + std::to_wstring(oRunnerStyle.GetSpacing()) + L"\"/>");
if (oRunnerStyle.UIsSet())
{
oBuilder.WriteString(L"<w:u w:val=\"");
@ -709,9 +719,10 @@ CRunnerStyle& CRunnerStyle::operator-=(const CRunnerStyle& oRunnerStyle)
m_nSz -= oRunnerStyle.m_nSz;
m_oColor -= oRunnerStyle.m_oColor;
m_nShadeColor -= oRunnerStyle.m_nShadeColor;
m_shRatio -= oRunnerStyle.m_shRatio;
m_oU -= oRunnerStyle.m_oU;
m_eStrike -= oRunnerStyle.m_eStrike;
m_nSpacing -= oRunnerStyle.m_nSpacing;
m_shSpacing -= oRunnerStyle.m_shSpacing;
m_oHighlight -= oRunnerStyle.m_oHighlight;
m_eVerticalAlign -= oRunnerStyle.m_eVerticalAlign;
@ -727,9 +738,10 @@ void CRunnerStyle::Clear()
m_nSz.UnSet();
m_oColor.UnSet();
m_nShadeColor.UnSet();
m_shRatio.UnSet();
m_oU.UnSet();
m_eStrike.UnSet();
m_nSpacing.UnSet();
m_shSpacing.UnSet();
m_oHighlight.UnSet();
m_eVerticalAlign.UnSet();
}
@ -737,8 +749,8 @@ void CRunnerStyle::Clear()
bool CRunnerStyle::Empty() const
{
return !m_oRFonts.m_wsAscii.IsSet() && !m_oRFonts.m_wsEastAsia.IsSet() && !m_bBold.IsSet() && !m_bItalic.IsSet() &&
!m_nSz.IsSet() && !m_oColor.IsSet() && !m_nShadeColor.IsSet() && !m_oU.IsSet() && !m_eStrike.IsSet() &&
!m_nSpacing.IsSet() && !m_oHighlight.IsSet() && !m_eVerticalAlign.IsSet();
!m_nSz.IsSet() && !m_oColor.IsSet() && !m_nShadeColor.IsSet() && !m_shRatio.IsSet() && !m_oU.IsSet() &&
!m_eStrike.IsSet() && !m_shSpacing.IsSet() && !m_oHighlight.IsSet() && !m_eVerticalAlign.IsSet();
}
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, std::wstring, Ascii, m_oRFonts.m_wsAscii);
@ -748,9 +760,10 @@ CREATE_BODY_METHODS_FOR_PROPERTY_BOOL(CRunnerStyle, Italic, m_bItalic);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, int, Sz, m_nSz);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, TColor, Color, m_oColor);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, int, ShadeColor, m_nShadeColor)
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, short, Ratio, m_shRatio)
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, TU, U, m_oU);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, EStrikeType, Strike, m_eStrike);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, int, Spacing, m_nSpacing);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, short, Spacing, m_shSpacing);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, EHighlightColors, Highlight, m_oHighlight);
CREATE_BODY_METHODS_FOR_PROPERTY(CRunnerStyle, EVerticalAlignRun, VerticalAlign, m_eVerticalAlign);

View File

@ -190,9 +190,10 @@ public:
CREATE_METHODS_FOR_PROPERTY(int, Sz);
CREATE_METHODS_FOR_PROPERTY(TColor, Color);
CREATE_METHODS_FOR_PROPERTY(int, ShadeColor);
CREATE_METHODS_FOR_PROPERTY(short, Ratio);
CREATE_METHODS_FOR_PROPERTY(TU, U);
CREATE_METHODS_FOR_PROPERTY(EStrikeType, Strike);
CREATE_METHODS_FOR_PROPERTY(int, Spacing);
CREATE_METHODS_FOR_PROPERTY(short, Spacing);
CREATE_METHODS_FOR_PROPERTY(EHighlightColors, Highlight);
CREATE_METHODS_FOR_PROPERTY(EVerticalAlignRun, VerticalAlign);
private:
@ -202,9 +203,10 @@ private:
CProperty<int> m_nSz;
CProperty<TColor> m_oColor;
CProperty<int> m_nShadeColor;
CProperty<short> m_shRatio;
CProperty<TU> m_oU;
CProperty<EStrikeType> m_eStrike;
CProperty<int> m_nSpacing;
CProperty<short> m_shSpacing;
CProperty<EHighlightColors> m_oHighlight;
CProperty<EVerticalAlignRun> m_eVerticalAlign;
};

View File

@ -360,6 +360,14 @@ HWP_STRING CHWPRecordCharShape::GetFontName(ELang eLang) const
return m_arFontNames[(int)eLang];
}
short CHWPRecordCharShape::GetRatio(ELang eLang) const
{
if (ELang::MAX == eLang)
return 0;
return m_arRatios[(int)eLang];
}
short CHWPRecordCharShape::GetSpacing(ELang eLang) const
{
if (ELang::MAX == eLang)

View File

@ -121,6 +121,7 @@ public:
short GetRelSize(ELang eLang) const;
HWP_STRING GetFontName(ELang eLang) const;
short GetRatio(ELang eLang) const;
short GetSpacing(ELang eLang) const;
int GetTextColor() const;
int GetShadeColor() const;