Kaydet (Commit) 7c97a22a authored tarafından Mark Hung's avatar Mark Hung

tdf#35301 Modify Asian phonetic guide dialog.

* Add a new ruby position option "Right" in the Asian phonetic
guide dialog.
* Allow set/get RubyPosition property via XRubySelection interface.

Change-Id: I306450ad32f0eff71f284c85e78497a341bc7971
Reviewed-on: https://gerrit.libreoffice.org/48209Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst bc13ad8d
......@@ -62,7 +62,7 @@ namespace
static const sal_Char cRubyBaseText[] = "RubyBaseText";
static const sal_Char cRubyText[] = "RubyText";
static const sal_Char cRubyAdjust[] = "RubyAdjust";
static const sal_Char cRubyIsAbove[] = "RubyIsAbove";
static const sal_Char cRubyPosition[] = "RubyPosition";
static const sal_Char cRubyCharStyleName[] = "RubyCharStyleName";
} // end anonymous namespace
......@@ -195,7 +195,7 @@ void SvxRubyData_Impl::AssertOneEntry()
pValues[0].Name = cRubyBaseText;
pValues[1].Name = cRubyText;
pValues[2].Name = cRubyAdjust;
pValues[3].Name = cRubyIsAbove;
pValues[3].Name = cRubyPosition;
pValues[4].Name = cRubyCharStyleName;
}
}
......@@ -476,12 +476,13 @@ void SvxRubyDialog::Update()
else if(nAdjust != nTmp)
nAdjust = -2;
}
if (nPosition > -2 && pProps[nProp].Name == cRubyIsAbove)
if (nPosition > -2 && pProps[nProp].Name == cRubyPosition )
{
bool bTmp = *o3tl::doAccess<bool>(pProps[nProp].Value);
sal_Int16 nTmp = sal_Int16();
pProps[nProp].Value >>= nTmp;
if (!nRuby)
nPosition = bTmp ? 0 : 1;
else if ((!nPosition && !bTmp) || (nPosition == 1 && bTmp))
nPosition = nTmp;
else if(nPosition != nTmp)
nPosition = -2;
}
if (bCharStyleEqual && pProps[nProp].Name == cRubyCharStyleName)
......@@ -611,14 +612,14 @@ IMPL_LINK(SvxRubyDialog, AdjustHdl_Impl, ListBox&, rBox, void)
IMPL_LINK(SvxRubyDialog, PositionHdl_Impl, ListBox&, rBox, void)
{
AssertOneEntry();
bool bAbove = !rBox.GetSelectedEntryPos();
sal_Int16 nPosition = rBox.GetSelectedEntryPos();
Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues();
for (PropertyValues & rProps : aRubyValues)
{
for (PropertyValue & propVal : rProps)
{
if (propVal.Name == cRubyIsAbove)
propVal.Value <<= bAbove;
if (propVal.Name == cRubyPosition)
propVal.Value <<= nPosition;
}
SetModified(true);
}
......@@ -810,20 +811,38 @@ void RubyPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectang
bool bRubyStretch = nBaseWidth >= nRubyWidth;
long nCenter = aWinSize.Width() / 2;
long nLeftStart = nCenter - (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
long nRightEnd = nCenter + (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
long nHalfWidth = std::max( nBaseWidth, nRubyWidth ) /2;
long nLeftStart = nCenter - nHalfWidth;
long nRightEnd = nCenter + nHalfWidth;
// Deafult values for TOP or no selection
long nYRuby = aWinSize.Height() / 4 - nTextHeight / 2;
long nYBase = aWinSize.Height() * 3 / 4 - nTextHeight / 2;
//use above also if no selection is set
bool bAbove = m_pParentDlg->m_pPositionLB->GetSelectedEntryPos() != 1;
if (!bAbove)
sal_Int16 nRubyPos = m_pParentDlg->m_pPositionLB->GetSelectedEntryPos();
if ( nRubyPos == 1 ) // BOTTOM
{
long nTmp = nYRuby;
nYRuby = nYBase;
nYBase = nTmp;
}
else if ( nRubyPos == 2 ) // RIGHT ( vertically )
{
// Align the ruby text and base text to the vertical center.
nYBase = ( aWinSize.Height() - nTextHeight ) / 2;
nYRuby = ( aWinSize.Height() - nRubyWidth ) / 2;
// Align the ruby text at the right side of the base text
nAdjust = RubyAdjust_RIGHT;
nHalfWidth = nBaseWidth / 2;
nLeftStart = nCenter - nHalfWidth;
nRightEnd = nCenter + nHalfWidth + nRubyWidth + nTextHeight;
// Render base text first, then render ruby text on the right.
bRubyStretch = true;
aRubyFont.SetVertical(true);
aRubyFont.SetOrientation(2700);
}
long nYOutput;
long nOutTextWidth;
......
......@@ -351,6 +351,7 @@
<items>
<item translatable="yes" context="asianphoneticguidedialog|positionlb">Top</item>
<item translatable="yes" context="asianphoneticguidedialog|positionlb">Bottom</item>
<item translatable="yes" context="asianphoneticguidedialog|positionlb">Right</item>
</items>
</object>
<packing>
......
......@@ -561,6 +561,7 @@
#define UNO_NAME_RUBY_ADJUST "RubyAdjust"
#define UNO_NAME_RUBY_CHAR_STYLE_NAME "RubyCharStyleName"
#define UNO_NAME_RUBY_IS_ABOVE "RubyIsAbove"
#define UNO_NAME_RUBY_POSITION "RubyPosition"
#define UNO_NAME_FOOTNOTE_HEIGHT "FootnoteHeight"
#define UNO_NAME_FOOTNOTE_LINE_WEIGHT "FootnoteLineWeight"
#define UNO_NAME_FOOTNOTE_LINE_COLOR "FootnoteLineColor"
......
......@@ -533,7 +533,7 @@ Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAuto
const OUString& rEntryText = pEntry->GetText();
const SwFormatRuby& rAttr = pEntry->GetRubyAttr();
pRet[n].realloc(5);
pRet[n].realloc(6);
PropertyValue* pValues = pRet[n].getArray();
pValues[0].Name = UNO_NAME_RUBY_BASE_TEXT;
pValues[0].Value <<= rEntryText;
......@@ -546,6 +546,8 @@ Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAuto
pValues[3].Value <<= static_cast<sal_Int16>(rAttr.GetAdjustment());
pValues[4].Name = UNO_NAME_RUBY_IS_ABOVE;
pValues[4].Value <<= !rAttr.GetPosition();
pValues[5].Name = UNO_NAME_RUBY_POSITION;
pValues[5].Value <<= rAttr.GetPosition();
}
return aRet;
}
......@@ -611,6 +613,12 @@ void SAL_CALL SwXTextView::setRubyList(
*o3tl::doAccess<bool>(pProperties[nProp].Value);
pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
}
else if(pProperties[nProp].Name == UNO_NAME_RUBY_POSITION)
{
sal_Int16 nTmp = 0;
if(pProperties[nProp].Value >>= nTmp)
pEntry->GetRubyAttr().SetPosition( nTmp );
}
}
aList.insert(aList.begin() + nPos, std::move(pEntry));
}
......
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