chart2/CppunitTest_chart2_export.mk | 1 chart2/CppunitTest_chart2_import.mk | 1 chart2/qa/extras/chart2import.cxx | 53 +++++++++++++++++++++ chart2/qa/extras/charttest.hxx | 14 +++++ chart2/qa/extras/data/xlsx/number-formats.xlsx |binary include/oox/drawingml/chart/objectformatter.hxx | 3 - oox/source/drawingml/chart/axisconverter.cxx | 2 oox/source/drawingml/chart/chartconverter.cxx | 7 ++ oox/source/drawingml/chart/chartspaceconverter.cxx | 14 ----- oox/source/drawingml/chart/objectformatter.cxx | 24 +++++---- oox/source/drawingml/chart/seriesconverter.cxx | 2 sw/qa/extras/ooxmlimport/data/fdo79535.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 11 ++++ sw/source/core/doc/docredln.cxx | 3 - 14 files changed, 107 insertions(+), 28 deletions(-)
New commits: commit bea4100cd9ad62637a7ed33488f2a17769aa519a Author: Tushar Bende <[email protected]> Date: Wed Jun 4 15:04:18 2014 +0530 fdo#79535 :LO writer crash while Opening some document. Problem Description : While setting ExtraData for Redline LO calls SwRangeRedline::SetExtraData() with argument of type SwRedlineExtraData_FormattingChanges* which contains SfxItemSet* In function SwRedlineExtraData_FormattingChanges() without Null checking SfxItemSet*, LO was trying to get rCpy.pSet->Count() which was the reason for segmentation fault while opening some documents in LO. Added Null check before accessing a pointer. Change-Id: I33299d2be2777ab6a8af0621595c9453145f1069 Reviewed-on: https://gerrit.libreoffice.org/9647 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit 8fcd4bf323bc3390e366229d549641444b5a3e9a) diff --git a/sw/qa/extras/ooxmlimport/data/fdo79535.docx b/sw/qa/extras/ooxmlimport/data/fdo79535.docx new file mode 100644 index 0000000..64aab18 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo79535.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 9dab8ea..305b6ed 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2164,6 +2164,17 @@ DECLARE_OOXMLIMPORT_TEST(testFdo78883, "fdo78883.docx") CPPUNIT_ASSERT(xCursor->getPage() > sal_Int16(0)); } +DECLARE_OOXMLIMPORT_TEST(testFdo79535, "fdo79535.docx") +{ + // fdo#79535 : LO was crashing while opening document + // Checking there is a single page after loading a doc successfully in LO. + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); +} + DECLARE_OOXMLIMPORT_TEST(testBnc875718, "bnc875718.docx") { // The frame in the footer must not accidentally end up in the document body. diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 64887a1..cb1520a 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -3204,7 +3204,8 @@ SwRedlineExtraData_FormattingChanges::SwRedlineExtraData_FormattingChanges( cons SwRedlineExtraData_FormattingChanges::SwRedlineExtraData_FormattingChanges( const SwRedlineExtraData_FormattingChanges& rCpy ) : SwRedlineExtraData() { - if( rCpy.pSet->Count() ) + // Checking pointer pSet before accessing it for Count + if( rCpy.pSet && rCpy.pSet->Count() ) { pSet = new SfxItemSet( *(rCpy.pSet) ); } commit 7c3dd4a9c1a05bbb6867ca6db6229da38f5f68ed Author: Matúš Kukan <[email protected]> Date: Thu Sep 11 08:56:22 2014 +0200 bnc#892610: OOXML import: Improve chart number formats. If sourceLinked is used, do not set "PercentageNumberFormat" even if showPercent is true. The format string should be used for "NumberFormat". c8cc89ff802d86b1f3a69afe1b4835b7df7f70c7 unnecessarily disabled "LinkNumberFormatToSource". Use that for data labels but not for axis. Also, actually make attaching number format supplier work for Calc. Previously, non standard formats were added into wrong supplier, and they were thrown away later because it was attached too late. (See also ChartModel::attachNumberFormatsSupplier) (cherry picked from commit d22a4d945ccf1456fbdb2c39802d956afa583a2a) Conflicts: chart2/qa/extras/chart2import.cxx oox/source/drawingml/chart/chartconverter.cxx Change-Id: Iaf9945abc3d82d0ac63d9f36b8888eb49f39ab57 Reviewed-on: https://gerrit.libreoffice.org/11414 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/chart2/CppunitTest_chart2_export.mk b/chart2/CppunitTest_chart2_export.mk index 55127d7..e2a3f31 100644 --- a/chart2/CppunitTest_chart2_export.mk +++ b/chart2/CppunitTest_chart2_export.mk @@ -60,6 +60,7 @@ $(eval $(call gb_CppunitTest_use_libraries,chart2_export, \ )) $(eval $(call gb_CppunitTest_set_include,chart2_export,\ + -I$(SRCDIR)/chart2/inc \ $$(INCLUDE) \ )) diff --git a/chart2/CppunitTest_chart2_import.mk b/chart2/CppunitTest_chart2_import.mk index 5ae09fd..3e25b36 100644 --- a/chart2/CppunitTest_chart2_import.mk +++ b/chart2/CppunitTest_chart2_import.mk @@ -59,6 +59,7 @@ $(eval $(call gb_CppunitTest_use_libraries,chart2_import, \ )) $(eval $(call gb_CppunitTest_set_include,chart2_import,\ + -I$(SRCDIR)/chart2/inc \ $$(INCLUDE) \ )) diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 47df59f..7cff8fd 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -11,6 +11,7 @@ #include "charttest.hxx" #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/chart2/CurveStyle.hpp> +#include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart/XChartDocument.hpp> @@ -40,6 +41,7 @@ public: void testSimpleStrictXLSX(); void testDelayedCellImport(); // chart range referencing content on later sheets void testFlatODSStackedColumnChart(); + void testNumberFormatsXLSX(); CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); @@ -65,6 +67,7 @@ public: CPPUNIT_TEST(testSimpleStrictXLSX); CPPUNIT_TEST(testDelayedCellImport); CPPUNIT_TEST(testFlatODSStackedColumnChart); + CPPUNIT_TEST(testNumberFormatsXLSX); CPPUNIT_TEST_SUITE_END(); private: @@ -384,6 +387,56 @@ void Chart2ImportTest::testFlatODSStackedColumnChart() CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aSeriesSeq.getLength()); } +void Chart2ImportTest::testNumberFormatsXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "number-formats.xlsx"); + Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference<beans::XPropertySet> xPropertySet; + chart2::DataPointLabel aLabel; + sal_Int32 nNumberFormat; + bool bLinkNumberFormatToSource = false; + bool bSuccess = false; + const sal_Int32 nChartDataNumberFormat = getNumberFormat( + xChartDoc, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"??_);_(@_)"); + + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW); + xPropertySet->getPropertyValue("Label") >>= aLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber); + CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent); + xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat); + bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(false, bSuccess); + bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); + + xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_QUERY_THROW); + xPropertySet->getPropertyValue("Label") >>= aLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber); + CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumberInPercent); + xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat); + bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(false, bSuccess); + bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); + + xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_QUERY_THROW); + xPropertySet->getPropertyValue("Label") >>= aLabel; + CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber); + CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent); + xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat); + bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(false, bSuccess); + bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 7e260cc..b933b30 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -40,6 +40,11 @@ #include <com/sun/star/chart/XChartDataArray.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/util/NumberFormat.hpp> + +#include <unonames.hxx> + #include <iostream> #include <libxml/xmlwriter.h> @@ -403,4 +408,13 @@ uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const c return seriesList; } +sal_Int32 getNumberFormat( const Reference<chart2::XChartDocument>& xChartDoc, const OUString& sFormat ) +{ + Reference<util::XNumberFormatsSupplier> xNFS(xChartDoc, uno::UNO_QUERY_THROW); + Reference<util::XNumberFormats> xNumberFormats = xNFS->getNumberFormats(); + CPPUNIT_ASSERT(xNumberFormats.is()); + + return xNumberFormats->queryKey(sFormat, css::lang::Locale(), sal_False); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/qa/extras/data/xlsx/number-formats.xlsx b/chart2/qa/extras/data/xlsx/number-formats.xlsx new file mode 100755 index 0000000..f5250c5 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/number-formats.xlsx differ diff --git a/include/oox/drawingml/chart/objectformatter.hxx b/include/oox/drawingml/chart/objectformatter.hxx index ebe5a01..d3a6a6d 100644 --- a/include/oox/drawingml/chart/objectformatter.hxx +++ b/include/oox/drawingml/chart/objectformatter.hxx @@ -131,7 +131,8 @@ public: void convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, - bool bPercentFormat = false ); + bool bAxis, + bool bShowPercent = false ); /** Sets automatic fill properties to the passed property set. */ void convertAutomaticFill( diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 4133ae1..4251bf8 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -331,7 +331,7 @@ void AxisConverter::convertFromModel( // number format ------------------------------------------------------ if( (aScaleData.AxisType == cssc2::AxisType::REALNUMBER) || (aScaleData.AxisType == cssc2::AxisType::PERCENT) ) - getFormatter().convertNumberFormat(aAxisProp, mrModel.maNumberFormat, false); + getFormatter().convertNumberFormat(aAxisProp, mrModel.maNumberFormat, true); // position of crossing axis ------------------------------------------ diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx index 35c70f5..86f1ca8 100644 --- a/oox/source/drawingml/chart/chartconverter.cxx +++ b/oox/source/drawingml/chart/chartconverter.cxx @@ -20,6 +20,8 @@ #include "oox/drawingml/chart/chartconverter.hxx" #include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include "oox/drawingml/chart/chartspaceconverter.hxx" #include "oox/drawingml/chart/chartspacemodel.hxx" #include "oox/helper/containerhelper.hxx" @@ -102,6 +104,11 @@ void ChartConverter::convertFromModel( XmlFilterBase& rFilter, OSL_ENSURE( rxChartDoc.is(), "ChartConverter::convertFromModel - missing chart document" ); if( rxChartDoc.is() ) { + Reference< data::XDataReceiver > xDataReceiver( rxChartDoc, uno::UNO_QUERY_THROW ); + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( rFilter.getModel(), uno::UNO_QUERY ); + if (xNumberFormatsSupplier.is()) + xDataReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier ); + ConverterRoot aConvBase( rFilter, *this, rChartModel, rxChartDoc, rChartSize ); ChartSpaceConverter aSpaceConv( aConvBase, rChartModel ); aSpaceConv.convertFromModel( rxExternalPage, rChartPos ); diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx index b63bfe9..232ce6e5 100644 --- a/oox/source/drawingml/chart/chartspaceconverter.cxx +++ b/oox/source/drawingml/chart/chartspaceconverter.cxx @@ -23,7 +23,6 @@ #include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XTitled.hpp> -#include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include "oox/core/xmlfilterbase.hxx" @@ -40,12 +39,10 @@ using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::makeAny; -using ::com::sun::star::util::XNumberFormatsSupplier; using ::com::sun::star::drawing::XDrawPageSupplier; using ::com::sun::star::drawing::XShapes; using ::com::sun::star::chart2::XDiagram; using ::com::sun::star::chart2::XTitled; -using ::com::sun::star::chart2::data::XDataReceiver; using ::com::sun::star::beans::XPropertySet; namespace oox { @@ -81,17 +78,6 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern derived converters may create an external data provider) */ getChartConverter()->createDataProvider( getChartDocument() ); - // attach number formatter of container document to data receiver - try - { - Reference< XDataReceiver > xDataRec( getChartDocument(), UNO_QUERY_THROW ); - Reference< XNumberFormatsSupplier > xNumFmtSupp( getFilter().getModel(), UNO_QUERY_THROW ); - xDataRec->attachNumberFormatsSupplier( xNumFmtSupp ); - } - catch( Exception& ) - { - } - // formatting of the chart background. The default fill style varies with applications. PropertySet aBackPropSet( getChartDocument()->getPageBackground() ); aBackPropSet.setProperty( diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 6360fc2..ae45550 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -1128,19 +1128,21 @@ void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef } } -void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bPercentFormat ) +void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bAxis, bool bShowPercent ) { if( mxData->mxNumFmts.is() ) { - sal_Int32 nPropId = bPercentFormat ? PROP_PercentageNumberFormat : PROP_NumberFormat; + const bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general"); + const bool bPercent = !bAxis && bShowPercent && !rNumberFormat.mbSourceLinked; + sal_Int32 nPropId = bPercent ? PROP_PercentageNumberFormat : PROP_NumberFormat; + OUString sFormatCode(rNumberFormat.maFormatCode); + if (bPercent && bGeneral) + sFormatCode = OUString("0%"); try { - bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general"); - sal_Int32 nIndex = bGeneral && !bPercentFormat ? + sal_Int32 nIndex = bGeneral && !bPercent ? mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) : - mxData->mxNumFmts->addNewConverted( - bGeneral ? OUString("0%") : rNumberFormat.maFormatCode, - mxData->maEnUsLocale, mxData->maFromLocale ); + mxData->mxNumFmts->addNewConverted( sFormatCode, mxData->maEnUsLocale, mxData->maFromLocale ); if( nIndex >= 0 ) rPropSet.setProperty( nPropId, nIndex ); } @@ -1150,9 +1152,11 @@ void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFo append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() ); } - // Format code is ignored if "LinkNumberFormatToSource" is set to "true" :-/ - // See AxisHelper::getExplicitNumberFormatKeyForAxis() - rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty())); + // Setting "LinkNumberFormatToSource" does not really work, at least not for axis :-/ + if (!bAxis) + rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.mbSourceLinked)); + else + rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty())); } } diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 6febc3f..177e9ba 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -132,7 +132,7 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt if( !rDataLabel.mbDeleted ) { // data label number format (percentage format wins over value format) - rFormatter.convertNumberFormat( rPropSet, rDataLabel.maNumberFormat, bShowPercent ); + rFormatter.convertNumberFormat( rPropSet, rDataLabel.maNumberFormat, false, bShowPercent ); // data label text formatting (frame formatting not supported by Chart2) rFormatter.convertTextFormatting( rPropSet, rDataLabel.mxTextProp, OBJECTTYPE_DATALABEL );
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
