editeng/qa/unit/core-test.cxx        |  111 +++++++++++++++++++++++++++++++++++
 editeng/source/editeng/editeng.cxx   |   14 +++-
 editeng/source/editeng/impedit.hxx   |    9 ++
 editeng/source/editeng/impedit2.cxx  |   16 +++--
 editeng/source/editeng/impedit3.cxx  |   12 +++
 editeng/source/outliner/outliner.cxx |   10 +++
 include/editeng/editeng.hxx          |    6 +
 include/editeng/outliner.hxx         |    4 +
 include/svx/svdmodel.hxx             |    4 +
 sd/qa/unit/data/odp/tdf115639.odp    |binary
 sd/qa/unit/data/ppt/tdf115639.ppt    |binary
 sd/qa/unit/data/pptx/tdf115639.pptx  |binary
 sd/qa/unit/import-tests.cxx          |   33 ++++++++++
 sd/source/ui/docshell/docshel4.cxx   |   16 +++++
 sd/source/ui/view/Outliner.cxx       |    1 
 svx/source/svdraw/svdetc.cxx         |    1 
 svx/source/svdraw/svdmodel.cxx       |   22 ++++++
 17 files changed, 246 insertions(+), 13 deletions(-)

New commits:
commit f26899be899f1a39ea1e6b5ad8b46bad9cf1216f
Author: Tamás Zolnai <tamas.zol...@collabora.com>
Date:   Sat Feb 17 15:49:27 2018 +0100

    tdf#115639: Align right/center with trailing spaces the same as MS 
PowerPoint
    
    * Add HoriAlignIgnoreTrailingWhitespace compatibility option.
    ** For MSO file formats it is set to true
    ** For ODP format it's set to false by default
    ** The flag is saved to ODP format as user data if the document
    comes from an MSO format.
    
    Reviewed-on: https://gerrit.libreoffice.org/49889
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>
    (cherry picked from commit 1da3a3cb74a415a76fa547ef0c8f61780e260e7f)
    
    Change-Id: Ie22233d33a25e605de46120bfc2195038dffd63c
    Reviewed-on: https://gerrit.libreoffice.org/49909
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 8048feabf131..b6da4d4a1a8d 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -26,6 +26,7 @@
 #include "editeng/section.hxx"
 #include "editeng/editobj.hxx"
 #include "editeng/flditem.hxx"
+#include <editeng/adjustitem.hxx>
 #include "svl/srchitem.hxx"
 
 #include <com/sun/star/text/textfield/Type.hpp>
@@ -57,12 +58,16 @@ public:
 
     void testSectionAttributes();
 
+    /// Test HoriAlignIgnoreTrailingWhitespace compatibility flag
+    void testHoriAlignIgnoreTrailingWhitespace();
+
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testConstruction);
     CPPUNIT_TEST(testUnoTextFields);
     CPPUNIT_TEST(testAutocorrect);
     CPPUNIT_TEST(testHyperlinkSearch);
     CPPUNIT_TEST(testSectionAttributes);
+    CPPUNIT_TEST(testHoriAlignIgnoreTrailingWhitespace);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -631,6 +636,112 @@ void Test::testSectionAttributes()
     }
 }
 
+void Test::testHoriAlignIgnoreTrailingWhitespace()
+{
+    // Create EditEngine's instance
+    EditEngine aEditEngine(mpItemPool);
+
+    // Get EditDoc for current EditEngine's instance
+    EditDoc &rDoc = aEditEngine.GetEditDoc();
+
+    // Initially no text should be there
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(0), rDoc.GetTextLen());
+    CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0)));
+
+    // Set initial text
+    OUString aText = "Some text    ";
+    sal_Int32 aTextLen = aText.getLength();
+    aEditEngine.SetText(aText);
+
+    // Assert changes - text insertion
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(aTextLen), rDoc.GetTextLen());
+    CPPUNIT_ASSERT_EQUAL(aText, 
rDoc.GetParaAsString(static_cast<sal_Int32>(0)));
+
+    // First test case: center alignment with compatibility option enabled
+    {
+        aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(true);
+        std::unique_ptr<SfxItemSet> pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+        pSet->Put(SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count());
+
+        // Select all paragraphs and apply changes
+        ESelection aSelection(0, 0, 0, aTextLen);
+        aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+        // Use a one line paragraph
+        aEditEngine.SetPaperSize(Size(10000, 6000));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
aEditEngine.GetLineCount(0));
+
+        // Check horizontal position
+        ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+        EditLine* pLine = &pParaPortion->GetLines()[0];
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(4527), 
pLine->GetStartPosX(), 10);
+    }
+
+    // Second test case: center alignment with compatibility option disabled
+    {
+        aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(false);
+        std::unique_ptr<SfxItemSet> pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+        pSet->Put(SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count());
+
+        // Select all paragraphs and apply changes
+        ESelection aSelection(0, 0, 0, aTextLen);
+        aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+        // Use a one line paragraph
+        aEditEngine.SetPaperSize(Size(10000, 6000));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
aEditEngine.GetLineCount(0));
+
+        // Check horizontal position
+        ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+        EditLine* pLine = &pParaPortion->GetLines()[0];
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(4407), 
pLine->GetStartPosX(), 10);
+    }
+
+    // Third test case: right alignment with compatibility option enabled
+    {
+        aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(true);
+        std::unique_ptr<SfxItemSet> pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+        pSet->Put(SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count());
+
+        // Select all paragraphs and apply changes
+        ESelection aSelection(0, 0, 0, aTextLen);
+        aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+        // Use a one line paragraph
+        aEditEngine.SetPaperSize(Size(10000, 6000));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
aEditEngine.GetLineCount(0));
+
+        // Check horizontal position
+        ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+        EditLine* pLine = &pParaPortion->GetLines()[0];
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(9054), 
pLine->GetStartPosX(), 10);
+    }
+
+    // Fourth test case: right alignment with compatibility option disabled
+    {
+        aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(false);
+        std::unique_ptr<SfxItemSet> pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+        pSet->Put(SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count());
+
+        // Select all paragraphs and apply changes
+        ESelection aSelection(0, 0, 0, aTextLen);
+        aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+        // Use a one line paragraph
+        aEditEngine.SetPaperSize(Size(10000, 6000));
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
aEditEngine.GetLineCount(0));
+
+        // Check horizontal position
+        ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+        EditLine* pLine = &pParaPortion->GetLines()[0];
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(8815), 
pLine->GetStartPosX(), 10);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 4c75a7e2930d..dca25cc94873 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1434,13 +1434,13 @@ sal_uInt32 EditEngine::GetTextHeightNTP() const
     return pImpEditEngine->GetTextHeightNTP();
 }
 
-sal_uInt32 EditEngine::CalcTextWidth()
+sal_uInt32 EditEngine::CalcTextWidth(bool bIgnoreTrailingWhiteSpaces)
 {
 
     if ( !pImpEditEngine->IsFormatted() )
         pImpEditEngine->FormatDoc();
 
-    sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( true ) 
: pImpEditEngine->GetTextHeight();
+    sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( true, 
bIgnoreTrailingWhiteSpaces ) : pImpEditEngine->GetTextHeight();
      return nWidth;
 }
 
@@ -2791,6 +2791,16 @@ bool EditEngine::IsPageOverflow() {
     return pImpEditEngine->IsPageOverflow();
 }
 
