a944f99
From 92d793255590d660e28081287235fc5b36151a74 Mon Sep 17 00:00:00 2001
a944f99
From: Michael Stahl <mstahl@redhat.com>
a944f99
Date: Thu, 30 Oct 2014 15:12:33 +0100
a944f99
Subject: [PATCH 2/2] fdo#79602: sw: add new compatibiltiy flag
a944f99
 PropLineSpacingShrinksFirstLine
a944f99
a944f99
This is enabled by default, to get the new formatting where the first
a944f99
line of a paragraph is shrunk if a proportional line spacing < 100% is
a944f99
applied; existing OOo documents get the previous (before LO 3.3)
a944f99
formatting.  Since the formatting in LO releases is broken anyway, it
a944f99
does not matter much which way documents written by old LO get
a944f99
formatted.
a944f99
a944f99
(cherry picked from commit 9605763e3dc8c85137787c77c31e8639553a35ed)
a944f99
a944f99
Conflicts:
a944f99
	sw/source/filter/ww8/ww8par.cxx
a944f99
a944f99
Reviewed-on: https://gerrit.libreoffice.org/12157
a944f99
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
a944f99
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
a944f99
(cherry picked from commit cff2323e10161d3cbbdba088e8ec74aee3839c62)
a944f99
a944f99
Conflicts:
a944f99
	sw/source/core/doc/DocumentSettingManager.cxx
a944f99
	sw/source/core/inc/DocumentSettingManager.hxx
a944f99
	sw/source/filter/xml/xmlimp.cxx
a944f99
	sw/source/ui/uno/SwXDocumentSettings.cxx
a944f99
a944f99
Change-Id: I0952f568a933c137bd03070759989cac3517d8b9
a944f99
---
a944f99
 sw/inc/IDocumentSettingAccess.hxx           |  3 ++-
a944f99
 sw/inc/doc.hxx                              |  1 +
a944f99
 sw/source/core/doc/doc.cxx                  |  5 +++++
a944f99
 sw/source/core/doc/docnew.cxx               |  1 +
a944f99
 sw/source/core/text/itrform2.cxx            |  3 ++-
a944f99
 sw/source/filter/ww8/ww8par.cxx             |  1 +
a944f99
 sw/source/filter/xml/xmlimp.cxx             | 10 ++++++++++
a944f99
 sw/source/ui/uno/SwXDocumentSettings.cxx    | 21 ++++++++++++++++++++-
a944f99
 writerfilter/source/filter/ImportFilter.cxx |  1 +
a944f99
 9 files changed, 43 insertions(+), 3 deletions(-)
a944f99
a944f99
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
a944f99
index 4e94a1e..a67d469 100644
a944f99
--- a/sw/inc/IDocumentSettingAccess.hxx
a944f99
+++ b/sw/inc/IDocumentSettingAccess.hxx
a944f99
@@ -79,6 +79,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
a944f99
          TAB_OVER_MARGIN,
a944f99
          // MS Word still wraps text around objects with less space than LO would.
a944f99
          SURROUND_TEXT_WRAP_SMALL,
a944f99
+         PROP_LINE_SPACING_SHRINKS_FIRST_LINE,
a944f99
          // COMPATIBILITY FLAGS END
a944f99
 
a944f99
          BROWSE_MODE,
a944f99
@@ -93,7 +94,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
a944f99
          FLOATTABLE_NOMARGINS,
a944f99
          EMBED_FONTS,
a944f99
          EMBED_SYSTEM_FONTS,
a944f99
-         APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING
a944f99
+         APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
a944f99
      };
a944f99
 
a944f99
  public:
a944f99
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
a944f99
index b872119..98928a8 100644
a944f99
--- a/sw/inc/doc.hxx
a944f99
+++ b/sw/inc/doc.hxx
a944f99
@@ -581,6 +581,7 @@ private:
a944f99
     bool mbBackgroundParaOverDrawings;
a944f99
     bool mbTabOverMargin;
a944f99
     bool mbSurroundTextWrapSmall;
a944f99
+    bool mbPropLineSpacingShrinksFirstLine; // fdo#79602
a944f99
     bool mApplyParagraphMarkFormatToNumbering;
a944f99
 
a944f99
     bool mbLastBrowseMode                           : 1;
a944f99
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
a944f99
index d3c74e9..a0223ca 100644
a944f99
--- a/sw/source/core/doc/doc.cxx
a944f99
+++ b/sw/source/core/doc/doc.cxx
a944f99
@@ -192,6 +192,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
a944f99
         case BACKGROUND_PARA_OVER_DRAWINGS: return mbBackgroundParaOverDrawings;
a944f99
         case TAB_OVER_MARGIN: return mbTabOverMargin;
