diff -r d75b2e77b8eb chart2/source/controller/main/ChartController_Position.cxx --- a/chart2/source/controller/main/ChartController_Position.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/chart2/source/controller/main/ChartController_Position.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -37,6 +37,7 @@ #include "UndoGuard.hxx" #include "Strings.hrc" #include "ObjectNameProvider.hxx" +#include "DiagramHelper.hxx" #include "chartview/ExplicitValueProvider.hxx" #include "CommonConverters.hxx" #include @@ -135,10 +136,12 @@ if( pProvider ) aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) ); + ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, - ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), + ObjectNameProvider::getName( eObjectType)), m_xUndoManager, getModel() ); SfxAbstractTabDialog * pDlg = NULL; @@ -151,7 +154,7 @@ bool bResizePossible = m_aSelection.isResizeableObjectSelected(); ::vos::OGuard aGuard( Application::GetSolarMutex()); - SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create(); + SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create(); DBG_ASSERT( pFact, "No dialog factory" ); pDlg = pFact->CreateSchTransformTabDialog( m_pChartWindow, &aItemSet, pSdrView, RID_SCH_TransformTabDLG_SVXPAGE_ANGLE, bResizePossible ); @@ -169,10 +172,18 @@ awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); - bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() + + bool bChanged = false; + if ( eObjectType == OBJECTTYPE_LEGEND && (aSelectedSize.Width != aObjectRect.getWidth() + || aSelectedSize.Height != aObjectRect.getHeight())) + 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()) ); + bChanged = bMoved || bChanged; if( bChanged ) aUndoGuard.commitAction(); } diff -r d75b2e77b8eb chart2/source/controller/main/ChartController_Window.cxx --- a/chart2/source/controller/main/ChartController_Window.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/chart2/source/controller/main/ChartController_Window.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -868,15 +868,21 @@ if( !bIsMoveOnly && m_aSelection.isResizeableObjectSelected() ) eActionType = ActionDescriptionProvider::RESIZE; + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + UndoGuard aUndoGuard( - ActionDescriptionProvider::createDescription( - eActionType, - ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))), + ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( eObjectType)), m_xUndoManager, getModel() ); - bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() + + bool bChanged = false; + if ( eObjectType == OBJECTTYPE_LEGEND && eActionType == ActionDescriptionProvider::RESIZE ) + 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()) ); + bChanged = bMoved || bChanged; if( bChanged ) { bDraggingDone = true; diff -r d75b2e77b8eb chart2/source/controller/main/PositionAndSizeHelper.cxx --- a/chart2/source/controller/main/PositionAndSizeHelper.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -33,6 +33,7 @@ #include "ChartModelHelper.hxx" #include "ControllerLockGuard.hxx" #include +#include #include #include #include "chartview/ExplicitValueProvider.hxx" @@ -83,51 +84,13 @@ } else if(OBJECTTYPE_LEGEND==eObjectType) { - LegendPosition ePos = LegendPosition_LINE_END; - xObjectProp->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos; + xObjectProp->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny(LegendPosition(LegendPosition_CUSTOM))); + xObjectProp->setPropertyValue( C2U( "Expansion" ), uno::makeAny(LegendExpansion(LegendExpansion_CUSTOM))); chart2::RelativePosition aRelativePosition; + chart2::RelativeSize aRelativeSize; Point aAnchor = aObjectRect.TopLeft(); - switch( ePos ) - { - case LegendPosition_LINE_START: - { - //@todo language dependent positions ... - aRelativePosition.Anchor = drawing::Alignment_LEFT; - aAnchor = aObjectRect.LeftCenter(); - } - break; - case LegendPosition_LINE_END: - { - //@todo language dependent positions ... - aRelativePosition.Anchor = drawing::Alignment_RIGHT; - aAnchor = aObjectRect.RightCenter(); - } - break; - case LegendPosition_PAGE_START: - { - //@todo language dependent positions ... - aRelativePosition.Anchor = drawing::Alignment_TOP; - aAnchor = aObjectRect.TopCenter(); - } - break; - case LegendPosition_PAGE_END: - //@todo language dependent positions ... - { - aRelativePosition.Anchor = drawing::Alignment_BOTTOM; - aAnchor = aObjectRect.BottomCenter(); - } - break; - case LegendPosition_CUSTOM: - { - //@todo language dependent positions ... - aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; - } - break; - case LegendPosition_MAKE_FIXED_SIZE: - OSL_ASSERT( false ); - break; - } + aRelativePosition.Primary = static_cast< double >( aAnchor.X()) / static_cast< double >( aPageRect.getWidth() ); @@ -136,6 +99,19 @@ static_cast< double >( aPageRect.getHeight()); xObjectProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + + aRelativeSize.Primary = + static_cast< double >( aObjectRect.getWidth()) / + static_cast< double >( aPageRect.getWidth() ); + if (aRelativeSize.Primary > 1.0) + aRelativeSize.Primary = 1.0; + aRelativeSize.Secondary = + static_cast< double >( aObjectRect.getHeight()) / + static_cast< double >( aPageRect.getHeight()); + if (aRelativeSize.Secondary > 1.0) + aRelativeSize.Secondary = 1.0; + + xObjectProp->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) ); } else if(OBJECTTYPE_DIAGRAM==eObjectType || OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType) { diff -r d75b2e77b8eb chart2/source/controller/main/SelectionHelper.cxx --- a/chart2/source/controller/main/SelectionHelper.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/chart2/source/controller/main/SelectionHelper.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -309,6 +309,7 @@ case OBJECTTYPE_DIAGRAM: case OBJECTTYPE_DIAGRAM_WALL: case OBJECTTYPE_SHAPE: + case OBJECTTYPE_LEGEND: return true; default: return false; diff -r d75b2e77b8eb chart2/source/model/main/Legend.cxx --- a/chart2/source/model/main/Legend.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/chart2/source/model/main/Legend.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -66,7 +67,8 @@ PROP_LEGEND_PREFERRED_EXPANSION, PROP_LEGEND_SHOW, PROP_LEGEND_REF_PAGE_SIZE, - PROP_LEGEND_REL_POS + PROP_LEGEND_REL_POS, + PROP_LEGEND_REL_SIZE }; void lcl_AddPropertiesToVector( @@ -105,6 +108,15 @@ ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID )); + + + rOutProperties.push_back( + Property( C2U( "RelativeSize" ), + PROP_LEGEND_REL_SIZE, + ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + } void lcl_AddDefaultsToMap( diff -r d75b2e77b8eb chart2/source/view/main/VLegend.cxx --- a/chart2/source/view/main/VLegend.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/chart2/source/view/main/VLegend.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -706,16 +706,32 @@ // for quickly setting properties tPropertyValues aLineFillProperties; tPropertyValues aTextProperties; + + bool bIsCustomSized = false; // limit the width of texts to 30% of the total available width // #i109336# Improve auto positioning in chart sal_Int32 nMaxLabelWidth = rAvailableSpace.Width * 3 / 10; Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY ); LegendExpansion eExpansion = LegendExpansion_HIGH; + awt::Size aCustomSize; + if( xLegendProp.is()) { // get Expansion property xLegendProp->getPropertyValue( C2U( "Expansion" )) >>= eExpansion; + bIsCustomSized = (eExpansion == LegendExpansion_CUSTOM); + RelativeSize aRelativeSize; + if ((xLegendProp->getPropertyValue( C2U( "RelativeSize" )) >>= aRelativeSize)) + { + aCustomSize.Width = aRelativeSize.Primary * rPageSize.Width; + aCustomSize.Height = aRelativeSize.Secondary * rPageSize.Height; + } + else + { + bIsCustomSized =false; + eExpansion = LegendExpansion_HIGH; + } if( eExpansion == LegendExpansion_WIDE ) { //#i80377# @@ -766,7 +782,13 @@ , rAvailableSpace, rPageSize, aLegendSize ); if( xBorder.is()) - xBorder->setSize( aLegendSize ); + if ( bIsCustomSized) + { + xBorder->setSize( aCustomSize ); + } + else + xBorder->setSize( aLegendSize ); + } } catch( uno::Exception & ex ) diff -r d75b2e77b8eb offapi/com/sun/star/chart2/LegendExpansion.idl --- a/offapi/com/sun/star/chart2/LegendExpansion.idl Thu Oct 28 18:59:05 2010 +0200 +++ b/offapi/com/sun/star/chart2/LegendExpansion.idl Sun Nov 07 19:19:06 2010 +0100 @@ -40,25 +40,21 @@ */ enum LegendExpansion { - /** The legend is laid out such that it is wider that high. The - aspect ratio is greater than 1. + /** The legend entries are arranged in a single row if possible. If not enough space is available further rows are added.

