[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - 5 commits - include/sfx2 sfx2/source sw/inc sw/source

Michael Stahl mstahl at redhat.com
Wed Mar 14 20:22:58 UTC 2018


 include/sfx2/objsh.hxx                        |    3 
 sfx2/source/doc/objmisc.cxx                   |    7 +-
 sw/inc/IDocumentSettingAccess.hxx             |    3 
 sw/inc/docsh.hxx                              |    1 
 sw/inc/viewsh.hxx                             |    2 
 sw/source/core/doc/DocumentSettingManager.cxx |    9 ++
 sw/source/core/inc/DocumentSettingManager.hxx |    1 
 sw/source/core/text/guess.cxx                 |   31 +++++++++-
 sw/source/core/text/inftxt.cxx                |   80 +++++++++++++++++++++++++-
 sw/source/core/view/viewsh.cxx                |   11 +++
 sw/source/uibase/app/docsh.cxx                |   14 ++++
 11 files changed, 157 insertions(+), 5 deletions(-)

New commits:
commit 15b9ea2b42d1c2e012c064d39b9afffdb08a9bbd
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 18 15:54:47 2017 +0100

    sw: remove duplicate "MsWordCompTrailingBlanks" view setting
    
    This is already a document setting, no point in writing it twice into
    settings.xml.
    
    (cherry picked from commit 7667675397c98bb38cdd14dd689a32e9f8a986d3)
    
    Change-Id: Idcc99a194df321e11e091a2388b919e11fe94316

diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 4ca6fc94bfe6..6037ff24a417 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1262,14 +1262,12 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
         sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
 
         bool bSelectedFrame = ( m_pWrtShell->GetSelFrameType() != FrameTypeFlags::NONE ),
-             bMsWordCompTrailingBlanks = false,
                  bGotVisibleLeft = false,
                  bGotVisibleTop = false, bGotVisibleRight = false,
                  bGotVisibleBottom = false, bGotZoomType = false,
                  bGotZoomFactor = false, bGotIsSelectedFrame = false,
                  bGotViewLayoutColumns = false, bGotViewLayoutBookMode = false,
-                 bBrowseMode = false, bGotBrowseMode = false,
-                 bGotMsWordCompTrailingBlanks = false;
+                 bBrowseMode = false, bGotBrowseMode = false;
 
         for (sal_Int32 i = 0 ; i < nLength; i++)
         {
@@ -1337,11 +1335,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
                pValue->Value >>= bBrowseMode;
                bGotBrowseMode = true;
             }
-            else if ( pValue->Name == "MsWordCompTrailingBlanks" )
-            {
-                pValue->Value >>= bMsWordCompTrailingBlanks;
-                bGotMsWordCompTrailingBlanks = true;
-            }
             // Fallback to common SdrModel processing
             else GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(pValue);
             pValue++;
@@ -1473,10 +1466,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
                 m_pWrtShell->EnableSmooth( true );
             }
         }
-        if ( bGotMsWordCompTrailingBlanks )
-        {
-            GetDocShell()->GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, bMsWordCompTrailingBlanks );
-        }
     }
 }
 
@@ -1516,8 +1505,6 @@ void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSe
 
     aVector.push_back(comphelper::makePropertyValue("IsSelectedFrame", FrameTypeFlags::NONE != m_pWrtShell->GetSelFrameType()));
 
-    aVector.push_back(comphelper::makePropertyValue("MsWordCompTrailingBlanks", GetDocShell()->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS )));
-
     rSequence = comphelper::containerToSequence(aVector);
 
     // Common SdrModel processing
commit 6c86ae2fec7d2a1375a3e9683ea2155448990ce7
Author: Vitaliy Anderson <vanderson at smartru.com>
Date:   Fri Jan 13 05:26:07 2017 -0800

    tdf#104349, tdf#104668 MS Word compatibility trailing blanks option
    
    The commits: 1c1747ac13a9d895df0fcba2fbb1bd266dccd74b and 4a410dd147f7160c1d62e3e0b67388a178d5136c
    make trailing spaces and their highlighting compatible with the Ms Word.
    
    The option is enabled by default for imported MS Word formats: .doc, .docx, .rtf
    For the ODF files the option is disabled by default
    
    Also it allows saving and loading the option state to the ODF UserData.
    
    It may be manually set in Tools->Options->LibreOffice Writer->Compatibility
    
    Reviewed-on: https://gerrit.libreoffice.org/33046
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 7fa20da88a4778bdf20d6ca0491fe97ae03ab554)
    
    Change-Id: I5a86359c52d18e50bbb54b9f37c79b672591c369

diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 84ff20818883..ab885358b66f 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -460,6 +460,9 @@ public:
     // Transfer IFace
     bool                        IsAbortingImport() const;
     void                        FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
+
+    virtual void                SetFormatSpecificCompatibilityOptions( const OUString& /*rFilterTypeName*/ ) { /* Do not do anything here; Derived classes must overload to do actual work */ };
+
     void                        TemplateDisconnectionAfterLoad();
     bool                        IsLoading() const;
     bool                        IsLoadingFinished() const;
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 569a92f87939..59be71d84d2e 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1128,6 +1128,12 @@ void SfxObjectShell::InitOwnModel_Impl()
 
 void SfxObjectShell::FinishedLoading( SfxLoadedFlags nFlags )
 {
+    std::shared_ptr<const SfxFilter> pFlt = pMedium->GetFilter();
+    if( pFlt )
+    {
+        SetFormatSpecificCompatibilityOptions( pFlt->GetTypeName() );
+    }
+
     bool bSetModifiedTRUE = false;
     const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false);
     if( ( nFlags & SfxLoadedFlags::MAINDOCUMENT ) && !(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT )
@@ -1216,7 +1222,6 @@ void SfxObjectShell::FinishedLoading( SfxLoadedFlags nFlags )
     }
 }
 
-
 void SfxObjectShell::TemplateDisconnectionAfterLoad()
 {
     // document is created from a template
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 2827567d89f1..f152fef3ff26 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -62,6 +62,9 @@ enum class DocumentSettingId
     IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION,
     CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME,
 
+    // tdf#104349 tdf#104668
+    MS_WORD_COMP_TRAILING_BLANKS,
+
     UNIX_FORCE_ZERO_EXT_LEADING,
     TABS_RELATIVE_TO_INDENT,
     PROTECT_FORM,
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index d71e1fe989a9..6eaed1a844dd 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -267,6 +267,7 @@ public:
      the load of document being finished. */
 
     void LoadingFinished();
+    virtual void SetFormatSpecificCompatibilityOptions( const OUString& rFilterTypeName ) override;
 
     /// Cancel transfer (called from SFX).
     virtual void CancelTransfers() override;
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 7dc28460c20a..94d458753d7b 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -416,6 +416,8 @@ public:
 
     void SetProtectForm( bool _bProtectForm );
 
+    void SetMsWordCompTrailingBlanks( bool _bMsWordCompTrailingBlanks );
+
     void SetSubtractFlysAnchoredAtFlys(bool bSubtractFlysAnchoredAtFlys);
 
     // DOCUMENT COMPATIBILITY FLAGS END
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 78201b61016a..69361f0add48 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -73,6 +73,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
     mbUnixForceZeroExtLeading(false),
     mbTabRelativeToIndent(true),
     mbProtectForm(false), // i#78591#
+    mbMsWordCompTrailingBlanks(false), // tdf#104349 tdf#104668
     mbInvertBorderSpacing (false),
     mbCollapseEmptyCellPara(true),
     mbTabAtLeftIndentForParagraphsInList(false), //#i89181#
@@ -168,6 +169,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
         case DocumentSettingId::UNIX_FORCE_ZERO_EXT_LEADING: return mbUnixForceZeroExtLeading;
         case DocumentSettingId::TABS_RELATIVE_TO_INDENT : return mbTabRelativeToIndent;
         case DocumentSettingId::PROTECT_FORM: return mbProtectForm;
+        // tdf#104349 tdf#104668
+        case DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS: return mbMsWordCompTrailingBlanks;
         // #i89181#
         case DocumentSettingId::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
         case DocumentSettingId::INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
@@ -306,6 +309,11 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
             mbProtectForm = value;
             break;
 
+        // tdf#140349
+        case DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS:
+            mbMsWordCompTrailingBlanks = value;
+            break;
+
         case DocumentSettingId::TABS_RELATIVE_TO_INDENT:
             mbTabRelativeToIndent = value;
             break;
@@ -558,6 +566,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
     mbUnixForceZeroExtLeading = rSource.mbUnixForceZeroExtLeading;
     mbTabRelativeToIndent = rSource.mbTabRelativeToIndent;
     mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
+    mbMsWordCompTrailingBlanks = rSource.mbMsWordCompTrailingBlanks;
 }
 
 sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 6927f83db287..6efbb35ee59d 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -139,6 +139,7 @@ class DocumentSettingManager :
     bool mbUnixForceZeroExtLeading                  : 1;   // #i60945#
     bool mbTabRelativeToIndent                      : 1;   // #i24363# tab stops relative to indent
     bool mbProtectForm                              : 1;
