summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-01-18 08:06:20 +0800
committerMark Hung <marklh9@gmail.com>2018-01-22 13:21:25 +0100
commit7c97a22ac7851329d1a5c71772542c062cd6f4f0 (patch)
treed85664dc1c143f2b5af9abc828ffc870d8316bb2
parentbc13ad8d5f4c530f8ed8174c8e4fcfd06c972457 (diff)
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/48209 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r--svx/source/dialog/rubydialog.cxx47
-rw-r--r--svx/uiconfig/ui/asianphoneticguidedialog.ui1
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/source/uibase/uno/unotxvw.cxx10
4 files changed, 44 insertions, 15 deletions
diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx
index 309a23cc653e..6507fecd9fa2 100644
--- a/svx/source/dialog/rubydialog.cxx
+++ b/svx/source/dialog/rubydialog.cxx
@@ -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;
diff --git a/svx/uiconfig/ui/asianphoneticguidedialog.ui b/svx/uiconfig/ui/asianphoneticguidedialog.ui
index 16a536574a04..3b5c29a60535 100644
--- a/svx/uiconfig/ui/asianphoneticguidedialog.ui
+++ b/svx/uiconfig/ui/asianphoneticguidedialog.ui
@@ -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>
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index ecb8dfbc88a5..cb4e45a131f6 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -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"
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index b4a244499114..88b27cbae3c1 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -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));
}