This is usually used for legends that are displayed at the top or bottom of the page.

*/ WIDE, - /** The legend is laid out such that it is higher that wide. The - aspect ratio is less than 1. + /** The legend entries are stacked in a single column if possible. If not enough space is available further columns are added.

This is usually used for legends that are displayed on the left or right hand side of the page.

*/ HIGH, - /** The legend is laid out such that height and width are not - differing too much. It is not guaranteed to have an aspect - ratio of 1. + /** The legend entries are arranged in a way that the aspect ratio of the resulting legend is as near to 1 as possible. */ BALANCED, diff -r d75b2e77b8eb xmloff/inc/xmloff/xmltoken.hxx --- a/xmloff/inc/xmloff/xmltoken.hxx Thu Oct 28 18:59:05 2010 +0200 +++ b/xmloff/inc/xmloff/xmltoken.hxx Sun Nov 07 19:19:06 2010 +0100 @@ -3112,6 +3112,11 @@ XML_OUTSIDE_MINIMUM,//#i114142# XML_OUTSIDE_MAXIMUM,//#i114142# + + XML_LEGEND_EXPANSION, //#i28760# + XML_BALANCED, //#i28760# + XML_HIGH, //#i28760# + XML_WIDE, //#i28760# XML_TOKEN_END }; diff -r d75b2e77b8eb xmloff/source/chart/SchXMLExport.cxx --- a/xmloff/source/chart/SchXMLExport.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/xmloff/source/chart/SchXMLExport.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -66,6 +66,7 @@ #include #include +#include #include #include #include @@ -234,8 +235,8 @@ void addPosition( const ::com::sun::star::awt::Point & rPosition ); void addPosition( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape ); /// add svg size as attribute for current element - void addSize( const ::com::sun::star::awt::Size & rSize ); - void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape ); + void addSize( const ::com::sun::star::awt::Size & rSize, bool bIsOOoNamespace = false ); + void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape, bool bIsOOoNamespace = false ); /// fills the member msString with the appropriate String (i.e. "A3") void getCellAddress( sal_Int32 nCol, sal_Int32 nRow ); /// exports a string as a paragraph element @@ -1460,6 +1461,24 @@ Reference< drawing::XShape > xShape( xProp, uno::UNO_QUERY ); if( xShape.is()) addPosition( xShape ); + + // export size + chart2::LegendExpansion aLegendExpansion = chart2::LegendExpansion_HIGH; + try + { + Any aAny( xProp->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Expansion" )))); + bool bHasExpansion = (aAny >>= aLegendExpansion); + //todo + //if (bHasExpansion) + // mrExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION, ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_WARNING( "Property Expansion not found in ChartLegend" ); + } + + } // write style name @@ -3591,21 +3610,22 @@ addPosition( xShape->getPosition()); } -void SchXMLExportHelper_Impl::addSize( const awt::Size & rSize ) +void SchXMLExportHelper_Impl::addSize( const awt::Size & rSize, bool bIsOOoNamespace) { mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Width ); msString = msStringBuffer.makeStringAndClear(); - mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, msString ); - - mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Height ); + mrExport.AddAttribute( bIsOOoNamespace ? XML_NAMESPACE_CHART_EXT : XML_NAMESPACE_SVG , XML_WIDTH, msString ); + + + mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Height); msString = msStringBuffer.makeStringAndClear(); - mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, msString ); + mrExport.AddAttribute( bIsOOoNamespace ? XML_NAMESPACE_CHART_EXT : XML_NAMESPACE_SVG, XML_HEIGHT, msString ); } -void SchXMLExportHelper_Impl::addSize( Reference< drawing::XShape > xShape ) +void SchXMLExportHelper_Impl::addSize( Reference< drawing::XShape > xShape, bool bIsOOoNamespace ) { if( xShape.is()) - addSize( xShape->getSize() ); + addSize( xShape->getSize(), bIsOOoNamespace ); } awt::Size SchXMLExportHelper_Impl::getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ) const diff -r d75b2e77b8eb xmloff/source/core/xmltoken.cxx --- a/xmloff/source/core/xmltoken.cxx Thu Oct 28 18:59:05 2010 +0200 +++ b/xmloff/source/core/xmltoken.cxx Sun Nov 07 19:19:06 2010 +0100 @@ -3112,6 +3112,11 @@ TOKEN( "outside-minimum", XML_OUTSIDE_MINIMUM ), TOKEN( "outside-maximum", XML_OUTSIDE_MAXIMUM ), + + TOKEN( "legend-expansion", XML_LEGEND_EXPANSION), + TOKEN( "balanced", XML_BALANCED), + TOKEN( "high", XML_HIGH), + TOKEN( "wide", XML_WIDE), #if OSL_DEBUG_LEVEL > 0 { 0, NULL, NULL, XML_TOKEN_END }