Kaydet (Commit) 9605763e authored tarafından Michael Stahl's avatar Michael Stahl

fdo#79602: sw: add new compatibiltiy flag PropLineSpacingShrinksFirstLine

This is enabled by default, to get the new formatting where the first
line of a paragraph is shrunk if a proportional line spacing < 100% is
applied; existing OOo documents get the previous (before LO 3.3)
formatting.  Since the formatting in LO releases is broken anyway, it
does not matter much which way documents written by old LO get
formatted.

Change-Id: I0952f568a933c137bd03070759989cac3517d8b9
üst 4e223fab
...@@ -79,6 +79,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd ...@@ -79,6 +79,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
TAB_OVER_MARGIN, TAB_OVER_MARGIN,
// MS Word still wraps text around objects with less space than LO would. // MS Word still wraps text around objects with less space than LO would.
SURROUND_TEXT_WRAP_SMALL, SURROUND_TEXT_WRAP_SMALL,
PROP_LINE_SPACING_SHRINKS_FIRST_LINE,
// COMPATIBILITY FLAGS END // COMPATIBILITY FLAGS END
BROWSE_MODE, BROWSE_MODE,
...@@ -93,7 +94,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd ...@@ -93,7 +94,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
FLOATTABLE_NOMARGINS, FLOATTABLE_NOMARGINS,
EMBED_FONTS, EMBED_FONTS,
EMBED_SYSTEM_FONTS, EMBED_SYSTEM_FONTS,
APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
}; };
public: public:
......
...@@ -80,6 +80,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) ...@@ -80,6 +80,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbBackgroundParaOverDrawings(false), mbBackgroundParaOverDrawings(false),
mbTabOverMargin(false), mbTabOverMargin(false),
mbSurroundTextWrapSmall(false), mbSurroundTextWrapSmall(false),
mbPropLineSpacingShrinksFirstLine(true),
mApplyParagraphMarkFormatToNumbering(false), mApplyParagraphMarkFormatToNumbering(false),
mbLastBrowseMode( false ) mbLastBrowseMode( false )
...@@ -154,6 +155,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const ...@@ -154,6 +155,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
case BACKGROUND_PARA_OVER_DRAWINGS: return mbBackgroundParaOverDrawings; case BACKGROUND_PARA_OVER_DRAWINGS: return mbBackgroundParaOverDrawings;
case TAB_OVER_MARGIN: return mbTabOverMargin; case TAB_OVER_MARGIN: return mbTabOverMargin;
case SURROUND_TEXT_WRAP_SMALL: return mbSurroundTextWrapSmall; case SURROUND_TEXT_WRAP_SMALL: return mbSurroundTextWrapSmall;
case PROP_LINE_SPACING_SHRINKS_FIRST_LINE: return mbPropLineSpacingShrinksFirstLine;
case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the SwViewShell has to be asked! case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the SwViewShell has to be asked!
case HTML_MODE: return mbHTMLMode; case HTML_MODE: return mbHTMLMode;
...@@ -316,6 +318,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo ...@@ -316,6 +318,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
mbSurroundTextWrapSmall = value; mbSurroundTextWrapSmall = value;
break; break;
case PROP_LINE_SPACING_SHRINKS_FIRST_LINE:
mbPropLineSpacingShrinksFirstLine = value;
break;
// COMPATIBILITY FLAGS END // COMPATIBILITY FLAGS END
case BROWSE_MODE: //can be used temporary (load/save) when no SwViewShell is available case BROWSE_MODE: //can be used temporary (load/save) when no SwViewShell is available
......
...@@ -147,6 +147,7 @@ class DocumentSettingManager : ...@@ -147,6 +147,7 @@ class DocumentSettingManager :
bool mbBackgroundParaOverDrawings; bool mbBackgroundParaOverDrawings;
bool mbTabOverMargin; bool mbTabOverMargin;
bool mbSurroundTextWrapSmall; bool mbSurroundTextWrapSmall;
bool mbPropLineSpacingShrinksFirstLine; // fdo#79602
bool mApplyParagraphMarkFormatToNumbering; bool mApplyParagraphMarkFormatToNumbering;
bool mbLastBrowseMode : 1; bool mbLastBrowseMode : 1;
......
...@@ -1744,7 +1744,8 @@ void SwTxtFormatter::CalcRealHeight( bool bNewLine ) ...@@ -1744,7 +1744,8 @@ void SwTxtFormatter::CalcRealHeight( bool bNewLine )
case SVX_LINE_SPACE_AUTO: case SVX_LINE_SPACE_AUTO:
// shrink first line of paragraph too on spacing < 100% // shrink first line of paragraph too on spacing < 100%
if (IsParaLine() && if (IsParaLine() &&
pSpace->GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP) pSpace->GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP
&& GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE))
{ {
long nTmp = pSpace->GetPropLineSpace(); long nTmp = pSpace->GetPropLineSpace();
// Word will render < 50% too but it's just not readable // Word will render < 50% too but it's just not readable
......
...@@ -1945,6 +1945,7 @@ void SwWW8ImplReader::ImportDop() ...@@ -1945,6 +1945,7 @@ void SwWW8ImplReader::ImportDop()
rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::CLIPPED_PICTURES, true); rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::CLIPPED_PICTURES, true);
rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::TAB_OVER_MARGIN, true); rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::TAB_OVER_MARGIN, true);
rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, true); rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, true);
rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, true);
// COMPATIBILITY FLAGS END // COMPATIBILITY FLAGS END
......
...@@ -1064,6 +1064,9 @@ void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps) ...@@ -1064,6 +1064,9 @@ void SwXMLImport::SetViewSettings(const Sequence < PropertyValue > & aViewProps)
GetTextImport()->SetShowChanges( bShowRedlineChanges ); GetTextImport()->SetShowChanges( bShowRedlineChanges );
} }
// Note: this will be called only if there are OOo elements in settings.xml.
// So if a setting is missing there we can assume that it was written
// by an OOo/LO version that is older than the introduction of the setting!
void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps) void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aConfigProps)
{ {
// this method will modify the document directly -> lock SolarMutex // this method will modify the document directly -> lock SolarMutex
...@@ -1113,6 +1116,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC ...@@ -1113,6 +1116,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
aSet.insert("ClippedPictures"); aSet.insert("ClippedPictures");
aSet.insert("BackgroundParaOverDrawings"); aSet.insert("BackgroundParaOverDrawings");
aSet.insert("TabOverMargin"); aSet.insert("TabOverMargin");
aSet.insert("PropLineSpacingShrinksFirstLine");
sal_Int32 nCount = aConfigProps.getLength(); sal_Int32 nCount = aConfigProps.getLength();
const PropertyValue* pValues = aConfigProps.getConstArray(); const PropertyValue* pValues = aConfigProps.getConstArray();
...@@ -1147,6 +1151,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC ...@@ -1147,6 +1151,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bool bClippedPictures = false; bool bClippedPictures = false;
bool bBackgroundParaOverDrawings = false; bool bBackgroundParaOverDrawings = false;
bool bTabOverMargin = false; bool bTabOverMargin = false;
bool bPropLineSpacingShrinksFirstLine = false;
const PropertyValue* currentDatabaseDataSource = NULL; const PropertyValue* currentDatabaseDataSource = NULL;
const PropertyValue* currentDatabaseCommand = NULL; const PropertyValue* currentDatabaseCommand = NULL;
...@@ -1234,6 +1239,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC ...@@ -1234,6 +1239,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bBackgroundParaOverDrawings = true; bBackgroundParaOverDrawings = true;
else if ( pValues->Name == "TabOverMargin" ) else if ( pValues->Name == "TabOverMargin" )
bTabOverMargin = true; bTabOverMargin = true;
else if ( pValues->Name == "PropLineSpacingShrinksFirstLine" )
bPropLineSpacingShrinksFirstLine = true;
} }
catch( Exception& ) catch( Exception& )
{ {
...@@ -1409,6 +1416,9 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC ...@@ -1409,6 +1416,9 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
if ( !bTabOverMargin ) if ( !bTabOverMargin )
xProps->setPropertyValue("TabOverMargin", makeAny( false ) ); xProps->setPropertyValue("TabOverMargin", makeAny( false ) );
if (!bPropLineSpacingShrinksFirstLine)
xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", makeAny(false));
SwDoc *pDoc = getDoc(); SwDoc *pDoc = getDoc();
SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( false ); SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( false );
if( pPrinter ) if( pPrinter )
......
...@@ -126,7 +126,8 @@ enum SwDocumentSettingsPropertyHandles ...@@ -126,7 +126,8 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_EMBED_SYSTEM_FONTS, HANDLE_EMBED_SYSTEM_FONTS,
HANDLE_TAB_OVER_MARGIN, HANDLE_TAB_OVER_MARGIN,
HANDLE_SURROUND_TEXT_WRAP_SMALL, HANDLE_SURROUND_TEXT_WRAP_SMALL,
HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE,
}; };
static MasterPropertySetInfo * lcl_createSettingsInfo() static MasterPropertySetInfo * lcl_createSettingsInfo()
...@@ -198,6 +199,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() ...@@ -198,6 +199,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0, 0}, { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0, 0},
{ OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0, 0}, { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0, 0},
{ OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType<bool>::get(), 0, 0}, { OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType<bool>::get(), 0, 0},
{ OUString("PropLineSpacingShrinksFirstLine"), HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, cppu::UnoType<bool>::get(), 0, 0},
/* /*
* As OS said, we don't have a view when we need to set this, so I have to * As OS said, we don't have a view when we need to set this, so I have to
* find another solution before adding them to this property set - MTG * find another solution before adding them to this property set - MTG
...@@ -805,6 +807,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf ...@@ -805,6 +807,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->getIDocumentSettingAccess().set(IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, bTmp); mpDoc->getIDocumentSettingAccess().set(IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, bTmp);
} }
break; break;
case HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE:
{
bool bTmp;
if (rValue >>= bTmp)
{
mpDoc->getIDocumentSettingAccess().set(
IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE, bTmp);
}
}
break;
default: default:
throw UnknownPropertyException(); throw UnknownPropertyException();
} }
...@@ -1234,6 +1246,13 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf ...@@ -1234,6 +1246,13 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue.setValue( &bTmp, ::getBooleanCppuType() ); rValue.setValue( &bTmp, ::getBooleanCppuType() );
} }
break; break;
case HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE:
{
sal_Bool const bTmp(mpDoc->getIDocumentSettingAccess().get(
IDocumentSettingAccess::PROP_LINE_SPACING_SHRINKS_FIRST_LINE));
rValue <<= bTmp;
}
break;
default: default:
throw UnknownPropertyException(); throw UnknownPropertyException();
} }
......
...@@ -209,6 +209,7 @@ void WriterFilter::setTargetDocument( const uno::Reference< lang::XComponent >& ...@@ -209,6 +209,7 @@ void WriterFilter::setTargetDocument( const uno::Reference< lang::XComponent >&
xSettings->setPropertyValue( "ClippedPictures", uno::makeAny( sal_True ) ); xSettings->setPropertyValue( "ClippedPictures", uno::makeAny( sal_True ) );
xSettings->setPropertyValue( "BackgroundParaOverDrawings", uno::makeAny( sal_True ) ); xSettings->setPropertyValue( "BackgroundParaOverDrawings", uno::makeAny( sal_True ) );
xSettings->setPropertyValue( "TabOverMargin", uno::makeAny( sal_True ) ); xSettings->setPropertyValue( "TabOverMargin", uno::makeAny( sal_True ) );
xSettings->setPropertyValue("PropLineSpacingShrinksFirstLine", uno::makeAny(sal_True));
} }
void WriterFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc ) void WriterFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment