diff options
author | Katarina Machalkova <kmachalkova@suse.cz> | 2010-10-13 18:15:06 +0200 |
---|---|---|
committer | Katarina Machalkova <kmachalkova@suse.cz> | 2010-10-13 19:57:41 +0200 |
commit | 2fa5955d7fc7ed1aaeca236f6b87f0d40e5cd969 (patch) | |
tree | 21c02679852370dc2100a890ad6be48f958add88 /oox | |
parent | afc5c31646cc2108d788edee5d1ba1939430f773 (diff) |
Merged ooxml-sc-page-date-imp.diff from ooo-build
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/xls/pagesettings.hxx | 2 | ||||
-rw-r--r-- | oox/inc/oox/xls/workbooksettings.hxx | 3 | ||||
-rw-r--r-- | oox/source/xls/pagesettings.cxx | 42 | ||||
-rw-r--r-- | oox/source/xls/workbooksettings.cxx | 23 | ||||
-rw-r--r-- | oox/util/makefile.mk | 1 |
5 files changed, 60 insertions, 11 deletions
diff --git a/oox/inc/oox/xls/pagesettings.hxx b/oox/inc/oox/xls/pagesettings.hxx index eb163daf94c8..df2b237dc51a 100644 --- a/oox/inc/oox/xls/pagesettings.hxx +++ b/oox/inc/oox/xls/pagesettings.hxx @@ -58,6 +58,8 @@ struct PageSettingsModel double mfHeaderMargin; /// Margin between top edge of page and begin of header. double mfFooterMargin; /// Margin between end of footer and bottom edge of page. sal_Int32 mnPaperSize; /// Paper size (enumeration). + sal_Int32 mnPaperWidth; /// Paper width in twips + sal_Int32 mnPaperHeight; /// Paper height in twips sal_Int32 mnCopies; /// Number of copies to print. sal_Int32 mnScale; /// Page scale (zoom in percent). sal_Int32 mnFirstPage; /// First page number. diff --git a/oox/inc/oox/xls/workbooksettings.hxx b/oox/inc/oox/xls/workbooksettings.hxx index 8ba322103955..c9472e7be851 100644 --- a/oox/inc/oox/xls/workbooksettings.hxx +++ b/oox/inc/oox/xls/workbooksettings.hxx @@ -57,6 +57,7 @@ struct WorkbookSettingsModel sal_Int32 mnUpdateLinksMode; /// Specifies how external links are updated. sal_Int32 mnDefaultThemeVer; /// Default theme version. bool mbDateMode1904; /// True = null date is 1904-01-01. + bool mbDateCompatibility; /// False = null date is 1899-12-30. bool mbSaveExtLinkValues; /// True = save cached cell values for external links. explicit WorkbookSettingsModel(); @@ -148,7 +149,7 @@ public: private: /** Updates date mode and unit converter nulldate. */ - void setDateMode( bool bDateMode1904 ); + void setDateMode( bool bDateMode1904, bool bDateCompatibility=true ); private: FileSharingModel maFileSharing; diff --git a/oox/source/xls/pagesettings.cxx b/oox/source/xls/pagesettings.cxx index b6b84c67a7c2..907cdf2a384d 100644 --- a/oox/source/xls/pagesettings.cxx +++ b/oox/source/xls/pagesettings.cxx @@ -50,6 +50,8 @@ #include "oox/xls/excelhandlers.hxx" #include "oox/xls/stylesbuffer.hxx" #include "oox/xls/unitconverter.hxx" +#include "tools/mapunit.hxx" +#include "xmloff/xmluconv.hxx" using ::rtl::OString; using ::rtl::OStringBuffer; @@ -130,6 +132,8 @@ PageSettingsModel::PageSettingsModel() : mfHeaderMargin( OOX_MARGIN_DEFAULT_HF ), mfFooterMargin( OOX_MARGIN_DEFAULT_HF ), mnPaperSize( 1 ), + mnPaperWidth( 0 ), + mnPaperHeight( 0 ), mnCopies( 1 ), mnScale( 100 ), mnFirstPage( 1 ), @@ -188,8 +192,13 @@ void PageSettings::importPageMargins( const AttributeList& rAttribs ) void PageSettings::importPageSetup( const Relations& rRelations, const AttributeList& rAttribs ) { + OUString aStr; maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 ); + aStr = rAttribs.getString ( XML_paperWidth, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperWidth, aStr, MAP_100TH_MM ); + aStr = rAttribs.getString ( XML_paperHeight, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperHeight, aStr, MAP_100TH_MM ); maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 ); maModel.mnScale = rAttribs.getInteger( XML_scale, 100 ); maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 ); @@ -209,8 +218,13 @@ void PageSettings::importPageSetup( const Relations& rRelations, const Attribute void PageSettings::importChartPageSetup( const Relations& rRelations, const AttributeList& rAttribs ) { + OUString aStr; maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 ); + aStr = rAttribs.getString ( XML_paperWidth, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperWidth, aStr, MAP_100TH_MM ); + aStr = rAttribs.getString ( XML_paperHeight, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperHeight, aStr, MAP_100TH_MM ); maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 ); maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 ); maModel.mnHorPrintRes = rAttribs.getInteger( XML_horizontalDpi, 600 ); @@ -1142,13 +1156,29 @@ void PageSettingsConverter::writePageSettingsProperties( bLandscape = bChartSheet; // paper size - if( rModel.mbValidSettings && (0 < rModel.mnPaperSize) && (rModel.mnPaperSize < static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( spPaperSizeTable ) )) ) + if( !rModel.mbValidSettings ) { - const ApiPaperSize& rPaperSize = spPaperSizeTable[ rModel.mnPaperSize ]; - Size aSize( rPaperSize.mnWidth, rPaperSize.mnHeight ); - if( bLandscape ) - ::std::swap( aSize.Width, aSize.Height ); - rPropSet.setProperty( PROP_Size, aSize ); + Size aSize; + bool bValid = false; + + if( (0 < rModel.mnPaperSize) && (rModel.mnPaperSize < static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( spPaperSizeTable ) )) ) + { + const ApiPaperSize& rPaperSize = spPaperSizeTable[ rModel.mnPaperSize ]; + aSize = Size( rPaperSize.mnWidth, rPaperSize.mnHeight ); + bValid = true; + } + if( rModel.mnPaperWidth > 0 && rModel.mnPaperHeight > 0 ) + { + aSize = Size( rModel.mnPaperWidth, rModel.mnPaperHeight ); + bValid = true; + } + + if( bValid ) + { + if( bLandscape ) + ::std::swap( aSize.Width, aSize.Height ); + rPropSet.setProperty( PROP_Size, aSize ); + } } // header/footer diff --git a/oox/source/xls/workbooksettings.cxx b/oox/source/xls/workbooksettings.cxx index ae2c88a1c7ab..711cc9ac8e0d 100644 --- a/oox/source/xls/workbooksettings.cxx +++ b/oox/source/xls/workbooksettings.cxx @@ -36,6 +36,7 @@ #include "oox/helper/propertyset.hxx" #include "oox/helper/recordinputstream.hxx" #include "oox/core/filterbase.hxx" +#include "oox/core/xmlfilterbase.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/unitconverter.hxx" @@ -141,7 +142,7 @@ void WorkbookSettings::importWorkbookPr( const AttributeList& rAttribs ) maBookSettings.mnUpdateLinksMode = rAttribs.getToken( XML_updateLinks, XML_userSet ); maBookSettings.mnDefaultThemeVer = rAttribs.getInteger( XML_defaultThemeVersion, -1 ); maBookSettings.mbSaveExtLinkValues = rAttribs.getBool( XML_saveExternalLinkValues, true ); - setDateMode( rAttribs.getBool( XML_date1904, false ) ); + setDateMode( rAttribs.getBool( XML_date1904, false ), rAttribs.getBool( XML_dateCompatibility, true ) ); } void WorkbookSettings::importCalcPr( const AttributeList& rAttribs ) @@ -354,13 +355,27 @@ sal_Int16 WorkbookSettings::getApiShowObjectMode() const Date WorkbookSettings::getNullDate() const { - static const Date saDate1900( 30, 12, 1899 ), saDate1904( 1, 1, 1904 ); + static const Date saDate1900 ( 30, 12, 1899 ); + static const Date saDate1904 ( 1, 1, 1904 ); + static const Date saDateBackCompatibility1900( 31, 12, 1899 ); + + if( getOoxFilter().getVersion() == oox::core::ISOIEC_29500_2008 ) + { + if( !maBookSettings.mbDateCompatibility ) + return saDate1900; + + return maBookSettings.mbDateMode1904 ? saDate1904 : + saDateBackCompatibility1900; + } + return maBookSettings.mbDateMode1904 ? saDate1904 : saDate1900; } -void WorkbookSettings::setDateMode( bool bDateMode1904 ) +void WorkbookSettings::setDateMode( bool bDateMode1904, bool bDateCompatibility ) { - maBookSettings.mbDateMode1904 = bDateMode1904; + maBookSettings.mbDateMode1904 = bDateMode1904; + maBookSettings.mbDateCompatibility = bDateCompatibility; + getUnitConverter().finalizeNullDate( getNullDate() ); } diff --git a/oox/util/makefile.mk b/oox/util/makefile.mk index a8ba80c480e5..ff4ca038a483 100644 --- a/oox/util/makefile.mk +++ b/oox/util/makefile.mk @@ -78,6 +78,7 @@ SHL1STDLIBS= \ $(SVLLIB) \ $(MSFILTERLIB) \ $(UNOTOOLSLIB) \ + $(XMLOFFLIB) \ $(TOOLSLIB) # link openssl, copied this bit from ucb/source/ucp/webdav/makefile.mk |