[Libreoffice-commits] core.git: filter/source include/tools sd/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Thu May 14 07:59:48 UTC 2020


 filter/source/msfilter/svdfppt.cxx |    9 +++------
 include/tools/UnitConversion.hxx   |    6 ++++++
 sd/source/filter/eppt/epptso.cxx   |    7 +++----
 3 files changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 9c4048b1883f1dc9fdd621ffa2bb06ff9fe19d14
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue May 12 12:47:31 2020 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Thu May 14 09:59:11 2020 +0200

    tdf#79082 Improve ppt tab import/export
    
    Import/export the paragraph tabs without any text offset,
    tabs are relative to the text box anyway.
    
    Change-Id: Ife3b762e7581548e65500c16259a4481cc07a88f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94101
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index f36872724d3c..9734c6d3464f 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -6288,13 +6288,11 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  std::optional< sal_Int16 >& rS
     sal_uInt32 nLatestManTab = 0;
     GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs2, nDestinationInstance );
     GetAttrib( PPT_ParaAttr_BulletOfs, nTab, nDestinationInstance );
-    GetAttrib( PPT_ParaAttr_BulletOn, i, nDestinationInstance );
     GetAttrib( PPT_ParaAttr_DefaultTab, nDefaultTab, nDestinationInstance );
+
     SvxTabStopItem aTabItem( 0, 0, SvxTabAdjust::Default, EE_PARA_TABS );
     if ( GetTabCount() )
     {
-        //paragraph offset = MIN(first_line_offset, hanging_offset)
-        sal_uInt32 nParaOffset = std::min(nTextOfs2, nTab);
         for ( i = 0; i < GetTabCount(); i++ )
         {
             SvxTabAdjust eTabAdjust;
@@ -6306,8 +6304,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  std::optional< sal_Int16 >& rS
                 case 3 :    eTabAdjust = SvxTabAdjust::Decimal; break;
                 default :   eTabAdjust = SvxTabAdjust::Left;
             }
-            if ( nTab > nParaOffset )//If tab stop greater than paragraph offset
-                aTabItem.Insert( SvxTabStop( ( ( (long( nTab - nTextOfs2 )) * 2540 ) / 576 ), eTabAdjust ) );
+            aTabItem.Insert(SvxTabStop(convertMasterUnitToTwip(nTab), eTabAdjust));
         }
         nLatestManTab = nTab;
     }
@@ -6320,7 +6317,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  std::optional< sal_Int16 >& rS
         nTab = nDefaultTab * ( 1 + nTab );
         for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ )
         {
-            aTabItem.Insert( SvxTabStop( static_cast<sal_uInt16>( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ) ) );
+            aTabItem.Insert( SvxTabStop( convertMasterUnitToTwip(nTab)));
             nTab += nDefaultTab;
         }
     }
diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx
index 8ad489dee590..e59077d8a5fa 100644
--- a/include/tools/UnitConversion.hxx
+++ b/include/tools/UnitConversion.hxx
@@ -22,4 +22,10 @@ constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
     return (n >= 0) ? (n * 72 + 63) / 127 : (n * 72 - 63) / 127;
 }
 
+// Convert PPT's "master unit" (1/576 inch) to twips
+constexpr sal_Int64 convertMasterUnitToTwip(sal_Int64 n) { return n * 2540.0 / 576.0; }
+
+// Convert twips to PPT's "master unit"
+constexpr sal_Int64 convertTwipToMasterUnit(sal_Int64 n) { return n / (2540.0 / 576.0); }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 51403da517cd..2b26b9602eb4 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -1171,7 +1171,6 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u
         pPara = aTextObj.GetParagraph(0);
         sal_uInt32  nParaFlags = 0x1f;
         sal_Int16   nMask, nNumberingRule[ 10 ];
-        const sal_uInt32  nTextOfs = pPara->nTextOfs;
         const sal_uInt32  nTabs = pPara->maTabStop.getLength();
         const auto& rTabStops = pPara->maTabStop;
 
@@ -1210,7 +1209,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u
         const sal_uInt32 nDefaultTabSize = MapSize( awt::Size( nDefaultTabSizeSrc, 1 ) ).Width;
         sal_uInt32  nDefaultTabs = std::abs( maRect.GetWidth() ) / nDefaultTabSize;
         if ( nTabs )
-            nDefaultTabs -= static_cast<sal_Int32>( ( ( rTabStops[ nTabs - 1 ].Position / 4.40972 ) + nTextOfs ) / nDefaultTabSize );
+            nDefaultTabs -= static_cast<sal_Int32>( convertTwipToMasterUnit(rTabStops[ nTabs - 1 ].Position) / nDefaultTabSize );
         if ( static_cast<sal_Int32>(nDefaultTabs) < 0 )
             nDefaultTabs = 0;
 
@@ -1239,7 +1238,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u
                 pRuleOut->WriteUInt16( nTabCount );
                 for ( const css::style::TabStop& rTabStop : rTabStops )
                 {
-                    sal_uInt16 nPosition = static_cast<sal_uInt16>( ( rTabStop.Position / 4.40972 ) + nTextOfs );
+                    sal_uInt16 nPosition = static_cast<sal_uInt16>( convertTwipToMasterUnit(rTabStop.Position) );
                     sal_uInt16 nType;
                     switch ( rTabStop.Alignment )
                     {
@@ -1256,7 +1255,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u
 
                 sal_uInt32 nWidth = 1;
                 if ( nTabs )
-                    nWidth += static_cast<sal_Int32>( ( rTabStops[ nTabs - 1 ].Position / 4.40972 + nTextOfs ) / nDefaultTabSize );
+                    nWidth += static_cast<sal_Int32>( convertTwipToMasterUnit(rTabStops[ nTabs - 1 ].Position) / nDefaultTabSize );
                 nWidth *= nDefaultTabSize;
                 for ( i = 0; i < nDefaultTabs; i++, nWidth += nDefaultTabSize )
                     pRuleOut->WriteUInt32( nWidth );


More information about the Libreoffice-commits mailing list