[Libreoffice-commits] .: Branch 'libreoffice-3-4-0' - sw/inc sw/source

Jan Holesovsky kendy at kemper.freedesktop.org
Fri May 20 08:03:06 PDT 2011


 sw/inc/IDocumentSettingAccess.hxx        |    1 +
 sw/inc/doc.hxx                           |    1 +
 sw/source/core/doc/doc.cxx               |    5 +++++
 sw/source/core/doc/docnew.cxx            |    1 +
 sw/source/core/inc/swfont.hxx            |    3 ++-
 sw/source/core/txtnode/fntcap.cxx        |    9 +++++++--
 sw/source/core/txtnode/swfont.cxx        |    7 +++++++
 sw/source/filter/xml/xmlimp.cxx          |   14 ++++++++++++++
 sw/source/ui/uno/SwXDocumentSettings.cxx |   16 +++++++++++++++-
 9 files changed, 53 insertions(+), 4 deletions(-)

New commits:
commit 74df9fe4af182924c8e8e63865edc8db485c584c
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri May 20 14:44:03 2011 +0200

    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 at free.fr>
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>
    Signed-off-by: Jan Holesovsky <kendy at suse.cz>

diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 266be7f..4e83e72 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 4ff6238..72df51d 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 edcbb2d..0086fc9 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 49d4dea..0527ab9 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 bd29634..c26ba79 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 4ee0af6..440e169 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 773d9e5..b0bc6c5 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 78757d9..6f8cf88 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 639d0bd..907aaa2 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();
     }


More information about the Libreoffice-commits mailing list