summaryrefslogtreecommitdiff
path: root/editeng/source
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2020-02-17 20:20:31 +0300
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-03-03 16:20:03 +0100
commit2940d1905b921d9909b08b1e32014d3c44474ef0 (patch)
tree370d048aa01a44c5a900e751b818eceb9acdc84b /editeng/source
parentb9a124aae67cbd64917f07f2dca6603f149c018b (diff)
tdf#80194 editeng: fix auto subscript calculations
...and auto superscript too (although not as noticably). THIS WILL CHANGE THE POSITION OF EDITENG SUBSCRIPTS AND SUPERSCRIPTS IN EXISTING DOCUMENTS! That is because they were very poorly placed before - using a formula that is very different from how Writer does it. Everyone in the bug reports indicates that Writer does it good, but Impress does it really bad. (tdf#89849, tdf#63083) FOR EXAMPLE, when the char-size is reduced to the default OF 58%, it will now be raised by 33%, not 42%. Likewise, the subscript will now be lowered by 8%, not 42%. THIS AFFECTS/FIXES Writer textboxes, Calc, Draw/Impress. "Automatic" indicates that there is not a "correct" answer, but that the computer should make it "look good", so the user should be able to accept this change in positioning, as long as it looks good. The number of documents affected might be less than one would expect. By default .uno:SuperScript does NOT set auto mode (although Format-Character does). Since most people would use the toolbar instead of the format menu to create a superscript, auto will be rare. So there will be relatively few cases where subscripts are automatic in editeng, especially since it looks so poor that most people probably turned automatic off... This patch has no effect on non-automatic escapement. It uses the same fomula that calculated DFLT_ESC_SUB (since it isn't an arbitrarily chosen value). This is an approximation of the formula that Writer uses (since Writer does exact calculations based on each font's metrics). This Writer-inspired formula was introduced in LO 6.4 for more accurate exporting to MSO word processing formats (tdf#127316). Change-Id: I0267810efe31a2b3be41bf2d39e2278ce9bc99e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88911 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'editeng/source')
-rw-r--r--editeng/source/editeng/editattr.cxx4
-rw-r--r--editeng/source/editeng/editdoc.cxx4
-rw-r--r--editeng/source/editeng/impedit4.cxx4
3 files changed, 6 insertions, 6 deletions
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index f000cf793560..a99e4d496f74 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -273,9 +273,9 @@ void EditCharAttribEscapement::SetFont( SvxFont& rFont, OutputDevice* )
short nEsc = static_cast<const SvxEscapementItem*>(GetItem())->GetEsc();
if ( nEsc == DFLT_ESC_AUTO_SUPER )
- nEsc = 100 - nProp;
+ nEsc = .8 * (100 - nProp);
else if ( nEsc == DFLT_ESC_AUTO_SUB )
- nEsc = sal::static_int_cast< short >( -( 100 - nProp ) );
+ nEsc = .2 * -(100 - nProp);
rFont.SetEscapement( nEsc );
}
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index f3f55edf60c1..42fc1f3cc22c 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2008,9 +2008,9 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent, S
short nEsc = rEsc.GetEsc();
if ( nEsc == DFLT_ESC_AUTO_SUPER )
- nEsc = 100 - nProp;
+ nEsc = .8 * (100 - nProp);
else if ( nEsc == DFLT_ESC_AUTO_SUB )
- nEsc = sal::static_int_cast< short >( -( 100 - nProp ) );
+ nEsc = .2 * -(100 - nProp);
rFont.SetEscapement( nEsc );
}
if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_PAIRKERNING ) == SfxItemState::SET ) )
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 67e924653618..25d7ecc0aa8a 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -930,12 +930,12 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput,
short nEsc = static_cast<const SvxEscapementItem&>(rItem).GetEsc();
if ( nEsc == DFLT_ESC_AUTO_SUPER )
{
- nEsc = 100 - nProp;
+ nEsc = .8 * (100 - nProp);
nProp100++; // A 1 afterwards means 'automatic'.
}
else if ( nEsc == DFLT_ESC_AUTO_SUB )
{
- nEsc = sal::static_int_cast< short >( -( 100 - nProp ) );
+ nEsc = .2 * -(100 - nProp);
nProp100++;
}
// SWG: