summaryrefslogtreecommitdiff
path: root/chart2/source/view/main/ChartView.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/view/main/ChartView.cxx')
-rw-r--r--chart2/source/view/main/ChartView.cxx321
1 files changed, 221 insertions, 100 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 9f5908185..84cc24795 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -169,6 +169,7 @@ ChartView::ChartView(
, m_nScaleYNumerator(1)
, m_nScaleYDenominator(1)
, m_bSdrViewIsInEditMode(sal_False)
+ , m_aResultingDiagramRectangleExcludingAxes(0,0,0,0)
{
}
@@ -313,7 +314,7 @@ uno::Any SAL_CALL ChartView::getTransferData( const datatransfer::DataFlavor& aF
if( ! (bHighContrastMetaFile || aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMEType)) )
return aRet;
- impl_updateView();
+ update();
SvMemoryStream aStream( 1024, 1024 );
utl::OStreamWrapper* pStreamWrapper = new utl::OStreamWrapper( aStream );
@@ -681,7 +682,8 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
if(nT==0)
m_bChartTypeUsesShiftedXAxisTicksPerDefault = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType );
- VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount );
+ bool bExcludingPositioning = DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram );
+ VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning );
if( !pPlotter )
continue;
m_aSeriesPlotterList.push_back( pPlotter );
@@ -1166,7 +1168,7 @@ drawing::Direction3D SeriesPlotterContainer::getPreferredAspectRatio()
namespace
{
-bool lcl_resizeAfterCompleteCreation( const uno::Reference< XDiagram >& xDiagram )
+bool lcl_IsPieOrDonut( const uno::Reference< XDiagram >& xDiagram )
{
//special treatment for pie charts
//the size is checked after complete creation to get the datalabels into the given space
@@ -1324,16 +1326,23 @@ sal_Int16 lcl_getDefaultWritingModeFromPool( ::boost::shared_ptr< DrawModelWrapp
} //end anonymous namespace
//------------ create complete diagram shape (inclusive axis and series)
-void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer
+
+awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer
, const uno::Reference< drawing::XShapes>& xDiagramPlusAxes_Shapes
, const awt::Point& rAvailablePos
, const awt::Size& rAvailableSize
- , const awt::Size& rPageSize )
+ , const awt::Size& rPageSize
+ , bool bUseFixedInnerSize
+ , const uno::Reference< drawing::XShape>& xDiagram_MarkHandles /*needs to be resized to fit the result*/
+ )
{
+ //return the used rectangle
+ awt::Rectangle aUsedOuterRect( rAvailablePos.X, rAvailablePos.Y, 0, 0 );
+
// sal_Int32 nDiagramIndex = 0;//todo if more than one diagam is supported
uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
if( !xDiagram.is())
- return;
+ return aUsedOuterRect;
sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
if(!nDimensionCount)
@@ -1389,7 +1398,8 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo
aVDiagram.init(xDiagramPlusAxes_Shapes,xDiagramPlusAxes_Shapes,m_xShapeFactory);
aVDiagram.createShapes(rAvailablePos,rAvailableSize);
xSeriesTargetInFrontOfAxis = aVDiagram.getCoordinateRegion();
- aVDiagram.reduceToMimimumSize();
+ if( !bUseFixedInnerSize )
+ aVDiagram.reduceToMimimumSize();
}
uno::Reference< drawing::XShapes > xTextTargetShapes( ShapeFactory(m_xShapeFactory).createGroup2D(xDiagramPlusAxes_Shapes) );
@@ -1409,20 +1419,22 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo
}
//calculate resulting size respecting axis label layout and fontscaling
+
+ uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY );
+ ::basegfx::B2IRectangle aConsumedOuterRect;
//use first coosys only so far; todo: calculate for more than one coosys if we have more in future
//todo: this is just a workaround at the moment for pie and donut labels
- if( !lcl_resizeAfterCompleteCreation(xDiagram) && rVCooSysList.size() > 0 )
+ bool bIsPieOrDonut = lcl_IsPieOrDonut(xDiagram);
+ if( !bIsPieOrDonut && rVCooSysList.size() > 0 )
{
- uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY );
-
- ::basegfx::B2IRectangle aFirstConsumedOuterRect( ShapeFactory::getRectangleOfShape(xBoundingShape) );
-
VCoordinateSystem* pVCooSys = rVCooSysList[0];
pVCooSys->createMaximumAxesLabels();
- ::basegfx::B2IRectangle aConsumedOuterRect( ShapeFactory::getRectangleOfShape(xBoundingShape) );
- ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.adjustInnerSize( aConsumedOuterRect ) );
+ aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) );
+ ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() );
+ if( !bUseFixedInnerSize )
+ aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect );
pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
createTransformationSceneToScreen( aNewInnerRect ) ));
@@ -1445,13 +1457,13 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo
bLessSpaceConsumedThanExpected = true;
}
- if( bLessSpaceConsumedThanExpected )
+ if( bLessSpaceConsumedThanExpected && !bUseFixedInnerSize )
{
aVDiagram.adjustInnerSize( aConsumedOuterRect );
pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
createTransformationSceneToScreen( aVDiagram.getCurrentRectangle() ) ));
- pVCooSys->updatePositions();
}
+ pVCooSys->updatePositions();//todo: logically this belongs to the condition above, but it seems also to be neccessary to give the axes group shapes the right bounding rects for hit test - probably caused by bug i106183 -> check again if fixed
}
//create axes and grids for the final size
@@ -1481,7 +1493,7 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo
else
{
xSeriesTarget = xSeriesTargetBehindAxis;
- DBG_ASSERT( !lcl_resizeAfterCompleteCreation(xDiagram), "not implemented yet! - during a complete recreation this shape is destroyed so no series can be created anymore" );
+ DBG_ASSERT( !bIsPieOrDonut, "not implemented yet! - during a complete recreation this shape is destroyed so no series can be created anymore" );
}
pSeriesPlotter->initPlotter( xSeriesTarget,xTextTargetShapes,m_xShapeFactory,aCID );
pSeriesPlotter->setPageReferenceSize( rPageSize );
@@ -1500,16 +1512,16 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo
m_bPointsWereSkipped = m_bPointsWereSkipped || pSeriesPlotter->PointsWereSkipped();
}
- //recreate with corrected sizes if requested
- if( lcl_resizeAfterCompleteCreation(xDiagram) )
+ //recreate all with corrected sizes if requested
+ if( bIsPieOrDonut )
{
m_bPointsWereSkipped = false;
- uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY );
- ::basegfx::B2IRectangle aConsumedOuterRect( ShapeFactory::getRectangleOfShape(xBoundingShape) );
-
- ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.adjustInnerSize( aConsumedOuterRect ) );
-
+ aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) );
+ ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() );
+ if( !bUseFixedInnerSize )
+ aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect );
+
for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; aPlotterIter++ )
{
VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
@@ -1565,6 +1577,63 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo
pSeriesPlotter->rearrangeLabelToAvoidOverlapIfRequested( rPageSize );
}
}
+
+ if( bUseFixedInnerSize )
+ {
+ //if( !bIsPieOrDonut )
+ // aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) );
+ aUsedOuterRect = awt::Rectangle( aConsumedOuterRect.getMinX(), aConsumedOuterRect.getMinY(), aConsumedOuterRect.getWidth(), aConsumedOuterRect.getHeight() );
+ }
+ else
+ aUsedOuterRect = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height );
+
+ bool bSnapRectToUsedArea = false;
+ for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; aPlotterIter++ )
+ {
+ VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
+ bSnapRectToUsedArea = pSeriesPlotter->shouldSnapRectToUsedArea();
+ if(bSnapRectToUsedArea)
+ break;
+ }
+ if(bSnapRectToUsedArea)
+ {
+ if( bUseFixedInnerSize )
+ m_aResultingDiagramRectangleExcludingAxes = getRectangleOfObject( C2U("PlotAreaExcludingAxes") );
+ else
+ {
+ ::basegfx::B2IRectangle aConsumedInnerRect = aVDiagram.getCurrentRectangle();
+ m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(), aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() );
+ }
+ }
+ else
+ {
+ if( bUseFixedInnerSize )
+ m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height );
+ else
+ {
+ ::basegfx::B2IRectangle aConsumedInnerRect = aVDiagram.getCurrentRectangle();
+ m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(), aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() );
+ }
+ }
+
+ if( xDiagram_MarkHandles.is() )
+ {
+ awt::Point aPos(rAvailablePos);
+ awt::Size aSize(rAvailableSize);
+ bool bPosSizeExcludeAxesProperty = true;
+ uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY_THROW );
+ if( xDiaProps.is() )
+ xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bPosSizeExcludeAxesProperty;
+ if( bUseFixedInnerSize || bPosSizeExcludeAxesProperty )
+ {
+ aPos = awt::Point( m_aResultingDiagramRectangleExcludingAxes.X, m_aResultingDiagramRectangleExcludingAxes.Y );
+ aSize = awt::Size( m_aResultingDiagramRectangleExcludingAxes.Width, m_aResultingDiagramRectangleExcludingAxes.Height );
+ }
+ xDiagram_MarkHandles->setPosition( aPos );
+ xDiagram_MarkHandles->setSize( aSize );
+ }
+
+ return aUsedOuterRect;
}
//-------------------------------------------------------------
@@ -1622,6 +1691,12 @@ uno::Reference< drawing::XShape > ChartView::getShapeForCID( const rtl::OUString
return 0;
}
+awt::Rectangle ChartView::getDiagramRectangleExcludingAxes()
+{
+ impl_updateView();
+ return m_aResultingDiagramRectangleExcludingAxes;
+}
+
awt::Rectangle ChartView::getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect )
{
impl_updateView();
@@ -1645,7 +1720,10 @@ awt::Rectangle ChartView::getRectangleOfObject( const rtl::OUString& rObjectCID,
SdrObjList* pRootList = pRootSdrObject->GetSubList();
if( pRootList )
{
- SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( C2U("MarkHandles"), pRootList );
+ OUString aShapeName = C2U("MarkHandles");
+ if( eObjectType == OBJECTTYPE_DIAGRAM )
+ aShapeName = C2U("PlotAreaIncludingAxes");
+ SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( aShapeName, pRootList );
if( pShape )
xShape = uno::Reference< drawing::XShape >( pShape->getUnoShape(), uno::UNO_QUERY);
}
@@ -1933,12 +2011,12 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe
}
//static
-awt::Rectangle ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle(
+awt::Rectangle ExplicitValueProvider::addAxisTitleSizes(
const Reference< frame::XModel >& xChartModel
, const Reference< uno::XInterface >& xChartView
- , const awt::Rectangle& rExclusivePositionAndSize )
+ , const awt::Rectangle& rExcludingPositionAndSize )
{
- awt::Rectangle aRet(rExclusivePositionAndSize);
+ awt::Rectangle aRet(rExcludingPositionAndSize);
//add axis title sizes to the diagram size
uno::Reference< chart2::XTitle > xTitle_Height( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xChartModel ) );
@@ -2000,6 +2078,74 @@ awt::Rectangle ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTi
return aRet;
}
+//static
+awt::Rectangle ExplicitValueProvider::substractAxisTitleSizes(
+ const Reference< frame::XModel >& xChartModel
+ , const Reference< uno::XInterface >& xChartView
+ , const awt::Rectangle& rPositionAndSizeIncludingTitles )
+{
+ awt::Rectangle aRet(rPositionAndSizeIncludingTitles);
+
+ //add axis title sizes to the diagram size
+ uno::Reference< chart2::XTitle > xTitle_Height( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xChartModel ) );
+ uno::Reference< chart2::XTitle > xTitle_Width( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xChartModel ) );
+ uno::Reference< chart2::XTitle > xSecondTitle_Height( TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xChartModel ) );
+ uno::Reference< chart2::XTitle > xSecondTitle_Width( TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xChartModel ) );
+ if( xTitle_Height.is() || xTitle_Width.is() || xSecondTitle_Height.is() || xSecondTitle_Width.is() )
+ {
+ ExplicitValueProvider* pExplicitValueProvider = ExplicitValueProvider::getExplicitValueProvider(xChartView);
+ if( pExplicitValueProvider )
+ {
+ //detect wether x axis points into x direction or not
+ if( lcl_getPropertySwapXAndYAxis( ChartModelHelper::findDiagram( xChartModel ) ) )
+ {
+ std::swap( xTitle_Height, xTitle_Width );
+ std::swap( xSecondTitle_Height, xSecondTitle_Width );
+ }
+
+ sal_Int32 nTitleSpaceWidth = 0;
+ sal_Int32 nTitleSpaceHeight = 0;
+ sal_Int32 nSecondTitleSpaceWidth = 0;
+ sal_Int32 nSecondTitleSpaceHeight = 0;
+
+ if( xTitle_Height.is() )
+ {
+ rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Height, xChartModel ) );
+ nTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height;
+ if( nTitleSpaceHeight )
+ nTitleSpaceHeight+=lcl_getDiagramTitleSpace();
+ }
+ if( xTitle_Width.is() )
+ {
+ rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Width, xChartModel ) );
+ nTitleSpaceWidth = pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width;
+ if(nTitleSpaceWidth)
+ nTitleSpaceWidth+=lcl_getDiagramTitleSpace();
+ }
+ if( xSecondTitle_Height.is() )
+ {
+ rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Height, xChartModel ) );
+ nSecondTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height;
+ if( nSecondTitleSpaceHeight )
+ nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace();
+ }
+ if( xSecondTitle_Width.is() )
+ {
+ rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Width, xChartModel ) );
+ nSecondTitleSpaceWidth += pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width;
+ if( nSecondTitleSpaceWidth )
+ nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace();
+ }
+
+ aRet.X += nTitleSpaceWidth;
+ aRet.Y += nSecondTitleSpaceHeight;
+ aRet.Width -= (nTitleSpaceWidth + nSecondTitleSpaceWidth);
+ aRet.Height -= (nTitleSpaceHeight + nSecondTitleSpaceHeight);
+ }
+ }
+ return aRet;
+}
+
double lcl_getPageLayoutDistancePercentage()
{
return 0.02;
@@ -2010,9 +2156,10 @@ bool getAvailablePosAndSizeForDiagram(
, const awt::Rectangle& rSpaceLeft
, const awt::Size & rPageSize
, const uno::Reference< XDiagram > & xDiagram
- , VTitle* pXTitle, VTitle* pYTitle
- , VTitle* pSecondXTitle, VTitle* pSecondYTitle )
+ , bool& bUseFixedInnerSize )
{
+ bUseFixedInnerSize = false;
+
//@todo: we need a size dependent on the axis labels
awt::Rectangle aRemainingSpace(rSpaceLeft);
{
@@ -2028,7 +2175,9 @@ bool getAvailablePosAndSizeForDiagram(
uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY);
- bool bMakeRoomForTitle = false;
+ bool bPosSizeExcludeAxes = false;
+ if( xProp.is() )
+ xProp->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes;
//size:
::com::sun::star::chart2::RelativeSize aRelativeSize;
@@ -2036,7 +2185,7 @@ bool getAvailablePosAndSizeForDiagram(
{
rOutAvailableDiagramSize.Height = static_cast<sal_Int32>(aRelativeSize.Secondary*rPageSize.Height);
rOutAvailableDiagramSize.Width = static_cast<sal_Int32>(aRelativeSize.Primary*rPageSize.Width);
- bMakeRoomForTitle = true;
+ bUseFixedInnerSize = bPosSizeExcludeAxes;
}
else
rOutAvailableDiagramSize = awt::Size(aRemainingSpace.Width,aRemainingSpace.Height);
@@ -2054,7 +2203,7 @@ bool getAvailablePosAndSizeForDiagram(
rOutPos = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject(
awt::Point(static_cast<sal_Int32>(fX),static_cast<sal_Int32>(fY))
, rOutAvailableDiagramSize, aRelativePosition.Anchor );
- bMakeRoomForTitle = true;
+ bUseFixedInnerSize = bPosSizeExcludeAxes;
}
else
rOutPos = awt::Point(aRemainingSpace.X,aRemainingSpace.Y);
@@ -2067,52 +2216,6 @@ bool getAvailablePosAndSizeForDiagram(
rOutAvailableDiagramSize.Width = rPageSize.Width - rOutPos.X;
}
- if( bMakeRoomForTitle )
- {
- sal_Int32 nTitleSpaceWidth = 0;
- sal_Int32 nTitleSpaceHeight = 0;
- sal_Int32 nSecondTitleSpaceWidth = 0;
- sal_Int32 nSecondTitleSpaceHeight = 0;
- {
- //todo detect wether x axis points into x direction or not
- //detect wether x axis points into x direction or not
- if( lcl_getPropertySwapXAndYAxis( xDiagram ) )
- {
- std::swap( pXTitle, pYTitle );
- std::swap( pSecondXTitle, pSecondYTitle );
- }
-
- if( pXTitle )
- {
- nTitleSpaceHeight = pXTitle->getFinalSize().Height;
- if(nTitleSpaceHeight)
- nTitleSpaceHeight+=lcl_getDiagramTitleSpace();
- }
- if( pYTitle )
- {
- nTitleSpaceWidth = pYTitle->getFinalSize().Width;
- if(nTitleSpaceWidth)
- nTitleSpaceWidth+=lcl_getDiagramTitleSpace();
- }
- if( pSecondXTitle)
- {
- nSecondTitleSpaceHeight += pSecondXTitle->getFinalSize().Height;
- if(nSecondTitleSpaceHeight)
- nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace();
- }
- if( pSecondYTitle)
- {
- nSecondTitleSpaceWidth += pSecondYTitle->getFinalSize().Width;
- if(nSecondTitleSpaceWidth)
- nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace();
- }
- }
- rOutAvailableDiagramSize.Height -= nTitleSpaceHeight + nSecondTitleSpaceHeight;
- rOutAvailableDiagramSize.Width -= nTitleSpaceWidth + nSecondTitleSpaceWidth;
- rOutPos.X += nTitleSpaceWidth;
- rOutPos.Y += nSecondTitleSpaceHeight;
- }
-
return true;
}
@@ -2154,6 +2257,19 @@ void changePositionOfAxisTitle( VTitle* pVTitle, TitleAlignment eAlignment
break;
}
+ sal_Int32 nMaxY = rPageSize.Height - aTitleSize.Height/2;
+ sal_Int32 nMaxX = rPageSize.Width - aTitleSize.Width/2;
+ sal_Int32 nMinX = aTitleSize.Width/2;
+ sal_Int32 nMinY = aTitleSize.Height/2;
+ if( aNewPosition.Y > nMaxY )
+ aNewPosition.Y = nMaxY;
+ if( aNewPosition.X > nMaxX )
+ aNewPosition.X = nMaxX;
+ if( aNewPosition.Y < nMinY )
+ aNewPosition.Y = nMinY;
+ if( aNewPosition.X < nMinX )
+ aNewPosition.X = nMinX;
+
pVTitle->changePosition( aNewPosition );
}
@@ -2478,6 +2594,7 @@ void ChartView::createShapes()
if( impl_AddInDrawsAllByItself() )
return;
+ m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle(0,0,0,0);
impl_deleteCoordinateSystems();
if( m_pDrawModelWrapper )
{
@@ -2519,9 +2636,15 @@ void ChartView::createShapes()
uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
rtl::OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ) );//todo: other index if more than one diagram is possible
uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( ShapeFactory(m_xShapeFactory).createGroup2D(xPageShapes,aDiagramCID) );
- uno::Reference< drawing::XShape > xDiagramPlusAxes_MarkHandles( ShapeFactory(m_xShapeFactory).createInvisibleRectangle(
+
+ uno::Reference< drawing::XShape > xDiagram_MarkHandles( ShapeFactory(m_xShapeFactory).createInvisibleRectangle(
xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) );
- ShapeFactory::setShapeName( xDiagramPlusAxes_MarkHandles, C2U("MarkHandles") );
+ ShapeFactory::setShapeName( xDiagram_MarkHandles, C2U("MarkHandles") );
+
+ uno::Reference< drawing::XShape > xDiagram_OuterRect( ShapeFactory(m_xShapeFactory).createInvisibleRectangle(
+ xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) );
+ ShapeFactory::setShapeName( xDiagram_OuterRect, C2U("PlotAreaIncludingAxes") );
+
uno::Reference< drawing::XShapes > xDiagramPlusAxes_Shapes( ShapeFactory(m_xShapeFactory).createGroup2D(xDiagramPlusAxesPlusMarkHandlesGroup_Shapes ) );
//------------ create some titles
@@ -2606,21 +2729,22 @@ void ChartView::createShapes()
//------------ create complete diagram shape (inclusive axis and series)
awt::Point aAvailablePosDia;
awt::Size aAvailableSizeForDiagram;
- if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize, ChartModelHelper::findDiagram( m_xChartModel )
- , apVTitle_X.get(), apVTitle_Y.get(), apVTitle_SecondX.get(), apVTitle_SecondY.get() ) )
+ bool bUseFixedInnerSize = false;
+ if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize
+ , ChartModelHelper::findDiagram( m_xChartModel ), bUseFixedInnerSize ) )
{
- impl_createDiagramAndContent( aSeriesPlotterContainer
+ awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer
, xDiagramPlusAxes_Shapes
- , aAvailablePosDia ,aAvailableSizeForDiagram, aPageSize );
+ , aAvailablePosDia ,aAvailableSizeForDiagram, aPageSize, bUseFixedInnerSize, xDiagram_MarkHandles );
- if(xDiagramPlusAxes_MarkHandles.is())
+ if( xDiagram_OuterRect.is() )
{
- xDiagramPlusAxes_MarkHandles->setPosition( aAvailablePosDia );
- xDiagramPlusAxes_MarkHandles->setSize( aAvailableSizeForDiagram );
+ xDiagram_OuterRect->setPosition( awt::Point( aUsedOuterRect.X, aUsedOuterRect.Y ) );
+ xDiagram_OuterRect->setSize( awt::Size( aUsedOuterRect.Width, aUsedOuterRect.Height ) );
}
//correct axis title position
- awt::Rectangle aDiagramPlusAxesRect(aAvailablePosDia.X,aAvailablePosDia.Y,aAvailableSizeForDiagram.Width,aAvailableSizeForDiagram.Height);
+ awt::Rectangle aDiagramPlusAxesRect( aUsedOuterRect );
if(bAutoPosition_XTitle)
changePositionOfAxisTitle( apVTitle_X.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, aPageSize );
if(bAutoPosition_YTitle)
@@ -2691,17 +2815,6 @@ void ChartView::impl_updateView()
//create chart view
{
- /*
- ::vos::OGuard aGuard( Application::GetSolarMutex());
- while( m_bViewDirty )
- {
- createShapes();
- m_bViewDirty = m_bViewUpdatePending;
- m_bViewUpdatePending = false;
- m_bInViewUpdate = false;
- }
- */
-
m_bViewDirty = false;
m_bViewUpdatePending = false;
createShapes();
@@ -2871,6 +2984,14 @@ void SAL_CALL ChartView::removeModeChangeApproveListener( const uno::Reference<
void SAL_CALL ChartView::update() throw (uno::RuntimeException)
{
impl_updateView();
+
+ //#i100778# migrate all imported or old documents to a plot area sizing exclusive axes (in case the save settings allow for this):
+ //Although in general it is a bad idea to change the model from within the view this is exceptionally the best place to do this special conversion.
+ //When a view update is requested (what happens for creating the metafile or displaying
+ //the chart in edit mode or printing) it is most likely that all necessary informations are available - like the underlying spreadsheet data for example.
+ //Those data is important for the correct axis lable sizes which are needed during conversion.
+ if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_xChartModel, true, false ) )
+ impl_updateView();
}
// ____ XPropertySet ____