+    bool mbMsWordCompTrailingBlanks                 : 1;   // tdf#104349 tdf#104668
     bool mbInvertBorderSpacing                      : 1;
     bool mbCollapseEmptyCellPara                    : 1;
     bool mbTabAtLeftIndentForParagraphsInList;             // #i89181# - see above
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index e347013a4c9b..a405c87d3f9c 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -75,23 +75,30 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
 
     const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust();
 
-    // tdf#104668 space chars at the end should be cut
-    if ( rAdjust == SVX_ADJUST_RIGHT || rAdjust == SVX_ADJUST_CENTER )
+    // tdf#104668 space chars at the end should be cut if the compatibility option is enabled
+    // for LTR mode only
+    if ( !rInf.GetTextFrame()->IsRightToLeft() )
     {
-        sal_Int32 nSpaceCnt = 0;
-        for ( int i = (rInf.GetText().getLength() - 1); i >= rInf.GetIdx(); --i )
+        if ( rInf.GetTextFrame()->GetNode()->getIDocumentSettingAccess()->get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) )
         {
-            sal_Unicode cChar = rInf.GetText()[i];
-            if ( cChar != CH_BLANK && cChar != CH_FULL_BLANK )
-                break;
-            ++nSpaceCnt;
-        }
-        sal_Int32 nCharsCnt = nMaxLen - nSpaceCnt;
-        if ( nSpaceCnt && nCharsCnt < rPor.GetLen() )
-        {
-            nMaxLen = nCharsCnt;
-            if ( !nMaxLen )
-                return true;
+            if ( rAdjust == SVX_ADJUST_RIGHT || rAdjust == SVX_ADJUST_CENTER )
+            {
+                sal_Int32 nSpaceCnt = 0;
+                for ( int i = (rInf.GetText().getLength() - 1); i >= rInf.GetIdx(); --i )
+                {
+                    sal_Unicode cChar = rInf.GetText()[i];
+                    if ( cChar != CH_BLANK && cChar != CH_FULL_BLANK )
+                        break;
+                    ++nSpaceCnt;
+                }
+                sal_Int32 nCharsCnt = nMaxLen - nSpaceCnt;
+                if ( nSpaceCnt && nCharsCnt < rPor.GetLen() )
+                {
+                    nMaxLen = nCharsCnt;
+                    if ( !nMaxLen )
+                        return true;
+                }
+            }
         }
     }
 
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index a6dca7caae37..0bb5737070db 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1184,71 +1184,78 @@ void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const
             aFillColor = *m_pFnt->GetBackColor();
         }
 
