diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/core/filterdetect.hxx | 5 | ||||
-rw-r--r-- | oox/source/core/filterdetect.cxx | 28 | ||||
-rw-r--r-- | oox/source/drawingml/chart/axisconverter.cxx | 4 | ||||
-rw-r--r-- | oox/source/drawingml/chart/chartconverter.cxx | 6 | ||||
-rw-r--r-- | oox/source/drawingml/chart/objectformatter.cxx | 14 | ||||
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 45 | ||||
-rw-r--r-- | oox/source/xls/formulaparser.cxx | 6 |
7 files changed, 86 insertions, 22 deletions
diff --git a/oox/inc/oox/core/filterdetect.hxx b/oox/inc/oox/core/filterdetect.hxx index f28af86eea37..39b8abe8efb9 100644 --- a/oox/inc/oox/core/filterdetect.hxx +++ b/oox/inc/oox/core/filterdetect.hxx @@ -59,7 +59,7 @@ namespace core { class FilterDetectDocHandler : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastDocumentHandler > { public: - explicit FilterDetectDocHandler( ::rtl::OUString& rFilter ); + explicit FilterDetectDocHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, ::rtl::OUString& rFilter ); virtual ~FilterDetectDocHandler(); // XFastDocumentHandler @@ -91,6 +91,7 @@ private: ::rtl::OUString& mrFilterName; ContextVector maContextStack; ::rtl::OUString maTargetPath; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext; }; // ============================================================================ @@ -167,4 +168,4 @@ private: #endif -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index c15c9f8db410..46885bdb3a4a 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -39,6 +39,7 @@ #include "oox/helper/binaryoutputstream.hxx" #include "oox/helper/zipstorage.hxx" #include "oox/ole/olestorage.hxx" +#include <com/sun/star/uri/UriReferenceFactory.hpp> namespace oox { namespace core { @@ -57,8 +58,8 @@ using ::rtl::OUString; // ============================================================================ -FilterDetectDocHandler::FilterDetectDocHandler( OUString& rFilterName ) : - mrFilterName( rFilterName ) +FilterDetectDocHandler::FilterDetectDocHandler( const Reference< XComponentContext >& rxContext, OUString& rFilterName ) : + mrFilterName( rFilterName ), mxContext( rxContext ) { maContextStack.reserve( 2 ); } @@ -163,7 +164,24 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) { OUString aType = rAttribs.getString( XML_Type, OUString() ); if( aType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) ) ) - maTargetPath = OUString( sal_Unicode( '/' ) ) + rAttribs.getString( XML_Target, OUString() ); + { + Reference< com::sun::star::uri::XUriReferenceFactory > xFac = com::sun::star::uri::UriReferenceFactory::create( mxContext ); + try + { + // use '/' to representent the root of the zip package ( and provide a 'file' scheme to + // keep the XUriReference implementation happy ) + Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) ); + + Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse( rAttribs.getString( XML_Target, OUString() ) ); + Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute( xBase, xPart, sal_True, com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN ); + + if ( xAbs.is() ) + maTargetPath = xAbs->getPath(); + } + catch( Exception& e) + { + } + } } OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& rContentType ) const @@ -663,7 +681,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq aParser.registerNamespace( NMSP_packageRel ); aParser.registerNamespace( NMSP_officeRel ); aParser.registerNamespace( NMSP_packageContentTypes ); - aParser.setDocumentHandler( new FilterDetectDocHandler( aFilterName ) ); + aParser.setDocumentHandler( new FilterDetectDocHandler( mxContext, aFilterName ) ); /* Parse '_rels/.rels' to get the target path and '[Content_Types].xml' to determine the content type of the part at the target path. */ @@ -671,7 +689,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq aParser.parseStream( aZipStorage, CREATE_OUSTRING( "[Content_Types].xml" ) ); } } - catch( Exception& ) + catch( Exception& e ) { } diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 2225d7f5ae27..d07d28c79ae8 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -315,7 +315,11 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo // number format ------------------------------------------------------ if( (aScaleData.AxisType == cssc2::AxisType::REALNUMBER) || (aScaleData.AxisType == cssc2::AxisType::PERCENT) ) + { + if( mrModel.maNumberFormat.maFormatCode.indexOfAsciiL("%",1) >= 0) + mrModel.maNumberFormat.mbSourceLinked = false; getFormatter().convertNumberFormat( aAxisProp, mrModel.maNumberFormat ); + } // position of crossing axis ------------------------------------------ diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx index e66eca6bc0e2..261494327efd 100644 --- a/oox/source/drawingml/chart/chartconverter.cxx +++ b/oox/source/drawingml/chart/chartconverter.cxx @@ -59,7 +59,7 @@ static const sal_Unicode API_TOKEN_ARRAY_CLOSE = '}'; static const sal_Unicode API_TOKEN_ARRAY_ROWSEP = '|'; static const sal_Unicode API_TOKEN_ARRAY_COLSEP = ';'; -// Code similar to oox/source/xls/FormulaParser.cxx +// Code similar to oox/source/xls/formulabase.cxx static OUString lclGenerateApiString( const OUString& rString ) { OUString aRetString = rString; @@ -69,7 +69,7 @@ static OUString lclGenerateApiString( const OUString& rString ) return OUStringBuffer().append( sal_Unicode( '"' ) ).append( aRetString ).append( sal_Unicode( '"' ) ).makeStringAndClear(); } - static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix ) +static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix ) { OSL_ENSURE( !rMatrix.empty(), "ChartConverter::lclGenerateApiArray - missing matrix values" ); OUStringBuffer aBuffer; @@ -156,7 +156,7 @@ Reference< XDataSequence > ChartConverter::createDataSequence( const Reference< } catch( Exception& ) { - OSL_FAIL( "ExcelChartConverter::createDataSequence - cannot create data sequence" ); + OSL_FAIL( "ChartConverter::createDataSequence - cannot create data sequence" ); } } diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index af633dcfd0fa..714c26392d7d 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -190,7 +190,7 @@ static const AutoFormatEntry spNoFormats[] = AUTOFORMAT_END() }; -static const AutoFormatEntry spChartSpaceLines[] = +static const AutoFormatEntry spDataTableLines[] = { AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ), AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ), @@ -198,14 +198,6 @@ static const AutoFormatEntry spChartSpaceLines[] = AUTOFORMAT_END() }; -static const AutoFormatEntry spChartSpaceFills[] = -{ - AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ), - AUTOFORMAT_COLOR( 33, 40, THEMED_STYLE_SUBTLE, XML_lt1 ), - AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_SUBTLE, XML_dk1 ), - AUTOFORMAT_END() -}; - static const AutoFormatEntry spPlotArea2dFills[] = { AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ), @@ -519,7 +511,7 @@ struct ObjectTypeFormatEntry static const ObjectTypeFormatEntry spObjTypeFormatEntries[] = { // object type property type auto text auto line auto fill auto effect - TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, PROPERTYTYPE_COMMON, 0, spChartSpaceLines, spChartSpaceFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, PROPERTYTYPE_COMMON, 0, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, PROPERTYTYPE_COMMON, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, PROPERTYTYPE_COMMON, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ), @@ -544,7 +536,7 @@ static const ObjectTypeFormatEntry spObjTypeFormatEntries[] = TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, PROPERTYTYPE_LINEARSERIES, 0, spOtherLines ), TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, PROPERTYTYPE_COMMON, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ), TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, PROPERTYTYPE_COMMON, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ), - TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, PROPERTYTYPE_COMMON, spOtherTexts, spChartSpaceLines ) + TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, PROPERTYTYPE_COMMON, spOtherTexts, spDataTableLines ) }; #undef TYPEFORMAT_FRAME diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index f6f1ad8523ec..8a98471abca9 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> +#include <basegfx/numeric/ftools.hxx> #include "oox/drawingml/chart/datasourceconverter.hxx" #include "oox/drawingml/chart/seriesmodel.hxx" #include "oox/drawingml/chart/titleconverter.hxx" @@ -59,6 +60,15 @@ using ::rtl::OUString; namespace { +/** nastied-up sgn function - employs some gratuity around 0 - values + smaller than 0.33 are clamped to 0 + */ +int lclSgn( double nVal ) +{ + const int intVal=nVal*3; + return intVal == 0 ? 0 : (intVal < 0 ? -1 : 1); +} + Reference< XLabeledDataSequence > lclCreateLabeledDataSequence( const ConverterRoot& rParent, DataSourceModel* pValues, const OUString& rRole, @@ -114,6 +124,13 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt bool bShowValue = !rDataLabel.mbDeleted && rDataLabel.mobShowVal.get( false ); bool bShowPercent = !rDataLabel.mbDeleted && rDataLabel.mobShowPercent.get( false ) && (rTypeInfo.meTypeCategory == TYPECATEGORY_PIE); + if( bShowValue && + !bShowPercent && rTypeInfo.meTypeCategory == TYPECATEGORY_PIE && + rDataLabel.maNumberFormat.maFormatCode.indexOfAsciiL("%", 1) >= 0 ) + { + bShowValue = false; + bShowPercent = true; + } bool bShowCateg = !rDataLabel.mbDeleted && rDataLabel.mobShowCatName.get( false ); bool bShowSymbol = !rDataLabel.mbDeleted && rDataLabel.mobShowLegendKey.get( false ); @@ -178,6 +195,27 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat { PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) ); lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false ); + + if( !mrModel.mxLayout->mbAutoLayout ) + { + // bnc#694340 - nasty hack - chart2 cannot individually + // place data labels, let's try to find a useful + // compromise instead + namespace csscd = ::com::sun::star::chart::DataLabelPlacement; + const sal_Int32 aPositionsLookupTable[] = + { + csscd::TOP_LEFT, csscd::TOP, csscd::TOP_RIGHT, + csscd::LEFT, csscd::CENTER, csscd::RIGHT, + csscd::BOTTOM_LEFT, csscd::BOTTOM, csscd::BOTTOM_RIGHT + }; + const double nMax=std::max( + fabs(mrModel.mxLayout->mfX), + fabs(mrModel.mxLayout->mfY)); + const int simplifiedX=lclSgn(mrModel.mxLayout->mfX/nMax); + const int simplifiedY=lclSgn(mrModel.mxLayout->mfY/nMax); + aPropSet.setProperty( PROP_LabelPlacement, + aPositionsLookupTable[ simplifiedX+1 + 3*(simplifiedY+1) ] ); + } } catch( Exception& ) { @@ -206,6 +244,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa // data point label settings for( DataLabelsModel::DataLabelVector::iterator aIt = mrModel.maPointLabels.begin(), aEnd = mrModel.maPointLabels.end(); aIt != aEnd; ++aIt ) { + (*aIt)->maNumberFormat.maFormatCode = mrModel.maNumberFormat.maFormatCode; DataLabelConverter aLabelConv( *this, **aIt ); aLabelConv.convertFromModel( rxDataSeries, rTypeGroup ); } @@ -596,6 +635,12 @@ Reference< XDataSeries > SeriesConverter::createDataSeries( const TypeGroupConve ModelRef< DataLabelsModel > xLabels = mrModel.mxLabels.is() ? mrModel.mxLabels : rTypeGroup.getModel().mxLabels; if( xLabels.is() ) { + if( xLabels->maNumberFormat.maFormatCode.isEmpty() ) + { + // Use number format code from Value series + DataSourceModel* pValues = mrModel.maSources.get( SeriesModel::VALUES ).get(); + xLabels->maNumberFormat.maFormatCode = pValues->mxDataSeq->maFormatCode; + } DataLabelsConverter aLabelsConv( *this, *xLabels ); aLabelsConv.convertFromModel( xDataSeries, rTypeGroup ); } diff --git a/oox/source/xls/formulaparser.cxx b/oox/source/xls/formulaparser.cxx index 2543ef6dc910..fb7b5d37e473 100644 --- a/oox/source/xls/formulaparser.cxx +++ b/oox/source/xls/formulaparser.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/sheet/ComplexReference.hpp> #include <com/sun/star/sheet/ExternalReference.hpp> #include <com/sun/star/sheet/FormulaToken.hpp> +#include <com/sun/star/sheet/NameToken.hpp> #include <com/sun/star/sheet/ReferenceFlags.hpp> #include <com/sun/star/sheet/SingleReference.hpp> #include "oox/core/filterbase.hxx" @@ -2798,7 +2799,10 @@ void FormulaParser::convertNameToFormula( FormulaContext& rContext, sal_Int32 nT { ApiTokenSequence aTokens( 1 ); aTokens[ 0 ].OpCode = OPCODE_NAME; - aTokens[ 0 ].Data <<= nTokenIndex; + NameToken aNameTokenData; + aNameTokenData.Global = sal_True; + aNameTokenData.Index= nTokenIndex; + aTokens[ 0 ].Data <<= aNameTokenData; mxImpl->setFormula( rContext, aTokens ); } else |