+void EditEngine::SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled)
+{
+    pImpEditEngine->SetHoriAlignIgnoreTrailingWhitespace(bEnabled);
+}
+
+bool EditEngine::IsHoriAlignIgnoreTrailingWhitespace() const
+{
+    return pImpEditEngine->IsHoriAlignIgnoreTrailingWhitespace();
+}
+
 EFieldInfo::EFieldInfo()
 {
     pFieldItem = nullptr;
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index ac27e46e4f73..c1bdddbece80 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -527,6 +527,7 @@ private:
     bool            bFirstWordCapitalization:1;   // specifies if 
auto-correction should capitalize the first word or not
     bool            mbLastTryMerge:1;
     bool            mbReplaceLeadingSingleQuotationMark:1;
+    bool            mbHoriAlignIgnoreTrailingWhitespace:1;
 
 
     // Methods...
@@ -823,8 +824,8 @@ public:
     sal_uInt32      CalcTextHeight( sal_uInt32* pHeightNTP );
     sal_uInt32      GetTextHeight() const;
     sal_uInt32      GetTextHeightNTP() const;
-    sal_uInt32      CalcTextWidth( bool bIgnoreExtraSpace );
-    sal_uInt32      CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, 
bool bIgnoreExtraSpace );
+    sal_uInt32      CalcTextWidth( bool bIgnoreExtraSpace, bool 
bIgnoreTrailingWhiteSpaces = false );
+    sal_uInt32      CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, 
bool bIgnoreExtraSpace, bool bIgnoreTrailingWhiteSpaces = false );
     sal_Int32       GetLineCount( sal_Int32 nParagraph ) const;
     sal_Int32       GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
     void            GetLineBoundaries( /*out*/sal_Int32& rStart, 
/*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
@@ -1045,6 +1046,10 @@ public:
         mark (apostrophe) or not (default is on) */
     void            SetReplaceLeadingSingleQuotationMark( bool bReplace ) { 
mbReplaceLeadingSingleQuotationMark = bReplace; }
     bool            IsReplaceLeadingSingleQuotationMark() const { return 
mbReplaceLeadingSingleQuotationMark; }
+
+    // tdf#115639 compatibility flag
+    void SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled) { 
mbHoriAlignIgnoreTrailingWhitespace = bEnabled; }
+    bool IsHoriAlignIgnoreTrailingWhitespace() const { return 
mbHoriAlignIgnoreTrailingWhitespace; }
 };
 
 inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM )
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index c4448c40c55d..a6e3542547bd 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -102,7 +102,8 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* 
pItemPool ) :
     bImpConvertFirstCall(false),
     bFirstWordCapitalization(true),
     mbLastTryMerge(false),
-    mbReplaceLeadingSingleQuotationMark(true)
+    mbReplaceLeadingSingleQuotationMark(true),
+    mbHoriAlignIgnoreTrailingWhitespace(false)
 {
     pEditEngine         = pEE;
     pRefDev             = nullptr;
@@ -3041,7 +3042,7 @@ sal_uInt32 ImpEditEngine::GetTextHeight() const
     return nCurTextHeight;
 }
 
-sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
+sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace, bool 
bIgnoreTrailingWhiteSpaces )
 {
     // If still not formatted and not in the process.
     // Will be brought in the formatting for AutoPageSize.
@@ -3088,7 +3089,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool 
bIgnoreExtraSpace )
                     }
                 }
                 nCurWidth += GetXValue( rLRItem.GetRight() );
-                nCurWidth += CalcLineWidth( pPortion, &rLine, 
bIgnoreExtraSpace );
+                nCurWidth += CalcLineWidth( pPortion, &rLine, 
bIgnoreExtraSpace, bIgnoreTrailingWhiteSpaces );
                 if ( nCurWidth > nMaxWidth )
                 {
                     nMaxWidth = nCurWidth;
@@ -3101,7 +3102,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool 
bIgnoreExtraSpace )
     return (sal_uInt32)nMaxWidth;
 }
 
-sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* 
pLine, bool bIgnoreExtraSpace )
+sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* 
pLine, bool bIgnoreExtraSpace, bool bIgnoreTrailingWhiteSpaces )
 {
     sal_Int32 nPara = GetEditDoc().GetPos( pPortion->GetNode() );
 
@@ -3130,7 +3131,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* 
pPortion, EditLine* pLine,
             break;
             case PortionKind::TEXT:
             {
-                if ( ( eJustification != SVX_ADJUST_BLOCK ) || ( 
!bIgnoreExtraSpace ) )
+                if ( (( eJustification != SVX_ADJUST_BLOCK ) || ( 
!bIgnoreExtraSpace )) && !bIgnoreTrailingWhiteSpaces )
                 {
                     nWidth += rTextPortion.GetSize().Width();
                 }
@@ -3140,7 +3141,10 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* 
pPortion, EditLine* pLine,
                     SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
                     aTmpFont.SetPhysFont( GetRefDevice() );
                     ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
-                    nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), 
pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width();
+                    if (bIgnoreTrailingWhiteSpaces)
+                        nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), 
pPortion->GetNode()->GetString().trim(), nPos, rTextPortion.GetLen() ).Width();
+                    else
+                        nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), 
pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width();
                 }
             }
             break;
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 4bf113d34374..7f53110bccd6 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -1469,7 +1469,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
         {
             case SVX_ADJUST_CENTER:
             {
-                long n = ( nMaxLineWidth - aTextSize.Width() ) / 2;
+                long n;
+                if(IsHoriAlignIgnoreTrailingWhitespace())
+                    n = ( nMaxLineWidth - CalcTextWidth( true, true ) ) / 2;
+                else
+                    n = ( nMaxLineWidth - aTextSize.Width() ) / 2;
                 n += nStartX;  // Indentation is kept.
                 pLine->SetStartPosX( n );
             }
@@ -1478,7 +1482,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
             {
                 // For automatically wrapped lines, which has a blank at the 
end
                 // the blank must not be displayed!
-                long n = nMaxLineWidth - aTextSize.Width();
+                long n;
+                if(IsHoriAlignIgnoreTrailingWhitespace())
+                    n = nMaxLineWidth - CalcTextWidth( true, true );
+                else
+                    n = nMaxLineWidth - aTextSize.Width();
                 n += nStartX;  // Indentation is kept.
                 pLine->SetStartPosX( n );
             }
diff --git a/editeng/source/outliner/outliner.cxx 
b/editeng/source/outliner/outliner.cxx
index 9943efdb0d26..4df73c4a906b 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -366,6 +366,16 @@ sal_Int32 Outliner::GetBulletsNumberingStatus() const
            : 2;
 }
 
+void Outliner::SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled)
+{
+    pEditEngine->SetHoriAlignIgnoreTrailingWhitespace( bEnabled );
+}
+
+bool Outliner::IsHoriAlignIgnoreTrailingWhitespace() const
+{
+    return pEditEngine->IsHoriAlignIgnoreTrailingWhitespace();
+}
+
 OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, 
sal_Int32 nCount ) const
 {
     if ( static_cast<sal_uLong>(nStartPara) + nCount >
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index b1991af45e35..8846d0f73c10 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -278,7 +278,7 @@ public:
     sal_uInt32      GetTextLen() const;
     sal_uInt32      GetTextHeight() const;
     sal_uInt32      GetTextHeightNTP() const;
-    sal_uInt32      CalcTextWidth();
+    sal_uInt32      CalcTextWidth( bool bIgnoreTrailingWhiteSpaces = false );
 
     OUString        GetText( sal_Int32 nParagraph ) const;
     sal_Int32       GetTextLen( sal_Int32 nParagraph ) const;
@@ -614,6 +614,10 @@ public:
     sal_Int32 GetOverflowingLineNum() const;
     void ClearOverflowingParaNum();
     bool IsPageOverflow();
+
+    // tdf#115639 compatibility flag
+    void SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled);
+    bool IsHoriAlignIgnoreTrailingWhitespace() const;
 };
 
 #endif // INCLUDED_EDITENG_EDITENG_HXX
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 7fe332587e43..1f6983e9088f 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -1006,6 +1006,10 @@ public:
 
     // convenient method to determine the bullets/numbering status for all 
paragraphs
     sal_Int32 GetBulletsNumberingStatus() const;
+
+    // tdf#115639 compatibility flag
+    void SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled);
+    bool IsHoriAlignIgnoreTrailingWhitespace() const;
 };
 
 #endif
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 79337a826a60..6e1424f389e1 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -546,6 +546,10 @@ public:
     void SetAnchoredTextOverflowLegacy(bool bEnabled);
     bool IsAnchoredTextOverflowLegacy() const;
 
+    // tdf#115639 compatibility flag
+    void SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled);
+    bool IsHoriAlignIgnoreTrailingWhitespace() const;
+
     void ReformatAllTextObjects();
 
     SdrOutliner* createOutliner( OutlinerMode nOutlinerMode );