-        // tdf#104349 do not hightlight portions of space chars before end of line
-        bool           draw = false;
-        bool           full = false;
-        SwLinePortion *pPos = const_cast<SwLinePortion *>(&rPor);
-        sal_Int32      nIdx = GetIdx();
-        sal_Int32      nLen;
-
-        do
+        // tdf#104349 do not hightlight portions of space chars before end of line if the compatibility option is enabled
+        // for LTR mode only
+        if ( !GetTextFrame()->IsRightToLeft() )
         {
-            nLen = pPos->GetLen();
-            for ( int i = nIdx; i < (nIdx + nLen); ++i )
+            if ( GetTextFrame()->GetNode()->getIDocumentSettingAccess()->get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) )
             {
-                if (i < GetText().getLength() && GetText()[i] == CH_TXTATR_NEWLINE)
-                {
-                    if ( i >= (GetIdx() + rPor.GetLen()) )
-                    {
-                        goto drawcontinue;
-                    }
-                }
-                if (i >= GetText().getLength() || GetText()[i] != CH_BLANK)
+                bool           draw = false;
+                bool           full = false;
+                SwLinePortion *pPos = const_cast<SwLinePortion *>(&rPor);
+                sal_Int32      nIdx = GetIdx();
+                sal_Int32      nLen;
+
+                do
                 {
-                    draw = true;
-                    if ( i >= (GetIdx() + rPor.GetLen()) )
+                    nLen = pPos->GetLen();
+                    for ( int i = nIdx; i < (nIdx + nLen); ++i )
                     {
-                        full = true;
-                        goto drawcontinue;
+                        if ( i < GetText().getLength() && GetText()[i] == CH_TXTATR_NEWLINE )
+                        {
+                            if ( i >= (GetIdx() + rPor.GetLen()) )
+                            {
+                                goto drawcontinue;
+                            }
+                        }
+                        if ( i >= GetText().getLength() || GetText()[i] != CH_BLANK )
+                        {
+                            draw = true;
+                            if ( i >= (GetIdx() + rPor.GetLen()) )
+                            {
+                                full = true;
+                                goto drawcontinue;
+                            }
+                        }
                     }
-                }
-            }
-            nIdx += nLen;
-            pPos = pPos->GetPortion();
-        } while ( pPos );
+                    nIdx += nLen;
+                    pPos = pPos->GetPortion();
+                } while ( pPos );
 
-        drawcontinue:
+            drawcontinue:
 
-        if ( !draw )
-            return;
-
-        if ( !full )
-        {
-            pPos = const_cast<SwLinePortion *>(&rPor);
-            nIdx = GetIdx();
+                if ( !draw )
+                    return;
 
-            nLen = pPos->GetLen();
-            for ( int i = (nIdx + nLen - 1); i >= nIdx; --i )
-            {
-                if (i < GetText().getLength() && GetText()[i] == CH_TXTATR_NEWLINE)
-                {
-                    continue;
-                }
-                if (i >= GetText().getLength() || GetText()[i] != CH_BLANK)
+                if ( !full )
                 {
-                    sal_uInt16 nOldWidth = rPor.Width();
-                    sal_uInt16 nNewWidth = GetTextSize( m_pOut, nullptr, GetText(), nIdx, (i + 1 - nIdx) ).Width();
-
-                    const_cast<SwLinePortion&>(rPor).Width( nNewWidth );
-                    CalcRect( rPor, nullptr, &aIntersect, true );
-                    const_cast<SwLinePortion&>(rPor).Width( nOldWidth );
+                    pPos = const_cast<SwLinePortion *>(&rPor);
+                    nIdx = GetIdx();
 
-                    if ( ! aIntersect.HasArea() )
+                    nLen = pPos->GetLen();
+                    for ( int i = (nIdx + nLen - 1); i >= nIdx; --i )
                     {
-                        return;
-                    }
+                        if ( i < GetText().getLength() && GetText()[i] == CH_TXTATR_NEWLINE )
+                        {
+                            continue;
+                        }
+                        if ( i >= GetText().getLength() || GetText()[i] != CH_BLANK )
+                        {
+                            sal_uInt16 nOldWidth = rPor.Width();
+                            sal_uInt16 nNewWidth = GetTextSize( m_pOut, nullptr, GetText(), nIdx, (i + 1 - nIdx) ).Width();
 
-                    break;
+                            const_cast<SwLinePortion&>(rPor).Width( nNewWidth );
+                            CalcRect( rPor, nullptr, &aIntersect, true );
+                            const_cast<SwLinePortion&>(rPor).Width( nOldWidth );
+
+                            if ( !aIntersect.HasArea() )
+                            {
+                                return;
+                            }
+
+                            break;
+                        }
+                    }
                 }
             }
         }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 85042ba3694c..7441179f570e 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -899,6 +899,17 @@ void SwViewShell::SetProtectForm( bool _bProtectForm )
     rIDSA.set(DocumentSettingId::PROTECT_FORM, _bProtectForm );
 }
 
