[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - filter/source include/tools sd/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Tue May 19 21:42:38 UTC 2020


 filter/source/msfilter/svdfppt.cxx |   10 ++++------
 include/tools/UnitConversion.hxx   |   19 +++++++++++++++++++
 sd/source/filter/eppt/epptso.cxx   |    8 ++++----
 3 files changed, 27 insertions(+), 10 deletions(-)

New commits:
commit 3aea3d2399983c1c366ca745a9b183435f155f23
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue May 12 12:47:31 2020 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue May 19 23:42:06 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>
    (cherry picked from commit 9c4048b1883f1dc9fdd621ffa2bb06ff9fe19d14)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94429
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index de39c837fe3a..48e96ef5b4ad 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -105,6 +105,7 @@
 #include <svx/sxekitm.hxx>
 #include <editeng/flditem.hxx>
 #include <tools/zcodec.hxx>
+#include <tools/UnitConversion.hxx>
 #include <filter/msfilter/svxmsbas.hxx>
 #include <sfx2/objsh.hxx>
 #include <editeng/brushitem.hxx>
@@ -6316,13 +6317,11 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  boost::optional< sal_Int16 >&
     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;
@@ -6334,8 +6333,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  boost::optional< sal_Int16 >&
                 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;
     }
@@ -6348,7 +6346,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  boost::optional< sal_Int16 >&
         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
new file mode 100644
index 000000000000..3f2a5d870aee
--- /dev/null
+++ b/include/tools/UnitConversion.hxx
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+// 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 952a8275cbe8..14b0fe6f1959 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -29,6 +29,7 @@
 #include <tools/poly.hxx>
 #include <tools/stream.hxx>
 #include <tools/fontenum.hxx>
+#include <tools/UnitConversion.hxx>
 #include <sot/storage.hxx>
 #include <vcl/graph.hxx>
 #include <editeng/svxenum.hxx>
@@ -1180,7 +1181,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;
 
@@ -1219,7 +1219,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;
 
@@ -1248,7 +1248,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 )
                     {
@@ -1265,7 +1265,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