diff --git a/sd/qa/unit/data/odp/tdf115639.odp 
b/sd/qa/unit/data/odp/tdf115639.odp
new file mode 100755
index 000000000000..b732e4e7652b
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf115639.odp differ
diff --git a/sd/qa/unit/data/ppt/tdf115639.ppt 
b/sd/qa/unit/data/ppt/tdf115639.ppt
new file mode 100755
index 000000000000..dade453bfeee
Binary files /dev/null and b/sd/qa/unit/data/ppt/tdf115639.ppt differ
diff --git a/sd/qa/unit/data/pptx/tdf115639.pptx 
b/sd/qa/unit/data/pptx/tdf115639.pptx
new file mode 100755
index 000000000000..7e00b60cb397
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf115639.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 1212eee9495d..c66134291e05 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -157,6 +157,7 @@ public:
     void testTdf115394PPT();
     void testTdf114821();
     void testTdf51340();
+    void testTdf115639();
 
     bool checkPattern(sd::DrawDocShellRef& rDocRef, int nShapeNumber, 
std::vector<sal_uInt8>& rExpected);
     void testPatternImport();
@@ -230,6 +231,7 @@ public:
     CPPUNIT_TEST(testTdf115394PPT);
     CPPUNIT_TEST(testTdf114821);
     CPPUNIT_TEST(testTdf51340);
+    CPPUNIT_TEST(testTdf115639);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2409,6 +2411,37 @@ void SdImportTest::testTdf51340()
     xDocShRef->DoClose();
 }
 
+
+void SdImportTest::testTdf115639()
+{
+    // Check whether the new compatibility option is loaded correctly
+    // For PPTX we have the flag enabled by default
+    {
+        sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115639.pptx"), 
PPTX);
+        SdDrawDocument *pDoc = xDocShRef->GetDoc();
+        CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
+        CPPUNIT_ASSERT( pDoc->IsHoriAlignIgnoreTrailingWhitespace() );
+    }
+
+    // For PPT we have the flag enabled by default
+    {
+        sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf115639.ppt"), PPT);
+        SdDrawDocument *pDoc = xDocShRef->GetDoc();
+        CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
+        CPPUNIT_ASSERT( pDoc->IsHoriAlignIgnoreTrailingWhitespace() );
+        xDocShRef->DoClose();
+    }
+
+    // For ODP we have the flag disabled by default
+    {
+        sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf115639.odp"), ODP);
+        SdDrawDocument *pDoc = xDocShRef->GetDoc();
+        CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
+        CPPUNIT_ASSERT( !pDoc->IsHoriAlignIgnoreTrailingWhitespace() );
+        xDocShRef->DoClose();
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/docshell/docshel4.cxx 
b/sd/source/ui/docshell/docshel4.cxx
index a94c79ea4126..7082a8fef297 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -406,6 +406,14 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
         mpDoc->SetSummationOfParagraphs();
     }
 
+    // Set this flag for MSO formats
+    if (aFilterName.startsWith("MS PowerPoint 97") ||
+        aFilterName.startsWith("Impress MS PowerPoint 2007 XML") ||
+        aFilterName.startsWith("Impress Office Open XML"))
+    {
+        mpDoc->SetHoriAlignIgnoreTrailingWhitespace(true);
+    }
+
     const bool bRet = SfxObjectShell::ImportFrom(rMedium, xInsertPosition);
 
     SfxItemSet* pSet = rMedium.GetItemSet();
@@ -497,6 +505,14 @@ bool DrawDocShell::ConvertFrom( SfxMedium& rMedium )
         bRet = SdGRFFilter( rMedium, *this ).Import();
     }
 
