summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-05-20 14:44:03 +0200
committerJan Holesovsky <kendy@suse.cz>2011-05-20 17:01:26 +0200
commiteea95136da32d09a6f82a99583dd8c158d96c1d9 (patch)
tree93450d7b642e13e9e132dbdeee04e702d0253ae0 /sw
parent25df63c405345e923d2814479ddc1c2e170a303f (diff)
compatibility option for old size of small caps (bnc#691473)
Version 3.2 had 66 as the small capitals size percentage, later changed to 80 (see e.g. http://openoffice.org/bugzilla/show_bug.cgi?id=1526). This however can destroy layout of old documents that rely on the old size. So for backwards compatibility the old value is used if either the .odt document has an option enabled or does not have the option at all (meaning it's an older .odt document). There's unfortunately a period when the new value was already in effect where this change can break those documents :-/. Signed-off-by: Cedric Bosdonnat <cedric.bosdonnat.ooo@free.fr> Signed-off-by: Michael Meeks <michael.meeks@novell.com> Signed-off-by: Jan Holesovsky <kendy@suse.cz>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx1
-rw-r--r--sw/inc/doc.hxx1
-rw-r--r--sw/source/core/doc/doc.cxx5
-rw-r--r--sw/source/core/doc/docnew.cxx1
-rw-r--r--sw/source/core/inc/swfont.hxx3
-rw-r--r--sw/source/core/txtnode/fntcap.cxx9
-rw-r--r--sw/source/core/txtnode/swfont.cxx7
-rw-r--r--sw/source/filter/xml/xmlimp.cxx14
-rw-r--r--sw/source/ui/uno/SwXDocumentSettings.cxx16
9 files changed, 53 insertions, 4 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 76e3d977d447..1dd769912c06 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -81,6 +81,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
INVERT_BORDER_SPACING,
COLLAPSE_EMPTY_CELL_PARA,
+ SMALL_CAPS_PERCENTAGE_66,
// COMPATIBILITY FLAGS END
BROWSE_MODE,
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index b90fe63e50d7..c640bafbf554 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -580,6 +580,7 @@ private:
bool mbInvertBorderSpacing : 1;
bool mbCollapseEmptyCellPara : 1;
bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above
+ bool mbSmallCapsPercentage66;
bool mbLastBrowseMode : 1;
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 7c4e1984b819..e9ea7e9f30b0 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -201,6 +201,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
case INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara;
+ case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66;
case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked!
case HTML_MODE: return mbHTMLMode;
@@ -331,6 +332,10 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
case COLLAPSE_EMPTY_CELL_PARA:
mbCollapseEmptyCellPara = value;
break;
+
+ case SMALL_CAPS_PERCENTAGE_66:
+ mbSmallCapsPercentage66 = value;
+ break;
// COMPATIBILITY FLAGS END
case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 5c18528525f7..439f83901aff 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -356,6 +356,7 @@ SwDoc::SwDoc()
mbTabAtLeftIndentForParagraphsInList = false; // hidden #i89181#
mbInvertBorderSpacing = false; // hidden
mbCollapseEmptyCellPara = true; // hidden
+ mbSmallCapsPercentage66 = false; // hidden
//
// COMPATIBILITY FLAGS END
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index f0cf7bab6a32..d99e368d861f 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -58,8 +58,9 @@ class SwSubFont : public SvxFont
sal_uInt16 nOrgHeight; // Hoehe inkl. Escapement/Proportion
sal_uInt16 nOrgAscent; // Ascent inkl. Escapement/Proportion
sal_uInt16 nPropWidth; // proportional width
+ bool smallCapsPercentage66;
inline SwSubFont() : aSize(0,0)
- { pMagic = NULL; nFntIndex = nOrgHeight = nOrgAscent = 0; nPropWidth =100; }
+ { pMagic = NULL; nFntIndex = nOrgHeight = nOrgAscent = 0; nPropWidth =100; smallCapsPercentage66 = false; }
sal_uInt16 CalcEscAscent( const sal_uInt16 nOldAscent ) const;
sal_uInt16 CalcEscHeight( const sal_uInt16 nOldHeight,
diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx
index 5696984a7dce..98337825271b 100644
--- a/sw/source/core/txtnode/fntcap.cxx
+++ b/sw/source/core/txtnode/fntcap.cxx
@@ -622,8 +622,13 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo )
else
pBigFont = pLastFont;
- // Hier entsteht der Kleinbuchstabenfont:
- aFont.SetProportion( (aFont.GetPropr() * SMALL_CAPS_PERCENTAGE ) / 100L );
+ // Older LO versions had 66 as the small caps percentage size, later changed to 80,
+ // therefore a backwards compatibility option is kept (otherwise layout is changed).
+ // NOTE: There are more uses of SMALL_CAPS_PERCENTAGE in editeng, but it seems they
+ // do not matter for Writer (and if they did it'd be pretty ugly to propagate
+ // the option there).
+ int smallCapsPercentage = smallCapsPercentage66 ? 66 : SMALL_CAPS_PERCENTAGE;
+ aFont.SetProportion( (aFont.GetPropr() * smallCapsPercentage ) / 100L );
pMagic2 = NULL;
nIndex2 = 0;
SwFntAccess *pSmallFontAccess = new SwFntAccess( pMagic2, nIndex2, &aFont,
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index cfa8036ecdce..35216ec19983 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -560,6 +560,12 @@ SwFont::SwFont( const SwAttrSet* pAttrSet,
SetVertical( pAttrSet->GetCharRotate().GetValue() );
else
SetVertical( 0 );
+ if( pIDocumentSettingAccess && pIDocumentSettingAccess->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 ))
+ {
+ aSub[ SW_LATIN ].smallCapsPercentage66 = true;
+ aSub[ SW_CJK ].smallCapsPercentage66 = true;
+ aSub[ SW_CTL ].smallCapsPercentage66 = true;
+ }
}
SwSubFont& SwSubFont::operator=( const SwSubFont &rFont )
@@ -571,6 +577,7 @@ SwSubFont& SwSubFont::operator=( const SwSubFont &rFont )
nOrgAscent = rFont.nOrgAscent;
nPropWidth = rFont.nPropWidth;
aSize = rFont.aSize;
+ smallCapsPercentage66 = rFont.smallCapsPercentage66;
return *this;
}
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index b0904f059e0b..23e7d80cfe5f 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1189,6 +1189,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
aSet.insert(String("UpdateFromTemplate", RTL_TEXTENCODING_ASCII_US));
aSet.insert(String("PrinterIndependentLayout", RTL_TEXTENCODING_ASCII_US));
aSet.insert(String("PrintEmptyPages", RTL_TEXTENCODING_ASCII_US));
+ aSet.insert(String("SmallCapsPercentage66", RTL_TEXTENCODING_ASCII_US));
sal_Int32 nCount = aConfigProps.getLength();
const PropertyValue* pValues = aConfigProps.getConstArray();
@@ -1217,6 +1218,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bool bClipAsCharacterAnchoredWriterFlyFrames( false );
bool bUnixForceZeroExtLeading = false;
bool bUseOldPrinterMetrics = false;
+ bool bSmallCapsPercentage66 = false;
OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( "RedlineProtectionKey" ) );
@@ -1284,6 +1286,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bUnixForceZeroExtLeading = true;
else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseOldPrinterMetrics")) )
bUseOldPrinterMetrics = true;
+ else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66")) )
+ bSmallCapsPercentage66 = true;
}
catch( Exception& )
{
@@ -1429,6 +1433,16 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
}
// <--
+ // Old LO versions had 66 as the value for small caps percentage, later changed to 80.
+ // In order to keep backwards compatibility, SmallCapsPercentage66 option is written to .odt
+ // files, and the default for new documents is 'false'. Files without this option
+ // are considered to be old files, so set the compatibility option too.
+ if ( !bSmallCapsPercentage66 )
+ {
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("SmallCapsPercentage66") ), makeAny( true ) );
+ }
+
Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
Reference < XText > xText = xTextDoc->getText();
Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
index a9d2f0b9b9c0..3fb2202b2a16 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -122,7 +122,8 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_MODIFYPASSWORDINFO,
HANDLE_MATH_BASELINE_ALIGNMENT,
HANDLE_INVERT_BORDER_SPACING,
- HANDLE_COLLAPSE_EMPTY_CELL_PARA
+ HANDLE_COLLAPSE_EMPTY_CELL_PARA,
+ HANDLE_SMALL_CAPS_PERCENTAGE_66
};
MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -180,6 +181,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
{ RTL_CONSTASCII_STRINGPARAM("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, CPPUTYPE_BOOLEAN, 0, 0},
/*
* 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
@@ -705,6 +707,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, bTmp);
}
break;
+ case HANDLE_SMALL_CAPS_PERCENTAGE_66:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp);
+ }
+ break;
default:
throw UnknownPropertyException();
}
@@ -1050,6 +1058,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
+ case HANDLE_SMALL_CAPS_PERCENTAGE_66:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
default:
throw UnknownPropertyException();
}