a944f99
         case SURROUND_TEXT_WRAP_SMALL: return mbSurroundTextWrapSmall;
a944f99
+        case PROP_LINE_SPACING_SHRINKS_FIRST_LINE: return mbPropLineSpacingShrinksFirstLine;
a944f99
 
a944f99
         case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the SwViewShell has to be asked!
a944f99
         case HTML_MODE: return mbHTMLMode;
a944f99
@@ -353,6 +354,10 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
a944f99
             mbSurroundTextWrapSmall = value;
a944f99
             break;
a944f99
 
a944f99
+        case PROP_LINE_SPACING_SHRINKS_FIRST_LINE:
a944f99
+            mbPropLineSpacingShrinksFirstLine = value;
a944f99
+            break;
a944f99
+
a944f99
         // COMPATIBILITY FLAGS END
a944f99
 
a944f99
         case BROWSE_MODE: //can be used temporary (load/save) when no SwViewShell is avaiable
a944f99
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
a944f99
index a97e616..076ac2e 100644
a944f99
--- a/sw/source/core/doc/docnew.cxx
a944f99
+++ b/sw/source/core/doc/docnew.cxx
a944f99
@@ -313,6 +313,7 @@ SwDoc::SwDoc()
a944f99
     mbBackgroundParaOverDrawings(false),
a944f99
     mbTabOverMargin(false),
a944f99
     mbSurroundTextWrapSmall(false),
a944f99
+    mbPropLineSpacingShrinksFirstLine(true),
a944f99
     mApplyParagraphMarkFormatToNumbering(false),
a944f99
     mbLastBrowseMode( false ),
a944f99
     mn32DummyCompatabilityOptions1(0),
a944f99
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
a944f99
index 459d6c3..e16e301 100644
a944f99
--- a/sw/source/core/text/itrform2.cxx
a944f99
+++ b/sw/source/core/text/itrform2.cxx
a944f99
@@ -1820,7 +1820,8 @@ void SwTxtFormatter::CalcRealHeight( sal_Bool bNewLine )
a944f99
                 case SVX_LINE_SPACE_AUTO:
a944f99
                     // shrink first line of paragraph too on spacing < 100%
a944f99
                     if (IsParaLine() &&
a944f99
-                        pSpace->GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP)
a944f99
+                        pSpace->GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP
a944f99
+                        && GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE))
a944f99
                     {
a944f99
                         long nTmp = pSpace->GetPropLineSpace();
a944f99
                         // Word will render < 50% too but it's just not readable
a944f99
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
a944f99
index b07a5d0..605fcc9 100644
a944f99
--- a/sw/source/filter/ww8/ww8par.cxx
a944f99
+++ b/sw/source/filter/ww8/ww8par.cxx
a944f99
@@ -1911,6 +1911,7 @@ void SwWW8ImplReader::ImportDop()
a944f99
     rDoc.set(IDocumentSettingAccess::CLIPPED_PICTURES, true);
a944f99
     rDoc.set(IDocumentSettingAccess::TAB_OVER_MARGIN, true);
a944f99
     rDoc.set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, true);
a944f99
+    rDoc.set(IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, true);
a944f99
 
a944f99
     //
a944f99
     // COMPATIBILITY FLAGS END
a944f99
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
a944f99
index c49a463..32a8f16 100644
a944f99
--- a/sw/source/filter/xml/xmlimp.cxx
a944f99
+++ b/sw/source/filter/xml/xmlimp.cxx
a944f99
@@ -1078,6 +1078,9 @@ void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
a944f99
         GetTextImport()->SetShowChanges( bShowRedlineChanges );
a944f99
 }
a944f99
 
a944f99
+// Note: this will be called only if there are OOo elements in settings.xml.
a944f99
+// So if a setting is missing there we can assume that it was written
a944f99
+// by an OOo/LO version that is older than the introduction of the setting!
a944f99
 void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps)
a944f99
 {
a944f99
     // this method will modify the document directly -> lock SolarMutex
a944f99
@@ -1127,6 +1130,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
a944f99
     aSet.insert(OUString("ClippedPictures"));
a944f99
     aSet.insert(OUString("BackgroundParaOverDrawings"));
a944f99
     aSet.insert(OUString("TabOverMargin"));
a944f99
+    aSet.insert(OUString("PropLineSpacingShrinksFirstLine"));
a944f99
 
a944f99
     sal_Int32 nCount = aConfigProps.getLength();
a944f99
     const PropertyValue* pValues = aConfigProps.getConstArray();
a944f99
@@ -1161,6 +1165,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
a944f99
     bool bClippedPictures = false;
a944f99
     bool bBackgroundParaOverDrawings = false;
a944f99
     bool bTabOverMargin = false;
a944f99
+    bool bPropLineSpacingShrinksFirstLine = false;
a944f99
 
a944f99
     OUString sRedlineProtectionKey( "RedlineProtectionKey" );
a944f99
 
a944f99
@@ -1255,6 +1260,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
a944f99
                     bBackgroundParaOverDrawings = true;
a944f99
                 else if ( pValues->Name == "TabOverMargin" )
a944f99
                     bTabOverMargin = true;
a944f99
+                else if ( pValues->Name == "PropLineSpacingShrinksFirstLine" )
a944f99
+                    bPropLineSpacingShrinksFirstLine = true;
a944f99
             }