+void SwViewShell::SetMsWordCompTrailingBlanks( bool _bMsWordCompTrailingBlanks )
+{
+    IDocumentSettingAccess& rIDSA = getIDocumentSettingAccess();
+    if (rIDSA.get(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS) != _bMsWordCompTrailingBlanks)
+    {
+        SwWait aWait(*GetDoc()->GetDocShell(), true);
+        rIDSA.set(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, _bMsWordCompTrailingBlanks);
+        const SwInvalidateFlags nInv = SwInvalidateFlags::PrtArea | SwInvalidateFlags::Size | SwInvalidateFlags::Table | SwInvalidateFlags::Section;
+        lcl_InvalidateAllContent(*this, nInv);
+    }
+}
 
 void SwViewShell::SetSubtractFlysAnchoredAtFlys(bool bSubtractFlysAnchoredAtFlys)
 {
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 0412b11d3baa..df9e531a708b 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1163,6 +1163,20 @@ void SwDocShell::LoadingFinished()
     }
 }
 
+void SwDocShell::SetFormatSpecificCompatibilityOptions( const OUString& rFilterTypeName )
+{
+    //Enable MS Word-compatibility trailing blanks option for MS Word files
+    if ( rFilterTypeName == "writer_MS_Word_95" ||
+         rFilterTypeName == "writer_MS_Word_97" ||
+         rFilterTypeName == "writer_MS_Word_2003_XML" ||
+         rFilterTypeName == "writer_MS_Word_2007" ||
+         rFilterTypeName == "writer_MS_Word_2007_Template" ||
+         rFilterTypeName == "writer_Rich_Text_Format" )
+    {
+        GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, true );
+    }
+}
+
 // a Transfer is cancelled (is called from SFX)
 void SwDocShell::CancelTransfers()
 {
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 6037ff24a417..4ca6fc94bfe6 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1262,12 +1262,14 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
         sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
 
         bool bSelectedFrame = ( m_pWrtShell->GetSelFrameType() != FrameTypeFlags::NONE ),
+             bMsWordCompTrailingBlanks = false,
                  bGotVisibleLeft = false,
                  bGotVisibleTop = false, bGotVisibleRight = false,
                  bGotVisibleBottom = false, bGotZoomType = false,
                  bGotZoomFactor = false, bGotIsSelectedFrame = false,
                  bGotViewLayoutColumns = false, bGotViewLayoutBookMode = false,
-                 bBrowseMode = false, bGotBrowseMode = false;
+                 bBrowseMode = false, bGotBrowseMode = false,
+                 bGotMsWordCompTrailingBlanks = false;
 
         for (sal_Int32 i = 0 ; i < nLength; i++)
         {
@@ -1335,6 +1337,11 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
                pValue->Value >>= bBrowseMode;
                bGotBrowseMode = true;
             }
+            else if ( pValue->Name == "MsWordCompTrailingBlanks" )
+            {
+                pValue->Value >>= bMsWordCompTrailingBlanks;
+                bGotMsWordCompTrailingBlanks = true;
+            }
             // Fallback to common SdrModel processing
             else GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(pValue);
             pValue++;
@@ -1466,6 +1473,10 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
                 m_pWrtShell->EnableSmooth( true );
             }
         }
+        if ( bGotMsWordCompTrailingBlanks )
+        {
+            GetDocShell()->GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, bMsWordCompTrailingBlanks );
+        }
     }
 }
 
@@ -1505,6 +1516,8 @@ void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSe
 
     aVector.push_back(comphelper::makePropertyValue("IsSelectedFrame", FrameTypeFlags::NONE != m_pWrtShell->GetSelFrameType()));
 