+    // Set this flag for MSO formats
+    if (aFilterName.startsWith("MS PowerPoint 97") ||
+        aFilterName.startsWith("Impress MS PowerPoint 2007 XML") ||
+        aFilterName.startsWith("Impress Office Open XML"))
+    {
+        mpDoc->SetHoriAlignIgnoreTrailingWhitespace(true);
+    }
+
     FinishedLoading();
 
     // tell SFX to change viewshell when in preview mode
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 1a58a2102333..9b82afe0061c 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -230,6 +230,7 @@ SdOutliner::SdOutliner( SdDrawDocument* pDoc, OutlinerMode 
nMode )
         SetHyphenator( xHyphenator );
 
     SetDefaultLanguage( 
Application::GetSettings().GetLanguageTag().getLanguageType() );
+    SetHoriAlignIgnoreTrailingWhitespace( 
pDoc->IsHoriAlignIgnoreTrailingWhitespace() );
 }
 
 /// Nothing spectacular in the destructor.
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 1941cd4f3ef8..43c3ea287ac5 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -375,6 +375,7 @@ SdrOutliner* SdrMakeOutliner(OutlinerMode nOutlinerMode, 
SdrModel& rModel)
     pOutl->SetAsianCompressionMode(rModel.GetCharCompressType());
     pOutl->SetKernAsianPunctuation(rModel.IsKernAsianPunctuation());
     pOutl->SetAddExtLeading(rModel.IsAddExtLeading());
+    
pOutl->SetHoriAlignIgnoreTrailingWhitespace(rModel.IsHoriAlignIgnoreTrailingWhitespace());
     return pOutl;
 }
 
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 05fa868d46ea..8444e7d09861 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -107,6 +107,7 @@ struct SdrModelImpl
     SdrUndoFactory* mpUndoFactory;
 
     bool mbAnchoredTextOverflowLegacy; // tdf#99729 compatibility flag
+    bool mbHoriAlignIgnoreTrailingWhitespace; // tdf#115639 compatibility flag
 };
 
 
@@ -117,6 +118,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, 
::comphelper::IEmbeddedHelper* _pEmbe
     mpImpl->mpUndoManager=nullptr;
     mpImpl->mpUndoFactory=nullptr;
     mpImpl->mbAnchoredTextOverflowLegacy = false;
+    mpImpl->mbHoriAlignIgnoreTrailingWhitespace = false;
     mbInDestruction = false;
     aObjUnit=SdrEngineDefaults::GetMapFraction();
     eObjUnit=SdrEngineDefaults::GetMapUnit();
@@ -1905,6 +1907,17 @@ bool SdrModel::IsAnchoredTextOverflowLegacy() const
     return mpImpl->mbAnchoredTextOverflowLegacy;
 }
 
+void SdrModel::SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled)
+{
+    mpImpl->mbHoriAlignIgnoreTrailingWhitespace = bEnabled;
+    pDrawOutliner->SetHoriAlignIgnoreTrailingWhitespace(bEnabled);
+}
+
+bool SdrModel::IsHoriAlignIgnoreTrailingWhitespace() const
+{
+    return mpImpl->mbHoriAlignIgnoreTrailingWhitespace;
+}
+
 void SdrModel::ReformatAllTextObjects()
 {
     ImpReformatAllTextObjects();
@@ -1954,6 +1967,13 @@ void SdrModel::ReadUserDataSequenceValue(const 
css::beans::PropertyValue* pValue
             mpImpl->mbAnchoredTextOverflowLegacy = bBool;
         }
     }
+    if (pValue->Name == "HoriAlignIgnoreTrailingWhitespace")
+    {
+        if (pValue->Value >>= bBool)
+        {
+            SetHoriAlignIgnoreTrailingWhitespace(bBool);
+        }
+    }
 }
 
 template <typename T>
@@ -1966,6 +1986,8 @@ void SdrModel::WriteUserDataSequence(css::uno::Sequence < 
css::beans::PropertyVa
 {
     std::vector< std::pair< OUString, Any > > aUserData;
     addPair(aUserData, "AnchoredTextOverflowLegacy", 
IsAnchoredTextOverflowLegacy());
+    if (IsHoriAlignIgnoreTrailingWhitespace())
+        addPair(aUserData, "HoriAlignIgnoreTrailingWhitespace", 
IsHoriAlignIgnoreTrailingWhitespace());
 
     const sal_Int32 nOldLength = rValues.getLength();
     rValues.realloc(nOldLength + aUserData.size());
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to