diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-03-23 16:58:51 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-03-23 16:58:51 +0100 |
commit | e2dcaa374ba0f0e9947ce9a3b90b8aaa7625d4da (patch) | |
tree | c8fd9c041669bae7657dfde810f2f4e29565bdb0 | |
parent | 05ea11a238d608532842ddbc1cbcd81f4d9e8c02 (diff) | |
parent | 2e1e4666b895718793821417d54e903611e5fb56 (diff) |
Merge commit 'ooo/DEV300_m103'
Conflicts:
sc/source/filter/starcalc/scflt.cxx
sc/source/ui/unoobj/chart2uno.cxx
20 files changed, 274 insertions, 261 deletions
diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx index 90109914c..33f5130e7 100644 --- a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx @@ -185,6 +185,40 @@ void CharacterPropertyItemConverter::FillSpecialItem( } break; + case EE_CHAR_OVERLINE: + { + SvxOverlineItem aItem( UNDERLINE_NONE, EE_CHAR_OVERLINE ); + bool bModified = false; + + uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharOverline" ) ) ); + if ( aValue.hasValue() ) + { + aItem.PutValue( aValue, MID_TL_STYLE ); + bModified = true; + } + + aValue = GetPropertySet()->getPropertyValue( C2U( "CharOverlineHasColor" ) ); + if ( aValue.hasValue() && + ( *reinterpret_cast< const sal_Bool* >( aValue.getValue() ) != sal_False ) ) + { + aItem.PutValue( aValue, MID_TL_HASCOLOR ); + bModified = true; + } + + aValue = GetPropertySet()->getPropertyValue( C2U( "CharOverlineColor" ) ); + if ( aValue.hasValue() ) + { + aItem.PutValue( aValue, MID_TL_COLOR ); + bModified = true; + } + + if ( bModified ) + { + rOutItemSet.Put( aItem ); + } + } + break; + case EE_CHAR_ITALIC: case EE_CHAR_ITALIC_CJK: case EE_CHAR_ITALIC_CTL: @@ -389,6 +423,39 @@ bool CharacterPropertyItemConverter::ApplySpecialItem( } break; + case EE_CHAR_OVERLINE: + { + const SvxOverlineItem& rItem = static_cast< const SvxOverlineItem & >( rItemSet.Get( nWhichId ) ); + + if ( rItem.QueryValue( aValue, MID_TL_STYLE ) ) + { + if ( aValue != GetPropertySet()->getPropertyValue( C2U( "CharOverline" ) ) ) + { + GetPropertySet()->setPropertyValue( C2U( "CharOverline" ), aValue ); + bChanged = true; + } + } + + if ( rItem.QueryValue( aValue, MID_TL_COLOR ) ) + { + if ( aValue != GetPropertySet()->getPropertyValue( C2U( "CharOverlineColor" ) ) ) + { + GetPropertySet()->setPropertyValue( C2U( "CharOverlineColor" ), aValue ); + bChanged = true; + } + } + + if ( rItem.QueryValue( aValue, MID_TL_HASCOLOR ) ) + { + if ( aValue != GetPropertySet()->getPropertyValue( C2U( "CharOverlineHasColor" ) ) ) + { + GetPropertySet()->setPropertyValue( C2U( "CharOverlineHasColor" ), aValue ); + bChanged = true; + } + } + } + break; + case EE_CHAR_ITALIC: case EE_CHAR_ITALIC_CJK: case EE_CHAR_ITALIC_CTL: diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index ee478f4a7..10393e3ad 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -63,7 +63,7 @@ using namespace ::com::sun::star::chart2; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, Rectangle& rPosAndSize, const awt::Size aOriginalSize ) +void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt::Rectangle& rPosAndSize, const awt::Size aOriginalSize ) { long nPosX(0); long nPosY(0); @@ -122,7 +122,7 @@ void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, Rectangle& r break; } - rPosAndSize = Rectangle(Point(nPosX,nPosY),Size(nSizX,nSizY)); + rPosAndSize = awt::Rectangle(nPosX,nPosY,nSizX,nSizY); } void SAL_CALL ChartController::executeDispatch_PositionAndSize() @@ -167,19 +167,18 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() const SfxItemSet* pOutItemSet = pDlg->GetOutputItemSet(); if(pOutItemSet) { - Rectangle aObjectRect; + awt::Rectangle aObjectRect; aItemSet.Put(*pOutItemSet);//overwrite old values with new values (-> all items are set) lcl_getPositionAndSizeFromItemSet( aItemSet, aObjectRect, aSelectedSize ); awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); - Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); + awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); bool bChanged = false; if ( eObjectType == OBJECTTYPE_LEGEND ) bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( getModel(), false , true ); bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel() - , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) - , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); + , aObjectRect, aPageRect ); if( bMoved || bChanged ) aUndoGuard.commit(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index bee0060cd..3e6c889f9 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1658,7 +1658,16 @@ bool ChartController::requestQuickHelp( if ( bSuccess ) { + SolarMutexGuard aGuard; + if ( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() ) + { + this->EndTextEdit(); + } this->impl_selectObjectAndNotiy(); + if ( m_pChartWindow ) + { + m_pChartWindow->Invalidate(); + } return sal_True; } diff --git a/chart2/source/inc/CharacterProperties.hxx b/chart2/source/inc/CharacterProperties.hxx index ec291b472..e1aed6a92 100644 --- a/chart2/source/inc/CharacterProperties.hxx +++ b/chart2/source/inc/CharacterProperties.hxx @@ -64,6 +64,9 @@ public: PROP_CHAR_UNDERLINE, PROP_CHAR_UNDERLINE_COLOR, PROP_CHAR_UNDERLINE_HAS_COLOR, + PROP_CHAR_OVERLINE, + PROP_CHAR_OVERLINE_COLOR, + PROP_CHAR_OVERLINE_HAS_COLOR, PROP_CHAR_WEIGHT, PROP_CHAR_POSTURE, PROP_CHAR_AUTO_KERNING, diff --git a/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx b/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx index a06b4c671..d5bbe5020 100644 --- a/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx +++ b/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx @@ -64,9 +64,10 @@ private: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - // formula is: f(x) = m_fSlope ^ x + m_fIntercept - double m_fSlope; - double m_fIntercept; + // formula is: f(x) = exp(m_fLogIntercept) * exp( m_fLogSlope * x ) + // mathematical model f(x) = Intercept * Slope^x + double m_fLogSlope; + double m_fLogIntercept; }; } // namespace chart diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index f80b0258c..710053816 100755..100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -197,6 +197,7 @@ private: ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 ); + ::chart::SceneProperties::AddDefaultsToMap( rOutMap ); } }; diff --git a/chart2/source/tools/CharacterProperties.cxx b/chart2/source/tools/CharacterProperties.cxx index eba89b688..c42c13612 100755..100644 --- a/chart2/source/tools/CharacterProperties.cxx +++ b/chart2/source/tools/CharacterProperties.cxx @@ -149,6 +149,28 @@ void CharacterProperties::AddPropertiesToVector( ::getBooleanCppuType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT )); + // CharOverline (see awt.FontUnderline) + rOutProperties.push_back( + Property( C2U( "CharOverline" ), + PROP_CHAR_OVERLINE, + ::getCppuType( reinterpret_cast< const sal_Int16* >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); + // CharOverlineColor + rOutProperties.push_back( + Property( C2U( "CharOverlineColor" ), + PROP_CHAR_OVERLINE_COLOR, + ::getCppuType( reinterpret_cast< const sal_Int32* >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT + | beans::PropertyAttribute::MAYBEVOID ) ); + // CharOverlineHasColor + rOutProperties.push_back( + Property( C2U( "CharOverlineHasColor" ), + PROP_CHAR_OVERLINE_HAS_COLOR, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ) ); // CharWeight (see awt.FontWeight) rOutProperties.push_back( Property( C2U( "CharWeight" ), @@ -416,6 +438,9 @@ void CharacterProperties::AddDefaultsToMap( ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE, awt::FontUnderline::NONE ); ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_UNDERLINE_COLOR, -1 ); //automatic color (COL_AUTO) ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE_HAS_COLOR, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE, awt::FontUnderline::NONE ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_OVERLINE_COLOR, -1 ); //automatic color (COL_AUTO) + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE_HAS_COLOR, false ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WEIGHT, awt::FontWeight::NORMAL ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_POSTURE, awt::FontSlant_NONE ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_AUTO_KERNING, true ); diff --git a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx index 55da03afd..c64518936 100644 --- a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx @@ -44,11 +44,11 @@ namespace chart { ExponentialRegressionCurveCalculator::ExponentialRegressionCurveCalculator() : - m_fSlope( 0.0 ), - m_fIntercept( 0.0 ) + m_fLogSlope( 0.0 ), + m_fLogIntercept( 0.0 ) { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); + ::rtl::math::setNan( & m_fLogSlope ); + ::rtl::math::setNan( & m_fLogIntercept ); } ExponentialRegressionCurveCalculator::~ExponentialRegressionCurveCalculator() @@ -68,9 +68,9 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression( const size_t nMax = aValues.first.size(); if( nMax == 0 ) { - ::rtl::math::setNan( & m_fSlope ); - ::rtl::math::setNan( & m_fIntercept ); - ::rtl::math::setNan( & m_fCorrelationCoeffitient ); + ::rtl::math::setNan( & m_fLogSlope ); + ::rtl::math::setNan( & m_fLogIntercept ); + ::rtl::math::setNan( & m_fCorrelationCoeffitient );// actual it is coefficient of determination return; } @@ -97,12 +97,10 @@ void SAL_CALL ExponentialRegressionCurveCalculator::recalculateRegression( fQxy += fDeltaX * fDeltaY; } - m_fSlope = fQxy / fQx; - m_fIntercept = fAverageY - m_fSlope * fAverageX; + m_fLogSlope = fQxy / fQx; + m_fLogIntercept = fAverageY - m_fLogSlope * fAverageX; m_fCorrelationCoeffitient = fQxy / sqrt( fQx * fQy ); - m_fSlope = exp( m_fSlope ); - m_fIntercept = exp( m_fIntercept ); } double SAL_CALL ExponentialRegressionCurveCalculator::getCurveValue( double x ) @@ -112,10 +110,10 @@ double SAL_CALL ExponentialRegressionCurveCalculator::getCurveValue( double x ) double fResult; ::rtl::math::setNan( & fResult ); - if( ! ( ::rtl::math::isNan( m_fSlope ) || - ::rtl::math::isNan( m_fIntercept ))) + if( ! ( ::rtl::math::isNan( m_fLogSlope ) || + ::rtl::math::isNan( m_fLogIntercept ))) { - fResult = m_fIntercept * pow( m_fSlope, x ); + fResult = exp(m_fLogIntercept + x * m_fLogSlope); } return fResult; @@ -151,31 +149,48 @@ OUString ExponentialRegressionCurveCalculator::ImplGetRepresentation( const uno::Reference< util::XNumberFormatter >& xNumFormatter, ::sal_Int32 nNumberFormatKey ) const { + double fIntercept = exp(m_fLogIntercept); + double fSlope = exp(m_fLogSlope); + bool bHasSlope = !rtl::math::approxEqual( fSlope, 1.0 ); + bool bHasIntercept = !rtl::math::approxEqual( fIntercept, 1.0 ); + OUStringBuffer aBuf( C2U( "f(x) = " )); - if( m_fIntercept == 0.0 || - m_fSlope == 0.0 ) - { - aBuf.append( sal_Unicode( '0' )); - } - else if( rtl::math::approxEqual( m_fSlope, 1.0 ) ) + if ( fIntercept == 0.0) { - aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fIntercept )); + // underflow, a true zero is impossible + aBuf.append( C2U( "exp( " )); + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fLogIntercept) ); + aBuf.append( (m_fLogSlope < 0.0) ? C2U( " - " ) : C2U( " + " )); + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, fabs(m_fLogSlope)) ); + aBuf.append( C2U( " x )" )); } else { - if( ! rtl::math::approxEqual( m_fIntercept, 1.0 ) ) + if (bHasIntercept) { - aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fIntercept )); - aBuf.append( sal_Unicode( 0x00b7 )); + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, fIntercept) ); + aBuf.append( C2U( " exp( " )); + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fLogSlope) ); + aBuf.append( C2U( " x )" )); + } + else + { + // show logarithmic output, if intercept and slope both are near one + // otherwise drop output of intercept, which is 1 here + aBuf.append( C2U( " exp( " )); + if (!bHasSlope) + { + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fLogIntercept) ); + aBuf.append( (m_fLogSlope < 0.0) ? C2U( " - " ) : C2U( " + " )); + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, fabs(m_fLogSlope)) ); + } + else + { + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fLogSlope) ); + } + aBuf.append( C2U( " x )" )); } - - if( m_fSlope < 0.0 ) - aBuf.append( sal_Unicode( '(' )); - aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fSlope )); - if( m_fSlope < 0.0 ) - aBuf.append( sal_Unicode( ')' )); - aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "^x" )); } return aBuf.makeStringAndClear(); diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index da35c7195..cb9be009a 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -50,9 +50,16 @@ using ::com::sun::star::chart::TimeUnit::MONTH; using ::com::sun::star::chart::TimeUnit::YEAR; const sal_Int32 MAXIMUM_MANUAL_INCREMENT_COUNT = 500; -const sal_Int32 MAXIMUM_AUTO_INCREMENT_COUNT = 10; const sal_Int32 MAXIMUM_SUB_INCREMENT_COUNT = 100; +sal_Int32 lcl_getMaximumAutoIncrementCount( sal_Int32 nAxisType ) +{ + sal_Int32 nMaximumAutoIncrementCount = 10; + if( nAxisType==AxisType::DATE ) + nMaximumAutoIncrementCount = MAXIMUM_MANUAL_INCREMENT_COUNT; + return nMaximumAutoIncrementCount; +} + namespace { @@ -103,7 +110,7 @@ ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale, const Date& rNu : m_aSourceScale( rSourceScale ) , m_fValueMinimum( 0.0 ) , m_fValueMaximum( 0.0 ) - , m_nMaximumAutoMainIncrementCount( MAXIMUM_AUTO_INCREMENT_COUNT ) + , m_nMaximumAutoMainIncrementCount( lcl_getMaximumAutoIncrementCount( rSourceScale.AxisType ) ) , m_bExpandBorderToIncrementRhythm( false ) , m_bExpandIfValuesCloseToBorder( false ) , m_bExpandWideValuesToZero( false ) @@ -150,8 +157,8 @@ void ScaleAutomatism::setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMa { if( nMaximumAutoMainIncrementCount < 2 ) m_nMaximumAutoMainIncrementCount = 2; //#i82006 - else if( nMaximumAutoMainIncrementCount > MAXIMUM_AUTO_INCREMENT_COUNT ) - m_nMaximumAutoMainIncrementCount = MAXIMUM_AUTO_INCREMENT_COUNT; + else if( nMaximumAutoMainIncrementCount > lcl_getMaximumAutoIncrementCount( m_aSourceScale.AxisType ) ) + m_nMaximumAutoMainIncrementCount = lcl_getMaximumAutoIncrementCount( m_aSourceScale.AxisType ); else m_nMaximumAutoMainIncrementCount = nMaximumAutoMainIncrementCount; } @@ -693,6 +700,19 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( nNumer = static_cast<sal_Int32>( rtl::math::approxCeil( nIntervalDays/nDaysPerInterval ) ); if(nNumer<=0) nNumer=1; + if( rExplicitIncrement.MajorTimeInterval.TimeUnit == DAY ) + { + if( nNumer>2 && nNumer<7 ) + nNumer=7; + else if( nNumer>7 ) + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = MONTH; + nDaysPerInterval = 31.0; + nNumer = static_cast<sal_Int32>( rtl::math::approxCeil( nIntervalDays/nDaysPerInterval ) ); + if(nNumer<=0) + nNumer=1; + } + } rExplicitIncrement.MajorTimeInterval.Number = nNumer; nMainIncrementCount = nDayCount/(nNumer*nDaysPerInterval); } diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index c0dba5a2b..91dba8939 100755 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1139,9 +1139,19 @@ void VSeriesPlotter::createRegressionCurveEquationShapes( if( xTextShape.is()) { ShapeFactory::setShapeName( xTextShape, rEquationCID ); - xTextShape->setPosition( - RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( - aScreenPosition2D, xTextShape->getSize(), aRelativePosition.Anchor )); + awt::Size aSize( xTextShape->getSize() ); + awt::Point aPos( RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( + aScreenPosition2D, aSize, aRelativePosition.Anchor ) ); + //ensure that the equation is fully placed within the page (if possible) + if( (aPos.X + aSize.Width) > m_aPageReferenceSize.Width ) + aPos.X = m_aPageReferenceSize.Width - aSize.Width; + if( aPos.X < 0 ) + aPos.X = 0; + if( (aPos.Y + aSize.Height) > m_aPageReferenceSize.Height ) + aPos.Y = m_aPageReferenceSize.Height - aSize.Height; + if( aPos.Y < 0 ) + aPos.Y = 0; + xTextShape->setPosition(aPos); } } } diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 4667d5da6..91f4a8839 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2164,12 +2164,9 @@ std::auto_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType } uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, xChartModel ) ); - if(xTitle.is()) + rtl::OUString aCompleteString( TitleHelper::getCompleteString( xTitle ) ); + if( aCompleteString.getLength() != 0 ) { - rtl::OUString aCompleteString( TitleHelper::getCompleteString( xTitle ) ); - if ( aCompleteString.getLength() == 0 ) - return apVTitle;//don't create empty titles as the resulting diagram position is wrong then - //create title apVTitle = std::auto_ptr<VTitle>(new VTitle(xTitle)); rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ) ); diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx index 57b50be97..d85382f77 100644 --- a/chart2/source/view/main/PropertyMapper.cxx +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -214,6 +214,9 @@ const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForCharacterProper ( C2U( "CharUnderline" ), C2U("CharUnderline") ) ( C2U( "CharUnderlineColor" ), C2U("CharUnderlineColor") ) ( C2U( "CharUnderlineHasColor" ), C2U("CharUnderlineHasColor") ) + ( C2U( "CharOverline" ), C2U("CharOverline") ) + ( C2U( "CharOverlineColor" ), C2U("CharOverlineColor") ) + ( C2U( "CharOverlineHasColor" ), C2U("CharOverlineHasColor") ) ( C2U( "CharWeight" ), C2U("CharWeight") ) ( C2U( "CharWeightAsian" ), C2U("CharWeightAsian") ) ( C2U( "CharWeightComplex" ), C2U("CharWeightComplex") ) diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 028a643fc..1ad43dff8 100644..100755 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -898,8 +898,8 @@ void VLegend::createShapes( RelativeSize aRelativeSize; if ((xLegendProp->getPropertyValue( C2U( "RelativeSize" )) >>= aRelativeSize)) { - aLegendSize.Width = aRelativeSize.Primary * rPageSize.Width; - aLegendSize.Height = aRelativeSize.Secondary * rPageSize.Height; + aLegendSize.Width = ::rtl::math::approxCeil( aRelativeSize.Primary * rPageSize.Width ); + aLegendSize.Height = ::rtl::math::approxCeil( aRelativeSize.Secondary * rPageSize.Height ); } else eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx index 0d0885f34..2756a62b3 100644 --- a/sc/inc/chart2uno.hxx +++ b/sc/inc/chart2uno.hxx @@ -236,70 +236,6 @@ private: }; -// LabeledDataSequence ======================================================= - -class ScChart2LabeledDataSequence : public - ::cppu::WeakImplHelper4< - ::com::sun::star::chart2::data::XLabeledDataSequence, - ::com::sun::star::util::XCloneable, - ::com::sun::star::util::XModifyBroadcaster, - ::com::sun::star::lang::XServiceInfo >, - SfxListener -{ -public: - - explicit ScChart2LabeledDataSequence( ScDocument* pDoc ); - virtual ~ScChart2LabeledDataSequence(); - - // SfxListener ----------------------------------------------------------- - - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - - // XLabeledDataSequence -------------------------------------------------- - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL getValues() - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setValues( - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSequence ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL getLabel() - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setLabel( - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSequence ) - throw (::com::sun::star::uno::RuntimeException); - - // XCloneable ------------------------------------------------------------ - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone() - throw (::com::sun::star::uno::RuntimeException); - - // XModifyBroadcaster ---------------------------------------------------- - - virtual void SAL_CALL addModifyListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) - throw (::com::sun::star::uno::RuntimeException); - - // XServiceInfo ---------------------------------------------------------- - - virtual ::rtl::OUString SAL_CALL getImplementationName() throw( - ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& - rServiceName) throw( ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL - getSupportedServiceNames() throw( - ::com::sun::star::uno::RuntimeException); - -private: - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XDataSequence > m_aData; - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XDataSequence > m_aLabel; - ScDocument* m_pDocument; -}; - // DataSequence ============================================================== class ScChart2DataSequence : public diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index 86dadb090..808022b0b 100644..100755 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -649,7 +649,7 @@ void ScDocument::UpdateFontCharSet() pItem = (SvxFontItem*)pPool->GetItem2(ATTR_FONT, i); if ( pItem && ( pItem->GetCharSet() == eSrcSet || ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) - pItem->GetCharSet() = eSysSet; + pItem->SetCharSet(eSysSet); } if ( pDrawLayer ) @@ -661,7 +661,7 @@ void ScDocument::UpdateFontCharSet() pItem = (SvxFontItem*)rDrawPool.GetItem2(EE_CHAR_FONTINFO, i); if ( pItem && ( pItem->GetCharSet() == eSrcSet || ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) - pItem->GetCharSet() = eSysSet; + pItem->SetCharSet( eSysSet ); } } } diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx index ceffabce4..6831a6f7c 100644..100755 --- a/sc/source/core/tool/autoform.cxx +++ b/sc/source/core/tool/autoform.cxx @@ -385,7 +385,7 @@ sal_Bool ScAutoFormatDataField::Load( SvStream& rStream, const ScAfVersions& rVe CharSet eSysSet = gsl_getSystemTextEncoding(); CharSet eSrcSet = rStream.GetStreamCharSet(); if( eSrcSet != eSysSet && aFont.GetCharSet() == eSrcSet ) - aFont.GetCharSet() = eSysSet; + aFont.SetCharSet(eSysSet); aStacked.SetValue( aOrientation.IsStacked() ); aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) ); diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx index 21d37e910..9f75c5dd3 100644 --- a/sc/source/core/tool/charthelper.cxx +++ b/sc/source/core/tool/charthelper.cxx @@ -299,6 +299,7 @@ void ScChartHelper::AddRangesIfProtectedChart( ScRangeListVector& rRangesVector, if ( xEmbeddedObj.is() ) { bool bDisableDataTableDialog = false; + sal_Int32 nOldState = xEmbeddedObj->getCurrentState(); svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj ); uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY ); if ( xProps.is() && @@ -323,6 +324,10 @@ void ScChartHelper::AddRangesIfProtectedChart( ScRangeListVector& rRangesVector, } } } + if ( xEmbeddedObj->getCurrentState() != nOldState ) + { + xEmbeddedObj->changeState( nOldState ); + } } } } diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index 4f76ae852..d1f18e24b 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -395,7 +395,10 @@ Sc10FontData::Sc10FontData(SvStream& rStream) rStream >> PitchAndFamily; sal_uInt16 nLen; rStream >> nLen; - rStream.Read(FaceName, nLen); + if (nLen < sizeof(FaceName)) + rStream.Read(FaceName, nLen); + else + rStream.SetError(ERRCODE_IO_WRONGFORMAT); } @@ -431,10 +434,14 @@ Sc10NameData::Sc10NameData(SvStream& rStream) sal_uInt8 nLen; rStream >> nLen; rStream.Read(Name, sizeof(Name) - 1); + if (nLen >= sizeof(Name)) + nLen = sizeof(Name) - 1; Name[nLen] = 0; rStream >> nLen; rStream.Read(Reference, sizeof(Reference) - 1); + if (nLen >= sizeof(Reference)) + nLen = sizeof(Reference) - 1; Reference[nLen] = 0; rStream.Read(Reserved, sizeof(Reserved)); } @@ -1414,6 +1421,8 @@ void Sc10Import::LoadTables() sal_uInt8 nLen; rStream >> nLen; rStream.Read(TabName, sizeof(TabName) - 1); + if (nLen >= sizeof(TabName)) + nLen = sizeof(TabName) - 1; TabName[nLen] = 0; //---------------------------------------------------------- @@ -1634,7 +1643,7 @@ void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab) { /*double Value =*/ ScfTools::ReadLongDouble(rStream); sal_uInt8 Len; - sal_Char s[256]; + sal_Char s[256+1]; rStream >> Len; rStream.Read(&s[1], Len); s[0] = '='; diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx index 53208cd37..405b30752 100644 --- a/sc/source/ui/drawfunc/fusel.cxx +++ b/sc/source/ui/drawfunc/fusel.cxx @@ -57,6 +57,7 @@ #include "drwlayer.hxx" #include "userdat.hxx" #include "scmod.hxx" +#include "client.hxx" #include "charthelper.hxx" #include "docuno.hxx" #include "docsh.hxx" diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 969b9dc7f..32fc54a9e 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/text/XText.hpp> #include <comphelper/extract.hxx> +#include <comphelper/processfactory.hxx> #include <vector> #include <list> @@ -63,8 +64,6 @@ SC_SIMPLE_SERVICE_INFO( ScChart2DataProvider, "ScChart2DataProvider", "com.sun.star.chart2.data.DataProvider") SC_SIMPLE_SERVICE_INFO( ScChart2DataSource, "ScChart2DataSource", "com.sun.star.chart2.data.DataSource") -SC_SIMPLE_SERVICE_INFO( ScChart2LabeledDataSequence, "ScChart2LabeledDataSequence", - "com.sun.star.chart2.data.LabeledDataSequence") SC_SIMPLE_SERVICE_INFO( ScChart2DataSequence, "ScChart2DataSequence", "com.sun.star.chart2.data.DataSequence") #if USE_CHART2_EMPTYDATASEQUENCE @@ -1051,27 +1050,40 @@ void ScChart2DataProvider::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint namespace { -ScChart2LabeledDataSequence* lcl_createScChart2DataSequenceFromTokens( auto_ptr< vector<ScTokenRef> > pValueTokens, auto_ptr< vector<ScTokenRef> > pLabelTokens, - ScDocument* pDoc, const uno::Reference < chart2::data::XDataProvider >& xDP, bool bIncludeHiddenCells ) +Reference< chart2::data::XLabeledDataSequence > lcl_createLabeledDataSequenceFromTokens( + auto_ptr< vector< ScTokenRef > > pValueTokens, auto_ptr< vector< ScTokenRef > > pLabelTokens, + ScDocument* pDoc, const Reference< chart2::data::XDataProvider >& xDP, bool bIncludeHiddenCells ) { - ScChart2LabeledDataSequence* pRet = 0; + Reference< chart2::data::XLabeledDataSequence > xResult; bool bHasValues = pValueTokens.get() && !pValueTokens->empty(); bool bHasLabel = pLabelTokens.get() && !pLabelTokens->empty(); if( bHasValues || bHasLabel ) { - pRet = new ScChart2LabeledDataSequence(pDoc); - if(bHasValues) + try { - uno::Reference < chart2::data::XDataSequence > xSeq(new ScChart2DataSequence(pDoc, xDP, pValueTokens.release(), bIncludeHiddenCells)); - pRet->setValues(xSeq); + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + if ( xContext.is() ) + { + xResult.set( xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString::createFromAscii( "com.sun.star.chart2.data.LabeledDataSequence" ), + xContext ), uno::UNO_QUERY_THROW ); + } + if ( bHasValues ) + { + Reference< chart2::data::XDataSequence > xSeq( new ScChart2DataSequence( pDoc, xDP, pValueTokens.release(), bIncludeHiddenCells ) ); + xResult->setValues( xSeq ); + } + if ( bHasLabel ) + { + Reference< chart2::data::XDataSequence > xLabelSeq( new ScChart2DataSequence( pDoc, xDP, pLabelTokens.release(), bIncludeHiddenCells ) ); + xResult->setLabel( xLabelSeq ); + } } - if(bHasLabel) + catch( const uno::Exception& ) { - uno::Reference < chart2::data::XDataSequence > xLabelSeq(new ScChart2DataSequence(pDoc, xDP, pLabelTokens.release(), bIncludeHiddenCells)); - pRet->setLabel(xLabelSeq); } } - return pRet; + return xResult; } //---------------------------------------------------- @@ -1427,7 +1439,7 @@ ScChart2DataProvider::createDataSource( return xResult; ScChart2DataSource* pDS = NULL; - std::list < ScChart2LabeledDataSequence* > aSeqs; + ::std::list< Reference< chart2::data::XLabeledDataSequence > > aSeqs; // Fill Categories if( bCategories ) @@ -1441,9 +1453,12 @@ ScChart2DataProvider::createDataSource( auto_ptr< vector<ScTokenRef> > pLabelTokens(NULL); pLabelTokens.reset(pChartMap->getLeftUpperCornerRanges()); - ScChart2LabeledDataSequence* pCategories = lcl_createScChart2DataSequenceFromTokens( pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells );//ownership of pointers is transfered! - if( pCategories ) - aSeqs.push_back(pCategories); + Reference< chart2::data::XLabeledDataSequence > xCategories = lcl_createLabeledDataSequenceFromTokens( + pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells ); //ownership of pointers is transfered! + if ( xCategories.is() ) + { + aSeqs.push_back( xCategories ); + } } // Fill Serieses (values and label) @@ -1462,42 +1477,47 @@ ScChart2DataProvider::createDataSource( pValueTokens.reset(pChartMap->getDataRowRanges(static_cast<SCROW>(i))); pLabelTokens.reset(pChartMap->getRowHeaderRanges(static_cast<SCROW>(i))); } - ScChart2LabeledDataSequence* pChartSeries = lcl_createScChart2DataSequenceFromTokens( pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells ); //ownership of pointers is transfered! - if( pChartSeries ) - aSeqs.push_back(pChartSeries); + Reference< chart2::data::XLabeledDataSequence > xChartSeries = lcl_createLabeledDataSequenceFromTokens( + pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells ); //ownership of pointers is transfered! + if ( xChartSeries.is() ) + { + aSeqs.push_back( xChartSeries ); + } } pDS = new ScChart2DataSource(m_pDocument); - std::list < ScChart2LabeledDataSequence* >::iterator aItr(aSeqs.begin()); - std::list < ScChart2LabeledDataSequence* >::iterator aEndItr(aSeqs.end()); + ::std::list< Reference< chart2::data::XLabeledDataSequence > >::iterator aItr( aSeqs.begin() ); + ::std::list< Reference< chart2::data::XLabeledDataSequence > >::iterator aEndItr( aSeqs.end() ); //reorder labeled sequences according to aSequenceMapping - std::vector< ScChart2LabeledDataSequence* > aSeqVector; + ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aSeqVector; while(aItr != aEndItr) { aSeqVector.push_back(*aItr); ++aItr; } - std::map< sal_Int32, ScChart2LabeledDataSequence* > aSequenceMap; + ::std::map< sal_Int32, Reference< chart2::data::XLabeledDataSequence > > aSequenceMap; for( sal_Int32 nNewIndex = 0; nNewIndex < aSequenceMapping.getLength(); nNewIndex++ ) { // note: assuming that the values in the sequence mapping are always non-negative - std::vector< ScChart2LabeledDataSequence* >::size_type nOldIndex( static_cast< sal_uInt32 >( aSequenceMapping[nNewIndex] )); + ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::size_type nOldIndex( static_cast< sal_uInt32 >( aSequenceMapping[nNewIndex] ) ); if( nOldIndex < aSeqVector.size() ) { pDS->AddLabeledSequence( aSeqVector[nOldIndex] ); aSeqVector[nOldIndex] = 0; } - } - std::vector< ScChart2LabeledDataSequence* >::iterator aVectorItr(aSeqVector.begin()); - std::vector< ScChart2LabeledDataSequence* >::iterator aVectorEndItr(aSeqVector.end()); + ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::iterator aVectorItr( aSeqVector.begin() ); + ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::iterator aVectorEndItr( aSeqVector.end() ); while(aVectorItr != aVectorEndItr) { - if(*aVectorItr) - pDS->AddLabeledSequence(*aVectorItr); + Reference< chart2::data::XLabeledDataSequence > xSeq( *aVectorItr ); + if ( xSeq.is() ) + { + pDS->AddLabeledSequence( xSeq ); + } ++aVectorItr; } @@ -2200,114 +2220,6 @@ void ScChart2DataSource::AddLabeledSequence(const uno::Reference < chart2::data: m_aLabeledSequences.push_back(xNew); } -// LabeledDataSequence ======================================================= - -ScChart2LabeledDataSequence::ScChart2LabeledDataSequence( - ScDocument* pDoc ) : - m_pDocument( pDoc ) -{ - if ( m_pDocument ) - m_pDocument->AddUnoObject( *this); -} - -ScChart2LabeledDataSequence::~ScChart2LabeledDataSequence() -{ - if ( m_pDocument ) - m_pDocument->RemoveUnoObject( *this); -} - -// SfxListener ----------------------------------------------------------- - -void ScChart2LabeledDataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint) -{ - if ( rHint.ISA( SfxSimpleHint ) && - ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) - { - SolarMutexGuard aGuard; - m_pDocument = NULL; - } -} - -// XLabeledDataSequence -------------------------------------------------- - -uno::Reference< chart2::data::XDataSequence > SAL_CALL ScChart2LabeledDataSequence::getValues() - throw (uno::RuntimeException) -{ - SolarMutexGuard aGuard; - return m_aData; -} - -void SAL_CALL ScChart2LabeledDataSequence::setValues( - const uno::Reference< chart2::data::XDataSequence >& xSequence ) - throw (uno::RuntimeException) -{ - SolarMutexGuard aGuard; - m_aData = xSequence; -} - -uno::Reference< chart2::data::XDataSequence > SAL_CALL ScChart2LabeledDataSequence::getLabel() - throw (uno::RuntimeException) -{ - SolarMutexGuard aGuard; - return m_aLabel; -} - -void SAL_CALL ScChart2LabeledDataSequence::setLabel( - const uno::Reference< chart2::data::XDataSequence >& xSequence ) - throw (uno::RuntimeException) -{ - SolarMutexGuard aGuard; - m_aLabel = xSequence; -} - -// XCloneable ================================================================ - -uno::Reference< util::XCloneable > SAL_CALL ScChart2LabeledDataSequence::createClone() - throw (uno::RuntimeException) -{ - SolarMutexGuard aGuard; - uno::Reference< util::XCloneable > xToClone(m_aData, uno::UNO_QUERY); - if (xToClone.is()) - { - ScChart2LabeledDataSequence* pRet = new ScChart2LabeledDataSequence(m_pDocument); - uno::Reference< chart2::data::XDataSequence > xSequence(xToClone->createClone(), uno::UNO_QUERY); - pRet->setValues(xSequence); - xToClone.set(m_aLabel, uno::UNO_QUERY); - if(xToClone.is()) - { - xSequence.set(xToClone->createClone(), uno::UNO_QUERY); - pRet->setLabel(xSequence); - } - return pRet; - } - return NULL; -} - -// XModifyBroadcaster ======================================================== - -void SAL_CALL ScChart2LabeledDataSequence::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - // quick'n dirty: just add the listener to each DataSequence - - uno::Reference<util::XModifyBroadcaster> xDataBroadcaster( m_aData, uno::UNO_QUERY ); - if ( xDataBroadcaster.is() ) - xDataBroadcaster->addModifyListener( aListener ); - uno::Reference<util::XModifyBroadcaster> xLabelBroadcaster( m_aLabel, uno::UNO_QUERY ); - if ( xLabelBroadcaster.is() ) - xLabelBroadcaster->addModifyListener( aListener ); -} - -void SAL_CALL ScChart2LabeledDataSequence::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - uno::Reference<util::XModifyBroadcaster> xDataBroadcaster( m_aData, uno::UNO_QUERY ); - if ( xDataBroadcaster.is() ) - xDataBroadcaster->removeModifyListener( aListener ); - uno::Reference<util::XModifyBroadcaster> xLabelBroadcaster( m_aLabel, uno::UNO_QUERY ); - if ( xLabelBroadcaster.is() ) - xLabelBroadcaster->removeModifyListener( aListener ); -} // DataSequence ============================================================== |