+    aVector.push_back(comphelper::makePropertyValue("MsWordCompTrailingBlanks", GetDocShell()->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS )));
+
     rSequence = comphelper::containerToSequence(aVector);
 
     // Common SdrModel processing
commit 38d2aa02e8b617301f1a7db3831b73572d8b40bf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 22 15:42:10 2016 +0000

    avoid crash in 130+ odt export tests
    
    e.g. fdo44181-1.ott to odt
    
    Change-Id: I23403415378ddf50ff007fb4b5d88b4009668bf6
    (cherry picked from commit 2085d8203b0ff49b6e43ff900f497fb5343708d8)

diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 2c577010768e..a6dca7caae37 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1196,14 +1196,14 @@ void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const
             nLen = pPos->GetLen();
             for ( int i = nIdx; i < (nIdx + nLen); ++i )
             {
-                if ( GetText()[i] == CH_TXTATR_NEWLINE )
+                if (i < GetText().getLength() && GetText()[i] == CH_TXTATR_NEWLINE)
                 {
                     if ( i >= (GetIdx() + rPor.GetLen()) )
                     {
                         goto drawcontinue;
                     }
                 }
-                if ( GetText()[i] != CH_BLANK )
+                if (i >= GetText().getLength() || GetText()[i] != CH_BLANK)
                 {
                     draw = true;
                     if ( i >= (GetIdx() + rPor.GetLen()) )
@@ -1230,11 +1230,11 @@ void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const
             nLen = pPos->GetLen();
             for ( int i = (nIdx + nLen - 1); i >= nIdx; --i )
             {
-                if ( GetText()[i] == CH_TXTATR_NEWLINE )
+                if (i < GetText().getLength() && GetText()[i] == CH_TXTATR_NEWLINE)
                 {
                     continue;
                 }
-                if ( GetText()[i] != CH_BLANK )
+                if (i >= GetText().getLength() || GetText()[i] != CH_BLANK)
                 {
                     sal_uInt16 nOldWidth = rPor.Width();
                     sal_uInt16 nNewWidth = GetTextSize( m_pOut, nullptr, GetText(), nIdx, (i + 1 - nIdx) ).Width();
commit ec87fa387fec1f37f483b8e6bc65cbb210d83a49
Author: Vitaliy Anderson <vanderson at smartru.com>
Date:   Fri Dec 9 02:48:00 2016 -0500

    tdf#104349 remove the difference between MSO and LO highlight chars
    
    Change-Id: I5daadef359260ea74b828567197228633bb972ca
    Reviewed-on: https://gerrit.libreoffice.org/31783
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>
    Tested-by: jan iversen <jani at documentfoundation.org>
    (cherry picked from commit 4a410dd147f7160c1d62e3e0b67388a178d5136c)

diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 0f467d28e713..2c577010768e 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -690,8 +690,8 @@ void SwTextPaintInfo::DrawText_( const OUString &rText, const SwLinePortion &rPo
         }
         if( aFontPos.X() < 0 )
             aFontPos.X() = 0;
-        if( aFontPos.X() < 0 )
-            aFontPos.X() = 0;
+        if( aFontPos.Y() < 0 )
+            aFontPos.Y() = 0;
     }
 
     if( GetTextFly().IsOn() )
@@ -1184,6 +1184,75 @@ void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const
             aFillColor = *m_pFnt->GetBackColor();
         }
 
+        // tdf#104349 do not hightlight portions of space chars before end of line
+        bool           draw = false;
+        bool           full = false;
+        SwLinePortion *pPos = const_cast<SwLinePortion *>(&rPor);
+        sal_Int32      nIdx = GetIdx();
+        sal_Int32      nLen;
+
+        do
+        {
+            nLen = pPos->GetLen();
+            for ( int i = nIdx; i < (nIdx + nLen); ++i )
+            {
+                if ( GetText()[i] == CH_TXTATR_NEWLINE )
+                {
+                    if ( i >= (GetIdx() + rPor.GetLen()) )
+                    {
+                        goto drawcontinue;
+                    }
+                }
+                if ( GetText()[i] != CH_BLANK )
+                {
+                    draw = true;
+                    if ( i >= (GetIdx() + rPor.GetLen()) )
+                    {
+                        full = true;
+                        goto drawcontinue;
+                    }
+                }
+            }
+            nIdx += nLen;
+            pPos = pPos->GetPortion();
+        } while ( pPos );
+
+        drawcontinue:
+
+        if ( !draw )
+            return;
+
+        if ( !full )
+        {
+            pPos = const_cast<SwLinePortion *>(&rPor);
+            nIdx = GetIdx();
+
+            nLen = pPos->GetLen();
+            for ( int i = (nIdx + nLen - 1); i >= nIdx; --i )
+            {
+                if ( GetText()[i] == CH_TXTATR_NEWLINE )
+                {
+                    continue;
+                }
+                if ( GetText()[i] != CH_BLANK )
+                {
+                    sal_uInt16 nOldWidth = rPor.Width();
+                    sal_uInt16 nNewWidth = GetTextSize( m_pOut, nullptr, GetText(), nIdx, (i + 1 - nIdx) ).Width();
+
+                    const_cast<SwLinePortion&>(rPor).Width( nNewWidth );
+                    CalcRect( rPor, nullptr, &aIntersect, true );
+                    const_cast<SwLinePortion&>(rPor).Width( nOldWidth );
+
+                    if ( ! aIntersect.HasArea() )
+                    {
+                        return;
+                    }
+
+                    break;
+                }
+            }
+        }
+
         pTmpOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
 
         pTmpOut->SetFillColor(aFillColor);
commit b8f61b8046429030ab599862ac550e320596fd37
Author: Vitaliy Anderson <vanderson at smartru.com>
Date:   Tue Dec 20 03:00:51 2016 -0500

    tdf#104668 remove the difference between MSO and LO text alignment
    
    Change-Id: Id1964d87f6f4ec3dbcd617af2251a321c50ec428
    Reviewed-on: https://gerrit.libreoffice.org/32213
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: jan iversen <jani at documentfoundation.org>
    (cherry picked from commit 1c1747ac13a9d895df0fcba2fbb1bd266dccd74b)

diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index f9b24e02abca..e347013a4c9b 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -73,6 +73,28 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
     SwTwips nLineWidth = rInf.Width() - rInf.X();
     sal_Int32 nMaxLen = rInf.GetText().getLength() - rInf.GetIdx();
 
+    const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust();
+
+    // tdf#104668 space chars at the end should be cut
+    if ( rAdjust == SVX_ADJUST_RIGHT || rAdjust == SVX_ADJUST_CENTER )
+    {
+        sal_Int32 nSpaceCnt = 0;
+        for ( int i = (rInf.GetText().getLength() - 1); i >= rInf.GetIdx(); --i )
+        {
+            sal_Unicode cChar = rInf.GetText()[i];
+            if ( cChar != CH_BLANK && cChar != CH_FULL_BLANK )
+                break;
+            ++nSpaceCnt;
+        }
+        sal_Int32 nCharsCnt = nMaxLen - nSpaceCnt;
+        if ( nSpaceCnt && nCharsCnt < rPor.GetLen() )
+        {
+            nMaxLen = nCharsCnt;
+            if ( !nMaxLen )
+                return true;
+        }
+    }
+
     if ( rInf.GetLen() < nMaxLen )
         nMaxLen = rInf.GetLen();
 
@@ -212,7 +234,6 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
         nBreakPos = nCutPos;
         sal_Int32 nX = nBreakPos;
 
-        const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust();
         if ( rAdjust == SVX_ADJUST_LEFT )
         {
             // we step back until a non blank character has been found
@@ -423,7 +444,6 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
                 CHAR_SOFTHYPHEN == rInf.GetText()[ nBreakPos - 1 ] )
                 nBreakPos = rInf.GetIdx() - 1;
 
-            const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust();
             if( rAdjust != SVX_ADJUST_LEFT )
             {
                 // Delete any blanks at the end of a line, but be careful:


More information about the Libreoffice-commits mailing list