a944f99
             catch( Exception& )
a944f99
             {
a944f99
@@ -1444,6 +1451,9 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
a944f99
     if ( !bTabOverMargin )
a944f99
         xProps->setPropertyValue("TabOverMargin", makeAny( false ) );
a944f99
 
a944f99
+    if (!bPropLineSpacingShrinksFirstLine)
a944f99
+        xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", makeAny(false));
a944f99
+
a944f99
     SwDoc *pDoc = getDoc();
a944f99
     SfxPrinter *pPrinter = pDoc->getPrinter( false );
a944f99
     if( pPrinter )
a944f99
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
a944f99
index cf47b1c..3b9497d 100644
a944f99
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
a944f99
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
a944f99
@@ -124,7 +124,8 @@ enum SwDocumentSettingsPropertyHandles
a944f99
     HANDLE_EMBED_SYSTEM_FONTS,
a944f99
     HANDLE_TAB_OVER_MARGIN,
a944f99
     HANDLE_SURROUND_TEXT_WRAP_SMALL,
a944f99
-    HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING
a944f99
+    HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
a944f99
+    HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE,
a944f99
 };
a944f99
 
a944f99
 static MasterPropertySetInfo * lcl_createSettingsInfo()
a944f99
@@ -196,6 +197,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
a944f99
         { RTL_CONSTASCII_STRINGPARAM("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, CPPUTYPE_BOOLEAN, 0, 0},
a944f99
         { RTL_CONSTASCII_STRINGPARAM("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, CPPUTYPE_BOOLEAN, 0, 0},
a944f99
         { RTL_CONSTASCII_STRINGPARAM("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0},
a944f99
+        { RTL_CONSTASCII_STRINGPARAM("PropLineSpacingShrinksFirstLine"), HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, CPPUTYPE_BOOLEAN, 0,   0},
a944f99
 /*
a944f99
  * As OS said, we don't have a view when we need to set this, so I have to
a944f99
  * find another solution before adding them to this property set - MTG
a944f99
@@ -806,6 +808,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
a944f99
             mpDoc->set(IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, bTmp);
a944f99
         }
a944f99
         break;
a944f99
+        case HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE:
a944f99
+        {
a944f99
+            bool bTmp;
a944f99
+            if (rValue >>= bTmp)
a944f99
+            {
a944f99
+                mpDoc->set(
a944f99
+                    IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, bTmp);
a944f99
+            }
a944f99
+        }
a944f99
+        break;
a944f99
         default:
a944f99
             throw UnknownPropertyException();
a944f99
     }
a944f99
@@ -1232,6 +1244,13 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
a944f99
             rValue.setValue( &bTmp, ::getBooleanCppuType() );
a944f99
         }
a944f99
         break;
a944f99
+        case HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE:
a944f99
+        {
a944f99
+            sal_Bool const bTmp(mpDoc->get(
a944f99
+                IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE));
a944f99
+            rValue <<= bTmp;
a944f99
+        }
a944f99
+        break;
a944f99
         default:
a944f99
             throw UnknownPropertyException();
a944f99
     }
a944f99
diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
a944f99
index 0fa211c..67d08c8 100644
a944f99
--- a/writerfilter/source/filter/ImportFilter.cxx
a944f99
+++ b/writerfilter/source/filter/ImportFilter.cxx
a944f99
@@ -288,6 +288,7 @@ void WriterFilter::setTargetDocument( const uno::Reference< lang::XComponent >&
a944f99
    xSettings->setPropertyValue( "ClippedPictures", uno::makeAny( sal_True ) );
a944f99
    xSettings->setPropertyValue( "BackgroundParaOverDrawings", uno::makeAny( sal_True ) );
a944f99
    xSettings->setPropertyValue( "TabOverMargin", uno::makeAny( sal_True ) );
a944f99
+   xSettings->setPropertyValue("PropLineSpacingShrinksFirstLine", uno::makeAny(sal_True));
a944f99
 }
a944f99
 
a944f99
 void WriterFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
a944f99
-- 
a944f99
1.9.3
a944f99