summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-05-20 14:44:03 +0200
committerLuboš Luňák <l.lunak@suse.cz>2011-05-20 14:56:39 +0200
commit450ce7ee52672e77c6e5fe601d0ed3c416a60b16 (patch)
treeea84092afae99f16bbd08a6c9b49c173accb0d63
parent321c15e393af69a9100ce8fa018b427cf2891902 (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 :-/.
-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 266be7faca..4e83e72cd2 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 4ff6238c1d..72df51d048 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 aecba23d2e..b456ed5dd9 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 49d4dea287..0527ab95e7 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 bd2963419b..c26ba79857 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 4ee0af6e1d..440e169906 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 3dfd5235ed..458155dccd 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 2d23af0140..31b97f86ff 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1185,6 +1185,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();
@@ -1213,6 +1214,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" ) );
@@ -1280,6 +1282,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& )
{
@@ -1423,6 +1427,16 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
OUString( RTL_CONSTASCII_USTRINGPARAM("UseOldPrinterMetrics") ), makeAny( true ) );
}
+ // 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 50c9e6e951..e2014b7a25 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -121,7 +121,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()
@@ -179,6 +180,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
@@ -703,6 +705,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();
}
@@ -1047,6 +1055,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();
}